From 079caff78cf969825445f0f367b8117f0816c49f Mon Sep 17 00:00:00 2001 From: Martin Valigursky <59932779+mvaligursky@users.noreply.github.com> Date: Fri, 22 Nov 2024 15:55:05 +0000 Subject: [PATCH] WebGPU support for ClipDistances feature (#7134) Co-authored-by: Martin Valigursky --- src/platform/graphics/graphics-device.js | 8 ++++++++ src/platform/graphics/webgpu/webgpu-graphics-device.js | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/platform/graphics/graphics-device.js b/src/platform/graphics/graphics-device.js index 11abc43884e..6e9bc869b56 100644 --- a/src/platform/graphics/graphics-device.js +++ b/src/platform/graphics/graphics-device.js @@ -275,6 +275,14 @@ class GraphicsDevice extends EventHandler { */ supportsUniformBuffers = false; + /** + * True if the device supports clip distances (WebGPU only). Clip distances allow you to restrict + * primitives' clip volume with user-defined half-spaces in the output of vertex stage. + * + * @type {boolean} + */ + supportsClipDistances = false; + /** * True if 32-bit floating-point textures can be used as a frame buffer. * diff --git a/src/platform/graphics/webgpu/webgpu-graphics-device.js b/src/platform/graphics/webgpu/webgpu-graphics-device.js index 1841c9c8f47..449b0b09037 100644 --- a/src/platform/graphics/webgpu/webgpu-graphics-device.js +++ b/src/platform/graphics/webgpu/webgpu-graphics-device.js @@ -210,7 +210,6 @@ class WebgpuGraphicsDevice extends GraphicsDevice { */ this.gpuAdapter = await window.navigator.gpu.requestAdapter(adapterOptions); - // request optional features const requiredFeatures = []; const requireFeature = (feature) => { @@ -231,6 +230,7 @@ class WebgpuGraphicsDevice extends GraphicsDevice { this.supportsShaderF16 = requireFeature('shader-f16'); this.supportsStorageRGBA8 = requireFeature('bgra8unorm-storage'); this.textureRG11B10Renderable = requireFeature('rg11b10ufloat-renderable'); + this.supportsClipDistances = requireFeature('clip-distances'); Debug.log(`WEBGPU features: ${requiredFeatures.join(', ')}`); // copy all adapter limits to the requiredLimits object - to created a device with the best feature sets available