Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do texture init via clear passes when possible #2307

Merged
merged 27 commits into from
Dec 28, 2021

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Dec 19, 2021

Connections
Should fix #2149 - haven't confirmed since I don't a repro at hand.
Changes clear extension semantics a bit as discussed on #2174

Description
Previously, render target/depth textures couldn't be initialized at all if they not also were COPY_DST, violating the spec.
Now, we always will use render passes when possible since it's expected to be faster.

All this comes with an overhaul of the texture clearing mechanisms as we tried to optimize things based on the assumption of texture-init == copy zero_buffer:

  • Textures now know their TextureClearMode which may bring with it pre-created render views for clearing
  • I consolidated all texture clears to go through more similar code paths. In some cases this trades performance against maintainability of the code, but imho it looks like a better starting point for optimizations now

Other smaller but important things in this PR:

Testing
Tests in tests/clear_texture.rs clear now depth/stencil formats as well (this was not possible previously)
Ran cargo test locally (win10)

wgpu/src/lib.rs Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
@Wumpf
Copy link
Member Author

Wumpf commented Dec 19, 2021

there's apparently some DX12 test failures during tests that I need to look into

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skimmed to the first half, a lot more to go!

wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Show resolved Hide resolved
wgpu-core/src/command/mod.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/render.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/transfer.rs Outdated Show resolved Hide resolved
wgpu-core/src/device/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

almost there!

wgpu-core/src/command/clear.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/memory_init.rs Outdated Show resolved Hide resolved
wgpu-core/src/command/transfer.rs Outdated Show resolved Hide resolved
wgpu-core/src/device/mod.rs Outdated Show resolved Hide resolved
wgpu-core/src/device/mod.rs Outdated Show resolved Hide resolved
wgpu-core/src/device/mod.rs Outdated Show resolved Hide resolved
wgpu-core/src/device/queue.rs Outdated Show resolved Hide resolved
this has mostly implications on the constraints, but also allows a more leaky documentation which makes sense for this non-standard function as there is no other place to look it up
pending inits need to store Stored textures now though, causing more ref count bumping
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please take care of CI failures

@niklaskorz
Copy link
Contributor

niklaskorz commented Dec 27, 2021

Running this on https://github.com/niklaskorz/linon/tree/wgpu-0.12 gives me the following error instead of the current "Texture needs to have the COPY_DST flag" (#2309):

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NoValidTextureClearMode((5, 1, Metal))', /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu-core/src/command/memory_init.rs:284:18
  • OS: macOS 12.1
  • Device: 2020 Intel i7 MacBook Pro 13"
  • Backend: Metal
full stack trace
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: NoValidTextureClearMode((5, 1, Metal))', /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu-core/src/command/memory_init.rs:284:18
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:101:14
   2: core::result::unwrap_failed
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1617:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/result.rs:1299:23
   4: wgpu_core::command::memory_init::<impl wgpu_core::command::BakedCommands<A>>::initialize_texture_memory
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu-core/src/command/memory_init.rs:276:17
   5: wgpu_core::device::queue::<impl wgpu_core::hub::Global<G>>::queue_submit
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu-core/src/device/queue.rs:785:25
   6: <wgpu::backend::direct::Context as wgpu::Context>::queue_submit
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/backend/direct.rs:2162:15
   7: wgpu::Queue::submit
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/lib.rs:3206:9
   8: linon::application::Application::render
             at ./src/application.rs:573:9
   9: linon::run::{{closure}}::{{closure}}
             at ./src/main.rs:111:33
  10: <winit::platform_impl::platform::app_state::EventLoopHandler<T> as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/app_state.rs:101:13
  11: winit::platform_impl::platform::app_state::EventLoopHandler<T>::with_callback
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/app_state.rs:79:13
  12: <winit::platform_impl::platform::app_state::EventLoopHandler<T> as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/app_state.rs:100:9
  13: winit::platform_impl::platform::app_state::Handler::handle_nonuser_event
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/app_state.rs:206:21
  14: winit::platform_impl::platform::app_state::AppState::cleared
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/app_state.rs:389:13
  15: winit::platform_impl::platform::observer::control_flow_end_handler::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/observer.rs:180:21
  16: winit::platform_impl::platform::observer::control_flow_handler::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/observer.rs:142:57
  17: std::panicking::try::do_call
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:403:40
  18: <unknown>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/thread/local.rs:312:14
  19: std::panicking::try
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:367:19
  20: std::panic::catch_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panic.rs:129:14
  21: winit::platform_impl::platform::event_loop::stop_app_on_panic
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:229:11
  22: winit::platform_impl::platform::observer::control_flow_handler
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/observer.rs:142:5
  23: winit::platform_impl::platform::observer::control_flow_end_handler
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/observer.rs:175:9
  24: <unknown>
  25: <unknown>
  26: <unknown>
  27: <unknown>
  28: <unknown>
  29: <unknown>
  30: <unknown>
  31: <unknown>
  32: <unknown>
  33: <unknown>
  34: <() as objc::message::MessageArguments>::invoke
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:128:17
  35: objc::message::platform::send_unverified
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/objc-0.2.7/src/message/apple/mod.rs:27:9
  36: objc::message::send_message
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/objc-0.2.7/src/message/mod.rs:178:5
  37: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:188:22
  38: objc::rc::autorelease::autoreleasepool
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/objc-0.2.7/src/rc/autorelease.rs:29:5
  39: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:178:9
  40: winit::platform_impl::platform::event_loop::EventLoop<T>::run
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:157:9
  41: winit::event_loop::EventLoop<T>::run
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/event_loop.rs:154:9
  42: linon::run::{{closure}}
             at ./src/main.rs:57:5
  43: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/future/mod.rs:80:19
  44: futures_executor::local_pool::block_on::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:315:23
  45: futures_executor::local_pool::run_executor::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:90:37
  46: std::thread::local::LocalKey<T>::try_with
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/thread/local.rs:399:16
  47: std::thread::local::LocalKey<T>::with
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/thread/local.rs:375:9
  48: futures_executor::local_pool::run_executor
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:86:5
  49: futures_executor::local_pool::block_on
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:315:5
  50: linon::main
             at ./src/main.rs:193:5
  51: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[2021-12-27T12:26:55Z ERROR wgpu_hal::metal::device] No active command buffers for fence value 2
thread 'main' panicked at 'Error in Device::drop: parent device is lost', /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/backend/direct.rs:214:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:517:5
   1: std::panicking::begin_panic_fmt
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/panicking.rs:460:5
   2: wgpu::backend::direct::Context::handle_error_fatal
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/backend/direct.rs:214:9
   3: <wgpu::backend::direct::Context as wgpu::Context>::device_drop
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/backend/direct.rs:1536:29
   4: <wgpu::Device as core::ops::drop::Drop>::drop
             at /Users/niklaskorz/.cargo/git/checkouts/wgpu-de6245268e4c8054/dc24f94/wgpu/src/lib.rs:1926:13
   5: core::ptr::drop_in_place<wgpu::Device>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
   6: core::ptr::drop_in_place<linon::application::Application>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
   7: core::ptr::drop_in_place<linon::run::{{closure}}::{{closure}}>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
   8: core::ptr::drop_in_place<core::cell::UnsafeCell<dyn core::ops::function::FnMut<(winit::event::Event<()>,&winit::event_loop::EventLoopWindowTarget<()>,&mut winit::event_loop::ControlFlow)>+Output = ()>>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
   9: core::ptr::drop_in_place<core::cell::RefCell<dyn core::ops::function::FnMut<(winit::event::Event<()>,&winit::event_loop::EventLoopWindowTarget<()>,&mut winit::event_loop::ControlFlow)>+Output = ()>>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
  10: <alloc::rc::Rc<T> as core::ops::drop::Drop>::drop
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/alloc/src/rc.rs:1450:17
  11: core::ptr::drop_in_place<alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut<(winit::event::Event<()>,&winit::event_loop::EventLoopWindowTarget<()>,&mut winit::event_loop::ControlFlow)>+Output = ()>>>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
  12: core::ptr::drop_in_place<core::option::Option<alloc::rc::Rc<core::cell::RefCell<dyn core::ops::function::FnMut<(winit::event::Event<()>,&winit::event_loop::EventLoopWindowTarget<()>,&mut winit::event_loop::ControlFlow)>+Output = ()>>>>
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ptr/mod.rs:188:1
  13: core::mem::drop
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/mem/mod.rs:898:24
  14: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:191:17
  15: objc::rc::autorelease::autoreleasepool
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/objc-0.2.7/src/rc/autorelease.rs:29:5
  16: winit::platform_impl::platform::event_loop::EventLoop<T>::run_return
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:178:9
  17: winit::platform_impl::platform::event_loop::EventLoop<T>::run
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/platform_impl/macos/event_loop.rs:157:9
  18: winit::event_loop::EventLoop<T>::run
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/winit-0.26.0/src/event_loop.rs:154:9
  19: linon::run::{{closure}}
             at ./src/main.rs:57:5
  20: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/future/mod.rs:80:19
  21: futures_executor::local_pool::block_on::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:315:23
  22: futures_executor::local_pool::run_executor::{{closure}}
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:90:37
  23: std::thread::local::LocalKey<T>::try_with
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/thread/local.rs:399:16
  24: std::thread::local::LocalKey<T>::with
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/std/src/thread/local.rs:375:9
  25: futures_executor::local_pool::run_executor
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:86:5
  26: futures_executor::local_pool::block_on
             at /Users/niklaskorz/.cargo/registry/src/git.luolix.top-1ecc6299db9ec823/futures-executor-0.3.17/src/local_pool.rs:315:5
  27: linon::main
             at ./src/main.rs:193:5
  28: core::ops::function::FnOnce::call_once
             at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[2021-12-27T12:26:55Z ERROR wgpu_hal::metal::device] No active command buffers for fence value 2
[2021-12-27T12:26:55Z ERROR wgpu_core::device] failed to wait for the device: Lost

@kvark
Copy link
Member

kvark commented Dec 28, 2021

@niklaskorz looks like this will be addressed by the very PR we are commenting on

@niklaskorz
Copy link
Contributor

@niklaskorz looks like this will be addressed by the very PR we are commenting on

That's what I was hoping :) The error I posted occurs when using this PR as wgpu crate, which is why I thought it relevant for the discussion here.

@Wumpf
Copy link
Member Author

Wumpf commented Dec 28, 2021

@niklaskorz reproed it and looking for a solution, I think I know what to do but looking for a nice way to add a test for this in wgpu. Meanwhile, you can fix/workaround this in your application by passing a clear color to egui in your application:

diff --git a/src/application.rs b/src/application.rs
index 9c3e96f..e380a94 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -567,7 +567,13 @@ impl Application {
             .update_buffers(&self.device, &self.queue, &paint_jobs, &screen_descriptor);

         self.rpass
-            .execute(&mut encoder, &view, &paint_jobs, &screen_descriptor, None)
+            .execute(
+                &mut encoder,
+                &view,
+                &paint_jobs,
+                &screen_descriptor,
+                Some(wgpu::Color::WHITE),
+            )
             .unwrap();

         self.queue.submit(Some(encoder.finish()));

@kvark please hold on with merging until I have this done as well. Meanwhile, you may want to complain about
087145b which is needed to get Metal tests green pretty much like you anticipated in an earlier comment ;)

@Wumpf
Copy link
Member Author

Wumpf commented Dec 28, 2021

all done in f80a13d . Not pretty: For testing I needed to hijack an existing example so I didn't need to go through all the window creation stuff. Destruction of the new clear target every surface has is in two places and I'm actually not sure why this is ok to do it there (expecting it to be still in use, but neither DX12/Vulkan complain about this even under resize which causes discarded surfaces)

@Wumpf Wumpf requested a review from kvark December 28, 2021 17:21
Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, LGTM, such grand piece!

@kvark kvark merged commit 2fa75aa into gfx-rs:master Dec 28, 2021
@kvark kvark added the PR: needs back-porting PR with a fix that needs to land on crates label Dec 28, 2021
@Wumpf Wumpf deleted the texture-init-via-pass-clears branch December 28, 2021 23:26
@Wumpf Wumpf restored the texture-init-via-pass-clears branch December 28, 2021 23:26
@Wumpf Wumpf deleted the texture-init-via-pass-clears branch December 28, 2021 23:26
@Wumpf Wumpf restored the texture-init-via-pass-clears branch December 28, 2021 23:26
Wumpf added a commit to Wumpf/wgpu that referenced this pull request Dec 29, 2021
* CLEAR_COMMANDS extension is now more of a window into wgpu zero-init
this has mostly implications on the constraints, but also allows a more leaky documentation which makes sense for this non-standard function as there is no other place to look it up

* clear_texture via renderpasses wip

* 3D depth textures are no longer allowed, volumes are always cleared via CPY_DST

* cleanup texture's clear_views

* rename CLEAR_COMMANDS to CLEAR_TEXTURE

* separate clear_texture into reusable & more descriptive parts

* texture clear views are now created ahead of time

* discarded surface fixup goes through new clear_texture method now

* onq ueue texture initialization now goes threw clear_texture
pending inits need to store Stored textures now though, causing more ref count bumping

* texture init on queue_write_texture now also goes through new clear_texture

* transfer functions on commandbuffer use now new texture init route

* merge collect_zero_buffer_copies_for_clear_texture into clear_texture_via_buffer_copies

* clear functions now take TextureInitRange

* Fix clippy lints

* command_encoder_clear_texture no longer takes write lock on texture

* TextureClearMode encodes now is_color

* code cleanup, mostly about `use`

* Handle volume textures in clear_texture_via_render_passes properly

* texture clear no longer requires id::Stored

* init tracking fixes for volumes and init on partial subresource writes

* texture creation enforces COPY_DST only if absolutely necessary

* unrolled functional chain, reduce unsafe scope size

* fix clippy lints

* clear_texture test no longer creates 1D textures

see gfx-rs#2323

* 3D textures are no longer cleared as render target since this isn't supported on Metal

* fix deno building issue, fix formatting

* TextureInner::Surface can now be zero initialized
kvark pushed a commit that referenced this pull request Dec 29, 2021
* CLEAR_COMMANDS extension is now more of a window into wgpu zero-init
this has mostly implications on the constraints, but also allows a more leaky documentation which makes sense for this non-standard function as there is no other place to look it up

* clear_texture via renderpasses wip

* 3D depth textures are no longer allowed, volumes are always cleared via CPY_DST

* cleanup texture's clear_views

* rename CLEAR_COMMANDS to CLEAR_TEXTURE

* separate clear_texture into reusable & more descriptive parts

* texture clear views are now created ahead of time

* discarded surface fixup goes through new clear_texture method now

* onq ueue texture initialization now goes threw clear_texture
pending inits need to store Stored textures now though, causing more ref count bumping

* texture init on queue_write_texture now also goes through new clear_texture

* transfer functions on commandbuffer use now new texture init route

* merge collect_zero_buffer_copies_for_clear_texture into clear_texture_via_buffer_copies

* clear functions now take TextureInitRange

* Fix clippy lints

* command_encoder_clear_texture no longer takes write lock on texture

* TextureClearMode encodes now is_color

* code cleanup, mostly about `use`

* Handle volume textures in clear_texture_via_render_passes properly

* texture clear no longer requires id::Stored

* init tracking fixes for volumes and init on partial subresource writes

* texture creation enforces COPY_DST only if absolutely necessary

* unrolled functional chain, reduce unsafe scope size

* fix clippy lints

* clear_texture test no longer creates 1D textures

see #2323

* 3D textures are no longer cleared as render target since this isn't supported on Metal

* fix deno building issue, fix formatting

* TextureInner::Surface can now be zero initialized
@kvark
Copy link
Member

kvark commented Dec 29, 2021

#2327 is published in wgpu-core-0.12.1

@kvark kvark removed the PR: needs back-porting PR with a fix that needs to land on crates label Dec 29, 2021
bors bot pushed a commit to bevyengine/bevy that referenced this pull request Dec 29, 2021
# Objective

- `Msaa` was disabled in webgl due to a bug in wgpu
- Bug has been fixed (gfx-rs/wgpu#2307) and backported (gfx-rs/wgpu#2327), and updates for [`wgpu-core`](https://crates.io/crates/wgpu-core/0.12.1) and [`wgpu-hal`](https://crates.io/crates/wgpu-hal/0.12.1) have been released

## Solution

- Remove custom config for `Msaa` in webgl
- I also changed two options that were using the arch instead of the `webgl` feature. it shouldn't change much for webgl, but could help if someone wants to target wasm but not webgl2


Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
mockersf added a commit to mockersf/bevy that referenced this pull request Jan 1, 2022
# Objective

- `Msaa` was disabled in webgl due to a bug in wgpu
- Bug has been fixed (gfx-rs/wgpu#2307) and backported (gfx-rs/wgpu#2327), and updates for [`wgpu-core`](https://crates.io/crates/wgpu-core/0.12.1) and [`wgpu-hal`](https://crates.io/crates/wgpu-hal/0.12.1) have been released

## Solution

- Remove custom config for `Msaa` in webgl
- I also changed two options that were using the arch instead of the `webgl` feature. it shouldn't change much for webgl, but could help if someone wants to target wasm but not webgl2


Co-authored-by: François <8672791+mockersf@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebGL2: panicked at 'Tex storage 2D multisample is not supported'
3 participants