浏览代码

DX12 :
- Fix root constant size cost computation

ahzenrei 1 年之前
父节点
当前提交
cb4f7fa259
共有 1 个文件被更改,包括 9 次插入5 次删除
  1. 9 5
      h3d/impl/DX12Driver.hx

+ 9 - 5
h3d/impl/DX12Driver.hx

@@ -1059,15 +1059,19 @@ class DX12Driver extends h3d.impl.Driver {
 		var total = totalVertex + totalFragment;
 
 		if( total > 64 ) {
-			var withoutVP = total - (shader.vertex.paramsSize << 2);
-			var withoutFP = total - (shader.fragment.paramsSize << 2);
-			if( total > 64 && (withoutVP < 64 || withoutFP > 64) ) {
+			var vertexParamSizeCost = (shader.vertex.paramsSize << 2);
+			var fragmentParamSizeCost = (shader.fragment.paramsSize << 2);
+
+			// 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 ) {
 				vertexParamsCBV = true;
-				total -= (shader.vertex.paramsSize << 2);
+				total = withoutVP;
 			}
 			if( total > 64 ) {
 				fragmentParamsCBV = true;
-				total -= (shader.fragment.paramsSize << 2);
+				total = total - fragmentParamSizeCost + 1;
 			}
 			if( total > 64 )
 				throw "Too many globals";