D3D11: Fixed SRV for compute texture cube map.
This commit is contained in:
parent
8177da57f7
commit
06127b0aa7
@ -15,7 +15,7 @@
|
||||
#define SHARED shared
|
||||
|
||||
#define __IMAGE_XX(_name, _format, _reg, _image, _access) \
|
||||
layout(_format, binding=_reg) _access uniform highp _image _name
|
||||
layout(_format, binding=_reg) _access uniform highp _image _name
|
||||
|
||||
#define readwrite
|
||||
#define IMAGE2D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, readonly)
|
||||
@ -39,11 +39,11 @@
|
||||
#define IMAGE3D_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readwrite)
|
||||
#define UIMAGE3D_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readwrite)
|
||||
|
||||
#define __BUFFER_XX(_name, _type, _reg, _access) \
|
||||
layout(std430, binding=_reg) _access buffer _name ## Buffer \
|
||||
{ \
|
||||
_type _name[]; \
|
||||
}
|
||||
#define __BUFFER_XX(_name, _type, _reg, _access) \
|
||||
layout(std430, binding=_reg) _access buffer _name ## Buffer \
|
||||
{ \
|
||||
_type _name[]; \
|
||||
}
|
||||
|
||||
#define BUFFER_RO(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readonly)
|
||||
#define BUFFER_RW(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readwrite)
|
||||
@ -82,15 +82,15 @@
|
||||
#define UIMAGE2D_WR(_name, _format, _reg) IMAGE2D_RW(_name, _format, _reg)
|
||||
#define UIMAGE2D_RW(_name, _format, _reg) IMAGE2D_RW(_name, _format, _reg)
|
||||
|
||||
#define IMAGE2D_ARRAY_RO( _name, _format, _reg) \
|
||||
#define IMAGE2D_ARRAY_RO(_name, _format, _reg) \
|
||||
Texture2DArray<_format> _name ## Texture : REGISTER(t, _reg); \
|
||||
static BgfxROImageArray2D_ ## _format _name = { _name ## Texture }
|
||||
static BgfxROImage2DArray_ ## _format _name = { _name ## Texture }
|
||||
|
||||
#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) IMAGE2D_ARRAY_RO(_name, _format, _reg)
|
||||
|
||||
#define IMAGE2D_ARRAY_RW( _name, _format, _reg) \
|
||||
#define IMAGE2D_ARRAY_RW(_name, _format, _reg) \
|
||||
RWTexture2DArray<_format> _name ## Texture : REGISTER(u, _reg); \
|
||||
static BgfxRWImageArray2D_ ## _format _name = { _name ## Texture }
|
||||
static BgfxRWImage2DArray_ ## _format _name = { _name ## Texture }
|
||||
|
||||
#define UIMAGE2D_ARRAY_RW(_name, _format, _reg) IMAGE2D_ARRAY_RW(_name, _format, _reg)
|
||||
#define IMAGE2D_ARRAY_WR( _name, _format, _reg) IMAGE2D_ARRAY_RW(_name, _format, _reg)
|
||||
@ -116,37 +116,37 @@
|
||||
|
||||
#define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)]
|
||||
|
||||
#define __IMAGE_IMPL_S(_format, _storeComponents, _type, _loadComponents) \
|
||||
#define __IMAGE_IMPL_S(_format, _storeComponents, _type, _loadComponents) \
|
||||
\
|
||||
struct BgfxROImage2D_ ## _format \
|
||||
{ \
|
||||
Texture2D<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxROImage2D_ ## _format \
|
||||
{ \
|
||||
Texture2D<_format> m_texture; \
|
||||
}; \
|
||||
\
|
||||
struct BgfxRWImage2D_ ## _format \
|
||||
{ \
|
||||
RWTexture2D<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxRWImage2D_ ## _format \
|
||||
{ \
|
||||
RWTexture2D<_format> m_texture; \
|
||||
}; \
|
||||
\
|
||||
struct BgfxROImage2DArray_ ## _format \
|
||||
{ \
|
||||
Texture2DArray<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxROImage2DArray_ ## _format \
|
||||
{ \
|
||||
Texture2DArray<_format> m_texture; \
|
||||
}; \
|
||||
\
|
||||
struct BgfxRWImageArray2D_ ## _format \
|
||||
{ \
|
||||
RWTexture2DArray<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxRWImage2DArray_ ## _format \
|
||||
{ \
|
||||
RWTexture2DArray<_format> m_texture; \
|
||||
}; \
|
||||
\
|
||||
struct BgfxROImage3D_ ## _format \
|
||||
{ \
|
||||
Texture3D<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxROImage3D_ ## _format \
|
||||
{ \
|
||||
Texture3D<_format> m_texture; \
|
||||
}; \
|
||||
\
|
||||
struct BgfxRWImage3D_ ## _format \
|
||||
{ \
|
||||
RWTexture3D<_format> m_texture; \
|
||||
}; \
|
||||
struct BgfxRWImage3D_ ## _format \
|
||||
{ \
|
||||
RWTexture3D<_format> m_texture; \
|
||||
}; \
|
||||
|
||||
#define __IMAGE_IMPL_A(_format, _storeComponents, _type, _loadComponents) \
|
||||
__IMAGE_IMPL_S(_format, _storeComponents, _type, _loadComponents) \
|
||||
@ -192,17 +192,17 @@
|
||||
return ivec3(result); \
|
||||
} \
|
||||
\
|
||||
_type imageLoad(BgfxRWImageArray2D_ ## _format _image, ivec3 _uvw) \
|
||||
_type imageLoad(BgfxRWImage2DArray_ ## _format _image, ivec3 _uvw) \
|
||||
{ \
|
||||
return _image.m_texture[_uvw]._loadComponents; \
|
||||
} \
|
||||
\
|
||||
void imageStore(BgfxRWImageArray2D_ ## _format _image, ivec3 _uvw, _type _value) \
|
||||
void imageStore(BgfxRWImage2DArray_ ## _format _image, ivec3 _uvw, _type _value) \
|
||||
{ \
|
||||
_image.m_texture[_uvw] = _value._storeComponents; \
|
||||
} \
|
||||
\
|
||||
ivec3 imageSize(BgfxRWImageArray2D_ ## _format _image) \
|
||||
ivec3 imageSize(BgfxRWImage2DArray_ ## _format _image) \
|
||||
{ \
|
||||
uvec3 result; \
|
||||
_image.m_texture.GetDimensions(result.x, result.y, result.z); \
|
||||
|
@ -3212,7 +3212,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
murmur.begin();
|
||||
murmur.add(_handle);
|
||||
murmur.add(_mip);
|
||||
murmur.add(0);
|
||||
murmur.add(1);
|
||||
uint32_t hash = murmur.end();
|
||||
|
||||
IUnknown** ptr = m_srvUavLru.find(hash);
|
||||
@ -3257,13 +3257,14 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
return uav;
|
||||
}
|
||||
|
||||
ID3D11ShaderResourceView* getCachedSrv(TextureHandle _handle, uint8_t _mip)
|
||||
ID3D11ShaderResourceView* getCachedSrv(TextureHandle _handle, uint8_t _mip, bool _compute = false)
|
||||
{
|
||||
bx::HashMurmur2A murmur;
|
||||
murmur.begin();
|
||||
murmur.add(_handle);
|
||||
murmur.add(_mip);
|
||||
murmur.add(0);
|
||||
murmur.add(_compute);
|
||||
uint32_t hash = murmur.end();
|
||||
|
||||
IUnknown** ptr = m_srvUavLru.find(hash);
|
||||
@ -3289,9 +3290,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
break;
|
||||
|
||||
case TextureD3D11::TextureCube:
|
||||
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||
desc.TextureCube.MostDetailedMip = _mip;
|
||||
desc.TextureCube.MipLevels = 1;
|
||||
if (_compute)
|
||||
{
|
||||
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
|
||||
desc.Texture2DArray.MostDetailedMip = _mip;
|
||||
desc.Texture2DArray.MipLevels = 1;
|
||||
desc.Texture2DArray.FirstArraySlice = 0;
|
||||
desc.Texture2DArray.ArraySize = 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||
desc.TextureCube.MostDetailedMip = _mip;
|
||||
desc.TextureCube.MipLevels = 1;
|
||||
}
|
||||
break;
|
||||
|
||||
case TextureD3D11::Texture3D:
|
||||
@ -5843,10 +5855,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
|
||||
}
|
||||
else
|
||||
{
|
||||
srv[ii] = 0 == bind.m_un.m_compute.m_mip
|
||||
? texture.m_srv
|
||||
: s_renderD3D11->getCachedSrv(texture.getHandle(), bind.m_un.m_compute.m_mip)
|
||||
;
|
||||
srv[ii] = s_renderD3D11->getCachedSrv(texture.getHandle(), bind.m_un.m_compute.m_mip, true);
|
||||
sampler[ii] = s_renderD3D11->getSamplerState(texture.m_flags, NULL);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user