mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-31 07:15:00 +01:00
Error count decreasing
- Mostly silly typos - Do not clear the visbuffer if it hasn't been generated yet - Grow pass two index buffer instead of pass two dispatch buffer
This commit is contained in:
parent
b6ed3cefda
commit
4552716b74
5 changed files with 27 additions and 13 deletions
|
@ -90,14 +90,14 @@ public class IndirectBuffers {
|
|||
|
||||
void updateCounts(int instanceCount, int modelCount, int drawCount) {
|
||||
drawInstanceIndex.ensureCapacity(instanceCount);
|
||||
passTwoDispatch.ensureCapacity(instanceCount);
|
||||
passTwoInstanceIndex.ensureCapacity(instanceCount);
|
||||
model.ensureCapacity(modelCount);
|
||||
draw.ensureCapacity(drawCount);
|
||||
|
||||
final long ptr = multiBindBlock.ptr();
|
||||
|
||||
MemoryUtil.memPutInt(ptr + PASS_TWO_DISPATCH_HANDLE_OFFSET, passTwoDispatch.handle());
|
||||
MemoryUtil.memPutInt(ptr + PASS_TWO_INSTANCE_INDEX_HANDLE_OFFSET, objectStorage.frameDescriptorBuffer.handle());
|
||||
MemoryUtil.memPutInt(ptr + PASS_TWO_INSTANCE_INDEX_HANDLE_OFFSET, passTwoInstanceIndex.handle());
|
||||
MemoryUtil.memPutInt(ptr + PAGE_FRAME_DESCRIPTOR_HANDLE_OFFSET, objectStorage.frameDescriptorBuffer.handle());
|
||||
MemoryUtil.memPutInt(ptr + INSTANCE_HANDLE_OFFSET, objectStorage.objectBuffer.handle());
|
||||
MemoryUtil.memPutInt(ptr + DRAW_INSTANCE_INDEX_HANDLE_OFFSET, drawInstanceIndex.handle());
|
||||
|
@ -105,7 +105,7 @@ public class IndirectBuffers {
|
|||
MemoryUtil.memPutInt(ptr + DRAW_HANDLE_OFFSET, draw.handle());
|
||||
|
||||
MemoryUtil.memPutAddress(ptr + PASS_TWO_DISPATCH_SIZE_OFFSET, passTwoDispatch.capacity());
|
||||
MemoryUtil.memPutAddress(ptr + PASS_TWO_INSTANCE_INDEX_SIZE_OFFSET, objectStorage.frameDescriptorBuffer.capacity());
|
||||
MemoryUtil.memPutAddress(ptr + PASS_TWO_INSTANCE_INDEX_SIZE_OFFSET, passTwoInstanceIndex.capacity());
|
||||
MemoryUtil.memPutAddress(ptr + PAGE_FRAME_DESCRIPTOR_SIZE_OFFSET, objectStorage.frameDescriptorBuffer.capacity());
|
||||
MemoryUtil.memPutAddress(ptr + INSTANCE_SIZE_OFFSET, objectStorage.objectBuffer.capacity());
|
||||
MemoryUtil.memPutAddress(ptr + DRAW_INSTANCE_INDEX_SIZE_OFFSET, INT_SIZE * instanceCount);
|
||||
|
@ -144,7 +144,10 @@ public class IndirectBuffers {
|
|||
|
||||
private void multiBind(int base, int count) {
|
||||
final long ptr = multiBindBlock.ptr();
|
||||
nglBindBuffersRange(GL_SHADER_STORAGE_BUFFER, base, count, ptr + base * INT_SIZE, ptr + OFFSET_OFFSET + base * PTR_SIZE, ptr + SIZE_OFFSET + base * PTR_SIZE);
|
||||
long handlePtr = ptr + HANDLE_OFFSET + base * INT_SIZE;
|
||||
long offsetPtr = ptr + OFFSET_OFFSET + base * PTR_SIZE;
|
||||
long sizePtr = ptr + SIZE_OFFSET + base * PTR_SIZE;
|
||||
nglBindBuffersRange(GL_SHADER_STORAGE_BUFFER, base, count, handlePtr, offsetPtr, sizePtr);
|
||||
}
|
||||
|
||||
public void delete() {
|
||||
|
|
|
@ -99,6 +99,10 @@ public class VisibilityBuffer {
|
|||
}
|
||||
|
||||
public void clear() {
|
||||
if (lastWidth == -1 || lastHeight == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
GL46C.nglClearTexImage(textureId, 0, GL32.GL_RED_INTEGER, GL32.GL_UNSIGNED_INT, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ layout(std430, binding = _FLW_PASS_TWO_DISPATCH_BUFFER_BINDING) restrict buffer
|
|||
_FlwLateCullDispatch _flw_lateCullDispatch;
|
||||
};
|
||||
|
||||
layout(std430, binding = _FLW_PASS_TWO_INSTANCE_INDEX_BUFFER_BINDING) restrict readonly buffer PassTwoIndexBuffer {
|
||||
uint _flw_passTwoIndicies[];
|
||||
layout(std430, binding = _FLW_PASS_TWO_INSTANCE_INDEX_BUFFER_BINDING) restrict writeonly buffer PassTwoIndexBuffer {
|
||||
uint _flw_passTwoIndices[];
|
||||
};
|
||||
|
||||
layout(std430, binding = _FLW_DRAW_INSTANCE_INDEX_BUFFER_BINDING) restrict writeonly buffer DrawIndexBuffer {
|
||||
|
|
|
@ -7,13 +7,20 @@
|
|||
layout(local_size_x = 32) in;
|
||||
|
||||
layout(std430, binding = _FLW_PASS_TWO_INSTANCE_INDEX_BUFFER_BINDING) restrict readonly buffer PassTwoIndexBuffer {
|
||||
uint _flw_passTwoIndicies[];
|
||||
uint _flw_passTwoIndices[];
|
||||
};
|
||||
|
||||
layout(std430, binding = _FLW_DRAW_INSTANCE_INDEX_BUFFER_BINDING) restrict writeonly buffer DrawIndexBuffer {
|
||||
uint _flw_drawIndices[];
|
||||
};
|
||||
|
||||
|
||||
// High 6 bits for the number of instances in the page.
|
||||
const uint _FLW_PAGE_COUNT_OFFSET = 26u;
|
||||
// Bottom 26 bits for the model index.
|
||||
const uint _FLW_MODEL_INDEX_MASK = 0x3FFFFFF;
|
||||
|
||||
|
||||
layout(std430, binding = _FLW_PAGE_FRAME_DESCRIPTOR_BUFFER_BINDING) restrict readonly buffer PageFrameDescriptorBuffer {
|
||||
uint _flw_pageFrameDescriptors[];
|
||||
};
|
||||
|
@ -104,7 +111,7 @@ bool _flw_isVisible(uint instanceIndex, uint modelIndex) {
|
|||
}
|
||||
|
||||
void main() {
|
||||
if (gl_GlobalInvocationID.x >= _flw_passTwoIndicies.length()) {
|
||||
if (gl_GlobalInvocationID.x >= _flw_passTwoIndices.length()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -119,6 +126,6 @@ void main() {
|
|||
if (_flw_isVisible(instanceIndex, modelIndex)) {
|
||||
uint localIndex = atomicAdd(_flw_models[modelIndex].instanceCount, 1);
|
||||
uint targetIndex = _flw_models[modelIndex].baseInstance + localIndex;
|
||||
_flw_instanceIndices[targetIndex] = instanceIndex;
|
||||
_flw_drawIndices[targetIndex] = instanceIndex;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
#include "flywheel:internal/indirect/light.glsl"
|
||||
#include "flywheel:internal/indirect/matrices.glsl"
|
||||
|
||||
layout(std430, binding = _FLW_TARGET_BUFFER_BINDING) restrict readonly buffer TargetBuffer {
|
||||
uint _flw_instanceIndices[];
|
||||
layout(std430, binding = _FLW_DRAW_INSTANCE_INDEX_BUFFER_BINDING) restrict readonly buffer DrawIndexBuffer {
|
||||
uint _flw_drawIndices[];
|
||||
};
|
||||
|
||||
layout(std430, binding = _FLW_DRAW_BUFFER_BINDING) restrict readonly buffer DrawBuffer {
|
||||
|
@ -49,9 +49,9 @@ void main() {
|
|||
#endif
|
||||
|
||||
#if __VERSION__ < 460
|
||||
uint instanceIndex = _flw_instanceIndices[gl_BaseInstanceARB + gl_InstanceID];
|
||||
uint instanceIndex = _flw_drawIndices[gl_BaseInstanceARB + gl_InstanceID];
|
||||
#else
|
||||
uint instanceIndex = _flw_instanceIndices[gl_BaseInstance + gl_InstanceID];
|
||||
uint instanceIndex = _flw_drawIndices[gl_BaseInstance + gl_InstanceID];
|
||||
#endif
|
||||
FlwInstance instance = _flw_unpackInstance(instanceIndex);
|
||||
|
||||
|
|
Loading…
Reference in a new issue