Open ravi688 opened 1 week ago
@arcady-lunarg , could you please add the unit tests on your side again? I've ran out of my time this weekend. I see the tests are failing and I think it is expected for spv.8bit-16bit-construction.frag
. You may inspect the SPIR-V with my patch applied for this shader and correct the reference SPIR-V file used for testing.
I think the following set of SPIR-V instructions are inefficient as what more the SPVKHR{16|8}bit_storage extensions allow.
...
%19 = OpAccessChain %_ptr_Uniform_v4short %_ %int_0
%20 = OpLoad %v4short %19
%22 = OpSConvert %v4int %20
%23 = OpSConvert %v4char %22
%25 = OpAccessChain %_ptr_Uniform_v4char %cob %int_0
OpStore %25 %23
...
Direct conversion from short
to char
is possible and allowed in SPVKHR{16|8}bit_storage extensions. However, it is not allowed in the corresponding GLSL extensions.
Any comments appreciated...
Convert 8/16-bit int (and their composite vector) types to their corresponding 32-bit types first and then convert the resulting 32-bit type to the target 8/16-bit type.
This change emits appropriate Op{S|U}Convert instructions instead of OpCompositeExtract followed by OpCompositeConstruct for 8/16-bit integer types.
What types of shaders are affected?
The following GLSL shader:
Now compiles to the SPIR-V (i.e. with this patch applied):
Earlier it used to be compiled to the following SPIR-V instructions (i.e. without patch applied):