st/nine: Propagate const_range to context

As with the constant compaction we map the constant
slots to new slots, we need to pass that information
to the context which is in charge of uploading
the constants.

Signed-off-by: Axel Davy <davyaxel0@gmail.com>
This commit is contained in:
Axel Davy 2019-01-21 22:40:25 +01:00
parent 7761cda686
commit a3cdc466e7
7 changed files with 37 additions and 15 deletions

View File

@ -118,22 +118,25 @@ struct nine_shader_variant
{
struct nine_shader_variant *next;
void *cso;
unsigned *const_ranges;
uint64_t key;
};
static inline void *
nine_shader_variant_get(struct nine_shader_variant *list, uint64_t key)
nine_shader_variant_get(struct nine_shader_variant *list, unsigned **const_ranges, uint64_t key)
{
while (list->key != key && list->next)
list = list->next;
if (list->key == key)
if (list->key == key) {
*const_ranges = list->const_ranges;
return list->cso;
}
return NULL;
}
static inline boolean
nine_shader_variant_add(struct nine_shader_variant *list,
uint64_t key, void *cso)
uint64_t key, void *cso, unsigned *const_ranges)
{
while (list->next) {
assert(list->key != key);
@ -145,6 +148,7 @@ nine_shader_variant_add(struct nine_shader_variant *list,
list->next->next = NULL;
list->next->key = key;
list->next->cso = cso;
list->next->const_ranges = const_ranges;
return TRUE;
}

View File

@ -603,7 +603,7 @@ prepare_vs(struct NineDevice9 *device, uint8_t shader_changed)
/* likely because we dislike FF */
if (likely(context->programmable_vs)) {
context->cso_shader.vs = NineVertexShader9_GetVariant(vs);
context->cso_shader.vs = NineVertexShader9_GetVariant(vs, &context->cso_shader.vs_const_ranges);
} else {
vs = device->ff.vs;
context->cso_shader.vs = vs->ff_cso;
@ -637,7 +637,7 @@ prepare_ps(struct NineDevice9 *device, uint8_t shader_changed)
return 0;
if (likely(ps)) {
context->cso_shader.ps = NinePixelShader9_GetVariant(ps);
context->cso_shader.ps = NinePixelShader9_GetVariant(ps, &context->cso_shader.ps_const_ranges);
} else {
ps = device->ff.ps;
context->cso_shader.ps = ps->ff_cso;

View File

@ -239,7 +239,9 @@ struct nine_context {
struct {
void *vs;
unsigned *vs_const_ranges;
void *ps;
unsigned *ps_const_ranges;
} cso_shader;
struct pipe_context *pipe;

View File

@ -79,7 +79,9 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
This->byte_code.size = info.byte_size;
This->variant.cso = info.cso;
This->variant.const_ranges = info.const_ranges;
This->last_cso = info.cso;
This->last_const_ranges = info.const_ranges;
This->last_key = 0;
This->sampler_mask = info.sampler_mask;
@ -116,6 +118,7 @@ NinePixelShader9_dtor( struct NinePixelShader9 *This )
if (This->base.device->context.cso_shader.ps == var->cso)
pipe->bind_fs_state(pipe, NULL);
pipe->delete_fs_state(pipe, var->cso);
FREE(var->const_ranges);
}
var = var->next;
} while (var);
@ -156,7 +159,7 @@ NinePixelShader9_GetFunction( struct NinePixelShader9 *This,
}
void *
NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
NinePixelShader9_GetVariant( struct NinePixelShader9 *This, unsigned **const_ranges )
{
/* GetVariant is called from nine_context, thus we can
* get pipe directly */
@ -165,10 +168,12 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
uint64_t key;
key = This->next_key;
if (key == This->last_key)
if (key == This->last_key) {
*const_ranges = This->last_const_ranges;
return This->last_cso;
}
cso = nine_shader_variant_get(&This->variant, key);
cso = nine_shader_variant_get(&This->variant, const_ranges, key);
if (!cso) {
struct NineDevice9 *device = This->base.device;
struct nine_shader_info info;
@ -205,12 +210,14 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
hr = nine_translate_shader(This->base.device, &info, pipe);
if (FAILED(hr))
return NULL;
nine_shader_variant_add(&This->variant, key, info.cso);
nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
cso = info.cso;
*const_ranges = info.const_ranges;
}
This->last_key = key;
This->last_cso = cso;
This->last_const_ranges = *const_ranges;
return cso;
}

View File

@ -62,6 +62,7 @@ struct NinePixelShader9
uint64_t last_key;
void *last_cso;
unsigned *last_const_ranges;
uint64_t next_key;
};
@ -131,7 +132,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
}
void *
NinePixelShader9_GetVariant( struct NinePixelShader9 *ps );
NinePixelShader9_GetVariant( struct NinePixelShader9 *ps, unsigned **const_ranges );
/*** public ***/

View File

@ -94,7 +94,9 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
This->byte_code.size = info.byte_size;
This->variant.cso = info.cso;
This->variant.const_ranges = info.const_ranges;
This->last_cso = info.cso;
This->last_const_ranges = info.const_ranges;
This->last_key = (uint32_t) (info.swvp_on << 9);
This->const_used_size = info.const_used_size;
@ -133,6 +135,7 @@ NineVertexShader9_dtor( struct NineVertexShader9 *This )
if (This->base.device->context.cso_shader.vs == var->cso)
pipe->bind_vs_state(pipe, NULL);
pipe->delete_vs_state(pipe, var->cso);
FREE(var->const_ranges);
}
var = var->next;
} while (var);
@ -182,7 +185,7 @@ NineVertexShader9_GetFunction( struct NineVertexShader9 *This,
}
void *
NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
NineVertexShader9_GetVariant( struct NineVertexShader9 *This, unsigned **const_ranges )
{
/* GetVariant is called from nine_context, thus we can
* get pipe directly */
@ -191,10 +194,12 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
uint64_t key;
key = This->next_key;
if (key == This->last_key)
if (key == This->last_key) {
*const_ranges = This->last_const_ranges;
return This->last_cso;
}
cso = nine_shader_variant_get(&This->variant, key);
cso = nine_shader_variant_get(&This->variant, const_ranges, key);
if (!cso) {
struct NineDevice9 *device = This->base.device;
struct nine_shader_info info;
@ -218,12 +223,14 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
hr = nine_translate_shader(This->base.device, &info, pipe);
if (FAILED(hr))
return NULL;
nine_shader_variant_add(&This->variant, key, info.cso);
nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
cso = info.cso;
*const_ranges = info.const_ranges;
}
This->last_key = key;
This->last_cso = cso;
This->last_const_ranges = *const_ranges;
return cso;
}

View File

@ -72,6 +72,7 @@ struct NineVertexShader9
uint64_t last_key;
void *last_cso;
unsigned *last_const_ranges;
uint64_t next_key;
@ -123,7 +124,7 @@ NineVertexShader9_UpdateKey( struct NineVertexShader9 *vs,
}
void *
NineVertexShader9_GetVariant( struct NineVertexShader9 *vs );
NineVertexShader9_GetVariant( struct NineVertexShader9 *vs, unsigned **const_ranges );
void *
NineVertexShader9_GetVariantProcessVertices( struct NineVertexShader9 *vs,