radeonsi: don't change viewport for blits, use window-space positions
authorMarek Olšák <marek.olsak@amd.com>
Thu, 5 Oct 2017 19:29:35 +0000 (21:29 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 7 Oct 2017 16:26:35 +0000 (18:26 +0200)
The viewport state was an identity anyway.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/auxiliary/util/u_blitter.c
src/gallium/auxiliary/util/u_blitter.h
src/gallium/drivers/radeonsi/si_blit.c
src/gallium/drivers/radeonsi/si_pipe.c
src/gallium/drivers/radeonsi/si_state_draw.c
src/gallium/drivers/radeonsi/si_state_shaders.c
src/gallium/drivers/radeonsi/si_state_viewport.c

index a5c1f178a60d4683be929c77a4109cd2162f253f..72e22e7d826e6bb959bfe277ed12f9e1ef02227c 100644 (file)
@@ -650,7 +650,9 @@ void util_blitter_restore_fragment_states(struct blitter_context *blitter)
    /* XXX check whether these are saved and whether they need to be restored
     * (depending on the operation) */
    pipe->set_stencil_ref(pipe, &ctx->base.saved_stencil_ref);
-   pipe->set_viewport_states(pipe, 0, 1, &ctx->base.saved_viewport);
+
+   if (!blitter->skip_viewport_restore)
+      pipe->set_viewport_states(pipe, 0, 1, &ctx->base.saved_viewport);
 }
 
 static void blitter_check_saved_fb_state(struct blitter_context_priv *ctx)
index 0dd896d3818aca9b8eb17fd774e878b1ee1efeae..dba773906aeff42deb191239e4494f4e236b2983 100644 (file)
@@ -113,6 +113,7 @@ struct blitter_context
    struct pipe_stencil_ref saved_stencil_ref;     /**< stencil ref */
    struct pipe_viewport_state saved_viewport;
    struct pipe_scissor_state saved_scissor;
+   bool skip_viewport_restore;
    bool is_sample_mask_saved;
    unsigned saved_sample_mask;
 
index b3f44c3c9a873cd1b0859fd1df376626c96ad657..40f855059296a4f30799606802de726deba1de9f 100644 (file)
@@ -68,7 +68,6 @@ static void si_blitter_begin(struct pipe_context *ctx, enum si_blitter_op op)
                util_blitter_save_stencil_ref(sctx->blitter, &sctx->stencil_ref.state);
                util_blitter_save_fragment_shader(sctx->blitter, sctx->ps_shader.cso);
                util_blitter_save_sample_mask(sctx->blitter, sctx->sample_mask.sample_mask);
-               util_blitter_save_viewport(sctx->blitter, &sctx->viewports.states[0]);
                util_blitter_save_scissor(sctx->blitter, &sctx->scissors.states[0]);
        }
 
index 3001a3a8cd997fe7aeab6496527ea0b2c8a21c47..5cf71bec6a53413b3eec96296a0c660595012149 100644 (file)
@@ -255,6 +255,7 @@ static struct pipe_context *si_create_context(struct pipe_screen *screen,
        if (sctx->blitter == NULL)
                goto fail;
        sctx->blitter->draw_rectangle = si_draw_rectangle;
+       sctx->blitter->skip_viewport_restore = true;
 
        sctx->sample_mask.sample_mask = 0xffff;
 
index 8e541518ec8b375c5ddcd4ee271452581dce880f..c6c15c1acf74d501d54f155d7155c18fa56946a1 100644 (file)
@@ -1515,16 +1515,6 @@ void si_draw_rectangle(struct blitter_context *blitter,
 {
        struct pipe_context *pipe = util_blitter_get_pipe(blitter);
        struct si_context *sctx = (struct si_context*)pipe;
-       struct pipe_viewport_state viewport;
-
-       /* setup viewport */
-       viewport.scale[0] = 1.0f;
-       viewport.scale[1] = 1.0f;
-       viewport.scale[2] = 1.0f;
-       viewport.translate[0] = 0.0f;
-       viewport.translate[1] = 0.0f;
-       viewport.translate[2] = 0.0f;
-       pipe->set_viewport_states(pipe, 0, 1, &viewport);
 
        /* Pack position coordinates as signed int16. */
        sctx->vs_blit_sh_data[0] = (uint32_t)(x1 & 0xffff) |
index 90c3cf7e631a62eb1881988bd88380f2d047d6d1..40a76c85f3f9c7f028b9416e71256b39b8b1682d 100644 (file)
@@ -3442,6 +3442,7 @@ void *si_get_blit_vs(struct si_context *sctx, enum blitter_attrib_type type,
 
        /* Tell the shader to load VS inputs from SGPRs: */
        ureg_property(ureg, TGSI_PROPERTY_VS_BLIT_SGPRS, vs_blit_property);
+       ureg_property(ureg, TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION, true);
 
        /* This is just a pass-through shader with 1-3 MOV instructions. */
        ureg_MOV(ureg,
index 0d6b7a8da82ca996253daf1542e7f7db5f10b09d..f416558475446264c87e246b2a73465939b46ea3 100644 (file)
@@ -63,13 +63,6 @@ static void si_get_scissor_from_viewport(struct si_context *ctx,
        maxx = vp->scale[0] + vp->translate[0];
        maxy = vp->scale[1] + vp->translate[1];
 
-       /* r600_draw_rectangle sets this. Disable the scissor. */
-       if (minx == -1 && miny == -1 && maxx == 1 && maxy == 1) {
-               scissor->minx = scissor->miny = 0;
-               scissor->maxx = scissor->maxy = SI_MAX_SCISSOR;
-               return;
-       }
-
        /* Handle inverted viewports. */
        if (minx > maxx) {
                tmp = minx;