wesl-tooling 0.6.4 → 0.6.5
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/dist/index.d.ts +4 -4
- package/dist/index.js +3 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { VirtualLibraryFn, WeslBundle } from "wesl";
|
|
2
|
-
import {
|
|
2
|
+
import { WgslElementType, WgslElementType as WgslElementType$1 } from "thimbleberry";
|
|
3
3
|
|
|
4
4
|
//#region src/ParseDependencies.d.ts
|
|
5
5
|
/**
|
|
@@ -84,7 +84,7 @@ declare function compileShader(params: CompileShaderParams): Promise<GPUShaderMo
|
|
|
84
84
|
* @param resultFormat - format for interpreting the result buffer data. (default u32)
|
|
85
85
|
* @returns storage result array (typically four numbers if the buffer format is u32 or f32)
|
|
86
86
|
*/
|
|
87
|
-
declare function testComputeShader(projectDir: string, gpu: GPU, src: string, resultFormat
|
|
87
|
+
declare function testComputeShader(projectDir: string, gpu: GPU, src: string, resultFormat: WgslElementType$1, conditions?: Record<string, boolean>): Promise<number[]>;
|
|
88
88
|
/**
|
|
89
89
|
* Transpiles and runs a simple compute shader on the GPU for testing.
|
|
90
90
|
*
|
|
@@ -101,7 +101,7 @@ declare function testComputeShader(projectDir: string, gpu: GPU, src: string, re
|
|
|
101
101
|
* @param resultFormat - format for interpreting the result buffer data. (default u32)
|
|
102
102
|
* @returns storage result array
|
|
103
103
|
*/
|
|
104
|
-
declare function runSimpleComputePipeline(device: GPUDevice, module: GPUShaderModule, resultFormat?:
|
|
104
|
+
declare function runSimpleComputePipeline(device: GPUDevice, module: GPUShaderModule, resultFormat?: WgslElementType$1): Promise<number[]>;
|
|
105
105
|
|
|
106
106
|
//#endregion
|
|
107
|
-
export { CompileShaderParams, compileShader, dependencyBundles, parseDependencies, runSimpleComputePipeline, testComputeShader };
|
|
107
|
+
export { CompileShaderParams, WgslElementType, compileShader, dependencyBundles, parseDependencies, runSimpleComputePipeline, testComputeShader };
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { resolve } from "import-meta-resolve";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
import { WeslParseError, filterMap, findUnboundIdents, link, parseIntoRegistry, parsedRegistry, requestWeslDevice } from "wesl";
|
|
5
|
-
import { copyBuffer } from "thimbleberry";
|
|
5
|
+
import { copyBuffer, elementStride } from "thimbleberry";
|
|
6
6
|
|
|
7
7
|
//#region src/ParseDependencies.ts
|
|
8
8
|
/**
|
|
@@ -127,11 +127,11 @@ async function compileShader(params) {
|
|
|
127
127
|
* @param resultFormat - format for interpreting the result buffer data. (default u32)
|
|
128
128
|
* @returns storage result array (typically four numbers if the buffer format is u32 or f32)
|
|
129
129
|
*/
|
|
130
|
-
async function testComputeShader(projectDir, gpu, src, resultFormat
|
|
130
|
+
async function testComputeShader(projectDir, gpu, src, resultFormat, conditions = {}) {
|
|
131
131
|
const adapter = await gpu.requestAdapter();
|
|
132
132
|
const device = await requestWeslDevice(adapter);
|
|
133
133
|
try {
|
|
134
|
-
const arraySize = resultBufferSize /
|
|
134
|
+
const arraySize = resultBufferSize / elementStride(resultFormat);
|
|
135
135
|
const arrayType = `array<${resultFormat}, ${arraySize}>`;
|
|
136
136
|
const virtualLibs = { test: () => `@group(0) @binding(0) var <storage, read_write> results: ${arrayType};` };
|
|
137
137
|
const params = {
|
|
@@ -148,12 +148,6 @@ async function testComputeShader(projectDir, gpu, src, resultFormat = "f32", con
|
|
|
148
148
|
device.destroy();
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
|
-
/** size in bytes of a wgsl numeric type, e.g. 'f32' => 4 */
|
|
152
|
-
function elementByteSize(fmt) {
|
|
153
|
-
const found = fmt.match(/\d+/);
|
|
154
|
-
const bits = Number.parseInt(found?.[0]);
|
|
155
|
-
return bits / 8;
|
|
156
|
-
}
|
|
157
151
|
/**
|
|
158
152
|
* Transpiles and runs a simple compute shader on the GPU for testing.
|
|
159
153
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wesl-tooling",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"import-meta-resolve": "^4.1.0",
|
|
13
|
-
"thimbleberry": "^0.2.
|
|
13
|
+
"thimbleberry": "^0.2.10"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"dependent_package": "x",
|