From dcac48bfee545660dffbf23bd92a0939b19ffd18 Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Thu, 2 Feb 2017 21:16:47 -0600 Subject: swr: fix index buffers with non-zero indices Fix issue with index buffers that do not contain a 0 index. 0 index can be a non-valid index if the (copied) vertex buffers are a subset of the user's (which happens because we only copy the range between min & max). Core will use an index passed in from the driver to replace invalid indices. Only do this for calls that contain non-zero indices, to minimize performance Reviewed-by: Bruce Cherniak cost. --- src/gallium/drivers/swr/swr_state.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/gallium/drivers/swr/swr_state.cpp') diff --git a/src/gallium/drivers/swr/swr_state.cpp b/src/gallium/drivers/swr/swr_state.cpp index 116f19f1ecf..5e3d58d1733 100644 --- a/src/gallium/drivers/swr/swr_state.cpp +++ b/src/gallium/drivers/swr/swr_state.cpp @@ -1106,6 +1106,7 @@ swr_update_derived(struct pipe_context *pipe, SWR_VERTEX_BUFFER_STATE swrVertexBuffers[PIPE_MAX_ATTRIBS]; for (UINT i = 0; i < ctx->num_vertex_buffers; i++) { uint32_t size, pitch, elems, partial_inbounds; + uint32_t min_vertex_index; const uint8_t *p_data; struct pipe_vertex_buffer *vb = &ctx->vertex_buffer[i]; @@ -1117,6 +1118,7 @@ swr_update_derived(struct pipe_context *pipe, size = vb->buffer->width0; elems = size / pitch; partial_inbounds = size % pitch; + min_vertex_index = 0; p_data = swr_resource_data(vb->buffer) + vb->buffer_offset; } else { @@ -1128,6 +1130,7 @@ swr_update_derived(struct pipe_context *pipe, uint32_t base; swr_user_vbuf_range(&info, ctx->velems, vb, i, &elems, &base, &size); partial_inbounds = 0; + min_vertex_index = info.min_index; /* Copy only needed vertices to scratch space */ size = AlignUp(size, 4); @@ -1143,6 +1146,7 @@ swr_update_derived(struct pipe_context *pipe, swrVertexBuffers[i].pitch = pitch; swrVertexBuffers[i].pData = p_data; swrVertexBuffers[i].size = size; + swrVertexBuffers[i].minVertex = min_vertex_index; swrVertexBuffers[i].maxVertex = elems; swrVertexBuffers[i].partialInboundsSize = partial_inbounds; } -- cgit v1.2.3