summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/cso_cache/cso_cache.h10
-rw-r--r--src/mesa/pipe/failover/fo_context.h4
-rw-r--r--src/mesa/pipe/failover/fo_state.c75
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c6
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c28
-rw-r--r--src/mesa/pipe/p_context.h23
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h11
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c27
8 files changed, 119 insertions, 65 deletions
diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h
index cd4b64eec4..57d162b2ac 100644
--- a/src/mesa/pipe/cso_cache/cso_cache.h
+++ b/src/mesa/pipe/cso_cache/cso_cache.h
@@ -58,6 +58,16 @@ struct cso_rasterizer {
void *data;
};
+struct cso_fragment_shader {
+ struct pipe_shader_state state;
+ void *data;
+};
+
+struct cso_vertex_shader {
+ struct pipe_shader_state state;
+ void *data;
+};
+
enum cso_cache_type {
CSO_BLEND,
CSO_SAMPLER,
diff --git a/src/mesa/pipe/failover/fo_context.h b/src/mesa/pipe/failover/fo_context.h
index a649899010..a81bfe82dd 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -74,8 +74,8 @@ struct failover_context {
const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
const struct pipe_depth_stencil_state *depth_stencil;
const struct fo_state *rasterizer;
- const struct pipe_shader_state *fragment_shader;
- const struct pipe_shader_state *vertex_shader;
+ const struct fo_state *fragment_shader;
+ const struct fo_state *vertex_shader;
struct pipe_alpha_test_state alpha_test;
struct pipe_blend_color blend_color;
diff --git a/src/mesa/pipe/failover/fo_state.c b/src/mesa/pipe/failover/fo_state.c
index 25725625e0..db3aea7756 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -150,26 +150,81 @@ failover_set_framebuffer_state(struct pipe_context *pipe,
failover->hw->set_framebuffer_state( failover->hw, framebuffer );
}
+
+static void *
+failover_create_fs_state(struct pipe_context *pipe,
+ const struct pipe_shader_state *templ)
+{
+ struct fo_state *state = malloc(sizeof(struct fo_state));
+ struct failover_context *failover = failover_context(pipe);
+
+ state->sw_state = failover->sw->create_fs_state(pipe, templ);
+ state->hw_state = failover->hw->create_fs_state(pipe, templ);
+
+ return state;
+}
+
static void
failover_bind_fs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *fs)
+ void *fs)
{
struct failover_context *failover = failover_context(pipe);
- failover->fragment_shader = fs;
+ failover->fragment_shader = (struct fo_state *)fs;
failover->dirty |= FO_NEW_FRAGMENT_SHADER;
- failover->hw->bind_fs_state( failover->hw, fs );
+ failover->hw->bind_fs_state(failover->hw, (struct pipe_shader_state *)fs);
+}
+
+static void
+failover_delete_fs_state(struct pipe_context *pipe,
+ void *fs)
+{
+ struct fo_state *state = (struct fo_state*)fs;
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sw->delete_fs_state(pipe, state->sw_state);
+ failover->hw->delete_fs_state(pipe, state->hw_state);
+ state->sw_state = 0;
+ state->hw_state = 0;
+ free(state);
+}
+
+static void *
+failover_create_vs_state(struct pipe_context *pipe,
+ const struct pipe_shader_state *templ)
+{
+ struct fo_state *state = malloc(sizeof(struct fo_state));
+ struct failover_context *failover = failover_context(pipe);
+
+ state->sw_state = failover->sw->create_vs_state(pipe, templ);
+ state->hw_state = failover->hw->create_vs_state(pipe, templ);
+
+ return state;
}
static void
failover_bind_vs_state(struct pipe_context *pipe,
- const struct pipe_shader_state *vs)
+ void *vs)
{
struct failover_context *failover = failover_context(pipe);
- failover->vertex_shader = vs;
+ failover->vertex_shader = (struct fo_state*)vs;
failover->dirty |= FO_NEW_VERTEX_SHADER;
- failover->hw->bind_vs_state( failover->hw, vs );
+ failover->hw->bind_vs_state(failover->hw, vs);
+}
+
+static void
+failover_delete_vs_state(struct pipe_context *pipe,
+ void *vs)
+{
+ struct fo_state *state = (struct fo_state*)vs;
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sw->delete_vs_state(pipe, state->sw_state);
+ failover->hw->delete_vs_state(pipe, state->hw_state);
+ state->sw_state = 0;
+ state->hw_state = 0;
+ free(state);
}
static void
@@ -312,8 +367,12 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.create_rasterizer_state = failover_create_rasterizer_state;
failover->pipe.bind_rasterizer_state = failover_bind_rasterizer_state;
failover->pipe.delete_rasterizer_state = failover_delete_rasterizer_state;
- failover->pipe.bind_fs_state = failover_bind_fs_state;
- failover->pipe.bind_vs_state = failover_bind_vs_state;
+ failover->pipe.create_fs_state = failover_create_fs_state;
+ failover->pipe.bind_fs_state = failover_bind_fs_state;
+ failover->pipe.delete_fs_state = failover_delete_fs_state;
+ failover->pipe.create_vs_state = failover_create_vs_state;
+ failover->pipe.bind_vs_state = failover_bind_vs_state;
+ failover->pipe.delete_vs_state = failover_delete_vs_state;
failover->pipe.set_alpha_test_state = failover_set_alpha_test_state;
failover->pipe.set_blend_color = failover_set_blend_color;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index f2b0b1edc0..ec896fd020 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -78,10 +78,12 @@ failover_state_emit( struct failover_context *failover )
failover->sw->set_framebuffer_state( failover->sw, &failover->framebuffer );
if (failover->dirty & FO_NEW_FRAGMENT_SHADER)
- failover->sw->bind_fs_state( failover->sw, failover->fragment_shader );
+ failover->sw->bind_fs_state( failover->sw,
+ failover->fragment_shader->sw_state );
if (failover->dirty & FO_NEW_VERTEX_SHADER)
- failover->sw->bind_vs_state( failover->sw, failover->vertex_shader );
+ failover->sw->bind_vs_state( failover->sw,
+ failover->vertex_shader->sw_state );
if (failover->dirty & FO_NEW_STIPPLE)
failover->sw->set_polygon_stipple( failover->sw, &failover->poly_stipple );
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index 66aa9a0274..1104c9519d 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -228,41 +228,37 @@ static void i915_set_polygon_stipple( struct pipe_context *pipe,
}
-static const struct pipe_shader_state *
-i915_create_shader_state( struct pipe_context *pipe,
- const struct pipe_shader_state *templ )
+static void *
+i915_create_shader_state(struct pipe_context *pipe,
+ const struct pipe_shader_state *templ)
{
-
- struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state));
- memcpy(shader, templ, sizeof(struct pipe_shader_state));
-
- return shader;
+ return 0;
}
static void i915_bind_fs_state( struct pipe_context *pipe,
- const struct pipe_shader_state *fs )
+ void *fs )
{
struct i915_context *i915 = i915_context(pipe);
- i915->fs = fs;
+ i915->fs = (struct pipe_shader_state *)fs;
i915->dirty |= I915_NEW_FS;
}
-static void i915_bind_vs_state( struct pipe_context *pipe,
- const struct pipe_shader_state *vs )
+static void i915_bind_vs_state(struct pipe_context *pipe,
+ void *vs)
{
struct i915_context *i915 = i915_context(pipe);
/* just pass-through to draw module */
- draw_set_vertex_shader(i915->draw, vs);
+ draw_set_vertex_shader(i915->draw, (const struct pipe_shader_state *)vs);
}
-static void i915_delete_shader_state( struct pipe_context *pipe,
- const struct pipe_shader_state *shader )
+static void i915_delete_shader_state(struct pipe_context *pipe,
+ void *shader)
{
- free((struct pipe_shader_state*)shader);
+ /*do nothing*/
}
static void i915_set_constant_buffer(struct pipe_context *pipe,
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 65001dfdf9..e17faad2c7 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -113,20 +113,15 @@ struct pipe_context {
void (*delete_depth_stencil_state)(struct pipe_context *,
const struct pipe_depth_stencil_state *);
- const struct pipe_shader_state * (*create_fs_state)(
- struct pipe_context *,
- const struct pipe_shader_state *);
- void (*bind_fs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
- void (*delete_fs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
- const struct pipe_shader_state * (*create_vs_state)(
- struct pipe_context *,
- const struct pipe_shader_state *);
- void (*bind_vs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
- void (*delete_vs_state)(struct pipe_context *,
- const struct pipe_shader_state *);
+ void * (*create_fs_state)(struct pipe_context *,
+ const struct pipe_shader_state *);
+ void (*bind_fs_state)(struct pipe_context *, void *);
+ void (*delete_fs_state)(struct pipe_context *, void *);
+
+ void * (*create_vs_state)(struct pipe_context *,
+ const struct pipe_shader_state *);
+ void (*bind_vs_state)(struct pipe_context *, void *);
+ void (*delete_vs_state)(struct pipe_context *, void *);
void (*set_alpha_test_state)( struct pipe_context *,
const struct pipe_alpha_test_state * );
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index a20ae1d4a2..5ed963c21d 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -88,15 +88,12 @@ void softpipe_set_constant_buffer(struct pipe_context *,
void softpipe_set_feedback_state( struct pipe_context *,
const struct pipe_feedback_state * );
-const struct pipe_shader_state *
+void *
softpipe_create_shader_state( struct pipe_context *,
const struct pipe_shader_state * );
-void softpipe_bind_fs_state( struct pipe_context *,
- const struct pipe_shader_state * );
-void softpipe_bind_vs_state( struct pipe_context *,
- const struct pipe_shader_state * );
-void softpipe_delete_shader_state( struct pipe_context *,
- const struct pipe_shader_state * );
+void softpipe_bind_fs_state( struct pipe_context *, void * );
+void softpipe_bind_vs_state( struct pipe_context *, void * );
+void softpipe_delete_shader_state( struct pipe_context *, void * );
void softpipe_set_polygon_stipple( struct pipe_context *,
const struct pipe_poly_stipple * );
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
index fbbde2f520..8306a95f44 100644
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ b/src/mesa/pipe/softpipe/sp_state_fs.c
@@ -33,44 +33,39 @@
#include "pipe/draw/draw_context.h"
-const struct pipe_shader_state *
-softpipe_create_shader_state( struct pipe_context *pipe,
- const struct pipe_shader_state *templ )
+void * softpipe_create_shader_state(struct pipe_context *pipe,
+ const struct pipe_shader_state *templ)
{
- struct pipe_shader_state *shader = malloc(sizeof(struct pipe_shader_state));
- memcpy(shader, templ, sizeof(struct pipe_shader_state));
-
- return shader;
+ /* we just want the pipe_shader_state template in the bind calls */
+ return 0;
}
-void softpipe_bind_fs_state( struct pipe_context *pipe,
- const struct pipe_shader_state *fs )
+void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->fs = fs;
+ softpipe->fs = (struct pipe_shader_state *)fs;
softpipe->dirty |= SP_NEW_FS;
}
-void softpipe_bind_vs_state( struct pipe_context *pipe,
- const struct pipe_shader_state *vs )
+void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- softpipe->vs = vs;
+ softpipe->vs = (struct pipe_shader_state *)vs;
softpipe->dirty |= SP_NEW_VS;
- draw_set_vertex_shader(softpipe->draw, vs);
+ draw_set_vertex_shader(softpipe->draw, (struct pipe_shader_state *)vs);
}
void softpipe_delete_shader_state( struct pipe_context *pipe,
- const struct pipe_shader_state *shader )
+ void *shader )
{
- free((struct pipe_shader_state*)shader);
+ /* do nothing */
}
void softpipe_set_constant_buffer(struct pipe_context *pipe,