diff options
-rw-r--r-- | src/gallium/drivers/r300/r300_context.c | 3 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state.c | 17 | ||||
-rw-r--r-- | src/gallium/drivers/r300/r300_state_inlines.h | 31 |
4 files changed, 33 insertions, 22 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c index a17be173835..b8db6fb6c12 100644 --- a/src/gallium/drivers/r300/r300_context.c +++ b/src/gallium/drivers/r300/r300_context.c @@ -201,7 +201,7 @@ static boolean r300_setup_atoms(struct r300_context* r300) /* SC. */ R300_INIT_ATOM(scissor_state, 3); /* GB, FG, GA, SU, SC, RB3D. */ - R300_INIT_ATOM(invariant_state, 18 + (is_rv350 ? 4 : 0) + (is_r500 ? 4 : 0)); + R300_INIT_ATOM(invariant_state, 16 + (is_rv350 ? 4 : 0) + (is_r500 ? 4 : 0)); /* VAP. */ R300_INIT_ATOM(viewport_state, 9); R300_INIT_ATOM(pvs_flush, 2); @@ -349,7 +349,6 @@ static void r300_init_states(struct pipe_context *pipe) BEGIN_CB(invariant->cb, r300->invariant_state.size); OUT_CB_REG(R300_GB_SELECT, 0); OUT_CB_REG(R300_FG_FOG_BLEND, 0); - OUT_CB_REG(R300_GA_ROUND_MODE, 1); OUT_CB_REG(R300_GA_OFFSET, 0); OUT_CB_REG(R300_SU_TEX_WRAP, 0); OUT_CB_REG(R300_SU_DEPTH_SCALE, 0x4B7FFFFF); diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h index 446973696fc..58e1094e339 100644 --- a/src/gallium/drivers/r300/r300_context.h +++ b/src/gallium/drivers/r300/r300_context.h @@ -136,7 +136,7 @@ struct r300_gpu_flush { uint32_t cb_flush_clean[6]; }; -#define RS_STATE_MAIN_SIZE 23 +#define RS_STATE_MAIN_SIZE 25 struct r300_rs_state { /* Original rasterizer state. */ @@ -235,7 +235,7 @@ struct r300_vertex_stream_state { }; struct r300_invariant_state { - uint32_t cb[26]; + uint32_t cb[24]; }; struct r300_vap_invariant_state { diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c index 187829358fc..2b0c8750554 100644 --- a/src/gallium/drivers/r300/r300_state.c +++ b/src/gallium/drivers/r300/r300_state.c @@ -192,6 +192,7 @@ static void* r300_create_blend_state(struct pipe_context* pipe, uint32_t color_channel_mask = 0; /* R300_RB3D_COLOR_CHANNEL_MASK: 0x4e0c */ uint32_t rop = 0; /* R300_RB3D_ROPCNTL: 0x4e18 */ uint32_t dither = 0; /* R300_RB3D_DITHER_CTL: 0x4e50 */ + boolean clamp = TRUE; CB_LOCALS; if (state->rt[0].blend_enable) @@ -207,7 +208,7 @@ static void* r300_create_blend_state(struct pipe_context* pipe, /* despite the name, ALPHA_BLEND_ENABLE has nothing to do with alpha, * this is just the crappy D3D naming */ blend_control = R300_ALPHA_BLEND_ENABLE | - r300_translate_blend_function(eqRGB) | + r300_translate_blend_function(eqRGB, clamp) | ( r300_translate_blend_factor(srcRGB) << R300_SRC_BLEND_SHIFT) | ( r300_translate_blend_factor(dstRGB) << R300_DST_BLEND_SHIFT); @@ -268,7 +269,8 @@ static void* r300_create_blend_state(struct pipe_context* pipe, * * Equations other than ADD are rarely used and therefore won't be * optimized. */ - if ((eqRGB == PIPE_BLEND_ADD || eqRGB == PIPE_BLEND_REVERSE_SUBTRACT) && + if (clamp && + (eqRGB == PIPE_BLEND_ADD || eqRGB == PIPE_BLEND_REVERSE_SUBTRACT) && (eqA == PIPE_BLEND_ADD || eqA == PIPE_BLEND_REVERSE_SUBTRACT)) { /* ADD: X+Y * REVERSE_SUBTRACT: Y-X @@ -307,7 +309,7 @@ static void* r300_create_blend_state(struct pipe_context* pipe, if (srcA != srcRGB || dstA != dstRGB || eqA != eqRGB) { blend_control |= R300_SEPARATE_ALPHA_ENABLE; alpha_blend_control = - r300_translate_blend_function(eqA) | + r300_translate_blend_function(eqA, clamp) | (r300_translate_blend_factor(srcA) << R300_SRC_BLEND_SHIFT) | (r300_translate_blend_factor(dstA) << R300_DST_BLEND_SHIFT); } @@ -1014,12 +1016,14 @@ static void* r300_create_rs_state(struct pipe_context* pipe, uint32_t line_stipple_value; /* R300_GA_LINE_STIPPLE_VALUE: 0x4260 */ uint32_t polygon_mode; /* R300_GA_POLY_MODE: 0x4288 */ uint32_t clip_rule; /* R300_SC_CLIP_RULE: 0x43D0 */ + uint32_t round_mode; /* R300_GA_ROUND_MODE: 0x428c */ /* Point sprites texture coordinates, 0: lower left, 1: upper right */ float point_texcoord_left = 0; /* R300_GA_POINT_S0: 0x4200 */ float point_texcoord_bottom = 0;/* R300_GA_POINT_T0: 0x4204 */ float point_texcoord_right = 1; /* R300_GA_POINT_S1: 0x4208 */ float point_texcoord_top = 0; /* R300_GA_POINT_T1: 0x420c */ + boolean vclamp = TRUE; CB_LOCALS; /* Copy rasterizer state. */ @@ -1142,6 +1146,12 @@ static void* r300_create_rs_state(struct pipe_context* pipe, } } + /* Vertex color clamping. FP20 means no clamping. */ + round_mode = + R300_GA_ROUND_MODE_GEOMETRY_ROUND_NEAREST | + (!vclamp ? (R300_GA_ROUND_MODE_RGB_CLAMP_FP20 | + R300_GA_ROUND_MODE_ALPHA_CLAMP_FP20) : 0); + /* Build the main command buffer. */ BEGIN_CB(rs->cb_main, RS_STATE_MAIN_SIZE); OUT_CB_REG(R300_VAP_CNTL_STATUS, vap_control_status); @@ -1156,6 +1166,7 @@ static void* r300_create_rs_state(struct pipe_context* pipe, OUT_CB_REG(R300_GA_LINE_STIPPLE_CONFIG, line_stipple_config); OUT_CB_REG(R300_GA_LINE_STIPPLE_VALUE, line_stipple_value); OUT_CB_REG(R300_GA_POLY_MODE, polygon_mode); + OUT_CB_REG(R300_GA_ROUND_MODE, round_mode); OUT_CB_REG(R300_SC_CLIP_RULE, clip_rule); OUT_CB_REG_SEQ(R300_GA_POINT_S0, 4); OUT_CB_32F(point_texcoord_left); diff --git a/src/gallium/drivers/r300/r300_state_inlines.h b/src/gallium/drivers/r300/r300_state_inlines.h index 06da04c7ad7..54dae1acd98 100644 --- a/src/gallium/drivers/r300/r300_state_inlines.h +++ b/src/gallium/drivers/r300/r300_state_inlines.h @@ -38,23 +38,24 @@ static INLINE int pack_float_16_6x(float f) { /* Blend state. */ -static INLINE uint32_t r300_translate_blend_function(int blend_func) +static INLINE uint32_t r300_translate_blend_function(int blend_func, + boolean clamp) { switch (blend_func) { - case PIPE_BLEND_ADD: - return R300_COMB_FCN_ADD_CLAMP; - case PIPE_BLEND_SUBTRACT: - return R300_COMB_FCN_SUB_CLAMP; - case PIPE_BLEND_REVERSE_SUBTRACT: - return R300_COMB_FCN_RSUB_CLAMP; - case PIPE_BLEND_MIN: - return R300_COMB_FCN_MIN; - case PIPE_BLEND_MAX: - return R300_COMB_FCN_MAX; - default: - fprintf(stderr, "r300: Unknown blend function %d\n", blend_func); - assert(0); - break; + case PIPE_BLEND_ADD: + return clamp ? R300_COMB_FCN_ADD_CLAMP : R300_COMB_FCN_ADD_NOCLAMP; + case PIPE_BLEND_SUBTRACT: + return clamp ? R300_COMB_FCN_SUB_CLAMP : R300_COMB_FCN_SUB_NOCLAMP; + case PIPE_BLEND_REVERSE_SUBTRACT: + return clamp ? R300_COMB_FCN_RSUB_CLAMP : R300_COMB_FCN_RSUB_NOCLAMP; + case PIPE_BLEND_MIN: + return R300_COMB_FCN_MIN; + case PIPE_BLEND_MAX: + return R300_COMB_FCN_MAX; + default: + fprintf(stderr, "r300: Unknown blend function %d\n", blend_func); + assert(0); + break; } return 0; } |