gallium: remove u_resource_vtbl::transfer_(un)map

This removes the call indirection.

Reviewed-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10659>
This commit is contained in:
Marek Olšák
2021-05-05 16:06:28 -04:00
committed by Marge Bot
parent eb74f97769
commit 38171635af
36 changed files with 236 additions and 163 deletions

View File

@@ -97,22 +97,3 @@ u_resource( struct pipe_resource *res )
{ {
return (struct u_resource *)res; return (struct u_resource *)res;
} }
void *u_transfer_map_vtbl(struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **transfer)
{
struct u_resource *ur = u_resource(resource);
return ur->vtbl->transfer_map(context, resource, level, usage, box,
transfer);
}
void u_transfer_unmap_vtbl( struct pipe_context *pipe,
struct pipe_transfer *transfer )
{
struct u_resource *ur = u_resource(transfer->resource);
ur->vtbl->transfer_unmap(pipe, transfer);
}

View File

@@ -36,15 +36,6 @@ void u_default_transfer_flush_region( struct pipe_context *pipe,
* to exist in a single driver. This is intended to be transitionary! * to exist in a single driver. This is intended to be transitionary!
*/ */
struct u_resource_vtbl { struct u_resource_vtbl {
void *(*transfer_map)(struct pipe_context *,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *,
struct pipe_transfer **);
void (*transfer_unmap)( struct pipe_context *,
struct pipe_transfer *transfer );
}; };
@@ -53,17 +44,6 @@ struct u_resource {
const struct u_resource_vtbl *vtbl; const struct u_resource_vtbl *vtbl;
}; };
void *u_transfer_map_vtbl(struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **transfer);
void u_transfer_unmap_vtbl( struct pipe_context *rm_ctx,
struct pipe_transfer *transfer );
#ifdef __cplusplus #ifdef __cplusplus
} // extern "C" { } // extern "C" {
#endif #endif

View File

@@ -36,11 +36,11 @@ i915_resource_from_handle(struct pipe_screen * screen,
void void
i915_init_resource_functions(struct i915_context *i915 ) i915_init_resource_functions(struct i915_context *i915 )
{ {
i915->base.buffer_map = u_transfer_map_vtbl; i915->base.buffer_map = i915_buffer_transfer_map;
i915->base.texture_map = u_transfer_map_vtbl; i915->base.texture_map = i915_texture_transfer_map;
i915->base.transfer_flush_region = u_default_transfer_flush_region; i915->base.transfer_flush_region = u_default_transfer_flush_region;
i915->base.buffer_unmap = u_transfer_unmap_vtbl; i915->base.buffer_unmap = i915_buffer_transfer_unmap;
i915->base.texture_unmap = u_transfer_unmap_vtbl; i915->base.texture_unmap = i915_texture_transfer_unmap;
i915->base.buffer_subdata = i915_buffer_subdata; i915->base.buffer_subdata = i915_buffer_subdata;
i915->base.texture_subdata = u_default_texture_subdata; i915->base.texture_subdata = u_default_texture_subdata;
} }

View File

@@ -146,4 +146,28 @@ i915_buffer_subdata(struct pipe_context *rm_ctx,
unsigned usage, unsigned offset, unsigned usage, unsigned offset,
unsigned size, const void *data); unsigned size, const void *data);
void *
i915_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
i915_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
void *
i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
i915_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
#endif /* I915_RESOURCE_H */ #endif /* I915_RESOURCE_H */

View File

@@ -66,7 +66,7 @@ i915_resource_destroy(struct pipe_screen *screen,
} }
static void * void *
i915_buffer_transfer_map(struct pipe_context *pipe, i915_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
@@ -90,7 +90,7 @@ i915_buffer_transfer_map(struct pipe_context *pipe,
return buffer->data + transfer->box.x; return buffer->data + transfer->box.x;
} }
static void void
i915_buffer_transfer_unmap(struct pipe_context *pipe, i915_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
@@ -112,8 +112,6 @@ i915_buffer_subdata(struct pipe_context *rm_ctx,
struct u_resource_vtbl i915_buffer_vtbl = struct u_resource_vtbl i915_buffer_vtbl =
{ {
i915_buffer_transfer_map, /* transfer_map */
i915_buffer_transfer_unmap, /* transfer_unmap */
}; };

View File

@@ -698,7 +698,7 @@ i915_resource_get_handle(struct pipe_screen *screen,
return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride); return iws->buffer_get_handle(iws, tex->buffer, whandle, tex->stride);
} }
static void * void *
i915_texture_transfer_map(struct pipe_context *pipe, i915_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
@@ -774,7 +774,7 @@ i915_texture_transfer_map(struct pipe_context *pipe,
box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format); box->x / util_format_get_blockwidth(format) * util_format_get_blocksize(format);
} }
static void void
i915_texture_transfer_unmap(struct pipe_context *pipe, i915_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
@@ -895,8 +895,6 @@ out:
struct u_resource_vtbl i915_texture_vtbl = struct u_resource_vtbl i915_texture_vtbl =
{ {
i915_texture_transfer_map, /* transfer_map */
i915_texture_transfer_unmap, /* transfer_unmap */
}; };

View File

@@ -20,6 +20,17 @@ struct nouveau_transfer {
uint32_t offset; uint32_t offset;
}; };
static void *
nouveau_user_ptr_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level, unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
static void
nouveau_user_ptr_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
static inline struct nouveau_transfer * static inline struct nouveau_transfer *
nouveau_transfer(struct pipe_transfer *transfer) nouveau_transfer(struct pipe_transfer *transfer)
{ {
@@ -377,7 +388,7 @@ nouveau_buffer_should_discard(struct nv04_resource *buf, unsigned usage)
* The strategy for determining what kind of memory area to return is complex, * The strategy for determining what kind of memory area to return is complex,
* see comments inside of the function. * see comments inside of the function.
*/ */
static void * void *
nouveau_buffer_transfer_map(struct pipe_context *pipe, nouveau_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned usage, unsigned level, unsigned usage,
@@ -386,6 +397,10 @@ nouveau_buffer_transfer_map(struct pipe_context *pipe,
{ {
struct nouveau_context *nv = nouveau_context(pipe); struct nouveau_context *nv = nouveau_context(pipe);
struct nv04_resource *buf = nv04_resource(resource); struct nv04_resource *buf = nv04_resource(resource);
if (buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)
return nouveau_user_ptr_transfer_map(pipe, resource, level, usage, box, ptransfer);
struct nouveau_transfer *tx = MALLOC_STRUCT(nouveau_transfer); struct nouveau_transfer *tx = MALLOC_STRUCT(nouveau_transfer);
uint8_t *map; uint8_t *map;
int ret; int ret;
@@ -533,14 +548,18 @@ nouveau_buffer_transfer_flush_region(struct pipe_context *pipe,
* *
* Also marks vbo dirty based on the buffer's binding * Also marks vbo dirty based on the buffer's binding
*/ */
static void void
nouveau_buffer_transfer_unmap(struct pipe_context *pipe, nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
struct nouveau_context *nv = nouveau_context(pipe); struct nouveau_context *nv = nouveau_context(pipe);
struct nouveau_transfer *tx = nouveau_transfer(transfer);
struct nv04_resource *buf = nv04_resource(transfer->resource); struct nv04_resource *buf = nv04_resource(transfer->resource);
if (buf->status & NOUVEAU_BUFFER_STATUS_USER_PTR)
return nouveau_user_ptr_transfer_unmap(pipe, transfer);
struct nouveau_transfer *tx = nouveau_transfer(transfer);
if (tx->base.usage & PIPE_MAP_WRITE) { if (tx->base.usage & PIPE_MAP_WRITE) {
if (!(tx->base.usage & PIPE_MAP_FLUSH_EXPLICIT)) { if (!(tx->base.usage & PIPE_MAP_FLUSH_EXPLICIT)) {
if (tx->map) if (tx->map)
@@ -635,8 +654,6 @@ nouveau_resource_map_offset(struct nouveau_context *nv,
const struct u_resource_vtbl nouveau_buffer_vtbl = const struct u_resource_vtbl nouveau_buffer_vtbl =
{ {
nouveau_buffer_transfer_map, /* transfer_map */
nouveau_buffer_transfer_unmap, /* transfer_unmap */
}; };
static void * static void *
@@ -664,8 +681,6 @@ nouveau_user_ptr_transfer_unmap(struct pipe_context *pipe,
const struct u_resource_vtbl nouveau_user_ptr_buffer_vtbl = const struct u_resource_vtbl nouveau_user_ptr_buffer_vtbl =
{ {
nouveau_user_ptr_transfer_map, /* transfer_map */
nouveau_user_ptr_transfer_unmap, /* transfer_unmap */
}; };
struct pipe_resource * struct pipe_resource *

View File

@@ -128,4 +128,15 @@ nouveau_scratch_data(struct nouveau_context *,
const void *data, unsigned base, unsigned size, const void *data, unsigned base, unsigned size,
struct nouveau_bo **); struct nouveau_bo **);
void *
nouveau_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level, unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
nouveau_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
#endif #endif

View File

@@ -276,7 +276,7 @@ nv30_flush_resource(struct pipe_context *pipe,
{ {
} }
static void * void *
nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt, nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
unsigned level, unsigned usage, unsigned level, unsigned usage,
const struct pipe_box *box, const struct pipe_box *box,
@@ -370,7 +370,7 @@ nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
return tx->tmp.bo->map; return tx->tmp.bo->map;
} }
static void void
nv30_miptree_transfer_unmap(struct pipe_context *pipe, nv30_miptree_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *ptx) struct pipe_transfer *ptx)
{ {
@@ -403,8 +403,6 @@ nv30_miptree_transfer_unmap(struct pipe_context *pipe,
} }
const struct u_resource_vtbl nv30_miptree_vtbl = { const struct u_resource_vtbl nv30_miptree_vtbl = {
nv30_miptree_transfer_map,
nv30_miptree_transfer_unmap,
}; };
struct pipe_resource * struct pipe_resource *

View File

@@ -92,11 +92,11 @@ nv30_resource_screen_init(struct pipe_screen *pscreen)
void void
nv30_resource_init(struct pipe_context *pipe) nv30_resource_init(struct pipe_context *pipe)
{ {
pipe->buffer_map = u_transfer_map_vtbl; pipe->buffer_map = nouveau_buffer_transfer_map;
pipe->texture_map = u_transfer_map_vtbl; pipe->texture_map = nv30_miptree_transfer_map;
pipe->transfer_flush_region = nouveau_buffer_transfer_flush_region; pipe->transfer_flush_region = nouveau_buffer_transfer_flush_region;
pipe->buffer_unmap = u_transfer_unmap_vtbl; pipe->buffer_unmap = nouveau_buffer_transfer_unmap;
pipe->texture_unmap = u_transfer_unmap_vtbl; pipe->texture_unmap = nv30_miptree_transfer_unmap;
pipe->buffer_subdata = u_default_buffer_subdata; pipe->buffer_subdata = u_default_buffer_subdata;
pipe->texture_subdata = u_default_texture_subdata; pipe->texture_subdata = u_default_texture_subdata;
pipe->create_surface = nv30_miptree_surface_new; pipe->create_surface = nv30_miptree_surface_new;

View File

@@ -83,4 +83,14 @@ void
nv30_flush_resource(struct pipe_context *pipe, nv30_flush_resource(struct pipe_context *pipe,
struct pipe_resource *resource); struct pipe_resource *resource);
void *
nv30_miptree_transfer_map(struct pipe_context *pipe, struct pipe_resource *pt,
unsigned level, unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
nv30_miptree_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *ptx);
#endif #endif

View File

@@ -204,8 +204,6 @@ nv50_miptree_get_handle(struct pipe_screen *pscreen,
const struct u_resource_vtbl nv50_miptree_vtbl = const struct u_resource_vtbl nv50_miptree_vtbl =
{ {
nv50_miptree_transfer_map, /* transfer_map */
nv50_miptree_transfer_unmap, /* transfer_unmap */
}; };
static inline bool static inline bool

View File

@@ -103,11 +103,11 @@ nv50_invalidate_resource(struct pipe_context *pipe, struct pipe_resource *res)
void void
nv50_init_resource_functions(struct pipe_context *pcontext) nv50_init_resource_functions(struct pipe_context *pcontext)
{ {
pcontext->buffer_map = u_transfer_map_vtbl; pcontext->buffer_map = nouveau_buffer_transfer_map;
pcontext->texture_map = u_transfer_map_vtbl; pcontext->texture_map = nv50_miptree_transfer_map;
pcontext->transfer_flush_region = nouveau_buffer_transfer_flush_region; pcontext->transfer_flush_region = nouveau_buffer_transfer_flush_region;
pcontext->buffer_unmap = u_transfer_unmap_vtbl; pcontext->buffer_unmap = nouveau_buffer_transfer_unmap;
pcontext->texture_unmap = u_transfer_unmap_vtbl; pcontext->texture_unmap = nv50_miptree_transfer_unmap;
pcontext->buffer_subdata = u_default_buffer_subdata; pcontext->buffer_subdata = u_default_buffer_subdata;
pcontext->texture_subdata = u_default_texture_subdata; pcontext->texture_subdata = u_default_texture_subdata;
pcontext->create_surface = nv50_surface_create; pcontext->create_surface = nv50_surface_create;

View File

@@ -438,8 +438,6 @@ nvc0_miptree_select_best_modifier(struct pipe_screen *pscreen,
const struct u_resource_vtbl nvc0_miptree_vtbl = const struct u_resource_vtbl nvc0_miptree_vtbl =
{ {
nvc0_miptree_transfer_map, /* transfer_map */
nvc0_miptree_transfer_unmap, /* transfer_unmap */
}; };
struct pipe_resource * struct pipe_resource *

View File

@@ -154,11 +154,11 @@ nvc0_resource_from_user_memory(struct pipe_screen *pipe,
void void
nvc0_init_resource_functions(struct pipe_context *pcontext) nvc0_init_resource_functions(struct pipe_context *pcontext)
{ {
pcontext->buffer_map = u_transfer_map_vtbl; pcontext->buffer_map = nouveau_buffer_transfer_map;
pcontext->texture_map = u_transfer_map_vtbl; pcontext->texture_map = nvc0_miptree_transfer_map;
pcontext->transfer_flush_region = nouveau_buffer_transfer_flush_region; pcontext->transfer_flush_region = nouveau_buffer_transfer_flush_region;
pcontext->buffer_unmap = u_transfer_unmap_vtbl; pcontext->buffer_unmap = nouveau_buffer_transfer_unmap;
pcontext->texture_unmap = u_transfer_unmap_vtbl; pcontext->texture_unmap = nvc0_miptree_transfer_unmap;
pcontext->buffer_subdata = u_default_buffer_subdata; pcontext->buffer_subdata = u_default_buffer_subdata;
pcontext->texture_subdata = u_default_texture_subdata; pcontext->texture_subdata = u_default_texture_subdata;
pcontext->create_surface = nvc0_surface_create; pcontext->create_surface = nvc0_surface_create;

View File

@@ -25,6 +25,7 @@
#include "r300_context.h" #include "r300_context.h"
#include "r300_texture.h" #include "r300_texture.h"
#include "r300_transfer.h"
#include "r300_screen_buffer.h" #include "r300_screen_buffer.h"
static struct pipe_resource * static struct pipe_resource *
@@ -40,11 +41,11 @@ r300_resource_create(struct pipe_screen *screen,
void r300_init_resource_functions(struct r300_context *r300) void r300_init_resource_functions(struct r300_context *r300)
{ {
r300->context.buffer_map = u_transfer_map_vtbl; r300->context.buffer_map = r300_buffer_transfer_map;
r300->context.texture_map = u_transfer_map_vtbl; r300->context.texture_map = r300_texture_transfer_map;
r300->context.transfer_flush_region = u_default_transfer_flush_region; r300->context.transfer_flush_region = u_default_transfer_flush_region;
r300->context.buffer_unmap = u_transfer_unmap_vtbl; r300->context.buffer_unmap = r300_buffer_transfer_unmap;
r300->context.texture_unmap = u_transfer_unmap_vtbl; r300->context.texture_unmap = r300_texture_transfer_unmap;
r300->context.buffer_subdata = u_default_buffer_subdata; r300->context.buffer_subdata = u_default_buffer_subdata;
r300->context.texture_subdata = u_default_texture_subdata; r300->context.texture_subdata = u_default_texture_subdata;
r300->context.create_surface = r300_create_surface; r300->context.create_surface = r300_create_surface;

View File

@@ -78,7 +78,7 @@ void r300_resource_destroy(struct pipe_screen *screen,
} }
} }
static void * void *
r300_buffer_transfer_map( struct pipe_context *context, r300_buffer_transfer_map( struct pipe_context *context,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
@@ -153,7 +153,7 @@ r300_buffer_transfer_map( struct pipe_context *context,
return map + box->x; return map + box->x;
} }
static void r300_buffer_transfer_unmap( struct pipe_context *pipe, void r300_buffer_transfer_unmap( struct pipe_context *pipe,
struct pipe_transfer *transfer ) struct pipe_transfer *transfer )
{ {
struct r300_context *r300 = r300_context(pipe); struct r300_context *r300 = r300_context(pipe);
@@ -163,8 +163,6 @@ static void r300_buffer_transfer_unmap( struct pipe_context *pipe,
static const struct u_resource_vtbl r300_buffer_vtbl = static const struct u_resource_vtbl r300_buffer_vtbl =
{ {
r300_buffer_transfer_map, /* transfer_map */
r300_buffer_transfer_unmap, /* transfer_unmap */
}; };
struct pipe_resource *r300_buffer_create(struct pipe_screen *screen, struct pipe_resource *r300_buffer_create(struct pipe_screen *screen,

View File

@@ -54,4 +54,15 @@ static inline struct r300_buffer *r300_buffer(struct pipe_resource *buffer)
return (struct r300_buffer *)buffer; return (struct r300_buffer *)buffer;
} }
void *
r300_buffer_transfer_map( struct pipe_context *context,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer );
void r300_buffer_transfer_unmap( struct pipe_context *pipe,
struct pipe_transfer *transfer );
#endif #endif

View File

@@ -1042,8 +1042,6 @@ bool r300_resource_get_handle(struct pipe_screen* screen,
static const struct u_resource_vtbl r300_texture_vtbl = static const struct u_resource_vtbl r300_texture_vtbl =
{ {
r300_texture_transfer_map, /* transfer_map */
r300_texture_transfer_unmap, /* transfer_unmap */
}; };
/* The common texture constructor. */ /* The common texture constructor. */

View File

@@ -1230,7 +1230,7 @@ void evergreen_init_compute_state_functions(struct r600_context *rctx)
} }
static void *r600_compute_global_transfer_map(struct pipe_context *ctx, void *r600_compute_global_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
unsigned usage, unsigned usage,
@@ -1281,7 +1281,7 @@ static void *r600_compute_global_transfer_map(struct pipe_context *ctx,
offset, box->width, usage, ptransfer); offset, box->width, usage, ptransfer);
} }
static void r600_compute_global_transfer_unmap(struct pipe_context *ctx, void r600_compute_global_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
/* struct r600_resource_global are not real resources, they just map /* struct r600_resource_global are not real resources, they just map
@@ -1317,8 +1317,6 @@ void r600_compute_global_buffer_destroy(struct pipe_screen *screen,
static const struct u_resource_vtbl r600_global_buffer_vtbl = static const struct u_resource_vtbl r600_global_buffer_vtbl =
{ {
r600_compute_global_transfer_map, /* transfer_map */
r600_compute_global_transfer_unmap, /* transfer_unmap */
}; };
struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen,

View File

@@ -46,5 +46,13 @@ struct r600_resource* r600_compute_buffer_alloc_vram(struct r600_screen *screen,
struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ); struct pipe_resource *r600_compute_global_buffer_create(struct pipe_screen *screen, const struct pipe_resource *templ);
void r600_compute_global_buffer_destroy(struct pipe_screen *screen, void r600_compute_global_buffer_destroy(struct pipe_screen *screen,
struct pipe_resource *res); struct pipe_resource *res);
void *r600_compute_global_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void r600_compute_global_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer);
#endif #endif

View File

@@ -25,6 +25,7 @@
*/ */
#include "r600_cs.h" #include "r600_cs.h"
#include "evergreen_compute.h"
#include "util/u_memory.h" #include "util/u_memory.h"
#include "util/u_upload_mgr.h" #include "util/u_upload_mgr.h"
#include <inttypes.h> #include <inttypes.h>
@@ -338,7 +339,7 @@ static bool r600_can_dma_copy_buffer(struct r600_common_context *rctx,
} }
static void *r600_buffer_transfer_map(struct pipe_context *ctx, void *r600_buffer_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
unsigned usage, unsigned usage,
@@ -350,6 +351,10 @@ static void *r600_buffer_transfer_map(struct pipe_context *ctx,
struct r600_resource *rbuffer = r600_resource(resource); struct r600_resource *rbuffer = r600_resource(resource);
uint8_t *data; uint8_t *data;
if (r600_resource(resource)->compute_global_bo) {
return r600_compute_global_transfer_map(ctx, resource, level, usage, box, ptransfer);
}
assert(box->x + box->width <= resource->width0); assert(box->x + box->width <= resource->width0);
/* From GL_AMD_pinned_memory issues: /* From GL_AMD_pinned_memory issues:
@@ -519,12 +524,17 @@ void r600_buffer_flush_region(struct pipe_context *ctx,
} }
} }
static void r600_buffer_transfer_unmap(struct pipe_context *ctx, void r600_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
struct r600_common_context *rctx = (struct r600_common_context*)ctx; struct r600_common_context *rctx = (struct r600_common_context*)ctx;
struct r600_transfer *rtransfer = (struct r600_transfer*)transfer; struct r600_transfer *rtransfer = (struct r600_transfer*)transfer;
if (r600_resource(transfer->resource)->compute_global_bo) {
r600_compute_global_transfer_unmap(ctx, transfer);
return;
}
if (transfer->usage & PIPE_MAP_WRITE && if (transfer->usage & PIPE_MAP_WRITE &&
!(transfer->usage & PIPE_MAP_FLUSH_EXPLICIT)) !(transfer->usage & PIPE_MAP_FLUSH_EXPLICIT))
r600_buffer_do_flush_region(ctx, transfer, &transfer->box); r600_buffer_do_flush_region(ctx, transfer, &transfer->box);
@@ -563,8 +573,6 @@ void r600_buffer_subdata(struct pipe_context *ctx,
static const struct u_resource_vtbl r600_buffer_vtbl = static const struct u_resource_vtbl r600_buffer_vtbl =
{ {
r600_buffer_transfer_map, /* transfer_map */
r600_buffer_transfer_unmap, /* transfer_unmap */
}; };
static struct r600_resource * static struct r600_resource *

View File

@@ -590,11 +590,11 @@ bool r600_common_context_init(struct r600_common_context *rctx,
rctx->b.invalidate_resource = r600_invalidate_resource; rctx->b.invalidate_resource = r600_invalidate_resource;
rctx->b.resource_commit = r600_resource_commit; rctx->b.resource_commit = r600_resource_commit;
rctx->b.buffer_map = u_transfer_map_vtbl; rctx->b.buffer_map = r600_buffer_transfer_map;
rctx->b.texture_map = u_transfer_map_vtbl; rctx->b.texture_map = r600_texture_transfer_map;
rctx->b.transfer_flush_region = r600_buffer_flush_region; rctx->b.transfer_flush_region = r600_buffer_flush_region;
rctx->b.buffer_unmap = u_transfer_unmap_vtbl; rctx->b.buffer_unmap = r600_buffer_transfer_unmap;
rctx->b.texture_unmap = u_transfer_unmap_vtbl; rctx->b.texture_unmap = r600_texture_transfer_unmap;
rctx->b.texture_subdata = u_default_texture_subdata; rctx->b.texture_subdata = u_default_texture_subdata;
rctx->b.flush = r600_flush_from_st; rctx->b.flush = r600_flush_from_st;
rctx->b.set_debug_callback = r600_set_debug_callback; rctx->b.set_debug_callback = r600_set_debug_callback;

View File

@@ -663,6 +663,14 @@ r600_invalidate_resource(struct pipe_context *ctx,
void r600_replace_buffer_storage(struct pipe_context *ctx, void r600_replace_buffer_storage(struct pipe_context *ctx,
struct pipe_resource *dst, struct pipe_resource *dst,
struct pipe_resource *src); struct pipe_resource *src);
void *r600_buffer_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void r600_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer);
/* r600_common_pipe.c */ /* r600_common_pipe.c */
void r600_gfx_write_event_eop(struct r600_common_context *ctx, void r600_gfx_write_event_eop(struct r600_common_context *ctx,
@@ -775,6 +783,14 @@ void r600_init_context_texture_functions(struct r600_common_context *rctx);
void eg_resource_alloc_immed(struct r600_common_screen *rscreen, void eg_resource_alloc_immed(struct r600_common_screen *rscreen,
struct r600_resource *res, struct r600_resource *res,
unsigned immed_size); unsigned immed_size);
void *r600_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *texture,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void r600_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer* transfer);
/* r600_viewport.c */ /* r600_viewport.c */
void evergreen_apply_scissor_bug_workaround(struct r600_common_context *rctx, void evergreen_apply_scissor_bug_workaround(struct r600_common_context *rctx,

View File

@@ -1287,7 +1287,7 @@ static void r600_texture_invalidate_storage(struct r600_common_context *rctx,
rctx->num_alloc_tex_transfer_bytes += rtex->size; rctx->num_alloc_tex_transfer_bytes += rtex->size;
} }
static void *r600_texture_transfer_map(struct pipe_context *ctx, void *r600_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *texture, struct pipe_resource *texture,
unsigned level, unsigned level,
unsigned usage, unsigned usage,
@@ -1472,7 +1472,7 @@ static void *r600_texture_transfer_map(struct pipe_context *ctx,
return map + offset; return map + offset;
} }
static void r600_texture_transfer_unmap(struct pipe_context *ctx, void r600_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer* transfer) struct pipe_transfer* transfer)
{ {
struct r600_common_context *rctx = (struct r600_common_context*)ctx; struct r600_common_context *rctx = (struct r600_common_context*)ctx;
@@ -1520,8 +1520,6 @@ static void r600_texture_transfer_unmap(struct pipe_context *ctx,
static const struct u_resource_vtbl r600_texture_vtbl = static const struct u_resource_vtbl r600_texture_vtbl =
{ {
r600_texture_transfer_map, /* transfer_map */
r600_texture_transfer_unmap, /* transfer_unmap */
}; };
struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe, struct pipe_surface *r600_create_surface_custom(struct pipe_context *pipe,

View File

@@ -569,8 +569,6 @@ static void si_buffer_subdata(struct pipe_context *ctx, struct pipe_resource *bu
} }
static const struct u_resource_vtbl si_buffer_vtbl = { static const struct u_resource_vtbl si_buffer_vtbl = {
si_buffer_transfer_map, /* transfer_map */
si_buffer_transfer_unmap, /* transfer_unmap */
}; };
static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen, static struct si_resource *si_alloc_buffer_struct(struct pipe_screen *screen,
@@ -745,11 +743,9 @@ void si_init_screen_buffer_functions(struct si_screen *sscreen)
void si_init_buffer_functions(struct si_context *sctx) void si_init_buffer_functions(struct si_context *sctx)
{ {
sctx->b.invalidate_resource = si_invalidate_resource; sctx->b.invalidate_resource = si_invalidate_resource;
sctx->b.buffer_map = u_transfer_map_vtbl; sctx->b.buffer_map = si_buffer_transfer_map;
sctx->b.texture_map = u_transfer_map_vtbl;
sctx->b.transfer_flush_region = si_buffer_flush_region; sctx->b.transfer_flush_region = si_buffer_flush_region;
sctx->b.buffer_unmap = u_transfer_unmap_vtbl; sctx->b.buffer_unmap = si_buffer_transfer_unmap;
sctx->b.texture_unmap = u_transfer_unmap_vtbl;
sctx->b.texture_subdata = u_default_texture_subdata; sctx->b.texture_subdata = u_default_texture_subdata;
sctx->b.buffer_subdata = si_buffer_subdata; sctx->b.buffer_subdata = si_buffer_subdata;
sctx->b.resource_commit = si_resource_commit; sctx->b.resource_commit = si_resource_commit;

View File

@@ -1432,8 +1432,6 @@ si_texture_create_with_modifiers(struct pipe_screen *screen,
} }
static const struct u_resource_vtbl si_auxiliary_texture_vtbl = { static const struct u_resource_vtbl si_auxiliary_texture_vtbl = {
NULL, /* transfer_map */
NULL, /* transfer_unmap */
}; };
static bool si_texture_is_aux_plane(const struct pipe_resource *resource) static bool si_texture_is_aux_plane(const struct pipe_resource *resource)
@@ -1742,6 +1740,9 @@ static void *si_texture_transfer_map(struct pipe_context *ctx, struct pipe_resou
assert(!(texture->flags & SI_RESOURCE_FLAG_FORCE_LINEAR)); assert(!(texture->flags & SI_RESOURCE_FLAG_FORCE_LINEAR));
assert(box->width && box->height && box->depth); assert(box->width && box->height && box->depth);
if (tex->buffer.b.b.flags & SI_RESOURCE_AUX_PLANE)
return NULL;
if (tex->buffer.flags & RADEON_FLAG_ENCRYPTED) if (tex->buffer.flags & RADEON_FLAG_ENCRYPTED)
return NULL; return NULL;
@@ -1918,8 +1919,6 @@ static void si_texture_transfer_unmap(struct pipe_context *ctx, struct pipe_tran
} }
static const struct u_resource_vtbl si_texture_vtbl = { static const struct u_resource_vtbl si_texture_vtbl = {
si_texture_transfer_map, /* transfer_map */
si_texture_transfer_unmap, /* transfer_unmap */
}; };
/* Return if it's allowed to reinterpret one format as another with DCC enabled. /* Return if it's allowed to reinterpret one format as another with DCC enabled.
@@ -2232,6 +2231,8 @@ void si_init_screen_texture_functions(struct si_screen *sscreen)
void si_init_context_texture_functions(struct si_context *sctx) void si_init_context_texture_functions(struct si_context *sctx)
{ {
sctx->b.texture_map = si_texture_transfer_map;
sctx->b.texture_unmap = si_texture_transfer_unmap;
sctx->b.create_surface = si_create_surface; sctx->b.create_surface = si_create_surface;
sctx->b.surface_destroy = si_surface_destroy; sctx->b.surface_destroy = si_surface_destroy;
} }

View File

@@ -120,11 +120,11 @@ svga_can_create_resource(struct pipe_screen *screen,
void void
svga_init_resource_functions(struct svga_context *svga) svga_init_resource_functions(struct svga_context *svga)
{ {
svga->pipe.buffer_map = u_transfer_map_vtbl; svga->pipe.buffer_map = svga_buffer_transfer_map;
svga->pipe.texture_map = u_transfer_map_vtbl; svga->pipe.texture_map = svga_texture_transfer_map;
svga->pipe.transfer_flush_region = svga_buffer_transfer_flush_region; svga->pipe.transfer_flush_region = svga_buffer_transfer_flush_region;
svga->pipe.buffer_unmap = u_transfer_unmap_vtbl; svga->pipe.buffer_unmap = svga_buffer_transfer_unmap;
svga->pipe.texture_unmap = u_transfer_unmap_vtbl; svga->pipe.texture_unmap = svga_texture_transfer_unmap;
svga->pipe.buffer_subdata = u_default_buffer_subdata; svga->pipe.buffer_subdata = u_default_buffer_subdata;
svga->pipe.texture_subdata = u_default_texture_subdata; svga->pipe.texture_subdata = u_default_texture_subdata;

View File

@@ -90,7 +90,7 @@ svga_buffer_needs_hw_storage(const struct svga_screen *ss,
* the end result is exactly the same as if one DMA was used for every mapped * the end result is exactly the same as if one DMA was used for every mapped
* range. * range.
*/ */
static void * void *
svga_buffer_transfer_map(struct pipe_context *pipe, svga_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
@@ -329,7 +329,7 @@ svga_buffer_transfer_flush_region(struct pipe_context *pipe,
} }
static void void
svga_buffer_transfer_unmap(struct pipe_context *pipe, svga_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
@@ -456,8 +456,6 @@ svga_resource_destroy(struct pipe_screen *screen,
struct u_resource_vtbl svga_buffer_vtbl = struct u_resource_vtbl svga_buffer_vtbl =
{ {
svga_buffer_transfer_map, /* transfer_map */
svga_buffer_transfer_unmap, /* transfer_unmap */
}; };

View File

@@ -382,4 +382,16 @@ void
svga_resource_destroy(struct pipe_screen *screen, svga_resource_destroy(struct pipe_screen *screen,
struct pipe_resource *buf); struct pipe_resource *buf);
void *
svga_buffer_transfer_map(struct pipe_context *pipe,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
svga_buffer_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
#endif /* SVGA_BUFFER_H */ #endif /* SVGA_BUFFER_H */

View File

@@ -486,7 +486,7 @@ svga_texture_transfer_map_direct(struct svga_context *svga,
/** /**
* Request a transfer map to the texture resource * Request a transfer map to the texture resource
*/ */
static void * void *
svga_texture_transfer_map(struct pipe_context *pipe, svga_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *texture, struct pipe_resource *texture,
unsigned level, unsigned level,
@@ -789,7 +789,7 @@ svga_texture_transfer_unmap_direct(struct svga_context *svga,
} }
static void void
svga_texture_transfer_unmap(struct pipe_context *pipe, svga_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
@@ -843,8 +843,6 @@ format_has_depth(enum pipe_format format)
struct u_resource_vtbl svga_texture_vtbl = struct u_resource_vtbl svga_texture_vtbl =
{ {
svga_texture_transfer_map, /* transfer_map */
svga_texture_transfer_unmap, /* transfer_unmap */
}; };

View File

@@ -324,4 +324,16 @@ svga_texture_transfer_unmap_upload(struct svga_context *svga,
boolean boolean
svga_texture_device_format_has_alpha(struct pipe_resource *texture); svga_texture_device_format_has_alpha(struct pipe_resource *texture);
void *
svga_texture_transfer_map(struct pipe_context *pipe,
struct pipe_resource *texture,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **ptransfer);
void
svga_texture_transfer_unmap(struct pipe_context *pipe,
struct pipe_transfer *transfer);
#endif /* SVGA_TEXTURE_H */ #endif /* SVGA_TEXTURE_H */

View File

@@ -28,7 +28,7 @@
#include "virgl_resource.h" #include "virgl_resource.h"
#include "virgl_screen.h" #include "virgl_screen.h"
static void virgl_buffer_transfer_unmap(struct pipe_context *ctx, void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
struct virgl_context *vctx = virgl_context(ctx); struct virgl_context *vctx = virgl_context(ctx);
@@ -78,8 +78,6 @@ void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
static const struct u_resource_vtbl virgl_buffer_vtbl = static const struct u_resource_vtbl virgl_buffer_vtbl =
{ {
virgl_resource_transfer_map, /* transfer_map */
virgl_buffer_transfer_unmap, /* transfer_unmap */
}; };
void virgl_buffer_init(struct virgl_resource *res) void virgl_buffer_init(struct virgl_resource *res)

View File

@@ -672,11 +672,11 @@ static void virgl_buffer_subdata(struct pipe_context *pipe,
void virgl_init_context_resource_functions(struct pipe_context *ctx) void virgl_init_context_resource_functions(struct pipe_context *ctx)
{ {
ctx->buffer_map = u_transfer_map_vtbl; ctx->buffer_map = virgl_resource_transfer_map;
ctx->texture_map = u_transfer_map_vtbl; ctx->texture_map = virgl_texture_transfer_map;
ctx->transfer_flush_region = virgl_buffer_transfer_flush_region; ctx->transfer_flush_region = virgl_buffer_transfer_flush_region;
ctx->buffer_unmap = u_transfer_unmap_vtbl; ctx->buffer_unmap = virgl_buffer_transfer_unmap;
ctx->texture_unmap = u_transfer_unmap_vtbl; ctx->texture_unmap = virgl_texture_transfer_unmap;
ctx->buffer_subdata = virgl_buffer_subdata; ctx->buffer_subdata = virgl_buffer_subdata;
ctx->texture_subdata = u_default_texture_subdata; ctx->texture_subdata = u_default_texture_subdata;
} }

View File

@@ -111,6 +111,9 @@ void virgl_buffer_transfer_flush_region(struct pipe_context *ctx,
struct pipe_transfer *transfer, struct pipe_transfer *transfer,
const struct pipe_box *box); const struct pipe_box *box);
void virgl_buffer_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer);
void virgl_buffer_init(struct virgl_resource *res); void virgl_buffer_init(struct virgl_resource *res);
static inline unsigned pipe_to_virgl_bind(const struct virgl_screen *vs, static inline unsigned pipe_to_virgl_bind(const struct virgl_screen *vs,
@@ -199,4 +202,14 @@ bool virgl_resource_get_handle(struct pipe_screen *screen,
void virgl_resource_dirty(struct virgl_resource *res, uint32_t level); void virgl_resource_dirty(struct virgl_resource *res, uint32_t level);
void *virgl_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource,
unsigned level,
unsigned usage,
const struct pipe_box *box,
struct pipe_transfer **transfer);
void virgl_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer);
#endif #endif

View File

@@ -230,7 +230,7 @@ static bool needs_resolve(struct pipe_screen *screen,
return false; return false;
} }
static void *virgl_texture_transfer_map(struct pipe_context *ctx, void *virgl_texture_transfer_map(struct pipe_context *ctx,
struct pipe_resource *resource, struct pipe_resource *resource,
unsigned level, unsigned level,
unsigned usage, unsigned usage,
@@ -254,7 +254,7 @@ static void flush_data(struct pipe_context *ctx,
trans->base.level); trans->base.level);
} }
static void virgl_texture_transfer_unmap(struct pipe_context *ctx, void virgl_texture_transfer_unmap(struct pipe_context *ctx,
struct pipe_transfer *transfer) struct pipe_transfer *transfer)
{ {
struct virgl_context *vctx = virgl_context(ctx); struct virgl_context *vctx = virgl_context(ctx);
@@ -304,8 +304,6 @@ static void virgl_texture_transfer_unmap(struct pipe_context *ctx,
static const struct u_resource_vtbl virgl_texture_vtbl = static const struct u_resource_vtbl virgl_texture_vtbl =
{ {
virgl_texture_transfer_map, /* transfer_map */
virgl_texture_transfer_unmap, /* transfer_unmap */
}; };
void virgl_texture_init(struct virgl_resource *res) void virgl_texture_init(struct virgl_resource *res)