Skip to content

Commit 8c1a3a0

Browse files
authored
Add GL_EXT_shader_image_int64 support (KhronosGroup#2409)
1 parent 478b232 commit 8c1a3a0

19 files changed

+4963
-3311
lines changed

SPIRV/GLSL.ext.EXT.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@ static const char* const E_SPV_EXT_fragment_fully_covered = "SPV_EXT_fragment_fu
3636
static const char* const E_SPV_EXT_fragment_invocation_density = "SPV_EXT_fragment_invocation_density";
3737
static const char* const E_SPV_EXT_demote_to_helper_invocation = "SPV_EXT_demote_to_helper_invocation";
3838
static const char* const E_SPV_EXT_shader_atomic_float_add = "SPV_EXT_shader_atomic_float_add";
39+
static const char* const E_SPV_EXT_shader_image_int64 = "SPV_EXT_shader_image_int64";
3940

4041
#endif // #ifndef GLSLextEXT_H

SPIRV/GlslangToSpv.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,6 +1088,10 @@ spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TTy
10881088
builder.addCapability(spv::CapabilityStorageImageExtendedFormats);
10891089
break;
10901090

1091+
case glslang::ElfR64ui:
1092+
case glslang::ElfR64i:
1093+
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
1094+
builder.addCapability(spv::CapabilityInt64ImageEXT);
10911095
default:
10921096
break;
10931097
}
@@ -1134,6 +1138,8 @@ spv::ImageFormat TGlslangToSpvTraverser::TranslateImageFormat(const glslang::TTy
11341138
case glslang::ElfRg8ui: return spv::ImageFormatRg8ui;
11351139
case glslang::ElfR16ui: return spv::ImageFormatR16ui;
11361140
case glslang::ElfR8ui: return spv::ImageFormatR8ui;
1141+
case glslang::ElfR64ui: return spv::ImageFormatR64ui;
1142+
case glslang::ElfR64i: return spv::ImageFormatR64i;
11371143
default: return spv::ImageFormatMax;
11381144
}
11391145
}
@@ -3594,6 +3600,12 @@ spv::Id TGlslangToSpvTraverser::getSampledType(const glslang::TSampler& sampler)
35943600
builder.addExtension(spv::E_SPV_AMD_gpu_shader_half_float_fetch);
35953601
builder.addCapability(spv::CapabilityFloat16ImageAMD);
35963602
return builder.makeFloatType(16);
3603+
case glslang::EbtInt64: return builder.makeIntType(64);
3604+
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
3605+
builder.addCapability(spv::CapabilityFloat16ImageAMD);
3606+
case glslang::EbtUint64: return builder.makeUintType(64);
3607+
builder.addExtension(spv::E_SPV_EXT_shader_image_int64);
3608+
builder.addCapability(spv::CapabilityFloat16ImageAMD);
35973609
#endif
35983610
default:
35993611
assert(0);

SPIRV/doc.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,8 @@ const char* ImageFormatString(int format)
523523
case 37: return "Rg8ui";
524524
case 38: return "R16ui";
525525
case 39: return "R8ui";
526+
case 40: return "R64ui";
527+
case 41: return "R64i";
526528

527529
default:
528530
return "Bad";
@@ -958,6 +960,7 @@ const char* CapabilityString(int info)
958960

959961
case CapabilityDemoteToHelperInvocationEXT: return "DemoteToHelperInvocationEXT";
960962
case CapabilityShaderClockKHR: return "ShaderClockKHR";
963+
case CapabilityInt64ImageEXT: return "Int64ImageEXT";
961964

962965
case CapabilityIntegerFunctions2INTEL: return "CapabilityIntegerFunctions2INTEL";
963966

Test/baseResults/spv.imageAtomic64.frag.out

Lines changed: 634 additions & 0 deletions
Large diffs are not rendered by default.

Test/baseResults/spv.imageLoadStoreLod.frag.out

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,25 @@
11
spv.imageLoadStoreLod.frag
22
// Module Version 10000
33
// Generated by (magic number): 8000a
4-
// Id's are bound by 82
4+
// Id's are bound by 148
55

66
Capability Shader
7+
Capability Int64
78
Capability ImageCubeArray
89
Capability SparseResidency
910
Capability Image1D
1011
Capability ImageReadWriteLodAMD
12+
Capability Int64ImageEXT
1113
Extension "SPV_AMD_shader_image_load_store_lod"
14+
Extension "SPV_EXT_shader_image_int64"
1215
1: ExtInstImport "GLSL.std.450"
1316
MemoryModel Logical GLSL450
1417
EntryPoint Fragment 4 "main" 77
1518
ExecutionMode 4 OriginUpperLeft
1619
Source GLSL 450
1720
SourceExtension "GL_AMD_shader_image_load_store_lod"
21+
SourceExtension "GL_ARB_gpu_shader_int64"
22+
SourceExtension "GL_EXT_shader_image_int64"
1823
Name 4 "main"
1924
Name 9 "f4"
2025
Name 14 "i1D"
@@ -27,6 +32,18 @@ spv.imageLoadStoreLod.frag
2732
Name 65 "ResType"
2833
Name 71 "uiCubeArray"
2934
Name 77 "fragColor"
35+
Name 86 "Buf"
36+
MemberName 86(Buf) 0 "i64v4"
37+
MemberName 86(Buf) 1 "u64v4"
38+
Name 88 ""
39+
Name 92 "i64i1D"
40+
Name 102 "i64i2D"
41+
Name 111 "i64i3D"
42+
Name 120 "u64iCube"
43+
Name 127 "u64i1DArray"
44+
Name 133 "u64i2DArray"
45+
Name 136 "ResType"
46+
Name 142 "u64iCubeArray"
3047
Decorate 14(i1D) DescriptorSet 0
3148
Decorate 14(i1D) Binding 0
3249
Decorate 24(i2D) DescriptorSet 0
@@ -42,6 +59,25 @@ spv.imageLoadStoreLod.frag
4259
Decorate 71(uiCubeArray) DescriptorSet 0
4360
Decorate 71(uiCubeArray) Binding 6
4461
Decorate 77(fragColor) Location 0
62+
MemberDecorate 86(Buf) 0 Offset 0
63+
MemberDecorate 86(Buf) 1 Offset 32
64+
Decorate 86(Buf) BufferBlock
65+
Decorate 88 DescriptorSet 0
66+
Decorate 88 Binding 14
67+
Decorate 92(i64i1D) DescriptorSet 0
68+
Decorate 92(i64i1D) Binding 7
69+
Decorate 102(i64i2D) DescriptorSet 0
70+
Decorate 102(i64i2D) Binding 8
71+
Decorate 111(i64i3D) DescriptorSet 0
72+
Decorate 111(i64i3D) Binding 9
73+
Decorate 120(u64iCube) DescriptorSet 0
74+
Decorate 120(u64iCube) Binding 10
75+
Decorate 127(u64i1DArray) DescriptorSet 0
76+
Decorate 127(u64i1DArray) Binding 11
77+
Decorate 133(u64i2DArray) DescriptorSet 0
78+
Decorate 133(u64i2DArray) Binding 12
79+
Decorate 142(u64iCubeArray) DescriptorSet 0
80+
Decorate 142(u64iCubeArray) Binding 13
4581
2: TypeVoid
4682
3: TypeFunction 2
4783
6: TypeFloat 32
@@ -88,6 +124,38 @@ spv.imageLoadStoreLod.frag
88124
71(uiCubeArray): 70(ptr) Variable UniformConstant
89125
76: TypePointer Output 7(fvec4)
90126
77(fragColor): 76(ptr) Variable Output
127+
82: TypeInt 64 1
128+
83: TypeVector 82(int64_t) 4
129+
84: TypeInt 64 0
130+
85: TypeVector 84(int64_t) 4
131+
86(Buf): TypeStruct 83(i64vec4) 85(i64vec4)
132+
87: TypePointer Uniform 86(Buf)
133+
88: 87(ptr) Variable Uniform
134+
89: 16(int) Constant 0
135+
90: TypeImage 82(int64_t) 1D nonsampled format:R64i
136+
91: TypePointer UniformConstant 90
137+
92(i64i1D): 91(ptr) Variable UniformConstant
138+
95: TypePointer Uniform 83(i64vec4)
139+
100: TypeImage 82(int64_t) 2D nonsampled format:R64i
140+
101: TypePointer UniformConstant 100
141+
102(i64i2D): 101(ptr) Variable UniformConstant
142+
109: TypeImage 82(int64_t) 3D nonsampled format:R64i
143+
110: TypePointer UniformConstant 109
144+
111(i64i3D): 110(ptr) Variable UniformConstant
145+
118: TypeImage 84(int64_t) Cube nonsampled format:R64ui
146+
119: TypePointer UniformConstant 118
147+
120(u64iCube): 119(ptr) Variable UniformConstant
148+
122: TypePointer Uniform 85(i64vec4)
149+
125: TypeImage 84(int64_t) 1D array nonsampled format:R64ui
150+
126: TypePointer UniformConstant 125
151+
127(u64i1DArray): 126(ptr) Variable UniformConstant
152+
131: TypeImage 84(int64_t) 2D array nonsampled format:R64ui
153+
132: TypePointer UniformConstant 131
154+
133(u64i2DArray): 132(ptr) Variable UniformConstant
155+
136(ResType): TypeStruct 16(int) 85(i64vec4)
156+
140: TypeImage 84(int64_t) Cube array nonsampled format:R64ui
157+
141: TypePointer UniformConstant 140
158+
142(u64iCubeArray): 141(ptr) Variable UniformConstant
91159
4(main): 2 Function None 3
92160
5: Label
93161
9(f4): 8(ptr) Variable Function
@@ -131,5 +199,46 @@ spv.imageLoadStoreLod.frag
131199
80: 7(fvec4) ConvertUToF 79
132200
81: 7(fvec4) FAdd 78 80
133201
Store 77(fragColor) 81
202+
93: 90 Load 92(i64i1D)
203+
94: 83(i64vec4) ImageRead 93 17 Lod 18
204+
96: 95(ptr) AccessChain 88 89
205+
97: 83(i64vec4) Load 96
206+
98: 83(i64vec4) IAdd 97 94
207+
99: 95(ptr) AccessChain 88 89
208+
Store 99 98
209+
103: 100 Load 102(i64i2D)
210+
104: 83(i64vec4) ImageRead 103 28 Lod 18
211+
105: 95(ptr) AccessChain 88 89
212+
106: 83(i64vec4) Load 105
213+
107: 83(i64vec4) IAdd 106 104
214+
108: 95(ptr) AccessChain 88 89
215+
Store 108 107
216+
112: 109 Load 111(i64i3D)
217+
113: 83(i64vec4) ImageRead 112 40 Lod 18
218+
114: 95(ptr) AccessChain 88 89
219+
115: 83(i64vec4) Load 114
220+
116: 83(i64vec4) IAdd 115 113
221+
117: 95(ptr) AccessChain 88 89
222+
Store 117 116
223+
121: 118 Load 120(u64iCube)
224+
123: 122(ptr) AccessChain 88 17
225+
124: 85(i64vec4) Load 123
226+
ImageWrite 121 40 124 Lod 18
227+
128: 125 Load 127(u64i1DArray)
228+
129: 122(ptr) AccessChain 88 17
229+
130: 85(i64vec4) Load 129
230+
ImageWrite 128 28 130 Lod 18
231+
134: 131 Load 133(u64i2DArray)
232+
135: 122(ptr) AccessChain 88 17
233+
137:136(ResType) ImageSparseRead 134 40 Lod 18
234+
138: 85(i64vec4) CompositeExtract 137 1
235+
Store 135 138
236+
139: 16(int) CompositeExtract 137 0
237+
143: 140 Load 142(u64iCubeArray)
238+
144: 122(ptr) AccessChain 88 17
239+
145:136(ResType) ImageSparseRead 143 40 Lod 18
240+
146: 85(i64vec4) CompositeExtract 145 1
241+
Store 144 146
242+
147: 16(int) CompositeExtract 145 0
134243
Return
135244
FunctionEnd

Test/spv.imageAtomic64.frag

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#version 450 core
2+
3+
#extension GL_ARB_gpu_shader_int64: enable
4+
#extension GL_EXT_shader_image_int64: enable
5+
#extension GL_KHR_memory_scope_semantics: enable
6+
#extension GL_ARB_sparse_texture2: enable
7+
8+
layout(binding = 0, r64i) uniform i64image1D i1D;
9+
layout(binding = 1, r64ui) uniform u64image2D u2D;
10+
layout(binding = 2, r64i) uniform i64image3D i3D;
11+
layout(binding = 3, r64ui) uniform u64imageCube uCube;
12+
layout(binding = 4, r64i) uniform i64imageBuffer iBuf;
13+
layout(binding = 5, r64ui) uniform u64image1DArray u1DArray;
14+
layout(binding = 6, r64i) uniform i64image2DArray i2DArray;
15+
layout(binding = 7, r64ui) uniform u64imageCubeArray uCubeArray;
16+
layout(binding = 8, r64i) uniform i64image2DRect i2DRect;
17+
layout(binding = 9, r64ui) uniform u64image2DMS u2DMS;
18+
layout(binding = 10, r64i) uniform i64image2DMSArray i2DMSArray;
19+
20+
layout(binding = 11) buffer Buf
21+
{
22+
int64_t i64;
23+
uint64_t u64;
24+
i64vec4 i64v4;
25+
u64vec4 u64v4;
26+
ivec4 i32v4;
27+
};
28+
29+
void main()
30+
{
31+
i64 = imageAtomicAdd(i1D, i32v4.x, i64);
32+
i64 = imageAtomicMin(i3D, i32v4.xyz, i64);
33+
i64 = imageAtomicMax(iBuf, i32v4.x, i64);
34+
i64 = imageAtomicAnd(i2DArray, i32v4.xyz, i64);
35+
i64 = imageAtomicOr(i2DRect, i32v4.xy, i64);
36+
i64 = imageAtomicXor(i2DMSArray, i32v4.xyz, i32v4.w, i64);
37+
i64 = imageAtomicExchange(i1D, i32v4.x, i64);
38+
i64 = imageAtomicCompSwap(i3D, i32v4.xyz, i64, i64 + 1);
39+
40+
i64 = imageAtomicAdd(i1D, i32v4.x, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
41+
i64 = imageAtomicMin(i3D, i32v4.xyz, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
42+
i64 = imageAtomicMax(iBuf, i32v4.x, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
43+
i64 = imageAtomicAnd(i2DArray, i32v4.xyz, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
44+
i64 = imageAtomicOr(i2DRect, i32v4.xy, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
45+
i64 = imageAtomicXor(i2DMSArray, i32v4.xyz, i32v4.w, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
46+
i64 = imageAtomicExchange(i1D, i32v4.x, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
47+
i64 = imageAtomicCompSwap(i3D, i32v4.xyz, i64, i64 + 1, gl_ScopeDevice,
48+
gl_StorageSemanticsImage, gl_SemanticsRelaxed, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
49+
i64 = imageAtomicLoad(iBuf, i32v4.x, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
50+
imageAtomicStore(i2DArray, i32v4.xyz, i64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
51+
52+
u64 = imageAtomicAdd(u2D, i32v4.xy, u64);
53+
u64 = imageAtomicMin(uCube, i32v4.xyz, u64);
54+
u64 = imageAtomicMax(u1DArray, i32v4.xy, u64);
55+
u64 = imageAtomicAnd(uCubeArray, i32v4.xyz, u64);
56+
u64 = imageAtomicOr(u2DMS, i32v4.xy, i32v4.z, u64);
57+
u64 = imageAtomicXor(u2D, i32v4.xy, u64);
58+
u64 = imageAtomicExchange(uCube, i32v4.xyz, u64);
59+
u64 = imageAtomicCompSwap(u1DArray, i32v4.xy, u64, u64 + 1);
60+
61+
u64 = imageAtomicAdd(u2D, i32v4.xy, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
62+
u64 = imageAtomicMin(uCube, i32v4.xyz, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
63+
u64 = imageAtomicMax(u1DArray, i32v4.xy, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
64+
u64 = imageAtomicAnd(uCubeArray, i32v4.xyz, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
65+
u64 = imageAtomicOr(u2DMS, i32v4.xy, i32v4.z, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
66+
u64 = imageAtomicXor(u2D, i32v4.xy, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
67+
u64 = imageAtomicExchange(uCube, i32v4.xyz, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
68+
u64 = imageAtomicCompSwap(u1DArray, i32v4.xy, u64, u64 + 1, gl_ScopeDevice,
69+
gl_StorageSemanticsImage, gl_SemanticsRelaxed, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
70+
u64 = imageAtomicLoad(uCubeArray, i32v4.xyz, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
71+
imageAtomicStore(u2DMS, i32v4.xy, i32v4.z, u64, gl_ScopeDevice, gl_StorageSemanticsImage, gl_SemanticsRelaxed);
72+
73+
i64v4 += imageLoad(i1D, i32v4.x);
74+
i64v4 += imageLoad(i3D, i32v4.xyz);
75+
i64v4 += imageLoad(iBuf, i32v4.x);
76+
i64v4 += imageLoad(i2DArray, i32v4.xyz);
77+
i64v4 += imageLoad(i2DRect, i32v4.xy);
78+
i64v4 += imageLoad(i2DMSArray, i32v4.xyz, i32v4.w);
79+
80+
imageStore(u2D, i32v4.xy, u64v4);
81+
imageStore(uCube, i32v4.xyz, u64v4);
82+
imageStore(u1DArray, i32v4.xy, u64v4);
83+
imageStore(uCubeArray, i32v4.xyz, u64v4);
84+
imageStore(u2DMS, i32v4.xy, i32v4.z, u64v4);
85+
86+
sparseImageLoadARB(i3D, i32v4.xyz, i64v4);
87+
sparseImageLoadARB(i2DArray, i32v4.xyz, i64v4);
88+
sparseImageLoadARB(i2DRect, i32v4.xy, i64v4);
89+
sparseImageLoadARB(u2D, i32v4.xy, u64v4);
90+
sparseImageLoadARB(uCube, i32v4.xyz, u64v4);
91+
sparseImageLoadARB(uCubeArray, i32v4.xyz, u64v4);
92+
}

Test/spv.imageLoadStoreLod.frag

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#version 450 core
22

33
#extension GL_AMD_shader_image_load_store_lod: enable
4+
#extension GL_ARB_gpu_shader_int64: enable
5+
#extension GL_EXT_shader_image_int64: enable
46

57
layout(rgba32f, binding = 0) uniform image1D i1D;
68
layout(rgba32f, binding = 1) uniform image2D i2D;
@@ -12,6 +14,20 @@ layout(rgba32ui, binding = 6) uniform uimageCubeArray uiCubeArray;
1214

1315
layout(location = 0) out vec4 fragColor;
1416

17+
layout(r64i, binding = 7) uniform i64image1D i64i1D;
18+
layout(r64i, binding = 8) uniform i64image2D i64i2D;
19+
layout(r64i, binding = 9) uniform i64image3D i64i3D;
20+
layout(r64ui, binding = 10) uniform u64imageCube u64iCube;
21+
layout(r64ui, binding = 11) uniform u64image1DArray u64i1DArray;
22+
layout(r64ui, binding = 12) uniform u64image2DArray u64i2DArray;
23+
layout(r64ui, binding = 13) uniform u64imageCubeArray u64iCubeArray;
24+
25+
layout(binding = 14) buffer Buf
26+
{
27+
i64vec4 i64v4;
28+
u64vec4 u64v4;
29+
};
30+
1531
void main()
1632
{
1733
const int c1 = 1;
@@ -33,4 +49,14 @@ void main()
3349
sparseImageLoadLodAMD(uiCubeArray, c3, lod, u4);
3450

3551
fragColor = f4 + vec4(u4);
52+
53+
i64v4 += imageLoadLodAMD(i64i1D, c1, lod);
54+
i64v4 += imageLoadLodAMD(i64i2D, c2, lod);
55+
i64v4 += imageLoadLodAMD(i64i3D, c3, lod);
56+
57+
imageStoreLodAMD(u64iCube, c3, lod, u64v4);
58+
imageStoreLodAMD(u64i1DArray, c2, lod, u64v4);
59+
60+
sparseImageLoadLodAMD(u64i2DArray, c3, lod, u64v4);
61+
sparseImageLoadLodAMD(u64iCubeArray, c3, lod, u64v4);
3662
}

glslang/Include/Types.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,7 @@ enum TLayoutFormat {
406406
ElfRg8i,
407407
ElfR16i,
408408
ElfR8i,
409+
ElfR64i,
409410

410411
ElfIntGuard, // to help with comparisons
411412

@@ -423,6 +424,7 @@ enum TLayoutFormat {
423424
ElfRg8ui,
424425
ElfR16ui,
425426
ElfR8ui,
427+
ElfR64ui,
426428

427429
ElfCount
428430
};
@@ -1117,6 +1119,8 @@ class TQualifier {
11171119
case ElfR32ui: return "r32ui";
11181120
case ElfR16ui: return "r16ui";
11191121
case ElfR8ui: return "r8ui";
1122+
case ElfR64ui: return "r64ui";
1123+
case ElfR64i: return "r64i";
11201124
default: return "none";
11211125
}
11221126
}

0 commit comments

Comments
 (0)