IDirect3DVertexDeclaration9 *pDecl )
{
struct nine_state *state = This->update;
- struct nine_context *context = &This->context;
- BOOL was_programmable_vs = This->state.programmable_vs;
+ struct NineVertexDeclaration9 *vdecl = NineVertexDeclaration9(pDecl);
DBG("This=%p pDecl=%p\n", This, pDecl);
- if (likely(!This->is_recording) && state->vdecl == NineVertexDeclaration9(pDecl))
+ if (unlikely(This->is_recording)) {
+ nine_bind(&state->vdecl, vdecl);
+ state->changed.group |= NINE_STATE_VDECL;
return D3D_OK;
+ }
- nine_bind(&state->vdecl, pDecl);
+ if (state->vdecl == vdecl)
+ return D3D_OK;
- This->state.programmable_vs = This->state.vs && !(This->state.vdecl && This->state.vdecl->position_t);
- if (likely(!This->is_recording) && was_programmable_vs != This->state.programmable_vs) {
- context->commit |= NINE_STATE_COMMIT_CONST_VS;
- state->changed.group |= NINE_STATE_VS;
- }
+ nine_bind(&state->vdecl, vdecl);
- state->changed.group |= NINE_STATE_VDECL;
+ nine_context_set_vertex_declaration(This, vdecl);
return D3D_OK;
}
nine_bind(&state->vs, pShader);
- This->state.programmable_vs = This->state.vs && !(This->state.vdecl && This->state.vdecl->position_t);
+ This->state.programmable_vs = This->state.vs && !(This->context.vdecl && This->context.vdecl->position_t);
/* ff -> non-ff: commit back non-ff constants */
if (!was_programmable_vs && This->state.programmable_vs)
bld.key = &key;
/* FIXME: this shouldn't be NULL, but it is on init */
- if (state->vdecl) {
+ if (context->vdecl) {
key.color0in_one = 1;
key.color1in_zero = 1;
- for (i = 0; i < state->vdecl->nelems; i++) {
- uint16_t usage = state->vdecl->usage_map[i];
+ for (i = 0; i < context->vdecl->nelems; i++) {
+ uint16_t usage = context->vdecl->usage_map[i];
if (usage == NINE_DECLUSAGE_POSITIONT)
key.position_t = 1;
else if (usage == NINE_DECLUSAGE_i(COLOR, 0))
else if (usage % NINE_DECLUSAGE_COUNT == NINE_DECLUSAGE_TEXCOORD) {
s = usage / NINE_DECLUSAGE_COUNT;
if (s < 8)
- input_texture_coord[s] = nine_decltype_get_dim(state->vdecl->decls[i].Type);
+ input_texture_coord[s] = nine_decltype_get_dim(context->vdecl->decls[i].Type);
else
DBG("FF given texture coordinate >= 8. Ignoring\n");
} else if (usage < NINE_DECLUSAGE_NONE)
if (s >= 1)
key.ts[s-1].resultarg = 0;
- key.projected = nine_ff_get_projected_key(state);
+ key.projected = nine_ff_get_projected_key(state, context);
key.specular = !!context->rs[D3DRS_SPECULARENABLE];
for (; s < 8; ++s)
}
static inline uint16_t
-nine_ff_get_projected_key(struct nine_state *state)
+nine_ff_get_projected_key(struct nine_state *state, struct nine_context *context)
{
unsigned s, i;
uint16_t projected = 0;
char input_texture_coord[8];
memset(&input_texture_coord, 0, sizeof(input_texture_coord));
- if (state->vdecl) {
- for (i = 0; i < state->vdecl->nelems; i++) {
- uint16_t usage = state->vdecl->usage_map[i];
+ if (context->vdecl) {
+ for (i = 0; i < context->vdecl->nelems; i++) {
+ uint16_t usage = context->vdecl->usage_map[i];
if (usage % NINE_DECLUSAGE_COUNT == NINE_DECLUSAGE_TEXCOORD) {
s = usage / NINE_DECLUSAGE_COUNT;
if (s < 8)
- input_texture_coord[s] = nine_decltype_get_dim(state->vdecl->decls[i].Type);
+ input_texture_coord[s] = nine_decltype_get_dim(context->vdecl->decls[i].Type);
}
}
}
{
struct nine_state *state = &device->state;
struct nine_context *context = &device->context;
- const struct NineVertexDeclaration9 *vdecl = device->state.vdecl;
+ const struct NineVertexDeclaration9 *vdecl = device->context.vdecl;
const struct NineVertexShader9 *vs;
unsigned n, b, i;
int index;
state->changed.group |= NINE_STATE_STREAMFREQ;
}
+void
+nine_context_set_vertex_declaration(struct NineDevice9 *device,
+ struct NineVertexDeclaration9 *vdecl)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ BOOL was_programmable_vs = device->state.programmable_vs;
+
+ nine_bind(&context->vdecl, vdecl);
+
+ device->state.programmable_vs = device->state.vs && !(device->context.vdecl && device->context.vdecl->position_t);
+ if (was_programmable_vs != device->state.programmable_vs) {
+ context->commit |= NINE_STATE_COMMIT_CONST_VS;
+ state->changed.group |= NINE_STATE_VS;
+ }
+
+ state->changed.group |= NINE_STATE_VDECL;
+}
+
void
nine_context_apply_stateblock(struct NineDevice9 *device,
const struct nine_state *src)
}
context->changed.vtxbuf |= src->changed.vtxbuf;
}
+
+ /* Vertex declaration */
+ if ((src->changed.group & NINE_STATE_VDECL) && src->vdecl)
+ nine_context_set_vertex_declaration(device, src->vdecl);
+
+ device->state.programmable_vs = device->state.vs && !(context->vdecl && context->vdecl->position_t);
}
static void
{
unsigned i;
+ nine_bind(&context->vdecl, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
pipe_resource_reference(&context->vtxbuf[i].buffer, NULL);
uint8_t rt_mask;
+ struct NineVertexDeclaration9 *vdecl;
+
struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
UINT stream_freq[PIPE_MAX_ATTRIBS];
uint32_t stream_instancedata_mask; /* derived from stream_freq */
UINT StreamNumber,
UINT Setting);
+void
+nine_context_set_vertex_declaration(struct NineDevice9 *device,
+ struct NineVertexDeclaration9 *vdecl);
+
void
nine_context_apply_stateblock(struct NineDevice9 *device,
const struct nine_state *src);
key |= ((uint64_t)1) << 34;
if (unlikely(ps->byte_code.version < 0x14)) {
- projected = nine_ff_get_projected_key(state);
+ projected = nine_ff_get_projected_key(state, context);
key |= ((uint64_t) projected) << 48;
}
nine_context_apply_stateblock(device, src);
if ((src->changed.group & NINE_STATE_VDECL) && src->vdecl)
- NineDevice9_SetVertexDeclaration(This->base.device, (IDirect3DVertexDeclaration9 *)src->vdecl);
-
- /* Recomputing it is needed if we changed vs but not vdecl */
- dst->programmable_vs = dst->vs && !(dst->vdecl && dst->vdecl->position_t);
+ nine_bind(&dst->vdecl, src->vdecl);
/* Textures */
if (src->changed.texture) {