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

#include issue #308

Closed
realitix opened this issue Mar 2, 2017 · 5 comments
Closed

#include issue #308

realitix opened this issue Mar 2, 2017 · 5 comments

Comments

@realitix
Copy link
Contributor

realitix commented Mar 2, 2017

Hello,
I am using libshaderc to compile glsl ot Spir-V for Vulkan.
I want to use the #include preprocessor but I got an error during compilation.

Here the glsl:

  #version 450
  #extension GL_ARB_separate_shader_objects : enable
  
  #include "path/test.glsl"
 
  layout(location = 0) in vec2 i_position;
  layout(location = 1) in vec2 i_textureCoordinates;
  layout(location = 2) in vec4 i_color;
  
  layout(location = 0) out vec4 o_color;
  layout(location = 1) out vec2 o_textureCoordinates;
  
  layout(set = 0, binding = 0) uniform Uniform {
      mat4 u_combinedMatrix;
  };
  
  out gl_PerVertex {
      vec4 gl_Position;
  };
  
  
  void main() {
      o_color = i_color;
      o_textureCoordinates = i_textureCoordinates;
      gl_Position = u_combinedMatrix * vec4(i_position, 0., 1.);
  }

I got the following error:

spritebatch.vs.glsl:4: error: '#include' : #error u [ for header name: path/test.glsl

Like you can see, there is an error in the output, it's not proper ASCCI or UTF-8, there are strange characters u [ .

Is this a known error, maybe I misuse the library.

Thanks.

@dneto0
Copy link
Collaborator

dneto0 commented Mar 2, 2017

Can you replicate the problem with the glslc command line tool?
What is in the included file?

I've copied your code locally, and made 'path/test.glsl' and empty file, but can't reproduce your problem.
If I move the include file out of the way or make it unreadable I get:

$ glslc -E x.vert
x.vert:4: error: '#include' : Cannot find or open include file. for header name: path/test.glsl
1 error generated.

If I put garbage in path/test.glsl I get:

$ glslc -c x.vert
path/test.glsl:2: error: '' :  syntax error
1 error generated.

@realitix
Copy link
Contributor Author

realitix commented Mar 3, 2017

Indeed with glslc I got the good error. I am wondering why I obtain a malformated error with libshaderc... I continue to dig.

@realitix
Copy link
Contributor Author

realitix commented Mar 3, 2017

Ok it was my fault:
When calling shaderc_compile_into_spv, I didn't pass the last argument options which contains my includes callback.
That doesn't explain the encoding error but I can live with that.
So I close it. Thanks @dneto0

@realitix realitix closed this as completed Mar 3, 2017
@dneto0
Copy link
Collaborator

dneto0 commented Mar 3, 2017

Reopening. I can reproduce it.

When I send in an options object that does not have an includer set (this is the defaul), then I get garbled text in the error message.

Example output:

shader_src:2: error: '#include' :  ���� for header name: bar

I suspect Glslang should error out more sensibly, but will keep this open here so I track resolution.

@realitix
Copy link
Contributor Author

realitix commented Mar 3, 2017

I was not dreaming! Thanks @dneto0

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