From 38cdd28681b6d2f5b336ef3f97bef64d26ce7d5a Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Mon, 2 Nov 2020 19:44:56 +0100 Subject: [PATCH] gpu: fix depth buffer corruption on the Fairphone 2 Signed-off-by: Elias Naur --- gpu/gpu.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gpu/gpu.go b/gpu/gpu.go index 0ea1a011..b2adc08c 100644 --- a/gpu/gpu.go +++ b/gpu/gpu.go @@ -342,8 +342,10 @@ func (g *GPU) BeginFrame() { } g.ctx.BindFramebuffer(g.defFBO) g.ctx.DepthFunc(backend.DepthFuncGreater) - g.ctx.ClearDepth(0.0) + // Note that Clear must be before ClearDepth if nothing else is rendered + // (len(zimageOps) == 0). If not, the Fairphone 2 will corrupt the depth buffer. g.ctx.Clear(g.drawOps.clearColor.Float32()) + g.ctx.ClearDepth(0.0) g.ctx.Viewport(0, 0, viewport.X, viewport.Y) g.renderer.drawZOps(g.drawOps.zimageOps) g.zopsTimer.end()