IDirect3DIndexBuffer9 *pIndexData )
{
struct nine_state *state = This->update;
+ struct NineIndexBuffer9 *idxbuf = NineIndexBuffer9(pIndexData);
DBG("This=%p pIndexData=%p\n", This, pIndexData);
- if (likely(!This->is_recording))
- if (state->idxbuf == NineIndexBuffer9(pIndexData))
- return D3D_OK;
- nine_bind(&state->idxbuf, pIndexData);
+ if (unlikely(This->is_recording)) {
+ nine_bind(&state->idxbuf, idxbuf);
+ state->changed.group |= NINE_STATE_IDXBUF;
+ return D3D_OK;
+ }
+
+ if (state->idxbuf == idxbuf)
+ return D3D_OK;
+ nine_bind(&state->idxbuf, idxbuf);
- state->changed.group |= NINE_STATE_IDXBUF;
+ nine_context_set_indices(This, idxbuf);
return D3D_OK;
}
commit_index_buffer(struct NineDevice9 *device)
{
struct pipe_context *pipe = device->pipe;
- if (device->state.idxbuf)
- pipe->set_index_buffer(pipe, &device->state.idxbuf->buffer);
+ if (device->context.idxbuf.buffer)
+ pipe->set_index_buffer(pipe, &device->context.idxbuf);
else
pipe->set_index_buffer(pipe, NULL);
}
state->changed.group |= NINE_STATE_STREAMFREQ;
}
+void
+nine_context_set_indices(struct NineDevice9 *device,
+ struct NineIndexBuffer9 *idxbuf)
+{
+ struct nine_state *state = &device->state;
+ struct nine_context *context = &device->context;
+ const struct pipe_index_buffer *pipe_idxbuf;
+
+ if (idxbuf) {
+ pipe_idxbuf = NineIndexBuffer9_GetBuffer(idxbuf);
+ context->idxbuf.index_size = pipe_idxbuf->index_size;
+ pipe_resource_reference(&context->idxbuf.buffer, pipe_idxbuf->buffer);
+ context->idxbuf.offset = pipe_idxbuf->offset;
+ context->idxbuf.user_buffer = NULL;
+ } else
+ pipe_resource_reference(&context->idxbuf.buffer, NULL);
+
+ state->changed.group |= NINE_STATE_IDXBUF;
+}
+
void
nine_context_set_vertex_declaration(struct NineDevice9 *device,
struct NineVertexDeclaration9 *vdecl)
context->changed.vtxbuf |= src->changed.vtxbuf;
}
+ /* Index buffer */
+ if (src->changed.group & NINE_STATE_IDXBUF)
+ nine_context_set_indices(device, src->idxbuf);
+
/* Vertex declaration */
if ((src->changed.group & NINE_STATE_VDECL) && src->vdecl)
nine_context_set_vertex_declaration(device, src->vdecl);
nine_bind(&context->vdecl, NULL);
for (i = 0; i < PIPE_MAX_ATTRIBS; ++i)
pipe_resource_reference(&context->vtxbuf[i].buffer, NULL);
+ pipe_resource_reference(&context->idxbuf.buffer, NULL);
for (i = 0; i < NINE_MAX_SAMPLERS; ++i)
nine_bind(&context->texture[i], NULL);
uint32_t stream_instancedata_mask; /* derived from stream_freq */
uint32_t stream_usage_mask; /* derived from VS and vdecl */
+ struct pipe_index_buffer idxbuf;
+
DWORD rs[NINED3DRS_COUNT];
struct NineBaseTexture9 *texture[NINE_MAX_SAMPLERS];
UINT StreamNumber,
UINT Setting);
+void
+nine_context_set_indices(struct NineDevice9 *device,
+ struct NineIndexBuffer9 *idxbuf);
+
void
nine_context_set_vertex_declaration(struct NineDevice9 *device,
struct NineVertexDeclaration9 *vdecl);