summaryrefslogtreecommitdiffstats
path: root/Graphics/GraphicsEngineD3D12
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2018-10-17 16:26:27 +0000
committerEgor Yusov <egor.yusov@gmail.com>2018-10-17 16:26:27 +0000
commit435f70be7aebd9a669d6a276df67e8eb814a45e3 (patch)
tree040377c1ac3201fef75c01e9e3535a172babbcb1 /Graphics/GraphicsEngineD3D12
parentImproved StrCmpSuff() to allow optional suffix (diff)
downloadDiligentCore-435f70be7aebd9a669d6a276df67e8eb814a45e3.tar.gz
DiligentCore-435f70be7aebd9a669d6a276df67e8eb814a45e3.zip
Implemented separate samplers in D3D11
Diffstat (limited to 'Graphics/GraphicsEngineD3D12')
-rw-r--r--Graphics/GraphicsEngineD3D12/src/RootSignature.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp2
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp14
-rw-r--r--Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp67
4 files changed, 28 insertions, 57 deletions
diff --git a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
index c172ea95..565fc958 100644
--- a/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/RootSignature.cpp
@@ -262,7 +262,7 @@ void RootSignature::InitStaticSampler(SHADER_TYPE ShaderType, const String& Text
for (auto& StSmplr : m_StaticSamplers)
{
if (StSmplr.ShaderVisibility == ShaderVisibility &&
- TextureName.compare(StSmplr.SamplerDesc.TextureName) == 0)
+ TextureName.compare(StSmplr.SamplerDesc.SamplerOrTextureName) == 0)
{
StSmplr.ShaderRegister = SamplerAttribs.BindPoint;
StSmplr.ArraySize = SamplerAttribs.BindCount;
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
index 0c98369c..9169230b 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp
@@ -45,7 +45,7 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters,
// Load shader resources
auto& Allocator = GetRawAllocator();
auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", sizeof(ShaderResourcesD3D12));
- auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc, ShaderCreationAttribs.CombinedSamplerSuffix);
+ auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc, ShaderCreationAttribs.UseCombinedTextureSamplers ? ShaderCreationAttribs.CombinedSamplerSuffix : nullptr);
m_pShaderResources.reset(pResources, STDDeleterRawMem<ShaderResourcesD3D12>(Allocator));
// Clone only static resources that will be set directly in the shader
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
index 9c48cb76..708d971b 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourceLayoutD3D12.cpp
@@ -137,12 +137,17 @@ void ShaderResourceLayoutD3D12::Initialize(ID3D12Device*
VERIFY_EXPR(CB.IsAllowedType(AllowedTypeBits));
++CbvSrvUavCount[CB.GetVariableType()];
},
+ [&](const D3DShaderResourceAttribs& Sam, Uint32)
+ {
+ VERIFY_EXPR(Sam.IsAllowedType(AllowedTypeBits));
+
+ },
[&](const D3DShaderResourceAttribs& TexSRV, Uint32)
{
VERIFY_EXPR(TexSRV.IsAllowedType(AllowedTypeBits));
auto VarType = TexSRV.GetVariableType();
++CbvSrvUavCount[VarType];
- if(TexSRV.IsValidSampler())
+ if(TexSRV.ValidSamplerAssigned())
{
auto SamplerId = TexSRV.GetSamplerId();
const auto& SamplerAttribs = m_pResources->GetSampler(SamplerId);
@@ -220,13 +225,18 @@ void ShaderResourceLayoutD3D12::Initialize(ID3D12Device*
VERIFY_EXPR( CB.IsAllowedType(AllowedTypeBits) );
AddResource(CB, CachedResourceType::CBV);
},
+ [&](const D3DShaderResourceAttribs& Sam, Uint32)
+ {
+ VERIFY_EXPR( Sam.IsAllowedType(AllowedTypeBits) );
+
+ },
[&](const D3DShaderResourceAttribs& TexSRV, Uint32)
{
VERIFY_EXPR(TexSRV.IsAllowedType(AllowedTypeBits) );
auto VarType = TexSRV.GetVariableType();
Uint32 SamplerId = D3D12Resource::InvalidSamplerId;
- if(TexSRV.IsValidSampler())
+ if(TexSRV.ValidSamplerAssigned())
{
const auto& SrcSamplerAttribs = m_pResources->GetSampler(TexSRV.GetSamplerId());
VERIFY(SrcSamplerAttribs.GetVariableType() == VarType, "Inconsistent texture and sampler variable types" );
diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
index d61668bf..8922d379 100644
--- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
+++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp
@@ -37,61 +37,22 @@ namespace Diligent
ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix) :
ShaderResources(ShdrDesc.ShaderType)
{
- Uint32 CurrCB = 0, CurrTexSRV = 0, CurrTexUAV = 0, CurrBufSRV = 0, CurrBufUAV = 0, CurrSampler = 0;
- LoadD3DShaderResources<D3D12_SHADER_DESC, D3D12_SHADER_INPUT_BIND_DESC, ID3D12ShaderReflection>(
+ class NewResourceHandler
+ {
+ public:
+ void OnNewCB (const D3DShaderResourceAttribs& CBAttribs) {}
+ void OnNewTexUAV (const D3DShaderResourceAttribs& TexUAV) {}
+ void OnNewBuffUAV(const D3DShaderResourceAttribs& BuffUAV) {}
+ void OnNewBuffSRV(const D3DShaderResourceAttribs& BuffSRV) {}
+ void OnNewSampler(const D3DShaderResourceAttribs& SamplerAttribs){}
+ void OnNewTexSRV (const D3DShaderResourceAttribs& TexAttribs) {}
+ };
+ Initialize<D3D12_SHADER_DESC, D3D12_SHADER_INPUT_BIND_DESC, ID3D12ShaderReflection>(
pShaderBytecode,
-
- [&](Uint32 NumCBs, Uint32 NumTexSRVs, Uint32 NumTexUAVs, Uint32 NumBufSRVs, Uint32 NumBufUAVs, Uint32 NumSamplers, size_t ResourceNamesPoolSize)
- {
- Initialize(GetRawAllocator(), NumCBs, NumTexSRVs, NumTexUAVs, NumBufSRVs, NumBufUAVs, NumSamplers, ResourceNamesPoolSize);
- },
-
- [&](const D3DShaderResourceAttribs& CBAttribs)
- {
- new (&GetCB(CurrCB++)) D3DShaderResourceAttribs(m_ResourceNames, CBAttribs);
- },
-
- [&](const D3DShaderResourceAttribs& TexUAV)
- {
- new (&GetTexUAV(CurrTexUAV++)) D3DShaderResourceAttribs(m_ResourceNames, TexUAV);
- },
-
- [&](const D3DShaderResourceAttribs& BuffUAV)
- {
- new (&GetBufUAV(CurrBufUAV++)) D3DShaderResourceAttribs(m_ResourceNames, BuffUAV);
- },
-
- [&](const D3DShaderResourceAttribs& BuffSRV)
- {
- new (&GetBufSRV(CurrBufSRV++)) D3DShaderResourceAttribs(m_ResourceNames, BuffSRV);
- },
-
- [&](const D3DShaderResourceAttribs& SamplerAttribs)
- {
- new (&GetSampler(CurrSampler++)) D3DShaderResourceAttribs(m_ResourceNames, SamplerAttribs);
- },
-
- [&](const D3DShaderResourceAttribs& TexAttribs)
- {
- VERIFY(CurrSampler == GetNumSamplers(), "All samplers must be initialized before texture SRVs" );
-
- auto SamplerId =
- CombinedSamplerSuffix != nullptr ?
- FindAssignedSamplerId(TexAttribs, CombinedSamplerSuffix) :
- D3DShaderResourceAttribs::InvalidSamplerId;
- new (&GetTexSRV(CurrTexSRV++)) D3DShaderResourceAttribs(m_ResourceNames, TexAttribs, SamplerId);
- },
-
+ NewResourceHandler{},
ShdrDesc,
- CombinedSamplerSuffix);
-
- VERIFY_EXPR(m_ResourceNames.GetRemainingSize() == 0);
- VERIFY(CurrCB == GetNumCBs(), "Not all CBs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called");
- VERIFY(CurrTexSRV == GetNumTexSRV(), "Not all Tex SRVs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called" );
- VERIFY(CurrTexUAV == GetNumTexUAV(), "Not all Tex UAVs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called" );
- VERIFY(CurrBufSRV == GetNumBufSRV(), "Not all Buf SRVs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called" );
- VERIFY(CurrBufUAV == GetNumBufUAV(), "Not all Buf UAVs are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called" );
- VERIFY(CurrSampler == GetNumSamplers(), "Not all Samplers are initialized, which will result in a crash when ~D3DShaderResourceAttribs() is called" );
+ CombinedSamplerSuffix
+ );
}
}