Commit Graph
8897 Commits
Author SHA1 Message Date
João Capucho 67ef37ae99 Add support for 'break if' to IR, wgsl-in, and all backends. 2022-06-24 17:47:07 -07:00
victorvde 7375acb230 get_supported_formats: sort like the old get_preferred_format and simplify return type (#2786)
* get_supported_formats: sort srgb first like the old get_preferred_format

* get_supported_formats: simplify return type
2022-06-22 21:04:18 +00:00
Nicolas Silva 5dcd19c167 Add a vulkan workaround for large buffers. (#2796)
* Add Limit::max_buffer_size.

* Prevent very large buffer with some drivers.

Some drivers run into issues when buffer sizes and ranges are larger than what fits signed 32 bit integer. Adapt the maximum buffer size accordingly.
2022-06-22 12:31:53 -04:00
Nicolas Silva a9f1b4f8e0 Add create_texture_error. (#2800)
Firefox needs it to implement WebGPU's error model (see create_buffer_error).
2022-06-22 12:58:37 +00:00
Kevin Reid 2881a74de9 Fix formatting of TextureDimensionError::LimitExceeded. (#2799)
in the thiserror error format string, `{0:?}` ends up referring to the
first named argument, not the first struct field or a compile error, so
the error was incorrectly
    Dimension 32768 value 32768 exceeds the limit of 16384
instead of
    Dimension X value 32768 exceeds the limit of 16384
2022-06-21 21:46:12 -04:00
Connor Fitzgerald 7df4fd1cd4 Use FIFO swapchain in examples 2022-06-20 23:15:28 -07:00
Ashley ea832a9eec [glsl-out] Handle vector bitcasts (#1966)
* [spv-in] Fix bitcasts on non-scalars

* Fix ::As handling in glsl

* Cargo fmt

* Make cargo clippy happy

* Add snapshot tests

* Use write_type_value

* target_vector_kind -> target_vector_type
2022-06-20 22:25:13 -07:00
Rajveer Malviya f27a9788fd fix BufferMapCallbackC & SubmittedWorkDoneClosureC (#2787) 2022-06-18 16:55:24 +00:00
StevenandConnor Fitzgerald 0d4d3f4ceb Change get_preferred_format to get_supported_formats (#2783)
* Change all the functions

* Return the set of supported TextureFormat specified by WebGPU

* Remove redundant filtering and use list directly

* Replace pops with first

* Remove now unused function

* Fix doc and clarify preffered format

* Dereference enums

* Remove unused list

* Remove fancy coode

* Update wgpu-core/src/device/mod.rs

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>

Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-18 00:21:02 -04:00
Jim Blandy aba7197fe8 Update Naga to 0b60f410 (Thu 2022-6-16). (#2779) 2022-06-17 16:51:22 -04:00
João Capucho 6d78f1c06d hlsl-out: Fix indentation for continuing block
The continuing block in hlsl was being generated with the same indentation as the loop body
2022-06-17 16:34:23 +02:00
João Capucho cafdb160ae glsl-out: Fix indentation for continuing block 2022-06-17 16:17:22 +02:00
teoxoy 89f24b6cfe [msl-out] insert padding initialization for global constants 2022-06-17 10:55:28 +02:00
Jinlei Li f4c01052ef Rename MAX_COLOR_TARGETS to MAX_COLOR_ATTACHMENTS to match spec 2022-06-16 20:36:15 -07:00
Jim Blandy 0b60f410ab [wgsl-in] Restore error in the case of bad scalar widths. 2022-06-17 01:31:59 +02:00
teoxoy ad536ce0df [wgsl-in] remove unused code 2022-06-16 12:13:08 -07:00
teoxoy 531d563f0e [wgsl-in] implement complete validation for size and align attributes 2022-06-16 12:13:08 -07:00
teoxoy 46387e90ce unify alignment related functionality 2022-06-16 12:13:08 -07:00
Jinlei Li f2c3d42818 Add InvalidGroupIndex validation at create_shader_module 2022-06-16 10:06:11 -07:00
João Capucho 357da63076 Patch ron version (#1986)
Require at least version 0.7.1 of ron, this version changed how floating points are
serialized by forcing them to always have the decimal part, this makes it backwards
incompatible with our tests because we do a syntatic diff and not a semantic one.
2022-06-15 15:17:59 -04:00
Nicolas Silva 191537021e Expose naga span location helpers (#2752)
* Expose the source location in CreateShaderModuleError.

* Bump naga dep to 89bed99.
2022-06-14 23:10:22 -04:00
Jim Blandy 6da57dd4e0 Add type annotation to render pass code, for rust-analyzer. (#2773)
This is a workaround for a limitation in rust-analyzer:
https://github.com/rust-lang/rust-analyzer/issues/12247
2022-06-14 23:06:22 -04:00
Jim Blandy 915be10443 wgpu_core::command::bundle: Consolidate pipeline and vertex state. (#2769)
Refactor `wgpu_core::command::bundle::State` to more closely resemble
the internal slots of a WebGPU `GPURenderBundleEncoder`, and add
validation required by the WebGPU specification.

Use `Option` to represent state that may be left unset on the encoder:
specifically, the pipeline and vertex buffers. (Previous commits have
already addressed index buffers and bind groups.) Use `.ok_or`, etc.
for unwrapping, to ensure that encoding state errors are reported.

Consolidate state derived from the pipeline in a new `PipelineState`
struct.

Remove `wgpu_core::command::bundle::PushConstantState::is_dirty`; just
represent push constant state as a vector of `PushConstantRange`
values. It's sufficient to simply zero the push constants whenever the
vector is non-empty.

Rename `bundle::State::flush_push_constants` to `zero_push_constants`a.
This is not a "flush pending state changes" function like all the
others; it just ensures that each pipeline's push constant state is
initialized.
2022-06-14 23:06:05 -04:00
Ashley Ruglys 5c8d4a8c80 Change WEBGPU_TEXTURE_FORMAT_SUPPORT to 1 << 14 instead of 1 << 13 2022-06-14 19:01:49 -07:00
João Capucho 98bc8fedf9 Apply comments 2022-06-14 16:04:08 -07:00
João Capucho ae58fbf4d0 Add tests 2022-06-14 16:04:08 -07:00
João Capucho 70743ee7dc glsl-in: Perform casts in int only math functions
Some functions like abs only accept signed integers while naga's IR
accepts both signed and unsigned integers, this wasn't accounted for in
the glsl backend causing it to produce code that wouldn't type check.

This commit addresses it by performing casts from uint to int of the
function argument and then back from int to uint for the function
return.
2022-06-14 16:04:08 -07:00
João Capucho ae50f31d4f glsl-in: Don't allow empty last case in switch
The GLSL spec forbids switch statements with an empty last case, so we
check that now and throw an error if necessary
2022-06-14 22:31:27 +01:00
João Capucho dab932e8ce glsl-in: Fix last case falltrough and empty switch
GLSL allows the last case of a switch statement to not have a `break`
statement causing it to be marked as fall-trough, naga's IR on the other
hand doesn't allow the last case to be fall-trough, this is fixed by
force marking it in the glsl frontend as not fall-trough.

GLSL also allows empty switch statements and without default cases,
naga's IR requires there be a default case, this is fixed by adding an
empty default case in the glsl frontend if no default case was present
in the switch statement.
2022-06-14 22:31:27 +01:00
João Capucho 52bb25179b glsl-in: Splat inputs for smoothstep if needed
Glsl defines two overloads for smoothstep that accept `min` and `max` as
scalars and the value as a vector, naga's IR is stricter and only allows
operators with the same dimensions, so this inputs must be splatted.
2022-06-14 13:15:08 -07:00
João Capucho c7e6769001 Add tests 2022-06-14 13:14:43 -07:00
João Capucho 46bc882d19 msl: don't rely on cached expressions
Expressions marked for caching might not be cached, this can happen for
example when these expressions are pre emitted (for example Contants).
2022-06-14 13:14:43 -07:00
João Capucho b5a046982f glsl-out: don't rely on cached expressions
Expressions marked for caching might not be cached, this can happen for
example when these expressions are pre emitted (for example Contants).
2022-06-14 13:14:43 -07:00
João CapuchoandJasper St. Pierre 81e2b006e1 glsl-in: Add test for nested depth texture calls
Co-authored-by: Jasper St. Pierre <jstpierre@mecheye.net>
2022-06-14 13:11:30 -07:00
João Capucho 3d3e5ae00d glsl-in: Fix parameter not changing to depth
The conversion from sampled images to depth changed the `argument` type
but didn't change the `parameter` type (`argument` without pointer
indirection) causing 2+ deep propagation of depth images with function
arguments to fail.
2022-06-14 13:11:30 -07:00
teoxoy 0a6b0e5b71 update changelog for v0.9 2022-06-14 11:47:39 -07:00
Jinlei Li 006bbbc94d Update the Supported Platforms table in README (#2770) 2022-06-14 05:04:14 +00:00
Jim Blandy b30b445423 Clarify docs for wgpu_core's Id and gfx_select!. (#2766)
Clarify that `gfx_select!` is not specific to `hub::Global`.

Clarify that the `T` in `id<T>` is not a real resource type.
2022-06-14 00:46:58 -04:00
Jim Blandy fd22c7f269 Increase max_outliers on wgpu water example reftest. (#2767)
The example says:

    Using AMD RADV POLARIS12 (Vulkan)

The test says:

    thread 'water' panicked at 'Image data mismatch! Outlier count 464 over limit 460. Max difference 213', wgpu/examples/water/../../tests/common/image.rs:134:13

I checked the `water-difference.png` file, and it's just a few dots
here and there. The example seems to run fine.
2022-06-14 00:45:23 -04:00
Ashley a880eb9642 [WebGL] Add a downlevel capability for rendering to floating point textures (#2729)
* Add a downlevel capability for rendering to floating point textures

* Rename capabilities to _capabilities

* Run cargo fmt

* Pass downlevel_flags to the adapter

* Add wgt::DownlevelFlags::COLOR_ATTACHMENT_FLOAT to dx11

* Remove downlevel_flags from the adapter and use is_ext_color_buffer_float_supported instead

* Add DownlevelFlags::WEBGPU_TEXTURE_FORMAT_SUPPORT

* Apply suggestions
2022-06-14 00:43:56 -04:00
Jim Blandy 3a193ec3d3 Introduce VertexStep: a stride and a step mode. (#2768)
This is used in various places around render pipelines, passes, and
bundles.

The public `wgpu_core::pipeline::VertexBufferLayout` could use
`VertexStep` as well, but I think it's best to let that continue to
resemble `GPUVertexBufferLayout`.
2022-06-14 00:42:03 -04:00
Jim Blandy a4352a1dac Improve push constant documentation, including internal docs. (#2764) 2022-06-11 15:11:06 -04:00
StevenandConnor Fitzgerald df1472d4a3 Fix bunnymark test screenshot and replace rand with nanorand (#2746)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-10 21:44:27 +00:00
Nicolas Silva 629ccaf4e0 Align the validation of Device::create_texture with the WebGPU spec (#2759) 2022-06-10 16:02:49 -04:00
Jinlei LiandConnor Fitzgerald 048a420d82 Remove the default features from wgpu-info (#2753)
Co-authored-by: Connor Fitzgerald <connorwadefitzgerald@gmail.com>
2022-06-10 19:57:06 +00:00
Jim Blandy 498842f993 Expect shader_primitive_index tests to fail on AMD RADV. (#2754)
On Fedora, mesa-vulkan-drivers 22.0.3 AMD RADV POLARIS12 just colors
both the NE and SW corners red. There's no blue. (NW and SE are white,
as expected.) I suspect
this means that the primitive ID is always being passed as zero.

This is probably not just due to a difference in rasterization: I
tried enlarging the texture to 4x4 and shifting the triangles to
ensure that there was a pixel in each quadrant that was fully covered.

With Vulkan "llvmpipe (LLVM 14.0.0, 256 bits)", the unmodified test passes.

This is probably limited to Linux, but
`wgpu_tests::common::TestParameters` doesn't have a slot for that.

Fixes #2751.
2022-06-10 15:44:25 -04:00
Jim Blandy b2cc6ff185 Move RenderBundleEncoder::finish's pipeline layout id into the state. (#2755) 2022-06-10 15:41:32 -04:00
i509VCB e0327b1db7 expose vulkan physical device capabilities, enabled device extensions (#2688) 2022-06-10 15:32:52 -04:00
teoxoy 53aa3e2df5 [wgsl-in] overhaul number lexing / parsing
Bring the lexer's parsing of numeric literals in line with the WGSL
specification as of 86a23b83 (2022-05-10).
2022-06-10 10:36:07 -07:00
Jim Blandy f94f25f355 Fix documentation links. 2022-06-09 17:42:03 -07:00