r300: rework texture offset emission.
authorJerome Glisse <jglisse@redhat.com>
Thu, 28 May 2009 09:40:58 +0000 (11:40 +0200)
committerJerome Glisse <jglisse@redhat.com>
Thu, 28 May 2009 09:40:58 +0000 (11:40 +0200)
src/mesa/drivers/dri/r300/r300_cmdbuf.c

index 60ad8ea14b3d4376c3cd2f31b3942f2109bbdc86..e605076a51904cf4ed8361470646115b4d57671a 100644 (file)
@@ -179,27 +179,33 @@ static void emit_tex_offsets(GLcontext *ctx, struct radeon_state_atom * atom)
                if (r300->radeon.radeonScreen->kernel_mm && notexture) {
                        return;
                }
-               BEGIN_BATCH_NO_AUTOSTATE(4 * numtmus);
                for(i = 0; i < numtmus; ++i) {
                    radeonTexObj *t = r300->hw.textures[i];
-                   OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
                    if (t && !t->image_override) {
+                BEGIN_BATCH_NO_AUTOSTATE(4);
+                OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
                            OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
                                            RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+                END_BATCH();
                    } else if (!t) {
-                           OUT_BATCH(r300->radeon.radeonScreen->texOffset[0]);
+                /* Texture unit hasn't a texture bound nothings to do */
                    } else { /* override cases */
                            if (t->bo) {
+                    BEGIN_BATCH_NO_AUTOSTATE(4);
+                    OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
                                    OUT_BATCH_RELOC(t->tile_bits, t->bo, 0,
                                                    RADEON_GEM_DOMAIN_GTT|RADEON_GEM_DOMAIN_VRAM, 0, 0);
+                    END_BATCH();
                            } else if (!r300->radeon.radeonScreen->kernel_mm) {
+                    BEGIN_BATCH_NO_AUTOSTATE(2);
+                    OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
                                    OUT_BATCH(t->override_offset);
-                           }
-                           else
-                               OUT_BATCH(r300->radeon.radeonScreen->texOffset[0]);
+                    END_BATCH();
+                           } else {
+                    /* Texture unit hasn't a texture bound nothings to do */
+                }
                    }
                }
-               END_BATCH();
        }
 }