gallium: add PIPE_CAP_TGSI_CAN_READ_OUTPUTS
[mesa.git] / src / gallium / drivers / nouveau / nvc0 / nvc0_surface.c
index a1775698a3dc1efa94ada637fd0ddec3bbb8c4d6..0d1405871465b3e64295f1313442c6eb6e94378f 100644 (file)
@@ -280,7 +280,8 @@ nvc0_clear_render_target(struct pipe_context *pipe,
                          struct pipe_surface *dst,
                          const union pipe_color_union *color,
                          unsigned dstx, unsigned dsty,
-                         unsigned width, unsigned height)
+                         unsigned width, unsigned height,
+                         bool render_condition_enabled)
 {
    struct nvc0_context *nvc0 = nvc0_context(pipe);
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
@@ -343,7 +344,8 @@ nvc0_clear_render_target(struct pipe_context *pipe,
       nvc0_resource_fence(res, NOUVEAU_BO_WR);
    }
 
-   IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
+   if (!render_condition_enabled)
+      IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
 
    BEGIN_NIC0(push, NVC0_3D(CLEAR_BUFFERS), sf->depth);
    for (z = 0; z < sf->depth; ++z) {
@@ -351,7 +353,8 @@ nvc0_clear_render_target(struct pipe_context *pipe,
                  (z << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT));
    }
 
-   IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode);
+   if (!render_condition_enabled)
+      IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode);
 
    nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER;
 }
@@ -619,7 +622,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
                          double depth,
                          unsigned stencil,
                          unsigned dstx, unsigned dsty,
-                         unsigned width, unsigned height)
+                         unsigned width, unsigned height,
+                         bool render_condition_enabled)
 {
    struct nvc0_context *nvc0 = nvc0_context(pipe);
    struct nouveau_pushbuf *push = nvc0->base.pushbuf;
@@ -668,7 +672,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
    PUSH_DATA (push, dst->u.tex.first_layer);
    IMMED_NVC0(push, NVC0_3D(MULTISAMPLE_MODE), mt->ms_mode);
 
-   IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
+   if (!render_condition_enabled)
+      IMMED_NVC0(push, NVC0_3D(COND_MODE), NVC0_3D_COND_MODE_ALWAYS);
 
    BEGIN_NIC0(push, NVC0_3D(CLEAR_BUFFERS), sf->depth);
    for (z = 0; z < sf->depth; ++z) {
@@ -676,7 +681,8 @@ nvc0_clear_depth_stencil(struct pipe_context *pipe,
                  (z << NVC0_3D_CLEAR_BUFFERS_LAYER__SHIFT));
    }
 
-   IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode);
+   if (!render_condition_enabled)
+      IMMED_NVC0(push, NVC0_3D(COND_MODE), nvc0->cond_condmode);
 
    nvc0->dirty_3d |= NVC0_NEW_3D_FRAMEBUFFER;
 }
@@ -782,6 +788,7 @@ struct nvc0_blitctx
    enum pipe_texture_target target;
    struct {
       struct pipe_framebuffer_state fb;
+      struct nvc0_window_rect_stateobj window_rect;
       struct nvc0_rasterizer_stateobj *rast;
       struct nvc0_program *vp;
       struct nvc0_program *tcp;
@@ -829,11 +836,11 @@ nvc0_blitter_make_vp(struct nvc0_blitter *blit)
    };
    static const uint32_t code_gm107[] =
    {
-      0xfc0007e0, 0x001f8000, /* sched 0x7e0 0x7e0 0x7e0 */
+      0xfc0007e0, 0x001f8000, /* sched (st 0x0) (st 0x0) (st 0x0) */
       0x0807ff04, 0xefd8ff80, /* ld b64 $r4 a[0x80] 0x0 */
       0x0907ff00, 0xefd97f80, /* ld b96 $r0 a[0x90] 0x0 */
       0x0707ff04, 0xeff0ff80, /* st b64 a[0x70] $r4 0x0 */
-      0xfc0007e0, 0x00000000, /* sched 0x7e0 0x7e0 0x0 */
+      0xfc0007e0, 0x00000000, /* sched (st 0x0) (st 0x0) (st 0x0) */
       0x0807ff00, 0xeff17f80, /* st b96 a[0x80] $r0 0x0 */
       0x0007000f, 0xe3000000, /* exit */
    };
@@ -1035,7 +1042,8 @@ nvc0_blitctx_prepare_state(struct nvc0_blitctx *blit)
 }
 
 static void
-nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx)
+nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx,
+                      const struct pipe_blit_info *info)
 {
    struct nvc0_context *nvc0 = ctx->nvc0;
    struct nvc0_blitter *blitter = nvc0->screen->blitter;
@@ -1058,6 +1066,7 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx)
    ctx->saved.fp = nvc0->fragprog;
 
    ctx->saved.min_samples = nvc0->min_samples;
+   ctx->saved.window_rect = nvc0->window_rect;
 
    nvc0->rast = &ctx->rast;
 
@@ -1067,6 +1076,13 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx)
    nvc0->gmtyprog = NULL;
    nvc0->fragprog = ctx->fp;
 
+   nvc0->window_rect.rects =
+      MIN2(info->num_window_rectangles, NVC0_MAX_WINDOW_RECTANGLES);
+   nvc0->window_rect.inclusive = info->window_rectangle_include;
+   if (nvc0->window_rect.rects)
+      memcpy(nvc0->window_rect.rect, info->window_rectangles,
+             sizeof(struct pipe_scissor_state) * nvc0->window_rect.rects);
+
    for (s = 0; s <= 4; ++s) {
       ctx->saved.num_textures[s] = nvc0->num_textures[s];
       ctx->saved.num_samplers[s] = nvc0->num_samplers[s];
@@ -1099,7 +1115,7 @@ nvc0_blitctx_pre_blit(struct nvc0_blitctx *ctx)
    nvc0->dirty_3d = NVC0_NEW_3D_FRAMEBUFFER | NVC0_NEW_3D_MIN_SAMPLES |
       NVC0_NEW_3D_VERTPROG | NVC0_NEW_3D_FRAGPROG |
       NVC0_NEW_3D_TCTLPROG | NVC0_NEW_3D_TEVLPROG | NVC0_NEW_3D_GMTYPROG |
-      NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS;
+      NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS | NVC0_NEW_3D_WINDOW_RECTS;
 }
 
 static void
@@ -1127,6 +1143,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit)
    nvc0->fragprog = blit->saved.fp;
 
    nvc0->min_samples = blit->saved.min_samples;
+   nvc0->window_rect = blit->saved.window_rect;
 
    pipe_sampler_view_reference(&nvc0->textures[4][0], NULL);
    pipe_sampler_view_reference(&nvc0->textures[4][1], NULL);
@@ -1158,7 +1175,7 @@ nvc0_blitctx_post_blit(struct nvc0_blitctx *blit)
    nvc0->dirty_3d = blit->saved.dirty_3d |
       (NVC0_NEW_3D_FRAMEBUFFER | NVC0_NEW_3D_SCISSOR | NVC0_NEW_3D_SAMPLE_MASK |
        NVC0_NEW_3D_RASTERIZER | NVC0_NEW_3D_ZSA | NVC0_NEW_3D_BLEND |
-       NVC0_NEW_3D_VIEWPORT |
+       NVC0_NEW_3D_VIEWPORT | NVC0_NEW_3D_WINDOW_RECTS |
        NVC0_NEW_3D_TEXTURES | NVC0_NEW_3D_SAMPLERS |
        NVC0_NEW_3D_VERTPROG | NVC0_NEW_3D_FRAGPROG |
        NVC0_NEW_3D_TCTLPROG | NVC0_NEW_3D_TEVLPROG | NVC0_NEW_3D_GMTYPROG |
@@ -1191,7 +1208,7 @@ nvc0_blit_3d(struct nvc0_context *nvc0, const struct pipe_blit_info *info)
    blit->render_condition_enable = info->render_condition_enable;
 
    nvc0_blit_select_fp(blit, info);
-   nvc0_blitctx_pre_blit(blit);
+   nvc0_blitctx_pre_blit(blit, info);
 
    nvc0_blit_set_dst(blit, dst, info->dst.level, -1, info->dst.format);
    nvc0_blit_set_src(blit, src, info->src.level, -1, info->src.format,
@@ -1606,6 +1623,9 @@ nvc0_blit(struct pipe_context *pipe, const struct pipe_blit_info *info)
         info->src.box.height != -info->dst.box.height))
       eng3d = true;
 
+   if (info->num_window_rectangles > 0 || info->window_rectangle_include)
+      eng3d = true;
+
    if (nvc0->screen->num_occlusion_queries_active)
       IMMED_NVC0(push, NVC0_3D(SAMPLECNT_ENABLE), 0);