diff options
Diffstat (limited to 'src/gallium/state_trackers/nine')
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 27 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/indexbuffer9.c | 15 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/indexbuffer9.h | 7 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 56 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.h | 9 |
5 files changed, 56 insertions, 58 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 6390735ac57..9f9e104b91a 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2856,7 +2856,6 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, UINT VertexStreamZeroStride ) { struct pipe_vertex_buffer vbuf; - struct pipe_index_buffer ibuf; DBG("iface %p, PrimitiveType %u, MinVertexIndex %u, NumVertices %u " "PrimitiveCount %u, pIndexData %p, IndexDataFormat %u " @@ -2876,10 +2875,8 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, vbuf.is_user_buffer = true; vbuf.buffer.user = pVertexStreamZeroData; - ibuf.index_size = (IndexDataFormat == D3DFMT_INDEX16) ? 2 : 4; - ibuf.offset = 0; - ibuf.buffer = NULL; - ibuf.user_buffer = pIndexData; + unsigned index_size = (IndexDataFormat == D3DFMT_INDEX16) ? 2 : 4; + struct pipe_resource *ibuf = NULL; if (!This->driver_caps.user_vbufs) { const unsigned base = MinVertexIndex * VertexStreamZeroStride; @@ -2896,16 +2893,17 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, /* Won't be used: */ vbuf.buffer_offset -= base; } + + unsigned index_offset = 0; if (This->csmt_active) { u_upload_data(This->pipe_secondary->stream_uploader, 0, - (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * ibuf.index_size, + (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * index_size, 4, - ibuf.user_buffer, - &ibuf.offset, - &ibuf.buffer); + pIndexData, + &index_offset, + &ibuf); u_upload_unmap(This->pipe_secondary->stream_uploader); - ibuf.user_buffer = NULL; } NineBeforeDraw(This); @@ -2914,11 +2912,14 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, NumVertices, PrimitiveCount, &vbuf, - &ibuf); + ibuf, + ibuf ? NULL : (void*)pIndexData, + index_offset, + index_size); NineAfterDraw(This); pipe_vertex_buffer_unreference(&vbuf); - pipe_resource_reference(&ibuf.buffer, NULL); + pipe_resource_reference(&ibuf, NULL); NineDevice9_PauseRecording(This); NineDevice9_SetIndices(This, NULL); @@ -3032,7 +3033,7 @@ NineDevice9_ProcessVertices( struct NineDevice9 *This, draw.count_from_stream_output = NULL; draw.indirect = NULL; draw.instance_count = 1; - draw.indexed = FALSE; + draw.index_size = 0; draw.start = 0; draw.index_bias = 0; draw.min_index = 0; diff --git a/src/gallium/state_trackers/nine/indexbuffer9.c b/src/gallium/state_trackers/nine/indexbuffer9.c index cbd75fb928c..d5f5492563d 100644 --- a/src/gallium/state_trackers/nine/indexbuffer9.c +++ b/src/gallium/state_trackers/nine/indexbuffer9.c @@ -49,17 +49,16 @@ NineIndexBuffer9_ctor( struct NineIndexBuffer9 *This, if (FAILED(hr)) return hr; - This->buffer.buffer = NULL; - This->buffer.offset = 0; + This->buffer = NULL; + This->offset = 0; switch (pDesc->Format) { - case D3DFMT_INDEX16: This->buffer.index_size = 2; break; - case D3DFMT_INDEX32: This->buffer.index_size = 4; break; + case D3DFMT_INDEX16: This->index_size = 2; break; + case D3DFMT_INDEX32: This->index_size = 4; break; default: user_assert(!"Invalid index format.", D3DERR_INVALIDCALL); break; } - This->buffer.user_buffer = NULL; pDesc->Type = D3DRTYPE_INDEXBUFFER; This->desc = *pDesc; @@ -73,12 +72,12 @@ NineIndexBuffer9_dtor( struct NineIndexBuffer9 *This ) NineBuffer9_dtor(&This->base); } -const struct pipe_index_buffer * +struct pipe_resource * NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This ) { /* The resource may change */ - This->buffer.buffer = NineBuffer9_GetResource(&This->base, &This->buffer.offset); - return &This->buffer; + This->buffer = NineBuffer9_GetResource(&This->base, &This->offset); + return This->buffer; } HRESULT NINE_WINAPI diff --git a/src/gallium/state_trackers/nine/indexbuffer9.h b/src/gallium/state_trackers/nine/indexbuffer9.h index e695082a0c5..0efad7f5f16 100644 --- a/src/gallium/state_trackers/nine/indexbuffer9.h +++ b/src/gallium/state_trackers/nine/indexbuffer9.h @@ -29,7 +29,6 @@ struct pipe_screen; struct pipe_context; -struct pipe_index_buffer; struct pipe_transfer; struct NineDevice9; @@ -38,7 +37,9 @@ struct NineIndexBuffer9 struct NineBuffer9 base; /* g3d stuff */ - struct pipe_index_buffer buffer; + struct pipe_resource *buffer; + unsigned offset; + unsigned index_size; D3DINDEXBUFFER_DESC desc; }; @@ -63,7 +64,7 @@ NineIndexBuffer9_dtor( struct NineIndexBuffer9 *This ); /*** Nine private ***/ -const struct pipe_index_buffer * +struct pipe_resource * NineIndexBuffer9_GetBuffer( struct NineIndexBuffer9 *This ); /*** Direct3D public ***/ diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 3b1cd7ced6d..0fc4c8315a7 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -1100,17 +1100,6 @@ commit_rasterizer(struct NineDevice9 *device) } static inline void -commit_index_buffer(struct NineDevice9 *device) -{ - struct nine_context *context = &device->context; - struct pipe_context *pipe = context->pipe; - if (context->idxbuf.buffer) - pipe->set_index_buffer(pipe, &context->idxbuf); - else - pipe->set_index_buffer(pipe, NULL); -} - -static inline void commit_vs_constants(struct NineDevice9 *device) { struct nine_context *context = &device->context; @@ -1235,8 +1224,6 @@ nine_update_state(struct NineDevice9 *device) update_viewport(device); if (group & (NINE_STATE_VDECL | NINE_STATE_VS | NINE_STATE_STREAMFREQ)) update_vertex_elements(device); - if (group & NINE_STATE_IDXBUF) - commit_index_buffer(device); } if (likely(group & (NINE_STATE_FREQUENT | NINE_STATE_VS | NINE_STATE_PS | NINE_STATE_SWVP))) { @@ -1575,10 +1562,9 @@ CSMT_ITEM_NO_WAIT(nine_context_set_indices_apply, { struct nine_context *context = &device->context; - context->idxbuf.index_size = IndexSize; - context->idxbuf.offset = OffsetInBytes; - pipe_resource_reference(&context->idxbuf.buffer, res); - context->idxbuf.user_buffer = NULL; + context->index_size = IndexSize; + context->index_offset = OffsetInBytes; + pipe_resource_reference(&context->idxbuf, res); context->changed.group |= NINE_STATE_IDXBUF; } @@ -1587,16 +1573,14 @@ void nine_context_set_indices(struct NineDevice9 *device, struct NineIndexBuffer9 *idxbuf) { - const struct pipe_index_buffer *pipe_idxbuf; struct pipe_resource *res = NULL; UINT IndexSize = 0; UINT OffsetInBytes = 0; if (idxbuf) { - pipe_idxbuf = NineIndexBuffer9_GetBuffer(idxbuf); - IndexSize = pipe_idxbuf->index_size; - res = pipe_idxbuf->buffer; - OffsetInBytes = pipe_idxbuf->offset; + res = NineIndexBuffer9_GetBuffer(idxbuf); + IndexSize = idxbuf->index_size; + OffsetInBytes = idxbuf->offset; } nine_context_set_indices_apply(device, res, IndexSize, OffsetInBytes); @@ -2572,7 +2556,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_primitive, nine_update_state(device); init_draw_info(&info, device, PrimitiveType, PrimitiveCount); - info.indexed = FALSE; + info.index_size = 0; info.start = StartVertex; info.index_bias = 0; info.min_index = info.start; @@ -2595,12 +2579,13 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive, nine_update_state(device); init_draw_info(&info, device, PrimitiveType, PrimitiveCount); - info.indexed = TRUE; - info.start = StartIndex; + info.index_size = context->index_size; + info.start = context->index_offset / context->index_size + StartIndex; info.index_bias = BaseVertexIndex; /* These don't include index bias: */ info.min_index = MinVertexIndex; info.max_index = MinVertexIndex + NumVertices - 1; + info.index.resource = context->idxbuf; context->pipe->draw_vbo(context->pipe, &info); } @@ -2616,7 +2601,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_primitive_from_vtxbuf, nine_update_state(device); init_draw_info(&info, device, PrimitiveType, PrimitiveCount); - info.indexed = FALSE; + info.index_size = 0; info.start = 0; info.index_bias = 0; info.min_index = 0; @@ -2633,7 +2618,10 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf, ARG_VAL(UINT, NumVertices), ARG_VAL(UINT, PrimitiveCount), ARG_BIND_VBUF(struct pipe_vertex_buffer, vbuf), - ARG_BIND_IBUF(struct pipe_index_buffer, ibuf)) + ARG_BIND_RES(struct pipe_resource, ibuf), + ARG_VAL(void *, user_ibuf), + ARG_VAL(UINT, index_offset), + ARG_VAL(UINT, index_size)) { struct nine_context *context = &device->context; struct pipe_draw_info info; @@ -2641,13 +2629,18 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf, nine_update_state(device); init_draw_info(&info, device, PrimitiveType, PrimitiveCount); - info.indexed = TRUE; - info.start = 0; + info.index_size = index_size; + info.start = index_offset / info.index_size; info.index_bias = 0; info.min_index = MinVertexIndex; info.max_index = MinVertexIndex + NumVertices - 1; + info.has_user_indices = ibuf == NULL; + if (ibuf) + info.index.resource = ibuf; + else + info.index.user = user_ibuf; + context->pipe->set_vertex_buffers(context->pipe, 0, 1, vbuf); - context->pipe->set_index_buffer(context->pipe, ibuf); context->pipe->draw_vbo(context->pipe, &info); } @@ -3135,7 +3128,6 @@ nine_context_clear(struct NineDevice9 *device) cso_set_sampler_views(cso, PIPE_SHADER_FRAGMENT, 0, NULL); pipe->set_vertex_buffers(pipe, 0, device->caps.MaxStreams, NULL); - pipe->set_index_buffer(pipe, NULL); for (i = 0; i < ARRAY_SIZE(context->rt); ++i) nine_bind(&context->rt[i], NULL); @@ -3145,7 +3137,7 @@ nine_context_clear(struct NineDevice9 *device) nine_bind(&context->vdecl, NULL); for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) pipe_vertex_buffer_unreference(&context->vtxbuf[i]); - pipe_resource_reference(&context->idxbuf.buffer, NULL); + pipe_resource_reference(&context->idxbuf, NULL); for (i = 0; i < NINE_MAX_SAMPLERS; ++i) { context->texture[i].enabled = FALSE; diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h index a487d8cafff..f5fd1ef9cd8 100644 --- a/src/gallium/state_trackers/nine/nine_state.h +++ b/src/gallium/state_trackers/nine/nine_state.h @@ -271,7 +271,9 @@ 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; + struct pipe_resource *idxbuf; + unsigned index_offset; + unsigned index_size; struct pipe_clip_state clip; @@ -515,7 +517,10 @@ nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(struct NineDevice9 *devic UINT NumVertices, UINT PrimitiveCount, struct pipe_vertex_buffer *vbuf, - struct pipe_index_buffer *ibuf); + struct pipe_resource *ibuf, + void *user_ibuf, + unsigned index_offset, + unsigned index_size); void nine_context_resource_copy_region(struct NineDevice9 *device, |