diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp index 154dbe636..c956566ca 100644 --- a/Source/Engine/Render2D/Render2D.cpp +++ b/Source/Engine/Render2D/Render2D.cpp @@ -182,41 +182,44 @@ struct ClipMask Render2D::RenderingFeatures Render2D::Features = RenderingFeatures::VertexSnapping; -// Private Stuff -GPUContext* Context = nullptr; -GPUTextureView* Output = nullptr; -GPUTextureView* DepthBuffer = nullptr; -Viewport View; -Matrix ViewProjection; +namespace +{ + // Private Stuff + GPUContext* Context = nullptr; + GPUTextureView* Output = nullptr; + GPUTextureView* DepthBuffer = nullptr; + Viewport View; + Matrix ViewProjection; -// Drawing -Array DrawCalls; -Array Lines; -Array Lines2; -bool IsScissorsRectEmpty; -bool IsScissorsRectEnabled; + // Drawing + Array DrawCalls; + Array Lines; + Array Lines2; + bool IsScissorsRectEmpty; + bool IsScissorsRectEnabled; -// Transform -// Note: we use Matrix3x3 instead of Matrix because we use only 2D transformations on CPU side -// Matrix layout: -// [ m1, m2, 0 ] -// [ m3, m4, 0 ] -// [ t1, t2, 1 ] -// where 'm' is 2D transformation (scale, shear and rotate), 't' is translation -Array> TransformLayersStack; -Matrix3x3 TransformCached; + // Transform + // Note: we use Matrix3x3 instead of Matrix because we use only 2D transformations on CPU side + // Matrix layout: + // [ m1, m2, 0 ] + // [ m3, m4, 0 ] + // [ t1, t2, 1 ] + // where 'm' is 2D transformation (scale, shear and rotate), 't' is translation + Array> TransformLayersStack; + Matrix3x3 TransformCached; -Array> ClipLayersStack; + Array> ClipLayersStack; -// Shader -AssetReference GUIShader; -CachedPSO PsoDepth; -CachedPSO PsoNoDepth; -CachedPSO* CurrentPso = nullptr; -DynamicVertexBuffer VB(RENDER2D_INITIAL_VB_CAPACITY, (uint32)sizeof(Render2DVertex), TEXT("Render2D.VB")); -DynamicIndexBuffer IB(RENDER2D_INITIAL_IB_CAPACITY, sizeof(uint32), TEXT("Render2D.IB")); -uint32 VBIndex = 0; -uint32 IBIndex = 0; + // Shader + AssetReference GUIShader; + CachedPSO PsoDepth; + CachedPSO PsoNoDepth; + CachedPSO* CurrentPso = nullptr; + DynamicVertexBuffer VB(RENDER2D_INITIAL_VB_CAPACITY, (uint32)sizeof(Render2DVertex), TEXT("Render2D.VB")); + DynamicIndexBuffer IB(RENDER2D_INITIAL_IB_CAPACITY, sizeof(uint32), TEXT("Render2D.IB")); + uint32 VBIndex = 0; + uint32 IBIndex = 0; +} #define RENDER2D_WRITE_IB_QUAD(indices) \ indices[0] = VBIndex + 0; \ @@ -957,8 +960,8 @@ void DrawBatch(int32 startIndex, int32 count) data.Bounds.Y = bounds.Y; data.Bounds.Z = bounds.Z - bounds.X; data.Bounds.W = bounds.W - bounds.Y; - data.InvBufferSize.X = 1.0f / renderTargetWidth; - data.InvBufferSize.Y = 1.0f / renderTargetHeight; + 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); Context->UpdateCB(cb, &data); @@ -1003,11 +1006,8 @@ void DrawBatch(int32 startIndex, int32 count) break; } case DrawCallType::ClipScissors: - { - Rectangle* scissorsRect = (Rectangle*)&d.AsClipScissors.X; - Context->SetScissor(*scissorsRect); + Context->SetScissor(*(Rectangle*)&d.AsClipScissors.X); return; - } case DrawCallType::LineAA: Context->SetState(CurrentPso->PS_LineAA); break;