llvmpipe: Basic implementation of pipe_context::set_sample_mask.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 6 Jan 2014 18:45:49 +0000 (18:45 +0000)
committerJosé Fonseca <jfonseca@vmware.com>
Tue, 7 Jan 2014 16:04:42 +0000 (16:04 +0000)
We don't support MSAA (ie, number of samples is always one) therefore
sample_mask boils down to a synonym of the rasterizer_discard flag.

Also, this change makes setup actually use the value received in
lp_setup_set_rasterizer_discard instead of reaching out to llvmpipe
upper layers to re-fetch it.

Based on Si Chen's draft.

With this patch `wgf11multisample Coverage passes 100%` on the UMD
D3D10 state tracker.

Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Si Chen <sichen@vmware.com>
src/gallium/drivers/llvmpipe/lp_context.h
src/gallium/drivers/llvmpipe/lp_setup.c
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/llvmpipe/lp_state_derived.c
src/gallium/drivers/llvmpipe/lp_state_rasterizer.c

index 9ec18e8429edf4d2ea0630c1c0737486b884d78b..62fa6a90b4d6d286134ce7eb00754cee928f41bf 100644 (file)
@@ -69,6 +69,7 @@ struct llvmpipe_context {
    const struct lp_so_state *so;
 
    /** Other rendering state */
+   unsigned sample_mask;
    struct pipe_blend_color blend_color;
    struct pipe_stencil_ref stencil_ref;
    struct pipe_clip_state clip;
index 2fad469d1977e798b4e0e961102240acb11d7684..7f2223129aa0121481900b3c581c6985a82b9357 100644 (file)
@@ -66,9 +66,6 @@ static boolean try_update_scene_state( struct lp_setup_context *setup );
 static void
 lp_setup_get_empty_scene(struct lp_setup_context *setup)
 {
-   struct llvmpipe_context *lp = llvmpipe_context(setup->pipe);
-   boolean discard = lp->rasterizer ? lp->rasterizer->rasterizer_discard : FALSE;
-
    assert(setup->scene == NULL);
 
    setup->scene_idx++;
@@ -84,8 +81,8 @@ lp_setup_get_empty_scene(struct lp_setup_context *setup)
       lp_fence_wait(setup->scene->fence);
    }
 
-   lp_scene_begin_binning(setup->scene, &setup->fb, discard);
-   
+   lp_scene_begin_binning(setup->scene, &setup->fb, setup->rasterizer_discard);
+
 }
 
 
index 6bba9077d1b5a88c5ebde9d8c2f2b4661bb118db..b0fc1d38124bea475e4c06ed1c3e1136cb7c89f8 100644 (file)
@@ -177,6 +177,13 @@ static void
 llvmpipe_set_sample_mask(struct pipe_context *pipe,
                          unsigned sample_mask)
 {
+   struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe);
+
+   if (sample_mask != llvmpipe->sample_mask) {
+      llvmpipe->sample_mask = sample_mask;
+
+      llvmpipe->dirty |= LP_NEW_RASTERIZER;
+   }
 }
 
 void
@@ -194,4 +201,6 @@ llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
 
    llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
    llvmpipe->pipe.set_sample_mask = llvmpipe_set_sample_mask;
+
+   llvmpipe->sample_mask = ~0;
 }
index 5c3a3a8e3a9a9cabe3ffc54e7fdfe2e07c8f3c3c..a300841d395d0908981830e21fa7e45bf04f462b 100644 (file)
@@ -185,6 +185,14 @@ void llvmpipe_update_derived( struct llvmpipe_context *llvmpipe )
                           LP_NEW_OCCLUSION_QUERY))
       llvmpipe_update_fs( llvmpipe );
 
+   if (llvmpipe->dirty & (LP_NEW_RASTERIZER)) {
+      boolean discard =
+         (llvmpipe->sample_mask & 1) == 0 ||
+         (llvmpipe->rasterizer ? llvmpipe->rasterizer->rasterizer_discard : FALSE);
+
+      lp_setup_set_rasterizer_discard(llvmpipe->setup, discard);
+   }
+
    if (llvmpipe->dirty & (LP_NEW_FS |
                           LP_NEW_FRAMEBUFFER |
                           LP_NEW_RASTERIZER))
index 2149ffc2351dab384a509e3cbcd0c410d399e5f8..5a0f51fe108493f5cc65fccf23262604c981b771 100644 (file)
@@ -119,8 +119,6 @@ llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, void *handle)
                                   state->lp_state.bottom_edge_rule);
       lp_setup_set_flatshade_first( llvmpipe->setup,
                                    state->lp_state.flatshade_first);
-      lp_setup_set_rasterizer_discard( llvmpipe->setup,
-                                   state->lp_state.rasterizer_discard);
       lp_setup_set_line_state( llvmpipe->setup,
                               state->lp_state.line_width);
       lp_setup_set_point_state( llvmpipe->setup,