68 Commits

Author SHA1 Message Date
Gregg Tavares
07e932d04a build 2025-07-15 23:22:47 -07:00
Gregg Tavares
2b0e1daeb1 Support uploading multiple mip levels
This only works for passing arrays. It assumes you pass
however much data is needed for mips up to the level you
want uploaded. In other words. Say your texture is 10x7 RGBA.
Then src would be a TypedArray with 10x7 + 5x3 + 2x1 + 1x1
4 byte texels or exactly 352 bytes.

If you pass (10x7 + 5x3) * 4, which is 340 bytes, then it would
only fill out the first 2 mip levels. That texture would be
unrenderable unless you (1) set filtering to not use mips or
(2) set `maxLevel` to 1 (TEXTURE_MAX_LEVEL).
2025-07-15 23:15:58 -07:00
Gregg Tavares
0128db9cb4 More compressed texture cleanup
* fix colorRenderable, textureFilterable data

  All compressed texture formats are textureFilterable but not
  colorRenderable.

* Support cubemaps

  This code got simpilied. We require the src to by the exact size.
  so we can get the size of a face just by dividing by 6. No need
  for the extra math. This works for both compressed and normal
  textures.

  Added a test
2025-07-11 21:33:05 -07:00
Gregg Tavares
8f53aa82a9 Fix issues with compressed texture support
* Get rid of the compression option

  We know if a texture is compressed based on its internalFormat

* Remove level stuff

  I think there was a mis-understanding how how twgl works. If you
  want to set anything other than level 0 you need to directly
  call `setTextureFormArray` directly (or `setTextureFromElement`)

* Fix tests

  The tests needed to check that the extension exists

Note: we need to decide if and how to handle cubemaps.
The code in their currently will fail. Will fix in next PR
2025-07-11 20:21:23 -07:00
krapnik
e5bf81d26c - update webgl constants
- Optimize the calling parameters of `compressedTexImage2D`
- add `test compressed texture format`
2025-07-12 04:24:03 +08:00
Gregg Tavares
592b9e8112 test it does not delete existing shaders
fix async tests
2025-04-27 10:20:02 +09:00
Gregg Tavares
8e3447fb67 fix createProgram for getting passed WebGLShaders 2025-04-27 09:06:49 +09:00
Gregg Tavares
15a0b487ac skip webgl2-texturess as its timing out??? 2024-11-18 10:23:14 -08:00
Gregg Tavares
8d34a619c5 try use metal 2024-11-18 10:23:14 -08:00
Gregg Tavares
206eb721d1 add more info and use ignore-gpu-blacklist 2024-11-18 10:23:14 -08:00
Gregg Tavares
5f26a88407 remove ignore-block-list 2024-11-18 10:23:14 -08:00
Gregg Tavares
64c6cd8c77 skip dynamic-buffers.html because it timesout 2024-11-18 10:23:14 -08:00
Gregg Tavares
702ed2484f add network idle timeout 2024-11-18 10:23:14 -08:00
Gregg Tavares
3945a2d35e cleanup injected js 2024-11-18 10:23:14 -08:00
Gregg Tavares
33333e3f67 try ignore-gpu-blocklist 2024-11-18 10:23:14 -08:00
Gregg Tavares
2ed2de7d87 add gpu info 2024-11-18 10:23:14 -08:00
Gregg Tavares
3aeba35c17 use macos for test 2024-11-18 10:23:14 -08:00
Gregg Tavares
8b4505cf0f add screenshots to build 2024-11-18 10:23:14 -08:00
Gregg Tavares
b04426a320 fix test 2024-09-07 19:30:03 -07:00
Gregg Tavares
46355ae1d5 Handle the case of async loading and the user changing
the pack state.

Before

    const t = twgl.createTexture({src: 'https://some/img.jpg'});
    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
    // t is flipped

After

    const t = twgl.createTexture({src: 'https://some/img.jpg'});
    gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true);
    // t is not flipped
2024-09-07 18:49:41 -07:00
Gregg Tavares
f95b9def52 dist/5.x -> dist/6.x 2024-09-07 10:30:19 -07:00
Gregg Tavares
cceaa19c47 Fix pixel store issues
Internal change. `gl.pixelStorei` state for `UNPACK_COLORSPACE_CONVERSION_WEBGL`
`UNPACK_PREMULTIPLY_ALPHA_WEBGL` and `UNPACK_FLIP_Y_WEBGL`
is now saved and restored as the previous behavior had a race condition.

Before

```js
t1 = twgl.createTexture(gl, {src: 'https://p.com/slow.jpg'});  // may or may not be flipped!!!!
t2 = twgl.createTexture(gl, {src: 'https://p.com/fast.jpg', flipY: true });  // flipped
```

In the example above, whether or not `t1` is flipped was unknown
since if `t2` loads first, it would be flipped. If `t1` loads first
it would not be flipped.

The fix is to save and restore the `pixelStorei` state for each texture.

Unfortunately, this is a breaking change.

Before

```js
twgl.createTexture(gl, {src: someImageElem1, flipY: true });  // flipped
twgl.createTexture(gl, {src: someImageElem2 });               // also flipped
```

after

```js
twgl.createTexture(gl, {src: someImage, flipY: true });  // flipped
twgl.createTexture(gl, {src: someImage });               // NOT flipped
```

Note: in all versions the behavior was and still is, that if you set
the `pixelStorei` parameters outside they applied.

```js
gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, true)
twgl.createTexture(gl, {src: someImage });  // flipped
twgl.createTexture(gl, {src: someImage });  // flipped
```
2024-09-07 10:24:54 -07:00
Gregg Tavares
ca9c1eb929 add a few ts tests 2024-02-28 13:48:32 -08:00
Gregg Tavares
c47cf5ec9a try to type createAugmentedTypedArray 2023-07-14 10:04:24 -07:00
Zack Gomez
aed92542c6 allow setting null textures to sampler arrays 2023-03-17 01:01:23 +09:00
Gregg Tavares
f113b4dcca Allow binding null for texture via setUniforms 2022-11-28 07:59:43 -08:00
Gregg Tavares
a5cf37cd0f add createPrograms, createProgramInfos, createProgramsAsync, and createProgramInfosAsync 2022-10-21 22:22:36 -07:00
Gregg Tavares
aec377cf66 fix types 2022-10-18 14:54:25 -07:00
Gregg Tavares
20a2d8016a cleanup 2022-10-18 09:42:43 -07:00
Gregg Tavares
6bab1b51ed test examples 2022-09-30 20:44:17 -07:00
Gregg Tavares
1e81747d9a fix isX so passing in a non-object returns false 2022-09-30 16:45:19 -07:00
Gregg Tavares
22ca57dcaa add helper tests 2022-09-27 10:20:24 -07:00
Gregg Tavares
2cd51db876 4.x => 5.x 2022-09-10 23:05:13 -07:00
Gregg Tavares
675f9253e9 set drawBuffers 2022-07-07 14:26:40 -07:00
Gregg Tavares
412535bdf8 handle only value attributes 2022-07-03 17:20:07 -07:00
Gregg Tavares
dda1603785 update mocha 2022-06-23 00:07:48 -07:00
Gregg Tavares
81908bacf9 add timeout support 2022-06-12 18:23:09 -07:00
Gregg Tavares
c95eb78e43 fix bugs in programs.js that async introduced 2022-06-12 18:22:55 -07:00
Gregg Tavares
14917f801a add async compilation 2022-06-11 20:36:52 -07:00
Gregg Tavares
297e0d15de add samples to AttachmentOptions 2022-03-24 21:49:45 -07:00
Gregg Tavares
f8141e996f move old tests to new test harness 2021-09-27 13:32:02 -07:00
Gregg Tavares
438fb4a117 typo 2021-09-27 12:04:47 -07:00
Gregg Tavares
81fef1221b add support for partial uniform paths 2021-09-26 18:26:42 -07:00
Gregg Tavares
4853c9eed0 add support uniform structs/arrays 2021-09-26 16:28:09 -07:00
Gregg Tavares
18829680ee Experiment with uniform-tree support
This is just an experiement. I haven't decided if this is going to be added or not

Trying out, given uniforms like this.

```
    struct Extra {
      float f;
      vec4 v4;
      vec3 v3;
    };
    struct Light {
      float intensity;
      vec4 color;
      float nearFar[2];
      Extra extra[2];
    };
    uniform Light lights[2];
```

You can set them like this

```
twgl.setUniformTree(programInfo, {
  lights:[
    { intensity: 1.5, color: [1, 0, 0, 1], nearFar: [0.1, 1.0], extra: [ f: 0.1, v4: [1.2, 3.4, 1.2, 1.4], v3: [0, 1, 2], },
    { intensity: 2.3, color: [0, 0, 1, 1], nearFar: [0.1, 1.0], extra: [ f: 0.7, v4: [3.1, 7.9, 0.6, 5.8], v3: [4, 5, 6], },
  ],
});
```
2021-09-25 02:57:55 -07:00
Gregg Tavares
7a8890299f add itWebGL and itWebGL2 test helpers 2021-09-24 12:38:46 -07:00
Gregg Tavares
d766db311a remove console.log 2021-09-24 11:47:35 -07:00
Gregg Tavares
2340129465 fix issue with Uniform blocks and built in uniforms 2021-09-24 11:43:40 -07:00
Gregg Tavares
b033805847 add puppeteer test 2021-09-24 08:49:49 -07:00
Gregg Tavares
cfabc653df fix uniform block setting 2021-09-23 17:00:48 -07:00