Mesa (master): r300g: turn invariant state into a command buffer

Marek Olšák mareko at kemper.freedesktop.org
Sun Jun 27 13:17:52 UTC 2010


Module: Mesa
Branch: master
Commit: bb47d1c26fa000735bd06751ba00a98354c921b7
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bb47d1c26fa000735bd06751ba00a98354c921b7

Author: Marek Olšák <maraeo at gmail.com>
Date:   Fri Jun 25 02:55:14 2010 +0200

r300g: turn invariant state into a command buffer

---

 src/gallium/drivers/r300/Makefile               |    1 -
 src/gallium/drivers/r300/SConscript             |    1 -
 src/gallium/drivers/r300/r300_context.c         |   29 ++++++++++-
 src/gallium/drivers/r300/r300_context.h         |    4 ++
 src/gallium/drivers/r300/r300_emit.c            |    7 +++
 src/gallium/drivers/r300/r300_emit.h            |    3 +
 src/gallium/drivers/r300/r300_state_invariant.c |   59 -----------------------
 src/gallium/drivers/r300/r300_state_invariant.h |   31 ------------
 8 files changed, 40 insertions(+), 95 deletions(-)

diff --git a/src/gallium/drivers/r300/Makefile b/src/gallium/drivers/r300/Makefile
index dd897f6..1315263 100644
--- a/src/gallium/drivers/r300/Makefile
+++ b/src/gallium/drivers/r300/Makefile
@@ -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 \
diff --git a/src/gallium/drivers/r300/SConscript b/src/gallium/drivers/r300/SConscript
index ee19e9d..552ed4e 100644
--- a/src/gallium/drivers/r300/SConscript
+++ b/src/gallium/drivers/r300/SConscript
@@ -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',
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index ff25f3b..7b7dafb 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -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,
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index dc96d21..cea3ab3 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -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];
 };
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 413e2f6..e4de081 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -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;
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index a183312..44fad23 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -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
index acd2097..0000000
--- a/src/gallium/drivers/r300/r300_state_invariant.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright 2009 Joakim Sindholt <opensource at zhasha.com>
- *                Corbin Simpson <MostAwesomeDude at 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
index 83d031c..0000000
--- a/src/gallium/drivers/r300/r300_state_invariant.h
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2008 Corbin Simpson <MostAwesomeDude at 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 */




More information about the mesa-commit mailing list