Migrated StencilBuffer example and removed memory leaks for DX10 and DX11

Remove build message saying that a content file is still valid and will
be skipped.
Use OnApply for Effects, instead of an internal PreBindSetParameters.
Removed unnecessary dependencies from EffectParameterCollection and
EffectTechniqueCollection.
Moved Apply from INativeEffect to INativeEffectPass as Apply can only be
called on an EffectPass.
Added IDisposable to many Native object interfaces.
Added an InputLayoutManager so the InputLayouts don't get created on
every call.
Increased the amount of shared code for the GraphicsDevice between DX10
and DX11.
Simplified the amount of stuff the Draw calls do.
It's possible to use specific renderPasses when drawing and the drawing
methods of the GraphicsDevice don't draw all effectPasses of an effec
anymore.
Fixed the bug that a DynamicVertexBuffer created a staging buffer when
setting Elements for DX10 and DX11, which was unnecessary. Also it
didn't create a staging before for normal VertexBuffers which made it
not possible to set data there.
Implement EffectAnnotations for DX10.
Fixed SetRenderTargets for DX11.
This commit is contained in:
Konstantin Koch 2015-10-14 23:59:27 +02:00
parent 85322e2363
commit 3cd7efbba4
46 changed files with 1361 additions and 1071 deletions

View File

@ -290,7 +290,6 @@ namespace ANX.Framework.Content.Pipeline.Tasks
{
if (BuildCache.IsValid(buildItem, outputFilename))
{
BuildLogger.LogMessage("---\"{0}\" still valid, skipping build.", buildItem.SourceFilename);
return true;
}
return false;

View File

@ -151,8 +151,7 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
internal override void PreBindSetParameters()
protected internal override void OnApply()
{
Matrix worldView;
Matrix.Multiply(ref world, ref view, out worldView);
@ -173,7 +172,6 @@ namespace ANX.Framework.Graphics
else
Parameters["FogVector"].SetValue(Vector4.Zero);
}
#endregion
#region SetAlphaTestValue
private void SetAlphaTestValue()

View File

@ -244,8 +244,7 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
internal override void PreBindSetParameters()
protected internal override void OnApply()
{
Matrix worldView;
Matrix.Multiply(ref world, ref view, out worldView);
@ -270,7 +269,6 @@ namespace ANX.Framework.Graphics
SelectTechnique();
}
#endregion
#region SelectTechnique
private void SelectTechnique()

View File

@ -136,8 +136,7 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
internal override void PreBindSetParameters()
protected internal override void OnApply()
{
Matrix worldView;
Matrix.Multiply(ref world, ref view, out worldView);
@ -158,7 +157,6 @@ namespace ANX.Framework.Graphics
else
Parameters["FogVector"].SetValue(Vector4.Zero);
}
#endregion
#region SelectTechnique
private void SelectTechnique()

View File

@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using ANX.Framework.NonXNA;
using ANX.Framework.NonXNA.Development;
@ -19,6 +20,7 @@ namespace ANX.Framework.Graphics
private INativeEffect nativeEffect;
private readonly byte[] byteCode;
private EffectSourceLanguage sourceLanguage;
private EffectTechnique currentTechnique;
#endregion
#region Public
@ -26,29 +28,39 @@ namespace ANX.Framework.Graphics
{
get
{
if (nativeEffect == null)
{
CreateNativeEffect(this.sourceLanguage);
}
return this.nativeEffect;
}
}
public EffectTechnique CurrentTechnique { get; set; }
public EffectTechnique CurrentTechnique
{
get { return this.currentTechnique; }
set
{
if (value == null)
throw new ArgumentNullException("value");
if (!Techniques.Contains(value))
throw new InvalidOperationException("CurrentTechnique must be a technique of the same effect instance.");
this.currentTechnique = value;
}
}
public EffectParameterCollection Parameters { get; private set; }
public EffectTechniqueCollection Techniques { get; private set; }
#endregion
#region Constructor
protected Effect(Effect cloneSource)
: this(cloneSource.GraphicsDevice, cloneSource.byteCode)
{
CreateNativeEffect(cloneSource.sourceLanguage);
}
public Effect(GraphicsDevice graphicsDevice, byte[] byteCode)
: this(graphicsDevice, byteCode, EffectSourceLanguage.HLSL_FX)
{
CreateNativeEffect(EffectSourceLanguage.HLSL_FX);
}
public Effect(GraphicsDevice graphicsDevice, byte[] byteCode, EffectSourceLanguage sourceLanguage)
@ -67,14 +79,6 @@ namespace ANX.Framework.Graphics
this.sourceLanguage = sourceLanguage;
}
~Effect()
{
Dispose();
base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed;
}
#endregion
#region GraphicsDevice_ResourceCreated
private void GraphicsDevice_ResourceCreated(object sender, ResourceCreatedEventArgs e)
{
@ -106,14 +110,9 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
/// <summary>
/// This is used by the built in effects to set all their parameters only once and not everytime the properties change.
/// </summary>
internal virtual void PreBindSetParameters()
{
}
#endregion
protected internal virtual void OnApply()
{
}
#region Dispose
protected override void Dispose(bool disposeManaged)
@ -125,6 +124,23 @@ namespace ANX.Framework.Graphics
nativeEffect.Dispose();
nativeEffect = null;
}
if (Parameters != null)
{
foreach (var parameter in Parameters)
parameter.NativeParameter.Dispose();
Parameters = null;
}
if (Techniques != null)
{
foreach (var technique in Techniques)
technique.NativeTechnique.Dispose();
Techniques = null;
}
base.GraphicsDevice.ResourceCreated -= GraphicsDevice_ResourceCreated;
base.GraphicsDevice.ResourceDestroyed -= GraphicsDevice_ResourceDestroyed;
}
base.Dispose(disposeManaged);
@ -139,8 +155,8 @@ namespace ANX.Framework.Graphics
if (creator.IsLanguageSupported(sourceLanguage))
{
this.nativeEffect = creator.CreateEffect(GraphicsDevice, this, new MemoryStream(this.byteCode, false));
this.Techniques = new EffectTechniqueCollection(this, this.nativeEffect);
this.Parameters = new EffectParameterCollection(this, this.nativeEffect);
this.Techniques = new EffectTechniqueCollection(this.nativeEffect.Techniques);
this.Parameters = new EffectParameterCollection(this.nativeEffect.Parameters);
}
else
throw new InvalidOperationException("couldn't create " + sourceLanguage + " native effect using RenderSystem " +

View File

@ -13,81 +13,85 @@ namespace ANX.Framework.Graphics
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectAnnotation
{
private readonly INativeEffectAnnotation nativeAnnotation;
internal INativeEffectAnnotation NativeAnnotation
{
get;
private set;
}
public int ColumnCount
{
get { return nativeAnnotation.ColumnCount; }
get { return NativeAnnotation.ColumnCount; }
}
public string Name
{
get { return nativeAnnotation.Name; }
get { return NativeAnnotation.Name; }
}
public EffectParameterClass ParameterClass
{
get { return nativeAnnotation.ParameterClass; }
get { return NativeAnnotation.ParameterClass; }
}
public EffectParameterType ParameterType
{
get { return nativeAnnotation.ParameterType; }
get { return NativeAnnotation.ParameterType; }
}
public int RowCount
{
get { return nativeAnnotation.RowCount; }
get { return NativeAnnotation.RowCount; }
}
public string Semantic
{
get { return nativeAnnotation.Semantic; }
get { return NativeAnnotation.Semantic; }
}
internal EffectAnnotation(INativeEffectAnnotation setNativeAnnotation)
{
nativeAnnotation = setNativeAnnotation;
NativeAnnotation = setNativeAnnotation;
}
public bool GetValueBoolean()
{
return nativeAnnotation.GetValueBoolean();
return NativeAnnotation.GetValueBoolean();
}
public int GetValueInt32()
{
return nativeAnnotation.GetValueInt32();
return NativeAnnotation.GetValueInt32();
}
public Matrix GetValueMatrix()
{
return nativeAnnotation.GetValueMatrix();
return NativeAnnotation.GetValueMatrix();
}
public float GetValueSingle()
{
return nativeAnnotation.GetValueSingle();
return NativeAnnotation.GetValueSingle();
}
public string GetValueString()
{
return nativeAnnotation.GetValueString();
return NativeAnnotation.GetValueString();
}
public Vector2 GetValueVector2()
{
return nativeAnnotation.GetValueVector2();
return NativeAnnotation.GetValueVector2();
}
public Vector3 GetValueVector3()
{
return nativeAnnotation.GetValueVector3();
return NativeAnnotation.GetValueVector3();
}
public Vector4 GetValueVector4()
{
return nativeAnnotation.GetValueVector4();
return NativeAnnotation.GetValueVector4();
}
}
}

View File

@ -35,9 +35,9 @@ namespace ANX.Framework.Graphics
get { return annotations.FirstOrDefault(annotation => annotation.Name == name); }
}
internal EffectAnnotationCollection(List<EffectAnnotation> setAnnotations)
internal EffectAnnotationCollection(IEnumerable<EffectAnnotation> setAnnotations)
{
annotations = setAnnotations ?? new List<EffectAnnotation>();
annotations = new List<EffectAnnotation>(setAnnotations);
}
IEnumerator<EffectAnnotation> IEnumerable<EffectAnnotation>.GetEnumerator()

View File

@ -14,271 +14,275 @@ namespace ANX.Framework.Graphics
[Developer("Glatzemann")]
public sealed class EffectParameter
{
private readonly INativeEffectParameter nativeParameter;
internal INativeEffectParameter NativeParameter
{
get;
private set;
}
#region Public
public EffectAnnotationCollection Annotations
{
get { return nativeParameter.Annotations; }
get { return NativeParameter.Annotations; }
}
public EffectParameterCollection Elements
{
get { return nativeParameter.Elements; }
get { return NativeParameter.Elements; }
}
public EffectParameterCollection StructureMembers
{
get { return nativeParameter.StructureMembers; }
get { return NativeParameter.StructureMembers; }
}
public int ColumnCount
{
get { return nativeParameter.ColumnCount; }
get { return NativeParameter.ColumnCount; }
}
public string Name
{
get { return nativeParameter.Name; }
get { return NativeParameter.Name; }
}
public EffectParameterClass ParameterClass
{
get { return nativeParameter.ParameterClass; }
get { return NativeParameter.ParameterClass; }
}
public EffectParameterType ParameterType
{
get { return nativeParameter.ParameterType; }
get { return NativeParameter.ParameterType; }
}
public int RowCount
{
get { return nativeParameter.RowCount; }
get { return NativeParameter.RowCount; }
}
public string Semantic
{
get { return nativeParameter.Semantic; }
get { return NativeParameter.Semantic; }
}
#endregion
internal EffectParameter(INativeEffectParameter nativeParameter)
{
this.nativeParameter = nativeParameter;
this.NativeParameter = nativeParameter;
}
#region GetValue
public bool GetValueBoolean()
{
return nativeParameter.GetValueBoolean();
return NativeParameter.GetValueBoolean();
}
public bool[] GetValueBooleanArray(int count)
{
return nativeParameter.GetValueBooleanArray(count);
return NativeParameter.GetValueBooleanArray(count);
}
public int GetValueInt32()
{
return nativeParameter.GetValueInt32();
return NativeParameter.GetValueInt32();
}
public Int32[] GetValueInt32Array(int count)
{
return nativeParameter.GetValueInt32Array(count);
return NativeParameter.GetValueInt32Array(count);
}
public Matrix GetValueMatrix()
{
return nativeParameter.GetValueMatrix();
return NativeParameter.GetValueMatrix();
}
public Matrix[] GetValueMatrixArray(int count)
{
return nativeParameter.GetValueMatrixArray(count);
return NativeParameter.GetValueMatrixArray(count);
}
public Matrix GetValueMatrixTranspose()
{
return nativeParameter.GetValueMatrixTranspose();
return NativeParameter.GetValueMatrixTranspose();
}
public Matrix[] GetValueMatrixTransposeArray(int count)
{
return nativeParameter.GetValueMatrixTransposeArray(count);
return NativeParameter.GetValueMatrixTransposeArray(count);
}
public Quaternion GetValueQuaternion()
{
return nativeParameter.GetValueQuaternion();
return NativeParameter.GetValueQuaternion();
}
public Quaternion[] GetValueQuaternionArray(int count)
{
return nativeParameter.GetValueQuaternionArray(count);
return NativeParameter.GetValueQuaternionArray(count);
}
public float GetValueSingle()
{
return nativeParameter.GetValueSingle();
return NativeParameter.GetValueSingle();
}
public float[] GetValueSingleArray(int count)
{
return nativeParameter.GetValueSingleArray(count);
return NativeParameter.GetValueSingleArray(count);
}
public string GetValueString()
{
return nativeParameter.GetValueString();
return NativeParameter.GetValueString();
}
public Texture2D GetValueTexture2D()
{
return nativeParameter.GetValueTexture2D();
return NativeParameter.GetValueTexture2D();
}
public Texture3D GetValueTexture3D()
{
return nativeParameter.GetValueTexture3D();
return NativeParameter.GetValueTexture3D();
}
public TextureCube GetValueTextureCube()
{
return nativeParameter.GetValueTextureCube();
return NativeParameter.GetValueTextureCube();
}
public Vector2 GetValueVector2()
{
return nativeParameter.GetValueVector2();
return NativeParameter.GetValueVector2();
}
public Vector2[] GetValueVector2Array(int count)
{
return nativeParameter.GetValueVector2Array(count);
return NativeParameter.GetValueVector2Array(count);
}
public Vector3 GetValueVector3()
{
return nativeParameter.GetValueVector3();
return NativeParameter.GetValueVector3();
}
public Vector3[] GetValueVector3Array(int count)
{
return nativeParameter.GetValueVector3Array(count);
return NativeParameter.GetValueVector3Array(count);
}
public Vector4 GetValueVector4()
{
return nativeParameter.GetValueVector4();
return NativeParameter.GetValueVector4();
}
public Vector4[] GetValueVector4Array(int count)
{
return nativeParameter.GetValueVector4Array(count);
return NativeParameter.GetValueVector4Array(count);
}
#endregion
#region SetValue
public void SetValue([MarshalAs(UnmanagedType.U1)] bool value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(bool[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(int value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(int[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Matrix value)
{
nativeParameter.SetValue(value, false);
NativeParameter.SetValue(value, false);
}
public void SetValue(Matrix[] value)
{
nativeParameter.SetValue(value, false);
NativeParameter.SetValue(value, false);
}
public void SetValue(Quaternion value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Quaternion[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(float value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(float[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(string value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Texture value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector2 value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector2[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector3 value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector3[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector4 value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValue(Vector4[] value)
{
nativeParameter.SetValue(value);
NativeParameter.SetValue(value);
}
public void SetValueTranspose(Matrix value)
{
nativeParameter.SetValue(value, true);
NativeParameter.SetValue(value, true);
}
public void SetValueTranspose(Matrix[] value)
{
nativeParameter.SetValue(value, true);
NativeParameter.SetValue(value, true);
}
#endregion
}

View File

@ -20,8 +20,6 @@ namespace ANX.Framework.Graphics
public sealed class EffectParameterCollection : IEnumerable<EffectParameter>
{
#region Private Members
private Effect parentEffect;
private INativeEffect nativeEffect;
private List<EffectParameter> parameters;
#endregion
@ -40,16 +38,9 @@ namespace ANX.Framework.Graphics
get { return parameters.Count; }
}
internal EffectParameterCollection(Effect parentEffect, INativeEffect nativeEffect)
internal EffectParameterCollection(IEnumerable<EffectParameter> parameters)
{
this.parentEffect = parentEffect;
this.nativeEffect = nativeEffect;
this.parameters = new List<EffectParameter>();
foreach (EffectParameter p in nativeEffect.Parameters)
{
this.parameters.Add(p);
}
this.parameters = new List<EffectParameter>(parameters);
}
public EffectParameter GetParameterBySemantic(string semantic)

View File

@ -1,5 +1,6 @@
using System;
using ANX.Framework.NonXNA.Development;
using ANX.Framework.NonXNA;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -14,21 +15,33 @@ namespace ANX.Framework.Graphics
{
private readonly Effect parentEffect;
public string Name { get; private set; }
public EffectAnnotationCollection Annotations { get; private set; }
internal EffectPass(Effect parentEffect)
internal INativeEffectPass NativeEffectPass
{
if (parentEffect == null)
throw new ArgumentNullException("parentEffect");
get;
private set;
}
this.parentEffect = parentEffect;
public string Name
{
get { return this.NativeEffectPass.Name; }
}
public EffectAnnotationCollection Annotations
{
get { return this.NativeEffectPass.Annotations; }
}
internal EffectPass(INativeEffectPass nativeEffectPass)
{
if (nativeEffectPass == null)
throw new ArgumentNullException("nativeEffectPass");
this.NativeEffectPass = nativeEffectPass;
}
public void Apply()
{
parentEffect.PreBindSetParameters();
parentEffect.NativeEffect.Apply(parentEffect.GraphicsDevice);
this.NativeEffectPass.Apply();
}
}
}

View File

@ -21,8 +21,6 @@ namespace ANX.Framework.Graphics
public sealed class EffectTechniqueCollection : IEnumerable<EffectTechnique>, IEnumerable
{
#region Private Members
private Effect parentEffect;
private INativeEffect nativeEffect;
private List<EffectTechnique> techniques;
#endregion // Private Members
@ -42,16 +40,9 @@ namespace ANX.Framework.Graphics
get { return techniques.Count; }
}
internal EffectTechniqueCollection(Effect parentEffect, INativeEffect nativeEffect)
internal EffectTechniqueCollection(IEnumerable<EffectTechnique> techniques)
{
this.parentEffect = parentEffect;
this.nativeEffect = nativeEffect;
this.techniques = new List<EffectTechnique>();
foreach (EffectTechnique teq in nativeEffect.Techniques)
{
this.techniques.Add(teq);
}
this.techniques = new List<EffectTechnique>(techniques);
}
IEnumerator<EffectTechnique> IEnumerable<EffectTechnique>.GetEnumerator()

View File

@ -212,8 +212,7 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
internal override void PreBindSetParameters()
protected internal override void OnApply()
{
Matrix worldView;
Matrix.Multiply(ref world, ref view, out worldView);
@ -242,7 +241,6 @@ namespace ANX.Framework.Graphics
SelectTechnique();
}
#endregion
#region SelectTechnique
private void SelectTechnique()

View File

@ -16,7 +16,6 @@ namespace ANX.Framework.Graphics
public class GraphicsDevice : IDisposable
{
#region Private Members
private IndexBuffer indexBuffer;
private SamplerStateCollection samplerStateCollection;
private Viewport viewport;
private BlendState blendState;
@ -116,11 +115,9 @@ namespace ANX.Framework.Graphics
NativeDevice.Present();
}
public void Present(Nullable<Rectangle> sourceRectangle, Nullable<Rectangle> destinationRectangle,
WindowHandle overrideWindowHandle)
public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, WindowHandle overrideWindowHandle)
{
//TODO: implement
throw new NotImplementedException();
NativeDevice.Present(sourceRectangle, destinationRectangle, overrideWindowHandle);
}
#endregion // Present
@ -128,12 +125,7 @@ namespace ANX.Framework.Graphics
#region DrawPrimitives & DrawIndexedPrimitives
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
{
if (this.indexBuffer == null)
{
throw new InvalidOperationException("you have to set a index buffer before you can draw using DrawIndexedPrimitives");
}
NativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, primitiveCount, this.indexBuffer);
NativeDevice.DrawIndexedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex, primitiveCount);
}
public void DrawPrimitives(PrimitiveType primitiveType, int startVertex, int primitiveCount)
@ -147,7 +139,7 @@ namespace ANX.Framework.Graphics
int startIndex, int primitiveCount, int instanceCount)
{
NativeDevice.DrawInstancedPrimitives(primitiveType, baseVertex, minVertexIndex, numVertices, startIndex,
primitiveCount, instanceCount, this.indexBuffer);
primitiveCount, instanceCount);
}
#endregion
@ -403,11 +395,11 @@ namespace ANX.Framework.Graphics
{
get
{
return this.indexBuffer;
return this.NativeDevice.IndexBuffer;
}
set
{
this.indexBuffer = value;
this.NativeDevice.IndexBuffer = value;
}
}
@ -649,9 +641,6 @@ namespace ANX.Framework.Graphics
raise_ResourceCreated(this, new ResourceCreatedEventArgs(NativeDevice));
GraphicsResourceTracker.Instance.UpdateGraphicsDeviceReference(this);
if (this.indexBuffer != null)
NativeDevice.SetIndexBuffer(this.indexBuffer);
if (this.currentVertexBufferBindings != null)
NativeDevice.SetVertexBuffers(this.currentVertexBufferBindings);

View File

@ -274,8 +274,7 @@ namespace ANX.Framework.Graphics
}
#endregion
#region PreBindSetParameters
internal override void PreBindSetParameters()
protected internal override void OnApply()
{
Matrix worldView;
Matrix.Multiply(ref world, ref view, out worldView);
@ -302,7 +301,6 @@ namespace ANX.Framework.Graphics
SelectTechnique();
}
#endregion
#region SelectTechnique
private void SelectTechnique()

View File

@ -470,9 +470,7 @@ namespace ANX.Framework.Graphics
this.vertexBuffer.SetData<VertexPositionColorTexture>(this.vertices, 0, vertexCount);
SetRenderStates();
spriteBatchEffect.Parameters["Texture"].SetValue(this.spriteInfos[offset].texture);
SetRenderStates(offset);
GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertexCount, 0, count * 2);
}
@ -568,7 +566,7 @@ namespace ANX.Framework.Graphics
#endregion
#region SetRenderStates
private void SetRenderStates()
private void SetRenderStates(int offset)
{
GraphicsDevice.BlendState = blendState != null ? blendState : BlendState.AlphaBlend;
GraphicsDevice.DepthStencilState = depthStencilState != null ? depthStencilState : DepthStencilState.None;
@ -598,7 +596,8 @@ namespace ANX.Framework.Graphics
Matrix result;
Matrix.Multiply(ref transformMatrix, ref cachedTransformMatrix, out result);
this.spriteBatchEffect.Parameters["MatrixTransform"].SetValue(result);
spriteBatchEffect.NativeEffect.Apply(GraphicsDevice);
spriteBatchEffect.Parameters["Texture"].SetValue(this.spriteInfos[offset].texture);
spriteBatchEffect.CurrentTechnique.Passes[0].Apply();
GraphicsDevice.Indices = this.indexBuffer;
GraphicsDevice.SetVertexBuffer(this.vertexBuffer);

View File

@ -13,8 +13,6 @@ namespace ANX.Framework.NonXNA
{
public interface INativeEffect : IDisposable
{
void Apply(GraphicsDevice graphicsDevice);
IEnumerable<EffectTechnique> Techniques { get; }
IEnumerable<EffectParameter> Parameters { get; }

View File

@ -1,5 +1,6 @@
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.Development;
using System;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,7 +11,7 @@ namespace ANX.Framework.NonXNA.RenderSystem
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public interface INativeEffectAnnotation
public interface INativeEffectAnnotation : IDisposable
{
int ColumnCount { get; }
string Name { get; }

View File

@ -14,7 +14,7 @@ namespace ANX.Framework.NonXNA
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public interface INativeEffectParameter
public interface INativeEffectParameter : IDisposable
{
string Name { get; }
string Semantic { get; }

View File

@ -11,8 +11,12 @@ using ANX.Framework.Graphics;
namespace ANX.Framework.NonXNA
{
public interface INativeEffectPass
public interface INativeEffectPass : IDisposable
{
string Name { get; }
EffectAnnotationCollection Annotations { get; }
void Apply();
}
}

View File

@ -11,7 +11,7 @@ using ANX.Framework.Graphics;
namespace ANX.Framework.NonXNA
{
public interface INativeEffectTechnique
public interface INativeEffectTechnique : IDisposable
{
string Name { get; }
IEnumerable<EffectPass> Passes { get; }

View File

@ -13,10 +13,11 @@ namespace ANX.Framework.NonXNA
void Present();
void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, IndexBuffer indexBuffer);
void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, WindowHandle overrideWindowHandle);
void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount, IndexBuffer indexBuffer);
void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount);
void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount);
void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
@ -33,7 +34,7 @@ namespace ANX.Framework.NonXNA
void SetVertexBuffers(VertexBufferBinding[] vertexBuffers);
void SetIndexBuffer(IndexBuffer indexBuffer);
IndexBuffer IndexBuffer { get; set; }
void SetViewport(Viewport viewport);

View File

@ -227,55 +227,53 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
#region Translate (ShaderVariableType)
public static EffectParameterType Translate(ShaderVariableType type)
public static ANX.Framework.Graphics.EffectParameterClass Translate(this ShaderVariableClass variableClass)
{
switch (type)
switch (variableClass)
{
case ShaderVariableClass.Vector:
return Framework.Graphics.EffectParameterClass.Vector;
case ShaderVariableClass.Struct:
return Framework.Graphics.EffectParameterClass.Struct;
case ShaderVariableClass.Scalar:
return Framework.Graphics.EffectParameterClass.Scalar;
case ShaderVariableClass.Object:
return Framework.Graphics.EffectParameterClass.Object;
case ShaderVariableClass.MatrixColumns:
case ShaderVariableClass.MatrixRows:
return Framework.Graphics.EffectParameterClass.Matrix;
default:
return (Framework.Graphics.EffectParameterClass)(-1);
}
}
public static ANX.Framework.Graphics.EffectParameterType Translate(this ShaderVariableType variableType)
{
switch (variableType)
{
case ShaderVariableType.Bool:
return EffectParameterType.Bool;
case ShaderVariableType.Texture1D:
return EffectParameterType.Texture1D;
case ShaderVariableType.Texture2D:
return EffectParameterType.Texture2D;
case ShaderVariableType.Texture3D:
return EffectParameterType.Texture3D;
case ShaderVariableType.Texture:
return EffectParameterType.Texture;
case ShaderVariableType.Void:
return EffectParameterType.Void;
return Framework.Graphics.EffectParameterType.Bool;
case ShaderVariableType.Int:
return EffectParameterType.Int32;
return Framework.Graphics.EffectParameterType.Int32;
case ShaderVariableType.Float:
return EffectParameterType.Single;
return Framework.Graphics.EffectParameterType.Single;
case ShaderVariableType.String:
return EffectParameterType.String;
return Framework.Graphics.EffectParameterType.String;
case ShaderVariableType.Texture:
return Framework.Graphics.EffectParameterType.Texture;
case ShaderVariableType.Texture1D:
return Framework.Graphics.EffectParameterType.Texture1D;
case ShaderVariableType.Texture2D:
return Framework.Graphics.EffectParameterType.Texture2D;
case ShaderVariableType.Texture3D:
return Framework.Graphics.EffectParameterType.Texture3D;
case ShaderVariableType.TextureCube:
return EffectParameterType.TextureCube;
return Framework.Graphics.EffectParameterType.TextureCube;
case ShaderVariableType.Void:
return Framework.Graphics.EffectParameterType.Void;
default:
return (Framework.Graphics.EffectParameterType)(-1);
}
return EffectParameterType.Void;
}
#endregion
#region Translate (ShaderVariableType)
public static EffectParameterClass Translate(ShaderVariableClass type)
{
switch (type)
{
case ShaderVariableClass.Scalar:
return EffectParameterClass.Scalar;
case ShaderVariableClass.Vector:
return EffectParameterClass.Vector;
case ShaderVariableClass.Struct:
return EffectParameterClass.Struct;
case ShaderVariableClass.MatrixRows:
case ShaderVariableClass.MatrixColumns:
return EffectParameterClass.Matrix;
}
return EffectParameterClass.Object;
}
#endregion
}
}

View File

@ -0,0 +1,184 @@
using ANX.Framework.Graphics;
using SharpDX.D3DCompiler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Anx = ANX.Framework.Graphics;
#if DX10
using SharpDX.Direct3D10;
namespace ANX.RenderSystem.Windows.DX10
#elif DX11
using SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.DX11
#endif
{
class InputLayoutManager : IDisposable
{
#if DEBUG
private static int layoutCount = 0;
#endif
private Dictionary<InputLayoutBinding[], InputLayout> layouts = new Dictionary<InputLayoutBinding[], InputLayout>(new InputLayoutBindingCompararer());
/// <summary>
/// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives.
/// The VertexDeclaration of ANX/XNA needs to be mapped to the DirectX 10 types.
/// </summary>
public InputLayout GetInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexDeclaration == null) throw new ArgumentNullException("vertexDeclaration");
var inputLayoutBinding = new InputLayoutBinding[] { new InputLayoutBinding() { vertexElements = vertexDeclaration.GetVertexElements() } };
InputLayout layout;
var vertexElements = vertexDeclaration.GetVertexElements();
if (!layouts.TryGetValue(inputLayoutBinding, out layout))
{
InputElement[] inputElements = new InputElement[vertexElements.Length];
for (int i = 0; i < vertexElements.Length; i++)
{
inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]);
}
layout = CreateInputLayout(device, passSignature, inputElements);
layouts.Add(inputLayoutBinding, layout);
}
return layout;
}
public InputLayout GetInputLayout(Device device, ShaderBytecode passSignature, params ANX.Framework.Graphics.VertexBufferBinding[] vertexBufferBindings)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexBufferBindings == null) throw new ArgumentNullException("vertexBufferBindings");
var inputLayoutBindings = vertexBufferBindings.Select((x) => new InputLayoutBinding() { instanceFrequency = x.InstanceFrequency, vertexElements = x.VertexBuffer.VertexDeclaration.GetVertexElements() }).ToArray();
InputLayout layout;
if (!layouts.TryGetValue(inputLayoutBindings, out layout))
{
List<InputElement> inputElements = new List<InputElement>();
int slot = 0;
foreach (ANX.Framework.Graphics.VertexBufferBinding binding in vertexBufferBindings)
{
foreach (VertexElement vertexElement in binding.VertexBuffer.VertexDeclaration.GetVertexElements())
{
inputElements.Add(CreateInputElementFromVertexElement(vertexElement, binding.InstanceFrequency, slot));
}
slot++;
}
// Layout from VertexShader input signature
layout = CreateInputLayout(device, passSignature, inputElements.ToArray());
layouts.Add(inputLayoutBindings, layout);
}
return layout;
}
private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, InputElement[] inputElements)
{
var layout = new InputLayout(device, passSignature, inputElements);
#if DEBUG
layout.DebugName = "InputLayout_" + layoutCount++;
#endif
return layout;
}
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement, int instanceFrequency, int slot)
{
string elementName = DxFormatConverter.Translate(ref vertexElement);
SharpDX.DXGI.Format elementFormat = DxFormatConverter.ConvertVertexElementFormat(vertexElement.VertexElementFormat);
return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, slot, instanceFrequency == 0 ? InputClassification.PerVertexData : InputClassification.PerInstanceData, instanceFrequency);
}
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
{
string elementName = DxFormatConverter.Translate(ref vertexElement);
SharpDX.DXGI.Format elementFormat = DxFormatConverter.ConvertVertexElementFormat(vertexElement.VertexElementFormat);
return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
foreach (var layout in layouts.Values)
{
layout.Dispose();
}
layouts.Clear();
}
}
class InputLayoutBinding : IEquatable<InputLayoutBinding>
{
public int instanceFrequency = 0;
public VertexElement[] vertexElements;
public override int GetHashCode()
{
int hash = this.instanceFrequency;
foreach (var element in this.vertexElements)
hash ^= element.GetHashCode();
return hash;
}
public override bool Equals(object obj)
{
if (obj is InputLayoutBinding)
return this.Equals((InputLayoutBinding)obj);
return false;
}
public bool Equals(InputLayoutBinding other)
{
return other.instanceFrequency == this.instanceFrequency && other.vertexElements.SequenceEqual(this.vertexElements);
}
}
class InputLayoutBindingCompararer : IEqualityComparer<InputLayoutBinding[]>
{
public bool Equals(InputLayoutBinding[] x, InputLayoutBinding[] y)
{
if (x.Length == y.Length)
{
for (int i = 0; i < x.Length; i++)
if (!x[i].Equals(y[i]))
return false;
return true;
}
return false;
}
public int GetHashCode(InputLayoutBinding[] obj)
{
int hash = 0;
foreach (var binding in obj)
hash ^= binding.GetHashCode();
return hash;
}
}
}
}

View File

@ -13,9 +13,13 @@ using SharpDX.DXGI;
// For details see: http://anxframework.codeplex.com/license
#if DX10
using SharpDX.Direct3D10;
namespace ANX.RenderSystem.Windows.DX10
#endif
#if DX11
using SharpDX.Direct3D11;
namespace ANX.RenderSystem.Windows.DX11
#endif
{
@ -23,9 +27,11 @@ namespace ANX.RenderSystem.Windows.DX11
{
#region Private
protected SharpDX.DXGI.SwapChain swapChain;
protected VertexBufferBinding[] currentVertexBuffer;
protected Framework.Graphics.VertexBufferBinding[] currentVertexBuffer = new Framework.Graphics.VertexBufferBinding[0];
protected int currentVertexBufferCount;
protected IndexBuffer currentIndexBuffer;
private InputLayoutManager inputLayoutManager = new InputLayoutManager();
private InputLayout currentInputLayout = null;
#endregion
#region Public
@ -86,7 +92,80 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
#region GetBackBufferData (TODO)
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
{
if (primitiveCount <= 0) throw new ArgumentOutOfRangeException("primitiveCount is less than or equal to zero. When drawing, at least one primitive must be drawn.");
if (this.currentVertexBufferCount == 0) throw new InvalidOperationException("you have to set a valid vertex buffer before drawing.");
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
SetupDraw(primitiveType);
nativeDevice.DrawIndexed(vertexCount, startIndex, baseVertex);
}
public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
{
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
SetupDraw(primitiveType);
nativeDevice.Draw(vertexCount, vertexOffset);
}
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount)
{
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
SetupDraw(primitiveType);
nativeDevice.DrawIndexedInstanced(vertexCount, instanceCount, startIndex, baseVertex, 0);
}
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
IndexElementSize indexFormat) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
int indexCount = indexData.Length;
using (var vertexBuffer = new DynamicVertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly))
using (var indexBuffer = new DynamicIndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly))
{
vertexBuffer.SetData(vertexData);
this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) });
if (indexData.GetType() == typeof(Int16[]))
{
indexBuffer.SetData<short>((short[])indexData);
}
else
{
indexBuffer.SetData<int>((int[])indexData);
}
this.IndexBuffer = indexBuffer;
DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount);
}
}
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
//TODO: use a shared vertexBuffer, instead of creating one on every call.
using (var vertexBuffer = new DynamicVertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly))
{
vertexBuffer.SetData(vertexData);
this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) });
SetupDraw(primitiveType);
nativeDevice.Draw(vertexCount, vertexOffset);
}
}
#region GetBackBufferData
public void GetBackBufferData<T>(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
{
this.backBuffer.GetData(0, rect, data, startIndex, elementCount);
@ -103,6 +182,35 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
public IndexBuffer IndexBuffer
{
get
{
return this.currentIndexBuffer;
}
set
{
if (value == null)
throw new ArgumentNullException("indexBuffer");
if (this.currentIndexBuffer != value)
{
this.currentIndexBuffer = value;
DxIndexBuffer nativeIndexBuffer = value.NativeIndexBuffer as DxIndexBuffer;
if (nativeIndexBuffer != null)
{
nativeDevice.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, DxFormatConverter.Translate(value.IndexElementSize), 0);
}
else
{
throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
}
}
}
}
#if XNAEXT
#region SetConstantBuffer (TODO)
public void SetConstantBuffer(int slot, ConstantBuffer constantBuffer)
@ -114,5 +222,29 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
#endif
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool diposeManaged)
{
if (swapChain != null)
{
DisposeBackBuffer();
swapChain.Dispose();
swapChain = null;
}
if (inputLayoutManager != null)
{
inputLayoutManager.Dispose();
inputLayoutManager = null;
}
//TODO: dispose everything else
}
}
}

View File

@ -35,7 +35,7 @@ namespace ANX.RenderSystem.Windows.DX11
public void SetData<S>(int offsetInBytes, S[] data, int startIndex, int elementCount)
where S : struct
{
if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > NativeBuffer.Description.SizeInBytes)
if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > 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"));
var buffer = this.NativeBuffer;

View File

@ -52,11 +52,11 @@ namespace ANX.RenderSystem.Windows.DX11
if (startIndex + elementCount > data.Length)
throw new ArgumentOutOfRangeException("startIndex must be smaller than elementCount + data.Length.");
if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > NativeBuffer.Description.SizeInBytes)
if (offsetInBytes + elementCount * Marshal.SizeOf(typeof(S)) > this.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"));
var buffer = this.NativeBuffer;
if (!this.WriteNeedsStaging)
if (this.WriteNeedsStaging)
{
buffer = CreateStagingBuffer(ResourceMapping.Write);
}
@ -80,7 +80,7 @@ namespace ANX.RenderSystem.Windows.DX11
}
finally
{
if (!this.WriteNeedsStaging)
if (this.WriteNeedsStaging)
{
CopySubresource(buffer, this.NativeBuffer);
buffer.Dispose();

View File

@ -60,6 +60,9 @@
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\BufferHelper.cs">
<Link>BufferHelper.cs</Link>
</Compile>
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\InputLayoutManager.cs">
<Link>InputLayoutManager.cs</Link>
</Compile>
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
<Link>ResourceMapping.cs</Link>
</Compile>
@ -67,6 +70,7 @@
<Compile Include="Buffer.cs" />
<Compile Include="Creator.cs" />
<Compile Include="DepthStencilState_DX10.cs" />
<Compile Include="DxEffectAnnotation.cs" />
<Compile Include="EffectParameter_DX10.cs" />
<Compile Include="EffectTechnique_DX10.cs" />
<Compile Include="Extensions.cs" />

View File

@ -10,11 +10,32 @@ namespace ANX.RenderSystem.Windows.DX10
{
public abstract class Buffer : IDisposable
{
public Dx.Buffer NativeBuffer { get; protected set; }
public Dx.Buffer NativeBuffer
{
get { return nativeBuffer; }
protected set
{
if (value != null)
SizeInBytes = value.Description.SizeInBytes;
else
SizeInBytes = 0;
nativeBuffer = value;
}
}
private Dx.Buffer nativeBuffer;
private Dx.Device device;
private BufferUsage usage;
private bool isDynamic;
public int SizeInBytes
{
get;
private set;
}
protected Buffer(Dx.Device device, BufferUsage usage, bool isDynamic)
{
this.device = device;
@ -26,6 +47,9 @@ namespace ANX.RenderSystem.Windows.DX10
{
CheckUsage(mapping);
if (isDynamic && mapping == ResourceMapping.Write)
return buffer.Map(Dx.MapMode.WriteDiscard);
return buffer.Map(mapping.ToMapMode());
}
@ -59,7 +83,7 @@ namespace ANX.RenderSystem.Windows.DX10
var description = new Dx.BufferDescription()
{
Usage = Dx.ResourceUsage.Staging,
SizeInBytes = NativeBuffer.Description.SizeInBytes,
SizeInBytes = this.SizeInBytes,
CpuAccessFlags = mapping.ToCpuAccessFlags(),
OptionFlags = Dx.ResourceOptionFlags.None
};

View File

@ -0,0 +1,153 @@
using ANX.Framework.NonXNA.RenderSystem;
using SharpDX.Direct3D10;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ANX.RenderSystem.Windows.DX10
{
public class DxEffectAnnotation : INativeEffectAnnotation
{
private readonly EffectVariable nativeEffectVariable;
public DxEffectAnnotation(SharpDX.Direct3D10.EffectVariable nativeEffectVariable)
{
this.nativeEffectVariable = nativeEffectVariable;
var description = nativeEffectVariable.Description;
var typeDescription = nativeEffectVariable.TypeInfo.Description;
this.Name = description.Name;
this.ColumnCount = typeDescription.Columns;
this.ParameterClass = typeDescription.Class.ToParameterClass();
this.ParameterType = typeDescription.Type.ToParameterType();
this.RowCount = typeDescription.Rows;
this.Semantic = description.Semantic;
this.Matrix = nativeEffectVariable.AsMatrix();
this.Scalar = nativeEffectVariable.AsScalar();
this.String = nativeEffectVariable.AsString();
this.Vector = nativeEffectVariable.AsVector();
}
public int ColumnCount
{
get;
private set;
}
public string Name
{
get;
private set;
}
public Framework.Graphics.EffectParameterClass ParameterClass
{
get;
private set;
}
public Framework.Graphics.EffectParameterType ParameterType
{
get;
private set;
}
public int RowCount
{
get;
private set;
}
public string Semantic
{
get;
private set;
}
protected EffectScalarVariable Scalar
{
get;
private set;
}
protected EffectMatrixVariable Matrix
{
get;
private set;
}
protected EffectStringVariable String
{
get;
private set;
}
protected EffectVectorVariable Vector
{
get;
private set;
}
public bool GetValueBoolean()
{
return this.Scalar.GetBool();
}
public int GetValueInt32()
{
return this.Scalar.GetInt();
}
public Framework.Matrix GetValueMatrix()
{
return this.Matrix.GetMatrix<Framework.Matrix>();
}
public float GetValueSingle()
{
return this.Scalar.GetFloat();
}
public string GetValueString()
{
return this.String.GetString();
}
public Framework.Vector2 GetValueVector2()
{
return this.Vector.GetVector<Framework.Vector2>();
}
public Framework.Vector3 GetValueVector3()
{
return this.Vector.GetVector<Framework.Vector3>();
}
public Framework.Vector4 GetValueVector4()
{
return this.Vector.GetVector<Framework.Vector4>();
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
this.Matrix.Dispose();
this.Scalar.Dispose();
this.String.Dispose();
this.Vector.Dispose();
this.nativeEffectVariable.Dispose();
}
}
}
}

View File

@ -26,32 +26,17 @@ namespace ANX.RenderSystem.Windows.DX10
#region Public
internal Dx10.Effect NativeEffect { get; private set; }
public IEnumerable<EffectTechnique> Techniques
{
get
{
for (int i = 0; i < NativeEffect.Description.TechniqueCount; i++)
{
var teqDx10 = new EffectTechnique_DX10(managedEffect, NativeEffect.GetTechniqueByIndex(i));
yield return new EffectTechnique(this.managedEffect, teqDx10);
}
}
}
public IEnumerable<EffectTechnique> Techniques
{
get;
private set;
}
public IEnumerable<EffectParameter> Parameters
{
get
{
for (int i = 0; i < NativeEffect.Description.GlobalVariableCount; i++)
{
var parDx10 = new EffectParameter_DX10
{
NativeParameter = NativeEffect.GetVariableByIndex(i)
};
yield return new EffectParameter(parDx10);
}
}
}
public IEnumerable<EffectParameter> Parameters
{
get;
private set;
}
#endregion
#region Constructor
@ -61,6 +46,8 @@ namespace ANX.RenderSystem.Windows.DX10
var device = ((GraphicsDeviceDX)graphicsDevice.NativeDevice).NativeDevice;
vertexShader = new Dx10.VertexShader(device, GetByteCode(vertexShaderStream));
pixelShader = new Dx10.PixelShader(device, GetByteCode(pixelShaderStream));
this.BufferNativeData();
}
public EffectDX(GraphicsDevice graphicsDevice, Effect managedEffect, Stream effectStream)
@ -76,9 +63,30 @@ namespace ANX.RenderSystem.Windows.DX10
{
System.Diagnostics.Debugger.Break();
}
this.BufferNativeData();
}
#endregion
private void BufferNativeData()
{
var description = NativeEffect.Description;
var techniques = new EffectTechnique[description.TechniqueCount];
for (int i = 0; i < techniques.Length; i++)
{
techniques[i] = new EffectTechnique(this.managedEffect, new EffectTechnique_DX10(managedEffect, NativeEffect.GetTechniqueByIndex(i)));
}
this.Techniques = techniques;
var parameters = new EffectParameter[description.GlobalVariableCount];
for (int i = 0; i < parameters.Length; i++)
{
parameters[i] = new EffectParameter(new EffectParameter_DX10(NativeEffect.GetVariableByIndex(i)));
}
this.Parameters = parameters;
}
#region GetCurrentTechnique
public EffectTechnique_DX10 GetCurrentTechnique()
{
@ -86,13 +94,6 @@ namespace ANX.RenderSystem.Windows.DX10
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
((GraphicsDeviceDX)graphicsDevice.NativeDevice).currentEffect = this;
}
#endregion
#region CompileFXShader
public static byte[] CompileFXShader(string effectCode, string directory = "")
{
@ -103,16 +104,31 @@ namespace ANX.RenderSystem.Windows.DX10
#region Dispose
public void Dispose()
{
SafeDispose(pixelShader);
pixelShader = null;
SafeDispose(vertexShader);
vertexShader = null;
SafeDispose(NativeEffect);
NativeEffect = null;
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
SafeDispose(pixelShader);
pixelShader = null;
SafeDispose(vertexShader);
vertexShader = null;
SafeDispose(NativeEffect);
NativeEffect = null;
foreach (var technique in this.Techniques)
technique.NativeTechnique.Dispose();
foreach (var parameter in this.Parameters)
parameter.NativeParameter.Dispose();
}
}
private void SafeDispose(IDisposable disposable)
{
if (disposable != null)

View File

@ -4,6 +4,7 @@ using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
using Dx10 = SharpDX.Direct3D10;
using ANX.Framework.NonXNA.Development;
using SharpDX.Direct3D10;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -11,269 +12,214 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.RenderSystem.Windows.DX10
{
[PercentageComplete(50)]
[PercentageComplete(80)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public class EffectParameter_DX10 : INativeEffectParameter
[Developer("Glatzemann, KorsarNek")]
public class EffectParameter_DX10 : DxEffectAnnotation, INativeEffectParameter
{
#region Public
public Dx10.EffectVariable NativeParameter { get; internal set; }
public Dx10.EffectVariable NativeParameter { get; private set; }
public string Name
public EffectParameter_DX10(Dx10.EffectVariable nativeParameter)
: base(nativeParameter)
{
get { return NativeParameter.Description.Name; }
}
this.NativeParameter = nativeParameter;
public string Semantic
{
get { return NativeParameter.Description.Semantic; }
}
var description = nativeParameter.Description;
var typeDescription = nativeParameter.TypeInfo.Description;
public int ColumnCount
{
get { return NativeParameter.TypeInfo.Description.Columns; }
}
var annotations = new EffectAnnotation[description.AnnotationCount];
for (int i = 0; i < annotations.Length; i++)
annotations[i] = new EffectAnnotation(new DxEffectAnnotation(nativeParameter.GetAnnotationByIndex(i)));
this.Annotations = new EffectAnnotationCollection(annotations);
public int RowCount
{
get { return NativeParameter.TypeInfo.Description.Rows; }
}
var elements = new EffectParameter[typeDescription.Elements];
for (int i = 0; i < elements.Length; i++)
elements[i] = new EffectParameter(new EffectParameter_DX10(nativeParameter.GetElement(i)));
this.Elements = new EffectParameterCollection(elements);
public EffectParameterClass ParameterClass
{
get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Class); }
}
var members = new EffectParameter[typeDescription.Members];
for (int i = 0; i < members.Length; i++)
members[i] = new EffectParameter(new EffectParameter_DX10(nativeParameter.GetMemberByIndex(i)));
this.StructureMembers = new EffectParameterCollection(members);
public EffectParameterType ParameterType
{
get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Type); }
this.ShaderResource = nativeParameter.AsShaderResource();
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
get;
private set;
}
public EffectParameterCollection Elements
{
get { throw new NotImplementedException(); }
get;
private set;
}
public EffectParameterCollection StructureMembers
{
get { throw new NotImplementedException(); }
get;
private set;
}
#endregion
#region SetValue (bool)
protected EffectShaderResourceVariable ShaderResource
{
get;
private set;
}
#region SetValue (TODO)
public void SetValue(bool value)
{
NativeParameter.AsScalar().Set(value);
Scalar.Set(value);
}
#endregion
#region SetValue (bool[])
public void SetValue(bool[] value)
{
NativeParameter.AsScalar().Set(value);
Scalar.Set(value);
}
#endregion
#region SetValue (int)
public void SetValue(int value)
{
NativeParameter.AsScalar().Set(value);
Scalar.Set(value);
}
#endregion
#region SetValue (int[])
public void SetValue(int[] value)
{
NativeParameter.AsScalar().Set(value);
Scalar.Set(value);
}
#endregion
#region SetValue (Matrix, transpose) (TODO)
public void SetValue(Matrix value, bool transpose)
{
Matrix val = value;
if (transpose)
{
Matrix.Transpose(ref val, out val);
}
NativeParameter.AsMatrix().SetMatrix(val);
Matrix.SetMatrixTranspose(value);
else
Matrix.SetMatrix(value);
}
#endregion
#region SetValue (Matrix[], transpose) (TODO)
public void SetValue(Matrix[] value, bool transpose)
{
// TODO: handle transpose!
NativeParameter.AsMatrix().SetMatrix(value);
if (transpose)
Matrix.SetMatrixTranspose(value);
else
Matrix.SetMatrix(value);
}
#endregion
#region SetValue (Quaternion)
public void SetValue(Quaternion value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Quaternion[])
public void SetValue(Quaternion[] value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (float)
public void SetValue(float value)
{
NativeParameter.AsScalar().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (float[])
public void SetValue(float[] value)
{
NativeParameter.AsScalar().Set(value);
Scalar.Set(value);
}
#endregion
#region SetValue (Vector2)
public void SetValue(Vector2 value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Vector2[])
public void SetValue(Vector2[] value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Vector3)
public void SetValue(Vector3 value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Vector3[])
public void SetValue(Vector3[] value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Vector4)
public void SetValue(Vector4 value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Vector4[])
public void SetValue(Vector4[] value)
{
NativeParameter.AsVector().Set(value);
Vector.Set(value);
}
#endregion
#region SetValue (Texture)
public void SetValue(Texture value)
{
if (value == null)
throw new ArgumentNullException("value");
var tex = value.NativeTexture as DxTexture2D;
NativeParameter.AsShaderResource().SetResource(tex.NativeShaderResourceView);
ShaderResource.SetResource(((DxTexture2D)value.NativeTexture).NativeShaderResourceView);
}
#endregion
#region SetValue (string) (TODO)
public void SetValue(string value)
{
throw new NotImplementedException();
throw new NotImplementedException();
}
#endregion
#region Get (TODO)
public bool GetValueBoolean()
{
throw new NotImplementedException();
}
public bool[] GetValueBooleanArray(int count)
{
throw new NotImplementedException();
}
public int GetValueInt32()
{
throw new NotImplementedException();
return Scalar.GetBoolArray(0, count);
}
public int[] GetValueInt32Array(int count)
{
throw new NotImplementedException();
}
public Matrix GetValueMatrix()
{
throw new NotImplementedException();
return Scalar.GetIntArray(count);
}
public Matrix[] GetValueMatrixArray(int count)
{
throw new NotImplementedException();
return Matrix.GetMatrixArray<Matrix>(count);
}
public Matrix GetValueMatrixTranspose()
{
throw new NotImplementedException();
}
public Matrix GetValueMatrixTranspose()
{
return Matrix.GetMatrixTranspose<Matrix>();
}
public Matrix[] GetValueMatrixTransposeArray(int count)
{
throw new NotImplementedException();
return Matrix.GetMatrixTransposeArray<Matrix>(count);
}
public Quaternion GetValueQuaternion()
{
throw new NotImplementedException();
return Vector.GetVector<Quaternion>();
}
public Quaternion[] GetValueQuaternionArray(int count)
{
throw new NotImplementedException();
}
public float GetValueSingle()
{
throw new NotImplementedException();
return Vector.GetVectorArray<Quaternion>(count);
}
public float[] GetValueSingleArray(int count)
{
throw new NotImplementedException();
return Scalar.GetFloatArray(count);
}
public string GetValueString()
public ANX.Framework.Graphics.Texture2D GetValueTexture2D()
{
throw new NotImplementedException();
}
public Texture2D GetValueTexture2D()
{
throw new NotImplementedException();
}
public Texture3D GetValueTexture3D()
public ANX.Framework.Graphics.Texture3D GetValueTexture3D()
{
throw new NotImplementedException();
}
@ -283,35 +229,39 @@ namespace ANX.RenderSystem.Windows.DX10
throw new NotImplementedException();
}
public Vector2 GetValueVector2()
{
throw new NotImplementedException();
}
public Vector2[] GetValueVector2Array(int count)
{
throw new NotImplementedException();
}
public Vector3 GetValueVector3()
{
throw new NotImplementedException();
return Vector.GetVectorArray<Vector2>(count);
}
public Vector3[] GetValueVector3Array(int count)
{
throw new NotImplementedException();
}
public Vector4 GetValueVector4()
{
throw new NotImplementedException();
return Vector.GetVectorArray<Vector3>(count);
}
public Vector4[] GetValueVector4Array(int count)
{
throw new NotImplementedException();
return Vector.GetVectorArray<Vector4>(count);
}
#endregion
}
protected override void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
ShaderResource.Dispose();
foreach (var annotation in this.Annotations)
annotation.NativeAnnotation.Dispose();
foreach (var element in this.Elements)
element.NativeParameter.Dispose();
foreach (var member in this.StructureMembers)
member.NativeParameter.Dispose();
}
base.Dispose(disposeManaged);
}
}
}

View File

@ -1,5 +1,6 @@
using ANX.Framework.NonXNA;
using SharpDX.Direct3D10;
using System;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -9,19 +10,72 @@ namespace ANX.RenderSystem.Windows.DX10
{
public class EffectPass_DX10 : INativeEffectPass
{
private EffectPass nativePass;
private Framework.Graphics.Effect parentEffect;
public string Name
{
get
{
return nativePass.Description.Name;
}
get;
private set;
}
internal EffectPass_DX10(EffectPass setNativePass)
private EffectPass NativeEffectPass
{
get;
set;
}
public SharpDX.D3DCompiler.ShaderBytecode Signature
{
get;
private set;
}
internal EffectPass_DX10(Framework.Graphics.Effect parentEffect, EffectPass nativePass)
{
nativePass = setNativePass;
this.NativeEffectPass = nativePass;
this.parentEffect = parentEffect;
var description = nativePass.Description;
this.Name = description.Name;
this.Signature = description.Signature;
var annotations = new Framework.Graphics.EffectAnnotation[description.AnnotationCount];
for (int i = 0; i < annotations.Length; i++)
annotations[i] = new Framework.Graphics.EffectAnnotation(new DxEffectAnnotation(nativePass.GetAnnotationByIndex(i)));
this.Annotations = new Framework.Graphics.EffectAnnotationCollection(annotations);
}
public Framework.Graphics.EffectAnnotationCollection Annotations
{
get;
private set;
}
public void Apply()
{
//TODO: Don't set every state every time, use NativeEffectPass.ComputeStateBlockMask to prevent unnecessary state changes.
NativeEffectPass.Apply();
((GraphicsDeviceDX)this.parentEffect.GraphicsDevice.NativeDevice).currentPass = this;
parentEffect.OnApply();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
this.NativeEffectPass.Dispose();
foreach (var annotation in this.Annotations)
annotation.NativeAnnotation.Dispose();
}
}
}
}

View File

@ -17,6 +17,7 @@ namespace ANX.RenderSystem.Windows.DX10
public class EffectTechnique_DX10 : INativeEffectTechnique
{
private readonly Effect parentEffect;
private readonly EffectPass[] effectPasses;
public EffectTechnique_DX10(Effect parentEffect, Dx10.EffectTechnique nativeTechnique)
{
@ -27,34 +28,71 @@ namespace ANX.RenderSystem.Windows.DX10
this.parentEffect = parentEffect;
NativeTechnique = nativeTechnique;
var description = NativeTechnique.Description;
this.Name = description.Name;
var passCounts = description.PassCount;
this.effectPasses = new EffectPass[passCounts];
for (int i = 0; i < passCounts; i++)
{
this.effectPasses[i] = new EffectPass(new EffectPass_DX10(this.parentEffect, NativeTechnique.GetPassByIndex(i)));
}
var annotationCount = description.AnnotationCount;
var annotations = new EffectAnnotation[annotationCount];
for (int i = 0; i < annotationCount; i++)
annotations[i] = new EffectAnnotation(new DxEffectAnnotation(nativeTechnique.GetAnnotationByIndex(i)));
this.Annotations = new EffectAnnotationCollection(annotations);
}
public Dx10.EffectTechnique NativeTechnique { get; protected set; }
public Dx10.EffectTechnique NativeTechnique { get; private set; }
public string Name
{
get
{
return NativeTechnique.Description.Name;
}
}
{
get;
private set;
}
public IEnumerable<EffectPass> Passes
{
get
{
for (int i = 0; i < NativeTechnique.Description.PassCount; i++)
{
var passDx10 = new EffectPass_DX10(NativeTechnique.GetPassByIndex(i));
// TODO: wire up native pass and managed pass?
yield return new EffectPass(this.parentEffect);
}
return this.effectPasses;
}
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
get;
private set;
}
}
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
if (NativeTechnique != null)
{
NativeTechnique.Dispose();
NativeTechnique = null;
}
foreach (var pass in this.effectPasses)
pass.NativeEffectPass.Dispose();
foreach (var annotation in this.Annotations)
annotation.NativeAnnotation.Dispose();
}
}
}
}

View File

@ -1,4 +1,5 @@
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D10;
using System;
using System.Collections.Generic;
@ -38,5 +39,15 @@ namespace ANX.RenderSystem.Windows.DX10
Top = rect.Top,
};
}
public static ANX.Framework.Graphics.EffectParameterClass ToParameterClass(this ShaderVariableClass variableClass)
{
return DxFormatConverter.Translate(variableClass);
}
public static ANX.Framework.Graphics.EffectParameterType ToParameterType(this ShaderVariableType variableType)
{
return DxFormatConverter.Translate(variableType);
}
}
}

View File

@ -1,5 +1,6 @@
#region Using Statements
using System;
using System.Linq;
using System.Collections.Generic;
using ANX.Framework;
using ANX.Framework.Graphics;
@ -32,7 +33,7 @@ namespace ANX.RenderSystem.Windows.DX10
private Dx10.RenderTargetView[] renderTargetView = new RenderTargetView[MAX_RENDER_TARGETS];
private Dx10.DepthStencilView[] depthStencilView = new DepthStencilView[MAX_RENDER_TARGETS];
private RenderTarget2D_DX10 backBuffer;
internal EffectDX currentEffect;
internal EffectPass_DX10 currentPass;
#endregion
#region CreateDevice
@ -123,187 +124,34 @@ namespace ANX.RenderSystem.Windows.DX10
{
swapChain.Present(VSync ? 1 : 0, PresentFlags.None);
}
#endregion
#region DrawIndexedPrimitives
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, IndexBuffer indexBuffer)
{
if (primitiveCount <= 0) throw new ArgumentOutOfRangeException("primitiveCount is less than or equal to zero. When drawing, at least one primitive must be drawn.");
if (this.currentVertexBuffer == null || this.currentVertexBufferCount <= 0) throw new InvalidOperationException("you have to set a valid vertex buffer before drawing.");
Dx10.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
if (indexBuffer != null)
{
SetIndexBuffer(indexBuffer);
}
for (int i = 0; i < technique.Description.PassCount; ++i)
{
technique.GetPassByIndex(i).Apply();
nativeDevice.DrawIndexed(vertexCount, startIndex, baseVertex);
}
nativeDevice.InputAssembler.InputLayout.Dispose();
nativeDevice.InputAssembler.InputLayout = null;
}
#endregion
#region DrawPrimitives
public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
{
Dx10.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
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;
public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, WindowHandle overrideWindowHandle)
{
throw new NotImplementedException();
}
#endregion
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices,
int startIndex, int primitiveCount, int instanceCount, IndexBuffer indexBuffer)
private void SetupDraw(PrimitiveType primitiveType)
{
Dx10.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
var inputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice, currentPass.Signature, this.currentVertexBuffer);
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
if (indexBuffer != null)
if (currentInputLayout != inputLayout)
{
SetIndexBuffer(indexBuffer);
}
for (int i = 0; i < technique.Description.PassCount; ++i)
{
technique.GetPassByIndex(i).Apply();
nativeDevice.DrawIndexedInstanced(vertexCount, instanceCount, startIndex, baseVertex, 0);
}
nativeDevice.InputAssembler.InputLayout.Dispose();
nativeDevice.InputAssembler.InputLayout = null;
}
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
IndexElementSize indexFormat) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
int indexCount = indexData.Length;
using (var vertexBuffer = new DynamicVertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly))
using (var indexBuffer = new DynamicIndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly))
{
vertexBuffer.SetData(vertexData);
this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) });
if (indexData.GetType() == typeof(Int16[]))
{
indexBuffer.SetData<short>((short[])indexData);
}
else
{
indexBuffer.SetData<int>((int[])indexData);
}
DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer);
nativeDevice.InputAssembler.InputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice, currentPass.Signature, this.currentVertexBuffer);
currentInputLayout = inputLayout;
}
}
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
//TODO: use a shared vertexBuffer, instead of creating one on every call.
using (DxVertexBuffer vb10 = new DxVertexBuffer(nativeDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly, dynamic: true))
{
vb10.SetData<T>(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)
{
technique.GetPassByIndex(i).Apply();
nativeDevice.Draw(vertexCount, vertexOffset);
}
nativeDevice.InputAssembler.InputLayout.Dispose();
nativeDevice.InputAssembler.InputLayout = null;
}
}
private Dx10.EffectTechnique SetupEffectForDraw()
{
//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);
SetupInputLayout(pass.Description.Signature);
return technique;
}
#region SetupInputLayout
private InputLayout SetupInputLayout(ShaderBytecode passSignature)
{
// get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler
var layout = CreateInputLayout(nativeDevice, passSignature, currentVertexBuffer);
nativeDevice.InputAssembler.InputLayout = layout;
return layout;
}
#endregion
#region SetIndexBuffer
public void SetIndexBuffer(IndexBuffer indexBuffer)
{
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
this.currentIndexBuffer = indexBuffer;
DxIndexBuffer nativeIndexBuffer = indexBuffer.NativeIndexBuffer as DxIndexBuffer;
if (nativeIndexBuffer != null)
{
nativeDevice.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, DxFormatConverter.Translate(indexBuffer.IndexElementSize), 0);
}
else
{
throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
}
}
#endregion
#region SetVertexBuffers
public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
{
if (vertexBuffers == null)
throw new ArgumentNullException("vertexBuffers");
if (this.currentVertexBuffer.SequenceEqual(vertexBuffers))
return;
this.currentVertexBufferCount = vertexBuffers.Length;
if (this.currentVertexBuffer == null || this.currentVertexBuffer.Length < currentVertexBufferCount)
@ -347,67 +195,6 @@ namespace ANX.RenderSystem.Windows.DX10
{
nativeDevice.Rasterizer.SetViewports(viewports);
}
#endregion
#region CreateInputLayout
/// <summary>
/// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives.
/// The VertexDeclaration of ANX/XNA needs to be mapped to the DirectX 10 types.
/// </summary>
private Dx10.InputLayout CreateInputLayout(Dx10.Device device, ShaderBytecode passSignature, params VertexDeclaration[] vertexDeclaration)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexDeclaration == null) throw new ArgumentNullException("vertexDeclaration");
//TODO: try to get rid of the list
List<InputElement> inputElements = new List<InputElement>();
foreach (VertexDeclaration decl in vertexDeclaration)
{
foreach (VertexElement vertexElement in decl.GetVertexElements())
{
inputElements.Add(CreateInputElementFromVertexElement(vertexElement, 0));
}
}
return new Dx10.InputLayout(device, passSignature, inputElements.ToArray());
}
private Dx10.InputLayout CreateInputLayout(Dx10.Device device, ShaderBytecode passSignature, params ANX.Framework.Graphics.VertexBufferBinding[] vertexBufferBindings)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexBufferBindings == null) throw new ArgumentNullException("vertexBufferBindings");
//TODO: try to get rid of the list
List<InputElement> inputElements = new List<InputElement>();
int slot = 0;
foreach (ANX.Framework.Graphics.VertexBufferBinding binding in vertexBufferBindings)
{
foreach (VertexElement vertexElement in binding.VertexBuffer.VertexDeclaration.GetVertexElements())
{
inputElements.Add(CreateInputElementFromVertexElement(vertexElement, binding.InstanceFrequency, slot));
}
slot++;
}
// Layout from VertexShader input signature
return new InputLayout(device, passSignature, inputElements.ToArray());
}
#endregion
#region CreateInputElementFromVertexElement
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement, int slot)
{
return CreateInputElementFromVertexElement(vertexElement, 0, slot);
}
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement, int instanceFrequency, int slot)
{
string elementName = DxFormatConverter.Translate(ref vertexElement);
Format elementFormat = DxFormatConverter.ConvertVertexElementFormat(vertexElement.VertexElementFormat);
return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, slot, instanceFrequency == 0 ? InputClassification.PerVertexData : InputClassification.PerInstanceData, instanceFrequency);
}
#endregion
#region SetRenderTargets
@ -484,21 +271,6 @@ namespace ANX.RenderSystem.Windows.DX10
}
}
#region Dispose
public void Dispose()
{
if (swapChain != null)
{
DisposeBackBuffer();
swapChain.Dispose();
swapChain = null;
}
//TODO: dispose everything else
}
#endregion
internal Dx10.Device NativeDevice
{
get

View File

@ -73,6 +73,9 @@
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\BufferHelper.cs">
<Link>BufferHelper.cs</Link>
</Compile>
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\InputLayoutManager.cs">
<Link>InputLayoutManager.cs</Link>
</Compile>
<Compile Include="..\ANX.RenderSystem.DX.SharedSources\ResourceMapping.cs">
<Link>ResourceMapping.cs</Link>
</Compile>

View File

@ -10,11 +10,32 @@ namespace ANX.RenderSystem.Windows.DX11
{
public abstract class Buffer : IDisposable
{
public Dx.Buffer NativeBuffer { get; protected set; }
public Dx.Buffer NativeBuffer
{
get { return nativeBuffer; }
protected set
{
if (value != null)
SizeInBytes = value.Description.SizeInBytes;
else
SizeInBytes = 0;
nativeBuffer = value;
}
}
private Dx.Buffer nativeBuffer;
private Dx.Device device;
private BufferUsage usage;
private bool isDynamic;
public int SizeInBytes
{
get;
private set;
}
protected Buffer(Dx.Device device, BufferUsage usage, bool isDynamic)
{
this.device = device;
@ -26,8 +47,14 @@ namespace ANX.RenderSystem.Windows.DX11
{
CheckUsage(mapping);
Dx.MapMode mapMode;
if (isDynamic && mapping == ResourceMapping.Write)
mapMode = Dx.MapMode.WriteDiscard;
else
mapMode = mapping.ToMapMode();
DataStream dataStream;
device.ImmediateContext.MapSubresource(buffer, mapping.ToMapMode(), Dx.MapFlags.None, out dataStream);
device.ImmediateContext.MapSubresource(buffer, mapMode, Dx.MapFlags.None, out dataStream);
return dataStream;
}

View File

@ -86,13 +86,6 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
#region Apply
public void Apply(GraphicsDevice graphicsDevice)
{
((GraphicsDeviceDX)graphicsDevice.NativeDevice).currentEffect = this;
}
#endregion
#region CompileFXShader
public static byte[] CompileFXShader(string effectCode, string directory = "")
{

View File

@ -308,5 +308,23 @@ namespace ANX.RenderSystem.Windows.DX11
throw new NotImplementedException();
}
#endregion
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
if (NativeParameter != null)
{
NativeParameter.Dispose();
NativeParameter = null;
}
}
}
}
}

View File

@ -1,5 +1,6 @@
using ANX.Framework.NonXNA;
using SharpDX.Direct3D11;
using System;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -10,6 +11,7 @@ namespace ANX.RenderSystem.Windows.DX11
public class EffectPass_DX11 : INativeEffectPass
{
private EffectPass nativePass;
private Framework.Graphics.Effect parentEffect;
public string Name
{
@ -19,9 +21,50 @@ namespace ANX.RenderSystem.Windows.DX11
}
}
internal EffectPass_DX11(EffectPass setNativePass)
public SharpDX.D3DCompiler.ShaderBytecode Signature
{
get;
private set;
}
internal EffectPass_DX11(Framework.Graphics.Effect parentEffect, EffectPass setNativePass)
{
nativePass = setNativePass;
this.parentEffect = parentEffect;
this.Signature = nativePass.Description.Signature;
}
public Framework.Graphics.EffectAnnotationCollection Annotations
{
get { throw new System.NotImplementedException(); }
}
public void Apply()
{
var deviceContext = ((GraphicsDeviceDX)parentEffect.GraphicsDevice.NativeDevice).NativeDevice;
nativePass.Apply(deviceContext);
((GraphicsDeviceDX)this.parentEffect.GraphicsDevice.NativeDevice).currentPass = this;
parentEffect.OnApply();
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
if (nativePass != null)
{
nativePass.Dispose();
nativePass = null;
}
}
}
}
}

View File

@ -45,9 +45,7 @@ namespace ANX.RenderSystem.Windows.DX11
{
for (int i = 0; i < NativeTechnique.Description.PassCount; i++)
{
var passDx11 = new EffectPass_DX11(NativeTechnique.GetPassByIndex(i));
// TODO: wire up native pass and managed pass?
yield return new EffectPass(this.parentEffect);
yield return new EffectPass(new EffectPass_DX11(this.parentEffect, NativeTechnique.GetPassByIndex(i)));
}
}
}
@ -56,5 +54,23 @@ namespace ANX.RenderSystem.Windows.DX11
{
get { throw new NotImplementedException(); }
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
protected virtual void Dispose(bool disposeManaged)
{
if (disposeManaged)
{
if (NativeTechnique != null)
{
NativeTechnique.Dispose();
NativeTechnique = null;
}
}
}
}
}

View File

@ -1,4 +1,5 @@
using SharpDX;
using SharpDX.D3DCompiler;
using SharpDX.Direct3D11;
using System;
using System.Collections.Generic;
@ -30,5 +31,15 @@ namespace ANX.RenderSystem.Windows.DX11
{
return new ResourceRegion(rect.Left, rect.Top, 0, rect.Right, rect.Bottom, 1);
}
public static ANX.Framework.Graphics.EffectParameterClass ToParameterClass(this ShaderVariableClass variableClass)
{
return DxFormatConverter.Translate(variableClass);
}
public static ANX.Framework.Graphics.EffectParameterType ToParameterType(this ShaderVariableType variableType)
{
return DxFormatConverter.Translate(variableType);
}
}
}

View File

@ -27,14 +27,12 @@ namespace ANX.RenderSystem.Windows.DX11
static int graphicsDeviceCount = 0;
static int swapChainCount = 0;
#endif
//Restricted to 8 from DirectX side.
const int MAX_RENDER_TARGETS = 8;
private Dx11.DeviceContext nativeDevice;
private Dx11.RenderTargetView[] renderTargetView = new RenderTargetView[MAX_RENDER_TARGETS];
private Dx11.DepthStencilView[] depthStencilView = new DepthStencilView[MAX_RENDER_TARGETS];
private Dx11.RenderTargetView[] renderTargetView = new RenderTargetView[1];
private Dx11.DepthStencilView[] depthStencilView = new DepthStencilView[1];
private RenderTarget2D_DX11 backBuffer;
internal EffectDX currentEffect;
internal EffectPass_DX11 currentPass;
#endregion
#region CreateDevice
@ -50,7 +48,7 @@ namespace ANX.RenderSystem.Windows.DX11
OutputHandle = presentationParameters.DeviceWindowHandle,
SampleDescription = new SampleDescription(1, 0),
SwapEffect = SwapEffect.Discard,
Usage = Usage.RenderTargetOutput
Usage = Usage.RenderTargetOutput | Usage.ShaderInput
};
// Create Device and SwapChain
@ -63,12 +61,12 @@ namespace ANX.RenderSystem.Windows.DX11
#endif
// http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
Device.CreateWithSwapChain(DriverType.Hardware, flags, desc, out dxDevice, out swapChain);
nativeDevice = dxDevice.ImmediateContext;
#if DEBUG
nativeDevice.DebugName = "GraphicsDevice_" + graphicsDeviceCount++;
swapChain.DebugName = "SwapChain_" + swapChainCount++;
#endif
nativeDevice = dxDevice.ImmediateContext;
}
#endregion
@ -88,12 +86,9 @@ namespace ANX.RenderSystem.Windows.DX11
// Clear a RenderTarget (or BackBuffer)
var clearColor = new SharpDX.Color4(color.X, color.Y, color.Z, color.W);
for (int i = 0; i < MAX_RENDER_TARGETS; i++)
foreach (var renderTargetView in this.renderTargetView)
{
if (this.renderTargetView[i] == null)
break;
nativeDevice.ClearRenderTargetView(this.renderTargetView[i], clearColor);
nativeDevice.ClearRenderTargetView(renderTargetView, clearColor);
}
}
@ -111,12 +106,9 @@ namespace ANX.RenderSystem.Windows.DX11
clearFlags = Dx11.DepthStencilClearFlags.Depth;
}
for (int i = 0; i < MAX_RENDER_TARGETS; i++)
foreach (var depthStencilView in this.depthStencilView)
{
if (this.depthStencilView[i] == null)
break;
nativeDevice.ClearDepthStencilView(this.depthStencilView[i], clearFlags, depth, (byte)stencil);
nativeDevice.ClearDepthStencilView(depthStencilView, clearFlags, depth, (byte)stencil);
}
}
@ -127,212 +119,25 @@ namespace ANX.RenderSystem.Windows.DX11
{
swapChain.Present(VSync ? 1 : 0, PresentFlags.None);
}
public void Present(Rectangle? sourceRectangle, Rectangle? destinationRectangle, WindowHandle overrideWindowHandle)
{
throw new NotImplementedException();
}
#endregion
#region DrawIndexedPrimitives
public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, IndexBuffer indexBuffer)
{
if (primitiveCount <= 0) throw new ArgumentOutOfRangeException("primitiveCount is less than or equal to zero. When drawing, at least one primitive must be drawn.");
if (this.currentVertexBuffer == null || this.currentVertexBufferCount <= 0) throw new InvalidOperationException("you have to set a valid vertex buffer before drawing.");
Dx11.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
private void SetupDraw(PrimitiveType primitiveType)
{
var inputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice.Device, currentPass.Signature, this.currentVertexBuffer);
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
//nativeDevice.Rasterizer.SetViewports(currentViewport);
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
if (indexBuffer != null)
if (currentInputLayout != inputLayout)
{
SetIndexBuffer(indexBuffer);
}
for (int i = 0; i < technique.Description.PassCount; ++i)
{
technique.GetPassByIndex(i).Apply(nativeDevice);
nativeDevice.DrawIndexed(vertexCount, startIndex, baseVertex);
}
nativeDevice.InputAssembler.InputLayout.Dispose();
nativeDevice.InputAssembler.InputLayout = null;
}
#endregion
#region DrawPrimitives
public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
{
Dx11.EffectPass pass; Dx11.EffectTechnique technique; ShaderBytecode passSignature;
SetupEffectForDraw(out pass, out technique, out passSignature);
var layout = SetupInputLayout(passSignature);
// Prepare All the stages
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
//nativeDevice.Rasterizer.SetViewports(currentViewport);
//nativeDevice.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
#region DrawInstancedPrimitives
public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount, IndexBuffer indexBuffer)
{
Dx11.EffectTechnique technique = SetupEffectForDraw();
int vertexCount = DxFormatConverter.CalculateVertexCount(primitiveType, primitiveCount);
nativeDevice.InputAssembler.PrimitiveTopology = DxFormatConverter.Translate(primitiveType);
//nativeDevice.Rasterizer.SetViewports(currentViewport);
//nativeDevice.OutputMerger.SetTargets(this.depthStencilView, this.renderView);
if (indexBuffer != null)
{
SetIndexBuffer(indexBuffer);
}
for (int i = 0; i < technique.Description.PassCount; ++i)
{
technique.GetPassByIndex(i).Apply(nativeDevice);
nativeDevice.DrawIndexedInstanced(vertexCount, instanceCount, startIndex, baseVertex, 0);
}
nativeDevice.InputAssembler.InputLayout.Dispose();
nativeDevice.InputAssembler.InputLayout = null;
}
#endregion // DrawInstancedPrimitives
#region DrawUserIndexedPrimitives<T>
public void DrawUserIndexedPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices,
Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
IndexElementSize indexFormat) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
int indexCount = indexData.Length;
using (VertexBuffer vertexBuffer = new VertexBuffer(vertexDeclaration.GraphicsDevice, vertexDeclaration, vertexCount, BufferUsage.WriteOnly))
using (IndexBuffer indexBuffer = new IndexBuffer(vertexDeclaration.GraphicsDevice, indexFormat, indexCount, BufferUsage.WriteOnly))
{
vertexBuffer.SetData(vertexData);
this.SetVertexBuffers(new[] { new Framework.Graphics.VertexBufferBinding(vertexBuffer, vertexOffset) });
if (indexData.GetType() == typeof(Int16[]))
{
indexBuffer.SetData<short>((short[])indexData);
}
else
{
indexBuffer.SetData<int>((int[])indexData);
}
DrawIndexedPrimitives(primitiveType, 0, vertexOffset, numVertices, indexOffset, primitiveCount, indexBuffer);
nativeDevice.InputAssembler.InputLayout = this.inputLayoutManager.GetInputLayout(NativeDevice.Device, currentPass.Signature, this.currentVertexBuffer);
currentInputLayout = inputLayout;
}
}
#endregion // DrawUserIndexedPrimitives<T>
#region DrawUserPrimitives<T>
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
{
int vertexCount = vertexData.Length;
using (DxVertexBuffer vb11 = new DxVertexBuffer(this, vertexDeclaration, vertexCount, BufferUsage.WriteOnly, dynamic: true))
{
vb11.SetData<T>(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)
{
pass.Apply(nativeDevice);
nativeDevice.Draw(primitiveCount, vertexOffset);
}
layout.Dispose();
layout = null;
}
}
#endregion // DrawUserPrimitives<T>
#region SetupEffectForDraw
private void SetupEffectForDraw(out Dx11.EffectPass pass, out Dx11.EffectTechnique technique,
out ShaderBytecode passSignature)
{
// get the current effect
//TODO: check for null and throw exception
EffectDX effect = this.currentEffect;
// get the input semantic of the current effect / technique that is used
//TODO: check for null's and throw exceptions
// TODO: get the correct pass index!
technique = effect.GetCurrentTechnique().NativeTechnique;
pass = technique.GetPassByIndex(0);
passSignature = pass.Description.Signature;
}
private Dx11.EffectTechnique SetupEffectForDraw()
{
//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);
SetupInputLayout(pass.Description.Signature);
return technique;
}
#endregion
#region SetupInputLayout
private InputLayout SetupInputLayout(ShaderBytecode passSignature)
{
// get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler
var layout = CreateInputLayout(nativeDevice.Device, passSignature, currentVertexBuffer);
nativeDevice.InputAssembler.InputLayout = layout;
return layout;
}
#endregion
#region SetIndexBuffer
public void SetIndexBuffer(IndexBuffer indexBuffer)
{
if (indexBuffer == null)
throw new ArgumentNullException("indexBuffer");
this.currentIndexBuffer = indexBuffer;
DxIndexBuffer nativeIndexBuffer = indexBuffer.NativeIndexBuffer as DxIndexBuffer;
if (nativeIndexBuffer != null)
{
nativeDevice.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer,
DxFormatConverter.Translate(indexBuffer.IndexElementSize), 0);
}
else
throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
}
#endregion
#region SetVertexBuffers
public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
{
@ -384,49 +189,6 @@ namespace ANX.RenderSystem.Windows.DX11
}
#endregion
#region CreateInputLayout
private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, params VertexDeclaration[] vertexDeclaration)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexDeclaration == null) throw new ArgumentNullException("vertexDeclaration");
//TODO: try to get rid of the list
List<InputElement> inputElements = new List<InputElement>();
foreach (VertexDeclaration decl in vertexDeclaration)
{
foreach (VertexElement vertexElement in decl.GetVertexElements())
{
inputElements.Add(CreateInputElementFromVertexElement(vertexElement, 0));
}
}
return new InputLayout(device, passSignature, inputElements.ToArray());
}
private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, params ANX.Framework.Graphics.VertexBufferBinding[] vertexBufferBindings)
{
if (device == null) throw new ArgumentNullException("device");
if (passSignature == null) throw new ArgumentNullException("passSignature");
if (vertexBufferBindings == null) throw new ArgumentNullException("vertexBufferBindings");
//TODO: try to get rid of the list
List<InputElement> inputElements = new List<InputElement>();
int slot = 0;
foreach (ANX.Framework.Graphics.VertexBufferBinding binding in vertexBufferBindings)
{
foreach (VertexElement vertexElement in binding.VertexBuffer.VertexDeclaration.GetVertexElements())
{
inputElements.Add(CreateInputElementFromVertexElement(vertexElement, binding.InstanceFrequency, slot));
}
slot++;
}
// Layout from VertexShader input signature
return new InputLayout(device, passSignature, inputElements.ToArray());
}
#endregion
#region CreateInputElementFromVertexElement
private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement, int slot)
{
@ -446,27 +208,21 @@ namespace ANX.RenderSystem.Windows.DX11
{
if (renderTargets == null || renderTargets.Length == 0)
{
this.renderTargetView[0] = this.backBuffer.RenderTargetView;
this.depthStencilView[0] = this.backBuffer.DepthStencilView;
for (int i = 1; i < MAX_RENDER_TARGETS; i++)
{
this.renderTargetView[i] = null;
this.depthStencilView[i] = null;
}
this.renderTargetView = new RenderTargetView[] { this.backBuffer.RenderTargetView };
this.depthStencilView = new DepthStencilView[] { this.backBuffer.DepthStencilView };
nativeDevice.OutputMerger.ResetTargets();
//To correctly unset renderTargets, the amount of given rendertargetViews must be max(#previousRenderTargets, #newRenderTargets),
//otherwise the old ones at the slots stay bound. For us it means, we try to unbind every possible previous slot.
nativeDevice.OutputMerger.SetRenderTargets(this.backBuffer.DepthStencilView, this.renderTargetView);
nativeDevice.OutputMerger.SetRenderTargets(this.backBuffer.DepthStencilView, this.backBuffer.RenderTargetView);
nativeDevice.Rasterizer.SetViewport(new SharpDX.ViewportF(0, 0, this.backBuffer.Width, this.backBuffer.Height));
}
else
{
int renderTargetCount = renderTargets.Length;
if (renderTargetCount > MAX_RENDER_TARGETS)
throw new NotSupportedException(string.Format("{0} render targets are not supported. The maximum is {1}.", renderTargetCount, MAX_RENDER_TARGETS));
var rtViewports = new SharpDX.ViewportF[renderTargetCount];
this.renderTargetView = new RenderTargetView[renderTargetCount];
this.depthStencilView = new DepthStencilView[renderTargetCount];
var firstRenderTarget = renderTargets[0].RenderTarget as RenderTarget2D;
for (int i = 1; i < renderTargetCount; i++)
@ -481,16 +237,12 @@ namespace ANX.RenderSystem.Windows.DX11
RenderTarget2D renderTarget = renderTargets[i].RenderTarget as RenderTarget2D;
var nativeRenderTarget = renderTarget.NativeRenderTarget as RenderTarget2D_DX11;
renderTargetView[i] = nativeRenderTarget.RenderTargetView;
depthStencilView[i] = nativeRenderTarget.DepthStencilView;
this.renderTargetView[i] = nativeRenderTarget.RenderTargetView;
this.depthStencilView[i] = nativeRenderTarget.DepthStencilView;
rtViewports[i] = new SharpDX.ViewportF(0, 0, renderTarget.Width, renderTarget.Height);
}
for (int i = renderTargetCount; i < MAX_RENDER_TARGETS; i++)
{
this.renderTargetView[i] = null;
this.depthStencilView[i] = null;
}
nativeDevice.OutputMerger.ResetTargets();
nativeDevice.OutputMerger.SetRenderTargets(this.depthStencilView[0], renderTargetView);
nativeDevice.Rasterizer.SetViewports(rtViewports);
@ -502,34 +254,13 @@ 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);
nativeDevice.OutputMerger.ResetTargets();
backBuffer.Dispose();
backBuffer = null;
}
}
#region Dispose
public void Dispose()
{
if (swapChain != null)
{
DisposeBackBuffer();
swapChain.Dispose();
swapChain = null;
}
//TODO: dispose everything else
}
#endregion
internal DeviceContext NativeDevice
{
get

View File

@ -104,7 +104,6 @@
<AssemblyReference Name="ANX.InputSystem.Standard">..\..\bin\Debug\ANX.InputSystem.Standard.dll</AssemblyReference>
<AssemblyReference Name="ANX.PlatformSystem.Windows">..\..\bin\Debug\ANX.PlatformSystem.Windows.dll</AssemblyReference>
<AssemblyReference Name="ANX.RenderSystem.Windows.DX10">..\..\bin\Debug\ANX.RenderSystem.Windows.DX10.dll</AssemblyReference>
<AssemblyReference Name="ANX.RenderSystem.Windows.DX11">..\..\bin\Debug\ANX.RenderSystem.Windows.DX11.dll</AssemblyReference>
<AssemblyReference Name="AssimpNet">..\..\bin\Debug\AssimpNet.dll</AssemblyReference>
</References>
<BuildItems>

View File

@ -1,58 +1,199 @@

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}") = "StencilBuffer", "StencilBuffer\StencilBuffer.csproj", "{41E6C2CF-51EA-4D8E-96AE-739CA3951766}"
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|Any CPU = Debug|Any CPU
Debug|Android = Debug|Android
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
DebugWin8|Any CPU = DebugWin8|Any CPU
Debug|XBox 360 = Debug|XBox 360
DebugWin8|Android = DebugWin8|Android
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
Release|Any CPU = Release|Any CPU
DebugWin8|XBox 360 = DebugWin8|XBox 360
Release|Android = Release|Android
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
ReleaseWin8|Any CPU = ReleaseWin8|Any CPU
Release|XBox 360 = Release|XBox 360
ReleaseWin8|Android = ReleaseWin8|Android
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
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Any CPU.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Android.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|iOS.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Linux.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Mac OS.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Mixed Platforms.Build.0 = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|PS Vita.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Windows.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Windows Metro.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|Windows Phone.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|x86.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|x86.Build.0 = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Any CPU.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Debug|XBox 360.ActiveCfg = Debug|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Android.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|iOS.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Linux.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Mac OS.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Mixed Platforms.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Mixed Platforms.Build.0 = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|PS Vita.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Windows.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Windows Metro.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|Windows Phone.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|x86.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|x86.Build.0 = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Any CPU.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.DebugWin8|XBox 360.ActiveCfg = DebugWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Android.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|iOS.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Linux.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Mac OS.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Mixed Platforms.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Mixed Platforms.Build.0 = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|PS Vita.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Windows.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Windows Metro.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Windows Phone.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|x86.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|x86.Build.0 = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Any CPU.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|XBox 360.ActiveCfg = Release|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Android.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|iOS.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Linux.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Mac OS.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Mixed Platforms.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Mixed Platforms.Build.0 = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|PS Vita.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Windows.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Windows Metro.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|Windows Phone.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|x86.ActiveCfg = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.ReleaseWin8|x86.Build.0 = ReleaseWin8|x86
{41E6C2CF-51EA-4D8E-96AE-739CA3951766}.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|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|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|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|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

View File

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<ProjectGuid>{41E6C2CF-51EA-4D8E-96AE-739CA3951766}</ProjectGuid>
<ProjectTypeGuids>{6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<OutputType>WinExe</OutputType>
@ -11,28 +11,10 @@
<AssemblyName>StencilBuffer</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<XnaFrameworkVersion>v4.0</XnaFrameworkVersion>
<XnaPlatform>Windows</XnaPlatform>
<XnaProfile>HiDef</XnaProfile>
<XnaCrossPlatformGroupID>8d206378-4698-42f2-a96f-90f1ce3daa81</XnaCrossPlatformGroupID>
<XnaOutputType>Game</XnaOutputType>
<ApplicationIcon>anx.ico</ApplicationIcon>
<Thumbnail>GameThumbnail.png</Thumbnail>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<DebugSymbols>true</DebugSymbols>
@ -45,7 +27,6 @@
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>false</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>pdbonly</DebugType>
@ -57,7 +38,6 @@
<NoStdLib>true</NoStdLib>
<UseVSHostingProcess>false</UseVSHostingProcess>
<PlatformTarget>x86</PlatformTarget>
<XnaCompressContent>true</XnaCompressContent>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWin8|x86'">
<OutputPath>bin\x86\DebugWin8\</OutputPath>
@ -79,7 +59,13 @@
<CodeAnalysisRuleDirectories>;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Team Tools\Static Analysis Tools\FxCop\\Rules</CodeAnalysisRuleDirectories>
<CodeAnalysisIgnoreBuiltInRules>true</CodeAnalysisIgnoreBuiltInRules>
</PropertyGroup>
<PropertyGroup>
<RunPostBuildEvent>Always</RunPostBuildEvent>
</PropertyGroup>
<ItemGroup>
<Reference Include="ANX.RenderSystem.Windows.DX11">
<HintPath>..\..\bin\Debug\ANX.RenderSystem.Windows.DX11.dll</HintPath>
</Reference>
<Reference Include="mscorlib">
<Private>False</Private>
</Reference>
@ -105,6 +91,14 @@
<Compile Include="Game1.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\..\bin\Debug\sharpdx_direct3d11_effects_x64.dll">
<Link>sharpdx_direct3d11_effects_x64.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\..\bin\Debug\sharpdx_direct3d11_effects_x86.dll">
<Link>sharpdx_direct3d11_effects_x86.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="anx.ico" />
<Content Include="GameThumbnail.png" />
</ItemGroup>
@ -124,50 +118,28 @@
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Xna.Framework.4.0">
<Visible>False</Visible>
<ProductName>Microsoft XNA Framework Redistributable 4.0</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\ANX.Framework\ANX.Framework.csproj">
<Project>{6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}</Project>
<Name>ANX.Framework</Name>
</ProjectReference>
<ProjectReference Include="..\..\InputSystems\ANX.InputDevices.Windows.XInput\ANX.InputDevices.Windows.XInput.csproj">
<Project>{60D08399-244F-46A3-91F1-4CFD26D961A3}</Project>
<Name>ANX.InputDevices.Windows.XInput</Name>
</ProjectReference>
<ProjectReference Include="..\..\InputSystems\ANX.InputSystem.Standard\ANX.InputSystem.Standard.csproj">
<Project>{49066074-3B7B-4A55-B122-6BD33AB73558}</Project>
<Name>ANX.InputSystem.Standard</Name>
</ProjectReference>
<ProjectReference Include="..\..\PlatformSystems\ANX.PlatformSystem.Windows\ANX.PlatformSystem.Windows.csproj">
<Project>{068EB2E9-963C-4E1B-8831-E25011F11FFE}</Project>
<Name>ANX.PlatformSystem.Windows</Name>
</ProjectReference>
<ProjectReference Include="..\..\RenderSystems\ANX.RenderSystem.Windows.DX10\ANX.RenderSystem.Windows.DX10.csproj">
<Project>{5BE49183-2F6F-4527-AC90-D816911FCF90}</Project>
<Name>ANX.RenderSystem.Windows.DX10</Name>
</ProjectReference>
<ProjectReference Include="..\..\SoundSystems\ANX.SoundSystem.Windows.XAudio\ANX.SoundSystem.Windows.XAudio.csproj">
<Project>{6A582788-C4D2-410C-96CD-177F75712D65}</Project>
<Name>ANX.SoundSystem.Windows.XAudio</Name>
</ProjectReference>
<ProjectReference Include="..\SampleContent\SampleContent.contentproj">
<Project>{FA6E229D-4504-47B1-8A23-2D3FCC13F778}</Project>
<Name>SampleContent</Name>
<XnaReferenceType>Content</XnaReferenceType>
</ProjectReference>
<Reference Include="ANX.Framework">
<HintPath>..\..\bin\Debug\ANX.Framework.dll</HintPath>
</Reference>
<Reference Include="ANX.InputDevices.Windows.XInput">
<HintPath>..\..\bin\Debug\ANX.InputDevices.Windows.XInput.dll</HintPath>
</Reference>
<Reference Include="ANX.InputSystem.Standard">
<HintPath>..\..\bin\Debug\ANX.InputSystem.Standard.dll</HintPath>
</Reference>
<Reference Include="ANX.PlatformSystem.Windows">
<HintPath>..\..\bin\Debug\ANX.PlatformSystem.Windows.dll</HintPath>
</Reference>
<Reference Include="ANX.SoundSystem.Windows.XAudio">
<HintPath>..\..\bin\Debug\ANX.SoundSystem.Windows.XAudio.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\Microsoft.Xna.GameStudio.targets" />
<PropertyGroup>
<PostBuildEvent>xcopy $(ProjectDir)..\SampleContent\bin\$(ConfigurationName) $(TargetDir)SampleContent\ /D /E /Y</PostBuildEvent>
</PropertyGroup>
<!--
To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.