32 lines
943 B
Plaintext
32 lines
943 B
Plaintext
#version 450 core
|
|
layout(std430) buffer;
|
|
|
|
layout(set=0, binding=0) writeonly uniform image2D uOutput;
|
|
layout(set=0, binding=1) uniform sampler2D uInput;
|
|
layout(set=0, binding=2) uniform sampler2D uSlope;
|
|
|
|
layout(set = 0, binding = 3) uniform reluBuffer{
|
|
ivec4 imgSize;
|
|
float slope;
|
|
}uPreluParam;
|
|
|
|
layout(local_size_x = 16, local_size_y = 16, local_size_z = 1) in;
|
|
|
|
void main()
|
|
{
|
|
ivec3 pos = ivec3(gl_GlobalInvocationID);
|
|
ivec3 imgSize = uPreluParam.imgSize.xyz;
|
|
int oz = pos.z % imgSize.z;
|
|
int ob = pos.z / imgSize.z;
|
|
if(pos.x < imgSize.x && pos.y < imgSize.y)
|
|
{
|
|
ivec2 imgPos = ivec2(pos.x + oz * uPreluParam.imgSize.x, pos.y + ob * uPreluParam.imgSize.y);
|
|
vec4 slope = texelFetch(uSlope, ivec2(oz, 0), 0);
|
|
vec4 dataIn = texelFetch(uInput, imgPos, 0);
|
|
vec4 dataTemp = dataIn * slope;
|
|
bvec4 lessZero = bvec4(lessThan(dataIn, vec4(0.0)));
|
|
imageStore(uOutput, imgPos, mix(dataIn, dataTemp, lessZero));
|
|
}
|
|
|
|
}
|