diff --git a/Source/Engine/Content/Assets/Shader.h b/Source/Engine/Content/Assets/Shader.h index 0847d26e6..85e985d52 100644 --- a/Source/Engine/Content/Assets/Shader.h +++ b/Source/Engine/Content/Assets/Shader.h @@ -30,8 +30,9 @@ public: /// /// Gets the GPU shader object. + /// [Deprecated in v1.10] /// - FORCE_INLINE GPUShader* GetShader() const + FORCE_INLINE DEPRECATED("Use GPU field directly.") GPUShader* GetShader() const { return GPU; } diff --git a/Source/Engine/Core/Math/BoundingFrustum.h b/Source/Engine/Core/Math/BoundingFrustum.h index a3a5442e9..6bc39485b 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.h +++ b/Source/Engine/Core/Math/BoundingFrustum.h @@ -57,14 +57,6 @@ public: return _matrix; } - /// - /// Gets the matrix that describes this bounding frustum. - /// - FORCE_INLINE Matrix GetMatrix() - { - return _matrix; - } - /// /// Gets the inverted matrix to that describes this bounding frustum. /// diff --git a/Source/Engine/Debug/DebugDraw.cpp b/Source/Engine/Debug/DebugDraw.cpp index a4febc613..1cefbd3c8 100644 --- a/Source/Engine/Debug/DebugDraw.cpp +++ b/Source/Engine/Debug/DebugDraw.cpp @@ -686,7 +686,7 @@ void DebugDrawService::Update() if (DebugDrawPsWireTrianglesDepthTest.Depth == nullptr && DebugDrawShader && DebugDrawShader->IsLoaded()) { bool failed = false; - const auto shader = DebugDrawShader->GetShader(); + const auto shader = DebugDrawShader->GPU; // Create pipeline states GPUPipelineState::Description desc = GPUPipelineState::Description::Default; @@ -855,7 +855,7 @@ void DebugDraw::Draw(RenderContext& renderContext, GPUTextureView* target, GPUTe } // Update constant buffer - const auto cb = DebugDrawShader->GetShader()->GetCB(0); + const auto cb = DebugDrawShader->GPU->GetCB(0); ShaderData data; Matrix vp; Matrix::Multiply(view.View, view.Projection, vp); diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index f4b0cc234..ca9f4c8e4 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -420,7 +420,7 @@ bool GPUDevice::LoadContent() _res->QuadShader = Content::LoadAsyncInternal(TEXT("Shaders/Quad")); if (_res->QuadShader == nullptr || _res->QuadShader->WaitForLoaded()) return true; - QuadShader = _res->QuadShader->GetShader(); + QuadShader = _res->QuadShader->GPU; GPUPipelineState::Description::DefaultFullscreenTriangle.VS = QuadShader->GetVS("VS"); _res->PS_CopyLinear = CreatePipelineState(); GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultFullscreenTriangle; diff --git a/Source/Engine/Graphics/RenderView.h b/Source/Engine/Graphics/RenderView.h index a85480e3e..15010495e 100644 --- a/Source/Engine/Graphics/RenderView.h +++ b/Source/Engine/Graphics/RenderView.h @@ -350,12 +350,6 @@ public: return Frustum.GetMatrix(); } - // Camera's View * Projection matrix - FORCE_INLINE Matrix ViewProjection() - { - return Frustum.GetMatrix(); - } - // Calculates the world matrix for the given transformation instance rendering. void GetWorldMatrix(const Transform& transform, Matrix& world) const; diff --git a/Source/Engine/Level/Actors/ExponentialHeightFog.cpp b/Source/Engine/Level/Actors/ExponentialHeightFog.cpp index cfb5217a0..c1e804ea9 100644 --- a/Source/Engine/Level/Actors/ExponentialHeightFog.cpp +++ b/Source/Engine/Level/Actors/ExponentialHeightFog.cpp @@ -55,7 +55,7 @@ void ExponentialHeightFog::Draw(RenderContext& renderContext) psDesc.BlendMode.DestBlendAlpha = BlendingMode::Blend::Zero; psDesc.BlendMode.BlendOpAlpha = BlendingMode::Operation::Add; psDesc.BlendMode.RenderTargetWriteMask = BlendingMode::ColorWrite::RGB; - if (_psFog.Create(psDesc, _shader->GetShader(), "PS_Fog")) + if (_psFog.Create(psDesc, _shader->GPU, "PS_Fog")) { LOG(Warning, "Cannot create graphics pipeline state object for '{0}'.", ToString()); return; @@ -198,7 +198,7 @@ void ExponentialHeightFog::DrawFog(GPUContext* context, RenderContext& renderCon data.ExponentialHeightFog = renderContext.List->Fog.ExponentialHeightFogData; data.VolumetricFog = renderContext.List->Fog.VolumetricFogData; data.TemporalAAJitter = renderContext.View.TemporalAAJitter; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); ASSERT_LOW_LAYER(cb->GetSize() == sizeof(Data)); context->UpdateCB(cb, &data); context->BindCB(0, cb); diff --git a/Source/Engine/Level/Actors/Sky.cpp b/Source/Engine/Level/Actors/Sky.cpp index 4b7292542..09f9f086d 100644 --- a/Source/Engine/Level/Actors/Sky.cpp +++ b/Source/Engine/Level/Actors/Sky.cpp @@ -90,7 +90,7 @@ void Sky::Draw(RenderContext& renderContext) // Ensure to have pipeline state cache created if (_psSky == nullptr) { - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; // Create pipeline states if (_psSky == nullptr) @@ -198,7 +198,7 @@ void Sky::ApplySky(GPUContext* context, RenderContext& renderContext, const Matr } // Bind pipeline - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->SetState(_psSky); diff --git a/Source/Engine/Level/Actors/SkyLight.cpp b/Source/Engine/Level/Actors/SkyLight.cpp index 1165ee292..7b363a675 100644 --- a/Source/Engine/Level/Actors/SkyLight.cpp +++ b/Source/Engine/Level/Actors/SkyLight.cpp @@ -135,7 +135,7 @@ void SkyLight::Draw(RenderContext& renderContext) else if (CubeTexture* image = GetSource()) { data.CubemapImageView = GET_TEXTURE_VIEW_SAFE(image->GetTexture()); - data.CubemapImageMip = image->StreamingTexture()->TotalMipLevels() - 2.0; + data.CubemapImageMip = (float)image->StreamingTexture()->TotalMipLevels() - 2.0f; } data.StaticFlags = GetStaticFlags(); data.ID = GetID(); diff --git a/Source/Engine/Particles/Particles.cpp b/Source/Engine/Particles/Particles.cpp index 4b1160db8..e1f064601 100644 --- a/Source/Engine/Particles/Particles.cpp +++ b/Source/Engine/Particles/Particles.cpp @@ -710,7 +710,7 @@ void DrawEmittersGPU(GPUContext* context, RenderContextBatch& renderContextBatch } else if (!GPUParticlesSortingCB) { - const auto shader = GPUParticlesSorting->GetShader(); + const auto shader = GPUParticlesSorting->GPU; const StringAnsiView CS_Sort("CS_Sort"); GPUParticlesSortingCS[0] = shader->GetCS(CS_Sort, 0); GPUParticlesSortingCS[1] = shader->GetCS(CS_Sort, 1); diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 70127bf94..af3021b29 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -757,7 +757,7 @@ void Render2D::End() Output = nullptr; return; } - shader = GUIShader->GetShader(); + shader = GUIShader->GPU; } // Flush geometry buffers @@ -783,8 +783,8 @@ void Render2D::End() // Prepare PSO if (!PsoDepth.Inited) { - PsoDepth.Init(GUIShader.Get()->GetShader(), true); - PsoNoDepth.Init(GUIShader.Get()->GetShader(), false); + PsoDepth.Init(GUIShader.Get()->GPU, true); + PsoNoDepth.Init(GUIShader.Get()->GPU, false); } CurrentPso = DepthBuffer ? &PsoDepth : &PsoNoDepth; @@ -1045,7 +1045,7 @@ void DrawBatch(int32 startIndex, int32 count) Context->DrawIndexed(countIb, 0, d.StartIB); // Restore pipeline (material apply overrides it) - const auto cb = GUIShader->GetShader()->GetCB(0); + const auto cb = GUIShader->GPU->GetCB(0); Context->BindCB(0, cb); return; @@ -1074,7 +1074,7 @@ void DrawBatch(int32 startIndex, int32 count) Context->DrawIndexed(countIb, 0, d.StartIB); // Restore pipeline (material apply overrides it) - const auto cb = GUIShader->GetShader()->GetCB(0); + const auto cb = GUIShader->GPU->GetCB(0); Context->BindCB(0, cb); return; @@ -1120,7 +1120,7 @@ void DrawBatch(int32 startIndex, int32 count) data.InvBufferSize.X = 1.0f / (float)renderTargetWidth; data.InvBufferSize.Y = 1.0f / (float)renderTargetHeight; data.SampleCount = ComputeBlurWeights(kernelSize, blurStrength, data.WeightAndOffsets); - const auto cb = GUIShader->GetShader()->GetCB(1); + const auto cb = GUIShader->GPU->GetCB(1); Context->UpdateCB(cb, &data); Context->BindCB(1, cb); diff --git a/Source/Engine/Renderer/AmbientOcclusionPass.cpp b/Source/Engine/Renderer/AmbientOcclusionPass.cpp index 625eec155..3d5bcb756 100644 --- a/Source/Engine/Renderer/AmbientOcclusionPass.cpp +++ b/Source/Engine/Renderer/AmbientOcclusionPass.cpp @@ -117,7 +117,7 @@ bool AmbientOcclusionPass::setupResources() // Check shader if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, ASSAOConstants); // Create pipeline states @@ -313,7 +313,7 @@ void AmbientOcclusionPass::Render(RenderContext& renderContext) } // Update and bind constant buffer - const auto cb = _shader->GetShader()->GetCB(SSAO_CONSTANTS_BUFFER_SLOT); + const auto cb = _shader->GPU->GetCB(SSAO_CONSTANTS_BUFFER_SLOT); ASSAOConstants _constantsBufferData; { const auto& view = renderContext.View; diff --git a/Source/Engine/Renderer/AntiAliasing/FXAA.cpp b/Source/Engine/Renderer/AntiAliasing/FXAA.cpp index 2d5e40a14..c4d1c85ae 100644 --- a/Source/Engine/Renderer/AntiAliasing/FXAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/FXAA.cpp @@ -36,7 +36,7 @@ bool FXAA::setupResources() { return true; } - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); GPUPipelineState::Description psDesc; @@ -76,7 +76,7 @@ void FXAA::Render(RenderContext& renderContext, GPUTexture* input, GPUTextureVie // Bind input Data data; data.ScreenSize = renderContext.View.ScreenSize; - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->BindSR(0, input); diff --git a/Source/Engine/Renderer/AntiAliasing/SMAA.cpp b/Source/Engine/Renderer/AntiAliasing/SMAA.cpp index 2414118d3..3972b6f16 100644 --- a/Source/Engine/Renderer/AntiAliasing/SMAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/SMAA.cpp @@ -44,7 +44,7 @@ bool SMAA::setupResources() { return true; } - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline state @@ -115,7 +115,7 @@ void SMAA::Render(RenderContext& renderContext, GPUTexture* input, GPUTextureVie data.RtSize.Y = 1.0f / tempDesc.Height; data.RtSize.Z = (float)tempDesc.Width; data.RtSize.W = (float)tempDesc.Height; - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); diff --git a/Source/Engine/Renderer/AntiAliasing/TAA.cpp b/Source/Engine/Renderer/AntiAliasing/TAA.cpp index 7e2b5670b..c578f57c0 100644 --- a/Source/Engine/Renderer/AntiAliasing/TAA.cpp +++ b/Source/Engine/Renderer/AntiAliasing/TAA.cpp @@ -39,7 +39,7 @@ bool TAA::setupResources() { if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); GPUPipelineState::Description psDesc; if (!_psTAA.IsValid()) @@ -123,7 +123,7 @@ void TAA::Render(const RenderContext& renderContext, GPUTexture* input, GPUTextu data.MotionScale = 0.1f / data.ScreenSizeInv; // Hardcoded scale data.QuantizationError = RenderTools::GetColorQuantizationError(tempDesc.Format); GBufferPass::SetInputs(renderContext.View, data.GBuffer); - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->BindSR(0, input); diff --git a/Source/Engine/Renderer/AtmospherePreCompute.cpp b/Source/Engine/Renderer/AtmospherePreCompute.cpp index e139d4a9e..a60a7c798 100644 --- a/Source/Engine/Renderer/AtmospherePreCompute.cpp +++ b/Source/Engine/Renderer/AtmospherePreCompute.cpp @@ -141,7 +141,7 @@ bool InitAtmospherePreCompute() LOG(Warning, "Loading AtmospherePreCompute shader timeout!"); return true; } - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; ASSERT(shader->GetCB(0) != nullptr); CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); auto device = GPUDevice::Instance; @@ -353,7 +353,7 @@ void AtmospherePreComputeImpl::Render(RenderTask* task, GPUContext* context) RENDER_TARGET_POOL_SET_NAME(AtmosphereDeltaSM, "AtmospherePreCompute.DeltaSM"); RENDER_TARGET_POOL_SET_NAME(AtmosphereDeltaJ, "AtmospherePreCompute.DeltaJ"); - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; const auto cb = shader->GetCB(0); Data data; diff --git a/Source/Engine/Renderer/ColorGradingPass.cpp b/Source/Engine/Renderer/ColorGradingPass.cpp index 0f5134b6c..658d2e6a9 100644 --- a/Source/Engine/Renderer/ColorGradingPass.cpp +++ b/Source/Engine/Renderer/ColorGradingPass.cpp @@ -130,7 +130,7 @@ bool ColorGradingPass::setupResources() { if (!_shader || !_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stage @@ -247,7 +247,7 @@ GPUTexture* ColorGradingPass::RenderLUT(RenderContext& renderContext) // Render LUT PROFILE_GPU("Color Grading LUT"); auto context = device->GetMainContext(); - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->SetViewportAndScissors((float)lutDesc.Width, (float)lutDesc.Height); diff --git a/Source/Engine/Renderer/ContrastAdaptiveSharpeningPass.cpp b/Source/Engine/Renderer/ContrastAdaptiveSharpeningPass.cpp index 3231c32f8..e8f039aa0 100644 --- a/Source/Engine/Renderer/ContrastAdaptiveSharpeningPass.cpp +++ b/Source/Engine/Renderer/ContrastAdaptiveSharpeningPass.cpp @@ -47,7 +47,7 @@ bool ContrastAdaptiveSharpeningPass::setupResources() } if (!_shader || !_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stage @@ -82,7 +82,7 @@ void ContrastAdaptiveSharpeningPass::Render(const RenderContext& renderContext, data.EdgeSharpening = antiAliasing.CAS_EdgeSharpening; data.MinEdgeThreshold = antiAliasing.CAS_MinEdgeThreshold; data.OverBlurLimit = antiAliasing.CAS_OverBlurLimit; - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->BindSR(0, input); diff --git a/Source/Engine/Renderer/DepthOfFieldPass.cpp b/Source/Engine/Renderer/DepthOfFieldPass.cpp index a015d8d82..866df28fd 100644 --- a/Source/Engine/Renderer/DepthOfFieldPass.cpp +++ b/Source/Engine/Renderer/DepthOfFieldPass.cpp @@ -116,7 +116,7 @@ bool DepthOfFieldPass::setupResources() // Wait for shader if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stages @@ -207,7 +207,7 @@ void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame, auto device = GPUDevice::Instance; auto context = device->GetMainContext(); const auto depthBuffer = renderContext.Buffers->DepthBuffer; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; PROFILE_GPU_CPU("Depth Of Field"); context->ResetSR(); diff --git a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp index 9e69dd716..f30071223 100644 --- a/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp +++ b/Source/Engine/Renderer/Editor/LightmapUVsDensity.cpp @@ -56,7 +56,7 @@ const MaterialInfo& LightmapUVsDensityMaterialShader::GetInfo() const GPUShader* LightmapUVsDensityMaterialShader::GetShader() const { - return _shader->GetShader(); + return _shader->GPU; } bool LightmapUVsDensityMaterialShader::IsReady() const @@ -76,7 +76,7 @@ void LightmapUVsDensityMaterialShader::Bind(BindParameters& params) auto& drawCall = *params.DrawCall; // Setup - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; auto cb = shader->GetCB(0); if (!_ps->IsValid()) { diff --git a/Source/Engine/Renderer/Editor/MaterialComplexity.cpp b/Source/Engine/Renderer/Editor/MaterialComplexity.cpp index cc4e34431..1c55e539d 100644 --- a/Source/Engine/Renderer/Editor/MaterialComplexity.cpp +++ b/Source/Engine/Renderer/Editor/MaterialComplexity.cpp @@ -173,7 +173,7 @@ void MaterialComplexityMaterialShader::Draw(RenderContext& renderContext, GPUCon { _ps = GPUDevice::Instance->CreatePipelineState(); auto psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; - psDesc.PS = _shader->GetShader()->GetPS("PS"); + psDesc.PS = _shader->GPU->GetPS("PS"); _ps->Init(psDesc); } context->BindSR(0, lightBuffer); diff --git a/Source/Engine/Renderer/Editor/QuadOverdrawPass.cpp b/Source/Engine/Renderer/Editor/QuadOverdrawPass.cpp index f5e264c86..fcee51364 100644 --- a/Source/Engine/Renderer/Editor/QuadOverdrawPass.cpp +++ b/Source/Engine/Renderer/Editor/QuadOverdrawPass.cpp @@ -143,7 +143,7 @@ bool QuadOverdrawPass::setupResources() } if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; GPUPipelineState::Description psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; if (!_ps) diff --git a/Source/Engine/Renderer/Editor/VertexColors.cpp b/Source/Engine/Renderer/Editor/VertexColors.cpp index 17158a341..d85c0b0f5 100644 --- a/Source/Engine/Renderer/Editor/VertexColors.cpp +++ b/Source/Engine/Renderer/Editor/VertexColors.cpp @@ -44,7 +44,7 @@ const MaterialInfo& VertexColorsMaterialShader::GetInfo() const GPUShader* VertexColorsMaterialShader::GetShader() const { - return _shader->GetShader(); + return _shader->GPU; } bool VertexColorsMaterialShader::IsReady() const @@ -64,7 +64,7 @@ void VertexColorsMaterialShader::Bind(BindParameters& params) auto& drawCall = *params.DrawCall; // Setup - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; auto cb = shader->GetCB(0); if (!_ps->IsValid()) { diff --git a/Source/Engine/Renderer/EyeAdaptationPass.cpp b/Source/Engine/Renderer/EyeAdaptationPass.cpp index 739316556..8d2b0f0de 100644 --- a/Source/Engine/Renderer/EyeAdaptationPass.cpp +++ b/Source/Engine/Renderer/EyeAdaptationPass.cpp @@ -90,7 +90,7 @@ void EyeAdaptationPass::Render(RenderContext& renderContext, GPUTexture* colorBu data.DropHistory = dropHistory ? 1.0f : 0.0f; // Update constants - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; const auto cb0 = shader->GetCB(0); context->UpdateCB(cb0, &data); context->BindCB(0, cb0); @@ -258,7 +258,7 @@ bool EyeAdaptationPass::setupResources() // Wait for shader if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, EyeAdaptationData); // Create pipeline stages diff --git a/Source/Engine/Renderer/ForwardPass.cpp b/Source/Engine/Renderer/ForwardPass.cpp index c0d57b498..434a68560 100644 --- a/Source/Engine/Renderer/ForwardPass.cpp +++ b/Source/Engine/Renderer/ForwardPass.cpp @@ -46,7 +46,7 @@ bool ForwardPass::setupResources() { return true; } - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; // Create pipeline stages GPUPipelineState::Description psDesc; diff --git a/Source/Engine/Renderer/GBufferPass.cpp b/Source/Engine/Renderer/GBufferPass.cpp index 8b5927ceb..2cba6aec8 100644 --- a/Source/Engine/Renderer/GBufferPass.cpp +++ b/Source/Engine/Renderer/GBufferPass.cpp @@ -66,7 +66,7 @@ bool GBufferPass::setupResources() { if (!_gBufferShader || !_gBufferShader->IsLoaded()) return true; - auto gbuffer = _gBufferShader->GetShader(); + auto gbuffer = _gBufferShader->GPU; // Validate shader constant buffers sizes if (gbuffer->GetCB(0)->GetSize() != sizeof(GBufferPassData)) @@ -264,7 +264,7 @@ void GBufferPass::RenderDebug(RenderContext& renderContext) // Cache data auto device = GPUDevice::Instance; auto context = device->GetMainContext(); - auto lights = _gBufferShader->GetShader(); + auto lights = _gBufferShader->GPU; GBufferPassData data; // Set constants buffer diff --git a/Source/Engine/Renderer/GI/DynamicDiffuseGlobalIllumination.cpp b/Source/Engine/Renderer/GI/DynamicDiffuseGlobalIllumination.cpp index 2771682f0..ebbc92b01 100644 --- a/Source/Engine/Renderer/GI/DynamicDiffuseGlobalIllumination.cpp +++ b/Source/Engine/Renderer/GI/DynamicDiffuseGlobalIllumination.cpp @@ -70,7 +70,7 @@ GPU_CB_STRUCT(Data0 { float TemporalTime; Int4 ProbeScrollClears[4]; Float3 ViewDir; - float Padding1; + float TestValue; Float3 QuantizationError; int32 FrameIndexMod8; }); @@ -250,7 +250,7 @@ bool DynamicDiffuseGlobalIlluminationPass::setupResources() return true; // Initialize resources - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; _cb0 = shader->GetCB(0); _cb1 = shader->GetCB(1); if (!_cb0 || !_cb1) @@ -601,6 +601,7 @@ bool DynamicDiffuseGlobalIlluminationPass::RenderInner(RenderContext& renderCont data.TemporalTime = renderContext.List->Setup.UseTemporalAAJitter ? RenderTools::ComputeTemporalTime() : 0.0f; data.ViewDir = renderContext.View.Direction; data.SkyboxIntensity = renderContext.List->Sky ? renderContext.List->Sky->GetIndirectLightingIntensity() : 1.0f; + data.TestValue = Graphics::TestValue; data.QuantizationError = RenderTools::GetColorQuantizationError(ddgiData.ProbesIrradiance->Format()); data.FrameIndexMod8 = (int32)(Engine::FrameCount % 8); GBufferPass::SetInputs(renderContext.View, data.GBuffer); diff --git a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp index 724918096..40194ce91 100644 --- a/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp +++ b/Source/Engine/Renderer/GI/GlobalSurfaceAtlasPass.cpp @@ -796,7 +796,7 @@ bool GlobalSurfaceAtlasPass::setupResources() return true; const auto device = GPUDevice::Instance; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; _cb0 = shader->GetCB(0); if (!_cb0) return true; diff --git a/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp b/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp index fd9218304..b015b2c74 100644 --- a/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp +++ b/Source/Engine/Renderer/GlobalSignDistanceFieldPass.cpp @@ -706,7 +706,7 @@ bool GlobalSignDistanceFieldPass::setupResources() return true; const auto device = GPUDevice::Instance; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; // Check shader _cb0 = shader->GetCB(0); @@ -1208,7 +1208,7 @@ void GlobalSignDistanceFieldPass::RenderDebug(RenderContext& renderContext, GPUC int32 chunkRes = sdfData.Resolution / GLOBAL_SDF_RASTERIZE_CHUNK_SIZE; OverdrawData data; GBufferPass::SetInputs(renderContext.View, data.GBuffer); - GPUConstantBuffer* cb2 = _shader->GetShader()->GetCB(2); + GPUConstantBuffer* cb2 = _shader->GPU->GetCB(2); context->BindCB(2, cb2); context->BindSR(0, renderContext.Buffers->DepthBuffer); context->BindSR(1, renderContext.Buffers->GBuffer0); diff --git a/Source/Engine/Renderer/HistogramPass.cpp b/Source/Engine/Renderer/HistogramPass.cpp index 9b6e71a77..dc3d08b3b 100644 --- a/Source/Engine/Renderer/HistogramPass.cpp +++ b/Source/Engine/Renderer/HistogramPass.cpp @@ -40,7 +40,7 @@ GPUBuffer* HistogramPass::Render(RenderContext& renderContext, GPUTexture* color GetHistogramMad(data.HistogramMul, data.HistogramAdd); // Update constants - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; const auto cb0 = shader->GetCB(0); context->UpdateCB(cb0, &data); context->BindCB(0, cb0); @@ -112,7 +112,7 @@ bool HistogramPass::setupResources() // Wait for shader if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, HistogramData); _csClearHistogram = shader->GetCS("CS_ClearHistogram"); diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index 11eee30b8..94a16a62f 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -63,7 +63,7 @@ bool LightPass::setupResources() // Wait for the assets if (!_sphereModel->CanBeRendered() || !_shader->IsLoaded()) return true; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, PerLight); CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 1, PerFrame); @@ -167,14 +167,10 @@ void LightPass::RenderLights(RenderContextBatch& renderContextBatch, GPUTextureV if (checkIfSkipPass()) return; PROFILE_GPU_CPU("Lights"); - - // Cache data - auto device = GPUDevice::Instance; - auto context = device->GetMainContext(); + auto context = GPUDevice::Instance->GetMainContext(); auto& renderContext = renderContextBatch.GetMainContext(); auto& view = renderContext.View; auto mainCache = renderContext.List; - const auto lightShader = _shader->GetShader(); const bool disableSpecular = (view.Flags & ViewFlags::SpecularLight) == ViewFlags::None; // Check if debug lights @@ -188,13 +184,13 @@ void LightPass::RenderLights(RenderContextBatch& renderContextBatch, GPUTextureV { auto psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; psDesc.BlendMode.RenderTargetWriteMask = BlendingMode::ColorWrite::RGB; // Leave AO in Alpha channel unmodified - psDesc.PS = quadShader->GetShader()->GetPS("PS_Clear"); + psDesc.PS = quadShader->GPU->GetPS("PS_Clear"); _psClearDiffuse->Init(psDesc); } if (_psClearDiffuse->IsValid()) { context->SetRenderTarget(renderContext.Buffers->GBuffer0->View()); - auto cb = quadShader->GetShader()->GetCB(0); + auto cb = quadShader->GPU->GetCB(0); context->UpdateCB(cb, &Color::White); context->BindCB(0, cb); context->SetState(_psClearDiffuse); @@ -221,8 +217,8 @@ void LightPass::RenderLights(RenderContextBatch& renderContextBatch, GPUTextureV // Set per frame data GBufferPass::SetInputs(renderContext.View, perFrame.GBuffer); - auto cb0 = lightShader->GetCB(0); - auto cb1 = lightShader->GetCB(1); + auto cb0 = _shader->GPU->GetCB(0); + auto cb1 = _shader->GPU->GetCB(1); context->UpdateCB(cb1, &perFrame); // Bind inputs diff --git a/Source/Engine/Renderer/MotionBlurPass.cpp b/Source/Engine/Renderer/MotionBlurPass.cpp index 910ced532..69a26b825 100644 --- a/Source/Engine/Renderer/MotionBlurPass.cpp +++ b/Source/Engine/Renderer/MotionBlurPass.cpp @@ -85,7 +85,7 @@ bool MotionBlurPass::setupResources() // Check shader if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline state @@ -199,7 +199,7 @@ void MotionBlurPass::RenderMotionVectors(RenderContext& renderContext) Matrix::Transpose(renderContext.View.PrevViewProjection, data.PreviousVP); data.TemporalAAJitter = renderContext.View.TemporalAAJitter; data.PrevWorldOriginOffset = renderContext.View.Origin - renderContext.View.PrevOrigin; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->BindSR(0, depthBuffer); @@ -314,7 +314,7 @@ void MotionBlurPass::Render(RenderContext& renderContext, GPUTexture*& frame, GP data.MaxBlurSamples = Math::Clamp(settings.SampleCount / 2, 1, 64); // 2x samples in loop data.VariableTileLoopCount = tileSize / 8; data.Input0SizeInv = Float2(1.0f / (float)motionVectorsWidth, 1.0f / (float)motionVectorsWidth); - const auto cb = _shader->GetShader()->GetCB(0); + const auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); diff --git a/Source/Engine/Renderer/PostProcessingPass.cpp b/Source/Engine/Renderer/PostProcessingPass.cpp index da81f9744..d3913e648 100644 --- a/Source/Engine/Renderer/PostProcessingPass.cpp +++ b/Source/Engine/Renderer/PostProcessingPass.cpp @@ -104,7 +104,7 @@ bool PostProcessingPass::setupResources() // Wait for shader if (!_shader->IsLoaded()) return true; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 1, GaussianBlurData); @@ -286,7 +286,7 @@ void PostProcessingPass::Render(RenderContext& renderContext, GPUTexture* input, } // Cache data - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; auto cb0 = shader->GetCB(0); auto cb1 = shader->GetCB(1); diff --git a/Source/Engine/Renderer/ProbesRenderer.cpp b/Source/Engine/Renderer/ProbesRenderer.cpp index aa5a7f559..2f4a827da 100644 --- a/Source/Engine/Renderer/ProbesRenderer.cpp +++ b/Source/Engine/Renderer/ProbesRenderer.cpp @@ -314,7 +314,7 @@ bool ProbesRendererService::LazyInit() bool ProbesRendererService::InitShader() { - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); _psFilterFace = GPUDevice::Instance->CreatePipelineState(); auto psDesc = GPUPipelineState::Description::DefaultFullscreenTriangle; @@ -468,7 +468,7 @@ void ProbesRendererService::OnRender(RenderTask* task, GPUContext* context) return; } ASSERT(_updateFrameNumber == 0); - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; PROFILE_GPU("Render Probe"); #if COMPILE_WITH_DEV_ENV diff --git a/Source/Engine/Renderer/ReflectionsPass.cpp b/Source/Engine/Renderer/ReflectionsPass.cpp index 772461ee7..cf2e516b1 100644 --- a/Source/Engine/Renderer/ReflectionsPass.cpp +++ b/Source/Engine/Renderer/ReflectionsPass.cpp @@ -189,7 +189,7 @@ bool ReflectionsPass::setupResources() // Wait for the assets if (!_sphereModel->CanBeRendered() || !_boxModel->CanBeRendered() || !_preIntegratedGF->IsLoaded() || !_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stages @@ -278,7 +278,7 @@ void ReflectionsPass::Render(RenderContext& renderContext, GPUTextureView* light bool useSSR = EnumHasAnyFlags(view.Flags, ViewFlags::SSR) && renderContext.List->Settings.ScreenSpaceReflections.Intensity > ZeroTolerance; int32 probesCount = renderContext.List->EnvironmentProbes.Count(); bool renderProbes = probesCount > 0; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; auto cb = shader->GetCB(0); // Check if no need to render reflection environment diff --git a/Source/Engine/Renderer/RenderSetup.h b/Source/Engine/Renderer/RenderSetup.h index 3444f0838..b5a04b51f 100644 --- a/Source/Engine/Renderer/RenderSetup.h +++ b/Source/Engine/Renderer/RenderSetup.h @@ -10,6 +10,7 @@ struct FLAXENGINE_API RenderSetup { RenderingUpscaleLocation UpscaleLocation = RenderingUpscaleLocation::AfterAntiAliasingPass; + bool UseShadows = false; bool UseMotionVectors = false; bool UseTemporalAAJitter = false; bool UseGlobalSDF = false; diff --git a/Source/Engine/Renderer/Renderer.cpp b/Source/Engine/Renderer/Renderer.cpp index b62fbe14d..62c546919 100644 --- a/Source/Engine/Renderer/Renderer.cpp +++ b/Source/Engine/Renderer/Renderer.cpp @@ -385,6 +385,21 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont const int32 screenWidth = renderContext.Buffers->GetWidth(); const int32 screenHeight = renderContext.Buffers->GetHeight(); setup.UpscaleLocation = renderContext.Task->UpscaleLocation; + setup.UseShadows = !isGBufferDebug && EnumHasAnyFlags(view.Flags, ViewFlags::Shadows) && ShadowsPass::Instance()->IsReady(); + switch (renderContext.View.Mode) + { + case ViewMode::QuadOverdraw: + case ViewMode::Emissive: + case ViewMode::LightmapUVsDensity: + case ViewMode::GlobalSurfaceAtlas: + case ViewMode::GlobalSDF: + case ViewMode::GlobalSDFOverdraw: + case ViewMode::MaterialComplexity: + case ViewMode::VertexColors: + case ViewMode::LightOverlap: + setup.UseShadows = false; + break; + } if (screenWidth < 16 || screenHeight < 16 || renderContext.Task->IsCameraCut || isGBufferDebug || renderContext.View.Mode == ViewMode::NoPostFx) setup.UseMotionVectors = false; else @@ -453,22 +468,8 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont renderContextBatch.GetMainContext() = renderContext; // Sync render context in batch with the current value renderContext.List->PreDraw(context, renderContextBatch); - bool drawShadows = !isGBufferDebug && EnumHasAnyFlags(view.Flags, ViewFlags::Shadows) && ShadowsPass::Instance()->IsReady(); - switch (renderContext.View.Mode) - { - case ViewMode::QuadOverdraw: - case ViewMode::Emissive: - case ViewMode::LightmapUVsDensity: - case ViewMode::GlobalSurfaceAtlas: - case ViewMode::GlobalSDF: - case ViewMode::GlobalSDFOverdraw: - case ViewMode::MaterialComplexity: - case ViewMode::VertexColors: - drawShadows = false; - break; - } LightPass::Instance()->SetupLights(renderContext, renderContextBatch); - if (drawShadows) + if (setup.UseShadows) ShadowsPass::Instance()->SetupShadows(renderContext, renderContextBatch); #if USE_EDITOR GBufferPass::Instance()->PreOverrideDrawCalls(renderContext); diff --git a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp index bb113fbc2..80babe20b 100644 --- a/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp +++ b/Source/Engine/Renderer/ScreenSpaceReflectionsPass.cpp @@ -79,7 +79,7 @@ bool ScreenSpaceReflectionsPass::setupResources() return true; if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stages @@ -141,7 +141,7 @@ GPUTexture* ScreenSpaceReflectionsPass::Render(RenderContext& renderContext, GPU // Cache data auto device = GPUDevice::Instance; auto context = device->GetMainContext(); - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; auto cb = shader->GetCB(0); auto& settings = renderContext.List->Settings.ScreenSpaceReflections; const bool useTemporal = settings.TemporalEffect && !renderContext.Task->IsCameraCut && renderContext.List->Setup.UseMotionVectors; diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index a3fd7d625..459002f61 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -517,7 +517,7 @@ bool ShadowsPass::setupResources() // Wait for the assets if (!_sphereModel->CanBeRendered() || !_shader->IsLoaded()) return true; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline stages @@ -1695,7 +1695,7 @@ void ShadowsPass::RenderShadowMask(RenderContextBatch& renderContextBatch, Rende const ShadowsCustomBuffer& shadows = *renderContext.Buffers->FindCustomBuffer(TEXT("Shadows"), false); ASSERT(shadows.LastFrameUsed == Engine::FrameCount); auto& view = renderContext.View; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; const bool isLocalLight = light.IsPointLight || light.IsSpotLight; int32 shadowQuality = shadows.MaxShadowsQuality; if (isLocalLight) diff --git a/Source/Engine/Renderer/Utils/BitonicSort.cpp b/Source/Engine/Renderer/Utils/BitonicSort.cpp index a031b0e9d..001f903e8 100644 --- a/Source/Engine/Renderer/Utils/BitonicSort.cpp +++ b/Source/Engine/Renderer/Utils/BitonicSort.cpp @@ -49,7 +49,7 @@ bool BitonicSort::setupResources() { if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; _cb = shader->GetCB(0); CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); diff --git a/Source/Engine/Renderer/Utils/MultiScaler.cpp b/Source/Engine/Renderer/Utils/MultiScaler.cpp index e878d1e5c..26e4e6408 100644 --- a/Source/Engine/Renderer/Utils/MultiScaler.cpp +++ b/Source/Engine/Renderer/Utils/MultiScaler.cpp @@ -41,7 +41,7 @@ bool MultiScaler::setupResources() // Check if shader has not been loaded if (!_shader->IsLoaded()) return true; - const auto shader = _shader->GetShader(); + const auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // Create pipeline states @@ -140,7 +140,7 @@ void MultiScaler::Filter(FilterMode mode, GPUContext* context, int32 width, int3 Data data; data.TexelSize.X = 1.0f / (float)width; data.TexelSize.Y = 1.0f / (float)height; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); auto rtAction = GPUDrawPassAction::Store; @@ -197,7 +197,7 @@ void MultiScaler::Filter(FilterMode mode, GPUContext* context, int32 width, int3 Data data; data.TexelSize.X = 1.0f / (float)width; data.TexelSize.Y = 1.0f / (float)height; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); auto rtAction = GPUDrawPassAction::Store; @@ -241,7 +241,7 @@ void MultiScaler::DownscaleDepth(GPUContext* context, int32 dstWidth, int32 dstH Data data; data.TexelSize.X = 1.0f / (float)src->Width(); data.TexelSize.Y = 1.0f / (float)src->Height(); - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); @@ -324,7 +324,7 @@ void MultiScaler::Upscale(GPUContext* context, const Viewport& viewport, GPUText Data data; data.TexelSize.X = 1.0f / (float)src->Width(); data.TexelSize.Y = 1.0f / (float)src->Height(); - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &data); context->BindCB(0, cb); context->BindSR(0, src); diff --git a/Source/Engine/Renderer/VolumetricFogPass.cpp b/Source/Engine/Renderer/VolumetricFogPass.cpp index 1556c56a2..542f9db51 100644 --- a/Source/Engine/Renderer/VolumetricFogPass.cpp +++ b/Source/Engine/Renderer/VolumetricFogPass.cpp @@ -117,7 +117,7 @@ bool VolumetricFogPass::setupResources() { if (!_shader->IsLoaded()) return true; - auto shader = _shader->GetShader(); + auto shader = _shader->GPU; CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 0, Data); // CB1 is used for per-draw info (ObjectIndex) CHECK_INVALID_SHADER_PASS_CB_SIZE(shader, 2, PerLight); @@ -339,7 +339,7 @@ bool VolumetricFogPass::Init(FrameCache& cache, RenderContext& renderContext, GP } // Set constant buffer data - auto cb0 = _shader->GetShader()->GetCB(0); + auto cb0 = _shader->GPU->GetCB(0); context->UpdateCB(cb0, &cache.Data); // Clear local lights scattering table if was used and will be probably reused later @@ -498,7 +498,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) } // Set constant buffer data - auto cb0 = _shader->GetShader()->GetCB(0); + auto cb0 = _shader->GPU->GetCB(0); context->UpdateCB(cb0, &cache.Data); context->BindCB(0, cb0); @@ -542,7 +542,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) MaterialBase::BindParameters bindParams(context, renderContext); CustomData customData; - customData.Shader = _shader->GetShader(); + customData.Shader = _shader->GPU; customData.GridSize = cache.GridSize; customData.VolumetricFogMaxDistance = cache.Data.VolumetricFogRange.Y; customData.GridSliceParameters = cache.Data.GridSliceParameters; @@ -564,7 +564,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) // Setup volumetric shader data PerLight perLight; - auto cb2 = _shader->GetShader()->GetCB(2); + auto cb2 = _shader->GPU->GetCB(2); perLight.SliceToDepth.X = cache.Data.GridSize.Z; perLight.SliceToDepth.Y = cache.Data.VolumetricFogRange.Y; perLight.MinZ = sphere.VolumeZBoundsMin; @@ -622,7 +622,7 @@ void VolumetricFogPass::Render(RenderContext& renderContext) PerLight perLight; perLight.SliceToDepth.X = cache.Data.GridSize.Z; perLight.SliceToDepth.Y = cache.Data.VolumetricFogRange.Y; - auto cb2 = _shader->GetShader()->GetCB(2); + auto cb2 = _shader->GPU->GetCB(2); // Bind the output context->SetRenderTarget(localShadowedLightScattering); diff --git a/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp b/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp index 678cad294..0f3a2eca3 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.Jobs.cpp @@ -116,7 +116,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) // Render entry auto& entry = scene->Entries[lightmapEntry.Entries[_workerStagePosition1]]; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); switch (entry.Type) { case GeometryType::StaticModel: @@ -259,7 +259,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) ShaderData shaderData; shaderData.AtlasSize = atlasSize; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &shaderData); context->BindCB(0, cb); @@ -405,12 +405,12 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) shaderData.TexelAddress = (hemisphere.TexelY * atlasSize + hemisphere.TexelX) * NUM_SH_TARGETS; // Calculate per pixel irradiance using compute shaders - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &shaderData); context->BindCB(0, cb); context->BindUA(0, _irradianceReduction->View()); context->BindSR(0, radianceMap); - context->Dispatch(_shader->GetShader()->GetCS("CS_Integrate"), 1, HEMISPHERES_RESOLUTION, 1); + context->Dispatch(_shader->GPU->GetCS("CS_Integrate"), 1, HEMISPHERES_RESOLUTION, 1); context->ResetUA(); context->ResetSR(); @@ -418,7 +418,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) context->BindUA(0, lightmapEntry.LightmapData->View()); context->BindSR(0, _irradianceReduction->View()); // TODO: cache shader handle - context->Dispatch(_shader->GetShader()->GetCS("CS_Reduction"), 1, NUM_SH_TARGETS, 1); + context->Dispatch(_shader->GPU->GetCS("CS_Reduction"), 1, NUM_SH_TARGETS, 1); // Unbind slots now to make rendering backend live easier context->ResetSR(); @@ -467,7 +467,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) auto& lightmapEntry = scene->Lightmaps[_workerStagePosition0]; ShaderData shaderData; shaderData.AtlasSize = atlasSize; - auto cb = _shader->GetShader()->GetCB(0); + auto cb = _shader->GPU->GetCB(0); context->UpdateCB(cb, &shaderData); context->BindCB(0, cb); @@ -475,7 +475,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) context->ResetRenderTarget(); context->BindSR(0, lightmapEntry.LightmapData->View()); context->BindUA(0, scene->TempLightmapData->View()); - context->Dispatch(_shader->GetShader()->GetCS("CS_BlurEmpty"), atlasSize, atlasSize, 1); + context->Dispatch(_shader->GPU->GetCS("CS_BlurEmpty"), atlasSize, atlasSize, 1); // Swap temporary buffer used as output with lightmap entry data (these buffers are the same) // So we can rewrite data from one buffer to another with custom sampling @@ -492,7 +492,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) context->BindSR(0, lightmapEntry.LightmapData->View()); context->BindUA(0, scene->TempLightmapData->View()); - context->Dispatch(_shader->GetShader()->GetCS("CS_Dilate"), atlasSize, atlasSize, 1); + context->Dispatch(_shader->GPU->GetCS("CS_Dilate"), atlasSize, atlasSize, 1); Swap(scene->TempLightmapData, lightmapEntry.LightmapData); } @@ -500,7 +500,7 @@ void ShadowsOfMordor::Builder::onJobRender(GPUContext* context) context->BindUA(0, lightmapEntry.LightmapData->View()); // Remove the BACKGROUND_TEXELS_MARK from the unused texels (see shader for more info) - context->Dispatch(_shader->GetShader()->GetCS("CS_Finalize"), atlasSize, atlasSize, 1); + context->Dispatch(_shader->GPU->GetCS("CS_Finalize"), atlasSize, atlasSize, 1); // Move to another lightmap _workerStagePosition0++; diff --git a/Source/Engine/ShadowsOfMordor/Builder.cpp b/Source/Engine/ShadowsOfMordor/Builder.cpp index 048661617..80383227e 100644 --- a/Source/Engine/ShadowsOfMordor/Builder.cpp +++ b/Source/Engine/ShadowsOfMordor/Builder.cpp @@ -470,19 +470,19 @@ bool ShadowsOfMordor::Builder::initResources() _psRenderCacheModel = GPUDevice::Instance->CreatePipelineState(); GPUPipelineState::Description desc = GPUPipelineState::Description::DefaultNoDepth; desc.CullMode = CullMode::TwoSided; - desc.VS = _shader->GetShader()->GetVS("VS_RenderCacheModel"); - desc.PS = _shader->GetShader()->GetPS("PS_RenderCache"); + desc.VS = _shader->GPU->GetVS("VS_RenderCacheModel"); + desc.PS = _shader->GPU->GetPS("PS_RenderCache"); if (_psRenderCacheModel->Init(desc)) return true; _psRenderCacheTerrain = GPUDevice::Instance->CreatePipelineState(); - desc.VS = _shader->GetShader()->GetVS("VS_RenderCacheTerrain"); + desc.VS = _shader->GPU->GetVS("VS_RenderCacheTerrain"); if (_psRenderCacheTerrain->Init(desc)) return true; _psBlurCache = GPUDevice::Instance->CreatePipelineState(); desc = GPUPipelineState::Description::DefaultFullscreenTriangle; - desc.PS = _shader->GetShader()->GetPS("PS_BlurCache"); + desc.PS = _shader->GPU->GetPS("PS_BlurCache"); if (_psBlurCache->Init(desc)) return true; diff --git a/Source/Engine/Tools/ModelTool/ModelTool.cpp b/Source/Engine/Tools/ModelTool/ModelTool.cpp index fc86d74e5..192db62c2 100644 --- a/Source/Engine/Tools/ModelTool/ModelTool.cpp +++ b/Source/Engine/Tools/ModelTool/ModelTool.cpp @@ -143,7 +143,7 @@ public: // Allocate resources if (_shader == nullptr || _shader->WaitForLoaded()) return Result::Failed; - GPUShader* shader = _shader->GetShader(); + GPUShader* shader = _shader->GPU; const uint32 resolutionSize = _resolution.X * _resolution.Y * _resolution.Z; auto cb = shader->GetCB(0); Data data; diff --git a/Source/Shaders/GI/DDGI.shader b/Source/Shaders/GI/DDGI.shader index 18d46e5e5..f0528f5a3 100644 --- a/Source/Shaders/GI/DDGI.shader +++ b/Source/Shaders/GI/DDGI.shader @@ -49,7 +49,7 @@ float ResetBlend; float TemporalTime; int4 ProbeScrollClears[4]; float3 ViewDir; -float Padding1; +float TestValue; float3 QuantizationError; uint FrameIndexMod8; META_CB_END