Skip to content

Commit

Permalink
Merge pull request KhronosGroup#3079 from gby/GL_ARM_shader_core_buil…
Browse files Browse the repository at this point in the history
…tins

GL_ARM_shader_core_builtins support
  • Loading branch information
greg-lunarg authored Dec 6, 2022
2 parents a7603c1 + 0464ff4 commit e3e8baf
Show file tree
Hide file tree
Showing 18 changed files with 335 additions and 0 deletions.
2 changes: 2 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ genrule(
"SPIRV/GLSL.ext.EXT.h",
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.ext.NV.h",
"SPIRV/GLSL.ext.ARM.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/NonSemanticDebugPrintf.h",
"SPIRV/NonSemanticShaderDebugInfo100.h",
Expand All @@ -154,6 +155,7 @@ genrule(
"include/SPIRV/GLSL.ext.EXT.h",
"include/SPIRV/GLSL.ext.KHR.h",
"include/SPIRV/GLSL.ext.NV.h",
"include/SPIRV/GLSL.ext.ARM.h",
"include/SPIRV/GLSL.std.450.h",
"include/SPIRV/NonSemanticDebugPrintf.h",
"include/SPIRV/NonSemanticShaderDebugInfo100.h",
Expand Down
1 change: 1 addition & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ template("glslang_sources_common") {
"SPIRV/GLSL.ext.EXT.h",
"SPIRV/GLSL.ext.KHR.h",
"SPIRV/GLSL.ext.NV.h",
"SPIRV/GLSL.ext.ARM.h",
"SPIRV/GLSL.std.450.h",
"SPIRV/GlslangToSpv.cpp",
"SPIRV/GlslangToSpv.h",
Expand Down
1 change: 1 addition & 0 deletions SPIRV/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ set(HEADERS
disassemble.h
GLSL.ext.AMD.h
GLSL.ext.NV.h
GLSL.ext.ARM.h
NonSemanticDebugPrintf.h
NonSemanticShaderDebugInfo100.h)

Expand Down
35 changes: 35 additions & 0 deletions SPIRV/GLSL.ext.ARM.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
** Copyright (c) 2022 ARM Limited
**
** Permission is hereby granted, free of charge, to any person obtaining a copy
** of this software and/or associated documentation files (the "Materials"),
** to deal in the Materials without restriction, including without limitation
** the rights to use, copy, modify, merge, publish, distribute, sublicense,
** and/or sell copies of the Materials, and to permit persons to whom the
** Materials are furnished to do so, subject to the following conditions:
**
** The above copyright notice and this permission notice shall be included in
** all copies or substantial portions of the Materials.
**
** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS
** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND
** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/
**
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
** THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
** FROM,OUT OF OR IN CONNECTION WITH THE MATERIALS OR THE USE OR OTHER DEALINGS
** IN THE MATERIALS.
*/

#ifndef GLSLextARM_H
#define GLSLextARM_H

static const int GLSLextARMVersion = 100;
static const int GLSLextARMRevision = 1;

static const char * const E_SPV_ARM_core_builtins = "SPV_ARM_core_builtins";

#endif // #ifndef GLSLextARM_H
23 changes: 23 additions & 0 deletions SPIRV/GlslangToSpv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ namespace spv {
#include "GLSL.ext.EXT.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
#include "NonSemanticDebugPrintf.h"
}

Expand Down Expand Up @@ -1106,6 +1107,28 @@ spv::BuiltIn TGlslangToSpvTraverser::TranslateBuiltInDecoration(glslang::TBuiltI
builder.addExtension(spv::E_SPV_NV_shader_sm_builtins);
builder.addCapability(spv::CapabilityShaderSMBuiltinsNV);
return spv::BuiltInSMIDNV;

// ARM builtins
case glslang::EbvCoreCountARM:
builder.addExtension(spv::E_SPV_ARM_core_builtins);
builder.addCapability(spv::CapabilityCoreBuiltinsARM);
return spv::BuiltInCoreCountARM;
case glslang::EbvCoreIDARM:
builder.addExtension(spv::E_SPV_ARM_core_builtins);
builder.addCapability(spv::CapabilityCoreBuiltinsARM);
return spv::BuiltInCoreIDARM;
case glslang::EbvCoreMaxIDARM:
builder.addExtension(spv::E_SPV_ARM_core_builtins);
builder.addCapability(spv::CapabilityCoreBuiltinsARM);
return spv::BuiltInCoreMaxIDARM;
case glslang::EbvWarpIDARM:
builder.addExtension(spv::E_SPV_ARM_core_builtins);
builder.addCapability(spv::CapabilityCoreBuiltinsARM);
return spv::BuiltInWarpIDARM;
case glslang::EbvWarpMaxIDARM:
builder.addExtension(spv::E_SPV_ARM_core_builtins);
builder.addCapability(spv::CapabilityCoreBuiltinsARM);
return spv::BuiltInWarpMaxIDARM;
#endif

default:
Expand Down
1 change: 1 addition & 0 deletions SPIRV/SpvPostProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ namespace spv {
#include "GLSL.ext.EXT.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
}

namespace spv {
Expand Down
1 change: 1 addition & 0 deletions SPIRV/disassemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace spv {
#include "GLSL.std.450.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
}
}
const char* GlslStd450DebugNames[spv::GLSLstd450Count];
Expand Down
7 changes: 7 additions & 0 deletions SPIRV/doc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ namespace spv {
#include "GLSL.ext.EXT.h"
#include "GLSL.ext.AMD.h"
#include "GLSL.ext.NV.h"
#include "GLSL.ext.ARM.h"
}
}

Expand Down Expand Up @@ -439,6 +440,11 @@ const char* BuiltInString(int builtIn)
case BuiltInPrimitiveLineIndicesEXT: return "PrimitiveLineIndicesEXT";
case BuiltInPrimitiveTriangleIndicesEXT: return "PrimitiveTriangleIndicesEXT";
case BuiltInCullPrimitiveEXT: return "CullPrimitiveEXT";
case BuiltInCoreCountARM: return "CoreCountARM";
case BuiltInCoreIDARM: return "CoreIDARM";
case BuiltInCoreMaxIDARM: return "CoreMaxIDARM";
case BuiltInWarpIDARM: return "WarpIDARM";
case BuiltInWarpMaxIDARM: return "BuiltInWarpMaxIDARM";

default: return "Bad";
}
Expand Down Expand Up @@ -998,6 +1004,7 @@ const char* CapabilityString(int info)
case CapabilityWorkgroupMemoryExplicitLayoutKHR: return "CapabilityWorkgroupMemoryExplicitLayoutKHR";
case CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR: return "CapabilityWorkgroupMemoryExplicitLayout8BitAccessKHR";
case CapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR: return "CapabilityWorkgroupMemoryExplicitLayout16BitAccessKHR";
case CapabilityCoreBuiltinsARM: return "CoreBuiltinsARM";

default: return "Bad";
}
Expand Down
6 changes: 6 additions & 0 deletions SPIRV/spirv.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,11 @@ enum BuiltIn {
BuiltInSubgroupLocalInvocationId = 41,
BuiltInVertexIndex = 42,
BuiltInInstanceIndex = 43,
BuiltInCoreCountARM = 4161,
BuiltInCoreIDARM = 4160,
BuiltInCoreMaxIDARM = 4162,
BuiltInWarpIDARM = 4163,
BuiltInWarpMaxIDARM = 4164,
BuiltInSubgroupEqMask = 4416,
BuiltInSubgroupEqMaskKHR = 4416,
BuiltInSubgroupGeMask = 4417,
Expand Down Expand Up @@ -946,6 +951,7 @@ enum Capability {
CapabilityShaderLayer = 69,
CapabilityShaderViewportIndex = 70,
CapabilityUniformDecoration = 71,
CapabilityCoreBuiltinsARM = 4165,
CapabilityFragmentShadingRateKHR = 4422,
CapabilitySubgroupBallotKHR = 4423,
CapabilityDrawParameters = 4427,
Expand Down
61 changes: 61 additions & 0 deletions Test/baseResults/spv.ARMCoreBuiltIns.frag.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
spv.ARMCoreBuiltIns.frag
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 26

Capability Shader
Capability CoreBuiltinsARM
Extension "SPV_ARM_core_builtins"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 10 14 15 17 19 21
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_ARM_shader_core_builtins"
Name 4 "main"
Name 8 "temp"
Name 10 "gl_WarpMaxIDARM"
Name 14 "data"
Name 15 "gl_CoreIDARM"
Name 17 "gl_CoreCountARM"
Name 19 "gl_CoreMaxIDARM"
Name 21 "gl_WarpIDARM"
Decorate 10(gl_WarpMaxIDARM) Flat
Decorate 10(gl_WarpMaxIDARM) BuiltIn BuiltInWarpMaxIDARM
Decorate 14(data) Location 0
Decorate 15(gl_CoreIDARM) Flat
Decorate 15(gl_CoreIDARM) BuiltIn CoreIDARM
Decorate 17(gl_CoreCountARM) Flat
Decorate 17(gl_CoreCountARM) BuiltIn CoreCountARM
Decorate 19(gl_CoreMaxIDARM) Flat
Decorate 19(gl_CoreMaxIDARM) BuiltIn CoreMaxIDARM
Decorate 21(gl_WarpIDARM) Flat
Decorate 21(gl_WarpIDARM) BuiltIn WarpIDARM
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
9: TypePointer Input 6(int)
10(gl_WarpMaxIDARM): 9(ptr) Variable Input
12: TypeVector 6(int) 4
13: TypePointer Output 12(ivec4)
14(data): 13(ptr) Variable Output
15(gl_CoreIDARM): 9(ptr) Variable Input
17(gl_CoreCountARM): 9(ptr) Variable Input
19(gl_CoreMaxIDARM): 9(ptr) Variable Input
21(gl_WarpIDARM): 9(ptr) Variable Input
4(main): 2 Function None 3
5: Label
8(temp): 7(ptr) Variable Function
11: 6(int) Load 10(gl_WarpMaxIDARM)
Store 8(temp) 11
16: 6(int) Load 15(gl_CoreIDARM)
18: 6(int) Load 17(gl_CoreCountARM)
20: 6(int) Load 19(gl_CoreMaxIDARM)
22: 6(int) Load 21(gl_WarpIDARM)
23: 6(int) Load 8(temp)
24: 6(int) IAdd 22 23
25: 12(ivec4) CompositeConstruct 16 18 20 24
Store 14(data) 25
Return
FunctionEnd
65 changes: 65 additions & 0 deletions Test/baseResults/spv.ARMCoreBuiltIns.vert.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
spv.ARMCoreBuiltIns.vert
// Module Version 10000
// Generated by (magic number): 8000b
// Id's are bound by 31

Capability Shader
Capability CoreBuiltinsARM
Extension "SPV_ARM_core_builtins"
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 10 18 20 22 24
Source GLSL 450
SourceExtension "GL_ARM_shader_core_builtins"
Name 4 "main"
Name 8 "temp"
Name 10 "gl_WarpMaxIDARM"
Name 13 "Output"
MemberName 13(Output) 0 "result"
Name 15 ""
Name 18 "gl_CoreIDARM"
Name 20 "gl_CoreCountARM"
Name 22 "gl_CoreMaxIDARM"
Name 24 "gl_WarpIDARM"
Decorate 10(gl_WarpMaxIDARM) BuiltIn BuiltInWarpMaxIDARM
MemberDecorate 13(Output) 0 Offset 0
Decorate 13(Output) BufferBlock
Decorate 15 DescriptorSet 0
Decorate 15 Binding 0
Decorate 18(gl_CoreIDARM) BuiltIn CoreIDARM
Decorate 20(gl_CoreCountARM) BuiltIn CoreCountARM
Decorate 22(gl_CoreMaxIDARM) BuiltIn CoreMaxIDARM
Decorate 24(gl_WarpIDARM) BuiltIn WarpIDARM
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 0
7: TypePointer Function 6(int)
9: TypePointer Input 6(int)
10(gl_WarpMaxIDARM): 9(ptr) Variable Input
12: TypeVector 6(int) 4
13(Output): TypeStruct 12(ivec4)
14: TypePointer Uniform 13(Output)
15: 14(ptr) Variable Uniform
16: TypeInt 32 1
17: 16(int) Constant 0
18(gl_CoreIDARM): 9(ptr) Variable Input
20(gl_CoreCountARM): 9(ptr) Variable Input
22(gl_CoreMaxIDARM): 9(ptr) Variable Input
24(gl_WarpIDARM): 9(ptr) Variable Input
29: TypePointer Uniform 12(ivec4)
4(main): 2 Function None 3
5: Label
8(temp): 7(ptr) Variable Function
11: 6(int) Load 10(gl_WarpMaxIDARM)
Store 8(temp) 11
19: 6(int) Load 18(gl_CoreIDARM)
21: 6(int) Load 20(gl_CoreCountARM)
23: 6(int) Load 22(gl_CoreMaxIDARM)
25: 6(int) Load 24(gl_WarpIDARM)
26: 6(int) Load 8(temp)
27: 6(int) IAdd 25 26
28: 12(ivec4) CompositeConstruct 19 21 23 27
30: 29(ptr) AccessChain 15 17
Store 30 28
Return
FunctionEnd
8 changes: 8 additions & 0 deletions Test/spv.ARMCoreBuiltIns.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 450
#extension GL_ARM_shader_core_builtins: enable
layout(location = 0) out uvec4 data;
void main (void)
{
uint temp = gl_WarpMaxIDARM;
data = uvec4(gl_CoreIDARM, gl_CoreCountARM, gl_CoreMaxIDARM, gl_WarpIDARM + temp);
}
12 changes: 12 additions & 0 deletions Test/spv.ARMCoreBuiltIns.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 450
#extension GL_ARM_shader_core_builtins: enable
layout(set = 0, binding = 0, std430) buffer Output
{
uvec4 result;
};

void main (void)
{
uint temp = gl_WarpMaxIDARM;
result = uvec4(gl_CoreIDARM, gl_CoreCountARM, gl_CoreMaxIDARM, gl_WarpIDARM + temp);
}
7 changes: 7 additions & 0 deletions glslang/Include/BaseTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,13 @@ enum TBuiltInVariable {
EbvByteAddressBuffer,
EbvRWByteAddressBuffer,

// ARM specific core builtins
EbvCoreCountARM,
EbvCoreIDARM,
EbvCoreMaxIDARM,
EbvWarpIDARM,
EbvWarpMaxIDARM,

EbvLast
};

Expand Down
Loading

0 comments on commit e3e8baf

Please sign in to comment.