浏览代码

minor fixes

Nicolas Cannasse 11 月之前
父节点
当前提交
23163f7002
共有 2 个文件被更改,包括 11 次插入4 次删除
  1. 10 4
      h3d/impl/WebGpuDriver.hx
  2. 1 0
      hxsl/WgslOut.hx

+ 10 - 4
h3d/impl/WebGpuDriver.hx

@@ -316,7 +316,9 @@ class WebGpuDriver extends h3d.impl.Driver {
 	}
 	}
 
 
 	override function uploadTextureBitmap(t:h3d.mat.Texture, bmp:hxd.BitmapData, mipLevel:Int, side:Int) {
 	override function uploadTextureBitmap(t:h3d.mat.Texture, bmp:hxd.BitmapData, mipLevel:Int, side:Int) {
-		throw "Not implemented";
+		var pixels = bmp.getPixels();
+		uploadTexturePixels(t, pixels, mipLevel, side);
+		pixels.dispose();
 	}
 	}
 
 
 	override function uploadTexturePixels(t:h3d.mat.Texture, pixels:hxd.Pixels, mipLevel:Int, side:Int) {
 	override function uploadTexturePixels(t:h3d.mat.Texture, pixels:hxd.Pixels, mipLevel:Int, side:Int) {
@@ -504,16 +506,20 @@ class WebGpuDriver extends h3d.impl.Driver {
 			var group = device.createBindGroup({
 			var group = device.createBindGroup({
 				layout : currentShader.groups[index],
 				layout : currentShader.groups[index],
 				entries: [
 				entries: [
-					for( i in 0...buffers.tex.length ) {
+					for( i in 0...sh.texturesCount ) {
 						binding : i,
 						binding : i,
-						resource : buffers.tex[i].t.view,
+						resource : {
+							var t = buffers.tex[i];
+							if( t.t == null && t.realloc != null ) t.realloc();
+							t.t.view;
+						}
 					}
 					}
 				]
 				]
 			});
 			});
 			var samplers = device.createBindGroup({
 			var samplers = device.createBindGroup({
 				layout : currentShader.groups[index+1],
 				layout : currentShader.groups[index+1],
 				entries: [
 				entries: [
-					for( i in 0...buffers.tex.length ) {
+					for( i in 0...sh.texturesCount ) {
 						binding : i,
 						binding : i,
 						resource : createSampler(buffers.tex[i]),
 						resource : createSampler(buffers.tex[i]),
 					}
 					}

+ 1 - 0
hxsl/WgslOut.hx

@@ -607,6 +607,7 @@ class WgslOut {
 		var locals = Lambda.array(locals);
 		var locals = Lambda.array(locals);
 		locals.sort(function(v1, v2) return Reflect.compare(v1.name, v2.name));
 		locals.sort(function(v1, v2) return Reflect.compare(v1.name, v2.name));
 		for( v in locals ) {
 		for( v in locals ) {
+			add("var<private> ");
 			addVar(v);
 			addVar(v);
 			add(";\n");
 			add(";\n");
 		}
 		}