iris: AMD_pinned_memory
(rebased by Ken, mainly set res->internal_format)
This commit is contained in:
committed by
Kenneth Graunke
parent
93c1921ce2
commit
d209cc5170
@@ -362,6 +362,49 @@ tiling_to_modifier(uint32_t tiling)
|
||||
return map[tiling];
|
||||
}
|
||||
|
||||
static struct pipe_resource *
|
||||
iris_resource_from_user_memory(struct pipe_screen *pscreen,
|
||||
const struct pipe_resource *templ,
|
||||
void *user_memory)
|
||||
{
|
||||
struct iris_screen *screen = (struct iris_screen *)pscreen;
|
||||
struct iris_bufmgr *bufmgr = screen->bufmgr;
|
||||
struct iris_resource *res = iris_alloc_resource(pscreen, templ);
|
||||
if (!res)
|
||||
return NULL;
|
||||
|
||||
res->bo = iris_bo_create_userptr(bufmgr, "user",
|
||||
user_memory, templ->width0,
|
||||
IRIS_MEMZONE_OTHER);
|
||||
if (!res->bo) {
|
||||
free(res);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
res->internal_format = templ->format;
|
||||
|
||||
// XXX: usage...
|
||||
isl_surf_usage_flags_t isl_usage = 0;
|
||||
|
||||
isl_surf_init(&screen->isl_dev, &res->surf,
|
||||
.dim = target_to_isl_surf_dim(templ->target),
|
||||
.format = iris_isl_format_for_pipe_format(templ->format),
|
||||
.width = templ->width0,
|
||||
.height = templ->height0,
|
||||
.depth = templ->depth0,
|
||||
.levels = templ->last_level + 1,
|
||||
.array_len = templ->array_size,
|
||||
.samples = MAX2(templ->nr_samples, 1),
|
||||
.min_alignment_B = 0,
|
||||
.row_pitch_B = 0,
|
||||
.usage = isl_usage,
|
||||
.tiling_flags = 1 << ISL_TILING_LINEAR);
|
||||
|
||||
assert(res->bo->tiling_mode == isl_tiling_to_i915_tiling(res->surf.tiling));
|
||||
|
||||
return &res->base;
|
||||
}
|
||||
|
||||
static struct pipe_resource *
|
||||
iris_resource_from_handle(struct pipe_screen *pscreen,
|
||||
const struct pipe_resource *templ,
|
||||
@@ -850,6 +893,7 @@ iris_init_screen_resource_functions(struct pipe_screen *pscreen)
|
||||
pscreen->resource_create_with_modifiers =
|
||||
iris_resource_create_with_modifiers;
|
||||
pscreen->resource_create = u_transfer_helper_resource_create;
|
||||
pscreen->resource_from_user_memory = iris_resource_from_user_memory;
|
||||
pscreen->resource_from_handle = iris_resource_from_handle;
|
||||
pscreen->resource_get_handle = iris_resource_get_handle;
|
||||
pscreen->resource_destroy = u_transfer_helper_resource_destroy;
|
||||
|
||||
@@ -89,6 +89,7 @@ static int
|
||||
iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
{
|
||||
struct iris_screen *screen = (struct iris_screen *)pscreen;
|
||||
const struct gen_device_info *devinfo = &screen->devinfo;
|
||||
|
||||
switch (param) {
|
||||
case PIPE_CAP_NPOT_TEXTURES:
|
||||
@@ -283,6 +284,14 @@ iris_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
||||
case PIPE_CAP_FRAMEBUFFER_MSAA_CONSTRAINTS:
|
||||
return 0;
|
||||
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
|
||||
/* AMD_pinned_memory assumes the flexibility of using client memory
|
||||
* for any buffer (incl. vertex buffers) which rules out the prospect
|
||||
* of using snooped buffers, as using snooped buffers without
|
||||
* cogniscience is likely to be detrimental to performance and require
|
||||
* extensive checking in the driver for correctness, e.g. to prevent
|
||||
* illegal snoop <-> snoop transfers.
|
||||
*/
|
||||
return devinfo->has_llc;
|
||||
case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
|
||||
case PIPE_CAP_TGSI_TXQS:
|
||||
case PIPE_CAP_SHAREABLE_SHADERS:
|
||||
|
||||
Reference in New Issue
Block a user