|
|
@ -6154,12 +6154,6 @@ struct vrend_context *vrend_create_context(int id, uint32_t nlen, const char *de |
|
|
|
static int check_resource_valid(struct vrend_renderer_resource_create_args *args, |
|
|
|
static int check_resource_valid(struct vrend_renderer_resource_create_args *args, |
|
|
|
char errmsg[256]) |
|
|
|
char errmsg[256]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
/* do not accept handle 0 */ |
|
|
|
|
|
|
|
if (args->handle == 0) { |
|
|
|
|
|
|
|
snprintf(errmsg, 256, "Invalid handle"); |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* limit the target */ |
|
|
|
/* limit the target */ |
|
|
|
if (args->target >= PIPE_MAX_TEXTURE_TYPES) { |
|
|
|
if (args->target >= PIPE_MAX_TEXTURE_TYPES) { |
|
|
|
snprintf(errmsg, 256, "Invalid texture target %d (>= %d)", |
|
|
|
snprintf(errmsg, 256, "Invalid texture target %d (>= %d)", |
|
|
@ -6400,7 +6394,6 @@ vrend_renderer_resource_copy_args(struct vrend_renderer_resource_create_args *ar |
|
|
|
assert(gr); |
|
|
|
assert(gr); |
|
|
|
assert(args); |
|
|
|
assert(args); |
|
|
|
|
|
|
|
|
|
|
|
gr->handle = args->handle; |
|
|
|
|
|
|
|
gr->base.bind = args->bind; |
|
|
|
gr->base.bind = args->bind; |
|
|
|
gr->base.width0 = args->width; |
|
|
|
gr->base.width0 = args->width; |
|
|
|
gr->base.height0 = args->height; |
|
|
|
gr->base.height0 = args->height; |
|
|
@ -6668,8 +6661,8 @@ static int vrend_renderer_resource_allocate_texture(struct vrend_resource *gr, |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *args, |
|
|
|
struct pipe_resource * |
|
|
|
void *image_oes) |
|
|
|
vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *args, void *image_oes) |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct vrend_resource *gr; |
|
|
|
struct vrend_resource *gr; |
|
|
|
int ret; |
|
|
|
int ret; |
|
|
@ -6678,12 +6671,12 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a |
|
|
|
ret = check_resource_valid(args, error_string); |
|
|
|
ret = check_resource_valid(args, error_string); |
|
|
|
if (ret) { |
|
|
|
if (ret) { |
|
|
|
vrend_printf("%s, Illegal resource parameters, error: %s\n", __func__, error_string); |
|
|
|
vrend_printf("%s, Illegal resource parameters, error: %s\n", __func__, error_string); |
|
|
|
return EINVAL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gr = (struct vrend_resource *)CALLOC_STRUCT(vrend_texture); |
|
|
|
gr = (struct vrend_resource *)CALLOC_STRUCT(vrend_texture); |
|
|
|
if (!gr) |
|
|
|
if (!gr) |
|
|
|
return ENOMEM; |
|
|
|
return NULL; |
|
|
|
|
|
|
|
|
|
|
|
vrend_renderer_resource_copy_args(args, gr); |
|
|
|
vrend_renderer_resource_copy_args(args, gr); |
|
|
|
gr->storage_bits = VREND_STORAGE_GUEST_MEMORY; |
|
|
|
gr->storage_bits = VREND_STORAGE_GUEST_MEMORY; |
|
|
@ -6700,7 +6693,7 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a |
|
|
|
gr->ptr = malloc(args->width); |
|
|
|
gr->ptr = malloc(args->width); |
|
|
|
if (!gr->ptr) { |
|
|
|
if (!gr->ptr) { |
|
|
|
FREE(gr); |
|
|
|
FREE(gr); |
|
|
|
return ENOMEM; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (args->bind == VIRGL_BIND_STAGING) { |
|
|
|
} else if (args->bind == VIRGL_BIND_STAGING) { |
|
|
|
/* staging buffers only use guest memory -- nothing to do. */ |
|
|
|
/* staging buffers only use guest memory -- nothing to do. */ |
|
|
@ -6744,22 +6737,17 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
vrend_printf("%s: Illegal buffer binding flags 0x%x\n", __func__, args->bind); |
|
|
|
vrend_printf("%s: Illegal buffer binding flags 0x%x\n", __func__, args->bind); |
|
|
|
FREE(gr); |
|
|
|
FREE(gr); |
|
|
|
return EINVAL; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
int r = vrend_renderer_resource_allocate_texture(gr, image_oes); |
|
|
|
int r = vrend_renderer_resource_allocate_texture(gr, image_oes); |
|
|
|
if (r) { |
|
|
|
if (r) { |
|
|
|
FREE(gr); |
|
|
|
FREE(gr); |
|
|
|
return r; |
|
|
|
return NULL; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
ret = virgl_resource_create_from_pipe(args->handle, &gr->base); |
|
|
|
return &gr->base; |
|
|
|
if (ret) { |
|
|
|
|
|
|
|
vrend_renderer_resource_destroy(gr); |
|
|
|
|
|
|
|
return ret; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void vrend_renderer_resource_destroy(struct vrend_resource *res) |
|
|
|
void vrend_renderer_resource_destroy(struct vrend_resource *res) |
|
|
@ -10125,7 +10113,6 @@ int vrend_renderer_resource_get_info(struct pipe_resource *pres, |
|
|
|
|
|
|
|
|
|
|
|
elsize = util_format_get_blocksize(res->base.format); |
|
|
|
elsize = util_format_get_blocksize(res->base.format); |
|
|
|
|
|
|
|
|
|
|
|
info->handle = res->handle; |
|
|
|
|
|
|
|
info->tex_id = res->id; |
|
|
|
info->tex_id = res->id; |
|
|
|
info->width = res->base.width0; |
|
|
|
info->width = res->base.width0; |
|
|
|
info->height = res->base.height0; |
|
|
|
info->height = res->base.height0; |
|
|
|