Commit graph

98 commits

Author SHA1 Message Date
erin petra sofiya moon 763a7a9b41
update wgpu to 0.17 (#378)
required changes are entirely trivial:
wgpu::util::initialize_adapter_from_env's signature changed;
the backend_bits parameter is removed, and now solely specified by
the instance's enabled backends (see [the changelog](https://github.com/gfx-rs/wgpu/blob/trunk/CHANGELOG.md#initialize_adapter_from_env-argument-changes)).
2023-10-29 23:49:07 -05:00
Kanabenki 705f22b60d
Add present mode setters on Pixels (#373)
* Add present mode setters on Pixels

* Add present mode getter on Pixels
2023-08-09 13:36:12 -07:00
Jay Oster 3891192796
Update dependencies (#337)
Breaking changes:

- Updates `wgpu` to 0.16
2023-06-11 21:25:25 -07:00
Jay Oster 9f0a659853
Enable all wgpu backends (#356)
- This will allow `pixels` to run on platforms that have OpenGL without any extra configuration.
- It is better to allow wgpu to fallback to OpenGL than to select a Vulkan software rasterizer. This is the case on WSL2, where the only hardware-based adapter is available with the GLES backend.
- Fixes #354
2023-04-14 13:31:01 -07:00
Jay Oster 5a96eea6ba
Handle all wgpu::SurfaceError variants (#348)
This fixes error handling for all `wgpu::SurfaceError` variants. It also adds more context to error messages printed by the examples.

Closes #346
2023-03-21 07:16:51 -07:00
Jay Oster 899e27bafa
Remove get_ and set_ prefixes from public APIs (#341)
This renames:

- `get_frame` to `frame`
- `get_frame_mut` to `frame_mut`
- `set_clear_color` to `clear_color`

Which more closely follows convention set by the standard library et al.
2023-03-09 19:42:57 -08:00
Aggelos Tselios bbfd49deba
Add wgpu adapter getter API (#340)
Co-authored-by: Jay Oster <jay@kodewerx.org>
2023-03-07 17:39:02 -08:00
Jay Oster 860559272a
Simplify surface texture format selection (#336)
- We require sRGB because that's the color space users expect when they are plotting their own pixels.
- It simplifies the fragment shader because we don't have to do a linear->gamma transformation. The hardware will do it for us.
2023-01-28 11:34:25 -08:00
Jay Oster eede10ba42
Fix validation errors with WebGL2 backend (#335)
* Fix validation errors with WebGL2 backend

- view_formats are optional and should be empty unless a specific view format is needed.
- See: https://www.w3.org/TR/webgpu/#dom-gputexturedescriptor-viewformats
2023-01-28 11:19:45 -08:00
Jay Oster 332a02f12d
Update wgpu to 0.15 (#332)
* Update wgpu to 0.15
* Fix the panic described in #330
* Specify `min_binding_size` since we know what it is.
2023-01-27 21:49:40 -08:00
Jay Oster 6f4fa6c967
Fix invalid texture sizes (#250)
- Makes methods fallible when they create textures.
- Correctly handle window resize in fltk example.
- TODO: tests
- Closes #240
2022-12-17 20:21:28 -08:00
Jay Oster b4fc48c740
Change default PresentMode and update enable_vsync (#325)
- Fixes #263
2022-12-17 19:06:15 -08:00
David Cristofaro e8d5cf3ebc
Bump wgpu from 0.13 to 0.14 (#320)
* feat(wgpu): upgrade wgpu from 13 to 14

* Address feedback

* Bump tao in `minimal-tao` example

* Bump fltk in `minimal-fltk` example

* Bump egui in `minimal-egui` example

* Bump MSRV to `1.65`

* Bump crates in `imgui-winit` example

* Delete `minimal-sdl2` example

* Fix clippy lints

* Update examples/minimal-egui/src/gui.rs

Co-authored-by: Zageron <hello@zageron.ca>
Co-authored-by: Jay Oster <jay@kodewerx.org>
2022-12-17 13:50:11 -08:00
Jay Oster 051a523ee6
Update wgpu to 0.13 (#300)
* Intial work towards wgpu 0.13

* Increase MSRV for egui

* Add missing texture formats

* Update fermium

- Replaces beryllium with our own hand-rolled high-level abstraction
  layer for SDL2.

* Update dependencies

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
2022-08-17 17:30:04 -07:00
Alex 0b380b637d
Allow accessing frame on immutable buffer (#288)
* Allow accessing frame on immutable buffer

* Rename `get_frame` to `get_frame_mut`

* Use `get_frame_mut` in examples
2022-08-14 15:44:23 -07:00
JMS55 94a2cc2dbd
Make BlendState configurable (#260) 2022-02-06 03:01:50 -08:00
AnonymousDapper ebf7179a89
Decouple render_texture_format from surface texture format (#249) (#257)
- Closes #249
2022-01-15 20:31:18 -08:00
Jay Oster c1962ae35c
Update dependencies (#230)
* Move to Edition 2021
* Update `wgpu`, `raw-window-handle`, and all dependencies for the examples
* Update MSRV
* Closes #244
2021-12-31 14:57:57 -08:00
Jay Oster 4c6682e65b
Configurable clear color (#236)
- Closes #235
- Now using alpha blending (non-premultiplied) in the scaling renderer
  so that the clear color can be blended with the texture. This can be
  made configurable, but we'll go with this for now.
2021-12-05 14:23:06 -08:00
Jay Oster 2a4ebbf19d
Fix half-pixel offsets in scaling renderer (#231)
* Fix half-pixel offsets in scaling renderer

- This bug was very subtle. It can be hard to notice!
- Context: When the scaling renderer transformation matrix is created,
  it needs to center the image within the border.
- The previous code always evaluated the translation to (0, 0)
- This PR makes half-pixel adjustments to the translation when needed,
  making it impossible to rasterize the texture on a half-pixel
  boundary.
- I spotted this while working on pixel-aspect-ratio support, but it can
  most easily be witnessed in the `conway` example by grabbing the top
  or bottom resize handle on the window and slow dragging it up and down
  by 1-pixel-at-a-time. When you hit a half-pixel bug the entire texture
  will change slightly; some pixels will become hidden or duplicated.

* Bump MSRV
2021-12-01 21:36:56 -08:00
Jay Oster b2b8f1140d
Fix inverted Y-axis in window_pos_to_pixel() (#229)
- This fixes a regression caused by #228
2021-12-01 08:08:48 -08:00
Jay Oster c2454b01ab
Simplify vertex attributes (#228)
- Vertex UVs can be computed from the positions, which saves a small amount of code and a small amount of bandwidth (both inconsequential).
- This is mostly for readability.
- Fixes vertically-flipped pixel buffer in the `custom-shader` example.
2021-11-20 14:06:23 -08:00
Jay Oster b185ec32e9
Initial WebGL2 support. (#218)
Co-authored-by: MarkAnthonyM <37249494+MarkAnthonyM@users.noreply.github.com>
2021-11-16 11:37:56 -08:00
Jay Oster acd42495f2
Use adapter limits (unless overridden) (#226)
- Fixes a regression caused by #223
- `downlevel_webgl2_defaults` only supports 2048x2048 pixels buffers
- This will allow pixel buffers up to the max supported by the hardware
2021-11-14 17:20:57 -08:00
Jay Oster 6662fec55b
Set default device limits to downlevel_webgl2_defaults (#223)
- Fixes #139
- See also #115
2021-11-12 11:01:32 -08:00
Jay Oster 0fc722e011
Refactor public API (#222)
* Simplify constructor return types

* Render methods do not need an exclusive borrow
2021-11-08 20:03:38 -08:00
Jay Oster 5b00f7e32f
Make SurfaceSize private (#220)
- This struct is only used internally. No need to make it public.
- Technically a breaking change, so this will bump the SemVer.
2021-11-02 22:05:10 -07:00
Jay Oster 0295a54e30
Prepare 0.7.0 (#210) 2021-10-08 12:11:43 -07:00
JMS55 800dd931b7
Update to wgpu 0.11 (#209)
Co-authored-by: Jay Oster <jay@kodewerx.org>
2021-10-08 11:49:51 -07:00
Jay Oster c94dab65b7
Use wgpu environment variables (#198)
- Enables projects using `pixels` to select GPU and backend with
  the same environment variables used by `wgpu` examples.
- cc #142
2021-09-04 15:26:30 -07:00
Jay Oster 50c77a5f83
Add Send + Sync bounds for user-defined errors (#197)
- This enables compatibility with anyhow and the async ecosystem
2021-09-04 14:41:43 -07:00
Jay Oster db00a67c60
Add user-defined errors for render functions (#196)
- Fixes #189
2021-09-04 09:00:25 -07:00
Jay Oster b00c65fc55
Properly clip pixel buffer when larger than surface texture (#190)
- Fixes #186
2021-09-01 20:53:08 -07:00
Jay Oster e08c91bfd2
Update to wgpu 0.10 (#187)
- It would be nice to return an error from the render function
- imgui-winit is still a WIP (open PR: https://github.com/Yatekii/imgui-wgpu-rs/pull/66)
- Update README

Co-authored-by: Mohammed Alyousef <mohammed.alyousef@neurosrg.com>
2021-09-01 14:50:43 -07:00
Jay Oster 288da3675f
Use the swapchain-preferred texture format by default (#182)
- Fixes #140
- Adds a public method to get the current GPU framebuffer texture format (AKA the render texture format).
- This wasn't as difficult as it seemed; the extra API is used by the examples to get the right texture format instead of being hardcoded.
2021-07-17 08:21:49 -07:00
Jay Oster c4df23f65d
Update to wgpu 0.9 (#179)
* Update to wgpu 0.9

* Fix validation error in WGSL shader

- This moves the hardcoded vertex positions and texture coordinates to
  the vertex buffer.
- Replaces the two-triangle quad to 1 full-screen triangle (fixes #180)
- Rewrites the custom shader example to fix a bug with large surface
  textures;
  - The input texture size was used for the output texture, causing the
    purple rectangle to appear very jumpy on large displays in full screen.
- The `ScalingRenderer` now exposes its clipping rectangle. The custom
  shader example uses this for its own clipping rectangle, but it can
  also be used for interacting with the border in general.

* Switch to `wgpu::include_wgsl!()`

- This is a nice little simplification.
- Thanks to @JMS55 for the suggestion!
2021-06-27 11:09:29 -07:00
Jay Oster 338a63a40e
Minor improvement: only one shader module is necessary (#175) 2021-06-08 07:09:58 -07:00
Jay Oster 8d77ac2f8b
Rewrite shaders in WGSL (#172)
- Fixes #141
2021-06-05 18:40:33 -07:00
Jay Oster cdcfe57868
Validate width and height inputs (#162)
* Validate width and height inputs

- Fixes #157

* Add window size check to `imgui-winit` demo

- There is really nothing better that can be done in this case.
- The surface, buffer, and world sizes must all be non-zero.
- A zero-length surface would (previously) panic in `wgpu`.
- A zero-length buffer would panic with the new assertions.
- A zero-length world would cause a divide-by-zero panic when drawing.
2021-05-08 17:26:21 -07:00
Jay Oster f238814d12
Update wgpu to 0.8 (#160)
- Also update other dependencies
2021-05-07 23:52:11 -07:00
Jay Oster 9bfed17a7f
Various fixes (#154)
* Cargo clippy

* Fix typo
2021-03-29 00:52:43 -07:00
JMS55 11c5961e4c
Use default() when making wgpu::RenderPipelineDescriptor (#152) 2021-03-11 18:14:34 -08:00
Jay Oster 8071f34a1f
Rename resize to resize_surface (#149)
- Also cleanup documentation.
- Workaround FLTK window resize issues by disabling resizability.
2021-03-09 04:15:24 -08:00
Jay Oster 5dbe87d0c0
Fix matrix when creating a scaling renderer (#143)
- This issue can be seen when creating a window and pixel buffer that have differing sizes; the image will be stretched to fill the window.
- If the window supports the resize callback to correct the image aspect ratio, resizing the window will correct the matrix immediately, adding the black border as expected. This is a jarring effect when the texture size ratio is not an integer.
- This bug also causes issues with the new `resize_buffer()` API.
2021-03-03 10:45:14 -08:00
JMS55 f2d4a4f084
Upgrade to wgpu 0.7 (#134)
Co-authored-by: Jay Oster <jay@kodewerx.org>
2021-02-28 15:29:36 -08:00
Jay Oster 0709161e02 Remove commented code 2021-02-28 14:08:41 -08:00
Josh 26ae25c3d8
Resize buffer (#136)
- Fixes #125
2021-02-28 14:05:28 -08:00
Jay Oster 70ff52948b
Refactor builder (#128)
* Refactor PixelsBuilder into its own module

* Remove HasRawWindowHandle from public interface
2020-12-13 19:15:00 -08:00
schnippl0r fb243b8973
Expose new API method render_texture_format(). (#123)
This method is needed to let the user of the API configure the texture
format of the target texture/render texture that the surface texture is
rendered on. This texture format is hardware/platform dependent.

For example, this method makes it possible to use the pixels crate on
Android because Android seems not to use the previously hard-coded
texture format wgpu::TextureFormat::Bgra8UnormSrgb.
2020-12-10 18:40:06 -08:00
Jay Oster b6526c27e5
Remove pixels-dragons (#114)
- I don't want to publish this crate.
- Can't publish pixels 0.2.0 if it depends on an internal unpublished crate.
- This requires allowing unsafe code, and removing the safety dance badge.
2020-08-20 17:19:40 -07:00