@plasius/gpu-shader 0.1.2 → 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 +36 -0
- package/dist/cli.cjs +360 -147
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +360 -147
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +543 -146
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +543 -146
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +235 -84
- package/dist/node.cjs.map +1 -1
- package/dist/node.js +235 -84
- package/dist/node.js.map +1 -1
- package/dist/testing.cjs +366 -124
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.js +366 -124
- package/dist/testing.js.map +1 -1
- package/package.json +2 -1
package/dist/node.js
CHANGED
|
@@ -5765,63 +5765,217 @@ var cn;
|
|
|
5765
5765
|
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" };
|
|
5766
5766
|
|
|
5767
5767
|
// src/canonical-json.ts
|
|
5768
|
-
|
|
5769
|
-
|
|
5770
|
-
|
|
5768
|
+
var GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
5769
|
+
maximumDepth: 64,
|
|
5770
|
+
maximumNodes: 262144,
|
|
5771
|
+
maximumProperties: 131072,
|
|
5772
|
+
maximumElements: 131072,
|
|
5773
|
+
maximumArrayLength: 1e5,
|
|
5774
|
+
maximumStringBytes: 1024 * 1024,
|
|
5775
|
+
maximumAggregateStringBytes: 8 * 1024 * 1024,
|
|
5776
|
+
maximumAggregateBytes: 16 * 1024 * 1024,
|
|
5777
|
+
maximumInputBytes: 16 * 1024 * 1024
|
|
5778
|
+
});
|
|
5779
|
+
var QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS = Object.freeze({
|
|
5780
|
+
maximumDepth: 96,
|
|
5781
|
+
maximumNodes: 4e6,
|
|
5782
|
+
maximumProperties: 2e6,
|
|
5783
|
+
maximumElements: 2e6,
|
|
5784
|
+
maximumArrayLength: 25e4,
|
|
5785
|
+
maximumStringBytes: 4 * 1024 * 1024,
|
|
5786
|
+
maximumAggregateStringBytes: 128 * 1024 * 1024,
|
|
5787
|
+
maximumAggregateBytes: 256 * 1024 * 1024,
|
|
5788
|
+
maximumInputBytes: 256 * 1024 * 1024
|
|
5789
|
+
});
|
|
5790
|
+
var FAILURE_MESSAGES = Object.freeze({
|
|
5791
|
+
"aggregate-bytes": "GPU contract snapshot exceeds the aggregate byte limit.",
|
|
5792
|
+
"aggregate-string-bytes": "GPU contract snapshot exceeds the aggregate string byte limit.",
|
|
5793
|
+
"array-length": "GPU contract snapshot exceeds the single-array element limit.",
|
|
5794
|
+
cycle: "GPU contract snapshot contains a circular reference.",
|
|
5795
|
+
depth: "GPU contract snapshot exceeds the nesting-depth limit.",
|
|
5796
|
+
elements: "GPU contract snapshot exceeds the total element limit.",
|
|
5797
|
+
inspection: "GPU contract snapshot rejected unsafe object inspection.",
|
|
5798
|
+
nodes: "GPU contract snapshot exceeds the total node limit.",
|
|
5799
|
+
"non-finite": "GPU contract snapshot contains a non-finite number.",
|
|
5800
|
+
properties: "GPU contract snapshot exceeds the total property limit.",
|
|
5801
|
+
shape: "GPU contract snapshot requires plain JSON objects with own enumerable data properties and dense arrays.",
|
|
5802
|
+
"string-bytes": "GPU contract snapshot exceeds the individual string byte limit.",
|
|
5803
|
+
unicode: "GPU contract snapshot contains an invalid Unicode scalar string or unpaired UTF-16 surrogate.",
|
|
5804
|
+
value: "GPU contract snapshot contains undefined or another value that JSON cannot represent."
|
|
5805
|
+
});
|
|
5806
|
+
var GpuContractSnapshotError = class extends TypeError {
|
|
5807
|
+
code;
|
|
5808
|
+
constructor(code) {
|
|
5809
|
+
super(FAILURE_MESSAGES[code]);
|
|
5810
|
+
this.name = "GpuContractSnapshotError";
|
|
5811
|
+
this.code = code;
|
|
5812
|
+
}
|
|
5813
|
+
};
|
|
5814
|
+
var TYPED_ARRAY_PROTOTYPE = Reflect.getPrototypeOf(Uint8Array.prototype);
|
|
5815
|
+
var TYPED_ARRAY_BYTE_LENGTH = Reflect.getOwnPropertyDescriptor(
|
|
5816
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
5817
|
+
"byteLength"
|
|
5818
|
+
)?.get;
|
|
5819
|
+
var TYPED_ARRAY_TAG = Reflect.getOwnPropertyDescriptor(
|
|
5820
|
+
TYPED_ARRAY_PROTOTYPE,
|
|
5821
|
+
Symbol.toStringTag
|
|
5822
|
+
)?.get;
|
|
5823
|
+
var UINT8_ARRAY_SET = Uint8Array.prototype.set;
|
|
5824
|
+
function fail(reason) {
|
|
5825
|
+
throw new GpuContractSnapshotError(reason);
|
|
5826
|
+
}
|
|
5827
|
+
function inspected(operation) {
|
|
5828
|
+
try {
|
|
5829
|
+
return operation();
|
|
5830
|
+
} catch {
|
|
5831
|
+
return fail("inspection");
|
|
5832
|
+
}
|
|
5833
|
+
}
|
|
5834
|
+
function assertLimit(value, maximum, reason) {
|
|
5835
|
+
if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
|
|
5771
5836
|
}
|
|
5772
|
-
function
|
|
5837
|
+
function quotedJsonByteLength(value, maximum) {
|
|
5838
|
+
let raw = 0;
|
|
5839
|
+
let quoted = 2;
|
|
5773
5840
|
for (let index = 0; index < value.length; index += 1) {
|
|
5774
5841
|
const code = value.charCodeAt(index);
|
|
5775
|
-
if (code
|
|
5842
|
+
if (code <= 127) {
|
|
5843
|
+
raw += 1;
|
|
5844
|
+
if (code <= 31) quoted += code === 8 || code === 9 || code === 10 || code === 12 || code === 13 ? 2 : 6;
|
|
5845
|
+
else quoted += code === 34 || code === 92 ? 2 : 1;
|
|
5846
|
+
} else if (code <= 2047) {
|
|
5847
|
+
raw += 2;
|
|
5848
|
+
quoted += 2;
|
|
5849
|
+
} else if (code >= 55296 && code <= 56319) {
|
|
5776
5850
|
const next = value.charCodeAt(index + 1);
|
|
5777
|
-
if (!(next >= 56320 && next <= 57343))
|
|
5851
|
+
if (!(next >= 56320 && next <= 57343)) fail("unicode");
|
|
5852
|
+
raw += 4;
|
|
5853
|
+
quoted += 4;
|
|
5778
5854
|
index += 1;
|
|
5779
|
-
} else if (code >= 56320 && code <= 57343)
|
|
5855
|
+
} else if (code >= 56320 && code <= 57343) fail("unicode");
|
|
5856
|
+
else {
|
|
5857
|
+
raw += 3;
|
|
5858
|
+
quoted += 3;
|
|
5859
|
+
}
|
|
5860
|
+
if (raw > maximum) fail("string-bytes");
|
|
5780
5861
|
}
|
|
5862
|
+
return { raw, quoted };
|
|
5781
5863
|
}
|
|
5782
|
-
function
|
|
5864
|
+
function assertLimits(limits) {
|
|
5865
|
+
for (const value of Object.values(limits)) {
|
|
5866
|
+
if (!Number.isSafeInteger(value) || value < 1) throw new TypeError("GPU contract snapshot limits must be positive safe integers.");
|
|
5867
|
+
}
|
|
5868
|
+
}
|
|
5869
|
+
function snapshotGpuContract(value, limits = GPU_CONTRACT_SNAPSHOT_LIMITS) {
|
|
5870
|
+
assertLimits(limits);
|
|
5783
5871
|
const ancestors = /* @__PURE__ */ new Set();
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5872
|
+
let nodes = 0;
|
|
5873
|
+
let properties = 0;
|
|
5874
|
+
let elements = 0;
|
|
5875
|
+
let aggregateStringBytes = 0;
|
|
5876
|
+
let aggregateBytes = 0;
|
|
5877
|
+
const addAggregate = (bytes) => {
|
|
5878
|
+
aggregateBytes += bytes;
|
|
5879
|
+
assertLimit(aggregateBytes, limits.maximumAggregateBytes, "aggregate-bytes");
|
|
5880
|
+
};
|
|
5881
|
+
const addString = (text2) => {
|
|
5882
|
+
const measured = quotedJsonByteLength(text2, limits.maximumStringBytes);
|
|
5883
|
+
aggregateStringBytes += measured.raw;
|
|
5884
|
+
assertLimit(aggregateStringBytes, limits.maximumAggregateStringBytes, "aggregate-string-bytes");
|
|
5885
|
+
return measured.quoted;
|
|
5886
|
+
};
|
|
5887
|
+
const visit = (current, depth) => {
|
|
5888
|
+
if (depth > limits.maximumDepth) fail("depth");
|
|
5889
|
+
nodes += 1;
|
|
5890
|
+
assertLimit(nodes, limits.maximumNodes, "nodes");
|
|
5891
|
+
if (current === null) {
|
|
5892
|
+
addAggregate(4);
|
|
5893
|
+
return null;
|
|
5894
|
+
}
|
|
5895
|
+
if (typeof current === "string") {
|
|
5896
|
+
addAggregate(addString(current));
|
|
5897
|
+
return current;
|
|
5898
|
+
}
|
|
5899
|
+
if (typeof current === "boolean") {
|
|
5900
|
+
addAggregate(current ? 4 : 5);
|
|
5901
|
+
return current;
|
|
5789
5902
|
}
|
|
5790
5903
|
if (typeof current === "number") {
|
|
5791
|
-
if (!Number.isFinite(current))
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
return
|
|
5795
|
-
}
|
|
5796
|
-
if (typeof current !== "object")
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
}
|
|
5904
|
+
if (!Number.isFinite(current)) fail("non-finite");
|
|
5905
|
+
const normalized = Object.is(current, -0) ? 0 : current;
|
|
5906
|
+
addAggregate(JSON.stringify(normalized).length);
|
|
5907
|
+
return normalized;
|
|
5908
|
+
}
|
|
5909
|
+
if (typeof current !== "object") fail("value");
|
|
5910
|
+
if (ancestors.has(current)) fail("cycle");
|
|
5911
|
+
const isArray = inspected(() => Array.isArray(current));
|
|
5912
|
+
const prototype = inspected(() => Reflect.getPrototypeOf(current));
|
|
5913
|
+
if (isArray ? prototype !== Array.prototype : prototype !== Object.prototype && prototype !== null) fail("shape");
|
|
5802
5914
|
ancestors.add(current);
|
|
5803
5915
|
try {
|
|
5804
|
-
if (
|
|
5805
|
-
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5916
|
+
if (isArray) {
|
|
5917
|
+
const lengthDescriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, "length"));
|
|
5918
|
+
if (!lengthDescriptor || !Object.hasOwn(lengthDescriptor, "value") || lengthDescriptor.enumerable || typeof lengthDescriptor.value !== "number" || !Number.isSafeInteger(lengthDescriptor.value) || lengthDescriptor.value < 0) fail("shape");
|
|
5919
|
+
const length = lengthDescriptor.value;
|
|
5920
|
+
assertLimit(length, limits.maximumArrayLength, "array-length");
|
|
5921
|
+
elements += length;
|
|
5922
|
+
assertLimit(elements, limits.maximumElements, "elements");
|
|
5923
|
+
const ownKeys2 = inspected(() => Reflect.ownKeys(current));
|
|
5924
|
+
if (ownKeys2.some((key) => typeof key !== "string")) fail("shape");
|
|
5925
|
+
if (ownKeys2.length !== length + 1) fail("shape");
|
|
5926
|
+
const keySet = new Set(ownKeys2);
|
|
5927
|
+
if (!keySet.delete("length")) fail("shape");
|
|
5928
|
+
const output2 = new Array(length);
|
|
5929
|
+
addAggregate(2 + Math.max(0, length - 1));
|
|
5930
|
+
for (let index = 0; index < length; index += 1) {
|
|
5931
|
+
const key = String(index);
|
|
5932
|
+
if (!keySet.delete(key)) fail("shape");
|
|
5933
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
5934
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
5935
|
+
Object.defineProperty(output2, key, {
|
|
5936
|
+
configurable: true,
|
|
5937
|
+
enumerable: true,
|
|
5938
|
+
value: visit(descriptor.value, depth + 1),
|
|
5939
|
+
writable: true
|
|
5940
|
+
});
|
|
5816
5941
|
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5942
|
+
if (keySet.size !== 0) fail("shape");
|
|
5943
|
+
return output2;
|
|
5944
|
+
}
|
|
5945
|
+
const ownKeys = inspected(() => Reflect.ownKeys(current));
|
|
5946
|
+
if (ownKeys.some((key) => typeof key !== "string")) fail("shape");
|
|
5947
|
+
properties += ownKeys.length;
|
|
5948
|
+
assertLimit(properties, limits.maximumProperties, "properties");
|
|
5949
|
+
addAggregate(2 + Math.max(0, ownKeys.length - 1) + ownKeys.length);
|
|
5950
|
+
const output = {};
|
|
5951
|
+
for (const key of ownKeys) {
|
|
5952
|
+
addAggregate(addString(key));
|
|
5953
|
+
const descriptor = inspected(() => Reflect.getOwnPropertyDescriptor(current, key));
|
|
5954
|
+
if (!descriptor || !descriptor.enumerable || !Object.hasOwn(descriptor, "value")) fail("shape");
|
|
5955
|
+
Object.defineProperty(output, key, {
|
|
5956
|
+
configurable: true,
|
|
5957
|
+
enumerable: true,
|
|
5958
|
+
value: visit(descriptor.value, depth + 1),
|
|
5959
|
+
writable: true
|
|
5960
|
+
});
|
|
5961
|
+
}
|
|
5962
|
+
return output;
|
|
5820
5963
|
} finally {
|
|
5821
5964
|
ancestors.delete(current);
|
|
5822
5965
|
}
|
|
5823
5966
|
};
|
|
5824
|
-
return visit(value,
|
|
5967
|
+
return visit(value, 0);
|
|
5968
|
+
}
|
|
5969
|
+
function serializeSnapshot(value) {
|
|
5970
|
+
if (value === null) return "null";
|
|
5971
|
+
if (typeof value === "string" || typeof value === "boolean") return JSON.stringify(value);
|
|
5972
|
+
if (typeof value === "number") return JSON.stringify(value);
|
|
5973
|
+
if (Array.isArray(value)) return `[${value.map(serializeSnapshot).join(",")}]`;
|
|
5974
|
+
const input = value;
|
|
5975
|
+
return `{${Object.keys(input).sort().map((key) => `${JSON.stringify(key)}:${serializeSnapshot(input[key])}`).join(",")}}`;
|
|
5976
|
+
}
|
|
5977
|
+
function canonicalizeGpuContract(value) {
|
|
5978
|
+
return serializeSnapshot(snapshotGpuContract(value));
|
|
5825
5979
|
}
|
|
5826
5980
|
|
|
5827
5981
|
// src/contracts.ts
|
|
@@ -5919,39 +6073,41 @@ function modelProjection(manifest) {
|
|
|
5919
6073
|
};
|
|
5920
6074
|
}
|
|
5921
6075
|
async function computeGpuAbiHash(input) {
|
|
5922
|
-
|
|
6076
|
+
const snapshot = snapshotGpuContract(input);
|
|
6077
|
+
if (snapshot.kind === "model") {
|
|
5923
6078
|
return computeSha256(
|
|
5924
6079
|
`plasius.gpu.model-abi/v1
|
|
5925
|
-
${canonicalizeGpuContract(modelProjection(
|
|
6080
|
+
${canonicalizeGpuContract(modelProjection(snapshot.interface))}`
|
|
5926
6081
|
);
|
|
5927
6082
|
}
|
|
5928
|
-
if (
|
|
6083
|
+
if (snapshot.kind === "interface") {
|
|
5929
6084
|
return computeSha256(
|
|
5930
6085
|
`plasius.gpu.interface-abi/v1
|
|
5931
|
-
${canonicalizeGpuContract(interfaceProjection(
|
|
6086
|
+
${canonicalizeGpuContract(interfaceProjection(snapshot.interface))}`
|
|
5932
6087
|
);
|
|
5933
6088
|
}
|
|
5934
6089
|
const pipelines = sorted(
|
|
5935
|
-
|
|
6090
|
+
snapshot.pipelines,
|
|
5936
6091
|
(left, right) => compareString(left.pipelineId, right.pipelineId)
|
|
5937
6092
|
);
|
|
5938
6093
|
const requirements = {
|
|
5939
|
-
semantics: [...
|
|
5940
|
-
features: [...
|
|
5941
|
-
limits: sorted(
|
|
5942
|
-
formats: [...
|
|
6094
|
+
semantics: [...snapshot.requirements.semantics].sort(),
|
|
6095
|
+
features: [...snapshot.requirements.features].sort(),
|
|
6096
|
+
limits: sorted(snapshot.requirements.limits, (left, right) => compareString(left.name, right.name)),
|
|
6097
|
+
formats: [...snapshot.requirements.formats].sort()
|
|
5943
6098
|
};
|
|
5944
6099
|
return computeSha256(
|
|
5945
6100
|
`plasius.gpu.shader-abi/v1
|
|
5946
6101
|
${canonicalizeGpuContract({
|
|
5947
|
-
interface: interfaceProjection(
|
|
6102
|
+
interface: interfaceProjection(snapshot.interface),
|
|
5948
6103
|
pipelines,
|
|
5949
6104
|
requirements
|
|
5950
6105
|
})}`
|
|
5951
6106
|
);
|
|
5952
6107
|
}
|
|
5953
6108
|
async function computeShaderManifestCoreSha256(manifest) {
|
|
5954
|
-
const
|
|
6109
|
+
const snapshot = snapshotGpuContract(manifest);
|
|
6110
|
+
const core = Object.fromEntries(Object.entries(snapshot).filter(
|
|
5955
6111
|
([key]) => key !== "validationEvidence" && key !== "additionalValidationEvidence"
|
|
5956
6112
|
));
|
|
5957
6113
|
return computeSha256(
|
|
@@ -6312,11 +6468,10 @@ var stages = ["vertex", "fragment", "compute"];
|
|
|
6312
6468
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
6313
6469
|
function detachedJson(value, path2) {
|
|
6314
6470
|
try {
|
|
6315
|
-
return
|
|
6471
|
+
return snapshotGpuContract(value);
|
|
6316
6472
|
} catch (cause) {
|
|
6317
|
-
const detail = cause instanceof
|
|
6318
|
-
|
|
6319
|
-
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
6473
|
+
const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
|
|
6474
|
+
throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
|
|
6320
6475
|
}
|
|
6321
6476
|
}
|
|
6322
6477
|
function object(value, path2) {
|
|
@@ -6326,7 +6481,7 @@ function object(value, path2) {
|
|
|
6326
6481
|
function exact(value, keys, path2) {
|
|
6327
6482
|
const allowed = new Set(keys);
|
|
6328
6483
|
for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
|
|
6329
|
-
for (const key of keys) if (!(key
|
|
6484
|
+
for (const key of keys) if (!Object.hasOwn(value, key)) throw new TypeError(`${path2}.${key} is required.`);
|
|
6330
6485
|
}
|
|
6331
6486
|
function text(value, path2, maximum = 512) {
|
|
6332
6487
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
|
|
@@ -6342,11 +6497,8 @@ function token(value, path2) {
|
|
|
6342
6497
|
function immutableVersion(value, path2) {
|
|
6343
6498
|
try {
|
|
6344
6499
|
return assertImmutableAssetVersion(value);
|
|
6345
|
-
} catch
|
|
6346
|
-
throw new TypeError(
|
|
6347
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
6348
|
-
{ cause }
|
|
6349
|
-
);
|
|
6500
|
+
} catch {
|
|
6501
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
6350
6502
|
}
|
|
6351
6503
|
}
|
|
6352
6504
|
function enumeration(value, values, path2) {
|
|
@@ -6376,8 +6528,8 @@ function nullableToken(value, path2) {
|
|
|
6376
6528
|
function digest(value, path2) {
|
|
6377
6529
|
try {
|
|
6378
6530
|
return asSha256Hex(text(value, path2, 64));
|
|
6379
|
-
} catch
|
|
6380
|
-
throw new TypeError(`${path2} must be a lowercase SHA-256 digest
|
|
6531
|
+
} catch {
|
|
6532
|
+
throw new TypeError(`${path2} must be a lowercase SHA-256 digest.`);
|
|
6381
6533
|
}
|
|
6382
6534
|
}
|
|
6383
6535
|
function uri(value, path2) {
|
|
@@ -6385,8 +6537,8 @@ function uri(value, path2) {
|
|
|
6385
6537
|
let parsed;
|
|
6386
6538
|
try {
|
|
6387
6539
|
parsed = new URL(result);
|
|
6388
|
-
} catch
|
|
6389
|
-
throw new TypeError(`${path2} must be an absolute immutable asset URI
|
|
6540
|
+
} catch {
|
|
6541
|
+
throw new TypeError(`${path2} must be an absolute immutable asset URI.`);
|
|
6390
6542
|
}
|
|
6391
6543
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
|
|
6392
6544
|
const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
|
|
@@ -7524,7 +7676,7 @@ function validatePipelineInterfaces(input) {
|
|
|
7524
7676
|
// package.json
|
|
7525
7677
|
var package_default = {
|
|
7526
7678
|
name: "@plasius/gpu-shader",
|
|
7527
|
-
version: "0.1.
|
|
7679
|
+
version: "0.1.3",
|
|
7528
7680
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
7529
7681
|
type: "module",
|
|
7530
7682
|
sideEffects: false,
|
|
@@ -7616,6 +7768,7 @@ var package_default = {
|
|
|
7616
7768
|
access: "public"
|
|
7617
7769
|
},
|
|
7618
7770
|
overrides: {
|
|
7771
|
+
esbuild: "^0.28.1",
|
|
7619
7772
|
minimatch: "^10.2.1"
|
|
7620
7773
|
},
|
|
7621
7774
|
engines: {
|
|
@@ -8983,7 +9136,7 @@ function freezeJson(value) {
|
|
|
8983
9136
|
}
|
|
8984
9137
|
function exactKeys(value, keys) {
|
|
8985
9138
|
const expected = new Set(keys);
|
|
8986
|
-
return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => key
|
|
9139
|
+
return Object.keys(value).every((key) => expected.has(key)) && keys.every((key) => Object.hasOwn(value, key));
|
|
8987
9140
|
}
|
|
8988
9141
|
function safeToken(value) {
|
|
8989
9142
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
@@ -9007,13 +9160,13 @@ function validSha(value) {
|
|
|
9007
9160
|
function validateCompileUnitInventory(value) {
|
|
9008
9161
|
let snapshot;
|
|
9009
9162
|
try {
|
|
9010
|
-
snapshot =
|
|
9011
|
-
} catch
|
|
9163
|
+
snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9164
|
+
} catch {
|
|
9012
9165
|
return {
|
|
9013
9166
|
ok: false,
|
|
9014
9167
|
diagnostics: [issue2(
|
|
9015
9168
|
"invalid-contract",
|
|
9016
|
-
|
|
9169
|
+
"Compile-unit inventory must contain bounded detached JSON contract data."
|
|
9017
9170
|
)]
|
|
9018
9171
|
};
|
|
9019
9172
|
}
|
|
@@ -9254,9 +9407,9 @@ function object3(value, path2) {
|
|
|
9254
9407
|
}
|
|
9255
9408
|
function detachedJson2(value, label) {
|
|
9256
9409
|
try {
|
|
9257
|
-
return
|
|
9258
|
-
} catch
|
|
9259
|
-
throw new TypeError(`${label} must contain detached JSON contract data
|
|
9410
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9411
|
+
} catch {
|
|
9412
|
+
throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
|
|
9260
9413
|
}
|
|
9261
9414
|
}
|
|
9262
9415
|
function freezeJson2(value) {
|
|
@@ -9266,7 +9419,7 @@ function freezeJson2(value) {
|
|
|
9266
9419
|
}
|
|
9267
9420
|
function exact2(value, keys, path2) {
|
|
9268
9421
|
const expected = new Set(keys);
|
|
9269
|
-
if (!Object.keys(value).every((key) => expected.has(key)) || !keys.every((key) => key
|
|
9422
|
+
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.`);
|
|
9270
9423
|
}
|
|
9271
9424
|
function token2(value, path2) {
|
|
9272
9425
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
@@ -9275,11 +9428,8 @@ function token2(value, path2) {
|
|
|
9275
9428
|
function immutableVersion3(value, path2) {
|
|
9276
9429
|
try {
|
|
9277
9430
|
return assertImmutableAssetVersion(value);
|
|
9278
|
-
} catch
|
|
9279
|
-
throw new TypeError(
|
|
9280
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
9281
|
-
{ cause }
|
|
9282
|
-
);
|
|
9431
|
+
} catch {
|
|
9432
|
+
throw new TypeError(`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`);
|
|
9283
9433
|
}
|
|
9284
9434
|
}
|
|
9285
9435
|
function path(value, label, extensions) {
|
|
@@ -9291,8 +9441,8 @@ function path(value, label, extensions) {
|
|
|
9291
9441
|
function sha(value, label) {
|
|
9292
9442
|
try {
|
|
9293
9443
|
return asSha256Hex(String(value));
|
|
9294
|
-
} catch
|
|
9295
|
-
throw new TypeError(`${label} must be a lowercase SHA-256 digest
|
|
9444
|
+
} catch {
|
|
9445
|
+
throw new TypeError(`${label} must be a lowercase SHA-256 digest.`);
|
|
9296
9446
|
}
|
|
9297
9447
|
}
|
|
9298
9448
|
function integer4(value, label, minimum = 0, maximum = 4294967295) {
|
|
@@ -9416,6 +9566,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
9416
9566
|
}
|
|
9417
9567
|
function validateQualificationFixture(value, unit) {
|
|
9418
9568
|
try {
|
|
9569
|
+
const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
|
|
9419
9570
|
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
9420
9571
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
9421
9572
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
@@ -9546,14 +9697,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
9546
9697
|
unique2(bindingIds, `${label}.entries`);
|
|
9547
9698
|
bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
|
|
9548
9699
|
}
|
|
9549
|
-
const pipelines = new Map(
|
|
9700
|
+
const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
|
|
9550
9701
|
const pipelineIds = new Set(pipelines.keys());
|
|
9551
9702
|
const commandBindGroups = (value2, pipelineId, label) => {
|
|
9552
9703
|
const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
|
|
9553
9704
|
unique2(ids, label);
|
|
9554
9705
|
const pipeline2 = pipelines.get(pipelineId);
|
|
9555
9706
|
if (!pipeline2) {
|
|
9556
|
-
if (
|
|
9707
|
+
if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
|
|
9557
9708
|
return;
|
|
9558
9709
|
}
|
|
9559
9710
|
const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
|
|
@@ -9578,7 +9729,7 @@ function validateQualificationFixture(value, unit) {
|
|
|
9578
9729
|
executionCommands += 1;
|
|
9579
9730
|
exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
|
|
9580
9731
|
const id = token2(command.pipelineId, `${label}.pipelineId`);
|
|
9581
|
-
if (
|
|
9732
|
+
if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
|
|
9582
9733
|
commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
|
|
9583
9734
|
const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
|
|
9584
9735
|
if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);
|