diff options
author | Brian Paul <[email protected]> | 2013-09-12 14:59:14 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2013-10-03 14:05:26 -0600 |
commit | 5cba8725a4810c450cb386042a5701c21f2559c8 (patch) | |
tree | 320e54622264a354877b41a41c19ec97f76b1c0e /src/gallium/auxiliary/cso_cache | |
parent | 755d788fe24732127af0997f26e2fb61e5aa6173 (diff) |
cso: use pipe_context::bind_sampler_states() if non-null
Diffstat (limited to 'src/gallium/auxiliary/cso_cache')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index 6805427b816..60c9a9673d5 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -304,9 +304,26 @@ void cso_release_all( struct cso_context *ctx ) if (ctx->pipe) { ctx->pipe->bind_blend_state( ctx->pipe, NULL ); ctx->pipe->bind_rasterizer_state( ctx->pipe, NULL ); - ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL ); - if (ctx->pipe->bind_vertex_sampler_states) - ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL); + + if (ctx->pipe->bind_sampler_states) { + static void *zeros[PIPE_MAX_SAMPLERS] = { NULL }; + struct pipe_screen *scr = ctx->pipe->screen; + unsigned sh; + for (sh = 0; sh < PIPE_SHADER_TYPES; sh++) { + int max = scr->get_shader_param(scr, sh, + PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS); + assert(max <= PIPE_MAX_SAMPLERS); + if (max > 0) { + ctx->pipe->bind_sampler_states(ctx->pipe, sh, 0, max, zeros); + } + } + } + else { + ctx->pipe->bind_fragment_sampler_states( ctx->pipe, 0, NULL ); + if (ctx->pipe->bind_vertex_sampler_states) + ctx->pipe->bind_vertex_sampler_states(ctx->pipe, 0, NULL); + } + ctx->pipe->bind_depth_stencil_alpha_state( ctx->pipe, NULL ); ctx->pipe->bind_fs_state( ctx->pipe, NULL ); ctx->pipe->bind_vs_state( ctx->pipe, NULL ); @@ -1079,24 +1096,30 @@ single_sampler_done(struct cso_context *ctx, unsigned shader_stage) info->nr_samplers * sizeof(void *)); info->hw.nr_samplers = info->nr_samplers; - switch (shader_stage) { - case PIPE_SHADER_FRAGMENT: - ctx->pipe->bind_fragment_sampler_states(ctx->pipe, - info->nr_samplers, - info->samplers); - break; - case PIPE_SHADER_VERTEX: - ctx->pipe->bind_vertex_sampler_states(ctx->pipe, - info->nr_samplers, - info->samplers); - break; - case PIPE_SHADER_GEOMETRY: - ctx->pipe->bind_geometry_sampler_states(ctx->pipe, - info->nr_samplers, - info->samplers); - break; - default: - assert(!"bad shader type in single_sampler_done()"); + if (ctx->pipe->bind_sampler_states) { + ctx->pipe->bind_sampler_states(ctx->pipe, shader_stage, 0, + info->nr_samplers, info->samplers); + } + else { + switch (shader_stage) { + case PIPE_SHADER_FRAGMENT: + ctx->pipe->bind_fragment_sampler_states(ctx->pipe, + info->nr_samplers, + info->samplers); + break; + case PIPE_SHADER_VERTEX: + ctx->pipe->bind_vertex_sampler_states(ctx->pipe, + info->nr_samplers, + info->samplers); + break; + case PIPE_SHADER_GEOMETRY: + ctx->pipe->bind_geometry_sampler_states(ctx->pipe, + info->nr_samplers, + info->samplers); + break; + default: + assert(!"bad shader type in single_sampler_done()"); + } } } } |