Partially revert "gpu: saturate instead of overflowing depth buffer"

This reverts commit 504664e014.

Reason: Doesn't work.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
Elias Naur
2020-06-08 16:59:11 +02:00
parent 06f6f54b2d
commit ab9b6383a4
+7 -8
View File
@@ -71,7 +71,7 @@ type drawState struct {
t op.TransformOp t op.TransformOp
cpath *pathOp cpath *pathOp
rect bool rect bool
z uint16 z int
matType materialType matType materialType
// Current paint.ImageOp // Current paint.ImageOp
@@ -335,8 +335,7 @@ func (g *GPU) BeginFrame() {
g.zopsTimer.begin() g.zopsTimer.begin()
} }
g.ctx.BindFramebuffer(g.defFBO) g.ctx.BindFramebuffer(g.defFBO)
// Equal because of depth saturation. g.ctx.DepthFunc(backend.DepthFuncGreater)
g.ctx.DepthFunc(backend.DepthFuncGreaterEqual)
g.ctx.ClearDepth(0.0) g.ctx.ClearDepth(0.0)
g.ctx.Clear(g.drawOps.clearColor.Float32()) g.ctx.Clear(g.drawOps.clearColor.Float32())
g.ctx.Viewport(0, 0, viewport.X, viewport.Y) g.ctx.Viewport(0, 0, viewport.X, viewport.Y)
@@ -681,7 +680,7 @@ func (d *drawOps) newPathOp() *pathOp {
return &d.pathOpCache[len(d.pathOpCache)-1] return &d.pathOpCache[len(d.pathOpCache)-1]
} }
func (d *drawOps) collectOps(r *ops.Reader, state drawState) uint16 { func (d *drawOps) collectOps(r *ops.Reader, state drawState) int {
var aux []byte var aux []byte
var auxKey ops.Key var auxKey ops.Key
loop: loop:
@@ -750,10 +749,10 @@ loop:
d.clearColor = mat.color.Opaque() d.clearColor = mat.color.Opaque()
continue continue
} }
// It's ok to saturate the depth value because we're using state.z++
// the >= depth comparison function. if state.z != int(uint16(state.z)) {
if state.z < 0xffff { // TODO(eliasnaur) gioui.org/issue/127.
state.z++ panic("more than 65k paint objects not supported")
} }
// Assume 16-bit depth buffer. // Assume 16-bit depth buffer.
const zdepth = 1 << 16 const zdepth = 1 << 16