diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2007-12-12 14:19:59 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2007-12-12 14:20:58 +1100 |
commit | 79bca7dd884da33c06ecd3dabb893f9cfed1aaed (patch) | |
tree | adb844a1d95f794e9e24d22093b778cbabddd8a0 /src | |
parent | 58915980127ab4e57b6b40a8c42f44be4a12aeae (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')
-rw-r--r-- | src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c | 42 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_context.h | 4 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_query.c | 126 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_state.c | 50 | ||||
-rw-r--r-- | src/mesa/pipe/nv40/nv40_surface.c | 3 | ||||
-rw-r--r-- | src/mesa/pipe/nv50/nv50_context.c | 11 | ||||
-rw-r--r-- | src/mesa/pipe/nv50/nv50_query.c | 26 | ||||
-rw-r--r-- | src/mesa/pipe/nv50/nv50_state.c | 36 |
8 files changed, 145 insertions, 153 deletions
diff --git a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c index fdfad4a539..1e160f04ed 100644 --- a/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c +++ b/src/mesa/drivers/dri/nouveau_winsys/nouveau_winsys_pipe.c @@ -34,18 +34,8 @@ nouveau_get_name(struct pipe_winsys *pws) return "Nouveau/DRI"; } -static unsigned -nouveau_surface_pitch(struct pipe_winsys *ws, unsigned cpp, unsigned width, - unsigned flags) -{ - unsigned pitch = width * cpp; - - pitch = (pitch + 63) & ~63; - return pitch / cpp; -} - static struct pipe_surface * -nouveau_surface_alloc(struct pipe_winsys *ws, unsigned format) +nouveau_surface_alloc(struct pipe_winsys *ws) { struct pipe_surface *surf; @@ -53,12 +43,38 @@ nouveau_surface_alloc(struct pipe_winsys *ws, unsigned format) if (!surf) return NULL; - surf->format = format; surf->refcount = 1; surf->winsys = ws; return surf; } +static int +nouveau_surface_alloc_storage(struct pipe_winsys *ws, struct pipe_surface *surf, + unsigned width, unsigned height, + enum pipe_format format, unsigned flags) +{ + unsigned pitch = ((width * pf_get_size(format)) + 63) & ~63; + int ret; + + surf->format = format; + surf->width = width; + surf->height = height; + surf->cpp = pf_get_size(format); + surf->pitch = pitch / surf->cpp; + + surf->buffer = ws->buffer_create(ws, 256, 0, 0); + if (!surf->buffer) + return 1; + + ret = ws->buffer_data(ws, surf->buffer, pitch * height, NULL, 0); + if (ret) { + ws->buffer_reference(ws, &surf->buffer, NULL); + return ret; + } + + return 0; +} + static void nouveau_surface_release(struct pipe_winsys *ws, struct pipe_surface **s) { @@ -209,8 +225,8 @@ nouveau_create_pipe_winsys(struct nouveau_context *nv) pws->flush_frontbuffer = nouveau_flush_frontbuffer; pws->printf = nouveau_printf; - pws->surface_pitch = nouveau_surface_pitch; pws->surface_alloc = nouveau_surface_alloc; + pws->surface_alloc_storage = nouveau_surface_alloc_storage; pws->surface_release = nouveau_surface_release; pws->buffer_create = nouveau_pipe_bo_create; 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]; diff --git a/src/mesa/pipe/nv50/nv50_context.c b/src/mesa/pipe/nv50/nv50_context.c index 25ead1b564..ed12c6c0d9 100644 --- a/src/mesa/pipe/nv50/nv50_context.c +++ b/src/mesa/pipe/nv50/nv50_context.c @@ -7,16 +7,9 @@ #include "nv50_dma.h" static boolean -nv50_is_format_supported(struct pipe_context *pipe, uint format) +nv50_is_format_supported(struct pipe_context *pipe, enum pipe_format format, + uint type) { - switch (format) { - case PIPE_FORMAT_A8R8G8B8_UNORM: - case PIPE_FORMAT_Z24S8_UNORM: - return TRUE; - default: - break; - }; - return FALSE; } diff --git a/src/mesa/pipe/nv50/nv50_query.c b/src/mesa/pipe/nv50/nv50_query.c index 51cf6804d7..69eb0e700b 100644 --- a/src/mesa/pipe/nv50/nv50_query.c +++ b/src/mesa/pipe/nv50/nv50_query.c @@ -3,28 +3,46 @@ #include "nv50_context.h" #include "nv50_dma.h" +static struct pipe_query * +nv50_query_create(struct pipe_context *pipe, unsigned type) +{ + NOUVEAU_ERR("unimplemented\n"); + return NULL; +} + static void -nv50_query_begin(struct pipe_context *pipe, struct pipe_query_object *q) +nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *q) { NOUVEAU_ERR("unimplemented\n"); } static void -nv50_query_end(struct pipe_context *pipe, struct pipe_query_object *q) +nv50_query_begin(struct pipe_context *pipe, struct pipe_query *q) { NOUVEAU_ERR("unimplemented\n"); } static void -nv50_query_wait(struct pipe_context *pipe, struct pipe_query_object *q) +nv50_query_end(struct pipe_context *pipe, struct pipe_query *q) +{ + NOUVEAU_ERR("unimplemented\n"); +} + +static boolean +nv50_query_result(struct pipe_context *pipe, struct pipe_query *q, + boolean wait, uint64_t *result) { NOUVEAU_ERR("unimplemented\n"); + *result = 0xdeadcafe; + return TRUE; } void nv50_init_query_functions(struct nv50_context *nv50) { + nv50->pipe.create_query = nv50_query_create; + nv50->pipe.destroy_query = nv50_query_destroy; nv50->pipe.begin_query = nv50_query_begin; nv50->pipe.end_query = nv50_query_end; - nv50->pipe.wait_query = nv50_query_wait; + nv50->pipe.get_query_result = nv50_query_result; } diff --git a/src/mesa/pipe/nv50/nv50_state.c b/src/mesa/pipe/nv50/nv50_state.c index 778b9f5c9a..0a27a4676e 100644 --- a/src/mesa/pipe/nv50/nv50_state.c +++ b/src/mesa/pipe/nv50/nv50_state.c @@ -10,6 +10,7 @@ static void * nv50_alpha_test_state_create(struct pipe_context *pipe, const struct pipe_alpha_test_state *cso) { + return NULL; } static void @@ -26,6 +27,7 @@ static void * nv50_blend_state_create(struct pipe_context *pipe, const struct pipe_blend_state *cso) { + return NULL; } static void @@ -42,6 +44,7 @@ static void * nv50_sampler_state_create(struct pipe_context *pipe, const struct pipe_sampler_state *cso) { + return NULL; } static void @@ -55,10 +58,17 @@ nv50_sampler_state_delete(struct pipe_context *pipe, void *hwcso) { } +static void +nv50_set_sampler_texture(struct pipe_context *pipe, unsigned unit, + struct pipe_texture *pt) +{ +} + static void * nv50_rasterizer_state_create(struct pipe_context *pipe, const struct pipe_rasterizer_state *cso) { + return NULL; } static void @@ -75,6 +85,7 @@ static void * nv50_depth_stencil_state_create(struct pipe_context *pipe, const struct pipe_depth_stencil_state *cso) { + return NULL; } static void @@ -132,12 +143,6 @@ nv50_set_clip_state(struct pipe_context *pipe, } static void -nv50_set_clear_color_state(struct pipe_context *pipe, - const struct pipe_clear_color_state *ccol) -{ -} - -static void nv50_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index, const struct pipe_constant_buffer *buf ) { @@ -156,24 +161,12 @@ nv50_set_polygon_stipple(struct pipe_context *pipe, } static void -nv50_set_sampler_units(struct pipe_context *pipe, - uint num_samplers, const uint *units) -{ -} - -static void nv50_set_scissor_state(struct pipe_context *pipe, const struct pipe_scissor_state *s) { } static void -nv50_set_texture_state(struct pipe_context *pipe, unsigned unit, - struct pipe_texture *pt) -{ -} - -static void nv50_set_viewport_state(struct pipe_context *pipe, const struct pipe_viewport_state *vpt) { @@ -205,6 +198,7 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.create_sampler_state = nv50_sampler_state_create; nv50->pipe.bind_sampler_state = nv50_sampler_state_bind; nv50->pipe.delete_sampler_state = nv50_sampler_state_delete; + nv50->pipe.set_sampler_texture = nv50_set_sampler_texture; nv50->pipe.create_rasterizer_state = nv50_rasterizer_state_create; nv50->pipe.bind_rasterizer_state = nv50_rasterizer_state_bind; @@ -224,19 +218,13 @@ nv50_init_state_functions(struct nv50_context *nv50) nv50->pipe.set_blend_color = nv50_set_blend_color; nv50->pipe.set_clip_state = nv50_set_clip_state; - nv50->pipe.set_clear_color_state = nv50_set_clear_color_state; nv50->pipe.set_constant_buffer = nv50_set_constant_buffer; nv50->pipe.set_framebuffer_state = nv50_set_framebuffer_state; nv50->pipe.set_polygon_stipple = nv50_set_polygon_stipple; - nv50->pipe.set_sampler_units = nv50_set_sampler_units; nv50->pipe.set_scissor_state = nv50_set_scissor_state; - nv50->pipe.set_texture_state = nv50_set_texture_state; nv50->pipe.set_viewport_state = nv50_set_viewport_state; nv50->pipe.set_vertex_buffer = nv50_set_vertex_buffer; nv50->pipe.set_vertex_element = nv50_set_vertex_element; - -// nv50->pipe.set_feedback_state = nv50_set_feedback_state; -// nv50->pipe.set_feedback_buffer = nv50_set_feedback_buffer; } |