@@ -395,16 +395,16 @@ impl RutabagaVirtioGpu {
395
395
396
396
fn configure_rutabaga_builder (
397
397
gpu_config : & GpuConfig ,
398
+ fence : RutabagaFenceHandler ,
398
399
) -> ( RutabagaBuilder , RutabagaComponentType ) {
399
400
let component = match gpu_config. gpu_mode ( ) {
400
401
GpuMode :: VirglRenderer => RutabagaComponentType :: VirglRenderer ,
401
402
#[ cfg( feature = "gfxstream" ) ]
402
403
GpuMode :: Gfxstream => RutabagaComponentType :: Gfxstream ,
403
404
} ;
404
405
405
- let builder = RutabagaBuilder :: new ( component , gpu_config. capsets ( ) . bits ( ) )
406
+ let builder = RutabagaBuilder :: new ( gpu_config. capsets ( ) . bits ( ) , fence )
406
407
. set_use_egl ( gpu_config. flags ( ) . use_egl )
407
- . set_use_glx ( gpu_config. flags ( ) . use_glx )
408
408
. set_use_gles ( gpu_config. flags ( ) . use_gles )
409
409
. set_use_surfaceless ( gpu_config. flags ( ) . use_surfaceless )
410
410
// Since vhost-user-gpu is out-of-process this is the only type of blob resource that
@@ -417,11 +417,9 @@ impl RutabagaVirtioGpu {
417
417
pub fn new ( queue_ctl : & VringRwLock , gpu_config : & GpuConfig , gpu_backend : GpuBackend ) -> Self {
418
418
let fence_state = Arc :: new ( Mutex :: new ( FenceState :: default ( ) ) ) ;
419
419
let fence = Self :: create_fence_handler ( queue_ctl. clone ( ) , fence_state. clone ( ) ) ;
420
- let ( builder, component_type) = Self :: configure_rutabaga_builder ( gpu_config) ;
420
+ let ( builder, component_type) = Self :: configure_rutabaga_builder ( gpu_config, fence ) ;
421
421
422
- let rutabaga = builder
423
- . build ( fence, None )
424
- . expect ( "Rutabaga initialization failed!" ) ;
422
+ let rutabaga = builder. build ( ) . expect ( "Rutabaga initialization failed!" ) ;
425
423
426
424
Self {
427
425
rutabaga,
@@ -434,7 +432,7 @@ impl RutabagaVirtioGpu {
434
432
}
435
433
436
434
fn result_from_query ( & self , resource_id : u32 ) -> GpuResponse {
437
- let Ok ( query) = self . rutabaga . query ( resource_id) else {
435
+ let Ok ( query) = self . rutabaga . resource3d_info ( resource_id) else {
438
436
return OkNoData ;
439
437
} ;
440
438
let mut plane_info = Vec :: with_capacity ( 4 ) ;
@@ -728,10 +726,10 @@ impl VirtioGpu for RutabagaVirtioGpu {
728
726
let handle_opt: Option < Arc < RutabagaHandle > > =
729
727
self . rutabaga . export_blob ( resource_id) . map ( Arc :: new) . ok ( ) ;
730
728
731
- // Only trust query () when we have a DMABUF handle.
729
+ // Only trust resource3d_info () when we have a DMABUF handle.
732
730
let info_3d_opt: Option < Resource3DInfo > = if let Some ( h) = handle_opt. as_ref ( ) {
733
731
if h. handle_type == RUTABAGA_HANDLE_TYPE_MEM_DMABUF {
734
- self . rutabaga . query ( resource_id) . ok ( )
732
+ self . rutabaga . resource3d_info ( resource_id) . ok ( )
735
733
} else {
736
734
log:: warn!(
737
735
"export_blob for resource {} returned non-DMABUF handle type: {:?}" ,
@@ -1098,19 +1096,17 @@ impl VirtioGpu for RutabagaVirtioGpu {
1098
1096
1099
1097
#[ cfg( test) ]
1100
1098
mod tests {
1099
+ #[ cfg( feature = "gfxstream" ) ]
1100
+ use std:: env:: set_var;
1101
1101
use std:: {
1102
1102
os:: unix:: net:: UnixStream ,
1103
1103
sync:: { Arc , Mutex } ,
1104
1104
} ;
1105
1105
1106
- #[ cfg( feature = "gfxstream" ) ]
1107
- use std:: env:: set_var;
1108
-
1109
1106
use assert_matches:: assert_matches;
1110
1107
use rusty_fork:: rusty_fork_test;
1111
- use rutabaga_gfx:: {
1112
- RutabagaFence , RutabagaHandler , RUTABAGA_PIPE_BIND_RENDER_TARGET , RUTABAGA_PIPE_TEXTURE_2D ,
1113
- } ;
1108
+ use rutabaga_gfx:: { RutabagaFence , RUTABAGA_PIPE_BIND_RENDER_TARGET , RUTABAGA_PIPE_TEXTURE_2D } ;
1109
+ use vm_memory:: { GuestAddress , GuestMemoryAtomic , GuestMemoryMmap } ;
1114
1110
1115
1111
use super :: * ;
1116
1112
use crate :: { protocol:: VIRTIO_GPU_FORMAT_R8G8B8A8_UNORM , GpuCapset , GpuFlags } ;
@@ -1161,9 +1157,21 @@ mod tests {
1161
1157
1162
1158
let config = GpuConfig :: new ( gpu_mode, capsets, GpuFlags :: default ( ) ) . unwrap ( ) ;
1163
1159
1160
+ // Mock memory
1161
+ let mem = GuestMemoryAtomic :: new (
1162
+ GuestMemoryMmap :: < ( ) > :: from_ranges ( & [ ( GuestAddress ( 0 ) , 0x10000 ) ] ) . unwrap ( ) ,
1163
+ ) ;
1164
+ let vring = VringRwLock :: new ( mem, 0x1000 ) . unwrap ( ) ;
1165
+ vring. set_queue_info ( 0x100 , 0x200 , 0x300 ) . unwrap ( ) ;
1166
+ vring. set_queue_ready ( true ) ;
1167
+
1168
+ let fence_state = Arc :: new ( Mutex :: new ( FenceState :: default ( ) ) ) ;
1169
+ let fence = RutabagaVirtioGpu :: create_fence_handler ( vring, fence_state) ;
1170
+ // Test creating a fence with the `RutabagaFence` that can be used to determine
1171
+ // when the previous command completed.
1164
1172
let ( builder, actual_component_type) =
1165
- RutabagaVirtioGpu :: configure_rutabaga_builder ( & config) ;
1166
- let rutabaga = builder. build ( RutabagaHandler :: new ( |_| { } ) , None ) . unwrap ( ) ;
1173
+ RutabagaVirtioGpu :: configure_rutabaga_builder ( & config, fence ) ;
1174
+ let rutabaga = builder. build ( ) . unwrap ( ) ;
1167
1175
RutabagaVirtioGpu {
1168
1176
rutabaga,
1169
1177
gpu_backend : dummy_gpu_backend ( ) ,
@@ -1360,7 +1368,6 @@ mod tests {
1360
1368
offsets: [ 0 , 0 , 0 , 0 ] ,
1361
1369
drm_fourcc: 0x34325241 ,
1362
1370
modifier: 0 ,
1363
- guest_cpu_mappable: true ,
1364
1371
} ) ;
1365
1372
let result = virtio_gpu. set_scanout( VIRTIO_GPU_MAX_SCANOUTS + 1 , 1 , rect. clone( ) ) ;
1366
1373
assert_matches!( result, Err ( ErrInvalidResourceId ) ) ;
@@ -1405,7 +1412,6 @@ mod tests {
1405
1412
offsets: [ 0 , 0 , 0 , 0 ] ,
1406
1413
drm_fourcc: 0x34325241 , // 'AR24'
1407
1414
modifier: 0 ,
1408
- guest_cpu_mappable: false ,
1409
1415
} ) ;
1410
1416
res
1411
1417
}
0 commit comments