@plasius/gpu-shader 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -2
- package/dist/cli.cjs +539 -143
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +539 -143
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +738 -218
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -4
- package/dist/index.d.ts +13 -4
- package/dist/index.js +737 -218
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +329 -86
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +329 -86
- package/dist/node.js.map +1 -1
- package/dist/testing.cjs +436 -115
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +436 -115
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
package/dist/node.cjs
CHANGED
|
@@ -5796,63 +5796,217 @@ var cn;
|
|
|
5796
5796
|
var ln = { [cn.ExpensiveBuiltinInLoop]: "expensive-builtin-in-loop", [cn.CostlyArithmeticInLoop]: "costly-arithmetic-in-loop", [cn.LoopInvariantExpression]: "loop-invariant-expression", [cn.AtomicInLoop]: "atomic-in-loop", [cn.BarrierInLoop]: "barrier-in-loop", [cn.AtomicStorageRead]: "atomic-storage-read", [cn.WorkgroupArrayThreadPrivate]: "workgroup-array-thread-private", [cn.WorkgroupStorageOversized]: "workgroup-storage-oversized", [cn.SerialScanEmulation]: "serial-scan-emulation" };
|
|
5797
5797
|
|
|
5798
5798
|
// src/canonical-json.ts
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5799
|
+
var GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
5800
|
+
maximumDepth: 64,
|
|
5801
|
+
maximumNodes: 262144,
|
|
5802
|
+
maximumProperties: 131072,
|
|
5803
|
+
maximumElements: 131072,
|
|
5804
|
+
maximumArrayLength: 1e5,
|
|
5805
|
+
maximumStringBytes: 1024 * 1024,
|
|
5806
|
+
maximumAggregateStringBytes: 8 * 1024 * 1024,
|
|
5807
|
+
maximumAggregateBytes: 16 * 1024 * 1024,
|
|
5808
|
+
maximumInputBytes: 16 * 1024 * 1024
|
|
5809
|
+
});
|
|
5810
|
+
var QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
5811
|
+
maximumDepth: 96,
|
|
5812
|
+
maximumNodes: 4e6,
|
|
5813
|
+
maximumProperties: 2e6,
|
|
5814
|
+
maximumElements: 2e6,
|
|
5815
|
+
maximumArrayLength: 25e4,
|
|
5816
|
+
maximumStringBytes: 4 * 1024 * 1024,
|
|
5817
|
+
maximumAggregateStringBytes: 128 * 1024 * 1024,
|
|
5818
|
+
maximumAggregateBytes: 256 * 1024 * 1024,
|
|
5819
|
+
maximumInputBytes: 256 * 1024 * 1024
|
|
5820
|
+
});
|
|
5821
|
+
var FAILURE_MESSAGES = Object.freeze({
|
|
5822
|
+
"aggregate-bytes": "GPU contract snapshot exceeds the aggregate byte limit.",
|
|
5823
|
+
"aggregate-string-bytes": "GPU contract snapshot exceeds the aggregate string byte limit.",
|
|
5824
|
+
"array-length": "GPU contract snapshot exceeds the single-array element limit.",
|
|
5825
|
+
cycle: "GPU contract snapshot contains a circular reference.",
|
|
5826
|
+
depth: "GPU contract snapshot exceeds the nesting-depth limit.",
|
|
5827
|
+
elements: "GPU contract snapshot exceeds the total element limit.",
|
|
5828
|
+
inspection: "GPU contract snapshot rejected unsafe object inspection.",
|
|
5829
|
+
nodes: "GPU contract snapshot exceeds the total node limit.",
|
|
5830
|
+
"non-finite": "GPU contract snapshot contains a non-finite number.",
|
|
5831
|
+
properties: "GPU contract snapshot exceeds the total property limit.",
|
|
5832
|
+
shape: "GPU contract snapshot requires plain JSON objects with own enumerable data properties and dense arrays.",
|
|
5833
|
+
"string-bytes": "GPU contract snapshot exceeds the individual string byte limit.",
|
|
5834
|
+
unicode: "GPU contract snapshot contains an invalid Unicode scalar string or unpaired UTF-16 surrogate.",
|
|
5835
|
+
value: "GPU contract snapshot contains undefined or another value that JSON cannot represent."
|
|
5836
|
+
});
|
|
5837
|
+
var GpuContractSnapshotError = class extends TypeError {
|
|
5838
|
+
code;
|
|
5839
|
+
constructor(code) {
|
|
5840
|
+
super(FAILURE_MESSAGES[code]);
|
|
5841
|
+
this.name = "GpuContractSnapshotError";
|
|
5842
|
+
this.code = code;
|
|
5843
|
+
}
|
|
5844
|
+
};
|
|
5845
|
+
var TYPED_ARRAY_PROTOTYPE = Reflect.getPrototypeOf(Uint8Array.prototype);
|
|
5846
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
5847
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
5848
|
+
"byteLength"
|
|
5849
|
+
)?.get;
|
|
5850
|
+
var TYPED_ARRAY_TAG = Reflect.getOwnPropertyDescriptor(
|
|
5851
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
5852
|
+
Symbol.toStringTag
|
|
5853
|
+
)?.get;
|
|
5854
|
+
var UINT8_ARRAY_SET = Uint8Array.prototype.set;
|
|
5855
|
+
function fail(reason) {
|
|
5856
|
+
throw new GpuContractSnapshotError(reason);
|
|
5857
|
+
}
|
|
5858
|
+
function inspected(operation) {
|
|
5859
|
+
try {
|
|
5860
|
+
return operation();
|
|
5861
|
+
} catch {
|
|
5862
|
+
return fail("inspection");
|
|
5863
|
+
}
|
|
5802
5864
|
}
|
|
5803
|
-
function
|
|
5865
|
+
function assertLimit(value, maximum, reason) {
|
|
5866
|
+
if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
|
|
5867
|
+
}
|
|
5868
|
+
function quotedJsonByteLength(value, maximum) {
|
|
5869
|
+
let raw = 0;
|
|
5870
|
+
let quoted = 2;
|
|
5804
5871
|
for (let index = 0; index < value.length; index += 1) {
|
|
5805
5872
|
const code = value.charCodeAt(index);
|
|
5806
|
-
if (code
|
|
5873
|
+
if (code <= 127) {
|
|
5874
|
+
raw += 1;
|
|
5875
|
+
if (code <= 31) quoted += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
|
|
5876
|
+
else quoted += code === 34 || code === 92 ? 2 : 1;
|
|
5877
|
+
} else if (code <= 2047) {
|
|
5878
|
+
raw += 2;
|
|
5879
|
+
quoted += 2;
|
|
5880
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
5807
5881
|
const next = value.charCodeAt(index + 1);
|
|
5808
|
-
if (!(next >= 56320 && next <= 57343))
|
|
5882
|
+
if (!(next >= 56320 && next <= 57343)) fail("unicode");
|
|
5883
|
+
raw += 4;
|
|
5884
|
+
quoted += 4;
|
|
5809
5885
|
index += 1;
|
|
5810
|
-
} else if (code >= 56320 && code <= 57343)
|
|
5886
|
+
} else if (code >= 56320 && code <= 57343) fail("unicode");
|
|
5887
|
+
else {
|
|
5888
|
+
raw += 3;
|
|
5889
|
+
quoted += 3;
|
|
5890
|
+
}
|
|
5891
|
+
if (raw > maximum) fail("string-bytes");
|
|
5811
5892
|
}
|
|
5893
|
+
return { raw, quoted };
|
|
5812
5894
|
}
|
|
5813
|
-
function
|
|
5895
|
+
function assertLimits(limits) {
|
|
5896
|
+
for (const value of Object.values(limits)) {
|
|
5897
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("GPU contract snapshot limits must be positive safe integers.");
|
|
5898
|
+
}
|
|
5899
|
+
}
|
|
5900
|
+
function snapshotGpuContract(value, limits = GPU_CONTRACT_SNAPSHOT_LIMITS) {
|
|
5901
|
+
assertLimits(limits);
|
|
5814
5902
|
const ancestors = /* @__PURE__ */ new Set();
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5903
|
+
let nodes = 0;
|
|
5904
|
+
let properties = 0;
|
|
5905
|
+
let elements = 0;
|
|
5906
|
+
let aggregateStringBytes = 0;
|
|
5907
|
+
let aggregateBytes = 0;
|
|
5908
|
+
const addAggregate = (bytes) => {
|
|
5909
|
+
aggregateBytes += bytes;
|
|
5910
|
+
assertLimit(aggregateBytes, limits.maximumAggregateBytes, "aggregate-bytes");
|
|
5911
|
+
};
|
|
5912
|
+
const addString = (text2) => {
|
|
5913
|
+
const measured = quotedJsonByteLength(text2, limits.maximumStringBytes);
|
|
5914
|
+
aggregateStringBytes += measured.raw;
|
|
5915
|
+
assertLimit(aggregateStringBytes, limits.maximumAggregateStringBytes, "aggregate-string-bytes");
|
|
5916
|
+
return measured.quoted;
|
|
5917
|
+
};
|
|
5918
|
+
const visit = (current, depth) => {
|
|
5919
|
+
if (depth > limits.maximumDepth) fail("depth");
|
|
5920
|
+
nodes += 1;
|
|
5921
|
+
assertLimit(nodes, limits.maximumNodes, "nodes");
|
|
5922
|
+
if (current === null) {
|
|
5923
|
+
addAggregate(4);
|
|
5924
|
+
return null;
|
|
5925
|
+
}
|
|
5926
|
+
if (typeof current === "string") {
|
|
5927
|
+
addAggregate(addString(current));
|
|
5928
|
+
return current;
|
|
5929
|
+
}
|
|
5930
|
+
if (typeof current === "boolean") {
|
|
5931
|
+
addAggregate(current ? 4 : 5);
|
|
5932
|
+
return current;
|
|
5820
5933
|
}
|
|
5821
5934
|
if (typeof current === "number") {
|
|
5822
|
-
if (!Number.isFinite(current))
|
|
5823
|
-
|
|
5824
|
-
|
|
5825
|
-
return
|
|
5826
|
-
}
|
|
5827
|
-
if (typeof current !== "object")
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
}
|
|
5935
|
+
if (!Number.isFinite(current)) fail("non-finite");
|
|
5936
|
+
const normalized = Object.is(current, -0) ? 0 : current;
|
|
5937
|
+
addAggregate(JSON.stringify(normalized).length);
|
|
5938
|
+
return normalized;
|
|
5939
|
+
}
|
|
5940
|
+
if (typeof current !== "object") fail("value");
|
|
5941
|
+
if (ancestors.has(current)) fail("cycle");
|
|
5942
|
+
const isArray = inspected(() => Array.isArray(current));
|
|
5943
|
+
const prototype = inspected(() => Reflect.getPrototypeOf(current));
|
|
5944
|
+
if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail("shape");
|
|
5833
5945
|
ancestors.add(current);
|
|
5834
5946
|
try {
|
|
5835
|
-
if (
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5842
|
-
|
|
5843
|
-
|
|
5844
|
-
|
|
5845
|
-
|
|
5846
|
-
|
|
5947
|
+
if (isArray) {
|
|
5948
|
+
const lengthDescriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, "length"));
|
|
5949
|
+
if (!lengthDescriptor || !Object.hasOwn(lengthDescriptor, "value") || lengthDescriptor.enumerable || typeof lengthDescriptor.value !== "number" || !Number.isSafeInteger(lengthDescriptor.value) || lengthDescriptor.value < 0) fail("shape");
|
|
5950
|
+
const length = lengthDescriptor.value;
|
|
5951
|
+
assertLimit(length, limits.maximumArrayLength, "array-length");
|
|
5952
|
+
elements += length;
|
|
5953
|
+
assertLimit(elements, limits.maximumElements, "elements");
|
|
5954
|
+
const ownKeys2 = inspected(() => Reflect.ownKeys(current));
|
|
5955
|
+
if (ownKeys2.some((key) => typeof key !== "string")) fail("shape");
|
|
5956
|
+
if (ownKeys2.length !== length + 1) fail("shape");
|
|
5957
|
+
const keySet = new Set(ownKeys2);
|
|
5958
|
+
if (!keySet.delete("length")) fail("shape");
|
|
5959
|
+
const output2 = new Array(length);
|
|
5960
|
+
addAggregate(2 + Math.max(0, length - 1));
|
|
5961
|
+
for (let index = 0; index < length; index += 1) {
|
|
5962
|
+
const key = String(index);
|
|
5963
|
+
if (!keySet.delete(key)) fail("shape");
|
|
5964
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
5965
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
5966
|
+
Object.defineProperty(output2, key, {
|
|
5967
|
+
configurable: true,
|
|
5968
|
+
enumerable: true,
|
|
5969
|
+
value: visit(descriptor.value, depth + 1),
|
|
5970
|
+
writable: true
|
|
5971
|
+
});
|
|
5847
5972
|
}
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
|
|
5973
|
+
if (keySet.size !== 0) fail("shape");
|
|
5974
|
+
return output2;
|
|
5975
|
+
}
|
|
5976
|
+
const ownKeys = inspected(() => Reflect.ownKeys(current));
|
|
5977
|
+
if (ownKeys.some((key) => typeof key !== "string")) fail("shape");
|
|
5978
|
+
properties += ownKeys.length;
|
|
5979
|
+
assertLimit(properties, limits.maximumProperties, "properties");
|
|
5980
|
+
addAggregate(2 + Math.max(0, ownKeys.length - 1) + ownKeys.length);
|
|
5981
|
+
const output = {};
|
|
5982
|
+
for (const key of ownKeys) {
|
|
5983
|
+
addAggregate(addString(key));
|
|
5984
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
5985
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
5986
|
+
Object.defineProperty(output, key, {
|
|
5987
|
+
configurable: true,
|
|
5988
|
+
enumerable: true,
|
|
5989
|
+
value: visit(descriptor.value, depth + 1),
|
|
5990
|
+
writable: true
|
|
5991
|
+
});
|
|
5992
|
+
}
|
|
5993
|
+
return output;
|
|
5851
5994
|
} finally {
|
|
5852
5995
|
ancestors.delete(current);
|
|
5853
5996
|
}
|
|
5854
5997
|
};
|
|
5855
|
-
return visit(value,
|
|
5998
|
+
return visit(value, 0);
|
|
5999
|
+
}
|
|
6000
|
+
function serializeSnapshot(value) {
|
|
6001
|
+
if (value === null) return "null";
|
|
6002
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
6003
|
+
if (typeof value === "number") return JSON.stringify(value);
|
|
6004
|
+
if (Array.isArray(value)) return `[${value.map(serializeSnapshot).join(",")}]`;
|
|
6005
|
+
const input = value;
|
|
6006
|
+
return `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serializeSnapshot(input[key])}`).join(",")}}`;
|
|
6007
|
+
}
|
|
6008
|
+
function canonicalizeGpuContract(value) {
|
|
6009
|
+
return serializeSnapshot(snapshotGpuContract(value));
|
|
5856
6010
|
}
|
|
5857
6011
|
|
|
5858
6012
|
// src/contracts.ts
|
|
@@ -5950,39 +6104,41 @@ function modelProjection(manifest) {
|
|
|
5950
6104
|
};
|
|
5951
6105
|
}
|
|
5952
6106
|
async function computeGpuAbiHash(input) {
|
|
5953
|
-
|
|
6107
|
+
const snapshot = snapshotGpuContract(input);
|
|
6108
|
+
if (snapshot.kind === "model") {
|
|
5954
6109
|
return computeSha256(
|
|
5955
6110
|
`plasius.gpu.model-abi/v1
|
|
5956
|
-
${canonicalizeGpuContract(modelProjection(
|
|
6111
|
+
${canonicalizeGpuContract(modelProjection(snapshot.interface))}`
|
|
5957
6112
|
);
|
|
5958
6113
|
}
|
|
5959
|
-
if (
|
|
6114
|
+
if (snapshot.kind === "interface") {
|
|
5960
6115
|
return computeSha256(
|
|
5961
6116
|
`plasius.gpu.interface-abi/v1
|
|
5962
|
-
${canonicalizeGpuContract(interfaceProjection(
|
|
6117
|
+
${canonicalizeGpuContract(interfaceProjection(snapshot.interface))}`
|
|
5963
6118
|
);
|
|
5964
6119
|
}
|
|
5965
6120
|
const pipelines = sorted(
|
|
5966
|
-
|
|
6121
|
+
snapshot.pipelines,
|
|
5967
6122
|
(left, right) => compareString(left.pipelineId, right.pipelineId)
|
|
5968
6123
|
);
|
|
5969
6124
|
const requirements = {
|
|
5970
|
-
semantics: [...
|
|
5971
|
-
features: [...
|
|
5972
|
-
limits: sorted(
|
|
5973
|
-
formats: [...
|
|
6125
|
+
semantics: [...snapshot.requirements.semantics].sort(),
|
|
6126
|
+
features: [...snapshot.requirements.features].sort(),
|
|
6127
|
+
limits: sorted(snapshot.requirements.limits, (left, right) => compareString(left.name, right.name)),
|
|
6128
|
+
formats: [...snapshot.requirements.formats].sort()
|
|
5974
6129
|
};
|
|
5975
6130
|
return computeSha256(
|
|
5976
6131
|
`plasius.gpu.shader-abi/v1
|
|
5977
6132
|
${canonicalizeGpuContract({
|
|
5978
|
-
interface: interfaceProjection(
|
|
6133
|
+
interface: interfaceProjection(snapshot.interface),
|
|
5979
6134
|
pipelines,
|
|
5980
6135
|
requirements
|
|
5981
6136
|
})}`
|
|
5982
6137
|
);
|
|
5983
6138
|
}
|
|
5984
6139
|
async function computeShaderManifestCoreSha256(manifest) {
|
|
5985
|
-
const
|
|
6140
|
+
const snapshot = snapshotGpuContract(manifest);
|
|
6141
|
+
const core = Object.fromEntries(Object.entries(snapshot).filter(
|
|
5986
6142
|
([key]) => key !== "validationEvidence" && key !== "additionalValidationEvidence"
|
|
5987
6143
|
));
|
|
5988
6144
|
return computeSha256(
|
|
@@ -5991,6 +6147,29 @@ ${canonicalizeGpuContract(core)}`
|
|
|
5991
6147
|
);
|
|
5992
6148
|
}
|
|
5993
6149
|
|
|
6150
|
+
// src/asset-version.ts
|
|
6151
|
+
var ASSET_VERSION_PATTERN = /^[0-9A-Za-z][0-9A-Za-z._-]{0,127}$/u;
|
|
6152
|
+
var MUTABLE_VERSION_ALIASES = /* @__PURE__ */ new Set([
|
|
6153
|
+
"latest",
|
|
6154
|
+
"current",
|
|
6155
|
+
"stable",
|
|
6156
|
+
"preview",
|
|
6157
|
+
"default",
|
|
6158
|
+
"production",
|
|
6159
|
+
"canary",
|
|
6160
|
+
"next",
|
|
6161
|
+
"head",
|
|
6162
|
+
"main"
|
|
6163
|
+
]);
|
|
6164
|
+
var X_WILDCARD_SEGMENT_PATTERN = /^(?:[vV])?[xX](?:\.|-|$)|\.[xX](?:\.|-|$)/u;
|
|
6165
|
+
var IMMUTABLE_VERSION_ERROR_MESSAGE = "Immutable asset version must be an exact token up to 128 characters; mutable aliases, ranges, wildcards, and URLs are not allowed.";
|
|
6166
|
+
function assertImmutableAssetVersion(value) {
|
|
6167
|
+
if (typeof value !== "string" || !ASSET_VERSION_PATTERN.test(value) || MUTABLE_VERSION_ALIASES.has(value.toLowerCase()) || X_WILDCARD_SEGMENT_PATTERN.test(value)) {
|
|
6168
|
+
throw new TypeError(IMMUTABLE_VERSION_ERROR_MESSAGE);
|
|
6169
|
+
}
|
|
6170
|
+
return value;
|
|
6171
|
+
}
|
|
6172
|
+
|
|
5994
6173
|
// src/requirements-validation.ts
|
|
5995
6174
|
var ENABLED_FEATURES = Object.freeze({
|
|
5996
6175
|
f16: "shader-f16",
|
|
@@ -6318,6 +6497,14 @@ function validateShaderDerivedRequirements(input) {
|
|
|
6318
6497
|
// src/manifest-validation.ts
|
|
6319
6498
|
var stages = ["vertex", "fragment", "compute"];
|
|
6320
6499
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
6500
|
+
function detachedJson(value, path2) {
|
|
6501
|
+
try {
|
|
6502
|
+
return snapshotGpuContract(value);
|
|
6503
|
+
} catch (cause) {
|
|
6504
|
+
const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
|
|
6505
|
+
throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
|
|
6506
|
+
}
|
|
6507
|
+
}
|
|
6321
6508
|
function object(value, path2) {
|
|
6322
6509
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
6323
6510
|
return value;
|
|
@@ -6325,7 +6512,7 @@ function object(value, path2) {
|
|
|
6325
6512
|
function exact(value, keys, path2) {
|
|
6326
6513
|
const allowed = new Set(keys);
|
|
6327
6514
|
for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
|
|
6328
|
-
for (const key of keys) if (!(key
|
|
6515
|
+
for (const key of keys) if (!Object.hasOwn(value, key)) throw new TypeError(`${path2}.${key} is required.`);
|
|
6329
6516
|
}
|
|
6330
6517
|
function text(value, path2, maximum = 512) {
|
|
6331
6518
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
|
|
@@ -6338,6 +6525,13 @@ function token(value, path2) {
|
|
|
6338
6525
|
if (!/^[A-Za-z0-9][A-Za-z0-9._:/-]*$/u.test(result) || result.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
6339
6526
|
return result;
|
|
6340
6527
|
}
|
|
6528
|
+
function immutableVersion(value, path2) {
|
|
6529
|
+
try {
|
|
6530
|
+
return assertImmutableAssetVersion(value);
|
|
6531
|
+
} catch {
|
|
6532
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
6533
|
+
}
|
|
6534
|
+
}
|
|
6341
6535
|
function enumeration(value, values, path2) {
|
|
6342
6536
|
if (!values.includes(value)) throw new TypeError(`${path2} is invalid.`);
|
|
6343
6537
|
return value;
|
|
@@ -6365,8 +6559,8 @@ function nullableToken(value, path2) {
|
|
|
6365
6559
|
function digest(value, path2) {
|
|
6366
6560
|
try {
|
|
6367
6561
|
return asSha256Hex(text(value, path2, 64));
|
|
6368
|
-
} catch
|
|
6369
|
-
throw new TypeError(`${path2} must be a lowercase SHA-256 digest
|
|
6562
|
+
} catch {
|
|
6563
|
+
throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`);
|
|
6370
6564
|
}
|
|
6371
6565
|
}
|
|
6372
6566
|
function uri(value, path2) {
|
|
@@ -6374,8 +6568,8 @@ function uri(value, path2) {
|
|
|
6374
6568
|
let parsed;
|
|
6375
6569
|
try {
|
|
6376
6570
|
parsed = new URL(result);
|
|
6377
|
-
} catch
|
|
6378
|
-
throw new TypeError(`${path2} must be an absolute immutable asset URI
|
|
6571
|
+
} catch {
|
|
6572
|
+
throw new TypeError(`${path2} must be an absolute immutable asset URI.`);
|
|
6379
6573
|
}
|
|
6380
6574
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
|
|
6381
6575
|
const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
|
|
@@ -6611,7 +6805,7 @@ function interfaceRef(value, path2) {
|
|
|
6611
6805
|
const input = object(value, path2);
|
|
6612
6806
|
exact(input, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path2);
|
|
6613
6807
|
token(input.interfaceId, `${path2}.interfaceId`);
|
|
6614
|
-
|
|
6808
|
+
immutableVersion(input.interfaceVersion, `${path2}.interfaceVersion`);
|
|
6615
6809
|
uri(input.manifestUri, `${path2}.manifestUri`);
|
|
6616
6810
|
digest(input.manifestSha256, `${path2}.manifestSha256`);
|
|
6617
6811
|
digest(input.interfaceAbiHash, `${path2}.interfaceAbiHash`);
|
|
@@ -6749,7 +6943,7 @@ function pipeline(value, path2, moduleIds) {
|
|
|
6749
6943
|
return input;
|
|
6750
6944
|
}
|
|
6751
6945
|
function parseSerializableGpuPipelineDescriptors(value, moduleIds, path2 = "pipelines") {
|
|
6752
|
-
const parsed = array(value, path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
6946
|
+
const parsed = array(detachedJson(value, path2), path2).map((item, index) => pipeline(item, `${path2}[${index}]`, new Set(moduleIds)));
|
|
6753
6947
|
unique(parsed, (item) => item.pipelineId, path2);
|
|
6754
6948
|
return freeze(parsed);
|
|
6755
6949
|
}
|
|
@@ -6757,7 +6951,7 @@ function compatibleModel(value, path2) {
|
|
|
6757
6951
|
const input = object(value, path2);
|
|
6758
6952
|
exact(input, ["interfaceId", "interfaceVersion", "manifestSha256", "interfaceAbiHash", "modelAbiHash"], path2);
|
|
6759
6953
|
token(input.interfaceId, `${path2}.interfaceId`);
|
|
6760
|
-
|
|
6954
|
+
immutableVersion(input.interfaceVersion, `${path2}.interfaceVersion`);
|
|
6761
6955
|
digest(input.manifestSha256, `${path2}.manifestSha256`);
|
|
6762
6956
|
digest(input.interfaceAbiHash, `${path2}.interfaceAbiHash`);
|
|
6763
6957
|
digest(input.modelAbiHash, `${path2}.modelAbiHash`);
|
|
@@ -6770,7 +6964,7 @@ function validationEvidenceRef(value, path2) {
|
|
|
6770
6964
|
uri(evidence.uri, `${path2}.uri`);
|
|
6771
6965
|
digest(evidence.sha256, `${path2}.sha256`);
|
|
6772
6966
|
token(evidence.matrixId, `${path2}.matrixId`);
|
|
6773
|
-
|
|
6967
|
+
immutableVersion(evidence.matrixVersion, `${path2}.matrixVersion`);
|
|
6774
6968
|
digest(evidence.matrixSha256, `${path2}.matrixSha256`);
|
|
6775
6969
|
const attestation = object(evidence.attestationRef, `${path2}.attestationRef`);
|
|
6776
6970
|
exact(attestation, ["uri", "sha256"], `${path2}.attestationRef`);
|
|
@@ -6797,11 +6991,11 @@ function reflectedRecordBindingSize(record) {
|
|
|
6797
6991
|
return Math.ceil(unrounded / record.alignment) * record.alignment;
|
|
6798
6992
|
}
|
|
6799
6993
|
function parseGpuInterfaceManifest(value) {
|
|
6800
|
-
const input = object(value, "GpuInterfaceManifest");
|
|
6994
|
+
const input = object(detachedJson(value, "GpuInterfaceManifest"), "GpuInterfaceManifest");
|
|
6801
6995
|
exact(input, ["contractVersion", "interfaceId", "interfaceVersion", "modules", "records", "bindings", "entryPoints", "vertexInputs", "overrides", "modelAbi", "modelAbiHash", "interfaceAbiHash", "generatedBy"], "GpuInterfaceManifest");
|
|
6802
6996
|
if (input.contractVersion !== GPU_INTERFACE_MANIFEST_VERSION) throw new TypeError("Unsupported GPU interface contract version.");
|
|
6803
6997
|
token(input.interfaceId, "GpuInterfaceManifest.interfaceId");
|
|
6804
|
-
|
|
6998
|
+
immutableVersion(input.interfaceVersion, "GpuInterfaceManifest.interfaceVersion");
|
|
6805
6999
|
const moduleValues = array(input.modules, "GpuInterfaceManifest.modules");
|
|
6806
7000
|
if (moduleValues.length === 0) throw new TypeError("GpuInterfaceManifest.modules must not be empty.");
|
|
6807
7001
|
const moduleIds = moduleValues.map((value2, index) => {
|
|
@@ -6983,11 +7177,11 @@ function parseGpuInterfaceManifest(value) {
|
|
|
6983
7177
|
return freeze(input);
|
|
6984
7178
|
}
|
|
6985
7179
|
function parseShaderVersionManifest(value) {
|
|
6986
|
-
const input = object(value, "ShaderVersionManifest");
|
|
7180
|
+
const input = object(detachedJson(value, "ShaderVersionManifest"), "ShaderVersionManifest");
|
|
6987
7181
|
exact(input, ["contractVersion", "shaderId", "version", "modules", "gpuInterface", "pipelines", "renderRoles", "compatibleModelInterfaces", "requirements", "shaderAbiHash", "validationEvidence", "additionalValidationEvidence"], "ShaderVersionManifest");
|
|
6988
7182
|
if (input.contractVersion !== SHADER_VERSION_MANIFEST_VERSION) throw new TypeError("Unsupported shader manifest contract version.");
|
|
6989
7183
|
token(input.shaderId, "ShaderVersionManifest.shaderId");
|
|
6990
|
-
|
|
7184
|
+
immutableVersion(input.version, "ShaderVersionManifest.version");
|
|
6991
7185
|
const moduleValues = array(input.modules, "ShaderVersionManifest.modules");
|
|
6992
7186
|
if (moduleValues.length === 0) throw new TypeError("ShaderVersionManifest.modules must not be empty.");
|
|
6993
7187
|
const moduleIds = moduleValues.map((item, index) => {
|
|
@@ -7100,7 +7294,7 @@ function parseShaderVersionManifest(value) {
|
|
|
7100
7294
|
return freeze(input);
|
|
7101
7295
|
}
|
|
7102
7296
|
function parseShaderVersionManifestCore(value) {
|
|
7103
|
-
const input = object(value, "ShaderVersionManifestCore");
|
|
7297
|
+
const input = object(detachedJson(value, "ShaderVersionManifestCore"), "ShaderVersionManifestCore");
|
|
7104
7298
|
if ("validationEvidence" in input || "additionalValidationEvidence" in input) {
|
|
7105
7299
|
throw new TypeError("ShaderVersionManifestCore must not contain validationEvidence or additionalValidationEvidence.");
|
|
7106
7300
|
}
|
|
@@ -7126,10 +7320,10 @@ function parseShaderVersionManifestCore(value) {
|
|
|
7126
7320
|
return freeze(core);
|
|
7127
7321
|
}
|
|
7128
7322
|
function parseModelGpuCompatibilityDescriptor(value) {
|
|
7129
|
-
const input = object(value, "ModelGpuCompatibilityDescriptor");
|
|
7323
|
+
const input = object(detachedJson(value, "ModelGpuCompatibilityDescriptor"), "ModelGpuCompatibilityDescriptor");
|
|
7130
7324
|
exact(input, ["modelId", "version", "gpuInterface", "modelAbiHash", "providedSemantics", "defaultStyleProfile"], "ModelGpuCompatibilityDescriptor");
|
|
7131
7325
|
token(input.modelId, "ModelGpuCompatibilityDescriptor.modelId");
|
|
7132
|
-
|
|
7326
|
+
immutableVersion(input.version, "ModelGpuCompatibilityDescriptor.version");
|
|
7133
7327
|
const gpuInterface = interfaceRef(input.gpuInterface, "ModelGpuCompatibilityDescriptor.gpuInterface");
|
|
7134
7328
|
const modelAbiHash = digest(input.modelAbiHash, "ModelGpuCompatibilityDescriptor.modelAbiHash");
|
|
7135
7329
|
if (gpuInterface.modelAbiHash !== modelAbiHash) throw new TypeError("ModelGpuCompatibilityDescriptor.gpuInterface.modelAbiHash differs from modelAbiHash.");
|
|
@@ -7138,14 +7332,17 @@ function parseModelGpuCompatibilityDescriptor(value) {
|
|
|
7138
7332
|
const profile = object(input.defaultStyleProfile, "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
|
|
7139
7333
|
exact(profile, ["profileId", "version", "manifestUri", "manifestSha256"], "ModelGpuCompatibilityDescriptor.defaultStyleProfile");
|
|
7140
7334
|
token(profile.profileId, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.profileId");
|
|
7141
|
-
|
|
7335
|
+
immutableVersion(profile.version, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.version");
|
|
7142
7336
|
uri(profile.manifestUri, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestUri");
|
|
7143
7337
|
digest(profile.manifestSha256, "ModelGpuCompatibilityDescriptor.defaultStyleProfile.manifestSha256");
|
|
7144
7338
|
}
|
|
7145
7339
|
return freeze(input);
|
|
7146
7340
|
}
|
|
7147
7341
|
function parseShaderQualificationModelCompatibilityFixture(value) {
|
|
7148
|
-
const input = object(
|
|
7342
|
+
const input = object(
|
|
7343
|
+
detachedJson(value, "ShaderQualificationModelCompatibilityFixture"),
|
|
7344
|
+
"ShaderQualificationModelCompatibilityFixture"
|
|
7345
|
+
);
|
|
7149
7346
|
exact(input, ["contractVersion", "fixtureId", "model"], "ShaderQualificationModelCompatibilityFixture");
|
|
7150
7347
|
if (input.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported model compatibility fixture version.");
|
|
7151
7348
|
token(input.fixtureId, "ShaderQualificationModelCompatibilityFixture.fixtureId");
|
|
@@ -7510,7 +7707,7 @@ function validatePipelineInterfaces(input) {
|
|
|
7510
7707
|
// package.json
|
|
7511
7708
|
var package_default = {
|
|
7512
7709
|
name: "@plasius/gpu-shader",
|
|
7513
|
-
version: "0.1.
|
|
7710
|
+
version: "0.1.3",
|
|
7514
7711
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
7515
7712
|
type: "module",
|
|
7516
7713
|
sideEffects: false,
|
|
@@ -7602,6 +7799,7 @@ var package_default = {
|
|
|
7602
7799
|
access: "public"
|
|
7603
7800
|
},
|
|
7604
7801
|
overrides: {
|
|
7802
|
+
esbuild: "^0.28.1",
|
|
7605
7803
|
minimatch: "^10.2.1"
|
|
7606
7804
|
},
|
|
7607
7805
|
engines: {
|
|
@@ -8962,13 +9160,26 @@ function issue2(code, message, path2) {
|
|
|
8962
9160
|
function object2(value) {
|
|
8963
9161
|
return typeof value === "object" && value !== null && !Array.isArray(value) ? value : null;
|
|
8964
9162
|
}
|
|
9163
|
+
function freezeJson(value) {
|
|
9164
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
9165
|
+
for (const child of Object.values(value)) freezeJson(child);
|
|
9166
|
+
return Object.freeze(value);
|
|
9167
|
+
}
|
|
8965
9168
|
function exactKeys(value, keys) {
|
|
8966
9169
|
const expected = new Set(keys);
|
|
8967
|
-
return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => key
|
|
9170
|
+
return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => Object.hasOwn(value, key));
|
|
8968
9171
|
}
|
|
8969
9172
|
function safeToken(value) {
|
|
8970
9173
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
8971
9174
|
}
|
|
9175
|
+
function immutableVersion2(value) {
|
|
9176
|
+
try {
|
|
9177
|
+
assertImmutableAssetVersion(value);
|
|
9178
|
+
return true;
|
|
9179
|
+
} catch {
|
|
9180
|
+
return false;
|
|
9181
|
+
}
|
|
9182
|
+
}
|
|
8972
9183
|
function validSha(value) {
|
|
8973
9184
|
try {
|
|
8974
9185
|
asSha256Hex(String(value));
|
|
@@ -8978,8 +9189,20 @@ function validSha(value) {
|
|
|
8978
9189
|
}
|
|
8979
9190
|
}
|
|
8980
9191
|
function validateCompileUnitInventory(value) {
|
|
8981
|
-
|
|
8982
|
-
|
|
9192
|
+
let snapshot;
|
|
9193
|
+
try {
|
|
9194
|
+
snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9195
|
+
} catch {
|
|
9196
|
+
return {
|
|
9197
|
+
ok: false,
|
|
9198
|
+
diagnostics: [issue2(
|
|
9199
|
+
"invalid-contract",
|
|
9200
|
+
"Compile-unit inventory must contain bounded detached JSON contract data."
|
|
9201
|
+
)]
|
|
9202
|
+
};
|
|
9203
|
+
}
|
|
9204
|
+
const envelope = object2(snapshot);
|
|
9205
|
+
const candidate = envelope && Object.hasOwn(envelope, "inventory") ? object2(snapshot.inventory) : envelope;
|
|
8983
9206
|
const diagnostics = [];
|
|
8984
9207
|
if (!candidate || !exactKeys(candidate, ["contractVersion", "fragments", "compileUnits"])) {
|
|
8985
9208
|
return { ok: false, diagnostics: [issue2("invalid-contract", "Compile-unit inventory has unknown or missing fields.")] };
|
|
@@ -9110,7 +9333,7 @@ function validateCompileUnitInventory(value) {
|
|
|
9110
9333
|
diagnostics.push(issue2("invalid-contract", cause instanceof Error ? cause.message : "Compile-unit pipelines are invalid.", `${path2}.pipelines`));
|
|
9111
9334
|
}
|
|
9112
9335
|
const interfaceRef2 = object2(unit.interfaceRef);
|
|
9113
|
-
if (!interfaceRef2 || !exactKeys(interfaceRef2, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef2.interfaceId) || !
|
|
9336
|
+
if (!interfaceRef2 || !exactKeys(interfaceRef2, ["interfaceId", "interfaceVersion", "manifestUri", "manifestSha256", "interfaceAbiHash", "modelAbiHash"]) || !safeToken(interfaceRef2.interfaceId) || !immutableVersion2(interfaceRef2.interfaceVersion) || typeof interfaceRef2.manifestUri !== "string" || !interfaceRef2.manifestUri.startsWith("https://") || !validSha(interfaceRef2.manifestSha256) || !validSha(interfaceRef2.interfaceAbiHash) || !validSha(interfaceRef2.modelAbiHash)) {
|
|
9114
9337
|
diagnostics.push(issue2("invalid-contract", "Compile-unit interfaceRef is invalid.", `${path2}.interfaceRef`));
|
|
9115
9338
|
}
|
|
9116
9339
|
const fixture = object2(unit.qualificationFixture);
|
|
@@ -9121,7 +9344,7 @@ function validateCompileUnitInventory(value) {
|
|
|
9121
9344
|
for (const fragmentId of fragmentIds) {
|
|
9122
9345
|
if (!covered.has(fragmentId)) diagnostics.push(issue2("uncovered-fragment", `WGSL fragment ${fragmentId} has no compile unit.`));
|
|
9123
9346
|
}
|
|
9124
|
-
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: candidate };
|
|
9347
|
+
return diagnostics.length > 0 ? { ok: false, diagnostics } : { ok: true, value: freezeJson(candidate) };
|
|
9125
9348
|
}
|
|
9126
9349
|
|
|
9127
9350
|
// src/testing/qualification-bundle.ts
|
|
@@ -9213,14 +9436,33 @@ function object3(value, path2) {
|
|
|
9213
9436
|
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new TypeError(`${path2} must be an object.`);
|
|
9214
9437
|
return value;
|
|
9215
9438
|
}
|
|
9439
|
+
function detachedJson2(value, label) {
|
|
9440
|
+
try {
|
|
9441
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9442
|
+
} catch {
|
|
9443
|
+
throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
|
|
9444
|
+
}
|
|
9445
|
+
}
|
|
9446
|
+
function freezeJson2(value) {
|
|
9447
|
+
if (typeof value !== "object" || value === null || Object.isFrozen(value)) return value;
|
|
9448
|
+
for (const child of Object.values(value)) freezeJson2(child);
|
|
9449
|
+
return Object.freeze(value);
|
|
9450
|
+
}
|
|
9216
9451
|
function exact2(value, keys, path2) {
|
|
9217
9452
|
const expected = new Set(keys);
|
|
9218
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key
|
|
9453
|
+
if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => Object.hasOwn(value, key))) throw new TypeError(`${path2} has unknown or missing fields.`);
|
|
9219
9454
|
}
|
|
9220
9455
|
function token2(value, path2) {
|
|
9221
9456
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
9222
9457
|
return value;
|
|
9223
9458
|
}
|
|
9459
|
+
function immutableVersion3(value, path2) {
|
|
9460
|
+
try {
|
|
9461
|
+
return assertImmutableAssetVersion(value);
|
|
9462
|
+
} catch {
|
|
9463
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
9464
|
+
}
|
|
9465
|
+
}
|
|
9224
9466
|
function path(value, label, extensions) {
|
|
9225
9467
|
if (typeof value !== "string" || !SAFE_PATH2.test(value) || !extensions.some((extension) => value.endsWith(extension))) {
|
|
9226
9468
|
throw new TypeError(`${label} must be a safe data-only bundle path (${extensions.join(", ")}).`);
|
|
@@ -9230,8 +9472,8 @@ function path(value, label, extensions) {
|
|
|
9230
9472
|
function sha(value, label) {
|
|
9231
9473
|
try {
|
|
9232
9474
|
return asSha256Hex(String(value));
|
|
9233
|
-
} catch
|
|
9234
|
-
throw new TypeError(`${label} must be a lowercase SHA-256 digest
|
|
9475
|
+
} catch {
|
|
9476
|
+
throw new TypeError(`${label} must be a lowercase SHA-256 digest.`);
|
|
9235
9477
|
}
|
|
9236
9478
|
}
|
|
9237
9479
|
function integer4(value, label, minimum = 0, maximum = 4294967295) {
|
|
@@ -9355,7 +9597,8 @@ function jsonValue(value, label, depth = 0) {
|
|
|
9355
9597
|
}
|
|
9356
9598
|
function validateQualificationFixture(value, unit) {
|
|
9357
9599
|
try {
|
|
9358
|
-
const
|
|
9600
|
+
const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
|
|
9601
|
+
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
9359
9602
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
9360
9603
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
9361
9604
|
token2(fixture.fixtureId, "fixture.fixtureId");
|
|
@@ -9485,14 +9728,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
9485
9728
|
unique2(bindingIds, `${label}.entries`);
|
|
9486
9729
|
bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
|
|
9487
9730
|
}
|
|
9488
|
-
const pipelines = new Map(
|
|
9731
|
+
const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
|
|
9489
9732
|
const pipelineIds = new Set(pipelines.keys());
|
|
9490
9733
|
const commandBindGroups = (value2, pipelineId, label) => {
|
|
9491
9734
|
const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
|
|
9492
9735
|
unique2(ids, label);
|
|
9493
9736
|
const pipeline2 = pipelines.get(pipelineId);
|
|
9494
9737
|
if (!pipeline2) {
|
|
9495
|
-
if (
|
|
9738
|
+
if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
|
|
9496
9739
|
return;
|
|
9497
9740
|
}
|
|
9498
9741
|
const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
|
|
@@ -9517,7 +9760,7 @@ function validateQualificationFixture(value, unit) {
|
|
|
9517
9760
|
executionCommands += 1;
|
|
9518
9761
|
exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
|
|
9519
9762
|
const id = token2(command.pipelineId, `${label}.pipelineId`);
|
|
9520
|
-
if (
|
|
9763
|
+
if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
|
|
9521
9764
|
commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
|
|
9522
9765
|
const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
|
|
9523
9766
|
if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);
|
|
@@ -9691,14 +9934,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
9691
9934
|
}
|
|
9692
9935
|
unique2(probeIds, "fixture.layoutProbes probe IDs");
|
|
9693
9936
|
unique2(probeSources, "fixture.layoutProbes model sources");
|
|
9694
|
-
return { ok: true, value: fixture };
|
|
9937
|
+
return { ok: true, value: freezeJson2(fixture) };
|
|
9695
9938
|
} catch (cause) {
|
|
9696
9939
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification fixture." }] };
|
|
9697
9940
|
}
|
|
9698
9941
|
}
|
|
9699
9942
|
function validateQualificationBundleManifest(value) {
|
|
9700
9943
|
try {
|
|
9701
|
-
const bundle = object3(value, "qualification");
|
|
9944
|
+
const bundle = object3(detachedJson2(value, "qualification"), "qualification");
|
|
9702
9945
|
exact2(bundle, ["contractVersion", "inventory", "subject", "shaderManifestCorePath", "gpuInterfaceManifest", "modelCompatibilityFixtures", "modules", "fixtures"], "qualification");
|
|
9703
9946
|
if (bundle.contractVersion !== SHADER_QUALIFICATION_BUNDLE_VERSION) throw new TypeError("Unsupported qualification bundle version.");
|
|
9704
9947
|
const inventory = validateCompileUnitInventory(bundle.inventory);
|
|
@@ -9708,7 +9951,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
9708
9951
|
const candidate = object3(subject.shaderManifestCore, "qualification.subject.shaderManifestCore");
|
|
9709
9952
|
exact2(candidate, ["shaderId", "version", "sha256"], "qualification.subject.shaderManifestCore");
|
|
9710
9953
|
token2(candidate.shaderId, "qualification.subject.shaderManifestCore.shaderId");
|
|
9711
|
-
|
|
9954
|
+
immutableVersion3(candidate.version, "qualification.subject.shaderManifestCore.version");
|
|
9712
9955
|
sha(candidate.sha256, "qualification.subject.shaderManifestCore.sha256");
|
|
9713
9956
|
path(bundle.shaderManifestCorePath, "qualification.shaderManifestCorePath", [".json"]);
|
|
9714
9957
|
const interfaceManifest = object3(bundle.gpuInterfaceManifest, "qualification.gpuInterfaceManifest");
|
|
@@ -9768,7 +10011,7 @@ function validateQualificationBundleManifest(value) {
|
|
|
9768
10011
|
const expectedUnits = [...inventory.value.compileUnits.map((unit) => unit.compileUnitId)].sort();
|
|
9769
10012
|
if (unitIds.join("\n") !== expectedUnits.join("\n")) throw new TypeError("Subject compile-unit IDs differ from inventory.");
|
|
9770
10013
|
orderedUniqueTokens(subject.requiredCellIds, "qualification.subject.requiredCellIds");
|
|
9771
|
-
return { ok: true, value: bundle };
|
|
10014
|
+
return { ok: true, value: freezeJson2(bundle) };
|
|
9772
10015
|
} catch (cause) {
|
|
9773
10016
|
return { ok: false, diagnostics: [{ code: "invalid-contract", severity: "error", message: cause instanceof Error ? cause.message : "Invalid qualification bundle." }] };
|
|
9774
10017
|
}
|