Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Removed shader annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 22, 2020
1 parent 8fe9cd9 commit 638c03e
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 128 deletions.
32 changes: 16 additions & 16 deletions MonoGame/MonoGame.Framework/Graphics/Effect/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,28 +278,28 @@ private void ReadEffect (BinaryReaderEx reader)
{
var name = reader.ReadString();

var annotations = ReadAnnotations(reader);
ReadAnnotations(reader);

var passes = ReadPasses(reader, this, _shaders);

techniques[t] = new EffectTechnique(this, name, passes, annotations);
techniques[t] = new EffectTechnique(this, name, passes/*, annotations*/);
}

Techniques = new EffectTechniqueCollection(techniques);
CurrentTechnique = Techniques[0];
}

private static EffectAnnotationCollection ReadAnnotations(BinaryReader reader)
private static void ReadAnnotations(BinaryReader reader)
{
var count = (int)reader.ReadByte();
if (count == 0)
return EffectAnnotationCollection.Empty;

var annotations = new EffectAnnotation[count];

// TODO: Annotations are not implemented!

return new EffectAnnotationCollection(annotations);
// if (count == 0)
// return EffectAnnotationCollection.Empty;
//
// var annotations = new EffectAnnotation[count];
//
// // TODO: Annotations are not implemented!
//
// return new EffectAnnotationCollection(annotations);
}

private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effect, Shader[] shaders)
Expand All @@ -310,7 +310,7 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
for (var i = 0; i < count; i++)
{
var name = reader.ReadString();
var annotations = ReadAnnotations(reader);
ReadAnnotations(reader);

// Get the vertex shader.
Shader vertexShader = null;
Expand All @@ -324,7 +324,7 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
if (shaderIndex != 255)
pixelShader = shaders[shaderIndex];

BlendState blend = null;
// BlendState blend = null;
// DepthStencilState depth = null;
// RasterizerState raster = null;
// if (reader.ReadBoolean())
Expand Down Expand Up @@ -380,7 +380,7 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
// };
// }

passes[i] = new EffectPass(effect, name, vertexShader, pixelShader, blend, /*depth,*/ /*raster,*/ annotations);
passes[i] = new EffectPass(effect, name, vertexShader, pixelShader/*, blend, depth,*/ /*raster,*//* annotations*/);
}

return new EffectPassCollection(passes);
Expand All @@ -399,7 +399,7 @@ private static EffectParameterCollection ReadParameters(BinaryReaderEx reader)
var type = (EffectParameterType)reader.ReadByte();
var name = reader.ReadString();
var semantic = reader.ReadString();
var annotations = ReadAnnotations(reader);
ReadAnnotations(reader);
var rowCount = (int)reader.ReadByte();
var columnCount = (int)reader.ReadByte();

Expand Down Expand Up @@ -452,7 +452,7 @@ private static EffectParameterCollection ReadParameters(BinaryReaderEx reader)

parameters[i] = new EffectParameter(
class_, type, name, rowCount, columnCount, semantic,
annotations, elements, structMembers, data);
/*annotations,*/ elements, structMembers, data);
}

return new EffectParameterCollection(parameters);
Expand Down
88 changes: 44 additions & 44 deletions MonoGame/MonoGame.Framework/Graphics/Effect/EffectAnnotation.cs
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
using System;

namespace Microsoft.Xna.Framework.Graphics
{
// TODO: This class needs to be finished!

public class EffectAnnotation
{
internal EffectAnnotation (
EffectParameterClass class_,
EffectParameterType type,
string name,
int rowCount,
int columnCount,
string semantic,
object data)
{
ParameterClass = class_;
ParameterType = type;
Name = name;
RowCount = rowCount;
ColumnCount = columnCount;
Semantic = semantic;
}

internal EffectAnnotation (EffectParameter parameter)
{
ParameterClass = parameter.ParameterClass;
ParameterType = parameter.ParameterType;
Name = parameter.Name;
RowCount = parameter.RowCount;
ColumnCount = parameter.ColumnCount;
Semantic = parameter.Semantic;
}

public EffectParameterClass ParameterClass {get; private set;}
public EffectParameterType ParameterType {get; private set;}
public string Name {get; private set;}
public int RowCount {get; private set;}
public int ColumnCount {get; private set;}
public string Semantic {get; private set;}
}
}

// using System;
//
// namespace Microsoft.Xna.Framework.Graphics
// {
// // TODO: This class needs to be finished!
//
// public class EffectAnnotation
// {
// // internal EffectAnnotation (
// // EffectParameterClass class_,
// // EffectParameterType type,
// // string name,
// // int rowCount,
// // int columnCount,
// // string semantic,
// // object data)
// // {
// // ParameterClass = class_;
// // ParameterType = type;
// // Name = name;
// // RowCount = rowCount;
// // ColumnCount = columnCount;
// // Semantic = semantic;
// // }
// //
// // internal EffectAnnotation (EffectParameter parameter)
// // {
// // ParameterClass = parameter.ParameterClass;
// // ParameterType = parameter.ParameterType;
// // Name = parameter.Name;
// // RowCount = parameter.RowCount;
// // ColumnCount = parameter.ColumnCount;
// // Semantic = parameter.Semantic;
// // }
//
// // public EffectParameterClass ParameterClass {get; private set;}
// // public EffectParameterType ParameterType {get; private set;}
// public string Name {get; private set;}
// // public int RowCount {get; private set;}
// // public int ColumnCount {get; private set;}
// // public string Semantic {get; private set;}
// }
// }
//
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
using System.Collections.Generic;

namespace Microsoft.Xna.Framework.Graphics
{
public class EffectAnnotationCollection : IEnumerable<EffectAnnotation>
{
internal static readonly EffectAnnotationCollection Empty = new EffectAnnotationCollection(new EffectAnnotation[0]);

private readonly EffectAnnotation[] _annotations;

internal EffectAnnotationCollection(EffectAnnotation[] annotations)
{
_annotations = annotations;
}

public int Count
{
get { return _annotations.Length; }
}
public EffectAnnotation this[int index]
{
get { return _annotations[index]; }
}
public EffectAnnotation this[string name]
{
get
{
foreach (var annotation in _annotations)
{
if (annotation.Name == name)
return annotation;
}
return null;
}
}

public IEnumerator<EffectAnnotation> GetEnumerator()
{
return ((IEnumerable<EffectAnnotation>)_annotations).GetEnumerator();
}

System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return _annotations.GetEnumerator();
}
}
}

// using System.Collections.Generic;
//
// namespace Microsoft.Xna.Framework.Graphics
// {
// public class EffectAnnotationCollection : IEnumerable<EffectAnnotation>
// {
// internal static readonly EffectAnnotationCollection Empty = new EffectAnnotationCollection(new EffectAnnotation[0]);
//
// private readonly EffectAnnotation[] _annotations;
//
// internal EffectAnnotationCollection(EffectAnnotation[] annotations)
// {
// _annotations = annotations;
// }
//
// // public int Count
// // {
// // get { return _annotations.Length; }
// // }
// //
// // public EffectAnnotation this[int index]
// // {
// // get { return _annotations[index]; }
// // }
// //
// // public EffectAnnotation this[string name]
// // {
// // get
// // {
// // foreach (var annotation in _annotations)
// // {
// // if (annotation.Name == name)
// // return annotation;
// // }
// // return null;
// // }
// // }
//
// public IEnumerator<EffectAnnotation> GetEnumerator()
// {
// return ((IEnumerable<EffectAnnotation>)_annotations).GetEnumerator();
// }
//
// System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
// {
// return _annotations.GetEnumerator();
// }
// }
// }
//
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class EffectParameter
int rowCount,
int columnCount,
string semantic,
EffectAnnotationCollection annotations,
// EffectAnnotationCollection annotations,
EffectParameterCollection elements,
EffectParameterCollection structMembers,
object data )
Expand All @@ -30,7 +30,7 @@ public class EffectParameter

Name = name;
Semantic = semantic;
Annotations = annotations;
// Annotations = annotations;

RowCount = rowCount;
ColumnCount = columnCount;
Expand All @@ -49,7 +49,7 @@ internal EffectParameter(EffectParameter cloneSource)
ParameterType = cloneSource.ParameterType;
Name = cloneSource.Name;
Semantic = cloneSource.Semantic;
Annotations = cloneSource.Annotations;
// Annotations = cloneSource.Annotations;
RowCount = cloneSource.RowCount;
ColumnCount = cloneSource.ColumnCount;

Expand Down Expand Up @@ -80,7 +80,7 @@ internal EffectParameter(EffectParameter cloneSource)

public EffectParameterCollection StructureMembers { get; private set; }

public EffectAnnotationCollection Annotations { get; private set; }
// public EffectAnnotationCollection Annotations { get; private set; }


// TODO: Using object adds alot of boxing/unboxing overhead
Expand Down
20 changes: 10 additions & 10 deletions MonoGame/MonoGame.Framework/Graphics/Effect/EffectPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,25 @@ public class EffectPass
private readonly Shader _pixelShader;
private readonly Shader _vertexShader;

private readonly BlendState _blendState;
// private readonly BlendState _blendState;
// private readonly DepthStencilState _depthStencilState;
// private readonly RasterizerState _rasterizerState;

public string Name { get; private set; }

public EffectAnnotationCollection Annotations { get; private set; }
// public EffectAnnotationCollection Annotations { get; private set; }

internal EffectPass( Effect effect,
string name,
Shader vertexShader,
Shader pixelShader,
BlendState blendState,
Shader pixelShader//,
// BlendState blendState//,
/*DepthStencilState depthStencilState, */
/*RasterizerState rasterizerState,*/
EffectAnnotationCollection annotations )
/*EffectAnnotationCollection annotations*/ )
{
Debug.Assert(effect != null, "Got a null effect!");
Debug.Assert(annotations != null, "Got a null annotation collection!");
// Debug.Assert(annotations != null, "Got a null annotation collection!");

_effect = effect;

Expand All @@ -36,11 +36,11 @@ public class EffectPass
_vertexShader = vertexShader;
_pixelShader = pixelShader;

_blendState = blendState;
// _blendState = blendState;
// _depthStencilState = depthStencilState;
// _rasterizerState = rasterizerState;

Annotations = annotations;
// Annotations = annotations;
}

internal EffectPass(Effect effect, EffectPass cloneSource)
Expand All @@ -52,10 +52,10 @@ internal EffectPass(Effect effect, EffectPass cloneSource)

// Share all the immutable types.
Name = cloneSource.Name;
_blendState = cloneSource._blendState;
// _blendState = cloneSource._blendState;
// _depthStencilState = cloneSource._depthStencilState;
// _rasterizerState = cloneSource._rasterizerState;
Annotations = cloneSource.Annotations;
// Annotations = cloneSource.Annotations;
_vertexShader = cloneSource._vertexShader;
_pixelShader = cloneSource._pixelShader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ public class EffectTechnique
{
public EffectPassCollection Passes { get; private set; }

public EffectAnnotationCollection Annotations { get; private set; }
// public EffectAnnotationCollection Annotations { get; private set; }

public string Name { get; private set; }

internal EffectTechnique(Effect effect, EffectTechnique cloneSource)
{
// Share all the immutable types.
Name = cloneSource.Name;
Annotations = cloneSource.Annotations;
// Annotations = cloneSource.Annotations;

// Clone the mutable types.
Passes = cloneSource.Passes.Clone(effect);
}

internal EffectTechnique(Effect effect, string name, EffectPassCollection passes, EffectAnnotationCollection annotations)
internal EffectTechnique(Effect effect, string name, EffectPassCollection passes/*, EffectAnnotationCollection annotations*/)
{
Name = name;
Passes = passes;
Annotations = annotations;
// Annotations = annotations;
}
}

Expand Down

0 comments on commit 638c03e

Please sign in to comment.