HSSetShaderResources
Very cool explanation! I also got confused, and after your questions and explanations it's clear for me!
But I found a good example for this post, which I want to share. It seems it starts the counter of the slot for every SetShaderResources Type. All shaders (VS, HS, DS, PS) seems to have theirs own counter. Here the code from a NVidia example:
The 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 is holding two resources, so the next slot (line 4) has to add 2 for the starting slot (0+2=2). Every SetShaderResources has to start with 0, but you can do that on different places in your code, therefore there is no 0 slot for DS and PS here. Some times if you remove a line it still works but the data is postponed. Now you see the first four in HLSL at line t0, t1, t8, and t9 the other register were bound somewhere else.
The 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 );
posted on 2019-05-17 16:10 guanxi0808 阅读(191) 评论(0) 编辑 收藏 举报