dawn/node: Allow GPUTexture where GPUTextureView is used Roll third_party/gpuweb/ 813b4f445..a2637f7b8 (1 commit) https://chromium.googlesource.com/external/github.com/gpuweb/gpuweb/+log/813b4f445653..a2637f7b880c $ git log 813b4f445..a2637f7b8 --date=short --no-merges --format='%ad %ae %s' 2025-07-03 dneto Deploying to gh-pages from @ gpuweb/gpuweb@e93276a5b3b3fbfcd77e392779c03baa2adda061 🚀 Created with: roll-dep third_party/gpuweb Bug: 425906323 Change-Id: I244f9db2815979f31d743a6fd47a11a0e138532c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/250714 Reviewed-by: Loko Kung <lokokung@google.com> Commit-Queue: Fr <beaufort.francois@gmail.com>
diff --git a/DEPS b/DEPS index d831900..0ad4865 100644 --- a/DEPS +++ b/DEPS
@@ -382,7 +382,7 @@ 'condition': 'dawn_node', }, 'third_party/gpuweb': { - 'url': '{chromium_git}/external/github.com/gpuweb/gpuweb@813b4f445653c56df3b3aafc43e9fbf4028e676d', + 'url': '{chromium_git}/external/github.com/gpuweb/gpuweb@a2637f7b880c2556919cdb288fe89815e0ed1c41', 'condition': 'dawn_node', },
diff --git a/src/dawn/node/binding/Converter.cpp b/src/dawn/node/binding/Converter.cpp index 0709dcf..905ce84 100644 --- a/src/dawn/node/binding/Converter.cpp +++ b/src/dawn/node/binding/Converter.cpp
@@ -29,6 +29,7 @@ #include <cassert> #include <sstream> +#include <string> #include "src/dawn/node/binding/GPUBuffer.h" #include "src/dawn/node/binding/GPUPipelineLayout.h" @@ -1274,28 +1275,54 @@ return Throw("invalid value for GPUVertexFormat"); } +bool Converter::Convert(wgpu::TextureView& outView, + const std::variant<interop::Interface<interop::GPUTexture>, + interop::Interface<interop::GPUTextureView>>& in, + const char* name) { + if (auto* view = std::get_if<interop::Interface<interop::GPUTextureView>>(&in)) { + if (!Convert(outView, *view)) { + return false; + } + } else if (auto* tex = std::get_if<interop::Interface<interop::GPUTexture>>(&in)) { + wgpu::Texture texture; + if (!Convert(texture, *tex)) { + return false; + } + outView = texture.CreateView(); + } else { + return Throw((std::stringstream() << "invalid value for " << name).str()); + } + return true; +} + bool Converter::Convert(wgpu::RenderPassColorAttachment& out, const interop::GPURenderPassColorAttachment& in) { out = {}; - return Convert(out.view, in.view) && // - Convert(out.depthSlice, in.depthSlice) && // - Convert(out.resolveTarget, in.resolveTarget) && // - Convert(out.clearValue, in.clearValue) && // - Convert(out.loadOp, in.loadOp) && // + + if (in.resolveTarget && + !Convert(out.resolveTarget, *in.resolveTarget, "RenderPassColorAttachment.resolveTarget")) { + return false; + } + + return Convert(out.view, in.view, "RenderPassColorAttachment.view") && // + Convert(out.depthSlice, in.depthSlice) && // + Convert(out.clearValue, in.clearValue) && // + Convert(out.loadOp, in.loadOp) && // Convert(out.storeOp, in.storeOp); } bool Converter::Convert(wgpu::RenderPassDepthStencilAttachment& out, const interop::GPURenderPassDepthStencilAttachment& in) { out = {}; - return Convert(out.view, in.view) && // - Convert(out.depthClearValue, in.depthClearValue) && // - Convert(out.depthLoadOp, in.depthLoadOp) && // - Convert(out.depthStoreOp, in.depthStoreOp) && // - Convert(out.depthReadOnly, in.depthReadOnly) && // - Convert(out.stencilClearValue, in.stencilClearValue) && // - Convert(out.stencilLoadOp, in.stencilLoadOp) && // - Convert(out.stencilStoreOp, in.stencilStoreOp) && // + + return Convert(out.view, in.view, "RenderPassDepthStencilAttachment.view") && // + Convert(out.depthClearValue, in.depthClearValue) && // + Convert(out.depthLoadOp, in.depthLoadOp) && // + Convert(out.depthStoreOp, in.depthStoreOp) && // + Convert(out.depthReadOnly, in.depthReadOnly) && // + Convert(out.stencilClearValue, in.stencilClearValue) && // + Convert(out.stencilLoadOp, in.stencilLoadOp) && // + Convert(out.stencilStoreOp, in.stencilStoreOp) && // Convert(out.stencilReadOnly, in.stencilReadOnly); } @@ -1348,6 +1375,14 @@ if (auto* res = std::get_if<interop::Interface<interop::GPUSampler>>(&in.resource)) { return Convert(out.sampler, *res); } + if (auto* res = std::get_if<interop::Interface<interop::GPUTexture>>(&in.resource)) { + wgpu::Texture texture; + if (!Convert(texture, *res)) { + return false; + } + out.textureView = texture.CreateView(); + return true; + } if (auto* res = std::get_if<interop::Interface<interop::GPUTextureView>>(&in.resource)) { return Convert(out.textureView, *res); }
diff --git a/src/dawn/node/binding/Converter.h b/src/dawn/node/binding/Converter.h index 7ee19e4..196925a 100644 --- a/src/dawn/node/binding/Converter.h +++ b/src/dawn/node/binding/Converter.h
@@ -36,6 +36,7 @@ #include <type_traits> #include <unordered_map> #include <utility> +#include <variant> #include <vector> #include "dawn/native/DawnNative.h" @@ -209,6 +210,11 @@ [[nodiscard]] bool Convert(wgpu::VertexFormat& out, const interop::GPUVertexFormat& in); + [[nodiscard]] bool Convert(wgpu::TextureView& outView, + const std::variant<interop::Interface<interop::GPUTexture>, + interop::Interface<interop::GPUTextureView>>& in, + const char* name); + [[nodiscard]] bool Convert(wgpu::RenderPassColorAttachment& out, const interop::GPURenderPassColorAttachment& in);
diff --git a/third_party/gpuweb b/third_party/gpuweb index 813b4f4..a2637f7 160000 --- a/third_party/gpuweb +++ b/third_party/gpuweb
@@ -1 +1 @@ -Subproject commit 813b4f445653c56df3b3aafc43e9fbf4028e676d +Subproject commit a2637f7b880c2556919cdb288fe89815e0ed1c41