reset depth stencil state for render pass (#3230)

This commit is contained in:
yousifd
2025-02-17 22:54:17 +03:00
committed by GitHub
parent 4bb60dceb8
commit 53a6ca5a99
3 changed files with 22 additions and 0 deletions

View File

@@ -42,6 +42,13 @@ public:
void endEncoding();
/// Resets the states and bindings of the render pass to deal
/// with situations where they are changed by calling the
/// underlying rendering API directly. Currently this happens
/// when a user changes one of these states or bindings
/// in a custom layer
void resetState();
void addDebugSignpost(const char* name) override;
void bindVertex(const BufferResource&, std::size_t offset, std::size_t index, std::size_t size = 0);

View File

@@ -8,6 +8,7 @@
#if MLN_RENDER_BACKEND_METAL
#include <mbgl/style/layers/mtl/custom_layer_render_parameters.hpp>
#include <mbgl/mtl/render_pass.hpp>
#endif
#include <memory>
@@ -23,6 +24,9 @@ void DrawableCustomLayerHostTweaker::execute([[maybe_unused]] gfx::Drawable& dra
paintParameters.colorModeForRenderPass());
#if MLN_RENDER_BACKEND_METAL
const auto& mtlRenderPass = static_cast<mtl::RenderPass*>(paintParameters.renderPass.get());
mtlRenderPass->resetState();
style::mtl::CustomLayerRenderParameters parameters(paintParameters);
#else
style::CustomLayerRenderParameters parameters(paintParameters);

View File

@@ -72,6 +72,17 @@ void RenderPass::endEncoding() {
}
}
void RenderPass::resetState() {
currentDepthStencilState.reset();
currentStencilReferenceValue = 0;
for (int i = 0; i < maxBinds; ++i) {
vertexBinds[i].reset();
fragmentBinds[i].reset();
fragmentTextureBindings[i].reset();
fragmentSamplerStates[i].reset();
}
}
namespace {
constexpr auto missing = "<none>";
NS::String* toNSString(const char* str) {