I have the following shader compiled using D3DCompiler:
struct vertex_in
{
float3 position : POSITION;
float2 tex_coord : TEXCOORD;
};
struct vertex_out
{
float4 position : SV_POSITION;
float2 tex_coord : TEXCOORD;
};
Texture2D g_texture : register(t0);
SamplerState g_sampler : register(s0);
vertex_out VS(vertex_in vin)
{
vertex_out vout;
vout.position = float4(vin.position , 1.0f);
vout.tex_coord = vin.tex_coord;
return vout;
}
float4 PS(vertex_out pin) : SV_Target
{
float2 test_var;
test_var.x = 0.0f;
test_var.y = 1.0f;
return g_texture.Sample(g_sampler, test_var);
}
I would like to use the ID3D12ShaderReflection
interface in order to get information about the variable called test_var
in the pixel shader above. This is what I am currently trying:
com_ptr<ID3D12ShaderReflection> pixel_shader_reflector;
D3DReflect(pixel_shader->GetBufferPointer(), pixel_shader->GetBufferSize(), winrt::guid_of<ID3D12ShaderReflection>(), pixel_shader_reflector.put_void());
std::string test_var = "test_var";
ID3D12ShaderReflectionVariable* sr_variable = pixel_shader_reflector->GetVariableByName(test_var.c_str());
D3D12_SHADER_VARIABLE_DESC shader_var_desc = {};
sr_variable->GetDesc(&shader_var_desc);
However I get the following errors:
Exception thrown at 0x00007FFBF7AB5299 (KernelBase.dll) in wzrd_editor.exe: WinRT originate error - 0x80004005 : 'Unspecified error'.
Exception thrown at 0x00007FFBF7AB5299 in wzrd_editor.exe: Microsoft C++ exception: winrt::hresult_error at memory location 0x00000053DE1FB058.
Aucun commentaire:
Enregistrer un commentaire