aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/cso_cache/cso_cache.h5
-rw-r--r--src/mesa/pipe/failover/fo_context.h12
-rw-r--r--src/mesa/pipe/failover/fo_state.c72
-rw-r--r--src/mesa/pipe/failover/fo_state_emit.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c15
-rw-r--r--src/mesa/pipe/p_context.h13
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h9
-rw-r--r--src/mesa/pipe/softpipe/sp_state_sampler.c18
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c10
-rw-r--r--src/mesa/state_tracker/st_cache.c22
-rw-r--r--src/mesa/state_tracker/st_cache.h2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c7
-rw-r--r--src/mesa/state_tracker/st_context.h2
13 files changed, 105 insertions, 84 deletions
diff --git a/src/mesa/pipe/cso_cache/cso_cache.h b/src/mesa/pipe/cso_cache/cso_cache.h
index 291759d5d1e..2acb58c66b6 100644
--- a/src/mesa/pipe/cso_cache/cso_cache.h
+++ b/src/mesa/pipe/cso_cache/cso_cache.h
@@ -73,6 +73,11 @@ struct cso_vertex_shader {
void *data;
};
+struct cso_sampler {
+ struct pipe_sampler_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 7371ad4392b..8a2fbe2be9b 100644
--- a/src/mesa/pipe/failover/fo_context.h
+++ b/src/mesa/pipe/failover/fo_context.h
@@ -70,12 +70,12 @@ struct failover_context {
/* The most recent drawing state as set by the driver:
*/
- const struct fo_state *blend;
- const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
- const struct fo_state *depth_stencil;
- const struct fo_state *rasterizer;
- const struct fo_state *fragment_shader;
- const struct fo_state *vertex_shader;
+ const struct fo_state *blend;
+ const struct fo_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct fo_state *depth_stencil;
+ const struct fo_state *rasterizer;
+ 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 3379f453557..ce3f0ca6358 100644
--- a/src/mesa/pipe/failover/fo_state.c
+++ b/src/mesa/pipe/failover/fo_state.c
@@ -75,10 +75,10 @@ failover_bind_blend_state( struct pipe_context *pipe,
void *blend )
{
struct failover_context *failover = failover_context(pipe);
-
- failover->blend = (struct fo_state *)blend;
+ struct fo_state *state = (struct fo_state *)blend;
+ failover->blend = state;
failover->dirty |= FO_NEW_BLEND;
- failover->hw->bind_blend_state( failover->hw, blend );
+ failover->hw->bind_blend_state( failover->hw, state->hw_state );
}
static void
@@ -146,10 +146,10 @@ failover_bind_depth_stencil_state(struct pipe_context *pipe,
void *depth_stencil)
{
struct failover_context *failover = failover_context(pipe);
-
- failover->depth_stencil = (struct fo_state *)depth_stencil;
+ struct fo_state *state = (struct fo_state *)depth_stencil;
+ failover->depth_stencil = state;
failover->dirty |= FO_NEW_DEPTH_STENCIL;
- failover->hw->bind_depth_stencil_state( failover->hw, depth_stencil );
+ failover->hw->bind_depth_stencil_state(failover->hw, state->hw_state);
}
static void
@@ -192,14 +192,13 @@ failover_create_fs_state(struct pipe_context *pipe,
}
static void
-failover_bind_fs_state(struct pipe_context *pipe,
- void *fs)
+failover_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct failover_context *failover = failover_context(pipe);
-
- failover->fragment_shader = (struct fo_state *)fs;
+ struct fo_state *state = (struct fo_state*)fs;
+ failover->fragment_shader = state;
failover->dirty |= FO_NEW_FRAGMENT_SHADER;
- failover->hw->bind_fs_state(failover->hw, (struct pipe_shader_state *)fs);
+ failover->hw->bind_fs_state(failover->hw, state->hw_state);
}
static void
@@ -235,9 +234,10 @@ failover_bind_vs_state(struct pipe_context *pipe,
{
struct failover_context *failover = failover_context(pipe);
- failover->vertex_shader = (struct fo_state*)vs;
+ struct fo_state *state = (struct fo_state*)vs;
+ failover->vertex_shader = state;
failover->dirty |= FO_NEW_VERTEX_SHADER;
- failover->hw->bind_vs_state(failover->hw, vs);
+ failover->hw->bind_vs_state(failover->hw, state->hw_state);
}
static void
@@ -284,9 +284,10 @@ failover_bind_rasterizer_state(struct pipe_context *pipe,
{
struct failover_context *failover = failover_context(pipe);
- failover->rasterizer = (struct fo_state *)raster;
+ struct fo_state *state = (struct fo_state*)raster;
+ failover->rasterizer = state;
failover->dirty |= FO_NEW_RASTERIZER;
- failover->hw->bind_rasterizer_state( failover->hw, raster );
+ failover->hw->bind_rasterizer_state(failover->hw, state->hw_state);
}
static void
@@ -315,17 +316,44 @@ failover_set_scissor_state( struct pipe_context *pipe,
failover->hw->set_scissor_state( failover->hw, scissor );
}
+
+static void *
+failover_create_sampler_state(struct pipe_context *pipe,
+ const struct pipe_sampler_state *templ)
+{
+ struct fo_state *state = malloc(sizeof(struct fo_state));
+ struct failover_context *failover = failover_context(pipe);
+
+ state->sw_state = failover->sw->create_sampler_state(pipe, templ);
+ state->hw_state = failover->hw->create_sampler_state(pipe, templ);
+
+ return state;
+}
+
static void
failover_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit,
- const struct pipe_sampler_state *sampler)
+ unsigned unit, void *sampler)
{
struct failover_context *failover = failover_context(pipe);
-
- failover->sampler[unit] = sampler;
+ struct fo_state *state = (struct fo_state*)sampler;
+ failover->sampler[unit] = state;
failover->dirty |= FO_NEW_SAMPLER;
failover->dirty_sampler |= (1<<unit);
- failover->hw->bind_sampler_state( failover->hw, unit, sampler );
+ failover->hw->bind_sampler_state(failover->hw, unit,
+ state->hw_state);
+}
+
+static void
+failover_delete_sampler_state(struct pipe_context *pipe, void *sampler)
+{
+ struct fo_state *state = (struct fo_state*)sampler;
+ struct failover_context *failover = failover_context(pipe);
+
+ failover->sw->delete_sampler_state(pipe, state->sw_state);
+ failover->hw->delete_sampler_state(pipe, state->hw_state);
+ state->sw_state = 0;
+ state->hw_state = 0;
+ free(state);
}
@@ -389,7 +417,9 @@ failover_init_state_functions( struct failover_context *failover )
failover->pipe.create_blend_state = failover_create_blend_state;
failover->pipe.bind_blend_state = failover_bind_blend_state;
failover->pipe.delete_blend_state = failover_delete_blend_state;
- failover->pipe.bind_sampler_state = failover_bind_sampler_state;
+ failover->pipe.create_sampler_state = failover_create_sampler_state;
+ failover->pipe.bind_sampler_state = failover_bind_sampler_state;
+ failover->pipe.delete_sampler_state = failover_delete_sampler_state;
failover->pipe.create_depth_stencil_state = failover_create_depth_stencil_state;
failover->pipe.bind_depth_stencil_state = failover_bind_depth_stencil_state;
failover->pipe.delete_depth_stencil_state = failover_delete_depth_stencil_state;
diff --git a/src/mesa/pipe/failover/fo_state_emit.c b/src/mesa/pipe/failover/fo_state_emit.c
index da12b4e25ce..c0ea6810246 100644
--- a/src/mesa/pipe/failover/fo_state_emit.c
+++ b/src/mesa/pipe/failover/fo_state_emit.c
@@ -103,7 +103,7 @@ failover_state_emit( struct failover_context *failover )
for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
if (failover->dirty_sampler & (1<<i)) {
failover->sw->bind_sampler_state( failover->sw, i,
- failover->sampler[i] );
+ failover->sampler[i]->sw_state );
}
}
}
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index be549ed6fdb..0fb41e17ab3 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -142,32 +142,27 @@ static void i915_set_blend_color( struct pipe_context *pipe,
i915->dirty |= I915_NEW_BLEND;
}
-static const struct pipe_sampler_state *
+static void *
i915_create_sampler_state(struct pipe_context *pipe,
const struct pipe_sampler_state *sampler)
{
- struct pipe_sampler_state *new_sampler = malloc(sizeof(struct pipe_sampler_state));
- memcpy(new_sampler, sampler, sizeof(struct pipe_sampler_state));
-
- return new_sampler;
+ return 0;
}
static void i915_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit,
- const struct pipe_sampler_state *sampler)
+ unsigned unit, void *sampler)
{
struct i915_context *i915 = i915_context(pipe);
assert(unit < PIPE_MAX_SAMPLERS);
- i915->sampler[unit] = sampler;
+ i915->sampler[unit] = (const struct pipe_sampler_state *)sampler;
i915->dirty |= I915_NEW_SAMPLER;
}
static void i915_delete_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
+ void *sampler)
{
- free((struct pipe_sampler_state*)sampler);
}
diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h
index 84aca20c58a..07ee0198807 100644
--- a/src/mesa/pipe/p_context.h
+++ b/src/mesa/pipe/p_context.h
@@ -91,14 +91,11 @@ struct pipe_context {
void (*bind_blend_state)(struct pipe_context *, void *);
void (*delete_blend_state)(struct pipe_context *, void *);
- const struct pipe_sampler_state * (*create_sampler_state)(
- struct pipe_context *,
- const struct pipe_sampler_state *);
- void (*bind_sampler_state)(struct pipe_context *,
- unsigned unit,
- const struct pipe_sampler_state *);
- void (*delete_sampler_state)(struct pipe_context *,
- const struct pipe_sampler_state *);
+ void * (*create_sampler_state)(struct pipe_context *,
+ const struct pipe_sampler_state *);
+ void (*bind_sampler_state)(struct pipe_context *, unsigned unit,
+ void *);
+ void (*delete_sampler_state)(struct pipe_context *, void *);
void *(*create_rasterizer_state)(struct pipe_context *,
const struct pipe_rasterizer_state *);
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 08dfe208fbd..62323c41c3b 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -41,14 +41,11 @@ void softpipe_bind_blend_state(struct pipe_context *,
void softpipe_delete_blend_state(struct pipe_context *,
void *);
-const struct pipe_sampler_state *
+void *
softpipe_create_sampler_state(struct pipe_context *,
const struct pipe_sampler_state *);
-void softpipe_bind_sampler_state(struct pipe_context *,
- unsigned,
- const struct pipe_sampler_state *);
-void softpipe_delete_sampler_state(struct pipe_context *,
- const struct pipe_sampler_state *);
+void softpipe_bind_sampler_state(struct pipe_context *, unsigned, void *);
+void softpipe_delete_sampler_state(struct pipe_context *, void *);
void *
softpipe_create_depth_stencil_state(struct pipe_context *,
diff --git a/src/mesa/pipe/softpipe/sp_state_sampler.c b/src/mesa/pipe/softpipe/sp_state_sampler.c
index 09898eb5790..ad98375735b 100644
--- a/src/mesa/pipe/softpipe/sp_state_sampler.c
+++ b/src/mesa/pipe/softpipe/sp_state_sampler.c
@@ -32,27 +32,21 @@
#include "sp_context.h"
#include "sp_state.h"
-
-
-const struct pipe_sampler_state *
+void *
softpipe_create_sampler_state(struct pipe_context *pipe,
const struct pipe_sampler_state *sampler)
{
- struct pipe_sampler_state *new_sampler = malloc(sizeof(struct pipe_sampler_state));
- memcpy(new_sampler, sampler, sizeof(struct pipe_sampler_state));
-
- return new_sampler;
+ return 0;
}
void
softpipe_bind_sampler_state(struct pipe_context *pipe,
- unsigned unit,
- const struct pipe_sampler_state *sampler)
+ unsigned unit, void *sampler)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
assert(unit < PIPE_MAX_SAMPLERS);
- softpipe->sampler[unit] = sampler;
+ softpipe->sampler[unit] = (struct pipe_sampler_state *)sampler;
softpipe->dirty |= SP_NEW_SAMPLER;
}
@@ -60,9 +54,9 @@ softpipe_bind_sampler_state(struct pipe_context *pipe,
void
softpipe_delete_sampler_state(struct pipe_context *pipe,
- const struct pipe_sampler_state *sampler)
+ void *sampler)
{
- free((struct pipe_sampler_state*)sampler);
+ /* do nothing */
}
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 994d3691d8b..23ccd55a057 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -123,6 +123,7 @@ update_samplers(struct st_context *st)
const struct gl_texture_object *texobj
= st->ctx->Texture.Unit[u]._Current;
struct pipe_sampler_state sampler;
+ const struct cso_sampler *cso;
memset(&sampler, 0, sizeof(sampler));
@@ -143,13 +144,12 @@ update_samplers(struct st_context *st)
/* XXX more sampler state here */
}
- const struct pipe_sampler_state *cached_sampler =
- st_cached_sampler_state(st, &sampler);
+ cso = st_cached_sampler_state(st, &sampler);
- if (cached_sampler != st->state.sampler[u]) {
+ if (cso != st->state.sampler[u]) {
/* state has changed */
- st->state.sampler[u] = cached_sampler;
- st->pipe->bind_sampler_state(st->pipe, u, cached_sampler);
+ st->state.sampler[u] = cso;
+ st->pipe->bind_sampler_state(st->pipe, u, cso->data);
}
}
}
diff --git a/src/mesa/state_tracker/st_cache.c b/src/mesa/state_tracker/st_cache.c
index c1ec130b321..007a2311e98 100644
--- a/src/mesa/state_tracker/st_cache.c
+++ b/src/mesa/state_tracker/st_cache.c
@@ -61,21 +61,23 @@ const struct cso_blend * st_cached_blend_state(struct st_context *st,
return ((struct cso_blend *)cso_hash_iter_data(iter));
}
-struct pipe_sampler_state * st_cached_sampler_state(
- struct st_context *st,
- const struct pipe_sampler_state *sampler)
+const struct cso_sampler *
+st_cached_sampler_state(struct st_context *st,
+ const struct pipe_sampler_state *templ)
{
- unsigned hash_key = cso_construct_key((void*)sampler, sizeof(struct pipe_sampler_state));
+ unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
struct cso_hash_iter iter = cso_find_state_template(st->cache,
hash_key, CSO_SAMPLER,
- (void*)sampler);
+ (void*)templ);
if (cso_hash_iter_is_null(iter)) {
- const struct pipe_sampler_state *created_state = st->pipe->create_sampler_state(
- st->pipe, sampler);
- iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER,
- (void*)created_state);
+ struct cso_sampler *cso = malloc(sizeof(struct cso_sampler));
+ memcpy(&cso->state, templ, sizeof(struct pipe_sampler_state));
+ cso->data = st->pipe->create_sampler_state(st->pipe, templ);
+ if (!cso->data)
+ cso->data = &cso->state;
+ iter = cso_insert_state(st->cache, hash_key, CSO_SAMPLER, cso);
}
- return (struct pipe_sampler_state*)(cso_hash_iter_data(iter));
+ return (struct cso_sampler*)(cso_hash_iter_data(iter));
}
const struct cso_depth_stencil *
diff --git a/src/mesa/state_tracker/st_cache.h b/src/mesa/state_tracker/st_cache.h
index 167d9ec11a7..483af6fdb43 100644
--- a/src/mesa/state_tracker/st_cache.h
+++ b/src/mesa/state_tracker/st_cache.h
@@ -43,7 +43,7 @@ const struct cso_blend *
st_cached_blend_state(struct st_context *st,
const struct pipe_blend_state *blend);
-struct pipe_sampler_state *
+const struct cso_sampler *
st_cached_sampler_state(struct st_context *st,
const struct pipe_sampler_state *sampler);
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 95810b7baf1..d814e341575 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -345,6 +345,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* texture sampling state: */
{
struct pipe_sampler_state sampler;
+ const struct cso_sampler *cso;
memset(&sampler, 0, sizeof(sampler));
sampler.wrap_s = PIPE_TEX_WRAP_REPEAT;
sampler.wrap_t = PIPE_TEX_WRAP_REPEAT;
@@ -352,8 +353,8 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
sampler.min_img_filter = PIPE_TEX_FILTER_NEAREST;
sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
sampler.mag_img_filter = PIPE_TEX_FILTER_NEAREST;
- const struct pipe_sampler_state *state = st_cached_sampler_state(ctx->st, &sampler);
- pipe->bind_sampler_state(pipe, unit, state);
+ cso = st_cached_sampler_state(ctx->st, &sampler);
+ pipe->bind_sampler_state(pipe, unit, cso->data);
}
/* viewport state: viewport matching window dims */
@@ -396,7 +397,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
pipe->bind_fs_state(pipe, ctx->st->state.fs->data);
pipe->bind_vs_state(pipe, ctx->st->state.vs->data);
pipe->set_texture_state(pipe, unit, ctx->st->state.texture[unit]);
- pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]);
+ pipe->bind_sampler_state(pipe, unit, ctx->st->state.sampler[unit]->data);
pipe->set_viewport_state(pipe, &ctx->st->state.viewport);
free_mipmap_tree(pipe, mt);
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index b82cf242731..8a57227c84f 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -76,7 +76,7 @@ struct st_context
*/
struct {
const struct cso_blend *blend;
- const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS];
+ const struct cso_sampler *sampler[PIPE_MAX_SAMPLERS];
const struct cso_depth_stencil *depth_stencil;
const struct cso_rasterizer *rasterizer;
const struct cso_fragment_shader *fs;