gallium: fix blend state cso
if independent blend state was disabled, only the data from first rt was stored, however the comparison used the full state, hence there never was a match and always a new object was created. Fixes a huge performance drop with llvmpipe due to recompilation.
This commit is contained in:
parent
b8d4cbd7e2
commit
847ac8ec5f
|
@ -113,26 +113,6 @@ static struct cso_hash *_cso_hash_for_type(struct cso_cache *sc, enum cso_cache_
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _cso_size_for_type(enum cso_cache_type type)
|
|
||||||
{
|
|
||||||
switch(type) {
|
|
||||||
case CSO_BLEND:
|
|
||||||
return sizeof(struct pipe_blend_state);
|
|
||||||
case CSO_SAMPLER:
|
|
||||||
return sizeof(struct pipe_sampler_state);
|
|
||||||
case CSO_DEPTH_STENCIL_ALPHA:
|
|
||||||
return sizeof(struct pipe_depth_stencil_alpha_state);
|
|
||||||
case CSO_RASTERIZER:
|
|
||||||
return sizeof(struct pipe_rasterizer_state);
|
|
||||||
case CSO_FRAGMENT_SHADER:
|
|
||||||
return sizeof(struct pipe_shader_state);
|
|
||||||
case CSO_VERTEX_SHADER:
|
|
||||||
return sizeof(struct pipe_shader_state);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void delete_blend_state(void *state, void *data)
|
static void delete_blend_state(void *state, void *data)
|
||||||
{
|
{
|
||||||
struct cso_blend *cso = (struct cso_blend *)state;
|
struct cso_blend *cso = (struct cso_blend *)state;
|
||||||
|
@ -282,10 +262,9 @@ void *cso_hash_find_data_from_template( struct cso_hash *hash,
|
||||||
|
|
||||||
struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
|
struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
|
||||||
unsigned hash_key, enum cso_cache_type type,
|
unsigned hash_key, enum cso_cache_type type,
|
||||||
void *templ)
|
void *templ, unsigned size)
|
||||||
{
|
{
|
||||||
struct cso_hash_iter iter = cso_find_state(sc, hash_key, type);
|
struct cso_hash_iter iter = cso_find_state(sc, hash_key, type);
|
||||||
int size = _cso_size_for_type(type);
|
|
||||||
while (!cso_hash_iter_is_null(iter)) {
|
while (!cso_hash_iter_is_null(iter)) {
|
||||||
void *iter_data = cso_hash_iter_data(iter);
|
void *iter_data = cso_hash_iter_data(iter);
|
||||||
if (!memcmp(iter_data, templ, size))
|
if (!memcmp(iter_data, templ, size))
|
||||||
|
|
|
@ -160,7 +160,7 @@ struct cso_hash_iter cso_find_state(struct cso_cache *sc,
|
||||||
unsigned hash_key, enum cso_cache_type type);
|
unsigned hash_key, enum cso_cache_type type);
|
||||||
struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
|
struct cso_hash_iter cso_find_state_template(struct cso_cache *sc,
|
||||||
unsigned hash_key, enum cso_cache_type type,
|
unsigned hash_key, enum cso_cache_type type,
|
||||||
void *templ);
|
void *templ, unsigned size);
|
||||||
void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
|
void cso_for_each_state(struct cso_cache *sc, enum cso_cache_type type,
|
||||||
cso_state_callback func, void *user_data);
|
cso_state_callback func, void *user_data);
|
||||||
void * cso_take_state(struct cso_cache *sc, unsigned hash_key,
|
void * cso_take_state(struct cso_cache *sc, unsigned hash_key,
|
||||||
|
|
|
@ -317,7 +317,7 @@ enum pipe_error cso_set_blend(struct cso_context *ctx,
|
||||||
key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) :
|
key_size = templ->independent_blend_enable ? sizeof(struct pipe_blend_state) :
|
||||||
(char *)&(templ->rt[1]) - (char *)templ;
|
(char *)&(templ->rt[1]) - (char *)templ;
|
||||||
hash_key = cso_construct_key((void*)templ, key_size);
|
hash_key = cso_construct_key((void*)templ, key_size);
|
||||||
iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ);
|
iter = cso_find_state_template(ctx->cache, hash_key, CSO_BLEND, (void*)templ, key_size);
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
struct cso_blend *cso = MALLOC(sizeof(struct cso_blend));
|
struct cso_blend *cso = MALLOC(sizeof(struct cso_blend));
|
||||||
|
@ -372,10 +372,11 @@ enum pipe_error cso_single_sampler(struct cso_context *ctx,
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
|
|
||||||
if (templ != NULL) {
|
if (templ != NULL) {
|
||||||
unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
|
unsigned key_size = sizeof(struct pipe_sampler_state);
|
||||||
|
unsigned hash_key = cso_construct_key((void*)templ, key_size);
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key, CSO_SAMPLER,
|
hash_key, CSO_SAMPLER,
|
||||||
(void*)templ);
|
(void*)templ, key_size);
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
|
struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
|
||||||
|
@ -412,10 +413,11 @@ cso_single_vertex_sampler(struct cso_context *ctx,
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
|
|
||||||
if (templ != NULL) {
|
if (templ != NULL) {
|
||||||
unsigned hash_key = cso_construct_key((void*)templ, sizeof(struct pipe_sampler_state));
|
unsigned key_size = sizeof(struct pipe_sampler_state);
|
||||||
|
unsigned hash_key = cso_construct_key((void*)templ, key_size);
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key, CSO_SAMPLER,
|
hash_key, CSO_SAMPLER,
|
||||||
(void*)templ);
|
(void*)templ, key_size);
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
|
struct cso_sampler *cso = MALLOC(sizeof(struct cso_sampler));
|
||||||
|
@ -701,12 +703,12 @@ cso_restore_vertex_sampler_textures(struct cso_context *ctx)
|
||||||
enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
|
enum pipe_error cso_set_depth_stencil_alpha(struct cso_context *ctx,
|
||||||
const struct pipe_depth_stencil_alpha_state *templ)
|
const struct pipe_depth_stencil_alpha_state *templ)
|
||||||
{
|
{
|
||||||
unsigned hash_key = cso_construct_key((void*)templ,
|
unsigned key_size = sizeof(struct pipe_depth_stencil_alpha_state);
|
||||||
sizeof(struct pipe_depth_stencil_alpha_state));
|
unsigned hash_key = cso_construct_key((void*)templ, key_size);
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key,
|
hash_key,
|
||||||
CSO_DEPTH_STENCIL_ALPHA,
|
CSO_DEPTH_STENCIL_ALPHA,
|
||||||
(void*)templ);
|
(void*)templ, key_size);
|
||||||
void *handle;
|
void *handle;
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
|
@ -758,11 +760,11 @@ void cso_restore_depth_stencil_alpha(struct cso_context *ctx)
|
||||||
enum pipe_error cso_set_rasterizer(struct cso_context *ctx,
|
enum pipe_error cso_set_rasterizer(struct cso_context *ctx,
|
||||||
const struct pipe_rasterizer_state *templ)
|
const struct pipe_rasterizer_state *templ)
|
||||||
{
|
{
|
||||||
unsigned hash_key = cso_construct_key((void*)templ,
|
unsigned key_size = sizeof(struct pipe_rasterizer_state);
|
||||||
sizeof(struct pipe_rasterizer_state));
|
unsigned hash_key = cso_construct_key((void*)templ, key_size);
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key, CSO_RASTERIZER,
|
hash_key, CSO_RASTERIZER,
|
||||||
(void*)templ);
|
(void*)templ, key_size);
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
|
@ -844,7 +846,8 @@ enum pipe_error cso_set_fragment_shader(struct cso_context *ctx,
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key,
|
hash_key,
|
||||||
CSO_FRAGMENT_SHADER,
|
CSO_FRAGMENT_SHADER,
|
||||||
(void*)tokens);
|
(void*)tokens,
|
||||||
|
sizeof(*templ)); /* XXX correct? tokens_size? */
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
|
@ -923,7 +926,8 @@ enum pipe_error cso_set_vertex_shader(struct cso_context *ctx,
|
||||||
sizeof(struct pipe_shader_state));
|
sizeof(struct pipe_shader_state));
|
||||||
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
struct cso_hash_iter iter = cso_find_state_template(ctx->cache,
|
||||||
hash_key, CSO_VERTEX_SHADER,
|
hash_key, CSO_VERTEX_SHADER,
|
||||||
(void*)templ);
|
(void*)templ,
|
||||||
|
sizeof(*templ));
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
|
|
||||||
if (cso_hash_iter_is_null(iter)) {
|
if (cso_hash_iter_is_null(iter)) {
|
||||||
|
|
Loading…
Reference in New Issue