nv40: adapt to vertex element cso
authorRoland Scheidegger <sroland@vmware.com>
Mon, 1 Mar 2010 19:11:47 +0000 (20:11 +0100)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 1 Mar 2010 19:11:47 +0000 (20:11 +0100)
src/gallium/drivers/nv40/nv40_context.h
src/gallium/drivers/nv40/nv40_state.c
src/gallium/drivers/nv40/nv40_state_emit.c
src/gallium/drivers/nv40/nv40_vbo.c

index 4861924dac7c30a9338de054a18e968125fc3082..f96f2b89bf970f361590f25f58ba81226253a30c 100644 (file)
@@ -108,6 +108,12 @@ struct nv40_state {
        struct nouveau_stateobj *hw[NV40_STATE_MAX];
 };
 
+
+struct nv40_vtxelt_state {
+       struct pipe_vertex_element pipe[16];
+       unsigned num_elements;
+};
+
 struct nv40_context {
        struct pipe_context pipe;
 
@@ -158,8 +164,7 @@ struct nv40_context {
        unsigned dirty_samplers;
        struct pipe_vertex_buffer vtxbuf[PIPE_MAX_ATTRIBS];
        unsigned vtxbuf_nr;
-       struct pipe_vertex_element vtxelt[PIPE_MAX_ATTRIBS];
-       unsigned vtxelt_nr;
+       struct nv40_vtxelt_state *vtxelt;
 };
 
 static INLINE struct nv40_context *
index 2073bf0735374f57d04c7bcbbe179907998ba5ed..449e246b8c20abd9f3878996399867f484b11ffe 100644 (file)
@@ -684,15 +684,34 @@ nv40_set_vertex_buffers(struct pipe_context *pipe, unsigned count,
        nv40->draw_dirty |= NV40_NEW_ARRAYS;
 }
 
+static void *
+nv40_vtxelts_state_create(struct pipe_context *pipe,
+                         unsigned num_elements,
+                         const struct pipe_vertex_element *elements)
+{
+       struct nv40_vtxelt_state *cso = CALLOC_STRUCT(nv40_vtxelt_state);
+
+       assert(num_elements < 16); /* not doing fallbacks yet */
+       cso->num_elements = num_elements;
+       memcpy(cso->pipe, elements, num_elements * sizeof(*elements));
+
+/*     nv40_vtxelt_construct(cso);*/
+
+       return (void *)cso;
+}
+
 static void
-nv40_set_vertex_elements(struct pipe_context *pipe, unsigned count,
-                        const struct pipe_vertex_element *ve)
+nv40_vtxelts_state_delete(struct pipe_context *pipe, void *hwcso)
 {
-       struct nv40_context *nv40 = nv40_context(pipe);
+       FREE(hwcso);
+}
 
-       memcpy(nv40->vtxelt, ve, sizeof(*ve) * count);
-       nv40->vtxelt_nr = count;
+static void
+nv40_vtxelts_state_bind(struct pipe_context *pipe, void *hwcso)
+{
+       struct nv40_context *nv40 = nv40_context(pipe);
 
+       nv40->vtxelt = hwcso;
        nv40->dirty |= NV40_NEW_ARRAYS;
        nv40->draw_dirty |= NV40_NEW_ARRAYS;
 }
@@ -737,7 +756,10 @@ nv40_init_state_functions(struct nv40_context *nv40)
        nv40->pipe.set_scissor_state = nv40_set_scissor_state;
        nv40->pipe.set_viewport_state = nv40_set_viewport_state;
 
+       nv40->pipe.create_vertex_elements_state = nv40_vtxelts_state_create;
+       nv40->pipe.delete_vertex_elements_state = nv40_vtxelts_state_delete;
+       nv40->pipe.bind_vertex_elements_state = nv40_vtxelts_state_bind;
+
        nv40->pipe.set_vertex_buffers = nv40_set_vertex_buffers;
-       nv40->pipe.set_vertex_elements = nv40_set_vertex_elements;
 }
 
index 8990f303ce4e300d7465d5da6fe38571d2768270..297d71f4fac67eb6fd53a97e3994c7b87ee8a474 100644 (file)
@@ -174,7 +174,7 @@ nv40_state_validate_swtnl(struct nv40_context *nv40)
 
        if (nv40->draw_dirty & NV40_NEW_ARRAYS) {
                draw_set_vertex_buffers(draw, nv40->vtxbuf_nr, nv40->vtxbuf);
-               draw_set_vertex_elements(draw, nv40->vtxelt_nr, nv40->vtxelt);  
+               draw_set_vertex_elements(draw, nv40->vtxelt->num_elements, nv40->vtxelt->pipe); 
        }
 
        nv40_state_do_validate(nv40, swtnl_states);
index 7812460d2ed2ad1e26f239c9a9c2bd93c13b6641..fabdf4bf23b95b35e8f56580924cebc93ca34b56 100644 (file)
@@ -493,16 +493,16 @@ nv40_vbo_validate(struct nv40_context *nv40)
        int hw;
 
        vtxbuf = so_new(3, 17, 18);
-       so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt_nr);
+       so_method(vtxbuf, curie, NV40TCL_VTXBUF_ADDRESS(0), nv40->vtxelt->num_elements);
        vtxfmt = so_new(1, 16, 0);
-       so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt_nr);
+       so_method(vtxfmt, curie, NV40TCL_VTXFMT(0), nv40->vtxelt->num_elements);
 
-       for (hw = 0; hw < nv40->vtxelt_nr; hw++) {
+       for (hw = 0; hw < nv40->vtxelt->num_elements; hw++) {
                struct pipe_vertex_element *ve;
                struct pipe_vertex_buffer *vb;
                unsigned type, ncomp;
 
-               ve = &nv40->vtxelt[hw];
+               ve = &nv40->vtxelt->pipe[hw];
                vb = &nv40->vtxbuf[ve->vertex_buffer_index];
 
                if (!vb->stride) {