Very cool explanation! I was also embarrassed, and after your questions and explanations this is clear to me!
But I found a good example for this publication that I want to share. It seems to start a slot counter for each type of SetShaderResources. All shaders (VS, HS, DS, PS) have their own counter. Here is the code from the NVidia example:
Shaderclass Code:
pd3dDeviceContext->HSSetShaderResources( 0, 2, Resources ); pd3dDeviceContext->HSSetShaderResources( 8, 1, &m_pRegularWatertightTexSRV ); pd3dDeviceContext->HSSetShaderResources( 9, 1, &m_pQuadWatertightTexSRV ); pd3dDeviceContext->HSSetShaderResources( 2, 1, &pHeightMapTextureSRV ); pd3dDeviceContext->DSSetShaderResources( 2, 1, &pHeightMapTextureSRV ); pd3dDeviceContext->PSSetShaderResources( 2, 1, &pHeightMapTextureSRV ); pd3dDeviceContext->PSSetShaderResources( 10, 1, &pNormalMapTextureSRV ); pd3dDeviceContext->PSSetShaderResources( 3, 1, &pTexRenderRV11 );
The first contains two resources, so the next slot (line 4) should add 2 for the initial slot (0 + 2 = 2). Each SetShaderResources should start at 0, but you can do it in different places in your code, so there are no 0 slots for DS and PS. Several times, if you delete a row, it still works, but the data is delayed. Now you see the first four in HLSL on the lines t0, t1, t8 and t9, another register was linked somewhere else.
HLSL Code:
Texture2D<float> GregoryStencil : register( t0 ); Texture2D<uint> Index : register( t1 ); Texture2D<float> g_txHeight : register( t2 ); Texture2D<float> g_depth : register( t3 ); Texture2D g_FloorTexture : register( t4 ); Texture2D<float3> regularPatchControlPoints : register( t5 ); Texture2D<float3> gregoryPatchControlPoints : register( t6 ); Texture2D<float4> g_floorHeight : register( t7 ); Texture2D<float2> RegularWatertightUVs : register( t8 ); Texture2D<float2> QuadWatertightUVs : register( t9 ); Texture2D<float3> g_txNormal : register( t10 );
Jinxi
source share