Commit Graph
353 Commits
Author SHA1 Message Date
Andreas ReichandConnor Fitzgerald b838b0871c Added new UNRESTRICTED_INDEX_BUFFER downlevel flag. (#3157)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-11-07 15:45:50 -05:00
Nicolas Silva db30e3909a Avoid integer overflow on multiplication in write_texture. (#3146) 2022-11-07 15:31:19 -05:00
Jim Blandy 215884184b Reformat comments in wgpu-core. (#3102) 2022-10-13 18:34:44 +00:00
Jim Blandy fa4d8401e8 Use std::fmt::Formatter::debug_struct for RenderPass. (#3100) 2022-10-13 14:00:54 -04:00
Mikko Lehtonen 60fd2a32e9 Implement missing PrettyError impls (#3066) 2022-10-05 18:43:52 -04:00
Mauro GentileandMauro Gentile cdf6ee0c87 Updating TextureFormat matching specs (#2954)
Co-authored-by: Mauro Gentile <Mauro.Gentile@ubisoft.com>
2022-09-20 12:08:06 -04:00
Jim Blandy 7d138e2e76 Avoid overflow in check texture copy bounds. (#2963) 2022-08-28 20:07:04 -04:00
Jim Blandy 2cd08a1c9c Placate Clippy 0.1.63. (#2977) 2022-08-24 17:25:59 -04:00
Nicolas Silva 96a85b3ac5 Add missing validation in copy_texture_to-Buffer. (#2958) 2022-08-13 19:48:17 -04:00
Sébastien Marleau 2ce1318c8c fix deduplication not taking into account render bundles (#2867) 2022-07-10 22:15:52 +00:00
Connor Fitzgerald 464b61d01c Flip span labels to work better with tools (#2820) 2022-06-28 19:49:51 +00:00
Jinlei Li 61796b1d59 Relax render pass color_attachments validation (#2778)
* Make the color attachments `Option`-al in render pipelines, render passes, and render bundles

* vk:  `Option`-al color attachments support

* dx12: sparse color_attachments support

* Only non-hole attachments is supported on wasm target and gl backend

* deno_webgpu: `Option`-al color attachments support

* Follow all suggestions
2022-06-27 16:10:18 -07:00
Connor Fitzgerald 533fc13afe Properly Barrier Compute Indirect Buffers (#2810) 2022-06-26 21:03:56 +00:00
Connor Fitzgerald de5fe90f20 Restrict WriteTimestamp Inside Passes (#2802)
* Define feature flags in terms of the previous

* Add WRITE_TIMESTAMP_INSIDE_PASSES feature
2022-06-25 01:23:13 -04:00
Jinlei Li f4c01052ef Rename MAX_COLOR_TARGETS to MAX_COLOR_ATTACHMENTS to match spec 2022-06-16 20:36:15 -07:00
Jim Blandy 6da57dd4e0 Add type annotation to render pass code, for rust-analyzer. (#2773)
This is a workaround for a limitation in rust-analyzer:
https://github.com/rust-lang/rust-analyzer/issues/12247
2022-06-14 23:06:22 -04:00
Jim Blandy 915be10443 wgpu_core::command::bundle: Consolidate pipeline and vertex state. (#2769)
Refactor `wgpu_core::command::bundle::State` to more closely resemble
the internal slots of a WebGPU `GPURenderBundleEncoder`, and add
validation required by the WebGPU specification.

Use `Option` to represent state that may be left unset on the encoder:
specifically, the pipeline and vertex buffers. (Previous commits have
already addressed index buffers and bind groups.) Use `.ok_or`, etc.
for unwrapping, to ensure that encoding state errors are reported.

Consolidate state derived from the pipeline in a new `PipelineState`
struct.

Remove `wgpu_core::command::bundle::PushConstantState::is_dirty`; just
represent push constant state as a vector of `PushConstantRange`
values. It's sufficient to simply zero the push constants whenever the
vector is non-empty.

Rename `bundle::State::flush_push_constants` to `zero_push_constants`a.
This is not a "flush pending state changes" function like all the
others; it just ensures that each pipeline's push constant state is
initialized.
2022-06-14 23:06:05 -04:00
Jim Blandy 3a193ec3d3 Introduce VertexStep: a stride and a step mode. (#2768)
This is used in various places around render pipelines, passes, and
bundles.

The public `wgpu_core::pipeline::VertexBufferLayout` could use
`VertexStep` as well, but I think it's best to let that continue to
resemble `GPUVertexBufferLayout`.
2022-06-14 00:42:03 -04:00
Jim Blandy a4352a1dac Improve push constant documentation, including internal docs. (#2764) 2022-06-11 15:11:06 -04:00
Jim Blandy b2cc6ff185 Move RenderBundleEncoder::finish's pipeline layout id into the state. (#2755) 2022-06-10 15:41:32 -04:00
Jim Blandy f94f25f355 Fix documentation links. 2022-06-09 17:42:03 -07:00
Jim Blandy 091e9b1788 Clean up render bundle index buffer tracking. (#2743)
* Remove unused field `bundle::IndexState::pipeline_format`.

* Clean up render bundle index buffer tracking.

Put all state associated with an established index buffer within an
`Option`, so that the Rust types accurately represent value liveness.

Generate `MissingIndexBuffer` errors as needed for `DrawIndexed` and
indexed `MultiDrawIndirect` commands.
2022-06-07 02:17:27 -04:00
Jim Blandy d26c04c715 Don't dirty the vertex buffer for stride/rate changes on bundles. (#2744)
`wgpu_core::command::bundle::State::set_pipeline` marks a vertex
buffer slot dirty if the pipeline's stride or step mode for that
vertex buffer slot differs from what had been previously established.
The effect of marking the slot dirty is to ensure that a new
`SetVertexBuffer` command is inserted before the next draw command
that uses that vertex buffer. However, this is unnecessary:
`wgpu_hal::CommandEncoder::set_vertex_buffer` does not need to be
called simply because the stride or rate has changed.
2022-06-07 02:10:08 -04:00
Jim Blandy 5bee63e605 Track depth and stencil writability separately. (#2693)
Put some plumbing in place to accomodate the latest definition of
`GPURenderBundleEncoderDescriptor` in the WebGPU spec, which now has
separate `depthReadOnly` and `stencilReadOnly` members.

Rename `RenderPassDepthStencilAttachment::is_read_only` to
`depth_stencil_read_only`, and don't skip validation steps due to
early returns.
2022-06-07 02:02:23 -04:00
Jinlei Li 9e3cd08e59 Improve InvalidViewport error message (#2723) 2022-06-03 01:54:09 -04:00
Jinlei Li 75db572bf7 Improve InvalidScissorRect error message (#2713) 2022-06-02 07:35:13 +00:00
Jinlei Li 8063edc648 Add DEPTH24UNORM_STENCIL8 feature (#2689) 2022-05-30 15:29:12 -04:00
Jim Blandy 0c0bbdb3ad Perform "valid to use with" checks when recording render bundles. (#2690)
* Update module docs for `wgpu_core::commands::bundle`.

* Perform "valid to use with" checks when recording render bundles.
2022-05-28 04:57:06 -04:00
Connor Fitzgerald 9114283707 Tracking Optimization and Rewrite (#2662)
* Texture state full is dead code

* temp

* temp2 - next is lifetime only

* temp3 - all trackers in place

* temp4 - continue muddling along

* temp5 - doodle doodle

* temp6 - continuous progress is continuous

* temp7 - pro-gress

* temp8 - Add refcounts to trackers

* temp9 - Soundness, generics, refcounts, and epochs

* temp10 - Compiling?!1?!1?!1

* temp11 - Add bind group state optimization

* temp12 - Safety and adding size setting

* temp13 - unsafe

* temp14 - Abstract all the state transitions

* temp15 - It verks! kinda...

* temp16 - it more verks!

* temp17 - debugging and unit tests

* temp18 - fixing unfixed things

* temp19 - hmmm

* temp20 - curious about line deltas

* temp21 - working texture trackers

* temp22 - write merge/update/barrier for buffers

* temp23 - cleanup and buffers

* temp24 - clippy cleanup

* temp25 - Add inline markers on buffer functions

* temp26 - Fix buffer trackers

* temp27 - fixed texture insert to handle both sides

* temp28 - document tracker and usages

* temp29 - document track/mod.rs

* temp30 - convert STORAGE_WRITE to STORAGE_READ_WRITE

* temp31 - Add some debug asserts to make sure we can't insert invalid states

* temp32 - clippy is opinionated sometimes

* temp33 - renaming and documentation

* temp34 - logging
2022-05-24 11:36:13 -04:00
Jim Blandy c7872ab8b5 Eliminate wgpu_core::commands::bundle::State::raw_dynamic_offsets.
This vector's contents always ended up identical to the
`RenderBundleEncoder`'s `BasePass`'s `dynamic_offsets` vector, so
we can just take values from there instead of copying them.
2022-05-22 08:38:47 -07:00
Jim Blandy 87d75d9c7b Document command::BasePass. 2022-05-22 08:38:47 -07:00
Jim Blandy afed25fa5c Clean up render bundle bind group tracking.
The `dynamic_offsets` and `is_dirty` flags only make sense when the
slot is occupied, so they should be inside the `Option`. This makes
`State::bind` into an `ArrayVec<Option<BindState>>`, and cleans up
various other bits.
2022-05-22 08:38:47 -07:00
Jim Blandy d3235484f9 Document some parts of wgpu_core's render bundle code. 2022-05-22 08:38:47 -07:00
Jinlei Li 26f96c7dfe Add DEPTH32FLOAT_STENCIL8 featue (#2664) 2022-05-17 02:11:05 -04:00
Jim Blandy b51fd851be Report invalid pipelines in render bundles as errors, not panics.
Fixes #2665.
2022-05-16 14:26:36 -07:00
Jim Blandy 202d81a64a Move set_index_buffer FFI functions back into wgpu. (#2661)
It's very odd to have almost all the render pass and compute pass ffi
functions in `wgpu` except for the `set_index_buffer` functions, which
live in Firefox. I'd like to remove these from Firefox and put them
back next to their companions.

These functions were originally removed from wgpu in #1077, because
wgpu-native has its own incompatible version of IndexFormat (see that
PR for details). However, with wgpu-native#85, that code was removed,
so having these functions in `wgpu` should be no longer be a problem
for wgpu-native.
2022-05-15 15:18:05 -04:00
Jim Blandy 284ed4654e Spell out the type of the result from map_pass_err.
Without these changes, rust-analyzer cannot determine the type of
`cmd_buf`.
2022-05-13 22:18:12 -07:00
Connor Fitzgerald bc850d2a0e Bind group deduplication (#2623) 2022-04-25 04:19:25 +00:00
Jinlei Li 5706263917 Rename dispatch -> dispatch_workgroups 2022-04-20 23:24:21 -07:00
Kevin Reid cb7ad30d58 Prefix every wgpu-generated label with (wgpu internal).
This is intended to help developers new to wgpu or to graphics debugging
quickly recognize in a debugging tool which items are wgpu-generated, as
opposed to either part of their program or part of the platform graphics
system.

I also removed existing marker-like text such as leading underscores and
angle brackets.
2022-04-15 22:39:08 -07:00
Connor Fitzgerald b61939650c Add DownlevelFlag to prevent copies between Depth32 Textures 2022-02-28 21:38:52 -08:00
Connor Fitzgerald 63dfd98d68 Improve some error messages (#2446)
* Fix render target mismatch error message

* Reword bind group layout mismatch error
2022-02-01 18:51:48 -05:00
Dzmitry Malyshau f3891fed33 hal/dx12: improve RowPitch computation (#2409) 2022-01-20 19:59:25 -05:00
Dzmitry Malyshau dbec075cdc Texture format MSAA capabilities 2022-01-11 09:32:25 -05:00
Wumpf 2fa75aaf05 Do texture init via clear passes when possible (#2307)
* 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
2021-12-28 17:05:53 -05:00
Dzmitry Malyshau 1e593a6bd3 Trace push/pop debug group on command encoder (#2294) 2021-12-15 17:48:48 +00:00
Dzmitry Malyshau cdf948b920 Fix and re-enable player tests 2021-12-03 17:11:26 -05:00
UpsettingBoy d8c3b9489f Added command_encoder_copy_texture_to_texture texture format validation
+ Corrected small typo
2021-12-03 12:49:17 -05:00
Dzmitry Malyshau 6372aad845 Rename fill_buffer back to clear_buffer 2021-12-02 12:33:59 -05:00
Samuel Hurel f622c83a19 Allows for depth texture copies 2021-11-29 12:56:07 -05:00