r300g: turn invariant state into a command buffer
authorMarek Olšák <maraeo@gmail.com>
Fri, 25 Jun 2010 00:55:14 +0000 (02:55 +0200)
committerMarek Olšák <maraeo@gmail.com>
Sun, 27 Jun 2010 13:13:12 +0000 (15:13 +0200)
src/gallium/drivers/r300/Makefile
src/gallium/drivers/r300/SConscript
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_emit.h
src/gallium/drivers/r300/r300_state_invariant.c [deleted file]
src/gallium/drivers/r300/r300_state_invariant.h [deleted file]

index dd897f6072fb646912685af14d252bb70a74068c..13152635a65ff192194baa6835f85e4ebfb14e95 100644 (file)
@@ -21,7 +21,6 @@ C_SOURCES = \
        r300_screen_buffer.c \
        r300_state.c \
        r300_state_derived.c \
-       r300_state_invariant.c \
        r300_vs.c \
        r300_vs_draw.c \
        r300_texture.c \
index ee19e9d27837179f9bbab0d2150d04ec161c23a2..552ed4e5bef142e5573568816b264ea16a20cd4d 100644 (file)
@@ -31,7 +31,6 @@ r300 = env.ConvenienceLibrary(
         'r300_screen_buffer.c',
         'r300_state.c',
         'r300_state_derived.c',
-        'r300_state_invariant.c',
         'r300_vs.c',
         'r300_vs_draw.c',
         'r300_texture.c',
index ff25f3b88ae5db766d77d5296d6ba1d91115f3d1..7b7dafbc6faa5621c6ecd52d9fbc3e10a89c6fac 100644 (file)
@@ -32,7 +32,6 @@
 #include "r300_emit.h"
 #include "r300_screen.h"
 #include "r300_screen_buffer.h"
-#include "r300_state_invariant.h"
 #include "r300_winsys.h"
 
 #include <inttypes.h>
@@ -78,6 +77,7 @@ static void r300_destroy_context(struct pipe_context* context)
     FREE(r300->clip_state.state);
     FREE(r300->fb_state.state);
     FREE(r300->gpu_flush.state);
+    FREE(r300->invariant_state.state);
     FREE(r300->rs_block_state.state);
     FREE(r300->scissor_state.state);
     FREE(r300->textures_state.state);
@@ -109,6 +109,7 @@ static void r300_flush_cb(void *data)
 
 static void r300_setup_atoms(struct r300_context* r300)
 {
+    boolean is_rv350 = r300->screen->caps.is_rv350;
     boolean is_r500 = r300->screen->caps.is_r500;
     boolean has_tcl = r300->screen->caps.has_tcl;
 
@@ -133,7 +134,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     /* SC. */
     R300_INIT_ATOM(scissor_state, 3);
     /* GB, FG, GA, SU, SC, RB3D. */
-    R300_INIT_ATOM(invariant_state, 22);
+    R300_INIT_ATOM(invariant_state, 18 + (is_rv350 ? 4 : 0));
     /* VAP. */
     R300_INIT_ATOM(viewport_state, 9);
     R300_INIT_ATOM(pvs_flush, 2);
@@ -168,6 +169,7 @@ static void r300_setup_atoms(struct r300_context* r300)
     r300->clip_state.state = CALLOC_STRUCT(r300_clip_state);
     r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state);
     r300->gpu_flush.state = CALLOC_STRUCT(pipe_framebuffer_state);
+    r300->invariant_state.state = CALLOC_STRUCT(r300_invariant_state);
     r300->rs_block_state.state = CALLOC_STRUCT(r300_rs_block);
     r300->scissor_state.state = CALLOC_STRUCT(pipe_scissor_state);
     r300->textures_state.state = CALLOC_STRUCT(r300_textures_state);
@@ -181,7 +183,6 @@ static void r300_setup_atoms(struct r300_context* r300)
     }
 
     /* Some non-CSO atoms don't use the state pointer. */
-    r300->invariant_state.allow_null_state = TRUE;
     r300->fs_rc_constant_state.allow_null_state = TRUE;
     r300->pvs_flush.allow_null_state = TRUE;
     r300->query_start.allow_null_state = TRUE;
@@ -210,6 +211,8 @@ static void r300_init_states(struct pipe_context *pipe)
             (struct r300_gpu_flush*)r300->gpu_flush.state;
     struct r300_vap_invariant_state *vap_invariant =
             (struct r300_vap_invariant_state*)r300->vap_invariant_state.state;
+    struct r300_invariant_state *invariant =
+            (struct r300_invariant_state*)r300->invariant_state.state;
     CB_LOCALS;
 
     pipe->set_blend_color(pipe, &bc);
@@ -255,6 +258,26 @@ static void r300_init_states(struct pipe_context *pipe)
         OUT_CB_REG(R300_VAP_PSC_SGN_NORM_CNTL, R300_SGN_NORM_NO_ZERO);
         END_CB;
     }
+
+    /* Initialize the invariant state. */
+    {
+        BEGIN_CB(invariant->cb, r300->invariant_state.size);
+        OUT_CB_REG(R300_GB_SELECT, 0);
+        OUT_CB_REG(R300_FG_FOG_BLEND, 0);
+        OUT_CB_REG(R300_GA_ROUND_MODE, 1);
+        OUT_CB_REG(R300_GA_OFFSET, 0);
+        OUT_CB_REG(R300_SU_TEX_WRAP, 0);
+        OUT_CB_REG(R300_SU_DEPTH_SCALE, 0x4B7FFFFF);
+        OUT_CB_REG(R300_SU_DEPTH_OFFSET, 0);
+        OUT_CB_REG(R300_SC_HYPERZ, 0x1C);
+        OUT_CB_REG(R300_SC_EDGERULE, 0x2DA49525);
+
+        if (r300->screen->caps.is_rv350) {
+            OUT_CB_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x01010101);
+            OUT_CB_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFEFEFEFE);
+        }
+        END_CB;
+    }
 }
 
 struct pipe_context* r300_create_context(struct pipe_screen* screen,
index dc96d21f3189cf78eedab5b3b86658b43b70f6c0..cea3ab3418fb358a3bababf8279abbaa11be100c 100644 (file)
@@ -224,6 +224,10 @@ struct r300_vertex_stream_state {
     unsigned count;
 };
 
+struct r300_invariant_state {
+    uint32_t cb[22];
+};
+
 struct r300_vap_invariant_state {
     uint32_t cb[9];
 };
index 413e2f62a79070a81576bec882f23b037d526a70..e4de081fdc738827042dbe5c6ed473c5545abade 100644 (file)
@@ -519,6 +519,13 @@ void r300_emit_query_end(struct r300_context* r300)
     }
 }
 
+void r300_emit_invariant_state(struct r300_context *r300,
+                               unsigned size, void *state)
+{
+    CS_LOCALS(r300);
+    WRITE_CS_TABLE(state, size);
+}
+
 void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
 {
     struct r300_rs_state* rs = state;
index a18331222f3c5865732fe974df22b4964c9b6dda..44fad23560a22e454df30555a494dc7a77cf8d67 100644 (file)
@@ -101,6 +101,9 @@ void r300_emit_pvs_flush(struct r300_context* r300, unsigned size, void* state);
 
 void r300_emit_texture_cache_inval(struct r300_context* r300, unsigned size, void* state);
 
+void r300_emit_invariant_state(struct r300_context *r300,
+                               unsigned size, void *state);
+
 unsigned r300_get_num_dirty_dwords(struct r300_context *r300);
 
 /* Emit all dirty state. */
diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c
deleted file mode 100644 (file)
index acd2097..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009 Joakim Sindholt <opensource@zhasha.com>
- *                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_reg.h"
-#include "r300_screen.h"
-#include "r300_state_invariant.h"
-
-/* Calculate and emit invariant state. This is data that the 3D engine
- * will probably want at the beginning of every CS, but it's not currently
- * handled by any CSO setup, and in addition it doesn't really change much.
- *
- * Note that eventually this should be empty, but it's useful for development
- * and general unduplication of code. */
-void r300_emit_invariant_state(struct r300_context* r300,
-                               unsigned size, void* state)
-{
-    CS_LOCALS(r300);
-
-    BEGIN_CS(18 + (r300->screen->caps.is_rv350 ? 4 : 0));
-
-    OUT_CS_REG(R300_GB_SELECT, 0);
-    OUT_CS_REG(R300_FG_FOG_BLEND, 0);
-    OUT_CS_REG(R300_GA_ROUND_MODE, 1);
-    OUT_CS_REG(R300_GA_OFFSET, 0);
-    OUT_CS_REG(R300_SU_TEX_WRAP, 0);
-    OUT_CS_REG(R300_SU_DEPTH_SCALE, 0x4B7FFFFF);
-    OUT_CS_REG(R300_SU_DEPTH_OFFSET, 0);
-    OUT_CS_REG(R300_SC_HYPERZ, 0x1C);
-    OUT_CS_REG(R300_SC_EDGERULE, 0x2DA49525);
-
-    if (r300->screen->caps.is_rv350) {
-        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_LTE_THRESHOLD, 0x01010101);
-        OUT_CS_REG(R500_RB3D_DISCARD_SRC_PIXEL_GTE_THRESHOLD, 0xFEFEFEFE);
-    }
-
-    END_CS;
-}
diff --git a/src/gallium/drivers/r300/r300_state_invariant.h b/src/gallium/drivers/r300/r300_state_invariant.h
deleted file mode 100644 (file)
index 83d031c..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * 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. */
-
-#ifndef R300_STATE_INVARIANT_H
-#define R300_STATE_INVARIANT_H
-
-struct r300_context;
-
-void r300_emit_invariant_state(struct r300_context* r300,
-                               unsigned size, void* state);
-
-#endif /* R300_STATE_INVARIANT_H */