swr/rast: Migrate memory pointers to gfxptr_t type
Reviewed-by: Bruce Cherniak <bruce.cherniak@intel.com>
This commit is contained in:
parent
ae2412dbbd
commit
6f0fcec07a
|
@ -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)'
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue