-
Notifications
You must be signed in to change notification settings - Fork 58
Open
Description
The API seems to be unable to detect multi-location types. Calling SDL_ShaderCross_ReflectGraphicsSPIRV() for a shader that has inputs
layout(location = 0) in mat3 test1; //first input
layout(location = 3) in uint test2;
layout(location = 4) in mat4 test3; //last input
results in SDL_ShaderCross_GraphicsShaderMetadata with num_inputs = 3 and SDL_ShaderCross_IOVarMetadatas with
name = test1, location = 0, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 3
name = test2, location = 3, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_UINT32, vector_size = 1
name = test3, location = 4, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 4
This leaves the mat4 looking like a vec4 (the mat3 could be deduced from the missing locations, assuming the shader has been written without missing locations).
It seems to me the API could instead return either
num_inputs = 3
name = test1, location = 0, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 9
name = test2, location = 3, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_UINT32, vector_size = 1
name = test3, location = 4, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 16
or
num_inputs = 8
name = test1, location = 0, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 3
name = test1, location = 1, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 3
name = test1, location = 2, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 3
name = test2, location = 3, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_UINT32, vector_size = 1
name = test3, location = 4, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 4
name = test3, location = 5, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 4
name = test3, location = 6, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 4
name = test3, location = 7, vector_type = SDL_SHADERCROSS_IOVAR_TYPE_FLOAT32, vector_size = 4
The latter might be better since it works for mat2 as well, whereas the first suggestion would yield vector_size = 4 which would be the same as vec4.
Currently the user has to write the inputs as something like
layout(location = 0) in vec3 test1_1;
layout(location = 1) in vec3 test1_2;
layout(location = 2) in vec3 test1_3;
layout(location = 3) in uint test2;
layout(location = 4) in vec4 test3_1;
layout(location = 5) in vec4 test3_2;
layout(location = 6) in vec4 test3_3;
layout(location = 7) in vec4 test3_4;
to ensure proper detection of all inputs.
Metadata
Metadata
Assignees
Labels
No labels