diff --git a/.cargo/config.in b/.cargo/config.in index d13616e3df24..b726e7f8778c 100644 --- a/.cargo/config.in +++ b/.cargo/config.in @@ -25,14 +25,19 @@ git = "https://github.com/franziskuskiefer/cose-rust" rev = "43c22248d136c8b38fe42ea709d08da6355cf04b" replace-with = "vendored-sources" -[source."git+https://github.com/gfx-rs/naga?rev=cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c"] -git = "https://github.com/gfx-rs/naga" -rev = "cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c" +[source."git+https://github.com/gfx-rs/metal-rs/?rev=d24f1a4"] +git = "https://github.com/gfx-rs/metal-rs/" +rev = "d24f1a4" replace-with = "vendored-sources" -[source."git+https://github.com/gfx-rs/wgpu?rev=7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e"] +[source."git+https://github.com/gfx-rs/naga?rev=df8107b7"] +git = "https://github.com/gfx-rs/naga" +rev = "df8107b7" +replace-with = "vendored-sources" + +[source."git+https://github.com/gfx-rs/wgpu?rev=7e0d6c971f900f6a8f01a9de9c41f7894164a82c"] git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" replace-with = "vendored-sources" [source."git+https://github.com/glandium/prost?rev=95964e9d33df3c2a9c3f14285e262867cab6f96b"] diff --git a/Cargo.lock b/Cargo.lock index d358d047b2e5..bd9ec4f3eb9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3348,8 +3348,7 @@ dependencies = [ [[package]] name = "metal" version = "0.26.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "623b5e6cefd76e58f774bd3cc0c6f5c7615c58c03a97815245a25c3c9bdee318" +source = "git+https://github.com/gfx-rs/metal-rs/?rev=d24f1a4#d24f1a4ae92470bf87a0c65ecfe78c9299835505" dependencies = [ "bitflags 2.999.999", "block", @@ -3725,7 +3724,7 @@ checksum = "a2983372caf4480544083767bf2d27defafe32af49ab4df3a0b7fc90793a3664" [[package]] name = "naga" version = "0.13.0" -source = "git+https://github.com/gfx-rs/naga?rev=cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c#cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c" +source = "git+https://github.com/gfx-rs/naga?rev=df8107b7#df8107b78812cc2b1e3d5de35279cedc1f0da3fb" dependencies = [ "bit-set", "bitflags 2.999.999", @@ -6302,7 +6301,7 @@ dependencies = [ [[package]] name = "wgpu-core" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e#7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +source = "git+https://github.com/gfx-rs/wgpu?rev=7e0d6c971f900f6a8f01a9de9c41f7894164a82c#7e0d6c971f900f6a8f01a9de9c41f7894164a82c" dependencies = [ "arrayvec", "bit-vec", @@ -6325,7 +6324,7 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e#7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +source = "git+https://github.com/gfx-rs/wgpu?rev=7e0d6c971f900f6a8f01a9de9c41f7894164a82c#7e0d6c971f900f6a8f01a9de9c41f7894164a82c" dependencies = [ "android_system_properties", "arrayvec", @@ -6361,7 +6360,7 @@ dependencies = [ [[package]] name = "wgpu-types" version = "0.17.0" -source = "git+https://github.com/gfx-rs/wgpu?rev=7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e#7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +source = "git+https://github.com/gfx-rs/wgpu?rev=7e0d6c971f900f6a8f01a9de9c41f7894164a82c#7e0d6c971f900f6a8f01a9de9c41f7894164a82c" dependencies = [ "bitflags 2.999.999", "js-sys", diff --git a/gfx/wgpu_bindings/Cargo.toml b/gfx/wgpu_bindings/Cargo.toml index 38ef45574572..d18872f0c9f8 100644 --- a/gfx/wgpu_bindings/Cargo.toml +++ b/gfx/wgpu_bindings/Cargo.toml @@ -17,7 +17,7 @@ default = [] [dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" #Note: "replay" shouldn't ideally be needed, # but it allows us to serialize everything across IPC. features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl"] @@ -27,32 +27,32 @@ features = ["replay", "trace", "serial-pass", "strict_asserts", "wgsl"] [target.'cfg(any(target_os = "macos", target_os = "ios"))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" features = ["metal"] # We want the wgpu-core Direct3D backends on Windows. [target.'cfg(windows)'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" features = ["dx11", "dx12"] # We want the wgpu-core Vulkan backend on Linux and Windows. [target.'cfg(any(windows, all(unix, not(any(target_os = "macos", target_os = "ios")))))'.dependencies.wgc] package = "wgpu-core" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" features = ["vulkan"] [dependencies.wgt] package = "wgpu-types" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" [dependencies.wgh] package = "wgpu-hal" git = "https://github.com/gfx-rs/wgpu" -rev = "7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e" +rev = "7e0d6c971f900f6a8f01a9de9c41f7894164a82c" [target.'cfg(windows)'.dependencies] d3d12 = "0.7.0" diff --git a/gfx/wgpu_bindings/moz.yaml b/gfx/wgpu_bindings/moz.yaml index c216659eb6f2..ff5e4a6e4a12 100644 --- a/gfx/wgpu_bindings/moz.yaml +++ b/gfx/wgpu_bindings/moz.yaml @@ -20,11 +20,11 @@ origin: # Human-readable identifier for this version/release # Generally "version NNN", "tag SSS", "bookmark SSS" - release: commit 7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e + release: commit 7e0d6c971f900f6a8f01a9de9c41f7894164a82c # Revision to pull in # Must be a long or short commit SHA (long preferred) - revision: 7fea9e934efd8d5dc03b9aa3e06b775c1ac4a23e + revision: 7e0d6c971f900f6a8f01a9de9c41f7894164a82c license: ['MIT', 'Apache-2.0'] diff --git a/supply-chain/audits.toml b/supply-chain/audits.toml index 1f4b7afc662f..94a839e4deec 100644 --- a/supply-chain/audits.toml +++ b/supply-chain/audits.toml @@ -2147,6 +2147,11 @@ who = "Erich Gubler " criteria = "safe-to-deploy" delta = "0.25.0 -> 0.26.0" +[[audits.metal]] +who = "Nicolas Silva " +criteria = "safe-to-deploy" +delta = "0.26.0 -> 0.26.0@git:d24f1a4ae92470bf87a0c65ecfe78c9299835505" + [[audits.midir]] who = "Bobby Holley " criteria = "safe-to-deploy" @@ -2298,6 +2303,11 @@ who = "Erich Gubler +pub enum MTLBlitPassDescriptor {} + +foreign_obj_type! { + type CType = MTLBlitPassDescriptor; + pub struct BlitPassDescriptor; +} + +impl BlitPassDescriptor { + /// Creates a default blit command pass descriptor with no attachments. + pub fn new<'a>() -> &'a BlitPassDescriptorRef { + unsafe { msg_send![class!(MTLBlitPassDescriptor), blitPassDescriptor] } + } +} + +impl BlitPassDescriptorRef { + // See + pub fn sample_buffer_attachments(&self) -> &BlitPassSampleBufferAttachmentDescriptorArrayRef { + unsafe { msg_send![self, sampleBufferAttachments] } + } +} + +/// See +pub enum MTLBlitPassSampleBufferAttachmentDescriptorArray {} + +foreign_obj_type! { + type CType = MTLBlitPassSampleBufferAttachmentDescriptorArray; + pub struct BlitPassSampleBufferAttachmentDescriptorArray; +} + +impl BlitPassSampleBufferAttachmentDescriptorArrayRef { + pub fn object_at( + &self, + index: NSUInteger, + ) -> Option<&BlitPassSampleBufferAttachmentDescriptorRef> { + unsafe { msg_send![self, objectAtIndexedSubscript: index] } + } + + pub fn set_object_at( + &self, + index: NSUInteger, + attachment: Option<&BlitPassSampleBufferAttachmentDescriptorRef>, + ) { + unsafe { + msg_send![self, setObject:attachment + atIndexedSubscript:index] + } + } +} + +/// See +pub enum MTLBlitPassSampleBufferAttachmentDescriptor {} + +foreign_obj_type! { + type CType = MTLBlitPassSampleBufferAttachmentDescriptor; + pub struct BlitPassSampleBufferAttachmentDescriptor; +} + +impl BlitPassSampleBufferAttachmentDescriptor { + pub fn new() -> Self { + let class = class!(MTLBlitPassSampleBufferAttachmentDescriptor); + unsafe { msg_send![class, new] } + } +} + +impl BlitPassSampleBufferAttachmentDescriptorRef { + pub fn sample_buffer(&self) -> &CounterSampleBufferRef { + unsafe { msg_send![self, sampleBuffer] } + } + + pub fn set_sample_buffer(&self, sample_buffer: &CounterSampleBufferRef) { + unsafe { msg_send![self, setSampleBuffer: sample_buffer] } + } + + pub fn start_of_encoder_sample_index(&self) -> NSUInteger { + unsafe { msg_send![self, startOfEncoderSampleIndex] } + } + + pub fn set_start_of_encoder_sample_index(&self, start_of_encoder_sample_index: NSUInteger) { + unsafe { + msg_send![ + self, + setStartOfEncoderSampleIndex: start_of_encoder_sample_index + ] + } + } + + pub fn end_of_encoder_sample_index(&self) -> NSUInteger { + unsafe { msg_send![self, endOfEncoderSampleIndex] } + } + + pub fn set_end_of_encoder_sample_index(&self, end_of_encoder_sample_index: NSUInteger) { + unsafe { + msg_send![ + self, + setEndOfEncoderSampleIndex: end_of_encoder_sample_index + ] + } + } +} diff --git a/third_party/rust/metal/src/commandbuffer.rs b/third_party/rust/metal/src/commandbuffer.rs index ec808f80b687..26fea2e559fb 100644 --- a/third_party/rust/metal/src/commandbuffer.rs +++ b/third_party/rust/metal/src/commandbuffer.rs @@ -109,10 +109,31 @@ impl CommandBufferRef { unsafe { msg_send![self, blitCommandEncoder] } } + pub fn blit_command_encoder_with_descriptor( + &self, + descriptor: &BlitPassDescriptorRef, + ) -> &BlitCommandEncoderRef { + unsafe { msg_send![self, blitCommandEncoderWithDescriptor: descriptor] } + } + pub fn new_compute_command_encoder(&self) -> &ComputeCommandEncoderRef { unsafe { msg_send![self, computeCommandEncoder] } } + pub fn compute_command_encoder_with_dispatch_type( + &self, + ty: MTLDispatchType, + ) -> &ComputeCommandEncoderRef { + unsafe { msg_send![self, computeCommandEncoderWithDispatchType: ty] } + } + + pub fn compute_command_encoder_with_descriptor( + &self, + descriptor: &ComputePassDescriptorRef, + ) -> &ComputeCommandEncoderRef { + unsafe { msg_send![self, computeCommandEncoderWithDescriptor: descriptor] } + } + pub fn new_render_command_encoder( &self, descriptor: &RenderPassDescriptorRef, @@ -133,20 +154,6 @@ impl CommandBufferRef { unsafe { msg_send![self, accelerationStructureCommandEncoder] } } - pub fn compute_command_encoder_with_dispatch_type( - &self, - ty: MTLDispatchType, - ) -> &ComputeCommandEncoderRef { - unsafe { msg_send![self, computeCommandEncoderWithDispatchType: ty] } - } - - pub fn compute_command_encoder_with_descriptor( - &self, - descriptor: &ComputePassDescriptorRef, - ) -> &ComputeCommandEncoderRef { - unsafe { msg_send![self, computeCommandEncoderWithDescriptor: descriptor] } - } - pub fn encode_signal_event(&self, event: &EventRef, new_value: u64) { unsafe { msg_send![self, diff --git a/third_party/rust/metal/src/device.rs b/third_party/rust/metal/src/device.rs index 1f0d3861d5b6..11b55755778f 100644 --- a/third_party/rust/metal/src/device.rs +++ b/third_party/rust/metal/src/device.rs @@ -1958,6 +1958,19 @@ impl DeviceRef { } } + pub fn new_indirect_command_buffer_with_descriptor( + &self, + descriptor: &IndirectCommandBufferDescriptorRef, + max_command_count: NSUInteger, + options: MTLResourceOptions, + ) -> IndirectCommandBuffer { + unsafe { + msg_send![self, newIndirectCommandBufferWithDescriptor:descriptor + maxCommandCount:max_command_count + options:options] + } + } + pub fn new_texture(&self, descriptor: &TextureDescriptorRef) -> Texture { unsafe { msg_send![self, newTextureWithDescriptor: descriptor] } } diff --git a/third_party/rust/metal/src/encoder.rs b/third_party/rust/metal/src/encoder.rs index c4f609235a3b..7ecc56daded8 100644 --- a/third_party/rust/metal/src/encoder.rs +++ b/third_party/rust/metal/src/encoder.rs @@ -9,6 +9,9 @@ use super::*; use std::ops::Range; +/// See +pub const COUNTER_DONT_SAMPLE: NSUInteger = NSUInteger::MAX; // #define MTLCounterDontSample ((NSUInteger)-1) + /// See #[repr(u64)] #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] @@ -1215,6 +1218,22 @@ impl RenderCommandEncoderRef { ] } } + + /// See: + pub fn sample_counters_in_buffer( + &self, + sample_buffer: &CounterSampleBufferRef, + sample_index: NSUInteger, + with_barrier: bool, + ) { + unsafe { + msg_send![self, + sampleCountersInBuffer: sample_buffer + atSampleIndex: sample_index + withBarrier: with_barrier + ] + } + } } /// See @@ -1396,6 +1415,45 @@ impl BlitCommandEncoderRef { unsafe { msg_send![self, waitForFence: fence] } } + pub fn copy_indirect_command_buffer( + &self, + source: &IndirectCommandBufferRef, + source_range: NSRange, + destination: &IndirectCommandBufferRef, + destination_index: NSUInteger, + ) { + unsafe { + msg_send![self, + copyIndirectCommandBuffer: source + sourceRange: source_range + destination: destination + destinationIndex: destination_index + ] + } + } + + pub fn reset_commands_in_buffer(&self, buffer: &IndirectCommandBufferRef, range: NSRange) { + unsafe { + msg_send![self, + resetCommandsInBuffer: buffer + withRange: range + ] + } + } + + pub fn optimize_indirect_command_buffer( + &self, + buffer: &IndirectCommandBufferRef, + range: NSRange, + ) { + unsafe { + msg_send![self, + optimizeIndirectCommandBuffer: buffer + withRange: range + ] + } + } + /// See: pub fn sample_counters_in_buffer( &self, @@ -1861,6 +1919,35 @@ impl ArgumentEncoderRef { unsafe { msg_send![self, constantDataAtIndex: at_index] } } + pub fn set_indirect_command_buffer( + &self, + at_index: NSUInteger, + buffer: &IndirectCommandBufferRef, + ) { + unsafe { + msg_send![self, + setIndirectCommandBuffer: buffer + atIndex: at_index + ] + } + } + + pub fn set_indirect_command_buffers( + &self, + start_index: NSUInteger, + data: &[&IndirectCommandBufferRef], + ) { + unsafe { + msg_send![self, + setIndirectCommandBuffers: data.as_ptr() + withRange: NSRange { + location: start_index, + length: data.len() as _, + } + ] + } + } + pub fn new_argument_encoder_for_buffer(&self, index: NSUInteger) -> ArgumentEncoder { unsafe { let ptr = msg_send![self, newArgumentEncoderForBufferAtIndex: index]; diff --git a/third_party/rust/metal/src/indirect_encoder.rs b/third_party/rust/metal/src/indirect_encoder.rs index 441dfc60e4a0..e434d348f207 100644 --- a/third_party/rust/metal/src/indirect_encoder.rs +++ b/third_party/rust/metal/src/indirect_encoder.rs @@ -22,6 +22,13 @@ foreign_obj_type! { pub struct IndirectCommandBufferDescriptor; } +impl IndirectCommandBufferDescriptor { + pub fn new() -> Self { + let class = class!(MTLIndirectCommandBufferDescriptor); + unsafe { msg_send![class, new] } + } +} + impl IndirectCommandBufferDescriptorRef { pub fn command_types(&self) -> MTLIndirectCommandType { unsafe { msg_send![self, commandTypes] } diff --git a/third_party/rust/metal/src/lib.rs b/third_party/rust/metal/src/lib.rs index b9da590f7a93..b79acf6e8462 100644 --- a/third_party/rust/metal/src/lib.rs +++ b/third_party/rust/metal/src/lib.rs @@ -548,6 +548,7 @@ impl MetalLayerRef { mod accelerator_structure; mod argument; +mod blitpass; mod buffer; mod capturedescriptor; mod capturemanager; @@ -578,6 +579,7 @@ mod vertexdescriptor; pub use { accelerator_structure::*, argument::*, + blitpass::*, buffer::*, counters::*, computepass::*, diff --git a/third_party/rust/naga/.cargo-checksum.json b/third_party/rust/naga/.cargo-checksum.json index 3567e916216e..a75080a5349f 100644 --- a/third_party/rust/naga/.cargo-checksum.json +++ b/third_party/rust/naga/.cargo-checksum.json @@ -1 +1 @@ -{"files":{".cargo/config.toml":"d7389d2a0c08ec72b79e83a3c76980903e3f9123625c32e69c798721193e2e74",".github/workflows/ci.yml":"ee0ce3876bc6d30573146fa97fa7ec46b762d199187f1f50dfc510bfcb0e8c67",".github/workflows/lazy.yml":"3777882e946c4c60c497bc91d4caf82564d49be646391bc735039ee9a7857fa7",".github/workflows/validation-linux.yml":"133affe3d4b539846d5502af73d0ba1cab8ab6246222a072326324e01fd11216",".github/workflows/validation-macos.yml":"b0431e3abc99313587c4245757416850e54fdd71c15c1c646b192b82b95e3c14",".github/workflows/validation-windows.yml":"4e27d64d8c240ba98f277e6a75f79e0d8499076d62e23579446c06e605abed69","CHANGELOG.md":"141a4150e9abc5347299c12c2f892ab4d2028bcef08247ae29dd5074912f1058","Cargo.toml":"95eceba5cfd870667a04cf5db8aabaa9f3ab0d62f66163e9ba073dce21743fc0","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"ca3be8518f5ef097669cea882643fc532025f29972def4fda49df885565a0480","README.md":"a8209bed7462de253558ee8b197c0ce706d505243b2d23614f74464f1d62e15f","benches/criterion.rs":"9a033fe78e8e2fc2f89ba3f928c683bb89110b026cfe31d6ad4991889b7eb71c","codecov.yml":"729a58d729345908460c9cba0ea95bda5f5173256c407a601d870c68476de9d9","src/arena.rs":"068989016d473ccc35f0c829dfec83d3fd7eb8da05b4b107eadc8dd108376937","src/back/dot/mod.rs":"60ea80bd9a2c18b4855c92b9ec73629959ae6e58e4a25ff3bbf2d8c1185fc458","src/back/glsl/features.rs":"0642d0a1b73c2bbce8ca8b278fda0e8b02c086e8b14adfc4d9e5be62371fb993","src/back/glsl/keywords.rs":"fbc6dad7e0da457f682ee21f86f5b9ebf0b080d750e34e5600085e14f07ab1c1","src/back/glsl/mod.rs":"4bcaf8a29aef569143a9586b5dbfe6df7ef0d628c2f3c362e898b6964bcce0bc","src/back/hlsl/conv.rs":"f4ab12d3d5bacfc4d2ddc3f9e4145888a8c589a4f8bba30032055d6f06de1f3d","src/back/hlsl/help.rs":"a88cfc8f7adef6d3a533ba749d3df3f427badceeb4abff8fd3c9f1bc57250206","src/back/hlsl/keywords.rs":"eb4af8d697fb7f3991859d66339b5b2eac27c9fe41b73146ac838b207f462c9c","src/back/hlsl/mod.rs":"ba17c2ee42a5943b96c4a2e2357fb795eccb2d885e0b37bfa654d16ba0c01584","src/back/hlsl/storage.rs":"3d3a17e7c28d7d9c3365413a849f010358c93f13317f5a475ec15036e0d42f6c","src/back/hlsl/writer.rs":"d4da4237e3e8df3a542cbc76edafd3250d9b68d4811e8f663c0ad5b9fbcf1b6c","src/back/mod.rs":"5fca8d20d4e50beb63434cc94668a5d36930484210bf1f277db9a00d34851b21","src/back/msl/keywords.rs":"64a92abc3be4d4840817c1385d30d9f0401184a94367e604bbd25995e96c0154","src/back/msl/mod.rs":"3933c04424a39c42570ae7616ec9dcccec0a9e937ff0e84c6694f9fdfa70bf7a","src/back/msl/sampler.rs":"210cf28143ac17d6c56a9adf4fc0e3b85b1b16bb8b94771f9304f2a43b7ce78e","src/back/msl/writer.rs":"7bd529b31cbcd1797f56c8685fe80a9cbe4e5725d4ef86c8187518112a145cac","src/back/spv/block.rs":"b39ec707bd3fa5abd82c7851c738e746920c6113779bd61cbe6f595a4e3c5d23","src/back/spv/helpers.rs":"a4e260130f39c7345decec40dadf1e94419c8f6d236ce7a53b5300aa72952a1b","src/back/spv/image.rs":"09522b7d554b8ff7890256c3b080976aff84fb5f06b2d7c10ae62658928149bd","src/back/spv/index.rs":"26611dd50df5cfd214900e19415f5374dd301d3b7d3bfedbc5ec0f254328287a","src/back/spv/instructions.rs":"53ec2944626f214324aca20623b64c84a9e28e5bf9264c8f22a365f69d40fd7e","src/back/spv/layout.rs":"e263de53cd2f9a03ad94b82b434ce636609bc1ed435a2d1132951663bfaa8ebd","src/back/spv/mod.rs":"0eab37d18ee6e1735cfef87ac2fba2a2530d2b699351912648167d9aef3b73c2","src/back/spv/ray.rs":"4f3942cd7a98b5c3be9021e2f9435927e1ba0cde2ccacb973277d8dbee990d57","src/back/spv/recyclable.rs":"114db0ea12774d6514f995d07295cb9a42631ab75165fc60980c10e9b5ecb832","src/back/spv/selection.rs":"81e404abfa0a977f7c1f76ccb37a78d13ccadbda229048dad53cc67687cc39db","src/back/spv/writer.rs":"9755ab870c8340507142de3bc98cb31cc67d9093918ce579b5abf1ad478afb02","src/back/wgsl/mod.rs":"2dd12bbea9ace835850192bb68c5760953da6bac6a636073d1eca19381c0c0b6","src/back/wgsl/writer.rs":"dec42d346636d12b973033a5fab508caa3ac6543e94761c07ba4d4e4b39780e2","src/block.rs":"89c061206f608365ef3ce03c0d205d7205ef9d892035dd3dfb8d252003159f14","src/front/glsl/ast.rs":"3644350edabd0f83c476873ec22715a4b1a12a6cb7c99c98d7e41a6173be4ca5","src/front/glsl/builtins.rs":"6ba08e47ab1a5bb69f14cb12013c6f286583acef08be7b6f2812a72ac14374a6","src/front/glsl/constants.rs":"77cf618aa733d80096b11fdb94557ae379371c2fe943fa46a533d217f402e6c7","src/front/glsl/context.rs":"7c3850ede40153addbb7580bd5804732dae35892792587f214f9abb7c6624a1a","src/front/glsl/error.rs":"8617dc35fb3b595b897449076a26696c4556cfd77533c9f957feca48989a553c","src/front/glsl/functions.rs":"d6804e775d4f5ea8b242349777062169f9ecd6e982f0c4349a68712dc25ecb6f","src/front/glsl/lex.rs":"08736ae8beb955da5b0e6e3e0f45995a824995f7096d516a2910417e9c7afa32","src/front/glsl/mod.rs":"75b03ecb83f8ea847f34344a3c9668d1372d43cfb370e4e2650ca54494c7a00e","src/front/glsl/offset.rs":"f755eff29868c61452fb8c9f124a6af2070076b8166801968f86f6d105d38298","src/front/glsl/parser.rs":"7a60f6dc36799c91c2314e266138e26ba2bcd467dadaa733ae3b7432e87c8101","src/front/glsl/parser/declarations.rs":"da65e56ac293d61fda71786869a52679cd7694e967fff960b15fcfd22b07eaae","src/front/glsl/parser/expressions.rs":"97f9e4e9009992547d27d6b1ded3d7393e9372114b704ae67306174a6b46938c","src/front/glsl/parser/functions.rs":"067fe6305598d727d4d96af6fa5837ac47b08ae6239d2de3e490b7b759515d4e","src/front/glsl/parser/types.rs":"9cab32f1e40cf4251737fe8c0f04c709bf4073a9ade80cff5173e2bf9f2e76d0","src/front/glsl/parser_tests.rs":"4b1280fc60a9c07f05fa7a529be28b57a9b68778eba8092a3da4140e01908261","src/front/glsl/token.rs":"42325adbef5bfc9e6f9e40e7ed3cbfa7ef498c05799fdb7694b123e6450410e1","src/front/glsl/types.rs":"edb735e214fe7ef8dc1572e9abb28cef298d0d81f4df50a0a50c1f6bf73e9c77","src/front/glsl/variables.rs":"f107404f43a273987e9e3b60e6b2bb3dcaffb2958edca2e8c803d928ed00036a","src/front/interpolator.rs":"9b6ca498d5fbd9bc1515510a04e303a00b324121d7285da3c955cfe18eb4224c","src/front/mod.rs":"61b6750b2f8eec6165dfdc36e7b207ed7d2f48dd25f6d3698f03797997895030","src/front/spv/convert.rs":"80cf575de903d69c158b067706bfcda85c3ada006516d01e6e3a0678396199e0","src/front/spv/error.rs":"3129fd1fe346441d61d0f641734df7e919919db15df706788d16402ebf480607","src/front/spv/function.rs":"e25dada43fcbe399726db9f8bc63b497e7e67485724935f5fbbda8f1b1b9a47c","src/front/spv/image.rs":"06be5f35e09a91d7bb20693f777394fe2c3985d01fcfe2977cebba791da05e04","src/front/spv/mod.rs":"a950d2752e338091ed9b8403f748d31963b0c9c0a33c83a8e085ed1a50a6dc93","src/front/spv/null.rs":"e1446d99d04c76a9c3bbd24dd9b20c4711ce8a918a9b403be6cccbde1175b3b4","src/front/type_gen.rs":"8f5ab3a4296ba9e98941c2a0c03342ac1224706e557fe5ce06e5af818ad00f83","src/front/wgsl/error.rs":"3e372d3ad5e644b9aedea0670efa909b22989bd9cda54eac9053d9512bc0337c","src/front/wgsl/index.rs":"2b9a4929a46bd822d3ed6f9a150e24d437e5bdca8293eb748aebe80ce7e74153","src/front/wgsl/lower/construction.rs":"29045c8fe0b05f317fac56c7d4f895e6b0dd253d3ed05efe87d9d702f4cb8927","src/front/wgsl/lower/mod.rs":"ccf9ec11ca80cf77ca8d291f9880f3847ead5f6b86c93332919a49f53d2a0e8c","src/front/wgsl/mod.rs":"f049afd861b0ab0e8acedd8360395e2b2cbb9c055bb72ccf75cf873f7c0e4227","src/front/wgsl/parse/ast.rs":"b77b53135652c0fbdb54ae9139d8b5683eaa4e583593d33d687d6c812e61051c","src/front/wgsl/parse/conv.rs":"25d7f636af48d361931f9cf8f46b70a07ff82391ebfc6ea434d097e417f314c5","src/front/wgsl/parse/lexer.rs":"15e77c8b45de0b19e75c09b4e3b991f092ccff1df4aadf5cb89f9ce131e97b20","src/front/wgsl/parse/mod.rs":"adffe28e4774aa9952b9ac6c4fd71762672b685de16cf3e5cc96b23843edbc8f","src/front/wgsl/parse/number.rs":"64fe5d5f6b1d6a6acf15f4cad3cda8045ad5d82efda179627f848aba9c47e605","src/front/wgsl/tests.rs":"1e74a9bad3a6a6c28420d70fe316e54011398f8c4f9f0cb3f693fadf0161da74","src/keywords/mod.rs":"0138f3931f8af0b0a05174549d0fd2152945b027dc3febefc1bbd676581d2e45","src/keywords/wgsl.rs":"7c3b364b60ca29cb8a68ef781de9ecd28b76b74bed18bf18a35d2ebffaa855ab","src/lib.rs":"5290536217c7de288dc5ab347be418aed6beda59c8bd74a50e8b87caad622a8b","src/proc/index.rs":"f4250f6944c2b631e8140979024e8deb86fa8d5352d8641ba954a388b2c0940e","src/proc/layouter.rs":"0512547d57920c83b2dfd62595aacf8f437fb5b07e40e790e2dca19c71f5eecc","src/proc/mod.rs":"f3ee5c7d81d531f5ea799ee72187c27dd599acba6b01028f05f1d4f25f93c7e5","src/proc/namer.rs":"754e7328ebc4231afcd019aac062dcd8689aead0dec57e6de1a97704ae4289bd","src/proc/terminator.rs":"13c59bf00f5b26171d971effc421091f5e00dedddd246c2daa44fe65aeda060a","src/proc/typifier.rs":"f86ac0e22ed0c24b77de7c69ddc1c7a5b57f2d2d16cf2df69109c072139a29ca","src/span.rs":"67cb6293827f1909b0fce5400df8d39e19a377a16256c61f0a3301aa4248a4bd","src/valid/analyzer.rs":"dd224abc79a8d4c3842012db2709f5aa79d267c020e3d7be0cdd182811c8bb78","src/valid/compose.rs":"eebaa461a3a76526361eb5b16dfae42384dfdfde5afa9b1ddca266a2149c68ad","src/valid/expression.rs":"28b6704738184bc301c4666eda877e1e0f2c7e56c9414e6fb26653f39d0bfce4","src/valid/function.rs":"b1b7e52127a3f224488b5749503d51156e3eecf5bd09811db53b77d53dcdc30a","src/valid/handles.rs":"3d90df61a8791fc79f7408cf6cfd339f4db85f372e0e8696a49195e88a4a8bf7","src/valid/interface.rs":"108b4718c2d643a4a82b4935f3d770e79987d3fc3f8af3fe832ea821ac6cc628","src/valid/mod.rs":"bdacccc2a77fc48cfb88065436554c08bce25d26e2a12940dd22e9d09cf1ccdb","src/valid/type.rs":"8dc7b9833a59e029f6bdb46d879d03be90fedcddc4c37d8d2a6915d990d58070"},"package":null} \ No newline at end of file +{"files":{".cargo/config.toml":"d7389d2a0c08ec72b79e83a3c76980903e3f9123625c32e69c798721193e2e74",".github/workflows/ci.yml":"ee0ce3876bc6d30573146fa97fa7ec46b762d199187f1f50dfc510bfcb0e8c67",".github/workflows/lazy.yml":"3777882e946c4c60c497bc91d4caf82564d49be646391bc735039ee9a7857fa7",".github/workflows/validation-linux.yml":"133affe3d4b539846d5502af73d0ba1cab8ab6246222a072326324e01fd11216",".github/workflows/validation-macos.yml":"b0431e3abc99313587c4245757416850e54fdd71c15c1c646b192b82b95e3c14",".github/workflows/validation-windows.yml":"4e27d64d8c240ba98f277e6a75f79e0d8499076d62e23579446c06e605abed69","CHANGELOG.md":"141a4150e9abc5347299c12c2f892ab4d2028bcef08247ae29dd5074912f1058","Cargo.toml":"95eceba5cfd870667a04cf5db8aabaa9f3ab0d62f66163e9ba073dce21743fc0","LICENSE-APACHE":"c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4","LICENSE-MIT":"ca3be8518f5ef097669cea882643fc532025f29972def4fda49df885565a0480","README.md":"a8209bed7462de253558ee8b197c0ce706d505243b2d23614f74464f1d62e15f","benches/criterion.rs":"9a033fe78e8e2fc2f89ba3f928c683bb89110b026cfe31d6ad4991889b7eb71c","codecov.yml":"729a58d729345908460c9cba0ea95bda5f5173256c407a601d870c68476de9d9","src/arena.rs":"068989016d473ccc35f0c829dfec83d3fd7eb8da05b4b107eadc8dd108376937","src/back/dot/mod.rs":"60ea80bd9a2c18b4855c92b9ec73629959ae6e58e4a25ff3bbf2d8c1185fc458","src/back/glsl/features.rs":"0642d0a1b73c2bbce8ca8b278fda0e8b02c086e8b14adfc4d9e5be62371fb993","src/back/glsl/keywords.rs":"fbc6dad7e0da457f682ee21f86f5b9ebf0b080d750e34e5600085e14f07ab1c1","src/back/glsl/mod.rs":"4bcaf8a29aef569143a9586b5dbfe6df7ef0d628c2f3c362e898b6964bcce0bc","src/back/hlsl/conv.rs":"f4ab12d3d5bacfc4d2ddc3f9e4145888a8c589a4f8bba30032055d6f06de1f3d","src/back/hlsl/help.rs":"a88cfc8f7adef6d3a533ba749d3df3f427badceeb4abff8fd3c9f1bc57250206","src/back/hlsl/keywords.rs":"eb4af8d697fb7f3991859d66339b5b2eac27c9fe41b73146ac838b207f462c9c","src/back/hlsl/mod.rs":"ba17c2ee42a5943b96c4a2e2357fb795eccb2d885e0b37bfa654d16ba0c01584","src/back/hlsl/storage.rs":"3d3a17e7c28d7d9c3365413a849f010358c93f13317f5a475ec15036e0d42f6c","src/back/hlsl/writer.rs":"d4da4237e3e8df3a542cbc76edafd3250d9b68d4811e8f663c0ad5b9fbcf1b6c","src/back/mod.rs":"5fca8d20d4e50beb63434cc94668a5d36930484210bf1f277db9a00d34851b21","src/back/msl/keywords.rs":"64a92abc3be4d4840817c1385d30d9f0401184a94367e604bbd25995e96c0154","src/back/msl/mod.rs":"3933c04424a39c42570ae7616ec9dcccec0a9e937ff0e84c6694f9fdfa70bf7a","src/back/msl/sampler.rs":"210cf28143ac17d6c56a9adf4fc0e3b85b1b16bb8b94771f9304f2a43b7ce78e","src/back/msl/writer.rs":"7bd529b31cbcd1797f56c8685fe80a9cbe4e5725d4ef86c8187518112a145cac","src/back/spv/block.rs":"b39ec707bd3fa5abd82c7851c738e746920c6113779bd61cbe6f595a4e3c5d23","src/back/spv/helpers.rs":"a4e260130f39c7345decec40dadf1e94419c8f6d236ce7a53b5300aa72952a1b","src/back/spv/image.rs":"09522b7d554b8ff7890256c3b080976aff84fb5f06b2d7c10ae62658928149bd","src/back/spv/index.rs":"26611dd50df5cfd214900e19415f5374dd301d3b7d3bfedbc5ec0f254328287a","src/back/spv/instructions.rs":"53ec2944626f214324aca20623b64c84a9e28e5bf9264c8f22a365f69d40fd7e","src/back/spv/layout.rs":"e263de53cd2f9a03ad94b82b434ce636609bc1ed435a2d1132951663bfaa8ebd","src/back/spv/mod.rs":"0eab37d18ee6e1735cfef87ac2fba2a2530d2b699351912648167d9aef3b73c2","src/back/spv/ray.rs":"4f3942cd7a98b5c3be9021e2f9435927e1ba0cde2ccacb973277d8dbee990d57","src/back/spv/recyclable.rs":"114db0ea12774d6514f995d07295cb9a42631ab75165fc60980c10e9b5ecb832","src/back/spv/selection.rs":"81e404abfa0a977f7c1f76ccb37a78d13ccadbda229048dad53cc67687cc39db","src/back/spv/writer.rs":"be5561f239075798d558b20a07816ce835e3a89a400218d9fb23ba11dbae775f","src/back/wgsl/mod.rs":"2dd12bbea9ace835850192bb68c5760953da6bac6a636073d1eca19381c0c0b6","src/back/wgsl/writer.rs":"48812f1b41e9a8b845ca6bed0fa0a06acd83ddb14a8740cf3dabdced8560e443","src/block.rs":"02776b02303c381d6ed39852059e1cbe575da2c799b2421385280a07f828c77d","src/front/glsl/ast.rs":"3644350edabd0f83c476873ec22715a4b1a12a6cb7c99c98d7e41a6173be4ca5","src/front/glsl/builtins.rs":"6ba08e47ab1a5bb69f14cb12013c6f286583acef08be7b6f2812a72ac14374a6","src/front/glsl/constants.rs":"77cf618aa733d80096b11fdb94557ae379371c2fe943fa46a533d217f402e6c7","src/front/glsl/context.rs":"7c3850ede40153addbb7580bd5804732dae35892792587f214f9abb7c6624a1a","src/front/glsl/error.rs":"8617dc35fb3b595b897449076a26696c4556cfd77533c9f957feca48989a553c","src/front/glsl/functions.rs":"d6804e775d4f5ea8b242349777062169f9ecd6e982f0c4349a68712dc25ecb6f","src/front/glsl/lex.rs":"08736ae8beb955da5b0e6e3e0f45995a824995f7096d516a2910417e9c7afa32","src/front/glsl/mod.rs":"75b03ecb83f8ea847f34344a3c9668d1372d43cfb370e4e2650ca54494c7a00e","src/front/glsl/offset.rs":"f755eff29868c61452fb8c9f124a6af2070076b8166801968f86f6d105d38298","src/front/glsl/parser.rs":"7a60f6dc36799c91c2314e266138e26ba2bcd467dadaa733ae3b7432e87c8101","src/front/glsl/parser/declarations.rs":"da65e56ac293d61fda71786869a52679cd7694e967fff960b15fcfd22b07eaae","src/front/glsl/parser/expressions.rs":"97f9e4e9009992547d27d6b1ded3d7393e9372114b704ae67306174a6b46938c","src/front/glsl/parser/functions.rs":"067fe6305598d727d4d96af6fa5837ac47b08ae6239d2de3e490b7b759515d4e","src/front/glsl/parser/types.rs":"9cab32f1e40cf4251737fe8c0f04c709bf4073a9ade80cff5173e2bf9f2e76d0","src/front/glsl/parser_tests.rs":"4b1280fc60a9c07f05fa7a529be28b57a9b68778eba8092a3da4140e01908261","src/front/glsl/token.rs":"42325adbef5bfc9e6f9e40e7ed3cbfa7ef498c05799fdb7694b123e6450410e1","src/front/glsl/types.rs":"edb735e214fe7ef8dc1572e9abb28cef298d0d81f4df50a0a50c1f6bf73e9c77","src/front/glsl/variables.rs":"f107404f43a273987e9e3b60e6b2bb3dcaffb2958edca2e8c803d928ed00036a","src/front/interpolator.rs":"9b6ca498d5fbd9bc1515510a04e303a00b324121d7285da3c955cfe18eb4224c","src/front/mod.rs":"61b6750b2f8eec6165dfdc36e7b207ed7d2f48dd25f6d3698f03797997895030","src/front/spv/convert.rs":"80cf575de903d69c158b067706bfcda85c3ada006516d01e6e3a0678396199e0","src/front/spv/error.rs":"3129fd1fe346441d61d0f641734df7e919919db15df706788d16402ebf480607","src/front/spv/function.rs":"e25dada43fcbe399726db9f8bc63b497e7e67485724935f5fbbda8f1b1b9a47c","src/front/spv/image.rs":"06be5f35e09a91d7bb20693f777394fe2c3985d01fcfe2977cebba791da05e04","src/front/spv/mod.rs":"a950d2752e338091ed9b8403f748d31963b0c9c0a33c83a8e085ed1a50a6dc93","src/front/spv/null.rs":"e1446d99d04c76a9c3bbd24dd9b20c4711ce8a918a9b403be6cccbde1175b3b4","src/front/type_gen.rs":"8f5ab3a4296ba9e98941c2a0c03342ac1224706e557fe5ce06e5af818ad00f83","src/front/wgsl/error.rs":"583703c418952630cfab403f767e777712e7eb7c163ed66f0a4f512441f54586","src/front/wgsl/index.rs":"2b9a4929a46bd822d3ed6f9a150e24d437e5bdca8293eb748aebe80ce7e74153","src/front/wgsl/lower/construction.rs":"29045c8fe0b05f317fac56c7d4f895e6b0dd253d3ed05efe87d9d702f4cb8927","src/front/wgsl/lower/mod.rs":"ccf9ec11ca80cf77ca8d291f9880f3847ead5f6b86c93332919a49f53d2a0e8c","src/front/wgsl/mod.rs":"f049afd861b0ab0e8acedd8360395e2b2cbb9c055bb72ccf75cf873f7c0e4227","src/front/wgsl/parse/ast.rs":"b77b53135652c0fbdb54ae9139d8b5683eaa4e583593d33d687d6c812e61051c","src/front/wgsl/parse/conv.rs":"25d7f636af48d361931f9cf8f46b70a07ff82391ebfc6ea434d097e417f314c5","src/front/wgsl/parse/lexer.rs":"15e77c8b45de0b19e75c09b4e3b991f092ccff1df4aadf5cb89f9ce131e97b20","src/front/wgsl/parse/mod.rs":"adffe28e4774aa9952b9ac6c4fd71762672b685de16cf3e5cc96b23843edbc8f","src/front/wgsl/parse/number.rs":"64fe5d5f6b1d6a6acf15f4cad3cda8045ad5d82efda179627f848aba9c47e605","src/front/wgsl/tests.rs":"1e74a9bad3a6a6c28420d70fe316e54011398f8c4f9f0cb3f693fadf0161da74","src/keywords/mod.rs":"0138f3931f8af0b0a05174549d0fd2152945b027dc3febefc1bbd676581d2e45","src/keywords/wgsl.rs":"7c3b364b60ca29cb8a68ef781de9ecd28b76b74bed18bf18a35d2ebffaa855ab","src/lib.rs":"5290536217c7de288dc5ab347be418aed6beda59c8bd74a50e8b87caad622a8b","src/proc/index.rs":"f4250f6944c2b631e8140979024e8deb86fa8d5352d8641ba954a388b2c0940e","src/proc/layouter.rs":"406845127f080d47ab7323fa743965aad78b40136e81cb93cb13a396eaa252c1","src/proc/mod.rs":"f3ee5c7d81d531f5ea799ee72187c27dd599acba6b01028f05f1d4f25f93c7e5","src/proc/namer.rs":"754e7328ebc4231afcd019aac062dcd8689aead0dec57e6de1a97704ae4289bd","src/proc/terminator.rs":"13c59bf00f5b26171d971effc421091f5e00dedddd246c2daa44fe65aeda060a","src/proc/typifier.rs":"f86ac0e22ed0c24b77de7c69ddc1c7a5b57f2d2d16cf2df69109c072139a29ca","src/span.rs":"2d0bb1dac067743c1d3e6f296a2d22eedb0a358356c922c671f2f107424e78da","src/valid/analyzer.rs":"dd224abc79a8d4c3842012db2709f5aa79d267c020e3d7be0cdd182811c8bb78","src/valid/compose.rs":"eebaa461a3a76526361eb5b16dfae42384dfdfde5afa9b1ddca266a2149c68ad","src/valid/expression.rs":"ba5d0245b2212d9d6a4151aa69b5232280047ed874bb4cd7377c3932e84f3612","src/valid/function.rs":"b1b7e52127a3f224488b5749503d51156e3eecf5bd09811db53b77d53dcdc30a","src/valid/handles.rs":"3d90df61a8791fc79f7408cf6cfd339f4db85f372e0e8696a49195e88a4a8bf7","src/valid/interface.rs":"108b4718c2d643a4a82b4935f3d770e79987d3fc3f8af3fe832ea821ac6cc628","src/valid/mod.rs":"253a9afd818e880a36944bdf6361d7fcbb27725e1c0bd87f95193302443e2d7e","src/valid/type.rs":"8dc7b9833a59e029f6bdb46d879d03be90fedcddc4c37d8d2a6915d990d58070"},"package":null} \ No newline at end of file diff --git a/third_party/rust/naga/src/back/spv/writer.rs b/third_party/rust/naga/src/back/spv/writer.rs index 41a13cbc19d3..fd39fe2e4cdf 100644 --- a/third_party/rust/naga/src/back/spv/writer.rs +++ b/third_party/rust/naga/src/back/spv/writer.rs @@ -1016,12 +1016,27 @@ impl Writer { ref members, span: _, } => { + let mut has_runtime_array = false; let mut member_ids = Vec::with_capacity(members.len()); for (index, member) in members.iter().enumerate() { + let member_ty = &arena[member.ty]; + match member_ty.inner { + crate::TypeInner::Array { + base: _, + size: crate::ArraySize::Dynamic, + stride: _, + } => { + has_runtime_array = true; + } + _ => (), + } self.decorate_struct_member(id, index, member, arena)?; let member_id = self.get_type_id(LookupType::Handle(member.ty)); member_ids.push(member_id); } + if has_runtime_array { + self.decorate(id, Decoration::Block, &[]); + } Instruction::type_struct(id, member_ids.as_slice()) } @@ -1621,7 +1636,6 @@ impl Writer { space: global_variable.space, })) } - } else { } }; @@ -1656,16 +1670,17 @@ impl Writer { } else { // This is a global variable in the Storage address space. The only // way it could have `global_needs_wrapper() == false` is if it has - // a runtime-sized array. In this case, we need to decorate it with - // Block. + // a runtime-sized or binding array. + // Runtime-sized arrays were decorated when iterating through struct content. + // Now binding arrays require Block decorating. if let crate::AddressSpace::Storage { .. } = global_variable.space { - let decorated_id = match ir_module.types[global_variable.ty].inner { + match ir_module.types[global_variable.ty].inner { crate::TypeInner::BindingArray { base, .. } => { - self.get_type_id(LookupType::Handle(base)) + let decorated_id = self.get_type_id(LookupType::Handle(base)); + self.decorate(decorated_id, Decoration::Block, &[]); } - _ => inner_type_id, + _ => (), }; - self.decorate(decorated_id, Decoration::Block, &[]); } if substitute_inner_type_lookup.is_some() { inner_type_id diff --git a/third_party/rust/naga/src/back/wgsl/writer.rs b/third_party/rust/naga/src/back/wgsl/writer.rs index da39cd94f27b..3a0424e7bb9c 100644 --- a/third_party/rust/naga/src/back/wgsl/writer.rs +++ b/third_party/rust/naga/src/back/wgsl/writer.rs @@ -1132,6 +1132,12 @@ impl Writer { } write!(self.out, ")")? } + Expression::Splat { size, value } => { + let size = back::vector_size_str(size); + write!(self.out, "vec{size}(")?; + write_expression(self, value)?; + write!(self.out, ")")?; + } _ => unreachable!(), } @@ -1173,7 +1179,8 @@ impl Writer { Expression::Literal(_) | Expression::Constant(_) | Expression::ZeroValue(_) - | Expression::Compose { .. } => { + | Expression::Compose { .. } + | Expression::Splat { .. } => { self.write_possibly_const_expression( module, expr, @@ -1450,23 +1457,6 @@ impl Writer { self.write_expr(module, expr, func_ctx)?; write!(self.out, ")")?; } - Expression::Splat { size, value } => { - let inner = func_ctx.resolve_type(value, &module.types); - let (scalar_kind, scalar_width) = match *inner { - crate::TypeInner::Scalar { kind, width } => (kind, width), - _ => { - return Err(Error::Unimplemented(format!( - "write_expr expression::splat {inner:?}" - ))); - } - }; - let scalar = scalar_kind_str(scalar_kind, scalar_width); - let size = back::vector_size_str(size); - - write!(self.out, "vec{size}<{scalar}>(")?; - self.write_expr(module, value, func_ctx)?; - write!(self.out, ")")?; - } Expression::Load { pointer } => { let is_atomic_pointer = func_ctx .resolve_type(pointer, &module.types) diff --git a/third_party/rust/naga/src/block.rs b/third_party/rust/naga/src/block.rs index ba4c95ab3a39..b375132ef726 100644 --- a/third_party/rust/naga/src/block.rs +++ b/third_party/rust/naga/src/block.rs @@ -75,9 +75,8 @@ impl Block { pub fn splice + Clone>(&mut self, range: R, other: Self) { #[cfg(feature = "span")] - self.span_info - .splice(range.clone(), other.span_info.into_iter()); - self.body.splice(range, other.body.into_iter()); + self.span_info.splice(range.clone(), other.span_info); + self.body.splice(range, other.body); } pub fn span_iter(&self) -> impl Iterator { #[cfg(feature = "span")] diff --git a/third_party/rust/naga/src/front/wgsl/error.rs b/third_party/rust/naga/src/front/wgsl/error.rs index 7ce795fa08d1..f7bed6cdf902 100644 --- a/third_party/rust/naga/src/front/wgsl/error.rs +++ b/third_party/rust/naga/src/front/wgsl/error.rs @@ -17,7 +17,7 @@ pub struct ParseError { } impl ParseError { - pub fn labels(&self) -> impl Iterator + ExactSizeIterator + '_ { + pub fn labels(&self) -> impl ExactSizeIterator + '_ { self.labels .iter() .map(|&(span, ref msg)| (span, msg.as_ref())) diff --git a/third_party/rust/naga/src/proc/layouter.rs b/third_party/rust/naga/src/proc/layouter.rs index 11b2250e938f..4c52e5ec81ee 100644 --- a/third_party/rust/naga/src/proc/layouter.rs +++ b/third_party/rust/naga/src/proc/layouter.rs @@ -151,10 +151,10 @@ impl Layouter { self.layouts.clear(); } - /// Extend this `Layouter` with layouts for any new entries in `types`. + /// Extend this `Layouter` with layouts for any new entries in `gctx.types`. /// - /// Ensure that every type in `types` has a corresponding [TypeLayout] in - /// [`self.layouts`]. + /// Ensure that every type in `gctx.types` has a corresponding [TypeLayout] + /// in [`self.layouts`]. /// /// Some front ends need to be able to compute layouts for existing types /// while module construction is still in progress and new types are still diff --git a/third_party/rust/naga/src/span.rs b/third_party/rust/naga/src/span.rs index 90bf3d174e65..0bc97ff46048 100644 --- a/third_party/rust/naga/src/span.rs +++ b/third_party/rust/naga/src/span.rs @@ -181,7 +181,7 @@ impl WithSpan { } /// Iterator over stored [`SpanContext`]s. - pub fn spans(&self) -> impl Iterator + ExactSizeIterator { + pub fn spans(&self) -> impl ExactSizeIterator { #[cfg(feature = "span")] return self.spans.iter(); #[cfg(not(feature = "span"))] diff --git a/third_party/rust/naga/src/valid/expression.rs b/third_party/rust/naga/src/valid/expression.rs index 1d1d6c0b9919..f9b77b1297c9 100644 --- a/third_party/rust/naga/src/valid/expression.rs +++ b/third_party/rust/naga/src/valid/expression.rs @@ -157,7 +157,7 @@ impl super::Validator { &self, handle: Handle, gctx: crate::proc::GlobalCtx, - mod_info: &mut ModuleInfo, + mod_info: &ModuleInfo, ) -> Result<(), super::ConstExpressionError> { use crate::Expression as E; diff --git a/third_party/rust/naga/src/valid/mod.rs b/third_party/rust/naga/src/valid/mod.rs index 535128772540..f99a2055cecd 100644 --- a/third_party/rust/naga/src/valid/mod.rs +++ b/third_party/rust/naga/src/valid/mod.rs @@ -400,7 +400,7 @@ impl Validator { #[cfg(feature = "validate")] if self.flags.contains(ValidationFlags::CONSTANTS) { for (handle, _) in module.const_expressions.iter() { - self.validate_const_expression(handle, module.to_ctx(), &mut mod_info) + self.validate_const_expression(handle, module.to_ctx(), &mod_info) .map_err(|source| { ValidationError::ConstExpression { handle, source } .with_span_handle(handle, &module.const_expressions) diff --git a/third_party/rust/wgpu-core/.cargo-checksum.json b/third_party/rust/wgpu-core/.cargo-checksum.json index 454f78638c93..3ffc745acfb9 100644 --- a/third_party/rust/wgpu-core/.cargo-checksum.json +++ b/third_party/rust/wgpu-core/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"7e5c00225497db0d65e2d91d19645c708402165126f655d26b77375ed70077af","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/binding_model.rs":"3322f03854b92abeb4aeb65dda4ef776094713bce1277047fe85be73a9bc7b4e","src/command/bind.rs":"c243a4448b87e9b7274b10873b7091b385413ec0a4ea93cccd6d612214ec9abb","src/command/bundle.rs":"b26eb6cb877a19d203e9d2b8ac3b10e81f6a94b8b68617eac97a3b861cbe102b","src/command/clear.rs":"418ac36738d782ab72e8700aabef802638cdef1c873f4b036aa8a4c521cb9caf","src/command/compute.rs":"0f8492bdfddb58c413282b2640b1f2a2b934ee256106f661241ac144bfd63d28","src/command/draw.rs":"92facdd0e3fd553af590ecbc0de3491f212e237ea66494ff99f67dbf090d10df","src/command/memory_init.rs":"b50d3d20dbf659052f19da2e79469ba6435e06370f19d6ef45e1b1128d9900b7","src/command/mod.rs":"a63937a5b8a441b714329a5e1b0b4dd4b70ae2f39b52da633fd79edbe183edc6","src/command/query.rs":"d39e1b8cb6a054fd31333a916da5d79a6671a724212c90c490c13e55043a1685","src/command/render.rs":"e98d109e2fe3651a96f74cf1c40a2cc9c752bcf9ea8e893285d7fcad634724dc","src/command/transfer.rs":"c777c6e51afb459d2b5416e31071f24e4215c66f456fee3bd8f7395f9d1c5db1","src/conv.rs":"da95b36b7680ae74ebf810ad8f1decf01bd3eeaff44b3c5af1d4b3c3f0e2059a","src/device/global.rs":"84ca385802eba1c119b571a30885c59ae1a4056438d6f69b13a837e06b2cd584","src/device/life.rs":"4afecaf3602e23a4d8c795c29b9e5e148866e728b008884d55f658de29af4fe9","src/device/mod.rs":"5ac7886bc8b2054c52dfb5955fe7b72fc9bf725b08b5e39121d6a952aa4f8f2b","src/device/queue.rs":"d2692b5c12d05dfaf325d437b5bffe069cfff43228ce40f25147cec2cda428ba","src/device/resource.rs":"ef5ef881a2cf1037d6f5b6bf3b497a9826707ceee00421873c4cf32f0e5c4510","src/device/trace.rs":"21408dfd2c99e3ce36a77d08ba86cf52f32bb376ed82690bbbf74937bfd42cbe","src/error.rs":"ca37282283985e2b7d184b2ab7ca6f53f726432d920f8d8477bfff6fab9b34e2","src/global.rs":"cf551de97c3eb5acd0c2710da09ebd92cc863ad0bb0f53c0fd4911bf8cd3ad97","src/hal_api.rs":"92a2f0cb80f192693530ed61048919bbad446742c2370bf0944c44b1c5df8362","src/hub.rs":"48ccada54672a88169c23975ddc3758cd32ed5de577c55ca4f665d0ed17d3233","src/id.rs":"f6245d024586c7fe63ded13b3cb926b940c191bbee56aedc655e8cef74bdd66b","src/identity.rs":"3ce6a3b57c7c4fc0808d13cd342d928c214f32368e45c79d8e2bbf8df887f97f","src/init_tracker/buffer.rs":"a0ebf54a1e6d269c7b4aa0ac7bb8b04fd2cea3221a1d058ff33cb683b2aea3e9","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"37b6584aaca11c407d91f77002dcbb48d8a4876e27edd1b71b7929ef966f901d","src/instance.rs":"2798b83772dd82a5461901cfca0b91c8b101bfcdf96095091dc59d1bd4b69cc1","src/lib.rs":"27ff8dd787d41cf412e90d0c4674aa70db59e608f9eb3be485c0bd18e9f13369","src/pipeline.rs":"669219add15448fdf5fe8bc5e03fd6fd1ada2b45b07047fd8c0a9bbbcdecad8b","src/present.rs":"b17400ba823e2fce9438947d3dfbfd34045f959666c6718286112a3f3925e387","src/registry.rs":"4098413de7f48e9ff15d0246793be47a0d54c95b4c8594baf9fafd222a90ba84","src/resource.rs":"7d1d841dd185a1a857814cab424a8b892aa8731dddf3373ea9436fa619d655b7","src/storage.rs":"bc70689ba299e9b4d9f4992c4d3f4dd36b1d8e71327595094981fdfd624f811a","src/track/buffer.rs":"dd6f632c6f31b15807148d705c516a8a1a8d72d02b137dd3b9d7c939447917cb","src/track/metadata.rs":"a80bd086ce825f7484ce6318a586c482d06fea0efc9c76bfa0124e480cc8b75e","src/track/mod.rs":"42b791d9a41eb6e62f6d79cae7abb5ab523eeb9e6030b0f95bbb0e26d56ad0ec","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"1d786b5e9558672243ba7d913736561065ef2bd5c6105c935e982486d10841f0","src/track/texture.rs":"7d60dc81ba7f7e2c2819525b90e6e6c7760cb0920e36aeefe98e76cedd49d26e","src/validation.rs":"66ee194d095b7fc54e0545f8b848120eb42d458a50beea67301ff3e5c88a4b3c"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"34e400c82ab56ff7ed3b3e7fcd3d96246d68d6a246c7f12b3403465af1006772","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/binding_model.rs":"3322f03854b92abeb4aeb65dda4ef776094713bce1277047fe85be73a9bc7b4e","src/command/bind.rs":"c243a4448b87e9b7274b10873b7091b385413ec0a4ea93cccd6d612214ec9abb","src/command/bundle.rs":"b26eb6cb877a19d203e9d2b8ac3b10e81f6a94b8b68617eac97a3b861cbe102b","src/command/clear.rs":"418ac36738d782ab72e8700aabef802638cdef1c873f4b036aa8a4c521cb9caf","src/command/compute.rs":"0f8492bdfddb58c413282b2640b1f2a2b934ee256106f661241ac144bfd63d28","src/command/draw.rs":"92facdd0e3fd553af590ecbc0de3491f212e237ea66494ff99f67dbf090d10df","src/command/memory_init.rs":"b50d3d20dbf659052f19da2e79469ba6435e06370f19d6ef45e1b1128d9900b7","src/command/mod.rs":"a63937a5b8a441b714329a5e1b0b4dd4b70ae2f39b52da633fd79edbe183edc6","src/command/query.rs":"d39e1b8cb6a054fd31333a916da5d79a6671a724212c90c490c13e55043a1685","src/command/render.rs":"e98d109e2fe3651a96f74cf1c40a2cc9c752bcf9ea8e893285d7fcad634724dc","src/command/transfer.rs":"c777c6e51afb459d2b5416e31071f24e4215c66f456fee3bd8f7395f9d1c5db1","src/conv.rs":"da95b36b7680ae74ebf810ad8f1decf01bd3eeaff44b3c5af1d4b3c3f0e2059a","src/device/global.rs":"84ca385802eba1c119b571a30885c59ae1a4056438d6f69b13a837e06b2cd584","src/device/life.rs":"4afecaf3602e23a4d8c795c29b9e5e148866e728b008884d55f658de29af4fe9","src/device/mod.rs":"5ac7886bc8b2054c52dfb5955fe7b72fc9bf725b08b5e39121d6a952aa4f8f2b","src/device/queue.rs":"d2692b5c12d05dfaf325d437b5bffe069cfff43228ce40f25147cec2cda428ba","src/device/resource.rs":"0a3a9a83f65873819142c80e90043fa01bce87d4b8f27aef9646ed6c84c90929","src/device/trace.rs":"21408dfd2c99e3ce36a77d08ba86cf52f32bb376ed82690bbbf74937bfd42cbe","src/error.rs":"ca37282283985e2b7d184b2ab7ca6f53f726432d920f8d8477bfff6fab9b34e2","src/global.rs":"cf551de97c3eb5acd0c2710da09ebd92cc863ad0bb0f53c0fd4911bf8cd3ad97","src/hal_api.rs":"92a2f0cb80f192693530ed61048919bbad446742c2370bf0944c44b1c5df8362","src/hub.rs":"48ccada54672a88169c23975ddc3758cd32ed5de577c55ca4f665d0ed17d3233","src/id.rs":"f6245d024586c7fe63ded13b3cb926b940c191bbee56aedc655e8cef74bdd66b","src/identity.rs":"3ce6a3b57c7c4fc0808d13cd342d928c214f32368e45c79d8e2bbf8df887f97f","src/init_tracker/buffer.rs":"a0ebf54a1e6d269c7b4aa0ac7bb8b04fd2cea3221a1d058ff33cb683b2aea3e9","src/init_tracker/mod.rs":"0867f79f83555390d0982d1dc6dcf0d4340e10cb89aa633d3c3ecc45deb3c78c","src/init_tracker/texture.rs":"37b6584aaca11c407d91f77002dcbb48d8a4876e27edd1b71b7929ef966f901d","src/instance.rs":"2798b83772dd82a5461901cfca0b91c8b101bfcdf96095091dc59d1bd4b69cc1","src/lib.rs":"27ff8dd787d41cf412e90d0c4674aa70db59e608f9eb3be485c0bd18e9f13369","src/pipeline.rs":"212d469bc1a2256871f64b3f666f05995a92ce39391c32de3856ef2e11c08e16","src/present.rs":"b17400ba823e2fce9438947d3dfbfd34045f959666c6718286112a3f3925e387","src/registry.rs":"4098413de7f48e9ff15d0246793be47a0d54c95b4c8594baf9fafd222a90ba84","src/resource.rs":"7d1d841dd185a1a857814cab424a8b892aa8731dddf3373ea9436fa619d655b7","src/storage.rs":"bc70689ba299e9b4d9f4992c4d3f4dd36b1d8e71327595094981fdfd624f811a","src/track/buffer.rs":"dd6f632c6f31b15807148d705c516a8a1a8d72d02b137dd3b9d7c939447917cb","src/track/metadata.rs":"a80bd086ce825f7484ce6318a586c482d06fea0efc9c76bfa0124e480cc8b75e","src/track/mod.rs":"42b791d9a41eb6e62f6d79cae7abb5ab523eeb9e6030b0f95bbb0e26d56ad0ec","src/track/range.rs":"5bbfed6e103b3234d9de8e42057022da6d628c2cc1db6bb51b88f87f2d8adf8b","src/track/stateless.rs":"1d786b5e9558672243ba7d913736561065ef2bd5c6105c935e982486d10841f0","src/track/texture.rs":"7d60dc81ba7f7e2c2819525b90e6e6c7760cb0920e36aeefe98e76cedd49d26e","src/validation.rs":"fa84594ad2804684d298adf540b07723dd744bb5d6b19f1e85e00cbe86337f54"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-core/Cargo.toml b/third_party/rust/wgpu-core/Cargo.toml index a0d7328cf838..69f97e168a1f 100644 --- a/third_party/rust/wgpu-core/Cargo.toml +++ b/third_party/rust/wgpu-core/Cargo.toml @@ -55,7 +55,7 @@ package = "wgpu-hal" [dependencies.naga] version = "0.13.0" git = "https://github.com/gfx-rs/naga" -rev = "cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c" +rev = "df8107b7" features = [ "clone", "span", diff --git a/third_party/rust/wgpu-core/src/device/resource.rs b/third_party/rust/wgpu-core/src/device/resource.rs index 73f1887e10db..8acc34acf431 100644 --- a/third_party/rust/wgpu-core/src/device/resource.rs +++ b/third_party/rust/wgpu-core/src/device/resource.rs @@ -1276,6 +1276,10 @@ impl Device { .flags .contains(wgt::DownlevelFlags::MULTISAMPLED_SHADING), ); + caps.set( + Caps::DUAL_SOURCE_BLENDING, + self.features.contains(wgt::Features::DUAL_SOURCE_BLENDING), + ); let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), caps) .validate(&module) @@ -1286,7 +1290,8 @@ impl Device { inner: Box::new(inner), }) })?; - let interface = validation::Interface::new(&module, &info, self.limits.clone()); + let interface = + validation::Interface::new(&module, &info, self.limits.clone(), self.features); let hal_shader = hal::ShaderInput::Naga(hal::NagaShader { module, info }); let hal_desc = hal::ShaderModuleDescriptor { @@ -2560,6 +2565,8 @@ impl Device { let mut vertex_steps = Vec::with_capacity(desc.vertex.buffers.len()); let mut vertex_buffers = Vec::with_capacity(desc.vertex.buffers.len()); let mut total_attributes = 0; + let mut shader_expects_dual_source_blending = false; + let mut pipeline_expects_dual_source_blending = false; for (i, vb_state) in desc.vertex.buffers.iter().enumerate() { vertex_steps.push(pipeline::VertexStep { stride: vb_state.array_stride, @@ -2700,7 +2707,25 @@ impl Device { { break Some(pipeline::ColorStateError::FormatNotMultisampled(cs.format)); } - + if let Some(blend_mode) = cs.blend { + for factor in [ + blend_mode.color.src_factor, + blend_mode.color.dst_factor, + blend_mode.alpha.src_factor, + blend_mode.alpha.dst_factor, + ] { + if factor.ref_second_blend_source() { + self.require_features(wgt::Features::DUAL_SOURCE_BLENDING)?; + if i == 0 { + pipeline_expects_dual_source_blending = true; + break; + } else { + return Err(crate::pipeline::CreateRenderPipelineError + ::BlendFactorOnUnsupportedTarget { factor, target: i as u32 }); + } + } + } + } break None; }; if let Some(e) = error { @@ -2857,6 +2882,15 @@ impl Device { } } + if let Some(ref interface) = shader_module.interface { + shader_expects_dual_source_blending = interface + .fragment_uses_dual_source_blending(&fragment.stage.entry_point) + .map_err(|error| pipeline::CreateRenderPipelineError::Stage { + stage: flag, + error, + })?; + } + Some(hal::ProgrammableStage { module: &shader_module.raw, entry_point: fragment.stage.entry_point.as_ref(), @@ -2865,6 +2899,17 @@ impl Device { None => None, }; + if !pipeline_expects_dual_source_blending && shader_expects_dual_source_blending { + return Err( + pipeline::CreateRenderPipelineError::ShaderExpectsPipelineToUseDualSourceBlending, + ); + } + if pipeline_expects_dual_source_blending && !shader_expects_dual_source_blending { + return Err( + pipeline::CreateRenderPipelineError::PipelineExpectsShaderToUseDualSourceBlending, + ); + } + if validated_stages.contains(wgt::ShaderStages::FRAGMENT) { for (i, output) in io.iter() { match color_targets.get(*i as usize) { diff --git a/third_party/rust/wgpu-core/src/pipeline.rs b/third_party/rust/wgpu-core/src/pipeline.rs index da06b652ea73..c78a79820d8b 100644 --- a/third_party/rust/wgpu-core/src/pipeline.rs +++ b/third_party/rust/wgpu-core/src/pipeline.rs @@ -384,6 +384,15 @@ pub enum CreateRenderPipelineError { }, #[error("In the provided shader, the type given for group {group} binding {binding} has a size of {size}. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.")] UnalignedShader { group: u32, binding: u32, size: u64 }, + #[error("Using the blend factor {factor:?} for render target {target} is not possible. Only the first render target may be used when dual-source blending.")] + BlendFactorOnUnsupportedTarget { + factor: wgt::BlendFactor, + target: u32, + }, + #[error("Pipeline expects the shader entry point to make use of dual-source blending.")] + PipelineExpectsShaderToUseDualSourceBlending, + #[error("Shader entry point expects the pipeline to make use of dual-source blending.")] + ShaderExpectsPipelineToUseDualSourceBlending, } bitflags::bitflags! { diff --git a/third_party/rust/wgpu-core/src/validation.rs b/third_party/rust/wgpu-core/src/validation.rs index e3ecb916d341..ef5c65ed00a9 100644 --- a/third_party/rust/wgpu-core/src/validation.rs +++ b/third_party/rust/wgpu-core/src/validation.rs @@ -116,11 +116,13 @@ struct EntryPoint { spec_constants: Vec, sampling_pairs: FastHashSet<(naga::Handle, naga::Handle)>, workgroup_size: [u32; 3], + dual_source_blending: bool, } #[derive(Debug)] pub struct Interface { limits: wgt::Limits, + features: wgt::Features, resources: naga::Arena, entry_points: FastHashMap<(naga::ShaderStage, String), EntryPoint>, } @@ -830,7 +832,12 @@ impl Interface { list.push(varying); } - pub fn new(module: &naga::Module, info: &naga::valid::ModuleInfo, limits: wgt::Limits) -> Self { + pub fn new( + module: &naga::Module, + info: &naga::valid::ModuleInfo, + limits: wgt::Limits, + features: wgt::Features, + ) -> Self { let mut resources = naga::Arena::new(); let mut resource_mapping = FastHashMap::default(); for (var_handle, var) in module.global_variables.iter() { @@ -903,7 +910,7 @@ impl Interface { ep.sampling_pairs .insert((resource_mapping[&key.image], resource_mapping[&key.sampler])); } - + ep.dual_source_blending = info.dual_source_blending; ep.workgroup_size = entry_point.workgroup_size; entry_points.insert((entry_point.stage, entry_point.name.clone()), ep); @@ -911,6 +918,7 @@ impl Interface { Self { limits, + features, resources, entry_points, } @@ -1120,7 +1128,12 @@ impl Interface { } // Check all vertex outputs and make sure the fragment shader consumes them. - if shader_stage == naga::ShaderStage::Fragment { + // This requirement is removed if the `SHADER_UNUSED_VERTEX_OUTPUT` feature is enabled. + if shader_stage == naga::ShaderStage::Fragment + && !self + .features + .contains(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT) + { for &index in inputs.keys() { // This is a linear scan, but the count should be low enough // that this should be fine. @@ -1177,4 +1190,15 @@ impl Interface { .collect(); Ok(outputs) } + + pub fn fragment_uses_dual_source_blending( + &self, + entry_point_name: &str, + ) -> Result { + let pair = (naga::ShaderStage::Fragment, entry_point_name.to_string()); + self.entry_points + .get(&pair) + .ok_or(StageError::MissingEntryPoint(pair.1)) + .map(|ep| ep.dual_source_blending) + } } diff --git a/third_party/rust/wgpu-hal/.cargo-checksum.json b/third_party/rust/wgpu-hal/.cargo-checksum.json index 870afb286763..ba3eaa982786 100644 --- a/third_party/rust/wgpu-hal/.cargo-checksum.json +++ b/third_party/rust/wgpu-hal/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"0afcc8bdfadff54cc9f023364780d08dc622e15c7aa450ca99d4a37a0abcee19","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"78377f5876fafd77963eff7e3c2ba3a7e3ad5cf9201b09ed5612e49c2288eb18","examples/halmark/main.rs":"a043d9fc0d99ab6b9c379f50f1fd26399a4339cf0002cace21ed1e338efff094","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"d7e0d311514555f41b633eef2fdf355737e22c0b01d045d6afa6ba1b95511b2b","src/auxil/dxgi/conv.rs":"c1e8d584e408712097d075455375e04d1895a0ff9a494305c16d658277ce7b90","src/auxil/dxgi/exception.rs":"baad31f4529f1cf9d10519c4cceccbb21ed9bba7d7ea99e4789c1d5ddf3a450b","src/auxil/dxgi/factory.rs":"50431981d7fce15722ab66b65b491cc2dbebfab03287375e02121797307a11b8","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"20c8eb03d738062dff198feca6327addb9882ed0462be842c789eadf7dca0573","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"c38f0d3b10804d1c1d7e3b8e4a975fcb87271f8b1904f2f4a3153cceddafb56b","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx11/adapter.rs":"90ed68bb96cdb6d057da8aed23ebe6d72f9c3e0d8a4ce85d1a2d8dc373d525ab","src/dx11/command.rs":"32a759d36ebc6d92528a128b117a752dd7fb6f4f0b4d8eda3ed564e5b8d783c2","src/dx11/device.rs":"96ccd8d6645839f3daf832ddf569676643ac92d1b332ab9a0c8563b3b5026295","src/dx11/instance.rs":"e3a97b69eff157b4553fb604f4746ed5ffd92a3b9e3c77f7bb58c06c5fe8d493","src/dx11/library.rs":"4fb09475fb24bc45fb7a464a7c6a30b45e10fed0022aad2891a390b512c11ae1","src/dx11/mod.rs":"21bc698bc0ff8b36a4906ee8dfaf469b6ed35ad852b7c0a5f60c5e5007bba128","src/dx12/adapter.rs":"0cd2ae4c26255d2f5669b9612018c79f2eff4a1a8c266a238c200694674a8519","src/dx12/command.rs":"9074f4b3f80d9a9168b12b59518ca613a81bb7799f8756f5221e46c16cbeae8e","src/dx12/conv.rs":"6c6ca090d4976c6008304d7f44574d88f1e506c8d24f3a872f89d8f900fcf259","src/dx12/descriptor.rs":"d9e295c48dc7d1759fd121c927c2218c1bde90e9f1b35f2ad01b610b184b614e","src/dx12/device.rs":"9d86e55f729302941d579b7ebc6ebb8bfd74afa3b8227fec2fd08c71eb1f2668","src/dx12/instance.rs":"3f730a548eba3ddd86baab5e126cf96dda8bf9145ad25a90fe1879dccc0c95af","src/dx12/mod.rs":"138cd0723aa20179cb92009753cf6327627fba58ce08f865a7f1fd64cdf57e6e","src/dx12/shader_compilation.rs":"dcff4c2c37b4d8c971a1e940eb7a843a32a3016cc65ef26bad71372687a835dc","src/dx12/suballocation.rs":"f5eb7c11dfe9c8d319ec853fec2a1aec8abe6bc61a729faa60302b105265f677","src/dx12/types.rs":"29b11268d11c1b7437de3dac403af574ec8aa84fd9954a95a16d80f5808be44d","src/dx12/view.rs":"c09241520377e6a47ad8822c69075e6e16e6c558e18bb64398c8d7424fc57dcf","src/empty.rs":"98c4ad29fdf1bad55097d540393b9ef62cce23b9d5cfd2a131f790042e3bd8b8","src/gles/adapter.rs":"a28d74c3704dfc9961d16be9d7481e24e559f35fd1767adf7d79b6569687c974","src/gles/command.rs":"c7d6ff845b597d85d2fd61be625cf43554944d93f9324c98c2123995946cfd6b","src/gles/conv.rs":"1e1c4a0887fd0062b8e66c86a824e6ddb63b458dcd968e84fffbca519e7b5690","src/gles/device.rs":"11b99f2da55ee07db7549b4313ceb68e35a13f87041832643359e80e6f355034","src/gles/egl.rs":"f562f35c489d6831a58bffb5723cd78d14a4c623a809577ba8b6c2d48a295626","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"65996152dff84f00d6d491bfe5edc5c343f2302a4aa01eef14aadb4bdab096ed","src/gles/queue.rs":"5a85e6c2ad9e97779b6fec81d2811c1e05d71f82f7c5bee87b31eade64c1501e","src/gles/shaders/clear.frag":"aac702eed9ece5482db5ba6783a678b119a5e7802b1ecf93f4975dee8acab0b3","src/gles/shaders/clear.vert":"8f636168e1da2cac48091c466a543c3b09fb4a0dd8c60c1c9bf34cc890766740","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"48669af52f759cf29715835e69b24b0c34c01c9ed25d670eaf7c9cf76b9abfe8","src/lib.rs":"10cf339bba80cf908e127394c92f9e7d14027422a21ca0cd8484221989bc8eb2","src/metal/adapter.rs":"18508f30cf93c7f1bc8abf6ef556f9d3e9ff63faad1c285e01dac3261896fe9e","src/metal/command.rs":"ba1f1f345c94176cefe23f8afe501a10a03ebbd3d3dcdc9acfbecf53882cae65","src/metal/conv.rs":"e4aeafcddc75b2f9b54245faedaf0566f1e63681807ae786ceb46ac35f0e13bf","src/metal/device.rs":"d2fb16e8d7cfc0c9e3141dcf1245a1f0ea8a891962c0cd83c0cd4450e7acaf36","src/metal/mod.rs":"662b964b9a457dc7c0cf12fa53b9777888b96c0d155377e694d84425dc3de439","src/metal/surface.rs":"f4b3f8364ec32a7540f7a1da3b4b7e8c6c1cf336aa5535a4515b4efb5b11c443","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"c3445e2210e5bee535c4df4b9fe4e2e9794c0cca741fc6174fb8b19db7da1cd1","src/vulkan/command.rs":"08d9a43bd43820f2681efe4207a1be678f1aab47d779390c4dbb929d1b5450fa","src/vulkan/conv.rs":"284f002063260811ba3fcfe75d6dc1c4c2eb2bc8b6622eac781157b7683478cd","src/vulkan/device.rs":"46221186c22f1bb10c5aba4a1860eebf6c36d99481fc1d1783848f47babaf9d8","src/vulkan/instance.rs":"2341788015174730de81117790525a7943d8932bbc5e201857203561c6646970","src/vulkan/mod.rs":"1bef6c8213bfccf6dd23fe07414db2893a0f85a755bcf26f461371956c960173"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"20363250aac07e42c8980f0bc88e67c38b052148a272c300c75837d8943d6340","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","README.md":"78377f5876fafd77963eff7e3c2ba3a7e3ad5cf9201b09ed5612e49c2288eb18","examples/halmark/main.rs":"a043d9fc0d99ab6b9c379f50f1fd26399a4339cf0002cace21ed1e338efff094","examples/halmark/shader.wgsl":"26c256ec36d6f0e9a1647431ca772766bee4382d64eaa718ba7b488dcfb6bcca","examples/raw-gles.em.html":"70fbe68394a1a4522192de1dcfaf7d399f60d7bdf5de70b708f9bb0417427546","examples/raw-gles.rs":"d7e0d311514555f41b633eef2fdf355737e22c0b01d045d6afa6ba1b95511b2b","src/auxil/dxgi/conv.rs":"c1e8d584e408712097d075455375e04d1895a0ff9a494305c16d658277ce7b90","src/auxil/dxgi/exception.rs":"baad31f4529f1cf9d10519c4cceccbb21ed9bba7d7ea99e4789c1d5ddf3a450b","src/auxil/dxgi/factory.rs":"50431981d7fce15722ab66b65b491cc2dbebfab03287375e02121797307a11b8","src/auxil/dxgi/mod.rs":"a202564d9ac97530b16a234b87d180cd345aae705e082a9b1177dcde813645f9","src/auxil/dxgi/result.rs":"20c8eb03d738062dff198feca6327addb9882ed0462be842c789eadf7dca0573","src/auxil/dxgi/time.rs":"b6f966b250e9424d5d7e4065f2108cba87197c1e30baae6d87083055d1bc5a4b","src/auxil/mod.rs":"c38f0d3b10804d1c1d7e3b8e4a975fcb87271f8b1904f2f4a3153cceddafb56b","src/auxil/renderdoc.rs":"c2f849f70f576b0c9b0d32dd155b6a6353f74dff59cbeeaa994a12789d047c0f","src/dx11/adapter.rs":"90ed68bb96cdb6d057da8aed23ebe6d72f9c3e0d8a4ce85d1a2d8dc373d525ab","src/dx11/command.rs":"32a759d36ebc6d92528a128b117a752dd7fb6f4f0b4d8eda3ed564e5b8d783c2","src/dx11/device.rs":"96ccd8d6645839f3daf832ddf569676643ac92d1b332ab9a0c8563b3b5026295","src/dx11/instance.rs":"e3a97b69eff157b4553fb604f4746ed5ffd92a3b9e3c77f7bb58c06c5fe8d493","src/dx11/library.rs":"4fb09475fb24bc45fb7a464a7c6a30b45e10fed0022aad2891a390b512c11ae1","src/dx11/mod.rs":"21bc698bc0ff8b36a4906ee8dfaf469b6ed35ad852b7c0a5f60c5e5007bba128","src/dx12/adapter.rs":"e63c2190fdcdaced342e8f6fdfc1ffe8db09b33890dd01f3c351f2853fad49f3","src/dx12/command.rs":"9074f4b3f80d9a9168b12b59518ca613a81bb7799f8756f5221e46c16cbeae8e","src/dx12/conv.rs":"24d6ac9808f7534f3480ba2eb563f98f1441c8ad2b4c6e86b2700f5ac812e99a","src/dx12/descriptor.rs":"d9e295c48dc7d1759fd121c927c2218c1bde90e9f1b35f2ad01b610b184b614e","src/dx12/device.rs":"9d86e55f729302941d579b7ebc6ebb8bfd74afa3b8227fec2fd08c71eb1f2668","src/dx12/instance.rs":"3f730a548eba3ddd86baab5e126cf96dda8bf9145ad25a90fe1879dccc0c95af","src/dx12/mod.rs":"138cd0723aa20179cb92009753cf6327627fba58ce08f865a7f1fd64cdf57e6e","src/dx12/shader_compilation.rs":"dcff4c2c37b4d8c971a1e940eb7a843a32a3016cc65ef26bad71372687a835dc","src/dx12/suballocation.rs":"f5eb7c11dfe9c8d319ec853fec2a1aec8abe6bc61a729faa60302b105265f677","src/dx12/types.rs":"29b11268d11c1b7437de3dac403af574ec8aa84fd9954a95a16d80f5808be44d","src/dx12/view.rs":"c09241520377e6a47ad8822c69075e6e16e6c558e18bb64398c8d7424fc57dcf","src/empty.rs":"98c4ad29fdf1bad55097d540393b9ef62cce23b9d5cfd2a131f790042e3bd8b8","src/gles/adapter.rs":"f0e205b90558e4228160d9ad1a4567924f3c5781b5b2d362c27877d70c1da8e8","src/gles/command.rs":"c7d6ff845b597d85d2fd61be625cf43554944d93f9324c98c2123995946cfd6b","src/gles/conv.rs":"545caf12bcadbf4566385d401b388310c99148b015a632d89a5223592003d74b","src/gles/device.rs":"11b99f2da55ee07db7549b4313ceb68e35a13f87041832643359e80e6f355034","src/gles/egl.rs":"f562f35c489d6831a58bffb5723cd78d14a4c623a809577ba8b6c2d48a295626","src/gles/emscripten.rs":"19bb73a9d140645f3f32cd48b002151711a9b8456e213eab5f3a2be79239e147","src/gles/mod.rs":"65996152dff84f00d6d491bfe5edc5c343f2302a4aa01eef14aadb4bdab096ed","src/gles/queue.rs":"5a85e6c2ad9e97779b6fec81d2811c1e05d71f82f7c5bee87b31eade64c1501e","src/gles/shaders/clear.frag":"aac702eed9ece5482db5ba6783a678b119a5e7802b1ecf93f4975dee8acab0b3","src/gles/shaders/clear.vert":"8f636168e1da2cac48091c466a543c3b09fb4a0dd8c60c1c9bf34cc890766740","src/gles/shaders/srgb_present.frag":"dd9a43c339a2fa4ccf7f6a1854c6f400cabf271a7d5e9230768e9f39d47f3ff5","src/gles/shaders/srgb_present.vert":"6e85d489403d80b81cc94790730bb53b309dfc5eeede8f1ea3412a660f31d357","src/gles/web.rs":"48669af52f759cf29715835e69b24b0c34c01c9ed25d670eaf7c9cf76b9abfe8","src/lib.rs":"10cf339bba80cf908e127394c92f9e7d14027422a21ca0cd8484221989bc8eb2","src/metal/adapter.rs":"3074f59a3c28a700c0836834960834a4a9f0d9b83a2f2f3690fc8e0c0e2198ab","src/metal/command.rs":"a85e574592b1426423be49f9cee06b4549161e99f39ca5a61bf55fee31cef323","src/metal/conv.rs":"0bce6a8d0ccef16783475803d70d35e03ab7938c19374e22c9d253abe1f8b111","src/metal/device.rs":"d2fb16e8d7cfc0c9e3141dcf1245a1f0ea8a891962c0cd83c0cd4450e7acaf36","src/metal/mod.rs":"5b435be74845f794a644db6e289e8646c27d515fd759cdd58d256fefcff0f66d","src/metal/surface.rs":"f4b3f8364ec32a7540f7a1da3b4b7e8c6c1cf336aa5535a4515b4efb5b11c443","src/metal/time.rs":"c32d69f30e846dfcc0e39e01097fb80df63b2bebb6586143bb62494999850246","src/vulkan/adapter.rs":"26df80cd2c190bf3711f6dca552ebe678d68e5abd8559ef2b5615ade0594e028","src/vulkan/command.rs":"e045e886ab63b545effc12bb59c0f1c7a21f01d57ac0454e82f957be41301f2b","src/vulkan/conv.rs":"546a98b2d1222e8bbd562fda9a1dab347d5b5a6fd8631793c621d38a7a9a8070","src/vulkan/device.rs":"46221186c22f1bb10c5aba4a1860eebf6c36d99481fc1d1783848f47babaf9d8","src/vulkan/instance.rs":"2341788015174730de81117790525a7943d8932bbc5e201857203561c6646970","src/vulkan/mod.rs":"9837ae73177ef5828bef9b33b9d3e73359df914b42af289c0f2457fd56f9d7ee"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-hal/Cargo.toml b/third_party/rust/wgpu-hal/Cargo.toml index bee440c39405..a020974f3a73 100644 --- a/third_party/rust/wgpu-hal/Cargo.toml +++ b/third_party/rust/wgpu-hal/Cargo.toml @@ -64,7 +64,7 @@ optional = true [dependencies.naga] version = "0.13.0" git = "https://github.com/gfx-rs/naga" -rev = "cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c" +rev = "df8107b7" features = ["clone"] [dependencies.profiling] @@ -83,7 +83,7 @@ env_logger = "0.10" [dev-dependencies.naga] version = "0.13.0" git = "https://github.com/gfx-rs/naga" -rev = "cc87b8f9eb30bb55d0735b89d3df3e099e1a6e7c" +rev = "df8107b7" features = ["wgsl-in"] [dev-dependencies.winit] @@ -158,13 +158,16 @@ features = [ [target."cfg(any(target_os=\"macos\", target_os=\"ios\"))".dependencies] core-graphics-types = "0.1" -metal = "0.26.0" objc = "0.2.5" [target."cfg(any(target_os=\"macos\", target_os=\"ios\"))".dependencies.block] version = "0.1" optional = true +[target."cfg(any(target_os=\"macos\", target_os=\"ios\"))".dependencies.metal] +git = "https://github.com/gfx-rs/metal-rs/" +rev = "d24f1a4" + [target."cfg(not(target_arch = \"wasm32\"))".dependencies.ash] version = "0.37.3" optional = true diff --git a/third_party/rust/wgpu-hal/src/dx12/adapter.rs b/third_party/rust/wgpu-hal/src/dx12/adapter.rs index 02cde913ca1a..3959deeccd6e 100644 --- a/third_party/rust/wgpu-hal/src/dx12/adapter.rs +++ b/third_party/rust/wgpu-hal/src/dx12/adapter.rs @@ -250,7 +250,9 @@ impl super::Adapter { | wgt::Features::TEXTURE_FORMAT_16BIT_NORM | wgt::Features::PUSH_CONSTANTS | wgt::Features::SHADER_PRIMITIVE_INDEX - | wgt::Features::RG11B10UFLOAT_RENDERABLE; + | wgt::Features::RG11B10UFLOAT_RENDERABLE + | wgt::Features::DUAL_SOURCE_BLENDING; + //TODO: in order to expose this, we need to run a compute shader // that extract the necessary statistics out of the D3D12 result. // Alternatively, we could allocate a buffer for the query set, diff --git a/third_party/rust/wgpu-hal/src/dx12/conv.rs b/third_party/rust/wgpu-hal/src/dx12/conv.rs index 8b44ae9c4b05..f484d1a9e2c4 100644 --- a/third_party/rust/wgpu-hal/src/dx12/conv.rs +++ b/third_party/rust/wgpu-hal/src/dx12/conv.rs @@ -222,6 +222,10 @@ pub fn map_polygon_mode(mode: wgt::PolygonMode) -> d3d12_ty::D3D12_FILL_MODE { } } +/// D3D12 doesn't support passing factors ending in `_COLOR` for alpha blending +/// (see https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_render_target_blend_desc). +/// Therefore this function takes an additional `is_alpha` argument +/// which if set will return an equivalent `_ALPHA` factor. fn map_blend_factor(factor: wgt::BlendFactor, is_alpha: bool) -> d3d12_ty::D3D12_BLEND { use wgt::BlendFactor as Bf; match factor { @@ -242,12 +246,12 @@ fn map_blend_factor(factor: wgt::BlendFactor, is_alpha: bool) -> d3d12_ty::D3D12 Bf::Constant => d3d12_ty::D3D12_BLEND_BLEND_FACTOR, Bf::OneMinusConstant => d3d12_ty::D3D12_BLEND_INV_BLEND_FACTOR, Bf::SrcAlphaSaturated => d3d12_ty::D3D12_BLEND_SRC_ALPHA_SAT, - //Bf::Src1Color if is_alpha => d3d12_ty::D3D12_BLEND_SRC1_ALPHA, - //Bf::Src1Color => d3d12_ty::D3D12_BLEND_SRC1_COLOR, - //Bf::OneMinusSrc1Color if is_alpha => d3d12_ty::D3D12_BLEND_INV_SRC1_ALPHA, - //Bf::OneMinusSrc1Color => d3d12_ty::D3D12_BLEND_INV_SRC1_COLOR, - //Bf::Src1Alpha => d3d12_ty::D3D12_BLEND_SRC1_ALPHA, - //Bf::OneMinusSrc1Alpha => d3d12_ty::D3D12_BLEND_INV_SRC1_ALPHA, + Bf::Src1 if is_alpha => d3d12_ty::D3D12_BLEND_SRC1_ALPHA, + Bf::Src1 => d3d12_ty::D3D12_BLEND_SRC1_COLOR, + Bf::OneMinusSrc1 if is_alpha => d3d12_ty::D3D12_BLEND_INV_SRC1_ALPHA, + Bf::OneMinusSrc1 => d3d12_ty::D3D12_BLEND_INV_SRC1_COLOR, + Bf::Src1Alpha => d3d12_ty::D3D12_BLEND_SRC1_ALPHA, + Bf::OneMinusSrc1Alpha => d3d12_ty::D3D12_BLEND_INV_SRC1_ALPHA, } } diff --git a/third_party/rust/wgpu-hal/src/gles/adapter.rs b/third_party/rust/wgpu-hal/src/gles/adapter.rs index 348f62bc03c7..cbbcf7399e36 100644 --- a/third_party/rust/wgpu-hal/src/gles/adapter.rs +++ b/third_party/rust/wgpu-hal/src/gles/adapter.rs @@ -363,11 +363,16 @@ impl super::Adapter { wgt::Features::MULTIVIEW, extensions.contains("OVR_multiview2"), ); + features.set( + wgt::Features::DUAL_SOURCE_BLENDING, + extensions.contains("GL_EXT_blend_func_extended"), + ); features.set( wgt::Features::SHADER_PRIMITIVE_INDEX, ver >= (3, 2) || extensions.contains("OES_geometry_shader"), ); features.set(wgt::Features::SHADER_EARLY_DEPTH_TEST, ver >= (3, 1)); + features.set(wgt::Features::SHADER_UNUSED_VERTEX_OUTPUT, true); let gles_bcn_exts = [ "GL_EXT_texture_compression_s3tc_srgb", "GL_EXT_texture_compression_rgtc", diff --git a/third_party/rust/wgpu-hal/src/gles/conv.rs b/third_party/rust/wgpu-hal/src/gles/conv.rs index dd5d764c6a55..9bfac022a1f1 100644 --- a/third_party/rust/wgpu-hal/src/gles/conv.rs +++ b/third_party/rust/wgpu-hal/src/gles/conv.rs @@ -376,6 +376,10 @@ fn map_blend_factor(factor: wgt::BlendFactor) -> u32 { Bf::Constant => glow::CONSTANT_COLOR, Bf::OneMinusConstant => glow::ONE_MINUS_CONSTANT_COLOR, Bf::SrcAlphaSaturated => glow::SRC_ALPHA_SATURATE, + Bf::Src1 => glow::SRC1_COLOR, + Bf::OneMinusSrc1 => glow::ONE_MINUS_SRC1_COLOR, + Bf::Src1Alpha => glow::SRC1_ALPHA, + Bf::OneMinusSrc1Alpha => glow::ONE_MINUS_SRC1_ALPHA, } } diff --git a/third_party/rust/wgpu-hal/src/metal/adapter.rs b/third_party/rust/wgpu-hal/src/metal/adapter.rs index bc90954b3576..c4617deaa0b4 100644 --- a/third_party/rust/wgpu-hal/src/metal/adapter.rs +++ b/third_party/rust/wgpu-hal/src/metal/adapter.rs @@ -5,6 +5,8 @@ use wgt::{AstcBlock, AstcChannel}; use std::{sync::Arc, thread}; +use super::TimestampQuerySupport; + const MAX_COMMAND_BUFFERS: u64 = 2048; unsafe impl Send for super::Adapter {} @@ -536,6 +538,26 @@ impl super::PrivateCapabilities { MTLReadWriteTextureTier::TierNone }; + let mut timestamp_query_support = TimestampQuerySupport::empty(); + if version.at_least((11, 0), (14, 0), os_is_mac) + && device.supports_counter_sampling(metal::MTLCounterSamplingPoint::AtStageBoundary) + { + // If we don't support at stage boundary, don't support anything else. + timestamp_query_support.insert(TimestampQuerySupport::STAGE_BOUNDARIES); + + if device.supports_counter_sampling(metal::MTLCounterSamplingPoint::AtDrawBoundary) { + timestamp_query_support.insert(TimestampQuerySupport::ON_RENDER_ENCODER); + } + if device.supports_counter_sampling(metal::MTLCounterSamplingPoint::AtDispatchBoundary) + { + timestamp_query_support.insert(TimestampQuerySupport::ON_COMPUTE_ENCODER); + } + if device.supports_counter_sampling(metal::MTLCounterSamplingPoint::AtBlitBoundary) { + timestamp_query_support.insert(TimestampQuerySupport::ON_BLIT_ENCODER); + } + // `TimestampQuerySupport::INSIDE_WGPU_PASSES` emerges from the other flags. + } + Self { family_check, msl_version: if os_is_xr || version.at_least((12, 0), (15, 0), os_is_mac) { @@ -773,13 +795,7 @@ impl super::PrivateCapabilities { } else { None }, - support_timestamp_query: version.at_least((11, 0), (14, 0), os_is_mac) - && device - .supports_counter_sampling(metal::MTLCounterSamplingPoint::AtStageBoundary), - support_timestamp_query_in_passes: version.at_least((11, 0), (14, 0), os_is_mac) - && device.supports_counter_sampling(metal::MTLCounterSamplingPoint::AtDrawBoundary) - && device - .supports_counter_sampling(metal::MTLCounterSamplingPoint::AtDispatchBoundary), + timestamp_query_support, } } @@ -807,12 +823,20 @@ impl super::PrivateCapabilities { | F::DEPTH32FLOAT_STENCIL8 | F::MULTI_DRAW_INDIRECT; - features.set(F::TIMESTAMP_QUERY, self.support_timestamp_query); - // TODO: Not yet implemented. - // features.set( - // F::TIMESTAMP_QUERY_INSIDE_PASSES, - // self.support_timestamp_query_in_passes, - // ); + features.set( + F::TIMESTAMP_QUERY, + self.timestamp_query_support + .contains(TimestampQuerySupport::STAGE_BOUNDARIES), + ); + features.set( + F::TIMESTAMP_QUERY_INSIDE_PASSES, + self.timestamp_query_support + .contains(TimestampQuerySupport::INSIDE_WGPU_PASSES), + ); + features.set( + F::DUAL_SOURCE_BLENDING, + self.msl_version >= MTLLanguageVersion::V1_2 && self.dual_source_blending, + ); features.set(F::TEXTURE_COMPRESSION_ASTC, self.format_astc); features.set(F::TEXTURE_COMPRESSION_ASTC_HDR, self.format_astc_hdr); features.set(F::TEXTURE_COMPRESSION_BC, self.format_bc); @@ -847,6 +871,7 @@ impl super::PrivateCapabilities { features.set(F::ADDRESS_MODE_CLAMP_TO_ZERO, true); features.set(F::RG11B10UFLOAT_RENDERABLE, self.format_rg11b10_all); + features.set(F::SHADER_UNUSED_VERTEX_OUTPUT, true); features } diff --git a/third_party/rust/wgpu-hal/src/metal/command.rs b/third_party/rust/wgpu-hal/src/metal/command.rs index cc737fd228c1..c4b37f99325d 100644 --- a/third_party/rust/wgpu-hal/src/metal/command.rs +++ b/third_party/rust/wgpu-hal/src/metal/command.rs @@ -1,4 +1,4 @@ -use super::{conv, AsNative}; +use super::{conv, AsNative, TimestampQuerySupport}; use crate::CommandEncoder as _; use std::{borrow::Cow, mem, ops::Range}; @@ -18,6 +18,7 @@ impl Default for super::CommandState { storage_buffer_length_map: Default::default(), work_group_memory_sizes: Vec::new(), push_constants: Vec::new(), + pending_timer_queries: Vec::new(), } } } @@ -26,10 +27,85 @@ impl super::CommandEncoder { fn enter_blit(&mut self) -> &metal::BlitCommandEncoderRef { if self.state.blit.is_none() { debug_assert!(self.state.render.is_none() && self.state.compute.is_none()); + let cmd_buf = self.raw_cmd_buf.as_ref().unwrap(); + + // Take care of pending timer queries. + // If we can't use `sample_counters_in_buffer` we have to create a dummy blit encoder! + // + // There is a known bug in Metal where blit encoders won't write timestamps if they don't have a blit operation. + // See https://github.com/gpuweb/gpuweb/issues/2046#issuecomment-1205793680 & https://source.chromium.org/chromium/chromium/src/+/006c4eb70c96229834bbaf271290f40418144cd3:third_party/dawn/src/dawn/native/metal/BackendMTL.mm;l=350 + // + // To make things worse: + // * what counts as a blit operation is a bit unclear, experimenting seemed to indicate that resolve_counters doesn't count. + // * in some cases (when?) using `set_start_of_encoder_sample_index` doesn't work, so we have to use `set_end_of_encoder_sample_index` instead + // + // All this means that pretty much the only *reliable* thing as of writing is to: + // * create a dummy blit encoder using set_end_of_encoder_sample_index + // * do a dummy write that is known to be not optimized out. + // * close the encoder since we used set_end_of_encoder_sample_index and don't want to get any extra stuff in there. + // * create another encoder for whatever we actually had in mind. + let supports_sample_counters_in_buffer = self + .shared + .private_caps + .timestamp_query_support + .contains(TimestampQuerySupport::ON_BLIT_ENCODER); + + if !self.state.pending_timer_queries.is_empty() && !supports_sample_counters_in_buffer { + objc::rc::autoreleasepool(|| { + let descriptor = metal::BlitPassDescriptor::new(); + let mut last_query = None; + for (i, (set, index)) in self.state.pending_timer_queries.drain(..).enumerate() + { + let sba_descriptor = descriptor + .sample_buffer_attachments() + .object_at(i as _) + .unwrap(); + sba_descriptor + .set_sample_buffer(set.counter_sample_buffer.as_ref().unwrap()); + + // Here be dragons: + // As mentioned above, for some reasons using the start of the encoder won't yield any results sometimes! + sba_descriptor + .set_start_of_encoder_sample_index(metal::COUNTER_DONT_SAMPLE); + sba_descriptor.set_end_of_encoder_sample_index(index as _); + + last_query = Some((set, index)); + } + let encoder = cmd_buf.blit_command_encoder_with_descriptor(descriptor); + + // As explained above, we need to do some write: + // Conveniently, we have a buffer with every query set, that we can use for this for a dummy write, + // since we know that it is going to be overwritten again on timer resolve and HAL doesn't define its state before that. + let raw_range = metal::NSRange { + location: last_query.as_ref().unwrap().1 as u64 * crate::QUERY_SIZE, + length: 1, + }; + encoder.fill_buffer( + &last_query.as_ref().unwrap().0.raw_buffer, + raw_range, + 255, // Don't write 0, so it's easier to identify if something went wrong. + ); + + encoder.end_encoding(); + }); + } + objc::rc::autoreleasepool(|| { - let cmd_buf = self.raw_cmd_buf.as_ref().unwrap(); self.state.blit = Some(cmd_buf.new_blit_command_encoder().to_owned()); }); + + let encoder = self.state.blit.as_ref().unwrap(); + + // UNTESTED: + // If the above described issue with empty blit encoder applies to `sample_counters_in_buffer` as well, we should use the same workaround instead! + for (set, index) in self.state.pending_timer_queries.drain(..) { + debug_assert!(supports_sample_counters_in_buffer); + encoder.sample_counters_in_buffer( + set.counter_sample_buffer.as_ref().unwrap(), + index as _, + true, + ) + } } self.state.blit.as_ref().unwrap() } @@ -40,7 +116,7 @@ impl super::CommandEncoder { } } - fn enter_any(&mut self) -> Option<&metal::CommandEncoderRef> { + fn active_encoder(&mut self) -> Option<&metal::CommandEncoderRef> { if let Some(ref encoder) = self.state.render { Some(encoder) } else if let Some(ref encoder) = self.state.compute { @@ -127,9 +203,17 @@ impl crate::CommandEncoder for super::CommandEncoder { } unsafe fn end_encoding(&mut self) -> Result { + // Handle pending timer query if any. + if !self.state.pending_timer_queries.is_empty() { + self.leave_blit(); + self.enter_blit(); + } + self.leave_blit(); debug_assert!(self.state.render.is_none()); debug_assert!(self.state.compute.is_none()); + debug_assert!(self.state.pending_timer_queries.is_empty()); + Ok(super::CommandBuffer { raw: self.raw_cmd_buf.take().unwrap(), }) @@ -322,16 +406,43 @@ impl crate::CommandEncoder for super::CommandEncoder { _ => {} } } - unsafe fn write_timestamp(&mut self, _set: &super::QuerySet, _index: u32) { - // TODO: If MTLCounterSamplingPoint::AtDrawBoundary/AtBlitBoundary/AtDispatchBoundary is supported, - // we don't need to insert a new encoder, but can instead use respective current one. - //let encoder = self.enter_any().unwrap_or_else(|| self.enter_blit()); + unsafe fn write_timestamp(&mut self, set: &super::QuerySet, index: u32) { + let support = self.shared.private_caps.timestamp_query_support; + debug_assert!( + support.contains(TimestampQuerySupport::STAGE_BOUNDARIES), + "Timestamp queries are not supported" + ); + let sample_buffer = set.counter_sample_buffer.as_ref().unwrap(); + let with_barrier = true; - // TODO: Otherwise, we need to create a new blit command encoder with a descriptor that inserts the timestamps. - // Note that as of writing creating a new encoder is not exposed by the metal crate. - // https://developer.apple.com/documentation/metal/mtlcommandbuffer/3564431-makeblitcommandencoder + // Try to use an existing encoder for timestamp query if possible. + // This works only if it's supported for the active encoder. + if let (true, Some(encoder)) = ( + support.contains(TimestampQuerySupport::ON_BLIT_ENCODER), + self.state.blit.as_ref(), + ) { + encoder.sample_counters_in_buffer(sample_buffer, index as _, with_barrier); + } else if let (true, Some(encoder)) = ( + support.contains(TimestampQuerySupport::ON_RENDER_ENCODER), + self.state.render.as_ref(), + ) { + encoder.sample_counters_in_buffer(sample_buffer, index as _, with_barrier); + } else if let (true, Some(encoder)) = ( + support.contains(TimestampQuerySupport::ON_COMPUTE_ENCODER), + self.state.compute.as_ref(), + ) { + encoder.sample_counters_in_buffer(sample_buffer, index as _, with_barrier); + } else { + // If we're here it means we either have no encoder open, or it's not supported to sample within them. + // If this happens with render/compute open, this is an invalid usage! + debug_assert!(self.state.render.is_none() && self.state.compute.is_none()); - // TODO: Enable respective test in `examples/timestamp-queries/src/tests.rs`. + // But otherwise it means we'll put defer this to the next created encoder. + self.state.pending_timer_queries.push((set.clone(), index)); + + // Ensure we didn't already have a blit open. + self.leave_blit(); + }; } unsafe fn reset_queries(&mut self, set: &super::QuerySet, range: Range) { @@ -342,6 +453,7 @@ impl crate::CommandEncoder for super::CommandEncoder { }; encoder.fill_buffer(&set.raw_buffer, raw_range, 0); } + unsafe fn copy_query_results( &mut self, set: &super::QuerySet, @@ -454,8 +566,29 @@ impl crate::CommandEncoder for super::CommandEncoder { } } + let mut sba_index = 0; + let mut next_sba_descriptor = || { + let sba_descriptor = descriptor + .sample_buffer_attachments() + .object_at(sba_index) + .unwrap(); + + sba_descriptor.set_end_of_vertex_sample_index(metal::COUNTER_DONT_SAMPLE); + sba_descriptor.set_start_of_fragment_sample_index(metal::COUNTER_DONT_SAMPLE); + + sba_index += 1; + sba_descriptor + }; + + for (set, index) in self.state.pending_timer_queries.drain(..) { + let sba_descriptor = next_sba_descriptor(); + sba_descriptor.set_sample_buffer(set.counter_sample_buffer.as_ref().unwrap()); + sba_descriptor.set_start_of_vertex_sample_index(index as _); + sba_descriptor.set_end_of_fragment_sample_index(metal::COUNTER_DONT_SAMPLE); + } + if let Some(ref timestamp_writes) = desc.timestamp_writes { - let sba_descriptor = descriptor.sample_buffer_attachments().object_at(0).unwrap(); + let sba_descriptor = next_sba_descriptor(); sba_descriptor.set_sample_buffer( timestamp_writes .query_set @@ -464,12 +597,16 @@ impl crate::CommandEncoder for super::CommandEncoder { .unwrap(), ); - if let Some(start_index) = timestamp_writes.beginning_of_pass_write_index { - sba_descriptor.set_start_of_vertex_sample_index(start_index as _); - } - if let Some(end_index) = timestamp_writes.end_of_pass_write_index { - sba_descriptor.set_end_of_fragment_sample_index(end_index as _); - } + sba_descriptor.set_start_of_vertex_sample_index( + timestamp_writes + .beginning_of_pass_write_index + .map_or(metal::COUNTER_DONT_SAMPLE, |i| i as _), + ); + sba_descriptor.set_end_of_fragment_sample_index( + timestamp_writes + .end_of_pass_write_index + .map_or(metal::COUNTER_DONT_SAMPLE, |i| i as _), + ); } if let Some(occlusion_query_set) = desc.occlusion_query_set { @@ -697,19 +834,19 @@ impl crate::CommandEncoder for super::CommandEncoder { } unsafe fn insert_debug_marker(&mut self, label: &str) { - if let Some(encoder) = self.enter_any() { + if let Some(encoder) = self.active_encoder() { encoder.insert_debug_signpost(label); } } unsafe fn begin_debug_marker(&mut self, group_label: &str) { - if let Some(encoder) = self.enter_any() { + if let Some(encoder) = self.active_encoder() { encoder.push_debug_group(group_label); } else if let Some(ref buf) = self.raw_cmd_buf { buf.push_debug_group(group_label); } } unsafe fn end_debug_marker(&mut self) { - if let Some(encoder) = self.enter_any() { + if let Some(encoder) = self.active_encoder() { encoder.pop_debug_group(); } else if let Some(ref buf) = self.raw_cmd_buf { buf.pop_debug_group(); @@ -969,11 +1106,25 @@ impl crate::CommandEncoder for super::CommandEncoder { objc::rc::autoreleasepool(|| { let descriptor = metal::ComputePassDescriptor::new(); - if let Some(timestamp_writes) = desc.timestamp_writes.as_ref() { + let mut sba_index = 0; + let mut next_sba_descriptor = || { let sba_descriptor = descriptor .sample_buffer_attachments() - .object_at(0 as _) + .object_at(sba_index) .unwrap(); + sba_index += 1; + sba_descriptor + }; + + for (set, index) in self.state.pending_timer_queries.drain(..) { + let sba_descriptor = next_sba_descriptor(); + sba_descriptor.set_sample_buffer(set.counter_sample_buffer.as_ref().unwrap()); + sba_descriptor.set_start_of_encoder_sample_index(index as _); + sba_descriptor.set_end_of_encoder_sample_index(metal::COUNTER_DONT_SAMPLE); + } + + if let Some(timestamp_writes) = desc.timestamp_writes.as_ref() { + let sba_descriptor = next_sba_descriptor(); sba_descriptor.set_sample_buffer( timestamp_writes .query_set @@ -982,12 +1133,16 @@ impl crate::CommandEncoder for super::CommandEncoder { .unwrap(), ); - if let Some(start_index) = timestamp_writes.beginning_of_pass_write_index { - sba_descriptor.set_start_of_encoder_sample_index(start_index as _); - } - if let Some(end_index) = timestamp_writes.end_of_pass_write_index { - sba_descriptor.set_end_of_encoder_sample_index(end_index as _); - } + sba_descriptor.set_start_of_encoder_sample_index( + timestamp_writes + .beginning_of_pass_write_index + .map_or(metal::COUNTER_DONT_SAMPLE, |i| i as _), + ); + sba_descriptor.set_end_of_encoder_sample_index( + timestamp_writes + .end_of_pass_write_index + .map_or(metal::COUNTER_DONT_SAMPLE, |i| i as _), + ); } let encoder = raw.compute_command_encoder_with_descriptor(descriptor); diff --git a/third_party/rust/wgpu-hal/src/metal/conv.rs b/third_party/rust/wgpu-hal/src/metal/conv.rs index a1ceb287abac..8f6439b50bad 100644 --- a/third_party/rust/wgpu-hal/src/metal/conv.rs +++ b/third_party/rust/wgpu-hal/src/metal/conv.rs @@ -152,13 +152,11 @@ pub fn map_blend_factor(factor: wgt::BlendFactor) -> metal::MTLBlendFactor { Bf::OneMinusDstAlpha => OneMinusDestinationAlpha, Bf::Constant => BlendColor, Bf::OneMinusConstant => OneMinusBlendColor, - //Bf::ConstantAlpha => BlendAlpha, - //Bf::OneMinusConstantAlpha => OneMinusBlendAlpha, Bf::SrcAlphaSaturated => SourceAlphaSaturated, - //Bf::Src1 => Source1Color, - //Bf::OneMinusSrc1 => OneMinusSource1Color, - //Bf::Src1Alpha => Source1Alpha, - //Bf::OneMinusSrc1Alpha => OneMinusSource1Alpha, + Bf::Src1 => Source1Color, + Bf::OneMinusSrc1 => OneMinusSource1Color, + Bf::Src1Alpha => Source1Alpha, + Bf::OneMinusSrc1Alpha => OneMinusSource1Alpha, } } diff --git a/third_party/rust/wgpu-hal/src/metal/mod.rs b/third_party/rust/wgpu-hal/src/metal/mod.rs index 76f57002ff3e..c6b91a4f3c2b 100644 --- a/third_party/rust/wgpu-hal/src/metal/mod.rs +++ b/third_party/rust/wgpu-hal/src/metal/mod.rs @@ -33,6 +33,7 @@ use std::{ }; use arrayvec::ArrayVec; +use bitflags::bitflags; use metal::foreign_types::ForeignTypeRef as _; use parking_lot::Mutex; @@ -143,6 +144,24 @@ impl crate::Instance for Instance { } } +bitflags!( + /// Similar to `MTLCounterSamplingPoint`, but a bit higher abstracted for our purposes. + #[derive(Debug, Copy, Clone)] + pub struct TimestampQuerySupport: u32 { + /// On creating Metal encoders. + const STAGE_BOUNDARIES = 1 << 1; + /// Within existing draw encoders. + const ON_RENDER_ENCODER = Self::STAGE_BOUNDARIES.bits() | (1 << 2); + /// Within existing dispatch encoders. + const ON_COMPUTE_ENCODER = Self::STAGE_BOUNDARIES.bits() | (1 << 3); + /// Within existing blit encoders. + const ON_BLIT_ENCODER = Self::STAGE_BOUNDARIES.bits() | (1 << 4); + + /// Within any wgpu render/compute pass. + const INSIDE_WGPU_PASSES = Self::ON_RENDER_ENCODER.bits() | Self::ON_COMPUTE_ENCODER.bits(); + } +); + #[allow(dead_code)] #[derive(Clone, Debug)] struct PrivateCapabilities { @@ -239,8 +258,7 @@ struct PrivateCapabilities { supports_preserve_invariance: bool, supports_shader_primitive_index: bool, has_unified_memory: Option, - support_timestamp_query: bool, - support_timestamp_query_in_passes: bool, + timestamp_query_support: TimestampQuerySupport, } #[derive(Clone, Debug)] @@ -704,7 +722,7 @@ pub struct ComputePipeline { unsafe impl Send for ComputePipeline {} unsafe impl Sync for ComputePipeline {} -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct QuerySet { raw_buffer: metal::Buffer, //Metal has a custom buffer for counters. @@ -787,6 +805,9 @@ struct CommandState { work_group_memory_sizes: Vec, push_constants: Vec, + + /// Timer query that should be executed when the next pass starts. + pending_timer_queries: Vec<(QuerySet, u32)>, } pub struct CommandEncoder { diff --git a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs index 4a7ccf9535c0..b5156287262e 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/adapter.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/adapter.rs @@ -177,6 +177,7 @@ impl PhysicalDeviceFeatures { //.shader_resource_residency(requested_features.contains(wgt::Features::SHADER_RESOURCE_RESIDENCY)) .geometry_shader(requested_features.contains(wgt::Features::SHADER_PRIMITIVE_INDEX)) .depth_clamp(requested_features.contains(wgt::Features::DEPTH_CLIP_CONTROL)) + .dual_src_blend(requested_features.contains(wgt::Features::DUAL_SOURCE_BLENDING)) .build(), descriptor_indexing: if requested_features.intersects(indexing_features()) { Some( @@ -460,6 +461,7 @@ impl PhysicalDeviceFeatures { } features.set(F::DEPTH_CLIP_CONTROL, self.core.depth_clamp != 0); + features.set(F::DUAL_SOURCE_BLENDING, self.core.dual_src_blend != 0); if let Some(ref multiview) = self.multiview { features.set(F::MULTIVIEW, multiview.multiview != 0); @@ -520,6 +522,7 @@ impl PhysicalDeviceFeatures { | vk::FormatFeatureFlags::COLOR_ATTACHMENT_BLEND, ); features.set(F::RG11B10UFLOAT_RENDERABLE, rg11b10ufloat_renderable); + features.set(F::SHADER_UNUSED_VERTEX_OUTPUT, true); (features, dl_flags) } @@ -984,6 +987,10 @@ impl super::Instance { super::Workarounds::EMPTY_RESOLVE_ATTACHMENT_LISTS, phd_capabilities.properties.vendor_id == db::qualcomm::VENDOR, ); + workarounds.set( + super::Workarounds::FORCE_FILL_BUFFER_WITH_SIZE_GREATER_4096_ALIGNED_OFFSET_16, + phd_capabilities.properties.vendor_id == db::nvidia::VENDOR, + ); }; if phd_capabilities.effective_api_version == vk::API_VERSION_1_0 diff --git a/third_party/rust/wgpu-hal/src/vulkan/command.rs b/third_party/rust/wgpu-hal/src/vulkan/command.rs index c2e7afe3f1ef..391b754d335f 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/command.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/command.rs @@ -212,15 +212,44 @@ impl crate::CommandEncoder for super::CommandEncoder { } unsafe fn clear_buffer(&mut self, buffer: &super::Buffer, range: crate::MemoryRange) { - unsafe { - self.device.raw.cmd_fill_buffer( - self.active, - buffer.raw, - range.start, - range.end - range.start, - 0, - ) - }; + let range_size = range.end - range.start; + if self.device.workarounds.contains( + super::Workarounds::FORCE_FILL_BUFFER_WITH_SIZE_GREATER_4096_ALIGNED_OFFSET_16, + ) && range_size >= 4096 + && range.start % 16 != 0 + { + let rounded_start = wgt::math::align_to(range.start, 16); + let prefix_size = rounded_start - range.start; + + unsafe { + self.device.raw.cmd_fill_buffer( + self.active, + buffer.raw, + range.start, + prefix_size, + 0, + ) + }; + + // This will never be zero, as rounding can only add up to 12 bytes, and the total size is 4096. + let suffix_size = range.end - rounded_start; + + unsafe { + self.device.raw.cmd_fill_buffer( + self.active, + buffer.raw, + rounded_start, + suffix_size, + 0, + ) + }; + } else { + unsafe { + self.device + .raw + .cmd_fill_buffer(self.active, buffer.raw, range.start, range_size, 0) + }; + } } unsafe fn copy_buffer_to_buffer( diff --git a/third_party/rust/wgpu-hal/src/vulkan/conv.rs b/third_party/rust/wgpu-hal/src/vulkan/conv.rs index e2398c2689ad..459b7f858fb3 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/conv.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/conv.rs @@ -792,6 +792,10 @@ fn map_blend_factor(factor: wgt::BlendFactor) -> vk::BlendFactor { Bf::SrcAlphaSaturated => vk::BlendFactor::SRC_ALPHA_SATURATE, Bf::Constant => vk::BlendFactor::CONSTANT_COLOR, Bf::OneMinusConstant => vk::BlendFactor::ONE_MINUS_CONSTANT_COLOR, + Bf::Src1 => vk::BlendFactor::SRC1_COLOR, + Bf::OneMinusSrc1 => vk::BlendFactor::ONE_MINUS_SRC1_COLOR, + Bf::Src1Alpha => vk::BlendFactor::SRC1_ALPHA, + Bf::OneMinusSrc1Alpha => vk::BlendFactor::ONE_MINUS_SRC1_ALPHA, } } diff --git a/third_party/rust/wgpu-hal/src/vulkan/mod.rs b/third_party/rust/wgpu-hal/src/vulkan/mod.rs index c2165e1dd832..fe2ee914cda6 100644 --- a/third_party/rust/wgpu-hal/src/vulkan/mod.rs +++ b/third_party/rust/wgpu-hal/src/vulkan/mod.rs @@ -207,6 +207,28 @@ bitflags::bitflags!( /// Qualcomm OOMs when there are zero color attachments but a non-null pointer /// to a subpass resolve attachment array. This nulls out that pointer in that case. const EMPTY_RESOLVE_ATTACHMENT_LISTS = 0x2; + /// If the following code returns false, then nvidia will end up filling the wrong range. + /// + /// ```skip + /// fn nvidia_succeeds() -> bool { + /// # let (copy_length, start_offset) = (0, 0); + /// if copy_length >= 4096 { + /// if start_offset % 16 != 0 { + /// if copy_length == 4096 { + /// return true; + /// } + /// if copy_length % 16 == 0 { + /// return false; + /// } + /// } + /// } + /// true + /// } + /// ``` + /// + /// As such, we need to make sure all calls to vkCmdFillBuffer are aligned to 16 bytes + /// if they cover a range of 4096 bytes or more. + const FORCE_FILL_BUFFER_WITH_SIZE_GREATER_4096_ALIGNED_OFFSET_16 = 0x4; } ); diff --git a/third_party/rust/wgpu-types/.cargo-checksum.json b/third_party/rust/wgpu-types/.cargo-checksum.json index b96d798df907..b5ca7fcd40ba 100644 --- a/third_party/rust/wgpu-types/.cargo-checksum.json +++ b/third_party/rust/wgpu-types/.cargo-checksum.json @@ -1 +1 @@ -{"files":{"Cargo.toml":"9f4a8846579ca480d493e80ad1488dcd18feb08c79aa833e2733808f0473d79b","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"d65636e17a80dd44eb06b7bee735020869a7165b63505f11b126ab1eb76a5107","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null} \ No newline at end of file +{"files":{"Cargo.toml":"468c2c0c8fc2f2105248e445cb029a11338f8bde5e0444db5a362ad08c0b68aa","LICENSE.APACHE":"a6cba85bc92e0cff7a450b1d873c0eaa2e9fc96bf472df0247a26bec77bf3ff9","LICENSE.MIT":"c7fea58d1cfe49634cd92e54fc10a9d871f4b275321a4cd8c09e449122caaeb4","src/assertions.rs":"3fe98027aa73970c8ab7874a3e13dbfd6faa87df2081beb5c83aeec4c60f372f","src/lib.rs":"b4a6796691445880ffd9473769db832197f7fc626ccd2c5602a11abddfc7e6d0","src/math.rs":"4d03039736dd6926feb139bc68734cb59df34ede310427bbf059e5c925e0af3b"},"package":null} \ No newline at end of file diff --git a/third_party/rust/wgpu-types/Cargo.toml b/third_party/rust/wgpu-types/Cargo.toml index 1680b5ae8b21..1d27a81555ba 100644 --- a/third_party/rust/wgpu-types/Cargo.toml +++ b/third_party/rust/wgpu-types/Cargo.toml @@ -44,7 +44,7 @@ features = ["serde_derive"] optional = true [dev-dependencies] -serde_json = "1.0.106" +serde_json = "1.0.107" [dev-dependencies.serde] version = "1" diff --git a/third_party/rust/wgpu-types/src/lib.rs b/third_party/rust/wgpu-types/src/lib.rs index c892874afacd..a680d9129654 100644 --- a/third_party/rust/wgpu-types/src/lib.rs +++ b/third_party/rust/wgpu-types/src/lib.rs @@ -270,7 +270,7 @@ bitflags::bitflags! { /// Supported Platforms: /// - Vulkan /// - DX12 - /// - Metal - TODO: Not yet supported on command encoder. + /// - Metal /// /// This is a web and native feature. const TIMESTAMP_QUERY = 1 << 1; @@ -371,7 +371,7 @@ bitflags::bitflags! { /// Compressed textures sacrifice some quality in exchange for significantly reduced /// bandwidth usage. /// - /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ASTC formats. + /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ASTC formats with Unorm/UnormSrgb channel type. /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. /// /// Supported Platforms: @@ -409,7 +409,7 @@ bitflags::bitflags! { /// Compressed textures sacrifice some quality in exchange for significantly reduced /// bandwidth usage. /// - /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for BCn formats. + /// Support for this feature guarantees availability of [`TextureUsages::COPY_SRC | TextureUsages::COPY_DST | TextureUsages::TEXTURE_BINDING`] for ASTC formats with the HDR channel type. /// [`Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES`] may enable additional usages. /// /// Supported Platforms: @@ -458,10 +458,9 @@ bitflags::bitflags! { /// Supported platforms: /// - Vulkan /// - DX12 + /// - Metal (AMD & Intel, not Apple GPUs) /// - /// This is currently unimplemented on Metal. - /// When implemented, it will be supported on Metal on AMD and Intel GPUs, but not Apple GPUs. - /// (This is a common limitation of tile-based rasterization GPUs) + /// This is generally not available on tile-based rasterization GPUs. /// /// This is a native only feature with a [proposal](https://github.com/gpuweb/gpuweb/blob/0008bd30da2366af88180b511a5d0d0c1dffbc36/proposals/timestamp-query-inside-passes.md) for the web. const TIMESTAMP_QUERY_INSIDE_PASSES = 1 << 33; @@ -738,6 +737,15 @@ bitflags::bitflags! { /// This is a native only feature. const VERTEX_ATTRIBUTE_64BIT = 1 << 53; + /// Allows vertex shaders to have outputs which are not consumed + /// by the fragment shader. + /// + /// Supported platforms: + /// - Vulkan + /// - Metal + /// - OpenGL + const SHADER_UNUSED_VERTEX_OUTPUT = 1 << 54; + // 54..59 available // Shader: @@ -782,7 +790,17 @@ bitflags::bitflags! { /// This is a native only feature. const SHADER_EARLY_DEPTH_TEST = 1 << 62; - // 62..64 available + /// Allows two outputs from a shader to be used for blending. + /// Note that dual-source blending doesn't support multiple render targets. + /// + /// For more info see the OpenGL ES extension GL_EXT_blend_func_extended. + /// + /// Supported platforms: + /// - OpenGL ES (with GL_EXT_blend_func_extended) + /// - Metal (with MSL 1.2+) + /// - Vulkan (with dualSrcBlend) + /// - DX12 + const DUAL_SOURCE_BLENDING = 1 << 63; } } @@ -1550,6 +1568,8 @@ impl TextureViewDimension { /// /// Corresponds to [WebGPU `GPUBlendFactor`]( /// https://gpuweb.github.io/gpuweb/#enumdef-gpublendfactor). +/// Values using S1 requires [`Features::DUAL_SOURCE_BLENDING`] and can only be +/// used with the first render target. #[repr(C)] #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] #[cfg_attr(feature = "trace", derive(Serialize))] @@ -1582,6 +1602,29 @@ pub enum BlendFactor { Constant = 11, /// 1.0 - Constant OneMinusConstant = 12, + /// S1.component + Src1 = 13, + /// 1.0 - S1.component + OneMinusSrc1 = 14, + /// S1.alpha + Src1Alpha = 15, + /// 1.0 - S1.alpha + OneMinusSrc1Alpha = 16, +} + +impl BlendFactor { + /// Returns `true` if the blend factor references the second blend source. + /// + /// Note that the usage of those blend factors require [`Features::DUAL_SOURCE_BLENDING`]. + pub fn ref_second_blend_source(&self) -> bool { + match self { + BlendFactor::Src1 + | BlendFactor::OneMinusSrc1 + | BlendFactor::Src1Alpha + | BlendFactor::OneMinusSrc1Alpha => true, + _ => false, + } + } } /// Alpha blend operation. @@ -6430,6 +6473,7 @@ pub enum Gles3MinorVersion { } /// Options for creating an instance. +#[derive(Debug)] pub struct InstanceDescriptor { /// Which `Backends` to enable. pub backends: Backends,