-
Notifications
You must be signed in to change notification settings - Fork 854
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate vector constructions more efficiently when sizes match #3628
Generate vector constructions more efficiently when sizes match #3628
Conversation
When two vectors are the same size, there is no need to extract the components and construct a new vector.
A type can't have a negative number of constituents, components, rows, or columns. Therefore, the utility functions to query said information on types and values should return unsigned int rather than int.
This change leads to an assertion failure for the following shader: #version 460
#extension GL_EXT_shader_8bit_storage : require
#extension GL_EXT_shader_16bit_storage : require
layout(binding = 1 ) uniform _16bit_storage
{
int16_t i16;
i16vec4 i16v4;
};
// This is read back and checked on the CPU side to verify the converions
layout(binding = 2 ) writeonly buffer ConversionOutBuffer
{
int8_t i8;
i8vec4 i8v4;
} cob;
out vec4 fcolor;
void main()
{
// Conversions
{
cob.i8 = int8_t(i16);
cob.i8v4 = i8vec4(i16v4);
}
bool RED = true;
bool GREEN = false;
fcolor = vec4( (RED) ? 1.0f : 0.0f,
(GREEN) ? 1.0f : 0.0f,
0.0f, 1.0f);
} Assertion: |
…esponding 32-bit types first - this fixes KhronosGroup#3607 - and this also fixes assertion failure in the PR KhronosGroup#3628 - this change emits appropriate Op{S|U}Convert instructions instead of OpCompositeExtract followed by OpCompositeConstruct for 8/16-bit integer types.
The assertion failure is fixed in PR #3631. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. We should follow up on #3631 after this lands.
The assertion is in place of generating invalid SPIR-V so I wouldn't count it as a regression. |
When two vectors are the same size, there is no need to extract the components and construct a new vector.