summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3DBase
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-03-05 03:17:32 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-03-05 03:17:32 +0000
commitc72191a465edd01905181aa47cc57e47fcc29b9e (patch)
tree1a51acaf618fe32a23f3b3b0d020e15293b64a77 /Graphics/GraphicsEngineD3DBase
parentMinor interface improvement (diff)
downloadDiligentCore-c72191a465edd01905181aa47cc57e47fcc29b9e.tar.gz
DiligentCore-c72191a465edd01905181aa47cc57e47fcc29b9e.zip
Completed D3D12 back-end refactor to comply with the new API
Diffstat (limited to 'Graphics/GraphicsEngineD3DBase')
-rw-r--r--Graphics/GraphicsEngineD3DBase/include/ShaderResources.h66
1 files changed, 41 insertions, 25 deletions
diff --git a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h
index 7bfd2cfd..f8f6917b 100644
--- a/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h
+++ b/Graphics/GraphicsEngineD3DBase/include/ShaderResources.h
@@ -126,7 +126,7 @@ public:
VERIFY(_SamplerId < (1 << SamplerOrTexSRVIdBits), "SamplerOrTexSRVId is out of representable range");
if (_InputType == D3D_SIT_TEXTURE && _SRVDimension != D3D_SRV_DIMENSION_BUFFER)
- VERIFY_EXPR(GetSamplerId() == _SamplerId);
+ VERIFY_EXPR(GetCombinedSamplerId() == _SamplerId);
else
VERIFY(_SamplerId == InvalidSamplerId, "Only texture SRV can be assigned a valid texture sampler");
#endif
@@ -174,33 +174,14 @@ public:
return static_cast<D3D_SRV_DIMENSION>(SRVDimension);
}
- Uint32 GetSamplerId()const
+ bool IsCombinedWithSampler()const
{
- VERIFY(GetInputType() == D3D_SIT_TEXTURE && GetSRVDimension() != D3D_SRV_DIMENSION_BUFFER, "Invalid input type: D3D_SIT_TEXTURE is expected" );
- return SamplerOrTexSRVId;
- }
-
- void SetTexSRVId(Uint32 TexSRVId)
- {
- VERIFY(GetInputType() == D3D_SIT_SAMPLER, "Invalid input type: D3D_SIT_SAMPLER is expected" );
- VERIFY(TexSRVId < (1 << SamplerOrTexSRVIdBits), "TexSRVId (", TexSRVId, ") is out of representable range");
- SamplerOrTexSRVId = TexSRVId;
- }
-
- Uint32 GetTexSRVId()const
- {
- VERIFY(GetInputType() == D3D_SIT_SAMPLER, "Invalid input type: D3D_SIT_SAMPLER is expected" );
- return SamplerOrTexSRVId;
- }
-
- bool ValidSamplerAssigned()const
- {
- return GetSamplerId() != InvalidSamplerId;
+ return GetCombinedSamplerId() != InvalidSamplerId;
}
- bool ValidTexSRVAssigned()const
+ bool IsCombinedWithTexSRV()const
{
- return GetTexSRVId() != InvalidTexSRVId;
+ return GetCombinedTexSRVId() != InvalidTexSRVId;
}
bool IsValidBindPoint()const
@@ -230,6 +211,29 @@ public:
{
return ComputeHash(BindPoint, BindCount, InputType, SRVDimension, SamplerOrTexSRVId);
}
+
+
+private:
+ friend class ShaderResources;
+
+ Uint32 GetCombinedSamplerId()const
+ {
+ VERIFY(GetInputType() == D3D_SIT_TEXTURE && GetSRVDimension() != D3D_SRV_DIMENSION_BUFFER, "Invalid input type: D3D_SIT_TEXTURE is expected" );
+ return SamplerOrTexSRVId;
+ }
+
+ void SetTexSRVId(Uint32 TexSRVId)
+ {
+ VERIFY(GetInputType() == D3D_SIT_SAMPLER, "Invalid input type: D3D_SIT_SAMPLER is expected" );
+ VERIFY(TexSRVId < (1 << SamplerOrTexSRVIdBits), "TexSRVId (", TexSRVId, ") is out of representable range");
+ SamplerOrTexSRVId = TexSRVId;
+ }
+
+ Uint32 GetCombinedTexSRVId()const
+ {
+ VERIFY(GetInputType() == D3D_SIT_SAMPLER, "Invalid input type: D3D_SIT_SAMPLER is expected" );
+ return SamplerOrTexSRVId;
+ }
};
static_assert(sizeof(D3DShaderResourceAttribs) == sizeof(void*) + sizeof(Uint32)*2, "Unexpected sizeof(D3DShaderResourceAttribs)");
@@ -265,6 +269,18 @@ public:
const D3DShaderResourceAttribs& GetBufUAV (Uint32 n)const noexcept { return GetResAttribs(n, GetNumBufUAV(), m_BufUAVOffset); }
const D3DShaderResourceAttribs& GetSampler(Uint32 n)const noexcept { return GetResAttribs(n, GetNumSamplers(), m_SamplersOffset); }
+ const D3DShaderResourceAttribs& GetCombinedSampler(const D3DShaderResourceAttribs& TexSRV)const noexcept
+ {
+ VERIFY(TexSRV.IsCombinedWithSampler(), "This texture SRV is not combined with any sampler");
+ return GetSampler(TexSRV.GetCombinedSamplerId());
+ }
+
+ const D3DShaderResourceAttribs& GetCombinedTextureSRV(const D3DShaderResourceAttribs& Sampler)const noexcept
+ {
+ VERIFY(Sampler.IsCombinedWithTexSRV(), "This sampler is not combined with any texture SRV");
+ return GetTexSRV(Sampler.GetCombinedTexSRVId());
+ }
+
SHADER_TYPE GetShaderType()const noexcept{return m_ShaderType;}
ShaderResourceDesc GetShaderResourceDesc(Uint32 Index)const;
@@ -486,7 +502,7 @@ void ShaderResources::Initialize(ID3DBlob* pShaderByteCode,
for (Uint32 n=0; n < GetNumSamplers(); ++n)
{
const auto& Sampler = GetSampler(n);
- if (!Sampler.ValidTexSRVAssigned())
+ if (!Sampler.IsCombinedWithTexSRV())
LOG_ERROR_MESSAGE("Shader '", ShaderName, "' uses combined texture samplers, but sampler '", Sampler.Name, "' is not assigned to any texture");
}
#endif