Mesa (master): r300g: typecast using the r300_texture function

Marek Olšák mareko at kemper.freedesktop.org
Mon Apr 5 17:53:31 UTC 2010


Module: Mesa
Branch: master
Commit: a1f85cf689b6f9ccf6b7310485460f84c8d78cad
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a1f85cf689b6f9ccf6b7310485460f84c8d78cad

Author: Marek Olšák <maraeo at gmail.com>
Date:   Mon Apr  5 18:52:55 2010 +0200

r300g: typecast using the r300_texture function

---

 src/gallium/drivers/r300/r300_context.c       |    2 +-
 src/gallium/drivers/r300/r300_context.h       |    5 +++++
 src/gallium/drivers/r300/r300_emit.c          |   12 ++++++------
 src/gallium/drivers/r300/r300_state.c         |   10 +++++-----
 src/gallium/drivers/r300/r300_state_derived.c |    2 +-
 src/gallium/drivers/r300/r300_texture.c       |   10 +++++-----
 src/gallium/drivers/r300/r300_transfer.c      |   10 +++++-----
 7 files changed, 28 insertions(+), 23 deletions(-)

diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 46fdf08..55850e0 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -76,7 +76,7 @@ r300_is_texture_referenced(struct pipe_context *context,
                            unsigned face, unsigned level)
 {
     struct r300_context* r300 = r300_context(context);
-    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct r300_texture* tex = r300_texture(texture);
 
     return r300->rws->is_buffer_referenced(r300->rws, tex->buffer);
 }
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index 9d7e9d1..be01db5 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -411,6 +411,11 @@ struct r300_context {
 };
 
 /* Convenience cast wrapper. */
+static INLINE struct r300_texture* r300_texture(struct pipe_texture* tex)
+{
+    return (struct r300_texture*)tex;
+}
+
 static INLINE struct r300_context* r300_context(struct pipe_context* context)
 {
     return (struct r300_context*)context;
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index 6ef140d..79988a0 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -406,7 +406,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
     /* Set up colorbuffers. */
     for (i = 0; i < fb->nr_cbufs; i++) {
         surf = fb->cbufs[i];
-        tex = (struct r300_texture*)surf->texture;
+        tex = r300_texture(surf->texture);
         assert(tex && tex->buffer && "cbuf is marked, but NULL!");
 
         OUT_CS_REG_SEQ(R300_RB3D_COLOROFFSET0 + (4 * i), 1);
@@ -425,7 +425,7 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
     /* Set up a zbuffer. */
     if (fb->zsbuf) {
         surf = fb->zsbuf;
-        tex = (struct r300_texture*)surf->texture;
+        tex = r300_texture(surf->texture);
         assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
 
         OUT_CS_REG_SEQ(R300_ZB_DEPTHOFFSET, 1);
@@ -739,7 +739,7 @@ void r300_emit_textures_state(struct r300_context *r300,
             OUT_CS_REG(R300_TX_FORMAT2_0 + (i * 4), texstate->format[2]);
 
             OUT_CS_REG_SEQ(R300_TX_OFFSET_0 + (i * 4), 1);
-            OUT_CS_TEX_RELOC((struct r300_texture *)allstate->fragment_sampler_views[i]->texture,
+            OUT_CS_TEX_RELOC(r300_texture(allstate->fragment_sampler_views[i]->texture),
                              texstate->tile_config,
                              RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0, 0);
         }
@@ -998,7 +998,7 @@ void r300_emit_buffer_validate(struct r300_context *r300,
 validate:
     /* Color buffers... */
     for (i = 0; i < fb->nr_cbufs; i++) {
-        tex = (struct r300_texture*)fb->cbufs[i]->texture;
+        tex = r300_texture(fb->cbufs[i]->texture);
         assert(tex && tex->buffer && "cbuf is marked, but NULL!");
         if (!r300_add_texture(r300->rws, tex,
 			      0, RADEON_GEM_DOMAIN_VRAM)) {
@@ -1008,7 +1008,7 @@ validate:
     }
     /* ...depth buffer... */
     if (fb->zsbuf) {
-        tex = (struct r300_texture*)fb->zsbuf->texture;
+        tex = r300_texture(fb->zsbuf->texture);
         assert(tex && tex->buffer && "zsbuf is marked, but NULL!");
         if (!r300_add_texture(r300->rws, tex,
 			      0, RADEON_GEM_DOMAIN_VRAM)) {
@@ -1022,7 +1022,7 @@ validate:
             continue;
         }
 
-        tex = (struct r300_texture*)texstate->fragment_sampler_views[i]->texture;
+        tex = r300_texture(texstate->fragment_sampler_views[i]->texture);
         if (!r300_add_texture(r300->rws, tex,
 			      RADEON_GEM_DOMAIN_GTT | RADEON_GEM_DOMAIN_VRAM, 0)) {
             r300->context.flush(&r300->context, 0, NULL);
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index 2309f35..6549833 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -554,7 +554,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
             continue;
         }
 
-        tex = (struct r300_texture*)old_state->cbufs[i]->texture;
+        tex = r300_texture(old_state->cbufs[i]->texture);
 
         if (tex) {
             r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
@@ -566,7 +566,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
     if (old_state->zsbuf &&
         (!new_state->zsbuf ||
          old_state->zsbuf->texture != new_state->zsbuf->texture)) {
-        tex = (struct r300_texture*)old_state->zsbuf->texture;
+        tex = r300_texture(old_state->zsbuf->texture);
 
         if (tex) {
             r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
@@ -578,7 +578,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
 
     /* Set tiling flags for new surfaces. */
     for (i = 0; i < new_state->nr_cbufs; i++) {
-        tex = (struct r300_texture*)new_state->cbufs[i]->texture;
+        tex = r300_texture(new_state->cbufs[i]->texture);
         level = new_state->cbufs[i]->level;
 
         r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
@@ -587,7 +587,7 @@ static void r300_fb_update_tiling_flags(struct r300_context *r300,
                                         tex->mip_macrotile[level]);
     }
     if (new_state->zsbuf) {
-        tex = (struct r300_texture*)new_state->zsbuf->texture;
+        tex = r300_texture(new_state->zsbuf->texture);
         level = new_state->zsbuf->level;
 
         r300->rws->buffer_set_tiling(r300->rws, tex->buffer,
@@ -992,7 +992,7 @@ static void r300_set_fragment_sampler_views(struct pipe_context* pipe,
             dirty_tex = TRUE;
 
             /* R300-specific - set the texrect factor in the fragment shader */
-            texture = (struct r300_texture *)views[i]->texture;
+            texture = r300_texture(views[i]->texture);
             if (!is_r500 && texture->uses_pitch) {
                 /* XXX It would be nice to re-emit just 1 constant,
                  * XXX not all of them */
diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
index 292b20a..b9d3718 100644
--- a/src/gallium/drivers/r300/r300_state_derived.c
+++ b/src/gallium/drivers/r300/r300_state_derived.c
@@ -470,7 +470,7 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
             state->tx_enable |= 1 << i;
 
             view = state->fragment_sampler_views[i];
-            tex = (struct r300_texture *)view->texture;
+            tex = r300_texture(view->texture);
             sampler = state->sampler_states[i];
 
             assert(view->format == tex->tex.format);
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index cc4cf56..365b1cd 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -585,7 +585,7 @@ void r300_texture_reinterpret_format(struct pipe_screen *screen,
 
     tex->format = new_format;
 
-    r300_setup_texture_state(r300_screen(screen), (struct r300_texture*)tex);
+    r300_setup_texture_state(r300_screen(screen), r300_texture(tex));
 }
 
 unsigned r300_texture_get_offset(struct r300_texture* tex, unsigned level,
@@ -825,7 +825,7 @@ static struct pipe_texture* r300_texture_create(struct pipe_screen* screen,
 
 static void r300_texture_destroy(struct pipe_texture* texture)
 {
-    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct r300_texture* tex = r300_texture(texture);
     struct r300_winsys_screen *rws = (struct r300_winsys_screen *)texture->screen->winsys;
 
     rws->buffer_reference(rws, &tex->buffer, NULL);
@@ -839,7 +839,7 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
                                                  unsigned zslice,
                                                  unsigned flags)
 {
-    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct r300_texture* tex = r300_texture(texture);
     struct pipe_surface* surface = CALLOC_STRUCT(pipe_surface);
     unsigned offset;
 
@@ -919,7 +919,7 @@ static boolean
                             struct winsys_handle *whandle)
 {
     struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
-    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct r300_texture* tex = r300_texture(texture);
     unsigned stride;
 
     if (!tex) {
@@ -999,7 +999,7 @@ boolean r300_get_texture_buffer(struct pipe_screen* screen,
                                 struct r300_winsys_buffer** buffer,
                                 unsigned* stride)
 {
-    struct r300_texture* tex = (struct r300_texture*)texture;
+    struct r300_texture* tex = r300_texture(texture);
     struct r300_winsys_screen *rws = (struct r300_winsys_screen *)screen->winsys;
     struct r300_winsys_buffer *buf;
 
diff --git a/src/gallium/drivers/r300/r300_transfer.c b/src/gallium/drivers/r300/r300_transfer.c
index cbf3174..3cc86ba 100644
--- a/src/gallium/drivers/r300/r300_transfer.c
+++ b/src/gallium/drivers/r300/r300_transfer.c
@@ -126,7 +126,7 @@ r300_get_tex_transfer(struct pipe_context *ctx,
                       enum pipe_transfer_usage usage, unsigned x, unsigned y,
                       unsigned w, unsigned h)
 {
-    struct r300_texture *tex = (struct r300_texture *)texture;
+    struct r300_texture *tex = r300_texture(texture);
     struct r300_screen *r300screen = r300_screen(ctx->screen);
     struct r300_transfer *trans;
     struct pipe_texture base;
@@ -176,9 +176,9 @@ r300_get_tex_transfer(struct pipe_context *ctx,
             }
 
             /* Create the temporary texture. */
-            trans->detiled_texture = (struct r300_texture*)
+            trans->detiled_texture = r300_texture(
                ctx->screen->texture_create(ctx->screen,
-                                           &base);
+                                           &base));
 
             assert(!trans->detiled_texture->microtile &&
                    !trans->detiled_texture->macrotile);
@@ -229,7 +229,7 @@ static void* r300_transfer_map(struct pipe_context *ctx,
 {
     struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
     struct r300_transfer *r300transfer = r300_transfer(transfer);
-    struct r300_texture *tex = (struct r300_texture*)transfer->texture;
+    struct r300_texture *tex = r300_texture(transfer->texture);
     char *map;
     enum pipe_format format = tex->tex.format;
 
@@ -259,7 +259,7 @@ static void r300_transfer_unmap(struct pipe_context *ctx,
 {
     struct r300_winsys_screen *rws = (struct r300_winsys_screen *)ctx->winsys;
     struct r300_transfer *r300transfer = r300_transfer(transfer);
-    struct r300_texture *tex = (struct r300_texture*)transfer->texture;
+    struct r300_texture *tex = r300_texture(transfer->texture);
 
     if (r300transfer->detiled_texture) {
 	rws->buffer_unmap(rws, r300transfer->detiled_texture->buffer);




More information about the mesa-commit mailing list