Add composite array test shaders for GLSL and HLSL as well.

This commit is contained in:
Hans-Kristian Arntzen 2018-09-10 10:21:08 +02:00
parent 57a15dfb0c
commit af672b7a4b
7 changed files with 227 additions and 0 deletions

View File

@ -0,0 +1,50 @@
static const float X = 4.0f;
static const uint3 gl_WorkGroupSize = uint3(2u, 1u, 1u);
struct Data
{
float a;
float b;
};
static const Data _21 = { 1.0f, 2.0f };
static const Data _24 = { 3.0f, 4.0f };
static const Data _25[2] = { { 1.0f, 2.0f }, { 3.0f, 4.0f } };
static const Data _30 = { 3.0f, 5.0f };
RWByteAddressBuffer _61 : register(u0);
static uint3 gl_WorkGroupID;
static uint3 gl_LocalInvocationID;
static uint gl_LocalInvocationIndex;
struct SPIRV_Cross_Input
{
uint3 gl_WorkGroupID : SV_GroupID;
uint3 gl_LocalInvocationID : SV_GroupThreadID;
uint gl_LocalInvocationIndex : SV_GroupIndex;
};
static Data data[2];
static Data data2[2];
void comp_main()
{
data = _25;
Data _28 = { X, 2.0f };
Data _31[2] = { _28, _30 };
data2 = _31;
if (gl_LocalInvocationIndex == 0u)
{
_61.Store(gl_WorkGroupID.x * 8 + 0, asuint(data[gl_LocalInvocationID.x].a + data2[gl_LocalInvocationID.x].a));
_61.Store(gl_WorkGroupID.x * 8 + 4, asuint(data[gl_LocalInvocationID.x].b + data2[gl_LocalInvocationID.x].b));
}
}
[numthreads(2, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
gl_WorkGroupID = stage_input.gl_WorkGroupID;
gl_LocalInvocationID = stage_input.gl_LocalInvocationID;
gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex;
comp_main();
}

View File

@ -0,0 +1,25 @@
#version 310 es
layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in;
struct Data
{
float a;
float b;
};
layout(binding = 0, std430) buffer SSBO
{
Data outdata[];
} _53;
Data data[2];
Data data2[2];
void main()
{
data = Data[](Data(1.0, 2.0), Data(3.0, 4.0));
data2 = Data[](Data(4.0, 2.0), Data(3.0, 5.0));
_53.outdata[gl_WorkGroupID.x].a = data[gl_LocalInvocationID.x].a + data2[gl_LocalInvocationID.x].a;
_53.outdata[gl_WorkGroupID.x].b = data[gl_LocalInvocationID.x].b + data2[gl_LocalInvocationID.x].b;
}

View File

@ -0,0 +1,59 @@
static const float X = 4.0f;
static const uint3 gl_WorkGroupSize = uint3(2u, 1u, 1u);
struct Data
{
float a;
float b;
};
static const Data _21 = { 1.0f, 2.0f };
static const Data _24 = { 3.0f, 4.0f };
static const Data _25[2] = { { 1.0f, 2.0f }, { 3.0f, 4.0f } };
static const Data _30 = { 3.0f, 5.0f };
RWByteAddressBuffer _61 : register(u0);
static uint3 gl_WorkGroupID;
static uint3 gl_LocalInvocationID;
static uint gl_LocalInvocationIndex;
struct SPIRV_Cross_Input
{
uint3 gl_WorkGroupID : SV_GroupID;
uint3 gl_LocalInvocationID : SV_GroupThreadID;
uint gl_LocalInvocationIndex : SV_GroupIndex;
};
static Data data[2];
static Data data2[2];
Data combine(Data a, Data b)
{
Data _46 = { a.a + b.a, a.b + b.b };
return _46;
}
void comp_main()
{
data = _25;
Data _28 = { X, 2.0f };
Data _31[2] = { _28, _30 };
data2 = _31;
if (gl_LocalInvocationIndex == 0u)
{
Data param = data[gl_LocalInvocationID.x];
Data param_1 = data2[gl_LocalInvocationID.x];
Data _79 = combine(param, param_1);
_61.Store(gl_WorkGroupID.x * 8 + 0, asuint(_79.a));
_61.Store(gl_WorkGroupID.x * 8 + 4, asuint(_79.b));
}
}
[numthreads(2, 1, 1)]
void main(SPIRV_Cross_Input stage_input)
{
gl_WorkGroupID = stage_input.gl_WorkGroupID;
gl_LocalInvocationID = stage_input.gl_LocalInvocationID;
gl_LocalInvocationIndex = stage_input.gl_LocalInvocationIndex;
comp_main();
}

View File

@ -0,0 +1,33 @@
#version 310 es
layout(local_size_x = 2, local_size_y = 1, local_size_z = 1) in;
struct Data
{
float a;
float b;
};
layout(binding = 0, std430) buffer SSBO
{
Data outdata[];
} _53;
Data data[2];
Data data2[2];
Data combine(Data a, Data b)
{
return Data(a.a + b.a, a.b + b.b);
}
void main()
{
data = Data[](Data(1.0, 2.0), Data(3.0, 4.0));
data2 = Data[](Data(4.0, 2.0), Data(3.0, 5.0));
Data param = data[gl_LocalInvocationID.x];
Data param_1 = data2[gl_LocalInvocationID.x];
Data _73 = combine(param, param_1);
_53.outdata[gl_WorkGroupID.x].a = _73.a;
_53.outdata[gl_WorkGroupID.x].b = _73.b;
}

View File

@ -0,0 +1,29 @@
#version 450
layout(local_size_x = 2) in;
struct Data
{
float a;
float b;
};
layout(std430, binding = 0) buffer SSBO
{
Data outdata[];
};
layout(constant_id = 0) const float X = 4.0;
Data data[2] = Data[](Data(1.0, 2.0), Data(3.0, 4.0));
Data data2[2] = Data[](Data(X, 2.0), Data(3.0, 5.0));
Data combine(Data a, Data b)
{
return Data(a.a + b.a, a.b + b.b);
}
void main()
{
if (gl_LocalInvocationIndex == 0u)
outdata[gl_WorkGroupID.x] = combine(data[gl_LocalInvocationID.x], data2[gl_LocalInvocationID.x]);
}

View File

@ -0,0 +1,29 @@
#version 310 es
#extension GL_EXT_shader_non_constant_global_initializers : require
layout(local_size_x = 2) in;
struct Data
{
float a;
float b;
};
layout(std430, binding = 0) buffer SSBO
{
Data outdata[];
};
layout(constant_id = 0) const float X = 4.0;
Data data[2] = Data[](Data(1.0, 2.0), Data(3.0, 4.0));
Data data2[2] = Data[](Data(X, 2.0), Data(3.0, 5.0));
Data combine(Data a, Data b)
{
return Data(a.a + b.a, a.b + b.b);
}
void main()
{
outdata[gl_WorkGroupID.x] = combine(data[gl_LocalInvocationID.x], data2[gl_LocalInvocationID.x]);
}

View File

@ -3527,6 +3527,8 @@ void CompilerHLSL::emit_access_chain(const Instruction &instruction)
bool need_transpose;
base = access_chain(ops[2], &ops[3], to_plain_buffer_length, get<SPIRType>(ops[0]), &need_transpose);
}
else if (chain)
base = chain->base;
else
base = to_expression(ops[2]);