@ -5818,7 +5818,7 @@ int vrend_renderer_resource_attach_iov(int res_handle, struct iovec *iov,
res - > iov = iov ;
res - > iov = iov ;
res - > num_iovs = num_iovs ;
res - > num_iovs = num_iovs ;
if ( res - > storage = = VREND_RESOURCE_STORAGE_IOVEC ) {
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ) {
vrend_write_to_iovec ( res - > iov , res - > num_iovs , 0 ,
vrend_write_to_iovec ( res - > iov , res - > num_iovs , 0 ,
res - > ptr , res - > base . width0 ) ;
res - > ptr , res - > base . width0 ) ;
}
}
@ -5840,7 +5840,7 @@ void vrend_renderer_resource_detach_iov(int res_handle,
if ( num_iovs_p )
if ( num_iovs_p )
* num_iovs_p = res - > num_iovs ;
* num_iovs_p = res - > num_iovs ;
if ( res - > storage = = VREND_RESOURCE_STORAGE_IOVEC ) {
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ) {
vrend_read_from_iovec ( res - > iov , res - > num_iovs , 0 ,
vrend_read_from_iovec ( res - > iov , res - > num_iovs , 0 ,
res - > ptr , res - > base . width0 ) ;
res - > ptr , res - > base . width0 ) ;
}
}
@ -6154,7 +6154,7 @@ int vrend_renderer_resource_create(struct vrend_renderer_resource_create_args *a
if ( args - > bind = = VIRGL_BIND_CUSTOM ) {
if ( args - > bind = = VIRGL_BIND_CUSTOM ) {
assert ( args - > target = = PIPE_BUFFER ) ;
assert ( args - > target = = PIPE_BUFFER ) ;
/* use iovec directly when attached */
/* use iovec directly when attached */
gr - > storage = VREND_RESOURCE_STORAGE_IOVEC ;
gr - > storage = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ;
gr - > ptr = malloc ( args - > width ) ;
gr - > ptr = malloc ( args - > width ) ;
if ( ! gr - > ptr ) {
if ( ! gr - > ptr ) {
FREE ( gr ) ;
FREE ( gr ) ;
@ -6225,7 +6225,7 @@ void vrend_renderer_resource_destroy(struct vrend_resource *res)
if ( res - > tbo_tex_id )
if ( res - > tbo_tex_id )
glDeleteTextures ( 1 , & res - > tbo_tex_id ) ;
glDeleteTextures ( 1 , & res - > tbo_tex_id ) ;
break ;
break ;
case VREND_RESOURCE_STORAGE_IOVEC :
case VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM :
free ( res - > ptr ) ;
free ( res - > ptr ) ;
break ;
break ;
default :
default :
@ -6475,20 +6475,17 @@ static int vrend_renderer_transfer_write_iov(struct vrend_context *ctx,
{
{
void * data ;
void * data ;
if ( res - > storage = = VREND_RESOURCE_STORAGE_IOVEC ) {
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST | |
const bool need_write = ( res - > iov = = NULL | |
( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM & & res - > iov ) ) {
res - > iov ! = iov | |
return vrend_copy_iovec ( iov , num_iovs , info - > offset ,
info - > offset ! = ( size_t ) info - > box - > x ) ;
res - > iov , res - > num_iovs , info - > box - > x ,
if ( need_write ) {
info - > box - > width , res - > ptr ) ;
vrend_read_from_iovec ( iov , num_iovs , info - > offset ,
res - > ptr + info - > box - > x , info - > box - > width ) ;
if ( res - > iov ) {
vrend_write_to_iovec ( res - > iov , res - > num_iovs , info - > box - > x ,
res - > ptr + info - > box - > x , info - > box - > width ) ;
}
}
}
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ) {
assert ( ! res - > iov ) ;
vrend_read_from_iovec ( iov , num_iovs , info - > offset ,
res - > ptr + info - > box - > x , info - > box - > width ) ;
return 0 ;
return 0 ;
}
}
@ -7000,20 +6997,17 @@ static int vrend_renderer_transfer_send_iov(struct vrend_resource *res,
struct iovec * iov , int num_iovs ,
struct iovec * iov , int num_iovs ,
const struct vrend_transfer_info * info )
const struct vrend_transfer_info * info )
{
{
if ( res - > storage = = VREND_RESOURCE_STORAGE_IOVEC ) {
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST | |
const bool need_send = ( res - > iov = = NULL | |
( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM & & res - > iov ) ) {
res - > iov ! = iov | |
return vrend_copy_iovec ( res - > iov , res - > num_iovs , info - > box - > x ,
info - > offset ! = ( size_t ) info - > box - > x ) ;
iov , num_iovs , info - > offset ,
if ( need_send ) {
info - > box - > width , res - > ptr ) ;
if ( res - > iov ) {
vrend_read_from_iovec ( res - > iov , res - > num_iovs , info - > box - > x ,
res - > ptr + info - > box - > x , info - > box - > width ) ;
}
}
if ( res - > storage = = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ) {
assert ( ! res - > iov ) ;
vrend_write_to_iovec ( iov , num_iovs , info - > offset ,
vrend_write_to_iovec ( iov , num_iovs , info - > offset ,
res - > ptr + info - > box - > x , info - > box - > width ) ;
res - > ptr + info - > box - > x , info - > box - > width ) ;
}
return 0 ;
return 0 ;
}
}
@ -8198,7 +8192,7 @@ int vrend_create_query(struct vrend_context *ctx, uint32_t handle,
struct vrend_resource * res ;
struct vrend_resource * res ;
uint32_t ret_handle ;
uint32_t ret_handle ;
res = vrend_renderer_ctx_res_lookup ( ctx , res_handle ) ;
res = vrend_renderer_ctx_res_lookup ( ctx , res_handle ) ;
if ( ! res | | res - > storage ! = VREND_RESOURCE_STORAGE_IOVEC ) {
if ( ! res | | res - > storage ! = VREND_RESOURCE_STORAGE_GUEST_ELSE_SYSTEM ) {
report_context_error ( ctx , VIRGL_ERROR_CTX_ILLEGAL_RESOURCE , res_handle ) ;
report_context_error ( ctx , VIRGL_ERROR_CTX_ILLEGAL_RESOURCE , res_handle ) ;
return EINVAL ;
return EINVAL ;
}
}