r300: Add blend color state emit.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 27 Jan 2009 12:04:57 +0000 (04:04 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Mon, 2 Feb 2009 07:30:30 +0000 (23:30 -0800)
Slow and steady wins the race. Or something like that.

src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h [new file with mode: 0644]
src/gallium/drivers/r300/r300_surface.c
src/gallium/drivers/r300/r300_surface.h

index de606cfab761677c9b1fbeb39679647be8c224b6..e091352c3bd2c7b3048665c5816eac196075361e 100644 (file)
 
 /* r300_emit: Functions for emitting state. */
 
-#include "r300_context.h"
-#include "r300_cs.h"
-#include "r300_screen.h"
+#include "r300_emit.h"
 
 void r300_emit_blend_state(struct r300_context* r300,
                            struct r300_blend_state* blend)
 {
     CS_LOCALS(r300);
+    BEGIN_CS(7);
     OUT_CS_REG_SEQ(R300_RB3D_CBLEND, 2);
     OUT_CS(blend->blend_control);
     OUT_CS(blend->alpha_blend_control);
     OUT_CS_REG(R300_RB3D_ROPCNTL, blend->rop);
     OUT_CS_REG(R300_RB3D_DITHER_CTL, blend->dither);
+    END_CS;
+}
+
+void r300_emit_blend_color_state(struct r300_context* r300,
+                                 struct r300_blend_color_state* bc)
+{
+    struct r300_screen* r300screen =
+        (struct r300_screen*)r300->context.screen;
+    CS_LOCALS(r300);
+    if (r300screen->caps->is_r500) {
+        BEGIN_CS(3);
+        OUT_CS_REG_SEQ(R500_RB3D_CONSTANT_COLOR_AR, 2);
+        OUT_CS(bc->blend_color_red_alpha);
+        OUT_CS(bc->blend_color_green_blue);
+        END_CS;
+    } else {
+        BEGIN_CS(2);
+        OUT_CS_REG(R300_RB3D_BLEND_COLOR, bc->blend_color);
+        END_CS;
+    }
 }
 
 static void r300_emit_dirty_state(struct r300_context* r300)
 {
-    struct r300_screen* r300screen = (struct r300_screen*)r300->context.screen;
+    struct r300_screen* r300screen =
+        (struct r300_screen*)r300->context.screen;
     CS_LOCALS(r300);
 
     if (!(r300->dirty_state) && !(r300->dirty_hw)) {
@@ -53,17 +73,7 @@ static void r300_emit_dirty_state(struct r300_context* r300)
     }
 
     if (r300->dirty_state & R300_NEW_BLEND_COLOR) {
-        struct r300_blend_color_state* blend_color = r300->blend_color_state;
-        if (r300screen->caps->is_r500) {
-            /* XXX next two are contiguous regs */
-            OUT_CS_REG(R500_RB3D_CONSTANT_COLOR_AR,
-                       blend_color->blend_color_red_alpha);
-            OUT_CS_REG(R500_RB3D_CONSTANT_COLOR_GB,
-                       blend_color->blend_color_green_blue);
-        } else {
-            OUT_CS_REG(R300_RB3D_BLEND_COLOR,
-                       blend_color->blend_color);
-        }
+        r300_emit_blend_color_state(r300, r300->blend_color_state);
     }
 
     if (r300->dirty_state & R300_NEW_DSA) {
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
new file mode 100644 (file)
index 0000000..5756b6a
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * on the rights to use, copy, modify, merge, publish, distribute, sub
+ * license, and/or sell copies of the Software, and to permit persons to whom
+ * the Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+ * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+ * USE OR OTHER DEALINGS IN THE SOFTWARE. */
+
+#include "r300_context.h"
+#include "r300_cs.h"
+#include "r300_screen.h"
+
+void r300_emit_blend_state(struct r300_context* r300,
+                           struct r300_blend_state* blend);
+
+void r300_emit_blend_color_state(struct r300_context* r300,
+                                 struct r300_blend_color_state* bc);
index 6c7784dd4db628e6dcb398c5c2b88b8993b451c9..2e5a572f4773d013e72fb11663c80a9c8da6a3e2 100644 (file)
@@ -156,6 +156,9 @@ OUT_CS_REG(0x4BD8, 0x00000000);
 OUT_CS_REG(0x4BD8, 0x00000000);
 OUT_CS_REG(0x4E00, 0x00000000);
 OUT_CS_REG(0x4E0C, 0x0000000F);
+
+r300_emit_blend_color_state(r300, &blend_color_clear_state);
+
 OUT_CS_REG(0x4E10, 0x00000000);
 OUT_CS_REG(0x4E54, 0x00000000);
 OUT_CS_REG(0x4E58, 0x00000000);
@@ -261,8 +264,9 @@ OUT_CS_REG(0x1DA4, 0x00000000);
 OUT_CS_REG(0x1DA8, 0x3F800000);
 OUT_CS_REG(0x1DAC, 0x00000000);
 OUT_CS_REG(0x4BD4, 0x00000000);
+
 r300_emit_blend_state(r300, &blend_clear_state);
-/* XXX emit blend state */
+
 OUT_CS_REG(0x221C, 0x0001C000);
 OUT_CS_REG(R300_GA_POINT_SIZE, ((h * 6) & R300_POINTSIZE_Y_MASK) |
     ((w * 6) << R300_POINTSIZE_X_SHIFT));
index 6d71601b98cdc7cd77d371f03e193e839eb2fa82..8ec7151f4d2ae87396530a54cd4578c480b51578 100644 (file)
@@ -39,4 +39,10 @@ const struct r300_blend_state blend_clear_state = {
     .dither = 0x0,
 };
 
+const struct r300_blend_color_state blend_color_clear_state = {
+    .blend_color = 0x0,
+    .blend_color_red_alpha = 0x0,
+    .blend_color_green_blue = 0x0,
+};
+
 #endif /* R300_SURFACE_H */