summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/nv40
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2007-12-12 14:19:59 +1100
committerBen Skeggs <skeggsb@gmail.com>2007-12-12 14:20:58 +1100
commit79bca7dd884da33c06ecd3dabb893f9cfed1aaed (patch)
treeadb844a1d95f794e9e24d22093b778cbabddd8a0 /src/mesa/pipe/nv40
parent58915980127ab4e57b6b40a8c42f44be4a12aeae (diff)
nouveau: adapt
Some things that worked before are now broken, there's an "XXX:" around one of the culprits in the GL state tracker so hopefully it'll get fixed soon!
Diffstat (limited to 'src/mesa/pipe/nv40')
-rw-r--r--src/mesa/pipe/nv40/nv40_context.h4
-rw-r--r--src/mesa/pipe/nv40/nv40_query.c126
-rw-r--r--src/mesa/pipe/nv40/nv40_state.c50
-rw-r--r--src/mesa/pipe/nv40/nv40_surface.c3
4 files changed, 80 insertions, 103 deletions
diff --git a/src/mesa/pipe/nv40/nv40_context.h b/src/mesa/pipe/nv40/nv40_context.h
index 3a1d3f076c..83d3f7b676 100644
--- a/src/mesa/pipe/nv40/nv40_context.h
+++ b/src/mesa/pipe/nv40/nv40_context.h
@@ -35,7 +35,7 @@ struct nv40_context {
/* query objects */
struct nouveau_notifier *query;
- struct pipe_query_object **query_objects;
+ boolean *query_objects;
uint num_query_objects;
uint32_t dirty;
@@ -64,7 +64,7 @@ struct nv40_context {
struct pipe_vertex_buffer vtxbuf[PIPE_ATTRIB_MAX];
struct pipe_vertex_element vtxelt[PIPE_ATTRIB_MAX];
};
-
+#define nv40_context(ctx) ((struct nv40_context *)(ctx))
extern void nv40_init_state_functions(struct nv40_context *nv40);
extern void nv40_init_surface_functions(struct nv40_context *nv40);
diff --git a/src/mesa/pipe/nv40/nv40_query.c b/src/mesa/pipe/nv40/nv40_query.c
index bcd6fe0cf4..f51b34b119 100644
--- a/src/mesa/pipe/nv40/nv40_query.c
+++ b/src/mesa/pipe/nv40/nv40_query.c
@@ -3,33 +3,57 @@
#include "nv40_context.h"
#include "nv40_dma.h"
-static uint
-nv40_query_object_find(struct nv40_context *nv40, struct pipe_query_object *q)
+/*XXX: Maybe go notifier per-query one day? not sure if PRAMIN space is
+ * plentiful enough however.. */
+struct nv40_query {
+ unsigned type;
+ int id;
+};
+#define nv40_query(o) ((struct nv40_query *)(o))
+
+static struct pipe_query *
+nv40_query_create(struct pipe_context *pipe, unsigned query_type)
{
+ struct nv40_context *nv40 = nv40_context(pipe);
+ struct nv40_query *nv40query;
int id;
for (id = 0; id < nv40->num_query_objects; id++) {
- if (nv40->query_objects[id] == q)
- return id;
+ if (nv40->query_objects[id] == 0)
+ break;
}
+
+ if (id == nv40->num_query_objects)
+ return NULL;
+ nv40->query_objects[id] = TRUE;
- return -1;
+ nv40query = malloc(sizeof(struct nv40_query));
+ nv40query->type = query_type;
+ nv40query->id = id;
+
+ return (struct pipe_query *)nv40query;
}
static void
-nv40_query_begin(struct pipe_context *pipe, struct pipe_query_object *q)
+nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *q)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
- int id;
+ struct nv40_context *nv40 = nv40_context(pipe);
+ struct nv40_query *nv40query = nv40_query(q);
- assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
+ assert(nv40->query_objects[nv40query->id]);
+ nv40->query_objects[nv40query->id] = FALSE;
+ free(nv40query);
+}
- id = nv40_query_object_find(nv40, NULL);
- assert(id >= 0);
- nv40->query_objects[id] = q;
+static void
+nv40_query_begin(struct pipe_context *pipe, struct pipe_query *q)
+{
+ struct nv40_context *nv40 = nv40_context(pipe);
+ struct nv40_query *nv40query = nv40_query(q);
+
+ assert(nv40query->type == PIPE_QUERY_OCCLUSION_COUNTER);
- nv40->nvws->notifier_reset(nv40->query, id);
- q->ready = 0;
+ nv40->nvws->notifier_reset(nv40->query, nv40query->id);
BEGIN_RING(curie, NV40TCL_QUERY_RESET, 1);
OUT_RING (1);
@@ -38,68 +62,44 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query_object *q)
}
static void
-nv40_query_update(struct pipe_context *pipe, struct pipe_query_object *q)
+nv40_query_end(struct pipe_context *pipe, struct pipe_query *q)
{
struct nv40_context *nv40 = (struct nv40_context *)pipe;
- int id;
+ struct nv40_query *nv40query = nv40_query(q);
- id = nv40_query_object_find(nv40, q);
- assert(id >= 0);
-
- if (nv40->nvws->notifier_status(nv40->query, id) == 0) {
- q->ready = 1;
- q->count = nv40->nvws->notifier_retval(nv40->query, id);
- nv40->query_objects[id] = NULL;
- }
-}
-
-static void
-nv40_query_wait(struct pipe_context *pipe, struct pipe_query_object *q)
-{
- nv40_query_update(pipe, q);
- if (!q->ready) {
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
- int id;
-
- id = nv40_query_object_find(nv40, q);
- assert(id >= 0);
-
- nv40->nvws->notifier_wait(nv40->query, id, 0, 0);
- nv40_query_update(pipe, q);
- assert(q->ready);
- }
+ BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
+ OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
+ ((nv40query->id * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
+ FIRE_RING();
}
-static void
-nv40_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
+static boolean
+nv40_query_result(struct pipe_context *pipe, struct pipe_query *q,
+ boolean wait, uint64_t *result)
{
struct nv40_context *nv40 = (struct nv40_context *)pipe;
- int id;
-
- id = nv40_query_object_find(nv40, q);
- assert(id >= 0);
+ struct nv40_query *nv40query = nv40_query(q);
+ struct nouveau_winsys *nvws = nv40->nvws;
+ boolean status;
+
+ status = nvws->notifier_status(nv40->query, nv40query->id);
+ if (status != NV_NOTIFY_STATE_STATUS_COMPLETED) {
+ if (wait == FALSE)
+ return FALSE;
+ nvws->notifier_wait(nv40->query, nv40query->id,
+ NV_NOTIFY_STATE_STATUS_COMPLETED, 0);
+ }
- BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
- OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
- ((id * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
- FIRE_RING ();
-
- /*XXX: Some apps spin waiting for GL_QUERY_RESULT_AVAILABLE_ARB.
- * Core mesa won't ask the driver to update the query object's
- * status in this case, so the app waits forever.. fix this some
- * day.
- */
-#if 0
- nv40_query_update(pipe, q);
-#else
- nv40_query_wait(pipe, q);
-#endif
+ *result = nvws->notifier_retval(nv40->query, nv40query->id);
+ return TRUE;
}
void
nv40_init_query_functions(struct nv40_context *nv40)
{
+ nv40->pipe.create_query = nv40_query_create;
+ nv40->pipe.destroy_query = nv40_query_destroy;
nv40->pipe.begin_query = nv40_query_begin;
nv40->pipe.end_query = nv40_query_end;
- nv40->pipe.wait_query = nv40_query_wait;
+ nv40->pipe.get_query_result = nv40_query_result;
}
diff --git a/src/mesa/pipe/nv40/nv40_state.c b/src/mesa/pipe/nv40/nv40_state.c
index 1d4cbb454d..5aeba684ee 100644
--- a/src/mesa/pipe/nv40/nv40_state.c
+++ b/src/mesa/pipe/nv40/nv40_state.c
@@ -302,6 +302,18 @@ nv40_sampler_state_delete(struct pipe_context *pipe, void *hwcso)
free(hwcso);
}
+static void
+nv40_set_sampler_texture(struct pipe_context *pipe, unsigned unit,
+ struct pipe_texture *miptree)
+{
+ struct nv40_context *nv40 = (struct nv40_context *)pipe;
+
+ nv40->tex_miptree[unit] = miptree;
+ nv40->tex_dirty |= unit;
+
+ nv40->dirty |= NV40_NEW_TEXTURE;
+}
+
static void *
nv40_rasterizer_state_create(struct pipe_context *pipe,
const struct pipe_rasterizer_state *cso)
@@ -547,19 +559,6 @@ nv40_set_clip_state(struct pipe_context *pipe,
}
static void
-nv40_set_clear_color_state(struct pipe_context *pipe,
- const struct pipe_clear_color_state *ccol)
-{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
-
- BEGIN_RING(curie, NV40TCL_CLEAR_VALUE_COLOR, 1);
- OUT_RING ((float_to_ubyte(ccol->color[3]) << 24) |
- (float_to_ubyte(ccol->color[0]) << 16) |
- (float_to_ubyte(ccol->color[1]) << 8) |
- (float_to_ubyte(ccol->color[2]) << 0));
-}
-
-static void
nv40_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
const struct pipe_constant_buffer *buf )
{
@@ -733,12 +732,6 @@ nv40_set_polygon_stipple(struct pipe_context *pipe,
}
static void
-nv40_set_sampler_units(struct pipe_context *pipe,
- uint num_samplers, const uint *units)
-{
-}
-
-static void
nv40_set_scissor_state(struct pipe_context *pipe,
const struct pipe_scissor_state *s)
{
@@ -750,18 +743,6 @@ nv40_set_scissor_state(struct pipe_context *pipe,
}
static void
-nv40_set_texture_state(struct pipe_context *pipe, unsigned unit,
- struct pipe_texture *miptree)
-{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
-
- nv40->tex_miptree[unit] = miptree;
- nv40->tex_dirty |= unit;
-
- nv40->dirty |= NV40_NEW_TEXTURE;
-}
-
-static void
nv40_set_viewport_state(struct pipe_context *pipe,
const struct pipe_viewport_state *vpt)
{
@@ -814,6 +795,7 @@ nv40_init_state_functions(struct nv40_context *nv40)
nv40->pipe.create_sampler_state = nv40_sampler_state_create;
nv40->pipe.bind_sampler_state = nv40_sampler_state_bind;
nv40->pipe.delete_sampler_state = nv40_sampler_state_delete;
+ nv40->pipe.set_sampler_texture = nv40_set_sampler_texture;
nv40->pipe.create_rasterizer_state = nv40_rasterizer_state_create;
nv40->pipe.bind_rasterizer_state = nv40_rasterizer_state_bind;
@@ -833,19 +815,13 @@ nv40_init_state_functions(struct nv40_context *nv40)
nv40->pipe.set_blend_color = nv40_set_blend_color;
nv40->pipe.set_clip_state = nv40_set_clip_state;
- nv40->pipe.set_clear_color_state = nv40_set_clear_color_state;
nv40->pipe.set_constant_buffer = nv40_set_constant_buffer;
nv40->pipe.set_framebuffer_state = nv40_set_framebuffer_state;
nv40->pipe.set_polygon_stipple = nv40_set_polygon_stipple;
- nv40->pipe.set_sampler_units = nv40_set_sampler_units;
nv40->pipe.set_scissor_state = nv40_set_scissor_state;
- nv40->pipe.set_texture_state = nv40_set_texture_state;
nv40->pipe.set_viewport_state = nv40_set_viewport_state;
nv40->pipe.set_vertex_buffer = nv40_set_vertex_buffer;
nv40->pipe.set_vertex_element = nv40_set_vertex_element;
-
-// nv40->pipe.set_feedback_state = nv40_set_feedback_state;
-// nv40->pipe.set_feedback_buffer = nv40_set_feedback_buffer;
}
diff --git a/src/mesa/pipe/nv40/nv40_surface.c b/src/mesa/pipe/nv40/nv40_surface.c
index b4562f26e6..f140b764ca 100644
--- a/src/mesa/pipe/nv40/nv40_surface.c
+++ b/src/mesa/pipe/nv40/nv40_surface.c
@@ -190,10 +190,11 @@ nv40_get_tex_surface(struct pipe_context *pipe,
struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
struct pipe_surface *ps;
- ps = ws->surface_alloc(ws, pt->format);
+ ps = ws->surface_alloc(ws);
if (!ps)
return NULL;
ws->buffer_reference(ws, &ps->buffer, nv40mt->buffer);
+ ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];