draw_destroy(r300->draw);
+ FREE(r300->blend_color_state);
FREE(r300->scissor_state);
FREE(r300);
}
r300->draw = draw_create();
+ r300->blend_color_state = CALLOC_STRUCT(r300_blend_color_state);
r300->scissor_state = CALLOC_STRUCT(r300_scissor_state);
r300_init_surface_functions(r300);
uint32_t dither; /* R300_RB3D_DITHER_CTL: 0x4e50 */
};
+struct r300_blend_color_state {
+ /* RV515 and earlier */
+ uint32_t blend_color; /* R300_RB3D_BLEND_COLOR: 0x4e10 */
+ /* R520 and newer */
+ uint32_t blend_color_red_alpha; /* R500_RB3D_CONSTANT_COLOR_AR: 0x4ef8 */
+ uint32_t blend_color_green_blue; /* R500_RB3D_CONSTANT_COLOR_GB: 0x4efc */
+};
+
struct r300_dsa_state {
uint32_t alpha_function; /* R300_FG_ALPHA_FUNC: 0x4bd4 */
uint32_t alpha_reference; /* R500_FG_ALPHA_VALUE: 0x4be0 */
uint32_t scissor_bottom_right; /* R300_SC_SCISSORS_BR: 0x43e4 */
};
-#define R300_NEW_BLEND 0x1
-#define R300_NEW_DSA 0x2
-#define R300_NEW_RS 0x4
-#define R300_NEW_SCISSOR 0x8
+#define R300_NEW_BLEND 0x01
+#define R300_NEW_BLEND_COLOR 0x02
+#define R300_NEW_DSA 0x04
+#define R300_NEW_RS 0x08
+#define R300_NEW_SCISSOR 0x10
struct r300_context {
/* Parent class */
/* Various CSO state objects. */
/* Blend state. */
struct r300_blend_state* blend_state;
+ /* Blend color state. */
+ struct r300_blend_color_state* blend_color_state;
/* Depth, stencil, and alpha state. */
struct r300_dsa_state* dsa_state;
/* Rasterizer state. */
FREE(state);
}
+/* Set blend color.
+ * Setup both R300 and R500 registers, figure out later which one to write. */
+static void r300_set_blend_color(struct pipe_context* pipe,
+ const struct pipe_blend_color* color)
+{
+ struct r300_context* r300 = r300_context(pipe);
+ uint32_t r, g, b, a;
+ ubyte ur, ug, ub, ua;
+
+ r = util_iround(color->color[0] * 1023.0f);
+ g = util_iround(color->color[1] * 1023.0f);
+ b = util_iround(color->color[2] * 1023.0f);
+ a = util_iround(color->color[3] * 1023.0f);
+
+ ur = float_to_ubyte(color->color[0]);
+ ug = float_to_ubyte(color->color[1]);
+ ub = float_to_ubyte(color->color[2]);
+ ua = float_to_ubyte(color->color[3]);
+
+ r300->blend_color_state->blend_color = (a << 24) | (r << 16) | (g << 8) | b;
+
+ r300->blend_color_state->blend_color_red_alpha = ur | (ua << 16);
+ r300->blend_color_state->blend_color_green_blue = ub | (ug << 16);
+
+ r300->dirty_state |= R300_NEW_BLEND_COLOR;
+}
+
static uint32_t translate_depth_stencil_function(int zs_func) {
switch (zs_func) {
case PIPE_FUNC_NEVER:
r300->context.bind_blend_state = r300_bind_blend_state;
r300->context.delete_blend_state = r300_delete_blend_state;
+ r300->context.set_blend_color = r300_set_blend_color;
+
r300->context.create_rasterizer_state = r300_create_rs_state;
r300->context.bind_rasterizer_state = r300_bind_rs_state;
r300->context.delete_rasterizer_state = r300_delete_rs_state;