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!
This commit is contained in:
Ben Skeggs 2007-12-12 14:19:59 +11:00
parent 5891598012
commit 79bca7dd88
8 changed files with 147 additions and 155 deletions

View file

@ -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;

View file

@ -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);

View file

@ -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);
nv40->nvws->notifier_reset(nv40->query, id);
q->ready = 0;
assert(nv40query->type == PIPE_QUERY_OCCLUSION_COUNTER);
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;
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);
}
}
static void
nv40_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
{
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);
BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
OUT_RING ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
((id * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
FIRE_RING ();
((nv40query->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
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;
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);
}
*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;
}

View file

@ -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)
@ -546,19 +558,6 @@ nv40_set_clip_state(struct pipe_context *pipe,
nv40->dirty |= NV40_NEW_VERTPROG;
}
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 )
@ -732,12 +731,6 @@ nv40_set_polygon_stipple(struct pipe_context *pipe,
OUT_RINGp ((uint32_t *)stipple->stipple, 32);
}
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)
@ -749,18 +742,6 @@ nv40_set_scissor_state(struct pipe_context *pipe,
OUT_RING (((s->maxy - s->miny) << 16) | s->miny);
}
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;
}

View file

@ -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];

View file

@ -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;
}

View file

@ -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;
}

View file

@ -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
@ -131,12 +142,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 )
@ -155,24 +160,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;
}