Procházet zdrojové kódy

fix glsl bug with webgl/chrome

ncannasse před 7 roky
rodič
revize
9ac3947d56
1 změnil soubory, kde provedl 17 přidání a 3 odebrání
  1. 17 3
      hxsl/GlslOut.hx

+ 17 - 3
hxsl/GlslOut.hx

@@ -35,6 +35,7 @@ class GlslOut {
 	var isVertex : Bool;
 	var allNames : Map<String, Int>;
 	var outIndexes : Map<Int, Int>;
+	var intelDriverFix : Bool;
 	public var varNames : Map<Int,String>;
 	public var flipY : Bool;
 	public var glES : Bool;
@@ -112,8 +113,8 @@ class GlslOut {
 			switch( size ) {
 			case SVar(v):
 				ident(v);
-			case SConst(1):
-				add(2); // intel HD driver fix
+			case SConst(1) if( intelDriverFix ):
+				add(2);
 			case SConst(v):
 				add(v);
 			}
@@ -133,7 +134,7 @@ class GlslOut {
 			add("[");
 			switch( size ) {
 			case SVar(v): ident(v);
-			case SConst(1): add(2); // intel HD driver fix
+			case SConst(1) if( intelDriverFix ): add(2);
 			case SConst(n): add(n);
 			}
 			add("]");
@@ -495,6 +496,19 @@ class GlslOut {
 		buf = new StringBuf();
 		exprValues = [];
 
+		/*
+			Intel HD driver fix:
+				single element arrays are interpreted as not arrays, creating mismatch when
+				handling uniforms/textures. The fix changes decl[1] into decl[2] with one unused element
+
+				This fix is only for desktop, WebGL has errors with Cube Textures if there's
+				both Texture2D and TextureCube arrays in shader.
+				Also disable it for third party GL implementations (consoles)
+		*/
+		#if !(usegl || js)
+		intelDriverFix = true;
+		#end
+
 		decl("precision mediump float;");
 
 		if( s.funs.length != 1 ) throw "assert";