Jump to content

  • Log In with Google      Sign In   
  • Create Account

D3DReflect does not detect constant buffers


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 pulo   Members   -  Reputation: 228

Like
0Likes
Like

Posted 26 May 2014 - 03:51 PM

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.

 

 



Sponsor:

#2 unbird   Crossbones+   -  Reputation: 6011

Like
1Likes
Like

Posted 26 May 2014 - 04:10 PM

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.



#3 pulo   Members   -  Reputation: 228

Like
0Likes
Like

Posted 26 May 2014 - 04:19 PM

Oh i did not know that this works this way. Thanks a lot :)






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS