r300-gallium: Unify sampler and texture emit.
authorCorbin Simpson <MostAwesomeDude@gmail.com>
Tue, 19 May 2009 00:06:42 +0000 (17:06 -0700)
committerCorbin Simpson <MostAwesomeDude@gmail.com>
Wed, 8 Jul 2009 18:39:34 +0000 (11:39 -0700)
They have to cross into each other's registers.

src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_surface.c

index 45f9ec090d42d4ea461d88742da0d9e6e2a7d7f6..7ba56cdc1d221832d218b8938a59ada5d9313672 100644 (file)
@@ -289,18 +289,6 @@ void r300_emit_rs_block_state(struct r300_context* r300,
     END_CS;
 }
 
-void r300_emit_sampler(struct r300_context* r300,
-                       struct r300_sampler_state* sampler, unsigned offset)
-{
-    CS_LOCALS(r300);
-
-    BEGIN_CS(6);
-    OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
-    OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
-    OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
-    END_CS;
-}
-
 void r300_emit_scissor_state(struct r300_context* r300,
                              struct r300_scissor_state* scissor)
 {
@@ -314,11 +302,17 @@ void r300_emit_scissor_state(struct r300_context* r300,
 }
 
 void r300_emit_texture(struct r300_context* r300,
-                       struct r300_texture* tex, unsigned offset)
+                       struct r300_sampler_state* sampler,
+                       struct r300_texture* tex,
+                       unsigned offset)
 {
     CS_LOCALS(r300);
 
-    BEGIN_CS(10);
+    BEGIN_CS(16);
+    OUT_CS_REG(R300_TX_FILTER0_0 + (offset * 4), sampler->filter0);
+    OUT_CS_REG(R300_TX_FILTER1_0 + (offset * 4), sampler->filter1);
+    OUT_CS_REG(R300_TX_BORDER_COLOR_0 + (offset * 4), sampler->border_color);
+
     OUT_CS_REG(R300_TX_FORMAT0_0 + (offset * 4), tex->state.format0);
     OUT_CS_REG(R300_TX_FORMAT1_0 + (offset * 4), tex->state.format1);
     OUT_CS_REG(R300_TX_FORMAT2_0 + (offset * 4), tex->state.format2);
@@ -593,29 +587,27 @@ validate:
         r300->dirty_state &= ~R300_NEW_RS_BLOCK;
     }
 
-    if (r300->dirty_state & R300_ANY_NEW_SAMPLERS) {
-        for (i = 0; i < r300->sampler_count; i++) {
-            if (r300->dirty_state & (R300_NEW_SAMPLER << i)) {
-                r300_emit_sampler(r300, r300->sampler_states[i], i);
-                dirty_tex++;
-            }
-        }
-        r300->dirty_state &= ~R300_ANY_NEW_SAMPLERS;
-    }
-
     if (r300->dirty_state & R300_NEW_SCISSOR) {
         r300_emit_scissor_state(r300, r300->scissor_state);
         r300->dirty_state &= ~R300_NEW_SCISSOR;
     }
 
-    if (r300->dirty_state & R300_ANY_NEW_TEXTURES) {
-        for (i = 0; i < r300->texture_count; i++) {
-            if (r300->dirty_state & (R300_NEW_TEXTURE << i)) {
-                r300_emit_texture(r300, r300->textures[i], i);
+    /* Samplers and textures are tracked separately but emitted together. */
+    if (r300->dirty_state &
+            (R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES)) {
+        for (i = 0; i < MIN2(r300->sampler_count, r300->texture_count); i++) {
+            if (r300->dirty_state &
+                    ((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i))) {
+                r300_emit_texture(r300,
+                        r300->sampler_states[i],
+                        r300->textures[i],
+                        i);
+                r300->dirty_state &=
+                    ~((R300_NEW_SAMPLER << i) | (R300_NEW_TEXTURE << i));
                 dirty_tex++;
             }
         }
-        r300->dirty_state &= ~R300_ANY_NEW_TEXTURES;
+        r300->dirty_state &= ~(R300_ANY_NEW_SAMPLERS | R300_ANY_NEW_TEXTURES);
     }
 
     if (r300->dirty_state & R300_NEW_VIEWPORT) {
index 196b6c58d3c0d92fc9477a03f9d745871d1bb8a1..fda26f394810a5783b5258b0593f8f837d0941ad 100644 (file)
@@ -56,14 +56,13 @@ void r300_emit_rs_state(struct r300_context* r300, struct r300_rs_state* rs);
 void r300_emit_rs_block_state(struct r300_context* r300,
                               struct r300_rs_block* rs);
 
-void r300_emit_sampler(struct r300_context* r300,
-                       struct r300_sampler_state* sampler, unsigned offset);
-
 void r300_emit_scissor_state(struct r300_context* r300,
                              struct r300_scissor_state* scissor);
 
 void r300_emit_texture(struct r300_context* r300,
-                       struct r300_texture* tex, unsigned offset);
+                       struct r300_sampler_state* sampler,
+                       struct r300_texture* tex,
+                       unsigned offset);
 
 void r300_emit_vertex_buffer(struct r300_context* r300);
 
index 96b9a833830cd7848eb74a9932b57f72ba76304c..fdabe4d9cfed39e0261e9a1ca4f6cbe3345e7db7 100644 (file)
@@ -268,14 +268,10 @@ validate:
     r300_surface_setup(r300, desttex, destx, desty, w, h);
 
     /* Setup the texture. */
-    r300_emit_sampler(r300, &r300_sampler_copy_state, 0);
-    r300_emit_texture(r300, srctex, 0);
+    r300_emit_texture(r300, &r300_sampler_copy_state, srctex, 0);
 
     /* Flush and enable. */
-    BEGIN_CS(4);
-    OUT_CS_REG(R300_TX_INVALTAGS, 0);
-    OUT_CS_REG(R300_TX_ENABLE, 0x1);
-    END_CS;
+    r300_flush_textures(r300);
 
     /* Vertex shader setup */
     if (caps->has_tcl) {