From 11a33969be01c7b572b9af613d10cc2fe9b80e13 Mon Sep 17 00:00:00 2001 From: Egor Yusov Date: Wed, 6 Mar 2019 23:11:08 -0800 Subject: Added shader resource print; updated core --- Tests/TestApp/src/TestShaderVarAccess.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Tests/TestApp/src/TestShaderVarAccess.cpp') diff --git a/Tests/TestApp/src/TestShaderVarAccess.cpp b/Tests/TestApp/src/TestShaderVarAccess.cpp index 0205444..35af2ad 100644 --- a/Tests/TestApp/src/TestShaderVarAccess.cpp +++ b/Tests/TestApp/src/TestShaderVarAccess.cpp @@ -27,9 +27,27 @@ #include "pch.h" #include "TestShaderVarAccess.h" #include "BasicShaderSourceStreamFactory.h" +#include "GraphicsAccessories.h" using namespace Diligent; +void PrintShaderResources(IShader* pShader) +{ + std::stringstream ss; + ss << "Resources of shader '" << pShader->GetDesc().Name << "':" << std::endl; + for (Uint32 res=0; res < pShader->GetResourceCount(); ++res) + { + auto ResDec = pShader->GetResource(res); + std::stringstream name_ss; + name_ss << ResDec.Name; + if(ResDec.ArraySize > 1) + name_ss << "[" << ResDec.ArraySize << "]"; + ss << std::setw(2) << std::right << res << ": " << std::setw(24) << std::left << name_ss.str() + << " " << GetShaderResourceTypeLiteralName(ResDec.Type) << std::endl; + } + LOG_INFO_MESSAGE(ss.str()); +} + TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext *pContext, Diligent::ISwapChain* pSwapChain ) : UnitTestBase("Shader variable access test"), m_pDeviceContext(pContext) @@ -180,6 +198,8 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext pDevice->CreateShader(CreationAttrs, &pVS); VERIFY_EXPR(pVS); + + PrintShaderResources(pVS); } std::vector VarDesc = @@ -220,6 +240,8 @@ TestShaderVarAccess::TestShaderVarAccess( IRenderDevice *pDevice, IDeviceContext CreationAttrs.FilePath = pDevice->GetDeviceCaps().IsD3DDevice() ? "Shaders\\ShaderVarAccessTestDX.psh" : "Shaders\\ShaderVarAccessTestGL.psh"; pDevice->CreateShader(CreationAttrs, &pPS); VERIFY_EXPR(pPS); + + PrintShaderResources(pPS); } -- cgit v1.2.3