Add ComputeSharp.Uwp project
このコミットが含まれているのは:
1 親
cd168be42d
コミット
bfec870d41
10ファイル変更
+1152
検索条件に一致するファイルはありません
@@ -58,6 +58,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.WinUI", "src\C
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ComputeSharp.SwapChain.WinUI", "samples\ComputeSharp.SwapChain.WinUI\ComputeSharp.SwapChain.WinUI.csproj", "{0071701E-B9C5-4098-BE5F-EF556C4553C6}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ComputeSharp.Uwp", "src\ComputeSharp.Uwp\ComputeSharp.Uwp.csproj", "{AFAAFDC9-BE42-45D4-8C79-0EE8C8EDBF52}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SharedMSBuildProjectFiles) = preSolution
|
||||
src\ComputeSharp.NetStandard\ComputeSharp.NetStandard.projitems*{314eb353-e7e3-4146-8111-685cc83ec1de}*SharedItemsImports = 5
|
||||
@@ -69,117 +71,183 @@ Global
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|ARM = Debug|ARM
|
||||
Debug|ARM64 = Debug|ARM64
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|ARM = Release|ARM
|
||||
Release|ARM64 = Release|ARM64
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.ActiveCfg = Debug|ARM64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|ARM64.Build.0 = Debug|ARM64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x64.Build.0 = Debug|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|Any CPU.Build.0 = Release|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.ActiveCfg = Release|ARM64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|ARM64.Build.0 = Release|ARM64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.ActiveCfg = Release|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x64.Build.0 = Release|x64
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{314EB353-E7E3-4146-8111-685CC83EC1DE}.Release|x86.Build.0 = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{34AFE6E6-9A4C-4C3F-AE69-DD3693086DAF}.Release|x86.Build.0 = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x64.Build.0 = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{524CC5DD-1DEE-4A30-9515-AB90965E5207}.Release|x86.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E91F4D24-922A-4921-A8D7-9C45A143C45D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E889E6D6-A814-4950-AAC1-68F1ECFC5BD6}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{EB52CB67-4162-4722-874B-44EA8DA5450E}.Release|x86.Build.0 = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7048DEEA-0A6F-46A0-B951-B682A8F1CB75}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{BBBD0ADD-F2F9-49A3-BD5E-D223F0735D8B}.Release|x86.Build.0 = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{BF52326F-E415-49E6-8595-62762216762B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
@@ -198,24 +266,38 @@ Global
|
||||
{E7C9247D-016B-4819-AF9F-0E9B3591E04B}.Release|x64.Build.0 = Release|x64
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{7C625EC4-F599-4350-A915-F046DF2406D3}.Release|x86.Build.0 = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM.Build.0 = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|ARM64.Build.0 = Release|Any CPU
|
||||
{1F37A704-3CDF-45BB-8114-ED9137E5F2CF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{AFAAFDC9-BE42-45D4-8C79-0EE8C8EDBF52}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>ComputeSharp.Uwp</RootNamespace>
|
||||
<AssemblyName>ComputeSharp.Uwp</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ComputeShaderPanel.cs" />
|
||||
<Compile Include="Controls\ComputeShaderPanel.Properties.cs" />
|
||||
<Compile Include="Controls\ComputeShaderPanel.Rendering.cs" />
|
||||
<Compile Include="Helpers\DynamicResolutionManager.cs" />
|
||||
<Compile Include="IShaderRunner.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ShaderRunner{T}.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.12</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ComputeSharp\ComputeSharp.csproj">
|
||||
<Project>{314eb353-e7e3-4146-8111-685cc83ec1de}</Project>
|
||||
<Name>ComputeSharp</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using Windows.UI.Xaml;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace ComputeSharp.Uwp;
|
||||
|
||||
/// <inheritdoc cref="ComputeShaderPanel"/>
|
||||
public sealed unsafe partial class ComputeShaderPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the <see cref="IShaderRunner"/> instance to use to render content.
|
||||
/// </summary>
|
||||
public IShaderRunner? ShaderRunner
|
||||
{
|
||||
get => (IShaderRunner?)GetValue(ShaderFactoryProperty);
|
||||
set => SetValue(ShaderFactoryProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DependencyProperty"/> backing <see cref="ShaderRunner"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ShaderFactoryProperty = DependencyProperty.Register(
|
||||
nameof(ShaderRunner),
|
||||
typeof(IShaderRunner),
|
||||
typeof(ComputeShaderPanel),
|
||||
new PropertyMetadata(null, static (d, e) => ((ComputeShaderPanel)d).shaderRunner = (IShaderRunner?)e.NewValue));
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the resolution scale to be used to render frames.
|
||||
/// This can help achieve higher framerates with more complex shaders.
|
||||
/// </summary>
|
||||
/// <remarks>The accepted range is [0.1 and 1] (default is 1, exceeding values will be clamped).</remarks>
|
||||
public double ResolutionScale
|
||||
{
|
||||
get => (double)GetValue(ResolutionScaleProperty);
|
||||
set => SetValue(ResolutionScaleProperty, Math.Clamp(value, 0.1, 1.0));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DependencyProperty"/> backing <see cref="ResolutionScale"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty ResolutionScaleProperty = DependencyProperty.Register(
|
||||
nameof(ResolutionScale),
|
||||
typeof(double),
|
||||
typeof(ComputeShaderPanel),
|
||||
new PropertyMetadata(1.0, OnResolutionScalePropertyChanged));
|
||||
|
||||
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
|
||||
private static void OnResolutionScalePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var @this = (ComputeShaderPanel)d;
|
||||
var resolutionScale = (double)e.NewValue;
|
||||
|
||||
@this.targetResolutionScale = (float)resolutionScale;
|
||||
|
||||
if (!@this.isDynamicResolutionEnabled)
|
||||
{
|
||||
@this.OnResize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether dynamic resolution is enabled. If it is, the internal render
|
||||
/// resolution of the shader being run will be automatically adjusted to reach 60fps.
|
||||
/// <para>The default value for this property is <see langword="true"/>.</para>
|
||||
/// </summary>
|
||||
public bool IsDynamicResolutionEnabled
|
||||
{
|
||||
get => (bool)GetValue(IsDynamicResolutionEnabledProperty);
|
||||
set => SetValue(IsDynamicResolutionEnabledProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DependencyProperty"/> backing <see cref="IsDynamicResolutionEnabled"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsDynamicResolutionEnabledProperty = DependencyProperty.Register(
|
||||
nameof(IsDynamicResolutionEnabled),
|
||||
typeof(bool),
|
||||
typeof(ComputeShaderPanel),
|
||||
new PropertyMetadata(true, OnIsDynamicResolutionEnabledPropertyChanged));
|
||||
|
||||
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
|
||||
private static void OnIsDynamicResolutionEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var @this = (ComputeShaderPanel)d;
|
||||
var isDynamicResolutionEnabled = (bool)e.NewValue;
|
||||
|
||||
@this.isDynamicResolutionEnabled = isDynamicResolutionEnabled;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether or not the rendering is paused.
|
||||
/// </summary>
|
||||
public bool IsPaused
|
||||
{
|
||||
get => (bool)GetValue(IsPausedProperty);
|
||||
set => SetValue(IsPausedProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="DependencyProperty"/> backing <see cref="IsPaused"/>.
|
||||
/// </summary>
|
||||
public static readonly DependencyProperty IsPausedProperty = DependencyProperty.Register(
|
||||
nameof(IsPaused),
|
||||
typeof(bool),
|
||||
typeof(ComputeShaderPanel),
|
||||
new PropertyMetadata(false, OnIsPausedPropertyChanged));
|
||||
|
||||
/// <inheritdoc cref="DependencyPropertyChangedCallback"/>
|
||||
private static void OnIsPausedPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var @this = (ComputeShaderPanel)d;
|
||||
var isPaused = (bool)e.NewValue;
|
||||
|
||||
if (isPaused)
|
||||
{
|
||||
@this.OnStopRenderLoop();
|
||||
}
|
||||
else
|
||||
{
|
||||
@this.OnStartRenderLoop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,529 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using ComputeSharp.Core.Extensions;
|
||||
using ComputeSharp.Interop;
|
||||
using ComputeSharp.Uwp.Helpers;
|
||||
using TerraFX.Interop.DirectX;
|
||||
using TerraFX.Interop.Windows;
|
||||
using TerraFX.Interop.WinRT;
|
||||
using Win32 = TerraFX.Interop.Windows.Windows;
|
||||
|
||||
#nullable enable
|
||||
|
||||
#pragma warning disable CS0420
|
||||
|
||||
namespace ComputeSharp.Uwp;
|
||||
|
||||
/// <inheritdoc cref="ComputeShaderPanel"/>
|
||||
public sealed partial class ComputeShaderPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// The render thread in use, if any.
|
||||
/// </summary>
|
||||
private Thread? renderThread;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IShaderRunner"/> instance used to create shaders to run.
|
||||
/// </summary>
|
||||
private IShaderRunner? shaderRunner;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Device"/> pointer for the device currently in use.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12Device> d3D12Device;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12CommandQueue"/> instance to use for graphics operations.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12CommandQueue> d3D12CommandQueue;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12Fence"/> instance used for graphics operations.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12Fence> d3D12Fence;
|
||||
|
||||
/// <summary>
|
||||
/// The next fence value for graphics operations using <see cref="d3D12CommandQueue"/>.
|
||||
/// </summary>
|
||||
private ulong nextD3D12FenceValue = 1;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12CommandAllocator"/> object to create command lists.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12CommandAllocator> d3D12CommandAllocator;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ID3D12GraphicsCommandList"/> instance used to copy data to the back buffers.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12GraphicsCommandList> d3D12GraphicsCommandList;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="IDXGISwapChain2"/> instance used to display content onto the target window.
|
||||
/// </summary>
|
||||
private ComPtr<IDXGISwapChain2> dxgiSwapChain2;
|
||||
|
||||
/// <summary>
|
||||
/// The awaitable object for <see cref="IDXGISwapChain1.Present"/> calls.
|
||||
/// </summary>
|
||||
private HANDLE frameLatencyWaitableObject;
|
||||
|
||||
/// <summary>
|
||||
/// The first buffer within <see cref="dxgiSwapChain2"/>.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12Resource> d3D12Resource0;
|
||||
|
||||
/// <summary>
|
||||
/// The second buffer within <see cref="dxgiSwapChain2"/>.
|
||||
/// </summary>
|
||||
private ComPtr<ID3D12Resource> d3D12Resource1;
|
||||
|
||||
/// <summary>
|
||||
/// The index of the next buffer that can be used to present content.
|
||||
/// </summary>
|
||||
private uint currentBufferIndex;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="ReadWriteTexture2D{T, TPixel}"/> instance used to prepare frames to display.
|
||||
/// </summary>
|
||||
private ReadWriteTexture2D<Rgba32, Float4>? texture;
|
||||
|
||||
/// <summary>
|
||||
/// Whether or not the window has been resized and requires the buffers to be updated.
|
||||
/// </summary>
|
||||
private volatile bool isResizePending;
|
||||
|
||||
/// <summary>
|
||||
/// The backing store for <see cref="Windows.UI.Xaml.FrameworkElement.ActualWidth"/> for the render thread.
|
||||
/// </summary>
|
||||
private volatile float width;
|
||||
|
||||
/// <summary>
|
||||
/// The backing store for <see cref="Windows.UI.Xaml.FrameworkElement.ActualHeight"/> for the render thread.
|
||||
/// </summary>
|
||||
private volatile float height;
|
||||
|
||||
/// <summary>
|
||||
/// The backing store for <see cref="Windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleX"/> for the render thread.
|
||||
/// </summary>
|
||||
private volatile float compositionScaleX;
|
||||
|
||||
/// <summary>
|
||||
/// The backing store for <see cref="Windows.UI.Xaml.Controls.SwapChainPanel.CompositionScaleY"/> for the render thread.
|
||||
/// </summary>
|
||||
private volatile float compositionScaleY;
|
||||
|
||||
/// <summary>
|
||||
/// The resolution scale used to render frames when explicitly controlled by the user.
|
||||
/// </summary>
|
||||
private volatile float resolutionScale;
|
||||
|
||||
/// <summary>
|
||||
/// The resolution scale used to render frames, in either render mode.
|
||||
/// </summary>
|
||||
private volatile float targetResolutionScale;
|
||||
|
||||
/// <summary>
|
||||
/// Whether dynamic resolution is currently enabled.
|
||||
/// </summary>
|
||||
private volatile bool isDynamicResolutionEnabled;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not the rendering has been canceled.
|
||||
/// </summary>
|
||||
private volatile bool isCancellationRequested;
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="Stopwatch"/> instance tracking time since the first rendered frame.
|
||||
/// </summary>
|
||||
private Stopwatch? renderStopwatch;
|
||||
|
||||
/// <summary>
|
||||
/// Indicates whether or not <see cref="OnInitialize"/> has already been called.
|
||||
/// </summary>
|
||||
private bool isInitialized;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes the current application.
|
||||
/// </summary>
|
||||
private unsafe void OnInitialize()
|
||||
{
|
||||
if (this.isInitialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.isInitialized = true;
|
||||
|
||||
// Get the underlying ID3D12Device in use
|
||||
fixed (ID3D12Device** d3D12Device = this.d3D12Device)
|
||||
{
|
||||
InteropServices.TryGetID3D12Device(Gpu.Default, Win32.__uuidof<ID3D12Device>(), (void**)d3D12Device).Assert();
|
||||
}
|
||||
|
||||
// Create the direct command queue to use
|
||||
fixed (ID3D12CommandQueue** d3D12CommandQueue = this.d3D12CommandQueue)
|
||||
{
|
||||
D3D12_COMMAND_QUEUE_DESC d3D12CommandQueueDesc;
|
||||
d3D12CommandQueueDesc.Type = D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT;
|
||||
d3D12CommandQueueDesc.Priority = (int)D3D12_COMMAND_QUEUE_PRIORITY.D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
|
||||
d3D12CommandQueueDesc.Flags = D3D12_COMMAND_QUEUE_FLAGS.D3D12_COMMAND_QUEUE_FLAG_NONE;
|
||||
d3D12CommandQueueDesc.NodeMask = 0;
|
||||
|
||||
this.d3D12Device.Get()->CreateCommandQueue(
|
||||
&d3D12CommandQueueDesc,
|
||||
Win32.__uuidof<ID3D12CommandQueue>(),
|
||||
(void**)d3D12CommandQueue).Assert();
|
||||
}
|
||||
|
||||
// Create the direct fence
|
||||
fixed (ID3D12Fence** d3D12Fence = this.d3D12Fence)
|
||||
{
|
||||
this.d3D12Device.Get()->CreateFence(
|
||||
0,
|
||||
D3D12_FENCE_FLAGS.D3D12_FENCE_FLAG_NONE,
|
||||
Win32.__uuidof<ID3D12Fence>(),
|
||||
(void**)d3D12Fence).Assert();
|
||||
}
|
||||
|
||||
// Create the swap chain to display frames
|
||||
using (ComPtr<IDXGIFactory2> dxgiFactory2 = default)
|
||||
{
|
||||
DirectX.CreateDXGIFactory2(DXGI.DXGI_CREATE_FACTORY_DEBUG, Win32.__uuidof<IDXGIFactory2>(), (void**)dxgiFactory2.GetAddressOf()).Assert();
|
||||
|
||||
DXGI_SWAP_CHAIN_DESC1 dxgiSwapChainDesc1 = default;
|
||||
dxgiSwapChainDesc1.AlphaMode = DXGI_ALPHA_MODE.DXGI_ALPHA_MODE_IGNORE;
|
||||
dxgiSwapChainDesc1.BufferCount = 2;
|
||||
dxgiSwapChainDesc1.Flags = (uint)DXGI_SWAP_CHAIN_FLAG.DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT;
|
||||
dxgiSwapChainDesc1.Format = DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
dxgiSwapChainDesc1.Width = (uint)Math.Max(Math.Ceiling(this.width * this.compositionScaleX * this.targetResolutionScale), 1.0);
|
||||
dxgiSwapChainDesc1.Height = (uint)Math.Max(Math.Ceiling(this.height * this.compositionScaleY * this.targetResolutionScale), 1.0);
|
||||
dxgiSwapChainDesc1.SampleDesc = new DXGI_SAMPLE_DESC(count: 1, quality: 0);
|
||||
dxgiSwapChainDesc1.Scaling = DXGI_SCALING.DXGI_SCALING_STRETCH;
|
||||
dxgiSwapChainDesc1.Stereo = 0;
|
||||
dxgiSwapChainDesc1.SwapEffect = DXGI_SWAP_EFFECT.DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
|
||||
dxgiSwapChainDesc1.BufferUsage = DXGI.DXGI_USAGE_RENDER_TARGET_OUTPUT;
|
||||
|
||||
using ComPtr<IDXGISwapChain1> dxgiSwapChain1 = default;
|
||||
|
||||
dxgiFactory2.Get()->CreateSwapChainForComposition(
|
||||
(IUnknown*)this.d3D12CommandQueue.Get(),
|
||||
&dxgiSwapChainDesc1,
|
||||
null,
|
||||
(IDXGISwapChain1**)&dxgiSwapChain1).Assert();
|
||||
|
||||
fixed (IDXGISwapChain2** dxgiSwapChain2 = this.dxgiSwapChain2)
|
||||
{
|
||||
dxgiSwapChain1.CopyTo(dxgiSwapChain2).Assert();
|
||||
}
|
||||
}
|
||||
|
||||
// Get the awaitable object to synchronizize present calls
|
||||
this.frameLatencyWaitableObject = this.dxgiSwapChain2.Get()->GetFrameLatencyWaitableObject();
|
||||
|
||||
// Create the command allocator to use
|
||||
fixed (ID3D12CommandAllocator** d3D12CommandAllocator = this.d3D12CommandAllocator)
|
||||
{
|
||||
this.d3D12Device.Get()->CreateCommandAllocator(
|
||||
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
Win32.__uuidof<ID3D12CommandAllocator>(),
|
||||
(void**)d3D12CommandAllocator).Assert();
|
||||
}
|
||||
|
||||
// Create the reusable command list to copy data to the back buffers
|
||||
fixed (ID3D12GraphicsCommandList** d3D12GraphicsCommandList = this.d3D12GraphicsCommandList)
|
||||
{
|
||||
this.d3D12Device.Get()->CreateCommandList(
|
||||
0,
|
||||
D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
|
||||
this.d3D12CommandAllocator,
|
||||
null,
|
||||
Win32.__uuidof<ID3D12GraphicsCommandList>(),
|
||||
(void**)d3D12GraphicsCommandList).Assert();
|
||||
}
|
||||
|
||||
// Close the command list to prepare it for future use
|
||||
this.d3D12GraphicsCommandList.Get()->Close().Assert();
|
||||
|
||||
// Extract the ISwapChainPanelNative reference from the current panel, then query the
|
||||
// IDXGISwapChain reference just created and set that as the swap chain panel to use.
|
||||
using ComPtr<ISwapChainPanelNative> swapChainPanelNative = default;
|
||||
|
||||
IUnknown* swapChainPanel = (IUnknown*)Marshal.GetIUnknownForObject(this);
|
||||
|
||||
swapChainPanel->QueryInterface(
|
||||
Win32.__uuidof<ISwapChainPanelNative>(),
|
||||
(void**)&swapChainPanelNative).Assert();
|
||||
|
||||
using ComPtr<IDXGISwapChain> idxgiSwapChain = default;
|
||||
|
||||
this.dxgiSwapChain2.CopyTo(&idxgiSwapChain).Assert();
|
||||
|
||||
swapChainPanelNative.Get()->SetSwapChain(idxgiSwapChain.Get()).Assert();
|
||||
|
||||
GC.KeepAlive(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resizes the current application.
|
||||
/// </summary>
|
||||
private void OnResize()
|
||||
{
|
||||
this.isResizePending = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies the actual resize logic that was scheduled from <see cref="OnResize"/>.
|
||||
/// </summary>
|
||||
private unsafe void ApplyResize()
|
||||
{
|
||||
this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue).Assert();
|
||||
|
||||
// Wait for the fence again to ensure there are no pending operations
|
||||
this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default).Assert();
|
||||
|
||||
this.nextD3D12FenceValue++;
|
||||
|
||||
// Dispose the old buffers before resizing the buffer
|
||||
this.d3D12Resource0.Dispose();
|
||||
this.d3D12Resource1.Dispose();
|
||||
|
||||
// Resize the swap chain buffers
|
||||
this.dxgiSwapChain2.Get()->ResizeBuffers(
|
||||
2,
|
||||
(uint)Math.Max(Math.Ceiling(this.width * this.compositionScaleX * this.targetResolutionScale), 1.0),
|
||||
(uint)Math.Max(Math.Ceiling(this.height * this.compositionScaleY * this.targetResolutionScale), 1.0),
|
||||
DXGI_FORMAT.DXGI_FORMAT_UNKNOWN,
|
||||
(uint)DXGI_SWAP_CHAIN_FLAG.DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT).Assert();
|
||||
|
||||
// Apply the necessary scale transform
|
||||
DXGI_MATRIX_3X2_F transformMatrix = default;
|
||||
transformMatrix._11 = (1 / this.compositionScaleX) * (1 / this.targetResolutionScale);
|
||||
transformMatrix._22 = (1 / this.compositionScaleY) * (1 / this.targetResolutionScale);
|
||||
|
||||
this.dxgiSwapChain2.Get()->SetMatrixTransform(&transformMatrix).Assert();
|
||||
|
||||
// Retrieve the back buffers for the swap chain
|
||||
fixed (ID3D12Resource** d3D12Resource0 = this.d3D12Resource0)
|
||||
fixed (ID3D12Resource** d3D12Resource1 = this.d3D12Resource1)
|
||||
{
|
||||
this.dxgiSwapChain2.Get()->GetBuffer(0, Win32.__uuidof<ID3D12Resource>(), (void**)d3D12Resource0).Assert();
|
||||
this.dxgiSwapChain2.Get()->GetBuffer(1, Win32.__uuidof<ID3D12Resource>(), (void**)d3D12Resource1).Assert();
|
||||
}
|
||||
|
||||
// Get the index of the initial back buffer
|
||||
using (ComPtr<IDXGISwapChain3> dxgiSwapChain3 = default)
|
||||
{
|
||||
this.dxgiSwapChain2.CopyTo(dxgiSwapChain3.GetAddressOf()).Assert();
|
||||
|
||||
this.currentBufferIndex = dxgiSwapChain3.Get()->GetCurrentBackBufferIndex();
|
||||
}
|
||||
|
||||
this.texture?.Dispose();
|
||||
|
||||
D3D12_RESOURCE_DESC d3D12Resource0Description = this.d3D12Resource0.Get()->GetDesc();
|
||||
|
||||
// Create the 2D texture to use to generate frames to display
|
||||
this.texture = Gpu.Default.AllocateReadWriteTexture2D<Rgba32, Float4>(
|
||||
(int)d3D12Resource0Description.Width,
|
||||
(int)d3D12Resource0Description.Height);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the render resolution, if needed, and renders a new frame.
|
||||
/// </summary>
|
||||
/// <param name="time">The current time since the start of the application.</param>
|
||||
private unsafe void OnUpdate(TimeSpan time)
|
||||
{
|
||||
if (this.isResizePending)
|
||||
{
|
||||
ApplyResize();
|
||||
|
||||
this.isResizePending = false;
|
||||
}
|
||||
|
||||
// Skip if no factory is available
|
||||
if (this.shaderRunner is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate the new frame
|
||||
this.shaderRunner.Execute(this.texture!, time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Presents the last rendered frame for the current application.
|
||||
/// </summary>
|
||||
private unsafe void OnPresent()
|
||||
{
|
||||
_ = Win32.WaitForSingleObjectEx(frameLatencyWaitableObject, 1000, 1);
|
||||
|
||||
using ComPtr<ID3D12Resource> d3D12Resource = default;
|
||||
|
||||
// Get the underlying ID3D12Resource pointer for the texture
|
||||
InteropServices.TryGetID3D12Resource(this.texture!, Win32.__uuidof<ID3D12Resource>(), (void**)d3D12Resource.GetAddressOf()).Assert();
|
||||
|
||||
// Get the target back buffer to update
|
||||
ID3D12Resource* d3D12ResourceBackBuffer = this.currentBufferIndex switch
|
||||
{
|
||||
0 => this.d3D12Resource0.Get(),
|
||||
1 => this.d3D12Resource1.Get(),
|
||||
_ => null
|
||||
};
|
||||
|
||||
this.currentBufferIndex ^= 1;
|
||||
|
||||
// Reset the command list and command allocator
|
||||
this.d3D12CommandAllocator.Get()->Reset().Assert();
|
||||
this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null).Assert();
|
||||
|
||||
D3D12_RESOURCE_BARRIER* d3D12ResourceBarriers = stackalloc D3D12_RESOURCE_BARRIER[]
|
||||
{
|
||||
D3D12_RESOURCE_BARRIER.InitTransition(
|
||||
d3D12Resource.Get(),
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE),
|
||||
D3D12_RESOURCE_BARRIER.InitTransition(
|
||||
d3D12ResourceBackBuffer,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST)
|
||||
};
|
||||
|
||||
// Transition the resources to COPY_DEST and COPY_SOURCE respectively
|
||||
this.d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
|
||||
|
||||
// Copy the generated frame to the target back buffer
|
||||
this.d3D12GraphicsCommandList.Get()->CopyResource(d3D12ResourceBackBuffer, d3D12Resource.Get());
|
||||
|
||||
d3D12ResourceBarriers[0] = D3D12_RESOURCE_BARRIER.InitTransition(
|
||||
d3D12Resource.Get(),
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS);
|
||||
|
||||
d3D12ResourceBarriers[1] = D3D12_RESOURCE_BARRIER.InitTransition(
|
||||
d3D12ResourceBackBuffer,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST,
|
||||
D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON);
|
||||
|
||||
// Transition the resources back to COMMON and UNORDERED_ACCESS respectively
|
||||
this.d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);
|
||||
|
||||
this.d3D12GraphicsCommandList.Get()->Close().Assert();
|
||||
|
||||
// Execute the command list to perform the copy
|
||||
this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList**)this.d3D12GraphicsCommandList.GetAddressOf());
|
||||
this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue).Assert();
|
||||
|
||||
// Present the new frame
|
||||
this.dxgiSwapChain2.Get()->Present(0, 0).Assert();
|
||||
|
||||
if (this.nextD3D12FenceValue > this.d3D12Fence.Get()->GetCompletedValue())
|
||||
{
|
||||
this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default).Assert();
|
||||
}
|
||||
|
||||
this.nextD3D12FenceValue++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Executes the render loop for the current panel.
|
||||
/// </summary>
|
||||
/// <remarks>This method assumes to be invoked from a background thread.</remarks>
|
||||
private void OnStartRenderLoop()
|
||||
{
|
||||
static void ExecuteRenderLoop(ComputeShaderPanel @this)
|
||||
{
|
||||
Stopwatch
|
||||
renderStopwatch = @this.renderStopwatch ??= new(),
|
||||
frameStopwatch = Stopwatch.StartNew();
|
||||
|
||||
DynamicResolutionManager.Create(out DynamicResolutionManager frameTimeWatcher);
|
||||
|
||||
bool isDynamicResolutionEnabled = @this.isDynamicResolutionEnabled;
|
||||
|
||||
// Start the initial frame separately, before the timer starts. This ensures that
|
||||
// resuming after a pause correctly renders the first frame at the right time.
|
||||
@this.OnUpdate(renderStopwatch.Elapsed);
|
||||
@this.OnPresent();
|
||||
|
||||
renderStopwatch.Start();
|
||||
|
||||
const long targetFrameTimeInTicksFor61fps = 163934;
|
||||
|
||||
// Main render loop, until cancellation is requested
|
||||
while (!@this.isCancellationRequested)
|
||||
{
|
||||
// Update the resolution mode, if needed
|
||||
if (isDynamicResolutionEnabled != @this.isDynamicResolutionEnabled)
|
||||
{
|
||||
isDynamicResolutionEnabled = !isDynamicResolutionEnabled;
|
||||
|
||||
if (isDynamicResolutionEnabled)
|
||||
{
|
||||
DynamicResolutionManager.Create(out frameTimeWatcher);
|
||||
}
|
||||
else
|
||||
{
|
||||
@this.targetResolutionScale = @this.resolutionScale;
|
||||
}
|
||||
}
|
||||
|
||||
// Evaluate the dynamic resolution frame time step, if the mode is enabled
|
||||
if (isDynamicResolutionEnabled &&
|
||||
frameTimeWatcher.Advance(frameStopwatch.ElapsedTicks, ref @this.targetResolutionScale))
|
||||
{
|
||||
@this.isResizePending = true;
|
||||
}
|
||||
|
||||
while (frameStopwatch.ElapsedTicks < targetFrameTimeInTicksFor61fps)
|
||||
{
|
||||
}
|
||||
|
||||
frameStopwatch.Restart();
|
||||
|
||||
@this.OnUpdate(renderStopwatch.Elapsed);
|
||||
@this.OnPresent();
|
||||
}
|
||||
|
||||
renderStopwatch.Stop();
|
||||
}
|
||||
|
||||
this.isCancellationRequested = false;
|
||||
this.renderThread = new Thread(static args => ExecuteRenderLoop((ComputeShaderPanel)args!));
|
||||
this.renderThread.Start(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the current render loop, if one is running.
|
||||
/// </summary>
|
||||
private void OnStopRenderLoop()
|
||||
{
|
||||
this.isCancellationRequested = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stops the current render loop, and releases all resources.
|
||||
/// </summary>
|
||||
private void OnDisposed()
|
||||
{
|
||||
this.isCancellationRequested = true;
|
||||
|
||||
// Ensure the rendering has stopped
|
||||
if (this.renderThread is Thread renderThread)
|
||||
{
|
||||
renderThread.Join();
|
||||
}
|
||||
|
||||
this.d3D12Device.Dispose();
|
||||
this.d3D12CommandQueue.Dispose();
|
||||
this.d3D12Fence.Dispose();
|
||||
this.d3D12CommandAllocator.Dispose();
|
||||
this.d3D12GraphicsCommandList.Dispose();
|
||||
this.dxgiSwapChain2.Dispose();
|
||||
this.d3D12Resource0.Dispose();
|
||||
this.d3D12Resource1.Dispose();
|
||||
this.texture?.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
|
||||
namespace ComputeSharp.Uwp;
|
||||
|
||||
/// <summary>
|
||||
/// A custom <see cref="SwapChainPanel"/> that can be used to render animated backgrounds.
|
||||
/// It is powered by ComputeSharp and leverages compute shaders to create frames to display.
|
||||
/// </summary>
|
||||
public sealed unsafe partial class ComputeShaderPanel : SwapChainPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ComputeShaderPanel"/> instance.
|
||||
/// </summary>
|
||||
public ComputeShaderPanel()
|
||||
{
|
||||
this.Loaded += ComputeShaderPanel_Loaded;
|
||||
this.Unloaded += ComputeShaderPanel_Unloaded;
|
||||
this.SizeChanged += ComputeShaderPanel_SizeChanged;
|
||||
this.CompositionScaleChanged += ComputeShaderPanel_CompositionScaleChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finalizes the current <see cref="ComputeShaderPanel"/> instance and releases all resources.
|
||||
/// </summary>
|
||||
~ComputeShaderPanel()
|
||||
{
|
||||
OnDisposed();
|
||||
}
|
||||
|
||||
// Initializes the swap chain and starts the render thread
|
||||
private void ComputeShaderPanel_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.width = (float)ActualWidth;
|
||||
this.height = (float)ActualHeight;
|
||||
this.compositionScaleX = CompositionScaleX;
|
||||
this.compositionScaleY = CompositionScaleY;
|
||||
this.resolutionScale = (float)ResolutionScale;
|
||||
this.targetResolutionScale = 1.0f;
|
||||
this.isDynamicResolutionEnabled = true;
|
||||
|
||||
OnInitialize();
|
||||
OnStartRenderLoop();
|
||||
}
|
||||
|
||||
// Requests a cancellation for the render thread
|
||||
private void ComputeShaderPanel_Unloaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
OnStopRenderLoop();
|
||||
}
|
||||
|
||||
// Updates the background store for the frame size factors used by the render thread
|
||||
private void ComputeShaderPanel_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
this.width = (float)e.NewSize.Width;
|
||||
this.height = (float)e.NewSize.Height;
|
||||
|
||||
OnResize();
|
||||
}
|
||||
|
||||
// Updates the background store for the composition scale factors used by the render thread
|
||||
private void ComputeShaderPanel_CompositionScaleChanged(SwapChainPanel sender, object args)
|
||||
{
|
||||
this.compositionScaleX = CompositionScaleX;
|
||||
this.compositionScaleY = CompositionScaleY;
|
||||
|
||||
OnResize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace ComputeSharp.Uwp.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// A helper type that is responsible for applying dynamic resolution changes.
|
||||
/// </summary>
|
||||
internal unsafe ref struct DynamicResolutionManager
|
||||
{
|
||||
/// <summary>
|
||||
/// The target frame time in ticks to reach 60fps (set to 64fps).
|
||||
/// </summary>
|
||||
public const long TargetFrameTimeInTicksFor60fps = 156250;
|
||||
|
||||
/// <summary>
|
||||
/// The upper frame time threshold in ticks to reach 60fps.
|
||||
/// </summary>
|
||||
private const long UpperFrameTimeThresholdInTicksFor60fps = 166666;
|
||||
|
||||
/// <summary>
|
||||
/// The lower frame time threshold in ticks to reach 60fps (set to 68fps).
|
||||
/// </summary>
|
||||
private const long LowerFrameTimeThresholdInTicksFor60fps = 147058;
|
||||
|
||||
/// <summary>
|
||||
/// The size of the sliding frame time window to monitor frame times.
|
||||
/// </summary>
|
||||
private const int SlidingFrameTimeWindowLength = 32;
|
||||
|
||||
/// <summary>
|
||||
/// The threshold for scale factor updates.
|
||||
/// </summary>
|
||||
private const float ScaleFactorDeltaThreshold = 0.005f;
|
||||
|
||||
/// <summary>
|
||||
/// The constant multiplicative factor for the scale factor.
|
||||
/// </summary>
|
||||
private const float ScaleFactorDeltaK = 0.8f;
|
||||
|
||||
/// <summary>
|
||||
/// The window of registered frame times for previous frames.
|
||||
/// </summary>
|
||||
private fixed long frameTimesInTicks[SlidingFrameTimeWindowLength];
|
||||
|
||||
/// <summary>
|
||||
/// The current index into <see cref="frameTimesInTicks"/>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This will have a value of <c>-1</c> when a scale factor update has just been applied, indicating
|
||||
/// that the following frame update should not be tracked to contribute towards the next dynamic resolution
|
||||
/// check. This is done to avoid having the swap chain resize cost influence the moving average of frame times.
|
||||
/// </remarks>
|
||||
private int frameTimeOffset;
|
||||
|
||||
/// <summary>
|
||||
/// The current sum of values within <see cref="frameTimesInTicks"/>.
|
||||
/// </summary>
|
||||
private long slidingFrameTimeWindowSum;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new <see cref="DynamicResolutionManager"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="manager">The resulting <see cref="DynamicResolutionManager"/> instance.</param>
|
||||
public static void Create(out DynamicResolutionManager manager)
|
||||
{
|
||||
manager.frameTimeOffset = 0;
|
||||
manager.slidingFrameTimeWindowSum = TargetFrameTimeInTicksFor60fps * SlidingFrameTimeWindowLength;
|
||||
|
||||
fixed (long* p = &manager.frameTimesInTicks[0])
|
||||
{
|
||||
new Span<long>(p, SlidingFrameTimeWindowLength).Fill(TargetFrameTimeInTicksFor60fps);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advances one frame and updates the scale factor, if needed.
|
||||
/// </summary>
|
||||
/// <param name="frameTimeInTicks">The frame time in ticks for the last rendered frame.</param>
|
||||
/// <param name="scaleFactor">The current scale factor value being used to render frames.</param>
|
||||
/// <returns>Whether or not <paramref name="scaleFactor"/> has been updated and a resize is needed.</returns>
|
||||
public bool Advance(long frameTimeInTicks, ref float scaleFactor)
|
||||
{
|
||||
// Ignore the current frame if a resize has just happened
|
||||
if (this.frameTimeOffset == -1)
|
||||
{
|
||||
this.frameTimeOffset = 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ref long previousFrameTimeInTicks = ref this.frameTimesInTicks[this.frameTimeOffset];
|
||||
|
||||
this.slidingFrameTimeWindowSum -= previousFrameTimeInTicks;
|
||||
this.slidingFrameTimeWindowSum += frameTimeInTicks;
|
||||
|
||||
previousFrameTimeInTicks = frameTimeInTicks;
|
||||
|
||||
this.frameTimeOffset = (int)(((uint)this.frameTimeOffset + 1) % SlidingFrameTimeWindowLength);
|
||||
|
||||
// Check for a dynamic resolution update if the end of the sliding window has been reached.
|
||||
// This is not done every frame to reduce the overhead and amortize for render time fluctuations.
|
||||
if (this.frameTimeOffset == 0)
|
||||
{
|
||||
// This formula is adapted from https://software.intel.com/content/www/us/en/develop/articles/dynamic-resolution-rendering-article.html.
|
||||
long averageFrameTimeInTicks = this.slidingFrameTimeWindowSum / SlidingFrameTimeWindowLength;
|
||||
|
||||
if (averageFrameTimeInTicks is < LowerFrameTimeThresholdInTicksFor60fps or > UpperFrameTimeThresholdInTicksFor60fps)
|
||||
{
|
||||
float
|
||||
frameTimeDelta = (TargetFrameTimeInTicksFor60fps - averageFrameTimeInTicks) / (float)averageFrameTimeInTicks,
|
||||
scaleFactorDelta = scaleFactor * frameTimeDelta * ScaleFactorDeltaK,
|
||||
updatedScaleFactor = Math.Clamp(scaleFactor + scaleFactorDelta, 0.10f, 1.0f);
|
||||
|
||||
// Apply the scale factor update if the target scale has changed enough. This helps to avoid
|
||||
// too frequence resolution changes if the scale factor only changes very little every time.
|
||||
if (Math.Abs(scaleFactor - updatedScaleFactor) >= ScaleFactorDeltaThreshold)
|
||||
{
|
||||
Volatile.Write(ref scaleFactor, updatedScaleFactor);
|
||||
|
||||
this.frameTimeOffset = -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Uwp;
|
||||
|
||||
/// <summary>
|
||||
/// An interface for a shader runner to be used with <see cref="ComputeShaderPanel"/>.
|
||||
/// </summary>
|
||||
public interface IShaderRunner
|
||||
{
|
||||
/// <summary>
|
||||
/// Renders a single frame to a texture.
|
||||
/// </summary>
|
||||
/// <param name="texture">The target texture to render the frame to.</param>
|
||||
/// <param name="timespan">The timespan for the current frame.</param>
|
||||
public void Execute(IReadWriteTexture2D<Float4> texture, TimeSpan timespan);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
[module: SkipLocalsInit]
|
||||
|
||||
[assembly: ComVisible(false)]
|
||||
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
|
||||
namespace ComputeSharp.Uwp;
|
||||
|
||||
/// <summary>
|
||||
/// An <see cref="IShaderRunner"/> implementation powered by a supplied shader type.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of shader to use to render frames.</typeparam>
|
||||
public sealed class ShaderRunner<T> : IShaderRunner
|
||||
where T : struct, IPixelShader<Float4>
|
||||
{
|
||||
/// <summary>
|
||||
/// The <see cref="Func{T1, TResult}"/> instance used to create shaders to run.
|
||||
/// </summary>
|
||||
private readonly Func<TimeSpan, T> shaderFactory;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ShaderRunner{T}"/> instance that will create shader instances with
|
||||
/// the default constructor. Only use this constructor if the shader doesn't require any additional
|
||||
/// resources or other parameters being initialized before being dispatched on the GPU.
|
||||
/// </summary>
|
||||
public ShaderRunner()
|
||||
{
|
||||
this.shaderFactory = static _ => default;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="ShaderRunner{T}"/> instance.
|
||||
/// </summary>
|
||||
/// <param name="shaderFactory">The <see cref="Func{T1, T2, TResult}"/> instance used to create shaders to run.</param>
|
||||
public ShaderRunner(Func<TimeSpan, T> shaderFactory)
|
||||
{
|
||||
this.shaderFactory = shaderFactory;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Execute(IReadWriteTexture2D<Float4> texture, TimeSpan time)
|
||||
{
|
||||
Gpu.Default.ForEach(texture, this.shaderFactory(time));
|
||||
}
|
||||
}
|
||||
@@ -3,4 +3,5 @@
|
||||
[module: SkipLocalsInit]
|
||||
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.Tests.Internals")]
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.Uwp")]
|
||||
[assembly: InternalsVisibleTo("ComputeSharp.WinUI")]
|
||||
新しいイシューから参照
ユーザーをブロックする