@@ -328,3 +328,90 @@ fn empty_build(ctx: TestingContext) {
328
328
ctx. queue
329
329
. submit ( [ encoder_safe. finish ( ) , encoder_unsafe. finish ( ) ] ) ;
330
330
}
331
+
332
+ #[ gpu_test]
333
+ static BUILD_WITH_TRANSFORM : GpuTestConfiguration = GpuTestConfiguration :: new ( )
334
+ . parameters (
335
+ TestParameters :: default ( )
336
+ . test_features_limits ( )
337
+ . features ( wgpu:: Features :: EXPERIMENTAL_RAY_TRACING_ACCELERATION_STRUCTURE )
338
+ // https://github.com/gfx-rs/wgpu/issues/6727
339
+ . skip ( FailureCase :: backend_adapter ( wgpu:: Backends :: VULKAN , "AMD" ) ) ,
340
+ )
341
+ . run_sync ( build_with_transform) ;
342
+
343
+ fn build_with_transform ( ctx : TestingContext ) {
344
+ let vertices = ctx. device . create_buffer_init ( & BufferInitDescriptor {
345
+ label : None ,
346
+ contents : & [ 0 ; mem:: size_of :: < [ [ f32 ; 3 ] ; 3 ] > ( ) ] ,
347
+ usage : BufferUsages :: BLAS_INPUT ,
348
+ } ) ;
349
+
350
+ let transform = ctx
351
+ . device
352
+ . create_buffer_init ( & wgpu:: util:: BufferInitDescriptor {
353
+ label : Some ( "Vertex Buffer" ) ,
354
+ contents : bytemuck:: cast_slice ( & [
355
+ 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ,
356
+ ] ) ,
357
+ usage : wgpu:: BufferUsages :: VERTEX | wgpu:: BufferUsages :: BLAS_INPUT ,
358
+ } ) ;
359
+
360
+ let blas_size = BlasTriangleGeometrySizeDescriptor {
361
+ vertex_format : VertexFormat :: Float32x3 ,
362
+ vertex_count : 3 ,
363
+ index_format : None ,
364
+ index_count : None ,
365
+ flags : AccelerationStructureGeometryFlags :: empty ( ) ,
366
+ } ;
367
+
368
+ let blas = ctx. device . create_blas (
369
+ & CreateBlasDescriptor {
370
+ label : Some ( "BLAS" ) ,
371
+ flags : AccelerationStructureFlags :: PREFER_FAST_TRACE ,
372
+ update_mode : AccelerationStructureUpdateMode :: Build ,
373
+ } ,
374
+ BlasGeometrySizeDescriptors :: Triangles {
375
+ descriptors : vec ! [ blas_size. clone( ) ] ,
376
+ } ,
377
+ ) ;
378
+
379
+ let tlas = ctx. device . create_tlas ( & CreateTlasDescriptor {
380
+ label : Some ( "TLAS" ) ,
381
+ max_instances : 1 ,
382
+ flags : AccelerationStructureFlags :: PREFER_FAST_TRACE ,
383
+ update_mode : AccelerationStructureUpdateMode :: Build ,
384
+ } ) ;
385
+
386
+ let mut tlas_package = TlasPackage :: new ( tlas) ;
387
+ tlas_package[ 0 ] = Some ( TlasInstance :: new (
388
+ & blas,
389
+ [ 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 , 1.0 , 0.0 , 0.0 , 0.0 ] ,
390
+ 0 ,
391
+ 0xFF ,
392
+ ) ) ;
393
+
394
+ let mut encoder_build = ctx
395
+ . device
396
+ . create_command_encoder ( & CommandEncoderDescriptor {
397
+ label : Some ( "BUILD 1" ) ,
398
+ } ) ;
399
+
400
+ encoder_build. build_acceleration_structures (
401
+ [ & BlasBuildEntry {
402
+ blas : & blas,
403
+ geometry : BlasGeometries :: TriangleGeometries ( vec ! [ BlasTriangleGeometry {
404
+ size: & blas_size,
405
+ vertex_buffer: & vertices,
406
+ first_vertex: 0 ,
407
+ vertex_stride: mem:: size_of:: <[ f32 ; 3 ] >( ) as BufferAddress ,
408
+ index_buffer: None ,
409
+ index_buffer_offset: None ,
410
+ transform_buffer: Some ( & transform) ,
411
+ transform_buffer_offset: Some ( 0 ) ,
412
+ } ] ) ,
413
+ } ] ,
414
+ [ & tlas_package] ,
415
+ ) ;
416
+ ctx. queue . submit ( [ encoder_build. finish ( ) ] ) ;
417
+ }
0 commit comments