diff options
Diffstat (limited to 'src/gallium/drivers/softpipe')
-rw-r--r-- | src/gallium/drivers/softpipe/sp_context.c | 36 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_context.h | 4 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_flush.c | 2 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_derived.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_state_sampler.c | 63 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.c | 41 | ||||
-rw-r--r-- | src/gallium/drivers/softpipe/sp_tex_sample.h | 8 |
7 files changed, 79 insertions, 83 deletions
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index f3489c1c793..fe54f92addf 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -91,10 +91,17 @@ softpipe_destroy( struct pipe_context *pipe ) if (softpipe->draw) draw_destroy( softpipe->draw ); - softpipe->quad.shade->destroy( softpipe->quad.shade ); - softpipe->quad.depth_test->destroy( softpipe->quad.depth_test ); - softpipe->quad.blend->destroy( softpipe->quad.blend ); - softpipe->quad.pstipple->destroy( softpipe->quad.pstipple ); + if (softpipe->quad.shade) + softpipe->quad.shade->destroy( softpipe->quad.shade ); + + if (softpipe->quad.depth_test) + softpipe->quad.depth_test->destroy( softpipe->quad.depth_test ); + + if (softpipe->quad.blend) + softpipe->quad.blend->destroy( softpipe->quad.blend ); + + if (softpipe->quad.pstipple) + softpipe->quad.pstipple->destroy( softpipe->quad.pstipple ); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { sp_destroy_tile_cache(softpipe->cbuf_cache[i]); @@ -105,8 +112,8 @@ softpipe_destroy( struct pipe_context *pipe ) pipe_surface_reference(&softpipe->framebuffer.zsbuf, NULL); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - sp_destroy_tex_tile_cache(softpipe->tex_cache[i]); - pipe_sampler_view_reference(&softpipe->sampler_views[i], NULL); + sp_destroy_tex_tile_cache(softpipe->fragment_tex_cache[i]); + pipe_sampler_view_reference(&softpipe->fragment_sampler_views[i], NULL); } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { @@ -174,8 +181,8 @@ softpipe_is_resource_referenced( struct pipe_context *pipe, /* check if any of the tex_cache textures are this texture */ for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - if (softpipe->tex_cache[i] && - softpipe->tex_cache[i]->texture == texture) + if (softpipe->fragment_tex_cache[i] && + softpipe->fragment_tex_cache[i]->texture == texture) return PIPE_REFERENCED_FOR_READ; } for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { @@ -262,13 +269,22 @@ softpipe_create_context( struct pipe_screen *screen, softpipe->cbuf_cache[i] = sp_create_tile_cache( &softpipe->pipe ); softpipe->zsbuf_cache = sp_create_tile_cache( &softpipe->pipe ); - for (i = 0; i < PIPE_MAX_SAMPLERS; i++) - softpipe->tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); + for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { + softpipe->fragment_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); + if (!softpipe->fragment_tex_cache[i]) + goto fail; + } + for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { softpipe->vertex_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); + if (!softpipe->vertex_tex_cache[i]) + goto fail; } + for (i = 0; i < PIPE_MAX_GEOMETRY_SAMPLERS; i++) { softpipe->geometry_tex_cache[i] = sp_create_tex_tile_cache( &softpipe->pipe ); + if (!softpipe->geometry_tex_cache[i]) + goto fail; } softpipe->fs_machine = tgsi_exec_machine_create(); diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 903574b7e19..035d712d17c 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -77,7 +77,7 @@ struct softpipe_context { struct pipe_framebuffer_state framebuffer; struct pipe_poly_stipple poly_stipple; struct pipe_scissor_state scissor; - struct pipe_sampler_view *sampler_views[PIPE_MAX_SAMPLERS]; + struct pipe_sampler_view *fragment_sampler_views[PIPE_MAX_SAMPLERS]; struct pipe_sampler_view *vertex_sampler_views[PIPE_MAX_VERTEX_SAMPLERS]; struct pipe_sampler_view *geometry_sampler_views[PIPE_MAX_GEOMETRY_SAMPLERS]; struct pipe_viewport_state viewport; @@ -174,7 +174,7 @@ struct softpipe_context { struct softpipe_tile_cache *zsbuf_cache; unsigned tex_timestamp; - struct softpipe_tex_tile_cache *tex_cache[PIPE_MAX_SAMPLERS]; + struct softpipe_tex_tile_cache *fragment_tex_cache[PIPE_MAX_SAMPLERS]; struct softpipe_tex_tile_cache *vertex_tex_cache[PIPE_MAX_VERTEX_SAMPLERS]; struct softpipe_tex_tile_cache *geometry_tex_cache[PIPE_MAX_GEOMETRY_SAMPLERS]; diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index 4258395063b..d422cb17a4b 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -52,7 +52,7 @@ softpipe_flush( struct pipe_context *pipe, if (flags & PIPE_FLUSH_TEXTURE_CACHE) { for (i = 0; i < softpipe->num_sampler_views; i++) { - sp_flush_tex_tile_cache(softpipe->tex_cache[i]); + sp_flush_tex_tile_cache(softpipe->fragment_tex_cache[i]); } for (i = 0; i < softpipe->num_vertex_sampler_views; i++) { sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]); diff --git a/src/gallium/drivers/softpipe/sp_state_derived.c b/src/gallium/drivers/softpipe/sp_state_derived.c index bf4c12701af..f9590eb0b24 100644 --- a/src/gallium/drivers/softpipe/sp_state_derived.c +++ b/src/gallium/drivers/softpipe/sp_state_derived.c @@ -200,8 +200,8 @@ update_tgsi_samplers( struct softpipe_context *softpipe ) softpipe_reset_sampler_variants( softpipe ); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { - struct softpipe_tex_tile_cache *tc = softpipe->tex_cache[i]; - if (tc->texture) { + struct softpipe_tex_tile_cache *tc = softpipe->fragment_tex_cache[i]; + if (tc && tc->texture) { struct softpipe_resource *spt = softpipe_resource(tc->texture); if (spt->timestamp != tc->timestamp) { sp_tex_tile_cache_validate_texture( tc ); @@ -216,7 +216,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe ) for (i = 0; i < PIPE_MAX_VERTEX_SAMPLERS; i++) { struct softpipe_tex_tile_cache *tc = softpipe->vertex_tex_cache[i]; - if (tc->texture) { + if (tc && tc->texture) { struct softpipe_resource *spt = softpipe_resource(tc->texture); if (spt->timestamp != tc->timestamp) { @@ -229,7 +229,7 @@ update_tgsi_samplers( struct softpipe_context *softpipe ) for (i = 0; i < PIPE_MAX_GEOMETRY_SAMPLERS; i++) { struct softpipe_tex_tile_cache *tc = softpipe->geometry_tex_cache[i]; - if (tc->texture) { + if (tc && tc->texture) { struct softpipe_resource *spt = softpipe_resource(tc->texture); if (spt->timestamp != tc->timestamp) { diff --git a/src/gallium/drivers/softpipe/sp_state_sampler.c b/src/gallium/drivers/softpipe/sp_state_sampler.c index cfa211b60a0..38943563800 100644 --- a/src/gallium/drivers/softpipe/sp_state_sampler.c +++ b/src/gallium/drivers/softpipe/sp_state_sampler.c @@ -67,8 +67,8 @@ softpipe_create_sampler_state(struct pipe_context *pipe, static void -softpipe_bind_sampler_states(struct pipe_context *pipe, - unsigned num, void **sampler) +softpipe_bind_fragment_sampler_states(struct pipe_context *pipe, + unsigned num, void **sampler) { struct softpipe_context *softpipe = softpipe_context(pipe); unsigned i; @@ -181,9 +181,9 @@ softpipe_sampler_view_destroy(struct pipe_context *pipe, static void -softpipe_set_sampler_views(struct pipe_context *pipe, - unsigned num, - struct pipe_sampler_view **views) +softpipe_set_fragment_sampler_views(struct pipe_context *pipe, + unsigned num, + struct pipe_sampler_view **views) { struct softpipe_context *softpipe = softpipe_context(pipe); uint i; @@ -192,7 +192,8 @@ softpipe_set_sampler_views(struct pipe_context *pipe, /* Check for no-op */ if (num == softpipe->num_sampler_views && - !memcmp(softpipe->sampler_views, views, num * sizeof(struct pipe_sampler_view *))) + !memcmp(softpipe->fragment_sampler_views, views, + num * sizeof(struct pipe_sampler_view *))) return; draw_flush(softpipe->draw); @@ -200,8 +201,8 @@ softpipe_set_sampler_views(struct pipe_context *pipe, for (i = 0; i < PIPE_MAX_SAMPLERS; i++) { struct pipe_sampler_view *view = i < num ? views[i] : NULL; - pipe_sampler_view_reference(&softpipe->sampler_views[i], view); - sp_tex_tile_cache_set_sampler_view(softpipe->tex_cache[i], view); + pipe_sampler_view_reference(&softpipe->fragment_sampler_views[i], view); + sp_tex_tile_cache_set_sampler_view(softpipe->fragment_tex_cache[i], view); } softpipe->num_sampler_views = num; @@ -290,10 +291,9 @@ static struct sp_sampler_variant * get_sampler_variant( unsigned unit, struct sp_sampler *sampler, struct pipe_sampler_view *view, - struct pipe_resource *resource, unsigned processor ) { - struct softpipe_resource *sp_texture = softpipe_resource(resource); + struct softpipe_resource *sp_texture = softpipe_resource(view->texture); struct sp_sampler_variant *v = NULL; union sp_sampler_key key; @@ -343,68 +343,47 @@ softpipe_reset_sampler_variants(struct softpipe_context *softpipe) */ for (i = 0; i <= softpipe->vs->max_sampler; i++) { if (softpipe->vertex_samplers[i]) { - struct pipe_resource *texture = NULL; - - if (softpipe->vertex_sampler_views[i]) { - texture = softpipe->vertex_sampler_views[i]->texture; - } - softpipe->tgsi.vert_samplers_list[i] = get_sampler_variant( i, sp_sampler(softpipe->vertex_samplers[i]), softpipe->vertex_sampler_views[i], - texture, TGSI_PROCESSOR_VERTEX ); - sp_sampler_variant_bind_texture( softpipe->tgsi.vert_samplers_list[i], - softpipe->vertex_tex_cache[i], - texture ); + sp_sampler_variant_bind_view( softpipe->tgsi.vert_samplers_list[i], + softpipe->vertex_tex_cache[i], + softpipe->vertex_sampler_views[i] ); } } if (softpipe->gs) { for (i = 0; i <= softpipe->gs->max_sampler; i++) { if (softpipe->geometry_samplers[i]) { - struct pipe_resource *texture = NULL; - - if (softpipe->geometry_sampler_views[i]) { - texture = softpipe->geometry_sampler_views[i]->texture; - } - softpipe->tgsi.geom_samplers_list[i] = get_sampler_variant( i, sp_sampler(softpipe->geometry_samplers[i]), softpipe->geometry_sampler_views[i], - texture, TGSI_PROCESSOR_GEOMETRY ); - sp_sampler_variant_bind_texture( + sp_sampler_variant_bind_view( softpipe->tgsi.geom_samplers_list[i], softpipe->geometry_tex_cache[i], - texture ); + softpipe->geometry_sampler_views[i] ); } } } for (i = 0; i <= softpipe->fs->info.file_max[TGSI_FILE_SAMPLER]; i++) { if (softpipe->sampler[i]) { - struct pipe_resource *texture = NULL; - - if (softpipe->sampler_views[i]) { - texture = softpipe->sampler_views[i]->texture; - } - softpipe->tgsi.frag_samplers_list[i] = get_sampler_variant( i, sp_sampler(softpipe->sampler[i]), - softpipe->sampler_views[i], - texture, + softpipe->fragment_sampler_views[i], TGSI_PROCESSOR_FRAGMENT ); - sp_sampler_variant_bind_texture( softpipe->tgsi.frag_samplers_list[i], - softpipe->tex_cache[i], - texture ); + sp_sampler_variant_bind_view( softpipe->tgsi.frag_samplers_list[i], + softpipe->fragment_tex_cache[i], + softpipe->fragment_sampler_views[i] ); } } } @@ -429,12 +408,12 @@ void softpipe_init_sampler_funcs(struct pipe_context *pipe) { pipe->create_sampler_state = softpipe_create_sampler_state; - pipe->bind_fragment_sampler_states = softpipe_bind_sampler_states; + pipe->bind_fragment_sampler_states = softpipe_bind_fragment_sampler_states; pipe->bind_vertex_sampler_states = softpipe_bind_vertex_sampler_states; pipe->bind_geometry_sampler_states = softpipe_bind_geometry_sampler_states; pipe->delete_sampler_state = softpipe_delete_sampler_state; - pipe->set_fragment_sampler_views = softpipe_set_sampler_views; + pipe->set_fragment_sampler_views = softpipe_set_fragment_sampler_views; pipe->set_vertex_sampler_views = softpipe_set_vertex_sampler_views; pipe->set_geometry_sampler_views = softpipe_set_geometry_sampler_views; diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.c b/src/gallium/drivers/softpipe/sp_tex_sample.c index cbc40d4b446..242c27c7ebd 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.c +++ b/src/gallium/drivers/softpipe/sp_tex_sample.c @@ -550,7 +550,7 @@ compute_lambda_1d(const struct sp_sampler_variant *samp, const float t[QUAD_SIZE], const float p[QUAD_SIZE]) { - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float rho = MAX2(dsdx, dsdy) * texture->width0; @@ -565,7 +565,7 @@ compute_lambda_2d(const struct sp_sampler_variant *samp, const float t[QUAD_SIZE], const float p[QUAD_SIZE]) { - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]); @@ -584,7 +584,7 @@ compute_lambda_3d(const struct sp_sampler_variant *samp, const float t[QUAD_SIZE], const float p[QUAD_SIZE]) { - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; float dsdx = fabsf(s[QUAD_BOTTOM_RIGHT] - s[QUAD_BOTTOM_LEFT]); float dsdy = fabsf(s[QUAD_TOP_LEFT] - s[QUAD_BOTTOM_LEFT]); float dtdx = fabsf(t[QUAD_BOTTOM_RIGHT] - t[QUAD_BOTTOM_LEFT]); @@ -654,7 +654,7 @@ static INLINE const float * get_texel_2d(const struct sp_sampler_variant *samp, union tex_tile_address addr, int x, int y) { - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level = addr.bits.level; if (x < 0 || x >= (int) u_minify(texture->width0, level) || @@ -747,7 +747,7 @@ static INLINE const float * get_texel_3d(const struct sp_sampler_variant *samp, union tex_tile_address addr, int x, int y, int z) { - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level = addr.bits.level; if (x < 0 || x >= (int) u_minify(texture->width0, level) || @@ -959,7 +959,7 @@ img_filter_1d_nearest(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width; int x[4]; @@ -999,7 +999,7 @@ img_filter_2d_nearest(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width, height; int x[4], y[4]; @@ -1051,7 +1051,7 @@ img_filter_cube_nearest(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; const unsigned *faces = samp->faces; /* zero when not cube-mapping */ unsigned level0, j; int width, height; @@ -1095,7 +1095,7 @@ img_filter_3d_nearest(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width, height, depth; int x[4], y[4], z[4]; @@ -1137,7 +1137,7 @@ img_filter_1d_linear(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width; int x0[4], x1[4]; @@ -1177,7 +1177,7 @@ img_filter_2d_linear(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width, height; int x0[4], y0[4], x1[4], y1[4]; @@ -1224,7 +1224,7 @@ img_filter_cube_linear(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; const unsigned *faces = samp->faces; /* zero when not cube-mapping */ unsigned level0, j; int width, height; @@ -1273,7 +1273,7 @@ img_filter_3d_linear(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { const struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; unsigned level0, j; int width, height, depth; int x0[4], x1[4], y0[4], y1[4], z0[4], z1[4]; @@ -1349,7 +1349,7 @@ mip_filter_linear(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; int level0; float lambda; float lod[QUAD_SIZE]; @@ -1416,7 +1416,7 @@ mip_filter_nearest(struct tgsi_sampler *tgsi_sampler, float rgba[NUM_CHANNELS][QUAD_SIZE]) { struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; float lambda; float lod[QUAD_SIZE]; @@ -1500,7 +1500,7 @@ mip_filter_linear_2d_linear_repeat_POT( float rgba[NUM_CHANNELS][QUAD_SIZE]) { struct sp_sampler_variant *samp = sp_sampler_variant(tgsi_sampler); - const struct pipe_resource *texture = samp->texture; + const struct pipe_resource *texture = samp->view->texture; int level0; float lambda; float lod[QUAD_SIZE]; @@ -1990,13 +1990,14 @@ get_img_filter(const union sp_sampler_key key, * Bind the given texture object and texture cache to the sampler variant. */ void -sp_sampler_variant_bind_texture( struct sp_sampler_variant *samp, - struct softpipe_tex_tile_cache *tex_cache, - const struct pipe_resource *texture ) +sp_sampler_variant_bind_view( struct sp_sampler_variant *samp, + struct softpipe_tex_tile_cache *tex_cache, + const struct pipe_sampler_view *view ) { const struct pipe_sampler_state *sampler = samp->sampler; + const struct pipe_resource *texture = view->texture; - samp->texture = texture; + samp->view = view; samp->cache = tex_cache; samp->xpot = util_unsigned_logbase2( texture->width0 ); samp->ypot = util_unsigned_logbase2( texture->height0 ); diff --git a/src/gallium/drivers/softpipe/sp_tex_sample.h b/src/gallium/drivers/softpipe/sp_tex_sample.h index ed99006ab02..f0b867edc6e 100644 --- a/src/gallium/drivers/softpipe/sp_tex_sample.h +++ b/src/gallium/drivers/softpipe/sp_tex_sample.h @@ -89,7 +89,7 @@ struct sp_sampler_variant /* Currently bound texture: */ - const struct pipe_resource *texture; + const struct pipe_sampler_view *view; struct softpipe_tex_tile_cache *cache; unsigned processor; @@ -132,9 +132,9 @@ struct sp_sampler_variant * sp_create_sampler_variant( const struct pipe_sampler_state *sampler, const union sp_sampler_key key ); -void sp_sampler_variant_bind_texture( struct sp_sampler_variant *variant, - struct softpipe_tex_tile_cache *tex_cache, - const struct pipe_resource *tex ); +void sp_sampler_variant_bind_view( struct sp_sampler_variant *variant, + struct softpipe_tex_tile_cache *tex_cache, + const struct pipe_sampler_view *view ); void sp_sampler_variant_destroy( struct sp_sampler_variant * ); |