2021-07-05 17:18:16 +00:00
|
|
|
SamplerState samp : register(s0, space0);
|
|
|
|
cbuffer cbuffer_params : register(b1, space0) {
|
|
|
|
uint4 params[1];
|
|
|
|
};
|
|
|
|
Texture2D<float4> inputTex : register(t1, space1);
|
|
|
|
RWTexture2D<float4> outputTex : register(u2, space1);
|
|
|
|
|
|
|
|
cbuffer cbuffer_flip : register(b3, space1) {
|
|
|
|
uint4 flip[1];
|
|
|
|
};
|
|
|
|
groupshared float3 tile[4][256];
|
|
|
|
|
|
|
|
struct tint_symbol_1 {
|
|
|
|
uint3 LocalInvocationID : SV_GroupThreadID;
|
|
|
|
uint local_invocation_index : SV_GroupIndex;
|
|
|
|
uint3 WorkGroupID : SV_GroupID;
|
|
|
|
};
|
|
|
|
|
2021-08-04 22:15:28 +00:00
|
|
|
void main_inner(uint3 WorkGroupID, uint3 LocalInvocationID, uint local_invocation_index) {
|
2021-07-30 14:08:06 +00:00
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint idx = local_invocation_index; (idx < 1024u); idx = (idx + 64u)) {
|
2021-07-30 14:08:06 +00:00
|
|
|
const uint i_1 = (idx / 256u);
|
|
|
|
const uint i_2 = (idx % 256u);
|
|
|
|
tile[i_1][i_2] = float3(0.0f, 0.0f, 0.0f);
|
2021-07-05 17:18:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
2021-07-13 12:18:13 +00:00
|
|
|
const uint filterOffset = ((params[0].x - 1u) / 2u);
|
2021-07-05 17:18:16 +00:00
|
|
|
int3 tint_tmp;
|
|
|
|
inputTex.GetDimensions(0, tint_tmp.x, tint_tmp.y, tint_tmp.z);
|
|
|
|
const int2 dims = tint_tmp.xy;
|
2021-07-13 12:18:13 +00:00
|
|
|
const int2 baseIndex = (int2(((WorkGroupID.xy * uint2(params[0].y, 4u)) + (LocalInvocationID.xy * uint2(4u, 1u)))) - int2(int(filterOffset), 0));
|
2021-07-05 17:18:16 +00:00
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint r = 0u; (r < 4u); r = (r + 1u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint c = 0u; (c < 4u); c = (c + 1u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
int2 loadIndex = (baseIndex + int2(int(c), int(r)));
|
2021-07-13 12:18:13 +00:00
|
|
|
if ((flip[0].x != 0u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
loadIndex = loadIndex.yx;
|
|
|
|
}
|
|
|
|
tile[r][((4u * LocalInvocationID.x) + c)] = inputTex.SampleLevel(samp, ((float2(loadIndex) + float2(0.25f, 0.25f)) / float2(dims)), 0.0f).rgb;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
GroupMemoryBarrierWithGroupSync();
|
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint r = 0u; (r < 4u); r = (r + 1u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint c = 0u; (c < 4u); c = (c + 1u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
int2 writeIndex = (baseIndex + int2(int(c), int(r)));
|
2021-07-13 12:18:13 +00:00
|
|
|
if ((flip[0].x != 0u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
writeIndex = writeIndex.yx;
|
|
|
|
}
|
|
|
|
const uint center = ((4u * LocalInvocationID.x) + c);
|
|
|
|
bool tint_tmp_2 = (center >= filterOffset);
|
|
|
|
if (tint_tmp_2) {
|
|
|
|
tint_tmp_2 = (center < (256u - filterOffset));
|
|
|
|
}
|
|
|
|
bool tint_tmp_1 = (tint_tmp_2);
|
|
|
|
if (tint_tmp_1) {
|
|
|
|
tint_tmp_1 = all((writeIndex < dims));
|
|
|
|
}
|
|
|
|
if ((tint_tmp_1)) {
|
|
|
|
float3 acc = float3(0.0f, 0.0f, 0.0f);
|
|
|
|
{
|
2021-11-22 19:31:56 +00:00
|
|
|
for(uint f = 0u; (f < params[0].x); f = (f + 1u)) {
|
2021-07-05 17:18:16 +00:00
|
|
|
uint i = ((center + f) - filterOffset);
|
2021-07-13 12:18:13 +00:00
|
|
|
acc = (acc + ((1.0f / float(params[0].x)) * tile[r][i]));
|
2021-07-05 17:18:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
outputTex[writeIndex] = float4(acc, 1.0f);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-04 22:15:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[numthreads(64, 1, 1)]
|
|
|
|
void main(tint_symbol_1 tint_symbol) {
|
|
|
|
main_inner(tint_symbol.WorkGroupID, tint_symbol.LocalInvocationID, tint_symbol.local_invocation_index);
|
2021-07-05 17:18:16 +00:00
|
|
|
return;
|
|
|
|
}
|