Holographic Remoting version 2.1.0 (#6)

* version 2.1.0

* updated .gitignore file

Co-authored-by: Florian Bagar <flbagar@microsoft.com>
This commit is contained in:
FlorianBagarMicrosoft 2020-03-11 14:28:05 +01:00 коммит произвёл GitHub
Родитель d6ff35e13a
Коммит 012a50e416
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
152 изменённых файлов: 16857 добавлений и 15177 удалений

3
.gitignore поставляемый
Просмотреть файл

@ -23,6 +23,9 @@ bld/
[Bb]in/ [Bb]in/
[Oo]bj/ [Oo]bj/
[Ll]og/ [Ll]og/
*.dir/
player/sample/shaders/
remote/uwp/src/
# Visual Studio 2015/2017 cache/options directory # Visual Studio 2015/2017 cache/options directory
.vs/ .vs/

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

@ -1,251 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "CameraResources.h"
#include "DeviceResources.h"
#include "DirectXHelper.h"
#include <windows.graphics.directx.direct3d11.interop.h>
using namespace DirectX;
using namespace winrt::Windows::Graphics::Holographic;
using namespace winrt::Windows::Perception::Spatial;
DXHelper::CameraResources::CameraResources(const HolographicCamera& camera)
: m_holographicCamera(camera)
, m_isStereo(camera.IsStereo())
, m_d3dRenderTargetSize(camera.RenderTargetSize())
{
m_d3dViewport = CD3D11_VIEWPORT(0.f, 0.f, m_d3dRenderTargetSize.Width, m_d3dRenderTargetSize.Height);
};
// Updates resources associated with a holographic camera's swap chain.
// The app does not access the swap chain directly, but it does create
// resource views for the back buffer.
void DXHelper::CameraResources::CreateResourcesForBackBuffer(
DXHelper::DeviceResources* pDeviceResources, const HolographicCameraRenderingParameters& cameraParameters)
{
const auto device = pDeviceResources->GetD3DDevice();
// Get a DXGI interface for the holographic camera's back buffer.
// Holographic cameras do not provide the DXGI swap chain, which is owned
// by the system. The Direct3D back buffer resource is provided using WinRT
// interop APIs.
winrt::com_ptr<ID3D11Resource> resource;
{
winrt::com_ptr<::IInspectable> inspectable = cameraParameters.Direct3D11BackBuffer().as<::IInspectable>();
winrt::com_ptr<Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess> dxgiInterfaceAccess;
HRESULT hr = inspectable->QueryInterface(__uuidof(dxgiInterfaceAccess), dxgiInterfaceAccess.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
hr = dxgiInterfaceAccess->GetInterface(__uuidof(resource), resource.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
}
// Get a Direct3D interface for the holographic camera's back buffer.
winrt::com_ptr<ID3D11Texture2D> cameraBackBuffer;
resource.as(cameraBackBuffer);
// Determine if the back buffer has changed. If so, ensure that the render target view
// is for the current back buffer.
if (m_d3dBackBuffer != cameraBackBuffer)
{
// This can change every frame as the system moves to the next buffer in the
// swap chain. This mode of operation will occur when certain rendering modes
// are activated.
m_d3dBackBuffer = cameraBackBuffer;
// Get the DXGI format for the back buffer.
// This information can be accessed by the app using CameraResources::GetBackBufferDXGIFormat().
D3D11_TEXTURE2D_DESC backBufferDesc;
m_d3dBackBuffer->GetDesc(&backBufferDesc);
m_dxgiFormat = backBufferDesc.Format;
D3D11_RENDER_TARGET_VIEW_DESC viewDesc = {};
viewDesc.ViewDimension = backBufferDesc.ArraySize > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DARRAY : D3D11_RTV_DIMENSION_TEXTURE2D;
viewDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
if (backBufferDesc.ArraySize > 1)
{
viewDesc.Texture2DArray.ArraySize = backBufferDesc.ArraySize;
}
// Create a render target view of the back buffer.
// Creating this resource is inexpensive, and is better than keeping track of
// the back buffers in order to pre-allocate render target views for each one.
m_d3dRenderTargetView = nullptr;
winrt::check_hresult(device->CreateRenderTargetView(m_d3dBackBuffer.get(), &viewDesc, m_d3dRenderTargetView.put()));
// Check for render target size changes.
winrt::Windows::Foundation::Size currentSize = m_holographicCamera.RenderTargetSize();
if (m_d3dRenderTargetSize != currentSize)
{
// Set render target size.
m_d3dRenderTargetSize = currentSize;
// A new depth stencil view is also needed.
m_d3dDepthStencilView = nullptr;
}
}
// Refresh depth stencil resources, if needed.
if (m_d3dDepthStencilView == nullptr)
{
// Create a depth stencil view for use with 3D rendering if needed.
CD3D11_TEXTURE2D_DESC depthStencilDesc(
DXGI_FORMAT_D16_UNORM,
static_cast<UINT>(m_d3dRenderTargetSize.Width),
static_cast<UINT>(m_d3dRenderTargetSize.Height),
m_isStereo ? 2 : 1, // Create two textures when rendering in stereo.
1, // Use a single mipmap level.
D3D11_BIND_DEPTH_STENCIL);
winrt::com_ptr<ID3D11Texture2D> depthStencil;
winrt::check_hresult(device->CreateTexture2D(&depthStencilDesc, nullptr, depthStencil.put()));
CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
m_isStereo ? D3D11_DSV_DIMENSION_TEXTURE2DARRAY : D3D11_DSV_DIMENSION_TEXTURE2D);
winrt::check_hresult(device->CreateDepthStencilView(depthStencil.get(), &depthStencilViewDesc, m_d3dDepthStencilView.put()));
}
// Create the constant buffer, if needed.
if (m_viewProjectionConstantBuffer == nullptr)
{
// Create a constant buffer to store view and projection matrices for the camera.
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_viewProjectionConstantBuffer.put()));
}
}
// Releases resources associated with a back buffer.
void DXHelper::CameraResources::ReleaseResourcesForBackBuffer(DXHelper::DeviceResources* pDeviceResources)
{
// Release camera-specific resources.
m_d3dBackBuffer = nullptr;
m_d3dRenderTargetView = nullptr;
m_d3dDepthStencilView = nullptr;
m_viewProjectionConstantBuffer = nullptr;
// Ensure system references to the back buffer are released by clearing the render
// target from the graphics pipeline state, and then flushing the Direct3D context.
pDeviceResources->UseD3DDeviceContext([](auto context) {
ID3D11RenderTargetView* nullViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {nullptr};
context->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
context->Flush();
});
}
// Updates the view/projection constant buffer for a holographic camera.
void DXHelper::CameraResources::UpdateViewProjectionBuffer(
std::shared_ptr<DXHelper::DeviceResources> deviceResources,
const HolographicCameraPose& cameraPose,
const SpatialCoordinateSystem& coordinateSystem)
{
// The system changes the viewport on a per-frame basis for system optimizations.
m_d3dViewport =
CD3D11_VIEWPORT(cameraPose.Viewport().X, cameraPose.Viewport().Y, cameraPose.Viewport().Width, cameraPose.Viewport().Height);
// The projection transform for each frame is provided by the HolographicCameraPose.
auto cameraProjectionTransform = cameraPose.ProjectionTransform();
// Get a container object with the view and projection matrices for the given
// pose in the given coordinate system.
auto viewTransformContainer = cameraPose.TryGetViewTransform(coordinateSystem);
// If TryGetViewTransform returns a null pointer, that means the pose and coordinate
// system cannot be understood relative to one another; content cannot be rendered
// in this coordinate system for the duration of the current frame.
// This usually means that positional tracking is not active for the current frame, in
// which case it is possible to use a SpatialLocatorAttachedFrameOfReference to render
// content that is not world-locked instead.
DXHelper::ViewProjectionConstantBuffer viewProjectionConstantBufferData = {};
bool viewTransformAcquired = viewTransformContainer != nullptr;
if (viewTransformAcquired)
{
// Otherwise, the set of view transforms can be retrieved.
auto viewCoordinateSystemTransform = viewTransformContainer.Value();
// Update the view matrices. Holographic cameras (such as Microsoft HoloLens) are
// constantly moving relative to the world. The view matrices need to be updated
// every frame.
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[0],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Left) * XMLoadFloat4x4(&cameraProjectionTransform.Left)));
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[1],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Right) * XMLoadFloat4x4(&cameraProjectionTransform.Right)));
}
// Use the D3D device context to update Direct3D device-based resources.
deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || !viewTransformAcquired)
{
m_framePending = false;
}
else
{
// Update the view and projection matrices.
context->UpdateSubresource(m_viewProjectionConstantBuffer.get(), 0, nullptr, &viewProjectionConstantBufferData, 0, 0);
m_framePending = true;
}
});
}
// Gets the view-projection constant buffer for the HolographicCamera and attaches it
// to the shader pipeline.
bool DXHelper::CameraResources::AttachViewProjectionBuffer(std::shared_ptr<DXHelper::DeviceResources> deviceResources)
{
// This method uses Direct3D device-based resources.
return deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
// Cameras can also be added asynchronously, in which case they must be initialized
// before they can be used.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || m_framePending == false)
{
return false;
}
// Set the viewport for this camera.
context->RSSetViewports(1, &m_d3dViewport);
// Send the constant buffer to the vertex shader.
ID3D11Buffer* pBuffer = m_viewProjectionConstantBuffer.get();
context->VSSetConstantBuffers(1, 1, &pBuffer);
// The template includes a pass-through geometry shader that is used by
// default on systems that don't support the D3D11_FEATURE_D3D11_OPTIONS3::
// VPAndRTArrayIndexFromAnyShaderFeedingRasterizer extension. The shader
// will be enabled at run-time on systems that require it.
// If your app will also use the geometry shader for other tasks and those
// tasks require the view/projection matrix, uncomment the following line
// of code to send the constant buffer to the geometry shader as well.
/*context->GSSetConstantBuffers(
1,
1,
m_viewProjectionConstantBuffer.GetAddressOf()
);*/
m_framePending = false;
return true;
});
}

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

@ -1,32 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HolographicHostSample", "HolographicHostSample.vcxproj", "{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Debug|x64.ActiveCfg = Debug|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Debug|x64.Build.0 = Debug|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Debug|x64.Deploy.0 = Debug|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Release|x64.ActiveCfg = Release|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Release|x64.Build.0 = Release|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.Release|x64.Deploy.0 = Release|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}.RelWithDebInfo|x64.Deploy.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E8A3A1EC-E636-40D6-9E3D-C22347CC8162}
EndGlobalSection
EndGlobal

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

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="2.0.14.0" />
<mp:PhoneIdentity PhoneProductId="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>RemotingHostSample</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="SampleHostWindowUWPView">
<uap:VisualElements DisplayName="RemotingHostSampleUWP" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="RemotingHostSampleUWP" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<Capability Name="privateNetworkClientServer" />
<rescap:Capability Name="perceptionMonitoring" />
<DeviceCapability Name="microphone" />
</Capabilities>
</Package>

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

@ -1,242 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "SampleHostWindowWin32.h"
#include <HolographicAppRemoting\Streamer.h>
#include "Common\DbgLog.h"
#include <DirectXColors.h>
#include <windows.graphics.directx.direct3d11.interop.h>
#define WINDOWCLASSNAME L"SampleHostWindowWin32Class"
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static SampleHostWindowWin32* s_sampleHostWindow;
LRESULT result = 0;
switch (msg)
{
case WM_CREATE: {
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lParam);
s_sampleHostWindow = reinterpret_cast<SampleHostWindowWin32*>(cs->lpCreateParams);
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
result = 0;
}
break;
case WM_WINDOWPOSCHANGED: {
auto windowPos = reinterpret_cast<WINDOWPOS*>(lParam);
if ((windowPos->flags & SWP_NOSIZE) == 0)
{
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
}
result = 0;
}
break;
case WM_DESTROY: {
s_sampleHostWindow = nullptr;
result = 0;
PostQuitMessage(0);
}
break;
case WM_CLOSE: {
DestroyWindow(hWnd);
result = 0;
}
break;
case WM_CHAR: {
const int key = tolower(static_cast<int>(wParam));
s_sampleHostWindow->OnKeyPress(static_cast<char>(key));
}
break;
default:
result = DefWindowProc(hWnd, msg, wParam, lParam);
break;
}
return result;
}
void SampleHostWindowWin32::Initialize(bool listen, const std::wstring& hostname, uint32_t port)
{
m_main = std::make_shared<SampleHostMain>(weak_from_this());
m_main->SetHostOptions(listen, hostname, port);
}
void SampleHostWindowWin32::InitializeHwnd(HWND hWnd)
{
m_hWnd = hWnd;
}
void SampleHostWindowWin32::Tick()
{
if (const HolographicFrame& holographicFrame = m_main->Update())
{
m_main->Render(holographicFrame);
}
}
void SampleHostWindowWin32::OnKeyPress(char key)
{
m_main->OnKeyPress(key);
}
void SampleHostWindowWin32::OnResize(int width, int height)
{
m_main->OnResize(width, height);
}
winrt::com_ptr<IDXGISwapChain1>
SampleHostWindowWin32::CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc)
{
winrt::com_ptr<IDXGIDevice1> dxgiDevice;
device.as(dxgiDevice);
winrt::com_ptr<IDXGIAdapter> dxgiAdapter;
winrt::check_hresult(dxgiDevice->GetAdapter(dxgiAdapter.put()));
winrt::com_ptr<IDXGIFactory2> dxgiFactory;
winrt::check_hresult(dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), dxgiFactory.put_void()));
winrt::check_hresult(dxgiFactory->MakeWindowAssociation(m_hWnd, DXGI_MWA_NO_ALT_ENTER));
winrt::com_ptr<IDXGISwapChain1> swapChain = nullptr;
winrt::check_hresult(dxgiFactory->CreateSwapChainForHwnd(device.get(), m_hWnd, desc, nullptr, nullptr, swapChain.put()));
return swapChain;
}
void SampleHostWindowWin32::SetWindowTitle(std::wstring title)
{
if (m_hWnd)
{
if (!SetWindowTextW(m_hWnd, title.c_str()))
{
winrt::check_hresult(HRESULT_FROM_WIN32(GetLastError()));
}
}
}
int main(Platform::Array<Platform::String ^> ^ args)
{
winrt::init_apartment();
bool listen{false};
std::wstring host;
uint32_t port{0};
for (unsigned int i = 1; i < args->Length; ++i)
{
if (args[i]->Length() == 0)
continue;
std::wstring arg = args[i]->Data();
if (arg[0] == '-')
{
std::wstring param = arg.substr(1);
std::transform(param.begin(), param.end(), param.begin(), ::tolower);
if (param == L"listen")
{
listen = true;
}
continue;
}
size_t colonPos = arg.find(L':');
if (colonPos != std::wstring::npos)
{
std::wstring portStr = arg.substr(colonPos + 1);
host = arg.substr(0, colonPos);
port = std::wcstol(portStr.c_str(), nullptr, 10);
}
else
{
host = arg.c_str();
port = 0;
}
}
std::shared_ptr<SampleHostWindowWin32> sampleHostWindow = std::make_shared<SampleHostWindowWin32>();
sampleHostWindow->Initialize(listen, host, port);
WNDCLASSEXW wcex = {};
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = wndProc;
wcex.hInstance = 0;
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
wcex.lpszClassName = WINDOWCLASSNAME;
RegisterClassExW(&wcex);
RECT rc = {0, 0, INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT};
AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, FALSE, 0);
std::wstring windowName = TITLE_TEXT;
HWND hWnd = CreateWindowW(
WINDOWCLASSNAME,
windowName.c_str(),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right - rc.left,
rc.bottom - rc.top,
nullptr,
nullptr,
0,
sampleHostWindow.get());
RECT clientRect;
GetClientRect(hWnd, &clientRect);
sampleHostWindow->InitializeHwnd(hWnd);
ShowWindow(hWnd, SW_SHOWNORMAL);
bool quit = false;
while (!quit)
{
MSG msg = {0};
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
quit = true;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
sampleHostWindow->Tick();
}
}
return 0;
}

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

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Holographic.Remoting" version="2.0.14" targetFramework="native" />
</packages>

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 7.5 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Двоичные данные
hostsampleapp/uwp/Assets/StoreLogo.png

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

Двоичный файл не отображается.

До

Ширина:  |  Высота:  |  Размер: 3.1 KiB

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

@ -1,251 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "CameraResources.h"
#include "DeviceResources.h"
#include "DirectXHelper.h"
#include <windows.graphics.directx.direct3d11.interop.h>
using namespace DirectX;
using namespace winrt::Windows::Graphics::Holographic;
using namespace winrt::Windows::Perception::Spatial;
DXHelper::CameraResources::CameraResources(const HolographicCamera& camera)
: m_holographicCamera(camera)
, m_isStereo(camera.IsStereo())
, m_d3dRenderTargetSize(camera.RenderTargetSize())
{
m_d3dViewport = CD3D11_VIEWPORT(0.f, 0.f, m_d3dRenderTargetSize.Width, m_d3dRenderTargetSize.Height);
};
// Updates resources associated with a holographic camera's swap chain.
// The app does not access the swap chain directly, but it does create
// resource views for the back buffer.
void DXHelper::CameraResources::CreateResourcesForBackBuffer(
DXHelper::DeviceResources* pDeviceResources, const HolographicCameraRenderingParameters& cameraParameters)
{
const auto device = pDeviceResources->GetD3DDevice();
// Get a DXGI interface for the holographic camera's back buffer.
// Holographic cameras do not provide the DXGI swap chain, which is owned
// by the system. The Direct3D back buffer resource is provided using WinRT
// interop APIs.
winrt::com_ptr<ID3D11Resource> resource;
{
winrt::com_ptr<::IInspectable> inspectable = cameraParameters.Direct3D11BackBuffer().as<::IInspectable>();
winrt::com_ptr<Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess> dxgiInterfaceAccess;
HRESULT hr = inspectable->QueryInterface(__uuidof(dxgiInterfaceAccess), dxgiInterfaceAccess.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
hr = dxgiInterfaceAccess->GetInterface(__uuidof(resource), resource.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
}
// Get a Direct3D interface for the holographic camera's back buffer.
winrt::com_ptr<ID3D11Texture2D> cameraBackBuffer;
resource.as(cameraBackBuffer);
// Determine if the back buffer has changed. If so, ensure that the render target view
// is for the current back buffer.
if (m_d3dBackBuffer != cameraBackBuffer)
{
// This can change every frame as the system moves to the next buffer in the
// swap chain. This mode of operation will occur when certain rendering modes
// are activated.
m_d3dBackBuffer = cameraBackBuffer;
// Get the DXGI format for the back buffer.
// This information can be accessed by the app using CameraResources::GetBackBufferDXGIFormat().
D3D11_TEXTURE2D_DESC backBufferDesc;
m_d3dBackBuffer->GetDesc(&backBufferDesc);
m_dxgiFormat = backBufferDesc.Format;
D3D11_RENDER_TARGET_VIEW_DESC viewDesc = {};
viewDesc.ViewDimension = backBufferDesc.ArraySize > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DARRAY : D3D11_RTV_DIMENSION_TEXTURE2D;
viewDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
if (backBufferDesc.ArraySize > 1)
{
viewDesc.Texture2DArray.ArraySize = backBufferDesc.ArraySize;
}
// Create a render target view of the back buffer.
// Creating this resource is inexpensive, and is better than keeping track of
// the back buffers in order to pre-allocate render target views for each one.
m_d3dRenderTargetView = nullptr;
winrt::check_hresult(device->CreateRenderTargetView(m_d3dBackBuffer.get(), &viewDesc, m_d3dRenderTargetView.put()));
// Check for render target size changes.
winrt::Windows::Foundation::Size currentSize = m_holographicCamera.RenderTargetSize();
if (m_d3dRenderTargetSize != currentSize)
{
// Set render target size.
m_d3dRenderTargetSize = currentSize;
// A new depth stencil view is also needed.
m_d3dDepthStencilView = nullptr;
}
}
// Refresh depth stencil resources, if needed.
if (m_d3dDepthStencilView == nullptr)
{
// Create a depth stencil view for use with 3D rendering if needed.
CD3D11_TEXTURE2D_DESC depthStencilDesc(
DXGI_FORMAT_D16_UNORM,
static_cast<UINT>(m_d3dRenderTargetSize.Width),
static_cast<UINT>(m_d3dRenderTargetSize.Height),
m_isStereo ? 2 : 1, // Create two textures when rendering in stereo.
1, // Use a single mipmap level.
D3D11_BIND_DEPTH_STENCIL);
winrt::com_ptr<ID3D11Texture2D> depthStencil;
winrt::check_hresult(device->CreateTexture2D(&depthStencilDesc, nullptr, depthStencil.put()));
CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
m_isStereo ? D3D11_DSV_DIMENSION_TEXTURE2DARRAY : D3D11_DSV_DIMENSION_TEXTURE2D);
winrt::check_hresult(device->CreateDepthStencilView(depthStencil.get(), &depthStencilViewDesc, m_d3dDepthStencilView.put()));
}
// Create the constant buffer, if needed.
if (m_viewProjectionConstantBuffer == nullptr)
{
// Create a constant buffer to store view and projection matrices for the camera.
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_viewProjectionConstantBuffer.put()));
}
}
// Releases resources associated with a back buffer.
void DXHelper::CameraResources::ReleaseResourcesForBackBuffer(DXHelper::DeviceResources* pDeviceResources)
{
// Release camera-specific resources.
m_d3dBackBuffer = nullptr;
m_d3dRenderTargetView = nullptr;
m_d3dDepthStencilView = nullptr;
m_viewProjectionConstantBuffer = nullptr;
// Ensure system references to the back buffer are released by clearing the render
// target from the graphics pipeline state, and then flushing the Direct3D context.
pDeviceResources->UseD3DDeviceContext([](auto context) {
ID3D11RenderTargetView* nullViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {nullptr};
context->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
context->Flush();
});
}
// Updates the view/projection constant buffer for a holographic camera.
void DXHelper::CameraResources::UpdateViewProjectionBuffer(
std::shared_ptr<DXHelper::DeviceResources> deviceResources,
const HolographicCameraPose& cameraPose,
const SpatialCoordinateSystem& coordinateSystem)
{
// The system changes the viewport on a per-frame basis for system optimizations.
m_d3dViewport =
CD3D11_VIEWPORT(cameraPose.Viewport().X, cameraPose.Viewport().Y, cameraPose.Viewport().Width, cameraPose.Viewport().Height);
// The projection transform for each frame is provided by the HolographicCameraPose.
auto cameraProjectionTransform = cameraPose.ProjectionTransform();
// Get a container object with the view and projection matrices for the given
// pose in the given coordinate system.
auto viewTransformContainer = cameraPose.TryGetViewTransform(coordinateSystem);
// If TryGetViewTransform returns a null pointer, that means the pose and coordinate
// system cannot be understood relative to one another; content cannot be rendered
// in this coordinate system for the duration of the current frame.
// This usually means that positional tracking is not active for the current frame, in
// which case it is possible to use a SpatialLocatorAttachedFrameOfReference to render
// content that is not world-locked instead.
DXHelper::ViewProjectionConstantBuffer viewProjectionConstantBufferData = {};
bool viewTransformAcquired = viewTransformContainer != nullptr;
if (viewTransformAcquired)
{
// Otherwise, the set of view transforms can be retrieved.
auto viewCoordinateSystemTransform = viewTransformContainer.Value();
// Update the view matrices. Holographic cameras (such as Microsoft HoloLens) are
// constantly moving relative to the world. The view matrices need to be updated
// every frame.
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[0],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Left) * XMLoadFloat4x4(&cameraProjectionTransform.Left)));
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[1],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Right) * XMLoadFloat4x4(&cameraProjectionTransform.Right)));
}
// Use the D3D device context to update Direct3D device-based resources.
deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || !viewTransformAcquired)
{
m_framePending = false;
}
else
{
// Update the view and projection matrices.
context->UpdateSubresource(m_viewProjectionConstantBuffer.get(), 0, nullptr, &viewProjectionConstantBufferData, 0, 0);
m_framePending = true;
}
});
}
// Gets the view-projection constant buffer for the HolographicCamera and attaches it
// to the shader pipeline.
bool DXHelper::CameraResources::AttachViewProjectionBuffer(std::shared_ptr<DXHelper::DeviceResources> deviceResources)
{
// This method uses Direct3D device-based resources.
return deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
// Cameras can also be added asynchronously, in which case they must be initialized
// before they can be used.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || m_framePending == false)
{
return false;
}
// Set the viewport for this camera.
context->RSSetViewports(1, &m_d3dViewport);
// Send the constant buffer to the vertex shader.
ID3D11Buffer* pBuffer = m_viewProjectionConstantBuffer.get();
context->VSSetConstantBuffers(1, 1, &pBuffer);
// The template includes a pass-through geometry shader that is used by
// default on systems that don't support the D3D11_FEATURE_D3D11_OPTIONS3::
// VPAndRTArrayIndexFromAnyShaderFeedingRasterizer extension. The shader
// will be enabled at run-time on systems that require it.
// If your app will also use the geometry shader for other tasks and those
// tasks require the view/projection matrix, uncomment the following line
// of code to send the constant buffer to the geometry shader as well.
/*context->GSSetConstantBuffers(
1,
1,
m_viewProjectionConstantBuffer.GetAddressOf()
);*/
m_framePending = false;
return true;
});
}

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

@ -1,32 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.645
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HolographicHostSample", "HolographicHostSample.vcxproj", "{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Debug|x64.ActiveCfg = Debug|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Debug|x64.Build.0 = Debug|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Debug|x64.Deploy.0 = Debug|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Release|x64.ActiveCfg = Release|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Release|x64.Build.0 = Release|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.Release|x64.Deploy.0 = Release|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{8933B2A2-C780-3CC9-8B26-0CCB3E806E54}.RelWithDebInfo|x64.Deploy.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E8A3A1EC-E636-40D6-9E3D-C22347CC8162}
EndGlobalSection
EndGlobal

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

@ -1,32 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:rescap="http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities" IgnorableNamespaces="uap mp rescap">
<Identity Name="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="2.0.14.0" />
<mp:PhoneIdentity PhoneProductId="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>RemotingHostSample</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="SampleHostWindowUWPView">
<uap:VisualElements DisplayName="RemotingHostSampleUWP" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="RemotingHostSampleUWP" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<Capability Name="privateNetworkClientServer" />
<rescap:Capability Name="perceptionMonitoring" />
<DeviceCapability Name="microphone" />
</Capabilities>
</Package>

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

@ -1,242 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "SampleHostWindowWin32.h"
#include <HolographicAppRemoting\Streamer.h>
#include "Common\DbgLog.h"
#include <DirectXColors.h>
#include <windows.graphics.directx.direct3d11.interop.h>
#define WINDOWCLASSNAME L"SampleHostWindowWin32Class"
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static SampleHostWindowWin32* s_sampleHostWindow;
LRESULT result = 0;
switch (msg)
{
case WM_CREATE: {
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lParam);
s_sampleHostWindow = reinterpret_cast<SampleHostWindowWin32*>(cs->lpCreateParams);
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
result = 0;
}
break;
case WM_WINDOWPOSCHANGED: {
auto windowPos = reinterpret_cast<WINDOWPOS*>(lParam);
if ((windowPos->flags & SWP_NOSIZE) == 0)
{
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
}
result = 0;
}
break;
case WM_DESTROY: {
s_sampleHostWindow = nullptr;
result = 0;
PostQuitMessage(0);
}
break;
case WM_CLOSE: {
DestroyWindow(hWnd);
result = 0;
}
break;
case WM_CHAR: {
const int key = tolower(static_cast<int>(wParam));
s_sampleHostWindow->OnKeyPress(static_cast<char>(key));
}
break;
default:
result = DefWindowProc(hWnd, msg, wParam, lParam);
break;
}
return result;
}
void SampleHostWindowWin32::Initialize(bool listen, const std::wstring& hostname, uint32_t port)
{
m_main = std::make_shared<SampleHostMain>(weak_from_this());
m_main->SetHostOptions(listen, hostname, port);
}
void SampleHostWindowWin32::InitializeHwnd(HWND hWnd)
{
m_hWnd = hWnd;
}
void SampleHostWindowWin32::Tick()
{
if (const HolographicFrame& holographicFrame = m_main->Update())
{
m_main->Render(holographicFrame);
}
}
void SampleHostWindowWin32::OnKeyPress(char key)
{
m_main->OnKeyPress(key);
}
void SampleHostWindowWin32::OnResize(int width, int height)
{
m_main->OnResize(width, height);
}
winrt::com_ptr<IDXGISwapChain1>
SampleHostWindowWin32::CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc)
{
winrt::com_ptr<IDXGIDevice1> dxgiDevice;
device.as(dxgiDevice);
winrt::com_ptr<IDXGIAdapter> dxgiAdapter;
winrt::check_hresult(dxgiDevice->GetAdapter(dxgiAdapter.put()));
winrt::com_ptr<IDXGIFactory2> dxgiFactory;
winrt::check_hresult(dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), dxgiFactory.put_void()));
winrt::check_hresult(dxgiFactory->MakeWindowAssociation(m_hWnd, DXGI_MWA_NO_ALT_ENTER));
winrt::com_ptr<IDXGISwapChain1> swapChain = nullptr;
winrt::check_hresult(dxgiFactory->CreateSwapChainForHwnd(device.get(), m_hWnd, desc, nullptr, nullptr, swapChain.put()));
return swapChain;
}
void SampleHostWindowWin32::SetWindowTitle(std::wstring title)
{
if (m_hWnd)
{
if (!SetWindowTextW(m_hWnd, title.c_str()))
{
winrt::check_hresult(HRESULT_FROM_WIN32(GetLastError()));
}
}
}
int main(Platform::Array<Platform::String ^> ^ args)
{
winrt::init_apartment();
bool listen{false};
std::wstring host;
uint32_t port{0};
for (unsigned int i = 1; i < args->Length; ++i)
{
if (args[i]->Length() == 0)
continue;
std::wstring arg = args[i]->Data();
if (arg[0] == '-')
{
std::wstring param = arg.substr(1);
std::transform(param.begin(), param.end(), param.begin(), ::tolower);
if (param == L"listen")
{
listen = true;
}
continue;
}
size_t colonPos = arg.find(L':');
if (colonPos != std::wstring::npos)
{
std::wstring portStr = arg.substr(colonPos + 1);
host = arg.substr(0, colonPos);
port = std::wcstol(portStr.c_str(), nullptr, 10);
}
else
{
host = arg.c_str();
port = 0;
}
}
std::shared_ptr<SampleHostWindowWin32> sampleHostWindow = std::make_shared<SampleHostWindowWin32>();
sampleHostWindow->Initialize(listen, host, port);
WNDCLASSEXW wcex = {};
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = wndProc;
wcex.hInstance = 0;
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
wcex.lpszClassName = WINDOWCLASSNAME;
RegisterClassExW(&wcex);
RECT rc = {0, 0, INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT};
AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, FALSE, 0);
std::wstring windowName = TITLE_TEXT;
HWND hWnd = CreateWindowW(
WINDOWCLASSNAME,
windowName.c_str(),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right - rc.left,
rc.bottom - rc.top,
nullptr,
nullptr,
0,
sampleHostWindow.get());
RECT clientRect;
GetClientRect(hWnd, &clientRect);
sampleHostWindow->InitializeHwnd(hWnd);
ShowWindow(hWnd, SW_SHOWNORMAL);
bool quit = false;
while (!quit)
{
MSG msg = {0};
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
quit = true;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
sampleHostWindow->Tick();
}
}
return 0;
}

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

@ -1,4 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Holographic.Remoting" version="2.0.14" targetFramework="native" />
</packages>

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

@ -12,7 +12,7 @@
#include "pch.h" #include "pch.h"
#include "CameraResources.h" #include "CameraResources.h"
#include "DeviceResources.h" #include "DeviceResourcesUWP.h"
using namespace DirectX; using namespace DirectX;
using namespace winrt::Windows::Foundation::Numerics; using namespace winrt::Windows::Foundation::Numerics;
@ -35,7 +35,7 @@ namespace DXHelper
// The app does not access the swap chain directly, but it does create // The app does not access the swap chain directly, but it does create
// resource views for the back buffer. // resource views for the back buffer.
void CameraResources::CreateResourcesForBackBuffer( void CameraResources::CreateResourcesForBackBuffer(
DeviceResources* pDeviceResources, HolographicCameraRenderingParameters const& cameraParameters) DeviceResourcesUWP* pDeviceResources, HolographicCameraRenderingParameters const& cameraParameters)
{ {
ID3D11Device* device = pDeviceResources->GetD3DDevice(); ID3D11Device* device = pDeviceResources->GetD3DDevice();
@ -105,6 +105,10 @@ namespace DXHelper
1, // Use a single mipmap level. 1, // Use a single mipmap level.
D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE); D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE);
// Allow sharing by default for easier interop with future D3D12 components for processing the remote or local frame.
// This is optional, but without the flag any D3D12 components need to perform an additional copy.
depthStencilDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;
m_d3dDepthStencil = nullptr; m_d3dDepthStencil = nullptr;
winrt::check_hresult(device->CreateTexture2D(&depthStencilDesc, nullptr, m_d3dDepthStencil.put())); winrt::check_hresult(device->CreateTexture2D(&depthStencilDesc, nullptr, m_d3dDepthStencil.put()));
@ -119,12 +123,14 @@ namespace DXHelper
{ {
// Create a constant buffer to store view and projection matrices for the camera. // Create a constant buffer to store view and projection matrices for the camera.
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
constantBufferDesc.Usage = D3D11_USAGE_DYNAMIC;
constantBufferDesc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_viewProjectionConstantBuffer.put())); winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_viewProjectionConstantBuffer.put()));
} }
} }
// Releases resources associated with a back buffer. // Releases resources associated with a back buffer.
void CameraResources::ReleaseResourcesForBackBuffer(DeviceResources* pDeviceResources) void CameraResources::ReleaseResourcesForBackBuffer(DeviceResourcesUWP* pDeviceResources)
{ {
// Release camera-specific resources. // Release camera-specific resources.
m_d3dBackBuffer = nullptr; m_d3dBackBuffer = nullptr;
@ -144,7 +150,7 @@ namespace DXHelper
// Updates the view/projection constant buffer for a holographic camera. // Updates the view/projection constant buffer for a holographic camera.
void CameraResources::UpdateViewProjectionBuffer( void CameraResources::UpdateViewProjectionBuffer(
std::shared_ptr<DeviceResources> deviceResources, std::shared_ptr<DeviceResourcesUWP> deviceResources,
HolographicCameraPose const& cameraPose, HolographicCameraPose const& cameraPose,
SpatialCoordinateSystem const& coordinateSystem) SpatialCoordinateSystem const& coordinateSystem)
{ {
@ -153,7 +159,7 @@ namespace DXHelper
m_d3dViewport = CD3D11_VIEWPORT(viewport.X, viewport.Y, viewport.Width, viewport.Height); m_d3dViewport = CD3D11_VIEWPORT(viewport.X, viewport.Y, viewport.Width, viewport.Height);
// The projection transform for each frame is provided by the HolographicCameraPose. // The projection transform for each frame is provided by the HolographicCameraPose.
HolographicStereoTransform cameraProjectionTransform = cameraPose.ProjectionTransform(); m_cameraProjectionTransform = cameraPose.ProjectionTransform();
// Get a container object with the view and projection matrices for the given // Get a container object with the view and projection matrices for the given
// pose in the given coordinate system. // pose in the given coordinate system.
@ -166,6 +172,7 @@ namespace DXHelper
// which case it is possible to use a SpatialLocatorAttachedFrameOfReference to render // which case it is possible to use a SpatialLocatorAttachedFrameOfReference to render
// content that is not world-locked instead. // content that is not world-locked instead.
ViewProjectionConstantBuffer viewProjectionConstantBufferData; ViewProjectionConstantBuffer viewProjectionConstantBufferData;
bool viewTransformAcquired = viewTransformContainer != nullptr; bool viewTransformAcquired = viewTransformContainer != nullptr;
if (viewTransformAcquired) if (viewTransformAcquired)
{ {
@ -175,12 +182,14 @@ namespace DXHelper
// Update the view matrices. Holographic cameras (such as Microsoft HoloLens) are // Update the view matrices. Holographic cameras (such as Microsoft HoloLens) are
// constantly moving relative to the world. The view matrices need to be updated // constantly moving relative to the world. The view matrices need to be updated
// every frame. // every frame.
XMStoreFloat4x4( XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[0], &viewProjectionConstantBufferData.viewProjection[0],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Left) * XMLoadFloat4x4(&cameraProjectionTransform.Left))); XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Left) * XMLoadFloat4x4(&m_cameraProjectionTransform.Left)));
XMStoreFloat4x4( XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[1], &viewProjectionConstantBufferData.viewProjection[1],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Right) * XMLoadFloat4x4(&cameraProjectionTransform.Right))); XMMatrixTranspose(
XMLoadFloat4x4(&viewCoordinateSystemTransform.Right) * XMLoadFloat4x4(&m_cameraProjectionTransform.Right)));
} }
// Use the D3D device context to update Direct3D device-based resources. // Use the D3D device context to update Direct3D device-based resources.
@ -193,7 +202,10 @@ namespace DXHelper
else else
{ {
// Update the view and projection matrices. // Update the view and projection matrices.
context->UpdateSubresource(m_viewProjectionConstantBuffer.get(), 0, nullptr, &viewProjectionConstantBufferData, 0, 0); D3D11_MAPPED_SUBRESOURCE resource;
context->Map(m_viewProjectionConstantBuffer.get(), 0, D3D11_MAP_WRITE_DISCARD, 0, &resource);
memcpy(resource.pData, &viewProjectionConstantBufferData, sizeof(viewProjectionConstantBufferData));
context->Unmap(m_viewProjectionConstantBuffer.get(), 0);
m_framePending = true; m_framePending = true;
} }
@ -202,7 +214,7 @@ namespace DXHelper
// Gets the view-projection constant buffer for the HolographicCamera and attaches it // Gets the view-projection constant buffer for the HolographicCamera and attaches it
// to the shader pipeline. // to the shader pipeline.
bool CameraResources::AttachViewProjectionBuffer(std::shared_ptr<DeviceResources>& deviceResources) bool CameraResources::AttachViewProjectionBuffer(std::shared_ptr<DeviceResourcesUWP>& deviceResources)
{ {
// This method uses Direct3D device-based resources. // This method uses Direct3D device-based resources.
return deviceResources->UseD3DDeviceContext([&](auto context) { return deviceResources->UseD3DDeviceContext([&](auto context) {
@ -221,22 +233,22 @@ namespace DXHelper
ID3D11Buffer* viewProjectionConstantBuffers[1] = {m_viewProjectionConstantBuffer.get()}; ID3D11Buffer* viewProjectionConstantBuffers[1] = {m_viewProjectionConstantBuffer.get()};
context->VSSetConstantBuffers(1, 1, viewProjectionConstantBuffers); context->VSSetConstantBuffers(1, 1, viewProjectionConstantBuffers);
// The template includes a pass-through geometry shader that is used by
// default on systems that don't support the D3D11_FEATURE_D3D11_OPTIONS3::
// VPAndRTArrayIndexFromAnyShaderFeedingRasterizer extension. The shader
// will be enabled at run-time on systems that require it.
// If your app will also use the geometry shader for other tasks and those
// tasks require the view/projection matrix, uncomment the following line
// of code to send the constant buffer to the geometry shader as well.
/*context->GSSetConstantBuffers(
1,
1,
m_viewProjectionConstantBuffer.GetAddressOf()
);*/
m_framePending = false; m_framePending = false;
return true; return true;
}); });
} }
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface CameraResources::GetDepthStencilTextureInteropObject()
{
// Direct3D interop APIs are used to provide the buffer to the WinRT API.
winrt::com_ptr<IDXGIResource1> depthStencilResource;
winrt::check_bool(m_d3dDepthStencil.try_as(depthStencilResource));
winrt::com_ptr<IDXGISurface2> depthDxgiSurface;
winrt::check_hresult(depthStencilResource->CreateSubresourceSurface(0, depthDxgiSurface.put()));
winrt::com_ptr<::IInspectable> inspectableSurface;
winrt::check_hresult(CreateDirect3D11SurfaceFromDXGISurface(
depthDxgiSurface.get(), reinterpret_cast<IInspectable**>(winrt::put_abi(inspectableSurface))));
return inspectableSurface.as<winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface>();
}
} // namespace DXHelper } // namespace DXHelper

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

@ -12,7 +12,7 @@
namespace DXHelper namespace DXHelper
{ {
class DeviceResources; class DeviceResourcesUWP;
// Constant buffer used to send the view-projection matrices to the shader pipeline. // Constant buffer used to send the view-projection matrices to the shader pipeline.
struct ViewProjectionConstantBuffer struct ViewProjectionConstantBuffer
@ -33,16 +33,16 @@ namespace DXHelper
CameraResources(winrt::Windows::Graphics::Holographic::HolographicCamera const& holographicCamera); CameraResources(winrt::Windows::Graphics::Holographic::HolographicCamera const& holographicCamera);
void CreateResourcesForBackBuffer( void CreateResourcesForBackBuffer(
DeviceResources* pDeviceResources, DeviceResourcesUWP* pDeviceResources,
winrt::Windows::Graphics::Holographic::HolographicCameraRenderingParameters const& cameraParameters); winrt::Windows::Graphics::Holographic::HolographicCameraRenderingParameters const& cameraParameters);
void ReleaseResourcesForBackBuffer(DeviceResources* pDeviceResources); void ReleaseResourcesForBackBuffer(DeviceResourcesUWP* pDeviceResources);
void UpdateViewProjectionBuffer( void UpdateViewProjectionBuffer(
std::shared_ptr<DeviceResources> deviceResources, std::shared_ptr<DeviceResourcesUWP> deviceResources,
winrt::Windows::Graphics::Holographic::HolographicCameraPose const& cameraPose, winrt::Windows::Graphics::Holographic::HolographicCameraPose const& cameraPose,
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem); winrt::Windows::Perception::Spatial::SpatialCoordinateSystem const& coordinateSystem);
bool AttachViewProjectionBuffer(std::shared_ptr<DeviceResources>& deviceResources); bool AttachViewProjectionBuffer(std::shared_ptr<DeviceResourcesUWP>& deviceResources);
// Direct3D device resources. // Direct3D device resources.
ID3D11RenderTargetView* GetBackBufferRenderTargetView() const ID3D11RenderTargetView* GetBackBufferRenderTargetView() const
@ -86,6 +86,12 @@ namespace DXHelper
return m_holographicCamera; return m_holographicCamera;
} }
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface GetDepthStencilTextureInteropObject();
winrt::Windows::Graphics::Holographic::HolographicStereoTransform GetProjectionTransform()
{
return m_cameraProjectionTransform;
}
private: private:
// Direct3D rendering objects. Required for 3D. // Direct3D rendering objects. Required for 3D.
winrt::com_ptr<ID3D11RenderTargetView> m_d3dRenderTargetView; winrt::com_ptr<ID3D11RenderTargetView> m_d3dRenderTargetView;
@ -109,5 +115,7 @@ namespace DXHelper
// Pointer to the holographic camera these resources are for. // Pointer to the holographic camera these resources are for.
winrt::Windows::Graphics::Holographic::HolographicCamera m_holographicCamera = nullptr; winrt::Windows::Graphics::Holographic::HolographicCamera m_holographicCamera = nullptr;
winrt::Windows::Graphics::Holographic::HolographicStereoTransform m_cameraProjectionTransform;
}; };
} // namespace DXHelper } // namespace DXHelper

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

@ -21,8 +21,8 @@
#include "pch.h" #include "pch.h"
#include <assert.h>
#include <algorithm> #include <algorithm>
#include <assert.h>
#include <memory> #include <memory>
#include "DDSTextureLoader.h" #include "DDSTextureLoader.h"
@ -256,7 +256,6 @@ static HRESULT LoadTextureDataFromFile(
return S_OK; return S_OK;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Return the BPP for a particular format // Return the BPP for a particular format
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -419,7 +418,6 @@ static size_t BitsPerPixel(_In_ DXGI_FORMAT fmt)
} }
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
// Get surface information for a particular format // Get surface information for a particular format
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
@ -563,7 +561,6 @@ static void GetSurfaceInfo(
} }
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
#define ISBITMASK(r, g, b, a) (ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a) #define ISBITMASK(r, g, b, a) (ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a)
@ -777,7 +774,6 @@ static DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf)
return DXGI_FORMAT_UNKNOWN; return DXGI_FORMAT_UNKNOWN;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
static DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) static DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format)
{ {
@ -809,7 +805,6 @@ static DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format)
} }
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
static HRESULT FillInitData( static HRESULT FillInitData(
_In_ size_t width, _In_ size_t width,
@ -902,7 +897,6 @@ static HRESULT FillInitData(
return (index > 0) ? S_OK : E_FAIL; return (index > 0) ? S_OK : E_FAIL;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
static HRESULT CreateD3DResources( static HRESULT CreateD3DResources(
_In_ ID3D11Device* d3dDevice, _In_ ID3D11Device* d3dDevice,
@ -1122,7 +1116,6 @@ static HRESULT CreateD3DResources(
return hr; return hr;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
static HRESULT CreateTextureFromDDS( static HRESULT CreateTextureFromDDS(
_In_ ID3D11Device* d3dDevice, _In_ ID3D11Device* d3dDevice,
@ -1528,7 +1521,6 @@ static HRESULT CreateTextureFromDDS(
return hr; return hr;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
static DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header) static DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header)
{ {
@ -1556,7 +1548,6 @@ static DDS_ALPHA_MODE GetAlphaMode(_In_ const DDS_HEADER* header)
return DDS_ALPHA_MODE_UNKNOWN; return DDS_ALPHA_MODE_UNKNOWN;
} }
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
_Use_decl_annotations_ HRESULT DirectX::CreateDDSTextureFromMemory( _Use_decl_annotations_ HRESULT DirectX::CreateDDSTextureFromMemory(
ID3D11Device* d3dDevice, ID3D11Device* d3dDevice,

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

@ -84,7 +84,9 @@ bool ErrorHelper::ProcessOnDisconnect(const ConnectionFailureReason& reason)
return true; return true;
case ConnectionFailureReason::ProtocolVersionMismatch: case ConnectionFailureReason::ProtocolVersionMismatch:
AddError(L"Disconnect: Transport connection was closed due to protocol version mismatch"); AddError(L"Disconnect: Transport connection was closed due to protocol version mismatch. "
L"Please go to the store app and check for any updates and install them to potentially resolve "
L"this error.");
return true; return true;
case ConnectionFailureReason::ProtocolError: case ConnectionFailureReason::ProtocolError:
@ -107,6 +109,18 @@ bool ErrorHelper::ProcessOnDisconnect(const ConnectionFailureReason& reason)
case ConnectionFailureReason::DeviceLost: case ConnectionFailureReason::DeviceLost:
AddError(L"Disconnect: Connection has been closed due to graphics device loss"); AddError(L"Disconnect: Connection has been closed due to graphics device loss");
return true; return true;
case ConnectionFailureReason::HandshakeNetworkUnreachable:
AddError(L"Disconnect: Handshake - Network unreachable");
return true;
case ConnectionFailureReason::HandshakeConnectionRefused:
AddError(L"Disconnect: Handshake - Connection has been refused by remote host");
return true;
case ConnectionFailureReason::VideoFormatNotAvailable:
AddError(L"Disconnect: Transport connection was closed due to the requested video format not being available");
return true;
} }
return false; return false;

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

@ -22,7 +22,6 @@ static_assert(
(sizeof(ModelConstantBuffer) % (sizeof(float) * 4)) == 0, (sizeof(ModelConstantBuffer) % (sizeof(float) * 4)) == 0,
"Model constant buffer size must be multiple of 16-bytes (16 bytes is the length of four floats)."); "Model constant buffer size must be multiple of 16-bytes (16 bytes is the length of four floats).");
// Used to send per-vertex data to the vertex shader. // Used to send per-vertex data to the vertex shader.
struct VertexBufferElement struct VertexBufferElement
{ {

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

@ -18,13 +18,14 @@
#include <shaders\VPRTVertexShader.h> #include <shaders\VPRTVertexShader.h>
#include <shaders\VertexShader.h> #include <shaders\VertexShader.h>
#define TEXTURE_WIDTH 650 constexpr const wchar_t Font[] = L"Segoe UI";
#define TEXTURE_HEIGHT 650 // Font size in percent.
constexpr float FontSizeLarge = 0.06f;
#define Font L"Segoe UI" constexpr float FontSizeMedium = 0.04f;
#define FontSizeLarge 32.0f constexpr float FontSizeSmall = 0.035f;
#define FontSizeSmall 22.0f constexpr const wchar_t FontLanguage[] = L"en-US";
#define FontLanguage L"en-US" constexpr const float Degree2Rad = 3.14159265359f / 180.0f;
constexpr const float Meter2Inch = 39.37f;
using namespace DirectX; using namespace DirectX;
using namespace Concurrency; using namespace Concurrency;
@ -32,7 +33,7 @@ using namespace winrt::Windows::Foundation::Numerics;
using namespace winrt::Windows::UI::Input::Spatial; using namespace winrt::Windows::UI::Input::Spatial;
// Initializes D2D resources used for text rendering. // Initializes D2D resources used for text rendering.
StatusDisplay::StatusDisplay(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources) StatusDisplay::StatusDisplay(const std::shared_ptr<DXHelper::DeviceResourcesCommon>& deviceResources)
: m_deviceResources(deviceResources) : m_deviceResources(deviceResources)
{ {
CreateDeviceDependentResources(); CreateDeviceDependentResources();
@ -55,29 +56,37 @@ void StatusDisplay::Render()
return; return;
} }
// First render all text using direct2D bool linesChanged = false;
m_deviceResources->UseD3DDeviceContext(
[&](auto context) { context->ClearRenderTargetView(m_textRenderTarget.get(), DirectX::Colors::Transparent); });
m_d2dTextRenderTarget->BeginDraw();
// First render all text using direct2D.
{ {
std::scoped_lock lock(m_lineMutex); std::scoped_lock lock(m_lineMutex);
if (m_lines.size() > 0) if (m_lines.size() > 0)
{ {
float top = m_lines[0].metrics.height; linesChanged = true;
m_deviceResources->UseD3DDeviceContext(
[&](auto context) { context->ClearRenderTargetView(m_textRenderTarget.get(), DirectX::Colors::Transparent); });
m_d2dTextRenderTarget->BeginDraw();
float height = 0;
for (auto& line : m_lines)
{
height += line.metrics.height * line.lineHeightMultiplier;
}
// Vertical centered for the whole text with ~1/4 logical inch offset. In DIP.
float top = ((m_virtualDisplaySizeInchY / 2.0f) * 96.0f) - (height / 2.0f) - 48;
for (auto& line : m_lines) for (auto& line : m_lines)
{ {
if (line.alignBottom) if (line.alignBottom)
{ {
top = TEXTURE_HEIGHT - line.metrics.height; top = m_textTextureHeight - line.metrics.height;
} }
m_d2dTextRenderTarget->DrawTextLayout(D2D1::Point2F(0, top), line.layout.get(), m_brushes[line.color].get()); m_d2dTextRenderTarget->DrawTextLayout(D2D1::Point2F(0, top), line.layout.get(), m_brushes[line.color].get());
top += line.metrics.height * line.lineHeightMultiplier; top += line.metrics.height * line.lineHeightMultiplier;
} }
}
}
// Ignore D2DERR_RECREATE_TARGET here. This error indicates that the device // Ignore D2DERR_RECREATE_TARGET here. This error indicates that the device
// is lost. It will be handled during the next call to Present. // is lost. It will be handled during the next call to Present.
@ -86,25 +95,23 @@ void StatusDisplay::Render()
{ {
winrt::check_hresult(hr); winrt::check_hresult(hr);
} }
}
}
// Now render the quads into 3d space // Now render the quads into 3d space
m_deviceResources->UseD3DDeviceContext([&](auto context) { m_deviceResources->UseD3DDeviceContext([&](auto context) {
DXHelper::D3D11StoreAndRestoreState(context, [&]() {
// Each vertex is one instance of the VertexBufferElement struct. // Each vertex is one instance of the VertexBufferElement struct.
const UINT stride = sizeof(VertexBufferElement); const UINT stride = sizeof(VertexBufferElement);
const UINT offset = 0; const UINT offset = 0;
ID3D11Buffer* pBufferToSet = m_vertexBufferImage.get(); ID3D11Buffer* pBufferToSet = m_vertexBufferImage.get();
context->IASetVertexBuffers(0, 1, &pBufferToSet, &stride, &offset); context->IASetVertexBuffers(0, 1, &pBufferToSet, &stride, &offset);
context->IASetIndexBuffer( context->IASetIndexBuffer(m_indexBuffer.get(), DXGI_FORMAT_R16_UINT, 0);
m_indexBuffer.get(),
DXGI_FORMAT_R16_UINT, // Each index is one 16-bit unsigned integer (short).
0);
context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST); context->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
context->IASetInputLayout(m_inputLayout.get()); context->IASetInputLayout(m_inputLayout.get());
context->OMSetBlendState(m_textAlphaBlendState.get(), nullptr, 0xffffffff); context->OMSetBlendState(m_textAlphaBlendState.get(), nullptr, 0xffffffff);
context->OMSetDepthStencilState(m_depthStencilState.get(), 0);
// Attach the vertex shader.
context->VSSetShader(m_vertexShader.get(), nullptr, 0);
context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &m_modelConstantBufferDataImage, 0, 0); context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &m_modelConstantBufferDataImage, 0, 0);
@ -112,6 +119,9 @@ void StatusDisplay::Render()
pBufferToSet = m_modelConstantBuffer.get(); pBufferToSet = m_modelConstantBuffer.get();
context->VSSetConstantBuffers(0, 1, &pBufferToSet); context->VSSetConstantBuffers(0, 1, &pBufferToSet);
// Attach the vertex shader.
context->VSSetShader(m_vertexShader.get(), nullptr, 0);
// On devices that do not support the D3D11_FEATURE_D3D11_OPTIONS3:: // On devices that do not support the D3D11_FEATURE_D3D11_OPTIONS3::
// VPAndRTArrayIndexFromAnyShaderFeedingRasterizer optional feature, // VPAndRTArrayIndexFromAnyShaderFeedingRasterizer optional feature,
// a pass-through geometry shader sets the render target ID. // a pass-through geometry shader sets the render target ID.
@ -138,6 +148,10 @@ void StatusDisplay::Render()
); );
} }
// Draw the text.
{
if (linesChanged == true)
{
// Set up for rendering the texture that contains the text // Set up for rendering the texture that contains the text
pBufferToSet = m_vertexBufferText.get(); pBufferToSet = m_vertexBufferText.get();
context->IASetVertexBuffers(0, 1, &pBufferToSet, &stride, &offset); context->IASetVertexBuffers(0, 1, &pBufferToSet, &stride, &offset);
@ -150,7 +164,6 @@ void StatusDisplay::Render()
context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &m_modelConstantBufferDataText, 0, 0); context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &m_modelConstantBufferDataText, 0, 0);
// Draw the text.
context->DrawIndexedInstanced( context->DrawIndexedInstanced(
m_indexCount, // Index count per instance. m_indexCount, // Index count per instance.
2, // Instance count. 2, // Instance count.
@ -158,31 +171,27 @@ void StatusDisplay::Render()
0, // Base vertex location. 0, // Base vertex location.
0 // Start instance location. 0 // Start instance location.
); );
}
// Reset the blend state. }
context->OMSetBlendState(nullptr, nullptr, 0xffffffff); });
// Detach our texture.
ID3D11ShaderResourceView* emptyResource = nullptr;
context->PSSetShaderResources(0, 1, &emptyResource);
}); });
} }
void StatusDisplay::CreateDeviceDependentResources() void StatusDisplay::CreateDeviceDependentResources()
{ {
CD3D11_SAMPLER_DESC desc(D3D11_DEFAULT); auto device = m_deviceResources->GetD3DDevice();
CD3D11_TEXTURE2D_DESC textureDesc( CD3D11_TEXTURE2D_DESC textureDesc(
DXGI_FORMAT_B8G8R8A8_UNORM, TEXTURE_WIDTH, TEXTURE_HEIGHT, 1, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET); DXGI_FORMAT_B8G8R8A8_UNORM, m_textTextureWidth, m_textTextureHeight, 1, 1, D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
m_textTexture = nullptr; m_textTexture = nullptr;
m_deviceResources->GetD3DDevice()->CreateTexture2D(&textureDesc, nullptr, m_textTexture.put()); device->CreateTexture2D(&textureDesc, nullptr, m_textTexture.put());
m_textShaderResourceView = nullptr; m_textShaderResourceView = nullptr;
m_deviceResources->GetD3DDevice()->CreateShaderResourceView(m_textTexture.get(), nullptr, m_textShaderResourceView.put()); device->CreateShaderResourceView(m_textTexture.get(), nullptr, m_textShaderResourceView.put());
m_textRenderTarget = nullptr; m_textRenderTarget = nullptr;
m_deviceResources->GetD3DDevice()->CreateRenderTargetView(m_textTexture.get(), nullptr, m_textRenderTarget.put()); device->CreateRenderTargetView(m_textTexture.get(), nullptr, m_textRenderTarget.put());
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties( D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED), 96, 96); D2D1_RENDER_TARGET_TYPE_DEFAULT, D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED), 96, 96);
@ -190,7 +199,6 @@ void StatusDisplay::CreateDeviceDependentResources()
winrt::com_ptr<IDXGISurface> dxgiSurface; winrt::com_ptr<IDXGISurface> dxgiSurface;
m_textTexture.as(dxgiSurface); m_textTexture.as(dxgiSurface);
m_d2dTextRenderTarget = nullptr; m_d2dTextRenderTarget = nullptr;
winrt::check_hresult( winrt::check_hresult(
m_deviceResources->GetD2DFactory()->CreateDxgiSurfaceRenderTarget(dxgiSurface.get(), &props, m_d2dTextRenderTarget.put())); m_deviceResources->GetD2DFactory()->CreateDxgiSurfaceRenderTarget(dxgiSurface.get(), &props, m_d2dTextRenderTarget.put()));
@ -206,78 +214,38 @@ void StatusDisplay::CreateDeviceDependentResources()
const auto vertexShaderDataSize = m_usingVprtShaders ? sizeof(VPRTVertexShader) : sizeof(VertexShader); const auto vertexShaderDataSize = m_usingVprtShaders ? sizeof(VPRTVertexShader) : sizeof(VertexShader);
// create the vertex shader and input layout. // create the vertex shader and input layout.
task<void> createVSTask = task<void>([this, vertexShaderData, vertexShaderDataSize]() { task<void> createVSTask = task<void>([this, device, vertexShaderData, vertexShaderDataSize]() {
winrt::check_hresult( winrt::check_hresult(device->CreateVertexShader(vertexShaderData, vertexShaderDataSize, nullptr, m_vertexShader.put()));
m_deviceResources->GetD3DDevice()->CreateVertexShader(vertexShaderData, vertexShaderDataSize, nullptr, m_vertexShader.put()));
static const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = { static const D3D11_INPUT_ELEMENT_DESC vertexDesc[] = {
{"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0},
{"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0}, {"TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 12, D3D11_INPUT_PER_VERTEX_DATA, 0},
}; };
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateInputLayout( winrt::check_hresult(
vertexDesc, ARRAYSIZE(vertexDesc), vertexShaderData, vertexShaderDataSize, m_inputLayout.put())); device->CreateInputLayout(vertexDesc, ARRAYSIZE(vertexDesc), vertexShaderData, vertexShaderDataSize, m_inputLayout.put()));
}); });
// create the pixel shader and constant buffer. // create the pixel shader and constant buffer.
task<void> createPSTask([this]() { task<void> createPSTask([this, device]() {
winrt::check_hresult( winrt::check_hresult(device->CreatePixelShader(PixelShader, sizeof(PixelShader), nullptr, m_pixelShader.put()));
m_deviceResources->GetD3DDevice()->CreatePixelShader(PixelShader, sizeof(PixelShader), nullptr, m_pixelShader.put()));
const CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelConstantBuffer), D3D11_BIND_CONSTANT_BUFFER); const CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ModelConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateBuffer(&constantBufferDesc, nullptr, m_modelConstantBuffer.put())); winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_modelConstantBuffer.put()));
}); });
task<void> createGSTask; task<void> createGSTask;
if (!m_usingVprtShaders) if (!m_usingVprtShaders)
{ {
// create the geometry shader. // create the geometry shader.
createGSTask = task<void>([this]() { createGSTask = task<void>([this, device]() {
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateGeometryShader( winrt::check_hresult(device->CreateGeometryShader(GeometryShader, sizeof(GeometryShader), nullptr, m_geometryShader.put()));
GeometryShader, sizeof(GeometryShader), nullptr, m_geometryShader.put()));
}); });
} }
// Once all shaders are loaded, create the mesh. // Once all shaders are loaded, create the mesh.
task<void> shaderTaskGroup = m_usingVprtShaders ? (createPSTask && createVSTask) : (createPSTask && createVSTask && createGSTask); task<void> shaderTaskGroup = m_usingVprtShaders ? (createPSTask && createVSTask) : (createPSTask && createVSTask && createGSTask);
task<void> createQuadTask = shaderTaskGroup.then([this]() { task<void> createQuadTask = shaderTaskGroup.then([this, device]() {
// Load mesh vertices. Each vertex has a position and a color.
// Note that the quad size has changed from the default DirectX app
// template. Windows Holographic is scaled in meters, so to draw the
// quad at a comfortable size we made the quad width 0.2 m (20 cm).
static const float imageQuadExtent = 0.23f;
static const VertexBufferElement quadVertices[] = {
{XMFLOAT3(-imageQuadExtent, imageQuadExtent, 0.f), XMFLOAT2(0.f, 0.f)},
{XMFLOAT3(imageQuadExtent, imageQuadExtent, 0.f), XMFLOAT2(1.f, 0.f)},
{XMFLOAT3(imageQuadExtent, -imageQuadExtent, 0.f), XMFLOAT2(1.f, 1.f)},
{XMFLOAT3(-imageQuadExtent, -imageQuadExtent, 0.f), XMFLOAT2(0.f, 1.f)},
};
D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
vertexBufferData.pSysMem = quadVertices;
vertexBufferData.SysMemPitch = 0;
vertexBufferData.SysMemSlicePitch = 0;
const CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(quadVertices), D3D11_BIND_VERTEX_BUFFER);
winrt::check_hresult(
m_deviceResources->GetD3DDevice()->CreateBuffer(&vertexBufferDesc, &vertexBufferData, m_vertexBufferImage.put()));
static const float textQuadExtent = 0.3f;
static const VertexBufferElement quadVerticesText[] = {
{XMFLOAT3(-textQuadExtent, textQuadExtent, 0.f), XMFLOAT2(0.f, 0.f)},
{XMFLOAT3(textQuadExtent, textQuadExtent, 0.f), XMFLOAT2(1.f, 0.f)},
{XMFLOAT3(textQuadExtent, -textQuadExtent, 0.f), XMFLOAT2(1.f, 1.f)},
{XMFLOAT3(-textQuadExtent, -textQuadExtent, 0.f), XMFLOAT2(0.f, 1.f)},
};
D3D11_SUBRESOURCE_DATA vertexBufferDataText = {0};
vertexBufferDataText.pSysMem = quadVerticesText;
vertexBufferDataText.SysMemPitch = 0;
vertexBufferDataText.SysMemSlicePitch = 0;
const CD3D11_BUFFER_DESC vertexBufferDescText(sizeof(quadVerticesText), D3D11_BIND_VERTEX_BUFFER);
winrt::check_hresult(
m_deviceResources->GetD3DDevice()->CreateBuffer(&vertexBufferDescText, &vertexBufferDataText, m_vertexBufferText.put()));
// Load mesh indices. Each trio of indices represents // Load mesh indices. Each trio of indices represents
// a triangle to be rendered on the screen. // a triangle to be rendered on the screen.
// For example: 2,1,0 means that the vertices with indexes // For example: 2,1,0 means that the vertices with indexes
@ -300,34 +268,32 @@ void StatusDisplay::CreateDeviceDependentResources()
indexBufferData.SysMemPitch = 0; indexBufferData.SysMemPitch = 0;
indexBufferData.SysMemSlicePitch = 0; indexBufferData.SysMemSlicePitch = 0;
const CD3D11_BUFFER_DESC indexBufferDesc(sizeof(quadIndices), D3D11_BIND_INDEX_BUFFER); const CD3D11_BUFFER_DESC indexBufferDesc(sizeof(quadIndices), D3D11_BIND_INDEX_BUFFER);
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateBuffer(&indexBufferDesc, &indexBufferData, m_indexBuffer.put())); winrt::check_hresult(device->CreateBuffer(&indexBufferDesc, &indexBufferData, m_indexBuffer.put()));
}); });
// Create image sampler state // Create image sampler state
{ {
D3D11_SAMPLER_DESC desc = {}; D3D11_SAMPLER_DESC samplerDesc = {};
samplerDesc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR;
desc.Filter = D3D11_FILTER_MIN_MAG_MIP_LINEAR; samplerDesc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.AddressU = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.AddressV = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP;
desc.AddressW = D3D11_TEXTURE_ADDRESS_CLAMP; samplerDesc.MaxAnisotropy = 1;
desc.MaxAnisotropy = 1; samplerDesc.MinLOD = 0;
desc.MinLOD = 0; samplerDesc.MaxLOD = 3;
desc.MaxLOD = 3; samplerDesc.MipLODBias = 0.f;
desc.MipLODBias = 0.f; samplerDesc.BorderColor[0] = 0.f;
desc.BorderColor[0] = 0.f; samplerDesc.BorderColor[1] = 0.f;
desc.BorderColor[1] = 0.f; samplerDesc.BorderColor[2] = 0.f;
desc.BorderColor[2] = 0.f; samplerDesc.BorderColor[3] = 0.f;
desc.BorderColor[3] = 0.f; samplerDesc.ComparisonFunc = D3D11_COMPARISON_NEVER;
desc.ComparisonFunc = D3D11_COMPARISON_NEVER; winrt::check_hresult(device->CreateSamplerState(&samplerDesc, m_imageSamplerState.put()));
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateSamplerState(&desc, m_imageSamplerState.put()));
} }
// Create text sampler state // Create text sampler state
{ {
CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT); CD3D11_SAMPLER_DESC samplerDesc(D3D11_DEFAULT);
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateSamplerState(&samplerDesc, m_textSamplerState.put())); winrt::check_hresult(device->CreateSamplerState(&samplerDesc, m_textSamplerState.put()));
} }
// Create the blend state. This sets up a blend state for pre-multiplied alpha produced by TextRenderer.cpp's Direct2D text // Create the blend state. This sets up a blend state for pre-multiplied alpha produced by TextRenderer.cpp's Direct2D text
@ -352,7 +318,10 @@ void StatusDisplay::CreateDeviceDependentResources()
blendStateDesc.RenderTarget[i] = rtBlendDesc; blendStateDesc.RenderTarget[i] = rtBlendDesc;
} }
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateBlendState(&blendStateDesc, m_textAlphaBlendState.put())); winrt::check_hresult(device->CreateBlendState(&blendStateDesc, m_textAlphaBlendState.put()));
D3D11_DEPTH_STENCIL_DESC depthStencilDesc = {};
device->CreateDepthStencilState(&depthStencilDesc, m_depthStencilState.put());
// Once the quad is loaded, the object is ready to be rendered. // Once the quad is loaded, the object is ready to be rendered.
auto loadCompleteCallback = createQuadTask.then([this]() { m_loadingComplete = true; }); auto loadCompleteCallback = createQuadTask.then([this]() { m_loadingComplete = true; });
@ -412,7 +381,10 @@ void StatusDisplay::SetLines(winrt::array_view<Line> lines)
void StatusDisplay::UpdateLineText(size_t index, std::wstring text) void StatusDisplay::UpdateLineText(size_t index, std::wstring text)
{ {
std::scoped_lock lock(m_lineMutex); std::scoped_lock lock(m_lineMutex);
assert(index < m_lines.size() && "Line index out of bounds"); if (index >= m_lines.size())
{
return;
}
auto& runtimeLine = m_lines[index]; auto& runtimeLine = m_lines[index];
@ -423,7 +395,7 @@ void StatusDisplay::UpdateLineText(size_t index, std::wstring text)
size_t StatusDisplay::AddLine(const Line& line) size_t StatusDisplay::AddLine(const Line& line)
{ {
std::scoped_lock lock(m_lineMutex); std::scoped_lock lock(m_lineMutex);
auto newIndex = m_lines.size(); size_t newIndex = m_lines.size();
m_lines.resize(newIndex + 1); m_lines.resize(newIndex + 1);
UpdateLineInternal(m_lines[newIndex], line); UpdateLineInternal(m_lines[newIndex], line);
return newIndex; return newIndex;
@ -437,6 +409,11 @@ bool StatusDisplay::HasLine(size_t index)
void StatusDisplay::CreateFonts() void StatusDisplay::CreateFonts()
{ {
// DIP font size, based on the horizontal size of the virtual display.
float fontSizeLargeDIP = (m_virtualDisplaySizeInchX * FontSizeLarge) * 96;
float fontSizeMediumDIP = (m_virtualDisplaySizeInchX * FontSizeMedium) * 96;
float fontSizeSmallDIP = (m_virtualDisplaySizeInchX * FontSizeSmall) * 96;
// Create Large font // Create Large font
m_textFormats[Large] = nullptr; m_textFormats[Large] = nullptr;
winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextFormat( winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextFormat(
@ -445,7 +422,7 @@ void StatusDisplay::CreateFonts()
DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_WEIGHT_NORMAL,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
FontSizeLarge, fontSizeLargeDIP,
FontLanguage, FontLanguage,
m_textFormats[Large].put())); m_textFormats[Large].put()));
winrt::check_hresult(m_textFormats[Large]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)); winrt::check_hresult(m_textFormats[Large]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR));
@ -459,7 +436,7 @@ void StatusDisplay::CreateFonts()
DWRITE_FONT_WEIGHT_BOLD, DWRITE_FONT_WEIGHT_BOLD,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
FontSizeLarge, fontSizeLargeDIP,
FontLanguage, FontLanguage,
m_textFormats[LargeBold].put())); m_textFormats[LargeBold].put()));
winrt::check_hresult(m_textFormats[LargeBold]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)); winrt::check_hresult(m_textFormats[LargeBold]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR));
@ -473,13 +450,27 @@ void StatusDisplay::CreateFonts()
DWRITE_FONT_WEIGHT_MEDIUM, DWRITE_FONT_WEIGHT_MEDIUM,
DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL, DWRITE_FONT_STRETCH_NORMAL,
FontSizeSmall, fontSizeSmallDIP,
FontLanguage, FontLanguage,
m_textFormats[Small].put())); m_textFormats[Small].put()));
winrt::check_hresult(m_textFormats[Small]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR)); winrt::check_hresult(m_textFormats[Small]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR));
winrt::check_hresult(m_textFormats[Small]->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER)); winrt::check_hresult(m_textFormats[Small]->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER));
static_assert(TextFormatCount == 3, "Expected 3 text formats"); // Create medium font
m_textFormats[Medium] = nullptr;
winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextFormat(
Font,
nullptr,
DWRITE_FONT_WEIGHT_MEDIUM,
DWRITE_FONT_STYLE_NORMAL,
DWRITE_FONT_STRETCH_NORMAL,
fontSizeMediumDIP,
FontLanguage,
m_textFormats[Medium].put()));
winrt::check_hresult(m_textFormats[Medium]->SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR));
winrt::check_hresult(m_textFormats[Medium]->SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER));
static_assert(TextFormatCount == 4, "Expected 4 text formats");
} }
void StatusDisplay::CreateBrushes() void StatusDisplay::CreateBrushes()
@ -504,13 +495,19 @@ void StatusDisplay::UpdateLineInternal(RuntimeLine& runtimeLine, const Line& lin
runtimeLine.format = line.format; runtimeLine.format = line.format;
runtimeLine.text = line.text; runtimeLine.text = line.text;
const float virtualDisplayDPIx = m_textTextureWidth / m_virtualDisplaySizeInchX;
const float virtualDisplayDPIy = m_textTextureHeight / m_virtualDisplaySizeInchY;
const float dpiScaleX = virtualDisplayDPIx / 96.0f;
const float dpiScaleY = virtualDisplayDPIy / 96.0f;
runtimeLine.layout = nullptr; runtimeLine.layout = nullptr;
winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextLayout( winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextLayout(
line.text.c_str(), line.text.c_str(),
static_cast<UINT32>(line.text.length()), static_cast<UINT32>(line.text.length()),
m_textFormats[line.format].get(), m_textFormats[line.format].get(),
TEXTURE_WIDTH, // Max width of the input text. static_cast<float>(m_textTextureWidth / dpiScaleX), // Max width of the input text.
TEXTURE_HEIGHT, // Max height of the input text. static_cast<float>(m_textTextureHeight / dpiScaleY), // Max height of the input text.
runtimeLine.layout.put())); runtimeLine.layout.put()));
winrt::check_hresult(runtimeLine.layout->GetMetrics(&runtimeLine.metrics)); winrt::check_hresult(runtimeLine.layout->GetMetrics(&runtimeLine.metrics));
@ -536,11 +533,11 @@ void StatusDisplay::PositionDisplay(float deltaTimeInSeconds, const SpatialPoint
const float3 headPosition = pointerPose.Head().Position(); const float3 headPosition = pointerPose.Head().Position();
const float3 headDirection = pointerPose.Head().ForwardDirection(); const float3 headDirection = pointerPose.Head().ForwardDirection();
const float3 offsetImage = float3(0.0f, -0.02f, 0.0f); const float3 offsetImage = float3(0.0f, m_virtualDisplaySizeInchY * 0.002f, 0.0f);
const float3 gazeAtTwoMetersImage = headPosition + (2.05f * (headDirection + offsetImage)); const float3 gazeAtTwoMetersImage = headPosition + ((m_statusDisplayDistance + 0.05f) * (headDirection + offsetImage));
const float3 offsetText = float3(0.0f, -0.035f, 0.0f); const float3 offsetText = float3(0.0f, 0.0f, 0.0f);
const float3 gazeAtTwoMetersText = headPosition + (2.0f * (headDirection + offsetText)); const float3 gazeAtTwoMetersText = headPosition + (m_statusDisplayDistance * (headDirection + offsetText));
// Lerp the position, to keep the hologram comfortably stable. // Lerp the position, to keep the hologram comfortably stable.
auto imagePosition = lerp(m_positionImage, gazeAtTwoMetersImage, deltaTimeInSeconds * c_lerpRate); auto imagePosition = lerp(m_positionImage, gazeAtTwoMetersImage, deltaTimeInSeconds * c_lerpRate);
@ -597,3 +594,159 @@ void StatusDisplay::UpdateConstantBuffer(
auto& deltaX = position - lastPosition; // meters auto& deltaX = position - lastPosition; // meters
m_velocity = deltaX / deltaTimeInSeconds; // meters per second m_velocity = deltaX / deltaTimeInSeconds; // meters per second
} }
void StatusDisplay::UpdateTextScale(
winrt::Windows::Graphics::Holographic::HolographicStereoTransform holoTransform,
float screenWidth,
float screenHeight,
float quadFov,
float heightRatio)
{
DirectX::XMMATRIX projMat = XMLoadFloat4x4(&holoTransform.Left);
DirectX::XMFLOAT4X4 proj;
DirectX::XMStoreFloat4x4(&proj, projMat);
// Check if the projection matrix has changed.
bool projHasChanged = false;
for (int x = 0; x < 4; ++x)
{
for (int y = 0; y < 4; ++y)
{
if (proj.m[x][y] != m_projection.m[x][y])
{
projHasChanged = true;
break;
}
}
if (projHasChanged)
{
break;
}
}
const float fovDiff = m_currentQuadFov - quadFov;
const float fovEpsilon = 0.1f;
const bool quadFovHasChanged = std::abs(fovDiff) > fovEpsilon;
m_currentQuadFov = quadFov;
const float heightRatioDiff = m_currentHeightRatio - heightRatio;
const float heightRatioEpsilon = 0.1f;
const bool quadRatioHasChanged = std::abs(heightRatioDiff) > heightRatioEpsilon;
m_currentHeightRatio = heightRatio;
// Only update the StatusDisplay resolution and size if something has changed.
if (projHasChanged || quadFovHasChanged || quadRatioHasChanged)
{
// Quad extent based on FOV.
const float quadExtentX = tan((m_currentQuadFov / 2.0f) * Degree2Rad) * m_statusDisplayDistance;
const float quadExtentY = m_currentHeightRatio * quadExtentX;
// Calculate the virtual display size in inch.
m_virtualDisplaySizeInchX = (quadExtentX * 2.0f) * Meter2Inch;
m_virtualDisplaySizeInchY = (quadExtentY * 2.0f) * Meter2Inch;
// Pixel perfect resolution.
const float resX = screenWidth * quadExtentX / m_statusDisplayDistance * proj._11;
const float resY = screenHeight * quadExtentY / m_statusDisplayDistance * proj._22;
// sample with double resolution for multi sampling.
m_textTextureWidth = static_cast<int>(resX * 2.0f);
m_textTextureHeight = static_cast<int>(resY * 2.0f);
m_projection = proj;
// Create the new texture.
auto device = m_deviceResources->GetD3DDevice();
// Load mesh vertices. Each vertex has a position and a color.
// Note that the quad size has changed from the default DirectX app
// template. The quad size is based on the target FOV.
const VertexBufferElement quadVerticesText[] = {
{XMFLOAT3(-quadExtentX, quadExtentY, 0.f), XMFLOAT2(0.f, 0.f)},
{XMFLOAT3(quadExtentX, quadExtentY, 0.f), XMFLOAT2(1.f, 0.f)},
{XMFLOAT3(quadExtentX, -quadExtentY, 0.f), XMFLOAT2(1.f, 1.f)},
{XMFLOAT3(-quadExtentX, -quadExtentY, 0.f), XMFLOAT2(0.f, 1.f)},
};
D3D11_SUBRESOURCE_DATA vertexBufferDataText = {0};
vertexBufferDataText.pSysMem = quadVerticesText;
vertexBufferDataText.SysMemPitch = 0;
vertexBufferDataText.SysMemSlicePitch = 0;
const CD3D11_BUFFER_DESC vertexBufferDescText(sizeof(quadVerticesText), D3D11_BIND_VERTEX_BUFFER);
m_vertexBufferText = nullptr;
winrt::check_hresult(device->CreateBuffer(&vertexBufferDescText, &vertexBufferDataText, m_vertexBufferText.put()));
// Create image buffer
// The image contains 50% of the textFOV.
const float imageFOVDegree = 0.4f * (m_currentQuadFov * 0.5f);
const float imageQuadExtent = m_statusDisplayDistance / tan((90.0f - imageFOVDegree) * Degree2Rad);
const VertexBufferElement quadVertices[] = {
{XMFLOAT3(-imageQuadExtent, imageQuadExtent, 0.f), XMFLOAT2(0.f, 0.f)},
{XMFLOAT3(imageQuadExtent, imageQuadExtent, 0.f), XMFLOAT2(1.f, 0.f)},
{XMFLOAT3(imageQuadExtent, -imageQuadExtent, 0.f), XMFLOAT2(1.f, 1.f)},
{XMFLOAT3(-imageQuadExtent, -imageQuadExtent, 0.f), XMFLOAT2(0.f, 1.f)},
};
D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
vertexBufferData.pSysMem = quadVertices;
vertexBufferData.SysMemPitch = 0;
vertexBufferData.SysMemSlicePitch = 0;
const CD3D11_BUFFER_DESC vertexBufferDesc(sizeof(quadVertices), D3D11_BIND_VERTEX_BUFFER);
m_vertexBufferImage = nullptr;
winrt::check_hresult(device->CreateBuffer(&vertexBufferDesc, &vertexBufferData, m_vertexBufferImage.put()));
CD3D11_TEXTURE2D_DESC textureDesc(
DXGI_FORMAT_B8G8R8A8_UNORM,
m_textTextureWidth,
m_textTextureHeight,
1,
1,
D3D11_BIND_SHADER_RESOURCE | D3D11_BIND_RENDER_TARGET);
m_textTexture = nullptr;
device->CreateTexture2D(&textureDesc, nullptr, m_textTexture.put());
m_textShaderResourceView = nullptr;
device->CreateShaderResourceView(m_textTexture.get(), nullptr, m_textShaderResourceView.put());
m_textRenderTarget = nullptr;
device->CreateRenderTargetView(m_textTexture.get(), nullptr, m_textRenderTarget.put());
const float virtualDisplayDPIx = m_textTextureWidth / m_virtualDisplaySizeInchX;
const float virtualDisplayDPIy = m_textTextureHeight / m_virtualDisplaySizeInchY;
D2D1_RENDER_TARGET_PROPERTIES props = D2D1::RenderTargetProperties(
D2D1_RENDER_TARGET_TYPE_DEFAULT,
D2D1::PixelFormat(DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED),
virtualDisplayDPIx,
virtualDisplayDPIy);
winrt::com_ptr<IDXGISurface> dxgiSurface;
m_textTexture.as(dxgiSurface);
m_d2dTextRenderTarget = nullptr;
winrt::check_hresult(
m_deviceResources->GetD2DFactory()->CreateDxgiSurfaceRenderTarget(dxgiSurface.get(), &props, m_d2dTextRenderTarget.put()));
// Update the fonts.
CreateFonts();
// Update the text layout.
for (RuntimeLine& runtimeLine : m_lines)
{
const float dpiScaleX = virtualDisplayDPIx / 96.0f;
const float dpiScaleY = virtualDisplayDPIy / 96.0f;
runtimeLine.layout = nullptr;
winrt::check_hresult(m_deviceResources->GetDWriteFactory()->CreateTextLayout(
runtimeLine.text.c_str(),
static_cast<UINT32>(runtimeLine.text.length()),
m_textFormats[runtimeLine.format].get(),
static_cast<float>(m_textTextureWidth / dpiScaleX), // Max width of the input text.
static_cast<float>(m_textTextureHeight / dpiScaleY), // Max height of the input text.
runtimeLine.layout.put()));
winrt::check_hresult(runtimeLine.layout->GetMetrics(&runtimeLine.metrics));
}
}
}

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

@ -11,7 +11,7 @@
#pragma once #pragma once
#include "..\Common\DeviceResources.h" #include "..\Common\DeviceResourcesCommon.h"
#include "ShaderStructures.h" #include "ShaderStructures.h"
#include <string> #include <string>
@ -27,6 +27,7 @@ public:
Small = 0, Small = 0,
Large, Large,
LargeBold, LargeBold,
Medium,
TextFormatCount TextFormatCount
}; };
@ -52,7 +53,7 @@ public:
}; };
public: public:
StatusDisplay(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources); StatusDisplay(const std::shared_ptr<DXHelper::DeviceResourcesCommon>& deviceResources);
void Update(float deltaTimeInSeconds); void Update(float deltaTimeInSeconds);
@ -102,6 +103,29 @@ public:
return m_positionImage; return m_positionImage;
} }
void UpdateTextScale(
winrt::Windows::Graphics::Holographic::HolographicStereoTransform holoTransform,
float screenWidth,
float screenHeight,
float quadFov,
float heightRatio = 1.0f);
// Get default FOV for the text quad in degree.
float GetDefaultQuadFov()
{
return m_defaultQuadFov;
}
// Get statistics FOV for the text quad in degree.
float GetStatisticsFov()
{
return m_statisticsFov;
}
// Get the statistics height ratio.
float GetStatisticsHeightRatio()
{
return m_statisticsHeightRatio;
}
private: private:
// Runtime representation of a text line. // Runtime representation of a text line.
struct RuntimeLine struct RuntimeLine
@ -124,14 +148,13 @@ private:
winrt::Windows::Foundation::Numerics::float3 position, winrt::Windows::Foundation::Numerics::float3 position,
winrt::Windows::Foundation::Numerics::float3 lastPosition); winrt::Windows::Foundation::Numerics::float3 lastPosition);
winrt::com_ptr<ID2D1SolidColorBrush> m_brushes[TextColorCount] = {}; winrt::com_ptr<ID2D1SolidColorBrush> m_brushes[TextColorCount] = {};
winrt::com_ptr<IDWriteTextFormat> m_textFormats[TextFormatCount] = {}; winrt::com_ptr<IDWriteTextFormat> m_textFormats[TextFormatCount] = {};
std::vector<RuntimeLine> m_lines; std::vector<RuntimeLine> m_lines;
std::mutex m_lineMutex; std::mutex m_lineMutex;
// Cached pointer to device resources. // Cached pointer to device resources.
std::shared_ptr<DXHelper::DeviceResources> m_deviceResources; std::shared_ptr<DXHelper::DeviceResourcesCommon> m_deviceResources;
// Resources related to text rendering. // Resources related to text rendering.
winrt::com_ptr<ID3D11Texture2D> m_textTexture; winrt::com_ptr<ID3D11Texture2D> m_textTexture;
@ -155,6 +178,7 @@ private:
winrt::com_ptr<ID3D11SamplerState> m_textSamplerState; winrt::com_ptr<ID3D11SamplerState> m_textSamplerState;
winrt::com_ptr<ID3D11BlendState> m_textAlphaBlendState; winrt::com_ptr<ID3D11BlendState> m_textAlphaBlendState;
winrt::com_ptr<ID3D11DepthStencilState> m_depthStencilState;
// System resources for quad geometry. // System resources for quad geometry.
ModelConstantBuffer m_modelConstantBufferDataImage = {}; ModelConstantBuffer m_modelConstantBufferDataImage = {};
@ -178,4 +202,28 @@ private:
const float c_lerpRate = 4.0f; const float c_lerpRate = 4.0f;
bool m_imageEnabled = true; bool m_imageEnabled = true;
// The distance to the camera in fwd-direction.
float m_statusDisplayDistance = 1.0f;
// The view Projection matrix.
DirectX::XMFLOAT4X4 m_projection;
// Default size, gets adjusted based on HMD.
int m_textTextureWidth = 128;
int m_textTextureHeight = 128;
// Default size, gets adjusted based on the HMD and FOV.
float m_virtualDisplaySizeInchX = 10.0f;
float m_virtualDisplaySizeInchY = 10.0f;
// The current FOV for the text quad in degree.
float m_currentQuadFov{};
// The current height ratio of the quad.
float m_currentHeightRatio{};
// The default FOV for the text quad in degree.
float m_defaultQuadFov = 25.0f;
// The statistics FOV for the text quad in degree.
float m_statisticsFov = 23.0f;
// The height ratio for the statistics quad in percent.
float m_statisticsHeightRatio = 0.4f;
}; };

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

@ -1,395 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "DeviceResources.h"
using namespace D2D1;
using namespace winrt::Windows::Graphics::DirectX::Direct3D11;
using namespace winrt::Windows::Graphics::Display;
using namespace winrt::Windows::Graphics::Holographic;
namespace DXHelper
{
#if defined(_DEBUG)
// Check for SDK Layer support.
inline bool SdkLayersAvailable()
{
HRESULT hr = D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device.
0,
D3D11_CREATE_DEVICE_DEBUG, // Check for the SDK layers.
nullptr, // Any feature level will do.
0,
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Runtime apps.
nullptr, // No need to keep the D3D device reference.
nullptr, // No need to know the feature level.
nullptr // No need to keep the D3D device context reference.
);
return SUCCEEDED(hr);
}
#endif
// Constructor for DeviceResources.
DeviceResources::DeviceResources()
{
CreateDeviceIndependentResources();
}
DeviceResources::~DeviceResources()
{
UnregisterHolographicEventHandlers();
}
// Configures resources that don't depend on the Direct3D device.
void DeviceResources::CreateDeviceIndependentResources()
{
// Initialize Direct2D resources.
D2D1_FACTORY_OPTIONS options{};
#if defined(_DEBUG)
// If the project is in a debug build, enable Direct2D debugging via SDK Layers.
options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
#endif
// Initialize the Direct2D Factory.
m_d2dFactory = nullptr;
winrt::check_hresult(
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory2), &options, m_d2dFactory.put_void()));
// Initialize the DirectWrite Factory.
m_dwriteFactory = nullptr;
winrt::check_hresult(DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory2), reinterpret_cast<IUnknown**>(m_dwriteFactory.put_void())));
// Initialize the Windows Imaging Component (WIC) Factory.
m_wicFactory = nullptr;
winrt::check_hresult(CoCreateInstance(CLSID_WICImagingFactory2, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(m_wicFactory.put())));
}
void DeviceResources::SetWindow(const winrt::Windows::UI::Core::CoreWindow& window)
{
UnregisterHolographicEventHandlers();
m_holographicSpace = HolographicSpace::CreateForCoreWindow(window);
InitializeUsingHolographicSpace();
m_cameraAddedToken = m_holographicSpace.CameraAdded({this, &DeviceResources::OnCameraAdded});
m_cameraRemovedToken = m_holographicSpace.CameraRemoved({this, &DeviceResources::OnCameraRemoved});
}
void DeviceResources::InitializeUsingHolographicSpace()
{
// The holographic space might need to determine which adapter supports
// holograms, in which case it will specify a non-zero PrimaryAdapterId.
LUID id = {m_holographicSpace.PrimaryAdapterId().LowPart, m_holographicSpace.PrimaryAdapterId().HighPart};
// When a primary adapter ID is given to the app, the app should find
// the corresponding DXGI adapter and use it to create Direct3D devices
// and device contexts. Otherwise, there is no restriction on the DXGI
// adapter the app can use.
if ((id.HighPart != 0) || (id.LowPart != 0))
{
UINT createFlags = 0;
#ifdef DEBUG
if (SdkLayersAvailable())
{
createFlags |= DXGI_CREATE_FACTORY_DEBUG;
}
#endif
// Create the DXGI factory.
winrt::com_ptr<IDXGIFactory1> dxgiFactory;
winrt::check_hresult(CreateDXGIFactory2(createFlags, IID_PPV_ARGS(dxgiFactory.put())));
winrt::com_ptr<IDXGIFactory4> dxgiFactory4;
dxgiFactory.as(dxgiFactory4);
// Retrieve the adapter specified by the holographic space.
m_dxgiAdapter = nullptr;
winrt::check_hresult(dxgiFactory4->EnumAdapterByLuid(id, IID_PPV_ARGS(m_dxgiAdapter.put())));
}
else
{
m_dxgiAdapter = nullptr;
}
CreateDeviceResources();
m_holographicSpace.SetDirect3D11Device(m_d3dInteropDevice);
}
// Configures the Direct3D device, and stores handles to it and the device context.
void DeviceResources::CreateDeviceResources()
{
// This flag adds support for surfaces with a different color channel ordering
// than the API default. It is required for compatibility with Direct2D.
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if defined(_DEBUG)
if (SdkLayersAvailable())
{
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
}
#endif
// This array defines the set of DirectX hardware feature levels this app will support.
// Note the ordering should be preserved.
// Note that HoloLens supports feature level 11.1. The HoloLens emulator is also capable
// of running on graphics cards starting with feature level 10.0.
D3D_FEATURE_LEVEL featureLevels[] = {D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0,
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0};
// Create the Direct3D 11 API device object and a corresponding context.
winrt::com_ptr<ID3D11Device> device;
winrt::com_ptr<ID3D11DeviceContext> context;
const D3D_DRIVER_TYPE driverType = m_dxgiAdapter == nullptr ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_UNKNOWN;
const HRESULT hr = D3D11CreateDevice(
m_dxgiAdapter.get(), // Either nullptr, or the primary adapter determined by Windows Holographic.
driverType, // Create a device using the hardware graphics driver.
0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE.
creationFlags, // Set debug and Direct2D compatibility flags.
featureLevels, // List of feature levels this app can support.
ARRAYSIZE(featureLevels), // Size of the list above.
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Runtime apps.
device.put(), // Returns the Direct3D device created.
&m_d3dFeatureLevel, // Returns feature level of device created.
context.put() // Returns the device immediate context.
);
if (FAILED(hr))
{
// If the initialization fails, fall back to the WARP device.
// For more information on WARP, see:
// http://go.microsoft.com/fwlink/?LinkId=286690
winrt::check_hresult(D3D11CreateDevice(
nullptr, // Use the default DXGI adapter for WARP.
D3D_DRIVER_TYPE_WARP, // Create a WARP device instead of a hardware device.
0,
creationFlags,
featureLevels,
ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION,
device.put(),
&m_d3dFeatureLevel,
context.put()));
}
// Store pointers to the Direct3D device and immediate context.
device.as(m_d3dDevice);
context.as(m_d3dContext);
// Enable multithread protection for video decoding.
winrt::com_ptr<ID3D10Multithread> multithread;
device.as(multithread);
multithread->SetMultithreadProtected(true);
// Acquire the DXGI interface for the Direct3D device.
winrt::com_ptr<IDXGIDevice3> dxgiDevice;
m_d3dDevice.as(dxgiDevice);
// Wrap the native device using a WinRT interop object.
winrt::com_ptr<::IInspectable> object;
winrt::check_hresult(
CreateDirect3D11DeviceFromDXGIDevice(dxgiDevice.get(), reinterpret_cast<IInspectable**>(winrt::put_abi(object))));
m_d3dInteropDevice = object.as<IDirect3DDevice>();
// Cache the DXGI adapter.
// This is for the case of no preferred DXGI adapter, or fallback to WARP.
winrt::com_ptr<IDXGIAdapter> dxgiAdapter;
winrt::check_hresult(dxgiDevice->GetAdapter(dxgiAdapter.put()));
dxgiAdapter.as(m_dxgiAdapter);
// Check for device support for the optional feature that allows setting the render target array index from the vertex shader stage.
D3D11_FEATURE_DATA_D3D11_OPTIONS3 options;
m_d3dDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS3, &options, sizeof(options));
if (options.VPAndRTArrayIndexFromAnyShaderFeedingRasterizer)
{
m_supportsVprt = true;
}
}
void DeviceResources::OnCameraAdded(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraAddedEventArgs const& args)
{
UseHolographicCameraResources(
[this, camera = args.Camera()](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
cameraResourceMap[camera.Id()] = std::make_unique<CameraResources>(camera);
});
}
void DeviceResources::OnCameraRemoved(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraRemovedEventArgs const& args)
{
UseHolographicCameraResources(
[this, camera = args.Camera()](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
CameraResources* pCameraResources = cameraResourceMap[camera.Id()].get();
if (pCameraResources != nullptr)
{
pCameraResources->ReleaseResourcesForBackBuffer(this);
cameraResourceMap.erase(camera.Id());
}
});
}
void DeviceResources::UnregisterHolographicEventHandlers()
{
if (m_holographicSpace != nullptr)
{
// Clear previous event registrations.
m_holographicSpace.CameraAdded(m_cameraAddedToken);
m_cameraAddedToken = {};
m_holographicSpace.CameraRemoved(m_cameraRemovedToken);
m_cameraRemovedToken = {};
}
}
// Validates the back buffer for each HolographicCamera and recreates
// resources for back buffers that have changed.
// Locks the set of holographic camera resources until the function exits.
void DeviceResources::EnsureCameraResources(HolographicFrame frame, HolographicFramePrediction prediction)
{
UseHolographicCameraResources([this, frame, prediction](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
for (HolographicCameraPose const& cameraPose : prediction.CameraPoses())
{
HolographicCameraRenderingParameters renderingParameters = frame.GetRenderingParameters(cameraPose);
CameraResources* pCameraResources = cameraResourceMap[cameraPose.HolographicCamera().Id()].get();
pCameraResources->CreateResourcesForBackBuffer(this, renderingParameters);
}
});
}
// Recreate all device resources and set them back to the current state.
// Locks the set of holographic camera resources until the function exits.
void DeviceResources::HandleDeviceLost()
{
if (m_deviceNotify != nullptr)
{
m_deviceNotify->OnDeviceLost();
}
UseHolographicCameraResources([this](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
for (auto& pair : cameraResourceMap)
{
CameraResources* pCameraResources = pair.second.get();
pCameraResources->ReleaseResourcesForBackBuffer(this);
}
});
InitializeUsingHolographicSpace();
if (m_deviceNotify != nullptr)
{
m_deviceNotify->OnDeviceRestored();
}
}
// Register our DeviceNotify to be informed on device lost and creation.
void DeviceResources::RegisterDeviceNotify(IDeviceNotify* deviceNotify)
{
m_deviceNotify = deviceNotify;
}
// Call this method when the app suspends. It provides a hint to the driver that the app
// is entering an idle state and that temporary buffers can be reclaimed for use by other apps.
void DeviceResources::Trim()
{
if (m_d3dContext)
{
m_d3dContext->ClearState();
}
if (m_d3dDevice)
{
winrt::com_ptr<IDXGIDevice3> dxgiDevice;
m_d3dDevice.as(dxgiDevice);
dxgiDevice->Trim();
}
}
// Present the contents of the swap chain to the screen.
// Locks the set of holographic camera resources until the function exits.
void DeviceResources::Present(HolographicFrame frame)
{
HolographicFramePresentResult presentResult =
frame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior::DoNotWaitForFrameToFinish);
// Note, by not waiting on PresentUsingCurrentPrediction and instead using WaitForNextFrameReadyWithHeadStart we avoid going into
// pipelined mode.
try
{
// WaitForNextFrameReadyWithHeadStart has been added in 10.0.17763.0.
if (!m_useLegacyWaitBehavior)
{
m_holographicSpace.WaitForNextFrameReadyWithHeadStart(winrt::Windows::Foundation::TimeSpan(0));
}
else
{
frame.WaitForFrameToFinish();
}
}
catch (winrt::hresult_error& err)
{
switch (err.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
presentResult = HolographicFramePresentResult::DeviceRemoved;
break;
default:
try
{
m_useLegacyWaitBehavior = true;
frame.WaitForFrameToFinish();
}
catch (winrt::hresult_error& err2)
{
switch (err2.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
presentResult = HolographicFramePresentResult::DeviceRemoved;
break;
default:
throw err2;
}
}
break;
}
// The PresentUsingCurrentPrediction API will detect when the graphics device
// changes or becomes invalid. When this happens, it is considered a Direct3D
// device lost scenario.
if (presentResult == HolographicFramePresentResult::DeviceRemoved)
{
// The Direct3D device, context, and resources should be recreated.
HandleDeviceLost();
}
}
}
} // namespace DXHelper

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

@ -1,182 +0,0 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include "CameraResources.h"
#include <winrt/Windows.Graphics.Holographic.h>
namespace DXHelper
{
// Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created.
interface IDeviceNotify
{
virtual void OnDeviceLost() = 0;
virtual void OnDeviceRestored() = 0;
};
// Creates and manages a Direct3D device and immediate context, Direct2D device and context (for debug), and the holographic swap chain.
class DeviceResources
{
public:
DeviceResources();
~DeviceResources();
// Public methods related to Direct3D devices.
void HandleDeviceLost();
void RegisterDeviceNotify(IDeviceNotify* deviceNotify);
void Trim();
void Present(winrt::Windows::Graphics::Holographic::HolographicFrame frame);
void SetWindow(const winrt::Windows::UI::Core::CoreWindow& window);
void EnsureCameraResources(
winrt::Windows::Graphics::Holographic::HolographicFrame frame,
winrt::Windows::Graphics::Holographic::HolographicFramePrediction prediction);
// Holographic accessors.
template <typename LCallback>
void UseHolographicCameraResources(LCallback const& callback);
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice GetD3DInteropDevice() const
{
return m_d3dInteropDevice;
}
// D3D accessors.
ID3D11Device4* GetD3DDevice() const
{
return m_d3dDevice.get();
}
template <typename F>
auto UseD3DDeviceContext(F func) const
{
std::scoped_lock lock(m_d3dContextMutex);
return func(m_d3dContext.get());
}
D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const
{
return m_d3dFeatureLevel;
}
bool GetDeviceSupportsVprt() const
{
return m_supportsVprt;
}
// DXGI acessors.
IDXGIAdapter3* GetDXGIAdapter() const
{
return m_dxgiAdapter.get();
}
// D2D accessors.
ID2D1Factory2* GetD2DFactory() const
{
return m_d2dFactory.get();
}
IDWriteFactory2* GetDWriteFactory() const
{
return m_dwriteFactory.get();
}
IWICImagingFactory2* GetWicImagingFactory() const
{
return m_wicFactory.get();
}
// Holographic accessors.
winrt::Windows::Graphics::Holographic::HolographicSpace GetHolographicSpace()
{
return m_holographicSpace;
}
private:
// Private methods related to the Direct3D device, and resources based on that device.
void CreateDeviceIndependentResources();
void InitializeUsingHolographicSpace();
void CreateDeviceResources();
void OnCameraAdded(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraAddedEventArgs const& args);
void OnCameraRemoved(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraRemovedEventArgs const& args);
void UnregisterHolographicEventHandlers();
// Direct3D objects.
winrt::com_ptr<ID3D11Device4> m_d3dDevice;
mutable std::recursive_mutex m_d3dContextMutex;
winrt::com_ptr<ID3D11DeviceContext3> m_d3dContext;
winrt::com_ptr<IDXGIAdapter3> m_dxgiAdapter;
// Direct3D interop objects.
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice m_d3dInteropDevice;
// Direct2D factories.
winrt::com_ptr<ID2D1Factory2> m_d2dFactory;
winrt::com_ptr<IDWriteFactory2> m_dwriteFactory;
winrt::com_ptr<IWICImagingFactory2> m_wicFactory;
// The holographic space provides a preferred DXGI adapter ID.
winrt::Windows::Graphics::Holographic::HolographicSpace m_holographicSpace = nullptr;
// Properties of the Direct3D device currently in use.
D3D_FEATURE_LEVEL m_d3dFeatureLevel = D3D_FEATURE_LEVEL_10_0;
// The IDeviceNotify can be held directly as it owns the DeviceResources.
IDeviceNotify* m_deviceNotify = nullptr;
// Whether or not the current Direct3D device supports the optional feature
// for setting the render target array index from the vertex shader stage.
bool m_supportsVprt = false;
bool m_useLegacyWaitBehavior = false;
// Back buffer resources, etc. for attached holographic cameras.
std::map<UINT32, std::unique_ptr<CameraResources>> m_cameraResources;
std::mutex m_cameraResourcesLock;
winrt::event_token m_cameraAddedToken;
winrt::event_token m_cameraRemovedToken;
};
} // namespace DXHelper
// Device-based resources for holographic cameras are stored in a std::map. Access this list by providing a
// callback to this function, and the std::map will be guarded from add and remove
// events until the callback returns. The callback is processed immediately and must
// not contain any nested calls to UseHolographicCameraResources.
// The callback takes a parameter of type std::map<UINT32, std::unique_ptr<CameraResources>>&
// through which the list of cameras will be accessed.
template <typename LCallback>
void DXHelper::DeviceResources::UseHolographicCameraResources(LCallback const& callback)
{
try
{
std::lock_guard<std::mutex> guard(m_cameraResourcesLock);
callback(m_cameraResources);
}
catch (const winrt::hresult_error& err)
{
switch (err.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
HandleDeviceLost();
break;
default:
throw err;
}
}
}

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

@ -0,0 +1,210 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "DeviceResourcesCommon.h"
#include <d2d1_2.h>
#include <d3d11_4.h>
#include <dwrite_2.h>
#include <dxgi1_4.h>
#include <wincodec.h>
namespace DXHelper
{
#if defined(_DEBUG)
// Check for SDK Layer support.
inline bool SdkLayersAvailable()
{
HRESULT hr = D3D11CreateDevice(
nullptr,
D3D_DRIVER_TYPE_NULL, // There is no need to create a real hardware device.
0,
D3D11_CREATE_DEVICE_DEBUG, // Check for the SDK layers.
nullptr, // Any feature level will do.
0,
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Runtime apps.
nullptr, // No need to keep the D3D device reference.
nullptr, // No need to know the feature level.
nullptr // No need to keep the D3D device context reference.
);
return SUCCEEDED(hr);
}
#endif
// Constructor for DeviceResources.
DeviceResourcesCommon::DeviceResourcesCommon()
{
CreateDeviceIndependentResources();
}
DeviceResourcesCommon::~DeviceResourcesCommon()
{
}
// Configures resources that don't depend on the Direct3D device.
void DeviceResourcesCommon::CreateDeviceIndependentResources()
{
// Initialize Direct2D resources.
D2D1_FACTORY_OPTIONS options{};
#if defined(_DEBUG)
// If the project is in a debug build, enable Direct2D debugging via SDK Layers.
options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
#endif
// Initialize the Direct2D Factory.
m_d2dFactory = nullptr;
winrt::check_hresult(
D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, __uuidof(ID2D1Factory2), &options, m_d2dFactory.put_void()));
// Initialize the DirectWrite Factory.
m_dwriteFactory = nullptr;
winrt::check_hresult(DWriteCreateFactory(
DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory2), reinterpret_cast<IUnknown**>(m_dwriteFactory.put_void())));
// Initialize the Windows Imaging Component (WIC) Factory.
m_wicFactory = nullptr;
winrt::check_hresult(CoCreateInstance(CLSID_WICImagingFactory2, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(m_wicFactory.put())));
}
// Configures the Direct3D device, and stores handles to it and the device context.
void DeviceResourcesCommon::CreateDeviceResources()
{
// This flag adds support for surfaces with a different color channel ordering
// than the API default. It is required for compatibility with Direct2D.
UINT creationFlags = D3D11_CREATE_DEVICE_BGRA_SUPPORT;
#if defined(_DEBUG)
if (SdkLayersAvailable())
{
// If the project is in a debug build, enable debugging via SDK Layers with this flag.
creationFlags |= D3D11_CREATE_DEVICE_DEBUG;
}
#endif
// This array defines the set of DirectX hardware feature levels this app will support.
// Note the ordering should be preserved.
// Note that HoloLens supports feature level 11.1. The HoloLens emulator is also capable
// of running on graphics cards starting with feature level 10.0.
D3D_FEATURE_LEVEL featureLevels[] = {
D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0,
D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0,
D3D_FEATURE_LEVEL_10_1,
D3D_FEATURE_LEVEL_10_0};
// Create the Direct3D 11 API device object and a corresponding context.
winrt::com_ptr<ID3D11Device> device;
winrt::com_ptr<ID3D11DeviceContext> context;
const D3D_DRIVER_TYPE driverType = m_dxgiAdapter == nullptr ? D3D_DRIVER_TYPE_HARDWARE : D3D_DRIVER_TYPE_UNKNOWN;
const HRESULT hr = D3D11CreateDevice(
m_dxgiAdapter.get(), // Either nullptr, or the primary adapter determined by Windows Holographic.
driverType, // Create a device using the hardware graphics driver.
0, // Should be 0 unless the driver is D3D_DRIVER_TYPE_SOFTWARE.
creationFlags, // Set debug and Direct2D compatibility flags.
featureLevels, // List of feature levels this app can support.
ARRAYSIZE(featureLevels), // Size of the list above.
D3D11_SDK_VERSION, // Always set this to D3D11_SDK_VERSION for Windows Runtime apps.
device.put(), // Returns the Direct3D device created.
&m_d3dFeatureLevel, // Returns feature level of device created.
context.put() // Returns the device immediate context.
);
if (FAILED(hr))
{
// If the initialization fails, fall back to the WARP device.
// For more information on WARP, see:
// http://go.microsoft.com/fwlink/?LinkId=286690
winrt::check_hresult(D3D11CreateDevice(
nullptr, // Use the default DXGI adapter for WARP.
D3D_DRIVER_TYPE_WARP, // Create a WARP device instead of a hardware device.
0,
creationFlags,
featureLevels,
ARRAYSIZE(featureLevels),
D3D11_SDK_VERSION,
device.put(),
&m_d3dFeatureLevel,
context.put()));
}
// Store pointers to the Direct3D device and immediate context.
device.as(m_d3dDevice);
context.as(m_d3dContext);
// Enable multithread protection for video decoding.
winrt::com_ptr<ID3D10Multithread> multithread;
device.as(multithread);
multithread->SetMultithreadProtected(true);
// Acquire the DXGI interface for the Direct3D device.
winrt::com_ptr<IDXGIDevice3> dxgiDevice;
m_d3dDevice.as(dxgiDevice);
// Cache the DXGI adapter.
// This is for the case of no preferred DXGI adapter, or fallback to WARP.
winrt::com_ptr<IDXGIAdapter> dxgiAdapter;
winrt::check_hresult(dxgiDevice->GetAdapter(dxgiAdapter.put()));
dxgiAdapter.as(m_dxgiAdapter);
// Check for device support for the optional feature that allows setting the render target array index from the vertex shader stage.
D3D11_FEATURE_DATA_D3D11_OPTIONS3 options;
m_d3dDevice->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS3, &options, sizeof(options));
if (options.VPAndRTArrayIndexFromAnyShaderFeedingRasterizer)
{
m_supportsVprt = true;
}
}
void DeviceResourcesCommon::NotifyDeviceLost()
{
if (m_deviceNotify != nullptr)
{
m_deviceNotify->OnDeviceLost();
}
}
void DeviceResourcesCommon::NotifyDeviceRestored()
{
if (m_deviceNotify != nullptr)
{
m_deviceNotify->OnDeviceRestored();
}
}
// Register our DeviceNotify to be informed on device lost and creation.
void DeviceResourcesCommon::RegisterDeviceNotify(IDeviceNotify* deviceNotify)
{
m_deviceNotify = deviceNotify;
}
// Call this method when the app suspends. It provides a hint to the driver that the app
// is entering an idle state and that temporary buffers can be reclaimed for use by other apps.
void DeviceResourcesCommon::Trim()
{
if (m_d3dContext)
{
m_d3dContext->ClearState();
}
if (m_d3dDevice)
{
winrt::com_ptr<IDXGIDevice3> dxgiDevice;
m_d3dDevice.as(dxgiDevice);
dxgiDevice->Trim();
}
}
} // namespace DXHelper

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

@ -0,0 +1,169 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
#include <d3d11.h>
#include <winrt/base.h>
#define ARRAY_SIZE(a) (std::extent<decltype(a)>::value)
struct ID3D11Device4;
struct IDXGIAdapter3;
struct ID2D1Factory2;
struct IDWriteFactory2;
struct IWICImagingFactory2;
struct ID3D11DeviceContext3;
namespace DXHelper
{
// Provides an interface for an application that owns DeviceResources to be notified of the device being lost or created.
struct IDeviceNotify
{
virtual void OnDeviceLost() = 0;
virtual void OnDeviceRestored() = 0;
};
// Creates and manages a Direct3D device and immediate context, Direct2D device and context (for debug), and the holographic swap chain.
class DeviceResourcesCommon
{
public:
DeviceResourcesCommon();
virtual ~DeviceResourcesCommon();
// Public methods related to Direct3D devices.
void RegisterDeviceNotify(IDeviceNotify* deviceNotify);
void Trim();
// D3D accessors.
ID3D11Device4* GetD3DDevice() const
{
return m_d3dDevice.get();
}
template <typename F>
auto UseD3DDeviceContext(F func) const
{
std::scoped_lock lock(m_d3dContextMutex);
return func(m_d3dContext.get());
}
D3D_FEATURE_LEVEL GetDeviceFeatureLevel() const
{
return m_d3dFeatureLevel;
}
bool GetDeviceSupportsVprt() const
{
return m_supportsVprt;
}
// DXGI acessors.
IDXGIAdapter3* GetDXGIAdapter() const
{
return m_dxgiAdapter.get();
}
// D2D accessors.
ID2D1Factory2* GetD2DFactory() const
{
return m_d2dFactory.get();
}
IDWriteFactory2* GetDWriteFactory() const
{
return m_dwriteFactory.get();
}
IWICImagingFactory2* GetWicImagingFactory() const
{
return m_wicFactory.get();
}
protected:
// Private methods related to the Direct3D device, and resources based on that device.
void CreateDeviceIndependentResources();
virtual void CreateDeviceResources();
void NotifyDeviceLost();
void NotifyDeviceRestored();
// Direct3D objects.
winrt::com_ptr<ID3D11Device4> m_d3dDevice;
mutable std::recursive_mutex m_d3dContextMutex;
winrt::com_ptr<ID3D11DeviceContext3> m_d3dContext;
winrt::com_ptr<IDXGIAdapter3> m_dxgiAdapter;
// Direct2D factories.
winrt::com_ptr<ID2D1Factory2> m_d2dFactory;
winrt::com_ptr<IDWriteFactory2> m_dwriteFactory;
winrt::com_ptr<IWICImagingFactory2> m_wicFactory;
// Properties of the Direct3D device currently in use.
D3D_FEATURE_LEVEL m_d3dFeatureLevel = D3D_FEATURE_LEVEL_10_0;
// The IDeviceNotify can be held directly as it owns the DeviceResources.
IDeviceNotify* m_deviceNotify = nullptr;
// Whether or not the current Direct3D device supports the optional feature
// for setting the render target array index from the vertex shader stage.
bool m_supportsVprt = false;
};
template <typename F>
void D3D11StoreAndRestoreState(ID3D11DeviceContext* immediateContext, F customRenderingCode)
{
// Query the d3d11 state before rendering
static_assert(
sizeof(winrt::com_ptr<ID3D11ShaderResourceView>) == sizeof(void*),
"Below code reiles on winrt::com_ptr being exactly one pointer in size");
winrt::com_ptr<ID3D11VertexShader> vertexShader;
winrt::com_ptr<ID3D11GeometryShader> geometryShader;
winrt::com_ptr<ID3D11PixelShader> pixelShader;
winrt::com_ptr<ID3D11Buffer> vsConstantBuffers[2], psConstantBuffers[3];
winrt::com_ptr<ID3D11ShaderResourceView> views[4] = {};
winrt::com_ptr<ID3D11SamplerState> psSampler;
winrt::com_ptr<ID3D11RasterizerState> rasterizerState;
winrt::com_ptr<ID3D11DepthStencilState> depthStencilState;
winrt::com_ptr<ID3D11BlendState> blendState;
winrt::com_ptr<ID3D11InputLayout> inputLayout;
FLOAT blendFactor[4] = {};
UINT sampleMask = 0;
D3D11_PRIMITIVE_TOPOLOGY primitiveTopoloy = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
UINT stencilRef = 0;
immediateContext->VSGetShader(vertexShader.put(), nullptr, nullptr);
immediateContext->VSGetConstantBuffers(0, ARRAY_SIZE(vsConstantBuffers), reinterpret_cast<ID3D11Buffer**>(vsConstantBuffers));
immediateContext->GSGetShader(geometryShader.put(), nullptr, nullptr);
immediateContext->PSGetShader(pixelShader.put(), nullptr, nullptr);
immediateContext->PSGetShaderResources(0, ARRAY_SIZE(views), reinterpret_cast<ID3D11ShaderResourceView**>(views));
immediateContext->PSGetConstantBuffers(0, ARRAY_SIZE(psConstantBuffers), reinterpret_cast<ID3D11Buffer**>(psConstantBuffers));
immediateContext->PSGetSamplers(0, 1, psSampler.put());
immediateContext->RSGetState(rasterizerState.put());
immediateContext->OMGetDepthStencilState(depthStencilState.put(), &stencilRef);
immediateContext->OMGetBlendState(blendState.put(), blendFactor, &sampleMask);
immediateContext->IAGetPrimitiveTopology(&primitiveTopoloy);
immediateContext->IAGetInputLayout(inputLayout.put());
customRenderingCode();
// Restore the d3d11 state.
immediateContext->VSSetShader(vertexShader.get(), nullptr, 0);
immediateContext->VSSetConstantBuffers(0, ARRAY_SIZE(vsConstantBuffers), reinterpret_cast<ID3D11Buffer**>(vsConstantBuffers));
immediateContext->GSSetShader(geometryShader.get(), nullptr, 0);
immediateContext->PSSetShader(pixelShader.get(), nullptr, 0);
immediateContext->PSSetShaderResources(0, ARRAY_SIZE(views), reinterpret_cast<ID3D11ShaderResourceView**>(views));
immediateContext->PSSetConstantBuffers(0, ARRAY_SIZE(psConstantBuffers), reinterpret_cast<ID3D11Buffer**>(psConstantBuffers));
immediateContext->PSSetSamplers(0, 1, reinterpret_cast<ID3D11SamplerState**>(&psSampler));
immediateContext->RSSetState(rasterizerState.get());
immediateContext->OMSetDepthStencilState(depthStencilState.get(), stencilRef);
immediateContext->OMSetBlendState(blendState.get(), blendFactor, sampleMask);
immediateContext->IASetPrimitiveTopology(primitiveTopoloy);
immediateContext->IASetInputLayout(inputLayout.get());
}
} // namespace DXHelper

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

@ -0,0 +1,217 @@
#include <pch.h>
#include "CameraResources.h"
#include "DeviceResourcesUWP.h"
using namespace D2D1;
using namespace winrt::Windows::Graphics::DirectX::Direct3D11;
using namespace winrt::Windows::Graphics::Display;
using namespace winrt::Windows::Graphics::Holographic;
using namespace DXHelper;
void DeviceResourcesUWP::SetWindow(const winrt::Windows::UI::Core::CoreWindow& window)
{
UnregisterHolographicEventHandlers();
m_holographicSpace = HolographicSpace::CreateForCoreWindow(window);
InitializeUsingHolographicSpace();
m_cameraAddedToken = m_holographicSpace.CameraAdded({this, &DeviceResourcesUWP::OnCameraAdded});
m_cameraRemovedToken = m_holographicSpace.CameraRemoved({this, &DeviceResourcesUWP::OnCameraRemoved});
}
void DeviceResourcesUWP::InitializeUsingHolographicSpace()
{
// The holographic space might need to determine which adapter supports
// holograms, in which case it will specify a non-zero PrimaryAdapterId.
LUID id = {m_holographicSpace.PrimaryAdapterId().LowPart, m_holographicSpace.PrimaryAdapterId().HighPart};
// When a primary adapter ID is given to the app, the app should find
// the corresponding DXGI adapter and use it to create Direct3D devices
// and device contexts. Otherwise, there is no restriction on the DXGI
// adapter the app can use.
if ((id.HighPart != 0) || (id.LowPart != 0))
{
UINT createFlags = 0;
#ifdef DEBUG
if (SdkLayersAvailable())
{
createFlags |= DXGI_CREATE_FACTORY_DEBUG;
}
#endif
// Create the DXGI factory.
winrt::com_ptr<IDXGIFactory1> dxgiFactory;
winrt::check_hresult(CreateDXGIFactory2(createFlags, IID_PPV_ARGS(dxgiFactory.put())));
winrt::com_ptr<IDXGIFactory4> dxgiFactory4;
dxgiFactory.as(dxgiFactory4);
// Retrieve the adapter specified by the holographic space.
m_dxgiAdapter = nullptr;
winrt::check_hresult(dxgiFactory4->EnumAdapterByLuid(id, IID_PPV_ARGS(m_dxgiAdapter.put())));
}
else
{
m_dxgiAdapter = nullptr;
}
CreateDeviceResources();
m_holographicSpace.SetDirect3D11Device(m_d3dInteropDevice);
}
void DeviceResourcesUWP::OnCameraAdded(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraAddedEventArgs const& args)
{
UseHolographicCameraResources([this, camera = args.Camera()](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
cameraResourceMap[camera.Id()] = std::make_unique<CameraResources>(camera);
});
}
void DeviceResourcesUWP::OnCameraRemoved(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraRemovedEventArgs const& args)
{
UseHolographicCameraResources([this, camera = args.Camera()](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
CameraResources* pCameraResources = cameraResourceMap[camera.Id()].get();
if (pCameraResources != nullptr)
{
pCameraResources->ReleaseResourcesForBackBuffer(this);
cameraResourceMap.erase(camera.Id());
}
});
}
void DeviceResourcesUWP::UnregisterHolographicEventHandlers()
{
if (m_holographicSpace != nullptr)
{
// Clear previous event registrations.
m_holographicSpace.CameraAdded(m_cameraAddedToken);
m_cameraAddedToken = {};
m_holographicSpace.CameraRemoved(m_cameraRemovedToken);
m_cameraRemovedToken = {};
}
}
// Validates the back buffer for each HolographicCamera and recreates
// resources for back buffers that have changed.
// Locks the set of holographic camera resources until the function exits.
void DeviceResourcesUWP::EnsureCameraResources(HolographicFrame frame, HolographicFramePrediction prediction)
{
UseHolographicCameraResources([this, frame, prediction](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
for (HolographicCameraPose const& cameraPose : prediction.CameraPoses())
{
HolographicCameraRenderingParameters renderingParameters = frame.GetRenderingParameters(cameraPose);
CameraResources* pCameraResources = cameraResourceMap[cameraPose.HolographicCamera().Id()].get();
pCameraResources->CreateResourcesForBackBuffer(this, renderingParameters);
}
});
}
DeviceResourcesUWP::~DeviceResourcesUWP()
{
UnregisterHolographicEventHandlers();
}
// Recreate all device resources and set them back to the current state.
// Locks the set of holographic camera resources until the function exits.
void DeviceResourcesUWP::HandleDeviceLost()
{
NotifyDeviceLost();
UseHolographicCameraResources([this](std::map<UINT32, std::unique_ptr<CameraResources>>& cameraResourceMap) {
for (auto& pair : cameraResourceMap)
{
CameraResources* pCameraResources = pair.second.get();
pCameraResources->ReleaseResourcesForBackBuffer(this);
}
});
InitializeUsingHolographicSpace();
NotifyDeviceRestored();
}
void DeviceResourcesUWP::CreateDeviceResources()
{
DeviceResourcesCommon::CreateDeviceResources();
// Acquire the DXGI interface for the Direct3D device.
winrt::com_ptr<IDXGIDevice3> dxgiDevice;
m_d3dDevice.as(dxgiDevice);
// Wrap the native device using a WinRT interop object.
winrt::com_ptr<::IInspectable> object;
winrt::check_hresult(CreateDirect3D11DeviceFromDXGIDevice(dxgiDevice.get(), reinterpret_cast<IInspectable**>(winrt::put_abi(object))));
m_d3dInteropDevice = object.as<IDirect3DDevice>();
}
// Present the contents of the swap chain to the screen.
// Locks the set of holographic camera resources until the function exits.
void DeviceResourcesUWP::Present(HolographicFrame frame)
{
HolographicFramePresentResult presentResult =
frame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior::DoNotWaitForFrameToFinish);
// Note, by not waiting on PresentUsingCurrentPrediction and instead using WaitForNextFrameReadyWithHeadStart we avoid going into
// pipelined mode.
try
{
// WaitForNextFrameReadyWithHeadStart has been added in 10.0.17763.0.
if (!m_useLegacyWaitBehavior)
{
m_holographicSpace.WaitForNextFrameReadyWithHeadStart(winrt::Windows::Foundation::TimeSpan(0));
}
else
{
frame.WaitForFrameToFinish();
}
}
catch (winrt::hresult_error& err)
{
switch (err.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
presentResult = HolographicFramePresentResult::DeviceRemoved;
break;
default:
try
{
m_useLegacyWaitBehavior = true;
frame.WaitForFrameToFinish();
}
catch (winrt::hresult_error& err2)
{
switch (err2.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
presentResult = HolographicFramePresentResult::DeviceRemoved;
break;
default:
throw err2;
}
}
break;
}
// The PresentUsingCurrentPrediction API will detect when the graphics device
// changes or becomes invalid. When this happens, it is considered a Direct3D
// device lost scenario.
if (presentResult == HolographicFramePresentResult::DeviceRemoved)
{
// The Direct3D device, context, and resources should be recreated.
HandleDeviceLost();
}
}
}

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

@ -0,0 +1,100 @@
#pragma once
#include "DeviceResourcesCommon.h"
#include <winrt/Windows.Graphics.Holographic.h>
namespace DXHelper
{
class CameraResources;
class DeviceResourcesUWP : public DeviceResourcesCommon
{
public:
~DeviceResourcesUWP();
void HandleDeviceLost();
void Present(winrt::Windows::Graphics::Holographic::HolographicFrame frame);
void SetWindow(const winrt::Windows::UI::Core::CoreWindow& window);
void EnsureCameraResources(
winrt::Windows::Graphics::Holographic::HolographicFrame frame,
winrt::Windows::Graphics::Holographic::HolographicFramePrediction prediction);
// Holographic accessors.
template <typename LCallback>
void UseHolographicCameraResources(LCallback const& callback);
// Holographic accessors.
winrt::Windows::Graphics::Holographic::HolographicSpace GetHolographicSpace()
{
return m_holographicSpace;
}
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice GetD3DInteropDevice() const
{
return m_d3dInteropDevice;
}
protected:
virtual void CreateDeviceResources() override;
private:
void InitializeUsingHolographicSpace();
void OnCameraAdded(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraAddedEventArgs const& args);
void OnCameraRemoved(
winrt::Windows::Graphics::Holographic::HolographicSpace const& sender,
winrt::Windows::Graphics::Holographic::HolographicSpaceCameraRemovedEventArgs const& args);
void UnregisterHolographicEventHandlers();
// Direct3D interop objects.
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DDevice m_d3dInteropDevice;
// The holographic space provides a preferred DXGI adapter ID.
winrt::Windows::Graphics::Holographic::HolographicSpace m_holographicSpace = nullptr;
bool m_useLegacyWaitBehavior = false;
// Back buffer resources, etc. for attached holographic cameras.
std::map<UINT32, std::unique_ptr<CameraResources>> m_cameraResources;
std::mutex m_cameraResourcesLock;
winrt::event_token m_cameraAddedToken;
winrt::event_token m_cameraRemovedToken;
};
} // namespace DXHelper
// Device-based resources for holographic cameras are stored in a std::map. Access this list by providing a
// callback to this function, and the std::map will be guarded from add and remove
// events until the callback returns. The callback is processed immediately and must
// not contain any nested calls to UseHolographicCameraResources.
// The callback takes a parameter of type std::map<UINT32, std::unique_ptr<CameraResources>>&
// through which the list of cameras will be accessed.
template <typename LCallback>
void DXHelper::DeviceResourcesUWP::UseHolographicCameraResources(LCallback const& callback)
{
try
{
std::lock_guard<std::mutex> guard(m_cameraResourcesLock);
callback(m_cameraResources);
}
catch (const winrt::hresult_error& err)
{
switch (err.code())
{
case DXGI_ERROR_DEVICE_HUNG:
case DXGI_ERROR_DEVICE_REMOVED:
case DXGI_ERROR_DEVICE_RESET:
HandleDeviceLost();
break;
default:
throw err;
}
}
}

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

@ -13,6 +13,8 @@
#include "IpAddressUpdater.h" #include "IpAddressUpdater.h"
using namespace winrt::Windows::Networking;
using namespace winrt::Windows::Networking::Connectivity;
IpAddressUpdater::IpAddressUpdater() IpAddressUpdater::IpAddressUpdater()
{ {
@ -24,27 +26,50 @@ IpAddressUpdater::IpAddressUpdater()
IpAddressUpdater::~IpAddressUpdater() = default; IpAddressUpdater::~IpAddressUpdater() = default;
winrt::hstring IpAddressUpdater::GetIpAddress() winrt::hstring IpAddressUpdater::GetIpAddress(bool ipv6)
{ {
std::lock_guard lockGuard(m_lock); std::lock_guard lockGuard(m_lock);
return m_ipAddress; return ipv6 ? m_ipAddressIpv6 : m_ipAddressIpv4;
} }
void IpAddressUpdater::UpdateIpAddress(winrt::Windows::Foundation::IInspectable sender) void IpAddressUpdater::UpdateIpAddress(winrt::Windows::Foundation::IInspectable sender)
{ {
winrt::hstring ipAddress = L"(No Network Connection)"; winrt::hstring ipAddressIpv4 = L"";
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Networking::HostName> hostnames = winrt::hstring ipAddressIpv6 = L"";
winrt::Windows::Networking::Connectivity::NetworkInformation::GetHostNames(); winrt::Windows::Foundation::Collections::IVectorView<HostName> hostnames = NetworkInformation::GetHostNames();
for (winrt::Windows::Networking::HostName hostname : hostnames) for (winrt::Windows::Networking::HostName hostname : hostnames)
{ {
if (hostname.IPInformation() && hostname.IPInformation().NetworkAdapter() && hostname.CanonicalName().size() <= 15) // IPV4 only auto hostNameType = hostname.Type();
if (hostNameType != HostNameType::Ipv4 && hostNameType != HostNameType::Ipv6)
{ {
ipAddress = hostname.CanonicalName(); continue;
break; }
if (hostname.IPInformation() && hostname.IPInformation().NetworkAdapter())
{
if (hostNameType == HostNameType::Ipv6 && ipAddressIpv6.empty())
{
ipAddressIpv6 = hostname.CanonicalName();
}
else if (hostNameType == HostNameType::Ipv4 && ipAddressIpv4.empty())
{
ipAddressIpv4 = hostname.CanonicalName();
}
} }
} }
if (ipAddressIpv6.empty())
{
ipAddressIpv6 = L"(No Network Connection)";
}
if (ipAddressIpv4.empty())
{
ipAddressIpv4 = L"(No Network Connection)";
}
std::lock_guard lockGuard(m_lock); std::lock_guard lockGuard(m_lock);
m_ipAddress = ipAddress; m_ipAddressIpv6 = ipAddressIpv6;
m_ipAddressIpv4 = ipAddressIpv4;
}; };

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

@ -13,21 +13,21 @@
#include <winrt/Windows.Networking.Connectivity.h> #include <winrt/Windows.Networking.Connectivity.h>
class IpAddressUpdater class IpAddressUpdater
{ {
public: public:
IpAddressUpdater(); IpAddressUpdater();
~IpAddressUpdater(); ~IpAddressUpdater();
winrt::hstring GetIpAddress(); winrt::hstring GetIpAddress(bool ipv6);
private: private:
void UpdateIpAddress(winrt::Windows::Foundation::IInspectable sender); void UpdateIpAddress(winrt::Windows::Foundation::IInspectable sender);
private: private:
std::mutex m_lock; std::mutex m_lock;
winrt::hstring m_ipAddress; winrt::hstring m_ipAddressIpv6;
winrt::hstring m_ipAddressIpv4;
winrt::Windows::Networking::Connectivity::NetworkInformation::NetworkStatusChanged_revoker m_networkStatusChangedRevoker; winrt::Windows::Networking::Connectivity::NetworkInformation::NetworkStatusChanged_revoker m_networkStatusChangedRevoker;
}; };

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

@ -15,10 +15,8 @@
#include <sstream> #include <sstream>
using namespace winrt::Microsoft::Holographic::AppRemoting; using namespace winrt::Microsoft::Holographic::AppRemoting;
std::wstring PlayerFrameStatisticsHelper::GetStatisticsString() const std::wstring PlayerFrameStatisticsHelper::GetStatisticsString() const
{ {
float timeSinceLastPresentAvg = 0.0f; float timeSinceLastPresentAvg = 0.0f;
@ -31,7 +29,6 @@ std::wstring PlayerFrameStatisticsHelper::GetStatisticsString() const
float latencyAvg = 0.0f; float latencyAvg = 0.0f;
uint32_t videoFramesDiscarded = 0; uint32_t videoFramesDiscarded = 0;
for (const PlayerFrameStatistics& frameStatistics : m_lastWindowFrameStats) for (const PlayerFrameStatistics& frameStatistics : m_lastWindowFrameStats)
{ {
timeSinceLastPresentAvg += frameStatistics.TimeSinceLastPresent; timeSinceLastPresentAvg += frameStatistics.TimeSinceLastPresent;
@ -69,14 +66,14 @@ std::wstring PlayerFrameStatisticsHelper::GetStatisticsString() const
std::wstringstream statisticsStringStream; std::wstringstream statisticsStringStream;
statisticsStringStream.precision(3); statisticsStringStream.precision(3);
statisticsStringStream << L"Render: " << frameStatsCount << L" fps - " << timeSinceLastPresentAvg * 1000 << L" / " statisticsStringStream << L"Render: " << frameStatsCount << L" fps - " << timeSinceLastPresentAvg * 1000 << L" / "
<< timeSinceLastPresentMax * 1000 << L" ms (avg / max)" << std::endl << timeSinceLastPresentMax * 1000 << L" ms (avg/max)" << std::endl
<< L"Video frames: " << videoFramesSkipped << L" / " << videoFramesReused << L" / " << videoFramesReceived << L"Video frames: " << videoFramesSkipped << L" / " << videoFramesReused << L" / " << videoFramesReceived
<< L" skipped / reused / received" << std::endl << L" skipped/reused/received" << std::endl
<< L"Video frames delta: " << videoFrameMinDelta * 1000 << L" / " << videoFrameMaxDelta * 1000 << L"Video frames delta: " << videoFrameMinDelta * 1000 << L" / " << videoFrameMaxDelta * 1000
<< L" ms (min / max)" << std::endl << L" ms (min/max)" << std::endl
<< L"Latency: " << latencyAvg * 1000 << L" ms (avg)" << std::endl << L"Latency: " << latencyAvg * 1000 << L" ms (avg)" << std::endl
<< L"Video frames discarded: " << videoFramesDiscarded << L" / " << m_videoFramesDiscardedTotal << L"Video frames discarded: " << videoFramesDiscarded << L" / " << m_videoFramesDiscardedTotal
<< L" frames (last sec / total)" << std::endl; << L" frames (last sec/total)" << std::endl;
return statisticsStringStream.str(); return statisticsStringStream.str();
} }

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

@ -9,7 +9,6 @@
// //
//********************************************************* //*********************************************************
#pragma once #pragma once
#include <string> #include <string>

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

@ -0,0 +1,37 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "PlayerUtil.h"
#include <codecvt>
#include <regex>
std::wstring PlayerUtil::SplitHostnameAndPortString(const std::wstring& address, uint16_t& port)
{
static std::basic_regex<wchar_t> addressMatcher(L"(?:(\\[.*\\])|([^:]*))(?:[:](\\d+))?");
std::match_results<typename std::wstring::const_iterator> results;
if (std::regex_match(address, results, addressMatcher))
{
if (results[3].matched)
{
std::wstring portStr = results[3].str();
port = static_cast<uint16_t>(std::wcstol(portStr.c_str(), nullptr, 10));
}
return (results[1].matched) ? results[1].str() : results[2].str();
}
else
{
return address;
}
}

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

@ -0,0 +1,17 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#pragma once
struct PlayerUtil
{
static std::wstring SplitHostnameAndPortString(const std::wstring& address, uint16_t& port);
};

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

@ -13,13 +13,23 @@
struct PixelShaderInput struct PixelShaderInput
{ {
min16float4 pos : SV_POSITION; min16float4 pos : SV_POSITION;
float2 uv : TEXCOORD0; //Note: we use full precission floats for texture coordinates to avoid artifacts with large textures float2 uv : TEXCOORD0; // Note: we use full precission floats for texture coordinates to avoid artifacts with large textures
}; };
Texture2D tex : t0; Texture2D tex : t0;
SamplerState samp : s0; SamplerState samp : s0;
min16float4 main(PixelShaderInput input) : SV_TARGET float4 main(PixelShaderInput input) : SV_TARGET
{ {
return (min16float4)tex.Sample(samp, input.uv); float2 offsets[4] = {float2(-0.125, -0.375), float2(0.375, -0.125), float2(-0.375, 0.125), float2(0.125f, 0.375f)};
float4 color = float4(0, 0, 0, 0);
float2 dtdx = ddx(input.uv);
float2 dtdy = ddy(input.uv);
[unroll]
for (int i = 0; i < 4; ++i)
{
color += 0.25 * tex.Sample(samp, input.uv + offsets[i].x * dtdx + offsets[i].y * dtdy);
}
return color;
} }

20
player/sample/LICENSE Normal file
Просмотреть файл

@ -0,0 +1,20 @@
The MIT License (MIT)
Copyright (c) 2012-2019 Microsoft Corp
Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

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

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" IgnorableNamespaces="uap mp uap2"> <Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" xmlns:uap2="http://schemas.microsoft.com/appx/manifest/uap/windows10/2" IgnorableNamespaces="uap mp uap2">
<Identity Name="SampleHolographicRemotingPlayer" Publisher="CN=SampleHolographicRemotingPlayer" Version="2.0.14.0" /> <Identity Name="SampleHolographicRemotingPlayer" Publisher="CN=SampleHolographicRemotingPlayer" Version="2.1.0.0" />
<mp:PhoneIdentity PhoneProductId="b65c9a46-d0b3-4954-829a-6a60bed54d0a" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> <mp:PhoneIdentity PhoneProductId="b65c9a46-d0b3-4954-829a-6a60bed54d0a" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties> <Properties>
<DisplayName>Sample Holographic AppRemoting Player</DisplayName> <DisplayName>Sample Holographic AppRemoting Player</DisplayName>

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

@ -1,26 +1,26 @@
 
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15 # Visual Studio Version 16
VisualStudioVersion = 15.0.28307.645 VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SamplePlayer", "SamplePlayer.vcxproj", "{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SamplePlayer", "SamplePlayer.vcxproj", "{B848F924-651A-3EC7-8166-E5565290E1FB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|ARM = Debug|ARM Debug|ARM64 = Debug|ARM64
Release|ARM = Release|ARM Release|ARM64 = Release|ARM64
RelWithDebInfo|ARM = RelWithDebInfo|ARM RelWithDebInfo|ARM64 = RelWithDebInfo|ARM64
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Debug|ARM.ActiveCfg = Debug|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Debug|ARM64.ActiveCfg = Debug|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Debug|ARM.Build.0 = Debug|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Debug|ARM64.Build.0 = Debug|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Debug|ARM.Deploy.0 = Debug|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Debug|ARM64.Deploy.0 = Debug|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Release|ARM.ActiveCfg = Release|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Release|ARM64.ActiveCfg = Release|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Release|ARM.Build.0 = Release|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Release|ARM64.Build.0 = Release|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.Release|ARM.Deploy.0 = Release|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.Release|ARM64.Deploy.0 = Release|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.RelWithDebInfo|ARM.ActiveCfg = RelWithDebInfo|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.RelWithDebInfo|ARM64.ActiveCfg = RelWithDebInfo|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.RelWithDebInfo|ARM.Build.0 = RelWithDebInfo|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.RelWithDebInfo|ARM64.Build.0 = RelWithDebInfo|ARM64
{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}.RelWithDebInfo|ARM.Deploy.0 = RelWithDebInfo|ARM {B848F924-651A-3EC7-8166-E5565290E1FB}.RelWithDebInfo|ARM64.Deploy.0 = RelWithDebInfo|ARM64
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

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

@ -1,21 +1,25 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|ARM"> <ProjectConfiguration Include="Debug|ARM64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
<Platform>ARM</Platform> <Platform>ARM64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="Release|ARM"> <ProjectConfiguration Include="Release|ARM64">
<Configuration>Release</Configuration> <Configuration>Release</Configuration>
<Platform>ARM</Platform> <Platform>ARM64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
<ProjectConfiguration Include="RelWithDebInfo|ARM"> <ProjectConfiguration Include="RelWithDebInfo|ARM64">
<Configuration>RelWithDebInfo</Configuration> <Configuration>RelWithDebInfo</Configuration>
<Platform>ARM</Platform> <Platform>ARM64</Platform>
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{B26EEC5F-BBFF-3973-A459-AD3E5A33EF70}</ProjectGuid> <ProjectGuid>{B848F924-651A-3EC7-8166-E5565290E1FB}</ProjectGuid>
<ApplicationType>Windows Store</ApplicationType> <ApplicationType>Windows Store</ApplicationType>
<DefaultLanguage>en-US</DefaultLanguage> <DefaultLanguage>en-US</DefaultLanguage>
<ApplicationTypeRevision>10.0</ApplicationTypeRevision> <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
@ -24,67 +28,66 @@
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion> <WindowsTargetPlatformMinVersion>10.0.17134.0</WindowsTargetPlatformMinVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<Platform>ARM</Platform> <Platform>ARM64</Platform>
<ProjectName>SamplePlayer</ProjectName> <ProjectName>SamplePlayer</ProjectName>
<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName> <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet> <CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="packages\Microsoft.Holographic.Remoting.2.0.14\build\native\Microsoft.Holographic.Remoting.targets" Condition="Exists('packages\Microsoft.Holographic.Remoting.2.0.14\build\native\Microsoft.Holographic.Remoting.targets')" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion> <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.\bin\Debug\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.\bin\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">SamplePlayer.dir\Debug\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">SamplePlayer.dir\Debug\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">SamplePlayer</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">SamplePlayer</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.\bin\Release\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.\bin\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">SamplePlayer.dir\Release\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">SamplePlayer.dir\Release\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">SamplePlayer</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">SamplePlayer</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.\bin\RelWithDebInfo\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.\bin\RelWithDebInfo\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">SamplePlayer.dir\RelWithDebInfo\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">SamplePlayer.dir\RelWithDebInfo\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">SamplePlayer</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">SamplePlayer</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</GenerateManifest>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories>
<AssemblerListingLocation>Debug/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>false</CompileAsWinRT> <CompileAsWinRT>false</CompileAsWinRT>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4503;4311;4456;4458;4459;4499</DisableSpecificWarnings> <DisableSpecificWarnings>4503</DisableSpecificWarnings>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles> <ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
@ -98,11 +101,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;UNICODE;_UNICODE;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;UNICODE;_UNICODE;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -116,7 +119,7 @@
<Link> <Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>%(AdditionalOptions) /machine:ARM</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /machine:ARM64</AdditionalOptions>
<EnableCOMDATFolding>false</EnableCOMDATFolding> <EnableCOMDATFolding>false</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
@ -130,17 +133,17 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies> <LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories>
<AssemblerListingLocation>Release/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>false</CompileAsWinRT> <CompileAsWinRT>false</CompileAsWinRT>
<ControlFlowGuard>Guard</ControlFlowGuard> <ControlFlowGuard>Guard</ControlFlowGuard>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4503;4311;4456;4458;4459;4499</DisableSpecificWarnings> <DisableSpecificWarnings>4503</DisableSpecificWarnings>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles> <ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
@ -154,11 +157,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -172,7 +175,7 @@
<Link> <Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>%(AdditionalOptions) /machine:ARM</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /machine:ARM64</AdditionalOptions>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation> <GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@ -184,16 +187,16 @@
<LinkLibraryDependencies>false</LinkLibraryDependencies> <LinkLibraryDependencies>false</LinkLibraryDependencies>
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">
<ClCompile> <ClCompile>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(UniversalCRTSdkDir)UnionMetadata</AdditionalUsingDirectories>
<AssemblerListingLocation>RelWithDebInfo/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>false</CompileAsWinRT> <CompileAsWinRT>false</CompileAsWinRT>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4503;4311;4456;4458;4459;4499</DisableSpecificWarnings> <DisableSpecificWarnings>4503</DisableSpecificWarnings>
<ExceptionHandling>Sync</ExceptionHandling> <ExceptionHandling>Sync</ExceptionHandling>
<ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles> <ForcedUsingFiles>;%(ForcedUsingFiles)</ForcedUsingFiles>
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
@ -207,11 +210,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM32;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;UNICODE;_UNICODE;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WINRT;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_ARM;RDBUILD_ARCH_ARM_ARM64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -225,7 +228,7 @@
<Link> <Link>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalOptions>%(AdditionalOptions) /machine:ARM</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /machine:ARM64</AdditionalOptions>
<EnableCOMDATFolding>false</EnableCOMDATFolding> <EnableCOMDATFolding>false</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateWindowsMetadata>false</GenerateWindowsMetadata> <GenerateWindowsMetadata>false</GenerateWindowsMetadata>
@ -246,12 +249,16 @@
<ClCompile Include=".\SamplePlayerMain.cpp" /> <ClCompile Include=".\SamplePlayerMain.cpp" />
<ClCompile Include="..\common\CameraResources.cpp" /> <ClCompile Include="..\common\CameraResources.cpp" />
<ClInclude Include="..\common\CameraResources.h" /> <ClInclude Include="..\common\CameraResources.h" />
<ClCompile Include="..\common\DeviceResources.cpp" /> <ClCompile Include="..\common\DeviceResourcesCommon.cpp" />
<ClInclude Include="..\common\DeviceResources.h" /> <ClInclude Include="..\common\DeviceResourcesCommon.h" />
<ClCompile Include="..\common\DeviceResourcesUWP.cpp" />
<ClInclude Include="..\common\DeviceResourcesUWP.h" />
<ClInclude Include="..\common\IpAddressUpdater.h" /> <ClInclude Include="..\common\IpAddressUpdater.h" />
<ClCompile Include="..\common\IpAddressUpdater.cpp" /> <ClCompile Include="..\common\IpAddressUpdater.cpp" />
<ClInclude Include="..\common\PlayerFrameStatisticsHelper.h" /> <ClInclude Include="..\common\PlayerFrameStatisticsHelper.h" />
<ClCompile Include="..\common\PlayerFrameStatisticsHelper.cpp" /> <ClCompile Include="..\common\PlayerFrameStatisticsHelper.cpp" />
<ClInclude Include="..\common\PlayerUtil.h" />
<ClCompile Include="..\common\PlayerUtil.cpp" />
<ClCompile Include="..\common\Content\DDSTextureLoader.cpp" /> <ClCompile Include="..\common\Content\DDSTextureLoader.cpp" />
<ClInclude Include="..\common\Content\DDSTextureLoader.h" /> <ClInclude Include="..\common\Content\DDSTextureLoader.h" />
<ClInclude Include="..\common\Content\ErrorHelper.h" /> <ClInclude Include="..\common\Content\ErrorHelper.h" />
@ -261,97 +268,101 @@
<ClCompile Include="..\common\Content\StatusDisplay.cpp" /> <ClCompile Include="..\common\Content\StatusDisplay.cpp" />
<None Include=".\Content\RemotingLogo.dds"> <None Include=".\Content\RemotingLogo.dds">
<Link>.\%(FileName)%(Extension)</Link> <Link>.\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</None> </None>
<Image Include=".\Assets\LockScreenLogo.scale-200.png"> <Image Include=".\Assets\LockScreenLogo.scale-200.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\SplashScreen.scale-200.png"> <Image Include=".\Assets\SplashScreen.scale-200.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\Square44x44Logo.scale-200.png"> <Image Include=".\Assets\Square44x44Logo.scale-200.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\Square44x44Logo.targetsize-24_altform-unplated.png"> <Image Include=".\Assets\Square44x44Logo.targetsize-24_altform-unplated.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\Square150x150Logo.scale-200.png"> <Image Include=".\Assets\Square150x150Logo.scale-200.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\StoreLogo.png"> <Image Include=".\Assets\StoreLogo.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<Image Include=".\Assets\Wide310x150Logo.scale-200.png"> <Image Include=".\Assets\Wide310x150Logo.scale-200.png">
<Link>Assets\%(FileName)%(Extension)</Link> <Link>Assets\%(FileName)%(Extension)</Link>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</DeploymentContent>
<DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">true</DeploymentContent> <DeploymentContent Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">true</DeploymentContent>
</Image> </Image>
<AppxManifest Include=".\Package.appxmanifest" /> <AppxManifest Include=".\Package.appxmanifest" />
<FXCompile Include="..\common\Shaders\VertexShader.hlsl"> <FXCompile Include="..\common\Shaders\VertexShader.hlsl">
<ShaderType>Vertex</ShaderType> <ShaderType>Vertex</ShaderType>
<EntryPointName>main</EntryPointName> <EntryPointName>main</EntryPointName>
<ShaderModel>5.0</ShaderModel> <ShaderModel>5.0</ShaderModel>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">%(Filename)</VariableName>
</FXCompile> </FXCompile>
<FXCompile Include="..\common\Shaders\VPRTVertexShader.hlsl"> <FXCompile Include="..\common\Shaders\VPRTVertexShader.hlsl">
<ShaderType>Vertex</ShaderType> <ShaderType>Vertex</ShaderType>
<EntryPointName>main</EntryPointName> <EntryPointName>main</EntryPointName>
<ShaderModel>5.0</ShaderModel> <ShaderModel>5.0</ShaderModel>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">%(Filename)</VariableName>
</FXCompile> </FXCompile>
<FXCompile Include="..\common\Shaders\PixelShader.hlsl"> <FXCompile Include="..\common\Shaders\PixelShader.hlsl">
<ShaderType>Pixel</ShaderType> <ShaderType>Pixel</ShaderType>
<EntryPointName>main</EntryPointName> <EntryPointName>main</EntryPointName>
<ShaderModel>5.0</ShaderModel> <ShaderModel>5.0</ShaderModel>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">%(Filename)</VariableName>
</FXCompile> </FXCompile>
<FXCompile Include="..\common\Shaders\GeometryShader.hlsl"> <FXCompile Include="..\common\Shaders\GeometryShader.hlsl">
<ShaderType>Geometry</ShaderType> <ShaderType>Geometry</ShaderType>
<EntryPointName>main</EntryPointName> <EntryPointName>main</EntryPointName>
<ShaderModel>5.0</ShaderModel> <ShaderModel>5.0</ShaderModel>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">.\shaders\%(Filename).h</HeaderFileOutput> <HeaderFileOutput Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">.\shaders\%(Filename).h</HeaderFileOutput>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">%(Filename)</VariableName>
<VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM'">%(Filename)</VariableName> <VariableName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|ARM64'">%(Filename)</VariableName>
</FXCompile> </FXCompile>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="packages\Microsoft.Holographic.Remoting.2.1.0\build\native\Microsoft.Holographic.Remoting.targets" Condition="Exists('packages\Microsoft.Holographic.Remoting.2.1.0\build\native\Microsoft.Holographic.Remoting.targets')" />
</ImportGroup>
</Project> </Project>

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

@ -13,10 +13,14 @@
#include "SamplePlayerMain.h" #include "SamplePlayerMain.h"
#include "../common/CameraResources.h"
#include "../common/Content/DDSTextureLoader.h" #include "../common/Content/DDSTextureLoader.h"
#include "../common/PlayerUtil.h"
#include <sstream> #include <sstream>
#include <winrt/Windows.Foundation.Metadata.h>
using namespace std::chrono_literals; using namespace std::chrono_literals;
using namespace winrt::Microsoft::Holographic::AppRemoting; using namespace winrt::Microsoft::Holographic::AppRemoting;
@ -30,7 +34,11 @@ using namespace winrt::Windows::Perception::Spatial;
using namespace winrt::Windows::UI::Core; using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::Input::Spatial; using namespace winrt::Windows::UI::Input::Spatial;
SamplePlayerMain::SamplePlayerMain()
{
m_canCommitDirect3D11DepthBuffer = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(
L"Windows.Graphics.Holographic.HolographicCameraRenderingParameters", L"CommitDirect3D11DepthBuffer");
}
SamplePlayerMain::~SamplePlayerMain() SamplePlayerMain::~SamplePlayerMain()
{ {
Uninitialize(); Uninitialize();
@ -127,8 +135,8 @@ HolographicFrame SamplePlayerMain::Update(float deltaTimeInSeconds)
HolographicCameraRenderingParameters renderingParameters = holographicFrame.GetRenderingParameters(cameraPose); HolographicCameraRenderingParameters renderingParameters = holographicFrame.GetRenderingParameters(cameraPose);
// Set the focus point for image stabilization to the center of the status display. // Set the focus point for image stabilization to the center of the status display.
// NOTE: By doing this before the call to PlayerContext::BlitRemoteFrame (in the Render() method), // NOTE: The focus point set here will be overwritten with the focus point from the remote side by BlitRemoteFrame or
// the focus point can be overriden by the remote side. // ignored if a depth buffer is commited (see HolographicRemotingPlayerMain::Render for details).
renderingParameters.SetFocusPoint(coordinateSystem, m_statusDisplay->GetPosition()); renderingParameters.SetFocusPoint(coordinateSystem, m_statusDisplay->GetPosition());
} }
} }
@ -147,7 +155,7 @@ HolographicFrame SamplePlayerMain::Update(float deltaTimeInSeconds)
} }
else else
{ {
StatusDisplay::Line line = {std::move(statisticsString), StatusDisplay::Small, StatusDisplay::Yellow, 1.0f, true}; StatusDisplay::Line line = {std::move(statisticsString), StatusDisplay::Medium, StatusDisplay::Yellow, 1.0f, true};
m_statusDisplay->AddLine(line); m_statusDisplay->AddLine(line);
} }
} }
@ -156,7 +164,7 @@ HolographicFrame SamplePlayerMain::Update(float deltaTimeInSeconds)
{ {
if (m_playerOptions.m_listen) if (m_playerOptions.m_listen)
{ {
auto deviceIpNew = m_ipAddressUpdater.GetIpAddress(); auto deviceIpNew = m_ipAddressUpdater.GetIpAddress(m_playerOptions.m_ipv6);
if (m_deviceIp != deviceIpNew) if (m_deviceIp != deviceIpNew)
{ {
m_deviceIp = deviceIpNew; m_deviceIp = deviceIpNew;
@ -209,12 +217,30 @@ void SamplePlayerMain::Render(const HolographicFrame& holographicFrame)
deviceContext->ClearRenderTargetView(targets[0], DirectX::Colors::Transparent); deviceContext->ClearRenderTargetView(targets[0], DirectX::Colors::Transparent);
deviceContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); deviceContext->ClearDepthStencilView(depthStencilView, D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0);
if (coordinateSystem)
{
// The view and projection matrices for each holographic camera will change // The view and projection matrices for each holographic camera will change
// every frame. This function refreshes the data in the constant buffer for // every frame. This function refreshes the data in the constant buffer for
// the holographic camera indicated by cameraPose. // the holographic camera indicated by cameraPose.
if (coordinateSystem)
{
pCameraResources->UpdateViewProjectionBuffer(m_deviceResources, cameraPose, coordinateSystem); pCameraResources->UpdateViewProjectionBuffer(m_deviceResources, cameraPose, coordinateSystem);
const bool connected = (m_playerContext.ConnectionState() == ConnectionState::Connected);
// Reduce the fov of the statistics view.
float quadFov = m_statusDisplay->GetDefaultQuadFov();
float quadRatio = 1.0f;
if (m_playerOptions.m_showStatistics && connected && !m_trackingLost)
{
quadFov = m_statusDisplay->GetStatisticsFov();
quadRatio = m_statusDisplay->GetStatisticsHeightRatio();
}
// Pass data from the camera resources to the status display.
m_statusDisplay->UpdateTextScale(
pCameraResources->GetProjectionTransform(),
pCameraResources->GetRenderTargetSize().Width,
pCameraResources->GetRenderTargetSize().Height,
quadFov,
quadRatio);
} }
// Attach the view/projection constant buffer for this camera to the graphics pipeline. // Attach the view/projection constant buffer for this camera to the graphics pipeline.
@ -223,6 +249,8 @@ void SamplePlayerMain::Render(const HolographicFrame& holographicFrame)
// Only render world-locked content when positional tracking is active. // Only render world-locked content when positional tracking is active.
if (cameraActive) if (cameraActive)
{ {
bool depthAvailable = false;
try try
{ {
if (m_playerContext.ConnectionState() == ConnectionState::Connected) if (m_playerContext.ConnectionState() == ConnectionState::Connected)
@ -230,7 +258,11 @@ void SamplePlayerMain::Render(const HolographicFrame& holographicFrame)
// Blit the remote frame into the backbuffer for the HolographicFrame. // Blit the remote frame into the backbuffer for the HolographicFrame.
// NOTE: This overwrites the focus point for the current frame, if the remote application // NOTE: This overwrites the focus point for the current frame, if the remote application
// has specified a focus point during the rendering of the remote frame. // has specified a focus point during the rendering of the remote frame.
m_playerContext.BlitRemoteFrame(); if (m_playerContext.BlitRemoteFrame() == BlitResult::Success_Color_Depth)
{
// In case of Success_Color_Depth a depth buffer has been committed by the remote application.
depthAvailable = true;
}
} }
} }
catch (winrt::hresult_error err) catch (winrt::hresult_error err)
@ -240,10 +272,25 @@ void SamplePlayerMain::Render(const HolographicFrame& holographicFrame)
UpdateStatusDisplay(); UpdateStatusDisplay();
} }
// Render local content.
{
// NOTE: Any local custom content would be rendered here.
// Draw connection status and/or statistics. // Draw connection status and/or statistics.
m_statusDisplay->Render(); m_statusDisplay->Render();
} }
// Commit depth buffer if available.
// NOTE: CommitDirect3D11DepthBuffer should be the last thing before the frame is presented. By doing so the depth
// buffer submitted include remote content and local content.
if (m_canCommitDirect3D11DepthBuffer && depthAvailable)
{
auto interopSurface = pCameraResources->GetDepthStencilTextureInteropObject();
HolographicCameraRenderingParameters renderingParameters = holographicFrame.GetRenderingParameters(cameraPose);
renderingParameters.CommitDirect3D11DepthBuffer(interopSurface);
}
}
atLeastOneCameraRendered = true; atLeastOneCameraRendered = true;
}); });
} }
@ -274,7 +321,7 @@ void SamplePlayerMain::Initialize(const CoreApplicationView& applicationView)
m_suspendingEventRevoker = CoreApplication::Suspending(winrt::auto_revoke, {this, &SamplePlayerMain::OnSuspending}); m_suspendingEventRevoker = CoreApplication::Suspending(winrt::auto_revoke, {this, &SamplePlayerMain::OnSuspending});
m_resumingEventRevoker = CoreApplication::Resuming(winrt::auto_revoke, {this, &SamplePlayerMain::OnResuming}); m_resumingEventRevoker = CoreApplication::Resuming(winrt::auto_revoke, {this, &SamplePlayerMain::OnResuming});
m_deviceResources = std::make_shared<DXHelper::DeviceResources>(); m_deviceResources = std::make_shared<DXHelper::DeviceResourcesUWP>();
m_deviceResources->RegisterDeviceNotify(this); m_deviceResources->RegisterDeviceNotify(this);
m_spatialLocator = SpatialLocator::GetDefault(); m_spatialLocator = SpatialLocator::GetDefault();
@ -295,6 +342,9 @@ void SamplePlayerMain::Initialize(const CoreApplicationView& applicationView)
// Set the BlitRemoteFrame timeout to 0.5s // Set the BlitRemoteFrame timeout to 0.5s
m_playerContext.BlitRemoteFrameTimeout(500ms); m_playerContext.BlitRemoteFrameTimeout(500ms);
// Projection transform always reflects what has been configured on the remote side.
m_playerContext.ProjectionTransformConfig(ProjectionTransformMode::Remote);
} }
void SamplePlayerMain::SetWindow(const CoreWindow& window) void SamplePlayerMain::SetWindow(const CoreWindow& window)
@ -315,7 +365,7 @@ void SamplePlayerMain::SetWindow(const CoreWindow& window)
{ {
m_playerContext.OnDataChannelCreated([this](const IDataChannel& dataChannel, uint8_t channelId) { m_playerContext.OnDataChannelCreated([this](const IDataChannel& dataChannel, uint8_t channelId) {
std::lock_guard lock(m_customDataChannelLock); std::lock_guard lock(m_customDataChannelLock);
m_customDataChannel = dataChannel; m_customDataChannel = dataChannel.as<IDataChannel2>();
m_customChannelDataReceivedEventRevoker = m_customDataChannel.OnDataReceived( m_customChannelDataReceivedEventRevoker = m_customDataChannel.OnDataReceived(
winrt::auto_revoke, [this](winrt::array_view<const uint8_t> dataView) { OnCustomDataChannelDataReceived(); }); winrt::auto_revoke, [this](winrt::array_view<const uint8_t> dataView) { OnCustomDataChannelDataReceived(); });
@ -436,7 +486,7 @@ void SamplePlayerMain::LoadLogoImage()
SamplePlayerMain::PlayerOptions SamplePlayerMain::ParseActivationArgs(const IActivatedEventArgs& activationArgs) SamplePlayerMain::PlayerOptions SamplePlayerMain::ParseActivationArgs(const IActivatedEventArgs& activationArgs)
{ {
std::wstring host = L""; std::wstring host = L"";
int32_t port = 0; uint16_t port = 0;
bool listen = false; bool listen = false;
bool showStatistics = false; bool showStatistics = false;
@ -479,19 +529,7 @@ SamplePlayerMain::PlayerOptions SamplePlayerMain::ParseActivationArgs(const IAct
continue; continue;
} }
size_t colonPos = arg.find(L':'); host = PlayerUtil::SplitHostnameAndPortString(arg, port);
if (colonPos != std::wstring::npos)
{
std::wstring portStr = arg.substr(colonPos + 1);
host = arg.substr(0, colonPos);
port = std::wcstol(portStr.c_str(), nullptr, 10);
}
else
{
host = arg.c_str();
port = 0;
}
} }
break; break;
} }
@ -558,6 +596,7 @@ SamplePlayerMain::PlayerOptions SamplePlayerMain::ParseActivationArgs(const IAct
playerOptions.m_port = port; playerOptions.m_port = port;
playerOptions.m_listen = listen; playerOptions.m_listen = listen;
playerOptions.m_showStatistics = showStatistics; playerOptions.m_showStatistics = showStatistics;
playerOptions.m_ipv6 = hostname.front() == L'[';
return playerOptions; return playerOptions;
} }
@ -568,12 +607,10 @@ void SamplePlayerMain::UpdateStatusDisplay()
if (m_trackingLost) if (m_trackingLost)
{ {
StatusDisplay::Line lines[] = {StatusDisplay::Line{L"Device Tracking Lost", StatusDisplay::LargeBold, StatusDisplay::White, 1.2f}, StatusDisplay::Line lines[] = {
StatusDisplay::Line{L"Ensure your environment is properly lit\r\n" StatusDisplay::Line{L"Device Tracking Lost", StatusDisplay::LargeBold, StatusDisplay::White, 1.0f},
L"and the device's sensors are not covered.", StatusDisplay::Line{L"Ensure your environment is properly lit", StatusDisplay::Small, StatusDisplay::White, 1.0f},
StatusDisplay::Small, StatusDisplay::Line{L"and the device's sensors are not covered.", StatusDisplay::Small, StatusDisplay::White, 12.0f}};
StatusDisplay::White,
6.0f}};
m_statusDisplay->SetLines(lines); m_statusDisplay->SetLines(lines);
} }
else else
@ -581,13 +618,12 @@ void SamplePlayerMain::UpdateStatusDisplay()
if (m_playerContext.ConnectionState() != ConnectionState::Connected) if (m_playerContext.ConnectionState() != ConnectionState::Connected)
{ {
StatusDisplay::Line lines[] = { StatusDisplay::Line lines[] = {
StatusDisplay::Line{L"Sample Holographic Remoting Player", StatusDisplay::LargeBold, StatusDisplay::White, 1.2f}, StatusDisplay::Line{L"Holographic Remoting Player", StatusDisplay::LargeBold, StatusDisplay::White, 1.0f},
StatusDisplay::Line{L"This app is a sample companion for Holographic Remoting apps.\r\n" StatusDisplay::Line{
L"Connect from a compatible app to begin.", L"This app is a companion for Holographic Remoting apps.", StatusDisplay::Small, StatusDisplay::White, 1.0f},
StatusDisplay::Small, StatusDisplay::Line{L"Connect from a compatible app to begin.", StatusDisplay::Small, StatusDisplay::White, 8.0f},
StatusDisplay::White, StatusDisplay::Line{
6.0f}, m_playerOptions.m_listen ? L"Waiting for connection on" : L"Connecting to",
StatusDisplay::Line{m_playerOptions.m_listen ? L"Waiting for connection on" : L"Connecting to",
StatusDisplay::Large, StatusDisplay::Large,
StatusDisplay::White}}; StatusDisplay::White}};
m_statusDisplay->SetLines(lines); m_statusDisplay->SetLines(lines);
@ -598,14 +634,16 @@ void SamplePlayerMain::UpdateStatusDisplay()
{ {
addressLine << L":" << m_playerOptions.m_port; addressLine << L":" << m_playerOptions.m_port;
} }
m_statusDisplay->AddLine(StatusDisplay::Line{addressLine.str(), StatusDisplay::LargeBold, StatusDisplay::White}); m_statusDisplay->AddLine(StatusDisplay::Line{addressLine.str(), StatusDisplay::Large, StatusDisplay::White});
} m_statusDisplay->AddLine(
} StatusDisplay::Line{L"Get help at: https://aka.ms/holographicremotinghelp", StatusDisplay::Small, StatusDisplay::White});
if (m_playerOptions.m_showStatistics) if (m_playerOptions.m_showStatistics)
{ {
m_statusDisplay->AddLine(StatusDisplay::Line{L"Diagnostics Enabled", StatusDisplay::Small, StatusDisplay::Yellow}); m_statusDisplay->AddLine(StatusDisplay::Line{L"Diagnostics Enabled", StatusDisplay::Small, StatusDisplay::Yellow});
} }
}
}
m_errorHelper.Apply(m_statusDisplay); m_errorHelper.Apply(m_statusDisplay);
} }
@ -618,10 +656,27 @@ void SamplePlayerMain::OnCustomDataChannelDataReceived()
// For example: Send back artificial response // For example: Send back artificial response
std::lock_guard customDataChannelLockGuard(m_customDataChannelLock); std::lock_guard customDataChannelLockGuard(m_customDataChannelLock);
if (m_customDataChannel) if (m_customDataChannel)
{
// Get send queue size. The send queue size returns the size of data, that has not been send yet, in bytes. A big number can
// indicate that more data is being queued for sending than is actually getting sent. If possible skip sending data in this
// case, to help the queue getting smaller again.
uint32_t sendQueueSize = m_customDataChannel.SendQueueSize();
// Only send the packet if the send queue is smaller than 1MiB
if (sendQueueSize < 1 * 1024 * 1024)
{ {
uint8_t data[] = {1}; uint8_t data[] = {1};
try
{
m_customDataChannel.SendData(data, true); m_customDataChannel.SendData(data, true);
} }
catch (...)
{
// SendData might throw if channel is closed, but we did not get or process the async closed event yet.
}
}
}
} }
void SamplePlayerMain::OnCustomDataChannelClosed() void SamplePlayerMain::OnCustomDataChannelClosed()
@ -751,6 +806,7 @@ void SamplePlayerMain::OnWindowClosed(const CoreWindow& sender, const CoreWindow
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{ {
winrt::init_apartment(); winrt::init_apartment();
CoreApplication::Run(SamplePlayerMain()); winrt::com_ptr<SamplePlayerMain> main = winrt::make_self<SamplePlayerMain>();
CoreApplication::Run(*main);
return 0; return 0;
} }

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

@ -15,14 +15,12 @@
#include "../common/Content/ErrorHelper.h" #include "../common/Content/ErrorHelper.h"
#include "../common/Content/StatusDisplay.h" #include "../common/Content/StatusDisplay.h"
#include "../common/DeviceResources.h" #include "../common/DeviceResourcesUWP.h"
#include "../common/IpAddressUpdater.h" #include "../common/IpAddressUpdater.h"
#include "../common/PlayerFrameStatisticsHelper.h" #include "../common/PlayerFrameStatisticsHelper.h"
#include <winrt/Microsoft.Holographic.AppRemoting.h> #include <winrt/Microsoft.Holographic.AppRemoting.h>
class SamplePlayerMain : public winrt::implements< class SamplePlayerMain : public winrt::implements<
SamplePlayerMain, SamplePlayerMain,
winrt::Windows::ApplicationModel::Core::IFrameworkViewSource, winrt::Windows::ApplicationModel::Core::IFrameworkViewSource,
@ -30,6 +28,7 @@ class SamplePlayerMain : public winrt::implements<
public DXHelper::IDeviceNotify public DXHelper::IDeviceNotify
{ {
public: public:
SamplePlayerMain();
~SamplePlayerMain(); ~SamplePlayerMain();
// Try to (re-)connect to or listen on the hostname/port, that was set during activation of the app. // Try to (re-)connect to or listen on the hostname/port, that was set during activation of the app.
@ -67,6 +66,7 @@ private:
uint16_t m_port = 0; uint16_t m_port = 0;
bool m_listen = true; bool m_listen = true;
bool m_showStatistics = false; bool m_showStatistics = false;
bool m_ipv6 = false;
}; };
private: private:
@ -107,7 +107,7 @@ private:
private: private:
// Cached pointer to device resources. // Cached pointer to device resources.
std::shared_ptr<DXHelper::DeviceResources> m_deviceResources; std::shared_ptr<DXHelper::DeviceResourcesUWP> m_deviceResources;
// SpatialLocator that is attached to the default HolographicDisplay. // SpatialLocator that is attached to the default HolographicDisplay.
winrt::Windows::Perception::Spatial::SpatialLocator m_spatialLocator = nullptr; winrt::Windows::Perception::Spatial::SpatialLocator m_spatialLocator = nullptr;
@ -139,9 +139,9 @@ private:
#ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE #ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
std::mutex m_customDataChannelLock; std::mutex m_customDataChannelLock;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel m_customDataChannel = nullptr; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2 m_customDataChannel = nullptr;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel::OnDataReceived_revoker m_customChannelDataReceivedEventRevoker; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2::OnDataReceived_revoker m_customChannelDataReceivedEventRevoker;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel::OnClosed_revoker m_customChannelClosedEventRevoker; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2::OnClosed_revoker m_customChannelClosedEventRevoker;
#endif #endif
// Indicates that tracking has been lost // Indicates that tracking has been lost
@ -151,6 +151,8 @@ private:
bool m_windowClosed = false; bool m_windowClosed = false;
bool m_windowVisible = true; bool m_windowVisible = true;
bool m_canCommitDirect3D11DepthBuffer = false;
// Event registration revokers // Event registration revokers
winrt::Windows::Perception::Spatial::SpatialLocator::LocatabilityChanged_revoker m_locatabilityChangedRevoker; winrt::Windows::Perception::Spatial::SpatialLocator::LocatabilityChanged_revoker m_locatabilityChangedRevoker;
winrt::Windows::ApplicationModel::Core::CoreApplication::Suspending_revoker m_suspendingEventRevoker; winrt::Windows::ApplicationModel::Core::CoreApplication::Suspending_revoker m_suspendingEventRevoker;

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

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Microsoft.Holographic.Remoting" version="2.0.14" targetFramework="native" /> <package id="Microsoft.Windows.CppWinRT" version="2.0.200224.2" targetFramework="native" />
<package id="Microsoft.Holographic.Remoting" version="2.1.0" targetFramework="native" />
</packages> </packages>

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

@ -0,0 +1,269 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include "CameraResources.h"
#include "DeviceResources.h"
#include "DirectXHelper.h"
#include <windows.graphics.directx.direct3d11.interop.h>
using namespace DirectX;
using namespace winrt::Windows::Graphics::Holographic;
using namespace winrt::Windows::Perception::Spatial;
namespace DXHelper
{
CameraResources::CameraResources(const HolographicCamera& camera)
: m_holographicCamera(camera)
, m_isStereo(camera.IsStereo())
, m_d3dRenderTargetSize(camera.RenderTargetSize())
{
m_d3dViewport = CD3D11_VIEWPORT(0.f, 0.f, m_d3dRenderTargetSize.Width, m_d3dRenderTargetSize.Height);
};
// Updates resources associated with a holographic camera's swap chain.
// The app does not access the swap chain directly, but it does create
// resource views for the back buffer.
void CameraResources::CreateResourcesForBackBuffer(
DeviceResources* pDeviceResources, const HolographicCameraRenderingParameters& cameraParameters)
{
const auto device = pDeviceResources->GetD3DDevice();
// Get a DXGI interface for the holographic camera's back buffer.
// Holographic cameras do not provide the DXGI swap chain, which is owned
// by the system. The Direct3D back buffer resource is provided using WinRT
// interop APIs.
winrt::com_ptr<ID3D11Resource> resource;
{
winrt::com_ptr<::IInspectable> inspectable = cameraParameters.Direct3D11BackBuffer().as<::IInspectable>();
winrt::com_ptr<Windows::Graphics::DirectX::Direct3D11::IDirect3DDxgiInterfaceAccess> dxgiInterfaceAccess;
HRESULT hr = inspectable->QueryInterface(__uuidof(dxgiInterfaceAccess), dxgiInterfaceAccess.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
hr = dxgiInterfaceAccess->GetInterface(__uuidof(resource), resource.put_void());
if (FAILED(hr))
{
winrt::throw_hresult(hr);
}
}
// Get a Direct3D interface for the holographic camera's back buffer.
winrt::com_ptr<ID3D11Texture2D> cameraBackBuffer;
resource.as(cameraBackBuffer);
// Determine if the back buffer has changed. If so, ensure that the render target view
// is for the current back buffer.
if (m_d3dBackBuffer != cameraBackBuffer)
{
// This can change every frame as the system moves to the next buffer in the
// swap chain. This mode of operation will occur when certain rendering modes
// are activated.
m_d3dBackBuffer = cameraBackBuffer;
// Get the DXGI format for the back buffer.
// This information can be accessed by the app using CameraResources::GetBackBufferDXGIFormat().
D3D11_TEXTURE2D_DESC backBufferDesc;
m_d3dBackBuffer->GetDesc(&backBufferDesc);
m_dxgiFormat = backBufferDesc.Format;
D3D11_RENDER_TARGET_VIEW_DESC viewDesc = {};
viewDesc.ViewDimension = backBufferDesc.ArraySize > 1 ? D3D11_RTV_DIMENSION_TEXTURE2DARRAY : D3D11_RTV_DIMENSION_TEXTURE2D;
viewDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
if (backBufferDesc.ArraySize > 1)
{
viewDesc.Texture2DArray.ArraySize = backBufferDesc.ArraySize;
}
// Create a render target view of the back buffer.
// Creating this resource is inexpensive, and is better than keeping track of
// the back buffers in order to pre-allocate render target views for each one.
m_d3dRenderTargetView = nullptr;
winrt::check_hresult(device->CreateRenderTargetView(m_d3dBackBuffer.get(), &viewDesc, m_d3dRenderTargetView.put()));
// Check for render target size changes.
winrt::Windows::Foundation::Size currentSize = m_holographicCamera.RenderTargetSize();
if (m_d3dRenderTargetSize != currentSize)
{
// Set render target size.
m_d3dRenderTargetSize = currentSize;
// A new depth stencil view is also needed.
m_d3dDepthStencilView = nullptr;
}
}
// Refresh depth stencil resources, if needed.
if (m_d3dDepthStencilView == nullptr)
{
// Create a depth stencil view for use with 3D rendering if needed.
CD3D11_TEXTURE2D_DESC depthStencilDesc(
DXGI_FORMAT_R16_TYPELESS,
static_cast<UINT>(m_d3dRenderTargetSize.Width),
static_cast<UINT>(m_d3dRenderTargetSize.Height),
m_isStereo ? 2 : 1, // Create two textures when rendering in stereo.
1, // Use a single mipmap level.
D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE);
winrt::check_hresult(device->CreateTexture2D(&depthStencilDesc, nullptr, m_d3dDepthStencil.put()));
CD3D11_DEPTH_STENCIL_VIEW_DESC depthStencilViewDesc(
m_isStereo ? D3D11_DSV_DIMENSION_TEXTURE2DARRAY : D3D11_DSV_DIMENSION_TEXTURE2D);
depthStencilViewDesc.Format = DXGI_FORMAT_D16_UNORM;
winrt::check_hresult(
device->CreateDepthStencilView(m_d3dDepthStencil.get(), &depthStencilViewDesc, m_d3dDepthStencilView.put()));
}
// Create the constant buffer, if needed.
if (m_viewProjectionConstantBuffer == nullptr)
{
// Create a constant buffer to store view and projection matrices for the camera.
CD3D11_BUFFER_DESC constantBufferDesc(sizeof(ViewProjectionConstantBuffer), D3D11_BIND_CONSTANT_BUFFER);
winrt::check_hresult(device->CreateBuffer(&constantBufferDesc, nullptr, m_viewProjectionConstantBuffer.put()));
}
}
// Releases resources associated with a back buffer.
void CameraResources::ReleaseResourcesForBackBuffer(DeviceResources* pDeviceResources)
{
// Release camera-specific resources.
m_d3dBackBuffer = nullptr;
m_d3dDepthStencil = nullptr;
m_d3dRenderTargetView = nullptr;
m_d3dDepthStencilView = nullptr;
m_viewProjectionConstantBuffer = nullptr;
// Ensure system references to the back buffer are released by clearing the render
// target from the graphics pipeline state, and then flushing the Direct3D context.
pDeviceResources->UseD3DDeviceContext([](auto context) {
ID3D11RenderTargetView* nullViews[D3D11_SIMULTANEOUS_RENDER_TARGET_COUNT] = {nullptr};
context->OMSetRenderTargets(ARRAYSIZE(nullViews), nullViews, nullptr);
context->Flush();
});
}
// Updates the view/projection constant buffer for a holographic camera.
void CameraResources::UpdateViewProjectionBuffer(
std::shared_ptr<DeviceResources> deviceResources,
const HolographicCameraPose& cameraPose,
const SpatialCoordinateSystem& coordinateSystem)
{
// The system changes the viewport on a per-frame basis for system optimizations.
m_d3dViewport =
CD3D11_VIEWPORT(cameraPose.Viewport().X, cameraPose.Viewport().Y, cameraPose.Viewport().Width, cameraPose.Viewport().Height);
// The projection transform for each frame is provided by the HolographicCameraPose.
auto cameraProjectionTransform = cameraPose.ProjectionTransform();
// Get a container object with the view and projection matrices for the given
// pose in the given coordinate system.
auto viewTransformContainer = cameraPose.TryGetViewTransform(coordinateSystem);
// If TryGetViewTransform returns a null pointer, that means the pose and coordinate
// system cannot be understood relative to one another; content cannot be rendered
// in this coordinate system for the duration of the current frame.
// This usually means that positional tracking is not active for the current frame, in
// which case it is possible to use a SpatialLocatorAttachedFrameOfReference to render
// content that is not world-locked instead.
ViewProjectionConstantBuffer viewProjectionConstantBufferData = {};
bool viewTransformAcquired = viewTransformContainer != nullptr;
if (viewTransformAcquired)
{
// Otherwise, the set of view transforms can be retrieved.
auto viewCoordinateSystemTransform = viewTransformContainer.Value();
// Update the view matrices. Holographic cameras (such as Microsoft HoloLens) are
// constantly moving relative to the world. The view matrices need to be updated
// every frame.
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[0],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Left) * XMLoadFloat4x4(&cameraProjectionTransform.Left)));
XMStoreFloat4x4(
&viewProjectionConstantBufferData.viewProjection[1],
XMMatrixTranspose(XMLoadFloat4x4(&viewCoordinateSystemTransform.Right) * XMLoadFloat4x4(&cameraProjectionTransform.Right)));
}
// Use the D3D device context to update Direct3D device-based resources.
deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || !viewTransformAcquired)
{
m_framePending = false;
}
else
{
// Update the view and projection matrices.
context->UpdateSubresource(m_viewProjectionConstantBuffer.get(), 0, nullptr, &viewProjectionConstantBufferData, 0, 0);
m_framePending = true;
}
});
}
// Gets the view-projection constant buffer for the HolographicCamera and attaches it
// to the shader pipeline.
bool CameraResources::AttachViewProjectionBuffer(std::shared_ptr<DeviceResources> deviceResources)
{
// This method uses Direct3D device-based resources.
return deviceResources->UseD3DDeviceContext([&](auto context) {
// Loading is asynchronous. Resources must be created before they can be updated.
// Cameras can also be added asynchronously, in which case they must be initialized
// before they can be used.
if (context == nullptr || m_viewProjectionConstantBuffer == nullptr || m_framePending == false)
{
return false;
}
// Set the viewport for this camera.
context->RSSetViewports(1, &m_d3dViewport);
// Send the constant buffer to the vertex shader.
ID3D11Buffer* pBuffer = m_viewProjectionConstantBuffer.get();
context->VSSetConstantBuffers(1, 1, &pBuffer);
// The template includes a pass-through geometry shader that is used by
// default on systems that don't support the D3D11_FEATURE_D3D11_OPTIONS3::
// VPAndRTArrayIndexFromAnyShaderFeedingRasterizer extension. The shader
// will be enabled at run-time on systems that require it.
// If your app will also use the geometry shader for other tasks and those
// tasks require the view/projection matrix, uncomment the following line
// of code to send the constant buffer to the geometry shader as well.
/*context->GSSetConstantBuffers(
1,
1,
m_viewProjectionConstantBuffer.GetAddressOf()
);*/
m_framePending = false;
return true;
});
}
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface CameraResources::GetDepthStencilTextureInteropObject()
{
// Direct3D interop APIs are used to provide the buffer to the WinRT API.
winrt::com_ptr<IDXGIResource1> depthStencilResource;
winrt::check_bool(m_d3dDepthStencil.try_as(depthStencilResource));
winrt::com_ptr<IDXGISurface2> depthDxgiSurface;
winrt::check_hresult(depthStencilResource->CreateSubresourceSurface(0, depthDxgiSurface.put()));
winrt::com_ptr<::IInspectable> inspectableSurface;
winrt::check_hresult(CreateDirect3D11SurfaceFromDXGISurface(
depthDxgiSurface.get(), reinterpret_cast<IInspectable**>(winrt::put_abi(inspectableSurface))));
return inspectableSurface.as<winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface>();
}
} // namespace DXHelper

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

@ -64,6 +64,10 @@ namespace DXHelper
{ {
return m_d3dBackBuffer.get(); return m_d3dBackBuffer.get();
} }
ID3D11Texture2D* GetDepthStencilTexture2D() const
{
return m_d3dDepthStencil.get();
}
D3D11_VIEWPORT GetViewport() const D3D11_VIEWPORT GetViewport() const
{ {
return m_d3dViewport; return m_d3dViewport;
@ -89,19 +93,22 @@ namespace DXHelper
return m_holographicCamera; return m_holographicCamera;
} }
winrt::Windows::Graphics::DirectX::Direct3D11::IDirect3DSurface GetDepthStencilTextureInteropObject();
private: private:
// Direct3D rendering objects. Required for 3D. // Direct3D rendering objects. Required for 3D.
winrt::com_ptr<ID3D11RenderTargetView> m_d3dRenderTargetView; winrt::com_ptr<ID3D11RenderTargetView> m_d3dRenderTargetView;
winrt::com_ptr<ID3D11DepthStencilView> m_d3dDepthStencilView; winrt::com_ptr<ID3D11DepthStencilView> m_d3dDepthStencilView;
winrt::com_ptr<ID3D11Texture2D> m_d3dBackBuffer; winrt::com_ptr<ID3D11Texture2D> m_d3dBackBuffer;
winrt::com_ptr<ID3D11Texture2D> m_d3dDepthStencil;
// Device resource to store view and projection matrices. // Device resource to store view and projection matrices.
winrt::com_ptr<ID3D11Buffer> m_viewProjectionConstantBuffer; winrt::com_ptr<ID3D11Buffer> m_viewProjectionConstantBuffer;
// Direct3D rendering properties. // Direct3D rendering properties.
DXGI_FORMAT m_dxgiFormat; DXGI_FORMAT m_dxgiFormat = DXGI_FORMAT_UNKNOWN;
winrt::Windows::Foundation::Size m_d3dRenderTargetSize; winrt::Windows::Foundation::Size m_d3dRenderTargetSize = {};
D3D11_VIEWPORT m_d3dViewport; D3D11_VIEWPORT m_d3dViewport = {};
// Indicates whether the camera supports stereoscopic rendering. // Indicates whether the camera supports stereoscopic rendering.
bool m_isStereo = false; bool m_isStereo = false;

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

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

@ -125,7 +125,8 @@ void DXHelper::DeviceResources::CreateDeviceResources()
// Note the ordering should be preserved. // Note the ordering should be preserved.
// Note that HoloLens supports feature level 11.1. The HoloLens emulator is also capable // Note that HoloLens supports feature level 11.1. The HoloLens emulator is also capable
// of running on graphics cards starting with feature level 10.0. // of running on graphics cards starting with feature level 10.0.
D3D_FEATURE_LEVEL featureLevels[] = {D3D_FEATURE_LEVEL_12_1, D3D_FEATURE_LEVEL featureLevels[] = {
D3D_FEATURE_LEVEL_12_1,
D3D_FEATURE_LEVEL_12_0, D3D_FEATURE_LEVEL_12_0,
D3D_FEATURE_LEVEL_11_1, D3D_FEATURE_LEVEL_11_1,
D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_11_0,
@ -288,7 +289,7 @@ void DXHelper::DeviceResources::Trim()
void DXHelper::DeviceResources::Present(HolographicFrame frame) void DXHelper::DeviceResources::Present(HolographicFrame frame)
{ {
// By default, this API waits for the frame to finish before it returns. // By default, this API waits for the frame to finish before it returns.
// For Holographic Remoting we do not wait but instead wait in SampleHostMain::Update to ensure that CreateNextFrame is called exactly // For Holographic Remoting we do not wait but instead wait in SampleRemoteMain::Update to ensure that CreateNextFrame is called exactly
// with a delta of 16.6ms (in case of 60Hz). // with a delta of 16.6ms (in case of 60Hz).
HolographicFramePresentResult presentResult = HolographicFramePresentResult presentResult =
frame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior::DoNotWaitForFrameToFinish); frame.PresentUsingCurrentPrediction(HolographicFramePresentWaitBehavior::DoNotWaitForFrameToFinish);

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

@ -16,6 +16,7 @@
#include <d2d1_2.h> #include <d2d1_2.h>
#include <d3d11_4.h> #include <d3d11_4.h>
#include <dwrite_2.h> #include <dwrite_2.h>
#include <mutex>
#include <wincodec.h> #include <wincodec.h>
#include <wrl/client.h> #include <wrl/client.h>

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

@ -22,6 +22,8 @@
#include <windows.graphics.directx.direct3d11.interop.h> #include <windows.graphics.directx.direct3d11.interop.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <d3d11.h> #include <d3d11.h>
#include <dxgi1_2.h> #include <dxgi1_2.h>
@ -38,7 +40,7 @@ namespace DXHelper
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
wchar_t moduleFullyQualifiedFilename[MAX_PATH] = {}; wchar_t moduleFullyQualifiedFilename[MAX_PATH] = {};
uint32_t moduleFileNameLength = GetModuleFileNameW(NULL, moduleFullyQualifiedFilename, _countof(moduleFullyQualifiedFilename)); uint32_t moduleFileNameLength = GetModuleFileNameW(NULL, moduleFullyQualifiedFilename, _countof(moduleFullyQualifiedFilename) - 1);
moduleFullyQualifiedFilename[moduleFileNameLength] = L'\0'; moduleFullyQualifiedFilename[moduleFileNameLength] = L'\0';
std::filesystem::path modulePath = moduleFullyQualifiedFilename; std::filesystem::path modulePath = moduleFullyQualifiedFilename;

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

@ -20,7 +20,6 @@ DEFINE_GUID(SPATIALPROP_QRCode_PhysicalSize, 0xcfb07ae5, 0x456a, 0x4aaf, 0x9d, 0
DEFINE_GUID(SPATIALPROP_QRCode_LastSeenTime, 0xb2b08c2d, 0xb531, 0x4f18, 0x87, 0x84, 0x44, 0x84, 0x46, 0x3d, 0x88, 0x53); DEFINE_GUID(SPATIALPROP_QRCode_LastSeenTime, 0xb2b08c2d, 0xb531, 0x4f18, 0x87, 0x84, 0x44, 0x84, 0x46, 0x3d, 0x88, 0x53);
DEFINE_GUID(SPATIALPROP_QRCode_StreamInfo, 0x609143ea, 0x4ec5, 0x4b0e, 0xba, 0xef, 0x52, 0xa5, 0x5c, 0xfc, 0x23, 0x58); DEFINE_GUID(SPATIALPROP_QRCode_StreamInfo, 0x609143ea, 0x4ec5, 0x4b0e, 0xba, 0xef, 0x52, 0xa5, 0x5c, 0xfc, 0x23, 0x58);
#pragma pack(push, 1) #pragma pack(push, 1)
typedef struct SPATIAL_GRAPH_QR_CODE_STREAM_INFO typedef struct SPATIAL_GRAPH_QR_CODE_STREAM_INFO
{ {

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

@ -11,7 +11,7 @@
#include "pch.h" #include "pch.h"
#include "SampleHostMain.h" #include "SampleRemoteMain.h"
#include "Speech.h" #include "Speech.h"
#include <windows.h> #include <windows.h>
@ -47,13 +47,13 @@ namespace
winrt::fire_and_forget Speech::InitializeSpeechAsync( winrt::fire_and_forget Speech::InitializeSpeechAsync(
winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech remoteSpeech, winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech remoteSpeech,
winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech::OnRecognizedSpeech_revoker& onRecognizedSpeechRevoker, winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech::OnRecognizedSpeech_revoker& onRecognizedSpeechRevoker,
std::weak_ptr<SampleHostMain> sampleHostMainWeak) std::weak_ptr<SampleRemoteMain> sampleRemoteMainWeak)
{ {
onRecognizedSpeechRevoker = remoteSpeech.OnRecognizedSpeech( onRecognizedSpeechRevoker = remoteSpeech.OnRecognizedSpeech(
winrt::auto_revoke, [sampleHostMainWeak](const winrt::Microsoft::Holographic::AppRemoting::RecognizedSpeech& recognizedSpeech) { winrt::auto_revoke, [sampleRemoteMainWeak](const winrt::Microsoft::Holographic::AppRemoting::RecognizedSpeech& recognizedSpeech) {
if (auto sampleHostMain = sampleHostMainWeak.lock()) if (auto sampleRemoteMain = sampleRemoteMainWeak.lock())
{ {
sampleHostMain->OnRecognizedSpeech(recognizedSpeech.RecognizedText); sampleRemoteMain->OnRecognizedSpeech(recognizedSpeech.RecognizedText);
} }
}); });

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

@ -16,13 +16,12 @@
#include <winrt/Microsoft.Holographic.AppRemoting.h> #include <winrt/Microsoft.Holographic.AppRemoting.h>
#include <winrt/Windows.Foundation.h> #include <winrt/Windows.Foundation.h>
class SampleRemoteMain;
class SampleHostMain;
namespace Speech namespace Speech
{ {
winrt::fire_and_forget InitializeSpeechAsync( winrt::fire_and_forget InitializeSpeechAsync(
winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech remoteSpeech, winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech remoteSpeech,
winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech::OnRecognizedSpeech_revoker& onRecognizedSpeechRevoker, winrt::Microsoft::Holographic::AppRemoting::IRemoteSpeech::OnRecognizedSpeech_revoker& onRecognizedSpeechRevoker,
std::weak_ptr<SampleHostMain> sampleHostMainWeak); std::weak_ptr<SampleRemoteMain> sampleRemoteMainWeak);
} }

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

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

@ -16,7 +16,6 @@
#include "PerceptionDeviceHandler.h" #include "PerceptionDeviceHandler.h"
#include "QRCodeTracker.h" #include "QRCodeTracker.h"
PerceptionRootObject::~PerceptionRootObject() PerceptionRootObject::~PerceptionRootObject()
{ {
} }
@ -38,8 +37,6 @@ PerceptionRootObject::PerceptionRootObject(IPerceptionDevice* device, const GUID
m_device.copy_from(device); m_device.copy_from(device);
} }
PerceptionDeviceHandler::PerceptionDeviceHandler() PerceptionDeviceHandler::PerceptionDeviceHandler()
{ {
} }
@ -167,8 +164,6 @@ HRESULT PerceptionDeviceHandler::HandleRootObjectRemoved(IPerceptionDeviceRootOb
return S_OK; return S_OK;
} }
PerceptionDeviceHandler::RootObjectChangeHandler::RootObjectChangeHandler(PerceptionDeviceHandler& owner) PerceptionDeviceHandler::RootObjectChangeHandler::RootObjectChangeHandler(PerceptionDeviceHandler& owner)
: m_weakOwner(owner.weak_from_this()) : m_weakOwner(owner.weak_from_this())
{ {
@ -198,8 +193,6 @@ STDMETHODIMP PerceptionDeviceHandler::RootObjectChangeHandler::Invoke(
return S_OK; return S_OK;
} }
bool PerceptionDeviceHandler::RootObjectKey::operator<(const RootObjectKey& other) const bool PerceptionDeviceHandler::RootObjectKey::operator<(const RootObjectKey& other) const
{ {
const auto typeIdRes = GUIDComparer::compare(propertyId, other.propertyId); const auto typeIdRes = GUIDComparer::compare(propertyId, other.propertyId);

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

@ -11,13 +11,13 @@
#pragma once #pragma once
#include <mutex>
#include <vector> #include <vector>
#include <winrt/Windows.UI.Input.Spatial.h> #include <winrt/Windows.UI.Input.Spatial.h>
#include <PerceptionDevice.h> #include <PerceptionDevice.h>
// Base class for perception root objects managed by the PerceptionDeviceHandler // Base class for perception root objects managed by the PerceptionDeviceHandler
class PerceptionRootObject class PerceptionRootObject
{ {
@ -76,7 +76,6 @@ public:
} }
} }
private: private:
struct RootObjectChangeHandler struct RootObjectChangeHandler
: winrt::implements<RootObjectChangeHandler, IPerceptionDeviceRootObjectAddedHandler, IPerceptionDeviceRootObjectRemovedHandler> : winrt::implements<RootObjectChangeHandler, IPerceptionDeviceRootObjectAddedHandler, IPerceptionDeviceRootObjectRemovedHandler>
@ -103,7 +102,6 @@ private:
using RootObjectMap = std::map<RootObjectKey, std::shared_ptr<PerceptionRootObject>>; using RootObjectMap = std::map<RootObjectKey, std::shared_ptr<PerceptionRootObject>>;
private: private:
HRESULT HandleRootObjectAdded(IPerceptionDeviceRootObjectAddedEventArgs* args); HRESULT HandleRootObjectAdded(IPerceptionDeviceRootObjectAddedEventArgs* args);
HRESULT HandleRootObjectRemoved(IPerceptionDeviceRootObjectRemovedEventArgs* args); HRESULT HandleRootObjectRemoved(IPerceptionDeviceRootObjectRemovedEventArgs* args);

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

@ -17,6 +17,8 @@
#include "QRCodeRenderer.h" #include "QRCodeRenderer.h"
#include "QRCodeTracker.h" #include "QRCodeTracker.h"
#include <winrt/Windows.Perception.Spatial.h>
namespace namespace
{ {
using namespace DirectX; using namespace DirectX;
@ -41,7 +43,6 @@ namespace
} }
} // namespace } // namespace
QRCodeRenderer::QRCodeRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources) QRCodeRenderer::QRCodeRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources)
: RenderableObject(deviceResources) : RenderableObject(deviceResources)
{ {

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

@ -17,7 +17,6 @@
#include <set> #include <set>
QRCode::QRCode( QRCode::QRCode(
const GUID& id, const GUID& id,
PSPATIAL_GRAPH_QR_CODE_STREAM_INFO streamInfo, PSPATIAL_GRAPH_QR_CODE_STREAM_INFO streamInfo,
@ -51,8 +50,6 @@ winrt::Windows::Perception::Spatial::SpatialCoordinateSystem QRCode::GetCoordina
return m_coordinateSystem; return m_coordinateSystem;
} }
QRCodeTracker::QRCodeTracker(IPerceptionDevice* device, const GUID& typeId, const GUID& objectId) QRCodeTracker::QRCodeTracker(IPerceptionDevice* device, const GUID& typeId, const GUID& objectId)
: PerceptionRootObject(device, typeId, objectId) : PerceptionRootObject(device, typeId, objectId)
{ {
@ -312,8 +309,6 @@ HRESULT QRCodeTracker::UpdateQRCode(QRCode& qrCode)
return S_OK; return S_OK;
} }
QRCodeTracker::PropertyChangeHandler::PropertyChangeHandler(QRCodeTracker& owner) QRCodeTracker::PropertyChangeHandler::PropertyChangeHandler(QRCodeTracker& owner)
: m_owner(&owner) : m_owner(&owner)
{ {

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

@ -15,7 +15,6 @@
#include "../Common/DirectXHelper.h" #include "../Common/DirectXHelper.h"
RenderableObject::RenderableObject(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources) RenderableObject::RenderableObject(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources)
: m_deviceResources(deviceResources) : m_deviceResources(deviceResources)
{ {

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

@ -44,7 +44,6 @@ namespace
} }
} // namespace } // namespace
// Struct to hold one entity label type entry // Struct to hold one entity label type entry
struct Label struct Label
{ {

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

@ -23,7 +23,6 @@ static_assert(
(sizeof(ModelConstantBuffer) % (sizeof(float) * 4)) == 0, (sizeof(ModelConstantBuffer) % (sizeof(float) * 4)) == 0,
"Model constant buffer size must be 16-byte aligned (16 bytes is the length of four floats)."); "Model constant buffer size must be 16-byte aligned (16 bytes is the length of four floats).");
// Used to send per-vertex data to the vertex shader. // Used to send per-vertex data to the vertex shader.
struct VertexPositionNormalColor struct VertexPositionNormalColor
{ {

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

@ -13,14 +13,13 @@
#include "SpatialInputHandler.h" #include "SpatialInputHandler.h"
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.UI.Input.Spatial.h> #include <winrt/Windows.UI.Input.Spatial.h>
// Creates and initializes a GestureRecognizer that listens to a Person. // Creates and initializes a GestureRecognizer that listens to a Person.
SpatialInputHandler::SpatialInputHandler() SpatialInputHandler::SpatialInputHandler(winrt::Windows::UI::Input::Spatial::SpatialInteractionManager interactionManager)
: m_interactionManager(interactionManager)
{ {
// The interaction manager provides an event that informs the app when spatial interactions are detected.
m_interactionManager = winrt::Windows::UI::Input::Spatial::SpatialInteractionManager::GetForCurrentView();
m_gestureRecognizer = winrt::Windows::UI::Input::Spatial::SpatialGestureRecognizer( m_gestureRecognizer = winrt::Windows::UI::Input::Spatial::SpatialGestureRecognizer(
winrt::Windows::UI::Input::Spatial::SpatialGestureSettings::Tap | winrt::Windows::UI::Input::Spatial::SpatialGestureSettings::Tap |
winrt::Windows::UI::Input::Spatial::SpatialGestureSettings::ManipulationTranslate); winrt::Windows::UI::Input::Spatial::SpatialGestureSettings::ManipulationTranslate);
@ -88,8 +87,6 @@ SpatialInputHandler::SpatialInputHandler()
m_manipulationResult = ManipulationResult::Canceled; m_manipulationResult = ManipulationResult::Canceled;
})); }));
m_navigationStartedEventToken = m_navigationStartedEventToken =
m_gestureRecognizer.NavigationStarted(winrt::Windows::Foundation::TypedEventHandler< m_gestureRecognizer.NavigationStarted(winrt::Windows::Foundation::TypedEventHandler<
winrt::Windows::UI::Input::Spatial::SpatialGestureRecognizer, winrt::Windows::UI::Input::Spatial::SpatialGestureRecognizer,

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

@ -10,16 +10,16 @@
//********************************************************* //*********************************************************
#pragma once #pragma once
#include <mutex>
#include <vector> #include <vector>
#include <winrt/Windows.UI.Input.Spatial.h> #include <winrt/Windows.UI.Input.Spatial.h>
// Sample gesture handler. // Sample gesture handler.
// Hooks up events to recognize a tap gesture, and keeps track of input using a boolean value. // Hooks up events to recognize a tap gesture, and keeps track of input using a boolean value.
class SpatialInputHandler class SpatialInputHandler
{ {
public: public:
SpatialInputHandler(); SpatialInputHandler(winrt::Windows::UI::Input::Spatial::SpatialInteractionManager interactionManager);
~SpatialInputHandler(); ~SpatialInputHandler();
enum class ManipulationResult enum class ManipulationResult

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

@ -13,6 +13,7 @@
#include "SpatialInputRenderer.h" #include "SpatialInputRenderer.h"
#include <winrt/Windows.Devices.Haptics.h>
#include <winrt/Windows.Foundation.Numerics.h> #include <winrt/Windows.Foundation.Numerics.h>
#include <winrt/Windows.Perception.People.h> #include <winrt/Windows.Perception.People.h>
#include <winrt/Windows.Perception.Spatial.h> #include <winrt/Windows.Perception.Spatial.h>
@ -20,6 +21,9 @@
#include "../Common/DirectXHelper.h" #include "../Common/DirectXHelper.h"
#include <algorithm> #include <algorithm>
#include <sstream>
#include <winrt/Windows.Devices.Power.h>
namespace namespace
{ {
using namespace DirectX; using namespace DirectX;
@ -39,10 +43,12 @@ namespace
} }
} // namespace } // namespace
SpatialInputRenderer::SpatialInputRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources) SpatialInputRenderer::SpatialInputRenderer(
const std::shared_ptr<DXHelper::DeviceResources>& deviceResources,
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager interactionManager)
: RenderableObject(deviceResources) : RenderableObject(deviceResources)
, m_interactionManager(interactionManager)
{ {
m_manager = winrt::Windows::UI::Input::Spatial::SpatialInteractionManager::GetForCurrentView();
m_referenceFrame = winrt::Windows::Perception::Spatial::SpatialLocator::GetDefault().CreateAttachedFrameOfReferenceAtCurrentHeading(); m_referenceFrame = winrt::Windows::Perception::Spatial::SpatialLocator::GetDefault().CreateAttachedFrameOfReferenceAtCurrentHeading();
} }
@ -56,6 +62,7 @@ void SpatialInputRenderer::Update(
auto headingAdjustment = m_referenceFrame.TryGetRelativeHeadingAtTimestamp(timestamp); auto headingAdjustment = m_referenceFrame.TryGetRelativeHeadingAtTimestamp(timestamp);
if (headingAdjustment) if (headingAdjustment)
{ {
// keep coordinate systems facing user // keep coordinate systems facing user
m_referenceFrame.AdjustHeading(-headingAdjustment.Value()); m_referenceFrame.AdjustHeading(-headingAdjustment.Value());
auto coordinateSystem = m_referenceFrame.GetStationaryCoordinateSystemAtTimestamp(timestamp); auto coordinateSystem = m_referenceFrame.GetStationaryCoordinateSystemAtTimestamp(timestamp);
@ -74,12 +81,14 @@ void SpatialInputRenderer::Update(
} }
} }
auto states = m_manager.GetDetectedSourcesAtTimestamp(timestamp); auto states = m_interactionManager.GetDetectedSourcesAtTimestamp(timestamp);
m_transforms.reserve(states.Size()); m_transforms.reserve(states.Size());
for (const auto& state : states) for (const auto& state : states)
{ {
auto location = state.Properties().TryGetLocation(coordinateSystem); auto location = state.Properties().TryGetLocation(coordinateSystem);
QTransform currentTransform(float3::zero(), quaternion::identity());
if (location) if (location)
{ {
if (location.Position()) if (location.Position())
@ -96,7 +105,8 @@ void SpatialInputRenderer::Update(
DirectX::XMVECTOR xmPosition = DirectX::XMLoadFloat3(&position); DirectX::XMVECTOR xmPosition = DirectX::XMLoadFloat3(&position);
DirectX::XMVECTOR xmOrientation = DirectX::XMLoadQuaternion(&orientation); DirectX::XMVECTOR xmOrientation = DirectX::XMLoadQuaternion(&orientation);
m_transforms.emplace_back(QTransform(xmPosition, xmOrientation)); currentTransform = QTransform(xmPosition, xmOrientation);
m_transforms.push_back(currentTransform);
} }
if (auto sourcePose = location.SourcePointerPose()) if (auto sourcePose = location.SourcePointerPose())
@ -142,7 +152,8 @@ void SpatialInputRenderer::Update(
{ {
for (size_t jointIndex = 0; jointIndex < jointCount; ++jointIndex) for (size_t jointIndex = 0; jointIndex < jointCount; ++jointIndex)
{ {
m_joints.push_back({jointPoses[jointIndex].Position, m_joints.push_back(
{jointPoses[jointIndex].Position,
jointPoses[jointIndex].Orientation, jointPoses[jointIndex].Orientation,
jointPoses[jointIndex].Radius * 3, jointPoses[jointIndex].Radius * 3,
jointPoses[jointIndex].Radius}); jointPoses[jointIndex].Radius});
@ -183,6 +194,26 @@ void SpatialInputRenderer::Draw(unsigned int numInstances)
vertices.insert(vertices.end(), jointVertices.begin(), jointVertices.end()); vertices.insert(vertices.end(), jointVertices.begin(), jointVertices.end());
} }
for (const auto& coloredTransform : m_coloredTransforms)
{
DirectX::XMFLOAT3 quadPositions[4] = {
DirectX::XMFLOAT3(-0.01f, 0.0f, -0.01f),
DirectX::XMFLOAT3(0.01f, 0.0f, -0.01f),
DirectX::XMFLOAT3(0.01f, 0.0f, 0.01f),
DirectX::XMFLOAT3(-0.01f, 0.0f, 0.01f)};
DirectX::XMFLOAT3 transformedPositions[4];
for (uint32_t i = 0; i < 4; ++i)
{
transformedPositions[i] = coloredTransform.m_transform.TransformPosition(quadPositions[i]);
}
AppendColoredTriangle(
transformedPositions[0], transformedPositions[1], transformedPositions[2], coloredTransform.m_color, vertices);
AppendColoredTriangle(
transformedPositions[2], transformedPositions[3], transformedPositions[0], coloredTransform.m_color, vertices);
}
const UINT stride = sizeof(vertices[0]); const UINT stride = sizeof(vertices[0]);
const UINT offset = 0; const UINT offset = 0;
D3D11_SUBRESOURCE_DATA vertexBufferData = {0}; D3D11_SUBRESOURCE_DATA vertexBufferData = {0};
@ -201,7 +232,6 @@ void SpatialInputRenderer::Draw(unsigned int numInstances)
} }
} }
std::vector<VertexPositionNormalColor> SpatialInputRenderer::CalculateJointVisualizationVertices( std::vector<VertexPositionNormalColor> SpatialInputRenderer::CalculateJointVisualizationVertices(
float3 jointPosition, quaternion jointOrientation, float jointLength, float jointRadius) float3 jointPosition, quaternion jointOrientation, float jointLength, float jointRadius)
{ {

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

@ -31,7 +31,6 @@ struct QTransform
{ {
} }
DirectX::XMVECTOR TransformNormal(const DirectX::XMVECTOR& normal) const DirectX::XMVECTOR TransformNormal(const DirectX::XMVECTOR& normal) const
{ {
return DirectX::XMVector3Rotate(normal, m_orientation); return DirectX::XMVector3Rotate(normal, m_orientation);
@ -50,6 +49,13 @@ struct QTransform
return result; return result;
} }
float3 TransformPosition(const float3& position) const
{
DirectX::XMFLOAT3 temp;
XMStoreFloat3(&temp, TransformPosition(DirectX::XMLoadFloat3(&position)));
return float3(temp.x, temp.y, temp.z);
}
DirectX::XMVECTOR m_position; DirectX::XMVECTOR m_position;
DirectX::XMVECTOR m_orientation; DirectX::XMVECTOR m_orientation;
}; };
@ -57,7 +63,9 @@ struct QTransform
class SpatialInputRenderer : public RenderableObject class SpatialInputRenderer : public RenderableObject
{ {
public: public:
SpatialInputRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources); SpatialInputRenderer(
const std::shared_ptr<DXHelper::DeviceResources>& deviceResources,
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager interactionManager);
void Update( void Update(
winrt::Windows::Perception::PerceptionTimestamp timestamp, winrt::Windows::Perception::PerceptionTimestamp timestamp,
@ -72,14 +80,31 @@ private:
float radius; float radius;
}; };
struct ColoredTransform
{
ColoredTransform(const QTransform& transform, const DirectX::XMFLOAT3& color)
: m_transform(transform)
, m_color(color)
{
}
ColoredTransform(const float3& position, const quaternion& orientation, const DirectX::XMFLOAT3& colorIn)
: m_transform(position, orientation)
, m_color(colorIn)
{
}
QTransform m_transform;
DirectX::XMFLOAT3 m_color;
};
private: private:
static std::vector<VertexPositionNormalColor> static std::vector<VertexPositionNormalColor>
CalculateJointVisualizationVertices(float3 jointPosition, quaternion jointOrientation, float jointLength, float jointRadius); CalculateJointVisualizationVertices(float3 jointPosition, quaternion jointOrientation, float jointLength, float jointRadius);
void Draw(unsigned int numInstances) override; void Draw(unsigned int numInstances) override;
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager m_manager{nullptr}; winrt::Windows::UI::Input::Spatial::SpatialInteractionManager m_interactionManager{nullptr};
winrt::Windows::Perception::Spatial::SpatialLocatorAttachedFrameOfReference m_referenceFrame{nullptr}; winrt::Windows::Perception::Spatial::SpatialLocatorAttachedFrameOfReference m_referenceFrame{nullptr};
std::vector<QTransform> m_transforms; std::vector<QTransform> m_transforms;
std::vector<Joint> m_joints; std::vector<Joint> m_joints;
std::vector<ColoredTransform> m_coloredTransforms;
}; };

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

@ -30,15 +30,29 @@ SpatialSurfaceMeshRenderer::SpatialSurfaceMeshRenderer(const std::shared_ptr<DXH
: m_deviceResources(deviceResources) : m_deviceResources(deviceResources)
{ {
CreateDeviceDependentResources(); CreateDeviceDependentResources();
m_spatialLocator = SpatialLocator::GetDefault();
if (m_spatialLocator)
{
m_spatialLocatorLocabilityChangedEventRevoker =
m_spatialLocator.LocatabilityChanged(winrt::auto_revoke, {this, &SpatialSurfaceMeshRenderer::OnLocatibilityChanged});
m_attachedFrameOfReference = m_spatialLocator.CreateAttachedFrameOfReferenceAtCurrentHeading();
}
} }
SpatialSurfaceMeshRenderer::~SpatialSurfaceMeshRenderer() SpatialSurfaceMeshRenderer::~SpatialSurfaceMeshRenderer()
{ {
} }
std::future<void> SpatialSurfaceMeshRenderer::CreateDeviceDependentResources() std::future<void> SpatialSurfaceMeshRenderer::CreateDeviceDependentResources()
{ {
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
std::wstring fileNamePrefix = L"";
#else
std::wstring fileNamePrefix = L"ms-appx:///";
#endif
auto asyncAccess = Surfaces::SpatialSurfaceObserver::RequestAccessAsync(); auto asyncAccess = Surfaces::SpatialSurfaceObserver::RequestAccessAsync();
asyncAccess.Completed([this](auto handler, auto asyncStatus) { asyncAccess.Completed([this](auto handler, auto asyncStatus) {
m_surfaceObserver = Surfaces::SpatialSurfaceObserver(); m_surfaceObserver = Surfaces::SpatialSurfaceObserver();
@ -49,7 +63,7 @@ std::future<void> SpatialSurfaceMeshRenderer::CreateDeviceDependentResources()
}); });
}); });
std::vector<byte> vertexShaderFileData = co_await DXHelper::ReadDataAsync(L"hsa_SRMeshVertexShader.cso"); std::vector<byte> vertexShaderFileData = co_await DXHelper::ReadDataAsync(fileNamePrefix + L"hsa_SRMeshVertexShader.cso");
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateVertexShader( winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateVertexShader(
vertexShaderFileData.data(), vertexShaderFileData.size(), nullptr, m_vertexShader.put())); vertexShaderFileData.data(), vertexShaderFileData.size(), nullptr, m_vertexShader.put()));
@ -64,13 +78,13 @@ std::future<void> SpatialSurfaceMeshRenderer::CreateDeviceDependentResources()
static_cast<UINT>(vertexShaderFileData.size()), static_cast<UINT>(vertexShaderFileData.size()),
m_inputLayout.put())); m_inputLayout.put()));
std::vector<byte> geometryShaderFileData = co_await DXHelper::ReadDataAsync(L"hsa_SRMeshGeometryShader.cso"); std::vector<byte> geometryShaderFileData = co_await DXHelper::ReadDataAsync(fileNamePrefix + L"hsa_SRMeshGeometryShader.cso");
// After the pass-through geometry shader file is loaded, create the shader. // After the pass-through geometry shader file is loaded, create the shader.
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateGeometryShader( winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateGeometryShader(
geometryShaderFileData.data(), geometryShaderFileData.size(), nullptr, m_geometryShader.put())); geometryShaderFileData.data(), geometryShaderFileData.size(), nullptr, m_geometryShader.put()));
std::vector<byte> pixelShaderFileData = co_await DXHelper::ReadDataAsync(L"hsa_SRMeshPixelShader.cso"); std::vector<byte> pixelShaderFileData = co_await DXHelper::ReadDataAsync(fileNamePrefix + L"hsa_SRMeshPixelShader.cso");
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreatePixelShader( winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreatePixelShader(
pixelShaderFileData.data(), pixelShaderFileData.size(), nullptr, m_pixelShader.put())); pixelShaderFileData.data(), pixelShaderFileData.size(), nullptr, m_pixelShader.put()));
@ -104,6 +118,16 @@ void SpatialSurfaceMeshRenderer::OnObservedSurfaceChanged()
m_sufaceChanged = true; m_sufaceChanged = true;
} }
void SpatialSurfaceMeshRenderer::OnLocatibilityChanged(
const SpatialLocator& spatialLocator, const winrt::Windows::Foundation::IInspectable&)
{
SpatialLocatability locatibility = spatialLocator.Locatability();
if (locatibility != SpatialLocatability::PositionalTrackingActive)
{
m_meshParts.clear();
}
}
SpatialSurfaceMeshPart* SpatialSurfaceMeshRenderer::GetOrCreateMeshPart(winrt::guid id) SpatialSurfaceMeshPart* SpatialSurfaceMeshRenderer::GetOrCreateMeshPart(winrt::guid id)
{ {
GUID key = id; GUID key = id;
@ -117,7 +141,9 @@ SpatialSurfaceMeshPart* SpatialSurfaceMeshRenderer::GetOrCreateMeshPart(winrt::g
return found->second.get(); return found->second.get();
} }
void SpatialSurfaceMeshRenderer::Update(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem) void SpatialSurfaceMeshRenderer::Update(
winrt::Windows::Perception::PerceptionTimestamp timestamp,
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem)
{ {
if (m_surfaceObserver == nullptr) if (m_surfaceObserver == nullptr)
return; return;
@ -129,10 +155,20 @@ void SpatialSurfaceMeshRenderer::Update(winrt::Windows::Perception::Spatial::Spa
{10.0f, 10.0f, 5.f}, {10.0f, 10.0f, 5.f},
}; };
SpatialBoundingVolume volume = SpatialBoundingVolume::FromBox(renderingCoordinateSystem, axisAlignedBoundingBox); using namespace std::chrono_literals;
m_surfaceObserver.SetBoundingVolume(volume); auto now = std::chrono::high_resolution_clock::now();
} auto delta = now - m_boundingVolumeUpdateTime;
if (m_attachedFrameOfReference && delta > 1s)
{
SpatialCoordinateSystem attachedCoordinateSystem =
m_attachedFrameOfReference.GetStationaryCoordinateSystemAtTimestamp(timestamp);
SpatialBoundingVolume volume = SpatialBoundingVolume::FromBox(attachedCoordinateSystem, axisAlignedBoundingBox);
m_surfaceObserver.SetBoundingVolume(volume);
m_boundingVolumeUpdateTime = now;
}
}
if (m_sufaceChanged) if (m_sufaceChanged)
{ {
@ -153,7 +189,6 @@ void SpatialSurfaceMeshRenderer::Update(winrt::Windows::Perception::Spatial::Spa
} }
} }
// purge the ones not used // purge the ones not used
for (MeshPartMap::const_iterator itr = m_meshParts.cbegin(); itr != m_meshParts.cend();) for (MeshPartMap::const_iterator itr = m_meshParts.cbegin(); itr != m_meshParts.cend();)
{ {
@ -226,8 +261,6 @@ void SpatialSurfaceMeshRenderer::Render(bool isStereo)
}); });
} }
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
// SRMeshPart // SRMeshPart
////////////////////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -240,8 +273,6 @@ SpatialSurfaceMeshPart::SpatialSurfaceMeshPart(SpatialSurfaceMeshRenderer* owner
m_vertexScale.x = m_vertexScale.y = m_vertexScale.z = 1.0f; m_vertexScale.x = m_vertexScale.y = m_vertexScale.z = 1.0f;
} }
void SpatialSurfaceMeshPart::Update(Surfaces::SpatialSurfaceInfo surfaceInfo) void SpatialSurfaceMeshPart::Update(Surfaces::SpatialSurfaceInfo surfaceInfo)
{ {
m_inUse = true; m_inUse = true;
@ -255,8 +286,6 @@ void SpatialSurfaceMeshPart::Update(Surfaces::SpatialSurfaceInfo surfaceInfo)
}); });
} }
void SpatialSurfaceMeshPart::UpdateModelMatrix(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem) void SpatialSurfaceMeshPart::UpdateModelMatrix(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem)
{ {
if (m_coordinateSystem == nullptr) if (m_coordinateSystem == nullptr)
@ -273,7 +302,6 @@ void SpatialSurfaceMeshPart::UpdateModelMatrix(winrt::Windows::Perception::Spati
} }
} }
void SpatialSurfaceMeshPart::UpdateMesh(Surfaces::SpatialSurfaceMesh mesh) void SpatialSurfaceMeshPart::UpdateMesh(Surfaces::SpatialSurfaceMesh mesh)
{ {
m_coordinateSystem = mesh.CoordinateSystem(); m_coordinateSystem = mesh.CoordinateSystem();

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

@ -27,6 +27,11 @@ struct SRMeshConstantBuffer
DirectX::XMFLOAT4X4 modelMatrix; DirectX::XMFLOAT4X4 modelMatrix;
}; };
// Assert that the constant buffer remains 16-byte aligned (best practice).
static_assert(
(sizeof(SRMeshConstantBuffer) % (sizeof(float) * 4)) == 0,
"SR mesh constant buffer size must be 16-byte aligned (16 bytes is the length of four floats).");
// represents a single piece of mesh (SpatialSurfaceMesh) // represents a single piece of mesh (SpatialSurfaceMesh)
class SpatialSurfaceMeshPart class SpatialSurfaceMeshPart
{ {
@ -77,7 +82,6 @@ private:
DirectX::XMFLOAT3 m_vertexScale; DirectX::XMFLOAT3 m_vertexScale;
}; };
// Renders the SR mesh // Renders the SR mesh
class SpatialSurfaceMeshRenderer class SpatialSurfaceMeshRenderer
{ {
@ -85,7 +89,9 @@ public:
SpatialSurfaceMeshRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources); SpatialSurfaceMeshRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources);
virtual ~SpatialSurfaceMeshRenderer(); virtual ~SpatialSurfaceMeshRenderer();
void Update(winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem); void Update(
winrt::Windows::Perception::PerceptionTimestamp timestamp,
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem);
void Render(bool isStereo); void Render(bool isStereo);
@ -94,6 +100,8 @@ public:
private: private:
void OnObservedSurfaceChanged(); void OnObservedSurfaceChanged();
void OnLocatibilityChanged(
const winrt::Windows::Perception::Spatial::SpatialLocator& spatialLocator, const winrt::Windows::Foundation::IInspectable&);
SpatialSurfaceMeshPart* GetOrCreateMeshPart(winrt::guid id); SpatialSurfaceMeshPart* GetOrCreateMeshPart(winrt::guid id);
private: private:
@ -102,11 +110,6 @@ private:
// Cached pointer to device resources. // Cached pointer to device resources.
std::shared_ptr<DXHelper::DeviceResources> m_deviceResources; std::shared_ptr<DXHelper::DeviceResources> m_deviceResources;
// Resources related to mesh rendering.
winrt::com_ptr<ID3D11ShaderResourceView> m_shaderResourceView;
winrt::com_ptr<ID3D11SamplerState> m_pointSampler;
winrt::com_ptr<ID3D11RenderTargetView> m_renderTargetView;
// observer: // observer:
int m_surfaceChangedCounter = 0; int m_surfaceChangedCounter = 0;
bool m_sufaceChanged = false; bool m_sufaceChanged = false;
@ -127,4 +130,12 @@ private:
winrt::com_ptr<ID3D11PixelShader> m_pixelShader; winrt::com_ptr<ID3D11PixelShader> m_pixelShader;
winrt::com_ptr<ID3D11Buffer> m_modelConstantBuffer; winrt::com_ptr<ID3D11Buffer> m_modelConstantBuffer;
winrt::Windows::Perception::Spatial::SpatialLocator m_spatialLocator = nullptr;
winrt::Windows::Perception::Spatial::SpatialLocator::LocatabilityChanged_revoker m_spatialLocatorLocabilityChangedEventRevoker;
// A attached frame of reference based on m_spatialLocator.
winrt::Windows::Perception::Spatial::SpatialLocatorAttachedFrameOfReference m_attachedFrameOfReference = nullptr;
std::chrono::time_point<std::chrono::steady_clock> m_boundingVolumeUpdateTime;
}; };

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

@ -11,12 +11,12 @@
#include "pch.h" #include "pch.h"
#include "../Common/DirectXHelper.h" #include <Content/SpinningCubeRenderer.h>
#include "SpinningCubeRenderer.h"
#include <Common/DirectXHelper.h>
#include <winrt/Windows.Foundation.Numerics.h>
#include <winrt/Windows.Perception.People.h> #include <winrt/Windows.Perception.People.h>
#include <winrt/Windows.Perception.h> #include <winrt/Windows.Storage.Streams.h>
using namespace DirectX; using namespace DirectX;
@ -74,13 +74,17 @@ void SpinningCubeRenderer::PositionHologram(
// Called once per frame. Rotates the cube, and calculates and sets the model matrix // Called once per frame. Rotates the cube, and calculates and sets the model matrix
// relative to the position transform indicated by hologramPositionTransform. // relative to the position transform indicated by hologramPositionTransform.
void SpinningCubeRenderer::Update(float totalSeconds) void SpinningCubeRenderer::Update(
float totalSeconds,
winrt::Windows::Perception::PerceptionTimestamp timestamp,
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem)
{ {
// Rotate the cube. // Rotate the cube.
// Convert degrees to radians, then convert seconds to rotation angle. // Convert degrees to radians, then convert seconds to rotation angle.
const float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond); const float radiansPerSecond = XMConvertToRadians(m_degreesPerSecond);
const double relativeRotation = totalSeconds * radiansPerSecond; const double relativeRotation = totalSeconds * radiansPerSecond;
double totalRotation = m_rotationOffset; double totalRotation = m_rotationOffset;
switch (m_pauseState) switch (m_pauseState)
{ {
case PauseState::Unpaused: case PauseState::Unpaused:
@ -102,6 +106,7 @@ void SpinningCubeRenderer::Update(float totalSeconds)
const float radians = static_cast<float>(fmod(totalRotation, XM_2PI)); const float radians = static_cast<float>(fmod(totalRotation, XM_2PI));
const XMMATRIX modelRotation = XMMatrixRotationY(-radians); const XMMATRIX modelRotation = XMMatrixRotationY(-radians);
{
// Position the cube. // Position the cube.
const XMMATRIX modelTranslation = XMMatrixTranslationFromVector(XMLoadFloat3(&m_position)); const XMMATRIX modelTranslation = XMMatrixTranslationFromVector(XMLoadFloat3(&m_position));
@ -118,6 +123,7 @@ void SpinningCubeRenderer::Update(float totalSeconds)
// Here, we provide the model transform for the sample hologram. The model transform // Here, we provide the model transform for the sample hologram. The model transform
// matrix is transposed to prepare it for the shader. // matrix is transposed to prepare it for the shader.
XMStoreFloat4x4(&m_modelConstantBufferData.model, XMMatrixTranspose(modelTransform)); XMStoreFloat4x4(&m_modelConstantBufferData.model, XMMatrixTranspose(modelTransform));
}
// Loading is asynchronous. Resources must be created before they can be updated. // Loading is asynchronous. Resources must be created before they can be updated.
if (!m_loadingComplete) if (!m_loadingComplete)
@ -128,7 +134,7 @@ void SpinningCubeRenderer::Update(float totalSeconds)
// Use the D3D device context to update Direct3D device-based resources. // Use the D3D device context to update Direct3D device-based resources.
m_deviceResources->UseD3DDeviceContext([&](auto context) { m_deviceResources->UseD3DDeviceContext([&](auto context) {
// Update the model transform buffer for the hologram. // Update the model transform buffer for the hologram.
context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &m_modelConstantBufferData, 0, 0); context->UpdateSubresource(m_modelConstantBuffer.get(), 0, nullptr, &(m_modelConstantBufferData), 0, 0);
}); });
} }
@ -312,7 +318,7 @@ std::future<void> SpinningCubeRenderer::CreateDeviceDependentResources()
const CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER); const CD3D11_BUFFER_DESC indexBufferDesc(sizeof(cubeIndices), D3D11_BIND_INDEX_BUFFER);
winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateBuffer(&indexBufferDesc, &indexBufferData, m_indexBuffer.put())); winrt::check_hresult(m_deviceResources->GetD3DDevice()->CreateBuffer(&indexBufferDesc, &indexBufferData, m_indexBuffer.put()));
// Once the cube is loaded, the object is ready to be rendered. // Once everything is loaded, the object is ready to be rendered.
m_loadingComplete = true; m_loadingComplete = true;
} }

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

@ -11,19 +11,26 @@
#pragma once #pragma once
#include "..\Common\DeviceResources.h" #include <Common/DeviceResources.h>
#include "ShaderStructures.h" #include <Content/ShaderStructures.h>
#include <winrt/Windows.UI.Input.Spatial.h> #include <winrt/Windows.UI.Input.Spatial.h>
#include <future>
// This sample renderer instantiates a basic rendering pipeline. // This sample renderer instantiates a basic rendering pipeline.
class SpinningCubeRenderer class SpinningCubeRenderer
{ {
public: public:
SpinningCubeRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources); SpinningCubeRenderer(const std::shared_ptr<DXHelper::DeviceResources>& deviceResources);
void CreateWindowSizeDependentResources(); void CreateWindowSizeDependentResources();
std::future<void> CreateDeviceDependentResources(); std::future<void> CreateDeviceDependentResources();
void ReleaseDeviceDependentResources(); void ReleaseDeviceDependentResources();
void Update(float totalSeconds); void Update(
float totalSeconds,
winrt::Windows::Perception::PerceptionTimestamp timestamp,
winrt::Windows::Perception::Spatial::SpatialCoordinateSystem renderingCoordinateSystem);
void SetColorFilter(DirectX::XMFLOAT4 color); void SetColorFilter(DirectX::XMFLOAT4 color);
void Render(bool isStereo); void Render(bool isStereo);

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

@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp">
<Identity Name="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" Version="2.1.0.0" />
<mp:PhoneIdentity PhoneProductId="b0cf2e39-8f6e-4238-b33a-868c9b1122ce" PhonePublisherId="00000000-0000-0000-0000-000000000000" />
<Properties>
<DisplayName>RemotingHostSample</DisplayName>
<PublisherDisplayName>Microsoft Corporation</PublisherDisplayName>
<Logo>Assets\StoreLogo.png</Logo>
</Properties>
<Dependencies>
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
</Dependencies>
<Resources>
<Resource Language="x-generate" />
</Resources>
<Applications>
<Application Id="App" Executable="$targetnametoken$.exe" EntryPoint="SampleRemoteWindowUWPView">
<uap:VisualElements DisplayName="RemotingHostSampleUWP" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="RemotingHostSampleUWP" BackgroundColor="transparent">
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png">
</uap:DefaultTile>
<uap:SplashScreen Image="Assets\SplashScreen.png" />
</uap:VisualElements>
</Application>
</Applications>
<Capabilities>
<Capability Name="internetClient" />
<Capability Name="internetClientServer" />
<Capability Name="privateNetworkClientServer" />
<DeviceCapability Name="microphone" />
<DeviceCapability Name="webcam" />
</Capabilities>
<Extensions>
<!--Extension Category="windows.activatableClass.inProcessServer">
<InProcessServer>
<Path>SceneUnderstanding.dll</Path>
<ActivatableClass ActivatableClassId="SceneUnderstanding.Transform" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Id" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.QuadToolkit" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.SpatialCoordinateSystem" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Quad" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Toolkit" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.SpatialComponent" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Component" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Entity" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.Mesh" ThreadingModel="both" />
<ActivatableClass ActivatableClassId="SceneUnderstanding.SceneProcessor" ThreadingModel="both" />
</InProcessServer>
</Extension-->
</Extensions>
</Package>

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

@ -0,0 +1,32 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleRemote", "SampleRemote.vcxproj", "{D22B424F-B259-356A-8E4C-4937C36E783E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
RelWithDebInfo|x64 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D22B424F-B259-356A-8E4C-4937C36E783E}.Debug|x64.ActiveCfg = Debug|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.Debug|x64.Build.0 = Debug|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.Debug|x64.Deploy.0 = Debug|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.Release|x64.ActiveCfg = Release|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.Release|x64.Build.0 = Release|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.Release|x64.Deploy.0 = Release|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.RelWithDebInfo|x64.ActiveCfg = RelWithDebInfo|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.RelWithDebInfo|x64.Build.0 = RelWithDebInfo|x64
{D22B424F-B259-356A-8E4C-4937C36E783E}.RelWithDebInfo|x64.Deploy.0 = RelWithDebInfo|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E8A3A1EC-E636-40D6-9E3D-C22347CC8162}
EndGlobalSection
EndGlobal

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

@ -1,5 +1,9 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup>
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
</PropertyGroup>
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64"> <ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -15,55 +19,54 @@
</ProjectConfiguration> </ProjectConfiguration>
</ItemGroup> </ItemGroup>
<PropertyGroup Label="Globals"> <PropertyGroup Label="Globals">
<ProjectGuid>{59F48F16-7CF3-36AB-AE6D-B56A9DA89747}</ProjectGuid> <ProjectGuid>{D22B424F-B259-356A-8E4C-4937C36E783E}</ProjectGuid>
<WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion> <WindowsTargetPlatformVersion>10.0.18362.0</WindowsTargetPlatformVersion>
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<Platform>x64</Platform> <Platform>x64</Platform>
<ProjectName>HolographicHostSample</ProjectName> <ProjectName>SampleRemote</ProjectName>
<VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName> <VCProjectUpgraderObjectName>NoUpgrade</VCProjectUpgraderObjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
<SpectreMitigation>Spectre</SpectreMitigation> <SpectreMitigation>Spectre</SpectreMitigation>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<CharacterSet>MultiByte</CharacterSet> <CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v141</PlatformToolset> <PlatformToolset>v142</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="PropertySheets"> <ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="packages\Microsoft.Holographic.Remoting.2.0.14\build\native\Microsoft.Holographic.Remoting.targets" Condition="Exists('packages\Microsoft.Holographic.Remoting.2.0.14\build\native\Microsoft.Holographic.Remoting.targets')" />
</ImportGroup> </ImportGroup>
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup> <PropertyGroup>
<_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion> <_ProjectFileVersion>10.0.20506.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">bin\Debug\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">bin\Debug\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">HolographicHostSample.dir\Debug\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">SampleRemote.dir\Debug\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">HolographicHostSample</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">SampleRemote</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">bin\Release\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">bin\Release\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">HolographicHostSample.dir\Release\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">SampleRemote.dir\Release\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">HolographicHostSample</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">SampleRemote</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">bin\RelWithDebInfo\</OutDir> <OutDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">bin\RelWithDebInfo\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">HolographicHostSample.dir\RelWithDebInfo\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">SampleRemote.dir\RelWithDebInfo\</IntDir>
<TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">HolographicHostSample</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">SampleRemote</TargetName>
<TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">.exe</TargetExt> <TargetExt Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">.exe</TargetExt>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='RelWithDebInfo|x64'">true</GenerateManifest>
@ -73,7 +76,7 @@
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories>
<AssemblerListingLocation>Debug/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>true</CompileAsWinRT> <CompileAsWinRT>true</CompileAsWinRT>
@ -91,11 +94,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Debug";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Debug\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -113,9 +116,9 @@
<EnableCOMDATFolding>false</EnableCOMDATFolding> <EnableCOMDATFolding>false</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ImportLibrary>lib/Debug/HolographicHostSample.lib</ImportLibrary> <ImportLibrary>lib/Debug/SampleRemote.lib</ImportLibrary>
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<ProgramDataBaseFile>bin/Debug/HolographicHostSample.pdb</ProgramDataBaseFile> <ProgramDataBaseFile>bin/Debug/SampleRemote.pdb</ProgramDataBaseFile>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<ProjectReference> <ProjectReference>
@ -127,7 +130,7 @@
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories>
<AssemblerListingLocation>Release/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>true</CompileAsWinRT> <CompileAsWinRT>true</CompileAsWinRT>
<ControlFlowGuard>Guard</ControlFlowGuard> <ControlFlowGuard>Guard</ControlFlowGuard>
@ -145,11 +148,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="Release";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"Release\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -166,8 +169,8 @@
<AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /machine:x64</AdditionalOptions>
<GenerateDebugInformation>DebugFull</GenerateDebugInformation> <GenerateDebugInformation>DebugFull</GenerateDebugInformation>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ImportLibrary>lib/Release/HolographicHostSample.lib</ImportLibrary> <ImportLibrary>lib/Release/SampleRemote.lib</ImportLibrary>
<ProgramDataBaseFile>bin/Release/HolographicHostSample.pdb</ProgramDataBaseFile> <ProgramDataBaseFile>bin/Release/SampleRemote.pdb</ProgramDataBaseFile>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<ProjectReference> <ProjectReference>
@ -179,7 +182,7 @@
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions> <AdditionalOptions>%(AdditionalOptions) /await</AdditionalOptions>
<AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories> <AdditionalUsingDirectories>$(VCIDEInstallDir)vcpackages;$(WindowsSDK_UnionMetadataPath)</AdditionalUsingDirectories>
<AssemblerListingLocation>RelWithDebInfo/</AssemblerListingLocation> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
<CompileAs>CompileAsCpp</CompileAs> <CompileAs>CompileAsCpp</CompileAs>
<CompileAsWinRT>true</CompileAsWinRT> <CompileAsWinRT>true</CompileAsWinRT>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
@ -196,11 +199,11 @@
<SDLCheck>true</SDLCheck> <SDLCheck>true</SDLCheck>
<UseFullPaths>false</UseFullPaths> <UseFullPaths>false</UseFullPaths>
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR="RelWithDebInfo";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<ObjectFileName>$(IntDir)</ObjectFileName> <ObjectFileName>$(IntDir)</ObjectFileName>
</ClCompile> </ClCompile>
<ResourceCompile> <ResourceCompile>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;ALLOW_INSECURE_RANDOM_DEVICE=1;UNICODE;_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;_SILENCE_CXX17_OLD_ALLOCATOR_MEMBERS_DEPRECATION_WARNING;RDBUILD_PLATFORM_DEFINED;RDBUILD_PLATFORM_WINDOWS;RDBUILD_PLATFORM_WINDOWS_WIN32;RDBUILD_ARCHITECTURE_DEFINED;RDBUILD_ARCH_INTEL;RDBUILD_ARCH_INTEL_X64;RDBUILD_DEFAULT_CALL=;RDBUILD_FEATURE_OPENSSL=0;_SCL_SECURE_NO_WARNINGS;WIN32_LEAN_AND_MEAN=1;WINVER=0x0A00;_WIN32_WINNT=0x0A00;NTDDI_VERSION=0x0A000007;CMAKE_INTDIR=\"RelWithDebInfo\";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>.;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ResourceCompile> </ResourceCompile>
<Midl> <Midl>
@ -218,9 +221,9 @@
<EnableCOMDATFolding>false</EnableCOMDATFolding> <EnableCOMDATFolding>false</EnableCOMDATFolding>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries> <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
<ImportLibrary>lib/RelWithDebInfo/HolographicHostSample.lib</ImportLibrary> <ImportLibrary>lib/RelWithDebInfo/SampleRemote.lib</ImportLibrary>
<OptimizeReferences>false</OptimizeReferences> <OptimizeReferences>false</OptimizeReferences>
<ProgramDataBaseFile>bin/RelWithDebInfo/HolographicHostSample.pdb</ProgramDataBaseFile> <ProgramDataBaseFile>bin/RelWithDebInfo/SampleRemote.pdb</ProgramDataBaseFile>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
</Link> </Link>
<ProjectReference> <ProjectReference>
@ -228,12 +231,12 @@
</ProjectReference> </ProjectReference>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include=".\SampleHostMain.cpp" /> <ClCompile Include=".\SampleRemoteMain.cpp" />
<ClInclude Include=".\SampleHostMain.h" /> <ClInclude Include=".\SampleRemoteMain.h" />
<ClInclude Include=".\pch.h" /> <ClInclude Include=".\pch.h" />
<ClCompile Include=".\pch.cpp" /> <ClCompile Include=".\pch.cpp" />
<ClCompile Include=".\SampleHostWindowWin32.cpp" /> <ClCompile Include=".\SampleRemoteWindowWin32.cpp" />
<ClInclude Include=".\SampleHostWindowWin32.h" /> <ClInclude Include=".\SampleRemoteWindowWin32.h" />
<ClCompile Include=".\Common\CameraResources.cpp" /> <ClCompile Include=".\Common\CameraResources.cpp" />
<ClInclude Include=".\Common\CameraResources.h" /> <ClInclude Include=".\Common\CameraResources.h" />
<ClInclude Include=".\Common\DbgLog.h" /> <ClInclude Include=".\Common\DbgLog.h" />
@ -310,4 +313,8 @@
</None> </None>
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('packages\Microsoft.Windows.CppWinRT.2.0.200224.2\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="packages\Microsoft.Holographic.Remoting.2.1.0\build\native\Microsoft.Holographic.Remoting.targets" Condition="Exists('packages\Microsoft.Holographic.Remoting.2.1.0\build\native\Microsoft.Holographic.Remoting.targets')" />
</ImportGroup>
</Project> </Project>

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

@ -11,7 +11,7 @@
#include "pch.h" #include "pch.h"
#include "SampleHostMain.h" #include "SampleRemoteMain.h"
#include "Common\DbgLog.h" #include "Common\DbgLog.h"
#include "Common\DirectXHelper.h" #include "Common\DirectXHelper.h"
@ -19,15 +19,16 @@
#include <DirectXColors.h> #include <DirectXColors.h>
#include <HolographicAppRemoting\Streamer.h> #include <HolographicAppRemoting/Streamer.h>
#include <winrt/Microsoft.Holographic.AppRemoting.h> #include <winrt/Microsoft.Holographic.AppRemoting.h>
#include <winrt/Windows.Foundation.Metadata.h>
#include <winrt/Windows.Perception.People.h> #include <winrt/Windows.Perception.People.h>
#include <winrt/Windows.Security.Authorization.AppCapabilityAccess.h>
#include <iosfwd> #include <iosfwd>
#include <sstream> #include <sstream>
using namespace concurrency; using namespace concurrency;
using namespace std::chrono_literals; using namespace std::chrono_literals;
@ -35,14 +36,15 @@ using namespace std::chrono_literals;
using namespace winrt::Microsoft::Holographic::AppRemoting; using namespace winrt::Microsoft::Holographic::AppRemoting;
using namespace winrt::Windows::Foundation::Numerics; using namespace winrt::Windows::Foundation::Numerics;
using namespace winrt::Windows::Graphics::Holographic; using namespace winrt::Windows::Graphics::Holographic;
using namespace winrt::Windows::Graphics::DirectX;
using namespace winrt::Windows::Perception::People; using namespace winrt::Windows::Perception::People;
using namespace winrt::Windows::Perception::Spatial; using namespace winrt::Windows::Perception::Spatial;
using namespace winrt::Windows::UI::Input; using namespace winrt::Windows::UI::Input;
using namespace winrt::Windows::Security::Authorization::AppCapabilityAccess;
namespace namespace
{ {
const wchar_t* StreamerConnectionStateToString(ConnectionState state) const wchar_t* StreamerConnectionStateToString(ConnectionState state, bool disconnectPending)
{ {
switch (state) switch (state)
{ {
@ -53,22 +55,24 @@ namespace
return L"Connecting"; return L"Connecting";
case ConnectionState::Connected: case ConnectionState::Connected:
return L"Connected"; return disconnectPending ? L"Disconnecting" : L"Connected";
} }
return L"Unknown"; return L"Unknown";
} }
} // namespace } // namespace
SampleRemoteMain::SampleRemoteMain(std::weak_ptr<IWindow> window)
SampleHostMain::SampleHostMain(std::weak_ptr<IWindow> window)
: m_window(window) : m_window(window)
{ {
m_deviceResources = std::make_shared<DXHelper::DeviceResources>(); m_deviceResources = std::make_shared<DXHelper::DeviceResources>();
m_deviceResources->RegisterDeviceNotify(this); m_deviceResources->RegisterDeviceNotify(this);
m_canCommitDirect3D11DepthBuffer = winrt::Windows::Foundation::Metadata::ApiInformation::IsMethodPresent(
L"Windows.Graphics.Holographic.HolographicCameraRenderingParameters", L"CommitDirect3D11DepthBuffer");
} }
SampleHostMain::~SampleHostMain() SampleRemoteMain::~SampleRemoteMain()
{ {
ShutdownRemoteContext(); ShutdownRemoteContext();
@ -76,7 +80,7 @@ SampleHostMain::~SampleHostMain()
UnregisterHolographicEventHandlers(); UnregisterHolographicEventHandlers();
} }
HolographicFrame SampleHostMain::Update() HolographicFrame SampleRemoteMain::Update()
{ {
auto timeDelta = std::chrono::high_resolution_clock::now() - m_windowTitleUpdateTime; auto timeDelta = std::chrono::high_resolution_clock::now() - m_windowTitleUpdateTime;
if (timeDelta >= 1s) if (timeDelta >= 1s)
@ -101,7 +105,6 @@ HolographicFrame SampleHostMain::Update()
HolographicFrame holographicFrame = m_holographicSpace.CreateNextFrame(); HolographicFrame holographicFrame = m_holographicSpace.CreateNextFrame();
HolographicFramePrediction prediction = holographicFrame.CurrentPrediction(); HolographicFramePrediction prediction = holographicFrame.CurrentPrediction();
// Back buffers can change from frame to frame. Validate each buffer, and recreate resource views and depth buffers as needed. // Back buffers can change from frame to frame. Validate each buffer, and recreate resource views and depth buffers as needed.
m_deviceResources->EnsureCameraResources(holographicFrame, prediction); m_deviceResources->EnsureCameraResources(holographicFrame, prediction);
@ -118,7 +121,6 @@ HolographicFrame SampleHostMain::Update()
// When the Tapped spatial input event is received, the sample hologram will be repositioned two meters in front of the user. // When the Tapped spatial input event is received, the sample hologram will be repositioned two meters in front of the user.
m_spinningCubeRenderer->PositionHologram(pointerPose); m_spinningCubeRenderer->PositionHologram(pointerPose);
} }
else else
{ {
@ -156,16 +158,21 @@ HolographicFrame SampleHostMain::Update()
} }
std::chrono::duration<float> timeSinceStart = std::chrono::high_resolution_clock::now() - m_startTime; std::chrono::duration<float> timeSinceStart = std::chrono::high_resolution_clock::now() - m_startTime;
m_spinningCubeRenderer->Update(timeSinceStart.count()); m_spinningCubeRenderer->Update(timeSinceStart.count(), prediction.Timestamp(), coordinateSystem);
if (m_spatialSurfaceMeshRenderer != nullptr) if (m_spatialSurfaceMeshRenderer != nullptr)
{ {
m_spatialSurfaceMeshRenderer->Update(coordinateSystem); m_spatialSurfaceMeshRenderer->Update(prediction.Timestamp(), coordinateSystem);
} }
m_spatialInputRenderer->Update(prediction.Timestamp(), coordinateSystem); m_spatialInputRenderer->Update(prediction.Timestamp(), coordinateSystem);
m_qrCodeRenderer->Update(*m_perceptionDeviceHandler.get(), coordinateSystem); if (m_perceptionDeviceHandler)
{
m_qrCodeRenderer->Update(*m_perceptionDeviceHandler, coordinateSystem);
}
// We complete the frame update by using information about our content positioning to set the focus point. // We complete the frame update by using information about our content positioning to set the focus point.
if (!m_canCommitDirect3D11DepthBuffer || !m_commitDirect3D11DepthBuffer)
{
for (auto cameraPose : prediction.CameraPoses()) for (auto cameraPose : prediction.CameraPoses())
{ {
try try
@ -181,6 +188,7 @@ HolographicFrame SampleHostMain::Update()
{ {
} }
} }
}
#ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE #ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
timeDelta = std::chrono::high_resolution_clock::now() - m_customDataChannelSendTime; timeDelta = std::chrono::high_resolution_clock::now() - m_customDataChannelSendTime;
@ -191,12 +199,30 @@ HolographicFrame SampleHostMain::Update()
// Send ping every couple of frames if we have a custom data channel. // Send ping every couple of frames if we have a custom data channel.
std::lock_guard lock(m_customDataChannelLock); std::lock_guard lock(m_customDataChannelLock);
if (m_customDataChannel) if (m_customDataChannel)
{
// Try to get send queue size. The send queue size returns the size of data, that has not been send yet, in bytes.
// A big number might indicate that more data is queued to send than the amount of data, that is actually sent.
// If possible skip sending data in this case, to help the queue getting smaller again.
uint32_t sendQueueSize = m_customDataChannel.SendQueueSize();
// Only send the packet if the send queue is smaller than 1MiB
if (sendQueueSize < 1 * 1024 * 1024)
{ {
uint8_t data = 1; uint8_t data = 1;
try
{
m_customDataChannel.SendData( m_customDataChannel.SendData(
winrt::array_view<const uint8_t>(reinterpret_cast<const uint8_t*>(&data), reinterpret_cast<const uint8_t*>(&data + 1)), winrt::array_view<const uint8_t>(
reinterpret_cast<const uint8_t*>(&data), reinterpret_cast<const uint8_t*>(&data + 1)),
true); true);
OutputDebugString(TEXT("Ping Sent.\n")); OutputDebugString(TEXT("Request Sent.\n"));
}
catch (...)
{
// SendData might throw if channel is closed, but we did not get or process the async closed event yet.
}
}
} }
} }
#endif #endif
@ -204,7 +230,7 @@ HolographicFrame SampleHostMain::Update()
return holographicFrame; return holographicFrame;
} }
void SampleHostMain::Render(HolographicFrame holographicFrame) void SampleRemoteMain::Render(HolographicFrame holographicFrame)
{ {
bool atLeastOneCameraRendered = false; bool atLeastOneCameraRendered = false;
@ -224,7 +250,7 @@ void SampleHostMain::Render(HolographicFrame holographicFrame)
{ {
DXHelper::CameraResources* pCameraResources = cameraResourceMap[cameraPose.HolographicCamera().Id()].get(); DXHelper::CameraResources* pCameraResources = cameraResourceMap[cameraPose.HolographicCamera().Id()].get();
if (pCameraResources == nullptr) if (pCameraResources == nullptr || pCameraResources->GetBackBufferRenderTargetView() == nullptr)
{ {
continue; continue;
} }
@ -258,6 +284,14 @@ void SampleHostMain::Render(HolographicFrame holographicFrame)
} }
m_spatialInputRenderer->Render(pCameraResources->IsRenderingStereoscopic()); m_spatialInputRenderer->Render(pCameraResources->IsRenderingStereoscopic());
m_qrCodeRenderer->Render(pCameraResources->IsRenderingStereoscopic()); m_qrCodeRenderer->Render(pCameraResources->IsRenderingStereoscopic());
// Commit depth buffer if available and enabled.
if (m_canCommitDirect3D11DepthBuffer && m_commitDirect3D11DepthBuffer)
{
auto interopSurface = pCameraResources->GetDepthStencilTextureInteropObject();
HolographicCameraRenderingParameters renderingParameters = holographicFrame.GetRenderingParameters(cameraPose);
renderingParameters.CommitDirect3D11DepthBuffer(interopSurface);
}
} }
}); });
@ -274,6 +308,8 @@ void SampleHostMain::Render(HolographicFrame holographicFrame)
m_deviceResources->Present(holographicFrame); m_deviceResources->Present(holographicFrame);
} }
if (!m_isStandalone)
{
if (m_swapChain == nullptr && m_isInitialized) if (m_swapChain == nullptr && m_isInitialized)
{ {
// A device lost event has occurred. // A device lost event has occurred.
@ -288,7 +324,11 @@ void SampleHostMain::Render(HolographicFrame holographicFrame)
} }
// Determine whether or not to copy to the preview buffer. // Determine whether or not to copy to the preview buffer.
bool copyPreview = m_remoteContext == nullptr || m_remoteContext.ConnectionState() != ConnectionState::Connected; bool copyPreview;
{
std::lock_guard remoteContextLock(m_remoteContextAccess);
copyPreview = m_remoteContext == nullptr || m_remoteContext.ConnectionState() != ConnectionState::Connected;
}
if (copyPreview && m_isInitialized) if (copyPreview && m_isInitialized)
{ {
winrt::com_ptr<ID3D11Device1> spDevice; winrt::com_ptr<ID3D11Device1> spDevice;
@ -308,18 +348,34 @@ void SampleHostMain::Render(HolographicFrame holographicFrame)
WindowPresentSwapChain(); WindowPresentSwapChain();
} }
}
m_framesPerSecond++; m_framesPerSecond++;
} }
void SampleHostMain::SetHostOptions(bool listen, const std::wstring& hostname, uint32_t port) void SampleRemoteMain::ConfigureRemoting(
bool listen, const std::wstring& hostname, uint16_t port, uint16_t transportPort, bool ephemeralPort)
{ {
if (!m_isInitialized)
{
m_listen = listen; m_listen = listen;
m_hostname = hostname; m_hostname = hostname;
m_port = port; m_port = port;
m_transportPort = transportPort;
m_ephemeralPort = ephemeralPort;
}
} }
void SampleHostMain::OnKeyPress(char key) void SampleRemoteMain::InitializeStandalone()
{
if (!m_isInitialized)
{
m_isStandalone = true;
CreateHolographicSpaceAndDeviceResources();
}
}
void SampleRemoteMain::OnKeyPress(char key)
{ {
switch (key) switch (key)
{ {
@ -328,7 +384,14 @@ void SampleHostMain::OnKeyPress(char key)
break; break;
case 'd': case 'd':
ShutdownRemoteContext(); {
std::lock_guard remoteContextLock(m_remoteContextAccess);
if (m_remoteContext && m_remoteContext.ConnectionState() != ConnectionState::Disconnected)
{
m_disconnectPending = true;
m_remoteContext.Disconnect();
}
}
break; break;
case 'p': case 'p':
@ -343,6 +406,13 @@ void SampleHostMain::OnKeyPress(char key)
SavePosition(); SavePosition();
break; break;
case 'e':
ExportPosition();
break;
case 'x':
m_commitDirect3D11DepthBuffer = !m_commitDirect3D11DepthBuffer;
break;
case 'c': case 'c':
m_spinningCubeRenderer->TogglePauseState(); m_spinningCubeRenderer->TogglePauseState();
@ -352,7 +422,7 @@ void SampleHostMain::OnKeyPress(char key)
WindowUpdateTitle(); WindowUpdateTitle();
} }
void SampleHostMain::OnResize(int width, int height) void SampleRemoteMain::OnResize(int width, int height)
{ {
std::lock_guard _lg(m_deviceLock); std::lock_guard _lg(m_deviceLock);
@ -368,7 +438,7 @@ void SampleHostMain::OnResize(int width, int height)
} }
} }
void SampleHostMain::OnRecognizedSpeech(const winrt::hstring& recognizedText) void SampleRemoteMain::OnRecognizedSpeech(const winrt::hstring& recognizedText)
{ {
bool changedColor = false; bool changedColor = false;
DirectX::XMFLOAT4 color = {1, 1, 1, 1}; DirectX::XMFLOAT4 color = {1, 1, 1, 1};
@ -413,13 +483,18 @@ void SampleHostMain::OnRecognizedSpeech(const winrt::hstring& recognizedText)
} }
} }
void SampleHostMain::InitializeRemoteContextAndConnectOrListen() void SampleRemoteMain::InitializeRemoteContextAndConnectOrListen()
{ {
if (!m_remoteContext) std::lock_guard remoteContextLock(m_remoteContextAccess);
if (!m_remoteContext && !m_isStandalone)
{ {
// Create the RemoteContext // Create the RemoteContext
// IMPORTANT: This must be done before creating the HolographicSpace (or any other call to the Holographic API). // IMPORTANT: This must be done before creating the HolographicSpace (or any other call to the Holographic API).
CreateRemoteContext(m_remoteContext, 20000, false, PreferredVideoCodec::Default); CreateRemoteContext(m_remoteContext, 20000, true, PreferredVideoCodec::Any);
// Configure for half-resolution depth.
m_remoteContext.ConfigureDepthVideoStream(DepthBufferStreamResolution::Half_Resolution);
// Create the HolographicSpace // Create the HolographicSpace
CreateHolographicSpaceAndDeviceResources(); CreateHolographicSpaceAndDeviceResources();
@ -450,30 +525,20 @@ void SampleHostMain::InitializeRemoteContextAndConnectOrListen()
WindowUpdateTitle(); WindowUpdateTitle();
remoteContext.CreateDataChannel(0, DataChannelPriority::Low); remoteContext.CreateDataChannel(0, DataChannelPriority::Low);
} }
// The spatial surface renderer needs to get recreated on every connect, because its SpatialSurfaceObserver stops working on
// disconnect. Uncomment the below line to render spatial surfaces
// m_spatialSurfaceMeshRenderer = std::make_unique<SpatialSurfaceMeshRenderer>(m_deviceResources);
}); });
m_onDisconnectedEventRevoker = m_onDisconnectedEventRevoker =
m_remoteContext.OnDisconnected(winrt::auto_revoke, [this, remoteContextWeakRef](ConnectionFailureReason failureReason) { m_remoteContext.OnDisconnected(winrt::auto_revoke, [this, remoteContextWeakRef](ConnectionFailureReason failureReason) {
if (auto remoteContext = remoteContextWeakRef.get()) if (auto remoteContext = remoteContextWeakRef.get())
{ {
DebugLog(L"Disconnected with reason %d", failureReason); OnDisconnected(failureReason);
WindowUpdateTitle(); }
// Reconnect if this is a transient failure. m_spatialSurfaceMeshRenderer = nullptr;
if (failureReason == ConnectionFailureReason::HandshakeUnreachable ||
failureReason == ConnectionFailureReason::TransportUnreachable ||
failureReason == ConnectionFailureReason::ConnectionLost)
{
DebugLog(L"Reconnecting...");
ConnectOrListen();
}
// Failure reason None indicates a normal disconnect.
else if (failureReason != ConnectionFailureReason::None)
{
DebugLog(L"Disconnected with unrecoverable error, not attempting to reconnect.");
}
}
}); });
m_onSendFrameEventRevoker = m_remoteContext.OnSendFrame( m_onSendFrameEventRevoker = m_remoteContext.OnSendFrame(
@ -496,16 +561,49 @@ void SampleHostMain::InitializeRemoteContextAndConnectOrListen()
resource.as(texturePtr); resource.as(texturePtr);
} }
// Get source/dest dimensions and adjust copy rect and destination position to avoid D3D errors
D3D11_TEXTURE2D_DESC backBufferDesc, textureDesc;
spBackBuffer->GetDesc(&backBufferDesc);
texturePtr->GetDesc(&textureDesc);
UINT destX = 0, destY = 0;
D3D11_BOX srcBox{0, 0, 0, textureDesc.Width, textureDesc.Height, 1};
if (backBufferDesc.Width < textureDesc.Width)
{
// Target (BackBuffer) narrower than source (Texture)
srcBox.left = (textureDesc.Width - backBufferDesc.Width) / 2;
srcBox.right = srcBox.left + backBufferDesc.Width;
}
else if (backBufferDesc.Width > textureDesc.Width)
{
// Target (BackBuffer) wider than source (Texture)
destX = (backBufferDesc.Width - textureDesc.Width) / 2;
}
if (backBufferDesc.Height < textureDesc.Height)
{
// Target (BackBuffer) shorter than source (Texture)
srcBox.top = (textureDesc.Height - backBufferDesc.Height) / 2;
srcBox.bottom = srcBox.top + backBufferDesc.Height;
}
else if (backBufferDesc.Height > textureDesc.Height)
{
// Target (BackBuffer) taller than source (Texture)
destY = (backBufferDesc.Height - textureDesc.Height) / 2;
}
// Copy texture to back buffer
GetDeviceResources()->UseD3DDeviceContext([&](auto context) { GetDeviceResources()->UseD3DDeviceContext([&](auto context) {
context->CopySubresourceRegion( context->CopySubresourceRegion(
spBackBuffer.get(), // dest spBackBuffer.get(), // dest
0, // dest subresource 0, // dest subresource
0, destX,
0, destY,
0, // dest x, y, z 0, // dest x, y, z
texturePtr.get(), // source texturePtr.get(), // source
0, // source subresource 0, // source subresource
nullptr); // source box, null means the entire resource &srcBox); // source box, null means the entire resource
}); });
WindowPresentSwapChain(); WindowPresentSwapChain();
@ -516,7 +614,7 @@ void SampleHostMain::InitializeRemoteContextAndConnectOrListen()
m_onDataChannelCreatedEventRevoker = m_onDataChannelCreatedEventRevoker =
m_remoteContext.OnDataChannelCreated(winrt::auto_revoke, [this](const IDataChannel& dataChannel, uint8_t channelId) { m_remoteContext.OnDataChannelCreated(winrt::auto_revoke, [this](const IDataChannel& dataChannel, uint8_t channelId) {
std::lock_guard lock(m_customDataChannelLock); std::lock_guard lock(m_customDataChannelLock);
m_customDataChannel = dataChannel; m_customDataChannel = dataChannel.as<IDataChannel2>();
m_customChannelDataReceivedEventRevoker = m_customDataChannel.OnDataReceived( m_customChannelDataReceivedEventRevoker = m_customDataChannel.OnDataReceived(
winrt::auto_revoke, [this](winrt::array_view<const uint8_t> dataView) { OnCustomDataChannelDataReceived(); }); winrt::auto_revoke, [this](winrt::array_view<const uint8_t> dataView) { OnCustomDataChannelDataReceived(); });
@ -530,35 +628,36 @@ void SampleHostMain::InitializeRemoteContextAndConnectOrListen()
} }
} }
void SampleHostMain::CreateHolographicSpaceAndDeviceResources() void SampleRemoteMain::CreateHolographicSpaceAndDeviceResources()
{ {
UnregisterHolographicEventHandlers(); UnregisterHolographicEventHandlers();
m_holographicSpace = HolographicSpace::CreateForCoreWindow(nullptr); if (auto window = m_window.lock())
{
m_holographicSpace = window->CreateHolographicSpace();
m_interactionManager = window->CreateInteractionManager();
}
m_deviceResources->SetHolographicSpace(m_holographicSpace); m_deviceResources->SetHolographicSpace(m_holographicSpace);
m_spatialInputRenderer = std::make_shared<SpatialInputRenderer>(m_deviceResources, m_interactionManager);
m_spatialInputHandler = std::make_shared<SpatialInputHandler>(m_interactionManager);
{
m_spinningCubeRenderer = std::make_unique<SpinningCubeRenderer>(m_deviceResources); m_spinningCubeRenderer = std::make_unique<SpinningCubeRenderer>(m_deviceResources);
}
// Uncomment the below line to render spatial surfaces
// m_spatialSurfaceMeshRenderer = std::make_unique<SpatialSurfaceMeshRenderer>(m_deviceResources);
m_spatialInputRenderer = std::make_unique<SpatialInputRenderer>(m_deviceResources);
m_spatialInputHandler = std::make_shared<SpatialInputHandler>();
m_qrCodeRenderer = std::make_unique<QRCodeRenderer>(m_deviceResources); m_qrCodeRenderer = std::make_unique<QRCodeRenderer>(m_deviceResources);
m_perceptionDeviceHandler = std::make_shared<PerceptionDeviceHandler>(); CreatePerceptionDeviceHandler();
m_perceptionDeviceHandler->Start();
m_locator = SpatialLocator::GetDefault(); m_locator = SpatialLocator::GetDefault();
// Be able to respond to changes in the positional tracking state. // Be able to respond to changes in the positional tracking state.
m_locatabilityChangedToken = m_locator.LocatabilityChanged({this, &SampleHostMain::OnLocatabilityChanged}); m_locatabilityChangedToken = m_locator.LocatabilityChanged({this, &SampleRemoteMain::OnLocatabilityChanged});
m_cameraAddedToken = m_holographicSpace.CameraAdded({this, &SampleHostMain::OnCameraAdded}); m_cameraAddedToken = m_holographicSpace.CameraAdded({this, &SampleRemoteMain::OnCameraAdded});
m_cameraRemovedToken = m_holographicSpace.CameraRemoved({this, &SampleHostMain::OnCameraRemoved}); m_cameraRemovedToken = m_holographicSpace.CameraRemoved({this, &SampleRemoteMain::OnCameraRemoved});
{ {
m_referenceFrame = m_locator.CreateStationaryFrameOfReferenceAtCurrentLocation(float3::zero(), quaternion(0, 0, 0, 1), 0.0); m_referenceFrame = m_locator.CreateStationaryFrameOfReferenceAtCurrentLocation(float3::zero(), quaternion(0, 0, 0, 1), 0.0);
@ -567,28 +666,46 @@ void SampleHostMain::CreateHolographicSpaceAndDeviceResources()
m_isInitialized = true; m_isInitialized = true;
} }
void SampleHostMain::ConnectOrListen() void SampleRemoteMain::ConnectOrListen()
{ {
std::lock_guard remoteContextLock(m_remoteContextAccess);
if (!m_remoteContext || m_remoteContext.ConnectionState() != ConnectionState::Disconnected)
{
return;
}
// Try to establish a connection. // Try to establish a connection.
try try
{ {
m_remoteContext.Disconnect();
// Request access to eyes pose data on every connection/listen attempt. // Request access to eyes pose data on every connection/listen attempt.
RequestEyesPoseAccess(); RequestEyesPoseAccess();
if (m_port == 0) if (m_ephemeralPort)
{
m_port = 0;
}
else if (m_port == 0)
{ {
m_port = 8265; m_port = 8265;
} }
if (m_listen) if (m_listen)
{ {
if (m_ephemeralPort)
{
m_transportPort = 0;
}
else if (m_transportPort == 0)
{
m_transportPort = m_port + 1;
}
if (m_hostname.empty()) if (m_hostname.empty())
{ {
m_hostname = L"0.0.0.0"; m_hostname = L"0.0.0.0";
} }
m_remoteContext.Listen(m_hostname, m_port, m_port + 1); m_remoteContext.Listen(m_hostname, m_port, m_transportPort);
} }
else else
{ {
@ -612,7 +729,7 @@ void SampleHostMain::ConnectOrListen()
} }
} }
void SampleHostMain::LoadPosition() void SampleRemoteMain::LoadPosition()
{ {
auto storeRequest = SpatialAnchorManager::RequestStoreAsync(); auto storeRequest = SpatialAnchorManager::RequestStoreAsync();
storeRequest.Completed([this](winrt::Windows::Foundation::IAsyncOperation<SpatialAnchorStore> result, auto asyncStatus) { storeRequest.Completed([this](winrt::Windows::Foundation::IAsyncOperation<SpatialAnchorStore> result, auto asyncStatus) {
@ -640,7 +757,7 @@ void SampleHostMain::LoadPosition()
}); });
} }
void SampleHostMain::SavePosition() void SampleRemoteMain::SavePosition()
{ {
auto position = SpatialAnchor::TryCreateRelativeTo(m_referenceFrame.CoordinateSystem(), m_spinningCubeRenderer->GetPosition()); auto position = SpatialAnchor::TryCreateRelativeTo(m_referenceFrame.CoordinateSystem(), m_spinningCubeRenderer->GetPosition());
@ -663,8 +780,63 @@ void SampleHostMain::SavePosition()
}); });
} }
winrt::fire_and_forget SampleRemoteMain::ExportPosition()
{
const auto purpose = winrt::Windows::Perception::Spatial::SpatialAnchorExportPurpose::Sharing;
void SampleHostMain::RequestEyesPoseAccess() auto position = SpatialAnchor::TryCreateRelativeTo(m_referenceFrame.CoordinateSystem(), m_spinningCubeRenderer->GetPosition());
co_await winrt::resume_background();
try
{
using namespace winrt::Windows::Storage::Streams;
auto status = SpatialAnchorExporter::RequestAccessAsync().get();
if (status != SpatialPerceptionAccessStatus::Allowed)
{
co_return;
}
auto exporter = SpatialAnchorExporter::GetDefault();
auto sufficient = exporter.GetAnchorExportSufficiencyAsync(position, purpose).get();
if (!sufficient.IsMinimallySufficient())
{
OutputDebugStringW(L"\r\nNot enough data for the anchor to export. Try again later.");
co_return;
}
{
InMemoryRandomAccessStream stream = InMemoryRandomAccessStream();
bool result = exporter.TryExportAnchorAsync(position, purpose, stream.GetOutputStreamAt(0)).get();
uint64_t size = stream.Size();
if (size > UINT32_MAX)
{
co_return;
}
std::vector<uint8_t> data;
data.resize(size);
DataReader reader(stream);
reader.LoadAsync(static_cast<uint32_t>(size));
reader.ReadBytes(winrt::array_view(data.data(), data.data() + data.size()));
{
std::wostringstream debugMsg;
debugMsg << "\r\nSuccessfully exported anchor. Size is " << size << " bytes.";
OutputDebugStringW(debugMsg.str().c_str());
}
}
}
catch (...)
{
}
}
void SampleRemoteMain::RequestEyesPoseAccess()
{ {
try try
{ {
@ -696,7 +868,50 @@ void SampleHostMain::RequestEyesPoseAccess()
} }
} }
void SampleHostMain::UnregisterHolographicEventHandlers() winrt::fire_and_forget SampleRemoteMain::CreatePerceptionDeviceHandler()
{
AppCapabilityAccessStatus status;
if (m_isStandalone)
{
if (!winrt::Windows::Foundation::Metadata::ApiInformation::IsTypePresent(
L"Windows.Security.Authorization.AppCapabilityAccess.AppCapability"))
{
return;
}
AppCapability webcamCapability = AppCapability::Create(L"webcam");
if (!webcamCapability)
{
return;
}
auto webcamRequest = webcamCapability.RequestAccessAsync();
status = webcamRequest.get();
}
else
{
status = AppCapabilityAccessStatus::Allowed;
}
auto weakThis = weak_from_this();
co_await winrt::resume_background();
// Create the perception device if we have web cam access in standalone mode.
// Create the perception device if we do not use the standalone mode. In this case, the decision is made on the player side, whereby the
// assumption is that the access is allowed.
if (status == AppCapabilityAccessStatus::Allowed)
{
if (auto strongThis = weakThis.lock())
{
auto perceptionDeviceHandler = std::make_shared<PerceptionDeviceHandler>();
perceptionDeviceHandler->Start();
// Do not use the PerceptionDeviceHandler before initialization has been completed.
m_perceptionDeviceHandler = perceptionDeviceHandler;
}
}
}
void SampleRemoteMain::UnregisterHolographicEventHandlers()
{ {
if (m_holographicSpace != nullptr) if (m_holographicSpace != nullptr)
{ {
@ -710,12 +925,13 @@ void SampleHostMain::UnregisterHolographicEventHandlers()
} }
} }
void SampleHostMain::ShutdownRemoteContext() void SampleRemoteMain::ShutdownRemoteContext()
{ {
std::lock_guard remoteContextLock(m_remoteContextAccess);
if (m_remoteContext != nullptr) if (m_remoteContext != nullptr)
{ {
m_onConnectedEventRevoker.revoke(); m_onConnectedEventRevoker.revoke();
m_onDisconnectedEventRevoker.revoke();
m_onSendFrameEventRevoker.revoke(); m_onSendFrameEventRevoker.revoke();
m_onDataChannelCreatedEventRevoker.revoke(); m_onDataChannelCreatedEventRevoker.revoke();
@ -733,7 +949,7 @@ void SampleHostMain::ShutdownRemoteContext()
} }
} }
void SampleHostMain::OnDeviceLost() void SampleRemoteMain::OnDeviceLost()
{ {
m_spinningCubeRenderer->ReleaseDeviceDependentResources(); m_spinningCubeRenderer->ReleaseDeviceDependentResources();
m_spatialInputRenderer->ReleaseDeviceDependentResources(); m_spatialInputRenderer->ReleaseDeviceDependentResources();
@ -745,7 +961,7 @@ void SampleHostMain::OnDeviceLost()
} }
} }
void SampleHostMain::OnDeviceRestored() void SampleRemoteMain::OnDeviceRestored()
{ {
m_spinningCubeRenderer->CreateDeviceDependentResources(); m_spinningCubeRenderer->CreateDeviceDependentResources();
m_spatialInputRenderer->CreateDeviceDependentResources(); m_spatialInputRenderer->CreateDeviceDependentResources();
@ -757,10 +973,14 @@ void SampleHostMain::OnDeviceRestored()
} }
} }
void SampleHostMain::OnCameraAdded(const HolographicSpace& sender, const HolographicSpaceCameraAddedEventArgs& args) void SampleRemoteMain::OnCameraAdded(const HolographicSpace& sender, const HolographicSpaceCameraAddedEventArgs& args)
{ {
winrt::Windows::Foundation::Deferral deferral = args.GetDeferral(); winrt::Windows::Foundation::Deferral deferral = args.GetDeferral();
auto holographicCamera = args.Camera(); auto holographicCamera = args.Camera();
HolographicViewConfiguration viewConfig = holographicCamera.ViewConfiguration();
viewConfig.PixelFormat(DirectXPixelFormat::B8G8R8A8UIntNormalized);
create_task([this, deferral, holographicCamera]() { create_task([this, deferral, holographicCamera]() {
m_deviceResources->AddHolographicCamera(holographicCamera); m_deviceResources->AddHolographicCamera(holographicCamera);
@ -768,12 +988,12 @@ void SampleHostMain::OnCameraAdded(const HolographicSpace& sender, const Hologra
}); });
} }
void SampleHostMain::OnCameraRemoved(const HolographicSpace& sender, const HolographicSpaceCameraRemovedEventArgs& args) void SampleRemoteMain::OnCameraRemoved(const HolographicSpace& sender, const HolographicSpaceCameraRemovedEventArgs& args)
{ {
m_deviceResources->RemoveHolographicCamera(args.Camera()); m_deviceResources->RemoveHolographicCamera(args.Camera());
} }
void SampleHostMain::OnLocatabilityChanged(const SpatialLocator& sender, const winrt::Windows::Foundation::IInspectable& args) void SampleRemoteMain::OnLocatabilityChanged(const SpatialLocator& sender, const winrt::Windows::Foundation::IInspectable& args)
{ {
const wchar_t* locatability = L""; const wchar_t* locatability = L"";
switch (sender.Locatability()) switch (sender.Locatability())
@ -803,7 +1023,38 @@ void SampleHostMain::OnLocatabilityChanged(const SpatialLocator& sender, const w
OutputDebugStringW(message.data()); OutputDebugStringW(message.data());
} }
void SampleHostMain::WindowCreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device) void SampleRemoteMain::OnDisconnected(winrt::Microsoft::Holographic::AppRemoting::ConnectionFailureReason failureReason)
{
DebugLog(L"Disconnected with reason %d", failureReason);
{
std::lock_guard remoteContextLock(m_remoteContextAccess);
m_disconnectPending = false;
}
// Reconnect if this is a transient failure.
if (failureReason == ConnectionFailureReason::DisconnectRequest || failureReason == ConnectionFailureReason::PeerDisconnectRequest)
{
ShutdownRemoteContext();
}
else if (
failureReason == ConnectionFailureReason::HandshakeUnreachable || failureReason == ConnectionFailureReason::TransportUnreachable ||
failureReason == ConnectionFailureReason::ConnectionLost)
{
DebugLog(L"Reconnecting...");
ConnectOrListen();
}
// Failure reason None indicates a normal disconnect.
else if (failureReason != ConnectionFailureReason::None)
{
DebugLog(L"Disconnected with unrecoverable error, not attempting to reconnect.");
ShutdownRemoteContext();
}
WindowUpdateTitle();
}
void SampleRemoteMain::WindowCreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device)
{ {
std::lock_guard _lg(m_deviceLock); std::lock_guard _lg(m_deviceLock);
@ -829,7 +1080,7 @@ void SampleHostMain::WindowCreateSwapChain(const winrt::com_ptr<ID3D11Device1>&
} }
} }
void SampleHostMain::WindowPresentSwapChain() void SampleRemoteMain::WindowPresentSwapChain()
{ {
HRESULT hr = m_swapChain->Present(0, 0); HRESULT hr = m_swapChain->Present(0, 0);
@ -845,7 +1096,7 @@ void SampleHostMain::WindowPresentSwapChain()
} }
} }
void SampleHostMain::WindowUpdateTitle() void SampleRemoteMain::WindowUpdateTitle()
{ {
std::wstring title = TITLE_TEXT; std::wstring title = TITLE_TEXT;
std::wstring separator = TITLE_SEPARATOR; std::wstring separator = TITLE_SEPARATOR;
@ -856,18 +1107,24 @@ void SampleHostMain::WindowUpdateTitle()
// Title | {ip} | {State} [| Press Space to Connect] [| Preview Disabled (p toggles)] // Title | {ip} | {State} [| Press Space to Connect] [| Preview Disabled (p toggles)]
title += separator + m_hostname; title += separator + m_hostname;
{ {
std::lock_guard remoteContextLock(m_remoteContextAccess);
if (m_remoteContext) if (m_remoteContext)
{ {
auto connectionState = m_remoteContext.ConnectionState(); auto connectionState = m_remoteContext.ConnectionState();
title += separator + (m_isInitialized ? StreamerConnectionStateToString(connectionState) : L"Initializing"); title +=
separator + (m_isInitialized ? StreamerConnectionStateToString(connectionState, m_disconnectPending) : L"Initializing");
title += separator + ((connectionState == ConnectionState::Disconnected) ? TITLE_CONNECT_TEXT : TITLE_DISCONNECT_TEXT); title += separator + ((connectionState == ConnectionState::Disconnected) ? TITLE_CONNECT_TEXT : TITLE_DISCONNECT_TEXT);
} }
else else if (!m_isStandalone)
{ {
title += separator + TITLE_CONNECT_TEXT; title += separator + TITLE_CONNECT_TEXT;
} }
if (!m_isStandalone)
{
title += separator + (m_showPreview ? TITLE_DISABLE_PREVIEW_TEXT : TITLE_ENABLE_PREVIEW_TEXT); title += separator + (m_showPreview ? TITLE_DISABLE_PREVIEW_TEXT : TITLE_ENABLE_PREVIEW_TEXT);
} }
}
if (auto window = m_window.lock()) if (auto window = m_window.lock())
{ {
@ -876,12 +1133,13 @@ void SampleHostMain::WindowUpdateTitle()
} }
#ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE #ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
void SampleHostMain::OnCustomDataChannelDataReceived() void SampleRemoteMain::OnCustomDataChannelDataReceived()
{ {
// TODO: React on data received via the custom data channel here. // TODO: React on data received via the custom data channel here.
OutputDebugString(TEXT("Response Received.\n"));
} }
void SampleHostMain::OnCustomDataChannelClosed() void SampleRemoteMain::OnCustomDataChannelClosed()
{ {
std::lock_guard lock(m_customDataChannelLock); std::lock_guard lock(m_customDataChannelLock);
if (m_customDataChannel) if (m_customDataChannel)

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

@ -24,7 +24,6 @@
#include <winrt/Microsoft.Holographic.AppRemoting.h> #include <winrt/Microsoft.Holographic.AppRemoting.h>
#define INITIAL_WINDOW_WIDTH 1280 #define INITIAL_WINDOW_WIDTH 1280
#define INITIAL_WINDOW_HEIGHT 720 #define INITIAL_WINDOW_HEIGHT 720
@ -35,8 +34,9 @@
#define TITLE_ENABLE_PREVIEW_TEXT L"Preview Disabled (press P to enable)" #define TITLE_ENABLE_PREVIEW_TEXT L"Preview Disabled (press P to enable)"
#define TITLE_DISABLE_PREVIEW_TEXT L"Preview Enabled (press P to disable)" #define TITLE_DISABLE_PREVIEW_TEXT L"Preview Enabled (press P to disable)"
// #define ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
class SampleHostMain : public std::enable_shared_from_this<SampleHostMain>, public DXHelper::IDeviceNotify class SampleRemoteMain : public std::enable_shared_from_this<SampleRemoteMain>, public DXHelper::IDeviceNotify
{ {
public: public:
struct IWindow struct IWindow
@ -44,14 +44,16 @@ public:
virtual winrt::com_ptr<IDXGISwapChain1> virtual winrt::com_ptr<IDXGISwapChain1>
CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) = 0; CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) = 0;
virtual winrt::Windows::Graphics::Holographic::HolographicSpace CreateHolographicSpace() = 0;
virtual winrt::Windows::UI::Input::Spatial::SpatialInteractionManager CreateInteractionManager() = 0;
virtual void SetWindowTitle(std::wstring title) = 0; virtual void SetWindowTitle(std::wstring title) = 0;
}; };
public: public:
SampleHostMain(std::weak_ptr<IWindow> window); SampleRemoteMain(std::weak_ptr<IWindow> window);
~SampleHostMain(); ~SampleRemoteMain();
// Creates a HolographicFrame and updates the content. // Creates a HolographicFrame and updates the content.
winrt::Windows::Graphics::Holographic::HolographicFrame Update(); winrt::Windows::Graphics::Holographic::HolographicFrame Update();
@ -64,7 +66,12 @@ public:
return m_deviceResources; return m_deviceResources;
} }
void SetHostOptions(bool listen, const std::wstring& hostname, uint32_t port); // Initialize SampleRemoteMain for remote rendering targeting a HolographicRemotingPlayer.
void
ConfigureRemoting(bool listen, const std::wstring& hostname, uint16_t port, uint16_t transportPort = 0, bool ephemeralPort = false);
// Initialize SampleRemoteMain for local rendering targeting HoloLens or Windows Mixed Reality headsets.
void InitializeStandalone();
// Responds to key presses. // Responds to key presses.
void OnKeyPress(char key); void OnKeyPress(char key);
@ -79,10 +86,10 @@ public:
virtual void OnDeviceLost(); virtual void OnDeviceLost();
virtual void OnDeviceRestored(); virtual void OnDeviceRestored();
private:
// Initializes the RemoteContext and starts connecting or listening to the currently set network address // Initializes the RemoteContext and starts connecting or listening to the currently set network address
void InitializeRemoteContextAndConnectOrListen(); void InitializeRemoteContextAndConnectOrListen();
private:
// Initializes the HolographicSpace and creates graphics device dependent resources // Initializes the HolographicSpace and creates graphics device dependent resources
void CreateHolographicSpaceAndDeviceResources(); void CreateHolographicSpaceAndDeviceResources();
@ -95,12 +102,17 @@ private:
// Saves the position of the spinning cube. // Saves the position of the spinning cube.
void SavePosition(); void SavePosition();
// Exports a test anchor via SpatialAnchorExporter.
winrt::fire_and_forget ExportPosition();
// Request access for eyes pose data. // Request access for eyes pose data.
void RequestEyesPoseAccess(); void RequestEyesPoseAccess();
// Create the perception device handler which is required for qr code tracking.
winrt::fire_and_forget CreatePerceptionDeviceHandler();
// Clears event registration state. Used when changing to a new HolographicSpace // Clears event registration state. Used when changing to a new HolographicSpace
// and when tearing down SampleHostMain. // and when tearing down SampleRemoteMain.
void UnregisterHolographicEventHandlers(); void UnregisterHolographicEventHandlers();
// Shuts down the RemoteContext (which will also disconnect, if currently connected) // Shuts down the RemoteContext (which will also disconnect, if currently connected)
@ -130,6 +142,8 @@ private:
void OnLocatabilityChanged( void OnLocatabilityChanged(
const winrt::Windows::Perception::Spatial::SpatialLocator& sender, const winrt::Windows::Foundation::IInspectable& args); const winrt::Windows::Perception::Spatial::SpatialLocator& sender, const winrt::Windows::Foundation::IInspectable& args);
void OnDisconnected(winrt::Microsoft::Holographic::AppRemoting::ConnectionFailureReason failureReason);
#ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE #ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
void OnCustomDataChannelDataReceived(); void OnCustomDataChannelDataReceived();
void OnCustomDataChannelClosed(); void OnCustomDataChannelClosed();
@ -140,12 +154,21 @@ private:
std::chrono::high_resolution_clock::time_point m_startTime = std::chrono::high_resolution_clock::now(); std::chrono::high_resolution_clock::time_point m_startTime = std::chrono::high_resolution_clock::now();
// Lock to serialize remote context operations and event handlers
std::recursive_mutex m_remoteContextAccess;
// RemoteContext used to connect with a Holographic Remoting player and display rendered frames // RemoteContext used to connect with a Holographic Remoting player and display rendered frames
winrt::Microsoft::Holographic::AppRemoting::RemoteContext m_remoteContext = nullptr; winrt::Microsoft::Holographic::AppRemoting::RemoteContext m_remoteContext = nullptr;
// Whether a disconnect is currently pending.
bool m_disconnectPending{false};
// Represents the holographic space around the user. // Represents the holographic space around the user.
winrt::Windows::Graphics::Holographic::HolographicSpace m_holographicSpace = nullptr; winrt::Windows::Graphics::Holographic::HolographicSpace m_holographicSpace = nullptr;
// The interaction manager provides an event that informs the app when spatial interactions are detected.
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager m_interactionManager = nullptr;
// Cached pointer to device resources. // Cached pointer to device resources.
std::shared_ptr<DXHelper::DeviceResources> m_deviceResources; std::shared_ptr<DXHelper::DeviceResources> m_deviceResources;
@ -164,7 +187,7 @@ private:
// Listens for the Pressed spatial input event. // Listens for the Pressed spatial input event.
std::shared_ptr<SpatialInputHandler> m_spatialInputHandler; std::shared_ptr<SpatialInputHandler> m_spatialInputHandler;
std::unique_ptr<SpatialInputRenderer> m_spatialInputRenderer; std::shared_ptr<SpatialInputRenderer> m_spatialInputRenderer;
// Handles perception root objects and their events/updates // Handles perception root objects and their events/updates
std::shared_ptr<PerceptionDeviceHandler> m_perceptionDeviceHandler; std::shared_ptr<PerceptionDeviceHandler> m_perceptionDeviceHandler;
@ -184,7 +207,9 @@ private:
// Host options // Host options
std::wstring m_hostname; std::wstring m_hostname;
uint32_t m_port{0}; uint16_t m_port{0};
uint16_t m_transportPort{0};
bool m_ephemeralPort = false;
bool m_showPreview = true; bool m_showPreview = true;
bool m_listen{false}; bool m_listen{false};
@ -200,12 +225,16 @@ private:
winrt::com_ptr<IDXGISwapChain1> m_swapChain; winrt::com_ptr<IDXGISwapChain1> m_swapChain;
winrt::com_ptr<ID3D11Texture2D> m_spTexture; winrt::com_ptr<ID3D11Texture2D> m_spTexture;
bool m_canCommitDirect3D11DepthBuffer = false;
bool m_commitDirect3D11DepthBuffer = true;
bool m_isStandalone = false;
#ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE #ifdef ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
std::recursive_mutex m_customDataChannelLock; std::recursive_mutex m_customDataChannelLock;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel m_customDataChannel = nullptr; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2 m_customDataChannel = nullptr;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel::OnDataReceived_revoker m_customChannelDataReceivedEventRevoker; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2::OnDataReceived_revoker m_customChannelDataReceivedEventRevoker;
winrt::Microsoft::Holographic::AppRemoting::IDataChannel::OnClosed_revoker m_customChannelClosedEventRevoker; winrt::Microsoft::Holographic::AppRemoting::IDataChannel2::OnClosed_revoker m_customChannelClosedEventRevoker;
std::chrono::high_resolution_clock::time_point m_customDataChannelSendTime = std::chrono::high_resolution_clock::now(); std::chrono::high_resolution_clock::time_point m_customDataChannelSendTime = std::chrono::high_resolution_clock::now();
#endif #endif
}; };

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

@ -11,7 +11,7 @@
#include "pch.h" #include "pch.h"
#include "SampleHostWindowUWP.h" #include "SampleRemoteWindowUWP.h"
#include "Common\DbgLog.h" #include "Common\DbgLog.h"
#include "Common\Speech.h" #include "Common\Speech.h"
@ -40,48 +40,47 @@ using namespace winrt::Microsoft::Holographic::AppRemoting;
using namespace winrt::Windows::UI::Core; using namespace winrt::Windows::UI::Core;
using namespace winrt::Windows::UI::ViewManagement; using namespace winrt::Windows::UI::ViewManagement;
// The main function is only used to initialize our IFrameworkView class. // The main function is only used to initialize our IFrameworkView class.
int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int) int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
{ {
winrt::init_apartment(); winrt::init_apartment();
CoreApplication::Run(winrt::make<SampleHostWindowUWPView>()); CoreApplication::Run(winrt::make<SampleRemoteWindowUWPView>());
} }
SampleHostWindowUWP::SampleHostWindowUWP() SampleRemoteWindowUWP::SampleRemoteWindowUWP()
{ {
ApplicationView::PreferredLaunchViewSize(winrt::Windows::Foundation::Size(INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT)); ApplicationView::PreferredLaunchViewSize(winrt::Windows::Foundation::Size(INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT));
} }
// The first method called when the IFrameworkView is being created. // The first method called when the IFrameworkView is being created.
void SampleHostWindowUWP::Initialize(const CoreApplicationView& applicationView) void SampleRemoteWindowUWP::Initialize(const CoreApplicationView& applicationView)
{ {
CoreApplication::Suspending({this, &SampleHostWindowUWP::OnSuspending}); CoreApplication::Suspending({this, &SampleRemoteWindowUWP::OnSuspending});
CoreApplication::Resuming({this, &SampleHostWindowUWP::OnResuming}); CoreApplication::Resuming({this, &SampleRemoteWindowUWP::OnResuming});
applicationView.Activated({this, &SampleHostWindowUWP::OnViewActivated}); applicationView.Activated({this, &SampleRemoteWindowUWP::OnViewActivated});
m_main = std::make_shared<SampleHostMain>(weak_from_this()); m_main = std::make_shared<SampleRemoteMain>(weak_from_this());
} }
// Called when the CoreWindow object is created (or re-created). // Called when the CoreWindow object is created (or re-created).
void SampleHostWindowUWP::SetWindow(const CoreWindow& window) void SampleRemoteWindowUWP::SetWindow(const CoreWindow& window)
{ {
m_window = window; m_window = window;
window.SizeChanged({this, &SampleHostWindowUWP::OnWindowSizeChanged}); window.SizeChanged({this, &SampleRemoteWindowUWP::OnWindowSizeChanged});
window.VisibilityChanged({this, &SampleHostWindowUWP::OnVisibilityChanged}); window.VisibilityChanged({this, &SampleRemoteWindowUWP::OnVisibilityChanged});
window.Closed({this, &SampleHostWindowUWP::OnWindowClosed}); window.Closed({this, &SampleRemoteWindowUWP::OnWindowClosed});
window.KeyDown({this, &SampleHostWindowUWP::OnKeyDown}); window.KeyDown({this, &SampleRemoteWindowUWP::OnKeyDown});
} }
// Initializes scene resources, or loads a previously saved app state. // Initializes scene resources, or loads a previously saved app state.
void SampleHostWindowUWP::Load(const winrt::hstring& entryPoint) void SampleRemoteWindowUWP::Load(const winrt::hstring& entryPoint)
{ {
} }
// This method is called after the window becomes active. // This method is called after the window becomes active.
void SampleHostWindowUWP::Run() void SampleRemoteWindowUWP::Run()
{ {
CoreWindow window = CoreWindow::GetForCurrentThread(); CoreWindow window = CoreWindow::GetForCurrentThread();
window.Activate(); window.Activate();
@ -110,13 +109,12 @@ void SampleHostWindowUWP::Run()
// Required for IFrameworkView. // Required for IFrameworkView.
// Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView // Terminate events do not cause Uninitialize to be called. It will be called if your IFrameworkView
// class is torn down while the app is in the foreground. // class is torn down while the app is in the foreground.
void SampleHostWindowUWP::Uninitialize() void SampleRemoteWindowUWP::Uninitialize()
{ {
} }
winrt::com_ptr<IDXGISwapChain1> winrt::com_ptr<IDXGISwapChain1>
SampleHostWindowUWP::CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) SampleRemoteWindowUWP::CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc)
{ {
winrt::com_ptr<IDXGIDevice3> dxgiDevice; winrt::com_ptr<IDXGIDevice3> dxgiDevice;
device.as(dxgiDevice); device.as(dxgiDevice);
@ -134,7 +132,17 @@ winrt::com_ptr<IDXGISwapChain1>
return swapChain; return swapChain;
} }
void SampleHostWindowUWP::SetWindowTitle(std::wstring title) winrt::Windows::Graphics::Holographic::HolographicSpace SampleRemoteWindowUWP::CreateHolographicSpace()
{
return HolographicSpace::CreateForCoreWindow(m_window);
}
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager SampleRemoteWindowUWP::CreateInteractionManager()
{
return winrt::Windows::UI::Input::Spatial::SpatialInteractionManager::GetForCurrentView();
}
void SampleRemoteWindowUWP::SetWindowTitle(std::wstring title)
{ {
auto dispatcher = winrt::Windows::ApplicationModel::Core::CoreApplication::MainView().CoreWindow().Dispatcher(); auto dispatcher = winrt::Windows::ApplicationModel::Core::CoreApplication::MainView().CoreWindow().Dispatcher();
@ -163,11 +171,11 @@ void SampleHostWindowUWP::SetWindowTitle(std::wstring title)
// Application lifecycle event handlers. // Application lifecycle event handlers.
void SampleHostWindowUWP::OnSuspending(const winrt::Windows::Foundation::IInspectable& sender, const SuspendingEventArgs& args) void SampleRemoteWindowUWP::OnSuspending(const winrt::Windows::Foundation::IInspectable& sender, const SuspendingEventArgs& args)
{ {
} }
void SampleHostWindowUWP::OnResuming( void SampleRemoteWindowUWP::OnResuming(
const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args) const winrt::Windows::Foundation::IInspectable& sender, const winrt::Windows::Foundation::IInspectable& args)
{ {
// Restore any data or state that was unloaded on suspend. By default, data // Restore any data or state that was unloaded on suspend. By default, data
@ -179,25 +187,25 @@ void SampleHostWindowUWP::OnResuming(
// Window event handlers. // Window event handlers.
void SampleHostWindowUWP::OnWindowSizeChanged( void SampleRemoteWindowUWP::OnWindowSizeChanged(
const winrt::Windows::Foundation::IInspectable& sender, const WindowSizeChangedEventArgs& args) const winrt::Windows::Foundation::IInspectable& sender, const WindowSizeChangedEventArgs& args)
{ {
winrt::Windows::Foundation::Size size = args.Size(); winrt::Windows::Foundation::Size size = args.Size();
m_main->OnResize(static_cast<int>(size.Width + 0.5f), static_cast<int>(size.Height + 0.5f)); m_main->OnResize(static_cast<int>(size.Width + 0.5f), static_cast<int>(size.Height + 0.5f));
} }
void SampleHostWindowUWP::OnVisibilityChanged( void SampleRemoteWindowUWP::OnVisibilityChanged(
const winrt::Windows::Foundation::IInspectable& sender, const VisibilityChangedEventArgs& args) const winrt::Windows::Foundation::IInspectable& sender, const VisibilityChangedEventArgs& args)
{ {
m_windowVisible = args.Visible(); m_windowVisible = args.Visible();
} }
void SampleHostWindowUWP::OnWindowClosed(const CoreWindow& window, const CoreWindowEventArgs& args) void SampleRemoteWindowUWP::OnWindowClosed(const CoreWindow& window, const CoreWindowEventArgs& args)
{ {
m_windowClosed = true; m_windowClosed = true;
} }
void SampleHostWindowUWP::OnKeyDown(const CoreWindow& window, const KeyEventArgs& args) void SampleRemoteWindowUWP::OnKeyDown(const CoreWindow& window, const KeyEventArgs& args)
{ {
int32_t key = static_cast<int32_t>(args.VirtualKey()); int32_t key = static_cast<int32_t>(args.VirtualKey());
if (key >= 0 && key <= 0xFF) if (key >= 0 && key <= 0xFF)
@ -206,7 +214,7 @@ void SampleHostWindowUWP::OnKeyDown(const CoreWindow& window, const KeyEventArgs
} }
} }
void SampleHostWindowUWP::OnViewActivated(CoreApplicationView const& sender, IActivatedEventArgs const& activationArgs) void SampleRemoteWindowUWP::OnViewActivated(CoreApplicationView const& sender, IActivatedEventArgs const& activationArgs)
{ {
using namespace winrt::Windows::ApplicationModel; using namespace winrt::Windows::ApplicationModel;
using namespace Activation; using namespace Activation;
@ -214,6 +222,7 @@ void SampleHostWindowUWP::OnViewActivated(CoreApplicationView const& sender, IAc
std::wstring host = L"127.0.0.1"; std::wstring host = L"127.0.0.1";
int32_t port = 8265; int32_t port = 8265;
bool isStandalone = false;
if (activationArgs != nullptr) if (activationArgs != nullptr)
{ {
@ -234,6 +243,12 @@ void SampleHostWindowUWP::OnViewActivated(CoreApplicationView const& sender, IAc
if (arg.size() == 0) if (arg.size() == 0)
continue; continue;
if (arg == L"-standalone")
{
isStandalone = true;
continue;
}
size_t colonPos = arg.find(L':'); size_t colonPos = arg.find(L':');
if (colonPos != std::wstring::npos) if (colonPos != std::wstring::npos)
{ {
@ -250,6 +265,8 @@ void SampleHostWindowUWP::OnViewActivated(CoreApplicationView const& sender, IAc
} }
} }
if (!isStandalone)
{
// check for invalid port numbers // check for invalid port numbers
if (port < 0 || port > 65535) if (port < 0 || port > 65535)
{ {
@ -259,43 +276,48 @@ void SampleHostWindowUWP::OnViewActivated(CoreApplicationView const& sender, IAc
m_ipAddress = host; m_ipAddress = host;
m_port = port; m_port = port;
m_main->SetHostOptions(false, m_ipAddress, m_port); m_main->ConfigureRemoting(false, m_ipAddress, m_port);
}
else
{
m_main->InitializeStandalone();
}
// Run() won't start until the CoreWindow is activated. // Run() won't start until the CoreWindow is activated.
sender.CoreWindow().Activate(); sender.CoreWindow().Activate();
} }
SampleHostWindowUWPView::SampleHostWindowUWPView() SampleRemoteWindowUWPView::SampleRemoteWindowUWPView()
{ {
m_window = std::make_shared<SampleHostWindowUWP>(); m_window = std::make_shared<SampleRemoteWindowUWP>();
} }
winrt::Windows::ApplicationModel::Core::IFrameworkView SampleHostWindowUWPView::CreateView() winrt::Windows::ApplicationModel::Core::IFrameworkView SampleRemoteWindowUWPView::CreateView()
{ {
return *this; return *this;
} }
void SampleHostWindowUWPView::Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView) void SampleRemoteWindowUWPView::Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView)
{ {
m_window->Initialize(applicationView); m_window->Initialize(applicationView);
} }
void SampleHostWindowUWPView::SetWindow(const winrt::Windows::UI::Core::CoreWindow& window) void SampleRemoteWindowUWPView::SetWindow(const winrt::Windows::UI::Core::CoreWindow& window)
{ {
m_window->SetWindow(window); m_window->SetWindow(window);
} }
void SampleHostWindowUWPView::Load(const winrt::hstring& entryPoint) void SampleRemoteWindowUWPView::Load(const winrt::hstring& entryPoint)
{ {
m_window->Load(entryPoint); m_window->Load(entryPoint);
} }
void SampleHostWindowUWPView::Run() void SampleRemoteWindowUWPView::Run()
{ {
m_window->Run(); m_window->Run();
} }
void SampleHostWindowUWPView::Uninitialize() void SampleRemoteWindowUWPView::Uninitialize()
{ {
m_window->Uninitialize(); m_window->Uninitialize();
} }

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

@ -11,19 +11,18 @@
#pragma once #pragma once
#include "SampleHostMain.h" #include "SampleRemoteMain.h"
#include "Common\DeviceResources.h" #include "Common\DeviceResources.h"
#include <winrt/Microsoft.Holographic.AppRemoting.h> #include <winrt/Microsoft.Holographic.AppRemoting.h>
#include <winrt/Windows.ApplicationModel.Core.h> #include <winrt/Windows.ApplicationModel.Core.h>
// Main entry point for our app. Connects the app with the Windows shell and handles application lifecycle events. // Main entry point for our app. Connects the app with the Windows shell and handles application lifecycle events.
class SampleHostWindowUWP : public std::enable_shared_from_this<SampleHostWindowUWP>, public SampleHostMain::IWindow class SampleRemoteWindowUWP : public std::enable_shared_from_this<SampleRemoteWindowUWP>, public SampleRemoteMain::IWindow
{ {
public: public:
SampleHostWindowUWP(); SampleRemoteWindowUWP();
// IFrameworkView methods // IFrameworkView methods
virtual void Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView); virtual void Initialize(const winrt::Windows::ApplicationModel::Core::CoreApplicationView& applicationView);
@ -32,10 +31,14 @@ public:
virtual void Run(); virtual void Run();
virtual void Uninitialize(); virtual void Uninitialize();
// SampleHostMain::IWindow methods. // SampleRemoteMain::IWindow methods.
virtual winrt::com_ptr<IDXGISwapChain1> virtual winrt::com_ptr<IDXGISwapChain1>
CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) override; CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) override;
virtual winrt::Windows::Graphics::Holographic::HolographicSpace CreateHolographicSpace() override;
virtual winrt::Windows::UI::Input::Spatial::SpatialInteractionManager CreateInteractionManager() override;
virtual void SetWindowTitle(std::wstring title) override; virtual void SetWindowTitle(std::wstring title) override;
protected: protected:
@ -59,20 +62,20 @@ protected:
private: private:
winrt::Windows::UI::Core::CoreWindow m_window = nullptr; winrt::Windows::UI::Core::CoreWindow m_window = nullptr;
std::shared_ptr<SampleHostMain> m_main; std::shared_ptr<SampleRemoteMain> m_main;
std::wstring m_ipAddress; std::wstring m_ipAddress;
int32_t m_port = 8265; int32_t m_port = 8265;
bool m_windowClosed = false; bool m_windowClosed = false;
bool m_windowVisible = true; bool m_windowVisible = true;
}; };
class SampleHostWindowUWPView : public winrt::implements< class SampleRemoteWindowUWPView : public winrt::implements<
SampleHostWindowUWPView, SampleRemoteWindowUWPView,
winrt::Windows::ApplicationModel::Core::IFrameworkViewSource, winrt::Windows::ApplicationModel::Core::IFrameworkViewSource,
winrt::Windows::ApplicationModel::Core::IFrameworkView> winrt::Windows::ApplicationModel::Core::IFrameworkView>
{ {
public: public:
SampleHostWindowUWPView(); SampleRemoteWindowUWPView();
// IFrameworkViewSource methods. // IFrameworkViewSource methods.
winrt::Windows::ApplicationModel::Core::IFrameworkView CreateView(); winrt::Windows::ApplicationModel::Core::IFrameworkView CreateView();
@ -85,5 +88,5 @@ public:
virtual void Uninitialize(); virtual void Uninitialize();
private: private:
std::shared_ptr<SampleHostWindowUWP> m_window; std::shared_ptr<SampleRemoteWindowUWP> m_window;
}; };

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

@ -0,0 +1,363 @@
//*********************************************************
//
// Copyright (c) Microsoft. All rights reserved.
// This code is licensed under the MIT License (MIT).
// THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
// IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
// PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
//
//*********************************************************
#include "pch.h"
#include <windows.graphics.holographic.h>
#include <windows.ui.input.spatial.h>
#include <SampleRemoteWindowWin32.h>
#include <HolographicAppRemoting/Streamer.h>
#include <HolographicSpaceInterop.h>
#include <SpatialInteractionManagerInterop.h>
#include <Common/DbgLog.h>
#include <DirectXColors.h>
#include <codecvt>
#include <regex>
#include <windows.graphics.directx.direct3d11.interop.h>
#define WINDOWCLASSNAME L"SampleRemoteWindowWin32Class"
LRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static SampleRemoteWindowWin32* s_sampleHostWindow;
LRESULT result = 0;
switch (msg)
{
case WM_CREATE:
{
CREATESTRUCT* cs = reinterpret_cast<CREATESTRUCT*>(lParam);
s_sampleHostWindow = reinterpret_cast<SampleRemoteWindowWin32*>(cs->lpCreateParams);
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
result = 0;
}
break;
case WM_WINDOWPOSCHANGED:
{
auto windowPos = reinterpret_cast<WINDOWPOS*>(lParam);
if ((windowPos->flags & SWP_NOSIZE) == 0)
{
RECT clientRect;
GetClientRect(hWnd, &clientRect);
s_sampleHostWindow->OnResize(clientRect.right - clientRect.left, clientRect.bottom - clientRect.top);
}
result = 0;
}
break;
case WM_DESTROY:
{
s_sampleHostWindow = nullptr;
result = 0;
PostQuitMessage(0);
}
break;
case WM_CLOSE:
{
DestroyWindow(hWnd);
result = 0;
}
break;
case WM_CHAR:
{
const int key = tolower(static_cast<int>(wParam));
s_sampleHostWindow->OnKeyPress(static_cast<char>(key));
}
break;
default:
result = DefWindowProc(hWnd, msg, wParam, lParam);
break;
}
return result;
}
namespace
{
std::wstring SplitHostnameAndPortString(const std::wstring& address, uint16_t& port)
{
static std::basic_regex<wchar_t> addressMatcher(L"(?:(\\[.*\\])|([^:]*))(?:[:](\\d+))?");
std::match_results<typename std::wstring::const_iterator> results;
if (std::regex_match(address, results, addressMatcher))
{
if (results[3].matched)
{
std::wstring portStr = results[3].str();
port = static_cast<uint16_t>(std::wcstol(portStr.c_str(), nullptr, 10));
}
return (results[1].matched) ? results[1].str() : results[2].str();
}
else
{
return address;
}
}
} // namespace
void SampleRemoteWindowWin32::Initialize()
{
m_main = std::make_shared<SampleRemoteMain>(weak_from_this());
}
void SampleRemoteWindowWin32::InitializeHwnd(HWND hWnd)
{
m_hWnd = hWnd;
}
void SampleRemoteWindowWin32::ConfigureRemoting(
bool listen, const std::wstring& hostname, uint16_t port, uint16_t transportPort, bool ephemeralPort)
{
m_main->ConfigureRemoting(listen, hostname, port, transportPort, ephemeralPort);
}
void SampleRemoteWindowWin32::Connect()
{
m_main->InitializeRemoteContextAndConnectOrListen();
}
void SampleRemoteWindowWin32::InitializeStandalone()
{
m_main->InitializeStandalone();
}
void SampleRemoteWindowWin32::Tick()
{
if (const HolographicFrame& holographicFrame = m_main->Update())
{
m_main->Render(holographicFrame);
}
}
void SampleRemoteWindowWin32::OnKeyPress(char key)
{
m_main->OnKeyPress(key);
}
void SampleRemoteWindowWin32::OnResize(int width, int height)
{
m_main->OnResize(width, height);
}
winrt::com_ptr<IDXGISwapChain1>
SampleRemoteWindowWin32::CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc)
{
winrt::com_ptr<IDXGIDevice1> dxgiDevice;
device.as(dxgiDevice);
winrt::com_ptr<IDXGIAdapter> dxgiAdapter;
winrt::check_hresult(dxgiDevice->GetAdapter(dxgiAdapter.put()));
winrt::com_ptr<IDXGIFactory2> dxgiFactory;
winrt::check_hresult(dxgiAdapter->GetParent(__uuidof(IDXGIFactory2), dxgiFactory.put_void()));
winrt::check_hresult(dxgiFactory->MakeWindowAssociation(m_hWnd, DXGI_MWA_NO_ALT_ENTER));
winrt::com_ptr<IDXGISwapChain1> swapChain = nullptr;
winrt::check_hresult(dxgiFactory->CreateSwapChainForHwnd(device.get(), m_hWnd, desc, nullptr, nullptr, swapChain.put()));
return swapChain;
}
void SampleRemoteWindowWin32::SetWindowTitle(std::wstring title)
{
if (m_hWnd)
{
if (!SetWindowTextW(m_hWnd, title.c_str()))
{
winrt::check_hresult(HRESULT_FROM_WIN32(GetLastError()));
}
}
}
winrt::Windows::Graphics::Holographic::HolographicSpace SampleRemoteWindowWin32::CreateHolographicSpace()
{
// Use WinRT factory to create the holographic space.
// See https://docs.microsoft.com/en-us/windows/win32/api/holographicspaceinterop/
winrt::com_ptr<IHolographicSpaceInterop> holographicSpaceInterop =
winrt::get_activation_factory<HolographicSpace, IHolographicSpaceInterop>();
winrt::com_ptr<ABI::Windows::Graphics::Holographic::IHolographicSpace> spHolographicSpace;
winrt::check_hresult(holographicSpaceInterop->CreateForWindow(
m_hWnd, __uuidof(ABI::Windows::Graphics::Holographic::IHolographicSpace), winrt::put_abi(spHolographicSpace)));
return spHolographicSpace.as<HolographicSpace>();
}
winrt::Windows::UI::Input::Spatial::SpatialInteractionManager SampleRemoteWindowWin32::CreateInteractionManager()
{
using namespace winrt::Windows::UI::Input::Spatial;
// Use WinRT factory to create the spatial interaction manager.
// See https://docs.microsoft.com/en-us/windows/win32/api/spatialinteractionmanagerinterop/
winrt::com_ptr<ISpatialInteractionManagerInterop> spatialInteractionManagerInterop =
winrt::get_activation_factory<SpatialInteractionManager, ISpatialInteractionManagerInterop>();
winrt::com_ptr<ABI::Windows::UI::Input::Spatial::ISpatialInteractionManager> spSpatialInteractionManager;
winrt::check_hresult(spatialInteractionManagerInterop->GetForWindow(
m_hWnd, __uuidof(ABI::Windows::UI::Input::Spatial::ISpatialInteractionManager), winrt::put_abi(spSpatialInteractionManager)));
return spSpatialInteractionManager.as<SpatialInteractionManager>();
}
int main(Platform::Array<Platform::String ^> ^ args)
{
winrt::init_apartment();
bool listen{false};
std::wstring host;
uint16_t port{0};
uint16_t transportPort{0};
bool isStandalone = false;
bool noUserWait = false;
bool useEphemeralPort = false;
for (unsigned int i = 1; i < args->Length; ++i)
{
if (args[i]->Length() == 0)
continue;
std::wstring arg = args[i]->Data();
if (arg[0] == '-')
{
std::wstring param = arg.substr(1);
std::transform(param.begin(), param.end(), param.begin(), ::tolower);
if (param == L"listen")
{
listen = true;
continue;
}
if (param == L"standalone")
{
isStandalone = true;
continue;
}
if (param == L"nouserwait")
{
noUserWait = true;
continue;
}
if (param == L"ephemeralport")
{
useEphemeralPort = true;
continue;
}
if (param == L"transportport")
{
if (args->Length > i + 1)
{
std::wstring transportPortStr = args[i + 1]->Data();
transportPort = std::stoi(transportPortStr);
i++;
}
continue;
}
}
host = SplitHostnameAndPortString(arg, port);
}
std::shared_ptr<SampleRemoteWindowWin32> sampleHostWindow = std::make_shared<SampleRemoteWindowWin32>();
sampleHostWindow->Initialize();
WNDCLASSEXW wcex = {};
wcex.cbSize = sizeof(wcex);
wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = wndProc;
wcex.hInstance = 0;
wcex.hIcon = LoadIcon(0, IDI_APPLICATION);
wcex.hCursor = LoadCursor(nullptr, IDC_ARROW);
wcex.hbrBackground = static_cast<HBRUSH>(GetStockObject(NULL_BRUSH));
wcex.lpszClassName = WINDOWCLASSNAME;
RegisterClassExW(&wcex);
RECT rc = {0, 0, INITIAL_WINDOW_WIDTH, INITIAL_WINDOW_HEIGHT};
AdjustWindowRectEx(&rc, WS_OVERLAPPEDWINDOW, FALSE, 0);
std::wstring windowName = TITLE_TEXT;
HWND hWnd = CreateWindowW(
WINDOWCLASSNAME,
windowName.c_str(),
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
rc.right - rc.left,
rc.bottom - rc.top,
nullptr,
nullptr,
0,
sampleHostWindow.get());
RECT clientRect;
GetClientRect(hWnd, &clientRect);
sampleHostWindow->InitializeHwnd(hWnd);
if (!isStandalone)
{
sampleHostWindow->ConfigureRemoting(listen, host, port, transportPort, useEphemeralPort);
if (noUserWait)
{
sampleHostWindow->Connect();
}
}
else
{
sampleHostWindow->InitializeStandalone();
}
ShowWindow(hWnd, SW_SHOWNORMAL);
bool quit = false;
while (!quit)
{
MSG msg = {0};
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
quit = true;
}
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
try
{
sampleHostWindow->Tick();
}
catch (...)
{
// Unhandeled exception during tick, exit program
return 1;
}
}
}
return 0;
}

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

@ -11,19 +11,20 @@
#pragma once #pragma once
//#include <winrt/Windows.Graphics.Holographic.h> #include <SampleRemoteMain.h>
#include "SampleHostMain.h" class SampleRemoteWindowWin32 : public std::enable_shared_from_this<SampleRemoteWindowWin32>, public SampleRemoteMain::IWindow
// #define ENABLE_CUSTOM_DATA_CHANNEL_SAMPLE
class SampleHostWindowWin32 : public std::enable_shared_from_this<SampleHostWindowWin32>, public SampleHostMain::IWindow
{ {
public: public:
void Initialize(bool listen, const std::wstring& host, uint32_t port); void Initialize();
void InitializeHwnd(HWND hWnd); void InitializeHwnd(HWND hWnd);
void ConfigureRemoting(bool listen, const std::wstring& hostname, uint16_t port, uint16_t transportPort, bool ephemeralPort);
void Connect();
void InitializeStandalone();
void Tick(); void Tick();
void OnKeyPress(char key); void OnKeyPress(char key);
@ -32,10 +33,14 @@ public:
virtual winrt::com_ptr<IDXGISwapChain1> virtual winrt::com_ptr<IDXGISwapChain1>
CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) override; CreateSwapChain(const winrt::com_ptr<ID3D11Device1>& device, const DXGI_SWAP_CHAIN_DESC1* desc) override;
virtual winrt::Windows::Graphics::Holographic::HolographicSpace CreateHolographicSpace() override;
virtual winrt::Windows::UI::Input::Spatial::SpatialInteractionManager CreateInteractionManager() override;
virtual void SetWindowTitle(std::wstring title) override; virtual void SetWindowTitle(std::wstring title) override;
private: private:
HWND m_hWnd = 0; HWND m_hWnd = 0;
std::shared_ptr<SampleHostMain> m_main; std::shared_ptr<SampleRemoteMain> m_main;
}; };

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

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Windows.CppWinRT" version="2.0.200224.2" targetFramework="native" />
<package id="Microsoft.Holographic.Remoting" version="2.1.0" targetFramework="native" />
</packages>

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

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

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

До

Ширина:  |  Высота:  |  Размер: 1.4 KiB

После

Ширина:  |  Высота:  |  Размер: 1.4 KiB

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

До

Ширина:  |  Высота:  |  Размер: 7.5 KiB

После

Ширина:  |  Высота:  |  Размер: 7.5 KiB

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

До

Ширина:  |  Высота:  |  Размер: 2.9 KiB

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

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

До

Ширина:  |  Высота:  |  Размер: 1.6 KiB

После

Ширина:  |  Высота:  |  Размер: 1.6 KiB

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

До

Ширина:  |  Высота:  |  Размер: 1.2 KiB

После

Ширина:  |  Высота:  |  Размер: 1.2 KiB

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше