Generate vector constructions more efficiently when sizes match#3628
Merged
arcady-lunarg merged 2 commits intoKhronosGroup:mainfrom Jun 24, 2024
Merged
Generate vector constructions more efficiently when sizes match#3628arcady-lunarg merged 2 commits intoKhronosGroup:mainfrom
arcady-lunarg merged 2 commits intoKhronosGroup:mainfrom
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.
Contributor
|
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: |
ravi688
added a commit
to ravi688/glslang
that referenced
this pull request
Jun 23, 2024
…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.
Open
Contributor
|
The assertion failure is fixed in PR #3631. |
jeremy-lunarg
approved these changes
Jun 24, 2024
Contributor
jeremy-lunarg
left a comment
There was a problem hiding this comment.
Looks good. We should follow up on #3631 after this lands.
Contributor
Author
|
The assertion is in place of generating invalid SPIR-V so I wouldn't count it as a regression. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When two vectors are the same size, there is no need to extract the components and construct a new vector.