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.02k stars 1.95k forks source link

Error when trying to compile with shaderc for metal on macos #2673

Closed freeeranger closed 2 years ago

freeeranger commented 2 years ago

I'm trying to compile some bgfx shaders using shaderc and bgfx.cmake through a cmake script. When compiling on windows I don't have any issues compiling to dx11 or glsl or anything like that, but on macOS there's an issue when compiling to metal. The full error is available here.

It kinda seems like it doesn't understand the syntax at all which is really weird (it complains about every single line of the shader, aka the shaders for the cubes example), and it also complains about HLSL parsing for some reason:

(92): error at column 93, HLSL parsing failed.
ERROR: 7 compilation errors.  No code generated.

Any help would be appreciated. The relevant CMake code is available here.

pezcode commented 2 years ago

There is no platform metal:

  --platform <platform>     Target platform.
     android
     asm.js
     ios
     linux
     orbis
     osx
     windows
freeeranger commented 2 years ago

Thanks for answering! For some clarification though, the function can be run like this on windows:

if(WIN32)
    compile_shader(voxel_game ${PROJECT_SOURCE_DIR}/src/shader_src/vs_cubes.sc vertex dx11 vs_5_0)
    compile_shader(voxel_game ${PROJECT_SOURCE_DIR}/src/shader_src/fs_cubes.sc fragment dx11 ps_5_0)
endif()

And that works perfectly. Here the SHADER_PLATFORM argument is dx11 which is not part of the --platform alternatives either, so I don't really think that's the issue.

freeeranger commented 2 years ago

Nevermind, that actually fixed it on mac: I just needed to change the path so that it looked in the metal folder for the shader. It's interesting though that it's not an issue on windows, but since it's working I guess I'll just leave it. Thanks! Don't really know if I should close the issue yet tho because of the inconsistency.