@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.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
|
+
}
|
|
5864
|
+
}
|
|
5865
|
+
function assertLimit(value, maximum, reason) {
|
|
5866
|
+
if (!Number.isSafeInteger(value) || value > maximum) fail(reason);
|
|
5802
5867
|
}
|
|
5803
|
-
function
|
|
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(
|
|
@@ -6343,11 +6499,10 @@ var stages = ["vertex", "fragment", "compute"];
|
|
|
6343
6499
|
var roles = ["material", "lighting", "outline", "shadow", "post-processing"];
|
|
6344
6500
|
function detachedJson(value, path2) {
|
|
6345
6501
|
try {
|
|
6346
|
-
return
|
|
6502
|
+
return snapshotGpuContract(value);
|
|
6347
6503
|
} catch (cause) {
|
|
6348
|
-
const detail = cause instanceof
|
|
6349
|
-
|
|
6350
|
-
throw new TypeError(`${path2} must contain detached JSON contract data: ${boundedDetail}`, { cause });
|
|
6504
|
+
const detail = cause instanceof GpuContractSnapshotError ? ` ${cause.message}` : "";
|
|
6505
|
+
throw new TypeError(`${path2} must contain bounded detached JSON contract data.${detail}`);
|
|
6351
6506
|
}
|
|
6352
6507
|
}
|
|
6353
6508
|
function object(value, path2) {
|
|
@@ -6357,7 +6512,7 @@ function object(value, path2) {
|
|
|
6357
6512
|
function exact(value, keys, path2) {
|
|
6358
6513
|
const allowed = new Set(keys);
|
|
6359
6514
|
for (const key of Object.keys(value)) if (!allowed.has(key)) throw new TypeError(`${path2}.${key} is not part of this contract version.`);
|
|
6360
|
-
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.`);
|
|
6361
6516
|
}
|
|
6362
6517
|
function text(value, path2, maximum = 512) {
|
|
6363
6518
|
if (typeof value !== "string" || value.length === 0 || value.length > maximum || [...value].some((character) => character.charCodeAt(0) <= 31)) {
|
|
@@ -6373,11 +6528,8 @@ function token(value, path2) {
|
|
|
6373
6528
|
function immutableVersion(value, path2) {
|
|
6374
6529
|
try {
|
|
6375
6530
|
return assertImmutableAssetVersion(value);
|
|
6376
|
-
} catch
|
|
6377
|
-
throw new TypeError(
|
|
6378
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
6379
|
-
{ cause }
|
|
6380
|
-
);
|
|
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.`);
|
|
6381
6533
|
}
|
|
6382
6534
|
}
|
|
6383
6535
|
function enumeration(value, values, path2) {
|
|
@@ -6407,8 +6559,8 @@ function nullableToken(value, path2) {
|
|
|
6407
6559
|
function digest(value, path2) {
|
|
6408
6560
|
try {
|
|
6409
6561
|
return asSha256Hex(text(value, path2, 64));
|
|
6410
|
-
} catch
|
|
6411
|
-
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.`);
|
|
6412
6564
|
}
|
|
6413
6565
|
}
|
|
6414
6566
|
function uri(value, path2) {
|
|
@@ -6416,8 +6568,8 @@ function uri(value, path2) {
|
|
|
6416
6568
|
let parsed;
|
|
6417
6569
|
try {
|
|
6418
6570
|
parsed = new URL(result);
|
|
6419
|
-
} catch
|
|
6420
|
-
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.`);
|
|
6421
6573
|
}
|
|
6422
6574
|
if (parsed.protocol !== "https:" || parsed.username || parsed.password || parsed.hash) throw new TypeError(`${path2} must be credential-free HTTPS without a fragment.`);
|
|
6423
6575
|
const keys = [...parsed.searchParams.keys()].map((key) => key.toLowerCase());
|
|
@@ -7555,7 +7707,7 @@ function validatePipelineInterfaces(input) {
|
|
|
7555
7707
|
// package.json
|
|
7556
7708
|
var package_default = {
|
|
7557
7709
|
name: "@plasius/gpu-shader",
|
|
7558
|
-
version: "0.1.
|
|
7710
|
+
version: "0.1.3",
|
|
7559
7711
|
description: "Reflection-first WebGPU WGSL interfaces, CPU codecs, compatibility validation, style profiles, and qualification tooling",
|
|
7560
7712
|
type: "module",
|
|
7561
7713
|
sideEffects: false,
|
|
@@ -7647,6 +7799,7 @@ var package_default = {
|
|
|
7647
7799
|
access: "public"
|
|
7648
7800
|
},
|
|
7649
7801
|
overrides: {
|
|
7802
|
+
esbuild: "^0.28.1",
|
|
7650
7803
|
minimatch: "^10.2.1"
|
|
7651
7804
|
},
|
|
7652
7805
|
engines: {
|
|
@@ -9014,7 +9167,7 @@ function freezeJson(value) {
|
|
|
9014
9167
|
}
|
|
9015
9168
|
function exactKeys(value, keys) {
|
|
9016
9169
|
const expected = new Set(keys);
|
|
9017
|
-
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));
|
|
9018
9171
|
}
|
|
9019
9172
|
function safeToken(value) {
|
|
9020
9173
|
return typeof value === "string" && /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,159}$/u.test(value) && !value.includes("..");
|
|
@@ -9038,13 +9191,13 @@ function validSha(value) {
|
|
|
9038
9191
|
function validateCompileUnitInventory(value) {
|
|
9039
9192
|
let snapshot;
|
|
9040
9193
|
try {
|
|
9041
|
-
snapshot =
|
|
9042
|
-
} catch
|
|
9194
|
+
snapshot = snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9195
|
+
} catch {
|
|
9043
9196
|
return {
|
|
9044
9197
|
ok: false,
|
|
9045
9198
|
diagnostics: [issue2(
|
|
9046
9199
|
"invalid-contract",
|
|
9047
|
-
|
|
9200
|
+
"Compile-unit inventory must contain bounded detached JSON contract data."
|
|
9048
9201
|
)]
|
|
9049
9202
|
};
|
|
9050
9203
|
}
|
|
@@ -9285,9 +9438,9 @@ function object3(value, path2) {
|
|
|
9285
9438
|
}
|
|
9286
9439
|
function detachedJson2(value, label) {
|
|
9287
9440
|
try {
|
|
9288
|
-
return
|
|
9289
|
-
} catch
|
|
9290
|
-
throw new TypeError(`${label} must contain detached JSON contract data
|
|
9441
|
+
return snapshotGpuContract(value, QUALIFICATION_GPU_CONTRACT_SNAPSHOT_LIMITS);
|
|
9442
|
+
} catch {
|
|
9443
|
+
throw new TypeError(`${label} must contain bounded detached JSON contract data.`);
|
|
9291
9444
|
}
|
|
9292
9445
|
}
|
|
9293
9446
|
function freezeJson2(value) {
|
|
@@ -9297,7 +9450,7 @@ function freezeJson2(value) {
|
|
|
9297
9450
|
}
|
|
9298
9451
|
function exact2(value, keys, path2) {
|
|
9299
9452
|
const expected = new Set(keys);
|
|
9300
|
-
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.`);
|
|
9301
9454
|
}
|
|
9302
9455
|
function token2(value, path2) {
|
|
9303
9456
|
if (typeof value !== "string" || !TOKEN.test(value) || value.includes("..")) throw new TypeError(`${path2} must be a safe token.`);
|
|
@@ -9306,11 +9459,8 @@ function token2(value, path2) {
|
|
|
9306
9459
|
function immutableVersion3(value, path2) {
|
|
9307
9460
|
try {
|
|
9308
9461
|
return assertImmutableAssetVersion(value);
|
|
9309
|
-
} catch
|
|
9310
|
-
throw new TypeError(
|
|
9311
|
-
`${path2} must be an immutable asset version: exact token required; mutable aliases, ranges, wildcards, and URLs are not allowed.`,
|
|
9312
|
-
{ cause }
|
|
9313
|
-
);
|
|
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.`);
|
|
9314
9464
|
}
|
|
9315
9465
|
}
|
|
9316
9466
|
function path(value, label, extensions) {
|
|
@@ -9322,8 +9472,8 @@ function path(value, label, extensions) {
|
|
|
9322
9472
|
function sha(value, label) {
|
|
9323
9473
|
try {
|
|
9324
9474
|
return asSha256Hex(String(value));
|
|
9325
|
-
} catch
|
|
9326
|
-
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.`);
|
|
9327
9477
|
}
|
|
9328
9478
|
}
|
|
9329
9479
|
function integer4(value, label, minimum = 0, maximum = 4294967295) {
|
|
@@ -9447,6 +9597,7 @@ function jsonValue(value, label, depth = 0) {
|
|
|
9447
9597
|
}
|
|
9448
9598
|
function validateQualificationFixture(value, unit) {
|
|
9449
9599
|
try {
|
|
9600
|
+
const compileUnit = unit === void 0 ? void 0 : detachedJson2(unit, "compile unit");
|
|
9450
9601
|
const fixture = object3(detachedJson2(value, "fixture"), "fixture");
|
|
9451
9602
|
exact2(fixture, ["contractVersion", "fixtureId", "resources", "bindGroups", "commands", "layoutProbes", "readbacks", "bounds"], "fixture");
|
|
9452
9603
|
if (fixture.contractVersion !== SHADER_QUALIFICATION_FIXTURE_VERSION) throw new TypeError("Unsupported qualification fixture version.");
|
|
@@ -9577,14 +9728,14 @@ function validateQualificationFixture(value, unit) {
|
|
|
9577
9728
|
unique2(bindingIds, `${label}.entries`);
|
|
9578
9729
|
bindGroups.set(id, { group: groupIndex, entries: parsedEntries });
|
|
9579
9730
|
}
|
|
9580
|
-
const pipelines = new Map(
|
|
9731
|
+
const pipelines = new Map(compileUnit?.pipelines.map((pipeline2) => [pipeline2.pipelineId, pipeline2]) ?? []);
|
|
9581
9732
|
const pipelineIds = new Set(pipelines.keys());
|
|
9582
9733
|
const commandBindGroups = (value2, pipelineId, label) => {
|
|
9583
9734
|
const ids = boundedArray(value2, label, 32).map((item, index) => token2(item, `${label}[${index}]`));
|
|
9584
9735
|
unique2(ids, label);
|
|
9585
9736
|
const pipeline2 = pipelines.get(pipelineId);
|
|
9586
9737
|
if (!pipeline2) {
|
|
9587
|
-
if (
|
|
9738
|
+
if (compileUnit) throw new TypeError(`${label} pipeline is missing.`);
|
|
9588
9739
|
return;
|
|
9589
9740
|
}
|
|
9590
9741
|
const expectedGroups = [...pipeline2.layout.bindGroups].sort((left, right) => left.group - right.group);
|
|
@@ -9609,7 +9760,7 @@ function validateQualificationFixture(value, unit) {
|
|
|
9609
9760
|
executionCommands += 1;
|
|
9610
9761
|
exact2(command, ["kind", "pipelineId", "bindGroupIds", "workgroups"], label);
|
|
9611
9762
|
const id = token2(command.pipelineId, `${label}.pipelineId`);
|
|
9612
|
-
if (
|
|
9763
|
+
if (compileUnit && pipelines.get(id)?.kind !== "compute") throw new TypeError(`${label} references a missing or non-compute pipeline.`);
|
|
9613
9764
|
commandBindGroups(command.bindGroupIds, id, `${label}.bindGroupIds`);
|
|
9614
9765
|
const workgroups = tuple(command.workgroups, `${label}.workgroups`, 3, 1);
|
|
9615
9766
|
if (workgroups[0] * workgroups[1] * workgroups[2] > 1048576) throw new TypeError(`${label}.workgroups exceeds the hard dispatch bound.`);
|