swr/rast: Migrate memory pointers to gfxptr_t type
authorTim Rowley <timothy.o.rowley@intel.com>
Thu, 7 Sep 2017 20:17:23 +0000 (15:17 -0500)
committerTim Rowley <timothy.o.rowley@intel.com>
Wed, 13 Sep 2017 15:09:24 +0000 (10:09 -0500)
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
src/gallium/drivers/swr/rasterizer/codegen/gen_llvm_types.py
src/gallium/drivers/swr/rasterizer/core/state.h
src/gallium/drivers/swr/rasterizer/memory/StoreTile.h
src/gallium/drivers/swr/rasterizer/memory/TilingFunctions.h
src/gallium/drivers/swr/swr_context.cpp
src/gallium/drivers/swr/swr_draw.cpp
src/gallium/drivers/swr/swr_resource.h
src/gallium/drivers/swr/swr_screen.cpp
src/gallium/drivers/swr/swr_state.cpp

index 94f3f9feffbebefd2d22b30c4e34d595612fb4f5..ccf2bde1edd7aa356a9663435746cbd36b1f06de 100644 (file)
@@ -42,7 +42,7 @@ def gen_llvm_type(type, name, is_pointer, is_pointer_pointer, is_array, is_array
     else:
         if type == 'BYTE' or type == 'char' or type == 'uint8_t' or type == 'int8_t' or type == 'bool':
             llvm_type = 'Type::getInt8Ty(ctx)'
-        elif type == 'UINT64' or type == 'INT64' or type == 'uint64_t' or type == 'int64_t':
+        elif type == 'UINT64' or type == 'INT64' or type == 'uint64_t' or type == 'int64_t' or type == 'gfxptr_t':
             llvm_type = 'Type::getInt64Ty(ctx)'
         elif type == 'UINT16' or type == 'int16_t' or type == 'uint16_t':
             llvm_type = 'Type::getInt16Ty(ctx)'
index b0af663d50ec3abbb2e14743a5e438ce5c65617a..13c1d8b7e95a98489a3635257508e92ab82b7877 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "common/formats.h"
 #include "common/intrin.h"
+using gfxptr_t = unsigned long long;
 #include <functional>
 #include <algorithm>
 
@@ -513,7 +514,7 @@ enum SWR_AUX_MODE
 //////////////////////////////////////////////////////////////////////////
 struct SWR_SURFACE_STATE
 {
-    uint8_t *pBaseAddress;
+    gfxptr_t xpBaseAddress;
     SWR_SURFACE_TYPE type;  // @llvm_enum
     SWR_FORMAT format;      // @llvm_enum
     uint32_t width;
@@ -536,7 +537,7 @@ struct SWR_SURFACE_STATE
 
     uint32_t lodOffsets[2][15]; // lod offsets for sampled surfaces
 
-    uint8_t *pAuxBaseAddress;   // Used for compression, append/consume counter, etc.
+    gfxptr_t xpAuxBaseAddress;   // Used for compression, append/consume counter, etc.
     SWR_AUX_MODE auxMode;      // @llvm_enum
 
 
index c3d14e950921d04726bc7a7deec5a305f33d0320..512c33802702bddc9079823dada5e9cf264040b1 100644 (file)
@@ -1179,7 +1179,7 @@ struct StoreRasterTile
                     resolveColor[3] *= oneOverNumSamples;
 
                     // Use the resolve surface state
-                    SWR_SURFACE_STATE* pResolveSurface = (SWR_SURFACE_STATE*)pDstSurface->pAuxBaseAddress;
+                    SWR_SURFACE_STATE* pResolveSurface = (SWR_SURFACE_STATE*)pDstSurface->xpAuxBaseAddress;
                     uint8_t *pDst = (uint8_t*)ComputeSurfaceAddress<false, false>((x + rx), (y + ry),
                         pResolveSurface->arrayIndex + renderTargetArrayIndex, pResolveSurface->arrayIndex + renderTargetArrayIndex,
                         0, pResolveSurface->lod, pResolveSurface);
@@ -2390,7 +2390,7 @@ struct StoreMacroTile
             }
         }
 
-        if (pDstSurface->pAuxBaseAddress)
+        if (pDstSurface->xpAuxBaseAddress)
         {
             uint32_t sampleOffset = KNOB_TILE_X_DIM * KNOB_TILE_Y_DIM * (FormatTraits<SrcFormat>::bpp / 8);
             // Store each raster tile from the hot tile to the destination surface.
index 9222d3edfb8fadb92f4d0380fa5389ff7d660fdb..6c801c7ff690c6f171a004fbdee6e673c57a9bb2 100644 (file)
@@ -694,5 +694,5 @@ template<bool UseCachedOffsets, bool IsRead>
 INLINE
 void* ComputeSurfaceAddress(uint32_t x, uint32_t y, uint32_t z, uint32_t array, uint32_t sampleNum, uint32_t lod, const SWR_SURFACE_STATE *pState)
 {
-    return pState->pBaseAddress + ComputeSurfaceOffset<UseCachedOffsets>(x, y, z, array, sampleNum, lod, pState);
+    return (void*)(pState->xpBaseAddress + ComputeSurfaceOffset<UseCachedOffsets>(x, y, z, array, sampleNum, lod, pState));
 }
index c058870f2762bf279d6c5b0ed2909f1cd580be2c..e95bd3bcaa4353165e751818ac82b85a4073ddc6 100644 (file)
@@ -152,12 +152,12 @@ swr_transfer_map(struct pipe_context *pipe,
          for (int y = box->y; y < box->y + box->height; y++) {
             if (spr->base.format == PIPE_FORMAT_Z24_UNORM_S8_UINT) {
                for (int x = box->x; x < box->x + box->width; x++)
-                  spr->swr.pBaseAddress[zbase + 4 * x + 3] =
-                     spr->secondary.pBaseAddress[sbase + x];
+                  ((uint8_t*)(spr->swr.xpBaseAddress))[zbase + 4 * x + 3] =
+                     ((uint8_t*)(spr->secondary.xpBaseAddress))[sbase + x];
             } else if (spr->base.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
                for (int x = box->x; x < box->x + box->width; x++)
-                  spr->swr.pBaseAddress[zbase + 8 * x + 4] =
-                     spr->secondary.pBaseAddress[sbase + x];
+                  ((uint8_t*)(spr->swr.xpBaseAddress))[zbase + 8 * x + 4] =
+                     ((uint8_t*)(spr->secondary.xpBaseAddress))[sbase + x];
             }
             zbase += spr->swr.pitch;
             sbase += spr->secondary.pitch;
@@ -171,7 +171,7 @@ swr_transfer_map(struct pipe_context *pipe,
 
    *transfer = pt;
 
-   return spr->swr.pBaseAddress + offset + spr->mip_offsets[level];
+   return (void*)(spr->swr.xpBaseAddress + offset + spr->mip_offsets[level]);
 }
 
 static void
@@ -199,12 +199,12 @@ swr_transfer_flush_region(struct pipe_context *pipe,
       for (int y = box.y; y < box.y + box.height; y++) {
          if (spr->base.format == PIPE_FORMAT_Z24_UNORM_S8_UINT) {
             for (int x = box.x; x < box.x + box.width; x++)
-               spr->secondary.pBaseAddress[sbase + x] =
-                  spr->swr.pBaseAddress[zbase + 4 * x + 3];
+               ((uint8_t*)(spr->secondary.xpBaseAddress))[sbase + x] =
+                  ((uint8_t*)(spr->swr.xpBaseAddress))[zbase + 4 * x + 3];
          } else if (spr->base.format == PIPE_FORMAT_Z32_FLOAT_S8X24_UINT) {
             for (int x = box.x; x < box.x + box.width; x++)
-               spr->secondary.pBaseAddress[sbase + x] =
-                  spr->swr.pBaseAddress[zbase + 8 * x + 4];
+               ((uint8_t*)(spr->secondary.xpBaseAddress))[sbase + x] =
+                  ((uint8_t*)(spr->swr.xpBaseAddress))[zbase + 8 * x + 4];
          }
          zbase += spr->swr.pitch;
          sbase += spr->secondary.pitch;
index 2363800f8056ab6135197728d90f1528e335198a..d7f24d6e34674743b9b2ca177e6ceff6af2c4e43 100644 (file)
@@ -295,7 +295,7 @@ swr_store_render_target(struct pipe_context *pipe,
    struct SWR_SURFACE_STATE *renderTarget = &pDC->renderTargets[attachment];
 
    /* Only proceed if there's a valid surface to store to */
-   if (renderTarget->pBaseAddress) {
+   if (renderTarget->xpBaseAddress) {
       swr_update_draw_context(ctx);
       SWR_RECT full_rect =
          {0, 0,
@@ -322,9 +322,9 @@ swr_store_dirty_resource(struct pipe_context *pipe,
       swr_draw_context *pDC = &ctx->swrDC;
       SWR_SURFACE_STATE *renderTargets = pDC->renderTargets;
       for (uint32_t i = 0; i < SWR_NUM_ATTACHMENTS; i++)
-         if (renderTargets[i].pBaseAddress == spr->swr.pBaseAddress ||
-             (spr->secondary.pBaseAddress &&
-              renderTargets[i].pBaseAddress == spr->secondary.pBaseAddress)) {
+         if (renderTargets[i].xpBaseAddress == spr->swr.xpBaseAddress ||
+             (spr->secondary.xpBaseAddress &&
+              renderTargets[i].xpBaseAddress == spr->secondary.xpBaseAddress)) {
             swr_store_render_target(pipe, i, post_tile_state);
 
             /* Mesa thinks depth/stencil are fused, so we'll never get an
index 4effd4604f45111eef60966333138f577c8e7202..4a2d66906a6cccaf027b45f2ea1bf87866290014 100644 (file)
@@ -92,7 +92,7 @@ swr_resource_data(struct pipe_resource *resource)
 
    assert(!swr_resource_is_texture(resource));
 
-   return swr_r->swr.pBaseAddress;
+   return (uint8_t*)(swr_r->swr.xpBaseAddress);
 }
 
 
index 85bf765841615318b35181cf495075301863f6da..95046adb5ff05a87e409e2639c919c28e3e27bc7 100644 (file)
@@ -652,7 +652,7 @@ swr_displaytarget_layout(struct swr_screen *screen, struct swr_resource *res)
    void *map = winsys->displaytarget_map(winsys, dt, 0);
 
    res->display_target = dt;
-   res->swr.pBaseAddress = (uint8_t*) map;
+   res->swr.xpBaseAddress = (gfxptr_t)map;
 
    /* Clear the display target surface */
    if (map)
@@ -826,7 +826,7 @@ swr_texture_layout(struct swr_screen *screen,
       return false;
 
    if (allocate) {
-      res->swr.pBaseAddress = (uint8_t *)AlignedMalloc(total_size, 64);
+      res->swr.xpBaseAddress = (gfxptr_t)AlignedMalloc(total_size, 64);
 
       if (res->has_depth && res->has_stencil) {
          res->secondary = res->swr;
@@ -841,8 +841,7 @@ swr_texture_layout(struct swr_screen *screen,
          total_size = res->secondary.depth * res->secondary.qpitch *
                       res->secondary.pitch * res->secondary.numSamples;
 
-         res->secondary.pBaseAddress = (uint8_t *) AlignedMalloc(total_size,
-                                                                 64);
+         res->secondary.xpBaseAddress = (gfxptr_t) AlignedMalloc(total_size, 64);
       }
    }
 
@@ -902,7 +901,7 @@ swr_create_resolve_resource(struct pipe_screen *_screen,
 
       /* Hang resolve surface state off the multisample surface state to so
        * StoreTiles knows where to resolve the surface. */
-      msaa_res->swr.pAuxBaseAddress =  (uint8_t *)&swr_resource(alt)->swr;
+      msaa_res->swr.xpAuxBaseAddress = (gfxptr_t)&swr_resource(alt)->swr;
    }
 
    return true; /* success */
@@ -978,10 +977,10 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt)
       if (spr->swr.numSamples > 1) {
          /* Free an attached resolve resource */
          struct swr_resource *alt = swr_resource(spr->resolve_target);
-         swr_fence_work_free(screen->flush_fence, alt->swr.pBaseAddress, true);
+         swr_fence_work_free(screen->flush_fence, (void*)(alt->swr.xpBaseAddress), true);
 
          /* Free multisample buffer */
-         swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
+         swr_fence_work_free(screen->flush_fence, (void*)(spr->swr.xpBaseAddress), true);
       }
    } else {
       /* For regular resources, defer deletion */
@@ -990,12 +989,12 @@ swr_resource_destroy(struct pipe_screen *p_screen, struct pipe_resource *pt)
       if (spr->swr.numSamples > 1) {
          /* Free an attached resolve resource */
          struct swr_resource *alt = swr_resource(spr->resolve_target);
-         swr_fence_work_free(screen->flush_fence, alt->swr.pBaseAddress, true);
+         swr_fence_work_free(screen->flush_fence, (void*)(alt->swr.xpBaseAddress), true);
       }
 
-      swr_fence_work_free(screen->flush_fence, spr->swr.pBaseAddress, true);
+      swr_fence_work_free(screen->flush_fence, (void*)(spr->swr.xpBaseAddress), true);
       swr_fence_work_free(screen->flush_fence,
-                          spr->secondary.pBaseAddress, true);
+                          (void*)(spr->secondary.xpBaseAddress), true);
 
       /* If work queue grows too large, submit a fence to force queue to
        * drain.  This is mainly to decrease the amount of memory used by the
@@ -1037,7 +1036,7 @@ swr_flush_frontbuffer(struct pipe_screen *p_screen,
 
       void *map = winsys->displaytarget_map(winsys, spr->display_target,
                                             PIPE_TRANSFER_WRITE);
-      memcpy(map, resolve->pBaseAddress, resolve->pitch * resolve->height);
+      memcpy(map, (void*)(resolve->xpBaseAddress), resolve->pitch * resolve->height);
       winsys->displaytarget_unmap(winsys, spr->display_target);
    }
 
index 69a447334fe0040017cafe01bbddda3c83f7911f..1491868eaeb5418c1b1a0f38626c45b474f58670 100644 (file)
@@ -795,7 +795,7 @@ swr_update_texture_state(struct swr_context *ctx,
 
          jit_tex->width = res->width0;
          jit_tex->height = res->height0;
-         jit_tex->base_ptr = swr->pBaseAddress;
+         jit_tex->base_ptr = (uint8_t*)swr->xpBaseAddress;
          if (view->target != PIPE_BUFFER) {
             jit_tex->first_level = view->u.tex.first_level;
             jit_tex->last_level = view->u.tex.last_level;
@@ -902,7 +902,7 @@ swr_change_rt(struct swr_context *ctx,
    struct SWR_SURFACE_STATE *rt = &pDC->renderTargets[attachment];
 
    /* Do nothing if the render target hasn't changed */
-   if ((!sf || !sf->texture) && rt->pBaseAddress == nullptr)
+   if ((!sf || !sf->texture) && (void*)(rt->xpBaseAddress) == nullptr)
       return false;
 
    /* Deal with disabling RT up front */
@@ -918,12 +918,12 @@ swr_change_rt(struct swr_context *ctx,
    const SWR_SURFACE_STATE *swr_surface = &swr->swr;
    SWR_FORMAT fmt = mesa_to_swr_format(sf->format);
 
-   if (attachment == SWR_ATTACHMENT_STENCIL && swr->secondary.pBaseAddress) {
+   if (attachment == SWR_ATTACHMENT_STENCIL && swr->secondary.xpBaseAddress) {
       swr_surface = &swr->secondary;
       fmt = swr_surface->format;
    }
 
-   if (rt->pBaseAddress == swr_surface->pBaseAddress &&
+   if (rt->xpBaseAddress == swr_surface->xpBaseAddress &&
        rt->format == fmt &&
        rt->lod == sf->u.tex.level &&
        rt->arrayIndex == sf->u.tex.first_layer)
@@ -932,7 +932,7 @@ swr_change_rt(struct swr_context *ctx,
    bool need_fence = false;
 
    /* StoreTile for changed target */
-   if (rt->pBaseAddress) {
+   if (rt->xpBaseAddress) {
       /* If changing attachment to a new target, mark tiles as
        * INVALID so they are reloaded from surface. */
       swr_store_render_target(&ctx->pipe, attachment, SWR_TILE_INVALID);