git.s-ol.nu ~forks/DiligentCore / 3a19570
Added test for input attachments in the resource signature; fixed few issues in D3D12 assiduous 6 months ago
6 changed file(s) with 53 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
766766 case SHADER_RESOURCE_TYPE_BUFFER_UAV: return D3D12_DESCRIPTOR_RANGE_TYPE_UAV;
767767 case SHADER_RESOURCE_TYPE_SAMPLER: return D3D12_DESCRIPTOR_RANGE_TYPE_SAMPLER;
768768 case SHADER_RESOURCE_TYPE_ACCEL_STRUCT: return D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
769 case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:return D3D12_DESCRIPTOR_RANGE_TYPE_SRV;
769770 // clang-format on
770 case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:
771771 default:
772772 UNEXPECTED("Unknown resource type");
773773 return static_cast<D3D12_DESCRIPTOR_RANGE_TYPE>(-1);
11791179 break;
11801180
11811181 case SHADER_RESOURCE_TYPE_TEXTURE_SRV:
1182 case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:
11821183 CacheResourceView<TextureViewD3D12Impl>(pObj, TEXTURE_VIEW_SHADER_RESOURCE);
11831184 break;
11841185
724724 {
725725 const auto& ResDesc = pSignature->GetResourceDesc(ResAttribution.ResourceIndex);
726726
727 if (Type != ResDesc.ResourceType)
727 auto ResourceType = ResDesc.ResourceType;
728 if (ResourceType == SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT)
729 ResourceType = SHADER_RESOURCE_TYPE_TEXTURE_SRV;
730 if (Type != ResourceType)
728731 {
729732 LOG_ERROR_AND_THROW("Shader '", pShader->GetDesc().Name, "' contains resource with name '", Attribs.Name,
730733 "' and type '", GetShaderResourceTypeLiteralName(Type), "' that is not compatible with type '",
460460 break;
461461
462462 case SHADER_RESOURCE_TYPE_TEXTURE_SRV:
463 case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:
463464 {
464465 auto* pTexViewD3D12 = pObject.RawPtr<TextureViewD3D12Impl>();
465466 auto* pTexToTransition = pTexViewD3D12->GetTexture<TextureD3D12Impl>();
557558 break;
558559
559560 case SHADER_RESOURCE_TYPE_TEXTURE_SRV:
561 case SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT:
560562 {
561563 const auto* pTexViewD3D12 = pObject.RawPtr<const TextureViewD3D12Impl>();
562564 const auto* pTexD3D12 = pTexViewD3D12->GetTexture<TextureD3D12Impl>();
8787 R"(
8888
8989 Texture2D<float4> g_SubpassInput;
90 SamplerState g_SubpassInput_sampler;
9190
9291 struct PSInput
9392 {
179179 pContext->EndRenderPass();
180180 }
181181
182 static void TestInputAttachment(bool UseSignature);
183
182184 static void Present()
183185 {
184186 auto* pEnv = TestingEnvironment::GetInstance();
691693 Present();
692694 }
693695
694 TEST_F(RenderPassTest, InputAttachment)
696 void RenderPassTest::TestInputAttachment(bool UseSignature)
695697 {
696698 auto* pEnv = TestingEnvironment::GetInstance();
697699 auto* pDevice = pEnv->GetDevice();
886888 PSOCreateInfo.pVS = pVS;
887889 PSOCreateInfo.pPS = pPS;
888890
891 RefCntAutoPtr<IPipelineResourceSignature> pSignature;
892 IPipelineResourceSignature* ppSignatures[1]{};
893 if (UseSignature)
894 {
895 PipelineResourceDesc Resources[] = //
896 {
897 {SHADER_TYPE_PIXEL, "g_SubpassInput", 1, SHADER_RESOURCE_TYPE_INPUT_ATTACHMENT, SHADER_RESOURCE_VARIABLE_TYPE_STATIC} //
898 };
899 PipelineResourceSignatureDesc PRSDesc;
900 PRSDesc.Name = "Render pass test - signature";
901 PRSDesc.UseCombinedTextureSamplers = true;
902 PRSDesc.Resources = Resources;
903 PRSDesc.NumResources = _countof(Resources);
904
905 pDevice->CreatePipelineResourceSignature(PRSDesc, &pSignature);
906 ASSERT_NE(pSignature, nullptr);
907 ppSignatures[0] = pSignature;
908 PSOCreateInfo.ppResourceSignatures = ppSignatures;
909 PSOCreateInfo.ResourceSignaturesCount = 1;
910 }
911
889912 pDevice->CreateGraphicsPipelineState(PSOCreateInfo, &pInputAttachmentPSO);
890913 ASSERT_NE(pInputAttachmentPSO, nullptr);
891 pInputAttachmentPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_SubpassInput")->Set(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
892 pInputAttachmentPSO->CreateShaderResourceBinding(&pInputAttachmentSRB, true);
914 if (pSignature)
915 {
916 pSignature->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_SubpassInput")->Set(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
917 pSignature->CreateShaderResourceBinding(&pInputAttachmentSRB, true);
918 }
919 else
920 {
921 pInputAttachmentPSO->GetStaticVariableByName(SHADER_TYPE_PIXEL, "g_SubpassInput")->Set(pTex->GetDefaultView(TEXTURE_VIEW_SHADER_RESOURCE));
922 pInputAttachmentPSO->CreateShaderResourceBinding(&pInputAttachmentSRB, true);
923 }
893924 ASSERT_NE(pInputAttachmentSRB, nullptr);
894925 }
895926
945976 Present();
946977 }
947978
979 TEST_F(RenderPassTest, InputAttachment)
980 {
981 TestInputAttachment(false);
982 }
983
984 TEST_F(RenderPassTest, InputAttachmentWithSignature)
985 {
986 TestInputAttachment(true);
987 }
988
989
948990 } // namespace