impostor indirect buffer merged into impostor data buffer
This commit is contained in:
@@ -12,7 +12,7 @@ static const float3 BILLBOARD[] = {
|
||||
RWBuffer<uint> output_indices : register(u0);
|
||||
RWByteAddressBuffer output_vertices_pos_nor : register(u1);
|
||||
RWByteAddressBuffer output_impostor_data : register(u2);
|
||||
RWStructuredBuffer<IndirectDrawArgsIndexedInstanced> output_indirect : register(u3);
|
||||
RWByteAddressBuffer output_indirect : register(u3);
|
||||
|
||||
struct ObjectCount
|
||||
{
|
||||
@@ -46,7 +46,7 @@ void main(uint3 DTid : SV_DispatchThreadID)
|
||||
uint waveOffset;
|
||||
if (WaveIsFirstLane() && waveAppendCount > 0)
|
||||
{
|
||||
InterlockedAdd(output_indirect[0].IndexCountPerInstance, waveAppendCount * 6u, waveOffset);
|
||||
output_indirect.InterlockedAdd(0, waveAppendCount * 6u, waveOffset); // atomic into IndexCountPerInstance
|
||||
}
|
||||
waveOffset = WaveReadLaneFirst(waveOffset);
|
||||
|
||||
|
||||
@@ -2860,7 +2860,7 @@ void RenderImpostors(
|
||||
device->BindResource(&vis.scene->impostorBuffer, 2, cmd, vis.scene->impostor_data.subresource_srv);
|
||||
device->BindResource(&vis.scene->impostorArray, 1, cmd);
|
||||
|
||||
device->DrawIndexedInstancedIndirect(&vis.scene->impostorIndirectBuffer, 0, cmd);
|
||||
device->DrawIndexedInstancedIndirect(&vis.scene->impostorBuffer, vis.scene->impostor_indirect.offset, cmd);
|
||||
|
||||
device->EventEnd(cmd);
|
||||
}
|
||||
@@ -4232,7 +4232,7 @@ void UpdateRenderData(
|
||||
device->EventBegin("Impostor prepare", cmd);
|
||||
auto range = wi::profiler::BeginRangeGPU("Impostor prepare", cmd);
|
||||
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorIndirectBuffer, ResourceState::INDIRECT_ARGUMENT, ResourceState::COPY_DST));
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorBuffer, ResourceState::SHADER_RESOURCE | ResourceState::INDIRECT_ARGUMENT, ResourceState::COPY_DST));
|
||||
barrier_stack_flush(cmd);
|
||||
IndirectDrawArgsIndexedInstanced clear_indirect = {};
|
||||
clear_indirect.IndexCountPerInstance = 0;
|
||||
@@ -4240,24 +4240,22 @@ void UpdateRenderData(
|
||||
clear_indirect.StartIndexLocation = 0;
|
||||
clear_indirect.BaseVertexLocation = 0;
|
||||
clear_indirect.StartInstanceLocation = 0;
|
||||
device->UpdateBuffer(&vis.scene->impostorIndirectBuffer, &clear_indirect, cmd, sizeof(clear_indirect), 0);
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorIndirectBuffer, ResourceState::COPY_DST, ResourceState::UNORDERED_ACCESS));
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorBuffer, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS));
|
||||
device->UpdateBuffer(&vis.scene->impostorBuffer, &clear_indirect, cmd, sizeof(clear_indirect), vis.scene->impostor_indirect.offset);
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorBuffer, ResourceState::COPY_DST, ResourceState::UNORDERED_ACCESS));
|
||||
barrier_stack_flush(cmd);
|
||||
|
||||
device->BindComputeShader(&shaders[CSTYPE_IMPOSTOR_PREPARE], cmd);
|
||||
device->BindUAV(&vis.scene->impostorBuffer, 0, cmd, vis.scene->impostor_ib.subresource_uav);
|
||||
device->BindUAV(&vis.scene->impostorBuffer, 1, cmd, vis.scene->impostor_vb.subresource_uav);
|
||||
device->BindUAV(&vis.scene->impostorBuffer, 2, cmd, vis.scene->impostor_data.subresource_uav);
|
||||
device->BindUAV(&vis.scene->impostorIndirectBuffer, 3, cmd);
|
||||
device->BindUAV(&vis.scene->impostorBuffer, 3, cmd, vis.scene->impostor_indirect.subresource_uav);
|
||||
|
||||
uint object_count = (uint)vis.scene->objects.GetCount();
|
||||
device->PushConstants(&object_count, sizeof(object_count), cmd);
|
||||
|
||||
device->Dispatch((object_count + 63u) / 64u, 1, 1, cmd);
|
||||
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorBuffer, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE));
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorIndirectBuffer,ResourceState::UNORDERED_ACCESS, ResourceState::INDIRECT_ARGUMENT));
|
||||
barrier_stack.push_back(GPUBarrier::Buffer(&vis.scene->impostorBuffer, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE | ResourceState::INDIRECT_ARGUMENT));
|
||||
barrier_stack_flush(cmd);
|
||||
|
||||
wi::profiler::EndRange(range);
|
||||
|
||||
@@ -669,8 +669,8 @@ namespace wi::scene
|
||||
GPUBufferDesc desc;
|
||||
desc.usage = Usage::DEFAULT;
|
||||
desc.size = required_impostor_buffer_size * 2; // *2 to grow fast
|
||||
desc.bind_flags = BindFlag::VERTEX_BUFFER | BindFlag::INDEX_BUFFER | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS;
|
||||
desc.misc_flags = ResourceMiscFlag::BUFFER_RAW;
|
||||
desc.bind_flags = BindFlag::INDEX_BUFFER | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS;
|
||||
desc.misc_flags = ResourceMiscFlag::BUFFER_RAW | ResourceMiscFlag::INDIRECT_ARGS;
|
||||
device->CreateBuffer(&desc, nullptr, &impostorBuffer);
|
||||
device->SetName(&impostorBuffer, "impostorBuffer");
|
||||
|
||||
@@ -701,12 +701,11 @@ namespace wi::scene
|
||||
impostor_data.descriptor_srv = device->GetDescriptorIndex(&impostorBuffer, SubresourceType::SRV, impostor_data.subresource_srv);
|
||||
impostor_data.descriptor_uav = device->GetDescriptorIndex(&impostorBuffer, SubresourceType::UAV, impostor_data.subresource_uav);
|
||||
|
||||
desc.stride = sizeof(IndirectDrawArgsIndexedInstanced);
|
||||
desc.size = desc.stride;
|
||||
desc.bind_flags = BindFlag::UNORDERED_ACCESS;
|
||||
desc.misc_flags = ResourceMiscFlag::INDIRECT_ARGS | ResourceMiscFlag::BUFFER_STRUCTURED;
|
||||
device->CreateBuffer(&desc, nullptr, &impostorIndirectBuffer);
|
||||
device->SetName(&impostorIndirectBuffer, "impostorIndirectBuffer");
|
||||
impostor_indirect.offset = buffer_offset;
|
||||
impostor_indirect.size = sizeof(IndirectDrawArgsIndexedInstanced);
|
||||
buffer_offset += AlignTo(impostor_data.size, alignment);
|
||||
impostor_indirect.subresource_uav = device->CreateSubresource(&impostorBuffer, SubresourceType::UAV, impostor_indirect.offset, impostor_indirect.size);
|
||||
|
||||
}
|
||||
|
||||
// Shader scene resources:
|
||||
|
||||
@@ -233,8 +233,8 @@ namespace wi::scene
|
||||
MeshComponent::BufferView impostor_ib;
|
||||
MeshComponent::BufferView impostor_vb;
|
||||
MeshComponent::BufferView impostor_data;
|
||||
MeshComponent::BufferView impostor_indirect;
|
||||
wi::graphics::Format impostor_ib_format = wi::graphics::Format::R32_UINT;
|
||||
wi::graphics::GPUBuffer impostorIndirectBuffer;
|
||||
uint32_t impostorInstanceOffset = ~0u;
|
||||
uint32_t impostorGeometryOffset = ~0u;
|
||||
uint32_t impostorMaterialOffset = ~0u;
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 224;
|
||||
const int revision = 225;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user