From cb92debd446581a094941e923d3a973d5450018f Mon Sep 17 00:00:00 2001 From: azhirnov Date: Tue, 8 Sep 2020 22:24:03 +0300 Subject: removed m_isDXIL flag, detect DXIL by bytecode --- .../include/ShaderResourcesD3D12.hpp | 2 +- .../GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp | 2 +- .../src/ShaderResourcesD3D12.cpp | 23 +++------------------- 3 files changed, 5 insertions(+), 22 deletions(-) (limited to 'Graphics/GraphicsEngineD3D12') diff --git a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp index 88c1cdc5..23f9882b 100644 --- a/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp +++ b/Graphics/GraphicsEngineD3D12/include/ShaderResourcesD3D12.hpp @@ -92,7 +92,7 @@ class ShaderResourcesD3D12 final : public ShaderResources { public: // Loads shader resources from the compiled shader bytecode - ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, bool isDXIL, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix); + ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix); // clang-format off ShaderResourcesD3D12 (const ShaderResourcesD3D12&) = delete; diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp index 3c740b29..d14eb122 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderD3D12Impl.cpp @@ -65,7 +65,7 @@ ShaderD3D12Impl::ShaderD3D12Impl(IReferenceCounters* pRefCounters, // Load shader resources auto& Allocator = GetRawAllocator(); auto* pRawMem = ALLOCATE(Allocator, "Allocator for ShaderResources", ShaderResourcesD3D12, 1); - auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_isDXIL, m_Desc, ShaderCI.UseCombinedTextureSamplers ? ShaderCI.CombinedSamplerSuffix : nullptr); + auto* pResources = new (pRawMem) ShaderResourcesD3D12(m_pShaderByteCode, m_Desc, ShaderCI.UseCombinedTextureSamplers ? ShaderCI.CombinedSamplerSuffix : nullptr); m_pShaderResources.reset(pResources, STDDeleterRawMem(Allocator)); } diff --git a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp index f7488afe..bcb34226 100644 --- a/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp +++ b/Graphics/GraphicsEngineD3D12/src/ShaderResourcesD3D12.cpp @@ -32,13 +32,12 @@ #include "ShaderD3DBase.hpp" #include "ShaderBase.hpp" #include "DXILUtils.hpp" -#include "dxc/dxcapi.h" namespace Diligent { -ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, bool isDXIL, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix) : +ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, const ShaderDesc& ShdrDesc, const char* CombinedSamplerSuffix) : ShaderResources{ShdrDesc.ShaderType} { class NewResourceHandler @@ -56,25 +55,9 @@ ShaderResourcesD3D12::ShaderResourcesD3D12(ID3DBlob* pShaderBytecode, bool isDXI CComPtr pShaderReflection; - HRESULT hr; - - if (isDXIL) - { - const uint32_t DFCC_DXIL = uint32_t('D') | (uint32_t('X') << 8) | (uint32_t('I') << 16) | (uint32_t('L') << 24); - CComPtr pReflection; - UINT32 shaderIdx; - hr = D3D12DxcCreateInstance(CLSID_DxcContainerReflection, IID_PPV_ARGS(&pReflection)); - CHECK_D3D_RESULT_THROW(hr, "Failed to create shader reflection instance"); - hr = pReflection->Load(reinterpret_cast(pShaderBytecode)); - CHECK_D3D_RESULT_THROW(hr, "Failed to load shader reflection from bytecode"); - hr = pReflection->FindFirstPartKind(DFCC_DXIL, &shaderIdx); - CHECK_D3D_RESULT_THROW(hr, "Failed to find DXIL part"); - hr = pReflection->GetPartReflection(shaderIdx, __uuidof(pShaderReflection), reinterpret_cast(&pShaderReflection)); - CHECK_D3D_RESULT_THROW(hr, "Failed to get the shader reflection"); - } - else + if (!DxcGetShaderReflection(reinterpret_cast(pShaderBytecode), &pShaderReflection)) { - hr = D3DReflect(pShaderBytecode->GetBufferPointer(), pShaderBytecode->GetBufferSize(), __uuidof(pShaderReflection), reinterpret_cast(&pShaderReflection)); + HRESULT hr = D3DReflect(pShaderBytecode->GetBufferPointer(), pShaderBytecode->GetBufferSize(), __uuidof(pShaderReflection), reinterpret_cast(&pShaderReflection)); CHECK_D3D_RESULT_THROW(hr, "Failed to get the shader reflection"); } -- cgit v1.2.3