[Mesa-dev] [PATCH 1/4] gallium: add polygon offset clamp state
Christoph Bumiller
e0425955 at student.tuwien.ac.at
Sat Sep 24 06:47:21 PDT 2011
This is required for D3D1x and supported by hardware.
---
src/gallium/auxiliary/draw/draw_pipe_offset.c | 6 ++++++
src/gallium/auxiliary/util/u_dump_state.c | 1 +
src/gallium/docs/source/cso/rasterizer.rst | 2 ++
src/gallium/drivers/trace/tr_dump_state.c | 1 +
src/gallium/include/pipe/p_state.h | 1 +
5 files changed, 11 insertions(+), 0 deletions(-)
diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c
index 8afbbfa..3da52b1 100644
--- a/src/gallium/auxiliary/draw/draw_pipe_offset.c
+++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c
@@ -43,6 +43,7 @@ struct offset_stage {
float scale;
float units;
+ float clamp;
};
@@ -90,6 +91,10 @@ static void do_offset_tri( struct draw_stage *stage,
float zoffset = offset->units + MAX2(dzdx, dzdy) * offset->scale;
+ if (offset->clamp)
+ zoffset = (offset->clamp < 0.0f) ? MAX2(zoffset, offset->clamp) :
+ MIN2(zoffset, offset->clamp);
+
/*
* Note: we're applying the offset and clamping per-vertex.
* Ideally, the offset is applied per-fragment prior to fragment shading.
@@ -125,6 +130,7 @@ static void offset_first_tri( struct draw_stage *stage,
offset->units = (float) (stage->draw->rasterizer->offset_units * stage->draw->mrd);
offset->scale = stage->draw->rasterizer->offset_scale;
+ offset->clamp = stage->draw->rasterizer->offset_clamp;
stage->tri = offset_tri;
stage->tri( stage, header );
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index 5ecf8cb..dfd57e5 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -332,6 +332,7 @@ util_dump_rasterizer_state(struct os_stream *stream, const struct pipe_rasterize
util_dump_member(stream, float, state, point_size);
util_dump_member(stream, float, state, offset_units);
util_dump_member(stream, float, state, offset_scale);
+ util_dump_member(stream, float, state, offset_clamp);
util_dump_struct_end(stream);
}
diff --git a/src/gallium/docs/source/cso/rasterizer.rst b/src/gallium/docs/source/cso/rasterizer.rst
index e10c16e..a3836d9 100644
--- a/src/gallium/docs/source/cso/rasterizer.rst
+++ b/src/gallium/docs/source/cso/rasterizer.rst
@@ -119,6 +119,8 @@ offset_units
Specifies the polygon offset bias
offset_scale
Specifies the polygon offset scale
+offset_clamp
+ Upper (if > 0) or lower (if < 0) bound on the polygon offset result
diff --git a/src/gallium/drivers/trace/tr_dump_state.c b/src/gallium/drivers/trace/tr_dump_state.c
index 291a6a2..774f99b 100644
--- a/src/gallium/drivers/trace/tr_dump_state.c
+++ b/src/gallium/drivers/trace/tr_dump_state.c
@@ -149,6 +149,7 @@ void trace_dump_rasterizer_state(const struct pipe_rasterizer_state *state)
trace_dump_member(float, state, point_size);
trace_dump_member(float, state, offset_units);
trace_dump_member(float, state, offset_scale);
+ trace_dump_member(float, state, offset_clamp);
trace_dump_struct_end();
}
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index a57e805..8b069ae 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -130,6 +130,7 @@ struct pipe_rasterizer_state
float point_size; /**< used when no per-vertex size */
float offset_units;
float offset_scale;
+ float offset_clamp;
};
--
1.7.3.4
More information about the mesa-dev
mailing list