Questions tagged [spir-v]

SPIR-V is an intermediate representation language designed by the Khronos Group for use by OpenCL (2.0+), OpenGL (4.6+), and Vulkan (all versions). Do not use this tag for questions about SPIR, the earlier standard used with OpenCL before 2.0.

SPIR-V (Standard, Portable, Intermediate Representation-V) is an intermediate representation language for parallel compute and graphics programs. It is intended to be a target for higher-level languages to be compiled into, and is consumed by compute/graphics APIs like OpenCL, OpenGL, and Vulkan.

For Vulkan, SPIR-V is the only option for providing shaders (though there is an extension to directly send a version of GLSL to the Vulkan compiler, it is not widely implemented). OpenGL supports SPIR-V only in version 4.6 (and as an extension). OpenCL 2.0 and above support versions of SPIR-V.

The current version of SPIR-V is 1.3.

Note that SPIR-V is quite distinct from the older SPIR. SPIR was just a way of translating OpenCL C into LLVM's IR language.

102 questions
1
vote
0 answers

Why doesn't Vulkan recognize my SPIR-V shaders?

I'm writing a simple Vulkan application to get familiar with the API. When I call vkCreateGraphicsPipelines my program prints "LLVM ERROR: Invalid SPIR-V magic number" to stderr and exits. The SPIR-V spec…
1
vote
0 answers

LINK error while i want to link glslang and SPIRV

I want to use glslang and SPIRV libraries for online glsl conversion and spirv generation, i was able to generate the project files through cmake and i was able to successfully Build the project glslang.sln, the building process yielded all the…
BulBul
  • 1,159
  • 3
  • 24
  • 37
1
vote
1 answer

One Particle too much: GL_INVALID_VALUE error generated. does not meet minimum alignment requirements for shader storage buffers

I get a strange error in my particle system. I set the size of my buffers dynamically and I can change the number of my particles like I want. I am playing with numbers like 30k, 40k and everything in between. The maximum is reached with 40800...…
Allwo
  • 225
  • 2
  • 10
1
vote
1 answer

No alpha blending working for me in OpenGL 4.6

I am working on a particle system using OpenGL and version 460 shaders that are compiled to SPIR-V. My particles are based on PNG textures with alpha and it's actually pretty straight forward, I have done it on earlier OpenGL versions before.…
Allwo
  • 225
  • 2
  • 10
1
vote
1 answer

Why won't my GLSL program link when one shader is optimized and the other is not?

I'm using a shader toolchain where I start with GLSL, compile it to SPIRV, optimize the SPIRV, and then use spirv-cross to generate optimized GLSL. This is working well for the most part. However, I have a mechanism whereby user generate snippets…
Jherico
  • 28,584
  • 8
  • 61
  • 87
1
vote
1 answer

What are the alignment rules for a dynamic arrays in SPIR-V with std430?

The spec says [140] An array has a base alignment equal to the base alignment of its element type, rounded up to a multiple of 16. .... [430] except for array and structure base alignment which do not need to be rounded up to a multiple of…
Maik Klein
  • 15,548
  • 27
  • 101
  • 197
1
vote
0 answers

loading SPIR-V in OpenGL fails

I am using Ubuntu 16.4 with NVIDIA driver 384.111 and I have a similar problem to this one. I compiled a minimal GLSL vertex shader (one input and an empty main function) to SPIR-V the same way as described in the linked discussion. When I load and…
Wobak
  • 11
  • 4
1
vote
1 answer

Why does SPIR-V use a "4 byte" code, or "Word code"?

According to the SPIR-V 1.3 specification, as I understand it, all instructions are segmented in 4 byte words. This is different from traditional byte code IR languages like Pythons byte code and Java's JVM bytecode, which if I understand correctly…
Krupip
  • 4,404
  • 2
  • 32
  • 54
1
vote
0 answers

SPIR-V compiler error when trying to use uniform struct as function argument

#version 400 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_shading_language_420pack : enable layout(location = 0) out vec4 fs_color; struct Test { float value; }; layout(std140,set = 0,binding = 0) uniform UTest { …
Silverlan
  • 2,783
  • 3
  • 31
  • 66
1
vote
2 answers

Modifying a HLSL shader to work in Vulkan, do I have to separate textures/samplers?

I'm modifying a HLSL shader used in D3D12 to compile to SPIR-V because I want to use the same shader code in Vulkan. Here's the shader: #if !VULKAN #define layout(a) #else #define register(a) blank #endif struct VSOutput { float4 pos :…
SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
1
vote
1 answer

glslang is unable to parse built-ins

Here is my code: bool ParseShader(glslang::TShader* p_shader) { EShMessages messages = (EShMessages)(EShMsgSpvRules | EShMsgVulkanRules); TBuiltInResource resources; InitializeResources(resources); if (!p_shader->parse(&resources,…
bachelor
  • 63
  • 5
1
vote
1 answer

Which types in SPIR-V are not allowed to be type aliases?

Non-structure types (scalars, vectors, arrays, etc.) with the same operand parameterization cannot be type aliases. For non-structures, two type s match if-and-only-if the types match. What exactly does this mean? #version 400 void…
Maik Klein
  • 15,548
  • 27
  • 101
  • 197
0
votes
1 answer

Failing to specialize OpenGl shader that uses spirv

I am trying to compile glsl shader into spirv using glslang, compilation process works fine. but for some reason glSpecializeShader crashes the whole application, I looked into GL_COMPILE_STATUS of glShaderBinary vertex shader and looks like it…
maksasj
  • 13
  • 3
0
votes
0 answers

Android Vulkan ClipDistance crash on Pixel6&7

I have a crash on Android(Pixel6 & 7) when creating a Vulkan pipeline using a vertex shader with a ClipDistance. This occurs on an empty project. Example crash info dump is below.. Cause: null pointer dereference x0 00000072e8a10be8 x1 …
Ryan
  • 1
  • 1
0
votes
1 answer

CL_INVALID_KERNEL_NAME with SPIRV programs created with clang on Intel

I'm trying to implement offline compilation of my OpenCL compute shaders for a library I'm researching in preparation for its development using SPIRV. The best way to do this seems to be using clang and LLVM, and I've been following the guide from…
Jon Rurka
  • 79
  • 2
  • 9