st/nine: Allow non-zero resource offset for vertex buffers
authorAxel Davy <axel.davy@ens.fr>
Sun, 4 Dec 2016 18:23:11 +0000 (19:23 +0100)
committerAxel Davy <axel.davy@ens.fr>
Tue, 20 Dec 2016 22:47:08 +0000 (23:47 +0100)
Next patches will introduce an offset.

Signed-off-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/vertexbuffer9.c
src/gallium/state_trackers/nine/vertexbuffer9.h

index c0bd6f7bccfbc257912631ffdef5d9acf8a25fe8..afc309f1dbe40ae46a730b7811235bd8c8e3c4d4 100644 (file)
@@ -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);
 }
 
@@ -2041,9 +2042,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;
                 }
             }
@@ -3276,16 +3278,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,
index b0eebfb48f3b281a503173b5947c440535070738..027f290d8a3c6b1c4559ac5cc96350c865e53f57 100644 (file)
@@ -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);
 }
 
index 6caa9bfe326809c929231e64b899dd79c92c989f..2991dbadd07a29c9b44e25ccbfe0a1d4b8ebe893 100644 (file)
@@ -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 ***/