Skip to content

Commit 5007a81

Browse files
finished shared mem refactor
1 parent f1c9d93 commit 5007a81

File tree

2 files changed

+3
-15
lines changed

2 files changed

+3
-15
lines changed

examples_tests/39.DenoiserTonemapper/ShaderCommon.glsl

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@ struct f16vec3_packed
2626
float16_t z;
2727
};
2828

29-
// the amount of memory needed for luma metering is bigger than interleaving
30-
#define _NBL_GLSL_SCRATCH_SHARED_SIZE_DEFINED_ ((COMPUTE_WG_SIZE+1)*8)
31-
shared uint repackBuffer[_NBL_GLSL_SCRATCH_SHARED_SIZE_DEFINED_];
32-
#define _NBL_GLSL_SCRATCH_SHARED_DEFINED_ repackBuffer
33-
3429

3530
// luma metering stuff
3631
// those don't really influence anything but need to let the header know that we're using the same number of invocations as bins

examples_tests/39.DenoiserTonemapper/main.cpp

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ void main()
301301
#include "nbl/builtin/glsl/ext/ToneMapper/operators.glsl"
302302
layout(binding = 0, std430) restrict readonly buffer ImageInputBuffer
303303
{
304-
float16_t inBuffer[];
304+
f16vec3_packed inBuffer[];
305305
};
306306
layout(binding = 1, std430) restrict writeonly buffer ImageOutputBuffer
307307
{
@@ -314,16 +314,9 @@ layout(binding = 3, std430) restrict readonly buffer IntensityBuffer
314314
void main()
315315
{
316316
// TODO: compute iFFT of the image
317-
uint wgOffset = (gl_GlobalInvocationID.y*pc.data.imageWidth+gl_WorkGroupID.x*COMPUTE_WG_SIZE)*SHARED_CHANNELS;
318-
uint localOffset = gl_LocalInvocationIndex;
319-
repackBuffer[localOffset] = floatBitsToUint(float(inBuffer[wgOffset+localOffset]));
320-
localOffset += COMPUTE_WG_SIZE;
321-
repackBuffer[localOffset] = floatBitsToUint(float(inBuffer[wgOffset+localOffset]));
322-
localOffset += COMPUTE_WG_SIZE;
323-
repackBuffer[localOffset] = floatBitsToUint(float(inBuffer[wgOffset+localOffset]));
324-
barrier();
317+
const uint inAddr = gl_GlobalInvocationID.y*pc.data.imageWidth+gl_GlobalInvocationID.x;
325318
bool alive = gl_GlobalInvocationID.x<pc.data.imageWidth;
326-
vec3 color = uintBitsToFloat(uvec3(repackBuffer[gl_LocalInvocationIndex*SHARED_CHANNELS+0u],repackBuffer[gl_LocalInvocationIndex*SHARED_CHANNELS+1u],repackBuffer[gl_LocalInvocationIndex*SHARED_CHANNELS+2u]));
319+
vec3 color = vec3(inBuffer[inAddr].x,inBuffer[inAddr].y,inBuffer[inAddr].z);
327320
328321
color = _NBL_GLSL_EXT_LUMA_METER_XYZ_CONVERSION_MATRIX_DEFINED_*color;
329322
color *= intensity[pc.data.intensityBufferDWORDOffset]; // *= 0.18/AvgLuma

0 commit comments

Comments
 (0)