Skip to content
Open
1 change: 1 addition & 0 deletions hxsl/Ast.hx
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ enum TGlobal {
InstanceID;
// gl globals
FragCoord;
FragDepth;
FrontFacing;
// bit casting
FloatBitsToInt;
Expand Down
18 changes: 12 additions & 6 deletions hxsl/Checker.hx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class Checker {
];
case ImageStore:
[];
case VertexID, InstanceID, FragCoord, FrontFacing:
case VertexID, InstanceID, FragCoord, FrontFacing,FragDepth:
null;
case AtomicAdd:
[{ args : [{ name : "buf", type : TBuffer(TInt, SConst(0), RW) },{ name : "index", type : TInt }, { name : "data", type : TInt }], ret : TInt }];
Expand Down Expand Up @@ -225,6 +225,7 @@ class Checker {
globals.set("vertexID", { t : TInt, g : VertexID });
globals.set("instanceID", { t : TInt, g : InstanceID });
globals.set("fragCoord", { t : vec4, g : FragCoord });
globals.set("fragDepth", { t : TFloat, g : FragDepth });
globals.set("frontFacing", { t : TBool, g : FrontFacing });
for( gname => vl in gvars )
globals.set(gname, { t : TStruct([
Expand Down Expand Up @@ -418,7 +419,13 @@ class Checker {
case TArray(e, _):
checkWrite(e);
return;
default:
case TGlobal(g):
switch(g) {
case FragDepth:
return;
default:
}
default:
Comment thread
lusius marked this conversation as resolved.
Outdated
}
error("This expression cannot be assigned", e.p);
}
Expand Down Expand Up @@ -799,12 +806,11 @@ class Checker {
checkConst(e);
einit = e;
}
if( v.type == null ) error("Type required for variable declaration", e.pos);
if( isImport && v.kind == Param )
continue;

if( v.type == null ) error("Type required for variable declaration", e.pos);
if( vars.exists(v.name) ) error("Duplicate var decl '" + v.name + "'", e.pos);
var v = makeVar(v, e.pos);
if( isImport && v.kind == Param )
continue;
Comment thread
lusius marked this conversation as resolved.

switch( v.type ) {
case TSampler(T3D, true), TRWTexture(T3D, true, _), TRWTexture(_,_,3):
Expand Down
1 change: 1 addition & 0 deletions hxsl/GlslOut.hx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class GlslOut {
set(BVec3, "bvec3");
set(BVec4, "bvec4");
set(FragCoord, "gl_FragCoord");
set(FragDepth, "gl_FragDepth");
set(FrontFacing, "gl_FrontFacing");
set(FloatBitsToUint, "_floatBitsToUint");
set(UintBitsToFloat, "_uintBitsToFloat");
Expand Down
3 changes: 2 additions & 1 deletion hxsl/HlslOut.hx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class HlslOut {
m.set(BVec3, "bool3");
m.set(BVec4, "bool4");
m.set(FragCoord,"_in.__pos__");
m.set(FragDepth,"SV_Depth");
m.set(FloatBitsToInt, "asint");
m.set(FloatBitsToUint, "asuint");
m.set(IntBitsToFloat, "asfloat");
Expand Down Expand Up @@ -458,7 +459,7 @@ class HlslOut {
case TCall({ e : TGlobal(g = (Texel)) }, args):
addValue(args[0], tabs);
add(".Load(");
switch( args[0].t ) {
switch( args[1].t ) {
Comment thread
lusius marked this conversation as resolved.
Outdated
case TSampler(dim,arr):
var size = Tools.getDimSize(dim, arr) + 1;
add("int"+size+"(");
Expand Down