Attempt to fix some woopsies

This commit is contained in:
mcrcortex
2025-05-28 12:11:42 +10:00
parent efda204001
commit f9d1d9961b
4 changed files with 7 additions and 6 deletions

View File

@@ -80,10 +80,10 @@ public class MDICSectionRenderer extends AbstractSectionRenderer<MDICViewport, B
.compile(); .compile();
private final GlBuffer uniform = new GlBuffer(1024).zero(); private final GlBuffer uniform = new GlBuffer(1024).zero();//TODO move to viewport?
//TODO: needs to be in the viewport, since it contains the compute indirect call/values //TODO: needs to be in the viewport, since it contains the compute indirect call/values
private final GlBuffer distanceCountBuffer = new GlBuffer(1024*4+100_000*4).zero(); private final GlBuffer distanceCountBuffer = new GlBuffer(1024*4+100_000*4).zero();//TODO move to viewport?
//Statistics //Statistics
private final GlBuffer statisticsBuffer = new GlBuffer(1024).zero(); private final GlBuffer statisticsBuffer = new GlBuffer(1024).zero();

View File

@@ -23,7 +23,6 @@ layout(binding = TRANSLUCENT_DISTANCE_BUFFER_BINDING, std430) restrict buffer Tr
uint[] translucentCommandData; uint[] translucentCommandData;
}; };
//Note: if i want reverse indexing i need to use the index buffer offset to offset
void writeCmd(uint idx, uint instance, uint offset, uint quadCount) { void writeCmd(uint idx, uint instance, uint offset, uint quadCount) {
DrawCommand cmd; DrawCommand cmd;
cmd.count = quadCount * 6; cmd.count = quadCount * 6;
@@ -44,7 +43,8 @@ void main() {
uvec3 rel = abs(extractPosition(meta)-(baseSectionPos>>detail)); uvec3 rel = abs(extractPosition(meta)-(baseSectionPos>>detail));
uint dist = (rel.x+rel.y+rel.z)<<detail; uint dist = (rel.x+rel.y+rel.z)<<detail;
dist = TRANSLUCENT_WRITE_BASE-min(dist, TRANSLUCENT_WRITE_BASE); //The -1 is because we want 0 to TRANSLUCENT_WRITE_BASE, exclusive of ending, not inclusive (0->1023)
dist = (TRANSLUCENT_WRITE_BASE-1)-min(dist, (TRANSLUCENT_WRITE_BASE-1));
uint drawPtr = atomicAdd(translucentCommandData[dist],1)+TRANSLUCENT_OFFSET; uint drawPtr = atomicAdd(translucentCommandData[dist],1)+TRANSLUCENT_OFFSET;
writeCmd(drawPtr, drawId, extractQuadStart(meta), meta.cntA&0xFFFF); writeCmd(drawPtr, drawId, extractQuadStart(meta), meta.cntA&0xFFFF);

View File

@@ -113,7 +113,8 @@ void main() {
translucentCommandData[tp] = drawId; translucentCommandData[tp] = drawId;
uvec3 absRel = abs(relative); uvec3 absRel = abs(relative);
uint distToCamera = (absRel.x+absRel.y+absRel.z)<<detail; uint distToCamera = (absRel.x+absRel.y+absRel.z)<<detail;
distToCamera = TRANSLUCENT_WRITE_BASE-min(distToCamera, TRANSLUCENT_WRITE_BASE); //The -1 is because we want 0 to TRANSLUCENT_WRITE_BASE, exclusive of ending, not inclusive (0->1023)
distToCamera = (TRANSLUCENT_WRITE_BASE-1)-min(distToCamera, (TRANSLUCENT_WRITE_BASE-1));
atomicAdd(translucentCommandData[distToCamera], 1); atomicAdd(translucentCommandData[distToCamera], 1);
#ifdef HAS_STATISTICS #ifdef HAS_STATISTICS
totalQuads += count; totalQuads += count;

View File

@@ -87,7 +87,7 @@ void main() {
memoryBarrierShared(); memoryBarrierShared();
barrier(); barrier();
if (gl_SubgroupID == 0) { if (subgroupId == 0) {
uint val = warpPrefixSum[gl_SubgroupInvocationID]; uint val = warpPrefixSum[gl_SubgroupInvocationID];
subgroupBarrier(); subgroupBarrier();
//Use warp to do entire add in 1 reduction //Use warp to do entire add in 1 reduction