Tinkering trying to add intel gpu support, however its multidrawindirect does not work correctly, might need to try multidrawindrectcounted

This commit is contained in:
mcrcortex
2024-01-13 17:55:31 +10:00
parent e015632cec
commit 5d2a0e2de8
6 changed files with 55 additions and 25 deletions

View File

@@ -70,5 +70,8 @@ layout(binding = 7, std430) readonly restrict buffer LightingBuffer {
};
vec4 getLighting(uint index) {
return vec4((uvec4(lightData[index])>>uvec4(16,8,0,24))&uvec4(0xFF))*vec4(1f/255.0f);
uvec4 arr = uvec4(lightData[index]);
arr = arr>>uvec4(16,8,0,24);
arr = arr & uvec4(0xFF);
return vec4(arr)*vec4(1.0f/255.0f);
}

View File

@@ -26,6 +26,9 @@ uint encodeLocalLodPos(uint detail, ivec3 pos) {
return (detail<<29)|(detla.x<<20)|(detla.y<<11)|(detla.z<<2);
}
//TODO: swap to a multidraw indirect counted
void main() {
if (gl_GlobalInvocationID.x >= sectionCount) {
return;
@@ -37,16 +40,14 @@ void main() {
vec3 cornerPos = vec3(((ipos<<detail)-baseSectionPos)<<5)-cameraSubPos;
bool shouldRender = testFrustum(frustum, cornerPos, cornerPos+vec3(1<<(detail+5)));
//Check the occlusion data from last frame
if (visibilityData[gl_GlobalInvocationID.x] != frameId - 1) {
shouldRender = false;
}
bool shouldRender = visibilityData[gl_GlobalInvocationID.x] == frameId - 1;
//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
//This prevents overflow of the relative position encoder
if (shouldRender) {

View File

@@ -33,29 +33,39 @@ uint extractLightId(uint64_t quad) {
#define Quad ivec2
#define Eu32(data, amountBits, shift) (uint((data)>>(shift))&((1u<<(amountBits))-1))
//#define Eu32(data, amountBits, shift) (uint((data)>>(shift))&((1u<<(amountBits))-1))
uint Eu32v(ivec2 data, int amount, int shift) {
if (shift > 31) {
shift -= 32;
return (uint(data.y)>>uint(shift))&((1u<<uint(amount))-1);
} else {
return (uint(data.x)>>uint(shift))&((1u<<uint(amount))-1);
}
}
vec3 extractPos(ivec2 quad) {
return vec3(0);
return vec3(Eu32v(quad, 5, 21), Eu32v(quad, 5, 16), Eu32v(quad, 5, 11));
}
ivec2 extractSize(ivec2 quad) {
return ivec2(0);
return ivec2(Eu32v(quad, 4, 3), Eu32v(quad, 4, 7)) + ivec2(1);//the + 1 is cause you cant actually have a 0 size quad
}
uint extractFace(ivec2 quad) {
return quad.y&7;
return Eu32v(quad, 3, 0);
}
uint extractStateId(ivec2 quad) {
return 0;
//Eu32(quad, 20, 26);
return 1;
}
uint extractBiomeId(ivec2 quad) {
return 0;
return Eu32v(quad, 9, 46);
}
uint extractLightId(ivec2 quad) {
return 0;
return Eu32v(quad, 8, 55);
}
#endif