diff --git a/src/platform/graphics/constants.js b/src/platform/graphics/constants.js index 20ae2438b59..a4d0eea0bbd 100644 --- a/src/platform/graphics/constants.js +++ b/src/platform/graphics/constants.js @@ -278,7 +278,7 @@ export const BUFFER_STREAM = 2; /** * The data store contents will be modified repeatedly on the GPU and used many times. Optimal for - * transform feedback usage (WebGL2 only). + * transform feedback usage. * * @type {number} * @category Graphics @@ -653,7 +653,7 @@ export const PIXELFORMAT_RGB32F = 13; export const PIXELFORMAT_RGBA32F = 14; /** - * 32-bit floating point single channel format (WebGL2 only). + * 32-bit floating point single channel format. * * @type {number} * @category Graphics @@ -669,7 +669,7 @@ export const PIXELFORMAT_R32F = 15; export const PIXELFORMAT_DEPTH = 16; /** - * A readable depth/stencil buffer format (WebGL2 only). + * A readable depth/stencil buffer format. * * @type {number} * @category Graphics @@ -678,7 +678,7 @@ export const PIXELFORMAT_DEPTHSTENCIL = 17; /** * A floating-point color-only format with 11 bits for red and green channels and 10 bits for the - * blue channel (WebGL2 only). + * blue channel. * * @type {number} * @category Graphics @@ -686,7 +686,7 @@ export const PIXELFORMAT_DEPTHSTENCIL = 17; export const PIXELFORMAT_111110F = 18; /** - * Color-only sRGB format (WebGL2 only). + * Color-only sRGB format. * * @type {number} * @category Graphics @@ -694,7 +694,7 @@ export const PIXELFORMAT_111110F = 18; export const PIXELFORMAT_SRGB = 19; /** - * Color sRGB format with additional alpha channel (WebGL2 only). + * Color sRGB format with additional alpha channel. * * @type {number} * @category Graphics @@ -791,7 +791,7 @@ export const PIXELFORMAT_ATC_RGBA = 30; export const PIXELFORMAT_BGRA8 = 31; /** - * 8-bit signed integer single-channel (R) format (Not supported by WebGL1). + * 8-bit signed integer single-channel (R) format. * * @type {number} * @category Graphics @@ -799,7 +799,7 @@ export const PIXELFORMAT_BGRA8 = 31; export const PIXELFORMAT_R8I = 32; /** - * 8-bit unsigned integer single-channel (R) format (Not supported by WebGL1). + * 8-bit unsigned integer single-channel (R) format. * * @type {number} * @category Graphics @@ -807,7 +807,7 @@ export const PIXELFORMAT_R8I = 32; export const PIXELFORMAT_R8U = 33; /** - * 16-bit signed integer single-channel (R) format (Not supported by WebGL1). + * 16-bit signed integer single-channel (R) format. * * @type {number} * @category Graphics @@ -815,7 +815,7 @@ export const PIXELFORMAT_R8U = 33; export const PIXELFORMAT_R16I = 34; /** - * 16-bit unsigned integer single-channel (R) format (Not supported by WebGL1). + * 16-bit unsigned integer single-channel (R) format. * * @type {number} * @category Graphics @@ -823,7 +823,7 @@ export const PIXELFORMAT_R16I = 34; export const PIXELFORMAT_R16U = 35; /** - * 32-bit signed integer single-channel (R) format (Not supported by WebGL1). + * 32-bit signed integer single-channel (R) format. * * @type {number} * @category Graphics @@ -831,7 +831,7 @@ export const PIXELFORMAT_R16U = 35; export const PIXELFORMAT_R32I = 36; /** - * 32-bit unsigned integer single-channel (R) format (Not supported by WebGL1). + * 32-bit unsigned integer single-channel (R) format. * * @type {number} * @category Graphics @@ -839,7 +839,7 @@ export const PIXELFORMAT_R32I = 36; export const PIXELFORMAT_R32U = 37; /** - * 8-bit per-channel signed integer (RG) format (Not supported by WebGL1). + * 8-bit per-channel signed integer (RG) format. * * @type {number} * @category Graphics @@ -847,7 +847,7 @@ export const PIXELFORMAT_R32U = 37; export const PIXELFORMAT_RG8I = 38; /** - * 8-bit per-channel unsigned integer (RG) format (Not supported by WebGL1). + * 8-bit per-channel unsigned integer (RG) format. * * @type {number} * @category Graphics @@ -855,7 +855,7 @@ export const PIXELFORMAT_RG8I = 38; export const PIXELFORMAT_RG8U = 39; /** - * 16-bit per-channel signed integer (RG) format (Not supported by WebGL1). + * 16-bit per-channel signed integer (RG) format. * * @type {number} * @category Graphics @@ -863,7 +863,7 @@ export const PIXELFORMAT_RG8U = 39; export const PIXELFORMAT_RG16I = 40; /** - * 16-bit per-channel unsigned integer (RG) format (Not supported by WebGL1). + * 16-bit per-channel unsigned integer (RG) format. * * @type {number} * @category Graphics @@ -871,7 +871,7 @@ export const PIXELFORMAT_RG16I = 40; export const PIXELFORMAT_RG16U = 41; /** - * 32-bit per-channel signed integer (RG) format (Not supported by WebGL1). + * 32-bit per-channel signed integer (RG) format. * * @type {number} * @category Graphics @@ -879,7 +879,7 @@ export const PIXELFORMAT_RG16U = 41; export const PIXELFORMAT_RG32I = 42; /** - * 32-bit per-channel unsigned integer (RG) format (Not supported by WebGL1). + * 32-bit per-channel unsigned integer (RG) format. * * @type {number} * @category Graphics @@ -887,7 +887,7 @@ export const PIXELFORMAT_RG32I = 42; export const PIXELFORMAT_RG32U = 43; /** - * 8-bit per-channel signed integer (RGBA) format (Not supported by WebGL1). + * 8-bit per-channel signed integer (RGBA) format. * * @type {number} * @category Graphics @@ -895,7 +895,7 @@ export const PIXELFORMAT_RG32U = 43; export const PIXELFORMAT_RGBA8I = 44; /** - * 8-bit per-channel unsigned integer (RGBA) format (Not supported by WebGL1). + * 8-bit per-channel unsigned integer (RGBA) format. * * @type {number} * @category Graphics @@ -903,7 +903,7 @@ export const PIXELFORMAT_RGBA8I = 44; export const PIXELFORMAT_RGBA8U = 45; /** - * 16-bit per-channel signed integer (RGBA) format (Not supported by WebGL1). + * 16-bit per-channel signed integer (RGBA) format. * * @type {number} * @category Graphics @@ -911,7 +911,7 @@ export const PIXELFORMAT_RGBA8U = 45; export const PIXELFORMAT_RGBA16I = 46; /** - * 16-bit per-channel unsigned integer (RGBA) format (Not supported by WebGL1). + * 16-bit per-channel unsigned integer (RGBA) format. * * @type {number} * @category Graphics @@ -919,7 +919,7 @@ export const PIXELFORMAT_RGBA16I = 46; export const PIXELFORMAT_RGBA16U = 47; /** - * 32-bit per-channel signed integer (RGBA) format (Not supported by WebGL1). + * 32-bit per-channel signed integer (RGBA) format. * * @type {number} * @category Graphics @@ -927,7 +927,7 @@ export const PIXELFORMAT_RGBA16U = 47; export const PIXELFORMAT_RGBA32I = 48; /** - * 32-bit per-channel unsigned integer (RGBA) format (Not supported by WebGL1). + * 32-bit per-channel unsigned integer (RGBA) format. * * @type {number} * @category Graphics @@ -953,7 +953,7 @@ export const PIXELFORMAT_RG16F = 51; // map of engine PIXELFORMAT_*** enums to information about the format export const pixelFormatInfo = new Map([ - // uncompressed formats + // float formats [PIXELFORMAT_A8, { name: 'A8', size: 1 }], [PIXELFORMAT_L8, { name: 'L8', size: 1 }], [PIXELFORMAT_LA8, { name: 'LA8', size: 2 }], @@ -991,7 +991,7 @@ export const pixelFormatInfo = new Map([ [PIXELFORMAT_ATC_RGB, { name: 'ATC_RGB', blockSize: 8 }], [PIXELFORMAT_ATC_RGBA, { name: 'ATC_RGBA', blockSize: 16 }], - // uncompressed integer formats (Not supported on WebGL1) + // integer formats [PIXELFORMAT_R8I, { name: 'R8I', size: 1, isInt: true }], [PIXELFORMAT_R8U, { name: 'R8U', size: 1, isInt: true }], [PIXELFORMAT_R16I, { name: 'R16I', size: 2, isInt: true }], @@ -1694,7 +1694,7 @@ export const TYPE_UINT32 = 5; export const TYPE_FLOAT32 = 6; /** - * 16-bit floating point vertex element type (not supported by WebGL1). + * 16-bit floating point vertex element type. * * @type {number} * @category Graphics diff --git a/src/platform/graphics/texture.js b/src/platform/graphics/texture.js index f082af884e6..11b5bfc0a5c 100644 --- a/src/platform/graphics/texture.js +++ b/src/platform/graphics/texture.js @@ -71,7 +71,7 @@ class Texture { * @param {string} [options.name] - The name of the texture. Defaults to null. * @param {number} [options.width] - The width of the texture in pixels. Defaults to 4. * @param {number} [options.height] - The height of the texture in pixels. Defaults to 4. - * @param {number} [options.depth] - The number of depth slices in a 3D texture (not supported by WebGl1). + * @param {number} [options.depth] - The number of depth slices in a 3D texture. * @param {number} [options.format] - The pixel format of the texture. Can be: * * - {@link PIXELFORMAT_A8} @@ -128,9 +128,9 @@ class Texture { * Defaults to false. * @param {number} [options.arrayLength] - Specifies whether the texture is to be a 2D texture array. * When passed in as undefined or < 1, this is not an array texture. If >= 1, this is an array texture. - * (not supported by WebGL1). Defaults to undefined. - * @param {boolean} [options.volume] - Specifies whether the texture is to be a 3D volume - * (not supported by WebGL1). Defaults to false. + * Defaults to undefined. + * @param {boolean} [options.volume] - Specifies whether the texture is to be a 3D volume. + * Defaults to false. * @param {string} [options.type] - Specifies the texture type. Can be: * * - {@link TEXTURETYPE_DEFAULT} @@ -150,10 +150,10 @@ class Texture { * present) is multiplied into the color channels. Defaults to false. * @param {boolean} [options.compareOnRead] - When enabled, and if texture format is * {@link PIXELFORMAT_DEPTH} or {@link PIXELFORMAT_DEPTHSTENCIL}, hardware PCF is enabled for - * this texture, and you can get filtered results of comparison using texture() in your shader - * (not supported by WebGL1). Defaults to false. - * @param {number} [options.compareFunc] - Comparison function when compareOnRead is enabled - * (not supported by WebGL1). Can be: + * this texture, and you can get filtered results of comparison using texture() in your shader. + * Defaults to false. + * @param {number} [options.compareFunc] - Comparison function when compareOnRead is enabled. + * Can be: * * - {@link FUNC_LESS} * - {@link FUNC_LESSEQUAL} @@ -485,7 +485,7 @@ class Texture { } /** - * The addressing mode to be applied to the 3D texture depth (not supported on WebGL1). Can be: + * The addressing mode to be applied to the 3D texture depth. Can be: * * - {@link ADDRESS_REPEAT} * - {@link ADDRESS_CLAMP_TO_EDGE} @@ -512,7 +512,7 @@ class Texture { /** * When enabled, and if texture format is {@link PIXELFORMAT_DEPTH} or * {@link PIXELFORMAT_DEPTHSTENCIL}, hardware PCF is enabled for this texture, and you can get - * filtered results of comparison using texture() in your shader (not supported on WebGL1). + * filtered results of comparison using texture() in your shader. * * @type {boolean} */ @@ -528,7 +528,7 @@ class Texture { } /** - * Comparison function when compareOnRead is enabled (not supported on WebGL1). Possible values: + * Comparison function when compareOnRead is enabled. Possible values: * * - {@link FUNC_LESS} * - {@link FUNC_LESSEQUAL} diff --git a/src/platform/graphics/webgl/webgl-texture.js b/src/platform/graphics/webgl/webgl-texture.js index e319cd5a2c6..c181a517c3a 100644 --- a/src/platform/graphics/webgl/webgl-texture.js +++ b/src/platform/graphics/webgl/webgl-texture.js @@ -136,12 +136,12 @@ class WebglTexture { break; case PIXELFORMAT_RGB8: this._glFormat = gl.RGB; - this._glInternalFormat = device.isWebGL2 ? gl.RGB8 : gl.RGB; + this._glInternalFormat = gl.RGB8; this._glPixelType = gl.UNSIGNED_BYTE; break; case PIXELFORMAT_RGBA8: this._glFormat = gl.RGBA; - this._glInternalFormat = device.isWebGL2 ? gl.RGBA8 : gl.RGBA; + this._glInternalFormat = gl.RGBA8; this._glPixelType = gl.UNSIGNED_BYTE; break; case PIXELFORMAT_DXT1: @@ -197,202 +197,157 @@ class WebglTexture { this._glInternalFormat = device.extCompressedTextureATC.COMPRESSED_RGBA_ATC_INTERPOLATED_ALPHA_WEBGL; break; case PIXELFORMAT_R16F: - if (device.isWebGL2) { - this._glFormat = gl.RED; - this._glInternalFormat = gl.R16F; - this._glPixelType = gl.HALF_FLOAT; - } else { - this._glFormat = gl.LUMINANCE; - this._glInternalFormat = gl.LUMINANCE; - this._glPixelType = device.extTextureHalfFloat.HALF_FLOAT_OES; - } + this._glFormat = gl.RED; + this._glInternalFormat = gl.R16F; + this._glPixelType = gl.HALF_FLOAT; break; case PIXELFORMAT_RG16F: - if (device.isWebGL2) { - this._glFormat = gl.RG; - this._glInternalFormat = gl.RG16F; - this._glPixelType = gl.HALF_FLOAT; - } else { - this._glFormat = gl.RG; - this._glInternalFormat = gl.RG; - this._glPixelType = device.extTextureHalfFloat.HALF_FLOAT_OES; - } + this._glFormat = gl.RG; + this._glInternalFormat = gl.RG16F; + this._glPixelType = gl.HALF_FLOAT; break; case PIXELFORMAT_RGB16F: - // definition varies between WebGL1 and 2 this._glFormat = gl.RGB; - if (device.isWebGL2) { - this._glInternalFormat = gl.RGB16F; - this._glPixelType = gl.HALF_FLOAT; - } else { - this._glInternalFormat = gl.RGB; - this._glPixelType = device.extTextureHalfFloat.HALF_FLOAT_OES; - } + this._glInternalFormat = gl.RGB16F; + this._glPixelType = gl.HALF_FLOAT; break; case PIXELFORMAT_RGBA16F: - // definition varies between WebGL1 and 2 this._glFormat = gl.RGBA; - if (device.isWebGL2) { - this._glInternalFormat = gl.RGBA16F; - this._glPixelType = gl.HALF_FLOAT; - } else { - this._glInternalFormat = gl.RGBA; - this._glPixelType = device.extTextureHalfFloat.HALF_FLOAT_OES; - } + this._glInternalFormat = gl.RGBA16F; + this._glPixelType = gl.HALF_FLOAT; break; case PIXELFORMAT_RGB32F: - // definition varies between WebGL1 and 2 this._glFormat = gl.RGB; - if (device.isWebGL2) { - this._glInternalFormat = gl.RGB32F; - } else { - this._glInternalFormat = gl.RGB; - } + this._glInternalFormat = gl.RGB32F; this._glPixelType = gl.FLOAT; break; case PIXELFORMAT_RGBA32F: - // definition varies between WebGL1 and 2 this._glFormat = gl.RGBA; - if (device.isWebGL2) { - this._glInternalFormat = gl.RGBA32F; - } else { - this._glInternalFormat = gl.RGBA; - } + this._glInternalFormat = gl.RGBA32F; this._glPixelType = gl.FLOAT; break; - case PIXELFORMAT_R32F: // WebGL2 only + case PIXELFORMAT_R32F: this._glFormat = gl.RED; this._glInternalFormat = gl.R32F; this._glPixelType = gl.FLOAT; break; case PIXELFORMAT_DEPTH: - if (device.isWebGL2) { - // native WebGL2 - this._glFormat = gl.DEPTH_COMPONENT; - this._glInternalFormat = gl.DEPTH_COMPONENT32F; // should allow 16/24 bits? - this._glPixelType = gl.FLOAT; - } else { - // using WebGL1 extension - this._glFormat = gl.DEPTH_COMPONENT; - this._glInternalFormat = gl.DEPTH_COMPONENT; - this._glPixelType = gl.UNSIGNED_SHORT; // the only acceptable value? - } + this._glFormat = gl.DEPTH_COMPONENT; + this._glInternalFormat = gl.DEPTH_COMPONENT32F; // should allow 16/24 bits? + this._glPixelType = gl.FLOAT; break; case PIXELFORMAT_DEPTHSTENCIL: this._glFormat = gl.DEPTH_STENCIL; - if (device.isWebGL2) { - this._glInternalFormat = gl.DEPTH24_STENCIL8; - this._glPixelType = gl.UNSIGNED_INT_24_8; - } else { - this._glInternalFormat = gl.DEPTH_STENCIL; - this._glPixelType = device.extDepthTexture.UNSIGNED_INT_24_8_WEBGL; - } + this._glInternalFormat = gl.DEPTH24_STENCIL8; + this._glPixelType = gl.UNSIGNED_INT_24_8; break; - case PIXELFORMAT_111110F: // WebGL2 only - Debug.assert(device.isWebGL2, "PIXELFORMAT_111110F texture format is not supported by WebGL1."); + case PIXELFORMAT_111110F: this._glFormat = gl.RGB; this._glInternalFormat = gl.R11F_G11F_B10F; this._glPixelType = gl.UNSIGNED_INT_10F_11F_11F_REV; break; - case PIXELFORMAT_SRGB: // WebGL2 only + case PIXELFORMAT_SRGB: this._glFormat = gl.RGB; this._glInternalFormat = gl.SRGB8; this._glPixelType = gl.UNSIGNED_BYTE; break; - case PIXELFORMAT_SRGBA: // WebGL2 only + case PIXELFORMAT_SRGBA: this._glFormat = gl.RGBA; this._glInternalFormat = gl.SRGB8_ALPHA8; this._glPixelType = gl.UNSIGNED_BYTE; break; - // Integer texture formats (R) (WebGL2 only) - case PIXELFORMAT_R8I: // WebGL2 only + + // Integer texture formats (R) + case PIXELFORMAT_R8I: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R8I; this._glPixelType = gl.BYTE; break; - case PIXELFORMAT_R8U: // WebGL2 only + case PIXELFORMAT_R8U: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R8UI; this._glPixelType = gl.UNSIGNED_BYTE; break; - case PIXELFORMAT_R16I: // WebGL2 only + case PIXELFORMAT_R16I: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R16I; this._glPixelType = gl.SHORT; break; - case PIXELFORMAT_R16U: // WebGL2 only + case PIXELFORMAT_R16U: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R16UI; this._glPixelType = gl.UNSIGNED_SHORT; break; - case PIXELFORMAT_R32I: // WebGL2 only + case PIXELFORMAT_R32I: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R32I; this._glPixelType = gl.INT; break; - case PIXELFORMAT_R32U: // WebGL2 only + case PIXELFORMAT_R32U: this._glFormat = gl.RED_INTEGER; this._glInternalFormat = gl.R32UI; this._glPixelType = gl.UNSIGNED_INT; break; - // Integer texture formats (RG) (WebGL2 only) - case PIXELFORMAT_RG8I: // WebGL2 only + + // Integer texture formats (RG) + case PIXELFORMAT_RG8I: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG8I; this._glPixelType = gl.BYTE; break; - case PIXELFORMAT_RG8U: // WebGL2 only + case PIXELFORMAT_RG8U: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG8UI; this._glPixelType = gl.UNSIGNED_BYTE; break; - case PIXELFORMAT_RG16I: // WebGL2 only + case PIXELFORMAT_RG16I: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG16I; this._glPixelType = gl.SHORT; break; - case PIXELFORMAT_RG16U: // WebGL2 only + case PIXELFORMAT_RG16U: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG16UI; this._glPixelType = gl.UNSIGNED_SHORT; break; - case PIXELFORMAT_RG32I: // WebGL2 only + case PIXELFORMAT_RG32I: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG32I; this._glPixelType = gl.INT; break; - case PIXELFORMAT_RG32U: // WebGL2 only + case PIXELFORMAT_RG32U: this._glFormat = gl.RG_INTEGER; this._glInternalFormat = gl.RG32UI; this._glPixelType = gl.UNSIGNED_INT; break; - // Integer texture formats (RGBA) (WebGL2 only) - case PIXELFORMAT_RGBA8I: // WebGL2 only + + // Integer texture formats (RGBA) + case PIXELFORMAT_RGBA8I: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA8I; this._glPixelType = gl.BYTE; break; - case PIXELFORMAT_RGBA8U: // WebGL2 only + case PIXELFORMAT_RGBA8U: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA8UI; this._glPixelType = gl.UNSIGNED_BYTE; break; - case PIXELFORMAT_RGBA16I: // WebGL2 only + case PIXELFORMAT_RGBA16I: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA16I; this._glPixelType = gl.SHORT; break; - case PIXELFORMAT_RGBA16U: // WebGL2 only + case PIXELFORMAT_RGBA16U: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA16UI; this._glPixelType = gl.UNSIGNED_SHORT; break; - case PIXELFORMAT_RGBA32I: // WebGL2 only + case PIXELFORMAT_RGBA32I: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA32I; this._glPixelType = gl.INT; break; - case PIXELFORMAT_RGBA32U: // WebGL2 only + case PIXELFORMAT_RGBA32U: this._glFormat = gl.RGBA_INTEGER; this._glInternalFormat = gl.RGBA32UI; this._glPixelType = gl.UNSIGNED_INT; @@ -740,7 +695,7 @@ class WebglTexture { } } - if (!texture._compressed && !texture._integerFormat && texture._mipmaps && texture._needsMipmapsUpload && (texture.pot || device.isWebGL2) && texture._levels.length === 1) { + if (!texture._compressed && !texture._integerFormat && texture._mipmaps && texture._needsMipmapsUpload && texture._levels.length === 1) { gl.generateMipmap(this._glTarget); texture._mipmapsUploaded = true; }