@ -2979,7 +2979,7 @@ void test_rayquery(void)
vkd3d_test_set_context ( NULL ) ;
}
void test_raytracing_local_rs_static_sampler ( void )
static void test_raytracing_local_rs_static_sampler_inner ( bool use_libraries )
{
ID3D12GraphicsCommandList4 * command_list4 ;
ID3D12GraphicsCommandList * command_list ;
@ -3070,6 +3070,86 @@ void test_raytracing_local_rs_static_sampler(void)
}
/* Create PSO. */
if ( use_libraries )
{
/* Test that we can deal with local samplers in collections.
* We can only deal with this as long as the collections are compatible ,
* but at least do what we can . */
D3D12_EXPORT_DESC collection_export_descs [ 2 ] = { { u " RayClosest1 " } , { u " RayClosest2 " } } ;
D3D12_EXPORT_DESC export_descs [ 2 ] = { { u " RayGen " } , { u " RayMiss " } } ;
ID3D12StateObject * collections [ 2 ] ;
D3D12_HIT_GROUP_DESC hit_group [ 2 ] ;
struct rt_pso_factory factory ;
unsigned local_index [ 2 ] ;
unsigned int i ;
memset ( hit_group , 0 , sizeof ( hit_group ) ) ;
hit_group [ 0 ] . Type = D3D12_HIT_GROUP_TYPE_TRIANGLES ;
hit_group [ 0 ] . HitGroupExport = u " RayHit1 " ;
hit_group [ 0 ] . ClosestHitShaderImport = u " RayClosest1 " ;
hit_group [ 1 ] . Type = D3D12_HIT_GROUP_TYPE_TRIANGLES ;
hit_group [ 1 ] . HitGroupExport = u " RayHit2 " ;
hit_group [ 1 ] . ClosestHitShaderImport = u " RayClosest2 " ;
for ( i = 0 ; i < 2 ; i + + )
{
rt_pso_factory_init ( & factory ) ;
rt_pso_factory_add_dxil_library ( & factory , get_static_sampler_rt_lib ( ) , 1 , & collection_export_descs [ i ] ) ;
rt_pso_factory_add_state_object_config ( & factory , D3D12_STATE_OBJECT_FLAG_NONE ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
rt_pso_factory_add_global_root_signature ( & factory , global_rs ) ;
rt_pso_factory_add_local_root_signature ( & factory , local_rs [ i ] ) ;
rt_pso_factory_add_hit_group ( & factory , & hit_group [ i ] ) ;
collections [ i ] = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_COLLECTION ) ;
}
rt_pso_factory_init ( & factory ) ;
for ( i = 0 ; i < 2 ; i + + )
rt_pso_factory_add_existing_collection ( & factory , collections [ i ] , 0 , NULL ) ;
rt_pso_factory_add_state_object_config ( & factory , D3D12_STATE_OBJECT_FLAG_NONE ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
rt_pso_factory_add_global_root_signature ( & factory , global_rs ) ;
rt_pso_factory_add_dxil_library ( & factory , get_static_sampler_rt_lib ( ) , ARRAY_SIZE ( export_descs ) , export_descs ) ;
rt_pso = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE ) ;
/* Currently, we expect this to fail on vkd3d-proton since the local sampler sets definitions diverge
* in the different collections . */
todo ok ( ! ! rt_pso , " Failed to compile RTPSO. \n " ) ;
for ( i = 0 ; i < 2 ; i + + )
ID3D12StateObject_Release ( collections [ i ] ) ;
if ( ! rt_pso )
{
/* Try again, but now with both local sets in one collection, which we can make work. */
rt_pso_factory_init ( & factory ) ;
rt_pso_factory_add_dxil_library ( & factory , get_static_sampler_rt_lib ( ) ,
ARRAY_SIZE ( collection_export_descs ) , collection_export_descs ) ;
rt_pso_factory_add_state_object_config ( & factory , D3D12_STATE_OBJECT_FLAG_NONE ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
rt_pso_factory_add_global_root_signature ( & factory , global_rs ) ;
for ( i = 0 ; i < 2 ; i + + )
{
rt_pso_factory_add_hit_group ( & factory , & hit_group [ i ] ) ;
local_index [ i ] = rt_pso_factory_add_local_root_signature ( & factory , local_rs [ i ] ) ;
rt_pso_factory_add_subobject_to_exports_association ( & factory , local_index [ i ] , 1 , & hit_group [ i ] . HitGroupExport ) ;
}
collections [ 0 ] = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_COLLECTION ) ;
rt_pso_factory_init ( & factory ) ;
rt_pso_factory_add_existing_collection ( & factory , collections [ 0 ] , 0 , NULL ) ;
rt_pso_factory_add_state_object_config ( & factory , D3D12_STATE_OBJECT_FLAG_NONE ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
rt_pso_factory_add_global_root_signature ( & factory , global_rs ) ;
rt_pso_factory_add_dxil_library ( & factory , get_static_sampler_rt_lib ( ) , ARRAY_SIZE ( export_descs ) , export_descs ) ;
rt_pso = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE ) ;
ok ( ! ! rt_pso , " Failed to compile RTPSO. \n " ) ;
ID3D12StateObject_Release ( collections [ 0 ] ) ;
}
}
else
{
D3D12_HIT_GROUP_DESC hit_group [ 2 ] ;
struct rt_pso_factory factory ;
@ -3253,6 +3333,16 @@ void test_raytracing_local_rs_static_sampler(void)
destroy_raytracing_test_context ( & context ) ;
}
void test_raytracing_local_rs_static_sampler ( void )
{
test_raytracing_local_rs_static_sampler_inner ( false ) ;
}
void test_raytracing_local_rs_static_sampler_collection ( void )
{
test_raytracing_local_rs_static_sampler_inner ( true ) ;
}
void test_raytracing_no_global_root_signature ( void )
{
struct raytracing_test_context context ;
@ -3673,3 +3763,73 @@ void test_raytracing_embedded_subobjects(void)
ID3D12Device_Release ( device ) ;
destroy_raytracing_test_context ( & context ) ;
}
void test_raytracing_collection_identifiers ( void )
{
uint8_t collection_identifier [ D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ] = { 0 } ;
uint8_t rtpso_identifier [ D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ] = { 0 } ;
struct raytracing_test_context context ;
ID3D12RootSignature * root_signature ;
ID3D12StateObjectProperties * props ;
D3D12_ROOT_SIGNATURE_DESC rs_desc ;
ID3D12StateObject * full_object ;
struct rt_pso_factory factory ;
D3D12_ROOT_PARAMETER param ;
ID3D12StateObject * object ;
ID3D12Device * device ;
const void * ident ;
HRESULT hr ;
if ( ! init_raytracing_test_context ( & context , D3D12_RAYTRACING_TIER_1_0 ) )
return ;
ID3D12Device5_QueryInterface ( context . device5 , & IID_ID3D12Device , ( void * * ) & device ) ;
memset ( & rs_desc , 0 , sizeof ( rs_desc ) ) ;
rs_desc . pParameters = & param ;
rs_desc . NumParameters = 1 ;
memset ( & param , 0 , sizeof ( param ) ) ;
param . ParameterType = D3D12_ROOT_PARAMETER_TYPE_UAV ;
param . ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL ;
create_root_signature ( device , & rs_desc , & root_signature ) ;
rt_pso_factory_init ( & factory ) ;
rt_pso_factory_add_dxil_library ( & factory , get_dummy_raygen_rt_lib ( ) , 0 , NULL ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
rt_pso_factory_add_global_root_signature ( & factory , root_signature ) ;
object = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_COLLECTION ) ;
ok ( ! ! object , " Failed to create collection. \n " ) ;
hr = ID3D12StateObject_QueryInterface ( object , & IID_ID3D12StateObjectProperties , ( void * * ) & props ) ;
ok ( SUCCEEDED ( hr ) , " Failed to query props interface, hr #%x. \n " , hr ) ;
ident = ID3D12StateObjectProperties_GetShaderIdentifier ( props , u " main " ) ;
todo ok ( ! ! ident , " Failed to query identifier for COLLECTION. \n " ) ;
if ( ident )
memcpy ( collection_identifier , ident , sizeof ( collection_identifier ) ) ;
ID3D12StateObjectProperties_Release ( props ) ;
rt_pso_factory_init ( & factory ) ;
rt_pso_factory_add_existing_collection ( & factory , object , 0 , NULL ) ;
rt_pso_factory_add_pipeline_config ( & factory , 1 ) ;
rt_pso_factory_add_shader_config ( & factory , 8 , 4 ) ;
full_object = rt_pso_factory_compile ( & context , & factory , D3D12_STATE_OBJECT_TYPE_RAYTRACING_PIPELINE ) ;
ok ( ! ! full_object , " Failed to create RTPSO. \n " ) ;
hr = ID3D12StateObject_QueryInterface ( full_object , & IID_ID3D12StateObjectProperties , ( void * * ) & props ) ;
ident = ID3D12StateObjectProperties_GetShaderIdentifier ( props , u " main " ) ;
ok ( ! ! ident , " Failed to query identifier for COLLECTION. \n " ) ;
if ( ident )
memcpy ( rtpso_identifier , ident , sizeof ( collection_identifier ) ) ;
ID3D12StateObjectProperties_Release ( props ) ;
todo ok ( memcmp ( collection_identifier , rtpso_identifier , D3D12_SHADER_IDENTIFIER_SIZE_IN_BYTES ) = = 0 , " COLLECTION identifier does not match RTPSO identifier. \n " ) ;
if ( object )
ID3D12StateObject_Release ( object ) ;
if ( full_object )
ID3D12StateObject_Release ( full_object ) ;
ID3D12RootSignature_Release ( root_signature ) ;
ID3D12Device_Release ( device ) ;
destroy_raytracing_test_context ( & context ) ;
}