From dfc0b3273371402956e3f19bbb18329c8d4225ee Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Sun, 26 Feb 2017 15:40:53 +0100 Subject: [PATCH] More work on UWP upbring --- UWP/App.cpp | 4 +- UWP/PPSSPP_UWPMain.cpp | 15 ++++++- UWP/Package.appxmanifest | 6 +-- UWP/UWP.vcxproj | 64 ++++++++++++++++++++++++++---- UWP/UWP.vcxproj.filters | 38 ++++++++++++++++++ ext/native/thin3d/thin3d_d3d11.cpp | 3 +- ext/native/ui/ui_context.cpp | 3 +- 7 files changed, 117 insertions(+), 16 deletions(-) diff --git a/UWP/App.cpp b/UWP/App.cpp index d6cdeab602..62e2111bef 100644 --- a/UWP/App.cpp +++ b/UWP/App.cpp @@ -73,11 +73,11 @@ void App::SetWindow(CoreWindow^ window) { DisplayInformation::DisplayContentsInvalidated += ref new TypedEventHandler(this, &App::OnDisplayContentsInvalidated); - window->KeyDown += ref new TypedEventHandler(this, &App::OnKeyDown); + // window->KeyDown += ref new TypedEventHandler(this, &App::OnKeyDown); m_deviceResources->SetWindow(window); } - + // Initializes scene resources, or loads a previously saved app state. void App::Load(Platform::String^ entryPoint) { if (m_main == nullptr) { diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index e1b251955c..ce567cd38d 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -19,10 +19,14 @@ using namespace UWP; using namespace Windows::Foundation; +using namespace Windows::Storage; using namespace Windows::System::Threading; using namespace Concurrency; +namespace UWP { + // TODO: Use Microsoft::WRL::ComPtr<> for D3D11 objects? +// TODO: See https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/WindowsAudioSession for WASAPI with UWP // Loads and initializes application assets when the application is loaded. PPSSPP_UWPMain::PPSSPP_UWPMain(const std::shared_ptr& deviceResources) : @@ -31,6 +35,8 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(const std::shared_ptr& devic // Register to be notified if the Device is lost or recreated m_deviceResources->RegisterDeviceNotify(this); + // create_task(KnownFolders::GetFolderForUserAsync(nullptr, KnownFolderId::RemovableDevices)).then([this](StorageFolder ^)); + // TODO: Change the timer settings if you want something other than the default variable timestep mode. // e.g. for 60 FPS fixed timestep update logic, call: /* @@ -90,9 +96,12 @@ PPSSPP_UWPMain::PPSSPP_UWPMain(const std::shared_ptr& devic NativeInit(1, argv, "", "", "", false); NativeInitGraphics(m_graphicsContext.get()); + NativeResized(); + m_graphicsContext->GetDrawContext()->HandleEvent(Draw::Event::GOT_BACKBUFFER); } PPSSPP_UWPMain::~PPSSPP_UWPMain() { + m_graphicsContext->GetDrawContext()->HandleEvent(Draw::Event::LOST_BACKBUFFER); NativeShutdownGraphics(); NativeShutdown(); @@ -120,6 +129,7 @@ bool PPSSPP_UWPMain::Render() { // Reset the viewport to target the whole screen. auto viewport = m_deviceResources->GetScreenViewport(); + m_deviceResources->GetBackBufferRenderTargetView() pixel_xres = viewport.Width; pixel_yres = viewport.Height; @@ -131,7 +141,6 @@ bool PPSSPP_UWPMain::Render() { dp_xres = pixel_xres * g_dpi_scale; dp_yres = pixel_yres * g_dpi_scale; - /* context->RSSetViewports(1, &viewport); // Reset render targets to the screen. @@ -141,7 +150,6 @@ bool PPSSPP_UWPMain::Render() { // Clear the back buffer and depth stencil view. context->ClearRenderTargetView(m_deviceResources->GetBackBufferRenderTargetView(), DirectX::Colors::CornflowerBlue); context->ClearDepthStencilView(m_deviceResources->GetDepthStencilView(), D3D11_CLEAR_DEPTH | D3D11_CLEAR_STENCIL, 1.0f, 0); - */ NativeRender(m_graphicsContext.get()); return true; } @@ -155,6 +163,7 @@ void PPSSPP_UWPMain::OnDeviceLost() { void PPSSPP_UWPMain::OnDeviceRestored() { CreateWindowSizeDependentResources(); + } UWPGraphicsContext::UWPGraphicsContext(std::shared_ptr resources) { @@ -169,6 +178,8 @@ void UWPGraphicsContext::SwapInterval(int interval) { } +} // namespace UWP + std::string System_GetProperty(SystemProperty prop) { static bool hasCheckedGPUDriverVersion = false; switch (prop) { diff --git a/UWP/Package.appxmanifest b/UWP/Package.appxmanifest index 359e07c205..48992445cc 100644 --- a/UWP/Package.appxmanifest +++ b/UWP/Package.appxmanifest @@ -20,15 +20,15 @@ - - - + + + \ No newline at end of file diff --git a/UWP/UWP.vcxproj b/UWP/UWP.vcxproj index 75ba1eb380..5d239396af 100644 --- a/UWP/UWP.vcxproj +++ b/UWP/UWP.vcxproj @@ -189,13 +189,36 @@ - - - - - - - + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + + + true + @@ -232,6 +255,28 @@ Designer + + true + + + true + Document + + + true + + + true + + + true + + + true + + + true + @@ -263,6 +308,11 @@ {ddf90203-0aae-4f38-b589-2e9637658ce6} + + + true + + diff --git a/UWP/UWP.vcxproj.filters b/UWP/UWP.vcxproj.filters index fa3d9f07e8..c2b493e02b 100644 --- a/UWP/UWP.vcxproj.filters +++ b/UWP/UWP.vcxproj.filters @@ -35,6 +35,9 @@ Assets + + {ef87b390-608f-4c6d-a0ad-88963875ed11} + @@ -54,11 +57,46 @@ Assets + + Content + + + Content + + + Content + + + Content + + + Content + + + Content + + + Content + + + Content + + + Content + + + Content + + + + + Content + \ No newline at end of file diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index f8f8ce9346..86b7deb1d7 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -1280,6 +1280,7 @@ bool D3D11DrawContext::BlitFramebuffer(Framebuffer *srcfb, int srcX1, int srcY1, // These functions should be self explanatory. void D3D11DrawContext::BindFramebufferAsRenderTarget(Framebuffer *fbo) { + // TODO: deviceContext1 can actually discard. Useful on Windows Mobile. D3D11Framebuffer *fb = (D3D11Framebuffer *)fbo; if (curRenderTargetView_ == fb->colorRTView && curDepthStencilView_ == fb->depthStencilRTView) { return; @@ -1336,4 +1337,4 @@ DrawContext *T3DCreateD3D11Context(ID3D11Device *device, ID3D11DeviceContext *co return new D3D11DrawContext(device, context, device1, context1, featureLevel, hWnd); } -} // namespace Draw \ No newline at end of file +} // namespace Draw diff --git a/ext/native/ui/ui_context.cpp b/ext/native/ui/ui_context.cpp index f287c63f50..c4e0b06c67 100644 --- a/ext/native/ui/ui_context.cpp +++ b/ext/native/ui/ui_context.cpp @@ -1,3 +1,4 @@ +#include "ppsspp_config.h" #include "base/display.h" #include "ui/ui.h" #include "ui/view.h" @@ -27,7 +28,7 @@ void UIContext::Init(Draw::DrawContext *thin3d, Draw::Pipeline *uipipe, Draw::Pi ui_pipeline_notex_ = uipipenotex; uidrawbuffer_ = uidrawbuffer; uidrawbufferTop_ = uidrawbufferTop; -#if defined(_WIN32) || defined(USING_QT_UI) +#if (defined(_WIN32) && !PPSSPP_PLATFORM(UWP)) || defined(USING_QT_UI) textDrawer_ = new TextDrawer(thin3d); #else textDrawer_ = nullptr;