4

PSSetShaderResource()の最初のパラメーター:

void PSSetShaderResources(
  [in]  UINT StartSlot,
  [in]  UINT NumViews,
  [in]  ID3D11ShaderResourceView *const *ppShaderResourceViews
);

StartSlot:「デバイスのゼロベースの配列にインデックスを付けてシェーダーリソースの設定を開始します」

では、整数インデックスと.hlsl変数の間の関係は何ですか?d3d9では、すべてが文字列ベースの名前でした。今、これらの整数インデックスには何かが欠けているようです......

シェーダーファイルが1つあるとします。

// shader_1.psh
Texture2D tex ;

そして別の..

// shader_2.psh
TextureCube cubeTex ;

シェーダー_1.pshのみを使用している場合、それらが別々のファイルにある場合、それらをどのように区別しますか?

// something like this..
d3d11devicecontext->PSSetShaderResources( 0, 1, &texture2d ) ;
// index 0 sets 0th texture..
// what index is the tex cube?
4

1 に答える 1

3

これはまだ実験的に検証された推測です(参照ドキュメントは見つかりませんでした)が、次のように実行できると思います。

// HLSL shader
Texture2D tex : register( t0 );
Texture2D cubeTex : register( t1 );
SamplerState theSampler : register( s0 );

したがって、C ++コードから、シェーダーでにをバインドするD3D11Texture2D*ためtexのタイアップは次のとおりです。

// C++
d3d11devicecontext->PSSetShaderResources( 0, 1, &texture2d ) ; // SETS TEX @ register( t0 )
d3d11devicecontext->PSSetShaderResources( 1, 1, &textureCUBE ) ;//SETS TEX @ register( t1 )
于 2011-09-26T17:45:12.547 に答える