@@ -173,8 +173,10 @@ public:
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether depth buffer is binded to the pipeline.
|
||||
/// [Deprecated in v1.10]
|
||||
/// </summary>
|
||||
/// <returns><c>true</c> if depth buffer is binded; otherwise, <c>false</c>.</returns>
|
||||
DEPRECATED("IsDepthBufferBinded has been deprecated and will be removed in ")
|
||||
virtual bool IsDepthBufferBinded() = 0;
|
||||
|
||||
public:
|
||||
|
||||
@@ -34,8 +34,8 @@ void GUIMaterialShader::Bind(BindParameters& params)
|
||||
auto materialData = reinterpret_cast<GUIMaterialShaderData*>(cb.Get());
|
||||
cb = Span<byte>(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;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ API_CLASS(Static) class FLAXENGINE_API Render2D
|
||||
{
|
||||
Matrix ViewProjection;
|
||||
Float2 ViewSize;
|
||||
bool UseDepthBuffer;
|
||||
};
|
||||
|
||||
public:
|
||||
|
||||
Reference in New Issue
Block a user