summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/llvmpipe/lp_state_surface.c
diff options
context:
space:
mode:
authorMatthew McClure <[email protected]>2013-10-29 13:36:41 -0700
committerJosé Fonseca <[email protected]>2013-11-07 18:32:54 +0000
commitf9e2c24326869542c9b43220f63dd9841c6de38f (patch)
treebd208be0c8a880c0665c6672138083e00eeef680 /src/gallium/drivers/llvmpipe/lp_state_surface.c
parent185b5a54c94ce11487146042c8eec24909187ed6 (diff)
draw,llvmpipe,util: add depth bias calculation for arb_depth_buffer_float
With this patch, the llvmpipe and draw modules will calculate the depth bias according to floating point depth buffer semantics described in the arb_depth_buffer_float specification, when the driver has a z buffer bound with a format type of UTIL_FORMAT_TYPE_FLOAT. By default, the driver will use the existing UNORM calculation for depth bias. A new function, draw_set_zs_format, was added to calculate the Minimum Resolvable Depth value and floating point depth sense for the draw module. Reviewed-by: Jose Fonseca <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
Diffstat (limited to 'src/gallium/drivers/llvmpipe/lp_state_surface.c')
-rw-r--r--src/gallium/drivers/llvmpipe/lp_state_surface.c28
1 files changed, 18 insertions, 10 deletions
diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c
index 89098410280..c228c63d139 100644
--- a/src/gallium/drivers/llvmpipe/lp_state_surface.c
+++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c
@@ -57,24 +57,32 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe,
assert(fb->height <= LP_MAX_HEIGHT);
if (changed) {
+ /*
+ * If no depth buffer is bound, send the utility function the default
+ * format for no bound depth (PIPE_FORMAT_NONE).
+ */
+ enum pipe_format depth_format = fb->zsbuf ?
+ fb->zsbuf->format : PIPE_FORMAT_NONE;
+ const struct util_format_description *depth_desc =
+ util_format_description(depth_format);
+
util_copy_framebuffer_state(&lp->framebuffer, fb);
if (LP_PERF & PERF_NO_DEPTH) {
pipe_surface_reference(&lp->framebuffer.zsbuf, NULL);
}
- /* Tell draw module how deep the Z/depth buffer is.
- *
- * If no depth buffer is bound, send the utility function the default
- * format for no bound depth (PIPE_FORMAT_NONE).
- *
- * FIXME: mrd constant isn't right should use a value derived from
- * current primitive not a constant (for float depth buffers)
+ /*
+ * Calculate the floating point depth sense and Minimum Resolvable Depth
+ * value for the llvmpipe module. This is separate from the draw module.
*/
- lp->mrd = util_get_depth_format_mrd((lp->framebuffer.zsbuf) ?
- lp->framebuffer.zsbuf->format : PIPE_FORMAT_NONE);
+ lp->floating_point_depth =
+ (util_get_depth_format_type(depth_desc) == UTIL_FORMAT_TYPE_FLOAT);
+
+ lp->mrd = util_get_depth_format_mrd(depth_desc);
- draw_set_mrd(lp->draw, lp->mrd);
+ /* Tell the draw module how deep the Z/depth buffer is. */
+ draw_set_zs_format(lp->draw, depth_format);
lp_setup_bind_framebuffer( lp->setup, &lp->framebuffer );