Finished the ANX.Framework side of EffectAnnotation, EffectParameter and EffectTechnique

This commit is contained in:
SND\AstrorEnales_cp 2012-10-13 13:12:07 +00:00 committed by Konstantin Koch
parent f08d6ea189
commit 0b9acc40ee
25 changed files with 252 additions and 190 deletions

View File

@ -445,6 +445,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />

View File

@ -445,6 +445,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />

View File

@ -447,6 +447,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />

View File

@ -448,6 +448,7 @@
<Compile Include="NonXNA\Reflection\AssemblyLoader.cs" />
<Compile Include="NonXNA\RenderSystem\INativeConstantBuffer.cs" />
<Compile Include="NonXNA\RenderSystem\IOcclusionQuery.cs" />
<Compile Include="NonXNA\RenderSystem\INativeEffectAnnotation.cs" />
<Compile Include="NonXNA\RenderSystem\VertexTypeHelper.cs" />
<Compile Include="NonXNA\SoundSystem\IDynamicSoundEffectInstance.cs" />
<Compile Include="NonXNA\SoundSystem\IMicrophone.cs" />

View File

@ -1,5 +1,6 @@
using System;
using ANX.Framework.NonXNA.Development;
using ANX.Framework.NonXNA.RenderSystem;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
@ -7,97 +8,86 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(10)]
[Developer("Glatzemann")]
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectAnnotation
{
{
private readonly INativeEffectAnnotation nativeAnnotation;
public int ColumnCount
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.ColumnCount; }
}
public string Name
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.Name; }
}
public EffectParameterClass ParameterClass
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.ParameterClass; }
}
public EffectParameterType ParameterType
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.ParameterType; }
}
public int RowCount
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.RowCount; }
}
public string Semantic
{
get
{
throw new NotImplementedException();
}
get { return nativeAnnotation.Semantic; }
}
internal EffectAnnotation(INativeEffectAnnotation setNativeAnnotation)
{
nativeAnnotation = setNativeAnnotation;
}
public bool GetValueBoolean()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueBoolean();
}
public int GetValueInt32()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueInt32();
}
public Matrix GetValueMatrix()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueMatrix();
}
public float GetValueSingle()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueSingle();
}
public string GetValueString()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueString();
}
public Vector2 GetValueVector2()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueVector2();
}
public Vector3 GetValueVector3()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueVector3();
}
public Vector4 GetValueVector4()
{
throw new NotImplementedException();
return nativeAnnotation.GetValueVector4();
}
}
}

View File

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

View File

@ -9,280 +9,276 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(80)]
[PercentageComplete(100)]
[TestState(TestStateAttribute.TestState.Untested)]
[Developer("Glatzemann")]
public sealed class EffectParameter
{
#region Public (TODO)
public INativeEffectParameter NativeParameter { get; set; }
private readonly INativeEffectParameter nativeParameter;
public EffectAnnotationCollection Annotations
{
get
{
throw new NotImplementedException();
}
}
#region Public
public EffectAnnotationCollection Annotations
{
get { return nativeParameter.Annotations; }
}
public EffectParameterCollection Elements
{
get
{
throw new NotImplementedException();
}
get { return nativeParameter.Elements; }
}
public EffectParameterCollection StructureMembers
{
get
{
throw new NotImplementedException();
}
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;
}
#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

@ -12,25 +12,10 @@ namespace ANX.Framework.Graphics
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectPass
{
private string name;
private EffectAnnotationCollection annotations;
private Effect parentEffect;
private readonly Effect parentEffect;
public string Name
{
get
{
return this.name;
}
}
public EffectAnnotationCollection Annotations
{
get
{
return this.annotations;
}
}
public string Name { get; private set; }
public EffectAnnotationCollection Annotations { get; private set; }
internal EffectPass(Effect parentEffect)
{
@ -43,7 +28,7 @@ namespace ANX.Framework.Graphics
public void Apply()
{
parentEffect.PreBindSetParameters();
parentEffect.NativeEffect.Apply(this.parentEffect.GraphicsDevice);
parentEffect.NativeEffect.Apply(parentEffect.GraphicsDevice);
}
}
}

View File

@ -8,7 +8,7 @@ using ANX.Framework.NonXNA.Development;
namespace ANX.Framework.Graphics
{
[PercentageComplete(90)]
[PercentageComplete(100)]
[Developer("Glatzemann")]
[TestState(TestStateAttribute.TestState.Untested)]
public sealed class EffectTechnique
@ -22,10 +22,7 @@ namespace ANX.Framework.Graphics
public EffectAnnotationCollection Annotations
{
get
{
throw new NotImplementedException();
}
get { return NativeTechnique.Annotations; }
}
public EffectPassCollection Passes { get; private set; }

View File

@ -89,13 +89,10 @@ namespace ANX.Framework.Graphics
public override bool Equals(object obj)
{
if (obj != null && obj is VertexElement)
return this == (VertexElement)obj;
return false;
return obj is VertexElement && this == (VertexElement)obj;
}
public static bool operator ==(VertexElement lhs, VertexElement rhs)
public static bool operator ==(VertexElement lhs, VertexElement rhs)
{
return lhs.offset == rhs.offset && lhs.elementFormat == rhs.elementFormat && lhs.elementUsage == rhs.elementUsage &&
lhs.usageIndex == rhs.usageIndex;

View File

@ -0,0 +1,31 @@
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA.Development;
// This file is part of the ANX.Framework created by the
// "ANX.Framework developer group" and released under the Ms-PL license.
// For details see: http://anxframework.codeplex.com/license
namespace ANX.Framework.NonXNA.RenderSystem
{
[PercentageComplete(100)]
[Developer("AstrorEnales")]
[TestState(TestStateAttribute.TestState.Untested)]
public interface INativeEffectAnnotation
{
int ColumnCount { get; }
string Name { get; }
EffectParameterClass ParameterClass { get; }
EffectParameterType ParameterType { get; }
int RowCount { get; }
string Semantic { get; }
bool GetValueBoolean();
int GetValueInt32();
Matrix GetValueMatrix();
float GetValueSingle();
string GetValueString();
Vector2 GetValueVector2();
Vector3 GetValueVector3();
Vector4 GetValueVector4();
}
}

View File

@ -22,6 +22,9 @@ namespace ANX.Framework.NonXNA
int RowCount { get; }
EffectParameterClass ParameterClass { get; }
EffectParameterType ParameterType { get; }
EffectAnnotationCollection Annotations { get; }
EffectParameterCollection Elements { get; }
EffectParameterCollection StructureMembers { get; }
#region GetValue
bool GetValueBoolean();

View File

@ -14,7 +14,7 @@ namespace ANX.Framework.NonXNA
public interface INativeEffectTechnique
{
string Name { get; }
IEnumerable<EffectPass> Passes { get; }
EffectAnnotationCollection Annotations { get; }
}
}

View File

@ -214,12 +214,10 @@ namespace ANX.RenderSystem.GL3
#endregion
#region AddParametersFrom
private void AddParametersFrom(int programHandle, List<string> parameterNames,
EffectTechniqueGL3 technique)
private void AddParametersFrom(int programHandle, List<string> parameterNames, EffectTechniqueGL3 technique)
{
int uniformCount;
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms,
out uniformCount);
GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms, out uniformCount);
ErrorHelper.Check("GetProgram ActiveUniforms");
for (int index = 0; index < uniformCount; index++)
@ -231,13 +229,8 @@ namespace ANX.RenderSystem.GL3
{
parameterNames.Add(name);
int uniformIndex = GL.GetUniformLocation(programHandle, name);
ErrorHelper.Check("GetUniformLocation name=" + name +
" uniformIndex=" + uniformIndex);
parameters.Add(new EffectParameter()
{
NativeParameter =
new EffectParameterGL3(technique, name, uniformIndex),
});
ErrorHelper.Check("GetUniformLocation name=" + name + " uniformIndex=" + uniformIndex);
parameters.Add(new EffectParameter(new EffectParameterGL3(technique, name, uniformIndex)));
}
}
}

View File

@ -51,6 +51,21 @@ namespace ANX.RenderSystem.GL3
}
public EffectParameterType ParameterType
{
get { throw new NotImplementedException(); }
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection Elements
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection StructureMembers
{
get { throw new NotImplementedException(); }
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
@ -34,25 +35,23 @@ namespace ANX.RenderSystem.GL3
#endregion
#region Public
/// <summary>
/// The name of the effect technique.
/// </summary>
public string Name
{
get;
private set;
}
/// <summary>
/// The name of the effect technique.
/// </summary>
public string Name { get; private set; }
/// <summary>
/// The passes of the technique.
/// </summary>
public IEnumerable<EffectPass> Passes
{
get
{
yield return pass;
}
}
/// <summary>
/// The passes of the technique.
/// </summary>
public IEnumerable<EffectPass> Passes
{
get { yield return pass; }
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
#endregion
#region Constructor

View File

@ -42,15 +42,14 @@ namespace ANX.RenderSystem.Windows.DX10
{
get
{
for (int i = 0; i < NativeEffect.Description.GlobalVariableCount; i++)
{
EffectParameter_DX10 parDx10 = new EffectParameter_DX10();
parDx10.NativeParameter = NativeEffect.GetVariableByIndex(i);
EffectParameter par = new EffectParameter();
par.NativeParameter = parDx10;
yield return par;
}
for (int i = 0; i < NativeEffect.Description.GlobalVariableCount; i++)
{
var parDx10 = new EffectParameter_DX10
{
NativeParameter = NativeEffect.GetVariableByIndex(i)
};
yield return new EffectParameter(parDx10);
}
}
}
#endregion

View File

@ -48,6 +48,21 @@ namespace ANX.RenderSystem.Windows.DX10
{
get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Type); }
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection Elements
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection StructureMembers
{
get { throw new NotImplementedException(); }
}
#endregion
#region SetValue (bool)

View File

@ -16,7 +16,7 @@ namespace ANX.RenderSystem.Windows.DX10
{
public class EffectTechnique_DX10 : INativeEffectTechnique
{
private Effect parentEffect;
private readonly Effect parentEffect;
public EffectTechnique_DX10(Effect parentEffect, Dx10.EffectTechnique nativeTechnique)
{
@ -51,5 +51,10 @@ namespace ANX.RenderSystem.Windows.DX10
}
}
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
}
}

View File

@ -42,12 +42,11 @@ namespace ANX.RenderSystem.Windows.DX11
{
for (int i = 0; i < NativeEffect.Description.GlobalVariableCount; i++)
{
EffectParameter_DX11 parDx11 = new EffectParameter_DX11();
parDx11.NativeParameter = NativeEffect.GetVariableByIndex(i);
EffectParameter par = new EffectParameter();
par.NativeParameter = parDx11;
yield return par;
var parDx11 = new EffectParameter_DX11
{
NativeParameter = NativeEffect.GetVariableByIndex(i)
};
yield return new EffectParameter(parDx11);
}
}
}

View File

@ -48,6 +48,21 @@ namespace ANX.RenderSystem.Windows.DX11
{
get { return DxFormatConverter.Translate(NativeParameter.TypeInfo.Description.Type); }
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection Elements
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection StructureMembers
{
get { throw new NotImplementedException(); }
}
#endregion
#region SetValue (bool)

View File

@ -16,7 +16,7 @@ namespace ANX.RenderSystem.Windows.DX11
{
public class EffectTechnique_DX11 : INativeEffectTechnique
{
private Effect parentEffect;
private readonly Effect parentEffect;
public EffectTechnique_DX11(Effect parentEffect, Dx11.EffectTechnique nativeTechnique)
{
@ -51,5 +51,10 @@ namespace ANX.RenderSystem.Windows.DX11
}
}
}
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
}
}

View File

@ -50,6 +50,21 @@ namespace ANX.RenderSystem.Windows.Metro
}
public EffectParameterType ParameterType
{
get { throw new NotImplementedException(); }
}
public EffectAnnotationCollection Annotations
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection Elements
{
get { throw new NotImplementedException(); }
}
public EffectParameterCollection StructureMembers
{
get { throw new NotImplementedException(); }
}

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
@ -41,12 +42,14 @@ namespace ANX.RenderSystem.Windows.Metro
}
}
public EffectPass_Metro this[int index]
public EffectPass_Metro this[int index]
{
get { return passes[index]; }
}
public EffectAnnotationCollection Annotations
{
get
{
return passes[index];
}
get { throw new NotImplementedException(); }
}
#endregion

View File

@ -101,11 +101,7 @@ namespace ANX.RenderSystem.Windows.Metro
parameters = new List<EffectParameter>();
foreach (ExtendedShaderParameter parameter in shader.Parameters)
{
EffectParameter newParam = new EffectParameter();
newParam.NativeParameter = new EffectParameter_Metro(this, parameter);
parameters.Add(newParam);
}
parameters.Add(new EffectParameter(new EffectParameter_Metro(this, parameter)));
paramBuffer = new ParameterBuffer(this, NativeDxDevice.Current);
}