Jump to content
  • Advertisement
Sign in to follow this  
pulo

D3DReflect does not detect constant buffers

This topic is 1484 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

Hey there,

So i am trying to get the number of constant buffers from my compiled shaders through reflection. Sadly it is not working as expected and i don't know why. Here is how i load the shader code inside a ID3DBlob:

ID3DBlob* vertexBlob;
HRESULT result = D3DReadFileToBlob(vertexShader.c_str(), &vertexBlob);

And this is how i get the reflection:

ComPtr<ID3D11ShaderReflection> reflection;
HRESULT hr = D3DReflect(shader.code->GetBufferPointer(), shader.code->GetBufferSize(), IID_ID3D11ShaderReflection, reinterpret_cast<void**>(reflection.GetAddressOf()));

if (FAILED(hr)) {
// SOMETHING WENT WRONG;
return (nullptr);
}

D3D11_SHADER_DESC shaderDesc;
reflection->GetDesc(&shaderDesc);

If i check the shaderDesc in Debug the ConstantBuffers variable is 0. I already made sure that changes made to the Shader are getting recognized. I added another input variable and the number of input parameters inside the description increased. Finally here is how i define the constant buffer, but i don't think that this is the problem:

cbuffer perObject 
{
matrix worldViewProj;
};

struct vertexInput
{
float3 position : POSITION;
float3 color : COLOR;
};

float4 main(vertexInput input) : SV_POSITION
{
return float4(input.position, 1.0f);
}

Has anyone any ideas what might be wrong?-
Thank you in advance.

 

 

Share this post


Link to post
Share on other sites
Advertisement

Since that shader doesn't use anything from that buffer, the compiler won't assign a slot. So yeah, your vertex shader does in fact have no constant buffers.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!