From 85322e2363d10a558a956961f2e01eb77eb7f14e Mon Sep 17 00:00:00 2001 From: Konstantin Koch Date: Sun, 4 Oct 2015 21:30:00 +0200 Subject: [PATCH] Migrated Primitives, RecordingSample, RenderTarget and SimpleSprite. Also implemented DynamicBuffers and fixed many Dispose functions increased the amount of shared code between vertex and index buffers fixed GraphicsDevice.Reset() which didn't save the provided presentation parameters and the backbuffer was still bound after the recent changes about the rendertargets Vertex and IndexBuffers that get dynamically generated for the UserDraw methods dispose the buffers now Added DebugNames to Index and VertexBuffers and their Dynamic version. --- .gitignore | 2 +- ANX.Framework/Graphics/BlendState.cs | 14 +- ANX.Framework/Graphics/ConstantBuffer.cs | 17 +- ANX.Framework/Graphics/DepthStencilState.cs | 14 +- ANX.Framework/Graphics/DynamicVertexBuffer.cs | 15 +- ANX.Framework/Graphics/Effect.cs | 27 +-- ANX.Framework/Graphics/GraphicsDevice.cs | 4 +- ANX.Framework/Graphics/GraphicsResource.cs | 21 +- ANX.Framework/Graphics/IndexBuffer.cs | 21 +- ANX.Framework/Graphics/OcclusionQuery.cs | 20 +- ANX.Framework/Graphics/RasterizerState.cs | 21 +- ANX.Framework/Graphics/SamplerState.cs | 20 +- ANX.Framework/Graphics/SpriteBatch.cs | 41 ++-- ANX.Framework/Graphics/Texture.cs | 25 ++- ANX.Framework/Graphics/Texture2D.cs | 12 -- ANX.Framework/Graphics/Texture3D.cs | 7 +- ANX.Framework/Graphics/TextureCube.cs | 7 +- ANX.Framework/Graphics/VertexBuffer.cs | 78 +++----- ANX.Framework/Graphics/VertexDeclaration.cs | 10 - .../RenderSystem/IRenderSystemCreator.cs | 10 +- .../SharedDxTexture2D.cs | 15 +- .../SharedIndexBuffer.cs | 66 ++++--- .../SharedVertexBuffer.cs | 66 ++++--- .../ANX.RenderSystem.Windows.DX10.csproj | 1 + .../ANX.RenderSystem.Windows.DX10/Buffer.cs | 79 ++++++++ .../ANX.RenderSystem.Windows.DX10/Creator.cs | 19 +- .../DxIndexBuffer.cs | 73 ++----- .../DxTexture2D.cs | 2 +- .../DxVertexBuffer.cs | 94 +++------ .../GraphicsDeviceDX.cs | 87 +++++---- .../ANX.RenderSystem.Windows.DX11.csproj | 1 + .../ANX.RenderSystem.Windows.DX11/Buffer.cs | 81 ++++++++ .../ANX.RenderSystem.Windows.DX11/Creator.cs | 18 +- .../DxIndexBuffer.cs | 87 ++------- .../DxTexture2D.cs | 2 +- .../DxVertexBuffer.cs | 85 ++------ .../GraphicsDeviceDX.cs | 86 ++++---- .../AlphaTestEffectSample.csproj | 2 +- Samples/Primitives.sln | 183 ++++++++++++++++-- Samples/Primitives/Primitives.csproj | 39 +--- Samples/RecordingSample.sln | 183 ++++++++++++++++-- .../RecordingSample/RecordingSample.csproj | 82 +++----- Samples/RenderTarget.sln | 183 ++++++++++++++++-- Samples/RenderTarget/RenderTarget.csproj | 81 +++----- Samples/SimpleSprite.sln | 119 ++++++++---- Samples/SimpleSprite/Game1.cs | 67 +++---- Samples/SimpleSprite/SimpleSprite.csproj | 87 +++------ 47 files changed, 1339 insertions(+), 935 deletions(-) create mode 100644 RenderSystems/ANX.RenderSystem.Windows.DX10/Buffer.cs create mode 100644 RenderSystems/ANX.RenderSystem.Windows.DX11/Buffer.cs diff --git a/.gitignore b/.gitignore index e19c0f75..b06dbd46 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,6 @@ obj *.cachefile /packages/** /package -/UpgradeLog.htm +UpgradeLog*.htm log.txt *.diagsession diff --git a/ANX.Framework/Graphics/BlendState.cs b/ANX.Framework/Graphics/BlendState.cs index 9ef27e88..42e66203 100644 --- a/ANX.Framework/Graphics/BlendState.cs +++ b/ANX.Framework/Graphics/BlendState.cs @@ -245,17 +245,17 @@ namespace ANX.Framework.Graphics "You are not allowed to change BlendState properties while it is bound to the GraphicsDevice."); } - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (this.nativeBlendState != null) + if (disposeManaged) { - this.nativeBlendState.Dispose(); - this.nativeBlendState = null; + if (this.nativeBlendState != null) + { + this.nativeBlendState.Dispose(); + this.nativeBlendState = null; + } } - } - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { base.Dispose(disposeManaged); } } diff --git a/ANX.Framework/Graphics/ConstantBuffer.cs b/ANX.Framework/Graphics/ConstantBuffer.cs index 6050fb99..612437c6 100644 --- a/ANX.Framework/Graphics/ConstantBuffer.cs +++ b/ANX.Framework/Graphics/ConstantBuffer.cs @@ -117,13 +117,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (nativeConstantBuffer != null) - { - nativeConstantBuffer.Dispose(); - nativeConstantBuffer = null; - } + if (disposeManaged) + { + if (nativeConstantBuffer != null) + { + nativeConstantBuffer.Dispose(); + nativeConstantBuffer = null; + } + } + + base.Dispose(disposeManaged); } #endregion diff --git a/ANX.Framework/Graphics/DepthStencilState.cs b/ANX.Framework/Graphics/DepthStencilState.cs index 144d9c2d..7b797ee5 100644 --- a/ANX.Framework/Graphics/DepthStencilState.cs +++ b/ANX.Framework/Graphics/DepthStencilState.cs @@ -311,17 +311,17 @@ namespace ANX.Framework.Graphics "You are not allowed to change DepthStencilState properties while it is bound to the GraphicsDevice."); } - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (this.nativeDepthStencilState != null) + if (disposeManaged) { - this.nativeDepthStencilState.Dispose(); - this.nativeDepthStencilState = null; + if (this.nativeDepthStencilState != null) + { + this.nativeDepthStencilState.Dispose(); + this.nativeDepthStencilState = null; + } } - } - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { base.Dispose(disposeManaged); } } diff --git a/ANX.Framework/Graphics/DynamicVertexBuffer.cs b/ANX.Framework/Graphics/DynamicVertexBuffer.cs index 8ee8fa28..936b9823 100644 --- a/ANX.Framework/Graphics/DynamicVertexBuffer.cs +++ b/ANX.Framework/Graphics/DynamicVertexBuffer.cs @@ -1,6 +1,7 @@ #region Using Statements using System; using ANX.Framework.NonXNA.Development; +using ANX.Framework.NonXNA; #endregion // Using Statements @@ -34,9 +35,10 @@ namespace ANX.Framework.Graphics graphicsDevice.DeviceReset += graphicsDevice_DeviceReset; } - ~DynamicVertexBuffer() + internal override void CreateNativeBuffer() { - base.GraphicsDevice.DeviceReset -= graphicsDevice_DeviceReset; + var creator = AddInSystemFactory.Instance.GetDefaultCreator(); + this.NativeVertexBuffer = creator.CreateDynamicVertexBuffer(GraphicsDevice, this, VertexDeclaration, VertexCount, BufferUsage); } private void graphicsDevice_DeviceReset(object sender, EventArgs e) @@ -81,5 +83,14 @@ namespace ANX.Framework.Graphics } } + protected override void Dispose(bool disposeManaged) + { + if (disposeManaged) + { + base.GraphicsDevice.DeviceReset -= graphicsDevice_DeviceReset; + } + + base.Dispose(disposeManaged); + } } } diff --git a/ANX.Framework/Graphics/Effect.cs b/ANX.Framework/Graphics/Effect.cs index bf669190..911be9a4 100644 --- a/ANX.Framework/Graphics/Effect.cs +++ b/ANX.Framework/Graphics/Effect.cs @@ -116,25 +116,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (nativeEffect != null) - { - nativeEffect.Dispose(); - nativeEffect = null; - } - } + if (disposeManaged) + { + if (nativeEffect != null) + { + nativeEffect.Dispose(); + nativeEffect = null; + } + } - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - try - { - Dispose(); - } - finally - { - base.Dispose(false); - } + base.Dispose(disposeManaged); } #endregion diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index a3ece76a..1484b68f 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -364,8 +364,8 @@ namespace ANX.Framework.Graphics // reset presentation parameters NativeDevice.ResizeBuffers(presentationParameters); - this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth, - presentationParameters.BackBufferHeight); + this.viewport = new Graphics.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + this.currentPresentationParameters = presentationParameters; samplerStateCollection.InitializeDeviceState(); diff --git a/ANX.Framework/Graphics/GraphicsResource.cs b/ANX.Framework/Graphics/GraphicsResource.cs index 9c73efc7..29b09245 100644 --- a/ANX.Framework/Graphics/GraphicsResource.cs +++ b/ANX.Framework/Graphics/GraphicsResource.cs @@ -21,15 +21,10 @@ namespace ANX.Framework.Graphics GraphicsResourceTracker.Instance.RegisterTrackedObject(this); } - ~GraphicsResource() - { - GraphicsResourceTracker.Instance.UnregisterTrackedObject(this); - } - public GraphicsResource(GraphicsDevice device) + : this() { this.GraphicsDevice = device; - GraphicsResourceTracker.Instance.RegisterTrackedObject(this); } public GraphicsDevice GraphicsDevice @@ -56,7 +51,11 @@ namespace ANX.Framework.Graphics set; } - public abstract void Dispose(); + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } protected void raise_Disposing(object sender, EventArgs args) { @@ -66,8 +65,14 @@ namespace ANX.Framework.Graphics } } - protected virtual void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) + protected virtual void Dispose(bool disposeManaged) { + if (disposeManaged) + { + raise_Disposing(this, EventArgs.Empty); + + GraphicsResourceTracker.Instance.UnregisterTrackedObject(this); + } } public override string ToString() diff --git a/ANX.Framework/Graphics/IndexBuffer.cs b/ANX.Framework/Graphics/IndexBuffer.cs index fc13dd13..305d944a 100644 --- a/ANX.Framework/Graphics/IndexBuffer.cs +++ b/ANX.Framework/Graphics/IndexBuffer.cs @@ -180,19 +180,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - Dispose(true); - } + if (disposeManaged) + { + if (this.nativeIndexBuffer != null) + { + this.nativeIndexBuffer.Dispose(); + this.nativeIndexBuffer = null; + } + } - protected override void Dispose( - [MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - if (this.nativeIndexBuffer != null) - { - this.nativeIndexBuffer.Dispose(); - this.nativeIndexBuffer = null; - } + base.Dispose(disposeManaged); } #endregion } diff --git a/ANX.Framework/Graphics/OcclusionQuery.cs b/ANX.Framework/Graphics/OcclusionQuery.cs index b9bd8bff..711bfee6 100644 --- a/ANX.Framework/Graphics/OcclusionQuery.cs +++ b/ANX.Framework/Graphics/OcclusionQuery.cs @@ -86,18 +86,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - Dispose(true); - } + if (disposeManaged) + { + if (nativeQuery != null) + { + nativeQuery.Dispose(); + nativeQuery = null; + } + } - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - if (nativeQuery != null) - { - nativeQuery.Dispose(); - nativeQuery = null; - } + base.Dispose(disposeManaged); } #endregion } diff --git a/ANX.Framework/Graphics/RasterizerState.cs b/ANX.Framework/Graphics/RasterizerState.cs index 0da56a4a..98ba483c 100644 --- a/ANX.Framework/Graphics/RasterizerState.cs +++ b/ANX.Framework/Graphics/RasterizerState.cs @@ -171,19 +171,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (this.nativeRasterizerState != null) - { - this.nativeRasterizerState.Dispose(); - this.nativeRasterizerState = null; - } - } + if (disposeManaged) + { + if (this.nativeRasterizerState != null) + { + this.nativeRasterizerState.Dispose(); + this.nativeRasterizerState = null; + } + } - protected override void Dispose( - [MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - base.Dispose(disposeManaged); + base.Dispose(disposeManaged); } #endregion } diff --git a/ANX.Framework/Graphics/SamplerState.cs b/ANX.Framework/Graphics/SamplerState.cs index 20eaf3f1..5412d4f0 100644 --- a/ANX.Framework/Graphics/SamplerState.cs +++ b/ANX.Framework/Graphics/SamplerState.cs @@ -186,18 +186,18 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + protected override void Dispose(bool disposeManaged) { - if (this.nativeSamplerState != null) - { - this.nativeSamplerState.Dispose(); - this.nativeSamplerState = null; - } - } + if (disposeManaged) + { + if (this.nativeSamplerState != null) + { + this.nativeSamplerState.Dispose(); + this.nativeSamplerState = null; + } + } - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - base.Dispose(disposeManaged); + base.Dispose(disposeManaged); } #endregion diff --git a/ANX.Framework/Graphics/SpriteBatch.cs b/ANX.Framework/Graphics/SpriteBatch.cs index b90acf29..ef31f742 100644 --- a/ANX.Framework/Graphics/SpriteBatch.cs +++ b/ANX.Framework/Graphics/SpriteBatch.cs @@ -606,30 +606,31 @@ namespace ANX.Framework.Graphics #endregion #region Dispose - public override void Dispose() + + protected override void Dispose(bool disposeManaged) { - if (this.spriteBatchEffect != null) - { - this.spriteBatchEffect.Dispose(); - this.spriteBatchEffect = null; - } + if (disposeManaged) + { + if (this.spriteBatchEffect != null) + { + this.spriteBatchEffect.Dispose(); + this.spriteBatchEffect = null; + } - if (this.indexBuffer != null) - { - this.indexBuffer.Dispose(); - this.indexBuffer = null; - } + if (this.indexBuffer != null) + { + this.indexBuffer.Dispose(); + this.indexBuffer = null; + } - if (this.vertexBuffer != null) - { - this.vertexBuffer.Dispose(); - this.vertexBuffer = null; - } - } + if (this.vertexBuffer != null) + { + this.vertexBuffer.Dispose(); + this.vertexBuffer = null; + } + } - protected override void Dispose(Boolean disposeManaged) - { - throw new NotImplementedException(); + base.Dispose(disposeManaged); } #endregion diff --git a/ANX.Framework/Graphics/Texture.cs b/ANX.Framework/Graphics/Texture.cs index 3a1f4674..485795b8 100644 --- a/ANX.Framework/Graphics/Texture.cs +++ b/ANX.Framework/Graphics/Texture.cs @@ -41,24 +41,21 @@ namespace ANX.Framework.Graphics base.GraphicsDevice.ResourceDestroyed += GraphicsDevice_ResourceDestroyed; } - ~Texture() - { - base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated; - base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed; - } - - public override void Dispose() - { - Dispose(true); - } - protected override void Dispose(bool disposeManaged) { - if (disposeManaged && nativeTexture != null) + if (disposeManaged) { - nativeTexture.Dispose(); - nativeTexture = null; + base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated; + base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed; + + if (nativeTexture != null) + { + nativeTexture.Dispose(); + nativeTexture = null; + } } + + base.Dispose(disposeManaged); } internal abstract void ReCreateNativeTextureSurface(); diff --git a/ANX.Framework/Graphics/Texture2D.cs b/ANX.Framework/Graphics/Texture2D.cs index ebe6bc1e..3123fc6d 100644 --- a/ANX.Framework/Graphics/Texture2D.cs +++ b/ANX.Framework/Graphics/Texture2D.cs @@ -170,18 +170,6 @@ namespace ANX.Framework.Graphics } #endregion - #region Dispose - public override void Dispose() - { - base.Dispose(true); - } - - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - base.Dispose(disposeManaged); - } - #endregion - #region ReCreateNativeTextureSurface internal override void ReCreateNativeTextureSurface() { diff --git a/ANX.Framework/Graphics/Texture3D.cs b/ANX.Framework/Graphics/Texture3D.cs index 2e30a9f5..69595f6f 100644 --- a/ANX.Framework/Graphics/Texture3D.cs +++ b/ANX.Framework/Graphics/Texture3D.cs @@ -72,12 +72,7 @@ namespace ANX.Framework.Graphics throw new NotImplementedException(); } - public override void Dispose() - { - throw new NotImplementedException(); - } - - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) + protected override void Dispose(bool disposeManaged) { throw new NotImplementedException(); } diff --git a/ANX.Framework/Graphics/TextureCube.cs b/ANX.Framework/Graphics/TextureCube.cs index cc8a6c98..65bf0eee 100644 --- a/ANX.Framework/Graphics/TextureCube.cs +++ b/ANX.Framework/Graphics/TextureCube.cs @@ -62,12 +62,7 @@ namespace ANX.Framework.Graphics } #endregion - public override void Dispose() - { - throw new NotImplementedException(); - } - - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) + protected override void Dispose(bool disposeManaged) { throw new NotImplementedException(); } diff --git a/ANX.Framework/Graphics/VertexBuffer.cs b/ANX.Framework/Graphics/VertexBuffer.cs index 9f9f7ca9..b63051c9 100644 --- a/ANX.Framework/Graphics/VertexBuffer.cs +++ b/ANX.Framework/Graphics/VertexBuffer.cs @@ -15,23 +15,14 @@ namespace ANX.Framework.Graphics [Developer("Glatzemann")] public class VertexBuffer : GraphicsResource, IGraphicsResource { - #region Private - private INativeVertexBuffer nativeVertexBuffer; - #endregion - #region Public // This is now internal because via befriending the assemblies // it's usable in the modules but doesn't confuse the enduser. - internal INativeVertexBuffer NativeVertexBuffer - { - get - { - if (nativeVertexBuffer == null) - CreateNativeBuffer(); - - return nativeVertexBuffer; - } - } + internal INativeVertexBuffer NativeVertexBuffer + { + get; + set; + } public BufferUsage BufferUsage { get; private set; } public int VertexCount { get; private set; } @@ -44,8 +35,7 @@ namespace ANX.Framework.Graphics { } - public VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, - BufferUsage usage) + public VertexBuffer(GraphicsDevice graphicsDevice, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) : base(graphicsDevice) { VertexCount = vertexCount; @@ -57,22 +47,15 @@ namespace ANX.Framework.Graphics CreateNativeBuffer(); } - - ~VertexBuffer() - { - Dispose(); - base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated; - base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed; - } #endregion #region GraphicsDevice_ResourceDestroyed private void GraphicsDevice_ResourceDestroyed(object sender, ResourceDestroyedEventArgs e) { - if (nativeVertexBuffer != null) + if (NativeVertexBuffer != null) { - nativeVertexBuffer.Dispose(); - nativeVertexBuffer = null; + NativeVertexBuffer.Dispose(); + NativeVertexBuffer = null; } } #endregion @@ -80,10 +63,10 @@ namespace ANX.Framework.Graphics #region GraphicsDevice_ResourceCreated private void GraphicsDevice_ResourceCreated(object sender, ResourceCreatedEventArgs e) { - if (nativeVertexBuffer != null) + if (NativeVertexBuffer != null) { - nativeVertexBuffer.Dispose(); - nativeVertexBuffer = null; + NativeVertexBuffer.Dispose(); + NativeVertexBuffer = null; } CreateNativeBuffer(); @@ -91,11 +74,10 @@ namespace ANX.Framework.Graphics #endregion #region CreateNativeBuffer - private void CreateNativeBuffer() + internal virtual void CreateNativeBuffer() { var creator = AddInSystemFactory.Instance.GetDefaultCreator(); - this.nativeVertexBuffer = creator.CreateVertexBuffer(GraphicsDevice, this, VertexDeclaration, VertexCount, - BufferUsage); + this.NativeVertexBuffer = creator.CreateVertexBuffer(GraphicsDevice, this, VertexDeclaration, VertexCount, BufferUsage); } #endregion @@ -133,27 +115,25 @@ namespace ANX.Framework.Graphics } #endregion - #region Dispose - public override void Dispose() - { - if (nativeVertexBuffer != null) - { - nativeVertexBuffer.Dispose(); - nativeVertexBuffer = null; - } - - // do not dispose the VertexDeclaration here, because it's only a reference - if (VertexDeclaration != null) - VertexDeclaration = null; - } - - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) + protected override void Dispose(bool disposeManaged) { if (disposeManaged) { - Dispose(); + if (NativeVertexBuffer != null) + { + NativeVertexBuffer.Dispose(); + NativeVertexBuffer = null; + } + + // do not dispose the VertexDeclaration here, because it's only a reference + if (VertexDeclaration != null) + VertexDeclaration = null; + + base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated; + base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed; } + + base.Dispose(disposeManaged); } - #endregion } } diff --git a/ANX.Framework/Graphics/VertexDeclaration.cs b/ANX.Framework/Graphics/VertexDeclaration.cs index a91c288b..e58161ea 100644 --- a/ANX.Framework/Graphics/VertexDeclaration.cs +++ b/ANX.Framework/Graphics/VertexDeclaration.cs @@ -45,16 +45,6 @@ namespace ANX.Framework.Graphics return elements != null ? (elements.Clone() as VertexElement[]) : null; } - public override void Dispose() - { - Dispose(true); - } - - protected override void Dispose([MarshalAs(UnmanagedType.U1)] bool disposeManaged) - { - // Nothing to dispose - } - private int GetElementStride(VertexElementFormat format) { switch (format) diff --git a/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs b/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs index 02e3dc12..449ac4c2 100644 --- a/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs +++ b/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs @@ -19,11 +19,13 @@ namespace ANX.Framework.NonXNA SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage); - INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, - int indexCount, BufferUsage usage); + INativeIndexBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage); - INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer, - VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage); + INativeIndexBuffer CreateDynamicIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage); + + INativeVertexBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage); + + INativeVertexBuffer CreateDynamicVertexBuffer(GraphicsDevice graphics, DynamicVertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage); #if XNAEXT INativeConstantBuffer CreateConstantBuffer(GraphicsDevice graphics, ConstantBuffer managedBuffer, BufferUsage usage); diff --git a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedDxTexture2D.cs b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedDxTexture2D.cs index 0789646d..1eb643fc 100644 --- a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedDxTexture2D.cs +++ b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedDxTexture2D.cs @@ -214,10 +214,19 @@ namespace ANX.RenderSystem.Windows.DX11 protected virtual void Dispose(bool managed) { - if (NativeShaderResourceView != null) + if (managed) { - NativeShaderResourceView.Dispose(); - NativeShaderResourceView = null; + if (NativeShaderResourceView != null) + { + NativeShaderResourceView.Dispose(); + NativeShaderResourceView = null; + } + + if (NativeTexture != null) + { + NativeTexture.Dispose(); + NativeTexture = null; + } } } #endregion diff --git a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedIndexBuffer.cs b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedIndexBuffer.cs index 8bf17ba4..bc7c8df4 100644 --- a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedIndexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedIndexBuffer.cs @@ -17,7 +17,7 @@ namespace ANX.RenderSystem.Windows.DX10 namespace ANX.RenderSystem.Windows.DX11 #endif { - public partial class DxIndexBuffer : IDisposable + public partial class DxIndexBuffer { protected IndexElementSize elementSize; @@ -38,19 +38,34 @@ namespace ANX.RenderSystem.Windows.DX11 if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > NativeBuffer.Description.SizeInBytes) throw new ArgumentOutOfRangeException(string.Format("The offset by \"{0}\" plus the byte length described by \"{1}\" is over the bounds of the buffer.", "offsetInBytes", "elementCount")); - using (var stream = MapBufferWrite()) + var buffer = this.NativeBuffer; + if (this.WriteNeedsStaging) + buffer = this.CreateStagingBuffer(ResourceMapping.Write); + + try { - if (offsetInBytes > 0) - stream.Seek(offsetInBytes, SeekOrigin.Current); + using (var stream = MapBuffer(buffer, ResourceMapping.Write)) + { + if (offsetInBytes > 0) + stream.Seek(offsetInBytes, SeekOrigin.Current); - if (startIndex > 0 || elementCount < data.Length) - for (int i = startIndex; i < startIndex + elementCount; i++) - stream.Write(data[i]); - else - for (int i = 0; i < data.Length; i++) - stream.Write(data[i]); + if (startIndex > 0 || elementCount < data.Length) + for (int i = startIndex; i < startIndex + elementCount; i++) + stream.Write(data[i]); + else + for (int i = 0; i < data.Length; i++) + stream.Write(data[i]); - UnmapBuffer(); + UnmapBuffer(buffer); + } + } + finally + { + if (this.WriteNeedsStaging) + { + CopySubresource(buffer, this.NativeBuffer); + buffer.Dispose(); + } } } #endregion @@ -74,16 +89,18 @@ namespace ANX.RenderSystem.Windows.DX11 if (data == null) throw new ArgumentNullException("data"); - var stagingBuffer = CreateStagingBuffer(); - CopySubresource(NativeBuffer, stagingBuffer); - - using (var stream = MapBufferRead(stagingBuffer)) + using (var stagingBuffer = CreateStagingBuffer(ResourceMapping.Read)) { - if (offsetInBytes > 0) - stream.Seek(offsetInBytes, SeekOrigin.Current); + CopySubresource(NativeBuffer, stagingBuffer); - stream.ReadRange(data, startIndex, elementCount); - UnmapBuffer(stagingBuffer); + using (var stream = MapBuffer(stagingBuffer, ResourceMapping.Read)) + { + if (offsetInBytes > 0) + stream.Seek(offsetInBytes, SeekOrigin.Current); + + stream.ReadRange(data, startIndex, elementCount); + UnmapBuffer(stagingBuffer); + } } } #endregion @@ -92,16 +109,5 @@ namespace ANX.RenderSystem.Windows.DX11 { return (elementSize == IndexElementSize.SixteenBits ? 2 : 4) * indexCount; } - - #region Dispose - public void Dispose() - { - if (NativeBuffer != null) - { - NativeBuffer.Dispose(); - NativeBuffer = null; - } - } - #endregion } } diff --git a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedVertexBuffer.cs b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedVertexBuffer.cs index d94bcc09..ee2ba598 100644 --- a/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedVertexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.DX.SharedSources/SharedVertexBuffer.cs @@ -25,7 +25,7 @@ using DxDevice = SharpDX.Direct3D11.Device; namespace ANX.RenderSystem.Windows.DX11 #endif { - public partial class DxVertexBuffer : IDisposable + public partial class DxVertexBuffer { private int vertexStride; @@ -55,19 +55,36 @@ namespace ANX.RenderSystem.Windows.DX11 if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > NativeBuffer.Description.SizeInBytes) throw new ArgumentOutOfRangeException(string.Format("The offset by \"{0}\" plus the byte length described by \"{1}\" is over the bounds of the buffer.", "offsetInBytes", "elementCount")); - using (var stream = MapBufferWrite()) + var buffer = this.NativeBuffer; + if (!this.WriteNeedsStaging) { - if (offsetInBytes > 0) - stream.Seek(offsetInBytes, SeekOrigin.Current); + buffer = CreateStagingBuffer(ResourceMapping.Write); + } - if (startIndex > 0 || elementCount < data.Length) - for (int i = startIndex; i < startIndex + elementCount; i++) - stream.Write(data[i]); - else - for (int i = 0; i < data.Length; i++) - stream.Write(data[i]); + try + { + using (var stream = MapBuffer(buffer, ResourceMapping.Write)) + { + if (offsetInBytes > 0) + stream.Seek(offsetInBytes, SeekOrigin.Current); - UnmapBuffer(); + if (startIndex > 0 || elementCount < data.Length) + for (int i = startIndex; i < startIndex + elementCount; i++) + stream.Write(data[i]); + else + for (int i = 0; i < data.Length; i++) + stream.Write(data[i]); + + UnmapBuffer(buffer); + } + } + finally + { + if (!this.WriteNeedsStaging) + { + CopySubresource(buffer, this.NativeBuffer); + buffer.Dispose(); + } } } #endregion @@ -96,27 +113,18 @@ namespace ANX.RenderSystem.Windows.DX11 throw new ArgumentOutOfRangeException("startIndex must be smaller than elementCount + data.Length."); //TODO: Create a staging buffer only with the needed size that correctly handles startIndex and offsetInBytes. - Dx.Buffer stagingBuffer = CreateStagingBuffer(); - CopySubresource(NativeBuffer, stagingBuffer); - - using (var stream = MapBufferRead(stagingBuffer)) + using (var stagingBuffer = CreateStagingBuffer(ResourceMapping.Read)) { - if (offsetInBytes > 0) - stream.Seek(offsetInBytes, SeekOrigin.Current); + CopySubresource(NativeBuffer, stagingBuffer); - stream.ReadRange(data, startIndex, elementCount); - UnmapBuffer(stagingBuffer); - } - } - #endregion + using (var stream = MapBuffer(stagingBuffer, ResourceMapping.Read)) + { + if (offsetInBytes > 0) + stream.Seek(offsetInBytes, SeekOrigin.Current); - #region Dispose - public void Dispose() - { - if (NativeBuffer != null) - { - NativeBuffer.Dispose(); - NativeBuffer = null; + stream.ReadRange(data, startIndex, elementCount); + UnmapBuffer(stagingBuffer); + } } } #endregion diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/ANX.RenderSystem.Windows.DX10.csproj b/RenderSystems/ANX.RenderSystem.Windows.DX10/ANX.RenderSystem.Windows.DX10.csproj index b2bacbc2..53774513 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/ANX.RenderSystem.Windows.DX10.csproj +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/ANX.RenderSystem.Windows.DX10.csproj @@ -64,6 +64,7 @@ ResourceMapping.cs + diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/Buffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/Buffer.cs new file mode 100644 index 00000000..7bf95f15 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/Buffer.cs @@ -0,0 +1,79 @@ +using ANX.Framework.Graphics; +using SharpDX; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Dx = SharpDX.Direct3D10; + +namespace ANX.RenderSystem.Windows.DX10 +{ + public abstract class Buffer : IDisposable + { + public Dx.Buffer NativeBuffer { get; protected set; } + private Dx.Device device; + private BufferUsage usage; + private bool isDynamic; + + protected Buffer(Dx.Device device, BufferUsage usage, bool isDynamic) + { + this.device = device; + this.usage = usage; + this.isDynamic = isDynamic; + } + + protected DataStream MapBuffer(Dx.Buffer buffer, ResourceMapping mapping) + { + CheckUsage(mapping); + + return buffer.Map(mapping.ToMapMode()); + } + + protected void UnmapBuffer(Dx.Buffer buffer) + { + buffer.Unmap(); + } + + protected void CopySubresource(Dx.Buffer source, Dx.Buffer destination) + { + BufferHelper.ValidateCopyResource(source, destination); + + this.device.CopyResource(source, destination); + } + + protected bool WriteNeedsStaging + { + get { return !isDynamic; } + } + + private void CheckUsage(ResourceMapping mapping) + { + if ((mapping & ResourceMapping.Write) != 0 && usage == BufferUsage.None) + throw new NotSupportedException("Resource was created with WriteOnly, reading from it is not supported."); + } + + protected Dx.Buffer CreateStagingBuffer(ResourceMapping mapping) + { + CheckUsage(mapping); + + var description = new Dx.BufferDescription() + { + Usage = Dx.ResourceUsage.Staging, + SizeInBytes = NativeBuffer.Description.SizeInBytes, + CpuAccessFlags = mapping.ToCpuAccessFlags(), + OptionFlags = Dx.ResourceOptionFlags.None + }; + + return new Dx.Buffer(device, description); + } + + public void Dispose() + { + if (NativeBuffer != null) + { + NativeBuffer.Dispose(); + NativeBuffer = null; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs index 95c3a053..30399f34 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/Creator.cs @@ -63,8 +63,14 @@ namespace ANX.RenderSystem.Windows.DX10 int indexCount, BufferUsage usage) { PreventSystemChange(); - return new DxIndexBuffer(graphics, size, indexCount, usage); + return new DxIndexBuffer((GraphicsDeviceDX)graphics.NativeDevice, size, indexCount, usage, false); } + + public INativeIndexBuffer CreateDynamicIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage) + { + PreventSystemChange(); + return new DxIndexBuffer((GraphicsDeviceDX)graphics.NativeDevice, size, indexCount, usage, true); + } #endregion #region CreateVertexBuffer @@ -72,8 +78,15 @@ namespace ANX.RenderSystem.Windows.DX10 VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { PreventSystemChange(); - return new DxVertexBuffer(graphics, vertexDeclaration, vertexCount, usage); + return new DxVertexBuffer((GraphicsDeviceDX)graphics.NativeDevice, vertexDeclaration, vertexCount, usage, false); } + + public INativeVertexBuffer CreateDynamicVertexBuffer(GraphicsDevice graphics, DynamicVertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + PreventSystemChange(); + return new DxVertexBuffer((GraphicsDeviceDX)graphics.NativeDevice, vertexDeclaration, vertexCount, usage, true); + } + #endregion #if XNAEXT @@ -262,5 +275,5 @@ namespace ANX.RenderSystem.Windows.DX10 throw new NotImplementedException(); } #endregion - } + } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxIndexBuffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxIndexBuffer.cs index 498e7ac2..62eb7253 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxIndexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxIndexBuffer.cs @@ -14,83 +14,50 @@ using Dx10 = SharpDX.Direct3D10; namespace ANX.RenderSystem.Windows.DX10 { - public partial class DxIndexBuffer : INativeIndexBuffer, IDisposable + public partial class DxIndexBuffer : Buffer, INativeIndexBuffer, IDisposable { - public Dx10.Buffer NativeBuffer { get; protected set; } - +#if DEBUG + private static int indexBufferCount = 0; + private static int dynamicIndexBufferCount = 0; +#endif #region Constructor - public DxIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) + public DxIndexBuffer(GraphicsDeviceDX graphics, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) + : base(graphics.NativeDevice, usage, dynamic) { elementSize = size; - GraphicsDeviceDX gd10 = graphics.NativeDevice as GraphicsDeviceDX; - Dx10.Device device = gd10 != null ? gd10.NativeDevice as Dx10.Device : null; - InitializeBuffer(device, size, indexCount, usage); + InitializeBuffer(graphics.NativeDevice, size, indexCount, usage, dynamic); } - internal DxIndexBuffer(Dx10.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + internal DxIndexBuffer(Dx10.Device device, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) + : base(device, usage, dynamic) { elementSize = size; - InitializeBuffer(device, size, indexCount, usage); + InitializeBuffer(device, size, indexCount, usage, dynamic); } #endregion #region InitializeBuffer - private void InitializeBuffer(Dx10.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + private void InitializeBuffer(Dx10.Device device, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) { //TODO: translate and use usage var description = new Dx10.BufferDescription() { - Usage = Dx10.ResourceUsage.Dynamic, + Usage = dynamic ? Dx10.ResourceUsage.Dynamic : Dx10.ResourceUsage.Default, SizeInBytes = GetSizeInBytes(indexCount), BindFlags = Dx10.BindFlags.IndexBuffer, - CpuAccessFlags = Dx10.CpuAccessFlags.Write, + CpuAccessFlags = dynamic ? Dx10.CpuAccessFlags.Write : Dx10.CpuAccessFlags.None, OptionFlags = Dx10.ResourceOptionFlags.None }; NativeBuffer = new Dx10.Buffer(device, description); - //NativeBuffer.Unmap(); +#if DEBUG + if (dynamic) + NativeBuffer.DebugName = "DynamicIndexBuffer_" + dynamicIndexBufferCount++; + else + NativeBuffer.DebugName = "IndexBuffer_" + indexBufferCount++; +#endif } #endregion - - protected DataStream MapBufferWrite() - { - return NativeBuffer.Map(Dx10.MapMode.WriteDiscard); - } - - private SharpDX.DataStream MapBufferRead(Dx10.Buffer buffer) - { - return buffer.Map(Dx10.MapMode.Read); - } - - protected void UnmapBuffer(Dx10.Buffer buffer) - { - buffer.Unmap(); - } - - protected void UnmapBuffer() - { - NativeBuffer.Unmap(); - } - - private void CopySubresource(Dx10.Buffer source, Dx10.Buffer destination) - { - BufferHelper.ValidateCopyResource(source, destination); - - this.NativeBuffer.Device.CopyResource(source, destination); - } - - private Dx10.Buffer CreateStagingBuffer() - { - var description = new Dx10.BufferDescription() - { - Usage = Dx10.ResourceUsage.Staging, - SizeInBytes = NativeBuffer.Description.SizeInBytes, - CpuAccessFlags = Dx10.CpuAccessFlags.Read, - OptionFlags = Dx10.ResourceOptionFlags.None, - }; - - return new Dx10.Buffer(NativeBuffer.Device, description); - } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxTexture2D.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxTexture2D.cs index c396ac07..2d0fb80d 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxTexture2D.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxTexture2D.cs @@ -50,7 +50,7 @@ namespace ANX.RenderSystem.Windows.DX10 this.GraphicsDevice = graphicsDevice; } - public DxTexture2D(GraphicsDeviceDX graphicsDevice, Dx10.Texture2D nativeTexture) + internal DxTexture2D(GraphicsDeviceDX graphicsDevice, Dx10.Texture2D nativeTexture) : this(graphicsDevice) { if (nativeTexture == null) diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxVertexBuffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxVertexBuffer.cs index 983d4d27..197f5e33 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/DxVertexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/DxVertexBuffer.cs @@ -10,99 +10,53 @@ using SharpDX; // "ANX.Framework developer group" and released under the Ms-PL license. // For details see: http://anxframework.codeplex.com/license -#if DX10 using Dx = SharpDX.Direct3D10; -using DxDevice = SharpDX.Direct3D10.Device; namespace ANX.RenderSystem.Windows.DX10 -#endif -#if DX11 -using Dx = SharpDX.Direct3D11; -using DxDevice = SharpDX.Direct3D11.Device; - -namespace ANX.RenderSystem.Windows.DX11 -#endif { - public partial class DxVertexBuffer : INativeVertexBuffer, IDisposable + public partial class DxVertexBuffer : Buffer, INativeVertexBuffer, IDisposable { - public Dx.Buffer NativeBuffer { get; protected set; } - private Dx.Device device; +#if DEBUG + private static int vertexBufferCount = 0; + private static int dynamicVertexBufferCount = 0; +#endif #region Constructor - public DxVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + public DxVertexBuffer(GraphicsDeviceDX graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) + : base(graphics.NativeDevice, usage, dynamic) { - GraphicsDeviceDX gd10 = graphics.NativeDevice as GraphicsDeviceDX; - this.device = gd10 != null ? gd10.NativeDevice as Dx.Device : null; - - InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + InitializeBuffer(graphics.NativeDevice, vertexDeclaration, vertexCount, usage, dynamic); } - internal DxVertexBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + internal DxVertexBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) + : base(device, usage, dynamic) { - InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + InitializeBuffer(device, vertexDeclaration, vertexCount, usage, dynamic); } #endregion #region InitializeBuffer - private void InitializeBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + private void InitializeBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) { this.vertexStride = vertexDeclaration.VertexStride; - //TODO: translate and use usage - - if (device != null) - { - var description = new Dx.BufferDescription() - { - Usage = Dx.ResourceUsage.Dynamic, - SizeInBytes = vertexDeclaration.VertexStride * vertexCount, - BindFlags = Dx.BindFlags.VertexBuffer, - CpuAccessFlags = Dx.CpuAccessFlags.Write, - OptionFlags = Dx.ResourceOptionFlags.None - }; - - NativeBuffer = new Dx.Buffer(device, description); - //NativeBuffer.Unmap(); - } - } - #endregion - - private DataStream MapBufferWrite() - { - return NativeBuffer.Map(Dx.MapMode.WriteDiscard); - } - - private SharpDX.DataStream MapBufferRead(Dx.Buffer buffer) - { - return buffer.Map(Dx.MapMode.ReadWrite); - } - - private void UnmapBuffer() - { - NativeBuffer.Unmap(); - } - - private void UnmapBuffer(Dx.Buffer buffer) - { - buffer.Unmap(); - } - - private void CopySubresource(Dx.Buffer source, Dx.Buffer destination) - { - this.device.CopyResource(source, destination); - } - - private Dx.Buffer CreateStagingBuffer() - { var description = new Dx.BufferDescription() { - Usage = Dx.ResourceUsage.Staging, - SizeInBytes = NativeBuffer.Description.SizeInBytes, - CpuAccessFlags = Dx.CpuAccessFlags.Read | Dx.CpuAccessFlags.Write, + Usage = dynamic ? Dx.ResourceUsage.Dynamic : Dx.ResourceUsage.Default, + SizeInBytes = vertexDeclaration.VertexStride * vertexCount, + BindFlags = Dx.BindFlags.VertexBuffer, + CpuAccessFlags = dynamic ? Dx.CpuAccessFlags.Write : Dx.CpuAccessFlags.None, OptionFlags = Dx.ResourceOptionFlags.None }; - return new Dx.Buffer(device, description); + NativeBuffer = new Dx.Buffer(device, description); +#if DEBUG + if (dynamic) + NativeBuffer.DebugName = "DynamicVertexBuffer_" + dynamicVertexBufferCount++; + else + NativeBuffer.DebugName = "VertexBuffer_" + vertexBufferCount++; +#endif } + #endregion } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX10/GraphicsDeviceDX.cs b/RenderSystems/ANX.RenderSystem.Windows.DX10/GraphicsDeviceDX.cs index fd25e190..fe59ac2f 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX10/GraphicsDeviceDX.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX10/GraphicsDeviceDX.cs @@ -201,52 +201,57 @@ namespace ANX.RenderSystem.Windows.DX10 int vertexCount = vertexData.Length; int indexCount = indexData.Length; - VertexBuffer vertexBuffer = new VertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly); - vertexBuffer.SetData(vertexData); - this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) }); - - IndexBuffer indexBuffer = new IndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly); - if (indexData.GetType() == typeof(Int16[])) + using (var vertexBuffer = new DynamicVertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly)) + using (var indexBuffer = new DynamicIndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly)) { - indexBuffer.SetData((short[])indexData); - } - else - { - indexBuffer.SetData((int[])indexData); - } + vertexBuffer.SetData(vertexData); + this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) }); - DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer); + if (indexData.GetType() == typeof(Int16[])) + { + indexBuffer.SetData((short[])indexData); + } + else + { + indexBuffer.SetData((int[])indexData); + } + + DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer); + } } public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType { int vertexCount = vertexData.Length; - DxVertexBuffer vb10 = new DxVertexBuffer(nativeDevice, vertexDeclaration, vertexCount, BufferUsage.None); - vb10.SetData(vertexData); - - Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer, vertexDeclaration.VertexStride, 0); - - nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); - - //TODO: check for currentEffect null and throw exception - // TODO: check for null's and throw exceptions - // TODO: get the correct pass index! - var technique = currentEffect.GetCurrentTechnique().NativeTechnique; - var pass = technique.GetPassByIndex(0); - var layout = CreateInputLayout(nativeDevice, pass.Description.Signature, vertexDeclaration); - - nativeDevice.InputAssembler.InputLayout = layout; - // Prepare All the stages - nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType); - - for (int i = 0; i < technique.Description.PassCount; ++i) + //TODO: use a shared vertexBuffer, instead of creating one on every call. + using (DxVertexBuffer vb10 = new DxVertexBuffer(nativeDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly, dynamic: true)) { - technique.GetPassByIndex(i).Apply(); - nativeDevice.Draw(vertexCount, vertexOffset); - } + vb10.SetData(vertexData); - nativeDevice.InputAssembler.InputLayout.Dispose(); - nativeDevice.InputAssembler.InputLayout = null; + Dx10.VertexBufferBinding nativeVertexBufferBindings = new Dx10.VertexBufferBinding(vb10.NativeBuffer, vertexDeclaration.VertexStride, 0); + + nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + //TODO: check for currentEffect null and throw exception + // TODO: check for null's and throw exceptions + // TODO: get the correct pass index! + var technique = currentEffect.GetCurrentTechnique().NativeTechnique; + var pass = technique.GetPassByIndex(0); + var layout = CreateInputLayout(nativeDevice, pass.Description.Signature, vertexDeclaration); + + nativeDevice.InputAssembler.InputLayout = layout; + // Prepare All the stages + nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType); + + for (int i = 0; i < technique.Description.PassCount; ++i) + { + technique.GetPassByIndex(i).Apply(); + nativeDevice.Draw(vertexCount, vertexOffset); + } + + nativeDevice.InputAssembler.InputLayout.Dispose(); + nativeDevice.InputAssembler.InputLayout = null; + } } private Dx10.EffectTechnique SetupEffectForDraw() @@ -466,6 +471,14 @@ namespace ANX.RenderSystem.Windows.DX10 { if (backBuffer != null) { + for (int i = 0; i < MAX_RENDER_TARGETS; i++) + { + this.renderTargetView[i] = null; + this.depthStencilView[i] = null; + } + + nativeDevice.OutputMerger.SetRenderTargets(MAX_RENDER_TARGETS, this.renderTargetView, null); + backBuffer.Dispose(); backBuffer = null; } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj index 80903d84..9f76be20 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj @@ -77,6 +77,7 @@ ResourceMapping.cs + diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Buffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Buffer.cs new file mode 100644 index 00000000..95c3ddb1 --- /dev/null +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Buffer.cs @@ -0,0 +1,81 @@ +using ANX.Framework.Graphics; +using SharpDX; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Dx = SharpDX.Direct3D11; + +namespace ANX.RenderSystem.Windows.DX11 +{ + public abstract class Buffer : IDisposable + { + public Dx.Buffer NativeBuffer { get; protected set; } + private Dx.Device device; + private BufferUsage usage; + private bool isDynamic; + + protected Buffer(Dx.Device device, BufferUsage usage, bool isDynamic) + { + this.device = device; + this.usage = usage; + this.isDynamic = isDynamic; + } + + protected DataStream MapBuffer(Dx.Buffer buffer, ResourceMapping mapping) + { + CheckUsage(mapping); + + DataStream dataStream; + device.ImmediateContext.MapSubresource(buffer, mapping.ToMapMode(), Dx.MapFlags.None, out dataStream); + return dataStream; + } + + protected void UnmapBuffer(Dx.Buffer buffer) + { + device.ImmediateContext.UnmapSubresource(buffer, 0); + } + + protected void CopySubresource(Dx.Buffer source, Dx.Buffer destination) + { + BufferHelper.ValidateCopyResource(source, destination); + + this.NativeBuffer.Device.ImmediateContext.CopyResource(source, destination); + } + + protected bool WriteNeedsStaging + { + get { return !this.isDynamic; } + } + + private void CheckUsage(ResourceMapping mapping) + { + if ((mapping & ResourceMapping.Write) != 0 && usage == BufferUsage.None) + throw new NotSupportedException("Resource was created with WriteOnly, reading from it is not supported."); + } + + protected Dx.Buffer CreateStagingBuffer(ResourceMapping mapping) + { + CheckUsage(mapping); + + var description = new Dx.BufferDescription() + { + Usage = Dx.ResourceUsage.Staging, + SizeInBytes = NativeBuffer.Description.SizeInBytes, + CpuAccessFlags = mapping.ToCpuAccessFlags(), + OptionFlags = Dx.ResourceOptionFlags.None + }; + + return new Dx.Buffer(device, description); + } + + public void Dispose() + { + if (NativeBuffer != null) + { + NativeBuffer.Dispose(); + NativeBuffer = null; + } + } + } +} diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs index a27826dc..93f1a109 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs @@ -77,8 +77,14 @@ namespace ANX.RenderSystem.Windows.DX11 int indexCount, BufferUsage usage) { PreventSystemChange(); - return new DxIndexBuffer(graphics, size, indexCount, usage); + return new DxIndexBuffer((GraphicsDeviceDX)graphics.NativeDevice, size, indexCount, usage, false); } + + public INativeIndexBuffer CreateDynamicIndexBuffer(GraphicsDevice graphics, IndexBuffer managedBuffer, IndexElementSize size, int indexCount, BufferUsage usage) + { + PreventSystemChange(); + return new DxIndexBuffer((GraphicsDeviceDX)graphics.NativeDevice, size, indexCount, usage, true); + } #endregion #region CreateVertexBuffer @@ -86,8 +92,14 @@ namespace ANX.RenderSystem.Windows.DX11 VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) { PreventSystemChange(); - return new DxVertexBuffer((GraphicsDeviceDX)graphics.NativeDevice, vertexDeclaration, vertexCount, usage); + return new DxVertexBuffer((GraphicsDeviceDX)graphics.NativeDevice, vertexDeclaration, vertexCount, usage, false); } + + public INativeVertexBuffer CreateDynamicVertexBuffer(GraphicsDevice graphics, DynamicVertexBuffer managedBuffer, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + { + PreventSystemChange(); + return new DxVertexBuffer((GraphicsDeviceDX)graphics.NativeDevice, vertexDeclaration, vertexCount, usage, true); + } #endregion #if XNAEXT @@ -277,5 +289,5 @@ namespace ANX.RenderSystem.Windows.DX11 AddInSystemFactory.Instance.PreventSystemChange(AddInType.RenderSystem); } #endregion - } + } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxIndexBuffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxIndexBuffer.cs index ab28a63e..8c9e241e 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxIndexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxIndexBuffer.cs @@ -14,91 +14,44 @@ using Dx11 = SharpDX.Direct3D11; namespace ANX.RenderSystem.Windows.DX11 { - public partial class DxIndexBuffer : INativeIndexBuffer, IDisposable + public partial class DxIndexBuffer : Buffer, INativeIndexBuffer { - public Dx11.Buffer NativeBuffer { get; protected set; } +#if DEBUG + private static int indexBufferCount = 0; + private static int dynamicIndexBufferCount = 0; +#endif - #region Constructor - public DxIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) + public DxIndexBuffer(GraphicsDeviceDX graphics, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) + : base(graphics.NativeDevice.Device, usage, dynamic) { - elementSize = size; - GraphicsDeviceDX gd11 = graphics.NativeDevice as GraphicsDeviceDX; - Dx11.DeviceContext context = gd11 != null ? gd11.NativeDevice as Dx11.DeviceContext : null; - - InitializeBuffer(context.Device, size, indexCount, usage); + InitializeBuffer(graphics.NativeDevice.Device, size, indexCount, usage, dynamic); } - internal DxIndexBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + internal DxIndexBuffer(SharpDX.Direct3D11.Device device, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) + : base(device, usage, dynamic) { elementSize = size; - InitializeBuffer(device, size, indexCount, usage); + InitializeBuffer(device, size, indexCount, usage, dynamic); } - #endregion - #region InitializeBuffer - private void InitializeBuffer(Dx11.Device device, IndexElementSize size, int indexCount, BufferUsage usage) + private void InitializeBuffer(Dx11.Device device, IndexElementSize size, int indexCount, BufferUsage usage, bool dynamic) { - //TODO: translate and use usage var description = new Dx11.BufferDescription() { - // TODO: translate usage - Usage = Dx11.ResourceUsage.Dynamic, + Usage = dynamic ? Dx11.ResourceUsage.Dynamic : Dx11.ResourceUsage.Default, SizeInBytes = GetSizeInBytes(indexCount), BindFlags = Dx11.BindFlags.IndexBuffer, - CpuAccessFlags = Dx11.CpuAccessFlags.Write, + CpuAccessFlags = dynamic ? Dx11.CpuAccessFlags.Write : Dx11.CpuAccessFlags.None, OptionFlags = Dx11.ResourceOptionFlags.None }; NativeBuffer = new SharpDX.Direct3D11.Buffer(device, description); - } - #endregion - - protected DataStream MapBufferWrite() - { - Dx11.DeviceContext context = NativeBuffer.Device.ImmediateContext; - DataStream stream; - context.MapSubresource(NativeBuffer, Dx11.MapMode.WriteDiscard, Dx11.MapFlags.None, out stream); - return stream; - } - - protected void UnmapBuffer() - { - Dx11.DeviceContext context = NativeBuffer.Device.ImmediateContext; - context.UnmapSubresource(NativeBuffer, 0); - } - - private SharpDX.DataStream MapBufferRead(Dx11.Buffer buffer) - { - Dx11.DeviceContext context = buffer.Device.ImmediateContext; - DataStream stream; - context.MapSubresource(buffer, Dx11.MapMode.Read, Dx11.MapFlags.None, out stream); - return stream; - } - - private void UnmapBuffer(Dx11.Buffer buffer) - { - Dx11.DeviceContext context = buffer.Device.ImmediateContext; - context.UnmapSubresource(buffer, 0); - } - - private void CopySubresource(Dx11.Buffer source, Dx11.Buffer destination) - { - BufferHelper.ValidateCopyResource(source, destination); - - this.NativeBuffer.Device.ImmediateContext.CopyResource(source, destination); - } - - private Dx11.Buffer CreateStagingBuffer() - { - var description = new Dx11.BufferDescription() - { - Usage = Dx11.ResourceUsage.Staging, - SizeInBytes = NativeBuffer.Description.SizeInBytes, - CpuAccessFlags = Dx11.CpuAccessFlags.Read, - OptionFlags = Dx11.ResourceOptionFlags.None, - }; - - return new Dx11.Buffer(NativeBuffer.Device, description); +#if DEBUG + if (dynamic) + NativeBuffer.DebugName = "DynamicIndexBuffer_" + dynamicIndexBufferCount++; + else + NativeBuffer.DebugName = "IndexBuffer_" + indexBufferCount++; +#endif } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxTexture2D.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxTexture2D.cs index 8182c3e2..8e5d57b1 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxTexture2D.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxTexture2D.cs @@ -50,7 +50,7 @@ namespace ANX.RenderSystem.Windows.DX11 this.GraphicsDevice = graphicsDevice; } - public DxTexture2D(GraphicsDeviceDX graphicsDevice, Dx11.Texture2D nativeTexture) + internal DxTexture2D(GraphicsDeviceDX graphicsDevice, Dx11.Texture2D nativeTexture) : this(graphicsDevice) { if (nativeTexture == null) diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxVertexBuffer.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxVertexBuffer.cs index b42e5d93..3209897b 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/DxVertexBuffer.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/DxVertexBuffer.cs @@ -23,90 +23,45 @@ using DxDevice = SharpDX.Direct3D11.Device; namespace ANX.RenderSystem.Windows.DX11 #endif { - public partial class DxVertexBuffer : INativeVertexBuffer, IDisposable + public partial class DxVertexBuffer : Buffer, INativeVertexBuffer { - public Dx.Buffer NativeBuffer { get; protected set; } - private Dx.DeviceContext context; +#if DEBUG + private static int vertexBufferCount = 0; + private static int dynamicVertexBufferCount = 0; +#endif - #region Constructor - public DxVertexBuffer(GraphicsDeviceDX graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + public DxVertexBuffer(GraphicsDeviceDX graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) + : base(graphics.NativeDevice.Device, usage, dynamic) { - this.context = graphics.NativeDevice; - - InitializeBuffer(context.Device, vertexDeclaration, vertexCount, usage); + InitializeBuffer(graphics.NativeDevice.Device, vertexDeclaration, vertexCount, usage, dynamic); } - internal DxVertexBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + internal DxVertexBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) + : base(device, usage, dynamic) { - InitializeBuffer(device, vertexDeclaration, vertexCount, usage); + InitializeBuffer(device, vertexDeclaration, vertexCount, usage, dynamic); } - #endregion - #region InitializeBuffer (TODO) - private void InitializeBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) + private void InitializeBuffer(Dx.Device device, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage, bool dynamic) { vertexStride = vertexDeclaration.VertexStride; - //TODO: translate and use usage - var description = new Dx.BufferDescription() { - Usage = Dx.ResourceUsage.Dynamic, + Usage = dynamic ? Dx.ResourceUsage.Dynamic : Dx.ResourceUsage.Default, SizeInBytes = vertexDeclaration.VertexStride * vertexCount, BindFlags = Dx.BindFlags.VertexBuffer, - CpuAccessFlags = Dx.CpuAccessFlags.Write, + CpuAccessFlags = dynamic ? Dx.CpuAccessFlags.Write : Dx.CpuAccessFlags.None, OptionFlags = Dx.ResourceOptionFlags.None }; NativeBuffer = new Dx.Buffer(device, description); - } - #endregion - - private SharpDX.DataStream MapBufferWrite() - { - Dx.DeviceContext context = NativeBuffer.Device.ImmediateContext; - DataStream stream; - context.MapSubresource(NativeBuffer, Dx.MapMode.WriteDiscard, Dx.MapFlags.None, out stream); - return stream; - } - - private SharpDX.DataStream MapBufferRead(Dx.Resource buffer) - { - DataStream stream; - buffer.Device.ImmediateContext.MapSubresource(buffer, 0, Dx.MapMode.Read, Dx.MapFlags.None, out stream); - return stream; - } - - private void UnmapBuffer() - { - Dx.DeviceContext context = NativeBuffer.Device.ImmediateContext; - context.UnmapSubresource(NativeBuffer, 0); - } - - private void CopySubresource(Dx.Buffer source, Dx.Buffer destination) - { - BufferHelper.ValidateCopyResource(source, destination); - - this.context.CopyResource(source, destination); - } - - private void UnmapBuffer(Dx.Resource buffer) - { - buffer.Device.ImmediateContext.UnmapSubresource(buffer, 0); - } - - private Dx.Buffer CreateStagingBuffer() - { - var description = new Dx.BufferDescription() - { - Usage = Dx.ResourceUsage.Staging, - SizeInBytes = NativeBuffer.Description.SizeInBytes, - BindFlags = Dx.BindFlags.VertexBuffer, - CpuAccessFlags = Dx.CpuAccessFlags.Read, - OptionFlags = Dx.ResourceOptionFlags.None - }; - - return new Dx.Buffer(context.Device, description); +#if DEBUG + if (dynamic) + NativeBuffer.DebugName = "DynamicVertexBuffer_" + dynamicVertexBufferCount++; + else + NativeBuffer.DebugName = "VertexBuffer_" + vertexBufferCount++; +#endif } } } diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceDX.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceDX.cs index cebb4cf0..4e293159 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceDX.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceDX.cs @@ -217,21 +217,23 @@ namespace ANX.RenderSystem.Windows.DX11 int vertexCount = vertexData.Length; int indexCount = indexData.Length; - VertexBuffer vertexBuffer = new VertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly); - vertexBuffer.SetData(vertexData); - this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) }); - - IndexBuffer indexBuffer = new IndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly); - if (indexData.GetType() == typeof(Int16[])) + using (VertexBuffer vertexBuffer = new VertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly)) + using (IndexBuffer indexBuffer = new IndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly)) { - indexBuffer.SetData((short[])indexData); - } - else - { - indexBuffer.SetData((int[])indexData); - } + vertexBuffer.SetData(vertexData); + this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) }); - DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer); + if (indexData.GetType() == typeof(Int16[])) + { + indexBuffer.SetData((short[])indexData); + } + else + { + indexBuffer.SetData((int[])indexData); + } + + DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer); + } } #endregion // DrawUserIndexedPrimitives @@ -240,32 +242,34 @@ namespace ANX.RenderSystem.Windows.DX11 public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType { int vertexCount = vertexData.Length; - DxVertexBuffer vb11 = new DxVertexBuffer(this, vertexDeclaration, vertexCount, BufferUsage.None); - vb11.SetData(vertexData); - - Dx11.VertexBufferBinding nativeVertexBufferBindings = new Dx11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0); - - nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); - - Dx11.EffectPass pass; Dx11.EffectTechnique technique; ShaderBytecode passSignature; - SetupEffectForDraw(out pass, out technique, out passSignature); - - var layout = CreateInputLayout(nativeDevice.Device, passSignature, vertexDeclaration); - - nativeDevice.InputAssembler.InputLayout = layout; - // Prepare All the stages - nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType); - //nativeDevice.Rasterizer.SetViewports(currentViewport); - //device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); - - for (int i = 0; i < technique.Description.PassCount; ++i) + using (DxVertexBuffer vb11 = new DxVertexBuffer(this, vertexDeclaration, vertexCount, BufferUsage.WriteOnly, dynamic: true)) { - pass.Apply(nativeDevice); - nativeDevice.Draw(primitiveCount, vertexOffset); - } + vb11.SetData(vertexData); - layout.Dispose(); - layout = null; + Dx11.VertexBufferBinding nativeVertexBufferBindings = new Dx11.VertexBufferBinding(vb11.NativeBuffer, vertexDeclaration.VertexStride, 0); + + nativeDevice.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings); + + Dx11.EffectPass pass; Dx11.EffectTechnique technique; ShaderBytecode passSignature; + SetupEffectForDraw(out pass, out technique, out passSignature); + + var layout = CreateInputLayout(nativeDevice.Device, passSignature, vertexDeclaration); + + nativeDevice.InputAssembler.InputLayout = layout; + // Prepare All the stages + nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType); + //nativeDevice.Rasterizer.SetViewports(currentViewport); + //device.OutputMerger.SetTargets(this.depthStencilView, this.renderView); + + for (int i = 0; i < technique.Description.PassCount; ++i) + { + pass.Apply(nativeDevice); + nativeDevice.Draw(primitiveCount, vertexOffset); + } + + layout.Dispose(); + layout = null; + } } #endregion // DrawUserPrimitives @@ -498,6 +502,14 @@ namespace ANX.RenderSystem.Windows.DX11 { if (backBuffer != null) { + for (int i = 0; i < MAX_RENDER_TARGETS; i++) + { + this.renderTargetView[i] = null; + this.depthStencilView[i] = null; + } + + nativeDevice.OutputMerger.SetRenderTargets(null, this.renderTargetView); + backBuffer.Dispose(); backBuffer = null; } diff --git a/Samples/AlphaTestEffectSample/AlphaTestEffectSample.csproj b/Samples/AlphaTestEffectSample/AlphaTestEffectSample.csproj index 01e500f0..efba9d85 100644 --- a/Samples/AlphaTestEffectSample/AlphaTestEffectSample.csproj +++ b/Samples/AlphaTestEffectSample/AlphaTestEffectSample.csproj @@ -4,7 +4,7 @@ Debug AnyCPU - {E1A73436-CD1C-41B8-9295-8F1C20740063} + {0005BDAA-F232-45C3-8D37-7E4FF7A1F605} WinExe Properties AlphaTestEffectSample diff --git a/Samples/Primitives.sln b/Samples/Primitives.sln index 41e56400..c7e4e215 100644 --- a/Samples/Primitives.sln +++ b/Samples/Primitives.sln @@ -1,58 +1,211 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleContent", "SampleContent\SampleContent.contentproj", "{FA6E229D-4504-47B1-8A23-2D3FCC13F778}" -EndProject +# Visual Studio 2013 +VisualStudioVersion = 12.0.40629.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primitives", "Primitives\Primitives.csproj", "{57097B7A-A283-4409-8AAC-35BF0F458657}" + ProjectSection(ProjectDependencies) = postProject + {75EFAE60-726E-430F-8661-4CF9ABD1306C} = {75EFAE60-726E-430F-8661-4CF9ABD1306C} + EndProjectSection +EndProject +Project("{75EFAE60-726E-430F-8661-4CF9ABD1306C}") = "SampleContent", "SampleContent\SampleContent.cproj", "{75EFAE60-726E-430F-8661-4CF9ABD1306C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Android = Debug|Android Debug|Any CPU = Debug|Any CPU + Debug|iOS = Debug|iOS + Debug|Linux = Debug|Linux + Debug|Mac OS = Debug|Mac OS Debug|Mixed Platforms = Debug|Mixed Platforms + Debug|PS Vita = Debug|PS Vita + Debug|Windows = Debug|Windows + Debug|Windows Metro = Debug|Windows Metro + Debug|Windows Phone = Debug|Windows Phone Debug|x86 = Debug|x86 + Debug|XBox 360 = Debug|XBox 360 + DebugWin8|Android = DebugWin8|Android DebugWin8|Any CPU = DebugWin8|Any CPU + DebugWin8|iOS = DebugWin8|iOS + DebugWin8|Linux = DebugWin8|Linux + DebugWin8|Mac OS = DebugWin8|Mac OS DebugWin8|Mixed Platforms = DebugWin8|Mixed Platforms + DebugWin8|PS Vita = DebugWin8|PS Vita + DebugWin8|Windows = DebugWin8|Windows + DebugWin8|Windows Metro = DebugWin8|Windows Metro + DebugWin8|Windows Phone = DebugWin8|Windows Phone DebugWin8|x86 = DebugWin8|x86 + DebugWin8|XBox 360 = DebugWin8|XBox 360 + Release|Android = Release|Android Release|Any CPU = Release|Any CPU + Release|iOS = Release|iOS + Release|Linux = Release|Linux + Release|Mac OS = Release|Mac OS Release|Mixed Platforms = Release|Mixed Platforms + Release|PS Vita = Release|PS Vita + Release|Windows = Release|Windows + Release|Windows Metro = Release|Windows Metro + Release|Windows Phone = Release|Windows Phone Release|x86 = Release|x86 + Release|XBox 360 = Release|XBox 360 + ReleaseWin8|Android = ReleaseWin8|Android ReleaseWin8|Any CPU = ReleaseWin8|Any CPU + ReleaseWin8|iOS = ReleaseWin8|iOS + ReleaseWin8|Linux = ReleaseWin8|Linux + ReleaseWin8|Mac OS = ReleaseWin8|Mac OS ReleaseWin8|Mixed Platforms = ReleaseWin8|Mixed Platforms + ReleaseWin8|PS Vita = ReleaseWin8|PS Vita + ReleaseWin8|Windows = ReleaseWin8|Windows + ReleaseWin8|Windows Metro = ReleaseWin8|Windows Metro + ReleaseWin8|Windows Phone = ReleaseWin8|Windows Phone ReleaseWin8|x86 = ReleaseWin8|x86 + ReleaseWin8|XBox 360 = ReleaseWin8|XBox 360 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Debug|x86.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.DebugWin8|Any CPU.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.DebugWin8|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.DebugWin8|x86.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Release|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.Release|x86.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.ReleaseWin8|Any CPU.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.ReleaseWin8|Mixed Platforms.ActiveCfg = Debug|Any CPU - {FA6E229D-4504-47B1-8A23-2D3FCC13F778}.ReleaseWin8|x86.ActiveCfg = Debug|Any CPU + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Android.ActiveCfg = Debug|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Any CPU.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|iOS.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Linux.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Mac OS.ActiveCfg = Debug|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|PS Vita.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Windows.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Windows Metro.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Windows Phone.ActiveCfg = Debug|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|x86.ActiveCfg = Debug|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|x86.Build.0 = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|XBox 360.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Android.ActiveCfg = DebugWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Any CPU.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|iOS.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Linux.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Mac OS.ActiveCfg = DebugWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Mixed Platforms.ActiveCfg = DebugWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Mixed Platforms.Build.0 = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|PS Vita.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Windows.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Windows Metro.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|Windows Phone.ActiveCfg = DebugWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|x86.ActiveCfg = DebugWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|x86.Build.0 = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.DebugWin8|XBox 360.ActiveCfg = DebugWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Android.ActiveCfg = Release|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Any CPU.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|iOS.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Linux.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Mac OS.ActiveCfg = Release|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Mixed Platforms.ActiveCfg = Release|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Mixed Platforms.Build.0 = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|PS Vita.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Windows.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Windows Metro.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Windows Phone.ActiveCfg = Release|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|x86.ActiveCfg = Release|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|x86.Build.0 = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|XBox 360.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Android.ActiveCfg = ReleaseWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Any CPU.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|iOS.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Linux.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Mac OS.ActiveCfg = ReleaseWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Mixed Platforms.ActiveCfg = ReleaseWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Mixed Platforms.Build.0 = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|PS Vita.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Windows.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Windows Metro.ActiveCfg = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|Windows Phone.ActiveCfg = ReleaseWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|x86.ActiveCfg = ReleaseWin8|x86 {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|x86.Build.0 = ReleaseWin8|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.ReleaseWin8|XBox 360.ActiveCfg = ReleaseWin8|x86 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Android.ActiveCfg = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Android.Build.0 = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Any CPU.ActiveCfg = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|iOS.ActiveCfg = Debug|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|iOS.Build.0 = Debug|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Linux.ActiveCfg = Debug|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Linux.Build.0 = Debug|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Mac OS.ActiveCfg = Debug|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Mac OS.Build.0 = Debug|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Mixed Platforms.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Mixed Platforms.Build.0 = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|PS Vita.ActiveCfg = Debug|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|PS Vita.Build.0 = Debug|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows.ActiveCfg = Debug|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows.Build.0 = Debug|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows Metro.ActiveCfg = Debug|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows Metro.Build.0 = Debug|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows Phone.ActiveCfg = Debug|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|Windows Phone.Build.0 = Debug|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|x86.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|XBox 360.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Debug|XBox 360.Build.0 = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Android.ActiveCfg = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Android.Build.0 = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Any CPU.ActiveCfg = Debug|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|iOS.ActiveCfg = Debug|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|iOS.Build.0 = Debug|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Linux.ActiveCfg = Debug|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Linux.Build.0 = Debug|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Mac OS.ActiveCfg = Debug|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Mac OS.Build.0 = Debug|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Mixed Platforms.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Mixed Platforms.Build.0 = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|PS Vita.ActiveCfg = Debug|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|PS Vita.Build.0 = Debug|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows.ActiveCfg = Debug|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows.Build.0 = Debug|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows Metro.ActiveCfg = Debug|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows Metro.Build.0 = Debug|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows Phone.ActiveCfg = Debug|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|Windows Phone.Build.0 = Debug|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|x86.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|XBox 360.ActiveCfg = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.DebugWin8|XBox 360.Build.0 = Debug|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Android.ActiveCfg = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Android.Build.0 = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Any CPU.ActiveCfg = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|iOS.ActiveCfg = Release|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|iOS.Build.0 = Release|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Linux.ActiveCfg = Release|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Linux.Build.0 = Release|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Mac OS.ActiveCfg = Release|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Mac OS.Build.0 = Release|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Mixed Platforms.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Mixed Platforms.Build.0 = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|PS Vita.ActiveCfg = Release|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|PS Vita.Build.0 = Release|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows.ActiveCfg = Release|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows.Build.0 = Release|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows Metro.ActiveCfg = Release|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows Metro.Build.0 = Release|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows Phone.ActiveCfg = Release|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|Windows Phone.Build.0 = Release|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|x86.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|XBox 360.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.Release|XBox 360.Build.0 = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Android.ActiveCfg = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Android.Build.0 = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Any CPU.ActiveCfg = Release|Android + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|iOS.ActiveCfg = Release|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|iOS.Build.0 = Release|iOS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Linux.ActiveCfg = Release|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Linux.Build.0 = Release|Linux + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Mac OS.ActiveCfg = Release|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Mac OS.Build.0 = Release|Mac OS + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Mixed Platforms.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Mixed Platforms.Build.0 = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|PS Vita.ActiveCfg = Release|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|PS Vita.Build.0 = Release|PS Vita + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows.ActiveCfg = Release|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows.Build.0 = Release|Windows + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows Metro.ActiveCfg = Release|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows Metro.Build.0 = Release|Windows Metro + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows Phone.ActiveCfg = Release|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|Windows Phone.Build.0 = Release|Windows Phone + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|x86.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|XBox 360.ActiveCfg = Release|XBox 360 + {75EFAE60-726E-430F-8661-4CF9ABD1306C}.ReleaseWin8|XBox 360.Build.0 = Release|XBox 360 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Samples/Primitives/Primitives.csproj b/Samples/Primitives/Primitives.csproj index cf26a96f..8964b07a 100644 --- a/Samples/Primitives/Primitives.csproj +++ b/Samples/Primitives/Primitives.csproj @@ -1,8 +1,8 @@  + {57097B7A-A283-4409-8AAC-35BF0F458657} - {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} Debug x86 WinExe @@ -11,28 +11,10 @@ Primitives v4.0 Client - v4.0 - Windows - HiDef - 4b5697b8-4699-4c1a-85fd-a80f5d4b2aa3 - Game anx.ico - GameThumbnail.png - publish\ - true - Disk - false - Foreground - 7 - Days - false - false true 0 1.0.0.%2a - false - false - true true @@ -45,7 +27,6 @@ true false x86 - false pdbonly @@ -57,7 +38,6 @@ true false x86 - true bin\x86\DebugWin8\ @@ -80,6 +60,9 @@ ;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules true + + Always + @@ -124,11 +107,6 @@ {6A582788-C4D2-410C-96CD-177F75712D65} ANX.SoundSystem.Windows.XAudio - - {FA6E229D-4504-47B1-8A23-2D3FCC13F778} - SampleContent - Content - @@ -151,14 +129,11 @@ Windows Installer 3.1 true - - False - Microsoft XNA Framework Redistributable 4.0 - true - - + + xcopy $(ProjectDir)..\SampleContent\bin\$(ConfigurationName) $(TargetDir)SampleContent\ /D /E /Y +