0

I'm trying to get reflection information for a compute shader compiled by my program by calling D3DCompile() or D3DCompile2().

Compilation is OK, confimed by code executing correctly.

Then I call D3DReflect to get a reflector against the compiled code.

Once I have the reflector, I call reflector->GetDesc(&ShaderDesc);

This works perfectly: ShaderDesc structure reports ConstantBuffers equal to 1 which is correct.

Then I call reflector->GetConstantBufferByIndex(0) which always returns the null pointer.

What is wrong ?

My environment: Windows 10 fully up-to-date, DirectX11 on NVidia Quadro K4200 with driver 24.21.14.1240 dated 21/07/2019, D3DCompiler_47.dll dated 19/03/2019.

Edit: In the shader, the constant buffer is defined like this:

cbuffer TImageParams : register(b0)
{
    int2   RawImageSize;        // Actual image size in RawImage
    // More items....
};

Kind regards

fpiette
  • 11,983
  • 1
  • 24
  • 46
  • Can you post your shader or a simple version that replicates the case? – mrvux Nov 26 '19 at 15:25
  • @catflier Edited the question to show how the constant buffer is defined. Nothing fancy... – fpiette Nov 27 '19 at 08:40
  • If could still have a small minimal example it would help, for the moment I can't reproduce with my version – mrvux Nov 27 '19 at 17:40
  • I already tried a minimal example and it works as expected. This is my full application where it doesn't work. This is a fairly large one: on CPU side it has 67K code lines out of wich 6K are specific to GPU. There are also more than 4K shader code lines. Beside the fact it is too long to publish it on StackOverflow, I'm not allowed to make the code public. I don't expect to get a solution here but I hope to get some advice about what to check or to try. Thanks. – fpiette Nov 28 '19 at 11:59
  • Do you have same issue if you use reflect->GetResourceBindingDesc() instead? – mrvux Nov 28 '19 at 16:00
  • I will try and let you know. Thanks. – fpiette Nov 28 '19 at 18:26
  • @catflier I confirm that reflect->GetResourceBindingDesc() works correctly. All bounds resources are enumerated and I get their descriptor. Constant buffer is of course not in that list. – fpiette Dec 03 '19 at 09:23
  • @catflier CORRECTION: Constant buffer IS IN THE LIST. – fpiette Dec 03 '19 at 09:46
  • I need the interface ID3D11ShaderReflectionConstantBuffer to be able to query the variables but reflector->GetConstantBufferByName(BoundResDesc.Name) always return NULL. So I'm back to the starting point. – fpiette Dec 03 '19 at 09:54

0 Answers0