gallium: implement set_sample_mask() in all drivers
authorRoland Scheidegger <sroland@vmware.com>
Tue, 18 May 2010 14:20:44 +0000 (16:20 +0200)
committerRoland Scheidegger <sroland@vmware.com>
Tue, 18 May 2010 14:20:44 +0000 (16:20 +0200)
prevents segfault when state trackers try to set default mask.
Other option would be to make this required only for drivers
supporting multisampling, but this seems more clean.
Only dummy implementations (for normal drivers) provided (no driver
supports multisampling yet neither).

16 files changed:
src/gallium/drivers/cell/ppu/cell_pipe_state.c
src/gallium/drivers/failover/fo_context.h
src/gallium/drivers/failover/fo_state.c
src/gallium/drivers/failover/fo_state_emit.c
src/gallium/drivers/i915/i915_state.c
src/gallium/drivers/i965/brw_pipe_depth.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/llvmpipe/lp_state_blend.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nvfx/nvfx_state.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_state.h
src/gallium/drivers/softpipe/sp_state_blend.c
src/gallium/drivers/svga/svga_pipe_depthstencil.c
src/gallium/drivers/trace/tr_context.c

index 8c975c6ae2a1eccf4a23ac77c9e37dc653f8c63d..ecc9de4df6605af9f0e5d4a45185fa8e9bf40e74 100644 (file)
@@ -125,6 +125,7 @@ cell_set_stencil_ref(struct pipe_context *pipe,
    cell->dirty |= CELL_NEW_DEPTH_STENCIL;
 }
 
+
 static void
 cell_set_clip_state(struct pipe_context *pipe,
                     const struct pipe_clip_state *clip)
@@ -136,6 +137,12 @@ cell_set_clip_state(struct pipe_context *pipe,
 }
 
 
+static void
+cell_set_sample_mask(struct pipe_context *pipe,
+                     unsigned sample_mask)
+{
+}
+
 
 /* Called when driver state tracker notices changes to the viewport
  * matrix:
@@ -430,7 +437,6 @@ cell_set_framebuffer_state(struct pipe_context *pipe,
 }
 
 
-
 void
 cell_init_state_functions(struct cell_context *cell)
 {
@@ -457,6 +463,7 @@ cell_init_state_functions(struct cell_context *cell)
    cell->pipe.set_blend_color = cell_set_blend_color;
    cell->pipe.set_stencil_ref = cell_set_stencil_ref;
    cell->pipe.set_clip_state = cell_set_clip_state;
+   cell->pipe.set_sample_mask = cell_set_sample_mask;
 
    cell->pipe.set_framebuffer_state = cell_set_framebuffer_state;
 
index 88ae5ad60d538722759d6f08345b63008d3c1629..9d3e0d0dba0d24c7509e2ed5376dd1fb1ca2a9fb 100644 (file)
@@ -55,6 +55,7 @@
 #define FO_NEW_CLEAR_COLOR     0x20000
 #define FO_NEW_VERTEX_BUFFER   0x40000
 #define FO_NEW_VERTEX_ELEMENT  0x80000
+#define FO_NEW_SAMPLE_MASK     0x100000
 
 
 
@@ -90,6 +91,7 @@ struct failover_context {
    struct pipe_blend_color blend_color;
    struct pipe_stencil_ref stencil_ref;
    struct pipe_clip_state clip;
+   unsigned sample_mask;
    struct pipe_framebuffer_state framebuffer;
    struct pipe_poly_stipple poly_stipple;
    struct pipe_scissor_state scissor;
index 272e683067e5a0d97608d7c3a6aef048fb625b51..12e42379f98b95c345657bbd54da6e4c77f85c98 100644 (file)
@@ -125,6 +125,19 @@ failover_set_clip_state( struct pipe_context *pipe,
    failover->hw->set_clip_state( failover->hw, clip );
 }
 
+static void
+failover_set_sample_mask(struct pipe_context *pipe,
+                         unsigned sample_mask)
+{
+   struct failover_context *failover = failover_context(pipe);
+
+   failover->sample_mask = sample_mask;
+   failover->dirty |= FO_NEW_SAMPLE_MASK;
+   failover->sw->set_sample_mask( failover->sw, sample_mask );
+   failover->hw->set_sample_mask( failover->hw, sample_mask );
+
+}
+
 
 static void *
 failover_create_depth_stencil_state(struct pipe_context *pipe,
@@ -614,6 +627,7 @@ failover_init_state_functions( struct failover_context *failover )
    failover->pipe.set_blend_color = failover_set_blend_color;
    failover->pipe.set_stencil_ref = failover_set_stencil_ref;
    failover->pipe.set_clip_state = failover_set_clip_state;
+   failover->pipe.set_sample_mask = failover_set_sample_mask;
    failover->pipe.set_framebuffer_state = failover_set_framebuffer_state;
    failover->pipe.set_polygon_stipple = failover_set_polygon_stipple;
    failover->pipe.set_scissor_state = failover_set_scissor_state;
index 42bd6929a7fbe3433d66d9cbc31a28a589148b3c..147f23269ca252698eda843ad7a3eea373d309fe 100644 (file)
@@ -63,6 +63,9 @@ failover_state_emit( struct failover_context *failover )
    if (failover->dirty & FO_NEW_CLIP)
       failover->sw->set_clip_state( failover->sw, &failover->clip );
 
+   if (failover->dirty & FO_NEW_SAMPLE_MASK)
+      failover->sw->set_sample_mask( failover->sw, failover->sample_mask );
+
    if (failover->dirty & FO_NEW_DEPTH_STENCIL)
       failover->sw->bind_depth_stencil_alpha_state( failover->sw,
                                                     failover->depth_stencil->sw_state );
index f883883852a14f59f04fc41cf6cd796fd5ef3f52..e008195a910b1cc0692b7e9cd751bac2127adc72 100644 (file)
@@ -806,6 +806,12 @@ i915_delete_vertex_elements_state(struct pipe_context *pipe, void *velems)
    FREE( velems );
 }
 
+static void
+i915_set_sample_mask(struct pipe_context *pipe,
+                     unsigned sample_mask)
+{
+}
+
 void
 i915_init_state_functions( struct i915_context *i915 )
 {
@@ -837,6 +843,7 @@ i915_init_state_functions( struct i915_context *i915 )
    i915->base.set_blend_color = i915_set_blend_color;
    i915->base.set_stencil_ref = i915_set_stencil_ref;
    i915->base.set_clip_state = i915_set_clip_state;
+   i915->base.set_sample_mask = i915_set_sample_mask;
    i915->base.set_constant_buffer = i915_set_constant_buffer;
    i915->base.set_framebuffer_state = i915_set_framebuffer_state;
 
index b7000d5e3344ea0103a9f140be3903ba303e208f..31c2c343d89489dbfb813176d11513f7f70955ec 100644 (file)
@@ -167,12 +167,19 @@ static void brw_set_stencil_ref(struct pipe_context *pipe,
    brw->state.dirty.mesa |= PIPE_NEW_DEPTH_STENCIL_ALPHA;
 }
 
+static void
+brw_set_sample_mask(struct pipe_context *pipe,
+                    unsigned sample_mask)
+{
+}
+
 void brw_pipe_depth_stencil_init( struct brw_context *brw )
 {
    brw->base.set_stencil_ref = brw_set_stencil_ref;
    brw->base.create_depth_stencil_alpha_state = brw_create_depth_stencil_state;
    brw->base.bind_depth_stencil_alpha_state = brw_bind_depth_stencil_state;
    brw->base.delete_depth_stencil_alpha_state = brw_delete_depth_stencil_state;
+   brw->base.set_sample_mask = brw_set_sample_mask;
 }
 
 void brw_pipe_depth_stencil_cleanup( struct brw_context *brw )
index bd1b5ea2d0eb747b1222e933a448c802fe0f49a9..9813170fb18d2c8fceadb0ae284ebdbb2f11b0ac 100644 (file)
@@ -451,6 +451,17 @@ identity_set_clip_state(struct pipe_context *_pipe,
                         clip);
 }
 
+static void
+identity_set_sample_mask(struct pipe_context *_pipe,
+                         unsigned sample_mask)
+{
+   struct identity_context *id_pipe = identity_context(_pipe);
+   struct pipe_context *pipe = id_pipe->pipe;
+
+   pipe->set_sample_mask(pipe,
+                         sample_mask);
+}
+
 static void
 identity_set_constant_buffer(struct pipe_context *_pipe,
                              uint shader,
@@ -892,6 +903,7 @@ identity_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    id_pipe->base.set_blend_color = identity_set_blend_color;
    id_pipe->base.set_stencil_ref = identity_set_stencil_ref;
    id_pipe->base.set_clip_state = identity_set_clip_state;
+   id_pipe->base.set_sample_mask = identity_set_sample_mask;
    id_pipe->base.set_constant_buffer = identity_set_constant_buffer;
    id_pipe->base.set_framebuffer_state = identity_set_framebuffer_state;
    id_pipe->base.set_polygon_stipple = identity_set_polygon_stipple;
index 8569507f4e5e94c4860e654e91587dd82061b938..5b39d9d1a91aa4a599e7f6f28db56ff80921a9b4 100644 (file)
@@ -148,6 +148,11 @@ llvmpipe_set_stencil_ref(struct pipe_context *pipe,
    llvmpipe->dirty |= LP_NEW_DEPTH_STENCIL_ALPHA;
 }
 
+static void
+llvmpipe_set_sample_mask(struct pipe_context *pipe,
+                         unsigned sample_mask)
+{
+}
 
 void
 llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
@@ -163,4 +168,5 @@ llvmpipe_init_blend_funcs(struct llvmpipe_context *llvmpipe)
    llvmpipe->pipe.set_blend_color = llvmpipe_set_blend_color;
 
    llvmpipe->pipe.set_stencil_ref = llvmpipe_set_stencil_ref;
+   llvmpipe->pipe.set_sample_mask = llvmpipe_set_sample_mask;
 }
index e885a2b719686087e9df50c296cf24a16d973a2d..3fde8592143f6e49799198e31c6ba8e8489c1f08 100644 (file)
@@ -688,6 +688,12 @@ nv50_set_clip_state(struct pipe_context *pipe,
 {
 }
 
+static void
+nv50_set_sample_mask(struct pipe_context *pipe,
+                    unsigned sample_mask)
+{
+}
+
 static void
 nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         struct pipe_resource *buf )
@@ -833,6 +839,7 @@ nv50_init_state_functions(struct nv50_context *nv50)
        nv50->pipe.set_blend_color = nv50_set_blend_color;
         nv50->pipe.set_stencil_ref = nv50_set_stencil_ref;
        nv50->pipe.set_clip_state = nv50_set_clip_state;
+       nv50->pipe_set_sample_mask = nv50_set_sample_mask;
        nv50->pipe.set_constant_buffer = nv50_set_constant_buffer;
        nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state;
        nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple;
index 315de492dab2c4d143b00ffa3a1b9fda2fe8a22e..3c566808d03ae6badccd8d604db407983e1d0398 100644 (file)
@@ -505,6 +505,12 @@ nvfx_set_clip_state(struct pipe_context *pipe,
        nvfx->draw_dirty |= NVFX_NEW_UCP;
 }
 
+static void
+nvfx_set_sample_mask(struct pipe_context *pipe,
+                    unsigned sample_mask)
+{
+}
+
 static void
 nvfx_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
                         struct pipe_resource *buf )
@@ -644,6 +650,7 @@ nvfx_init_state_functions(struct nvfx_context *nvfx)
        nvfx->pipe.set_blend_color = nvfx_set_blend_color;
         nvfx->pipe.set_stencil_ref = nvfx_set_stencil_ref;
        nvfx->pipe.set_clip_state = nvfx_set_clip_state;
+       nvfx->pipe.set_sample_mask = nvfx_set_sample_mask;
        nvfx->pipe.set_constant_buffer = nvfx_set_constant_buffer;
        nvfx->pipe.set_framebuffer_state = nvfx_set_framebuffer_state;
        nvfx->pipe.set_polygon_stipple = nvfx_set_polygon_stipple;
index 446422ca0f045e58dc71055e71feeab3025ddbf8..4f41530c16a648464a3014dd2c420431645dd685 100644 (file)
@@ -404,6 +404,13 @@ static void r300_set_clip_state(struct pipe_context* pipe,
     r300->clip_state.dirty = TRUE;
 }
 
+static void
+r300_set_sample_mask(struct pipe_context *pipe,
+                     unsigned sample_mask)
+{
+}
+
+
 /* Create a new depth, stencil, and alpha state based on the CSO dsa state.
  *
  * This contains the depth buffer, stencil buffer, alpha test, and such.
@@ -1502,6 +1509,7 @@ void r300_init_state_functions(struct r300_context* r300)
     r300->context.set_blend_color = r300_set_blend_color;
 
     r300->context.set_clip_state = r300_set_clip_state;
+    r300->context.set_sample_mask = r300_set_sample_mask;
 
     r300->context.set_constant_buffer = r300_set_constant_buffer;
 
index f6e2b80d46e19baeb569ed46f49e7feed1cf2232..0f1bcc21bd66e7ce133f64bf15b02b0c7134820f 100644 (file)
@@ -251,6 +251,7 @@ softpipe_create_context( struct pipe_screen *screen,
    softpipe->pipe.set_blend_color = softpipe_set_blend_color;
    softpipe->pipe.set_stencil_ref = softpipe_set_stencil_ref;
    softpipe->pipe.set_clip_state = softpipe_set_clip_state;
+   softpipe->pipe.set_sample_mask = softpipe_set_sample_mask;
    softpipe->pipe.set_constant_buffer = softpipe_set_constant_buffer;
    softpipe->pipe.set_framebuffer_state = softpipe_set_framebuffer_state;
    softpipe->pipe.set_polygon_stipple = softpipe_set_polygon_stipple;
index f97fc6eca8ffe028ee1e8c9ca4a2678dc040a8e1..5b0faabeaef48d2db2ff542da11ccb86ebd20723 100644 (file)
@@ -148,6 +148,9 @@ void softpipe_set_stencil_ref( struct pipe_context *pipe,
 void softpipe_set_clip_state( struct pipe_context *,
                               const struct pipe_clip_state * );
 
+void softpipe_set_sample_mask( struct pipe_context *,
+                               unsigned sample_mask );
+
 void softpipe_set_constant_buffer(struct pipe_context *,
                                   uint shader, uint index,
                                   struct pipe_resource *buf);
index c63a49e90b0ac99d3669b3ced7092059cb921c92..2a203f44e50de451b4ec26ff3c2954784b6de5b2 100644 (file)
@@ -111,3 +111,10 @@ void softpipe_set_stencil_ref( struct pipe_context *pipe,
 
    softpipe->dirty |= SP_NEW_DEPTH_STENCIL_ALPHA;
 }
+
+void
+softpipe_set_sample_mask(struct pipe_context *pipe,
+                         unsigned sample_mask)
+{
+}
+
index c317bec6d57d02707eef9b2f59523d1714d71b94..c84615a1f3bdc7a013e0ff5dae04514e3b161b53 100644 (file)
@@ -147,6 +147,12 @@ static void svga_set_stencil_ref( struct pipe_context *pipe,
    svga->dirty |= SVGA_NEW_STENCIL_REF;
 }
 
+static void
+svga_set_sample_mask(struct pipe_context *pipe,
+                     unsigned sample_mask)
+{
+}
+
 
 void svga_init_depth_stencil_functions( struct svga_context *svga )
 {
@@ -155,6 +161,7 @@ void svga_init_depth_stencil_functions( struct svga_context *svga )
    svga->pipe.delete_depth_stencil_alpha_state = svga_delete_depth_stencil_state;
 
    svga->pipe.set_stencil_ref = svga_set_stencil_ref;
+   svga->pipe.set_sample_mask = svga_set_sample_mask;
 }
 
 
index 0edb685ac7be924f0578ca3c14f2344acb64a0a3..64a4316984b3a7e1d919ce1b2684582a50ce926c 100644 (file)
@@ -876,6 +876,22 @@ trace_context_set_clip_state(struct pipe_context *_pipe,
    trace_dump_call_end();
 }
 
+static INLINE void
+trace_context_set_sample_mask(struct pipe_context *_pipe,
+                              unsigned sample_mask)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "set_sample_mask");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(uint, sample_mask);
+
+   pipe->set_sample_mask(pipe, sample_mask);
+
+   trace_dump_call_end();
+}
 
 static INLINE void
 trace_context_set_constant_buffer(struct pipe_context *_pipe,
@@ -1561,6 +1577,7 @@ trace_context_create(struct trace_screen *tr_scr,
    tr_ctx->base.set_blend_color = trace_context_set_blend_color;
    tr_ctx->base.set_stencil_ref = trace_context_set_stencil_ref;
    tr_ctx->base.set_clip_state = trace_context_set_clip_state;
+   tr_ctx->base.set_sample_mask = trace_context_set_sample_mask;
    tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer;
    tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state;
    tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;