summaryrefslogtreecommitdiff
path: root/src/mesa
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-01-16 13:41:50 +1100
committerBen Skeggs <skeggsb@gmail.com>2008-01-16 13:45:31 +1100
commite0e9326bdadb268dbb5eeedb14404ac2f48c103e (patch)
treecad1807addb4f13a50785dadc9f49854e94e0436 /src/mesa
parentbc1ca3793d661de343b956d66ef70605d7de2dbb (diff)
nv40: stronger type safety
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/pipe/nv40/nv40_context.c6
-rw-r--r--src/mesa/pipe/nv40/nv40_context.h7
-rw-r--r--src/mesa/pipe/nv40/nv40_query.c13
-rw-r--r--src/mesa/pipe/nv40/nv40_state.c34
-rw-r--r--src/mesa/pipe/nv40/nv40_surface.c6
-rw-r--r--src/mesa/pipe/nv40/nv40_vbo.c6
6 files changed, 41 insertions, 31 deletions
diff --git a/src/mesa/pipe/nv40/nv40_context.c b/src/mesa/pipe/nv40/nv40_context.c
index 334e50ef89..f6fdd6b437 100644
--- a/src/mesa/pipe/nv40/nv40_context.c
+++ b/src/mesa/pipe/nv40/nv40_context.c
@@ -8,7 +8,7 @@
static const char *
nv40_get_name(struct pipe_context *pipe)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
static char buffer[128];
snprintf(buffer, sizeof(buffer), "NV%02X", nv40->chipset);
@@ -80,7 +80,7 @@ nv40_get_paramf(struct pipe_context *pipe, int param)
static void
nv40_flush(struct pipe_context *pipe, unsigned flags)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nouveau_winsys *nvws = nv40->nvws;
if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
@@ -107,7 +107,7 @@ nv40_flush(struct pipe_context *pipe, unsigned flags)
static void
nv40_destroy(struct pipe_context *pipe)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nouveau_winsys *nvws = nv40->nvws;
if (nv40->draw)
diff --git a/src/mesa/pipe/nv40/nv40_context.h b/src/mesa/pipe/nv40/nv40_context.h
index 86aebbb927..b505efab54 100644
--- a/src/mesa/pipe/nv40/nv40_context.h
+++ b/src/mesa/pipe/nv40/nv40_context.h
@@ -82,7 +82,12 @@ 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))
+
+static inline struct nv40_context *
+nv40_context(struct pipe_context *pipe)
+{
+ return (struct nv40_context *)pipe;
+}
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 ea30d3ede8..06f41fe84f 100644
--- a/src/mesa/pipe/nv40/nv40_query.c
+++ b/src/mesa/pipe/nv40/nv40_query.c
@@ -8,7 +8,12 @@ struct nv40_query {
boolean ready;
uint64_t result;
};
-#define nv40_query(o) ((struct nv40_query *)(o))
+
+static inline struct nv40_query *
+nv40_query(struct pipe_query *pipe)
+{
+ return (struct nv40_query *)pipe;
+}
static struct pipe_query *
nv40_query_create(struct pipe_context *pipe, unsigned query_type)
@@ -55,7 +60,7 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
static void
nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_query *q = nv40_query(pq);
BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
@@ -66,9 +71,9 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
static boolean
nv40_query_result(struct pipe_context *pipe, struct pipe_query *pq,
- boolean wait, uint64_t *result)
+ boolean wait, uint64 *result)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_query *q = nv40_query(pq);
struct nouveau_winsys *nvws = nv40->nvws;
diff --git a/src/mesa/pipe/nv40/nv40_state.c b/src/mesa/pipe/nv40/nv40_state.c
index 41de5650aa..03a9e735c0 100644
--- a/src/mesa/pipe/nv40/nv40_state.c
+++ b/src/mesa/pipe/nv40/nv40_state.c
@@ -37,7 +37,7 @@ nv40_blend_state_create(struct pipe_context *pipe,
static void
nv40_blend_state_bind(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_blend_state *cb = hwcso;
BEGIN_RING(curie, NV40TCL_DITHER_ENABLE, 1);
@@ -234,7 +234,7 @@ static void
nv40_sampler_state_bind(struct pipe_context *pipe, unsigned unit,
void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_sampler_state *ps = hwcso;
nv40->tex_sampler[unit] = ps;
@@ -251,7 +251,7 @@ static void
nv40_set_sampler_texture(struct pipe_context *pipe, unsigned unit,
struct pipe_texture *miptree)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
nv40->tex_miptree[unit] = (struct nv40_miptree *)miptree;
nv40->dirty_samplers |= (1 << unit);
@@ -339,7 +339,7 @@ nv40_rasterizer_state_create(struct pipe_context *pipe,
static void
nv40_rasterizer_state_bind(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_rasterizer_state *rs = hwcso;
BEGIN_RING(curie, NV40TCL_SHADE_MODEL, 1);
@@ -415,7 +415,7 @@ nv40_depth_stencil_alpha_state_create(struct pipe_context *pipe,
static void
nv40_depth_stencil_alpha_state_bind(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_depth_stencil_alpha_state *hw = hwcso;
BEGIN_RING(curie, NV40TCL_DEPTH_FUNC, 3);
@@ -448,7 +448,7 @@ nv40_vp_state_create(struct pipe_context *pipe,
static void
nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_vertex_program *vp = hwcso;
nv40->vertprog.current = vp;
@@ -458,7 +458,7 @@ nv40_vp_state_bind(struct pipe_context *pipe, void *hwcso)
static void
nv40_vp_state_delete(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_vertex_program *vp = hwcso;
nv40_vertprog_destroy(nv40, vp);
@@ -480,7 +480,7 @@ nv40_fp_state_create(struct pipe_context *pipe,
static void
nv40_fp_state_bind(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_fragment_program *fp = hwcso;
nv40->fragprog.current = fp;
@@ -490,7 +490,7 @@ nv40_fp_state_bind(struct pipe_context *pipe, void *hwcso)
static void
nv40_fp_state_delete(struct pipe_context *pipe, void *hwcso)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nv40_fragment_program *fp = hwcso;
nv40_fragprog_destroy(nv40, fp);
@@ -501,7 +501,7 @@ static void
nv40_set_blend_color(struct pipe_context *pipe,
const struct pipe_blend_color *bcol)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
BEGIN_RING(curie, NV40TCL_BLEND_COLOR, 1);
OUT_RING ((float_to_ubyte(bcol->color[3]) << 24) |
@@ -520,7 +520,7 @@ static void
nv40_set_constant_buffer(struct pipe_context *pipe, uint shader, uint index,
const struct pipe_constant_buffer *buf )
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
if (shader == PIPE_SHADER_VERTEX) {
nv40->vertprog.constant_buf = buf->buffer;
@@ -536,7 +536,7 @@ static void
nv40_set_framebuffer_state(struct pipe_context *pipe,
const struct pipe_framebuffer_state *fb)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct pipe_surface *rt[4], *zeta;
uint32_t rt_enable, rt_format, w, h;
int i, colour_format = 0, zeta_format = 0;
@@ -669,7 +669,7 @@ static void
nv40_set_polygon_stipple(struct pipe_context *pipe,
const struct pipe_poly_stipple *stipple)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
BEGIN_RING(curie, NV40TCL_POLYGON_STIPPLE_PATTERN(0), 32);
OUT_RINGp ((uint32_t *)stipple->stipple, 32);
@@ -679,7 +679,7 @@ static void
nv40_set_scissor_state(struct pipe_context *pipe,
const struct pipe_scissor_state *s)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
BEGIN_RING(curie, NV40TCL_SCISSOR_HORIZ, 2);
OUT_RING (((s->maxx - s->minx) << 16) | s->minx);
@@ -690,7 +690,7 @@ static void
nv40_set_viewport_state(struct pipe_context *pipe,
const struct pipe_viewport_state *vpt)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
BEGIN_RING(curie, NV40TCL_VIEWPORT_TRANSLATE_X, 8);
OUT_RINGf (vpt->translate[0]);
@@ -707,7 +707,7 @@ static void
nv40_set_vertex_buffer(struct pipe_context *pipe, unsigned index,
const struct pipe_vertex_buffer *vb)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
nv40->vtxbuf[index] = *vb;
@@ -718,7 +718,7 @@ static void
nv40_set_vertex_element(struct pipe_context *pipe, unsigned index,
const struct pipe_vertex_element *ve)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
nv40->vtxelt[index] = *ve;
diff --git a/src/mesa/pipe/nv40/nv40_surface.c b/src/mesa/pipe/nv40/nv40_surface.c
index 91ac9e3694..159837388f 100644
--- a/src/mesa/pipe/nv40/nv40_surface.c
+++ b/src/mesa/pipe/nv40/nv40_surface.c
@@ -109,7 +109,7 @@ nv40_surface_data(struct pipe_context *pipe, struct pipe_surface *dest,
unsigned src_stride, unsigned srcx, unsigned srcy,
unsigned width, unsigned height)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nouveau_winsys *nvws = nv40->nvws;
nvws->surface_data(nvws, dest, destx, desty, src, src_stride,
@@ -121,7 +121,7 @@ nv40_surface_copy(struct pipe_context *pipe, struct pipe_surface *dest,
unsigned destx, unsigned desty, struct pipe_surface *src,
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nouveau_winsys *nvws = nv40->nvws;
nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
@@ -133,7 +133,7 @@ nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
unsigned destx, unsigned desty, unsigned width,
unsigned height, unsigned value)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct nouveau_winsys *nvws = nv40->nvws;
nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
diff --git a/src/mesa/pipe/nv40/nv40_vbo.c b/src/mesa/pipe/nv40/nv40_vbo.c
index 7cf089e007..3de87ecab5 100644
--- a/src/mesa/pipe/nv40/nv40_vbo.c
+++ b/src/mesa/pipe/nv40/nv40_vbo.c
@@ -192,7 +192,7 @@ boolean
nv40_draw_arrays(struct pipe_context *pipe, unsigned mode, unsigned start,
unsigned count)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
unsigned nr;
assert(nv40_vbo_validate_state(nv40, NULL, 0));
@@ -300,7 +300,7 @@ nv40_draw_elements_inline(struct pipe_context *pipe,
struct pipe_buffer_handle *ib, unsigned ib_size,
unsigned mode, unsigned start, unsigned count)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
struct pipe_winsys *ws = pipe->winsys;
void *map;
@@ -341,7 +341,7 @@ nv40_draw_elements_vbo(struct pipe_context *pipe,
struct pipe_buffer_handle *ib, unsigned ib_size,
unsigned mode, unsigned start, unsigned count)
{
- struct nv40_context *nv40 = (struct nv40_context *)pipe;
+ struct nv40_context *nv40 = nv40_context(pipe);
unsigned nr, type;
switch (ib_size) {