This commit is contained in:
linnealovespie 2020-07-31 15:36:46 -04:00
Родитель 9c83864997
Коммит 4011511b10
7 изменённых файлов: 26 добавлений и 20 удалений

Просмотреть файл

@ -49,7 +49,7 @@ namespace StyleTransfer
_saveEnabled = true;
NotifyUser(true);
m_notifier = new StyleTransferEffectNotifier();
m_notifier = new StyleTransferEffectCpp.StyleTransferEffectNotifier();
m_notifier.FrameRateUpdated += async (_, e) =>
{
await DispatcherHelper.RunAsync(() =>

Просмотреть файл

@ -9,7 +9,7 @@
<Identity
Name="7fafd263-abdf-4f88-87a1-ffb0922489d1"
Publisher="CN=t-limay"
Version="1.0.10.0" />
Version="1.0.11.0" />
<mp:PhoneIdentity PhoneProductId="7fafd263-abdf-4f88-87a1-ffb0922489d1" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Просмотреть файл

@ -212,7 +212,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AI.MachineLearning">
<Version>1.3.1-dev-20200711-0122-00cc8041c</Version>
<Version>1.4.0</Version>
</PackageReference>
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
<Version>6.2.10</Version>

Просмотреть файл

@ -41,9 +41,10 @@ namespace winrt::StyleTransferEffectCpp::implementation
OutputDebugString(L"Close\n");
if (Binding != nullptr) Binding.Clear();
if (Session != nullptr) Session.Close();
for (int i = 0; i < swapChainEntryCount; i++) {
bindings[i]->binding.Clear();
}
/*for (int i = 0; i < swapChainEntryCount; i++) {
if (bindings[i]->binding != nullptr)
bindings[i]->binding.Clear();
}*/
}
void StyleTransferEffect::SubmitEval(int swapchaindex, VideoFrame input, VideoFrame output) {
@ -54,6 +55,7 @@ namespace winrt::StyleTransferEffectCpp::implementation
if (currentBinding->activetask == nullptr
|| currentBinding->activetask.Status() != Windows::Foundation::AsyncStatus::Started)
{
auto now = std::chrono::high_resolution_clock::now();
OutputDebugString(L"PF Start new Eval ");
std::wostringstream ss;
ss << swapchaindex;
@ -70,22 +72,27 @@ namespace winrt::StyleTransferEffectCpp::implementation
}
currentBinding->activetask = Session.EvaluateAsync(currentBinding->binding, ss.str().c_str());
currentBinding->activetask.Completed([&, currentBinding](auto&& asyncInfo, winrt::Windows::Foundation::AsyncStatus const args) {
currentBinding->activetask.Completed([&, currentBinding, now](auto&& asyncInfo, winrt::Windows::Foundation::AsyncStatus const args) {
OutputDebugString(L"PF Eval completed |");
VideoFrame evalOutput = asyncInfo.GetResults().Outputs().Lookup(OutputImageDescription).try_as<VideoFrame>();
int bindingIdx;
bool finishedFrameUpdated;
{
std::lock_guard<mutex> guard{ Processing };
auto binding = std::find_if(bindings.begin(), bindings.end(), [currentBinding](const auto& b) {return b.get() == currentBinding; });
bindingIdx = std::distance(bindings.begin(), binding);
finishedIdx = bindingIdx >= finishedIdx ? bindingIdx : finishedIdx;
finishedFrameUpdated = bindingIdx >= finishedIdx;
finishedIdx = finishedFrameUpdated ? bindingIdx : finishedIdx;
}
if (bindingIdx >= finishedIdx)
if (finishedFrameUpdated)
{
OutputDebugString(L"PF Copy | ");
evalOutput.CopyToAsync(currentBinding->outputCache);
}
auto timePassed = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - now);
Notifier.SetFrameRate(1000.f / timePassed.count()); // Convert to FPS: milli to seconds, invert
OutputDebugString(L"PF End ");
});
}

Просмотреть файл

@ -58,7 +58,6 @@ namespace winrt::StyleTransferEffectCpp::implementation
int swapChainIndex = 0;
static const int swapChainEntryCount = 5;
std::vector < std::unique_ptr<SwapChainEntry>> bindings;
//SwapChainEntry bindings[swapChainEntryCount];
int finishedIdx = 0;
};
}

Просмотреть файл

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.props" Condition="Exists('..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.props')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" />
<Import Project="..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.props" Condition="Exists('..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.props')" />
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props')" />
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
@ -155,8 +155,8 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets" Condition="Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets')" />
<Import Project="..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.targets" Condition="Exists('..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.targets" Condition="Exists('..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.targets')" />
<Import Project="..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
@ -166,9 +166,9 @@
<Error Condition="!Exists('packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.props'))" />
<Error Condition="!Exists('packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.AI.MachineLearning.1.3.0\build\native\Microsoft.AI.MachineLearning.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AI.MachineLearning.1.3.1-dev-20200711-0122-00cc8041c\build\native\Microsoft.AI.MachineLearning.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200703.9\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.AI.MachineLearning.1.4.0\build\native\Microsoft.AI.MachineLearning.targets'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.props'))" />
<Error Condition="!Exists('..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Microsoft.Windows.CppWinRT.2.0.200729.8\build\native\Microsoft.Windows.CppWinRT.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AI.MachineLearning" version="1.3.1-dev-20200711-0122-00cc8041c" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.200703.9" targetFramework="native" />
<package id="Microsoft.AI.MachineLearning" version="1.4.0" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.200729.8" targetFramework="native" />
</packages>