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
3
votes
1 answer

How could I simply compile GLSL to SPIR-V?

So I need to get the SPIR-V code of some GLSL Every resource I can find on the topic involves setting up a whole enviroment for graphics and more. In the simplest case when I have some GLSL code and I want to get the SPIR-V code, what would be the…
Jonathan Woollett-light
  • 2,813
  • 5
  • 30
  • 58
3
votes
2 answers

How to compile HLSL shaders with Vulkan?

I'm current learning Vulkan API, it's time to create pipeline, I chose HLSL because in the future I want to reuse shaders in DirectX and when I get an RTX GPU I intend to bring ray tracing, I'm new in HLSL, I wrote a simple vertex shader: float4…
Ives TI
  • 137
  • 2
  • 9
3
votes
1 answer

Compiling GLSL to corresponding Spir V for use in a Vulkan Application

I'm using Jonno Robson's Vulkan code base from github found here: Vulkan-Terrain-Generator as a guide and or learning reference to better understand Vulkan. I don't have any issues with the source code itself, but my question or concern pertains to…
Francis Cugler
  • 7,788
  • 2
  • 28
  • 59
3
votes
1 answer

Why won't Cmake build my vulkan/spirv shaders?

I am currently working on learning Vulkan by following this website. I am currently at the point where I need to compile my GLSL shaders to SPIR-V. Unlike the website, which just creates a separate compile script for shaders (e.g. with bash), I want…
john01dav
  • 1,842
  • 1
  • 21
  • 40
3
votes
2 answers

SPIR-V shader causing validation errors at runtime

I have a compute shader: #version 450 #extension GL_ARB_separate_shader_objects : enable #extension GL_ARB_gpu_shader_int64 : enable layout(local_size_x_id = 0) in; layout(set = 0, binding = 0) buffer Foo { u64vec2[256] scratchpad; }…
vazgriz
  • 33
  • 6
3
votes
2 answers

What steps need to be taken to implement OpenCL on a device?

Lets say I have a device which, while it has the capability to support, does not currently support OpenCL. I have the ISA, the hardware design documents and a lot of other documentation. My system which the device is located on currently has C…
Krupip
  • 4,404
  • 2
  • 32
  • 54
3
votes
1 answer

How to use OpenGL ARB_gl_spirv extension?

I would like to compile my GLSL shaders to SPIR-V binaries, and use that in my OpenGL project. I've found glslang, using I can compile the glsl shaders to spir-v. But I haven't found any tutorials about how to use it in my C++ project. How to load…
Iter Ator
  • 8,226
  • 20
  • 73
  • 164
3
votes
0 answers

Loading SPIRV binary shader fails

In my program I tried to load precompiled binary shaders with the example code from Sasha Willems (https://github.com/SaschaWillems/openglcpp/blob/master/SPIRVShader/main.cpp): bool loadBinaryShader(const char *fileName, GLuint stage, GLuint…
woidler
  • 59
  • 6
3
votes
1 answer

Is it possible to use bindless textures in SPIR-V shaders on OpenGL 4.5?

I'm trying to compile the following shader using LunarG Vulkan SDK 1.0.37.0 on Windows: #version 450 core #extension GL_ARB_bindless_texture : require layout(std140, binding=1) uniform LightUbo { vec3 lightDirectionVS; }; layout(std140,…
SurvivalMachine
  • 7,946
  • 15
  • 57
  • 87
3
votes
0 answers

Does OpenCL2.2 SPIRV compiler not checking invalid code

I just used the reference clang implementation of OpenCL C++ to compile the source at page 13 of the specs: #include #include #include half bar(half a) { //ok: half built-in type passed by…
abergmeier
  • 13,224
  • 13
  • 64
  • 120
3
votes
1 answer

Is there a way to get attributes and uniforms in Vulkan after the vkCreateShaderModule?

Like in opengl we can do glGetActiveAttrib and glGetActiveUniform.
abhijit jagdale
  • 609
  • 2
  • 8
  • 21
2
votes
1 answer

Invalid entry point for shader when using HLSL->SPIR-V->OpenGL

I am trying to implement a system so that I can use HLSL in my OpenGL application, since it can be compiled to SPIR-V, and SPIR-V can be translated to something that works with e.g DirectX. However, I receive an error when specializing the…
khhs
  • 21
  • 3
2
votes
2 answers

what is the most fundamental difference between SPIR-V and LLVM-IR?

Spir-v and LLVM IR have the same granularity and can be converted to each other. May I ask why SPir-V is still so popular with LLVM IR? The fundamental difference between the two?
eawang
  • 21
  • 1
2
votes
1 answer

Is there a good HLSL to SPIR-V compiler?

I'm writing a voxel engine in C++, and I'm implementing a Vulkan renderer. I've decided to write shaders in HLSL, and translate them via SPIRV-Cross. However, this brings me to a problem - glslang's HLSL compiler does not allow samplers. For…
YodaSoda1219
  • 23
  • 1
  • 4
2
votes
1 answer

How to convert uint64_t to sampler2D?

I want to use bindless textures, but spirv does not support it. I found here: https://www.khronos.org/opengl/wiki/Bindless_Texture that uint64_t can be converted to a sampler2D. uint64_t values can be converted to any sampler or image type using…
BrodaJarek3
  • 311
  • 1
  • 9