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

HLSL compiled with shaderc and introspected with SPIRV-cross has wrong size?

I am compiling this shader struct VSInput { [[vk::location(0)]] float2 Pos : POSITION0; [[vk::location(1)]] float3 Color : COLOR0; }; struct UBO { float2x2 transform; }; cbuffer ubo : register(b0) { UBO ubo; } struct VSOutput { float4 Pos…
Makogan
  • 8,208
  • 7
  • 44
  • 112
0
votes
0 answers

GLSL to SPIR-V using VS2019 Cusotm build step

I'm looking to take my GLSL shader files which have the extension .vert and .frag and have them compile to SPIR-V format after the project build. Currently I have been using a .bat file which compiles all my GLSL files to SPIR-V however, hitting the…
Krellex
  • 613
  • 2
  • 7
  • 20
0
votes
1 answer

Spir-V and OpenGL: Entry points and pipeline stages

Is there a built-in way in OpenGL to find which entry points and shader stages a compiled spir-v shader supports, or do I have to use a separate library like https://github.com/KhronosGroup/SPIRV-Reflect ? Edit: I ended up using SPIRV-Reflect: My…
user1387
  • 187
  • 10
0
votes
1 answer

Clarification on what exactly constitutes as a continue target in Vulkan SPIR-V

I'm trying to understand the SPIR-V spec, understanding for loops for example. In the beginning of the 1.6 revision 2 spec, the following example (taking only part of it for consisveness) for (int i = 0; i < 4; ++i) color *= multiplier; turns…
Krupip
  • 4,404
  • 2
  • 32
  • 54
0
votes
0 answers

How to have a structure of buffer_reference types in Vulkan GLSL?

I'm using shaderc that comes VulkanSDK-1.3.224.1. Attempting to compile the following when added to any of my shaders: #extension GL_EXT_scalar_block_layout: enable #extension GL_EXT_buffer_reference2 : enable #extension…
Krupip
  • 4,404
  • 2
  • 32
  • 54
0
votes
0 answers

Validation warning about SPIR-V Capability

I'm using Vulkan for heavy GPU computations and in some kernels I'm applying subgroup arithmetic operations. In order to use this, I've included necessary extensions in the kernel: #extension GL_KHR_shader_subgroup_arithmetic: enable #extension…
Eugene Alexeev
  • 1,152
  • 12
  • 32
0
votes
0 answers

Generating OpVectorShuffle instead of OpCompositeConstruct

According to the SPIR-V specification the opcode OpVectorShuffle seems to be versatile enough to take two input vectors (and a list of constants). When trying to combine two vectors / extract unaligned subsequence from two vectors i.e. #version 450 …
Aki Suihkonen
  • 19,144
  • 1
  • 36
  • 57
0
votes
1 answer

How to disable built-in HLSL compiler for Visual Studio 2019

The topic may sound like a duplicate question but the problem in my case is that I don't have any HLSL files included in the project. Thus, I can not manually disable/change the dxc compiler. Though, I have added a pre-build command using CMake to…
Tunti
  • 79
  • 6
0
votes
1 answer

Can not use Vulkan Subgroup operations in Android Studio

I'm writing a Vulkan compute shader in Android studio and launching it on Android phone. The problem I'm experiencing is next - I can not use any subgroup operations like subgroupAdd and subgroupElect. When I'm trying to use these functions I have…
Eugene Alexeev
  • 1,152
  • 12
  • 32
0
votes
1 answer

when do i need GL_EXT_nonuniform_qualifier?

I want to compile the following code into SPIR-V #version 450 core #define BATCH_ID (PushConstants.Indices.x >> 16) #define MATERIAL_ID (PushConstants.Indices.x & 0xFFFF) layout (push_constant) uniform constants { ivec2 Indices; }…
Samwise
  • 86
  • 6
0
votes
1 answer

How to copy SPIR-V Private storage-qualified matrix array into Function storage-qualified matrix array?

I am fighting with driver bug, and long story short i have created OpVariables with proper data in invocation-level global memory, aka Private storage-qualified OpVariable of type float4x3[6]. Now, i need this data converted to Function storage…
wild-ptr
  • 100
  • 6
0
votes
1 answer

vkCreateComputePipelines takes too long

I encountered a strange problem with compiling Vulkan compute shader. I have this shader (which is not even all that complex) #version 450 #extension GL_GOOGLE_include_directive : enable //#extension GL_EXT_debug_printf : enable #extension…
alagris
  • 1,838
  • 16
  • 31
0
votes
0 answers

What are The SPIR-V Capability (Geometry) Requirements

I have 2 framebuffers. First, one is layered. And renders HDR image to Cubemap. In this Renderpass Geometry Shader is used. Debug layer gives me the following error message. [VAL][VUID-VkShaderModuleCreateInfo-pCode-01091] Validation Error: […
aramok
  • 35
  • 1
  • 1
  • 6
0
votes
1 answer

How to Use Vulkan SPIR-V Data Formats in GLSL

SPIR-V allows for very verbose data formats. GLSL has only basic data types (Chapter 4) that do not specify bit length. As far as I am aware the most convenient way to program shaders for Vulkan is to program them in GLSL, then use the Vulkan SDK…
Ryoku
  • 397
  • 2
  • 16
0
votes
1 answer

Is there an OS-independent way to transpile OpenCL kernels into SPIR-V?

I've found a guide on Offline Compilation of OpenCL Kernels into SPIR-V Using Open Source Tooling for clang but I cannot find an official way to do this with other compilers. Is there a way to transpile an OpenCL kernel into SPIR-V using CMake? If…
Charlie
  • 826
  • 1
  • 11
  • 27