Merge pull request #970 from KhronosGroup/fix-967

GLSL: Support OpBitcast for buffer references.
This commit is contained in:
Hans-Kristian Arntzen 2019-05-09 11:00:59 +02:00 committed by GitHub
commit 01451583c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 6 deletions

View File

@ -1,8 +1,8 @@
#!/bin/bash
GLSLANG_REV=ef807f4bc543e061f25dbbee6cb64dd5053b2adc
SPIRV_TOOLS_REV=12e4a7b649e6fe28683de9fc352200c82948a1f0
SPIRV_HEADERS_REV=111a25e4ae45e2b4d7c18415e1d6884712b958c4
GLSLANG_REV=e291f7a09f6733f6634fe077a228056fabee881e
SPIRV_TOOLS_REV=89fe836fe22c3e5c2a062ebeade012e2c2f0839b
SPIRV_HEADERS_REV=c4f8f65792d4bf2657ca751904c511bbcf2ac77b
if [ -z $PROTOCOL ]; then
PROTOCOL=git

View File

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

View File

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

View File

@ -22,7 +22,7 @@ void copy_node(restrict Node dst, restrict Node a, restrict Node b)
dst.value = a.value + b.value;
}
void overwrite_node(out Node dst, Node src)
void overwrite_node(out restrict Node dst, restrict Node src)
{
dst = src;
}

View File

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

View File

@ -21,7 +21,7 @@ void copy_node(restrict Node dst, restrict Node a, restrict Node b)
dst.value = a.value + b.value;
}
void overwrite_node(out Node dst, Node src)
void overwrite_node(out restrict Node dst, restrict Node src)
{
dst = src;
}

View File

@ -4217,7 +4217,7 @@ Compiler::PhysicalStorageBufferPointerHandler::PhysicalStorageBufferPointerHandl
bool Compiler::PhysicalStorageBufferPointerHandler::handle(Op op, const uint32_t *args, uint32_t)
{
if (op == OpConvertUToPtr)
if (op == OpConvertUToPtr || op == OpBitcast)
{
auto &type = compiler.get<SPIRType>(args[0]);
if (type.storage == StorageClassPhysicalStorageBufferEXT && type.pointer && type.pointer_depth == 1)

View File

@ -5772,6 +5772,10 @@ case OpGroupNonUniform##op: \
string CompilerGLSL::bitcast_glsl_op(const SPIRType &out_type, const SPIRType &in_type)
{
// OpBitcast can deal with pointers.
if (out_type.pointer || in_type.pointer)
return type_to_glsl(out_type);
if (out_type.basetype == in_type.basetype)
return "";