Skip to content

Commit

Permalink
Merged pull request "Fix for barrier in not dynamically uniform contr…
Browse files Browse the repository at this point in the history
…ol flow": #129
  • Loading branch information
apanteleev committed Aug 23, 2021
2 parents 6227941 + f1a0682 commit 37e296c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/refresh/vkpt/shader/tone_mapping_histogram.comp
Original file line number Diff line number Diff line change
Expand Up @@ -175,17 +175,16 @@ void main()
const ivec2 ipos = ivec2(gl_GlobalInvocationID);
const ivec2 screenSize = ivec2(global_ubo.taa_output_width, global_ubo.taa_output_height);

if(any(greaterThanEqual(ipos, screenSize)))
return;
bool validThread = !any(greaterThanEqual(ipos, screenSize));

vec3 input_color = imageLoad(IMG_TAA_OUTPUT, ipos).rgb;
vec3 input_color = validThread ? imageLoad(IMG_TAA_OUTPUT, ipos).rgb : vec3(0.0);
input_color /= STORAGE_SCALE_HDR;

const uint linear_idx = gl_LocalInvocationIndex;

// Compute and write histogram value
// Initialize local memory
if(linear_idx < HISTOGRAM_BINS)
if(validThread && linear_idx < HISTOGRAM_BINS)
{
s_Histogram[linear_idx] = 0;
}
Expand All @@ -194,7 +193,7 @@ void main()
barrier();

// Ignore completely black pixels
if(luminance(input_color) > 0)
if(validThread && luminance(input_color) > 0)
{
// Compute histogram bin (based on photographic stops)
// This is (log2(lum) - min_log_luminance)/(max_log_luminance - min_log_luminance),
Expand Down Expand Up @@ -230,7 +229,7 @@ void main()
barrier();

// Add warp histogram to global histogram.
if(linear_idx < HISTOGRAM_BINS)
if(validThread && linear_idx < HISTOGRAM_BINS)
{
int localBinValue = int(s_Histogram[linear_idx]);
if (localBinValue != 0)
Expand Down

0 comments on commit 37e296c

Please sign in to comment.