4
PSSetShaderResource()的第一個參數:什麼的佔用ID3D11DeviceContext :: PSSetShaderResource()
void PSSetShaderResources(
[in] UINT StartSlot,
[in] UINT NumViews,
[in] ID3D11ShaderResourceView *const *ppShaderResourceViews
);
StartSlot:‘索引到設備的從零開始的數組,開始設置着色器資源’
那麼,有什麼整數索引和你的.hlsl變量之間的關係?在d3d9中,所有內容都是基於字符串的名稱。現在,這些整數指數似乎缺了點什麼......
假設你有一個着色器文件:
// shader_1.psh
Texture2D tex ;
而另一..
// shader_2.psh
TextureCube cubeTex ;
如果你只使用shader_1.psh,當他們在不同的文件中時,你怎麼區分它們?
// something like this..
d3d11devicecontext->PSSetShaderResources(0, 1, &texture2d) ;
// index 0 sets 0th texture..
// what index is the tex cube?
看來,在DirectX 11 API參數名「插槽」的概念是實際上意味着直接的「寄存」的概念,以對應在HLSL。目前在DX11 MSDN文章中沒有任何記載,但這是一個關鍵信息。此外,「t」前綴表示「紋理寄存器插槽」,「b」表示「恆定緩衝寄存器插槽」等等。 –