{"record":{"id":"398517cd47e87516","repo":"stride3d/stride","slug":"cross-compilergetcombinedimagesamplers-compiler","errorCode":null,"errorMessage":"{cross.CompilerGetCombinedImageSamplers(compiler, &combinedImageSamplers, ref numSamplers)}","messagePattern":"\\{cross\\.CompilerGetCombinedImageSamplers\\(compiler, &combinedImageSamplers, ref numSamplers\\)\\}","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs","lineNumber":162,"sourceCode":"                    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);\n        cross.ContextReleaseAllocations(context);\n        cross.ContextDestroy(context);\n        return translatedCode ?? throw new Exception(\"Could not translate code\");\n    }\n}","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/shaders/Stride.Shaders.Compilers/SpirvTranslator.cs#L144-L180","documentation":"Translate throws this when CompilerGetCombinedImageSamplers fails to retrieve the list of combined image samplers after the combination pass ran for GLSL. The returned pointer and count are unavailable, so the subsequent renaming loop cannot run and translation aborts. The message is the raw call result.","triggerScenarios":"Calling Translate(Backend.Glsl, ...) when the query returns non-success — internal spirv-cross error, compiler state invalid after BuildCombinedImageSamplers, or binding/ABI mismatch between the Silk.NET bindings and the loaded native library.","commonSituations":"Mismatched Silk.NET.SPIRV.Cross binding vs native spirv-cross version (struct ABI changes); spirv-cross built with combined-sampler support disabled; rare native memory failures.","solutions":["Ensure the native spirv-cross binary version matches the Silk.NET.SPIRV.Cross bindings","Check the spirv-cross error-callback log lines before the throw","Re-run with a known-good GLSL shader to isolate environment vs shader cause","Update the native library to the latest release","Verify CompilerBuildCombinedImageSamplers succeeded immediately before (it should have, or 2086 would have thrown first)"],"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(\"CompilerGetCombinedImageSamplers\"))\n{ Log.Error($\"Combined sampler query failed (check spirv-cross native/binding version match): {ex.Message}\"); throw; }","handlingStrategy":"try-catch","validationCode":"// Check native/binding version alignment at startup:\n// typeof(Silk.NET.SPIRV.Cross.Cross).Assembly.GetName().Version vs native spirv-cross build","typeGuard":null,"tryCatchPattern":"try { var glsl = translator.Translate(Backend.Glsl, entryPoint); } catch (Exception ex) when (ex.Message.Contains(\"CompilerGetCombinedImageSamplers\")) { Log.Error($\"Combined-sampler query failed — check native library/binding ABI match: {ex.Message}\"); throw; }","preventionTips":["Upgrade Silk.NET bindings and the native binary together","Smoke-test one GLSL shader at startup to catch ABI mismatches early","Check error-callback logs for native-side detail","Run shader translation tests on every supported platform"],"tags":["spirv-cross","glsl","native-interop","abi-mismatch"],"backgroundTag":"api-request-failed","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"}