radeonsi: move viewport to new handling
authorChristian König <deathsimple@vodafone.de>
Tue, 17 Jul 2012 13:46:24 +0000 (15:46 +0200)
committerChristian König <deathsimple@vodafone.de>
Tue, 24 Jul 2012 10:29:29 +0000 (12:29 +0200)
Signed-off-by: Christian König <deathsimple@vodafone.de>
src/gallium/drivers/radeonsi/evergreen_hw_context.c
src/gallium/drivers/radeonsi/evergreen_state.c
src/gallium/drivers/radeonsi/r600_blit.c
src/gallium/drivers/radeonsi/radeonsi_pipe.h
src/gallium/drivers/radeonsi/si_state.c
src/gallium/drivers/radeonsi/si_state.h

index 155489fadc74031166c3d214122b63b9c2865eda..424728e69bbc7ce6494115cb634195158bb8bf16 100644 (file)
@@ -89,9 +89,6 @@ static const struct r600_reg si_context_reg_list[] = {
        {R_028244_PA_SC_GENERIC_SCISSOR_BR, 0},
        {R_028250_PA_SC_VPORT_SCISSOR_0_TL, 0},
        {R_028254_PA_SC_VPORT_SCISSOR_0_BR, 0},
-       {R_0282D0_PA_SC_VPORT_ZMIN_0, 0},
-       {R_0282D4_PA_SC_VPORT_ZMAX_0, 0},
-       {R_028350_PA_SC_RASTER_CONFIG, 0},
        {GROUP_FORCE_NEW_BLOCK, 0},
        {R_028400_VGT_MAX_VTX_INDX, 0},
        {R_028404_VGT_MIN_VTX_INDX, 0},
@@ -101,12 +98,6 @@ static const struct r600_reg si_context_reg_list[] = {
        {GROUP_FORCE_NEW_BLOCK, 0},
        {R_028430_DB_STENCILREFMASK, 0},
        {R_028434_DB_STENCILREFMASK_BF, 0},
-       {R_02843C_PA_CL_VPORT_XSCALE_0, 0},
-       {R_028440_PA_CL_VPORT_XOFFSET_0, 0},
-       {R_028444_PA_CL_VPORT_YSCALE_0, 0},
-       {R_028448_PA_CL_VPORT_YOFFSET_0, 0},
-       {R_02844C_PA_CL_VPORT_ZSCALE_0, 0},
-       {R_028450_PA_CL_VPORT_ZOFFSET_0, 0},
        {R_028644_SPI_PS_INPUT_CNTL_0, 0},
        {R_028648_SPI_PS_INPUT_CNTL_1, 0},
        {R_02864C_SPI_PS_INPUT_CNTL_2, 0},
@@ -157,7 +148,6 @@ static const struct r600_reg si_context_reg_list[] = {
        {R_02880C_DB_SHADER_CONTROL, 0},
        {R_028810_PA_CL_CLIP_CNTL, 0},
        {R_028814_PA_SU_SC_MODE_CNTL, 0},
-       {R_028818_PA_CL_VTE_CNTL, 0},
        {R_02881C_PA_CL_VS_OUT_CNTL, 0},
        {R_028820_PA_CL_NANINF_CNTL, 0},
        {R_028824_PA_SU_LINE_STIPPLE_CNTL, 0},
index cfae877de147c289b8e7380d0253ff874a11e480..2b3403be3a7c1695053c3e5afe9aa491ddafed25 100644 (file)
@@ -1254,33 +1254,6 @@ static void evergreen_set_sample_mask(struct pipe_context *pipe, unsigned sample
 {
 }
 
-static void evergreen_set_viewport_state(struct pipe_context *ctx,
-                                       const struct pipe_viewport_state *state)
-{
-       struct r600_context *rctx = (struct r600_context *)ctx;
-       struct r600_pipe_state *rstate = CALLOC_STRUCT(r600_pipe_state);
-
-       if (rstate == NULL)
-               return;
-
-       rctx->viewport = *state;
-       rstate->id = R600_PIPE_STATE_VIEWPORT;
-       r600_pipe_state_add_reg(rstate, R_0282D0_PA_SC_VPORT_ZMIN_0, 0x00000000, NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_0282D4_PA_SC_VPORT_ZMAX_0, 0x3F800000, NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028350_PA_SC_RASTER_CONFIG, 0x00000000, NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_02843C_PA_CL_VPORT_XSCALE_0, fui(state->scale[0]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028444_PA_CL_VPORT_YSCALE_0, fui(state->scale[1]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_02844C_PA_CL_VPORT_ZSCALE_0, fui(state->scale[2]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028440_PA_CL_VPORT_XOFFSET_0, fui(state->translate[0]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028448_PA_CL_VPORT_YOFFSET_0, fui(state->translate[1]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028450_PA_CL_VPORT_ZOFFSET_0, fui(state->translate[2]), NULL, 0);
-       r600_pipe_state_add_reg(rstate, R_028818_PA_CL_VTE_CNTL, 0x0000043F, NULL, 0);
-
-       free(rctx->states[R600_PIPE_STATE_VIEWPORT]);
-       rctx->states[R600_PIPE_STATE_VIEWPORT] = rstate;
-       r600_context_pipe_state_set(rctx, rstate);
-}
-
 static void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
                         const struct pipe_framebuffer_state *state, int cb)
 {
@@ -1670,7 +1643,6 @@ void cayman_init_state_functions(struct r600_context *rctx)
        rctx->context.set_vertex_buffers = r600_set_vertex_buffers;
        rctx->context.set_index_buffer = r600_set_index_buffer;
        rctx->context.set_vertex_sampler_views = evergreen_set_vs_sampler_view;
-       rctx->context.set_viewport_state = evergreen_set_viewport_state;
        rctx->context.sampler_view_destroy = r600_sampler_view_destroy;
        rctx->context.texture_barrier = r600_texture_barrier;
        rctx->context.create_stream_output_target = r600_create_so_target;
index 3b476bcee0977c35dda0551a2938ade4926822ff..cc6dc4b7c29a42ba510a0d191e2425c7f74acfe1 100644 (file)
@@ -24,6 +24,7 @@
 #include "util/u_blitter.h"
 #include "util/u_format.h"
 #include "radeonsi_pipe.h"
+#include "si_state.h"
 
 enum r600_blitter_op /* bitmask */
 {
@@ -56,8 +57,8 @@ static void r600_blitter_begin(struct pipe_context *ctx, enum r600_blitter_op op
        util_blitter_save_fragment_shader(rctx->blitter, rctx->ps_shader);
        util_blitter_save_vertex_shader(rctx->blitter, rctx->vs_shader);
        util_blitter_save_vertex_elements(rctx->blitter, rctx->vertex_elements);
-       if (rctx->states[R600_PIPE_STATE_VIEWPORT]) {
-               util_blitter_save_viewport(rctx->blitter, &rctx->viewport);
+       if (rctx->queued.named.viewport) {
+               util_blitter_save_viewport(rctx->blitter, &rctx->queued.named.viewport->viewport);
        }
        util_blitter_save_vertex_buffers(rctx->blitter,
                                         rctx->nr_vertex_buffers,
index e303d99417d297d4726d3213bcabd3c3e5c04e9f..f13d35007341c568ca157486021117048c6b19aa 100644 (file)
@@ -77,7 +77,6 @@ struct r600_atom_surface_sync {
 enum r600_pipe_state_id {
        R600_PIPE_STATE_CONFIG,
        R600_PIPE_STATE_SEAMLESS_CUBEMAP,
-       R600_PIPE_STATE_VIEWPORT,
        R600_PIPE_STATE_RASTERIZER,
        R600_PIPE_STATE_VGT,
        R600_PIPE_STATE_FRAMEBUFFER,
@@ -239,7 +238,6 @@ struct r600_context {
        unsigned                        pa_cl_vs_out_cntl;
        /* for saving when using blitter */
        struct pipe_stencil_ref         stencil_ref;
-       struct pipe_viewport_state      viewport;
        struct r600_pipe_state          config;
        struct si_pipe_shader   *ps_shader;
        struct si_pipe_shader   *vs_shader;
index 68ff5cfbf0f888a3f99c6566ce76d257a788f800..3e3a915457acdee96c648da05391b7a078eb6b91 100644 (file)
@@ -240,6 +240,31 @@ static void si_set_scissor_state(struct pipe_context *ctx,
        si_pm4_set_state(rctx, scissor, pm4);
 }
 
+static void si_set_viewport_state(struct pipe_context *ctx,
+                                 const struct pipe_viewport_state *state)
+{
+       struct r600_context *rctx = (struct r600_context *)ctx;
+       struct si_state_viewport *viewport = CALLOC_STRUCT(si_state_viewport);
+       struct si_pm4_state *pm4 = &viewport->pm4;
+
+       if (viewport == NULL)
+               return;
+
+       viewport->viewport = *state;
+       si_pm4_set_reg(pm4, R_0282D0_PA_SC_VPORT_ZMIN_0, 0x00000000);
+       si_pm4_set_reg(pm4, R_0282D4_PA_SC_VPORT_ZMAX_0, 0x3F800000);
+       si_pm4_set_reg(pm4, R_028350_PA_SC_RASTER_CONFIG, 0x00000000);
+       si_pm4_set_reg(pm4, R_02843C_PA_CL_VPORT_XSCALE_0, fui(state->scale[0]));
+       si_pm4_set_reg(pm4, R_028440_PA_CL_VPORT_XOFFSET_0, fui(state->translate[0]));
+       si_pm4_set_reg(pm4, R_028444_PA_CL_VPORT_YSCALE_0, fui(state->scale[1]));
+       si_pm4_set_reg(pm4, R_028448_PA_CL_VPORT_YOFFSET_0, fui(state->translate[1]));
+       si_pm4_set_reg(pm4, R_02844C_PA_CL_VPORT_ZSCALE_0, fui(state->scale[2]));
+       si_pm4_set_reg(pm4, R_028450_PA_CL_VPORT_ZOFFSET_0, fui(state->translate[2]));
+       si_pm4_set_reg(pm4, R_028818_PA_CL_VTE_CNTL, 0x0000043F);
+
+       si_pm4_set_state(rctx, viewport, viewport);
+}
+
 void si_init_state_functions(struct r600_context *rctx)
 {
        rctx->context.create_blend_state = si_create_blend_state;
@@ -249,4 +274,5 @@ void si_init_state_functions(struct r600_context *rctx)
 
        rctx->context.set_clip_state = si_set_clip_state;
        rctx->context.set_scissor_state = si_set_scissor_state;
+       rctx->context.set_viewport_state = si_set_viewport_state;
 }
index 51cb1c0d5b0f602a4b6a4dd5fc0ef8fee2317a1a..c70a2613864753874e5f8dc60695baca08346953 100644 (file)
@@ -35,12 +35,18 @@ struct si_state_blend {
        uint32_t                cb_color_control;
 };
 
+struct si_state_viewport {
+       struct si_pm4_state             pm4;
+       struct pipe_viewport_state      viewport;
+};
+
 union si_state {
        struct {
-               struct si_state_blend   *blend;
-               struct si_pm4_state     *blend_color;
-               struct si_pm4_state     *clip;
-               struct si_pm4_state     *scissor;
+               struct si_state_blend           *blend;
+               struct si_pm4_state             *blend_color;
+               struct si_pm4_state             *clip;
+               struct si_pm4_state             *scissor;
+               struct si_state_viewport        *viewport;
        } named;
        struct si_pm4_state     *array[0];
 };