瀏覽代碼

[DX12] Fix root signature and add safety check.

TothBenoit 1 年之前
父節點
當前提交
9850ba193d
共有 1 個文件被更改,包括 4 次插入1 次删除
  1. 4 1
      h3d/impl/DX12Driver.hx

+ 4 - 1
h3d/impl/DX12Driver.hx

@@ -1225,7 +1225,7 @@ class DX12Driver extends h3d.impl.Driver {
 			// Remove the size cost of the root constant and add one descriptor table.
 			var withoutVP = total - vertexParamSizeCost + 1;
 			var withoutFP = total - fragmentParamSizeCost + 1;
-			if( withoutVP < 64 || withoutFP > 64 ) {
+			if( withoutVP < 64 || ( withoutFP > 64 && withoutVP > 64 ) ) {
 				vertexParamsCBV = true;
 				total = withoutVP;
 			}
@@ -1235,6 +1235,9 @@ class DX12Driver extends h3d.impl.Driver {
 			}
 			if( total > 64 ) {
 				globalsParamsCBV = true;
+				var withoutGlobal = total - (shader.vertex.globalsSize << 2) - (shader.fragment.globalsSize << 2) + 2;
+				if ( withoutGlobal > 64 )
+					throw "Too many params. Use less textures or improve descriptor table packing";
 			}
 		}