Render basics

This commit is contained in:
mcrcortex
2024-08-04 22:08:49 +10:00
parent 0bb04b2f8e
commit e4fe056586
12 changed files with 120 additions and 33 deletions

View File

@@ -60,13 +60,17 @@ layout(binding = DRAW_COUNT_BUFFER_BINDING, std430) restrict buffer DrawCommandC
uint cmdGenDispatchX;
uint cmdGenDispatchY;
uint cmdGenDispatchZ;
uint opaqueDrawCount;
uint translucentDrawCount;
uint pad_A;
DrawCommand cullDrawIndirectCommand;
};
#endif
#ifdef SECTION_METADA_BUFFER_BINDING
layout(binding = SECTION_METADA_BUFFER_BINDING, std430) readonly restrict buffer SectionBuffer {
#ifdef SECTION_METADATA_BUFFER_BINDING
layout(binding = SECTION_METADATA_BUFFER_BINDING, std430) readonly restrict buffer SectionBuffer {
SectionMeta sectionData[];
};
#endif

View File

@@ -5,7 +5,7 @@ layout(local_size_x = 128) in;
#define DRAW_BUFFER_BINDING 1
#define DRAW_COUNT_BUFFER_BINDING 2
#define SECTION_METADA_BUFFER_BINDING 3
#define SECTION_METADATA_BUFFER_BINDING 3
#define VISIBILITY_BUFFER_BINDING 4
#define INDIRECT_SECTION_LOOKUP_BINDING 5
@@ -97,8 +97,8 @@ void main() {
//Translucency
count = meta.cntA&0xFFFF;
if (count != 0) {
uint translucentCommandPtr = atomicAdd(translucentDrawCount, 1) + 400000;//FIXME: dont hardcode this offset
writeCmd(translucentCommandPtr, encodedPos, ptr, count);
//uint translucentCommandPtr = atomicAdd(translucentDrawCount, 1) + 400000;//FIXME: dont hardcode this offset
//writeCmd(translucentCommandPtr, encodedPos, ptr, count);
}
ptr += count;

View File

@@ -1,6 +1,7 @@
#version 460 core
#extension GL_ARB_gpu_shader_int64 : enable
#define VISIBILITY_ACCESS writeonly
#define VISIBILITY_BUFFER_BINDING 2
#import <voxy:lod/gl46/bindings.glsl>
layout(early_fragment_tests) in;

View File

@@ -1,6 +1,11 @@
#version 460 core
#extension GL_ARB_gpu_shader_int64 : enable
#define VISIBILITY_ACCESS writeonly
#define SECTION_METADATA_BUFFER_BINDING 1
#define VISIBILITY_BUFFER_BINDING 2
#define INDIRECT_SECTION_LOOKUP_BINDING 3
#import <voxy:lod/gl46/bindings.glsl>
#import <voxy:lod/section.glsl>
@@ -8,7 +13,7 @@ flat out uint id;
flat out uint value;
void main() {
uint sid = gl_InstanceID;
uint sid = indirectLookup[gl_InstanceID];
SectionMeta section = sectionData[sid];
@@ -25,6 +30,6 @@ void main() {
gl_Position = MVP * vec4(vec3(pos),1);
//Write to this id
id = sid;
id = gl_InstanceID;//Note!! we write to the instance id _not_ the section id
value = frameId;
}

View File

@@ -0,0 +1,23 @@
#version 450
layout(local_size_x = 1) in;
#define DRAW_COUNT_BUFFER_BINDING 1
#define INDIRECT_SECTION_LOOKUP_BINDING 2
#import <voxy:lod/gl46/bindings.glsl>
void main() {
cmdGenDispatchX = ((sectionCount+127)/128);
cmdGenDispatchY = 1;
cmdGenDispatchZ = 1;
opaqueDrawCount = 0;
translucentDrawCount = 0;
cullDrawIndirectCommand.count = 6*2*3;
cullDrawIndirectCommand.instanceCount = sectionCount;
cullDrawIndirectCommand.firstIndex = (1<<16)*6*2;
cullDrawIndirectCommand.baseVertex = 0;
cullDrawIndirectCommand.baseInstance = 0;
}

View File

@@ -2,7 +2,7 @@
#extension GL_ARB_gpu_shader_int64 : enable
#define QUAD_BUFFER_BINDING 1
#define SECTION_METADA_BUFFER_BINDING 2
#define SECTION_METADATA_BUFFER_BINDING 2
#define MODEL_BUFFER_BINDING 3
#define MODEL_COLOUR_BUFFER_BINDING 4
#define LIGHTING_BUFFER_BINDING 5