r300-gallium: Various thingies.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 13 Feb 2009 16:14:42 +0000 (08:14 -0800)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Fri, 13 Feb 2009 16:18:26 +0000 (08:18 -0800)
Add formats to framebuffer emit, fix up shader function names,
make sure fragment format is emitted for r500.

src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_reg.h
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_shader.c
src/gallium/drivers/r300/r300_state_shader.h
src/gallium/drivers/r300/r300_surface.c

index c0990cabd9c14edb75fbc776b2b47db3d7422646..8108b99f944fc15477773c8dfb1f9a68df7cd86f 100644 (file)
@@ -136,6 +136,21 @@ void r500_emit_fragment_shader(struct r300_context* r300,
     END_CS;
 }
 
+/* Translate pipe_format into US_OUT_FMT. Note that formats are stored from
+ * C3 to C0. */
+uint32_t translate_out_fmt(enum pipe_format format)
+{
+    switch (format) {
+        case PIPE_FORMAT_A8R8G8B8_UNORM:
+            return R300_US_OUT_FMT_C4_8 |
+                R300_C0_SEL_B | R300_C1_SEL_G |
+                R300_C2_SEL_R | R300_C3_SEL_A;
+        default:
+            return R300_US_OUT_FMT_UNUSED;
+    }
+    return 0;
+}
+
 /* XXX add pitch, stride, z/stencil buf */
 void r300_emit_fb_state(struct r300_context* r300,
                         struct pipe_framebuffer_state* fb)
@@ -149,6 +164,9 @@ void r300_emit_fb_state(struct r300_context* r300,
         tex = (struct r300_texture*)fb->cbufs[i]->texture;
         OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
         OUT_CS_RELOC(tex->buffer, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
+
+        OUT_CS_REG(R300_US_OUT_FMT_0 + (4 * i),
+            translate_out_fmt(fb->cbufs[i]->format));
     }
     R300_PACIFY;
     END_CS;
index 9e86423efbd5a7ff4deeae483f5a36608cbb4d87..468e0a2e44b3fccd2edbb846a91126abcba2ecf8 100644 (file)
@@ -1709,6 +1709,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #   define R300_C3_SEL_G                               (2 << 14)
 #   define R300_C3_SEL_B                               (3 << 14)
 #   define R300_OUT_SIGN(x)                            (x << 16)
+#   define R500_ROUND_ADJ                              (1 << 20)
 
 /* ALU
  * The ALU instructions register blocks are enumerated according to the order
@@ -3048,48 +3049,6 @@ enum {
 #   define R500_FORMAT_TXWIDTH(x)                      (x << 0)
 #   define R500_FORMAT_TXHEIGHT(x)                     (x << 11)
 #   define R500_FORMAT_TXDEPTH(x)                      (x << 22)
-/* _0 through _3 */
-#define R500_US_OUT_FMT_0                              0x46A4
-#   define R500_OUT_FMT_C4_8                           (0 << 0)
-#   define R500_OUT_FMT_C4_10                          (1 << 0)
-#   define R500_OUT_FMT_C4_10_GAMMA                    (2 << 0)
-#   define R500_OUT_FMT_C_16                           (3 << 0)
-#   define R500_OUT_FMT_C2_16                          (4 << 0)
-#   define R500_OUT_FMT_C4_16                          (5 << 0)
-#   define R500_OUT_FMT_C_16_MPEG                      (6 << 0)
-#   define R500_OUT_FMT_C2_16_MPEG                     (7 << 0)
-#   define R500_OUT_FMT_C2_4                           (8 << 0)
-#   define R500_OUT_FMT_C_3_3_2                                (9 << 0)
-#   define R500_OUT_FMT_C_6_5_6                                (10 << 0)
-#   define R500_OUT_FMT_C_11_11_10                     (11 << 0)
-#   define R500_OUT_FMT_C_10_11_11                     (12 << 0)
-#   define R500_OUT_FMT_C_2_10_10_10                   (13 << 0)
-/* #define R500_OUT_FMT_RESERVED                       (14 << 0) */
-#   define R500_OUT_FMT_UNUSED                         (15 << 0)
-#   define R500_OUT_FMT_C_16_FP                                (16 << 0)
-#   define R500_OUT_FMT_C2_16_FP                       (17 << 0)
-#   define R500_OUT_FMT_C4_16_FP                       (18 << 0)
-#   define R500_OUT_FMT_C_32_FP                                (19 << 0)
-#   define R500_OUT_FMT_C2_32_FP                       (20 << 0)
-#   define R500_OUT_FMT_C4_32_FP                       (21 << 0)
-#   define R500_C0_SEL_A                               (0 << 8)
-#   define R500_C0_SEL_R                               (1 << 8)
-#   define R500_C0_SEL_G                               (2 << 8)
-#   define R500_C0_SEL_B                               (3 << 8)
-#   define R500_C1_SEL_A                               (0 << 10)
-#   define R500_C1_SEL_R                               (1 << 10)
-#   define R500_C1_SEL_G                               (2 << 10)
-#   define R500_C1_SEL_B                               (3 << 10)
-#   define R500_C2_SEL_A                               (0 << 12)
-#   define R500_C2_SEL_R                               (1 << 12)
-#   define R500_C2_SEL_G                               (2 << 12)
-#   define R500_C2_SEL_B                               (3 << 12)
-#   define R500_C3_SEL_A                               (0 << 14)
-#   define R500_C3_SEL_R                               (1 << 14)
-#   define R500_C3_SEL_G                               (2 << 14)
-#   define R500_C3_SEL_B                               (3 << 14)
-#   define R500_OUT_SIGN(x)                            (x << 16)
-#   define R500_ROUND_ADJ                              (1 << 20)
 #define R500_US_PIXSIZE                                        0x4604
 #   define R500_PIX_SIZE(x)                            (x)
 #define R500_US_TEX_ADDR_0                             0x9800
index 2c0906aad8188118654303c21f183afd7a528983..d02679c7c5e751ad274d4cbb3457e4c4215345fe 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "r300_context.h"
 #include "r300_reg.h"
+#include "r300_state_shader.h"
 
 /* r300_state: Functions used to intialize state context by translating
  * Gallium state objects into semi-native r300 state objects.
@@ -429,9 +430,9 @@ static void r300_bind_fs_state(struct pipe_context* pipe, void* shader)
         return;
     } else if (!fs->translated) {
         if (r300_screen(r300->context.screen)->caps->is_r500) {
-            r500_translate_shader(r300, fs);
+            r500_translate_fragment_shader(r300, (struct r500_fragment_shader*)fs);
         } else {
-            r300_translate_shader(r300, fs);
+            r300_translate_fragment_shader(r300, (struct r300_fragment_shader*)fs);
         }
     }
 
index cb606c409aa3c3a16a5986e5ec92c217a915760d..d10ac55580afc5287deb23ab270ef337005b20ef 100644 (file)
@@ -40,13 +40,13 @@ static void r500_copy_passthrough_shader(struct r500_fragment_shader* fs)
     fs->instructions[0] = pt->instructions[0];
 }
 
-void r300_translate_shader(struct r300_context* r300,
+void r300_translate_fragment_shader(struct r300_context* r300,
                            struct r300_fragment_shader* fs)
 {
     r300_copy_passthrough_shader(fs);
 }
 
-void r500_translate_shader(struct r300_context* r300,
+void r500_translate_fragment_shader(struct r300_context* r300,
                            struct r500_fragment_shader* fs)
 {
     r500_copy_passthrough_shader(fs);
index 108f5ec085f950d123fbf924b70ba2142d497386..1d5d9ee943bc9a95131f8eeb3548dcea9f18f349 100644 (file)
 #include "r300_reg.h"
 #include "r300_screen.h"
 
-void r300_translate_shader(struct r300_context* r300,
+void r300_translate_fragment_shader(struct r300_context* r300,
                            struct r300_fragment_shader* fs);
 
-void r500_translate_shader(struct r300_context* r300,
+void r500_translate_fragment_shader(struct r300_context* r300,
                            struct r500_fragment_shader* fs);
 
 static const struct r300_fragment_shader r300_passthrough_fragment_shader = {
@@ -41,12 +41,7 @@ static const struct r300_fragment_shader r300_passthrough_fragment_shader = {
     OUT_CS_REG(R300_US_CODE_ADDR_1, 0x0);
     OUT_CS_REG(R300_US_CODE_ADDR_2, 0x0);
     OUT_CS_REG(R300_US_CODE_ADDR_3, 0x400000);
-    OUT_CS_REG_SEQ(R300_US_OUT_FMT_0, 4);
-    OUT_CS(R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A);
-    OUT_CS(R300_US_OUT_FMT_UNUSED);
-    OUT_CS(R300_US_OUT_FMT_UNUSED);
-    OUT_CS(R300_US_OUT_FMT_UNUSED);
-    OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0); */
+*/
     .alu_instruction_count = 1,
     .tex_instruction_count = 0,
     .indirections = 1,
index 7a4114554b5b959ea9a97be76248b06e7988bf76..07837cb823d154f6454159c57cee72943c3ecb19 100644 (file)
@@ -235,7 +235,13 @@ static void r300_surface_fill(struct pipe_context* pipe,
         r300_emit_fragment_shader(r300, &r300_passthrough_fragment_shader);
     }
 
-    BEGIN_CS(2 + (caps->has_tcl ? 23 : 2));
+    BEGIN_CS(10 + (caps->has_tcl ? 23 : 2));
+    OUT_CS_REG_SEQ(R300_US_OUT_FMT_0, 4);
+    OUT_CS(R300_C0_SEL_B | R300_C1_SEL_G | R300_C2_SEL_R | R300_C3_SEL_A);
+    OUT_CS(R300_US_OUT_FMT_UNUSED);
+    OUT_CS(R300_US_OUT_FMT_UNUSED);
+    OUT_CS(R300_US_OUT_FMT_UNUSED);
+    OUT_CS_REG(R300_US_W_FMT, R300_W_FMT_W0);
     /* XXX these magic numbers should be explained when
      * this becomes a cached state object */
     if (caps->has_tcl) {