Skip to content

GPU examples #23

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

Draft
wants to merge 24 commits into
base: main
Choose a base branch
from
Draft

GPU examples #23

wants to merge 24 commits into from

Conversation

Giesch
Copy link

@Giesch Giesch commented May 14, 2025

This adds / will add some more SDL GPU examples based on the official ones in C.

Notes:

  • the shader json metadata is from shadercross
    I've been using a justfile setup for managing that in my own project, we could do something similar here,
    or I could remove the serde dependencies and hardcode the resource counts.
    The serde dependency is also the reason for the new examples directory (based on axum's examples setup).
  • my editor/LSP setup locally was sad without a rustfmt.toml specifying the edition

Remaining todos:

  • use some more rust-friendly patterns (ie avoid unnecessary SDL_free)
  • re-add the clear screen example
  • re-add the basic triangle example
  • find a way to share the common module
  • maybe add a shadercross setup for compiling example shaders
  • maybe switch examples to using app_impl
  • remove build-from-source-static

@Lokathor
Copy link

if there should be a rustfmt file just add a rustfmt file

@Giesch
Copy link
Author

Giesch commented May 14, 2025

Sorry; I can see how that'd come off as catty. I meant it as an explanation for a kind of pointless change. I don't think the file's actually required by rustfmt itself, only by my editor extension.

@Lokathor
Copy link

I'm not the lead but the crates are using 2021 edition, so there should probably be a rustfmt that configures for that.

@maia-s
Copy link
Owner

maia-s commented May 14, 2025

Looks good so far! Thank you for doing this.

I don't think the examples should require the build-from-source-static feature so people can run them with an already installed SDL library, but you can leave taking that out for last if it makes developing easier for you.

@maia-s
Copy link
Owner

maia-s commented May 14, 2025

The examples fail here (macos) with newLibraryWithSource:8657: failed assertion `source must not be nil.'. I can investigate later.

Giesch added 6 commits May 14, 2025 17:21
* the color_target_descriptions array needs its own declaration
  without this, the slice pointer gets invalidated in release mode
  which leads to the texture format being some arbitrary value
* now I'm paranoid about as_ptr
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.

3 participants