gallium: remove pipe_vertex_buffer::max_index
authorMarek Olšák <maraeo@gmail.com>
Mon, 10 Jan 2011 04:41:47 +0000 (05:41 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 14 Feb 2011 20:50:08 +0000 (21:50 +0100)
This is redundant to pipe_draw_info::max_index and doesn't really fit
in the optimizations I plan.

26 files changed:
src/gallium/auxiliary/draw/draw_llvm.c
src/gallium/auxiliary/draw/draw_llvm.h
src/gallium/auxiliary/draw/draw_pt.c
src/gallium/auxiliary/draw/draw_pt_fetch.c
src/gallium/auxiliary/draw/draw_pt_fetch_emit.c
src/gallium/auxiliary/draw/draw_pt_fetch_shade_emit.c
src/gallium/auxiliary/util/u_draw_quad.c
src/gallium/auxiliary/util/u_dump_state.c
src/gallium/docs/d3d11ddi.txt
src/gallium/drivers/nvc0/nvc0_vbo.c
src/gallium/drivers/svga/svga_state_vs.c
src/gallium/drivers/trace/tr_dump_state.c
src/gallium/include/pipe/p_state.h
src/gallium/state_trackers/d3d1x/dxgi/src/dxgi_native.cpp
src/gallium/state_trackers/d3d1x/gd3d11/d3d11_context.h
src/gallium/state_trackers/vega/polygon.c
src/gallium/tests/graw/fs-test.c
src/gallium/tests/graw/gs-test.c
src/gallium/tests/graw/quad-tex.c
src/gallium/tests/graw/shader-leak.c
src/gallium/tests/graw/tri-gs.c
src/gallium/tests/graw/tri-instanced.c
src/gallium/tests/graw/tri.c
src/gallium/tests/graw/vs-test.c
src/mesa/state_tracker/st_draw.c
src/mesa/state_tracker/st_draw_feedback.c

index a73bdd7808782a44e2c350e6be172f5986af4732..a5217c1d4ec8c1bf3cc76b5f1bf618ff76e271da 100644 (file)
@@ -214,13 +214,12 @@ static LLVMTypeRef
 create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
 {
    LLVMTargetDataRef target = gallivm->target;
-   LLVMTypeRef elem_types[4];
+   LLVMTypeRef elem_types[3];
    LLVMTypeRef vb_type;
 
    elem_types[0] =
-   elem_types[1] =
-   elem_types[2] = LLVMInt32TypeInContext(gallivm->context);
-   elem_types[3] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
+   elem_types[1] = LLVMInt32TypeInContext(gallivm->context);
+   elem_types[2] = LLVMPointerType(LLVMInt8TypeInContext(gallivm->context), 0); /* vs_constants */
 
    vb_type = LLVMStructTypeInContext(gallivm->context, elem_types,
                                      Elements(elem_types), 0);
@@ -229,10 +228,8 @@ create_jit_vertex_buffer_type(struct gallivm_state *gallivm)
 
    LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, stride,
                           target, vb_type, 0);
-   LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, max_index,
-                          target, vb_type, 1);
    LP_CHECK_MEMBER_OFFSET(struct pipe_vertex_buffer, buffer_offset,
-                          target, vb_type, 2);
+                          target, vb_type, 1);
 
    LP_CHECK_STRUCT_SIZE(struct pipe_vertex_buffer, target, vb_type);
 
@@ -513,9 +510,7 @@ generate_fetch(struct gallivm_state *gallivm,
    LLVMValueRef vbuffer_ptr = LLVMBuildGEP(builder, vbuffers_ptr,
                                            &indices, 1, "");
    LLVMValueRef vb_stride = draw_jit_vbuffer_stride(gallivm, vbuf);
-   LLVMValueRef vb_max_index = draw_jit_vbuffer_max_index(gallivm, vbuf);
    LLVMValueRef vb_buffer_offset = draw_jit_vbuffer_offset(gallivm, vbuf);
-   LLVMValueRef cond;
    LLVMValueRef stride;
 
    if (velem->instance_divisor) {
@@ -525,10 +520,6 @@ generate_fetch(struct gallivm_state *gallivm,
                             "instance_divisor");
    }
 
-   /* limit index to min(index, vb_max_index) */
-   cond = LLVMBuildICmp(builder, LLVMIntULE, index, vb_max_index, "");
-   index = LLVMBuildSelect(builder, cond, index, vb_max_index, "");
-
    stride = LLVMBuildMul(builder, vb_stride, index, "");
 
    vbuffer_ptr = LLVMBuildLoad(builder, vbuffer_ptr, "vbuffer");
index 9f038f1f04d641f9e4d69f5ddbb154188eef20eb..e8623e7bcdc6c2c085054d08c94f672ddd977173 100644 (file)
@@ -133,11 +133,8 @@ struct draw_jit_context
 #define draw_jit_vbuffer_stride(_gallivm, _ptr)         \
    lp_build_struct_get(_gallivm, _ptr, 0, "stride")
 
-#define draw_jit_vbuffer_max_index(_gallivm, _ptr)      \
-   lp_build_struct_get(_gallivm, _ptr, 1, "max_index")
-
 #define draw_jit_vbuffer_offset(_gallivm, _ptr)         \
-   lp_build_struct_get(_gallivm, _ptr, 2, "buffer_offset")
+   lp_build_struct_get(_gallivm, _ptr, 1, "buffer_offset")
 
 
 typedef int
index 4078b2a07d035b1bda510dfaf0ab6949f8634f03..c3d7e871f7a3e54bb7a9db4fbbf7cd739ad76ab3 100644 (file)
@@ -459,10 +459,9 @@ draw_vbo(struct draw_context *draw,
       }
       debug_printf("Buffers:\n");
       for (i = 0; i < draw->pt.nr_vertex_buffers; i++) {
-         debug_printf("  %u: stride=%u maxindex=%u offset=%u ptr=%p\n",
+         debug_printf("  %u: stride=%u offset=%u ptr=%p\n",
                       i,
                       draw->pt.vertex_buffer[i].stride,
-                      draw->pt.vertex_buffer[i].max_index,
                       draw->pt.vertex_buffer[i].buffer_offset,
                       draw->pt.user.vbuffer[i]);
       }
index ae12ee24bdc36b2b7cfad30345a5712a4085e7a3..4fa3b265e10daf20876354614e5b9b6392fe7ed3 100644 (file)
@@ -139,7 +139,7 @@ void draw_pt_fetch_run( struct pt_fetch *fetch,
                            ((char *)draw->pt.user.vbuffer[i] + 
                             draw->pt.vertex_buffer[i].buffer_offset),
                            draw->pt.vertex_buffer[i].stride,
-                           draw->pt.vertex_buffer[i].max_index);
+                           draw->pt.user.max_index);
    }
 
    translate->run_elts( translate,
@@ -166,7 +166,7 @@ void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
                            ((char *)draw->pt.user.vbuffer[i] +
                             draw->pt.vertex_buffer[i].buffer_offset),
                            draw->pt.vertex_buffer[i].stride,
-                           draw->pt.vertex_buffer[i].max_index);
+                           draw->pt.user.max_index);
    }
 
    translate->run( translate,
index e706b7796f82249e451196a61a5494ae208d03f4..51043102a6113e14f6169983dfee69cb9e5195d6 100644 (file)
@@ -186,7 +186,7 @@ static void fetch_emit_prepare( struct draw_pt_middle_end *middle,
                                   ((char *)draw->pt.user.vbuffer[i] + 
                                    draw->pt.vertex_buffer[i].buffer_offset),
                                   draw->pt.vertex_buffer[i].stride,
-                                  draw->pt.vertex_buffer[i].max_index);
+                                  draw->pt.user.max_index);
    }
 
    *max_vertices = (draw->render->max_vertex_buffer_bytes / 
index c98fb3d5205a9dd4ed518e727ff416a9370287bc..1e926fb028ea069aacac2f2e560f7876f135b659 100644 (file)
@@ -169,7 +169,7 @@ static void fse_prepare( struct draw_pt_middle_end *middle,
                                ((const ubyte *) draw->pt.user.vbuffer[i] + 
                                 draw->pt.vertex_buffer[i].buffer_offset),
                               draw->pt.vertex_buffer[i].stride,
-                              draw->pt.vertex_buffer[i].max_index );
+                              draw->pt.user.max_index );
    }
 
    *max_vertices = (draw->render->max_vertex_buffer_bytes / 
index 2747cd4b0c1c2174d362acc0d629ab30d6b555b4..0defd9199749fbee49ee70bef6da17c582d19ebf 100644 (file)
@@ -56,7 +56,6 @@ util_draw_vertex_buffer(struct pipe_context *pipe,
    vbuffer.buffer = vbuf;
    vbuffer.stride = num_attribs * 4 * sizeof(float);  /* vertex size */
    vbuffer.buffer_offset = offset;
-   vbuffer.max_index = num_verts - 1;
 
    if (cso) {
       cso_set_vertex_buffers(cso, 1, &vbuffer);
index b471d59eebf35295fd6fe39c65e7abc38c709d67..5ecf8cbb0674cc8ac598a2dcc0fce30c3057c1f4 100644 (file)
@@ -681,7 +681,6 @@ util_dump_vertex_buffer(struct os_stream *stream, const struct pipe_vertex_buffe
    util_dump_struct_begin(stream, "pipe_vertex_buffer");
 
    util_dump_member(stream, uint, state, stride);
-   util_dump_member(stream, uint, state, max_index);
    util_dump_member(stream, uint, state, buffer_offset);
    util_dump_member(stream, ptr, state, buffer);
 
index 11e77190895672e66fd429d03e17df8158057524..0a9e7e50f1d7af08cd4587e4736b2d5c41c6ac32 100644 (file)
@@ -337,7 +337,6 @@ IaSetTopology
        + Gallium supports line loops, triangle fans, quads, quad strips and polygons
 
 IaSetVertexBuffers -> set_vertex_buffers
-       + Gallium allows to specify a max_index here
        - Gallium only allows setting all vertex buffers at once, while D3D11 supports setting a subset
 
 OpenResource -> texture_from_handle
index aa5decfc23312ab6c78a310969164ff8874a8f91..80e05823759796ca9abb00457cf6846ec0eae9fa 100644 (file)
@@ -152,7 +152,7 @@ nvc0_vbuf_range(struct nvc0_context *nvc0, int vbi,
    if (unlikely(nvc0->vertex->instance_bufs & (1 << vbi))) {
       /* TODO: use min and max instance divisor to get a proper range */
       *base = 0;
-      *size = (nvc0->vtxbuf[vbi].max_index + 1) * nvc0->vtxbuf[vbi].stride;
+      *size = nvc0->vtxbuf[vbi].buffer->width0;
    } else {
       assert(nvc0->vbo_max_index != ~0);
       *base = nvc0->vbo_min_index * nvc0->vtxbuf[vbi].stride;
index 6682a1efe66ae1aea88136b3777c1835dca5a6eb..ae9a20ebb816e113a106ae2dd7c148517a1fa0e8 100644 (file)
@@ -229,7 +229,7 @@ static int update_zero_stride( struct svga_context *svga,
 
          translate->set_buffer(translate, vel->vertex_buffer_index,
                                mapped_buffer,
-                               vbuffer->stride, vbuffer->max_index);
+                               vbuffer->stride, ~0);
          translate->run(translate, 0, 1, 0,
                         svga->curr.zero_stride_constants);
 
index 155c869fbd95652725ec7e5868025b3bf9e4649d..18805655bd77b56a59236a0e1076949713011d44 100644 (file)
@@ -517,7 +517,6 @@ void trace_dump_vertex_buffer(const struct pipe_vertex_buffer *state)
    trace_dump_struct_begin("pipe_vertex_buffer");
 
    trace_dump_member(uint, state, stride);
-   trace_dump_member(uint, state, max_index);
    trace_dump_member(uint, state, buffer_offset);
    trace_dump_member(resource_ptr, state, buffer);
 
index 574a7a801115f09061e67356078afbf2d25bcae3..cf6c5b50268d3cb85f938893a4a474f8bfb5291f 100644 (file)
@@ -408,7 +408,6 @@ struct pipe_transfer
 struct pipe_vertex_buffer
 {
    unsigned stride;    /**< stride to same attrib in next vertex, in bytes */
-   unsigned max_index;   /**< number of vertices in this buffer */
    unsigned buffer_offset;  /**< offset to start of data in buffer, in bytes */
    struct pipe_resource *buffer;  /**< the actual buffer */
 };
index 2ff24e17d41c9a321de9ebca56bb0df8407befce..61cf2ddd9df1bf9c77ae6510fcaa456cdda3a699 100644 (file)
@@ -796,7 +796,6 @@ struct dxgi_blitter
 
                vbuf.buffer = pipe_buffer_create(pipe->screen, PIPE_BIND_VERTEX_BUFFER, sizeof(quad_data));
                vbuf.buffer_offset = 0;
-               vbuf.max_index = ~0;
                vbuf.stride = 4 * sizeof(float);
                pipe_buffer_write(pipe, vbuf.buffer, 0, sizeof(quad_data), quad_data);
 
index e1ba6c184fdc9a939afa19e41f9f00efcf6ef8d9..542d65912936c1e8f44346a1540dce0d9a04e36c 100644 (file)
@@ -623,7 +623,6 @@ struct GalliumD3D10Device : public GalliumD3D10ScreenImpl<threadsafe>
                                vertex_buffers[start + i].buffer = buffer ? ((GalliumD3D11Buffer*)buffer)->resource : 0;
                                vertex_buffers[start + i].buffer_offset = new_offsets[i];
                                vertex_buffers[start + i].stride = new_strides[i];
-                               vertex_buffers[start + i].max_index = ~0;
                                last_different = i;
                        }
                }
index a491de27fa675613c9197f6263a3ab389eece1cc..bcc5cb272ca45d93fb2d19c03ee1adce898906ef 100644 (file)
@@ -303,7 +303,6 @@ void polygon_fill(struct polygon *poly, struct vg_context *ctx)
    vbuffer.buffer = poly->vbuf;
    vbuffer.stride = COMPONENTS * sizeof(float);  /* vertex size */
    vbuffer.buffer_offset = 0;
-   vbuffer.max_index = poly->num_verts - 1;
 
    renderer_polygon_stencil_begin(ctx->renderer,
          &velement, ctx->state.vg.fill_rule, VG_FALSE);
@@ -354,7 +353,6 @@ void polygon_array_fill(struct polygon_array *polyarray, struct vg_context *ctx)
 
       polygon_prepare_buffer(ctx, poly);
       vbuffer.buffer = poly->vbuf;
-      vbuffer.max_index = poly->num_verts - 1;
 
       renderer_polygon_stencil(ctx->renderer, &vbuffer,
             PIPE_PRIM_TRIANGLE_FAN, 0, (VGuint) poly->num_verts);
index d21eb44e1164c24f31ba33c7734ec8856a909113..ff82b6071100c76350f8fcbbaf610e344ffdd3b6 100644 (file)
@@ -215,7 +215,6 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index 0c65390e109c171a29696b2a228a985fb66951dd..cc05889dd05c66ca3aceef8a301bdeb7c81ef4c4 100644 (file)
@@ -251,13 +251,11 @@ static void set_vertices( void )
    vbuf.stride = sizeof( struct vertex );
    vbuf.buffer_offset = 0;
    if (draw_strip) {
-      vbuf.max_index = sizeof(vertices_strip) / vbuf.stride;
       vbuf.buffer = screen->user_buffer_create(screen,
                                                vertices_strip,
                                                sizeof(vertices_strip),
                                                PIPE_BIND_VERTEX_BUFFER);
    } else {
-      vbuf.max_index = sizeof(vertices) / vbuf.stride;
       vbuf.buffer = screen->user_buffer_create(screen,
                                                vertices,
                                                sizeof(vertices),
index 58ca639d2073c879fec739356ab55918addccb8a..4e66813b301274304e5d1c7d3d62fd89f977eeb1 100644 (file)
@@ -97,7 +97,6 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index 9af76f51ea2d881cb5b4a85e38aaa514189c9902..a23ca73ac1df4eee14ef8841045335e25a70f561 100644 (file)
@@ -88,7 +88,6 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof(struct vertex);
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index a1a00b3209857fd80a76cc580cdef91396af4b89..47b76530c6b2d62d302f9f0c41d62d52f880fa56 100644 (file)
@@ -89,7 +89,6 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index f61d8b9844d4eb7cadf03cc9a7f453f04d213953..259b3d9527c92cf1a983dac92f8c2200b440c064 100644 (file)
@@ -132,7 +132,6 @@ static void set_vertices( void )
 
    /* vertex data */
    vbuf[0].stride = sizeof( struct vertex );
-   vbuf[0].max_index = sizeof(vertices) / vbuf[0].stride;
    vbuf[0].buffer_offset = 0;
    vbuf[0].buffer = screen->user_buffer_create(screen,
                                                vertices,
@@ -141,7 +140,6 @@ static void set_vertices( void )
 
    /* instance data */
    vbuf[1].stride = sizeof( inst_data[0] );
-   vbuf[1].max_index = sizeof(inst_data) / vbuf[1].stride;
    vbuf[1].buffer_offset = 0;
    vbuf[1].buffer = screen->user_buffer_create(screen,
                                                inst_data,
index 006d61ca88c8c237ddbe10ea46d9f867cd6e38f6..4266c0394d813b80350a01e747b66b865e99c750 100644 (file)
@@ -93,7 +93,6 @@ static void set_vertices( void )
 
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index 1358fa85dfd82d7ea8eb9b075d9fea5f4cf47032..dd64d8b9301d7c5502ce2b4b19bca32cebac6d0f 100644 (file)
@@ -171,7 +171,6 @@ static void set_vertices( void )
    }
 
    vbuf.stride = sizeof( struct vertex );
-   vbuf.max_index = sizeof(vertices) / vbuf.stride;
    vbuf.buffer_offset = 0;
    vbuf.buffer = screen->user_buffer_create(screen,
                                             vertices,
index d9b99a349908b699a30b948b4339eecca1e58b9a..4cbcecfd8ba46c0a7e828da755ef420c2102c4e2 100644 (file)
@@ -384,7 +384,6 @@ setup_interleaved_attribs(struct gl_context *ctx,
             vbuffer->buffer_offset = pointer_to_offset(low);
          }
          vbuffer->stride = stride; /* in bytes */
-         vbuffer->max_index = max_index;
       }
 
       /*
@@ -488,10 +487,6 @@ setup_non_interleaved_attribs(struct gl_context *ctx,
 
       /* common-case setup */
       vbuffer[attr].stride = stride; /* in bytes */
-      if (arrays[mesaAttr]->InstanceDivisor)
-         vbuffer[attr].max_index = arrays[mesaAttr]->_MaxElement;
-      else
-         vbuffer[attr].max_index = max_index;
 
       velements[attr].src_offset = 0;
       velements[attr].instance_divisor = arrays[mesaAttr]->InstanceDivisor;
index 545b32d75bb5f50ec7bbd27f37e8fd61aabdf919..1e1220bfe5279a4339d78ed96610f3780edc67ff 100644 (file)
@@ -179,7 +179,6 @@ st_feedback_draw_vbo(struct gl_context *ctx,
 
       /* common-case setup */
       vbuffers[attr].stride = arrays[mesaAttr]->StrideB; /* in bytes */
-      vbuffers[attr].max_index = max_index;
       velements[attr].instance_divisor = 0;
       velements[attr].vertex_buffer_index = attr;
       velements[attr].src_format =