Temporal coherance
This commit is contained in:
@@ -59,20 +59,16 @@ void main() {
|
||||
vec3 cornerPos = vec3(((ipos<<detail)-baseSectionPos)<<5)-cameraSubPos;
|
||||
|
||||
|
||||
//Note! its not with respect to the sectionId
|
||||
//
|
||||
//Check the occlusion data from this frame occlusion
|
||||
bool shouldRender = visibilityData[gl_GlobalInvocationID.x] == frameId;
|
||||
uint dat = visibilityData[sectionId];
|
||||
|
||||
//Clear the occlusion data (not strictly? needed? i think???)
|
||||
//visibilityData[gl_GlobalInvocationID.x] = 0;
|
||||
|
||||
//TODO: need to make it check that only if it was also in the frustum last frame does it apply the visibilityData check!
|
||||
// this fixes temporal coherance
|
||||
//if the section was visible this frame
|
||||
bool shouldRender = (dat&0x7fffffffu) == frameId;
|
||||
bool renderTemporally = (dat&0x80000000u)==0;// means, if it was not visible last frame
|
||||
|
||||
|
||||
|
||||
if (shouldRender) {
|
||||
|
||||
#ifdef HAS_STATISTICS
|
||||
atomicAdd(visibleSectionCounts[detail], 1);
|
||||
#endif
|
||||
@@ -95,8 +91,15 @@ void main() {
|
||||
msk |= uint(((meta.cntA>>16)&0xFFFF)!=0)<<6;
|
||||
|
||||
|
||||
uint cmdPtr = atomicAdd(opaqueDrawCount, bitCount(msk));
|
||||
uint cmdCnt = bitCount(msk);
|
||||
uint cmdPtr = atomicAdd(opaqueDrawCount, cmdCnt);
|
||||
|
||||
uint tCmdPtr = 0;
|
||||
if (renderTemporally) {
|
||||
tCmdPtr = atomicAdd(temporalOpaqueDrawCount, cmdCnt) + TEMPORAL_OFFSET;
|
||||
}
|
||||
|
||||
//TODO: make totalQuads also have temporal amount
|
||||
#ifdef HAS_STATISTICS
|
||||
uint totalQuads = 0;
|
||||
#endif
|
||||
@@ -117,6 +120,9 @@ void main() {
|
||||
count = (meta.cntA>>16)&0xFFFF;
|
||||
if (count != 0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -127,6 +133,9 @@ void main() {
|
||||
count = (meta.cntB)&0xFFFF;
|
||||
if (((msk&(1u<<0))!=0)) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -137,6 +146,9 @@ void main() {
|
||||
count = (meta.cntB>>16)&0xFFFF;
|
||||
if ((msk&(1u<<1))!=0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -147,6 +159,9 @@ void main() {
|
||||
count = (meta.cntC)&0xFFFF;
|
||||
if ((msk&(1u<<2))!=0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -157,6 +172,9 @@ void main() {
|
||||
count = (meta.cntC>>16)&0xFFFF;
|
||||
if ((msk&(1u<<3))!=0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -167,6 +185,9 @@ void main() {
|
||||
count = (meta.cntD)&0xFFFF;
|
||||
if ((msk&(1u<<4))!=0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
@@ -177,6 +198,9 @@ void main() {
|
||||
count = (meta.cntD>>16)&0xFFFF;
|
||||
if ((msk&(1u<<5))!=0) {
|
||||
writeCmd(cmdPtr++, drawId, ptr, count);
|
||||
if (renderTemporally) {
|
||||
writeCmd(tCmdPtr++, drawId, ptr, count);
|
||||
}
|
||||
#ifdef HAS_STATISTICS
|
||||
totalQuads += count;
|
||||
#endif
|
||||
|
||||
@@ -7,9 +7,9 @@ layout(early_fragment_tests) in;
|
||||
|
||||
flat in uint id;
|
||||
flat in uint value;
|
||||
out vec4 colour;
|
||||
//out vec4 colour;
|
||||
|
||||
void main() {
|
||||
visibilityData[id] = value;
|
||||
colour = vec4(float(id&7u)/7, float((id>>3)&7u)/7, float((id>>6)&7u)/7, 1);
|
||||
//colour = vec4(float(id&7u)/7, float((id>>3)&7u)/7, float((id>>6)&7u)/7, 1);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#version 460 core
|
||||
#extension GL_ARB_gpu_shader_int64 : enable
|
||||
#define VISIBILITY_ACCESS writeonly
|
||||
#define VISIBILITY_ACCESS readonly
|
||||
|
||||
#define SECTION_METADATA_BUFFER_BINDING 1
|
||||
#define VISIBILITY_BUFFER_BINDING 2
|
||||
@@ -29,7 +29,10 @@ void main() {
|
||||
|
||||
gl_Position = MVP * vec4(vec3(pos),1);
|
||||
|
||||
//Write to this id
|
||||
id = gl_InstanceID;//Note!! we write to the instance id _not_ the section id
|
||||
value = frameId;
|
||||
//Write to the section id, to track temporal over time (litterally just need a single bit, 1 fking bit, but no)
|
||||
id = sid;
|
||||
|
||||
uint previous = visibilityData[sid]&0x7fffffffu;
|
||||
bool wasVisibleLastFrame = previous==(frameId-1);
|
||||
value = (frameId&0x7fffffffu)|(uint(wasVisibleLastFrame)<<31);//Encode if it was visible last frame
|
||||
}
|
||||
Reference in New Issue
Block a user