[Mesa-dev] [PATCH 3/4] r600g: set minimum point size to 1.0 for non-sprite non-aa points

Marek Olšák maraeo at gmail.com
Fri Jan 27 16:38:55 PST 2012


---
 src/gallium/drivers/r600/evergreen_state.c |   10 +++++++++-
 src/gallium/drivers/r600/evergreend.h      |    6 ++++++
 src/gallium/drivers/r600/r600_pipe.h       |    7 +++++++
 src/gallium/drivers/r600/r600_state.c      |   10 +++++++++-
 4 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/r600/evergreen_state.c b/src/gallium/drivers/r600/evergreen_state.c
index 69e3be9..243c490 100644
--- a/src/gallium/drivers/r600/evergreen_state.c
+++ b/src/gallium/drivers/r600/evergreen_state.c
@@ -896,6 +896,7 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
 	unsigned tmp;
 	unsigned prov_vtx = 1, polygon_dual_mode;
 	unsigned clip_rule;
+	float psize_min, psize_max;
 
 	if (rs == NULL) {
 		return NULL;
@@ -949,7 +950,14 @@ static void *evergreen_create_rs_state(struct pipe_context *ctx,
 	/* point size 12.4 fixed point */
 	tmp = (unsigned)(state->point_size * 8.0);
 	r600_pipe_state_add_reg(rstate, R_028A00_PA_SU_POINT_SIZE, S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp), 0xFFFFFFFF, NULL, 0);
-	r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX, 0x80000000, 0xFFFFFFFF, NULL, 0);
+
+	psize_min = state->point_quad_rasterization || state->point_smooth ? 0.0f : 1.0f;
+	psize_max = 8192;
+	/* Divide by two, because 0.5 = 1 pixel. */
+	r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX,
+				S_028A04_MIN_SIZE(r600_pack_float_12p4(psize_min/2)) |
+				S_028A04_MAX_SIZE(r600_pack_float_12p4(psize_max/2)),
+				0xFFFFFFFF, NULL, 0);
 
 	tmp = (unsigned)state->line_width * 8;
 	r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, S_028A08_WIDTH(tmp), 0xFFFFFFFF, NULL, 0);
diff --git a/src/gallium/drivers/r600/evergreend.h b/src/gallium/drivers/r600/evergreend.h
index d0c1130..3345ebf 100644
--- a/src/gallium/drivers/r600/evergreend.h
+++ b/src/gallium/drivers/r600/evergreend.h
@@ -1729,6 +1729,12 @@
 #define R_028980_ALU_CONST_CACHE_VS_0                0x00028980
 #define R_028984_ALU_CONST_CACHE_VS_1                0x00028984
 #define R_028A04_PA_SU_POINT_MINMAX                  0x00028A04
+#define   S_028A04_MIN_SIZE(x)                         (((x) & 0xFFFF) << 0)
+#define   G_028A04_MIN_SIZE(x)                         (((x) >> 0) & 0xFFFF)
+#define   C_028A04_MIN_SIZE                            0xFFFF0000
+#define   S_028A04_MAX_SIZE(x)                         (((x) & 0xFFFF) << 16)
+#define   G_028A04_MAX_SIZE(x)                         (((x) >> 16) & 0xFFFF)
+#define   C_028A04_MAX_SIZE                            0x0000FFFF
 #define R_028A08_PA_SU_LINE_CNTL                     0x00028A08
 #define   S_028A08_WIDTH(x)                            (((x) & 0xFFFF) << 0)
 #define   G_028A08_WIDTH(x)                            (((x) >> 0) & 0xFFFF)
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 9de8e7e..f5efcdb 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -384,4 +384,11 @@ static inline unsigned r600_tex_aniso_filter(unsigned filter)
 	 /* else */        return 4;
 }
 
+/* 12.4 fixed-point */
+static INLINE unsigned r600_pack_float_12p4(float x)
+{
+	return x <= 0    ? 0 :
+	       x >= 4096 ? 0xffff : x * 16;
+}
+
 #endif
diff --git a/src/gallium/drivers/r600/r600_state.c b/src/gallium/drivers/r600/r600_state.c
index e093e50..cea31f2 100644
--- a/src/gallium/drivers/r600/r600_state.c
+++ b/src/gallium/drivers/r600/r600_state.c
@@ -948,6 +948,7 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
 	unsigned prov_vtx = 1, polygon_dual_mode;
 	unsigned clip_rule;
 	unsigned sc_mode_cntl;
+	float psize_min, psize_max;
 
 	if (rs == NULL) {
 		return NULL;
@@ -1000,7 +1001,14 @@ static void *r600_create_rs_state(struct pipe_context *ctx,
 	/* point size 12.4 fixed point */
 	tmp = (unsigned)(state->point_size * 8.0);
 	r600_pipe_state_add_reg(rstate, R_028A00_PA_SU_POINT_SIZE, S_028A00_HEIGHT(tmp) | S_028A00_WIDTH(tmp), 0xFFFFFFFF, NULL, 0);
-	r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX, 0x80000000, 0xFFFFFFFF, NULL, 0);
+
+	psize_min = state->point_quad_rasterization || state->point_smooth ? 0.0f : 1.0f;
+	psize_max = 8192;
+	/* Divide by two, because 0.5 = 1 pixel. */
+	r600_pipe_state_add_reg(rstate, R_028A04_PA_SU_POINT_MINMAX,
+				S_028A04_MIN_SIZE(r600_pack_float_12p4(psize_min/2)) |
+				S_028A04_MAX_SIZE(r600_pack_float_12p4(psize_max/2)),
+				0xFFFFFFFF, NULL, 0);
 
 	tmp = (unsigned)state->line_width * 8;
 	r600_pipe_state_add_reg(rstate, R_028A08_PA_SU_LINE_CNTL, S_028A08_WIDTH(tmp), 0xFFFFFFFF, NULL, 0);
-- 
1.7.5.4



More information about the mesa-dev mailing list