summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers
diff options
context:
space:
mode:
authorAxel Davy <[email protected]>2016-10-19 20:41:40 +0200
committerAxel Davy <[email protected]>2016-12-20 23:44:22 +0100
commitaafbd62955f279172b0b57c3fd2b82da54f8035f (patch)
treef9523c8d6a0f93d82b6dea0c6fd8f916a94b16f3 /src/gallium/state_trackers
parentb13b217243f1700e9c88bfc91a4d85cc2c17ab60 (diff)
st/nine: Back current index buffer to nine_context
Part of the refactor to move all gallium calls to nine_state.c, and have all internal states required for those calls in nine_context. Signed-off-by: Axel Davy <[email protected]>
Diffstat (limited to 'src/gallium/state_trackers')
-rw-r--r--src/gallium/state_trackers/nine/device9.c16
-rw-r--r--src/gallium/state_trackers/nine/nine_state.c29
-rw-r--r--src/gallium/state_trackers/nine/nine_state.h6
3 files changed, 44 insertions, 7 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index fb87f2c9070..5fa44c42e35 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -3526,15 +3526,21 @@ NineDevice9_SetIndices( struct NineDevice9 *This,
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;
}
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index ef72cdc7ba3..5aaf5a132df 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -837,8 +837,8 @@ static inline void
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);
}
@@ -1241,6 +1241,26 @@ nine_context_set_stream_source_freq(struct NineDevice9 *device,
}
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)
{
@@ -1483,6 +1503,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
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);
@@ -2096,6 +2120,7 @@ nine_context_clear(struct nine_context *context)
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);
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index e8519e982c7..70a9f102b03 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -256,6 +256,8 @@ struct nine_context {
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];
@@ -331,6 +333,10 @@ nine_context_set_stream_source_freq(struct NineDevice9 *device,
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);