Skip to content

Commit

Permalink
Added docs for supported HDR formats
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valigursky committed May 10, 2024
1 parent c3c7e6c commit 3317a57
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/platform/graphics/graphics-device.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,15 @@ class GraphicsDevice extends EventHandler {
*/
textureHalfFloatRenderable;

/**
* True if small-float texture in format {@link PIXELFORMAT_111110F} can be used as a frame
* buffer. This is always true on WebGL2, but optional on WebGPU device.
*
* @type {boolean}
* @readonly
*/
textureRG11B10Renderable = false;

/**
* True if filtering can be applied when sampling float textures.
*
Expand Down Expand Up @@ -855,6 +864,9 @@ class GraphicsDevice extends EventHandler {
/**
* Get a renderable HDR pixel format supported by the graphics device.
*
* Note: On WebGL2 and WebGPU, this function returns at least one of the supported formats on
* all devices apart from some very old iOS and Android devices.
*
* @param {number[]} [formats] - An array of pixel formats to check for support. Can contain:
*
* - {@link PIXELFORMAT_111110F}
Expand Down
20 changes: 20 additions & 0 deletions src/platform/graphics/texture.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,26 @@ let id = 0;
* A texture is a container for texel data that can be utilized in a fragment shader. Typically,
* the texel data represents an image that is mapped over geometry.
*
* Note on **HDR texture format** support:
* 1. **As textures**:
* - float (e.x. {@link PIXELFORMAT_RGBA32F}), half-float (e.x. {@link PIXELFORMAT_RGBA16F}) and
* small-float ({@link PIXELFORMAT_111110F}) formats are always supported on both WebGL2 and WebGPU
* with point sampling.
* - half-float and small-float formats are always supported on WebGL2 and WebGPU with linear sampling.
* - float formats are supported on WebGL2 and WebGPU with linear sampling only if
* {@link GraphicsDevice#textureFloatFilterable} is true.
*
* 2. **As renderable textures** that can be used as color buffers in a {@link RenderTarget}:
* - on WebGPU, rendering to float and half-float formats is always supported.
* - on WebGPU, rendering to small-float format is supported only if
* {@link GraphicsDevice#textureRG11B10Renderable} is true.
* - on WebGL2, rendering to these 3 formats formats is supported only if
* {@link GraphicsDevice#textureFloatRenderable} is true.
* - on WebGL2, if {@link GraphicsDevice#textureFloatRenderable} is false, but
* {@link GraphicsDevice#textureHalfFloatRenderable} is true, rendering to half-float formats only
* is supported. This is the case of many mobile iOS devices.
* - you can determine available renderable HDR format using
* {@link GraphicsDevice#getRenderableHdrFormat}.
* @category Graphics
*/
class Texture {
Expand Down

0 comments on commit 3317a57

Please sign in to comment.