Skip to content

Commit

Permalink
shaderc: Fix integer vecs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed May 24, 2024
1 parent 4f1728d commit 87fd766
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions tools/shaderc/shaderc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ namespace bgfx
NULL
};

static const char* s_unsignedVecs[] =
static const char* s_integerVecs[] =
{
"ivec2",
"uvec2",
"ivec3",
"uvec3",
"ivec4",
"uvec4",
NULL
};
Expand Down Expand Up @@ -2259,15 +2262,15 @@ namespace bgfx
const bool usesTextureArray = !bx::findIdentifierMatch(input, s_textureArray).isEmpty();
const bool usesPacking = !bx::findIdentifierMatch(input, s_ARB_shading_language_packing).isEmpty();
const bool usesViewportLayerArray = !bx::findIdentifierMatch(input, s_ARB_shader_viewport_layer_array).isEmpty();
const bool usesUnsignedVecs = !bx::findIdentifierMatch(preprocessedInput, s_unsignedVecs).isEmpty();
const bool usesIntegerVecs = !bx::findIdentifierMatch(preprocessedInput, s_integerVecs).isEmpty();

if (profile->lang != ShadingLang::ESSL)
{
const bool need130 = (120 == glsl_profile && (false
|| !bx::findIdentifierMatch(input, s_130).isEmpty()
|| usesInterpolationQualifiers
|| usesTexelFetch
|| usesUnsignedVecs
|| usesIntegerVecs
) );

bx::stringPrintf(code, "#version %d\n", need130 ? 130 : glsl_profile);
Expand Down Expand Up @@ -2349,15 +2352,6 @@ namespace bgfx
);
}

if (130 > glsl_profile)
{
bx::stringPrintf(code,
"#define ivec2 vec2\n"
"#define ivec3 vec3\n"
"#define ivec4 vec4\n"
);
}

if (ARB_shader_texture_lod)
{
bx::stringPrintf(code,
Expand Down Expand Up @@ -2395,7 +2389,7 @@ namespace bgfx
else
{
if (glsl_profile < 300
&& usesUnsignedVecs)
&& usesIntegerVecs)
{
glsl_profile = 300;
}
Expand Down

0 comments on commit 87fd766

Please sign in to comment.