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

Generated SPIR-V with -fvk-use-scalar-layout flag using DirectxShaderCompiler causes validation layer error

I have a fairly simple HLSL shader that is being compiled into SPIR-V using DirectxShaderCompiler. Though, using scalar layout causes validation layer error. I have enabled the VK_EXT_SCALAR_BLOCK_LAYOUT_EXTENSION_NAME extension while creating the…
Tunti
  • 79
  • 6
1
vote
0 answers

Can an OpenCL .cl file compiled to SPIR-V be cross-compiled to Metal?

For context, I am researching upgrades into our OpenCL code at work as we are quite far behind current spec. The team I work in develops on all three of the major OSes and as far as I can tell Apple doesn't support past OpenCL 1.2 on any of their…
1
vote
0 answers

How to map shader inputs at compile time

I am using the following preprocessor hack // shader_descriptor.hpp #ifdef __cplusplus #include "./shader_source.hpp" #include "engine/utils/vec_t.hpp" #include #include #define…
user877329
  • 6,717
  • 8
  • 46
  • 88
1
vote
1 answer

Is there way to force SPIR-V assembly function to accept both Private and Function storage class arrays?

I am in the process of writing a binary processing module for SPIR-V shaders to fix alignment issues with float4x3[6] matrices because of driver bugs. Right now i have: injected necessary appropriate OpTypes and OpTypePointers. processed the binary…
wild-ptr
  • 100
  • 6
1
vote
1 answer

GLSL produced by SPIRV-cross from SPIR-V breaks std140 rules?

I've put my snippet HLSL code here: https://shader-playground.timjones.io/d9011ef7826a68ed93394792c2edb732 I compile HLSL with DXC to SPIR-V and then use SPIRV-Cross to get the GLSL code. The GLSL constant buffer is tagged with std140 and it…
matoek
  • 21
  • 2
1
vote
1 answer

How to place files next to a target's file location using CMake?

I want to automatically build GLSL shaders to SPIR-V and then copy them to the location of an executable target using CMake. I created the following function for this purpose: function(target_shaders target_name paths_in) set(paths_out "") …
janekb04
  • 4,304
  • 2
  • 20
  • 51
1
vote
1 answer

shader value conversion error when passing value between vertex and fragment shader

I have the following fragment and vertex shader. Vertex: #version 450 layout(location = 0) in vec2 Position; layout(location = 1) in vec4 Color; layout(location = 0) out vec2 fPosition; void main() { gl_Position =…
FutureCake
  • 2,614
  • 3
  • 27
  • 70
1
vote
1 answer

Determine if input attachment is valid within shader

For fragment shaders, it's possible to set color attachment indexes to VK_ATTACHMENT_UNUSED (from the C/C++ API); in that case, writes to those attachments are discarded. This is nice because it allows us to write shaders that unconditionally write…
Dess
  • 2,064
  • 19
  • 35
1
vote
0 answers

To what does SPIR-V get compiled to?

SPIR-V -???-> GPU native https://www.khronos.org/assets/uploads/developers/library/2016-vulkan-devday-uk/3-Intro-to-spir-v-shaders.pdf Mentioned it's a "IHV Compiler" but I can't figure out what that is. I presume it's a vendor (Nvidia/AMD/intel)…
Ron
  • 73
  • 1
  • 4
1
vote
1 answer

is there some method to solve macros in glsl for vulkan

Many GLSL programs use macros #ifdef #else #endif to solve different configurations, is there some elegant method to solve this issue when vulkan build pipeline layout and descriptor set?
yewei
  • 241
  • 2
  • 9
1
vote
1 answer

Specifying push constant block offset in HLSL

I am trying to write a Vulkan renderer, I use glslangValidator with HLSL for shaders and am trying to implement push constants. [[vk::push_constant]] cbuffer cbFragment { float4 imageColor; float4 aaaa; }; [[vk::push_constant]] cbuffer…
Salvage
  • 448
  • 1
  • 4
  • 13
1
vote
1 answer

Using SPIRV-Reflect, how do I know that two descriptor bindings from different shaders are actually referring to the same buffer?

I have a vertex and a fragment shader, written in HLSL, which I compile into a SPIR-V binary using the DirectX Shader Compiler. They both use a common cbuffer (which I want to treat as a uniform buffer) ubo. In order to construct a suitable…
0xbadf00d
  • 17,405
  • 15
  • 67
  • 107
1
vote
1 answer

Using Vulkan + OpenXR, getting strange transparency results on quest (not present in PCVR)

The long story short is that alpha values are behaving very strangely: transitioning reasonably between 1.0 to 0.5, but from 0.5 to 0.0 transitioning from half-opacity-{color} to opaque-black. ^ this is my font renderer (captured from quest beamed…
Phildo
  • 986
  • 2
  • 20
  • 36
1
vote
0 answers

_pdep_u32 in GLSL / HLSL / SPIR-V

I need to interleave* the bits of three unsigned integers in a GLSL program that will be compiled to SPIR-V. In C, I would use the intrinsic _pdep_u32 but I can't find something like that in the OpenGL reference. Does it exist with some other name?…
Marcel Pi
  • 63
  • 1
  • 7
1
vote
1 answer

Vulkan; Get list of uniforms & attribs from SPIR-V shader

Looking for a Vulkan alternative for this; In OpenGL is there a way to get a list of all uniforms & attribs used by a shader program?
Foxie
  • 117
  • 1
  • 7