}
+/**
+ * Specify the Minimum Resolvable Depth factor for polygon offset.
+ * This factor potentially depends on the number of Z buffer bits,
+ * the rasterization algorithm and the arithmetic performed on Z
+ * values between vertex shading and rasterization. It will vary
+ * from one driver to another.
+ */
+void draw_set_mrd(struct draw_context *draw, double mrd)
+{
+ draw->mrd = mrd;
+}
+
/**
* Register new primitive rasterization/rendering state.
void draw_enable_point_sprites(struct draw_context *draw, boolean enable);
+void draw_set_mrd(struct draw_context *draw, double mrd);
boolean
draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe);
struct prim_header *header )
{
struct offset_stage *offset = offset_stage(stage);
- float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */
- offset->units = stage->draw->rasterizer->offset_units * mrd;
+ offset->units = stage->draw->rasterizer->offset_units * stage->draw->mrd;
offset->scale = stage->draw->rasterizer->offset_scale;
stage->tri = offset_tri;
boolean force_passthrough; /**< never clip or shade */
+ double mrd; /**< minimum resolvable depth value, for polygon offset */
+
/* pipe state that we need: */
const struct pipe_rasterizer_state *rasterizer;
struct pipe_viewport_state viewport;
}
#endif
+ /* Tell draw module how deep the Z/depth buffer is */
+ {
+ int depth_bits;
+ double mrd;
+ if (sp->framebuffer.zsbuf) {
+ depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format,
+ PIPE_FORMAT_COMP_Z);
+ }
+ else {
+ depth_bits = 0;
+ }
+ if (depth_bits > 16) {
+ mrd = 0.0000001;
+ }
+ else {
+ mrd = 0.00002;
+ }
+ draw_set_mrd(sp->draw, mrd);
+ }
+
sp->framebuffer.width = fb->width;
sp->framebuffer.height = fb->height;