Commit Graph

594 Commits

Author SHA1 Message Date
Robert Broketa
79c50797cf [rs] Fixes #575 - vulkan-portability feature on MacOS 2020-09-21 14:32:46 -03:00
bors[bot]
9a4026129a [rs] Merge #574
574: Implement AsRef for BufferView r=kvark a=de-vri-es

This PR implements `AsRef` and `AsMut` in addition to `Deref` and `DerefMut` for `BufferView` and `BufferViewMut`.

This allows the buffer views to be used directly by generic code that wants an `AsRef<[u8]>`.

It's also subjectively a small win when you want to pass the views to non-generic code. I find `buffer.as_ref()` clearer than `&*buffer`. That also goes for `buffer.deref()`, but `Deref` is not in the prelude.

Co-authored-by: Maarten de Vries <maarten@de-vri.es>
2020-09-21 15:43:25 +00:00
Maarten de Vries
81df9fb707 [rs] Implement AsRef for BufferView
Remove AsRef<[u8]> for BufferViewMut.
2020-09-21 17:35:30 +02:00
bors[bot]
4b1c363def [rs] Merge #576
576: Convert swapchain.get_current_frame to a immutable reference r=kvark a=cwfitzgerald

Per our discussion on matrix, converts swapchain.get_current_frame to an immutable reference as it's internally synchronized.

Rationale: will allow me to take a non-pretty RW mutex as read instead of write in my application

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2020-09-20 19:33:08 +00:00
Connor Fitzgerald
f7b78115e3 [rs] Convert swapchain.get_current_frame to a immutable reference 2020-09-20 14:38:43 -04:00
bors[bot]
47c05b324f [rs] Merge #570
570: web: temporarily polyfill `create_buffer_init` r=kvark a=grovesNL

Temporarily polyfill `create_buffer_init` on the web backend by using the old buffer mapping API. This is just a temporary fix until the new buffer mapping API is available in Nightly.

This polyfill allows us to run `cube` from `master` on Nightly (there's still lots missing from other examples). But at least some simple use cases (e.g. projects only using `create_buffer_init`/`write_buffer` and no other buffer mapping functions) can run with `master`.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-09-17 03:20:06 +00:00
Joshua Groves
9270d85e3a [rs] web: temporarily polyfill create_buffer_init 2020-09-17 00:48:58 -02:30
bors[bot]
adfd90a148 [rs] Merge #569
569: Reorder framework canvas setup for web r=kvark a=grovesNL

winit only appends the canvas element once the window is built, and we need the canvas to exist before `create_surface` can use it. So we can just reorder the calls to build the window before using `create_surface` on the web backend in framework.

Also temporarily no-op debug markers for the web until we have them in gecko. Even though they're technically unimplemented, we can still proceed without them.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-09-16 03:57:52 +00:00
Joshua Groves
8153e29c98 [rs] Temporarily no-op debug marker functions for web 2020-09-16 01:05:12 -02:30
Joshua Groves
90cdc32c0c [rs] Reorder framework window creation for web 2020-09-16 01:04:49 -02:30
bors[bot]
da81673f64 [rs] Merge #567
567: Notes on LoadOp r=kvark a=PENGUINLIONG

If the swapchain image was drawn with a pipeline that loads a render target that has not been cleared before, the validation layer gives a triplet of confusing feedbacks:

```log
[2020-09-15T06:42:23Z ERROR gfx_backend_vulkan] 
    VALIDATION [UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (1303270965)] : Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1d80787bfe8, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | Submitted command buffer expects VkImage 0x6dc7200000000005[] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED.
    object info: (type: COMMAND_BUFFER, hndl: 2027350900712)

[2020-09-15T06:42:23Z ERROR gfx_backend_vulkan] 
    VALIDATION [UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (1303270965)] : Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1d8078586a8, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | Submitted command buffer expects VkImage 0x3ba5830000000006[] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED.
    object info: (type: COMMAND_BUFFER, hndl: 2027350754984)

[2020-09-15T06:42:23Z ERROR gfx_backend_vulkan] 
    VALIDATION [UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout (1303270965)] : Validation Error: [ UNASSIGNED-CoreValidation-DrawState-InvalidImageLayout ] Object 0: handle = 0x1d8078614f8, type = VK_OBJECT_TYPE_COMMAND_BUFFER; | MessageID = 0x4dae5635 | Submitted command buffer expects VkImage 0x4c5b620000000007[] (subresource: aspectMask 0x1 array layer 0, mip level 0) to be in layout VK_IMAGE_LAYOUT_PRESENT_SRC_KHR--instead, current layout is VK_IMAGE_LAYOUT_UNDEFINED.
    object info: (type: COMMAND_BUFFER, hndl: 2027350791416)
```

And it turns out they come from the triple-buffering swapchain images. It seems `wgpu` would only re-layout the swapchain image if it's been loaded by a clear op. I would be great to warn the users beforehand. (I know it's not something I should ever do tho)

Co-authored-by: PENGUINLIONG <admin@penguinliong.moe>
2020-09-15 13:32:59 +00:00
PENGUINLIONG
39b9a6218b [rs] Notes on LoadOp 2020-09-15 14:43:30 +08:00
bors[bot]
9840ae4eb3 [rs] Merge #565
565: Add context to errors r=kvark a=scoopr

ContextError is just a simple wrapper that contains a string and the original error, and it is used to decorate the error to give it more context.

Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2020-09-15 01:38:19 +00:00
bors[bot]
4829875193 [rs] Merge #566
566: Report out of memory errors r=kvark a=scoopr



Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2020-09-15 01:28:40 +00:00
Mikko Lehtonen
2e791cacde [rs] Report out of memory errors 2020-09-14 23:26:20 +03:00
Mikko Lehtonen
60af888c74 [rs] Add context to errors
ContextError is just a simple wrapper that contains a string and the original error, and it is used to decorate the error to give it more context.
2020-09-14 22:54:52 +03:00
bors[bot]
3c0634fdec [rs] Merge #562
562: More errorsinkifying r=kvark a=scoopr

Continuing on with errorsinkifying more places, these wrap Buffer, Texture and CommandEncoder with a struct that includes the `error_sink`, and uses it for the error handling.

I think most of the apis are errorsinkified with this. The remaining ones may need some more thinking. 

Queue would be wrapped mostly for the submit, the write_ stuff could in theory piggyback on the texture/buffer error-sink.
Others like swapchain, some mapping stuff, etc. needs some discussion or other implementation work.


Co-authored-by: Mikko Lehtonen <scoopr@iki.fi>
2020-09-13 04:28:57 +00:00
bors[bot]
f66bc8ff79 [rs] Merge #563
563: Document bind buffer alignment r=kvark a=kvark

Fixes  #561
Also updates wgpu dependency to latest, and our exampels are now fully validated for the shader interface 🎉 .

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-09-13 04:11:39 +00:00
Dzmitry Malyshau
c269703bcf [rs] Document the bind buffer alignment 2020-09-13 00:10:11 -04:00
Dzmitry Malyshau
24ad4af92c [rs] Update wgpu with Naga changes 2020-09-13 00:10:11 -04:00
Mikko Lehtonen
d0db3fc0a0 [rs] Errorsinkify CommandEncoder 2020-09-13 01:11:18 +03:00
Mikko Lehtonen
f5ab931aba [rs] Errorsinkify Texture 2020-09-12 23:26:35 +03:00
Mikko Lehtonen
d93d494582 [rs] Errorsinkify Buffer 2020-09-12 23:26:35 +03:00
bors[bot]
70732bb6ac [rs] Merge #559
559: Update wgpu with the polygon modes support, use in the cube example r=cwfitzgerald a=kvark

Uses https://github.com/gfx-rs/wgpu/pull/921, cc @manuel-woelker

Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2020-09-11 20:04:31 +00:00
Dzmitry Malyshau
dd850b8156 [rs] Use implicit bind group layout in the mipmap example 2020-09-10 23:59:52 -04:00
Dzmitry Malyshau
72ab5f2809 [rs] Update wgpu with the polygon modes support, use in the cube example 2020-09-10 22:02:05 -04:00
bors[bot]
9edf44118e [rs] Merge #557
557: Pin web-sys version r=grovesNL a=rukai

As mentioned in https://github.com/gfx-rs/wgpu-rs/pull/553 this will prevent the wasm build from breaking.
@grovesNL Is pinning just web-sys and wasm-bindgen sufficient?

Co-authored-by: Rukai <rubickent@gmail.com>
2020-09-10 22:43:34 +00:00
Rukai
0c213ec85d [rs] Pin web-sys version 2020-09-10 23:10:07 +10:00
bors[bot]
93ac56514a [rs] Merge #553
553: Add hello-windows example r=kvark a=qthree

# `hello-windows`
## Description

This is demonstration of ability to create multiple windows with differently colored backgrounds.

## Screenshot
![screenshot](https://user-images.githubusercontent.com/9898555/92568685-bc411c80-f2a9-11ea-9d4d-84bb236c40f9.png)

# `shared-textures` (old version)
## Description

This is demonstration of ability to create multiple windows and share single texture across all of them.
Available in ad3030ae8f61e3ea3f7b913cd03c366119d058fb commit.

## Screenshot
![screenshot](https://user-images.githubusercontent.com/9898555/92500037-cc63e800-f226-11ea-8f50-bfa02538cce5.png)


Co-authored-by: qthree <qthree3@gmail.com>
2020-09-10 04:34:35 +00:00
bors[bot]
67ee3d6678 [rs] Merge #555
555: Update to latest web-sys r=kvark a=grovesNL

Cherry-pick #497 into `master` now that new versions of web-sys/wasm-bindgen/js-sys/wasm-bindgen-futures are published.

We could also do this for `v0.6` too if we want CI to succeed there, or alternatively consider disabling CI for wasm builds on `v0.6`.

Co-authored-by: Joshua Groves <josh@joshgroves.com>
2020-09-10 04:25:18 +00:00
Joshua Groves
9d48bc26c0 [rs] Update to latest web-sys 2020-09-10 01:09:50 -02:30
qthree
5338992913 [rs] Add hello-windows example 2020-09-10 06:55:42 +07:00
bors[bot]
cc33e622cf [rs] Merge #551
551: Replace unsafe impl Pod with safe derive r=kvark a=rukai

bytemuck now includes derives that will implement the Pod trait, failing to compile if the struct cannot safely be a Pod.
Lets use it to remove most of the unsafe usage from the examples.
closes https://github.com/gfx-rs/wgpu-rs/issues/190

Co-authored-by: Rukai <rubickent@gmail.com>
2020-09-08 13:40:45 +00:00
Rukai
3cfb3295cb [rs] Replace unsafe impl Pod with safe derive 2020-09-08 23:39:12 +10:00
Dzmitry Malyshau
c69b03d32f [rs] Update wgpu to the latest DX11 fix 2020-09-06 20:41:24 -04: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
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]
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]
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]
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
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