diff --git a/Source/Engine/Graphics/GPUContext.h b/Source/Engine/Graphics/GPUContext.h
index c38faee34..a271a037a 100644
--- a/Source/Engine/Graphics/GPUContext.h
+++ b/Source/Engine/Graphics/GPUContext.h
@@ -173,8 +173,10 @@ public:
///
/// Determines whether depth buffer is binded to the pipeline.
+ /// [Deprecated in v1.10]
///
/// true if depth buffer is binded; otherwise, false.
+ DEPRECATED("IsDepthBufferBinded has been deprecated and will be removed in ")
virtual bool IsDepthBufferBinded() = 0;
public:
diff --git a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp
index 69a097a2a..13f8aa810 100644
--- a/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp
+++ b/Source/Engine/Graphics/Materials/GUIMaterialShader.cpp
@@ -34,8 +34,8 @@ void GUIMaterialShader::Bind(BindParameters& params)
auto materialData = reinterpret_cast(cb.Get());
cb = Span(cb.Get() + sizeof(GUIMaterialShaderData), cb.Length() - sizeof(GUIMaterialShaderData));
int32 srv = 0;
- const auto ps = context->IsDepthBufferBinded() ? _cache.Depth : _cache.NoDepth;
auto customData = (Render2D::CustomData*)params.CustomData;
+ const auto ps = customData->UseDepthBuffer ? _cache.Depth : _cache.NoDepth;
// Setup parameters
MaterialParameter::BindMeta bindMeta;
@@ -83,26 +83,21 @@ void GUIMaterialShader::Unload()
bool GUIMaterialShader::Load()
{
- GPUPipelineState::Description psDesc0 = GPUPipelineState::Description::DefaultFullscreenTriangle;
- psDesc0.Wireframe = EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::Wireframe);
- psDesc0.VS = _shader->GetVS("VS_GUI");
- psDesc0.PS = _shader->GetPS("PS_GUI");
- psDesc0.BlendMode = BlendingMode::AlphaBlend;
-
- psDesc0.DepthEnable = psDesc0.DepthWriteEnable = true;
+ auto desc = GPUPipelineState::Description::DefaultFullscreenTriangle;
+ desc.Wireframe = EnumHasAnyFlags(_info.FeaturesFlags, MaterialFeaturesFlags::Wireframe);
+ desc.VS = _shader->GetVS("VS_GUI");
+ desc.PS = _shader->GetPS("PS_GUI");
+ desc.BlendMode = BlendingMode::AlphaBlend;
+ desc.DepthEnable = true;
_cache.Depth = GPUDevice::Instance->CreatePipelineState();
_cache.NoDepth = GPUDevice::Instance->CreatePipelineState();
-
- bool failed = _cache.Depth->Init(psDesc0);
-
- psDesc0.DepthEnable = psDesc0.DepthWriteEnable = false;
- failed |= _cache.NoDepth->Init(psDesc0);
-
+ bool failed = _cache.Depth->Init(desc);
+ desc.DepthEnable = false;
+ failed |= _cache.NoDepth->Init(desc);
if (failed)
{
LOG(Warning, "Failed to create GUI material pipeline state.");
return true;
}
-
return false;
}
diff --git a/Source/Engine/Render2D/Render2D.cpp b/Source/Engine/Render2D/Render2D.cpp
index f709ed420..d4f6e81ce 100644
--- a/Source/Engine/Render2D/Render2D.cpp
+++ b/Source/Engine/Render2D/Render2D.cpp
@@ -759,10 +759,7 @@ void Render2D::End()
IsScissorsRectEmpty = false;
for (int32 i = 0; i < DrawCalls.Count(); i++)
{
- // Peek draw call
const auto& drawCall = DrawCalls[i];
-
- // Check if cannot add element to the batching
if (batchSize != 0 && !CanBatchDrawCalls(DrawCalls[batchStart], drawCall))
{
// Flush batched elements
@@ -990,6 +987,7 @@ void DrawBatch(int32 startIndex, int32 count)
Render2D::CustomData customData;
customData.ViewProjection = ViewProjection;
customData.ViewSize = Float2::One;
+ customData.UseDepthBuffer = DepthBuffer != nullptr;
bindParams.CustomData = &customData;
material->Bind(bindParams);
@@ -1026,6 +1024,7 @@ void DrawBatch(int32 startIndex, int32 count)
Render2D::CustomData customData;
customData.ViewProjection = ViewProjection;
customData.ViewSize = Float2(d.AsMaterial.Width, d.AsMaterial.Height);
+ customData.UseDepthBuffer = DepthBuffer != nullptr;
bindParams.CustomData = &customData;
material->Bind(bindParams);
diff --git a/Source/Engine/Render2D/Render2D.h b/Source/Engine/Render2D/Render2D.h
index 886c9e664..fabad97af 100644
--- a/Source/Engine/Render2D/Render2D.h
+++ b/Source/Engine/Render2D/Render2D.h
@@ -55,6 +55,7 @@ API_CLASS(Static) class FLAXENGINE_API Render2D
{
Matrix ViewProjection;
Float2 ViewSize;
+ bool UseDepthBuffer;
};
public: