I’m working on a compute shader plugin. It works fine – until I try to add a texture2d shader parameter.
In my shader CPP I declare the paramter blocks like this:
DECLARE_GLOBAL_SHADER(FComputeShaderExampleCS);
SHADER_USE_PARAMETER_STRUCT(FComputeShaderExampleCS, FGlobalShader);
BEGIN_SHADER_PARAMETER_STRUCT(FParameters, )
SHADER_PARAMETER_UAV(RWTexture2D<uint>, OutputTexture)
SHADER_PARAMETER(FVector2D, TextureSize) // Metal doesn't support GetDimensions(), so we send in this data via our parameters.
SHADER_PARAMETER(float, SimulationState)
SHADER_PARAMETER_TEXTURE(Texture2D, TestTexture)
END_SHADER_PARAMETER_STRUCT()
and in the corresponding USF file I have this:
RWTexture2D<uint> OutputTexture;
float2 TextureSize;
float SimulationState;
float Dummy;
Texture2D TestTexture;
However when I activate the shader, I get the following check exception:
Assertion failed: Bindings.StructureLayoutHash == ParametersMetadata->GetLayoutHash()
I’m not actually changing the bound texture (at least, not intentionally). Converting SHADER_PARAMETER_TEXTURE(Texture2D, TestTexture)
to SHADER_PARAMETER_UAV(Texture2D, TestTexture)
avoids the exception but doesn’t work (calling Load() on the texture always returns (0,0,0,0), or perhaps (NAN,NAN,NAN,NAN))
What’s the expected method for passing a Texture2D Parameter to a compute shader?