Merge pull request #1734 from KhronosGroup/buffer-reference-uvec2

GLSL: Emit GL_EXT_buffer_reference_uvec2 as required.
This commit is contained in:
Hans-Kristian Arntzen 2021-09-02 14:12:31 +02:00 committed by GitHub
commit 51d8e7be94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 112 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer PtrInt;
layout(buffer_reference, std430) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0, std430) buffer Buf
{
uvec2 ptr;
} _10;
void main()
{
PtrInt(_10.ptr).value = 10;
}

View File

@ -0,0 +1,22 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer PtrInt;
layout(buffer_reference, std430) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0, std430) buffer Buf
{
uvec2 ptr;
PtrInt ptrint;
} _13;
void main()
{
_13.ptr = uvec2(_13.ptrint);
}

View File

@ -0,0 +1,21 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
layout(buffer_reference) buffer PtrInt;
layout(buffer_reference, std430) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0, std430) buffer Buf
{
uvec2 ptr;
} _10;
void main()
{
PtrInt(_10.ptr).value = 10;
}

View File

@ -0,0 +1,19 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(buffer_reference) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0) buffer Buf
{
uvec2 ptr;
PtrInt ptrint;
};
void main()
{
ptr = uvec2(ptrint);
}

View File

@ -0,0 +1,18 @@
#version 450
#extension GL_EXT_buffer_reference : require
#extension GL_EXT_buffer_reference_uvec2 : require
layout(buffer_reference) buffer PtrInt
{
int value;
};
layout(set = 0, binding = 0) buffer Buf
{
uvec2 ptr;
};
void main()
{
PtrInt(ptr).value = 10;
}

View File

@ -8047,7 +8047,11 @@ string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &i
{
// OpBitcast can deal with pointers.
if (out_type.pointer || in_type.pointer)
{
if (out_type.vecsize == 2 || in_type.vecsize == 2)
require_extension_internal("GL_EXT_buffer_reference_uvec2");
return type_to_glsl(out_type);
}
if (out_type.basetype == in_type.basetype)
return "";
@ -12611,6 +12615,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (type.storage != StorageClassPhysicalStorageBufferEXT)
SPIRV_CROSS_THROW("Only StorageClassPhysicalStorageBufferEXT is supported by OpConvertUToPtr.");
auto &in_type = expression_type(ops[2]);
if (in_type.vecsize == 2)
require_extension_internal("GL_EXT_buffer_reference_uvec2");
auto op = type_to_glsl(type);
emit_unary_func_op(ops[0], ops[1], ops[2], op.c_str());
break;
@ -12623,6 +12631,9 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
if (ptr_type.storage != StorageClassPhysicalStorageBufferEXT)
SPIRV_CROSS_THROW("Only StorageClassPhysicalStorageBufferEXT is supported by OpConvertPtrToU.");
if (type.vecsize == 2)
require_extension_internal("GL_EXT_buffer_reference_uvec2");
auto op = type_to_glsl(type);
emit_unary_func_op(ops[0], ops[1], ops[2], op.c_str());
break;