Commit Graph

1648 Commits

Author SHA1 Message Date
Dzmitry Malyshau
fdd50e10fd Update naga to gfx-11 2021-02-16 09:46:22 -05:00
bors[bot]
94ee3d6c33 Merge #1219
1219: Validate texture bindings r=cwfitzgerald a=kvark

**Connections**
It was mentioned/requested somewhere, but I can't find the place...

**Description**
Fairly straightforward - just check the view properties against the bind group layout.

**Testing**
Tested on wgpu-rs examples

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-16 02:42:23 +00:00
Dzmitry Malyshau
9bf47dd772 Validate texture bindings 2021-02-15 20:14:23 -05:00
bors[bot]
6442b947cb Merge #1210
1210: Reset the bindings on the push constant change r=wumpf a=kvark

**Connections**
Fixes #1207
(unconfirmed!)

**Description**
I was able to replay the trace in #1207 without validation errors, so I looked deeper into what might have gone wrong.
The code isolated in #1194 looks great. However, the calling code's handling of push constants might have changed a bit.
And I see that the trace uses push constants, so here is what happened, I think:
  - layout A was set, expecting bind group layouts X and Z
  - bind groups X and Y where bound
  - layout B was set, expecting bind group layout X and Y. We see that Y group can now be bound, so we do this. The old logic in this case wasn't considering the push constants in any way, it would only consider them if bind group layouts didn't change, erroneously.
  - layout B has different push constant ranges...

So it's a one-line fix now, which I'm hoping is correct.

**Testing**
Not tested
@Wumpf would you be able to check this?

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2021-02-12 21:10:26 +00:00
bors[bot]
835b374ebb Merge #1214
1214: fix rustdoc warnings r=kvark a=jakobhellermann

**Connections**
fixes #1213 

**Description**
Fixes rustdoc warnings (broken links, `<autourls>`)

**Testing**
`cargo doc` does not complain anymore.

Co-authored-by: Jakob Hellermann <jakob.hellermann@protonmail.com>
2021-02-12 15:04:46 +00:00
Jakob Hellermann
b89cb21ce3 fix rustdoc warnings 2021-02-12 13:56:51 +01:00
Dzmitry Malyshau
692e82d521 Reset the bindings on the push constant change 2021-02-11 14:47:35 -05:00
bors[bot]
c71091b2e6 Merge #1209
1209: Handle player window resizing gracefully r=kvark a=kvark

**Connections**
Deprecates #794 and #793

**Description**
We were often getting this kind of errors when replaying on Linux:
>VALIDATION [VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 (2094043421)] : Validation Error: [ VUID-VkSwapchainCreateInfoKHR-imageExtent-01274 ] Object 0: handle = 0x56194a357250, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0x7cd0911d | vkCreateSwapchainKHR() called with imageExtent = (1980,1080), which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR(): currentExtent = (800,600), minImageExtent = (800,600), maxImageExtent = (800,600). The Vulkan spec states: imageExtent must be between minImageExtent and maxImageExtent, inclusive, where minImageExtent and maxImageExtent are members of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-VkSwapchainCreateInfoKHR-imageExtent-01274)
object info: (type: DEVICE, hndl: 94666619187792)

It's annoying to work around!

**Testing**
Tested on replaying wgpu-rs stuff.

Co-authored-by: Dzmitry Malyshau <kvark@fastmail.com>
2021-02-11 19:19:58 +00:00
Dzmitry Malyshau
b3387492a2 Handle player window resizing gracefully 2021-02-11 14:16:56 -05:00
bors[bot]
05a531191d Merge #1206
1206: Convert `PrimitiveState::cull_mode` to `Option<Face>` r=kvark a=yzsolt

**Connections**
Closes #1192 

**Description**
`wgpu::CullMode` was an enum with a `None` variant, which would be more idiomatic as an `Option` in Rust.

**Testing**
- `wgpu-rs` builds with the appropriate changes
- `wgpu-native` needs https://github.com/gfx-rs/wgpu-native/pull/71 merged before it can be updated


Co-authored-by: Zsolt Bölöny <bolony.zsolt@gmail.com>
2021-02-10 20:39:12 +00:00
Zsolt Bölöny
47a45bcaad Convert PrimitiveState::cull_mode to Option<Face> 2021-02-10 11:59:38 +01:00
bors[bot]
b1b44ca78c Merge #1205
1205: Update naga to gfx-10, add push constants validation r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3632 with a bunch of Naga stuff

**Description**
Update!

**Testing**
Not much

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-09 15:08:45 +00:00
Dzmitry Malyshau
42d3f1f087 Update naga to gfx-10, add push constants validation 2021-02-09 10:06:55 -05:00
bors[bot]
dc18ac72e4 Merge #1190
1190: Fix crash on zero init of buffer with no more ref count r=kvark a=Wumpf

**Description**
Previously, if a buffer would no longer have any reference, the zero init step crashed when trying to unwrap its ref_count.

**Testing**
Tested successfully on 54a0f4ff13 where this problem would pop up

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-06 22:15:44 +00:00
bors[bot]
9841b9b5dd Merge #1191
1191: Buffer zero init test for binding (and use in a compute shader) r=kvark a=Wumpf

**Connections**
Buffer zero init #1159 
Buffer zero crash on unused buffer fix #1190

**Description**
Tried to create a player ron file repro case for #1190 but didn't work out quite well (test keeps buffers alive even when I tried to go through an indirection via buffer copies). But with a bit of cleanup the test still felt very useful since it gives more coverage to buffer zero init.

Generally zero init is hard to test since the way to get the result is to map it which is one particular case of requiring zero init. But there's a few ways like in this test here where we look at what modifications a compute shader did to a buffer - since the buffer was not explicitly initialized, the outcome would be different if the compute shader would have seen a buffer without zero init.

Given how few tests there are right now this ofc implicitly tests a bunch of other things ;)

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-06 22:07:22 +00:00
bors[bot]
0abcb247ca Merge #1201
1201: Don't check the index format for non-indexed calls r=kvark a=kvark

**Connections**
Fixes #1200

**Description**
Avoid the check that shouldn't be done.

**Testing**
Not tested, but should work.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-06 15:59:27 +00:00
Dzmitry Malyshau
d0dcb105f5 Don't check the index format for non-indexed calls 2021-02-06 10:58:46 -05:00
Andreas Reich
fd810f839e merged buffer-zero-init-for-binding and buffer-zero-init-for-mapping-and-writing tests 2021-02-06 12:09:38 +01:00
Andreas Reich
3486fde638 Fix crash on zero init of buffer with no more ref count
Previously, if a buffer would no longer have any reference, the zero init step crashed when trying to unwrap its ref_count.
2021-02-06 11:11:10 +01:00
bors[bot]
3ebe198911 Merge #1198
1198: Fix command allocator race condition with maintenance r=kvark a=kvark

**Connections**
Fixes #1196

**Description**
This was a recent change, where I thought it would be more pure to just prepare the pool but not create anything right away. It looked more elegant, but now we see it was flowed.

**Testing**
Not really tested the concurrent aspect of it, but it should work.
Perhaps, we can hook up Loom in the future for this task?

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-05 05:59:16 +00:00
Dzmitry Malyshau
e357e3083a Fix command allocator race condition with maintenance 2021-02-05 00:57:18 -05:00
bors[bot]
c513bb03a6 Merge #1194
1194: Isolate binding compatibility logic into a separate module r=cwfitzgerald a=kvark

**Connections**
Fixes #1188 

**Description**
The actual problem was the following: when a pipeline changed, we used to go through the binding entries and re-bind only those that *became* compatible. However, we were missing ones that were already compatible, but were not activated because they were behind some previously incompatible ones.

So it's not a very complex fix. However, working with the binding code had me concerned that it wasn't isolated enough. It got quite a few issues discovered in it over the time, which only proven the point that it was way too fragile. So I took this opportunity to bring us closer to the world I want wgpu to be in: the world of semi-independent testable components.

This PR makes the binding compatibility checker one of these components. It's fully isolated, has unit tests, fairly straightforward to reason about, and integrates nicely with the render pass logic (without too many generics!). It's more profitable in the long run, I think, to build this kind of architecture versus integration-testing the thing (even at `wgpu` playtest level).

There is less magic overall now: no binding iterator, no fancy chaining, no complex matching. The logic is straightforward, hopefully. And the 40 LOC saved is a good indication of it.

**Testing**
Tested on wgpu-rs examples.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-05 02:29:45 +00:00
Dzmitry Malyshau
262d0c6dfc Isolate binding compatibility logic into a separate module 2021-02-04 01:16:40 -05:00
Andreas Reich
52aee1a037 Better error output for player test 2021-02-03 23:44:50 +01:00
Andreas Reich
5e488d4fea Added player test with compute shader reading & writing an uninitialized buffer 2021-02-03 23:44:42 +01:00
bors[bot]
780637eec0 Merge #1187
1187: validate for strip_index_format being used with non-strip topology r=kvark a=Wumpf

**Description**
Hit lack of this validation when porting a project to newest wgpu-rs: Accidentally set the strip_index_format for a TriangleList pipeline which left me with a Vulkan validation error (since wgpu decides to set `restart_index` in presence of a `strip_index_format`)

```
VALIDATION [VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428 (-1077750125)] : Validation Error: [ VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428 ] Object 0: handle = 0x1ebbfa512a8, type = VK_OBJECT_TYPE_DEVICE; | MessageID 
= 0xbfc2d693 | vkCreateGraphicsPipelines() pCreateInfo[0]: topology is VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST and primitiveRestartEnable is VK_TRUE. It is invalid. The Vulkan spec states: If topology is VK_PRIMITIVE_TOPOLOGY_POINT_LIST, VK_PRIMITIVE_TOPOLOGY_LINE_LIST, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY, VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY or VK_PRIMITIVE_TOPOLOGY_PATCH_LIST, primitiveRestartEnable must be VK_FALSE (https://vulkan.lunarg.com/doc/view/1.2.141.0/windows/1.2-extensions/vkspec.html#VUID-VkPipelineInputAssemblyStateCreateInfo-topology-00428)
    object info: (type: DEVICE, hndl: 2112044208808)
```

(arguably wgpu could be more clever about this and just not set `restart_index`, but that leaves the user code in a non-sense state)

**Testing**
One-off test triggering the error through wgpu-rs.

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-01 21:12:19 +00:00
Andreas Reich
9dd88cb338 validate for strip_index_format being used with non-strip topology 2021-02-01 21:46:24 +01:00
bors[bot]
aea2af588c Merge #1183
1183: Improve docs language r=cwfitzgerald a=danielzgtg

**Description**

- s/fact culling/face culling/g
- s/are draw /are drawn /g

**Testing**

- There are no code change.
- The documentation should be less confusing


Co-authored-by: Daniel Tang <danielzgtg.opensource@gmail.com>
2021-02-01 08:13:20 +00:00
bors[bot]
e15eefc718 Merge #1185
1185: [master] Fix Readme Date r=trivial a=cwfitzgerald

Port #1184 to master

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-02-01 07:46:17 +00:00
Connor Fitzgerald
c43bfaf8e0 Fix readme date 2021-02-01 02:45:31 -05:00
Daniel Tang
07a2c9a712 Improve docs language 2021-02-01 02:19:32 -05:00
bors[bot]
7c7501cab7 Merge #1182
1182: Update all versions r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3620 and a bunch of other fixes in gfx-rs and naga.

**Description**
Updates the dependencies ("gfx-9" naga train) as well as self version to 0.7, to match the v0.7 branch.

**Testing**
Should just work :)

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-01 05:37:39 +00:00
Dzmitry Malyshau
8ed543f26a Update all versions 2021-02-01 00:35:40 -05:00
bors[bot]
da8d17d8d3 Merge #1159
1159: Zero initialize buffers r=kvark a=Wumpf

**Connections**
First half of  #563, focusing solely on buffers and ignoring same issue for textures

**Description**
Tracks for each buffer which parts are initialized (i.e. set to zero). Identified three interaction points for this:
* buffer mapping: Zeroing out ad-hoc and marking as initialized
* queue write to buffer: Marks target buffer regions as initialized (i.e. optimizes away buffer init down the line)
* use in binding or copy operation in a command buffer:
   * fine grained tracking of regions that may require init (or will be initialized implicitly) on each command buffer
   * set in motion on queue submit, init is exclusively with `fill_buffer`

Todo list for Ready-to-Review

- [x] memory barriers for `fill_buffer` calls
- [x] better data structure for `memory_init_tracker`
- [x] coarse filtering on command-buffer buffer init requirements (the list should almost always be empty whereas now it pushes any buffer use)
- [x] improve naming of things
- [x] at least pretend this is adequately tested

Todo list beyond this PR

* make data structures usable for textures
  * and.. well.. implement all this for textures!
* explore reusing barrier tracker for memory init tracking?


**Testing**

* Some basic testing by doing some changes to wgpu-rs samples and watching them in in the debugger.
* Added a ron test file for the player (love those!) to poke the feature a little bit
* MemoryInitTracker comes with simple unit tests

Overall this is a bit shallow but as so often in this area accurate testing is hard because the outcomes are quite indirect



Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-01 03:17:36 +00:00
Andreas Reich
822424e519 Fix buffer init in bundle.rs with mem::size_of::<wgt::DrawIndirectArgs> 2021-01-31 22:01:52 +01:00
Andreas Reich
4f5acba5fb Fixed too eager lock usage, fixed O(N²) buffer range collapse 2021-01-31 21:56:31 +01:00
Andreas Reich
a8460b438c MemoryInitTracker drain is now O(N) 2021-01-31 21:56:31 +01:00
Andreas Reich
018ad05f56 memory init tracker check (previous is_initialized) clamps range now
and is O(log n)!
2021-01-31 21:56:31 +01:00
Andreas Reich
31d292b169 added clear helper method to memory_init_tracker, renamed drain 2021-01-31 21:56:31 +01:00
Andreas Reich
da86b3f401 Cleanup, better use of some rust std lib functions 2021-01-31 21:56:31 +01:00
Andreas Reich
cc183c885f Added player test for buffer-zero-init 2021-01-31 21:56:31 +01:00
Andreas Reich
216dcf949b MemoryInitTracker has now a custom impl that doesn't depend on range-alloc 2021-01-31 21:56:31 +01:00
Andreas Reich
32b4e32ac6 MemoryInitTracker tests and interface adjustments 2021-01-31 21:56:31 +01:00
Andreas Reich
492027fe6e command buffer buffer memory init tracking is only filled if necessary now 2021-01-31 21:56:22 +01:00
Andreas Reich
22fb9ab1eb buffer zero init on queue_submit emits correct barriers now
refactored this zero init into separate method
2021-01-31 21:55:49 +01:00
Andreas Reich
5d2afa52c1 Fix zero init for buffers mapped at cration that are not mappable 2021-01-31 21:55:49 +01:00
Andreas Reich
1efdc2b229 Queue_submit zeros out uninitialized buffer regions now
again but with fine grained scheme now
2021-01-31 21:55:49 +01:00
Andreas Reich
9595b39bb3 Fine grained tracking of buffer init requirements 2021-01-31 21:55:49 +01:00
Andreas Reich
5133b0da94 Introduced separate MemoryInitTracker 2021-01-31 21:55:49 +01:00
Andreas Reich
076aecd150 buffer map permeates zero init now in any case 2021-01-31 21:55:49 +01:00