mirror of
https://github.com/KhronosGroup/SPIRV-Cross.git
synced 2024-11-09 22:00:05 +00:00
Support globallycoherent in HLSL.
This commit is contained in:
parent
7607eb6923
commit
10dfaf79d5
16
reference/opt/shaders-hlsl/comp/globallycoherent.comp
Normal file
16
reference/opt/shaders-hlsl/comp/globallycoherent.comp
Normal file
@ -0,0 +1,16 @@
|
||||
globallycoherent RWByteAddressBuffer _29 : register(u3);
|
||||
ByteAddressBuffer _33 : register(t2);
|
||||
RWTexture2D<float> uImageIn : register(u0);
|
||||
globallycoherent RWTexture2D<float> uImageOut : register(u1);
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
uImageOut[int2(9, 7)] = uImageIn[int2(9, 7)].x;
|
||||
_29.Store(0, asuint(asfloat(_33.Load(0))));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
comp_main();
|
||||
}
|
18
reference/shaders-hlsl/comp/globallycoherent.comp
Normal file
18
reference/shaders-hlsl/comp/globallycoherent.comp
Normal file
@ -0,0 +1,18 @@
|
||||
globallycoherent RWByteAddressBuffer _29 : register(u3);
|
||||
ByteAddressBuffer _33 : register(t2);
|
||||
RWTexture2D<float> uImageIn : register(u0);
|
||||
globallycoherent RWTexture2D<float> uImageOut : register(u1);
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
int2 coord = int2(9, 7);
|
||||
float4 indata = uImageIn[coord].xxxx;
|
||||
uImageOut[coord] = indata.x;
|
||||
_29.Store(0, asuint(asfloat(_33.Load(0))));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
comp_main();
|
||||
}
|
25
shaders-hlsl/comp/globallycoherent.comp
Normal file
25
shaders-hlsl/comp/globallycoherent.comp
Normal file
@ -0,0 +1,25 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
layout(r32f, binding = 0) uniform readonly image2D uImageIn;
|
||||
layout(r32f, binding = 1) uniform coherent writeonly image2D uImageOut;
|
||||
|
||||
layout(set = 0, binding = 2) readonly buffer Foo
|
||||
{
|
||||
float foo;
|
||||
};
|
||||
|
||||
layout(set = 0, binding = 3) coherent writeonly buffer Bar
|
||||
{
|
||||
float bar;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
ivec2 coord = ivec2(9, 7);
|
||||
vec4 indata = imageLoad(uImageIn, coord);
|
||||
imageStore(uImageOut, coord, indata);
|
||||
|
||||
bar = foo;
|
||||
}
|
||||
|
@ -1838,9 +1838,10 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
{
|
||||
Bitset flags = get_buffer_block_flags(var);
|
||||
bool is_readonly = flags.get(DecorationNonWritable);
|
||||
bool is_coherent = flags.get(DecorationCoherent);
|
||||
add_resource_name(var.self);
|
||||
statement(is_readonly ? "ByteAddressBuffer " : "RWByteAddressBuffer ", to_name(var.self),
|
||||
type_to_array_glsl(type), to_resource_binding(var), ";");
|
||||
statement(is_coherent ? "globallycoherent " : "", is_readonly ? "ByteAddressBuffer " : "RWByteAddressBuffer ",
|
||||
to_name(var.self), type_to_array_glsl(type), to_resource_binding(var), ";");
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2922,8 +2923,12 @@ void CompilerHLSL::emit_modern_uniform(const SPIRVariable &var)
|
||||
case SPIRType::SampledImage:
|
||||
case SPIRType::Image:
|
||||
{
|
||||
statement(image_type_hlsl_modern(type), " ", to_name(var.self), type_to_array_glsl(type),
|
||||
to_resource_binding(var), ";");
|
||||
bool is_coherent = false;
|
||||
if (type.basetype == SPIRType::Image && type.image.sampled == 2)
|
||||
is_coherent = has_decoration(var.self, DecorationCoherent);
|
||||
|
||||
statement(is_coherent ? "globallycoherent " : "", image_type_hlsl_modern(type), " ", to_name(var.self),
|
||||
type_to_array_glsl(type), to_resource_binding(var), ";");
|
||||
|
||||
if (type.basetype == SPIRType::SampledImage && type.image.dim != DimBuffer)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user