Skip to content
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

glslang compilation error when using uvec2 in GLSL code #1077

Open
asafran opened this issue Jan 21, 2024 · 3 comments
Open

glslang compilation error when using uvec2 in GLSL code #1077

asafran opened this issue Jan 21, 2024 · 3 comments

Comments

@asafran
Copy link
Contributor

asafran commented Jan 21, 2024

Describe the bug
glslang compilation error when using uvec2 in GLSL code

To Reproduce
Steps to reproduce the behavior:

  1. Clone and build vsgFramework
  2. Modify any GLSL shader used in the example. Add any code (e.g. from https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#Examples) contains uvec2 initialization:
    const uvec2 range = uvec2(2, 5);
  3. Set VSG_FILE_PATH and run example (I used vsgtexturearray) using modified GLSL shader
  4. See error:
Warning: 
----  Fragment Shader  ---- 

Warning:    1: #version 450
   2: #extension GL_ARB_separate_shader_objects : enable
   3: 
   4: layout(constant_id = 0) const uint numBaseTextures = 1;
   5: 
   6: layout(set = 0, binding = 1) uniform sampler2D baseTextureSampler[numBaseTextures];
   7: 
   8: layout(set = 1, binding = 0) uniform TileSettings {
   9:     uint tileIndex;
  10: } tileSettings;
  11: 
  12: layout(location = 0) in vec3 fragColor;
  13: layout(location = 1) in vec2 fragTexCoord;
  14: 
  15: layout(location = 0) out vec4 outColor;
  16: 
  17: const uvec2 range = uvec2(2, 5);
  18: 
  19: void main() {
  20:     outColor = texture(baseTextureSampler[tileSettings.tileIndex], fragTexCoord);
  21: }

Warning: GLSL source failed to parse.
Warning: glslang info log:
ERROR: 0:17: 'constructor' : can't convert 
ERROR: 0:17: ' const 2-component vector of uint' : cannot construct with these arguments 
ERROR: 0:17: 'const' : non-matching or non-convertible constant type for const initializer 
ERROR: 0:17: '' : compilation terminated 
ERROR: 4 compilation errors.  No code generated.


info: glslang debug info log: 

Warning: --------
Segmentation fault (core dumped)

Expected behavior
Successful compilation of the GLSL code

Desktop (please complete the following information):

  • OS: Fedora Linux 39
  • Version master 081c88a
@robertosfield
Copy link
Collaborator

The VSG builds glslang as part of the VSG itself to compile GLSL shaders to SPIR-V, so either the version of glslang we are including has a problem, or glslang requires an option enabled to support uvec's.

Could you try out glslangValidator on the shader?

@robertosfield
Copy link
Collaborator

Yesterday evening I tried out uvec2 with shaders on my laptop and reproduced the issue, I tried glslangValidator from VulkanSDK 1.2.268 and 1.3.275 and both acceoted my uvec2 code, I then checked the glslang version used in each case.

The VSG's glslang is 12.0.0 which was drawn from glslang master last year, while the VulkanSDK versions were 10.x. and 11.x versions respectively, so it could be there was a regression between 11.x and 12.x. The VSG uses a branch from glslang so I there is changes the upstream glslang has resolved this regression and we just need to merge updates.

I have other tasks to tackle to today so can't spend time right away investigating this further.

@robertosfield
Copy link
Collaborator

@asafran I have created a branch of the VSG that links to glslang as an external dependency rather than then building a fork of glslang directly into VSG library. I've written up some details on the discussion therad #1199. Could you test of the new external_glslang branch with modern version of gslang (14.1 or later) to see if the issue uvec2 issue is resolved. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants