Commit graph

19585 commits

Author SHA1 Message Date
Ben Richards
c43a45d985 Allow RenderNodeManager to change parallel texture unit count.
The BatchTexturedTintedRawQuads node listens to this, and will
recompile its shader to the indicated performance strategy.
2024-05-14 17:03:00 +12:00
Ben Richards
d120e0a4b5 Fix invalid create and destroy code in Program Wrapper.
There is no `deleteUniformLocation` command. (Thanks, AI hallucinations!)
2024-05-14 16:14:56 +12:00
Ben Richards
e57ed463b2 Reduce accessor use in VAO wrapper. 2024-05-13 15:25:50 +12:00
Ben Richards
c8c170672d Use sub-batches to handle many textures in batches.
This is the way 3.80 handles things, and is useful for performance on
mobile devices where we might only use 1 texture unit per sub-batch.
2024-05-13 15:23:01 +12:00
Richard Davey
2c1ad33e1a Update const.js 2024-05-02 14:41:51 +01:00
Ben Richards
717bd96879 Fix the last missing data from DrawingContext clones.
I hope.
2024-05-02 18:42:42 +12:00
Ben Richards
e7f1269c12 Fix DrawingContext missing critical data. 2024-05-02 18:36:55 +12:00
Ben Richards
f3d1da68a9 Fix and tidy code.
Fix camera background color not working (a call signature changed).
Fix render graph only recording the last camera
(by adding a synthetic root node to the graph).
2024-05-02 16:47:28 +12:00
Ben Richards
65e69a8369 Unify flipped crop handling. 2024-05-02 14:41:01 +12:00
Ben Richards
ee8ebbdd1c Render Video using the new system. 2024-05-01 18:36:29 +12:00
Ben Richards
f86a353a2d Render Text using the new system.
It may be more correct than ever, now that we've standardised it.
2024-05-01 17:34:23 +12:00
Ben Richards
3140edf0c3 Fix Text UV updates.
Previously, Text didn't update the TextureSource dimensions,
so its UVs were identical to resolution.
They should have been normalized to the 0-1 range.
It used `MultiPipeline.batchTexture` to render, which accommodated
these UVs.
These changes update the dimensions when Text changes its canvas size,
and this makes normalized UVs available.
2024-05-01 15:58:45 +12:00
Ben Richards
48d1164c16 Swap order of src and drawingContext parameters.
This makes the standard `renderWebGL` parameters more similar to their
original state: we're just replacing `camera` with `drawingContext`.
2024-04-30 18:09:25 +12:00
Ben Richards
45e89e4574 Make camera part of DrawingContext, and simplify RenderNode calls. 2024-04-30 16:58:45 +12:00
Ben Richards
9bf0276af9 Improve renderer event handling.
Hook batch rendering into resize events.
Fix context restore:
- Restore VAOs
- Fix Program uniform restore.
2024-04-30 12:14:10 +12:00
Ben Richards
061fd21e5f Disable PipelineManager in WebGLRenderer.
This eliminates a lot of unused resources. Some will be recreated later,
but for now it keeps development simple.
I'm not actually removing it, because I want to reference where it is
used for the moment.
2024-04-30 11:45:04 +12:00
Ben Richards
d8a64110f9 Add camera flash and fade effects. 2024-04-29 17:48:27 +12:00
Ben Richards
a7cc7472a6 Add FillRect render node, and camera background fill.
Also use a TextureWrapper instead of a Frame for quad batching,
which makes this possible.
2024-04-29 17:06:21 +12:00
Ben Richards
d43e45d2a4 Handle blend mode in DrawingContext and use it in ListCompositor. 2024-04-29 15:06:43 +12:00
Ben Richards
ef4731c8b1 Avoid Camera generating unchanged DrawingContext. 2024-04-29 10:21:43 +12:00
Ben Richards
45a73c1d2d Complete canvas clear logic. 2024-04-26 20:34:36 +12:00
Ben Richards
af2e4449a0 Add scissor handling and simplify clearing on DrawingContext.
Clearing was just too complex. It was optimized for edge cases,
and made it hard to create DrawingContexts for multiple cameras
drawing to the same framebuffer.
2024-04-26 19:05:32 +12:00
Ben Richards
a007adf05b Document and add textures to main draw method. 2024-04-26 12:14:38 +12:00
Ben Richards
2c2d856b14 Improve batch texture performance. 2024-04-26 11:20:38 +12:00
Ben Richards
dd2bc50628 Fix batch flushing at texture limit instead of over limit. 2024-04-24 17:05:26 +12:00
Ben Richards
ecda5880da Add WebGLVertexBufferLayoutWrapper to standardise buffer handling. 2024-04-24 16:03:10 +12:00
Ben Richards
3b4956cc16 Simplify vertex buffer length. 2024-04-24 11:16:23 +12:00
Ben Richards
b00a6fdc04 Fix massive memory usage and non-managed program. 2024-04-24 11:05:15 +12:00
Ben Richards
a26972d77e Do matrix transforms in vertex shader. 2024-04-23 21:07:34 +12:00
Ben Richards
cc78cf9480 Fix old framebuffer invocation. 2024-04-23 16:32:16 +12:00
Ben Richards
8d790b6ac4 Add basic RenderNode system.
This currently only handles basic multi-textured images/sprites
through a basic camera. It forms the basis of a major overhaul.

We assume everything is based on independent quads.
Our shaders are initialized with VAOs,
and drawn using instanced quads.
The buffer memory usage is about 1/6th previous.

Most render systems don't work, and WebGLRenderer is a mess.
That's OK; we just needed to get this committed before it got any
more complicated.
2024-04-23 16:29:08 +12:00
Ben Richards
9b5a21f20f Integrate Program Wrapper changes to WebGLRenderer.
Also define some return types.
2024-04-23 16:21:26 +12:00
Ben Richards
c95c8c527a Add DrawingContext for tracking current drawing settings.
This is not at all complete yet, but it's doing some useful stuff.
2024-04-23 16:18:38 +12:00
Ben Richards
4f367741b7 Add renderbuffer handling to WebGLFramebufferWrapper. 2024-04-23 16:17:02 +12:00
Ben Richards
d33845eb3b Add Vertex Array Object (VAO) wrapper.
Add VAO to global state.
Define a way to clearly denote attribute buffer layout.
Integrate buffer layout into Program Wrapper for auto-completion.
2024-04-23 16:09:09 +12:00
Ben Richards
fbcc3580a5 Add padding support to WebGLProgramWrapper.setVertexBuffer layout. 2024-03-28 15:20:21 +13:00
Ben Richards
30eef85537 Upgrade WebGLProgramWrapper to set uniforms and attributes.
This necessitated expanding the map of WebGL constants/functions,
resulting in `WebGLShaderSetterWrapper`.
2024-03-26 13:12:53 +13:00
Ben Richards
de3fc50979 Upgrade WebGLProgramWrapper to generate uniforms and attributes.
It assumes that programs do not change after creation, so these values
are static, and much can be inferred about their behaviour.
Uniform-setting code is implemented and has been tested on Shader.
Attribute binding has not been finished.
- Change `gl` parameter to `renderer`.
2024-03-22 17:09:59 +13:00
Ben Richards
8272cf1a26 Fix reference to old resources on context restore. 2024-03-22 11:22:08 +13:00
Ben Richards
419d846498 Update WebGLBufferWrapper to use WebGLGlobalWrapper.
- Add `WebGLBufferWrapper.bind` to simplify attachment.
- Change `WebGLBufferWrapper` parameter `gl` to `renderer`.
2024-03-20 17:12:19 +13:00
Ben Richards
7cdd59eaf0 Make WebGLTextureUnitsWrapper.bind parameter units mandatory.
Allowing it to search for textures caused anomalies in video textures.
2024-03-20 16:16:07 +13:00
Ben Richards
4de15331dd Deprecate WebGLPipeline.bindTexture. 2024-03-20 15:53:50 +13:00
Ben Richards
13ed52f478 Use TextureUnits binding throughout the codebase.
- Remove `WebGLPipeline.activeTextures`, which is now covered by
  the more universal TextureUnit system.
- Change TextureUnitsWrapper to only bind `activeTexture` if the texture
  is not bound to that unit already.
- Remove `gl.isContextLost` check from `WebGLTextureWrapper`.
  The process should run without effect if context is lost,
  and we skip fetching data if it is not.
2024-03-19 22:08:59 +13:00
Ben Richards
d02c1f4a70 Fix WebGL background color. 2024-03-19 16:45:01 +13:00
Ben Richards
741fb897bd Implement WebGLRenderer.clearFramebuffer and use it. 2024-03-19 16:37:22 +13:00
Ben Richards
32bdb8ef0e Implement WebGLTextureUnitsWrapper and manage core texture ops with it.
Also tweak several related areas:
- Use `glWrapper` in `PipelineManager.rebind`, making WebGL state
  redeclaration more succinct.
- Add `WebGLRenderer.glTextureUnits` property.
- Deprecate `WebGLRenderer.textureindexes` property.
- Simplify WebGL context restoration with `glWrapper`.
- Remove `WebGLRenderer.createTemporaryTextures`.
- Remove texture units and binding from WebGLGlobalParameters.
- Change `WebGLTextureWrapper` to take `renderer` instead of `gl` as its
  first parameter. This allows us to use `glWrapper` code internally.
- `WebGLTextureWrapper` currently doesn't unbind textures after use,
  which might cause issues with framebuffers etc. We'll ensure that
  state management makes this a non-issue.
2024-03-19 14:52:49 +13:00
Ben Richards
46c9c95c02 Implement WebGLGlobalWrapper and manage blend modes with it.
The Wrapper won't do its job until everything uses wrappers,
but this is a start.
API changes:
- WebGLRenderer.blendModes type is now WebGLBlendParameters[]
  instead of untyped array.
- WebGLRenderer.updateBlendMode parameters now specify how to use
  separate parameters. The function no longer treats the `equation`
  parameter as optional.
2024-03-17 19:26:35 +13:00
Ben Richards
5b0af2f34c Correct transpose parameter for gl.uniformMatrixNfv().
The `transpose` property is never defined.
2024-03-08 18:28:24 +13:00
Ben Richards
9898a6aaae Update documentation on using compressed textures.
Correct the multiAtlas example.
Remove link to Mali, which has been discontinued.
Expand guidance on making valid compressed textures.
2024-03-07 18:06:51 +13:00
Ben Richards
0a2bede95e Limit textures probed by TextureManager.getPixel and getPixelAlpha. 2024-03-05 15:42:04 +13:00