r300g: typecast using the r300_texture function
authorMarek Olšák <maraeo@gmail.com>
Mon, 5 Apr 2010 16:52:55 +0000 (18:52 +0200)
committerMarek Olšák <maraeo@gmail.com>
Mon, 5 Apr 2010 17:21:09 +0000 (19:21 +0200)
src/gallium/drivers/r300/r300_context.c
src/gallium/drivers/r300/r300_context.h
src/gallium/drivers/r300/r300_emit.c
src/gallium/drivers/r300/r300_state.c
src/gallium/drivers/r300/r300_state_derived.c
src/gallium/drivers/r300/r300_texture.c
src/gallium/drivers/r300/r300_transfer.c

index 46fdf087942999953921040e3f5e5849e941430d..55850e09c3b9d20520d530ac8b13e8a158a20a4a 100644 (file)
@@ -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);
 }
index 9d7e9d1226dcefd359dbb7e7020742f289444983..be01db5b4484d1b7daee847deee5c51348b7b6bb 100644 (file)
@@ -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;
index 6ef140d8a36fa493d143b49d6b268a35f80917a7..79988a0caa66b85ed31a79bf663c0dc0c2cb9b5a 100644 (file)
@@ -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);
index 2309f35326817f85d2000cf4d8f6280c9183bc9c..654983398330ac84cdb7ea96e86911a63f89dab8 100644 (file)
@@ -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 */
index 292b20a7f476248f0a5cff9f4ccf7ca2ef3ae70f..b9d3718f1c9b8408cdf9c9f94a7cd68523d4ee20 100644 (file)
@@ -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);
index cc4cf560a0e986e3ee109a9590127750d3f1183b..365b1cdd55db0378fc637b79443ee754035c1525 100644 (file)
@@ -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;
 
index cbf3174b381430e26a79aa0209903a8ea7e9f245..3cc86bad382de7d14c225c619bf11e30c08e66d8 100644 (file)
@@ -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);