Commit Graph
9013 Commits
Author SHA1 Message Date
initial-algebra 602368d9f0 Support builtin(primitive_index) (#1097)
* Hack in support for PrimitiveID on Vulkan

* Rename to PrimitiveIndex and add preliminary support for GLSL, HLSL and MSL

* Implement as an extra WGSL built-in

* Update extra.wgsl outputs

* Run rustfmt; fix WGSL writer

* Add rustfmt changes I forgot

* Update extra.wgsl test output for WGSL fix

* Bump macOS version to 10.15 in validate-msl to support primitive_index
2021-07-16 22:18:20 -04:00
Joshua Groves cd12afa1db webgpu: remove naga dependency 2021-07-16 22:12:21 -02:30
Joshua Groves 4b7dac0e43 webgpu: pass wgsl directly 2021-07-16 22:11:59 -02:30
bors[bot]andDzmitry Malyshau 6fa8845465 Merge #1673
1673: hal/vk: relay semaphore r=Ralith a=kvark

**Connections**
Somewhere on the Matrix, by @pythonesque

**Description**
Vulkan (somewhat confusingly) requires semaphore synchronization between `vkQueueSubmit` and `vkQueuePresent` *even if* it's done on the same queue.
This PR exercises a dumb idea of just keeping one binary semaphore as a "relay" between all queue commands, all concealed within hal/vk backend.

**Testing**
Running Halmark shows that all the things break here. I'm not seeing anything particularly wrong with the code though. My humble guess is that AMD driver (at least) isn't happy about the mix of binary and timeline semaphores used together in the same signal operation.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-16 21:55:37 +00:00
Dzmitry Malyshau 5419947095 hal/vk: relay semaphore 2021-07-16 17:55:03 -04:00
Dzmitry Malyshau 8eef784416 WGSL: Flip true/false arguments of select() 2021-07-16 11:42:12 -04:00
Igor Shaposhnik 10a3a6a827 [glsl-out] Write sint array size 2021-07-16 10:59:27 -04:00
Gordon-F 4ef754bb9d [hlsl-out] Enable image snapshot 2021-07-16 10:31:01 -04:00
Gordon-F 03a5ef3a2f [hlsl-out] Implement all texture functions 2021-07-16 10:31:01 -04:00
Gordon-F c5acef791d [hlsl-out] Add module documentation 2021-07-16 10:31:01 -04:00
Gordon-F 2716d368a1 [hlsl-out] Implement barrier statement 2021-07-16 10:31:01 -04:00
bors[bot]andConnor Fitzgerald 6c711adb9b Merge #1671
1671: Use EGL_KHR_gl_colorspace for srgb if available r=kvark a=cwfitzgerald

**Connections**

Fixes #1667 

**Description**

Uses the extension to provide SRGB if needed relevant.

I also promoted the log message about missing robustness to a warning because it is a safety issue.

**Testing**

Tested on rpi and haswell.


Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-07-16 05:05:39 +00:00
Connor Fitzgerald 0f84c7cf6e Use EGL_KHR_gl_colorspace for srgb if available 2021-07-16 01:03:18 -04:00
bors[bot]andxiaopengli89 22a81de6a9 Merge #1665
1665: (macOS/iOS) readWriteTextureSupport is support on macOS 10.13+ / iOS 11.0 r=kvark a=xiaopengli89

```
[MTLIGAccelDevice readWriteTextureSupport]: unrecognized selector sent to instance 0x7f97d1070a00
```
https://developer.apple.com/documentation/metal/mtldevice/2887289-readwritetexturesupport?language=objc


Co-authored-by: xiaopengli89 <x.friday@outlook.com>
2021-07-15 15:07:38 +00:00
xiaopengli89 6e63964e51 fix: readWriteTextureSupport is support on macOS 10.13+ / iOS 11.0 2021-07-15 14:40:05 +08:00
bors[bot]andDzmitry Malyshau e1392a3525 Merge #1664
1664: hal/dx12: reset scissor and viewport r=kvark a=kvark

**Connections**
Follow-up to #1602 that actually makes it render!

**Description**
"hello-triange" and "msaa-line" examples work now.
Everything else is blocked on Naga's HLSL output, starting from https://github.com/gfx-rs/naga/pull/1086

**Testing**
Ran the examples :)


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-15 06:13:05 +00:00
Dzmitry Malyshau b98cba9bfd hal/dx12: reset scissor and viewport 2021-07-15 02:10:28 -04:00
bors[bot]andDzmitry Malyshau a4a90c09f4 Merge #1663
1663: hal/dx12: flip the root signature upside down r=kvark a=kvark

**Connections**
Another follow-up to #1602

**Description**
Apparently, Microsoft recommends putting most frequently changed stuff at the bottom of root signature.

**Testing**
Unable to test yet.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-15 06:00:18 +00:00
Dzmitry Malyshau e2bd9c935c hal/dx12: flip the root signature upside down 2021-07-15 01:37:49 -04:00
bors[bot]andAndreas Fischer eb68c5ec8b Merge #1662
1662: [Docs] Removed metal from platforms that support multi draw indirect r=cwfitzgerald a=Vengarioth

**Connections**
Discussed on [matrix](https://matrix.to/#/!XFRnMvAfptAHthwBCx:matrix.org/$3mJo3ZEKOBzWs9CpgSJDo_iyynZpZlYinW9Xqp3aeVs?via=matrix.org&via=kyju.org&via=mozilla.org).

**Description**
Removed metal from the platforms that support multi draw indirect

**Testing**
`cargo test --doc`


Co-authored-by: Andreas Fischer <opensource@deviru.de>
2021-07-15 05:26:08 +00:00
Andreas Fischer 6514b22145 Removed metal from platforms that support multi draw indirect 2021-07-15 07:20:21 +02:00
bors[bot]andDzmitry Malyshau 37bf7d8409 Merge #1661
1661: dx12/hal: invalidate root elements on signature change r=kvark a=kvark

**Connections**
A follow-up to #1602, which I hesitated to implement, but now it doesn't sound like there is any choice we have.

**Description**
D3D12's root signature is internally mapped to device's physical descriptors. But this mapping isn't guaranteed to have any properties. That is, any changes to the root signature mean that all of the bound resources need to be invalidated...

It's a bit unfortunate. gfx-backend-dx12 did a lazy flushing approach at draw call. In wgpu-hal I tried to be more aggressive, and we are rebinding everything as it goes. We can choose to go lazy if we want - this PR introduces the necessary logic and infrastructure to do so.

**Testing**
Untested.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-15 03:24:30 +00:00
Dzmitry Malyshau 22fff526ab dx12/hal: invalidate root elements on signature change 2021-07-14 23:13:08 -04:00
Jasper St. Pierre 0995c7161e [glsl-in] Keep around extra linkage variables
WGSL will require this. Note that this still might
cause some issues with multi-entry-point GLSL
that I didn't know how to handle. That is, we will
handle unused builtin inputs but not unused
builtin outputs correctly right now. This is an existing
issue though, not a regression.

This is also provided as an option, but I feel like
the more correct approach is to never strip linkage
variables. We'll see though.
2021-07-14 17:48:54 -04:00
Jasper St. Pierre 0b69aa8b8a Init env_logger in snapshots tests
For debugging. Maybe there's a way to do it for all tests,
not sure...
2021-07-14 17:48:54 -04:00
bors[bot]andConnor Fitzgerald 93e1eb8091 Merge #1658
1658: Removes nightly from bors r=kvark a=cwfitzgerald

**Connections**

Following up on the trouble #1654 had merging. We actually shouldn't force bors to wait for nightly to work.

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-07-14 20:22:54 +00:00
Connor Fitzgerald 03b2ba1cb3 Removes nightly from bors 2021-07-14 16:21:26 -04:00
Dzmitry Malyshau d85e8c6011 Clippy fixes 2021-07-14 16:17:39 -04:00
Dzmitry Malyshau 509b683e6b hal: renderdoc integration 2021-07-14 16:17:39 -04:00
bors[bot]andBoris-Chengbiao Zhou 0a81cb08bf Merge #1657
1657: hal: Fix copy-paste error in texture copy dimensions r=cwfitzgerald a=Bobo1239

**Testing**
My textures aren't cut off past the square anymore ^^
![2021-07-14_19-57-06_grim](https://user-images.githubusercontent.com/2302947/125669952-121b4da9-6f2f-4cf9-b4c3-b2f3bf081114.png)
![2021-07-14_19-50-38_grim](https://user-images.githubusercontent.com/2302947/125670442-351ebde1-e8d3-4be0-accf-5395537fc3b8.png)


Co-authored-by: Boris-Chengbiao Zhou <bobo1239@web.de>
2021-07-14 18:06:51 +00:00
Boris-Chengbiao Zhou 783c85e264 hal: Fix copy-paste error in texture copy dimensions 2021-07-14 19:52:57 +02:00
bors[bot]andBoris-Chengbiao Zhou 2cb2a6ed70 Merge #1655
1655: hal/vulkan: Respect swapchain's minImageCount r=kvark a=Bobo1239

**Description**
Respect `minImageCount` from the `VkSwapchainCreateInfoKHR` struct. Previously wgpu caused Vulkan validation errors like this:
```
[2021-07-14T17:15:18Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-VkSwapchainCreateInfoKHR-minImageCount-01271 (0xe18476f3)]
    	Validation Error: [ VUID-VkSwapchainCreateInfoKHR-minImageCount-01271 ] Object 0: handle = 0x5595501a6190, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xe18476f3 | vkCreateSwapchainKHR() called with minImageCount = 3, which is outside the bounds returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR() (i.e. minImageCount = 4, maxImageCount = 0). The Vulkan spec states: minImageCount must be greater than or equal to the value returned in the minImageCount member of the VkSurfaceCapabilitiesKHR structure returned by vkGetPhysicalDeviceSurfaceCapabilitiesKHR for the surface (https://github.com/KhronosGroup/Vulkan-Docs/search?q=)VUID-VkSwapchainCreateInfoKHR-minImageCount-01271)
```
(Wayland with AMD RADV POLARIS10 (ACO))

**Testing**
Validation error doesn't get emitted anymore.


Co-authored-by: Boris-Chengbiao Zhou <bobo1239@web.de>
2021-07-14 17:44:44 +00:00
Boris-Chengbiao Zhou 1ecb48db80 hal/vulkan: Respect swapchain's minImageCount 2021-07-14 19:20:17 +02:00
bors[bot]andDzmitry Malyshau 7e47f3082b Merge #1652
1652: Switch read-only storage textures to be exclusive and behind a feature r=cwfitzgerald a=kvark

**Connections**
See https://github.com/gpuweb/gpuweb/pull/1864 and https://github.com/gpuweb/gpuweb/pull/1794

**Description**
WebGPU API doesn't have RO storage textures right now. However, since `wgpu` already had a way to expose read-write storage textures, I figured we can just use it to gate read-only storage.

**Testing**
No examples currently exercise this path.


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-14 05:19:58 +00:00
Dzmitry Malyshau 8cd17aafe3 Switch read-only storage textures to be exclusive and behind a feature 2021-07-14 01:04:37 -04:00
pyrotechnick 1d1aea243f Improve WGSL interpolation attributes (#1083)
* [wgsl-in] Map interpolate(..., center) to Sampling::Center

* [wgsl-out] Improve interpolation attributes

* [wgsl] Fix tests/in/interpolate.wgsl typo/format

* [wgsl] Snapshot WGSL artefacts

* [wgsl-out] Stack-only writing of interpolation
2021-07-13 21:57:52 -04:00
bors[bot]andZicklag f11639e8ea Merge #1651
1651: Fix Vulkan Backend Texture Format Mapping r=cwfitzgerald a=zicklag

Fixes the Bgra8UnormSrgb texture format.

**Connections**
Resolves #1646.

**Description**
Fixes the mappings between the `Bgra8UnormSrgb` and `Bgra8Unorm` texture formats and their Vulkan equivalents.

**Testing**
Tested on my Ubuntu 20.04 machine on:

- Intel(R) UHD Graphics (CML GT2) (Vulkan)
- GeForce GTX 1650 (Vulkan)


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-14 01:39:40 +00:00
Zicklag 2896a6e5f3 Fix Vulkan Backend Texture Format Mapping
Fixes the Bgra8UnormSrgb texture format.

Resolves #1646.
2021-07-13 20:21:47 -05:00
0f784bb3c0 Merge #1602
1602: New DX12 backend (unfinished) r=kvark a=kvark

**Connections**
Continuation of #1471

**Description**
Mostly fresh implementation on DX12 backend for wgpu-hal
Core changes:
  - texture usage is filtered before passing to `create_texture_view`, so that wgpu-hal can assume every bit is important.
  - all the copies involving textures are limited to one array layer at a time
  - remove render pass boundary usages

**Testing**
Examples (not running yet)


Co-authored-by: Dzmitry Malyshau <dmalyshau@mozilla.com>
Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-13 22:26:44 +00:00
Gordon-F ccf3fe9707 Fix type info of texture dimensions function with texture cube parameter 2021-07-13 17:28:09 -04:00
bors[bot]andDzmitry Malyshau 2e02eefad9 Merge #1647
1647: Check for blendable flag in filtering r=cwfitzgerald a=kvark

**Connections**
Discussion on the matrix.

**Description**
The validation is written in a way that considers "filterable" to be responsible for both linear sampling and rendering.
But we didn't take blending into account when determining this filtering flag.

**Testing**
Untested


Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
2021-07-13 20:10:45 +00:00
bors[bot]andZicklag d136e0579c Merge #1645
1645: Disable Intel Fastclear in GL Backend r=kvark a=zicklag

This works around a Mesa bug on Intel cards:

- https://gitlab.freedesktop.org/mesa/mesa/-/issues/2565
- https://github.com/gfx-rs/wgpu/issues/1627#issuecomment-877854185

**Connections**
Related to pixelated edges in GL backend brought up in #1627.

**Description**
This just adds the `INTEL_DEBUG=nofc` environment variable setting when creating an `Instance` using the GL backend in `wgpu_hal`. This is just a workaround until the mesa bug is fixed.

I wanted to wait until adapters were enumerated to determine that the user wanted to use an Intel Mesa adapter, but the environment variable has to be set before the x11 display was opened so that wasn't an option.

This may not be the strategy we want to take with this one, but it seems relatively harmless. Because the environment variable prefixed with `INTEL` anyway, it might not effect devices other than the ones we want to, which would be good.

**Testing**
I tested this on Ubuntu 20.04 with Mesa Intel(R) UHD Graphics (CML GT2) on using the GL backend.


Co-authored-by: Zicklag <zicklag@katharostech.com>
2021-07-13 19:56:16 +00:00
Jim Blandy caa92ef7b9 [spv-out] Documentation for write_texture_coordinates. 2021-07-13 15:32:35 -04:00
Jim Blandy bdf792387a Document ImageLoad, ImageStore, and a few other bits. 2021-07-13 15:32:35 -04:00
bors[bot]andConnor Fitzgerald 049d94fccb Merge #1644
1644: Fix Example Resolution Limits r=kvark a=cwfitzgerald

**Connections**

Closes #1616.

**Description**

This change automatically expands resolution to the adapter's limits so examples always work.

**Testing**

Ran locally, but couldn't make it bigger than the screen



Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2021-07-13 18:10:11 +00:00
Connor Fitzgerald adcd708cf1 Fix example limits 2021-07-13 14:07:39 -04:00
Dzmitry Malyshau bbb046077e Check for blendable flag in filtering 2021-07-13 13:13:40 -04:00
Zicklag f0c7e990f7 Disable Intel Fastclear in GL Backend
This works around a Mesa bug on Intel cards:

- https://gitlab.freedesktop.org/mesa/mesa/-/issues/2565
- https://github.com/gfx-rs/wgpu/issues/1627#issuecomment-877854185
2021-07-13 11:21:06 -05:00
Aron Granberg c434b94ca2 Implicitly add COPY_DST when using create_texture_with_data (#1622)
* Implicitly add `COPY_DST` when using `create_texture_with_data`

* Always clone texture descriptor
2021-07-13 10:26:24 -04:00
Dzmitry Malyshau 0df804e9c2 hal/dx12: bunch of validation fixes 2021-07-13 02:54:37 -04:00