• Advertisement
Sign in to follow this  

Constant table GetSamplerIndex problem

This topic is 2686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I use GetSamplerIndex to get texture's register index. Here's the snippet:

D3DXHANDLE constantHandle = currentPixelShader->constantTable->GetConstantByName(NULL, samplerName.c_str());
uint shaderSamplerIndex = currentPixelShader->constantTable->GetSamplerIndex(constantHandle);

The problem is that I only get proper value for the first queried sampler. In my shader there are such lines:

uniform sampler2D diffuseMap: register(s1);
uniform sampler2D diffuseMap2: register(s2);

And in fact I get 1 when querying diffuseMap, but for diffuseMap2 I get 4294967295.
All I get in Debug runtime is:

D3DX: ID3DXConstantTable: hConstant parameter is NULL

what probably means I should have passed something as first argument to GetConstantByName but... what should be passed?

Share this post


Link to post
Share on other sites
Advertisement
You're probably getting that debug output because GetConstantByName is returning NULL, and you're passing that NULL handle to GetSamplerIndex. NULL is perfectly valid for the hConstant parameter of GetConstantByName .

Are you sure you're passing the right name? Are you also sure that the shader actually uses the sampler you're interested in? If the shader doesn't use it, it won't show up in the constant table.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement