Skip to content

Commit

Permalink
rendering fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Nov 25, 2023
1 parent ec73604 commit aaf6aae
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 32 deletions.
2 changes: 1 addition & 1 deletion WickedEngine/shaders/impostorVS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ VSOut main(uint vertexID : SV_VertexID)
Out.slice = data.x & 0xFFFFFF;
Out.dither = float((data.x >> 24u) & 0xFF) / 255.0;
Out.instanceColor = data.y;
Out.primitiveID = impostorID * 2;
Out.primitiveID = vertexID / 2u;
return Out;
}
8 changes: 4 additions & 4 deletions WickedEngine/shaders/impostor_prepareCS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,12 @@ void main(uint3 DTid : SV_DispatchThreadID)
const uint vertexOffset = impostorOffset * 4u;

// Write out indices:
output_indices[indexOffset + 0] = vertexOffset + 0;
output_indices[indexOffset + 0] = vertexOffset + 0; // provoking vertex prim0
output_indices[indexOffset + 1] = vertexOffset + 1;
output_indices[indexOffset + 2] = vertexOffset + 2;
output_indices[indexOffset + 3] = vertexOffset + 2;
output_indices[indexOffset + 4] = vertexOffset + 1;
output_indices[indexOffset + 5] = vertexOffset + 3;
output_indices[indexOffset + 3] = vertexOffset + 3; // provoking vertex prim1
output_indices[indexOffset + 4] = vertexOffset + 2;
output_indices[indexOffset + 5] = vertexOffset + 1;

// We rotate the billboard to face camera, but unlike emitted particles,
// they don't rotate according to camera rotation, but the camera position relative
Expand Down
11 changes: 8 additions & 3 deletions WickedEngine/wiRenderPath3D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,11 @@ namespace wi
{
TextureDesc desc;
desc.format = wi::renderer::format_idbuffer;
desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE | BindFlag::UNORDERED_ACCESS;
desc.bind_flags = BindFlag::RENDER_TARGET | BindFlag::SHADER_RESOURCE;
if (getMSAASampleCount() > 1)
{
desc.bind_flags |= BindFlag::UNORDERED_ACCESS;
}
desc.width = internalResolution.x;
desc.height = internalResolution.y;
desc.sample_count = 1;
Expand Down Expand Up @@ -817,6 +821,8 @@ namespace wi

wi::renderer::OcclusionCulling_Reset(visibility_main, cmd); // must be outside renderpass!

wi::renderer::RefreshImpostors(*scene, cmd);

RenderPassImage rp[] = {
RenderPassImage::DepthStencil(
&depthBuffer_Main,
Expand Down Expand Up @@ -1036,7 +1042,6 @@ namespace wi
);
wi::renderer::RefreshLightmaps(*scene, cmd);
wi::renderer::RefreshEnvProbes(visibility_main, cmd);
wi::renderer::RefreshImpostors(*scene, cmd);
});

if (visibility_main.IsRequestedPlanarReflections())
Expand Down Expand Up @@ -2042,7 +2047,7 @@ namespace wi
}
}

if (getDepthOfFieldEnabled() && camera->aperture_size > 0 && getDepthOfFieldStrength() > 0 && depthoffieldResources.IsValid())
if (getDepthOfFieldEnabled() && camera->aperture_size > 0.001f && getDepthOfFieldStrength() > 0.001f && depthoffieldResources.IsValid())
{
wi::renderer::Postprocess_DepthOfField(
depthoffieldResources,
Expand Down
66 changes: 43 additions & 23 deletions WickedEngine/wiRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9944,6 +9944,25 @@ void ComputeBloom(
device->EventBegin("Bloom", cmd);
auto range = wi::profiler::BeginRangeGPU("Bloom", cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Image(&res.texture_bloom, res.texture_bloom.desc.layout, ResourceState::UNORDERED_ACCESS),
GPUBarrier::Image(&res.texture_temp, res.texture_temp.desc.layout, ResourceState::UNORDERED_ACCESS),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->ClearUAV(&res.texture_bloom, 0, cmd);
device->ClearUAV(&res.texture_temp, 0, cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Memory(&res.texture_bloom),
GPUBarrier::Memory(&res.texture_temp),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

// Separate bright parts of image to bloom texture:
{
device->EventBegin("Bloom Separate", cmd);
Expand All @@ -9962,31 +9981,24 @@ void ComputeBloom(
bloom.buffer_input_luminance = device->GetDescriptorIndex((buffer_luminance == nullptr) ? &luminance_dummy : buffer_luminance, SubresourceType::SRV);
device->PushConstants(&bloom, sizeof(bloom), cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Image(&res.texture_bloom, res.texture_bloom.desc.layout, ResourceState::UNORDERED_ACCESS),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->Dispatch(
(desc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
(desc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
1,
cmd
);

{
GPUBarrier barriers[] = {
GPUBarrier::Memory(),
GPUBarrier::Image(&res.texture_bloom, ResourceState::UNORDERED_ACCESS, res.texture_bloom.desc.layout),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->EventEnd(cmd);
}

{
GPUBarrier barriers[] = {
GPUBarrier::Image(&res.texture_bloom, ResourceState::UNORDERED_ACCESS, res.texture_bloom.desc.layout),
GPUBarrier::Image(&res.texture_temp, ResourceState::UNORDERED_ACCESS, res.texture_temp.desc.layout),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->EventBegin("Bloom Mipchain", cmd);
MIPGEN_OPTIONS mipopt;
mipopt.gaussian_temp = &res.texture_temp;
Expand Down Expand Up @@ -14977,6 +14989,22 @@ void Postprocess_Tonemap(

device->EventBegin("Postprocess_Tonemap", cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->ClearUAV(&output, 0, cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Memory(&output),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->BindComputeShader(&shaders[CSTYPE_POSTPROCESS_TONEMAP], cmd);

const TextureDesc& desc = output.GetDesc();
Expand Down Expand Up @@ -15008,13 +15036,6 @@ void Postprocess_Tonemap(
tonemap_push.display_colorspace = static_cast<uint32_t>(display_colorspace);
device->PushConstants(&tonemap_push, sizeof(tonemap_push), cmd);

{
GPUBarrier barriers[] = {
GPUBarrier::Image(&output, output.desc.layout, ResourceState::UNORDERED_ACCESS),
};
device->Barrier(barriers, arraysize(barriers), cmd);
}

device->Dispatch(
(desc.width + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
(desc.height + POSTPROCESS_BLOCKSIZE - 1) / POSTPROCESS_BLOCKSIZE,
Expand All @@ -15024,7 +15045,6 @@ void Postprocess_Tonemap(

{
GPUBarrier barriers[] = {
GPUBarrier::Memory(),
GPUBarrier::Image(&output, ResourceState::UNORDERED_ACCESS, output.desc.layout),
};
device->Barrier(barriers, arraysize(barriers), cmd);
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 352;
const int revision = 353;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit aaf6aae

Please sign in to comment.