summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/nv40
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers/nv40')
-rw-r--r--src/gallium/drivers/nv40/nv40_context.c1
-rw-r--r--src/gallium/drivers/nv40/nv40_context.h10
-rw-r--r--src/gallium/drivers/nv40/nv40_miptree.c7
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.c1
-rw-r--r--src/gallium/drivers/nv40/nv40_screen.h3
-rw-r--r--src/gallium/drivers/nv40/nv40_state.c34
-rw-r--r--src/gallium/drivers/nv40/nv40_state.h4
-rw-r--r--src/gallium/drivers/nv40/nv40_state_emit.c2
-rw-r--r--src/gallium/drivers/nv40/nv40_transfer.c23
-rw-r--r--src/gallium/drivers/nv40/nv40_vbo.c8
10 files changed, 62 insertions, 31 deletions
diff --git a/src/gallium/drivers/nv40/nv40_context.c b/src/gallium/drivers/nv40/nv40_context.c
index 65dc73e88b..e828f17643 100644
--- a/src/gallium/drivers/nv40/nv40_context.c
+++ b/src/gallium/drivers/nv40/nv40_context.c
@@ -74,6 +74,7 @@ nv40_create(struct pipe_screen *pscreen, void *priv)
nv40_init_query_functions(nv40);
nv40_init_surface_functions(nv40);
nv40_init_state_functions(nv40);
+ nv40_init_transfer_functions(nv40);
/* Create, configure, and install fallback swtnl path */
nv40->draw = draw_create();
diff --git a/src/gallium/drivers/nv40/nv40_context.h b/src/gallium/drivers/nv40/nv40_context.h
index 97fb6a2ef9..cb5d9e2d9d 100644
--- a/src/gallium/drivers/nv40/nv40_context.h
+++ b/src/gallium/drivers/nv40/nv40_context.h
@@ -107,6 +107,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;
@@ -157,8 +163,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 *
@@ -178,6 +183,7 @@ struct nv40_state_entry {
extern void nv40_init_state_functions(struct nv40_context *nv40);
extern void nv40_init_surface_functions(struct nv40_context *nv40);
extern void nv40_init_query_functions(struct nv40_context *nv40);
+extern void nv40_init_transfer_functions(struct nv40_context *nv40);
extern void nv40_screen_init_miptree_functions(struct pipe_screen *pscreen);
diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index 85d7e1f197..62e97bcea4 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -20,7 +20,7 @@ nv40_miptree_layout(struct nv40_miptree *mt)
PIPE_TEXTURE_USAGE_DEPTH_STENCIL |
PIPE_TEXTURE_USAGE_RENDER_TARGET |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
- PIPE_TEXTURE_USAGE_PRIMARY);
+ PIPE_TEXTURE_USAGE_SCANOUT);
if (pt->target == PIPE_TEXTURE_CUBE) {
nr_faces = 6;
@@ -80,7 +80,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
pt->height0 & (pt->height0 - 1))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
else
- if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
+ if (pt->tex_usage & (PIPE_TEXTURE_USAGE_SCANOUT |
PIPE_TEXTURE_USAGE_DISPLAY_TARGET |
PIPE_TEXTURE_USAGE_DEPTH_STENCIL))
mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
@@ -227,9 +227,10 @@ void
nv40_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv40_miptree_create;
- pscreen->texture_blanket = nv40_miptree_blanket;
pscreen->texture_destroy = nv40_miptree_destroy;
pscreen->get_tex_surface = nv40_miptree_surface_new;
pscreen->tex_surface_destroy = nv40_miptree_surface_del;
+
+ nouveau_screen(pscreen)->texture_blanket = nv40_miptree_blanket;
}
diff --git a/src/gallium/drivers/nv40/nv40_screen.c b/src/gallium/drivers/nv40/nv40_screen.c
index b216c5e38c..dbcc33d8d9 100644
--- a/src/gallium/drivers/nv40/nv40_screen.c
+++ b/src/gallium/drivers/nv40/nv40_screen.c
@@ -201,7 +201,6 @@ nv40_screen_create(struct pipe_winsys *ws, struct nouveau_device *dev)
pscreen->context_create = nv40_create;
nv40_screen_init_miptree_functions(pscreen);
- nv40_screen_init_transfer_functions(pscreen);
/* 3D object */
switch (dev->chipset & 0xf0) {
diff --git a/src/gallium/drivers/nv40/nv40_screen.h b/src/gallium/drivers/nv40/nv40_screen.h
index 9437aa050d..2765ab764a 100644
--- a/src/gallium/drivers/nv40/nv40_screen.h
+++ b/src/gallium/drivers/nv40/nv40_screen.h
@@ -34,7 +34,4 @@ nv40_screen(struct pipe_screen *screen)
return (struct nv40_screen *)screen;
}
-void
-nv40_screen_init_transfer_functions(struct pipe_screen *pscreen);
-
#endif
diff --git a/src/gallium/drivers/nv40/nv40_state.c b/src/gallium/drivers/nv40/nv40_state.c
index 4f28675e64..ee471e6ce4 100644
--- a/src/gallium/drivers/nv40/nv40_state.c
+++ b/src/gallium/drivers/nv40/nv40_state.c
@@ -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;
}
diff --git a/src/gallium/drivers/nv40/nv40_state.h b/src/gallium/drivers/nv40/nv40_state.h
index 192074e747..e2e69420ea 100644
--- a/src/gallium/drivers/nv40/nv40_state.h
+++ b/src/gallium/drivers/nv40/nv40_state.h
@@ -73,6 +73,8 @@ struct nv40_fragment_program {
struct nouveau_stateobj *so;
};
+#define NV40_MAX_TEXTURE_LEVELS 16
+
struct nv40_miptree {
struct pipe_texture base;
struct nouveau_bo *bo;
@@ -83,7 +85,7 @@ struct nv40_miptree {
struct {
uint pitch;
uint *image_offset;
- } level[PIPE_MAX_TEXTURE_LEVELS];
+ } level[NV40_MAX_TEXTURE_LEVELS];
};
#endif
diff --git a/src/gallium/drivers/nv40/nv40_state_emit.c b/src/gallium/drivers/nv40/nv40_state_emit.c
index 8990f303ce..297d71f4fa 100644
--- a/src/gallium/drivers/nv40/nv40_state_emit.c
+++ b/src/gallium/drivers/nv40/nv40_state_emit.c
@@ -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);
diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
index 0462a042c3..c552a68113 100644
--- a/src/gallium/drivers/nv40/nv40_transfer.c
+++ b/src/gallium/drivers/nv40/nv40_transfer.c
@@ -33,11 +33,12 @@ nv40_compatible_transfer_tex(struct pipe_texture *pt, unsigned width, unsigned h
}
static struct pipe_transfer *
-nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
+nv40_transfer_new(struct pipe_context *pcontext, struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice,
enum pipe_transfer_usage usage,
unsigned x, unsigned y, unsigned w, unsigned h)
{
+ struct pipe_screen *pscreen = pcontext->screen;
struct nv40_miptree *mt = (struct nv40_miptree *)pt;
struct nv40_transfer *tx;
struct pipe_texture tx_tex_template, *tx_tex;
@@ -117,12 +118,12 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv40_transfer_del(struct pipe_transfer *ptx)
+nv40_transfer_del(struct pipe_context *pcontext, struct pipe_transfer *ptx)
{
struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
if (!tx->direct && (ptx->usage & PIPE_TRANSFER_WRITE)) {
- struct pipe_screen *pscreen = ptx->texture->screen;
+ struct pipe_screen *pscreen = pcontext->screen;
struct nv40_screen *nvscreen = nv40_screen(pscreen);
struct pipe_surface *dst;
@@ -145,8 +146,9 @@ nv40_transfer_del(struct pipe_transfer *ptx)
}
static void *
-nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+nv40_transfer_map(struct pipe_context *pcontext, struct pipe_transfer *ptx)
{
+ struct pipe_screen *pscreen = pcontext->screen;
struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
struct nv04_surface *ns = (struct nv04_surface *)tx->surface;
struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
@@ -160,8 +162,9 @@ nv40_transfer_map(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
}
static void
-nv40_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
+nv40_transfer_unmap(struct pipe_context *pcontext, struct pipe_transfer *ptx)
{
+ struct pipe_screen *pscreen = pcontext->screen;
struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
struct nv40_miptree *mt = (struct nv40_miptree *)tx->surface->texture;
@@ -169,10 +172,10 @@ nv40_transfer_unmap(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
}
void
-nv40_screen_init_transfer_functions(struct pipe_screen *pscreen)
+nv40_init_transfer_functions(struct nv40_context *nv40)
{
- pscreen->get_tex_transfer = nv40_transfer_new;
- pscreen->tex_transfer_destroy = nv40_transfer_del;
- pscreen->transfer_map = nv40_transfer_map;
- pscreen->transfer_unmap = nv40_transfer_unmap;
+ nv40->pipe.get_tex_transfer = nv40_transfer_new;
+ nv40->pipe.tex_transfer_destroy = nv40_transfer_del;
+ nv40->pipe.transfer_map = nv40_transfer_map;
+ nv40->pipe.transfer_unmap = nv40_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv40/nv40_vbo.c b/src/gallium/drivers/nv40/nv40_vbo.c
index 7812460d2e..fabdf4bf23 100644
--- a/src/gallium/drivers/nv40/nv40_vbo.c
+++ b/src/gallium/drivers/nv40/nv40_vbo.c
@@ -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) {