Commit graph

47 commits

Author SHA1 Message Date
Jay Oster e3b10ab83b
Fix the doc issue described in #80 (#99) 2020-07-19 01:56:52 -07:00
Jay Oster 7e38a7262d
Some documentation fixes. (#97) 2020-07-18 22:25:51 -07:00
Jay Oster 27e7bfe998
New render api (#96)
* Extreme WIP: New wgpu access api

* Add getters for device and queue to Pixels

* Don't run ScalingRenderer in render_custom()

* Expose Pixels::scaling_renderer

* Fix exposing ScalingRenderer

* Tweak Pixels::render_custom()

* Cleanup

* More cleanup

* Fix doc comment

* Clippy

* Fix doctests

Co-authored-by: JMS55 <47158642+JMS55@users.noreply.github.com>
2020-07-18 18:12:37 -07:00
Jay Oster 755b1fed28
Add environment variable overrides for wgpu::PowerPreference (#94)
* Add environment variable overrides for `wgpu::PowerPreference`

* Bump MSRV
2020-07-17 17:31:16 -07:00
Jay Oster b397eb4e48
Change Vsync setting to use Fifo present mode (#93)
And add a method to set `Mailbox` or other explicit modes.

Closes #88
2020-07-17 16:34:54 -07:00
Jay Oster 7779d682cf
Fix compatible_surface overrides when RequestAdapterOptions is provided (#85)
- This will use the default `compatible_surface` from `SurfaceTexture` when `RequestAdapterOptions` is configured without `compatible_surface`.
2020-06-05 02:20:17 -07:00
JMS55 4991d2cddc
Switch from futures-executor to pollster (#84) 2020-05-29 05:29:12 -07:00
JMS55 b55f75e157
Fix include_spv!() documentation (#81) 2020-05-23 16:59:11 -07:00
Aeledfyr c96e46d3d4
Add a method to convert cursor coords to pixel coords (#77)
* 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.
2020-05-20 21:37:29 -07:00
Aeledfyr b43336d45d
Add builder methods for VSync and setting wgpu backend (#78)
* 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.
2020-05-19 18:09:57 -07:00
Jay Oster 774b749145
Slim dependencies (#71) 2020-04-13 21:06:01 -07:00
Jay Oster 9de2383712
Fix dependency bloat (#67)
* 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
2020-04-13 10:12:18 -07:00
Jay Oster 37b90fe6b4
Fix transform for wgpu 0.5 (#66) 2020-04-12 23:51:04 -07:00
Bernardo Meurer 246375f0e9
treewide: bump dependencies (#60) 2020-04-12 23:13:40 -07:00
Jay Oster b38363a602
Fix CI (#58)
* Replace bespoke Error impl with `thiserror`

* cargo update

* Finix winit version in dev-dependencies
2020-03-17 20:36:08 -07:00
Jay Oster 17c94574a2
Safety dance (#50)
* Update Cargo.lock

* Forbid unsafe

* Update README
2019-11-19 22:10:08 -08:00
fuckwit c5718cc041 Remove Unsafe in macro.rs (#43)
* 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
2019-11-19 21:27:55 -08:00
Jay Oster 84d35e1205
Update wgpu to 0.4.0 (#35)
- Closes #16
- Closes #32
2019-11-03 22:07:57 -08:00
Jay Oster f19740003f Minor doc improvement 2019-11-02 23:16:26 -07:00
Jay Oster 113ffafced Use TextureFormat to show the example iterates one-byte-per-pixel 2019-10-31 20:35:54 -07:00
Jay Oster 27c4309223 Fix typo 2019-10-29 20:49:25 -07:00
Jay Oster 109d115997 Document rounding the screen size to account for non-integer HiDPI scaling factors 2019-10-27 20:36:49 -07:00
Jay Oster 4bbf9770bc Document accessing wgpu through pixels 2019-10-27 20:34:48 -07:00
Jay Oster b7e751b507 Fix typo in docs 2019-10-27 20:28:06 -07:00
Jay Oster 5795fa7943
Add include_spv!() macro, donated by Ralith (#26) 2019-10-27 19:50:15 -07:00
Jay Oster 8bebb29a06
Fix screen scaling when window is resized (#25)
* Refactor window creation and size handling

* Require pixel aspect ratio to be > 0

* Fix screen scaling when window is resized

- Ensure the screen retains its correct pixel aspect ratio
- Updated public API on `RenderPass` ... this will continue to be unstable until the initial release
- Add build instructions for the internal shaders
2019-10-27 16:35:22 -07:00
Jay Oster 8801bad58a
Update public API to provide &mut [u8] instead of accepting &[u8] from the app (#22)
- Closes #19
2019-10-21 23:17:58 -07:00
Jay Oster 6f0b1e0102
Support resize (#12)
- `Pixels` now takes ownership of the `Surface`. Deal with it. CBF to mess around with weird static lifetime requirements that don't make sense.
2019-10-14 22:17:42 -07:00
Jay Oster 383b0d83ff
Replace vk-shader-macros with pre-compiled GLSL. Fixes #9 (#10) 2019-10-13 21:43:30 -07:00
Jay Oster 2847a8bd39 Update docs 2019-10-04 22:48:29 -07:00
Jay Oster b7d1623e67 Include missing module 2019-10-04 22:45:30 -07:00
Jay Oster 4d2d313faa Implement Renderer::factory() as a client would
- I had to move the texture state back to `Pixels` for now ... not satusfied with this yet
2019-10-04 22:43:45 -07:00
Jay Oster 8dc33fcf4e
Enable clippy in CI (#2)
* Enable clippy in CI

- Removed beta and nightly channels to prevent build breakage
- Fixed some lints noted by `pedantic` and `nursery` level (but not denying these levels by default)
2019-10-04 21:35:00 -07:00
Jay Oster 889d1ae44a clippy 2019-10-04 21:08:24 -07:00
Jay Oster c994b35a5c Settle on an interface for PixelsBuilder::add_render_pass()
- Accepts a closure (factory function) which itself accepts references to the `wgpu` instances needed for rendering
- This solves a need for creating `RenderPass` objects with a lot of `Option` types and trying to update them dynamically after the fact
- In other words, this is an RAII implementation
- `RenderPass` objects are created during the `PixelsBuilder` build stage
- It should prevent patterns where half-created `RenderPass` objects are necessary
2019-10-04 20:52:32 -07:00
Jay Oster 26860496a8 Consolidate Renderer state and support multiple render passes 2019-10-04 00:59:40 -07:00
Jay Oster ac400f6122 Remove redundant fields 2019-10-03 23:28:13 -07:00
Jay Oster 64cd487c37 Merge Pixels::update() with Pixels::render()
- Adds `PixelsBuilder::texture_format()` to configure the format for the pixel buffer
2019-10-03 23:16:23 -07:00
Jay Oster d0391be62a Initial pass with texture rendering
- The example app generates a scaled version of pixel Ferris as a test.
- TODO:
  - Pixel aspect ratio is still unsupported
  - The `RenderPass` trait is incomplete
2019-10-02 20:22:20 -07:00
Jay Oster 38ce5c186d Rewrite all doc comments to wrap at 100 characters (was 80) 2019-10-02 01:07:11 -07:00
Jay Oster 70306c5cfd Add RenderPass trait and refactor PixelsBuilder 2019-10-02 00:53:41 -07:00
Jay Oster 2ec43fccd1 Cleanly separate the two texture dimensions
- The pixel buffer dimensions
- The surface texture dimensions
2019-10-01 22:00:37 -07:00
Jay Oster 44f5b67c9e Remove shaders from PixelsOptions
- This is the first step toward refactoring the rendering pipeline
- These will be replaced by optional render passes
2019-10-01 18:36:40 -07:00
Jay Oster 2ec303812f Remove deprecated error variants 2019-09-29 17:42:40 -07:00
Jay Oster 337241c866 Switch to vk_shader_macros 2019-09-29 17:40:05 -07:00
Jay Oster c4d762d5f5 Rename the Error type and add docs for the variants. 2019-09-25 23:47:04 -07:00
Jay Oster cc4976079b Initial commit.
- Just a copy of the wgpu `hello-triangle` example for now... more to come!
2019-09-25 23:07:30 -07:00