Commit Graph

1669 Commits

Author SHA1 Message Date
Dzmitry Malyshau
103e7763a3 Rename depth to depth_or_array_layers 2021-03-01 11:08:17 -05:00
bors[bot]
3bb2835fb5 Merge #1240
1240: Fix issue with multiple queued mappings where the last one is not cancelled r=kvark a=Imberflur


**Connections**
Follow up from #1239

**Description**
In #1239 I missed the case where there are multiple rounds of mapping/unmapping with the last map not being cancelled. In practice it doesn't occur very often, but I did encounter it with settings/a scene that created a heavy GPU load.

Sorry for not catching this earlier!

**Testing**
Using `wgpu-rs` capture example, after the first `map_async` I added in an `unmap` followed by another `map_async`.
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Imbris <imbrisf@gmail.com>
2021-03-01 03:53:57 +00:00
Imbris
2c153f5d50 Fix issue with multiple queued mappings where the last one is not cancelled 2021-02-28 00:56:17 -05:00
bors[bot]
ecbddedfaf Merge #1239
1239: Avoid panic when requesting to unmap a buffer that is pending mapping r=kvark a=Imberflur

**Connections**
Fix for #1238 

**Description**
This might not be the cleanest fix but it is quite minimal. I'm not sure what the exact intent is with the organization of things and with the async status enum, would be happy to hear critiques.

**Testing**
Tested against example in #1238 
<!--
Non-trivial functional changes would need to be tested through:
  - [wgpu-rs](https://github.com/gfx-rs/wgpu-rs) - test the examples.
  - [wgpu-native](https://github.com/gfx-rs/wgpu-native/) - check the generated C header for sanity.

Ideally, a PR needs to link to the draft PRs in these projects with relevant modifications.
See https://github.com/gfx-rs/wgpu/pull/666 for an example.
If you can add a unit/integration test here in `wgpu`, that would be best.
-->


Co-authored-by: Imbris <imbrisf@gmail.com>
2021-02-28 03:18:35 +00:00
Imbris
c82a3a77d2 Avoid panic when requesting to unmap a buffer that is pending mapping 2021-02-27 17:38:53 -05:00
bors[bot]
c3a18c3d8b Merge #1235
1235: Update VertexFormat variants r=grovesNL a=kvark

**Connections**
Matches https://github.com/gpuweb/gpuweb/pull/1322 and https://github.com/gpuweb/gpuweb/pull/1469

**Description**
Just updates us to recent upstream API.
Also breaks lots of user code!

**Testing**
Not functional


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-27 16:05:04 +00:00
bors[bot]
29058e03b0 Merge #1237
1237: Move `#[error]` attributes after the corresponding `#[derive]` r=kvark a=Aaron1011

**Connections**
See https://github.com/rust-lang/rust/issues/79202

**Description**
Fixes Nightly future-incompat warnings

**Testing**
There are no behavior changes intended.

Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
2021-02-26 01:09:41 +00:00
bors[bot]
39aa01d1b1 Merge #1236
1236: Update gfx to 0a201d1c406b5119ec11068293a40e50ec0be4c8 r=kvark a=Aaron1011

**Connections**
wgpu issue: #246
GFX PR: https://github.com/gfx-rs/gfx/pull/3653
Underlying libloading issue: https://github.com/nagisa/rust_libloading/issues/41

**Description**

Pulls in https://github.com/gfx-rs/gfx/pull/3653,
which fixes a segfault when using wgpu from a non-main thread.

**Testing**

The example in https://github.com/gfx-rs/wgpu/issues/246 should run successfully. I'm not certain how to add an integration test to the repository.

Co-authored-by: Aaron Hill <aa1ronham@gmail.com>
2021-02-26 01:03:12 +00:00
Aaron Hill
12b086d92d Move #[error] attributes after the corresponding #[derive]
This fixes Nightly warnings

See https://github.com/rust-lang/rust/issues/79202
2021-02-25 15:40:11 -05:00
Dzmitry Malyshau
cf165f9a3e Update VertexFormat variants 2021-02-25 15:25:56 -05:00
Aaron Hill
8b4bec5d9a Update gfx to 0a201d1c406b5119ec11068293a40e50ec0be4c8
Fixes #246

Pulls in https://github.com/gfx-rs/gfx/pull/3653,
which fixes a segfault when using wgpu from a non-main thread.
2021-02-25 15:25:40 -05:00
Jökull Máni Reynisson
ce4668a7ac const in ShaderStage that represents vertex and fragment access (#1229)
* const in ShaderStage that represents vertex and fragment access

We can store `ShaderStage`s as const values or members of const structs in all individual cases, but for example `ShaderStage::VERTEX | ShaderStage::FRAGMENT` cannot be stored in a const. This is not very elegant, but would be convenient.

* Correct VERTEX_FRAGMENT definition

VERTEX_FRAGMENT definition now follows directly from the bit representation of `ShaderStage::VERTEX` and `Shaderstage::FRAGMENT` such that it does not need to be independently maintained.
2021-02-24 16:37:05 -05:00
bors[bot]
f430adb828 Merge #1231
1231: Added TextureFormatFeatures::filterable which may overwrite TextureSampleType::Float.filterable r=kvark a=Wumpf

**Description**
The expectation is that with `wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES` enabled, any texture format which is sampled as float may be (linearly) filtered if so supported by the adapter, not only those that the webgpu specification denotes as filterable.

This arguably causes a bit of a mess in the way we distinguish `sample_type` and `(guaranteed_)format_features`: The float sample type (via spec) essentially integrates a feature, namely if it is filterable or not. Unlike the actual format _type_ which is just a property of the format, this property may or may not be available depending on the device.
So the type of `sample_type` stays statically defined whereas the Float.filterable property suddenly becomes overwritten by a format_feature which may or may not be present. Couldn't come up with a cleaner solution so far.

**Testing**
Tested in project (blub) depending on R32F filtering - passing now what was previously causing
```
wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
      note: label = `BindGroup: Narrow Range filter 1`
    texture binding 1 expects sample type = Float { filterable: true }, but given a view with format = R32Float
```
(Blub still can't run on latest wgpu because of other reported issues)

Co-authored-by: Andreas Reich <r_andreas2@web.de>
2021-02-24 01:20:12 +00:00
Andreas Reich
dfe686bbc6 Added TextureFormatFeatures::filterable
Can overwrite TextureSampleType::Float.filterable
2021-02-23 23:59:17 +01:00
bors[bot]
e5f1f6a5c0 Merge #1227
1227: Derive more things for primitive and multisampling states r=kvark a=kvark

**Connections**
Related to https://github.com/gfx-rs/wgpu-rs/issues/769

**Description**
Adding a few derives and fixing a doc comment.

**Testing**
CI gets it

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-22 06:12:14 +00:00
Dzmitry Malyshau
c506c76e45 Derive more things for primitive and multisampling states 2021-02-22 01:10:26 -05:00
bors[bot]
2d0142a2e7 Merge #1226
1226: Update gfx and naga to gfx-12 r=kvark a=kvark

**Connections**
Picks up https://github.com/gfx-rs/gfx/pull/3650
Fixes #1225

**Description**
Also fixes our playtests, interestingly. One of the changes here was that now `Analysis` is needed for everything, including the SPV-out backend of Naga. And we can only get it via validating the `naga::Module`.

What we used to was: if validation isn't enabled, we'd carry the module around, and then still try to produce a SPIR-V from it, if there is no original SPIR-V. This precise thing was happening in the tests. However, we had `dummy` backend depending on the `wgpu-core/cross` feature, which means the playtests were actually built and run with spirv-cross enabled!
Another factor here is the introduction of `ShaderModule::flags` instead of a single boolean, which was done in #1093. The problem here was that the playtest RON files weren't updated accordingly, they still had `experimental_translation: true` in them, which got ignored now.
So with this combination of events, the playtests ended up generating SPIR-V from Naga modules, without validation(!), and passing the SPIR-V to gfx-rs and SPIRV-Cross... Which still worked, as we'd expect, but definitely not want here.

So this PR fixes everything. It makes it required to have the validation for a module, and we force-validate if there is no SPV source to fall back on. And it disables "cross" feature implicitly enabled in testing.

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

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-21 16:36:54 +00:00
Dzmitry Malyshau
91f5329b33 Update gfx and naga to gfx-12 2021-02-21 11:25:45 -05:00
bors[bot]
53bab9d68f Merge #1224
1224: Update the blend API to upstream r=kvark a=kvark

**Connections**
Matches https://github.com/gpuweb/gpuweb/pull/1134

**Description**
Makes blending state ON/OFF explicit.

**Testing**
Simple enough!

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-19 17:38:16 +00:00
Dzmitry Malyshau
ff31911760 Update the blend API to upstream 2021-02-19 12:07:47 -05:00
bors[bot]
5afe832c3c Merge #1220
1220: Update naga to gfx-11, make spirv-cross optional r=kvark a=kvark

**Connections**
https://github.com/gfx-rs/gfx/pull/3642
https://github.com/gfx-rs/gfx/pull/3641

**Description**
Gets us the latest Naga updates, plus the ability to make spirv-cross optional (on Linux and Windows only for now).

**Testing**
Will be tested on wgpu-rs

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-02-16 15:24:03 +00:00
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