2011-11-16 14:27:53 +00:00
|
|
|
using System;
|
2012-08-09 09:45:04 +00:00
|
|
|
using ANX.Framework;
|
2012-09-06 09:58:13 +00:00
|
|
|
using ANX.Framework.Graphics;
|
|
|
|
using ANX.Framework.NonXNA;
|
|
|
|
using Dx10 = SharpDX.Direct3D10;
|
2012-09-30 10:43:06 +00:00
|
|
|
using ANX.Framework.NonXNA.Development;
|
2015-10-14 23:59:27 +02:00
|
|
|
using SharpDX.Direct3D10;
|
2011-11-16 14:27:53 +00:00
|
|
|
|
2012-08-09 09:45:04 +00:00
|
|
|
// 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.RenderSystem.Windows.DX10
|
2011-11-16 14:27:53 +00:00
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
[PercentageComplete(80)]
|
2012-09-30 10:43:06 +00:00
|
|
|
[TestState(TestStateAttribute.TestState.Untested)]
|
2015-10-14 23:59:27 +02:00
|
|
|
[Developer("Glatzemann, KorsarNek")]
|
|
|
|
public class EffectParameter_DX10 : DxEffectAnnotation, INativeEffectParameter
|
2012-09-06 09:58:13 +00:00
|
|
|
{
|
|
|
|
#region Public
|
2015-10-14 23:59:27 +02:00
|
|
|
public Dx10.EffectVariable NativeParameter { get; private set; }
|
2012-09-06 09:58:13 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
public EffectParameter_DX10(Dx10.EffectVariable nativeParameter)
|
|
|
|
: base(nativeParameter)
|
2012-10-13 10:51:27 +00:00
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
this.NativeParameter = nativeParameter;
|
2012-09-30 10:43:06 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
var description = nativeParameter.Description;
|
|
|
|
var typeDescription = nativeParameter.TypeInfo.Description;
|
2012-10-13 10:51:27 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
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);
|
2012-10-13 10:51:27 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
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);
|
2012-10-13 10:51:27 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
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);
|
2012-10-13 10:51:27 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
this.ShaderResource = nativeParameter.AsShaderResource();
|
2012-10-13 10:51:27 +00:00
|
|
|
}
|
2012-10-13 13:12:07 +00:00
|
|
|
|
|
|
|
public EffectAnnotationCollection Annotations
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
get;
|
|
|
|
private set;
|
2012-10-13 13:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public EffectParameterCollection Elements
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
get;
|
|
|
|
private set;
|
2012-10-13 13:12:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public EffectParameterCollection StructureMembers
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
get;
|
|
|
|
private set;
|
2012-10-13 13:12:07 +00:00
|
|
|
}
|
2012-10-13 10:51:27 +00:00
|
|
|
#endregion
|
2012-09-06 09:58:13 +00:00
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
protected EffectShaderResourceVariable ShaderResource
|
|
|
|
{
|
|
|
|
get;
|
|
|
|
private set;
|
|
|
|
}
|
|
|
|
|
|
|
|
#region SetValue (TODO)
|
2012-09-06 09:58:13 +00:00
|
|
|
public void SetValue(bool value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Scalar.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(bool[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Scalar.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(int value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Scalar.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(int[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Scalar.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Matrix value, bool transpose)
|
|
|
|
{
|
2012-09-22 11:17:36 +00:00
|
|
|
if (transpose)
|
2015-10-14 23:59:27 +02:00
|
|
|
Matrix.SetMatrixTranspose(value);
|
|
|
|
else
|
|
|
|
Matrix.SetMatrix(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
2011-11-16 14:27:53 +00:00
|
|
|
|
2012-09-06 09:58:13 +00:00
|
|
|
public void SetValue(Matrix[] value, bool transpose)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
if (transpose)
|
|
|
|
Matrix.SetMatrixTranspose(value);
|
|
|
|
else
|
|
|
|
Matrix.SetMatrix(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Quaternion value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Quaternion[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(float value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(float[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Scalar.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector2 value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector2[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector3 value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector3[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector4 value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Vector4[] value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
Vector.Set(value);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(Texture value)
|
|
|
|
{
|
|
|
|
if (value == null)
|
|
|
|
throw new ArgumentNullException("value");
|
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
ShaderResource.SetResource(((DxTexture2D)value.NativeTexture).NativeShaderResourceView);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void SetValue(string value)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
throw new NotImplementedException();
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region Get (TODO)
|
|
|
|
|
|
|
|
public bool[] GetValueBooleanArray(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Scalar.GetBoolArray(0, count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public int[] GetValueInt32Array(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Scalar.GetIntArray(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Matrix[] GetValueMatrixArray(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Matrix.GetMatrixArray<Matrix>(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
public Matrix GetValueMatrixTranspose()
|
|
|
|
{
|
|
|
|
return Matrix.GetMatrixTranspose<Matrix>();
|
|
|
|
}
|
2012-09-06 09:58:13 +00:00
|
|
|
|
|
|
|
public Matrix[] GetValueMatrixTransposeArray(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Matrix.GetMatrixTransposeArray<Matrix>(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Quaternion GetValueQuaternion()
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Vector.GetVector<Quaternion>();
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Quaternion[] GetValueQuaternionArray(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Vector.GetVectorArray<Quaternion>(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public float[] GetValueSingleArray(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Scalar.GetFloatArray(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
public ANX.Framework.Graphics.Texture2D GetValueTexture2D()
|
2012-09-06 09:58:13 +00:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
2015-10-14 23:59:27 +02:00
|
|
|
public ANX.Framework.Graphics.Texture3D GetValueTexture3D()
|
2012-09-06 09:58:13 +00:00
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public TextureCube GetValueTextureCube()
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Vector2[] GetValueVector2Array(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Vector.GetVectorArray<Vector2>(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public Vector3[] GetValueVector3Array(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Vector.GetVectorArray<Vector3>(count);
|
2012-09-06 09:58:13 +00:00
|
|
|
}
|
2012-01-16 15:03:28 +00:00
|
|
|
|
2012-09-06 09:58:13 +00:00
|
|
|
public Vector4[] GetValueVector4Array(int count)
|
|
|
|
{
|
2015-10-14 23:59:27 +02:00
|
|
|
return Vector.GetVectorArray<Vector4>(count);
|
2012-01-16 15:03:28 +00:00
|
|
|
}
|
2012-09-06 09:58:13 +00:00
|
|
|
#endregion
|
2015-10-14 23:59:27 +02:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2011-11-16 14:27:53 +00:00
|
|
|
}
|