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

Commit

Permalink
Removed depth stencil.
Browse files Browse the repository at this point in the history
  • Loading branch information
jessefreeman committed May 21, 2020
1 parent 3aeeb35 commit ab42b66
Show file tree
Hide file tree
Showing 8 changed files with 380 additions and 376 deletions.
44 changes: 23 additions & 21 deletions MonoGame/MonoGame.Framework/Graphics/Effect/Effect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.IO;
using Microsoft.Xna.Framework.Utilities;

// using Microsoft.Xna.Framework.Utilities;

namespace Microsoft.Xna.Framework.Graphics
{
public class Effect : GraphicsResource
Expand Down Expand Up @@ -323,7 +325,7 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
pixelShader = shaders[shaderIndex];

BlendState blend = null;
DepthStencilState depth = null;
// DepthStencilState depth = null;
RasterizerState raster = null;
if (reader.ReadBoolean())
{
Expand All @@ -345,25 +347,25 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
}
if (reader.ReadBoolean())
{
depth = new DepthStencilState
{
CounterClockwiseStencilDepthBufferFail = (StencilOperation)reader.ReadByte(),
CounterClockwiseStencilFail = (StencilOperation)reader.ReadByte(),
CounterClockwiseStencilFunction = (CompareFunction)reader.ReadByte(),
CounterClockwiseStencilPass = (StencilOperation)reader.ReadByte(),
DepthBufferEnable = reader.ReadBoolean(),
DepthBufferFunction = (CompareFunction)reader.ReadByte(),
DepthBufferWriteEnable = reader.ReadBoolean(),
ReferenceStencil = reader.ReadInt32(),
StencilDepthBufferFail = (StencilOperation)reader.ReadByte(),
StencilEnable = reader.ReadBoolean(),
StencilFail = (StencilOperation)reader.ReadByte(),
StencilFunction = (CompareFunction)reader.ReadByte(),
StencilMask = reader.ReadInt32(),
StencilPass = (StencilOperation)reader.ReadByte(),
StencilWriteMask = reader.ReadInt32(),
TwoSidedStencilMode = reader.ReadBoolean(),
};
// depth = new DepthStencilState
// {
// CounterClockwiseStencilDepthBufferFail = (StencilOperation)reader.ReadByte(),
// CounterClockwiseStencilFail = (StencilOperation)reader.ReadByte(),
// CounterClockwiseStencilFunction = (CompareFunction)reader.ReadByte(),
// CounterClockwiseStencilPass = (StencilOperation)reader.ReadByte(),
// DepthBufferEnable = reader.ReadBoolean(),
// DepthBufferFunction = (CompareFunction)reader.ReadByte(),
// DepthBufferWriteEnable = reader.ReadBoolean(),
// ReferenceStencil = reader.ReadInt32(),
// StencilDepthBufferFail = (StencilOperation)reader.ReadByte(),
// StencilEnable = reader.ReadBoolean(),
// StencilFail = (StencilOperation)reader.ReadByte(),
// StencilFunction = (CompareFunction)reader.ReadByte(),
// StencilMask = reader.ReadInt32(),
// StencilPass = (StencilOperation)reader.ReadByte(),
// StencilWriteMask = reader.ReadInt32(),
// TwoSidedStencilMode = reader.ReadBoolean(),
// };
}
if (reader.ReadBoolean())
{
Expand All @@ -378,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 Down
14 changes: 7 additions & 7 deletions MonoGame/MonoGame.Framework/Graphics/Effect/EffectPass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class EffectPass
private readonly Shader _vertexShader;

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

public string Name { get; private set; }
Expand All @@ -22,7 +22,7 @@ public class EffectPass
Shader vertexShader,
Shader pixelShader,
BlendState blendState,
DepthStencilState depthStencilState,
/*DepthStencilState depthStencilState, */
RasterizerState rasterizerState,
EffectAnnotationCollection annotations )
{
Expand All @@ -37,7 +37,7 @@ public class EffectPass
_pixelShader = pixelShader;

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

Annotations = annotations;
Expand All @@ -53,7 +53,7 @@ internal EffectPass(Effect effect, EffectPass cloneSource)
// Share all the immutable types.
Name = cloneSource.Name;
_blendState = cloneSource._blendState;
_depthStencilState = cloneSource._depthStencilState;
// _depthStencilState = cloneSource._depthStencilState;
_rasterizerState = cloneSource._rasterizerState;
Annotations = cloneSource.Annotations;
_vertexShader = cloneSource._vertexShader;
Expand Down Expand Up @@ -111,8 +111,8 @@ public void Apply()
device.RasterizerState = _rasterizerState;
if (_blendState != null)
device.BlendState = _blendState;
if (_depthStencilState != null)
device.DepthStencilState = _depthStencilState;
// if (_depthStencilState != null)
// device.DepthStencilState = _depthStencilState;
}

private void SetShaderSamplers(Shader shader, TextureCollection textures, SamplerStateCollection samplerStates)
Expand All @@ -130,4 +130,4 @@ private void SetShaderSamplers(Shader shader, TextureCollection textures, Sample
}
}
}
}
}
100 changes: 50 additions & 50 deletions MonoGame/MonoGame.Framework/Graphics/GraphicsDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ public partial class GraphicsDevice : IDisposable
private BlendState _blendStateNonPremultiplied;
private BlendState _blendStateOpaque;

private DepthStencilState _depthStencilState;
private DepthStencilState _actualDepthStencilState;
private bool _depthStencilStateDirty;

private DepthStencilState _depthStencilStateDefault;
private DepthStencilState _depthStencilStateDepthRead;
private DepthStencilState _depthStencilStateNone;
// private DepthStencilState _depthStencilState;
// private DepthStencilState _actualDepthStencilState;
// private bool _depthStencilStateDirty;
//
// private DepthStencilState _depthStencilStateDefault;
// private DepthStencilState _depthStencilStateDepthRead;
// private DepthStencilState _depthStencilStateNone;

private RasterizerState _rasterizerState;
private RasterizerState _actualRasterizerState;
Expand Down Expand Up @@ -309,11 +309,11 @@ private void Setup()

BlendState = BlendState.Opaque;

_depthStencilStateDefault = DepthStencilState.Default.Clone();
_depthStencilStateDepthRead = DepthStencilState.DepthRead.Clone();
_depthStencilStateNone = DepthStencilState.None.Clone();

DepthStencilState = DepthStencilState.Default;
// _depthStencilStateDefault = DepthStencilState.Default.Clone();
// _depthStencilStateDepthRead = DepthStencilState.DepthRead.Clone();
// _depthStencilStateNone = DepthStencilState.None.Clone();
//
// DepthStencilState = DepthStencilState.Default;

_rasterizerStateCullClockwise = RasterizerState.CullClockwise.Clone();
_rasterizerStateCullCounterClockwise = RasterizerState.CullCounterClockwise.Clone();
Expand Down Expand Up @@ -357,9 +357,9 @@ internal void Initialize()
PlatformInitialize();

// Force set the default render states.
_blendStateDirty = _depthStencilStateDirty = _rasterizerStateDirty = true;
// _blendStateDirty = _depthStencilStateDirty = _rasterizerStateDirty = true;
BlendState = BlendState.Opaque;
DepthStencilState = DepthStencilState.Default;
// DepthStencilState = DepthStencilState.Default;
RasterizerState = RasterizerState.CullCounterClockwise;

// Clear the texture and sampler collections forcing
Expand Down Expand Up @@ -487,37 +487,37 @@ public BlendState BlendState
}
}

public DepthStencilState DepthStencilState
{
get { return _depthStencilState; }
set
{
if (value == null)
throw new ArgumentNullException("value");

// Don't set the same state twice!
if (_depthStencilState == value)
return;

_depthStencilState = value;

// Static state properties never actually get bound;
// instead we use our GraphicsDevice-specific version of them.
var newDepthStencilState = _depthStencilState;
if (ReferenceEquals(_depthStencilState, DepthStencilState.Default))
newDepthStencilState = _depthStencilStateDefault;
else if (ReferenceEquals(_depthStencilState, DepthStencilState.DepthRead))
newDepthStencilState = _depthStencilStateDepthRead;
else if (ReferenceEquals(_depthStencilState, DepthStencilState.None))
newDepthStencilState = _depthStencilStateNone;

newDepthStencilState.BindToGraphicsDevice(this);

_actualDepthStencilState = newDepthStencilState;

_depthStencilStateDirty = true;
}
}
// public DepthStencilState DepthStencilState
// {
// get { return _depthStencilState; }
// set
// {
// if (value == null)
// throw new ArgumentNullException("value");
//
// // Don't set the same state twice!
// if (_depthStencilState == value)
// return;
//
// _depthStencilState = value;
//
// // Static state properties never actually get bound;
// // instead we use our GraphicsDevice-specific version of them.
// var newDepthStencilState = _depthStencilState;
// if (ReferenceEquals(_depthStencilState, DepthStencilState.Default))
// newDepthStencilState = _depthStencilStateDefault;
// else if (ReferenceEquals(_depthStencilState, DepthStencilState.DepthRead))
// newDepthStencilState = _depthStencilStateDepthRead;
// else if (ReferenceEquals(_depthStencilState, DepthStencilState.None))
// newDepthStencilState = _depthStencilStateNone;
//
// newDepthStencilState.BindToGraphicsDevice(this);
//
// _actualDepthStencilState = newDepthStencilState;
//
// _depthStencilStateDirty = true;
// }
// }

internal void ApplyState(bool applyShaders)
{
Expand Down Expand Up @@ -607,11 +607,11 @@ protected virtual void Dispose(bool disposing)
_blendStateNonPremultiplied.Dispose();
_blendStateOpaque.Dispose();

_depthStencilState = null;
_actualDepthStencilState = null;
_depthStencilStateDefault.Dispose();
_depthStencilStateDepthRead.Dispose();
_depthStencilStateNone.Dispose();
// _depthStencilState = null;
// _actualDepthStencilState = null;
// _depthStencilStateDefault.Dispose();
// _depthStencilStateDepthRead.Dispose();
// _depthStencilStateNone.Dispose();

_rasterizerState = null;
_actualRasterizerState = null;
Expand Down
8 changes: 4 additions & 4 deletions MonoGame/MonoGame.Framework/Graphics/SpriteBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class SpriteBatch : GraphicsResource
SpriteSortMode _sortMode;
BlendState _blendState;
SamplerState _samplerState;
DepthStencilState _depthStencilState;
// DepthStencilState _depthStencilState;
RasterizerState _rasterizerState;
Effect _effect;
bool _beginCalled;
Expand Down Expand Up @@ -81,7 +81,7 @@ public void Begin
SpriteSortMode sortMode = SpriteSortMode.Deferred,
BlendState blendState = null,
SamplerState samplerState = null,
DepthStencilState depthStencilState = null,
/*DepthStencilState depthStencilState = null,*/
RasterizerState rasterizerState = null,
Effect effect = null,
Matrix? transformMatrix = null
Expand All @@ -94,7 +94,7 @@ public void Begin
_sortMode = sortMode;
_blendState = blendState ?? BlendState.AlphaBlend;
_samplerState = samplerState ?? SamplerState.LinearClamp;
_depthStencilState = depthStencilState ?? DepthStencilState.None;
// _depthStencilState = depthStencilState ?? DepthStencilState.None;
_rasterizerState = rasterizerState ?? RasterizerState.CullCounterClockwise;
_effect = effect;
_spriteEffect.TransformMatrix = transformMatrix;
Expand Down Expand Up @@ -129,7 +129,7 @@ void Setup()
{
var gd = GraphicsDevice;
gd.BlendState = _blendState;
gd.DepthStencilState = _depthStencilState;
// gd.DepthStencilState = _depthStencilState;
gd.RasterizerState = _rasterizerState;
gd.SamplerStates[0] = _samplerState;

Expand Down

0 comments on commit ab42b66

Please sign in to comment.