struct nine_shader_variant *next;
void *cso;
unsigned *const_ranges;
+ unsigned const_used_size;
uint64_t key;
};
static inline void *
-nine_shader_variant_get(struct nine_shader_variant *list, unsigned **const_ranges, uint64_t key)
+nine_shader_variant_get(struct nine_shader_variant *list,
+ unsigned **const_ranges,
+ unsigned *const_used_size,
+ uint64_t key)
{
while (list->key != key && list->next)
list = list->next;
if (list->key == key) {
*const_ranges = list->const_ranges;
+ *const_used_size = list->const_used_size;
return list->cso;
}
return NULL;
static inline boolean
nine_shader_variant_add(struct nine_shader_variant *list,
- uint64_t key, void *cso, unsigned *const_ranges)
+ uint64_t key, void *cso,
+ unsigned *const_ranges,
+ unsigned const_used_size)
{
while (list->next) {
assert(list->key != key);
list->next->key = key;
list->next->cso = cso;
list->next->const_ranges = const_ranges;
+ list->next->const_used_size = const_used_size;
return TRUE;
}
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
- cb.buffer_size = context->vs->const_used_size;
+ cb.buffer_size = context->cso_shader.vs_const_used_size;
cb.user_buffer = context->vs_const_f;
if (context->swvp) {
struct pipe_constant_buffer cb;
cb.buffer = NULL;
cb.buffer_offset = 0;
- cb.buffer_size = context->ps->const_used_size;
+ cb.buffer_size = context->cso_shader.ps_const_used_size;
cb.user_buffer = context->ps_const_f;
if (context->changed.ps_const_i) {
/* Upload special constants needed to implement PS1.x instructions like TEXBEM,TEXBEML and BEM */
if (context->ps->bumpenvmat_needed) {
- memcpy(context->ps_lconstf_temp, cb.user_buffer, cb.buffer_size);
+ memcpy(context->ps_lconstf_temp, cb.user_buffer, 8 * sizeof(float[4]));
memcpy(&context->ps_lconstf_temp[4 * 8], &device->context.bumpmap_vars, sizeof(device->context.bumpmap_vars));
cb.user_buffer = context->ps_lconstf_temp;
context->rs[D3DRS_FOGENABLE]) {
float *dst = &context->ps_lconstf_temp[4 * 32];
if (cb.user_buffer != context->ps_lconstf_temp) {
- memcpy(context->ps_lconstf_temp, cb.user_buffer, cb.buffer_size);
+ memcpy(context->ps_lconstf_temp, cb.user_buffer, 32 * sizeof(float[4]));
cb.user_buffer = context->ps_lconstf_temp;
}
} else if (context->rs[D3DRS_FOGTABLEMODE] != D3DFOG_NONE) {
dst[4] = asfloat(context->rs[D3DRS_FOGDENSITY]);
}
- cb.buffer_size = 4 * 4 * 34;
}
if (!cb.buffer_size)
/* likely because we dislike FF */
if (likely(context->programmable_vs)) {
- context->cso_shader.vs = NineVertexShader9_GetVariant(vs, &context->cso_shader.vs_const_ranges);
+ context->cso_shader.vs = NineVertexShader9_GetVariant(vs,
+ &context->cso_shader.vs_const_ranges,
+ &context->cso_shader.vs_const_used_size);
} else {
vs = device->ff.vs;
context->cso_shader.vs = vs->ff_cso;
return 0;
if (likely(ps)) {
- context->cso_shader.ps = NinePixelShader9_GetVariant(ps, &context->cso_shader.ps_const_ranges);
+ context->cso_shader.ps = NinePixelShader9_GetVariant(ps,
+ &context->cso_shader.ps_const_ranges,
+ &context->cso_shader.ps_const_used_size);
} else {
ps = device->ff.ps;
context->cso_shader.ps = ps->ff_cso;
struct {
void *vs;
unsigned *vs_const_ranges;
+ unsigned vs_const_used_size;
void *ps;
unsigned *ps_const_ranges;
+ unsigned ps_const_used_size;
} cso_shader;
struct pipe_context *pipe;
This->variant.cso = info.cso;
This->variant.const_ranges = info.const_ranges;
+ This->variant.const_used_size = info.const_used_size;
This->last_cso = info.cso;
This->last_const_ranges = info.const_ranges;
+ This->last_const_used_size = info.const_used_size;
This->last_key = 0;
This->sampler_mask = info.sampler_mask;
This->rt_mask = info.rt_mask;
- This->const_used_size = info.const_used_size;
This->bumpenvmat_needed = info.bumpenvmat_needed;
memcpy(This->int_slots_used, info.int_slots_used, sizeof(This->int_slots_used));
}
void *
-NinePixelShader9_GetVariant( struct NinePixelShader9 *This, unsigned **const_ranges )
+NinePixelShader9_GetVariant( struct NinePixelShader9 *This,
+ unsigned **const_ranges,
+ unsigned *const_used_size )
{
/* GetVariant is called from nine_context, thus we can
* get pipe directly */
key = This->next_key;
if (key == This->last_key) {
*const_ranges = This->last_const_ranges;
+ *const_used_size = This->last_const_used_size;
return This->last_cso;
}
- cso = nine_shader_variant_get(&This->variant, const_ranges, key);
+ cso = nine_shader_variant_get(&This->variant, const_ranges, const_used_size, key);
if (!cso) {
struct NineDevice9 *device = This->base.device;
struct nine_shader_info info;
hr = nine_translate_shader(This->base.device, &info, pipe);
if (FAILED(hr))
return NULL;
- nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
+ nine_shader_variant_add(&This->variant, key, info.cso,
+ info.const_ranges, info.const_used_size);
cso = info.cso;
*const_ranges = info.const_ranges;
+ *const_used_size = info.const_used_size;
}
This->last_key = key;
This->last_cso = cso;
This->last_const_ranges = *const_ranges;
+ This->last_const_used_size = *const_used_size;
return cso;
}
uint8_t version; /* (major << 4) | minor */
} byte_code;
- unsigned const_used_size; /* in bytes */
-
uint8_t bumpenvmat_needed;
uint16_t sampler_mask;
uint8_t rt_mask;
uint64_t last_key;
void *last_cso;
unsigned *last_const_ranges;
+ unsigned last_const_used_size; /* in bytes */
uint64_t next_key;
};
}
void *
-NinePixelShader9_GetVariant( struct NinePixelShader9 *ps, unsigned **const_ranges );
+NinePixelShader9_GetVariant( struct NinePixelShader9 *ps,
+ unsigned **const_ranges,
+ unsigned *const_used_size );
/*** public ***/
This->variant.cso = info.cso;
This->variant.const_ranges = info.const_ranges;
+ This->variant.const_used_size = info.const_used_size;
This->last_cso = info.cso;
This->last_const_ranges = info.const_ranges;
+ This->last_const_used_size = info.const_used_size;
This->last_key = (uint32_t) (info.swvp_on << 9);
- This->const_used_size = info.const_used_size;
This->lconstf = info.lconstf;
This->sampler_mask = info.sampler_mask;
This->position_t = info.position_t;
}
void *
-NineVertexShader9_GetVariant( struct NineVertexShader9 *This, unsigned **const_ranges )
+NineVertexShader9_GetVariant( struct NineVertexShader9 *This,
+ unsigned **const_ranges,
+ unsigned *const_used_size )
{
/* GetVariant is called from nine_context, thus we can
* get pipe directly */
key = This->next_key;
if (key == This->last_key) {
*const_ranges = This->last_const_ranges;
+ *const_used_size = This->last_const_used_size;
return This->last_cso;
}
- cso = nine_shader_variant_get(&This->variant, const_ranges, key);
+ cso = nine_shader_variant_get(&This->variant, const_ranges, const_used_size, key);
if (!cso) {
struct NineDevice9 *device = This->base.device;
struct nine_shader_info info;
hr = nine_translate_shader(This->base.device, &info, pipe);
if (FAILED(hr))
return NULL;
- nine_shader_variant_add(&This->variant, key, info.cso, info.const_ranges);
+ nine_shader_variant_add(&This->variant, key, info.cso,
+ info.const_ranges, info.const_used_size);
cso = info.cso;
*const_ranges = info.const_ranges;
+ *const_used_size = info.const_used_size;
}
This->last_key = key;
This->last_cso = cso;
This->last_const_ranges = *const_ranges;
+ This->last_const_used_size = *const_used_size;
return cso;
}
boolean point_size; /* if true, set rasterizer.point_size_per_vertex to 1 */
boolean swvp_only;
- unsigned const_used_size; /* in bytes */
-
struct nine_lconstf lconstf;
boolean int_slots_used[NINE_MAX_CONST_I];
uint64_t last_key;
void *last_cso;
unsigned *last_const_ranges;
+ unsigned last_const_used_size; /* in bytes */
uint64_t next_key;
}
void *
-NineVertexShader9_GetVariant( struct NineVertexShader9 *vs, unsigned **const_ranges );
+NineVertexShader9_GetVariant( struct NineVertexShader9 *vs,
+ unsigned **const_ranges,
+ unsigned *const_used_size );
void *
NineVertexShader9_GetVariantProcessVertices( struct NineVertexShader9 *vs,