diff --git a/Desktop/Direct3D12/HelloWPF/App.config b/Desktop/Direct3D12/HelloWPF/App.config
new file mode 100644
index 00000000..731f6de6
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Desktop/Direct3D12/HelloWPF/App.xaml b/Desktop/Direct3D12/HelloWPF/App.xaml
new file mode 100644
index 00000000..3a2fd1be
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/App.xaml
@@ -0,0 +1,9 @@
+
+
+
+
+
diff --git a/Desktop/Direct3D12/HelloWPF/App.xaml.cs b/Desktop/Direct3D12/HelloWPF/App.xaml.cs
new file mode 100644
index 00000000..fd48f161
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/App.xaml.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace HelloWPF {
+ ///
+ /// Logique d'interaction pour App.xaml
+ ///
+ public partial class App : Application {
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/AppWPF.cs b/Desktop/Direct3D12/HelloWPF/AppWPF.cs
new file mode 100644
index 00000000..29d15989
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/AppWPF.cs
@@ -0,0 +1,479 @@
+using SharpDX.DXGI;
+using System.Threading;
+using System;
+
+namespace HelloWPF
+{
+ using Microsoft.Wpf.Interop.DirectX;
+ using SharpDX;
+ using SharpDX.Direct3D12;
+ using System.Runtime.InteropServices;
+ using System.Windows;
+
+ public class AppWPF : IDisposable
+ {
+ ///
+ /// Initialise pipeline and assets
+ ///
+ /// The form
+ public void Initialize(int width, int height, IntPtr handle)
+ {
+
+ LoadPipeline(width, height, handle);
+ LoadAssets();
+ }
+
+ private void LoadPipeline(int width, int height, IntPtr handle)
+ {
+ viewport.Width = width;
+ viewport.Height = height;
+ viewport.MaxDepth = 1.0f;
+
+ scissorRect.Right = width;
+ scissorRect.Bottom = height;
+
+#if DEBUG
+ // Enable the D3D12 debug layer.
+ {
+ DebugInterface.Get().EnableDebugLayer();
+ }
+#endif
+ device = new Device(null, SharpDX.Direct3D.FeatureLevel.Level_11_0);
+ using (var factory = new Factory4())
+ {
+ // Describe and create the command queue.
+ var queueDesc = new CommandQueueDescription(CommandListType.Direct);
+ commandQueue = device.CreateCommandQueue(queueDesc);
+
+ var flags = SharpDX.Direct3D11.DeviceCreationFlags.BgraSupport;
+#if DEBUG
+ flags |= SharpDX.Direct3D11.DeviceCreationFlags.Debug;
+#endif
+
+ d3d11Device = SharpDX.Direct3D11.Device.CreateFromDirect3D12(device, flags, new[] { SharpDX.Direct3D.FeatureLevel.Level_11_0 }, null, commandQueue);
+ d3d11On12Device = d3d11Device.QueryInterface();
+
+ // Describe and create the swap chain.
+ var swapChainDesc = new SwapChainDescription()
+ {
+ BufferCount = FrameCount,
+ ModeDescription = new ModeDescription(width, height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
+ Usage = Usage.RenderTargetOutput,
+ SwapEffect = SwapEffect.FlipDiscard,
+ OutputHandle = handle,
+ //Flags = SwapChainFlags.None,
+ SampleDescription = new SampleDescription(1, 0),
+ IsWindowed = true
+ };
+
+ var tempSwapChain = new SwapChain(factory, commandQueue, swapChainDesc);
+ swapChain = tempSwapChain.QueryInterface();
+ tempSwapChain.Dispose();
+ frameIndex = swapChain.CurrentBackBufferIndex;
+ }
+
+ // Create descriptor heaps.
+ // Describe and create a render target view (RTV) descriptor heap.
+ var rtvHeapDesc = new DescriptorHeapDescription()
+ {
+ DescriptorCount = FrameCount,
+ Flags = DescriptorHeapFlags.None,
+ Type = DescriptorHeapType.RenderTargetView
+ };
+
+ renderTargetViewHeap = device.CreateDescriptorHeap(rtvHeapDesc);
+
+ var srvHeapDesc = new DescriptorHeapDescription()
+ {
+ DescriptorCount = 1,
+ Flags = DescriptorHeapFlags.ShaderVisible,
+ Type = DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView
+ };
+
+ shaderRenderViewHeap = device.CreateDescriptorHeap(srvHeapDesc);
+
+ rtvDescriptorSize = device.GetDescriptorHandleIncrementSize(DescriptorHeapType.RenderTargetView);
+
+ // Create frame resources.
+ var rtvHandle = renderTargetViewHeap.CPUDescriptorHandleForHeapStart;
+ for (int n = 0; n < FrameCount; n++)
+ {
+ renderTargets[n] = swapChain.GetBackBuffer(n);
+ device.CreateRenderTargetView(renderTargets[n], null, rtvHandle);
+
+ d3d11On12Device.CreateWrappedResource(renderTargets[n], new SharpDX.Direct3D11.D3D11ResourceFlags { BindFlags = (int)SharpDX.Direct3D11.BindFlags.RenderTarget, CPUAccessFlags = 0, MiscFlags = 0, StructureByteStride = 0 }, (int)ResourceStates.RenderTarget, (int)ResourceStates.Present, typeof(SharpDX.Direct3D11.Texture2D).GUID, out d3d11BackBuffers[n]);
+
+ rtvHandle += rtvDescriptorSize;
+ }
+
+ commandAllocator = device.CreateCommandAllocator(CommandListType.Direct);
+ }
+
+ internal void UpdateD3D11Image(IntPtr surface) {
+ var unk = new ComObject(surface);
+ var dxgiRes = unk.QueryInterface();
+
+ var tempRes = d3d11Device.OpenSharedResource(dxgiRes.SharedHandle);
+ var backBuffer = tempRes.QueryInterface();
+ var d3d11BackBuffer = d3d11BackBuffers[frameIndex];
+
+ d3d11On12Device.AcquireWrappedResources(new[] { d3d11BackBuffer }, 1);
+ d3d11Device.ImmediateContext.CopyResource(d3d11BackBuffer, backBuffer);
+ d3d11Device.ImmediateContext.Flush();
+ d3d11On12Device.ReleaseWrappedResources(new[] { d3d11BackBuffer }, 1);
+ }
+
+ private void LoadAssets()
+ {
+ // Create the root signature description.
+ var rootSignatureDesc = new RootSignatureDescription(RootSignatureFlags.AllowInputAssemblerInputLayout,
+ // Root Parameters
+ new[]
+ {
+ new RootParameter(ShaderVisibility.Pixel,
+ new DescriptorRange()
+ {
+ RangeType = DescriptorRangeType.ShaderResourceView,
+ DescriptorCount = 1,
+ OffsetInDescriptorsFromTableStart = int.MinValue,
+ BaseShaderRegister = 0
+ })
+ },
+ // Samplers
+ new[]
+ {
+ new StaticSamplerDescription(ShaderVisibility.Pixel, 0, 0)
+ {
+ Filter = Filter.MinimumMinMagMipPoint,
+ AddressUVW = TextureAddressMode.Border,
+ }
+ });
+
+ rootSignature = device.CreateRootSignature(0, rootSignatureDesc.Serialize());
+
+ // Create the pipeline state, which includes compiling and loading shaders.
+#if DEBUG
+ var vertexShader = new ShaderBytecode(SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile("shaders.hlsl", "VSMain", "vs_5_0", SharpDX.D3DCompiler.ShaderFlags.Debug));
+#else
+ var vertexShader = new ShaderBytecode(SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile("shaders.hlsl", "VSMain", "vs_5_0"));
+#endif
+
+#if DEBUG
+ var pixelShader = new ShaderBytecode(SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile("shaders.hlsl", "PSMain", "ps_5_0", SharpDX.D3DCompiler.ShaderFlags.Debug));
+#else
+ var pixelShader = new ShaderBytecode(SharpDX.D3DCompiler.ShaderBytecode.CompileFromFile("shaders.hlsl", "PSMain", "ps_5_0"));
+#endif
+
+ // Define the vertex input layout.
+ var inputElementDescs = new []
+ {
+ new InputElement("POSITION",0,Format.R32G32B32_Float,0,0),
+ new InputElement("TEXCOORD",0,Format.R32G32_Float,12,0)
+ };
+
+ // Describe and create the graphics pipeline state object (PSO).
+ var psoDesc = new GraphicsPipelineStateDescription()
+ {
+ InputLayout = new InputLayoutDescription(inputElementDescs),
+ RootSignature = rootSignature,
+ VertexShader = vertexShader,
+ PixelShader = pixelShader,
+ RasterizerState = RasterizerStateDescription.Default(),
+ BlendState = BlendStateDescription.Default(),
+ DepthStencilFormat = SharpDX.DXGI.Format.D32_Float,
+ DepthStencilState = new DepthStencilStateDescription() { IsDepthEnabled = false, IsStencilEnabled = false },
+ SampleMask = int.MaxValue,
+ PrimitiveTopologyType = PrimitiveTopologyType.Triangle,
+ RenderTargetCount = 1,
+ Flags = PipelineStateFlags.None,
+ SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
+ StreamOutput = new StreamOutputDescription()
+ };
+ psoDesc.RenderTargetFormats[0] = SharpDX.DXGI.Format.R8G8B8A8_UNorm;
+
+ pipelineState = device.CreateGraphicsPipelineState(psoDesc);
+
+ // Create the command list.
+ commandList = device.CreateCommandList(CommandListType.Direct, commandAllocator, pipelineState);
+
+ // Create the vertex buffer.
+ float aspectRatio = viewport.Width / viewport.Height;
+
+ // Define the geometry for a triangle.
+ var triangleVertices = new []
+ {
+ new Vertex() { Position = new Vector3(0.0f, 0.25f * aspectRatio, 0.0f ), TexCoord = new Vector2(0.5f, 0.0f) },
+ new Vertex() { Position = new Vector3(0.25f, -0.25f * aspectRatio, 0.0f), TexCoord = new Vector2(1.0f, 1.0f) },
+ new Vertex() { Position = new Vector3(-0.25f, -0.25f * aspectRatio, 0.0f),TexCoord = new Vector2(0.0f, 1.0f) },
+ };
+
+ int vertexBufferSize = Utilities.SizeOf(triangleVertices);
+
+ // Note: using upload heaps to transfer static data like vert buffers is not
+ // recommended. Every time the GPU needs it, the upload heap will be marshalled
+ // over. Please read up on Default Heap usage. An upload heap is used here for
+ // code simplicity and because there are very few verts to actually transfer.
+ vertexBuffer = device.CreateCommittedResource(new HeapProperties(HeapType.Upload), HeapFlags.None, ResourceDescription.Buffer(vertexBufferSize), ResourceStates.GenericRead);
+
+ // Copy the triangle data to the vertex buffer.
+ var pVertexDataBegin = vertexBuffer.Map(0);
+ Utilities.Write(pVertexDataBegin, triangleVertices, 0, triangleVertices.Length);
+ vertexBuffer.Unmap(0);
+
+ // Initialize the vertex buffer view.
+ vertexBufferView = new VertexBufferView();
+ vertexBufferView.BufferLocation = vertexBuffer.GPUVirtualAddress;
+ vertexBufferView.StrideInBytes = Utilities.SizeOf();
+ vertexBufferView.SizeInBytes = vertexBufferSize;
+
+ // Create the texture.
+ // Describe and create a Texture2D.
+ var textureDesc = ResourceDescription.Texture2D(Format.R8G8B8A8_UNorm, TextureWidth, TextureHeight);
+ texture = device.CreateCommittedResource(new HeapProperties(HeapType.Default), HeapFlags.None, textureDesc, ResourceStates.CopyDestination);
+
+ long uploadBufferSize = GetRequiredIntermediateSize(this.texture, 0, 1);
+
+ // Create the GPU upload buffer.
+ var textureUploadHeap = device.CreateCommittedResource(new HeapProperties(CpuPageProperty.WriteBack, MemoryPool.L0), HeapFlags.None, ResourceDescription.Texture2D(Format.R8G8B8A8_UNorm, TextureWidth, TextureHeight), ResourceStates.GenericRead);
+
+ // Copy data to the intermediate upload heap and then schedule a copy
+ // from the upload heap to the Texture2D.
+ byte[] textureData = GenerateTextureData();
+
+ var handle = GCHandle.Alloc(textureData, GCHandleType.Pinned);
+ var ptr = Marshal.UnsafeAddrOfPinnedArrayElement(textureData, 0);
+ textureUploadHeap.WriteToSubresource(0, null, ptr, TexturePixelSize * TextureWidth, textureData.Length);
+ handle.Free();
+
+ commandList.CopyTextureRegion(new TextureCopyLocation(texture, 0), 0, 0, 0, new TextureCopyLocation(textureUploadHeap, 0), null);
+
+ commandList.ResourceBarrierTransition(this.texture, ResourceStates.CopyDestination, ResourceStates.PixelShaderResource);
+
+ // Describe and create a SRV for the texture.
+ var srvDesc = new ShaderResourceViewDescription
+ {
+ Shader4ComponentMapping = D3DXUtilities.DefaultComponentMapping(),
+ Format = textureDesc.Format,
+ Dimension = ShaderResourceViewDimension.Texture2D,
+ Texture2D = {MipLevels = 1},
+ };
+
+ device.CreateShaderResourceView(this.texture, srvDesc, shaderRenderViewHeap.CPUDescriptorHandleForHeapStart);
+
+ // Command lists are created in the recording state, but there is nothing
+ // to record yet. The main loop expects it to be closed, so close it now.
+ commandList.Close();
+
+ commandQueue.ExecuteCommandList(commandList);
+
+ // Create synchronization objects.
+ fence = device.CreateFence(0, FenceFlags.None);
+ fenceValue = 1;
+
+ // Create an event handle to use for frame synchronization.
+ fenceEvent = new AutoResetEvent(false);
+
+ WaitForPreviousFrame();
+
+ //release temp texture
+ textureUploadHeap.Dispose();
+ }
+
+ byte[] GenerateTextureData()
+ {
+ int rowPitch = TextureWidth * TexturePixelSize;
+ int cellPitch = rowPitch >> 3; // The width of a cell in the checkboard texture.
+ int cellHeight = TextureWidth >> 3; // The height of a cell in the checkerboard texture.
+ int textureSize = rowPitch * TextureHeight;
+ byte[] data = new byte[textureSize];
+
+ for (int n = 0; n < textureSize; n += TexturePixelSize)
+ {
+ int x = n % rowPitch;
+ int y = n / rowPitch;
+ int i = x / cellPitch;
+ int j = y / cellHeight;
+
+ if (i % 2 == j % 2)
+ {
+ data[n] = 0x00; // R
+ data[n + 1] = 0x00; // G
+ data[n + 2] = 0x00; // B
+ data[n + 3] = 0xff; // A
+ }
+ else
+ {
+ data[n] = 0xff; // R
+ data[n + 1] = 0xff; // G
+ data[n + 2] = 0xff; // B
+ data[n + 3] = 0xff; // A
+ }
+ }
+
+ return data;
+ }
+
+ private long GetRequiredIntermediateSize(Resource destinationResource, int firstSubresource, int NumSubresources)
+ {
+ var desc = destinationResource.Description;
+ long requiredSize;
+ device.GetCopyableFootprints(ref desc, firstSubresource, NumSubresources, 0, null, null, null, out requiredSize);
+ return requiredSize;
+ }
+
+ private void PopulateCommandList()
+ {
+ // Command list allocators can only be reset when the associated
+ // command lists have finished execution on the GPU; apps should use
+ // fences to determine GPU execution progress.
+ commandAllocator.Reset();
+
+ // However, when ExecuteCommandList() is called on a particular command
+ // list, that command list can then be reset at any time and must be before
+ // re-recording.
+ commandList.Reset(commandAllocator, pipelineState);
+
+
+ // Set necessary state.
+ commandList.SetGraphicsRootSignature(rootSignature);
+
+ commandList.SetDescriptorHeaps(1, new DescriptorHeap[] { shaderRenderViewHeap });
+
+ commandList.SetGraphicsRootDescriptorTable(0, shaderRenderViewHeap.GPUDescriptorHandleForHeapStart);
+
+ commandList.SetViewport(viewport);
+ commandList.SetScissorRectangles(scissorRect);
+
+ // Indicate that the back buffer will be used as a render target.
+ commandList.ResourceBarrierTransition(renderTargets[frameIndex], ResourceStates.Present, ResourceStates.RenderTarget);
+
+ var rtvHandle = renderTargetViewHeap.CPUDescriptorHandleForHeapStart;
+ rtvHandle += frameIndex * rtvDescriptorSize;
+ commandList.SetRenderTargets(rtvHandle, null);
+
+ // Record commands.
+ commandList.ClearRenderTargetView(rtvHandle, new Color4(0, 0.2F, 0.4f, 1), 0, null);
+
+ commandList.PrimitiveTopology = SharpDX.Direct3D.PrimitiveTopology.TriangleList;
+ commandList.SetVertexBuffer(0, vertexBufferView);
+ commandList.DrawInstanced(3, 1, 0, 0);
+
+ // Indicate that the back buffer will now be used to present.
+ commandList.ResourceBarrierTransition(renderTargets[frameIndex], ResourceStates.RenderTarget, ResourceStates.Present);
+
+ commandList.Close();
+ }
+
+
+ ///
+ /// Wait the previous command list to finish executing.
+ ///
+ private void WaitForPreviousFrame()
+ {
+ // WAITING FOR THE FRAME TO COMPLETE BEFORE CONTINUING IS NOT BEST PRACTICE.
+ // This is code implemented as such for simplicity.
+
+ int localFence = fenceValue;
+ commandQueue.Signal(this.fence, localFence);
+ fenceValue++;
+
+ // Wait until the previous frame is finished.
+ if (this.fence.CompletedValue < localFence)
+ {
+ this.fence.SetEventOnCompletion(localFence, fenceEvent.SafeWaitHandle.DangerousGetHandle());
+ fenceEvent.WaitOne();
+ }
+
+ frameIndex = swapChain.CurrentBackBufferIndex;
+ }
+
+ public void Update()
+ {
+ }
+
+ public void Render()
+ {
+ // Record all the commands we need to render the scene into the command list.
+ PopulateCommandList();
+
+ // Execute the command list.
+ commandQueue.ExecuteCommandList(commandList);
+
+ // Present the frame.
+ swapChain.Present(1, 0);
+
+ WaitForPreviousFrame();
+ }
+
+ public void Dispose()
+ {
+ // Wait for the GPU to be done with all resources.
+ WaitForPreviousFrame();
+
+ //release all resources
+ foreach (var target in renderTargets)
+ {
+ target.Dispose();
+ }
+ commandAllocator.Dispose();
+ commandQueue.Dispose();
+ rootSignature.Dispose();
+ renderTargetViewHeap.Dispose();
+ shaderRenderViewHeap.Dispose();
+ pipelineState.Dispose();
+ commandList.Dispose();
+ vertexBuffer.Dispose();
+ texture.Dispose();
+ fence.Dispose();
+ swapChain.Dispose();
+ device.Dispose();
+ }
+
+
+ struct Vertex
+ {
+ public Vector3 Position;
+
+ public Vector2 TexCoord;
+ };
+
+ const int TextureWidth = 256;
+ const int TextureHeight = 256;
+ const int TexturePixelSize = 4; // The number of bytes used to represent a pixel in the texture.
+
+
+ const int FrameCount = 2;
+
+ private ViewportF viewport;
+ private Rectangle scissorRect;
+ // Pipeline objects.
+ private SwapChain3 swapChain;
+ private Device device;
+ private SharpDX.Direct3D11.Device d3d11Device;
+ private SharpDX.Direct3D11.Device11On12 d3d11On12Device;
+ private SharpDX.Direct3D11.Resource[] d3d11BackBuffers = new SharpDX.Direct3D11.Resource[FrameCount];
+ private Resource[] renderTargets = new Resource[FrameCount];
+ private CommandAllocator commandAllocator;
+ private CommandQueue commandQueue;
+ private RootSignature rootSignature;
+ private DescriptorHeap renderTargetViewHeap;
+ private DescriptorHeap shaderRenderViewHeap;
+ private PipelineState pipelineState;
+ private GraphicsCommandList commandList;
+ private int rtvDescriptorSize;
+
+ // App resources.
+ Resource vertexBuffer;
+ VertexBufferView vertexBufferView;
+ Resource texture;
+
+ // Synchronization objects.
+ private int frameIndex;
+ private AutoResetEvent fenceEvent;
+
+ private Fence fence;
+ private int fenceValue;
+
+
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/D3DXUtilities.cs b/Desktop/Direct3D12/HelloWPF/D3DXUtilities.cs
new file mode 100644
index 00000000..39eb14fe
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/D3DXUtilities.cs
@@ -0,0 +1,32 @@
+namespace HelloWPF
+{
+ public class D3DXUtilities
+ {
+
+ public const int ComponentMappingMask = 0x7;
+
+ public const int ComponentMappingShift = 3;
+
+ public const int ComponentMappingAlwaysSetBitAvoidingZeromemMistakes = (1 << (ComponentMappingShift * 4));
+
+ public static int ComponentMapping(int src0, int src1, int src2, int src3)
+ {
+
+ return ((((src0) & ComponentMappingMask) |
+ (((src1) & ComponentMappingMask) << ComponentMappingShift) |
+ (((src2) & ComponentMappingMask) << (ComponentMappingShift * 2)) |
+ (((src3) & ComponentMappingMask) << (ComponentMappingShift * 3)) |
+ ComponentMappingAlwaysSetBitAvoidingZeromemMistakes));
+ }
+
+ public static int DefaultComponentMapping()
+ {
+ return ComponentMapping(0, 1, 2, 3);
+ }
+
+ public static int ComponentMapping(int ComponentToExtract, int Mapping)
+ {
+ return ((Mapping >> (ComponentMappingShift * ComponentToExtract) & ComponentMappingMask));
+ }
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/HelloWPF.csproj b/Desktop/Direct3D12/HelloWPF/HelloWPF.csproj
new file mode 100644
index 00000000..250c9c39
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/HelloWPF.csproj
@@ -0,0 +1,131 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}
+ WinExe
+ HelloWPF
+ HelloWPF
+ v4.6.1
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+ x64
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ false
+
+
+ x64
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+ ..\..\..\packages\Microsoft.Wpf.Interop.DirectX-x64.0.9.0-beta-22856\lib\net45\Microsoft.Wpf.Interop.DirectX.dll
+
+
+ ..\..\..\packages\SharpDX.4.0.1\lib\net45\SharpDX.dll
+
+
+ ..\..\..\packages\SharpDX.D3DCompiler.4.0.1\lib\net45\SharpDX.D3DCompiler.dll
+
+
+ ..\..\..\packages\SharpDX.Direct3D11.4.0.1\lib\net45\SharpDX.Direct3D11.dll
+
+
+ ..\..\..\packages\SharpDX.Direct3D12.4.0.1\lib\net45\SharpDX.Direct3D12.dll
+
+
+ ..\..\..\packages\SharpDX.DXGI.4.0.1\lib\net45\SharpDX.DXGI.dll
+
+
+ ..\..\..\packages\SharpDX.Mathematics.4.0.1\lib\net45\SharpDX.Mathematics.dll
+
+
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
+ Always
+
+
+
+
\ No newline at end of file
diff --git a/Desktop/Direct3D12/HelloWPF/MainWindow.xaml b/Desktop/Direct3D12/HelloWPF/MainWindow.xaml
new file mode 100644
index 00000000..f39e24ed
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/MainWindow.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
diff --git a/Desktop/Direct3D12/HelloWPF/MainWindow.xaml.cs b/Desktop/Direct3D12/HelloWPF/MainWindow.xaml.cs
new file mode 100644
index 00000000..0966c8ff
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/MainWindow.xaml.cs
@@ -0,0 +1,49 @@
+using SharpDX;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace HelloWPF {
+ ///
+ /// Logique d'interaction pour MainWindow.xaml
+ ///
+ public partial class MainWindow : Window {
+ private AppWPF app;
+
+ public MainWindow() {
+ InitializeComponent();
+ }
+
+ private void Window_Loaded(object sender, RoutedEventArgs e) {
+ DxImage.SetPixelSize(1280, 720);
+ DxImage.WindowOwner = (new System.Windows.Interop.WindowInteropHelper(this)).Handle;
+ DxImage.OnRender += OnDxImageRender;
+ CompositionTarget.Rendering += OnCompositionTargetRendering;
+
+ app = new AppWPF();
+ app.Initialize(1280, 720, DxImage.WindowOwner);
+ }
+
+ private void OnCompositionTargetRendering(object sender, EventArgs e) {
+ DxImage.RequestRender();
+ }
+
+ private void OnDxImageRender(IntPtr surface, bool isNewSurface) {
+ app.Update();
+ app.Render();
+
+ app.UpdateD3D11Image(surface);
+ }
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/Properties/AssemblyInfo.cs b/Desktop/Direct3D12/HelloWPF/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..4dbbe171
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// Les informations générales relatives à un assembly dépendent de
+// l'ensemble d'attributs suivant. Changez les valeurs de ces attributs pour modifier les informations
+// associées à un assembly.
+[assembly: AssemblyTitle("HelloWPF")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HelloWPF")]
+[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// L'affectation de la valeur false à ComVisible rend les types invisibles dans cet assembly
+// aux composants COM. Si vous devez accéder à un type dans cet assembly à partir de
+// COM, affectez la valeur true à l'attribut ComVisible sur ce type.
+[assembly: ComVisible(false)]
+
+//Pour commencer à générer des applications localisables, définissez
+//CultureUtiliséePourCoder dans votre fichier .csproj
+//dans . Par exemple, si vous utilisez le français
+//dans vos fichiers sources, définissez à fr-FR. Puis, supprimez les marques de commentaire de
+//l'attribut NeutralResourceLanguage ci-dessous. Mettez à jour "fr-FR" dans
+//la ligne ci-après pour qu'elle corresponde au paramètre UICulture du fichier projet.
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //où se trouvent les dictionnaires de ressources spécifiques à un thème
+ //(utilisé si une ressource est introuvable dans la page,
+ // ou dictionnaires de ressources de l'application)
+ ResourceDictionaryLocation.SourceAssembly //où se trouve le dictionnaire de ressources générique
+ //(utilisé si une ressource est introuvable dans la page,
+ // dans l'application ou dans l'un des dictionnaires de ressources spécifiques à un thème)
+)]
+
+
+// Les informations de version pour un assembly se composent des quatre valeurs suivantes :
+//
+// Version principale
+// Version secondaire
+// Numéro de build
+// Révision
+//
+// Vous pouvez spécifier toutes les valeurs ou indiquer les numéros de build et de révision par défaut
+// en utilisant '*', comme indiqué ci-dessous :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/Desktop/Direct3D12/HelloWPF/Properties/Resources.Designer.cs b/Desktop/Direct3D12/HelloWPF/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..5f94640b
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/Properties/Resources.Designer.cs
@@ -0,0 +1,62 @@
+//------------------------------------------------------------------------------
+//
+// Ce code a été généré par un outil.
+// Version du runtime :4.0.30319.42000
+//
+// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si
+// le code est régénéré.
+//
+//------------------------------------------------------------------------------
+
+namespace HelloWPF.Properties {
+
+
+ ///
+ /// Une classe de ressource fortement typée destinée, entre autres, à la consultation des chaînes localisées.
+ ///
+ // Cette classe a été générée automatiquement par la classe StronglyTypedResourceBuilder
+ // à l'aide d'un outil, tel que ResGen ou Visual Studio.
+ // Pour ajouter ou supprimer un membre, modifiez votre fichier .ResX, puis réexécutez ResGen
+ // avec l'option /str ou régénérez votre projet VS.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// Retourne l'instance ResourceManager mise en cache utilisée par cette classe.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if ((resourceMan == null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HelloWPF.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Remplace la propriété CurrentUICulture du thread actuel pour toutes
+ /// les recherches de ressources à l'aide de cette classe de ressource fortement typée.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/Properties/Resources.resx b/Desktop/Direct3D12/HelloWPF/Properties/Resources.resx
new file mode 100644
index 00000000..af7dbebb
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/Desktop/Direct3D12/HelloWPF/Properties/Settings.Designer.cs b/Desktop/Direct3D12/HelloWPF/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..d378893a
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/Properties/Settings.Designer.cs
@@ -0,0 +1,26 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace HelloWPF.Properties {
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default {
+ get {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/Desktop/Direct3D12/HelloWPF/Properties/Settings.settings b/Desktop/Direct3D12/HelloWPF/Properties/Settings.settings
new file mode 100644
index 00000000..033d7a5e
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Desktop/Direct3D12/HelloWPF/packages.config b/Desktop/Direct3D12/HelloWPF/packages.config
new file mode 100644
index 00000000..7c4f5430
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/packages.config
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Desktop/Direct3D12/HelloWPF/shaders.hlsl b/Desktop/Direct3D12/HelloWPF/shaders.hlsl
new file mode 100644
index 00000000..4f83f5b2
--- /dev/null
+++ b/Desktop/Direct3D12/HelloWPF/shaders.hlsl
@@ -0,0 +1,23 @@
+struct PSInput
+{
+ float4 position : SV_POSITION;
+ float2 uv : TEXCOORD;
+};
+
+Texture2D g_texture : register(t0);
+SamplerState g_sampler : register(s0);
+
+PSInput VSMain(float4 position : POSITION, float4 uv : TEXCOORD)
+{
+ PSInput result;
+
+ result.position = position;
+ result.uv = uv;
+
+ return result;
+}
+
+float4 PSMain(PSInput input) : SV_TARGET
+{
+ return g_texture.Sample(g_sampler, input.uv);
+}
\ No newline at end of file
diff --git a/SharpDXSamples-Desktop.sln b/SharpDXSamples-Desktop.sln
index 785f891f..38aea5c8 100644
--- a/SharpDXSamples-Desktop.sln
+++ b/SharpDXSamples-Desktop.sln
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio 14
-VisualStudioVersion = 14.0.23107.0
+# Visual Studio 15
+VisualStudioVersion = 15.0.27703.2018
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{361E4316-4AE0-424F-B786-5A82D3A6CF0C}"
EndProject
@@ -117,6 +117,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloConstBuffers", "Deskto
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloBundles", "Desktop\Direct3D12\HelloBundles\HelloBundles.csproj", "{3C72571E-602A-4451-B0F3-98095278FF90}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloWPF", "Desktop\Direct3D12\HelloWPF\HelloWPF.csproj", "{8B651388-71E1-4607-AB6C-95254540C32F}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -453,6 +455,14 @@ Global
{3C72571E-602A-4451-B0F3-98095278FF90}.Win8Debug|Any CPU.Build.0 = Debug|Any CPU
{3C72571E-602A-4451-B0F3-98095278FF90}.Win8Release|Any CPU.ActiveCfg = Release|Any CPU
{3C72571E-602A-4451-B0F3-98095278FF90}.Win8Release|Any CPU.Build.0 = Release|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Win8Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Win8Debug|Any CPU.Build.0 = Debug|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Win8Release|Any CPU.ActiveCfg = Release|Any CPU
+ {8B651388-71E1-4607-AB6C-95254540C32F}.Win8Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -499,5 +509,9 @@ Global
{2A37FD61-2263-4364-AEE4-18FB93CCE610} = {D7442738-C81F-4BD0-81BD-B92944FF3707}
{C373D091-EEDD-4829-8B8A-15F67227C8DC} = {D7442738-C81F-4BD0-81BD-B92944FF3707}
{3C72571E-602A-4451-B0F3-98095278FF90} = {D7442738-C81F-4BD0-81BD-B92944FF3707}
+ {8B651388-71E1-4607-AB6C-95254540C32F} = {D7442738-C81F-4BD0-81BD-B92944FF3707}
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {E75D59E8-DD3F-45E6-8558-DEA5EBE5A482}
EndGlobalSection
EndGlobal