bkaradzic / bgfx

Cross-platform, graphics API agnostic, "Bring Your Own Engine/Framework" style rendering library.
https://bkaradzic.github.io/bgfx/overview.html
BSD 2-Clause "Simplified" License
15.15k stars 1.95k forks source link

sampler2DArray NEW_IDENTIFIER for texture 2d array #1637

Open zhongyin-hu opened 5 years ago

zhongyin-hu commented 5 years ago

Hi, I'm having trouble using SAMPLER2DARRAY and have been stuck for a while. I have tested it in a very simple shader. But it seems that the sampler2DArray is not recognized by bgfx. I also tried SAMPLER2D and SAMPLER3D and those are fine.

my_fragment_shader.sc

include

SAMPLER2DARRAY(u_texture0, 0);

void main() {
gl_FragColor = vec4(1,1,1,1); }

Error msg from compiler: 95: uniform sampler2DArray u_texture0; 24: ^

Error: (95,24): error: syntax error, unexpected NEW_IDENTIFIER, expecting '{'

I look at bgfx_shader.sh and it seems that SAMPLER2DARRAY macro is defined a couple of places depending on the BGFX_SHADERLANGUAGE* I tried both Vulkan and OpenGL for the renderer type of my program, but both have the same compile issue. I also checked BGFX_CAPS_TEXTURE_2D_ARRAY is enabled.

Any thought what may go wrong? Many thanks! I appreciated your attention.

thegabman commented 5 years ago

I just stumbled on the same issue on Metal in this second.

thegabman commented 5 years ago

Using the new version of shaderc solved this issue for me

zhongyin-hu commented 5 years ago

@thegabman Hi thanks for the info. Which exact version do you use? I tried BGFX_API_VERSION (91) and this issue still persists on my end.

bwrsandman commented 5 years ago

I run into this issue if no specifying --profile which defaults to essl = 2.

Try adding --profile 120 to your command if you're not using essl.

hydrogen18 commented 4 years ago

@bwrsandman Thank you for providing this solution