diff options
author | Roland Scheidegger <[email protected]> | 2010-01-20 18:26:49 +0100 |
---|---|---|
committer | Roland Scheidegger <[email protected]> | 2010-01-20 18:26:49 +0100 |
commit | bef610f693266c338b99511b4d1eea5d5b97644e (patch) | |
tree | bef0799e1011b972727f5c254a09c7abe5ebc748 /src/gallium | |
parent | 5a99ca490fee65d37a4c7469888680b412d27f7f (diff) |
gallium: prepare for per-rendertarget blend enables, writemasks, blend funcs
GL 3.0 (EXT_draw_buffers2) and other APIs allow independent blend enables and
write masks per render target, ARB_draw_buffers_blend (and other APIs) also
allow independent blend functions. Things like dithering, logic ops however
are not extended to be per rendertarget, that might be conceptually possible
however it doesn't look like any API wants to expose this.
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/auxiliary/cso_cache/cso_context.c | 13 | ||||
-rw-r--r-- | src/gallium/include/pipe/p_state.h | 11 |
2 files changed, 16 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/cso_cache/cso_context.c b/src/gallium/auxiliary/cso_cache/cso_context.c index fdfb5faa59e..c8fdfc81248 100644 --- a/src/gallium/auxiliary/cso_cache/cso_context.c +++ b/src/gallium/auxiliary/cso_cache/cso_context.c @@ -310,18 +310,21 @@ void cso_destroy_context( struct cso_context *ctx ) enum pipe_error cso_set_blend(struct cso_context *ctx, const struct pipe_blend_state *templ) { - unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_blend_state)); - struct cso_hash_iter iter = cso_find_state_template(ctx->cache, - hash_key, CSO_BLEND, - (void*)templ); + unsigned key_size, hash_key; + struct cso_hash_iter iter; void *handle; + key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) : + (void *)&(templ->rt[1]) - (void *)templ; + hash_key = cso_construct_key((void*)templ, key_size); + iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ); + if (cso_hash_iter_is_null(iter)) { struct cso_blend *cso = MALLOC(sizeof(struct cso_blend)); if (!cso) return PIPE_ERROR_OUT_OF_MEMORY; - memcpy(&cso->state, templ, sizeof(*templ)); + memcpy(&cso->state, templ, key_size); cso->data = ctx->pipe->create_blend_state(ctx->pipe, &cso->state); cso->delete_state = (cso_state_callback)ctx->pipe->delete_blend_state; cso->context = ctx->pipe; diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h index fdd29ed4492..3c217645ab4 100644 --- a/src/gallium/include/pipe/p_state.h +++ b/src/gallium/include/pipe/p_state.h @@ -217,7 +217,7 @@ struct pipe_depth_stencil_alpha_state }; -struct pipe_blend_state +struct pipe_rt_blend_state { unsigned blend_enable:1; @@ -229,11 +229,16 @@ struct pipe_blend_state unsigned alpha_src_factor:5; /**< PIPE_BLENDFACTOR_x */ unsigned alpha_dst_factor:5; /**< PIPE_BLENDFACTOR_x */ + unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ +}; + +struct pipe_blend_state +{ + unsigned independent_blend_enable:1; unsigned logicop_enable:1; unsigned logicop_func:4; /**< PIPE_LOGICOP_x */ - - unsigned colormask:4; /**< bitmask of PIPE_MASK_R/G/B/A */ unsigned dither:1; + struct pipe_rt_blend_state rt[PIPE_MAX_COLOR_BUFS]; }; |