diff --git a/filament/backend/src/webgpu/WebGPUHandles.cpp b/filament/backend/src/webgpu/WebGPUHandles.cpp index 06c0344334..6d9f956c4f 100644 --- a/filament/backend/src/webgpu/WebGPUHandles.cpp +++ b/filament/backend/src/webgpu/WebGPUHandles.cpp @@ -514,7 +514,7 @@ WGPUTexture::WGPUTexture(SamplerType target, uint8_t levels, TextureFormat forma "the spec. See https://www.w3.org/TR/webgpu/#texture-creation or " "https://gpuweb.github.io/gpuweb/#multisample-state"); // First, the texture aspect, starting with the defaults/basic configuration - mUsage = fToWGPUTextureUsage(usage); + mUsage = fToWGPUTextureUsage(usage, device.HasFeature(wgpu::FeatureName::TransientAttachments)); mFormat = fToWGPUTextureFormat(format); wgpu::TextureDescriptor textureDescriptor{ .label = getUserTextureLabel(target), @@ -566,7 +566,8 @@ WGPUTexture::WGPUTexture(WGPUTexture* src, uint8_t baseLevel, uint8_t levelCount mTexView = makeTextureView(baseLevel, levelCount, target); } -wgpu::TextureUsage WGPUTexture::fToWGPUTextureUsage(const TextureUsage& fUsage) { +wgpu::TextureUsage WGPUTexture::fToWGPUTextureUsage(const TextureUsage& fUsage, + const bool supportsTransientAttachment) { wgpu::TextureUsage retUsage = wgpu::TextureUsage::None; // Basing this mapping off of VulkanTexture.cpp's getUsage func and suggestions from Gemini @@ -592,6 +593,7 @@ wgpu::TextureUsage WGPUTexture::fToWGPUTextureUsage(const TextureUsage& fUsage) // This is from Vulkan logic- if there are any issues try disabling this first, allows perf // benefit though const bool useTransientAttachment = + supportsTransientAttachment && // Usage consists of attachment flags only. none(fUsage & ~TextureUsage::ALL_ATTACHMENTS) && // Usage contains at least one attachment flag. diff --git a/filament/backend/src/webgpu/WebGPUHandles.h b/filament/backend/src/webgpu/WebGPUHandles.h index fdc51e92b0..3c3eb33cc3 100644 --- a/filament/backend/src/webgpu/WebGPUHandles.h +++ b/filament/backend/src/webgpu/WebGPUHandles.h @@ -194,7 +194,8 @@ private: wgpu::TextureFormat mFormat = wgpu::TextureFormat::Undefined; uint32_t mArrayLayerCount = 1; wgpu::TextureView mTexView = nullptr; - wgpu::TextureUsage fToWGPUTextureUsage(const filament::backend::TextureUsage& fUsage); + wgpu::TextureUsage fToWGPUTextureUsage(const filament::backend::TextureUsage& fUsage, + const bool supportsTransientAttachment); }; struct WGPURenderPrimitive : public HwRenderPrimitive { diff --git a/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp b/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp index f41d71a30b..7ec365f94d 100644 --- a/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp +++ b/filament/backend/src/webgpu/platform/WebGPUPlatform.cpp @@ -100,9 +100,11 @@ wgpu::Adapter WebGPUPlatform::requestAdapter(wgpu::Surface const& surface) { wgpu::Device WebGPUPlatform::requestDevice(wgpu::Adapter const& adapter) { // TODO consider passing limits constexpr std::array optionalFeatures = { wgpu::FeatureName::DepthClipControl, - wgpu::FeatureName::Depth32FloatStencil8, wgpu::FeatureName::CoreFeaturesAndLimits }; + wgpu::FeatureName::Depth32FloatStencil8, wgpu::FeatureName::CoreFeaturesAndLimits, + wgpu::FeatureName::TransientAttachments }; - constexpr std::array requiredFeatures = { wgpu::FeatureName::TransientAttachments }; + // Currently no required features, but logic to check them is available + constexpr std::array requiredFeatures = {}; wgpu::SupportedFeatures supportedFeatures; adapter.GetFeatures(&supportedFeatures);