@@ -3242,3 +3242,173 @@ void test_input_attachments(void)
32423242 ID3D12DeviceExt2_Release (device_ext2 );
32433243 destroy_test_context (& context );
32443244}
3245+
3246+ void test_input_attachments_feedback (void )
3247+ {
3248+ D3D12_GRAPHICS_PIPELINE_STATE_DESC pso_desc ;
3249+ D3D12_VK_INPUT_ATTACHMENT_MAPPINGS mappings ;
3250+ ID3D12GraphicsCommandListExt2 * list_ext2 ;
3251+ struct test_context_desc context_desc ;
3252+ static const float black [4 ] = { 0 };
3253+ D3D12_CPU_DESCRIPTOR_HANDLE depth ;
3254+ D3D12_ROOT_SIGNATURE_DESC rs_desc ;
3255+ D3D12_CPU_DESCRIPTOR_HANDLE rtvs ;
3256+ ID3D12DeviceExt2 * device_ext2 ;
3257+ struct resource_readback rb ;
3258+ struct test_context context ;
3259+ ID3D12DescriptorHeap * descs ;
3260+ ID3D12DescriptorHeap * rtv ;
3261+ ID3D12DescriptorHeap * dsv ;
3262+ ID3D12Resource * color ;
3263+ ID3D12Resource * ds ;
3264+ D3D12_VIEWPORT vp ;
3265+ unsigned int x , y ;
3266+ D3D12_RECT sci ;
3267+ unsigned int i ;
3268+ HRESULT hr ;
3269+
3270+ #include "shaders/render_target/headers/vs_no_attachments.h"
3271+ #include "shaders/render_target/headers/ps_input_attachment_feedback.h"
3272+
3273+ memset (& context_desc , 0 , sizeof (context_desc ));
3274+ memset (& context , 0 , sizeof (context ));
3275+ context_desc .no_pipeline = true;
3276+ context_desc .no_render_target = true;
3277+ context_desc .no_root_signature = true;
3278+
3279+ if (!init_test_context (& context , & context_desc ))
3280+ return ;
3281+
3282+ if (FAILED (ID3D12Device_QueryInterface (context .device , & IID_ID3D12DeviceExt2 , (void * * )& device_ext2 )))
3283+ {
3284+ skip ("ID3D12DeviceExt2 not supported, skipping.\n" );
3285+ destroy_test_context (& context );
3286+ return ;
3287+ }
3288+
3289+ if (ID3D12DeviceExt2_GetTilerOptimizationTier (device_ext2 ) < D3D12_VK_TILER_OPTIMIZATION_TIER_1 )
3290+ {
3291+ skip ("Tiler optimization tier 1 not supported, skipping.\n" );
3292+ ID3D12DeviceExt2_Release (device_ext2 );
3293+ destroy_test_context (& context );
3294+ return ;
3295+ }
3296+
3297+ if (FAILED (ID3D12GraphicsCommandList_QueryInterface (context .list , & IID_ID3D12GraphicsCommandListExt2 , (void * * )& list_ext2 )))
3298+ {
3299+ skip ("ID3D12GraphicsCommandListExt2 not supported, skipping.\n" );
3300+ ID3D12DeviceExt2_Release (device_ext2 );
3301+ destroy_test_context (& context );
3302+ return ;
3303+ }
3304+
3305+ ID3D12DeviceExt2_OptInToTilerOptimizations (device_ext2 );
3306+
3307+ memset (& rs_desc , 0 , sizeof (rs_desc ));
3308+
3309+ mappings .NumRenderTargets = 1 ;
3310+ mappings .EnableDepth = TRUE;
3311+ mappings .RenderTargets [0 ].RegisterSpace = 1 ;
3312+ mappings .RenderTargets [0 ].ShaderRegister = 100 ;
3313+ mappings .Depth .RegisterSpace = 1 ;
3314+ mappings .Depth .ShaderRegister = 101 ;
3315+
3316+ create_root_signature_with_input_attachments (context .device , & rs_desc , & mappings , & context .root_signature );
3317+
3318+ init_pipeline_state_desc (& pso_desc , context .root_signature , DXGI_FORMAT_R32_UINT ,
3319+ & vs_no_attachments_dxbc ,
3320+ & ps_input_attachment_feedback_dxbc , NULL );
3321+
3322+ pso_desc .DSVFormat = DXGI_FORMAT_D32_FLOAT ;
3323+ pso_desc .DepthStencilState .DepthEnable = TRUE;
3324+ pso_desc .DepthStencilState .DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL ;
3325+ pso_desc .DepthStencilState .DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS ;
3326+
3327+ hr = ID3D12Device_CreateGraphicsPipelineState (context .device , & pso_desc , & IID_ID3D12PipelineState , (void * * )& context .pipeline_state );
3328+ ok (SUCCEEDED (hr ), "Failed to create PSO, hr #%x.\n" , hr );
3329+
3330+ color = create_default_texture2d (context .device , 64 , 64 , 1 , 1 ,
3331+ DXGI_FORMAT_R32_UINT ,
3332+ D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET ,
3333+ D3D12_RESOURCE_STATE_RENDER_TARGET );
3334+
3335+ ds = create_default_texture2d (context .device , 64 , 64 , 1 , 1 ,
3336+ DXGI_FORMAT_D32_FLOAT ,
3337+ D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL ,
3338+ D3D12_RESOURCE_STATE_DEPTH_WRITE );
3339+
3340+ rtv = create_cpu_descriptor_heap (context .device , D3D12_DESCRIPTOR_HEAP_TYPE_RTV , 1 );
3341+ dsv = create_cpu_descriptor_heap (context .device , D3D12_DESCRIPTOR_HEAP_TYPE_DSV , 1 );
3342+
3343+ rtvs = get_cpu_rtv_handle (& context , rtv , 0 );
3344+ depth = get_cpu_dsv_handle (& context , dsv , 0 );
3345+
3346+ ID3D12Device_CreateRenderTargetView (context .device , color , NULL , rtvs );
3347+ ID3D12Device_CreateDepthStencilView (context .device , ds , NULL , depth );
3348+
3349+ descs = create_gpu_descriptor_heap (context .device , D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV ,
3350+ ID3D12DeviceExt2_GetInputAttachmentDescriptorsCount (device_ext2 ));
3351+
3352+ ID3D12GraphicsCommandList_SetDescriptorHeaps (context .list , 1 , & descs );
3353+ ID3D12GraphicsCommandList_SetGraphicsRootSignature (context .list , context .root_signature );
3354+
3355+ /* Write input attachment descriptors to heap. */
3356+ ID3D12DeviceExt2_CreateInputAttachmentDescriptors (device_ext2 , 1 , & rtvs , TRUE,
3357+ & depth , NULL , get_cpu_descriptor_handle (& context , descs , 0 ));
3358+ ID3D12GraphicsCommandListExt2_SetRootSignatureInputAttachments (list_ext2 ,
3359+ get_gpu_descriptor_handle (& context , descs , 0 ));
3360+
3361+ set_viewport (& vp , 0 , 0 , 64 , 64 , 0 , 1 );
3362+ set_rect (& sci , 0 , 0 , 64 , 64 );
3363+
3364+ ID3D12GraphicsCommandList_RSSetViewports (context .list , 1 , & vp );
3365+ ID3D12GraphicsCommandList_RSSetScissorRects (context .list , 1 , & sci );
3366+ ID3D12GraphicsCommandList_IASetPrimitiveTopology (context .list , D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST );
3367+ ID3D12GraphicsCommandList_OMSetStencilRef (context .list , 0x60 );
3368+ ID3D12GraphicsCommandListExt2_SetInputAttachmentFeedback (list_ext2 , 0x1 , TRUE, FALSE);
3369+ ID3D12GraphicsCommandList_OMSetRenderTargets (context .list , 1 , & rtvs , TRUE, & depth );
3370+ ID3D12GraphicsCommandList_SetPipelineState (context .list , context .pipeline_state );
3371+ ID3D12GraphicsCommandList_ClearRenderTargetView (context .list , rtvs , black , 0 , NULL );
3372+ ID3D12GraphicsCommandList_ClearDepthStencilView (context .list , depth , D3D12_CLEAR_FLAG_DEPTH , 0.0f , 0 , 0 , NULL );
3373+
3374+ for (i = 0 ; i < 4 ; i ++ )
3375+ {
3376+ /* Need to sync with the clear. */
3377+ ID3D12GraphicsCommandListExt2_InputAttachmentPixelBarrier (list_ext2 );
3378+ ID3D12GraphicsCommandList_DrawInstanced (context .list , 3 , 1 , 0 , 0 );
3379+ }
3380+
3381+ transition_resource_state (context .list , color , D3D12_RESOURCE_STATE_RENDER_TARGET ,
3382+ D3D12_RESOURCE_STATE_COPY_SOURCE );
3383+
3384+ get_texture_readback_with_command_list (color , 0 , & rb , context .queue , context .list );
3385+ for (y = 0 ; y < 64 ; y ++ )
3386+ {
3387+ for (x = 0 ; x < 64 ; x ++ )
3388+ {
3389+ uint32_t rt = 0 ;
3390+ float d = 0.0f ;
3391+ uint32_t value ;
3392+
3393+ /* Resolve the feedback. */
3394+ for (i = 0 ; i < 4 ; i ++ )
3395+ {
3396+ rt += (uint32_t )(d * 1024.0f );
3397+ d += (x + 0.5f ) / 1024.0f + (y + 0.5f ) / 512.0f ;
3398+ }
3399+
3400+ value = get_readback_uint (& rb , x , y , 0 );
3401+ ok (value == rt , "coord %u, %u: expected %u, got %u\n" , x , y , rt , value );
3402+ }
3403+ }
3404+ release_resource_readback (& rb );
3405+
3406+ ID3D12Resource_Release (color );
3407+ ID3D12Resource_Release (ds );
3408+ ID3D12DescriptorHeap_Release (descs );
3409+ ID3D12DescriptorHeap_Release (rtv );
3410+ ID3D12DescriptorHeap_Release (dsv );
3411+ ID3D12GraphicsCommandListExt2_Release (list_ext2 );
3412+ ID3D12DeviceExt2_Release (device_ext2 );
3413+ destroy_test_context (& context );
3414+ }
0 commit comments