From 5d92cab84334a5a5731b0db0950bf3f3910daf9e Mon Sep 17 00:00:00 2001 From: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com> Date: Wed, 15 Nov 2023 09:41:52 +0000 Subject: [PATCH] WebGPU support for rendering to RG11B10 format (#5824) Co-authored-by: Martin Valigursky --- src/platform/graphics/webgl/webgl-graphics-device.js | 1 + src/platform/graphics/webgl/webgl-texture.js | 1 + src/platform/graphics/webgpu/webgpu-graphics-device.js | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/platform/graphics/webgl/webgl-graphics-device.js b/src/platform/graphics/webgl/webgl-graphics-device.js index 05e23947b10..b72f1116231 100644 --- a/src/platform/graphics/webgl/webgl-graphics-device.js +++ b/src/platform/graphics/webgl/webgl-graphics-device.js @@ -937,6 +937,7 @@ class WebglGraphicsDevice extends GraphicsDevice { this.extVertexArrayObject = true; this.extColorBufferFloat = this.getExtension('EXT_color_buffer_float'); this.extDepthTexture = true; + this.textureRG11B10Renderable = true; } else { this.extBlendMinmax = this.getExtension("EXT_blend_minmax"); this.extDrawBuffers = this.getExtension('WEBGL_draw_buffers'); diff --git a/src/platform/graphics/webgl/webgl-texture.js b/src/platform/graphics/webgl/webgl-texture.js index a1ec2b609d3..7a777074328 100644 --- a/src/platform/graphics/webgl/webgl-texture.js +++ b/src/platform/graphics/webgl/webgl-texture.js @@ -263,6 +263,7 @@ class WebglTexture { } break; case PIXELFORMAT_111110F: // WebGL2 only + Debug.assert(device.isWebGL2, "PIXELFORMAT_111110F texture format is not supported by WebGL1."); this._glFormat = gl.RGB; this._glInternalFormat = gl.R11F_G11F_B10F; this._glPixelType = gl.UNSIGNED_INT_10F_11F_11F_REV; diff --git a/src/platform/graphics/webgpu/webgpu-graphics-device.js b/src/platform/graphics/webgpu/webgpu-graphics-device.js index b975b35e775..fb14fd7ff54 100644 --- a/src/platform/graphics/webgpu/webgpu-graphics-device.js +++ b/src/platform/graphics/webgpu/webgpu-graphics-device.js @@ -206,7 +206,6 @@ class WebgpuGraphicsDevice extends GraphicsDevice { // "depth32float-stencil8", // "indirect-first-instance", // "shader-f16", - // "rg11b10ufloat-renderable", // "bgra8unorm-storage", // request optional features @@ -223,6 +222,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice { this.extCompressedTextureETC = requireFeature('texture-compression-etc2'); this.extCompressedTextureASTC = requireFeature('texture-compression-astc'); this.supportsTimestampQuery = requireFeature('timestamp-query'); + this.textureRG11B10Renderable = requireFeature('rg11b10ufloat-renderable'); Debug.log(`WEBGPU features: ${requiredFeatures.join(', ')}`); /** @type {GPUDeviceDescriptor} */