Commit Graph

9013 Commits

Author SHA1 Message Date
Dzmitry Malyshau
68bf10a3a5 Fix invalidated segment of the staging memory 2020-09-06 20:37:03 -04:00
Timo de Kort
a3bac5ee0f [Spirv-out] Move instructions to own module (#174)
* [spirv-out] Move instructions to own module

* [spirv-out] Fix wrong function use of some instructions

* [spirv-out] Update instruction parameters

* [spirv-out] Update current instruction tests

* [spirv-out] Order current instruction tests

* [spirv-out] Add missing instruction tests
2020-09-06 00:35:59 -04:00
bors[bot]
5cfdd4a135 Merge #920
920: Don't bind groups that aren't expected by the layout  r=grovesNL a=kvark

**Connections**
Sibling of #919 for master.

**Description**

**Testing**
In addition to the fix itself, this comes with a new regression playtest!

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-09-06 02:22:02 +00:00
bors[bot]
9e81e3d6ef [rs] Merge #547
547: Implement on_uncaptured_error  r=kvark,cwfitzgerald a=scoopr

This is very crude at the moment, I'm mostly just checking if the directions is at all viable.

So I set out to implement `on_caught_error`, focusing solely on the direct backend. It just accepts a `Fn(GPUError)` (and I named it GPUError because I didn't yet want to rename the import of `std::error::Error`).

I store the handler in a `ErrorSinkRaw` struct, which is then wrapped in Arc+Mutex, with the idea that other resources can point to the same Arc, so when `Device::on_uncaught_error` is called mid application, all resources will point to the right place. Otherwise I think something like `Buffer::unmap` would have to find the `Device` it was created with, to find the uncaught handler.

Now I store the `ErrorSink` in the `Device` struct, because it is a convenient place to hold it. But I guess it is a bit nonsensical with the web backend, so either it would need to be `cfg(not(wasm32))`, or move the whole thing in the backend side, but in the direct backend, I don't see a convenient place to store the closure. But the unwrapping is done in direct backend, so it can't really be moved up in to wgpu-core either, unless the error handling overall is moved there.

Also related, I'm now passing the `error_sink` argument to the few methods where I implemented the error handling, which I think is a bit ugly, but it works.

Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2020-09-05 16:02:20 +00:00
Dzmitry Malyshau
eed8bf84ef Playtest for binding a group 2020-09-04 23:47:24 -04:00
Dzmitry Malyshau
1886149cae Don't bind groups that aren't expected by the layout 2020-09-04 23:47:24 -04:00
Mikko Lehtonen
e28bc9cbbb [rs] impl std error for Error
Relies more on the source() of error for informative messages
2020-09-05 01:29:03 +03:00
Mikko Lehtonen
4277bcab2c [rs] direct: ErrorSinkify Device methods 2020-09-05 00:21:53 +03:00
Mikko Lehtonen
03fda219e3 [rs] direct: Implement on_uncaptured_error
Currently the sink is used only in Device::create_shader_module and
Device::create_render_pipeline, to be expanded in future commits.
2020-09-05 00:21:47 +03:00
Mikko Lehtonen
506ee7a368 [rs] direct: Move Device to its own struct 2020-09-05 00:21:11 +03:00
Mikko Lehtonen
f987a82503 [rs] Add Device::on_captured_error
The implementation is dummy one
2020-09-03 09:37:09 +03:00
Mikko Lehtonen
117d323f71 [rs] Don't import Error directly 2020-09-03 09:34:10 +03:00
bors[bot]
1e7eec0686 [rs] Merge #548
548: wgpu update with correctness fixes r=kvark a=kvark

Picks up a few important correctness fixes, such as https://github.com/gfx-rs/wgpu/pull/916 and https://github.com/gfx-rs/wgpu/pull/912

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-09-02 20:47:07 +00:00
Dzmitry Malyshau
2ac4876361 [rs] wgpu update with correctness fixes 2020-09-02 16:45:20 -04:00
bors[bot]
3f1abf571e Merge #908
908: Clarify usage of SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING r=cwfitzgerald a=im-0

**Connections**
https://github.com/gfx-rs/wgpu-rs/pull/540

**Description**
This clarifies usage of SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING with GLSL.

**Testing**
This commit only changes documentation.

Co-authored-by: Ivan Mironov <mironov.ivan@gmail.com>
2020-09-02 20:43:32 +00:00
bors[bot]
ad3657aba8 [rs] Merge #540
540: Improve and fix examples/texture-arrays r=cwfitzgerald a=im-0

Original examples/texture-arrays produces following output on my machine (Linux, Mesa/RADV 20.2-rc3, Radeon VII):

![texture-arrays-non-uniform-bug](https://user-images.githubusercontent.com/18099621/91645079-8c00af00-ea5b-11ea-854a-ef5ab5a63ce2.png)

Quick investigation showed that only shaders with non-uniform indexing are problematic (first commit helped with this). Then, after searching on the web, I figured out that the problem is in missing `nonuniformEXT`. Second commit fixes this.

I am new to graphics programming, and `nonuniformEXT` may work just by accident. So please confirm my finding before merging.

Co-authored-by: Ivan Mironov <mironov.ivan@gmail.com>
2020-09-02 20:38:32 +00:00
bors[bot]
bbb9b84bd2 Merge #916
916: Flush staging init buffers r=cwfitzgerald a=kvark

**Connections**
Related to https://github.com/gfx-rs/gfx/pull/3362
With the new use of `write_buffer`/`write_texture`, the results on D3D11 regressed.

**Description**
It just happened to be the case that all the backends returned coherent staging buffers, used internally for `write_*` and `mapped_at_creation == true`. However, D3D11 backend currently doesn't have the coherent memory at all, and it helped me to see that we were missing a flush() on the staging buffer.

**Testing**
Untested, but should work (tm).

Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
2020-09-02 20:24:41 +00:00
Dzmitry Malyshau
35d2ed39b5 Flush staging init buffers 2020-09-02 15:58:32 -04:00
Pelle Johnsen
2cdb54e266 [glsl-new] Update last exprs to ExpressionRule (#173)
* [glsl-new] Update last exprs to ExpressionRule

Refactor out binary_expr to keep parser.rs 'small' and readable

* [glsl-new] Change binary_expr to method on Program

* [glsl-new] Make binary_expr a proper method
2020-09-02 01:34:39 -04:00
Timo de Kort
9ba075c990 [spirv-out] Implement FunctionCall 2020-09-01 23:56:43 -04:00
Timo de Kort
c56013b46e [spirv-out] Implement FunctionParameter 2020-09-01 23:56:43 -04:00
Timo de Kort
b7d834ed33 [spirv-out] Implement return value for functions 2020-09-01 23:56:43 -04:00
Timo de Kort
dc38fc115b [spirv-out] Add OpFunctionParameter 2020-09-01 23:56:43 -04:00
bors[bot]
6df8421f22 Merge #909
909: Add Quad play test r=kvark a=DevOrc

**Connections**
#807 

**Description**
Adds a play test that renders a white quad to a texture. The texture is then copied to a buffer and checked for accuracy with a file of expected bytes (All 0xFF). 

**Testing**
Cargo test succeeds

Co-authored-by: Noah Charlton <ncharlton002@gmail.com>
2020-09-01 20:18:21 +00:00
Noah Charlton
d05d1aeec1 Add Quad play test 2020-09-01 16:07:24 -04:00
Pelle Johnsen
f97c62b0e6 [glsl-new] Add bool consts, update logical exprs (#171) 2020-09-01 00:52:07 -04:00
Matus Talcik
b67739034e Implement Execution Modes (#169)
Add documentation, make clippy happy


Compilation errors


Add some more docs


Few more compilation errors


Changes based on the review


glsl-new parser fix


Set default local size to (0, 0, 0)


final cleanup


Last design


New design
2020-08-31 14:34:38 -04:00
bors[bot]
6069a3f055 [rs] Merge #545
545: Remove bake.frag from shadow example r=kvark a=yutannihilation

Now that `fragment_stage` is a `Option`, I guess this is the case when we don't need fragment shader.

Co-authored-by: Hiroaki Yutani <yutani.ini@gmail.com>
2020-08-31 16:05:56 +00:00
Hiroaki Yutani
b2ec7f360a [rs] Remove bake.frag 2020-09-01 00:22:19 +09:00
bors[bot]
ca7f6aee9a Merge #910
910: Replace backends! Macro with CFG Aliases r=kvark a=zicklag

**Connections**
Needs to be merged before: https://github.com/gfx-rs/wgpu/pull/907

**Description**
This change makes it easier to conditionally compile code based on graphics backends by adding `#[cfg]` aliases for the backends such as `vulkan`, `metal`, etc. This makes the code easier to read and maintain.

**Testing**
Tested the WGPU-rs cube and boids examples and they work as normal on a Linux machine with Vulkan.

Co-authored-by: Zicklag <zicklag@katharostech.com>
2020-08-31 04:33:42 +00:00
bors[bot]
9068ac8ff8 [rs] Merge #543
543: Don't use `log` crate in include_spirv r=kvark a=kvark

Fixes  #541

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-31 04:06:16 +00:00
Dzmitry Malyshau
7eeff9c321 [rs] Don't use log crate in include_spirv 2020-08-31 00:05:45 -04:00
bors[bot]
128ead0141 Merge #912
912: Fix write-only stencil state descriptors from not working - fixes #911 r=kvark a=Dinnerbone

**Connections**
This fixes [#911 - Stencil testing broken between v0.5 and v0.6](https://github.com/gfx-rs/wgpu/issues/911).

**Description**
Write-only stencil states (read 0, write >0) are being treated as if they are disabled, which causes pipelines to act as though they don't have any stencil state set at all. This worked prior to commit 2473c25971 (introduced in PR #873). As far as I can tell, this works fine in Vulkan, Metal, DX12 and DX11 as we've been using this approach over at Ruffle for a while now.

**Testing**
You can view the reproduction case in #911 for manual testing. I have confirmed that this fix makes that case work as expected.

I couldn't find any automated tests for wgpu-types to copy and add for this case. If that's wanted then please let me know what the best approach is.

Co-authored-by: Nathan Adams <dinnerbone@dinnerbone.com>
2020-08-31 03:51:17 +00:00
Nathan Adams
0e94752749 Fix write-only stencil state descriptors from not working - fixes #911 2020-08-30 23:33:09 +02:00
Zicklag
7572dbeaf9 Use CFG Aliases to Replace the backends! Macro
Uses the `cfg_aliases` crate to replace the `backends!` macro and
provide a more natural way to gate backend specific code.
2020-08-29 21:55:17 -05:00
Ivan Mironov
9557ab36a6 Clarify usage of SAMPLED_TEXTURE_ARRAY_NON_UNIFORM_INDEXING 2020-08-30 00:47:00 +05:00
Ivan Mironov
39c5153f2f [rs] Add nonuniformEXT qualifier in examples/texture-arrays
This fixes corruption of output on some AMD GPUs.
2020-08-30 00:30:06 +05:00
Ivan Mironov
76b5a3a331 [rs] Use wgpu::include_spirv!() for all shaders in examples/texture-arrays
`wgpu::include_spirv!()` writes file name into log. This is useful to
understand which fragment shader is used (choice depends on device
features).
2020-08-29 22:41:14 +05:00
Dzmitry Malyshau
dc442343d6 Make TypeInner to be non-clonable 2020-08-28 19:37:39 -04:00
Dzmitry Malyshau
d370686351 proc: support parameter types in Typifier 2020-08-28 19:37:39 -04:00
bors[bot]
b383285b85 [rs] Merge #537
537: Update wgpu with DepthComparison component and better shader validation r=cwfitzgerald a=kvark

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

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-08-28 21:39:11 +00:00
Dzmitry Malyshau
85becef23e [rs] Update wgpu with DepthComparison component and better shader validation 2020-08-28 17:37:33 -04:00
Matus Talcik
7a43c78e29 Add storage formats (#167)
Add GLSL backend


Add SPIR-V back + front
2020-08-28 14:55:30 -04:00
bors[bot]
bba82724a8 Merge #903
903: fix for mixed STORAGE_STORE and STORAGE_LOAD r=kvark a=kocsis1david

**Connections**
None

**Description**
A buffer that contains dynamic data is used for both uniforms and storage read. This was a problem for wgpu and it gave a `PendingTransition` error.

**Testing**
It's a trivial fix, but I don't know if there's an example for it in wgpu-rs that can be used for testing.

It seems that the PR "Sync changes from mozilla-central" is already solving the same issue.


Co-authored-by: Dávid Kocsis <kocsis1david@windowslive.com>
2020-08-28 16:10:55 +00:00
Pelle Johnsen
c824287fd5 [glsl-new] Refactor type handling (#166)
* [glsl-new] Refactor type handling

* [glsl-new] Fix clippy error
2020-08-28 12:09:57 -04:00
Maximilian Lupke
5d50b2ac24 Allow copying from depth textures (#901)
* Allow copying from depth textures

* Rename TextureFormat::is_depth_format to just is_depth

* Only allow Depth32Float format for copying, and only as source
2020-08-28 10:58:48 -04:00
Dávid Kocsis
5ea3ea7b55 fix for mixed STORAGE_STORE and STORAGE_LOAD 2020-08-28 07:23:38 +02:00
Dzmitry Malyshau
1b17030d05 Split wgsl into sub-modules, and gate by a feature (#165) 2020-08-27 23:30:53 -04:00
João Capucho
73204d094c glsl-out: fixes (#164)
* Fixed not generating wrong op on booleans
Correctly handle storage images and sampled images

* Fixed comments
2020-08-27 18:01:19 -04:00
Matúš Talčík
447e2483f9 Format, clippy
pub(super)
2020-08-27 17:08:25 -04:00