3029: [pre-ll] Remove derivative r=kvark a=alexheretic
* Remove crate derivative.
* Fix some warnings: `&Error` -> `&dyn Error`.
After reading about master branch speeding up compile times by removing _derivative_ I wondered if it would help the pre-ll code too. Tbf I can see derivative is quite helpful for the `PhantomData` types where regular `#[derive(...)]` falls down. But it isn't _that_ hard to write out the impls.
It impacts clean builds more than I would expect _(linux, rust 1.38, ryzen 2700x)_.
### Before
```sh
$ hyperfine --max-runs 3 'cargo clean; cargo build --example cube'
Benchmark #1: cargo clean; cargo build --example cube
Time (mean ± σ): 34.765 s ± 0.126 s [User: 248.966 s, System: 12.062 s]
Range (min … max): 34.666 s … 34.906 s 3 runs
```
### After
```sh
$ hyperfine --max-runs 3 'cargo clean; cargo build --example cube'
Benchmark #1: cargo clean; cargo build --example cube
Time (mean ± σ): 28.158 s ± 0.343 s [User: 250.888 s, System: 12.067 s]
Range (min … max): 27.819 s … 28.504 s 3 runs
```
PR checklist:
- [x] tested examples with the following backends: gl
Co-authored-by: Alex Butler <alexheretic@gmail.com>
2979: [pre-ll] Remove `core` alias in gfx_device_gl r=kvark a=alexheretic
Fixes `gfx_device_gl` to compile on recent nightlies, see #2964. I only removed the alias usage in this crate as it was the one that seems to cause issues.
PR checklist:
- [x] tested examples with the following backends: gl
Co-authored-by: Alex Butler <alexheretic@gmail.com>
2942: [pre-ll] dx11: handle structs in cbuffers r=kvark a=tangmi
If one puts a struct as a member of a constant buffer, `gfx` crashes trying to divide by zero.
When a shader variable type is a `D3D_SVC_STRUCT`, it is an array when the `Elements` field is > 0 and a struct when the `Members` field is > 0.
This changeset makes it so we calculate the struct of an array variable only when it is an array.
Co-authored-by: Michael Tang <tangmi@uw.edu>
2747: [pre-ll] Support HLSL semantic indexes r=kvark a=tangmi
Fixes#2748
PR checklist:
- [x] tested examples with the following backends: DX11
This changeset adds support for HLSL semantic indices.
Users should now be able to specify a semantic with an index (such as `"TEXCOORD1"`) in their pipeline. If one does not include the index, an index of `0` is assumed (as HLSL assumes).
Introduces a struct that can be converted to and from a packed String.
Here are some sample mappings:
- `"TEXCOORD"` -> `VertexSemantic { name: "TEXCOORD", index: 0 }` -> `"TEXCOORD0"`
- `"TEXCOORD0"` <-> `VertexSemantic { name: "TEXCOORD", index: 0 }`
- `"TEXCOORD10"` <-> `VertexSemantic { name: "TEXCOORD", index: 10 }`
On link_input, we will try linking against the semantic name and index together (e.g. `"TEXCOORD0"`) and also just the semantic name (e.g. `"TEXCOORD"`) if the semantic index is 0, in the case that the user did not explicitly provide the semantic index, esp. for GLSL compatibility).
Co-authored-by: Michael Tang <tangmi@uw.edu>
2760: [pre-ll] DX11 add ID3D11InfoQueue in debug builds r=kvark a=tangmi
Fixes #issue
PR checklist:
- [x] tested examples with the following backends: dx11
This adds debug output from the ID3D11InfoQueue (e.g. it'll send a message whenever a method is called incorrectly and sometimes call out which arguments are wrong). This code could also be adapted for `gfx-hal`'s dx11 backend to aid in the development experience there.
Co-authored-by: Michael Tang <tangmi@uw.edu>
2733: [pre-ll] Add BC1 (DXT1), BC3 (DXT5) S3TC texture formats r=alexheretic a=alexheretic
Adds compressed BC1 & BC3 image formats for gfx_device_gl/opengl. Image data is expected to be already compressed.
New formats:
* `SurfaceType::BC1_R8_G8_B8` (DXT1)
* `SurfaceType::BC3_R8_G8_B8_A8` (DXT5)
Each supports rgb & srgb.
Resolves#2688
## Motive
I've been investigating texture compression to reduce VRAM usage in my game Robo Instructus. For this end I wanted more efficient 8-bit channel rgb & rgba storage with good opengl driver & hardware support.
S3TC is old and the best supported compression available (see https://opengl.gpuinfo.org/listcompressedformats.php). Patent issues are now history (see https://en.wikipedia.org/wiki/S3_Texture_Compression). For testing I used [GPUOpen-Tools/Compressonator](https://github.com/GPUOpen-Tools/Compressonator) for encoding, which is quite fast and seems to have decent quality.
* `BC1_R8_G8_B8` offers 8:1 compression over `R8_G8_B8_A8`
* `BC3_R8_G8_B8_A8` offers 4:1 compression over `R8_G8_B8_A8`
I didn't include BC2/DXT3, or BC7 as I don't plan to use it. However, support for this format can be trivially added on top of this change.
## No ETC2?
I did investigate ETC2 compression too which is newer yet features wide support. However, I found actual _hardware_ support for ETC2 on the desktop is much more limited that it may appear. It was a bit of a downer to see no VRAM usage reduction on my polaris RX480 when using ETC2 compressed textures. ETC2 formats also didn't seem to work without the `GL_ARB_texture_storage`/immutable storage code paths, whereas I've tested the BC1 & BC3 formats working either way. That can probably be addressed, but I didn't.
For the above reasons I decided against using ETC2 in the game & adding it here. Note though; similarly to BC2, this change will make it simpler to support ETC2 formats in future if desired.
## Issues
### OpenGL Extensions
~This code requires S3TC extensions added to `gfx_gl`. The changes there are ready to go if this PR is wanted. The gfx_gl dependency line needs to be changed:~
~https://github.com/gfx-rs/gfx_gl/pull/38~
Extensions now available in gfx_gl `0.6`.
### API support
Robo Instructus is an OpenGL 3.3 game so I'm not personally interested in other API support for these formats at the moment. Also considering pre-ll code is in support mode, and unsupported formats already seem common I thought it wasn't a big deal not supporting other APIs.
### Naming
I went with Vulkan naming style ie prefix with BC1. Maybe you guys have a better idea of what you'd like to name the formats. I'm not hugely fussed here.
### Format documentation
~It would be nice to have documentation for the new formats. Mentioning there various other pseudonyms & API support will probably help people wondering what BC1 does & means. However, the `impl_formats!` macro prevents easy documentation.~ I've added this. Other formats can now be fairly easily documented too.
Co-authored-by: Alex Butler <alexheretic@gmail.com>
2742: [pre-ll] Update glutin -> 0.21 r=kvark a=alexheretic
Update to the latest quite breaking glutin api changes.
PR checklist:
- [x] tested examples with the following backends: gl
Co-authored-by: Alex Butler <alexheretic@gmail.com>
2745: [pre-ll] initialize device r=msiglreith a=tangmi
Fixes#2727
PR checklist:
- [x] tested examples with the following backends: DX11
- [ ] `rustfmt` run on changed code
Co-authored-by: Michael Tang <tangmi@uw.edu>