diff --git a/WickedEngine/wiRenderPath3D.cpp b/WickedEngine/wiRenderPath3D.cpp index 446d414d52..bf583175da 100644 --- a/WickedEngine/wiRenderPath3D.cpp +++ b/WickedEngine/wiRenderPath3D.cpp @@ -925,6 +925,7 @@ namespace wi wi::renderer::ComputeTiledLightCulling( tiledLightResources, + visibility_main, debugUAV, cmd ); @@ -1132,6 +1133,7 @@ namespace wi wi::renderer::ComputeTiledLightCulling( tiledLightResources_planarReflection, + visibility_reflection, Texture(), cmd ); diff --git a/WickedEngine/wiRenderer.cpp b/WickedEngine/wiRenderer.cpp index b5e6120ade..d17ee3cbde 100644 --- a/WickedEngine/wiRenderer.cpp +++ b/WickedEngine/wiRenderer.cpp @@ -4265,15 +4265,25 @@ void UpdateRenderData( { auto range = wi::profiler::BeginRangeGPU("Wind", cmd); device->EventBegin("Wind", cmd); - - device->BindComputeShader(&shaders[CSTYPE_WIND], cmd); - device->BindUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); - device->BindUAV(&textures[TEXTYPE_3D_WIND_PREV], 1, cmd); - const TextureDesc& desc = textures[TEXTYPE_3D_WIND].GetDesc(); - device->Dispatch(desc.width / 8, desc.height / 8, desc.depth / 8, cmd); + if ( + vis.scene->weather.windDirection.x == 0 && + vis.scene->weather.windDirection.y == 0 && + vis.scene->weather.windDirection.z == 0 + ) + { + device->ClearUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); + device->ClearUAV(&textures[TEXTYPE_3D_WIND_PREV], 0, cmd); + } + else + { + device->BindComputeShader(&shaders[CSTYPE_WIND], cmd); + device->BindUAV(&textures[TEXTYPE_3D_WIND], 0, cmd); + device->BindUAV(&textures[TEXTYPE_3D_WIND_PREV], 1, cmd); + const TextureDesc& desc = textures[TEXTYPE_3D_WIND].GetDesc(); + device->Dispatch(desc.width / 8, desc.height / 8, desc.depth / 8, cmd); + } barrier_stack.push_back(GPUBarrier::Image(&textures[TEXTYPE_3D_WIND], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_3D_WIND].desc.layout)); barrier_stack.push_back(GPUBarrier::Image(&textures[TEXTYPE_3D_WIND_PREV], ResourceState::UNORDERED_ACCESS, textures[TEXTYPE_3D_WIND_PREV].desc.layout)); - device->EventEnd(cmd); wi::profiler::EndRange(range); } @@ -8837,13 +8847,48 @@ void CreateTiledLightResources(TiledLightResources& res, XMUINT2 resolution) } void ComputeTiledLightCulling( const TiledLightResources& res, + const Visibility& vis, const Texture& debugUAV, CommandList cmd ) { - BindCommonResources(cmd); auto range = wi::profiler::BeginRangeGPU("Entity Culling", cmd); + // Initial barriers to put all resources into UAV: + { + GPUBarrier barriers[] = { + GPUBarrier::Buffer(&res.tileFrustums, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Buffer(&res.entityTiles_Transparent, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS), + GPUBarrier::Buffer(&res.entityTiles_Opaque, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + + if ( + vis.visibleLights.empty() && + vis.visibleDecals.empty() && + vis.visibleEnvProbes.empty() + ) + { + device->EventBegin("Tiled Entity Clear Only", cmd); + device->ClearUAV(&res.tileFrustums, 0, cmd); + device->ClearUAV(&res.entityTiles_Transparent, 0, cmd); + device->ClearUAV(&res.entityTiles_Opaque, 0, cmd); + { + GPUBarrier barriers[] = { + GPUBarrier::Buffer(&res.tileFrustums, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), + GPUBarrier::Buffer(&res.entityTiles_Transparent, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), + GPUBarrier::Buffer(&res.entityTiles_Opaque, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + device->EventEnd(cmd); + wi::profiler::EndRange(range); + return; + } + + BindCommonResources(cmd); + // Frustum computation { device->EventBegin("Tile Frustums", cmd); @@ -8854,13 +8899,6 @@ void ComputeTiledLightCulling( }; device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Buffer(&res.tileFrustums, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS) - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->Dispatch( (res.tileCount.x + TILED_CULLING_BLOCKSIZE - 1) / TILED_CULLING_BLOCKSIZE, (res.tileCount.y + TILED_CULLING_BLOCKSIZE - 1) / TILED_CULLING_BLOCKSIZE, @@ -8868,6 +8906,13 @@ void ComputeTiledLightCulling( cmd ); + { + GPUBarrier barriers[] = { + GPUBarrier::Buffer(&res.tileFrustums, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), + }; + device->Barrier(barriers, arraysize(barriers), cmd); + } + device->EventEnd(cmd); } @@ -8893,25 +8938,8 @@ void ComputeTiledLightCulling( }; device->BindUAVs(uavs, 0, arraysize(uavs), cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Buffer(&res.tileFrustums, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), - GPUBarrier::Buffer(&res.entityTiles_Transparent, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS), - GPUBarrier::Buffer(&res.entityTiles_Opaque, ResourceState::SHADER_RESOURCE, ResourceState::UNORDERED_ACCESS), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->Dispatch(res.tileCount.x, res.tileCount.y, 1, cmd); - { - GPUBarrier barriers[] = { - GPUBarrier::Buffer(&res.entityTiles_Opaque, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), - GPUBarrier::Buffer(&res.entityTiles_Transparent, ResourceState::UNORDERED_ACCESS, ResourceState::SHADER_RESOURCE), - }; - device->Barrier(barriers, arraysize(barriers), cmd); - } - device->EventEnd(cmd); } diff --git a/WickedEngine/wiRenderer.h b/WickedEngine/wiRenderer.h index 3bceb2c10f..b7e96c60ec 100644 --- a/WickedEngine/wiRenderer.h +++ b/WickedEngine/wiRenderer.h @@ -305,6 +305,7 @@ namespace wi::renderer // Compute light grid tiles void ComputeTiledLightCulling( const TiledLightResources& res, + const Visibility& vis, const wi::graphics::Texture& debugUAV, wi::graphics::CommandList cmd ); diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index e7ee5f22e6..34f4c7d523 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -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 = 357; + const int revision = 358; const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);