Permalink
Browse files

removed the gl_FragDepth keyword and unified frag depth write to

[FragmentOut(UsageSemantic.Depth)] float Name;

Added GLSL crosstranslation for it.
HLSL support is native.
  • Loading branch information...
1 parent 362c18e commit 93a837fa8ccd764c9b5057998575776e2d5b37c2 @WolfgangSt WolfgangSt committed Oct 17, 2011
@@ -22,6 +22,8 @@ public enum UsageSemantic
Depth*/
Unknown,
+ Depth,
+
PositionX,
Position0,
Position1,
@@ -14,8 +14,6 @@ public abstract partial class ShaderDefinition
protected vec4 gl_Position;
- protected float gl_FragDepth;
-
// ReSharper restore InconsistentNaming
// ReSharper restore UnusedParameter.Local
}
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
+using IIS.SLSharp.Annotations;
using IIS.SLSharp.Descriptions;
using IIS.SLSharp.Shaders;
using Mono.Cecil;
@@ -112,7 +113,18 @@ public static string ToGlsl(this SourceDescription desc, ShaderType type)
if (type == ShaderType.FragmentShader)
desc.FragmentOuts.ForEach(
- v => s.AppendFormat("out {0} {1};{2}", v.Type.ToGlsl(), v.Name, v.Comment).Append(Environment.NewLine));
+ v =>
+ {
+ if (v.Semantic == UsageSemantic.Depth)
+ {
+ // validate type and let SL# throw rather than generate invalid GL code
+ if (v.Type != typeof(float))
+ throw new SLSharpException(v.Name + "'s must be float, as it is marked as fragment depth!");
+ s.AppendFormat("#define {0} gl_FragDepth {1}", v.Name, v.Comment).Append(Environment.NewLine);
+ return;
+ }
+ s.AppendFormat("out {0} {1};{2}", v.Type.ToGlsl(), v.Name, v.Comment).Append(Environment.NewLine);
+ });
s.AppendLine();
desc.ForwardDecl.ForEach(v => s.AppendLine(v));

0 comments on commit 93a837f

Please sign in to comment.