1

Ok I have a shader compiled up under D3D10.

I am obtaining a shader reflection to get details of all the constants/globals in the shader. However I'm a little confused on something ... how do I set a texture to a constant buffer?

I assume I don't just Map the constant buffer and copy the ID3D10Texture pointer into it ... I assume I use an ID3D10ShaderResourceView but I'm just unsure of how I set it in the constant buffer.

Any help would be much appreciated!

Goz
  • 61,365
  • 24
  • 124
  • 204

1 Answers1

1

You don't bind a texture to a constant buffer. You bind textures, via views, to a stage (here GS stage) using method:

void GSSetShaderResources(
  [in]  UINT StartSlot,
  [in]  UINT NumViews,
  [in]  ID3D10ShaderResourceView *ppShaderResourceViews
);

Views and CBs are actually two separate things.

elmattic
  • 12,046
  • 5
  • 43
  • 79
  • Ok I'm beginning to realise this but how do I tie a given shader global "Texture2D" to a given slot? – Goz Jul 07 '10 at 20:48
  • 1
    Maybe I should start a new question...? Damn me for using an XP macine to attempt to do DX10 stuff earlier ;) – Goz Jul 07 '10 at 20:51
  • You have to use a register attribute to tie an SRV (on a buffer or texture) to a given slot: e.g: Texture2D diffuse : register(t0) //slot 0 here – elmattic Jul 07 '10 at 22:09
  • Then this SRV is bound to ppShaderResourceViews[0+StartSlot] when calling *SetShaderResources. – elmattic Jul 07 '10 at 22:15