From 489671c5445d2e8f64382590f3229c64eb4f6ea3 Mon Sep 17 00:00:00 2001 From: johndoe6345789 Date: Wed, 7 Jan 2026 10:38:41 +0000 Subject: [PATCH] fix(shader): Prevent automatic location mapping in shader creation to maintain explicit layout consistency --- src/services/impl/bgfx_graphics_backend.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/services/impl/bgfx_graphics_backend.cpp b/src/services/impl/bgfx_graphics_backend.cpp index dc0baa4..60aa4c9 100644 --- a/src/services/impl/bgfx_graphics_backend.cpp +++ b/src/services/impl/bgfx_graphics_backend.cpp @@ -700,7 +700,10 @@ bgfx::ShaderHandle BgfxGraphicsBackend::CreateShader(const std::string& label, shaderc::CompileOptions options; options.SetTargetEnvironment(shaderc_target_env_vulkan, shaderc_env_version_vulkan_1_1); options.SetAutoBindUniforms(true); - options.SetAutoMapLocations(true); + // Do NOT use SetAutoMapLocations - it overrides explicit layout(location=N) declarations + // and assigns locations alphabetically by variable name, breaking the vertex layout. + // MaterialX and other shaders already specify explicit locations matching our VertexLayout. + // options.SetAutoMapLocations(true); shaderc_shader_kind kind = isVertex ? shaderc_vertex_shader : shaderc_fragment_shader; auto result = compiler.CompileGlslToSpv(source, kind, label.c_str(), options);