Last active
January 21, 2026 21:28
-
-
Save petar-andrejic/51fad6cae71f1ac523fee38200447019 to your computer and use it in GitHub Desktop.
Slang overlapping push constants issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| slangc -target spirv -profile spirv_1_4 -emit-spirv-directly -fvk-use-c-layout -reflection-json quad.json quad.slang |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| OpCapability DrawParameters | |
| OpCapability PhysicalStorageBufferAddresses | |
| OpCapability RuntimeDescriptorArray | |
| OpCapability Shader | |
| OpExtension "SPV_KHR_physical_storage_buffer" | |
| OpExtension "SPV_EXT_descriptor_indexing" | |
| OpMemoryModel PhysicalStorageBuffer64 GLSL450 | |
| OpEntryPoint Vertex %2 "vertex_main" %27 %50 %54 %14 %16 | |
| OpEntryPoint Fragment %57 "fragment_main" %71 %80 %64 %89 %61 | |
| OpExecutionMode %57 OriginUpperLeft | |
| OpSource Slang 1 | |
| OpName %23 "EntryPointParams_c" | |
| OpMemberName %23 0 "vertices" | |
| OpName %27 "entryPointParams" | |
| OpName %54 "entryPointParam_vertex_main.uv" | |
| OpName %2 "vertex_main" | |
| OpName %61 "v_out.uv" | |
| OpName %62 "EntryPointParams_c" | |
| OpMemberName %62 0 "tex_idx" | |
| OpMemberName %62 1 "sampler_idx" | |
| OpName %64 "entryPointParams" | |
| OpName %71 "textures" | |
| OpName %80 "samplers" | |
| OpName %86 "sampledImage" | |
| OpName %87 "sampled" | |
| OpName %89 "entryPointParam_fragment_main" | |
| OpName %57 "fragment_main" | |
| OpName %24 "Vertex_c" | |
| OpMemberName %24 0 "position" | |
| OpMemberName %24 1 "uv" | |
| OpDecorate %14 BuiltIn VertexIndex | |
| OpDecorate %16 BuiltIn BaseVertex | |
| OpDecorate %25 ArrayStride 16 | |
| OpDecorate %23 Block | |
| OpMemberDecorate %23 0 Offset 0 | |
| OpDecorate %32 ArrayStride 8 | |
| OpDecorate %50 BuiltIn Position | |
| OpDecorate %54 Location 0 | |
| OpDecorate %61 Location 0 | |
| OpDecorate %62 Block | |
| OpMemberDecorate %62 0 Offset 0 | |
| OpMemberDecorate %62 1 Offset 4 | |
| OpDecorate %71 Binding 0 | |
| OpDecorate %71 DescriptorSet 0 | |
| OpDecorate %80 Binding 1 | |
| OpDecorate %80 DescriptorSet 0 | |
| OpDecorate %89 Location 0 | |
| OpMemberDecorate %24 0 Offset 0 | |
| OpMemberDecorate %24 1 Offset 8 | |
| %1 = OpTypeVoid | |
| %3 = OpTypeFunction %1 | |
| %6 = OpTypeFloat 32 | |
| %7 = OpTypeVector %6 4 | |
| %8 = OpTypeVector %6 2 | |
| %11 = OpTypeInt 32 1 | |
| %13 = OpTypePointer Input %11 | |
| %18 = OpTypeInt 32 0 | |
| %20 = OpConstant %11 0 | |
| OpTypeForwardPointer %25 PhysicalStorageBuffer | |
| %23 = OpTypeStruct %25 | |
| %26 = OpTypePointer PushConstant %23 | |
| %28 = OpTypePointer PushConstant %25 | |
| %32 = OpTypePointer PhysicalStorageBuffer %8 | |
| %36 = OpConstant %6 0.0 | |
| %37 = OpConstant %6 1.0 | |
| %39 = OpConstant %11 1 | |
| %49 = OpTypePointer Output %7 | |
| %53 = OpTypePointer Output %8 | |
| %60 = OpTypePointer Input %8 | |
| %62 = OpTypeStruct %18 %18 | |
| %63 = OpTypePointer PushConstant %62 | |
| %65 = OpTypePointer PushConstant %18 | |
| %69 = OpTypeImage %6 2D 2 0 0 1 Unknown | |
| %68 = OpTypeRuntimeArray %69 | |
| %70 = OpTypePointer UniformConstant %68 | |
| %72 = OpTypePointer UniformConstant %69 | |
| %78 = OpTypeSampler | |
| %77 = OpTypeRuntimeArray %78 | |
| %79 = OpTypePointer UniformConstant %77 | |
| %81 = OpTypePointer UniformConstant %78 | |
| %85 = OpTypeSampledImage %69 | |
| %24 = OpTypeStruct %8 %8 | |
| %25 = OpTypePointer PhysicalStorageBuffer %24 | |
| %14 = OpVariable %13 Input | |
| %16 = OpVariable %13 Input | |
| %27 = OpVariable %26 PushConstant | |
| %50 = OpVariable %49 Output | |
| %54 = OpVariable %53 Output | |
| %61 = OpVariable %60 Input | |
| %64 = OpVariable %63 PushConstant | |
| %71 = OpVariable %70 UniformConstant | |
| %80 = OpVariable %79 UniformConstant | |
| %89 = OpVariable %49 Output | |
| %2 = OpFunction %1 None %3 | |
| %4 = OpLabel | |
| %12 = OpLoad %11 %14 | |
| %15 = OpLoad %11 %16 | |
| %17 = OpISub %11 %12 %15 | |
| %19 = OpBitcast %18 %17 | |
| %29 = OpAccessChain %28 %27 %20 | |
| %30 = OpLoad %25 %29 | |
| %31 = OpPtrAccessChain %25 %30 %19 | |
| %33 = OpAccessChain %32 %31 %20 | |
| %34 = OpLoad %8 %33 Aligned 4 | |
| %35 = OpCompositeConstruct %7 %34 %36 %37 | |
| %42 = OpLoad %25 %29 | |
| %43 = OpPtrAccessChain %25 %42 %19 | |
| %44 = OpAccessChain %32 %43 %39 | |
| %45 = OpLoad %8 %44 Aligned 4 | |
| OpStore %50 %35 | |
| OpStore %54 %45 | |
| OpReturn | |
| OpFunctionEnd | |
| %57 = OpFunction %1 None %3 | |
| %58 = OpLabel | |
| %59 = OpLoad %8 %61 | |
| %66 = OpAccessChain %65 %64 %20 | |
| %67 = OpLoad %18 %66 | |
| %73 = OpAccessChain %72 %71 %67 | |
| %75 = OpAccessChain %65 %64 %39 | |
| %76 = OpLoad %18 %75 | |
| %82 = OpAccessChain %81 %80 %76 | |
| %83 = OpLoad %69 %73 | |
| %84 = OpLoad %78 %82 | |
| %86 = OpSampledImage %85 %83 %84 | |
| %87 = OpImageSampleImplicitLod %7 %86 %59 None | |
| OpStore %89 %87 | |
| OpReturn | |
| OpFunctionEnd |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "parameters": [ | |
| { | |
| "name": "textures", | |
| "binding": {"kind": "descriptorTableSlot", "index": 0}, | |
| "type": { | |
| "kind": "array", | |
| "elementCount": 0, | |
| "elementType": { | |
| "kind": "resource", | |
| "baseShape": "texture2D", | |
| "resultType": { | |
| "kind": "vector", | |
| "elementCount": 4, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| { | |
| "name": "samplers", | |
| "binding": {"kind": "descriptorTableSlot", "index": 1}, | |
| "type": { | |
| "kind": "array", | |
| "elementCount": 0, | |
| "elementType": { | |
| "kind": "samplerState" | |
| } | |
| } | |
| } | |
| ], | |
| "entryPoints": [ | |
| { | |
| "name": "vertex_main", | |
| "stage": "vertex", | |
| "parameters": [ | |
| { | |
| "name": "vid", | |
| "semanticName": "SV_VERTEXID", | |
| "type": { | |
| "kind": "scalar", | |
| "scalarType": "uint32" | |
| } | |
| }, | |
| { | |
| "name": "vertices", | |
| "binding": {"kind": "uniform", "offset": 0, "size": 8, "elementStride": 0}, | |
| "type": { | |
| "kind": "pointer", | |
| "valueType": "Vertex" | |
| } | |
| } | |
| ], | |
| "result": { | |
| "stage": "vertex", | |
| "binding": {"kind": "varyingOutput", "index": 0}, | |
| "type": { | |
| "kind": "struct", | |
| "name": "VertexOutput", | |
| "fields": [ | |
| { | |
| "name": "sv_position", | |
| "type": { | |
| "kind": "vector", | |
| "elementCount": 4, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| }, | |
| "semanticName": "SV_POSITION" | |
| }, | |
| { | |
| "name": "uv", | |
| "type": { | |
| "kind": "vector", | |
| "elementCount": 2, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| }, | |
| "stage": "vertex", | |
| "binding": {"kind": "varyingOutput", "index": 0} | |
| } | |
| ] | |
| } | |
| }, | |
| "bindings": [ | |
| { | |
| "name": "textures", | |
| "binding": {"kind": "descriptorTableSlot", "index": 0} | |
| }, | |
| { | |
| "name": "samplers", | |
| "binding": {"kind": "descriptorTableSlot", "index": 1} | |
| } | |
| ] | |
| }, | |
| { | |
| "name": "fragment_main", | |
| "stage": "fragment", | |
| "parameters": [ | |
| { | |
| "name": "v_out", | |
| "stage": "fragment", | |
| "binding": {"kind": "varyingInput", "index": 0}, | |
| "type": { | |
| "kind": "struct", | |
| "name": "VertexOutput", | |
| "fields": [ | |
| { | |
| "name": "sv_position", | |
| "type": { | |
| "kind": "vector", | |
| "elementCount": 4, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| }, | |
| "semanticName": "SV_POSITION" | |
| }, | |
| { | |
| "name": "uv", | |
| "type": { | |
| "kind": "vector", | |
| "elementCount": 2, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| }, | |
| "stage": "fragment", | |
| "binding": {"kind": "varyingInput", "index": 0} | |
| } | |
| ] | |
| } | |
| }, | |
| { | |
| "name": "tex_idx", | |
| "binding": {"kind": "uniform", "offset": 0, "size": 4, "elementStride": 0}, | |
| "type": { | |
| "kind": "scalar", | |
| "scalarType": "uint32" | |
| } | |
| }, | |
| { | |
| "name": "sampler_idx", | |
| "binding": {"kind": "uniform", "offset": 4, "size": 4, "elementStride": 0}, | |
| "type": { | |
| "kind": "scalar", | |
| "scalarType": "uint32" | |
| } | |
| } | |
| ], | |
| "result": { | |
| "stage": "fragment", | |
| "binding": {"kind": "varyingOutput", "index": 0}, | |
| "semanticName": "SV_TARGET", | |
| "type": { | |
| "kind": "vector", | |
| "elementCount": 4, | |
| "elementType": { | |
| "kind": "scalar", | |
| "scalarType": "float32" | |
| } | |
| } | |
| }, | |
| "bindings": [ | |
| { | |
| "name": "textures", | |
| "binding": {"kind": "descriptorTableSlot", "index": 0} | |
| }, | |
| { | |
| "name": "samplers", | |
| "binding": {"kind": "descriptorTableSlot", "index": 1} | |
| } | |
| ] | |
| } | |
| ] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| uniform Texture2D textures[]; | |
| uniform SamplerState samplers[]; | |
| struct Vertex { | |
| float2 position; | |
| float2 uv; | |
| } | |
| struct VertexOutput { | |
| float4 sv_position : SV_Position; | |
| float2 uv; | |
| }; | |
| [shader("vertex")] | |
| VertexOutput vertex_main(uint vid: SV_VertexID, uniform Vertex *vertices) { | |
| VertexOutput v_out; | |
| v_out.sv_position = float4(vertices[vid].position, 0.0, 1.0); | |
| v_out.uv = vertices[vid].uv; | |
| return v_out; | |
| } | |
| [shader("fragment")] | |
| float4 fragment_main(VertexOutput v_out, uniform uint tex_idx, uniform uint sampler_idx) : | |
| SV_Target { | |
| return textures[tex_idx].Sample(samplers[sampler_idx], v_out.uv); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment