summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c16
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h23
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_fs.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_quad_stencil.c20
-rw-r--r--src/mesa/pipe/softpipe/sp_state.h33
-rw-r--r--src/mesa/pipe/softpipe/sp_state_derived.c2
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c35
-rw-r--r--src/mesa/pipe/softpipe/sp_tile_cache.c17
8 files changed, 89 insertions, 58 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index b6995b8a6c..c7af63cc2d 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -127,6 +127,8 @@ softpipe_unmap_surfaces(struct softpipe_context *sp)
static void softpipe_destroy( struct pipe_context *pipe )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
+ struct pipe_winsys *ws = pipe->winsys;
+ uint i;
draw_destroy( softpipe->draw );
@@ -143,6 +145,20 @@ static void softpipe_destroy( struct pipe_context *pipe )
softpipe->quad.colormask->destroy( softpipe->quad.colormask );
softpipe->quad.output->destroy( softpipe->quad.output );
+ for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
+ sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
+ sp_destroy_tile_cache(softpipe->zbuf_cache);
+ sp_destroy_tile_cache(softpipe->sbuf_cache_sep);
+
+ for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
+ sp_destroy_tile_cache(softpipe->tex_cache[i]);
+
+ for (i = 0; i < Elements(softpipe->constants); i++) {
+ if (softpipe->constants[i].buffer) {
+ ws->buffer_reference(ws, &softpipe->constants[i].buffer, NULL);
+ }
+ }
+
FREE( softpipe );
}
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index 8f14dd11d1..394baf0109 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -43,29 +43,10 @@ struct softpipe_winsys;
struct draw_context;
struct draw_stage;
struct softpipe_tile_cache;
+struct sp_fragment_shader_state;
+struct sp_vertex_shader_state;
-#define SP_NEW_VIEWPORT 0x1
-#define SP_NEW_RASTERIZER 0x2
-#define SP_NEW_FS 0x4
-#define SP_NEW_BLEND 0x8
-#define SP_NEW_CLIP 0x10
-#define SP_NEW_SCISSOR 0x20
-#define SP_NEW_STIPPLE 0x40
-#define SP_NEW_FRAMEBUFFER 0x80
-#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
-#define SP_NEW_CONSTANTS 0x200
-#define SP_NEW_SAMPLER 0x400
-#define SP_NEW_TEXTURE 0x800
-#define SP_NEW_VERTEX 0x1000
-#define SP_NEW_VS 0x2000
-#define SP_NEW_QUERY 0x4000
-
-struct sp_vertex_shader_state {
- struct pipe_shader_state *state;
- void *draw_data;
-};
-
struct softpipe_context {
struct pipe_context pipe; /**< base class */
struct softpipe_winsys *winsys; /**< window system interface */
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index 6e7e7eb074..921dfbaccb 100644
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -335,6 +335,7 @@ static void shade_destroy(struct quad_stage *qs)
{
struct quad_shade_stage *qss = (struct quad_shade_stage *) qs;
+ tgsi_exec_machine_free_data(&qss->machine);
FREE( qss->inputs );
FREE( qss->outputs );
FREE( qs );
diff --git a/src/mesa/pipe/softpipe/sp_quad_stencil.c b/src/mesa/pipe/softpipe/sp_quad_stencil.c
index a688a06c74..33740883d3 100644
--- a/src/mesa/pipe/softpipe/sp_quad_stencil.c
+++ b/src/mesa/pipe/softpipe/sp_quad_stencil.c
@@ -208,16 +208,22 @@ stencil_test_quad(struct quad_stage *qs, struct quad_header *quad)
struct softpipe_cached_tile *tile
= sp_get_cached_tile(softpipe, softpipe->sbuf_cache, quad->x0, quad->y0);
uint j;
+ uint face = quad->facing;
+
+ if (!softpipe->depth_stencil->stencil[1].enabled) {
+ /* single-sided stencil test, use front (face=0) state */
+ face = 0;
+ }
/* choose front or back face function, operator, etc */
/* XXX we could do these initializations once per primitive */
- func = softpipe->depth_stencil->stencil[quad->facing].func;
- failOp = softpipe->depth_stencil->stencil[quad->facing].fail_op;
- zFailOp = softpipe->depth_stencil->stencil[quad->facing].zfail_op;
- zPassOp = softpipe->depth_stencil->stencil[quad->facing].zpass_op;
- ref = softpipe->depth_stencil->stencil[quad->facing].ref_value;
- wrtMask = softpipe->depth_stencil->stencil[quad->facing].write_mask;
- valMask = softpipe->depth_stencil->stencil[quad->facing].value_mask;
+ func = softpipe->depth_stencil->stencil[face].func;
+ failOp = softpipe->depth_stencil->stencil[face].fail_op;
+ zFailOp = softpipe->depth_stencil->stencil[face].zfail_op;
+ zPassOp = softpipe->depth_stencil->stencil[face].zpass_op;
+ ref = softpipe->depth_stencil->stencil[face].ref_value;
+ wrtMask = softpipe->depth_stencil->stencil[face].write_mask;
+ valMask = softpipe->depth_stencil->stencil[face].value_mask;
assert(ps); /* shouldn't get here if there's no stencil buffer */
diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h
index 76b79b5280..c1f5555a86 100644
--- a/src/mesa/pipe/softpipe/sp_state.h
+++ b/src/mesa/pipe/softpipe/sp_state.h
@@ -35,13 +35,32 @@
#include "x86/rtasm/x86sse.h"
+
+#define SP_NEW_VIEWPORT 0x1
+#define SP_NEW_RASTERIZER 0x2
+#define SP_NEW_FS 0x4
+#define SP_NEW_BLEND 0x8
+#define SP_NEW_CLIP 0x10
+#define SP_NEW_SCISSOR 0x20
+#define SP_NEW_STIPPLE 0x40
+#define SP_NEW_FRAMEBUFFER 0x80
+#define SP_NEW_DEPTH_STENCIL_ALPHA 0x100
+#define SP_NEW_CONSTANTS 0x200
+#define SP_NEW_SAMPLER 0x400
+#define SP_NEW_TEXTURE 0x800
+#define SP_NEW_VERTEX 0x1000
+#define SP_NEW_VS 0x2000
+#define SP_NEW_QUERY 0x4000
+
+
+
#ifdef MESA_LLVM
struct gallivm_prog;
#endif
-/**
- * Softpipe fs state is derived from pipe_shader_state.
- */
+
+
+/** Subclass of pipe_shader_state */
struct sp_fragment_shader_state {
struct pipe_shader_state shader;
#if defined(__i386__) || defined(__386__)
@@ -53,6 +72,14 @@ struct sp_fragment_shader_state {
};
+/** Subclass of pipe_shader_state */
+struct sp_vertex_shader_state {
+ struct pipe_shader_state shader;
+ void *draw_data;
+};
+
+
+
void *
softpipe_create_blend_state(struct pipe_context *,
const struct pipe_blend_state *);
diff --git a/src/mesa/pipe/softpipe/sp_state_derived.c b/src/mesa/pipe/softpipe/sp_state_derived.c
index a5e766781f..630ae3163f 100644
--- a/src/mesa/pipe/softpipe/sp_state_derived.c
+++ b/src/mesa/pipe/softpipe/sp_state_derived.c
@@ -40,7 +40,7 @@
*/
static void calculate_vertex_layout( struct softpipe_context *softpipe )
{
- const struct pipe_shader_state *vs = softpipe->vs->state;
+ const struct pipe_shader_state *vs = &softpipe->vs->shader;
const struct pipe_shader_state *fs = &softpipe->fs->shader;
const enum interp_mode colorInterp
= softpipe->rasterizer->flatshade ? INTERP_CONSTANT : INTERP_LINEAR;
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
index a360b4f02b..f72a91485f 100644
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ b/src/mesa/pipe/softpipe/sp_state_fs.c
@@ -42,18 +42,20 @@ void * softpipe_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
+ struct sp_fragment_shader_state *state;
/* Decide whether we'll be codegenerating this shader and if so do
* that now.
*/
- struct sp_fragment_shader_state *state = MALLOC( sizeof(struct sp_fragment_shader_state) );
+ state = CALLOC_STRUCT(sp_fragment_shader_state);
+ if (!state)
+ return NULL;
+
state->shader = *templ;
- if( softpipe->dump_fs ) {
- tgsi_dump(
- state->shader.tokens,
- 0 );
+ if (softpipe->dump_fs) {
+ tgsi_dump(state->shader.tokens, 0);
}
#if defined(__i386__) || defined(__386__)
@@ -75,6 +77,7 @@ void * softpipe_create_fs_state(struct pipe_context *pipe,
return state;
}
+
void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -84,6 +87,7 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
softpipe->dirty |= SP_NEW_FS;
}
+
void softpipe_delete_fs_state(struct pipe_context *pipe,
void *shader)
{
@@ -103,22 +107,16 @@ void * softpipe_create_vs_state(struct pipe_context *pipe,
struct softpipe_context *softpipe = softpipe_context(pipe);
struct sp_vertex_shader_state *state;
- state = MALLOC( sizeof(struct sp_vertex_shader_state) );
+ state = CALLOC_STRUCT(sp_vertex_shader_state);
if (state == NULL ) {
return NULL;
}
- state->state = MALLOC( sizeof(struct pipe_shader_state) );
- if (state->state == NULL) {
- FREE( state );
- return NULL;
- }
- memcpy( state->state, templ, sizeof(struct pipe_shader_state) );
+ state->shader = *templ;
state->draw_data = draw_create_vertex_shader(softpipe->draw,
- state->state);
+ &state->shader);
if (state->draw_data == NULL) {
- FREE( state->state );
FREE( state );
return NULL;
}
@@ -126,6 +124,7 @@ void * softpipe_create_vs_state(struct pipe_context *pipe,
return state;
}
+
void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -137,8 +136,8 @@ void softpipe_bind_vs_state(struct pipe_context *pipe, void *vs)
softpipe->dirty |= SP_NEW_VS;
}
-void softpipe_delete_vs_state(struct pipe_context *pipe,
- void *vs)
+
+void softpipe_delete_vs_state(struct pipe_context *pipe, void *vs)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
@@ -146,12 +145,10 @@ void softpipe_delete_vs_state(struct pipe_context *pipe,
(struct sp_vertex_shader_state *)vs;
draw_delete_vertex_shader(softpipe->draw, state->draw_data);
- FREE( state->state );
FREE( state );
}
-
void softpipe_set_constant_buffer(struct pipe_context *pipe,
uint shader, uint index,
const struct pipe_constant_buffer *buf)
@@ -170,5 +167,3 @@ void softpipe_set_constant_buffer(struct pipe_context *pipe,
softpipe->dirty |= SP_NEW_CONSTANTS;
}
-
-
diff --git a/src/mesa/pipe/softpipe/sp_tile_cache.c b/src/mesa/pipe/softpipe/sp_tile_cache.c
index ba1f71b01e..1dbcc5aadd 100644
--- a/src/mesa/pipe/softpipe/sp_tile_cache.c
+++ b/src/mesa/pipe/softpipe/sp_tile_cache.c
@@ -126,9 +126,17 @@ void
sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
{
uint pos;
+
for (pos = 0; pos < NUM_ENTRIES; pos++) {
- assert(tc->entries[pos].x < 0);
+ //assert(tc->entries[pos].x < 0);
+ }
+ if (tc->surface) {
+ pipe_surface_reference(&tc->surface, NULL);
+ }
+ if (tc->tex_surf) {
+ pipe_surface_reference(&tc->tex_surf, NULL);
}
+
FREE( tc );
}
@@ -466,15 +474,12 @@ sp_get_cached_tile_tex(struct pipe_context *pipe,
tc->tex_level != level ||
tc->tex_z != z) {
/* get new surface (view into texture) */
- struct pipe_surface *ps;
if (tc->tex_surf && tc->tex_surf->map)
pipe_surface_unmap(tc->tex_surf);
- ps = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
- pipe_surface_reference(&tc->tex_surf, ps);
-
- pipe_surface_map(ps);
+ tc->tex_surf = pipe->get_tex_surface(pipe, tc->texture, face, level, z);
+ pipe_surface_map(tc->tex_surf);
tc->tex_face = face;
tc->tex_level = level;