Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tilemap optimizations #132

Merged
merged 27 commits into from
Jun 16, 2024
Merged

Conversation

melody-rs
Copy link
Member

Connections
#98
#102

Description
This PR overhauls how the tilemap and its components are rendered and used.

  • The placeholder texture is now shared
  • Vertex buffers for everything except sprites have been removed
  • Instance buffers have been significantly shrunk or outright removed
  • Only resources required for rendering are stored in an Arc, so all uses of AtomicCell have been removed
  • Push constants code has been removed
  • Uncapped layer size (layer opacity is now a dynamic uniform buffer)

Testing
Open maps, move events around, hover over events to display them

Checklist

  • Run cargo fmt.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown -Z build-std=std,panic_abort
  • Run cargo build --release
  • If applicable, run trunk build --release

@melody-rs melody-rs requested a review from a team as a code owner June 15, 2024 05:11
crates/components/src/map_view.rs Outdated Show resolved Hide resolved
@melody-rs melody-rs requested a review from white-axe June 16, 2024 08:07
Copy link
Collaborator

@white-axe white-axe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get this panic message when using the web build with WebGL in both Chromium and Firefox:

The application panicked (crashed).
Message:  wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `Tilemap Sprite Render Pipeline`
    In the provided shader, the type given for group 0 binding 2 has a size of 24. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.

Location: /home/h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/backend/wgpu_core.rs:3009

Luminol version: d6d5041e

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

@melody-rs
Copy link
Member Author

I get this panic message when using the web build with WebGL in both Chromium and Firefox:

The application panicked (crashed).
Message:  wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `Tilemap Sprite Render Pipeline`
    In the provided shader, the type given for group 0 binding 2 has a size of 24. As the device does not support `DownlevelFlags::BUFFER_BINDINGS_NOT_16_BYTE_ALIGNED`, the type must have a size that is a multiple of 16 bytes.

Location: /home/h/.cargo/registry/src/index.crates.io-6f17d22bba15001f/wgpu-0.19.1/src/backend/wgpu_core.rs:3009

Luminol version: d6d5041e

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Weird, I don't get this panic. Should be an easy fix though!

@melody-rs melody-rs requested a review from white-axe June 16, 2024 19:03
@white-axe white-axe linked an issue Jun 16, 2024 that may be closed by this pull request
@white-axe white-axe merged commit 15806d2 into Astrabit-ST:dev Jun 16, 2024
5 checks passed
@melody-rs melody-rs deleted the tilemap-optimizations branch June 16, 2024 19:29
MolassesLover pushed a commit to MolassesLover/luminol-molasses that referenced this pull request Jul 23, 2024
* Use the layout from the old branch

* Remove support for push constants

* Use bytes_of and from_bytes

* Use vec2 instead of vec3

* Move grid.wgsl

* Don't use an instance buffer for the grid

* Move the tilepicker mostly into graphics

* Fix collision shader

* Remove vertex buffer from grid

* Remove tilemap vertex buffer

* Remove vertex buffer from collision

* Use shared placeholder png

* Update alox-48

* Massively refactor things (still broken)
- Splits viewport into a transform and screen size
- Fundamentally changes how things are drawn
- Ditches Arc everywhere, so now there are practically 0 multithreading primitives
- Breaks things

* Fix event position bug

* Actually render the grid

* Fix viewport translations

* Fix autotile animation

* Fix some grid issues

* Reimplement event preview

* Fix collision

* Fix align bug

* Fix event preview rendering

* Fix some webgl issues
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Viewport transformation efficiency
2 participants