sparcoon 0.9.3 → 0.9.4
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
CHANGED
|
@@ -8,7 +8,7 @@ build.
|
|
|
8
8
|
|
|
9
9
|
**[Open the editor](https://jango-git.github.io/sparcoon-editor/)** -
|
|
10
10
|
[Editor source](https://github.com/jango-git/sparcoon-editor) -
|
|
11
|
-
[npm](https://www.npmjs.com/package/sparcoon/v/0.9.
|
|
11
|
+
[npm](https://www.npmjs.com/package/sparcoon/v/0.9.4)
|
|
12
12
|
|
|
13
13
|
> **Pre-release.** The artifact format is not frozen yet - breaking changes are possible before the
|
|
14
14
|
> first stable release. The package is published under the `experimental` tag: npm's `latest` holds
|
|
@@ -38,6 +38,7 @@ export class FXTransformFeedbackSimulationHolder {
|
|
|
38
38
|
// class's own tests use.
|
|
39
39
|
this.bufferNames = artifact.buffers.map((buffer) => meshPropertyKeyFor(buffer.name));
|
|
40
40
|
this.strides = artifact.buffers.map((buffer) => buffer.stride);
|
|
41
|
+
assertFitsTransformFeedback(gl, artifact.buffers);
|
|
41
42
|
const vertexShader = compileShader(gl, gl.VERTEX_SHADER, artifact.vertexSource);
|
|
42
43
|
const fragmentShader = compileShader(gl, gl.FRAGMENT_SHADER, artifact.fragmentSource);
|
|
43
44
|
const program = gl.createProgram();
|
|
@@ -233,6 +234,27 @@ const FIXED_UNIFORM_NAMES = [
|
|
|
233
234
|
FX_TRANSFORM_FEEDBACK_OBJECT_VELOCITY_UNIFORM,
|
|
234
235
|
FX_TRANSFORM_FEEDBACK_OBJECT_ANGULAR_VELOCITY_UNIFORM,
|
|
235
236
|
];
|
|
237
|
+
/**
|
|
238
|
+
* Throws when `buffers` need more transform-feedback outputs than this GPU offers: one output per
|
|
239
|
+
* buffer (SEPARATE_ATTRIBS), each at most so many components. Checked up front because WebGL does
|
|
240
|
+
* not fail anything visible over it - `transformFeedbackVaryings` only raises a GL error, the
|
|
241
|
+
* program links without its outputs, and every pass then writes nothing, so particles never spawn.
|
|
242
|
+
* The throw instead sends the emitter to its JS kernel (see `FXEmitter.fromArtifacts`). WebGL2
|
|
243
|
+
* guarantees only 4 outputs of 4 components, the two core buffers included.
|
|
244
|
+
*/
|
|
245
|
+
function assertFitsTransformFeedback(gl, buffers) {
|
|
246
|
+
const maxBuffers = gl.getParameter(gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS);
|
|
247
|
+
if (buffers.length > maxBuffers) {
|
|
248
|
+
throw new Error(`FXTransformFeedbackSimulationHolder: the kernel writes ${String(buffers.length)} buffers; ` +
|
|
249
|
+
`this GPU's transform feedback takes at most ${String(maxBuffers)}`);
|
|
250
|
+
}
|
|
251
|
+
const maxComponents = gl.getParameter(gl.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS);
|
|
252
|
+
const wide = buffers.find((buffer) => buffer.stride > maxComponents);
|
|
253
|
+
if (wide !== undefined) {
|
|
254
|
+
throw new Error(`FXTransformFeedbackSimulationHolder: buffer "${wide.name}" has ${String(wide.stride)} ` +
|
|
255
|
+
`components; this GPU's transform feedback takes at most ${String(maxComponents)} per buffer`);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
236
258
|
function compileShader(gl, type, source) {
|
|
237
259
|
const shader = gl.createShader(type);
|
|
238
260
|
if (shader === null) {
|
package/package.json
CHANGED