This commit is contained in:
mcrcortex
2025-09-11 22:05:46 +10:00
parent 711d3c44d3
commit 5657018a98
3 changed files with 56 additions and 9 deletions

View File

@@ -7,6 +7,7 @@ layout(binding = 2) uniform sampler2D depthTex;
layout(location=1) perprimitiveEXT in PerPrimData { layout(location=1) perprimitiveEXT in PerPrimData {
uvec4 data; uvec4 data;
uvec4 padd;
} primIn; } primIn;
layout(location = 0) out vec4 outColour; layout(location = 0) out vec4 outColour;
@@ -49,6 +50,29 @@ vec2 getBaseUV() {
void main() { void main() {
if (all(equal(primIn.data, uvec4(0)).yzw)) {
outColour = vec4(0,1,0,0);
} else {
if (all(equal(primIn.data, uvec4(1)).yzw)) {
outColour = vec4(1, 0, 1, 0);
} else {
outColour = vec4(primIn.data%256)/255;
return;
}
}
uint quadDebug = primIn.data.x;
uint hash = quadDebug;
if (hash != 0) {
hash = hash*1231421+123141;
hash ^= hash>>16;
hash = hash*1231421+123141;
hash ^= hash>>16;
hash = hash * 1827364925 + 123325621;
}
outColour = vec4(float(hash&15u)/15, float((hash>>4)&15u)/15, float((hash>>8)&15u)/15, 0);
return;
vec2 uv = vec2(0); vec2 uv = vec2(0);
//Tile is the tile we are in //Tile is the tile we are in
@@ -85,6 +109,14 @@ void main() {
} }
colour = computeColour(colour); colour = computeColour(colour);
outColour = colour; outColour = colour;
/*
uint quadDebug = gl_PrimitiveID;
uint hash = quadDebug*1231421+123141;
hash ^= hash>>16;
hash = hash*1231421+123141;
hash ^= hash>>16;
hash = hash * 1827364925 + 123325621;
outColour = vec4(float(hash&15u)/15, float((hash>>4)&15u)/15, float((hash>>8)&15u)/15, 1);*/
} }

View File

@@ -19,18 +19,19 @@ layout(triangles, max_vertices=(MESH_SIZE*4), max_primitives=(MESH_SIZE*2)) out;
//uvec4 binB; //uvec4 binB;
struct Task { struct Task {
uint bins[8]; uint bins[8];
vec3 cameraOffset; vec3 cameraOffset;
uint lodLvl; uint lodLvl;
uint baseQuad; uint baseQuad;
uint quadCount; uint quadCount;
//uint padddd[64];
}; };
taskPayloadSharedEXT Task task; taskPayloadSharedEXT Task task;
layout(location=1) perprimitiveEXT out PerPrimData { layout(location=1) perprimitiveEXT out PerPrimData {
uvec4 data; uvec4 data;
uvec4 padd;
} primOut[]; } primOut[];
@@ -273,6 +274,18 @@ layout(binding = STATISTICS_BUFFER_BINDING, std430) restrict buffer statisticsBu
#endif #endif
void main() { void main() {
/*
if (task.quadCount == 0) {
SetMeshOutputsEXT(0,0);
return;
}
SetMeshOutputsEXT(0,0);
#ifdef HAS_STATISTICS
atomicAdd(quadCounts[task.quadCount%5], 1);
#endif
return;
*/
uint qid = uint(-1); uint qid = uint(-1);
Quad quad; Quad quad;
if (gl_GlobalInvocationID.x<task.quadCount) { if (gl_GlobalInvocationID.x<task.quadCount) {
@@ -289,6 +302,7 @@ void main() {
uint qc = subgroupMax(triId_+(qid!=uint(-1)?2:0)); uint qc = subgroupMax(triId_+(qid!=uint(-1)?2:0));
SetMeshOutputsEXT(qc*2, qc); SetMeshOutputsEXT(qc*2, qc);
#ifdef HAS_STATISTICS #ifdef HAS_STATISTICS
if (subgroupElect()) { if (subgroupElect()) {
atomicAdd(quadCounts[task.lodLvl], qc); atomicAdd(quadCounts[task.lodLvl], qc);
@@ -317,11 +331,11 @@ void main() {
//Prim 1 //Prim 1
gl_PrimitiveTriangleIndicesEXT[triId] = uvec3(vertId_+0, vertId_+1, vertId); gl_PrimitiveTriangleIndicesEXT[triId] = uvec3(vertId_+0, vertId_+1, vertId);
gl_MeshVerticesEXT[vertId++].gl_Position = p0; gl_MeshVerticesEXT[vertId++].gl_Position = p0;
primOut[triId++].data = data; primOut[triId++].data = uvec4(qid,0,0,0);
//Prim 2 //Prim 2
gl_PrimitiveTriangleIndicesEXT[triId] = uvec3(vertId_+0, vertId, vertId_+1); gl_PrimitiveTriangleIndicesEXT[triId] = uvec3(vertId_+0, vertId, vertId_+1);
gl_MeshVerticesEXT[vertId++].gl_Position = p3; gl_MeshVerticesEXT[vertId++].gl_Position = p3;
primOut[triId++].data = data; primOut[triId++].data = uvec4(qid,1,1,1);
} }
} }

View File

@@ -40,12 +40,12 @@ struct Task {
//uvec4 binA; //uvec4 binA;
//uvec4 binB; //uvec4 binB;
uint bins[8]; uint bins[8];
vec3 cameraOffset; vec3 cameraOffset;
uint lodLvl; uint lodLvl;
uint baseQuad; uint baseQuad;
uint quadCount; uint quadCount;
//uint padddd[64];
}; };
taskPayloadSharedEXT Task task; taskPayloadSharedEXT Task task;
@@ -97,8 +97,7 @@ void main() {
bool shouldRender = (vis&0x7fffffffu) == frameId-1;//-1 since we are technically in the next frame for the primary rasterization bool shouldRender = (vis&0x7fffffffu) == frameId-1;//-1 since we are technically in the next frame for the primary rasterization
bool renderTemporally = (vis&0x80000000u)==0; bool renderTemporally = (vis&0x80000000u)==0;
task.quadCount = 0; uint qc = 0;
if (shouldRender) { if (shouldRender) {
SectionMeta section = sectionData[secId]; SectionMeta section = sectionData[secId];
@@ -114,12 +113,14 @@ void main() {
//TODO: here enqueue the id here for both translucent and temporal (if relevant) (* note technically dont need for temporal as can just check :tm: if we are in temporal render mode) //TODO: here enqueue the id here for both translucent and temporal (if relevant) (* note technically dont need for temporal as can just check :tm: if we are in temporal render mode)
task.baseQuad = extractQuadStart(section); task.baseQuad = extractQuadStart(section);
task.quadCount = fillBins(section.b, relative); qc = fillBins(section.b, relative);
task.quadCount = qc;
task.cameraOffset = vec3(((ipos<<detail) - baseSectionPos)<<5); task.cameraOffset = vec3(((ipos<<detail) - baseSectionPos)<<5);
task.lodLvl = detail; task.lodLvl = detail;
} }
//It appears to be valid to read from taskPayloadSharedEXT //It appears to be valid to read from taskPayloadSharedEXT
EmitMeshTasksEXT((task.quadCount+(MESH_SIZE-1))/MESH_SIZE, 1, 1); EmitMeshTasksEXT((qc+(MESH_SIZE-1))/MESH_SIZE, 1, 1);
} }