SPV_KHR_physical_storage_buffer/SPV: Add GL_EXT_buffer_reference_uvec2

Adds uvec2 <-> reference constructor support.
Switches from EXT to KHR for physical_storage_buffer.
This commit is contained in:
John Kessenich 2019-09-17 23:19:38 -06:00
parent e0932f676d
commit 90e402f42b
29 changed files with 217 additions and 25 deletions

View File

@ -40,7 +40,7 @@ static const char* const E_SPV_KHR_8bit_storage = "SPV_KHR_8bit_
static const char* const E_SPV_KHR_storage_buffer_storage_class = "SPV_KHR_storage_buffer_storage_class";
static const char* const E_SPV_KHR_post_depth_coverage = "SPV_KHR_post_depth_coverage";
static const char* const E_SPV_KHR_vulkan_memory_model = "SPV_KHR_vulkan_memory_model";
static const char* const E_SPV_EXT_physical_storage_buffer = "SPV_EXT_physical_storage_buffer";
static const char* const E_SPV_KHR_physical_storage_buffer = "SPV_KHR_physical_storage_buffer";
static const char* const E_SPV_EXT_fragment_shader_interlock = "SPV_EXT_fragment_shader_interlock";
static const char* const E_SPV_KHR_shader_clock = "SPV_KHR_shader_clock";

View File

@ -1399,7 +1399,7 @@ TGlslangToSpvTraverser::TGlslangToSpvTraverser(unsigned int spvVersion, const gl
if (glslangIntermediate->usingPhysicalStorageBuffer()) {
addressingModel = spv::AddressingModelPhysicalStorageBuffer64EXT;
builder.addIncorporatedExtension(spv::E_SPV_EXT_physical_storage_buffer, spv::Spv_1_5);
builder.addIncorporatedExtension(spv::E_SPV_KHR_physical_storage_buffer, spv::Spv_1_5);
builder.addCapability(spv::CapabilityPhysicalStorageBufferAddressesEXT);
};
if (glslangIntermediate->usingVulkanMemoryModel()) {
@ -6273,6 +6273,10 @@ spv::Id TGlslangToSpvTraverser::createConversion(glslang::TOperator op, OpDecora
case glslang::EOpConvPtrToUint64:
convOp = spv::OpConvertPtrToU;
break;
case glslang::EOpConvPtrToUvec2:
case glslang::EOpConvUvec2ToPtr:
convOp = spv::OpBitcast;
break;
#endif
default:

View File

@ -6,7 +6,7 @@ spv.bufferhandle1.frag
Capability Shader
Capability VulkanMemoryModelKHR
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
Extension "SPV_KHR_vulkan_memory_model"
1: ExtInstImport "GLSL.std.450"

View File

@ -6,7 +6,7 @@ spv.bufferhandle10.frag
Capability Shader
Capability VulkanMemoryModelKHR
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
Extension "SPV_KHR_vulkan_memory_model"
1: ExtInstImport "GLSL.std.450"

View File

@ -9,8 +9,8 @@ WARNING: 0:6: '' : all default precisions are highp; use precision statements to
Capability Shader
Capability StorageBuffer8BitAccess
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_8bit_storage"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -9,8 +9,8 @@ WARNING: 0:6: '' : all default precisions are highp; use precision statements to
Capability Shader
Capability StorageUniformBufferBlock16
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_16bit_storage"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle13.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle14.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 4 "main"

View File

@ -8,7 +8,7 @@ WARNING: 0:16: '' : all default precisions are highp; use precision statements t
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -6,7 +6,7 @@ spv.bufferhandle16.frag
Capability Shader
Capability Int64
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 4 "main"

View File

@ -6,7 +6,7 @@ spv.bufferhandle18.frag
Capability Shader
Capability Int64
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 4 "main"

View File

@ -5,7 +5,7 @@ spv.bufferhandle2.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle3.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle4.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle5.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 4 "main"

View File

@ -5,7 +5,7 @@ spv.bufferhandle6.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle7.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -5,7 +5,7 @@ spv.bufferhandle8.frag
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -6,7 +6,7 @@ spv.bufferhandle9.frag
Capability Shader
Capability Int64
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450

View File

@ -0,0 +1,133 @@
spv.bufferhandleUvec2.frag
// Module Version 10000
// Generated by (magic number): 80007
// Id's are bound by 71
Capability Shader
Capability PhysicalStorageBufferAddressesEXT
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
1: ExtInstImport "GLSL.std.450"
MemoryModel PhysicalStorageBuffer64EXT GLSL450
EntryPoint Fragment 4 "main" 16 19
ExecutionMode 4 OriginUpperLeft
Source GLSL 450
SourceExtension "GL_EXT_buffer_reference"
SourceExtension "GL_EXT_buffer_reference_uvec2"
Name 4 "main"
Name 8 "blockType"
MemberName 8(blockType) 0 "a"
MemberName 8(blockType) 1 "b"
MemberName 8(blockType) 2 "c"
MemberName 8(blockType) 3 "d"
MemberName 8(blockType) 4 "e"
Name 13 "b1"
Name 16 "h"
Name 19 "i"
Name 34 "b2"
Name 37 "b3"
Name 46 "j"
Name 54 "carry"
Name 55 "ResType"
Name 68 "t2"
MemberName 68(t2) 0 "f"
MemberName 68(t2) 1 "g"
Name 70 "t"
MemberDecorate 8(blockType) 0 Offset 0
MemberDecorate 8(blockType) 1 Offset 4
MemberDecorate 8(blockType) 2 Offset 8
MemberDecorate 8(blockType) 3 Offset 12
MemberDecorate 8(blockType) 4 Offset 16
Decorate 8(blockType) Block
Decorate 13(b1) DecorationAliasedPointerEXT
Decorate 16(h) Flat
Decorate 19(i) Flat
Decorate 34(b2) DecorationAliasedPointerEXT
Decorate 37(b3) DecorationAliasedPointerEXT
MemberDecorate 68(t2) 0 Offset 0
MemberDecorate 68(t2) 1 Offset 8
Decorate 68(t2) Block
Decorate 70(t) DescriptorSet 0
Decorate 70(t) Binding 0
2: TypeVoid
3: TypeFunction 2
TypeForwardPointer 6 PhysicalStorageBufferEXT
7: TypeInt 32 1
8(blockType): TypeStruct 7(int) 7(int) 7(int) 7(int) 7(int)
6: TypePointer PhysicalStorageBufferEXT 8(blockType)
9: TypeInt 32 0
10: 9(int) Constant 2
11: TypeArray 6(ptr) 10
12: TypePointer Function 11
14: TypeVector 9(int) 2
15: TypePointer Input 14(ivec2)
16(h): 15(ptr) Variable Input
19(i): 15(ptr) Variable Input
23: 7(int) Constant 0
24: TypePointer Function 6(ptr)
27: 7(int) Constant 1
30: TypePointer PhysicalStorageBufferEXT 7(int)
45: TypePointer Function 14(ivec2)
49: 9(int) Constant 0
50: TypePointer Function 9(int)
53: 9(int) Constant 256
55(ResType): TypeStruct 9(int) 9(int)
61: 9(int) Constant 1
68(t2): TypeStruct 6(ptr) 6(ptr)
69: TypePointer StorageBuffer 68(t2)
70(t): 69(ptr) Variable StorageBuffer
4(main): 2 Function None 3
5: Label
13(b1): 12(ptr) Variable Function
34(b2): 24(ptr) Variable Function
37(b3): 24(ptr) Variable Function
46(j): 45(ptr) Variable Function
54(carry): 50(ptr) Variable Function
17: 14(ivec2) Load 16(h)
18: 6(ptr) Bitcast 17
20: 14(ivec2) Load 19(i)
21: 6(ptr) Bitcast 20
22: 11 CompositeConstruct 18 21
Store 13(b1) 22
25: 24(ptr) AccessChain 13(b1) 23
26: 6(ptr) Load 25
28: 24(ptr) AccessChain 13(b1) 27
29: 6(ptr) Load 28
31: 30(ptr) AccessChain 29 27
32: 7(int) Load 31 Aligned 4
33: 30(ptr) AccessChain 26 23
Store 33 32 Aligned 16
35: 14(ivec2) Load 16(h)
36: 6(ptr) Bitcast 35
Store 34(b2) 36
38: 14(ivec2) Load 19(i)
39: 6(ptr) Bitcast 38
Store 37(b3) 39
40: 6(ptr) Load 34(b2)
41: 6(ptr) Load 37(b3)
42: 30(ptr) AccessChain 41 27
43: 7(int) Load 42 Aligned 4
44: 30(ptr) AccessChain 40 23
Store 44 43 Aligned 16
47: 6(ptr) Load 34(b2)
48: 14(ivec2) Bitcast 47
Store 46(j) 48
51: 50(ptr) AccessChain 46(j) 49
52: 9(int) Load 51
56: 55(ResType) IAddCarry 52 53
57: 9(int) CompositeExtract 56 1
Store 54(carry) 57
58: 9(int) CompositeExtract 56 0
59: 50(ptr) AccessChain 46(j) 49
Store 59 58
60: 9(int) Load 54(carry)
62: 50(ptr) AccessChain 46(j) 61
63: 9(int) Load 62
64: 9(int) IAdd 63 60
65: 50(ptr) AccessChain 46(j) 61
Store 65 64
66: 14(ivec2) Load 46(j)
67: 6(ptr) Bitcast 66
Store 34(b2) 67
Return
FunctionEnd

View File

@ -9,8 +9,8 @@ spv.coopmat.comp
Capability VulkanMemoryModelKHR
Capability PhysicalStorageBufferAddressesEXT
Capability CooperativeMatrixNV
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_16bit_storage"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
Extension "SPV_KHR_vulkan_memory_model"
Extension "SPV_NV_cooperative_matrix"

View File

@ -10,8 +10,8 @@ spv.intcoopmat.comp
Capability VulkanMemoryModelKHR
Capability PhysicalStorageBufferAddressesEXT
Capability CooperativeMatrixNV
Extension "SPV_EXT_physical_storage_buffer"
Extension "SPV_KHR_8bit_storage"
Extension "SPV_KHR_physical_storage_buffer"
Extension "SPV_KHR_storage_buffer_storage_class"
Extension "SPV_KHR_vulkan_memory_model"
Extension "SPV_NV_cooperative_matrix"

View File

@ -0,0 +1,32 @@
#version 450
#extension GL_EXT_buffer_reference_uvec2 : enable
layout(buffer_reference, std430) buffer blockType {
layout(offset = 0) int a;
layout(offset = 4) int b;
layout(offset = 8) int c;
layout(offset = 12) int d;
layout(offset = 16) int e;
};
layout(std430) buffer t2 {
blockType f;
blockType g;
} t;
flat in uvec2 h, i;
void main() {
blockType b1[2] = blockType[2](blockType(h), blockType(i));
b1[0].a = b1[1].b;
blockType b2 = blockType(h);
blockType b3 = blockType(i);
b2.a = b3.b;
uvec2 j = uvec2(b2);
uint carry;
j.x = uaddCarry(j.x, 256, carry);
j.y += carry;
b2 = blockType(j);
}

View File

@ -275,6 +275,10 @@ enum TOperator {
EOpConvUint64ToPtr,
EOpConvPtrToUint64,
// uvec2 <-> pointer
EOpConvUvec2ToPtr,
EOpConvPtrToUvec2,
//
// binary operations
//

View File

@ -6941,6 +6941,12 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
break;
case EOpConstructUVec2:
if (node->getType().getBasicType() == EbtReference) {
requireExtensions(loc, 1, &E_GL_EXT_buffer_reference_uvec2, "reference conversion to uvec2");
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvPtrToUvec2, true, node,
type);
return newNode;
}
case EOpConstructUVec3:
case EOpConstructUVec4:
case EOpConstructUint:
@ -7098,7 +7104,15 @@ TIntermTyped* TParseContext::constructBuiltIn(const TType& type, TOperator op, T
return newNode;
// construct reference from uint64
} else if (node->getType().isScalar() && node->getType().getBasicType() == EbtUint64) {
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvUint64ToPtr, true, node, type);
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvUint64ToPtr, true, node,
type);
return newNode;
// construct reference from uvec2
} else if (node->getType().isVector() && node->getType().getBasicType() == EbtUint &&
node->getVectorSize() == 2) {
requireExtensions(loc, 1, &E_GL_EXT_buffer_reference_uvec2, "uvec2 conversion to reference");
TIntermTyped* newNode = intermediate.addBuiltInFunctionCall(node->getLoc(), EOpConvUvec2ToPtr, true, node,
type);
return newNode;
} else {
return nullptr;

View File

@ -214,6 +214,7 @@ void TParseVersions::initializeExtensionBehavior()
extensionBehavior[E_GL_EXT_fragment_invocation_density] = EBhDisable;
extensionBehavior[E_GL_EXT_buffer_reference] = EBhDisable;
extensionBehavior[E_GL_EXT_buffer_reference2] = EBhDisable;
extensionBehavior[E_GL_EXT_buffer_reference_uvec2] = EBhDisable;
extensionBehavior[E_GL_EXT_demote_to_helper_invocation] = EBhDisable;
extensionBehavior[E_GL_EXT_shader_16bit_storage] = EBhDisable;
@ -404,6 +405,7 @@ void TParseVersions::getPreamble(std::string& preamble)
"#define GL_EXT_fragment_invocation_density 1\n"
"#define GL_EXT_buffer_reference 1\n"
"#define GL_EXT_buffer_reference2 1\n"
"#define GL_EXT_buffer_reference_uvec2 1\n"
"#define GL_EXT_demote_to_helper_invocation 1\n"
// GL_KHR_shader_subgroup
@ -833,7 +835,8 @@ void TParseVersions::updateExtensionBehavior(int line, const char* extension, co
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
else if (strcmp(extension, "GL_NV_shader_subgroup_partitioned") == 0)
updateExtensionBehavior(line, "GL_KHR_shader_subgroup_basic", behaviorString);
else if (strcmp(extension, "GL_EXT_buffer_reference2") == 0)
else if (strcmp(extension, "GL_EXT_buffer_reference2") == 0 ||
strcmp(extension, "GL_EXT_buffer_reference_uvec2") == 0)
updateExtensionBehavior(line, "GL_EXT_buffer_reference", behaviorString);
else if (strcmp(extension, "GL_NV_integer_cooperative_matrix") == 0)
updateExtensionBehavior(line, "GL_NV_cooperative_matrix", behaviorString);

View File

@ -174,6 +174,7 @@ const char* const E_GL_EXT_scalar_block_layout = "GL_EXT_scalar_blo
const char* const E_GL_EXT_fragment_invocation_density = "GL_EXT_fragment_invocation_density";
const char* const E_GL_EXT_buffer_reference = "GL_EXT_buffer_reference";
const char* const E_GL_EXT_buffer_reference2 = "GL_EXT_buffer_reference2";
const char* const E_GL_EXT_buffer_reference_uvec2 = "GL_EXT_buffer_reference_uvec2";
const char* const E_GL_EXT_demote_to_helper_invocation = "GL_EXT_demote_to_helper_invocation";
const char* const E_GL_EXT_shader_realtime_clock = "GL_EXT_shader_realtime_clock";

View File

@ -284,6 +284,7 @@ INSTANTIATE_TEST_CASE_P(
"spv.bufferhandle7.frag",
"spv.bufferhandle8.frag",
"spv.bufferhandle9.frag",
"spv.bufferhandleUvec2.frag",
"spv.bufferhandle_Error.frag",
"spv.builtInXFB.vert",
"spv.conditionalDemote.frag",

View File

@ -5,14 +5,14 @@
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Tools",
"subdir" : "External/spirv-tools",
"commit" : "9b3cc3e05337358d0bd9fec1b7a51e3cbf55312b"
"commit" : "bbb29870b510f83f99994358179c9ea6838c3100"
},
{
"name" : "spirv-tools/external/spirv-headers",
"site" : "github",
"subrepo" : "KhronosGroup/SPIRV-Headers",
"subdir" : "External/spirv-tools/external/spirv-headers",
"commit" : "38cafab379e5d16137cb97a485b9385191039b92"
"commit" : "601d738723ac381741311c6c98c36d6170be14a2"
}
]
}