Commit Graph
8897 Commits
Author SHA1 Message Date
Dzmitry Malyshau de41bac69b [rs] Update wgpu for optional layouts 2020-08-10 16:42:52 -04:00
bors[bot]andDzmitry Malyshau 04f5cfd1c8 Merge #872
872: Respect texture view aspect on creation r=cwfitzgerald a=kvark

**Connections**
Fixing https://github.com/gfx-rs/wgpu-rs/issues/498 (but needs wgpu-rs update then)

**Description**
We added the aspect field to texture view descriptor but didn't respect it properly.
We do that now, and also disallow Depth-Stencil sampled views

**Testing**
Used the modified water example for testing.

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-08-10 20:16:45 +00:00
Dzmitry Malyshau 1f5622a0b3 Respect texture view aspect on creation 2020-08-10 16:14:20 -04:00
bors[bot]andDzmitry Malyshau 12352035f0 Merge #870
870: Implicit layout r=cwfitzgerald a=kvark

**Connections**
Closes #868

**Description**
The implementation can be split into 3 parts:
  1. reflecting the shader for binding expectations, and building a bind entry map from it, merging them between stages. This is only done for shaders that can be reflected, and we error on the rest, for now.
  2. based on this info, create new bind group layouts and pipeline layouts. The tricky part here is that we can't generate the ID out of thin air, so we have to pass them into the `create_xx_pipeline` function, which now also returns the number of IDs it consumed, allowing the client to free the rest.
  3. API changes in the descriptors, new methods to obtain the bind group layouts from a pipeline

**Testing**
This isn't tested, but I think it's fine: it doesn't affect the old path, and we'll be testing the new path while improving Naga and our reflection anyway.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-10 18:38:34 +00:00
Pelle Johnsen b96b7449db [gls-new] handle local vars 2020-08-10 10:57:31 -04:00
Pelle Johnsen 41c1c713dc [glsl-new] handle global vars in external_decl 2020-08-10 10:57:31 -04:00
Dzmitry Malyshau f164fd1f46 Bump BGL refcounts on getting them from pipelines 2020-08-10 10:11:31 -04:00
Dzmitry Malyshau 55064ace4c New get_bind_group_layout functions 2020-08-09 18:33:47 -04:00
Dzmitry Malyshau d8efe3b6fe Attempt to unite implicit layout code between compute and render 2020-08-09 18:16:03 -04:00
Dzmitry Malyshau 173c7c3dbf Create implicit layouts for render pipelines 2020-08-09 14:43:44 -04:00
Pelle Johnsen ede04ba4dc [glsl-new] Simplify declaration code
- Fix clippy issues
2020-08-09 10:57:41 -04:00
Pelle Johnsen 482c6d042d [glsl.new] Add initial declaration support
Focus on handling global in/out vars
2020-08-09 10:57:41 -04:00
Pelle Johnsen f98054afdd [glsl-new] add vec2 and vec3 2020-08-09 10:57:41 -04:00
Timo de Kort 6db5b373f8 Add support for other matrices keywords (#121)
Add mat2x3, mat2x4, mat3x2, mat3x4, mat4x2, and mat4x3 keywords
2020-08-09 09:32:22 -04:00
Dzmitry Malyshau a9b8a99e19 Create implicit layouts for compute pipelines 2020-08-09 08:33:33 -04:00
Dzmitry Malyshau f18fa7ef9b Derive bind group layout entries in Naga validation 2020-08-08 01:09:41 -04:00
bors[bot]andDzmitry Malyshau 430b29d781 Merge #866
866: Streghten the multi-ref-count on BGLs r=cwfitzgerald a=kvark

**Connections**
Fixes #834

**Description**
Bind group layouts (BGLs) have to be somewhat uniquely tracked, and there was a synchronization issue with their use of `MultiRefCount`. What would happen in multi-thread environment is that we'd see `bind_group_layout_drop`, which first decreases the refcount, and then adds the ID to the list of suspected resources for deletion. But between these operations, something else may have triggered the triage of suspected resources, and if BGL was already there previously, it would be removed earlier than expected.

The solution I came up with is deferring the "dec()" call until the triage itself. That guarantees no gaps, and in fact it goes in line with the other resources we are tracking. I'm fairly confident that the new method works correctly at all times.

**Testing**
Tested extensively on https://github.com/gfx-rs/wgpu/issues/834#issuecomment-669362572

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-05 21:46:20 +00:00
Dzmitry Malyshau 8731da278e Streghten the multi-ref-count on BGLs 2020-08-05 17:39:25 -04:00
bors[bot]andKunal Mohan 5d85f591e9 [rs] Merge #496
496: Replace u32 with NonZeroU32 in TextureView r=kvark a=kunalmohan

Includes https://github.com/gfx-rs/wgpu/pull/865

Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-08-05 17:45:46 +00:00
Kunal Mohan f9ab713d0e [rs] Replace u32 with NonZeroU32 in TextureView 2020-08-05 22:54:41 +05:30
bors[bot]andKunal Mohan 8057acf120 Merge #865
865: Replace u32 with NonZeroU32 in TextureView r=kvark a=kunalmohan

**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._
We now expose separate methods under `Global` to register error/invalid resources. So the check for `mip_level_count = 0` and `array_layer_count = 0` can be made on the client-side in Servo, and directly register an error resource instead of trying to create a real one.

**Testing**
_Explain how this change is tested._
Not yet tested. Will be done wgpu-rs examples.
<!--
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: Kunal Mohan <kunalmohan99@gmail.com>
2020-08-05 17:10:47 +00:00
Kunal Mohan aa44969818 Replace u32 with NonZeroU32 in TextureView 2020-08-05 21:23:25 +05:30
bors[bot]andGabriel Majeri fc14f3d21d Merge #864
864: Remove `power` module r=kvark a=GabrielMajeri

**Connections**
Closes #859 

**Description**
Removes the `power.rs` module. If the user wants to detect the battery status and choose between low-power and high-performance, they can do so themselves.

**Testing**
Tested with core.

Co-authored-by: Gabriel Majeri <gabriel.majeri6@gmail.com>
2020-08-05 13:46:34 +00:00
Pelle Johnsen 745ef6a6d6 [glsl-new] Add float consts (#119) 2020-08-05 09:45:42 -04:00
Gabriel Majeri 021251a908 Remove power module 2020-08-05 16:27:41 +03:00
bors[bot]andDzmitry Malyshau 768c606844 [rs] Merge #494
494: Update wgpu with the error model changes r=cwfitzgerald a=kvark

Depends on https://github.com/gfx-rs/wgpu/pull/857

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-05 00:00:21 +00:00
Dzmitry Malyshau 6832ad1513 [rs] Update wgpu with the error model changes 2020-08-04 17:09:21 -04:00
bors[bot]andDzmitry Malyshau 78546f410d Merge #857
857: Separate valid internal IDs from external ones r=cwfitzgerald a=kvark

**Connections**
Closes #638 
wgpu-rs update - https://github.com/gfx-rs/wgpu-rs/pull/494

**Description**
The core change here is to allow user-specified IDs to be in the "Error" state that was introduced in #776 .

This is done by defining an internal `Valid<I>` wrapper. Now, the hub storages can be indexed by this valid wrapper only. For regular IDs, we have to go through `storage.get(index)`, which returns a `Result`. It still panics if the ID is totally garbage though, we don't want to handle what can't be expected here.

All the other changes come mostly as a consequence of that:
  - new "Invalid*" error variants are added
  - the error types are undergone sever refactoring
  - new `command/draw.rs` module for stuff shared between render passes and bundles
  - functions to generate error IDs for all the types
  - various renames, e.g. `comb` -> `cmd_buf`

The expected use by wgpu-rs is unchanged. So far, I don't think we'd be generating Error IDs, but we can always reconsider.
For browsers though, if `device_create_xxx` failed, they would generate and error ID. It will occupy the slot up until the corresponding JS object is dropped.

**Testing**
Tested on wgpu-rs examples

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-04 20:51:11 +00:00
Pelle Johnsen 747535906f [glsl-new] Add ExpressionRule for expr/stmts (#118)
- Initial work for handling expressions that also generates statements
2020-08-04 15:45:55 -04:00
Dzmitry Malyshau dbd7e2c579 Separate valid internal IDs from external ones 2020-08-04 11:16:59 -04:00
bors[bot]andAndrea Nardi 5d35936d5c Merge #856
856: Implementation of the builder pattern r=kvark a=Andful

**Connections**
This pull request addresses the issue #851 

**Description**
Add a builder for wgpu types.

**Testing**
TODO
<!--
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: Andrea Nardi <buongiorno19972@gmail.com>
2020-08-02 03:51:58 +00:00
Andrea Nardi acfbbb42b5 Implementation of the builder pattern
Signed-off-by: Andrea Nardi <buongiorno19972@gmail.com>
2020-08-02 05:49:10 +02:00
bors[bot]andHiroaki Yutani d846081d36 [rs] Merge #495
495: Update a documentation to refer to create_buffer_init() instead of create_buffer_with_data() r=kvark a=yutannihilation

A followup of #482

Co-authored-by: Hiroaki Yutani <yutani.ini@gmail.com>
2020-08-02 00:26:48 +00:00
Hiroaki Yutani 3c823e24c0 [rs] Update a doc's reference to create_buffer_init() 2020-08-01 17:57:13 +09:00
bors[bot]andDzmitry Malyshau 872a6c4c2b Merge #860
860: Update naga and fix type widths r=mechanical a=kvark

**Connections**
Related to https://github.com/gfx-rs/naga/pull/98

**Description**
Naga's "width" has type `Bytes`, so we should treat it as such.

**Testing**
How did it use to work? Oh right, it didn't.

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-01 03:48:19 +00:00
Dzmitry Malyshau 3291b72368 Update naga and fix type widths 2020-07-31 23:46:19 -04:00
bors[bot]andConnor Fitzgerald 6183e205a0 [rs] Merge #493
493: Use BCn textures if possible in skybox example r=kvark a=cwfitzgerald

This converts the skybox to using compressed textures if available. I have designed the code to be extensible to other compressed formats as they are added.

Additionally I added srgb to the texture types, as we were using a srgb framebuffer without properly converting into  linear on the texture reads.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-31 02:52:35 +00:00
Connor Fitzgerald aeffeaf869 [rs] Use BCn textures if possible in skybox example 2020-07-30 20:55:40 -04:00
bors[bot]andConnor Fitzgerald b352093988 Merge #855
855: Fix multi-layer copies r=kvark a=cwfitzgerald

**Description**

When copying multiple layers at the same time, we ignored 

**Testing**

Tested on the skybox example with BC1 textures doing all layer copies.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-30 21:07:40 +00:00
Connor Fitzgerald 00a5be7f7b Fix multi-layer copies 2020-07-30 16:58:29 -04:00
bors[bot]andKunal Mohan c320599e20 [rs] Merge #492
492: Replace NonZeroU32 with u32 in TextureViewDescriptor r=kvark a=kunalmohan

Includes https://github.com/gfx-rs/wgpu/pull/854

(rustfmt seems to have introduced a number of other changes. I can revert them if they are undesired)

r?@kvark

Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-07-30 17:41:55 +00:00
Kunal Mohan eba4cd977b [rs] Replace NonZeroU32 with u32 in TextureViewDescriptor 2020-07-30 23:01:49 +05:30
bors[bot]andKunal Mohan 9e4839eb04 Merge #854
854: Replace NonZeroU32 with u32 in TextureViewDescriptor r=kvark a=kunalmohan

**Connections**
_Link to the issues addressed by this PR, or dependent PRs in other repositories_

**Description**
_Describe what problem this is solving, and how it's solved._

**Testing**
_Explain how this change is tested._
Not yet tested
<!--
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.
-->

r?@kvark


Co-authored-by: Kunal Mohan <kunalmohan99@gmail.com>
2020-07-30 16:10:29 +00:00
Kunal Mohan c8360152cd Replace NonZeroU32 with u32 in TextureViewDescriptor 2020-07-30 21:35:07 +05:30
bors[bot]andConnor Fitzgerald 0e27959404 Merge #853
853: Implement TEXTURE_COMPRESSION_BC extension r=kvark a=cwfitzgerald

**Connections**

Closes #852.

**Description**

Adds support for BCn textures as specified in the upstream issue. This also shores up the validation and copy logic to work well with the block oriented nature of compressed textures. ETC2 and ASTC should fall out of this easily.

**Testing**

No wgpu-rs changes were needed, however I tested it with the following changes in wgpu-rs: https://github.com/cwfitzgerald/wgpu-rs/commit/96c05ef4bf34c955ec5123a3ebeee1ab98916dc6.


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-07-30 02:57:12 +00:00
bors[bot]andOptimisticPeach 45df7b03ca [rs] Merge #482
482: Add label parameter to `create_buffer_with_data` r=kvark a=OptimisticPeach

Improves QOL by allowing you to attach a label to a buffer when created with predetermined data:
```
let uniform_buf = device.create_buffer_with_data(
    bytemuck::cast_slice(my_data),
    wgpu::BufferUsage::UNIFORM,
    Some(Cow::Borrowed("My Uniforms")),
);
```

Co-authored-by: OptimisticPeach <patrikbuhring@yahoo.com>
2020-07-30 02:08:24 +00:00
OptimisticPeach 208e3ec8a0 [rs] Combine create_buffer and create_buffer_with_dataCombines both by creating a new buffer descriptor which can deal with both of copying and allocating. 2020-07-29 21:35:21 -04:00
Connor Fitzgerald e5c647745e Implement TEXTURE_COMPRESSION_BC extension 2020-07-29 18:43:50 -04:00
bors[bot]andMac O'Brien a41b91b284 [rs] Merge #490
490: Panic using error Display rather than unwrapping r=kvark a=cormac-obrien

Fixes #489.

Co-authored-by: Mac O'Brien <cormac@c-obrien.org>
2020-07-29 20:01:03 +00:00
Mac O'Brien 71b2763159 [rs] Panic using error Display rather than unwrapping
Fixes #489
2020-07-29 14:01:50 -05:00