<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - GL_DEPTH_CLAMP doesn't clamp to the far plane"
href="https://bugs.freedesktop.org/show_bug.cgi?id=97231#c20">Comment # 20</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - GL_DEPTH_CLAMP doesn't clamp to the far plane"
href="https://bugs.freedesktop.org/show_bug.cgi?id=97231">bug 97231</a>
from <span class="vcard"><a class="email" href="mailto:sroland@vmware.com" title="Roland Scheidegger <sroland@vmware.com>"> <span class="fn">Roland Scheidegger</span></a>
</span></b>
<pre>(In reply to Ilia Mirkin from <a href="show_bug.cgi?id=97231#c18">comment #18</a>)
<span class="quote">> FWIW this also fails on nouveau right now... this is a part of the patch I'm
> going to have to apply (still working out the full details, but this should
> have the general idea):
>
> @@ -329,8 +329,21 @@ nvc0_validate_viewport(struct nvc0_context *nvc0)
> PUSH_DATA (push, (w << 16) | x);
> PUSH_DATA (push, (h << 16) | y);
>
> - zmin = vp->translate[2] - fabsf(vp->scale[2]);
> - zmax = vp->translate[2] + fabsf(vp->scale[2]);
> + if (nvc0->rast->pipe.clip_halfz) {
> + zmin = vp->translate[2];
> + zmax = vp->translate[2] + vp->scale[2];
> + if (zmax < zmin) {
> + float t = zmax;
> + zmax = zmin;
> + zmin = t;
> + }
> + } else {
> + zmin = vp->translate[2] - fabsf(vp->scale[2]);
> + zmax = vp->translate[2] + fabsf(vp->scale[2]);
> + }
>
> Note that the near/far planes have to be calculated differently based on
> whether clip_halfz is enabled.</span >
Yes, that's pretty much what I had in mind for fixing llvmpipe. Albeit llvmpipe
already does different calculation depending on halfz.
It does:
if (lp->rasterizer->clip_halfz == 0) {
float half_depth = viewports[i].scale[2];
min_depth = viewports[i].translate[2] - half_depth;
max_depth = min_depth + half_depth * 2.0f;
} else {
min_depth = viewports[i].translate[2];
max_depth = min_depth + viewports[i].scale[2];
}
That said, it doesn't do the abs part. Is that really required?
And don't you need the zmin/zmax swap part too without clip_halfz?
(And as said, llvmpipe has problems with depth clamp as it does only actually
clamp the values if they are output by fs.)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
<li>You are the QA Contact for the bug.</li>
</ul>
</body>
</html>