[Mesa-dev] [PATCH 3/4] gallium: remove pipe_index_buffer and set_index_buffer
Axel Davy
axel.davy at normalesup.org
Sun Apr 30 06:38:50 UTC 2017
Dear Marek,
I'm not sure where is the regression in nine reported by Mike and Edmondo,
but here there's a mistake with the handling of the index user buffer case.
After your patch, when 'csmt_active' is false,
NineDevice9_DrawIndexedPrimitiveUP
won't work because you don't upload the data (previously it would use
index user buffer,
but you remove support for it)
Yours,
Axel Davy
On 29/04/2017 01:12, Marek Olšák wrote:
> diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
> index 6390735..5dc24d6 100644
> --- a/src/gallium/state_trackers/nine/device9.c
> +++ b/src/gallium/state_trackers/nine/device9.c
> @@ -2849,83 +2849,83 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This,
> D3DPRIMITIVETYPE PrimitiveType,
> UINT MinVertexIndex,
> UINT NumVertices,
> UINT PrimitiveCount,
> const void *pIndexData,
> D3DFORMAT IndexDataFormat,
> const void *pVertexStreamZeroData,
> 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 "
> "pVertexStreamZeroData %p, VertexStreamZeroStride %u\n",
> This, PrimitiveType, MinVertexIndex, NumVertices, PrimitiveCount,
> pIndexData, IndexDataFormat,
> pVertexStreamZeroData, VertexStreamZeroStride);
>
> user_assert(pIndexData && pVertexStreamZeroData, D3DERR_INVALIDCALL);
> user_assert(VertexStreamZeroStride, D3DERR_INVALIDCALL);
> user_assert(IndexDataFormat == D3DFMT_INDEX16 ||
> IndexDataFormat == D3DFMT_INDEX32, D3DERR_INVALIDCALL);
> user_assert(PrimitiveCount, D3D_OK);
>
> vbuf.stride = VertexStreamZeroStride;
> vbuf.buffer_offset = 0;
> 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;
> vbuf.is_user_buffer = false;
> vbuf.buffer.resource = NULL;
> u_upload_data(This->vertex_uploader,
> base,
> NumVertices * VertexStreamZeroStride, /* XXX */
> 4,
> (const uint8_t *)pVertexStreamZeroData + base,
> &vbuf.buffer_offset,
> &vbuf.buffer.resource);
> u_upload_unmap(This->vertex_uploader);
> /* 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);
> nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf(This, PrimitiveType,
> MinVertexIndex,
> NumVertices,
> PrimitiveCount,
> &vbuf,
> - &ibuf);
> + ibuf,
> + 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);
> NineDevice9_SetStreamSource(This, 0, NULL, 0, 0);
> NineDevice9_ResumeRecording(This);
>
> return D3D_OK;
> }
More information about the mesa-dev
mailing list