- 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.
* 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
- 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.
- 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
- 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>
- 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.
* 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!
* 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.
- 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.
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.
- 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.
* WIP: Render API v2
* Fix doctests
* Expose all of PixelsContext (#110)
* Fix ScalingRenderer::new() taking &mut Device
* Replace getters with direct access to &mut PixelsContext
* Fix wrong reference type
* Fix unneeded mut
* Remove unnecessary mutable borrow, resurrect the shorter getter methods
* Initial port to wgpu master (0.6)
Surface creation is broken (see examples)
Does not support compressed textures
* Fix SurfaceTexture and examples
* Add support for compressed texture formats
* resize doesn't need mutability
* Update documentation
* Update wgpu
* Prepare release
* Goodbye Travis! Thanks for all the fish
Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
* Add a method to convert cursor coords to pixel coords
* Add method `window_pos_to_pixel` to Pixels struct
* Converts cursor / window physical coordinates to pixel coords
* Fix formatting
* Return result rather than clamping pixel coordinates
* Use transformation matrices to convert from cursor coord to pixel
* Adds a struct ScalingMatrix that manages the creation and usage
of the transformation matrix used in the renderer.
* Added an inverse function on ScalingMatrix - 4x4 matrix inverse
(This should probably use a library, but it doesn't seem worth
adding a dependancy for one function)
* Optimize matrix multiplication for cursor position calculation
* Use ultraviolet for matrix and vector math
* Add suggested changes
This keeps the split between usize and isize
This also changes the input cursor position to f32, because it was
immediately cast to an f32 for the transformations.
* Add builder methods for VSync and setting wgpu backends
* enable_vsync sets the VSync mode
* wgpu_backend sets the wgpu BackendBit struct
* Made RequestAdapterOptions use compatible_surface by default
* Internally store wgpu::PresentMode for enabling vsync
This doesn't expose the PresentMode for the external api, because
the variants of PresentMode aren't very obvious to people without
wgpu experience. Mailbox corresponds to VSync enabled, and
Immediate corresponds to VSync disabled.
* Move all examples to individual crates
* CI: Add libsdl2
* Use Ubuntu bionic for updated libsdl; 2.0.8
* Clippy
* libudev-dev is a dependency of libsdl2-dev
* Clippy
* Remove unnecessary dev-dependency
* `winit` is actually used in unit tests
* Fix a typo
* Move `simple-invaders` crate
* remove unsafe slice::from_raw_parts
this should be a way to remove the unsafe code in the Spirv Deref impl.
Not sure how it affects performance yet.
I will take a look at the bytecode and see if maybe the compiler is
smart enough to optimize that away.
* change renderers to accomodate new Deref
Let the deref return a `Vec<u32>` instead of a slice reference. This
should not hurt performance too much as this will be done a finite
amount of times att startup.
* replaced deref with normal impl
* fixed endianness, fixed offset + rustfmt
* bump version
* fixed clippy lints
* respect the target endianness
* use wgpu::read_spirv()
* remove an unneccessary allocation of a vec
* move borrow into macro