-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
83 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#version 450 | ||
|
||
#extension GL_GOOGLE_include_directive : enable | ||
#extension GL_ARB_separate_shader_objects : enable | ||
#extension GL_EXT_samplerless_texture_functions : enable | ||
|
||
#include "virtual_shadow/vsm_common.glsl" | ||
#include "scene.glsl" | ||
#include "common.glsl" | ||
|
||
layout(local_size_x = 32, local_size_y = 32) in; | ||
|
||
layout(binding = 0, std430) buffer Pages { VsmHeader header; uint pageList[]; } vsm; | ||
layout(binding = 1, r32ui) uniform uimage3D pageTbl; | ||
|
||
void trimPage(int mip) { | ||
const ivec3 size = imageSize(pageTbl); | ||
const ivec3 id = ivec3(gl_LocalInvocationID); | ||
|
||
const ivec2 b = ivec2(VSM_PAGE_TBL_SIZE/4); | ||
const ivec2 h = ivec2(VSM_PAGE_TBL_SIZE/2); | ||
|
||
for(int i=id.x; i<h.x; i+=int(gl_WorkGroupSize.x)) { | ||
for(int r=id.y; r<h.y; r+=int(gl_WorkGroupSize.y)) { | ||
ivec3 ax = ivec3(i+b.x, r+b.y, mip); | ||
uint st = imageLoad(pageTbl, ax).r; | ||
if(st==0) | ||
continue; | ||
|
||
ivec3 at = ivec3(i*2, r*2, mip-1); | ||
uint a = imageLoad(pageTbl, at+ivec3(0,0,0)).r; | ||
uint b = imageLoad(pageTbl, at+ivec3(1,0,0)).r; | ||
uint c = imageLoad(pageTbl, at+ivec3(0,1,0)).r; | ||
uint d = imageLoad(pageTbl, at+ivec3(1,1,0)).r; | ||
if(a+b+c+d == 4) { | ||
imageStore(pageTbl, ax, uvec4(0)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
void main() { | ||
const ivec3 size = imageSize(pageTbl); | ||
for(int i=0; i<size.z; ++i) | ||
trimPage(i); | ||
} |