Ver Fonte

Using Opengl, fix working with default Texture3D and make dispatch barrier works with texture fetches.

borisrp há 2 semanas atrás
pai
commit
342a63bef6
2 ficheiros alterados com 16 adições e 1 exclusões
  1. 3 1
      h3d/impl/GlDriver.hx
  2. 13 0
      h3d/mat/Texture3D.hx

+ 3 - 1
h3d/impl/GlDriver.hx

@@ -646,6 +646,8 @@ class GlDriver extends Driver {
 					switch( pt.t ) {
 					case TSampler(TCube, false):
 						t = h3d.mat.Texture.defaultCubeTexture();
+					case TSampler(T3D, false):
+						t = h3d.mat.Texture3D.default3DTexture();
 					case TSampler(_, false):
 						var color = h3d.mat.Defaults.loadingTextureColor;
 						t = h3d.mat.Texture.fromColor(color, (color >>> 24) / 255);
@@ -2040,7 +2042,7 @@ class GlDriver extends Driver {
 
 	override function computeDispatch(x:Int = 1, y:Int = 1, z:Int = 1) {
 		GL.dispatchCompute(x,y,z);
-		GL.memoryBarrier(GL.BUFFER_UPDATE_BARRIER_BIT);
+		GL.memoryBarrier(GL.BUFFER_UPDATE_BARRIER_BIT | GL.TEXTURE_FETCH_BARRIER_BIT);
 	}
 
 	override function allocQuery(kind:QueryKind) {

+ 13 - 0
h3d/mat/Texture3D.hx

@@ -29,4 +29,17 @@ class Texture3D extends Texture {
 		return super.toString()+"x("+depth+")";
 	}
 
+	/**
+		Returns a default 1x1x1 black 3D texture
+	**/
+	public static function default3DTexture() {
+		var engine = h3d.Engine.getCurrent();
+		var t : h3d.mat.Texture3D = @:privateAccess engine.resCache.get(Texture3D);
+		if( t != null )
+			return t;
+		t = new Texture3D(1, 1, 1, hxd.PixelFormat.R8);
+		@:privateAccess engine.resCache.set(Texture,t);
+		return t;
+	}
+
 }