{"record":{"id":"0d9272b25c795821","repo":"stride3d/stride","slug":"cross-compilerbuildcombinedimagesamplers-compiler-could-not","errorCode":null,"errorMessage":"{cross.CompilerBuildCombinedImageSamplers(compiler)} : Could not enable combined image samplers","messagePattern":"(.+?) : Could not enable combined image samplers","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs","lineNumber":157,"sourceCode":"            for (uint i = 0; i < resourcesCount; ++i)\n            {\n                if (cross.CompilerHasDecoration(compiler, resourcesList[i].Id, Decoration.Location) != 0\n                    && cross.CompilerHasDecoration(compiler, resourcesList[i].Id, Decoration.UserSemantic) != 0)\n                {\n                    vertexInputRemap[vertexInputRemapCount].Location = cross.CompilerGetDecoration(compiler, resourcesList[i].Id, Decoration.Location);\n                    vertexInputRemap[vertexInputRemapCount].Semantic = cross.CompilerGetDecorationString(compiler, resourcesList[i].Id, Decoration.UserSemantic);\n                    vertexInputRemapCount++;\n                }\n            }\n            cross.CompilerHlslAddVertexAttributeRemap(compiler, vertexInputRemap, (nuint)vertexInputRemapCount);\n\n            cross.CompilerHlslSetResourceBindingFlags(compiler, 0);\n        }\n\n        if (backend == Backend.Glsl)\n        {\n            if (cross.CompilerBuildCombinedImageSamplers(compiler) != Result.Success)\n                throw new Exception($\"{cross.CompilerBuildCombinedImageSamplers(compiler)} : Could not enable combined image samplers\");\n\n            nuint numSamplers = 0;\n            CombinedImageSampler* combinedImageSamplers = null;\n            if (cross.CompilerGetCombinedImageSamplers(compiler, &combinedImageSamplers, ref numSamplers) != Result.Success)\n                throw new Exception($\"{cross.CompilerGetCombinedImageSamplers(compiler, &combinedImageSamplers, ref numSamplers)}\");\n\n            for (uint i = 0; i < numSamplers; ++i)\n            {\n                var textureName = cross.CompilerGetNameS(compiler, combinedImageSamplers[i].ImageId);\n                var samplerName = cross.CompilerGetNameS(compiler, combinedImageSamplers[i].SamplerId);\n                cross.CompilerSetName(compiler, combinedImageSamplers[i].CombinedId, $\"SPIRV_Cross_Combined{textureName}{samplerName}\");\n            }\n        }\n\n        if (cross.CompilerCompile(compiler, &translated) != Result.Success)\n            throw new Exception($\"{cross.CompilerCompile(compiler, &translated)} : could not compile code\");\n\n        translatedCode = SilkMarshal.PtrToString((nint)translated);","sourceCodeStart":139,"sourceCodeEnd":175,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs#L139-L175","documentation":"Translate throws this when CompilerBuildCombinedImageSamplers fails while translating to GLSL. GLSL combines separate texture and sampler objects into combined sampler2D-style variables; this call builds that combined list and fails rarely — usually on internal spirv-cross state errors or an IR that the combination pass cannot process.","triggerScenarios":"Calling Translate(Backend.Glsl, ...) on a module whose separate image/sampler declarations cannot be combined (degenerate IR, reflection data missing because a prior step failed, or a spirv-cross version bug in the combination pass).","commonSituations":"GLSL translation of SPIR-V produced by unusual toolchains; older spirv-cross builds with known combined-sampler bugs; translation attempted after a partially failed pipeline left the compiler in a bad state.","solutions":["Update the native spirv-cross binary — several combined-image-sampler bugs were fixed upstream","Check error-callback log output preceding the throw","Validate the SPIR-V module with spirv-val","Confirm resource reflection succeeded (CompilerCreateShaderResources) before the GLSL branch","Fall back to Backend.Hlsl to determine if the failure is GLSL-specific"],"exampleFix":"// before\nvar glsl = translator.Translate(Backend.Glsl, entryPoint);\n// after\ntry { var glsl = translator.Translate(Backend.Glsl, entryPoint); }\ncatch (Exception ex) when (ex.Message.Contains(\"combined image samplers\"))\n{ Log.Error($\"GLSL combined-sampler pass failed: {ex.Message}\"); throw; }","handlingStrategy":"fallback","validationCode":"if (backend == Backend.Glsl) { /* ensure shader only uses features expressible with combined samplers */ }","typeGuard":null,"tryCatchPattern":"try { var glsl = translator.Translate(Backend.Glsl, entryPoint); } catch (Exception ex) when (ex.Message.Contains(\"combined image samplers\")) { Log.Warn(\"GLSL combined-sampler pass failed; falling back to HLSL\"); var src = translator.Translate(Backend.Hlsl, entryPoint); }","preventionTips":["Update spirv-cross for combined-sampler fixes","Test GLSL translation of every shader in CI","Confirm resource reflection succeeds before the GLSL branch","Prefer separate-sampler-friendly shader layouts where possible"],"tags":["spirv-cross","glsl","textures","samplers"],"backgroundTag":"internal-invariant-violation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}