diff --git a/Editor/Editor.cpp b/Editor/Editor.cpp index 45e7ec681..e6fb78523 100644 --- a/Editor/Editor.cpp +++ b/Editor/Editor.cpp @@ -141,7 +141,7 @@ void EditorComponent::ChangeRenderPath(RENDERPATH path) objectWnd.reset(new ObjectWindow(this)); meshWnd.reset(new MeshWindow(&GetGUI())); cameraWnd.reset(new CameraWindow(&GetGUI())); - rendererWnd.reset(new RendererWindow(&GetGUI(), renderPath)); + rendererWnd.reset(new RendererWindow(&GetGUI(), this, renderPath)); envProbeWnd.reset(new EnvProbeWindow(&GetGUI())); soundWnd.reset(new SoundWindow(&GetGUI())); decalWnd.reset(new DecalWindow(&GetGUI())); @@ -169,6 +169,13 @@ void EditorComponent::ResizeBuffers() desc.Format = wiRenderer::GetDevice()->GetBackBufferFormat(); // todo: smaller format, but then somehow need to specify custom rt format for wiImage PSO! desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; + if (renderPath->getMSAASampleCount() > 1) + { + desc.SampleDesc.Count = renderPath->getMSAASampleCount(); + hr = device->CreateTexture2D(&desc, nullptr, &rt_selectionOutline_MSAA); + assert(SUCCEEDED(hr)); + desc.SampleDesc.Count = 1; + } hr = device->CreateTexture2D(&desc, nullptr, &rt_selectionOutline[0]); assert(SUCCEEDED(hr)); @@ -182,6 +189,10 @@ void EditorComponent::ResizeBuffers() RenderPassDesc desc; desc.numAttachments = 2; desc.attachments[0] = { RenderPassAttachment::RENDERTARGET, RenderPassAttachment::LOADOP_CLEAR, &rt_selectionOutline[0], -1 }; + if (renderPath->getMSAASampleCount() > 1) + { + desc.attachments[0].texture = &rt_selectionOutline_MSAA; + } desc.attachments[1] = { RenderPassAttachment::DEPTH_STENCIL, RenderPassAttachment::LOADOP_LOAD, renderPath->GetDepthStencil(), -1 }; hr = device->CreateRenderPass(&desc, &renderpass_selectionOutline[0]); assert(SUCCEEDED(hr)); @@ -1606,6 +1617,11 @@ void EditorComponent::Render() const device->RenderPassEnd(cmd); + if (renderPath->getMSAASampleCount() > 1) + { + device->MSAAResolve(&rt_selectionOutline[0], &rt_selectionOutline_MSAA, cmd); + } + // Outline the solid blocks: wiRenderer::BindCommonResources(cmd); wiRenderer::Postprocess_Outline(rt_selectionOutline[0], rt_selectionOutline[1], cmd, 0.1f, 1, selectionColor2); @@ -1621,6 +1637,11 @@ void EditorComponent::Render() const device->RenderPassEnd(cmd); + if (renderPath->getMSAASampleCount() > 1) + { + device->MSAAResolve(&rt_selectionOutline[0], &rt_selectionOutline_MSAA, cmd); + } + // Outline the solid blocks: wiRenderer::BindCommonResources(cmd); wiRenderer::Postprocess_Outline(rt_selectionOutline[0], rt_selectionOutline[1], cmd, 0.1f, 1, selectionColor); diff --git a/Editor/Editor.h b/Editor/Editor.h index 546760d0d..ed1d75dc3 100644 --- a/Editor/Editor.h +++ b/Editor/Editor.h @@ -86,6 +86,7 @@ public: EDITORSTENCILREF_HIGHLIGHT_MATERIAL = 0x02, EDITORSTENCILREF_LAST = 0x0F, }; + wiGraphics::Texture2D rt_selectionOutline_MSAA; wiGraphics::Texture2D rt_selectionOutline[2]; wiGraphics::RenderPass renderpass_selectionOutline[2]; float selectionOutlineTimer = 0; diff --git a/Editor/RendererWindow.cpp b/Editor/RendererWindow.cpp index 3b93d9f71..82f95543c 100644 --- a/Editor/RendererWindow.cpp +++ b/Editor/RendererWindow.cpp @@ -1,9 +1,10 @@ #include "stdafx.h" #include "RendererWindow.h" #include "RenderPath3D.h" +#include "Editor.h" -RendererWindow::RendererWindow(wiGUI* gui, RenderPath3D* path) : GUI(gui) +RendererWindow::RendererWindow(wiGUI* gui, EditorComponent* editorcomponent, RenderPath3D* path) : GUI(gui) { assert(GUI && "Invalid GUI!"); @@ -324,6 +325,7 @@ RendererWindow::RendererWindow(wiGUI* gui, RenderPath3D* path) : GUI(gui) default: break; } + editorcomponent->ResizeBuffers(); }); MSAAComboBox->SetSelected(0); MSAAComboBox->SetEnabled(true); diff --git a/Editor/RendererWindow.h b/Editor/RendererWindow.h index 2eb7631c2..8622c89b3 100644 --- a/Editor/RendererWindow.h +++ b/Editor/RendererWindow.h @@ -1,5 +1,7 @@ #pragma once +class EditorComponent; + class wiGUI; class wiWindow; class wiLabel; @@ -25,7 +27,7 @@ enum PICKTYPE class RendererWindow { public: - RendererWindow(wiGUI* gui, RenderPath3D* path); + RendererWindow(wiGUI* gui, EditorComponent* editorcomponent, RenderPath3D* path); ~RendererWindow(); wiGUI* GUI; diff --git a/WickedEngine/RenderPath3D.cpp b/WickedEngine/RenderPath3D.cpp index 7afb799a7..d351ded60 100644 --- a/WickedEngine/RenderPath3D.cpp +++ b/WickedEngine/RenderPath3D.cpp @@ -86,8 +86,8 @@ void RenderPath3D::ResizeBuffers() TextureDesc desc; desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE; desc.Format = wiRenderer::RTFormat_hdr; - desc.Width = wiRenderer::GetInternalResolution().x; - desc.Height = wiRenderer::GetInternalResolution().y; + desc.Width = wiRenderer::GetInternalResolution().x / 4; + desc.Height = wiRenderer::GetInternalResolution().y / 4; desc.layout = IMAGE_LAYOUT_SHADER_RESOURCE; device->CreateTexture2D(&desc, nullptr, &rtReflection); device->SetName(&rtReflection, "rtReflection"); @@ -216,6 +216,16 @@ void RenderPath3D::ResizeBuffers() device->CreateTexture2D(&desc, nullptr, &depthBuffer_Copy); device->SetName(&depthBuffer_Copy, "depthBuffer_Copy"); } + { + TextureDesc desc; + desc.BindFlags = BIND_DEPTH_STENCIL; + desc.Format = wiRenderer::DSFormat_full; + desc.Width = wiRenderer::GetInternalResolution().x / 4; + desc.Height = wiRenderer::GetInternalResolution().y / 4; + desc.layout = IMAGE_LAYOUT_DEPTHSTENCIL; + device->CreateTexture2D(&desc, nullptr, &depthBuffer_Reflection); + device->SetName(&depthBuffer_Reflection, "depthBuffer_Reflection"); + } { TextureDesc desc; desc.BindFlags = BIND_SHADER_RESOURCE | BIND_UNORDERED_ACCESS; @@ -248,7 +258,7 @@ void RenderPath3D::ResizeBuffers() RenderPassDesc desc; desc.numAttachments = 2; desc.attachments[0] = { RenderPassAttachment::RENDERTARGET,RenderPassAttachment::LOADOP_DONTCARE,&rtReflection,-1,RenderPassAttachment::STOREOP_STORE,IMAGE_LAYOUT_RENDERTARGET,IMAGE_LAYOUT_SHADER_RESOURCE }; - desc.attachments[1] = { RenderPassAttachment::DEPTH_STENCIL,RenderPassAttachment::LOADOP_CLEAR,&depthBuffer,-1,RenderPassAttachment::STOREOP_DONTCARE }; + desc.attachments[1] = { RenderPassAttachment::DEPTH_STENCIL,RenderPassAttachment::LOADOP_CLEAR,&depthBuffer_Reflection,-1,RenderPassAttachment::STOREOP_DONTCARE,IMAGE_LAYOUT_DEPTHSTENCIL,IMAGE_LAYOUT_DEPTHSTENCIL }; device->CreateRenderPass(&desc, &renderpass_reflection); } @@ -350,8 +360,8 @@ void RenderPath3D::RenderReflections(CommandList cmd) const wiRenderer::UpdateCameraCB(wiRenderer::GetRefCamera(), cmd); ViewPort vp; - vp.Width = (float)depthBuffer.GetDesc().Width; - vp.Height = (float)depthBuffer.GetDesc().Height; + vp.Width = (float)depthBuffer_Reflection.GetDesc().Width; + vp.Height = (float)depthBuffer_Reflection.GetDesc().Height; device->BindViewports(1, &vp, cmd); // reverse clipping if underwater diff --git a/WickedEngine/RenderPath3D.h b/WickedEngine/RenderPath3D.h index fb00df8d6..de149e026 100644 --- a/WickedEngine/RenderPath3D.h +++ b/WickedEngine/RenderPath3D.h @@ -65,6 +65,7 @@ protected: wiGraphics::Texture2D depthBuffer; // used for depth-testing, can be MSAA wiGraphics::Texture2D depthBuffer_Copy; // used for shader resource, single sample + wiGraphics::Texture2D depthBuffer_Reflection; // used for reflection, single sample wiGraphics::Texture2D rtLinearDepth; // linear depth result wiGraphics::Texture2D smallDepth; // downsampled depth buffer diff --git a/WickedEngine/RenderPath3D_Deferred.cpp b/WickedEngine/RenderPath3D_Deferred.cpp index d37819e94..003ab69c8 100644 --- a/WickedEngine/RenderPath3D_Deferred.cpp +++ b/WickedEngine/RenderPath3D_Deferred.cpp @@ -187,6 +187,7 @@ void RenderPath3D_Deferred::Render() const cmd = device->BeginCommandList(); wiJobSystem::Execute(ctx, [this, device, cmd] { + wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); wiRenderer::BindCommonResources(cmd); RenderDecals(cmd); @@ -217,10 +218,6 @@ void RenderPath3D_Deferred::Render() const DownsampleDepthBuffer(cmd); - wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); - - RenderOutline(rtDeferred, cmd); - RenderLightShafts(cmd); RenderVolumetrics(cmd); @@ -231,6 +228,8 @@ void RenderPath3D_Deferred::Render() const RenderTransparents(renderpass_transparent, RENDERPASS_FORWARD, cmd); + RenderOutline(rtDeferred, cmd); + RenderParticles(true, cmd); TemporalAAResolve(rtDeferred, rtGBuffer[1], cmd); diff --git a/WickedEngine/RenderPath3D_Forward.cpp b/WickedEngine/RenderPath3D_Forward.cpp index d92de3efd..de6ffa1fc 100644 --- a/WickedEngine/RenderPath3D_Forward.cpp +++ b/WickedEngine/RenderPath3D_Forward.cpp @@ -168,16 +168,19 @@ void RenderPath3D_Forward::Render() const cmd = device->BeginCommandList(); wiJobSystem::Execute(ctx, [this, device, cmd] { + wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); wiRenderer::BindCommonResources(cmd); - RenderSSR(*GetSceneRT_Read(0), rtMain[1], cmd); + if (getMSAASampleCount() > 1) + { + device->MSAAResolve(GetSceneRT_Read(0), &rtMain[0], cmd); + device->MSAAResolve(GetSceneRT_Read(1), &rtMain[1], cmd); + } + + RenderSSR(*GetSceneRT_Read(0), *GetSceneRT_Read(1), cmd); DownsampleDepthBuffer(cmd); - wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); - - RenderOutline(rtMain[0], cmd); - RenderLightShafts(cmd); RenderVolumetrics(cmd); @@ -193,6 +196,8 @@ void RenderPath3D_Forward::Render() const device->MSAAResolve(GetSceneRT_Read(0), &rtMain[0], cmd); } + RenderOutline(*GetSceneRT_Read(0), cmd); + RenderParticles(true, cmd); TemporalAAResolve(*GetSceneRT_Read(0), *GetSceneRT_Read(1), cmd); diff --git a/WickedEngine/RenderPath3D_TiledDeferred.cpp b/WickedEngine/RenderPath3D_TiledDeferred.cpp index 775de608f..0c37991e7 100644 --- a/WickedEngine/RenderPath3D_TiledDeferred.cpp +++ b/WickedEngine/RenderPath3D_TiledDeferred.cpp @@ -60,6 +60,7 @@ void RenderPath3D_TiledDeferred::Render() const cmd = device->BeginCommandList(); wiJobSystem::Execute(ctx, [this, device, cmd] { + wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); wiRenderer::BindCommonResources(cmd); RenderDecals(cmd); @@ -85,10 +86,6 @@ void RenderPath3D_TiledDeferred::Render() const DownsampleDepthBuffer(cmd); - wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); - - RenderOutline(rtDeferred, cmd); - RenderLightShafts(cmd); RenderVolumetrics(cmd); @@ -99,6 +96,8 @@ void RenderPath3D_TiledDeferred::Render() const RenderTransparents(renderpass_transparent, RENDERPASS_TILEDFORWARD, cmd); + RenderOutline(rtDeferred, cmd); + RenderParticles(true, cmd); TemporalAAResolve(rtDeferred, rtGBuffer[1], cmd); diff --git a/WickedEngine/RenderPath3D_TiledForward.cpp b/WickedEngine/RenderPath3D_TiledForward.cpp index de9bc74de..a3472b90b 100644 --- a/WickedEngine/RenderPath3D_TiledForward.cpp +++ b/WickedEngine/RenderPath3D_TiledForward.cpp @@ -100,6 +100,7 @@ void RenderPath3D_TiledForward::Render() const cmd = device->BeginCommandList(); wiJobSystem::Execute(ctx, [this, device, cmd] { + wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); wiRenderer::BindCommonResources(cmd); if (getMSAASampleCount() > 1) @@ -108,14 +109,10 @@ void RenderPath3D_TiledForward::Render() const device->MSAAResolve(GetSceneRT_Read(1), &rtMain[1], cmd); } - RenderSSR(*GetSceneRT_Read(0), rtMain[1], cmd); + RenderSSR(*GetSceneRT_Read(0), *GetSceneRT_Read(1), cmd); DownsampleDepthBuffer(cmd); - wiRenderer::UpdateCameraCB(wiRenderer::GetCamera(), cmd); - - RenderOutline(rtMain[0], cmd); - RenderLightShafts(cmd); RenderVolumetrics(cmd); @@ -131,6 +128,10 @@ void RenderPath3D_TiledForward::Render() const device->MSAAResolve(GetSceneRT_Read(0), &rtMain[0], cmd); } + RenderOutline(*GetSceneRT_Read(0), cmd); + + RenderParticles(true, cmd); + TemporalAAResolve(*GetSceneRT_Read(0), *GetSceneRT_Read(1), cmd); RenderBloom(renderpass_bloom, cmd); diff --git a/WickedEngine/wiGraphicsDevice_Vulkan.cpp b/WickedEngine/wiGraphicsDevice_Vulkan.cpp index d028be94a..0ea8a8a84 100644 --- a/WickedEngine/wiGraphicsDevice_Vulkan.cpp +++ b/WickedEngine/wiGraphicsDevice_Vulkan.cpp @@ -3656,7 +3656,7 @@ namespace wiGraphics } colorAttachmentRefs[subpass.colorAttachmentCount].attachment = validAttachmentCount; - colorAttachmentRefs[subpass.colorAttachmentCount].layout = attachmentDescriptions[validAttachmentCount].initialLayout; + colorAttachmentRefs[subpass.colorAttachmentCount].layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; subpass.colorAttachmentCount++; subpass.pColorAttachments = colorAttachmentRefs; } @@ -3705,7 +3705,11 @@ namespace wiGraphics } depthAttachmentRef.attachment = validAttachmentCount; - depthAttachmentRef.layout = attachmentDescriptions[validAttachmentCount].initialLayout; + depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL; + if (attachmentDescriptions[validAttachmentCount].initialLayout == VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL) + { + depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_READ_ONLY_OPTIMAL; + } subpass.pDepthStencilAttachment = &depthAttachmentRef; } else diff --git a/WickedEngine/wiVersion.cpp b/WickedEngine/wiVersion.cpp index 3ac9f7b0a..059719a39 100644 --- a/WickedEngine/wiVersion.cpp +++ b/WickedEngine/wiVersion.cpp @@ -9,7 +9,7 @@ namespace wiVersion // minor features, major updates const int minor = 31; // minor bug fixes, alterations, refactors, updates - const int revision = 0; + const int revision = 1; long GetVersion()