diff --git a/WindowsUWP.sln b/WindowsUWP.sln
new file mode 100644
index 00000000..15ce31e3
--- /dev/null
+++ b/WindowsUWP.sln
@@ -0,0 +1,43 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27130.0
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UWPSwapchain", "WindowsUWP\Direct3D11\Swapchain\UWPSwapchain.csproj", "{948B81A7-97FF-4C62-82B6-35A8733DDD7F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.ActiveCfg = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.Build.0 = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|ARM.Deploy.0 = Debug|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.ActiveCfg = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.Build.0 = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x64.Deploy.0 = Debug|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.ActiveCfg = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.Build.0 = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Debug|x86.Deploy.0 = Debug|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.ActiveCfg = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.Build.0 = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|ARM.Deploy.0 = Release|ARM
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.ActiveCfg = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.Build.0 = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x64.Deploy.0 = Release|x64
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.ActiveCfg = Release|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.Build.0 = Release|x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}.Release|x86.Deploy.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {91C21AD8-0B37-492E-B233-289135C42A0E}
+ EndGlobalSection
+EndGlobal
diff --git a/WindowsUWP/Direct3D11/Swapchain/App.xaml b/WindowsUWP/Direct3D11/Swapchain/App.xaml
new file mode 100644
index 00000000..7f60b57e
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/App.xaml
@@ -0,0 +1,8 @@
+
+
+
diff --git a/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs b/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs
new file mode 100644
index 00000000..6f2f7948
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/App.xaml.cs
@@ -0,0 +1,100 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.ApplicationModel;
+using Windows.ApplicationModel.Activation;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+
+namespace UWPSwapchain
+{
+ ///
+ /// Provides application-specific behavior to supplement the default Application class.
+ ///
+ sealed partial class App : Application
+ {
+ ///
+ /// Initializes the singleton application object. This is the first line of authored code
+ /// executed, and as such is the logical equivalent of main() or WinMain().
+ ///
+ public App()
+ {
+ this.InitializeComponent();
+ this.Suspending += OnSuspending;
+ }
+
+ ///
+ /// Invoked when the application is launched normally by the end user. Other entry points
+ /// will be used such as when the application is launched to open a specific file.
+ ///
+ /// Details about the launch request and process.
+ protected override void OnLaunched(LaunchActivatedEventArgs e)
+ {
+ Frame rootFrame = Window.Current.Content as Frame;
+
+ // Do not repeat app initialization when the Window already has content,
+ // just ensure that the window is active
+ if (rootFrame == null)
+ {
+ // Create a Frame to act as the navigation context and navigate to the first page
+ rootFrame = new Frame();
+
+ rootFrame.NavigationFailed += OnNavigationFailed;
+
+ if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
+ {
+ //TODO: Load state from previously suspended application
+ }
+
+ // Place the frame in the current Window
+ Window.Current.Content = rootFrame;
+ }
+
+ if (e.PrelaunchActivated == false)
+ {
+ if (rootFrame.Content == null)
+ {
+ // When the navigation stack isn't restored navigate to the first page,
+ // configuring the new page by passing required information as a navigation
+ // parameter
+ rootFrame.Navigate(typeof(MainPage), e.Arguments);
+ }
+ // Ensure the current window is active
+ Window.Current.Activate();
+ }
+ }
+
+ ///
+ /// Invoked when Navigation to a certain page fails
+ ///
+ /// The Frame which failed navigation
+ /// Details about the navigation failure
+ void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
+ {
+ throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
+ }
+
+ ///
+ /// Invoked when application execution is being suspended. Application state is saved
+ /// without knowing whether the application will be terminated or resumed with the contents
+ /// of memory still intact.
+ ///
+ /// The source of the suspend request.
+ /// Details about the suspend request.
+ private void OnSuspending(object sender, SuspendingEventArgs e)
+ {
+ var deferral = e.SuspendingOperation.GetDeferral();
+ //TODO: Save application state and stop any background activity
+ deferral.Complete();
+ }
+ }
+}
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png
new file mode 100644
index 00000000..735f57ad
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/LockScreenLogo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png
new file mode 100644
index 00000000..023e7f1f
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/SplashScreen.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png
new file mode 100644
index 00000000..af49fec1
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square150x150Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png
new file mode 100644
index 00000000..ce342a2e
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
new file mode 100644
index 00000000..f6c02ce9
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png b/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png
new file mode 100644
index 00000000..7385b56c
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/StoreLogo.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png b/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png
new file mode 100644
index 00000000..288995b3
Binary files /dev/null and b/WindowsUWP/Direct3D11/Swapchain/Assets/Wide310x150Logo.scale-200.png differ
diff --git a/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml
new file mode 100644
index 00000000..dff91358
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+
+
diff --git a/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs
new file mode 100644
index 00000000..89868296
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/MainPage.xaml.cs
@@ -0,0 +1,151 @@
+using SharpDX.DXGI;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices.WindowsRuntime;
+using Windows.Foundation;
+using Windows.Foundation.Collections;
+using Windows.UI.Xaml;
+using Windows.UI.Xaml.Controls;
+using Windows.UI.Xaml.Controls.Primitives;
+using Windows.UI.Xaml.Data;
+using Windows.UI.Xaml.Input;
+using Windows.UI.Xaml.Media;
+using Windows.UI.Xaml.Navigation;
+using SharpDX;
+using SharpDX.Direct3D11;
+using Windows.ApplicationModel;
+using System.Text;
+using System.Diagnostics;
+
+namespace UWPSwapchain
+{
+
+
+ public sealed partial class MainPage : Page
+ {
+ SharpDX.Direct3D11.Device device;
+ SharpDX.Direct3D11.DeviceContext deviceContext;
+
+ SharpDX.DXGI.SwapChain1 swapchain;
+ Texture2D backBufferTexture;
+ RenderTargetView backBufferView;
+
+ Stopwatch sw = Stopwatch.StartNew();
+
+ public MainPage()
+ {
+ this.InitializeComponent();
+
+ bool enableDebug = false;
+
+ DeviceCreationFlags flags = DeviceCreationFlags.BgraSupport;
+ if (enableDebug)
+ flags |= DeviceCreationFlags.Debug;
+
+ this.device = new SharpDX.Direct3D11.Device(SharpDX.Direct3D.DriverType.Hardware, flags);
+ this.deviceContext = this.device.ImmediateContext;
+ }
+
+ private void CompositionTarget_Rendering(object sender, object e)
+ {
+ SharpDX.Color4 c = Color.Red;
+ c.Red = (float)Math.Abs(Math.Sin(sw.Elapsed.TotalSeconds));
+
+ //This is your render call, perform all render tasks and then call present on the swap chain
+ this.deviceContext.ClearRenderTargetView(this.backBufferView, c);
+
+ //Attach render target and set viewport
+ this.deviceContext.OutputMerger.SetRenderTargets(this.backBufferView);
+ this.deviceContext.Rasterizer.SetViewport(new ViewportF(0.0f, 0.0f, this.backBufferTexture.Description.Width, this.backBufferTexture.Description.Height, 0.0f, 1.0f));
+
+ //perform draw calls here
+
+ this.swapchain.Present(0, PresentFlags.None);
+ }
+
+ private void panel_Loaded(object sender, RoutedEventArgs e)
+ {
+ //This is trigerred when panel is loaded, you can now create your swap chain.
+
+ //Please note : Do not use this.panel.Width, make sure to use render size as width property returns NaN on create
+ SwapChainDescription1 swapChainDescription = new SwapChainDescription1()
+ {
+ AlphaMode = AlphaMode.Ignore,
+ BufferCount = 2,
+ Format = Format.R8G8B8A8_UNorm,
+ Height = (int)(this.panel.RenderSize.Height),
+ Width = (int)(this.panel.RenderSize.Width),
+ SampleDescription = new SampleDescription(1, 0),
+ Scaling = SharpDX.DXGI.Scaling.Stretch,
+ Stereo = false,
+ SwapEffect = SwapEffect.FlipSequential,
+ Usage = Usage.RenderTargetOutput
+ };
+
+ using (SharpDX.DXGI.Device3 dxgiDevice3 = this.device.QueryInterface())
+ {
+ using (SharpDX.DXGI.Factory3 dxgiFactory3 = dxgiDevice3.Adapter.GetParent())
+ {
+ SharpDX.DXGI.SwapChain1 swapChain1 = new SharpDX.DXGI.SwapChain1(dxgiFactory3, this.device, ref swapChainDescription);
+ this.swapchain = swapChain1;
+ }
+ }
+
+ using (SharpDX.DXGI.ISwapChainPanelNative nativeObject = SharpDX.ComObject.As(this.panel))
+ {
+ nativeObject.SwapChain = this.swapchain;
+ }
+
+ this.backBufferTexture = this.swapchain.GetBackBuffer(0);
+ this.backBufferView = new RenderTargetView(this.device, this.backBufferTexture);
+
+ CompositionTarget.Rendering += CompositionTarget_Rendering;
+ Application.Current.Suspending += Current_Suspending;
+ }
+
+ private void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e)
+ {
+ //This is the only part where you will receive a "close event", you should serialize any state so app can resume correctly.
+
+ //Please note that this method has a time out (e.SuspendingOperation.Deadline), if you do not return prior to this time, application will terminate instead of being suspended.
+
+ if (this.swapchain != null)
+ {
+ this.deviceContext.ClearState();
+ using (SharpDX.DXGI.Device3 dxgiDevice3 = this.device.QueryInterface())
+ dxgiDevice3.Trim();
+ }
+
+
+ }
+
+ private void panel_Unloaded(object sender, RoutedEventArgs e)
+ {
+ //On uwp windows 10 , this is never called, quitting the app does not do anything on it
+ }
+
+ private void panel_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ /* Resize swap chain, to do it cleanly, we clear state (to ensure resources are not bound to pipeline, and
+ * dispose associated resources (eg : render view and texture object)
+ * Once done, we can call resizebuffers, and create direct3d11 objects again */
+ if (this.swapchain != null)
+ {
+ this.deviceContext.ClearState();
+
+ Size2 newSize = new Size2((int)e.NewSize.Width, (int)e.NewSize.Height);
+
+ Utilities.Dispose(ref this.backBufferView);
+ Utilities.Dispose(ref this.backBufferTexture);
+
+ this.swapchain.ResizeBuffers(this.swapchain.Description.BufferCount, (int)e.NewSize.Width, (int)e.NewSize.Height, swapchain.Description1.Format, swapchain.Description1.Flags);
+
+ this.backBufferTexture = this.swapchain.GetBackBuffer(0);
+ this.backBufferView = new RenderTargetView(this.device, this.backBufferTexture);
+
+ }
+ }
+ }
+}
diff --git a/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest b/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest
new file mode 100644
index 00000000..ac056a7d
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Package.appxmanifest
@@ -0,0 +1,29 @@
+
+
+
+
+
+ TestUWPDX
+ vux
+ Assets\StoreLogo.png
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs b/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..69864852
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Properties/AssemblyInfo.cs
@@ -0,0 +1,29 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("TestUWPDX")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("TestUWPDX")]
+[assembly: AssemblyCopyright("Copyright © 2017")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
+[assembly: ComVisible(false)]
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml b/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml
new file mode 100644
index 00000000..7c40ffeb
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/Properties/Default.rd.xml
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj b/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj
new file mode 100644
index 00000000..8ae59154
--- /dev/null
+++ b/WindowsUWP/Direct3D11/Swapchain/UWPSwapchain.csproj
@@ -0,0 +1,154 @@
+
+
+
+
+ Debug
+ x86
+ {948B81A7-97FF-4C62-82B6-35A8733DDD7F}
+ AppContainerExe
+ Properties
+ TestUWPDX
+ TestUWPDX
+ en-US
+ UAP
+ 10.0.16299.0
+ 10.0.16299.0
+ 14
+ 512
+ {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ true
+ TestUWPDX_TemporaryKey.pfx
+
+
+ true
+ bin\x86\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x86
+ false
+ prompt
+ true
+
+
+ bin\x86\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x86
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\ARM\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ ARM
+ false
+ prompt
+ true
+
+
+ bin\ARM\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ ARM
+ false
+ prompt
+ true
+ true
+
+
+ true
+ bin\x64\Debug\
+ DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP
+ ;2008
+ full
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ bin\x64\Release\
+ TRACE;NETFX_CORE;WINDOWS_UWP
+ true
+ ;2008
+ pdbonly
+ x64
+ false
+ prompt
+ true
+ true
+
+
+ PackageReference
+
+
+
+ App.xaml
+
+
+ MainPage.xaml
+
+
+
+
+
+ Designer
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+
+
+ 5.2.2
+
+
+ 4.0.1
+
+
+ 4.0.1
+
+
+ 4.0.1
+
+
+
+ 14.0
+
+
+
+
\ No newline at end of file