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:
parent
7761cda686
commit
a3cdc466e7
|
@ -118,22 +118,25 @@ struct nine_shader_variant
|
||||||
{
|
{
|
||||||
struct nine_shader_variant *next;
|
struct nine_shader_variant *next;
|
||||||
void *cso;
|
void *cso;
|
||||||
|
unsigned *const_ranges;
|
||||||
uint64_t key;
|
uint64_t key;
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline void *
|
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)
|
while (list->key != key && list->next)
|
||||||
list = list->next;
|
list = list->next;
|
||||||
if (list->key == key)
|
if (list->key == key) {
|
||||||
|
*const_ranges = list->const_ranges;
|
||||||
return list->cso;
|
return list->cso;
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline boolean
|
static inline boolean
|
||||||
nine_shader_variant_add(struct nine_shader_variant *list,
|
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) {
|
while (list->next) {
|
||||||
assert(list->key != key);
|
assert(list->key != key);
|
||||||
|
@ -145,6 +148,7 @@ nine_shader_variant_add(struct nine_shader_variant *list,
|
||||||
list->next->next = NULL;
|
list->next->next = NULL;
|
||||||
list->next->key = key;
|
list->next->key = key;
|
||||||
list->next->cso = cso;
|
list->next->cso = cso;
|
||||||
|
list->next->const_ranges = const_ranges;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -603,7 +603,7 @@ prepare_vs(struct NineDevice9 *device, uint8_t shader_changed)
|
||||||
|
|
||||||
/* likely because we dislike FF */
|
/* likely because we dislike FF */
|
||||||
if (likely(context->programmable_vs)) {
|
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 {
|
} else {
|
||||||
vs = device->ff.vs;
|
vs = device->ff.vs;
|
||||||
context->cso_shader.vs = vs->ff_cso;
|
context->cso_shader.vs = vs->ff_cso;
|
||||||
|
@ -637,7 +637,7 @@ prepare_ps(struct NineDevice9 *device, uint8_t shader_changed)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (likely(ps)) {
|
if (likely(ps)) {
|
||||||
context->cso_shader.ps = NinePixelShader9_GetVariant(ps);
|
context->cso_shader.ps = NinePixelShader9_GetVariant(ps, &context->cso_shader.ps_const_ranges);
|
||||||
} else {
|
} else {
|
||||||
ps = device->ff.ps;
|
ps = device->ff.ps;
|
||||||
context->cso_shader.ps = ps->ff_cso;
|
context->cso_shader.ps = ps->ff_cso;
|
||||||
|
|
|
@ -239,7 +239,9 @@ struct nine_context {
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
void *vs;
|
void *vs;
|
||||||
|
unsigned *vs_const_ranges;
|
||||||
void *ps;
|
void *ps;
|
||||||
|
unsigned *ps_const_ranges;
|
||||||
} cso_shader;
|
} cso_shader;
|
||||||
|
|
||||||
struct pipe_context *pipe;
|
struct pipe_context *pipe;
|
||||||
|
|
|
@ -79,7 +79,9 @@ NinePixelShader9_ctor( struct NinePixelShader9 *This,
|
||||||
This->byte_code.size = info.byte_size;
|
This->byte_code.size = info.byte_size;
|
||||||
|
|
||||||
This->variant.cso = info.cso;
|
This->variant.cso = info.cso;
|
||||||
|
This->variant.const_ranges = info.const_ranges;
|
||||||
This->last_cso = info.cso;
|
This->last_cso = info.cso;
|
||||||
|
This->last_const_ranges = info.const_ranges;
|
||||||
This->last_key = 0;
|
This->last_key = 0;
|
||||||
|
|
||||||
This->sampler_mask = info.sampler_mask;
|
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)
|
if (This->base.device->context.cso_shader.ps == var->cso)
|
||||||
pipe->bind_fs_state(pipe, NULL);
|
pipe->bind_fs_state(pipe, NULL);
|
||||||
pipe->delete_fs_state(pipe, var->cso);
|
pipe->delete_fs_state(pipe, var->cso);
|
||||||
|
FREE(var->const_ranges);
|
||||||
}
|
}
|
||||||
var = var->next;
|
var = var->next;
|
||||||
} while (var);
|
} while (var);
|
||||||
|
@ -156,7 +159,7 @@ NinePixelShader9_GetFunction( struct NinePixelShader9 *This,
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
|
NinePixelShader9_GetVariant( struct NinePixelShader9 *This, unsigned **const_ranges )
|
||||||
{
|
{
|
||||||
/* GetVariant is called from nine_context, thus we can
|
/* GetVariant is called from nine_context, thus we can
|
||||||
* get pipe directly */
|
* get pipe directly */
|
||||||
|
@ -165,10 +168,12 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
|
||||||
uint64_t key;
|
uint64_t key;
|
||||||
|
|
||||||
key = This->next_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;
|
return This->last_cso;
|
||||||
|
}
|
||||||
|
|
||||||
cso = nine_shader_variant_get(&This->variant, key);
|
cso = nine_shader_variant_get(&This->variant, const_ranges, key);
|
||||||
if (!cso) {
|
if (!cso) {
|
||||||
struct NineDevice9 *device = This->base.device;
|
struct NineDevice9 *device = This->base.device;
|
||||||
struct nine_shader_info info;
|
struct nine_shader_info info;
|
||||||
|
@ -205,12 +210,14 @@ NinePixelShader9_GetVariant( struct NinePixelShader9 *This )
|
||||||
hr = nine_translate_shader(This->base.device, &info, pipe);
|
hr = nine_translate_shader(This->base.device, &info, pipe);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return NULL;
|
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;
|
cso = info.cso;
|
||||||
|
*const_ranges = info.const_ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->last_key = key;
|
This->last_key = key;
|
||||||
This->last_cso = cso;
|
This->last_cso = cso;
|
||||||
|
This->last_const_ranges = *const_ranges;
|
||||||
|
|
||||||
return cso;
|
return cso;
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ struct NinePixelShader9
|
||||||
|
|
||||||
uint64_t last_key;
|
uint64_t last_key;
|
||||||
void *last_cso;
|
void *last_cso;
|
||||||
|
unsigned *last_const_ranges;
|
||||||
|
|
||||||
uint64_t next_key;
|
uint64_t next_key;
|
||||||
};
|
};
|
||||||
|
@ -131,7 +132,7 @@ NinePixelShader9_UpdateKey( struct NinePixelShader9 *ps,
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
NinePixelShader9_GetVariant( struct NinePixelShader9 *ps );
|
NinePixelShader9_GetVariant( struct NinePixelShader9 *ps, unsigned **const_ranges );
|
||||||
|
|
||||||
/*** public ***/
|
/*** public ***/
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,9 @@ NineVertexShader9_ctor( struct NineVertexShader9 *This,
|
||||||
This->byte_code.size = info.byte_size;
|
This->byte_code.size = info.byte_size;
|
||||||
|
|
||||||
This->variant.cso = info.cso;
|
This->variant.cso = info.cso;
|
||||||
|
This->variant.const_ranges = info.const_ranges;
|
||||||
This->last_cso = info.cso;
|
This->last_cso = info.cso;
|
||||||
|
This->last_const_ranges = info.const_ranges;
|
||||||
This->last_key = (uint32_t) (info.swvp_on << 9);
|
This->last_key = (uint32_t) (info.swvp_on << 9);
|
||||||
|
|
||||||
This->const_used_size = info.const_used_size;
|
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)
|
if (This->base.device->context.cso_shader.vs == var->cso)
|
||||||
pipe->bind_vs_state(pipe, NULL);
|
pipe->bind_vs_state(pipe, NULL);
|
||||||
pipe->delete_vs_state(pipe, var->cso);
|
pipe->delete_vs_state(pipe, var->cso);
|
||||||
|
FREE(var->const_ranges);
|
||||||
}
|
}
|
||||||
var = var->next;
|
var = var->next;
|
||||||
} while (var);
|
} while (var);
|
||||||
|
@ -182,7 +185,7 @@ NineVertexShader9_GetFunction( struct NineVertexShader9 *This,
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
|
NineVertexShader9_GetVariant( struct NineVertexShader9 *This, unsigned **const_ranges )
|
||||||
{
|
{
|
||||||
/* GetVariant is called from nine_context, thus we can
|
/* GetVariant is called from nine_context, thus we can
|
||||||
* get pipe directly */
|
* get pipe directly */
|
||||||
|
@ -191,10 +194,12 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
|
||||||
uint64_t key;
|
uint64_t key;
|
||||||
|
|
||||||
key = This->next_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;
|
return This->last_cso;
|
||||||
|
}
|
||||||
|
|
||||||
cso = nine_shader_variant_get(&This->variant, key);
|
cso = nine_shader_variant_get(&This->variant, const_ranges, key);
|
||||||
if (!cso) {
|
if (!cso) {
|
||||||
struct NineDevice9 *device = This->base.device;
|
struct NineDevice9 *device = This->base.device;
|
||||||
struct nine_shader_info info;
|
struct nine_shader_info info;
|
||||||
|
@ -218,12 +223,14 @@ NineVertexShader9_GetVariant( struct NineVertexShader9 *This )
|
||||||
hr = nine_translate_shader(This->base.device, &info, pipe);
|
hr = nine_translate_shader(This->base.device, &info, pipe);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return NULL;
|
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;
|
cso = info.cso;
|
||||||
|
*const_ranges = info.const_ranges;
|
||||||
}
|
}
|
||||||
|
|
||||||
This->last_key = key;
|
This->last_key = key;
|
||||||
This->last_cso = cso;
|
This->last_cso = cso;
|
||||||
|
This->last_const_ranges = *const_ranges;
|
||||||
|
|
||||||
return cso;
|
return cso;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,7 @@ struct NineVertexShader9
|
||||||
|
|
||||||
uint64_t last_key;
|
uint64_t last_key;
|
||||||
void *last_cso;
|
void *last_cso;
|
||||||
|
unsigned *last_const_ranges;
|
||||||
|
|
||||||
uint64_t next_key;
|
uint64_t next_key;
|
||||||
|
|
||||||
|
@ -123,7 +124,7 @@ NineVertexShader9_UpdateKey( struct NineVertexShader9 *vs,
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
NineVertexShader9_GetVariant( struct NineVertexShader9 *vs );
|
NineVertexShader9_GetVariant( struct NineVertexShader9 *vs, unsigned **const_ranges );
|
||||||
|
|
||||||
void *
|
void *
|
||||||
NineVertexShader9_GetVariantProcessVertices( struct NineVertexShader9 *vs,
|
NineVertexShader9_GetVariantProcessVertices( struct NineVertexShader9 *vs,
|
||||||
|
|
Loading…
Reference in New Issue