diff options
author | Marek Olšák <[email protected]> | 2017-04-02 14:30:16 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2017-05-10 19:00:16 +0200 |
commit | c24c3b94ed29ecd99b1101c74c6c4606f9b5580e (patch) | |
tree | 81f6966bc59a68d9867693c65d35fae9bb1d9819 /src/gallium/state_trackers/nine | |
parent | fe437882ea2d60e91c244cc95beb4b79c615af49 (diff) |
gallium: decrease the size of pipe_vertex_buffer - 24 -> 16 bytes
Diffstat (limited to 'src/gallium/state_trackers/nine')
-rw-r--r-- | src/gallium/state_trackers/nine/device9.c | 26 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_csmt_helper.h | 13 | ||||
-rw-r--r-- | src/gallium/state_trackers/nine/nine_state.c | 41 |
3 files changed, 48 insertions, 32 deletions
diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c index 4943658934a..6f97ddd647b 100644 --- a/src/gallium/state_trackers/nine/device9.c +++ b/src/gallium/state_trackers/nine/device9.c @@ -2815,26 +2815,27 @@ NineDevice9_DrawPrimitiveUP( struct NineDevice9 *This, vtxbuf.stride = VertexStreamZeroStride; vtxbuf.buffer_offset = 0; - vtxbuf.buffer = NULL; - vtxbuf.user_buffer = pVertexStreamZeroData; + vtxbuf.is_user_buffer = true; + vtxbuf.buffer.user = pVertexStreamZeroData; if (!This->driver_caps.user_vbufs) { + vtxbuf.is_user_buffer = false; + vtxbuf.buffer.resource = NULL; u_upload_data(This->vertex_uploader, 0, (prim_count_to_vertex_count(PrimitiveType, PrimitiveCount)) * VertexStreamZeroStride, /* XXX */ 4, - vtxbuf.user_buffer, + pVertexStreamZeroData, &vtxbuf.buffer_offset, - &vtxbuf.buffer); + &vtxbuf.buffer.resource); u_upload_unmap(This->vertex_uploader); - vtxbuf.user_buffer = NULL; } NineBeforeDraw(This); nine_context_draw_primitive_from_vtxbuf(This, PrimitiveType, PrimitiveCount, &vtxbuf); NineAfterDraw(This); - pipe_resource_reference(&vtxbuf.buffer, NULL); + pipe_vertex_buffer_unreference(&vtxbuf); NineDevice9_PauseRecording(This); NineDevice9_SetStreamSource(This, 0, NULL, 0, 0); @@ -2872,8 +2873,8 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, vbuf.stride = VertexStreamZeroStride; vbuf.buffer_offset = 0; - vbuf.buffer = NULL; - vbuf.user_buffer = pVertexStreamZeroData; + vbuf.is_user_buffer = true; + vbuf.buffer.user = pVertexStreamZeroData; ibuf.index_size = (IndexDataFormat == D3DFMT_INDEX16) ? 2 : 4; ibuf.offset = 0; @@ -2882,17 +2883,18 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, 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 *)vbuf.user_buffer + base, + (const uint8_t *)pVertexStreamZeroData + base, &vbuf.buffer_offset, - &vbuf.buffer); + &vbuf.buffer.resource); u_upload_unmap(This->vertex_uploader); /* Won't be used: */ vbuf.buffer_offset -= base; - vbuf.user_buffer = NULL; } if (This->csmt_active) { u_upload_data(This->pipe_secondary->stream_uploader, @@ -2915,7 +2917,7 @@ NineDevice9_DrawIndexedPrimitiveUP( struct NineDevice9 *This, &ibuf); NineAfterDraw(This); - pipe_resource_reference(&vbuf.buffer, NULL); + pipe_vertex_buffer_unreference(&vbuf); pipe_resource_reference(&ibuf.buffer, NULL); NineDevice9_PauseRecording(This); diff --git a/src/gallium/state_trackers/nine/nine_csmt_helper.h b/src/gallium/state_trackers/nine/nine_csmt_helper.h index dc46bbd3a28..7286cc31140 100644 --- a/src/gallium/state_trackers/nine/nine_csmt_helper.h +++ b/src/gallium/state_trackers/nine/nine_csmt_helper.h @@ -402,7 +402,18 @@ name##_priv( struct NineDevice9 *device ARGS_FOR_DECLARATION( __VA_ARGS__ ) ) ,\ y -#define ARG_BIND_BUF(x, y) \ +#define ARG_BIND_VBUF(x, y) \ + x _##y ,\ + memcpy(&args->_##y , y, sizeof(x)); \ + args->_##y.buffer.resource = NULL; \ + pipe_resource_reference(&args->_##y.buffer.resource, y->buffer.resource); ,\ + x *y ,\ + &args->_##y ,\ + pipe_resource_reference(&args->_##y.buffer.resource, NULL); ,\ + ,\ + y + +#define ARG_BIND_IBUF(x, y) \ x _##y ,\ memcpy(&args->_##y , y, sizeof(x)); \ args->_##y.buffer = NULL; \ diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c index 26c21f29f72..2046d9dbf2a 100644 --- a/src/gallium/state_trackers/nine/nine_state.c +++ b/src/gallium/state_trackers/nine/nine_state.c @@ -899,9 +899,9 @@ update_vertex_buffers(struct NineDevice9 *device) if (context->dummy_vbo_bound_at >= 0) { if (!context->vbo_bound_done) { - dummy_vtxbuf.buffer = device->dummy_vbo; + dummy_vtxbuf.buffer.resource = device->dummy_vbo; dummy_vtxbuf.stride = 0; - dummy_vtxbuf.user_buffer = NULL; + dummy_vtxbuf.is_user_buffer = false; dummy_vtxbuf.buffer_offset = 0; pipe->set_vertex_buffers(pipe, context->dummy_vbo_bound_at, 1, &dummy_vtxbuf); @@ -912,7 +912,7 @@ update_vertex_buffers(struct NineDevice9 *device) for (i = 0; mask; mask >>= 1, ++i) { if (mask & 1) { - if (context->vtxbuf[i].buffer) + if (context->vtxbuf[i].buffer.resource) pipe->set_vertex_buffers(pipe, i, 1, &context->vtxbuf[i]); else pipe->set_vertex_buffers(pipe, i, 1, NULL); @@ -1526,7 +1526,7 @@ CSMT_ITEM_NO_WAIT(nine_context_set_stream_source_apply, context->vtxbuf[i].stride = Stride; context->vtxbuf[i].buffer_offset = OffsetInBytes; - pipe_resource_reference(&context->vtxbuf[i].buffer, res); + pipe_resource_reference(&context->vtxbuf[i].buffer.resource, res); context->changed.vtxbuf |= 1 << StreamNumber; } @@ -2609,7 +2609,7 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive, CSMT_ITEM_NO_WAIT(nine_context_draw_primitive_from_vtxbuf, ARG_VAL(D3DPRIMITIVETYPE, PrimitiveType), ARG_VAL(UINT, PrimitiveCount), - ARG_BIND_BUF(struct pipe_vertex_buffer, vtxbuf)) + ARG_BIND_VBUF(struct pipe_vertex_buffer, vtxbuf)) { struct nine_context *context = &device->context; struct pipe_draw_info info; @@ -2633,8 +2633,8 @@ CSMT_ITEM_NO_WAIT(nine_context_draw_indexed_primitive_from_vtxbuf_idxbuf, ARG_VAL(UINT, MinVertexIndex), ARG_VAL(UINT, NumVertices), ARG_VAL(UINT, PrimitiveCount), - ARG_BIND_BUF(struct pipe_vertex_buffer, vbuf), - ARG_BIND_BUF(struct pipe_index_buffer, ibuf)) + ARG_BIND_VBUF(struct pipe_vertex_buffer, vbuf), + ARG_BIND_IBUF(struct pipe_index_buffer, ibuf)) { struct nine_context *context = &device->context; struct pipe_draw_info info; @@ -3145,7 +3145,7 @@ nine_context_clear(struct NineDevice9 *device) nine_bind(&context->ps, NULL); nine_bind(&context->vdecl, NULL); for (i = 0; i < PIPE_MAX_ATTRIBS; ++i) - pipe_resource_reference(&context->vtxbuf[i].buffer, NULL); + pipe_vertex_buffer_unreference(&context->vtxbuf[i]); pipe_resource_reference(&context->idxbuf.buffer, NULL); for (i = 0; i < NINE_MAX_SAMPLERS; ++i) { @@ -3283,33 +3283,36 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_ unsigned offset; struct pipe_resource *buf; struct pipe_box box; + void *userbuf; vtxbuf = state->vtxbuf[i]; - vtxbuf.buffer = NineVertexBuffer9_GetResource(state->stream[i], &offset); + buf = NineVertexBuffer9_GetResource(state->stream[i], &offset); - DBG("Locking %p (offset %d, length %d)\n", vtxbuf.buffer, + DBG("Locking %p (offset %d, length %d)\n", buf, vtxbuf.buffer_offset, num_vertices * vtxbuf.stride); u_box_1d(vtxbuf.buffer_offset + offset + start_vertice * vtxbuf.stride, num_vertices * vtxbuf.stride, &box); - buf = vtxbuf.buffer; - vtxbuf.user_buffer = pipe->transfer_map(pipe, buf, 0, PIPE_TRANSFER_READ, &box, - &(sw_internal->transfers_so[i])); - vtxbuf.buffer = NULL; + + userbuf = pipe->transfer_map(pipe, buf, 0, PIPE_TRANSFER_READ, &box, + &(sw_internal->transfers_so[i])); + vtxbuf.is_user_buffer = true; + vtxbuf.buffer.user = userbuf; + if (!device->driver_caps.user_sw_vbufs) { + vtxbuf.buffer.resource = NULL; + vtxbuf.is_user_buffer = false; u_upload_data(device->pipe_sw->stream_uploader, 0, box.width, 16, - vtxbuf.user_buffer, + userbuf, &(vtxbuf.buffer_offset), - &(vtxbuf.buffer)); + &(vtxbuf.buffer.resource)); u_upload_unmap(device->pipe_sw->stream_uploader); - vtxbuf.user_buffer = NULL; } pipe_sw->set_vertex_buffers(pipe_sw, i, 1, &vtxbuf); - if (vtxbuf.buffer) - pipe_resource_reference(&vtxbuf.buffer, NULL); + pipe_vertex_buffer_unreference(&vtxbuf); } else pipe_sw->set_vertex_buffers(pipe_sw, i, 1, NULL); } |