[Mesa-dev] [PATCH 83/84] st/nine: Allow non-zero resource offset for vertex buffers

Axel Davy axel.davy at ens.fr
Wed Dec 7 22:55:56 UTC 2016


Next patches will introduce an offset.

Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/nine_state.c    | 15 +++++++++------
 src/gallium/state_trackers/nine/vertexbuffer9.c |  3 ++-
 src/gallium/state_trackers/nine/vertexbuffer9.h |  2 +-
 3 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index 3c3a2ac..5b9d5e7 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -1539,14 +1539,15 @@ nine_context_set_stream_source(struct NineDevice9 *device,
                                UINT Stride)
 {
     struct pipe_resource *res = NULL;
+    unsigned offset = 0;
 
     if (pVBuf9)
-        res = NineVertexBuffer9_GetResource(pVBuf9);
+        res = NineVertexBuffer9_GetResource(pVBuf9, &offset);
     /* in the future when there is internal offset, add it
      * to OffsetInBytes */
 
     nine_context_set_stream_source_apply(device, StreamNumber,
-                                         res, OffsetInBytes,
+                                         res, offset + OffsetInBytes,
                                          Stride);
 }
 
@@ -2040,9 +2041,10 @@ nine_context_apply_stateblock(struct NineDevice9 *device,
         for (i = 0; m; ++i, m >>= 1) {
             if (src->changed.vtxbuf & (1 << i)) {
                 if (src->stream[i]) {
-                    context->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset;
+                    unsigned offset = 0;
                     pipe_resource_reference(&context->vtxbuf[i].buffer,
-                        src->stream[i] ? NineVertexBuffer9_GetResource(src->stream[i]) : NULL);
+                        src->stream[i] ? NineVertexBuffer9_GetResource(src->stream[i], &offset) : NULL);
+                    context->vtxbuf[i].buffer_offset = src->vtxbuf[i].buffer_offset + offset;
                     context->vtxbuf[i].stride = src->vtxbuf[i].stride;
                 }
             }
@@ -3280,16 +3282,17 @@ update_vertex_buffers_sw(struct NineDevice9 *device, int start_vertice, int num_
     for (i = 0; mask; mask >>= 1, ++i) {
         if (mask & 1) {
             if (state->stream[i]) {
+                unsigned offset;
                 struct pipe_resource *buf;
                 struct pipe_box box;
 
                 vtxbuf = state->vtxbuf[i];
-                vtxbuf.buffer = NineVertexBuffer9_GetResource(state->stream[i]);
+                vtxbuf.buffer = NineVertexBuffer9_GetResource(state->stream[i], &offset);
 
                 DBG("Locking %p (offset %d, length %d)\n", vtxbuf.buffer,
                     vtxbuf.buffer_offset, num_vertices * vtxbuf.stride);
 
-                u_box_1d(vtxbuf.buffer_offset + start_vertice * 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,
diff --git a/src/gallium/state_trackers/nine/vertexbuffer9.c b/src/gallium/state_trackers/nine/vertexbuffer9.c
index b0eebfb..027f290 100644
--- a/src/gallium/state_trackers/nine/vertexbuffer9.c
+++ b/src/gallium/state_trackers/nine/vertexbuffer9.c
@@ -63,8 +63,9 @@ NineVertexBuffer9_dtor( struct NineVertexBuffer9 *This )
 }
 
 struct pipe_resource *
-NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This )
+NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This, unsigned *offset )
 {
+    *offset = 0;
     return NineBuffer9_GetResource(&This->base);
 }
 
diff --git a/src/gallium/state_trackers/nine/vertexbuffer9.h b/src/gallium/state_trackers/nine/vertexbuffer9.h
index 6caa9bf..2991dba 100644
--- a/src/gallium/state_trackers/nine/vertexbuffer9.h
+++ b/src/gallium/state_trackers/nine/vertexbuffer9.h
@@ -58,7 +58,7 @@ NineVertexBuffer9_dtor( struct NineVertexBuffer9 *This );
 /*** Nine private ***/
 
 struct pipe_resource *
-NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This );
+NineVertexBuffer9_GetResource( struct NineVertexBuffer9 *This, unsigned *offset );
 
 /*** Direct3D public ***/
 
-- 
2.10.2



More information about the mesa-dev mailing list