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

Add example to evaluate sky shader on CPU #141

Merged
merged 7 commits into from
Oct 26, 2020
Merged

Add example to evaluate sky shader on CPU #141

merged 7 commits into from
Oct 26, 2020

Conversation

repi
Copy link
Contributor

@repi repi commented Oct 25, 2020

Adds a new example that shows how to compile and evaluate a simple fragment shader (our sky shader) directly on the CPU.

For this specific shader as it doesn't use any resources it is very easy as one can just call the fragment shader function manually, later for standard shaders with resource bindings this will be much harder, but maybe still useful to test parts of shaders or reuse some functionality.

Right now it also just works for the current temp math functions that use core intrinsic, as all of those are available obviously on the CPU also, later when we start introducing GPU & SPIRV specific intrinsics (#81), this approach won't work, and then we will want to use a higher-level math layer in the shaders for the math instructions (glam: #134) so they can be mapped to the right available target intrinsic.

To make the example very simple, slim and cross-platform, this example uses the minifb crate to drive the Window. Could switch to something else later though but it is very basic.

image

Copy link
Contributor

@khyperia khyperia left a comment

Choose a reason for hiding this comment

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

this is super cool, and impressively simple!

later when we start introducing GPU & SPIRV specific intrinsics (#81), this approach won't work

It should work, I plan on implementing it in a way where it should work.

examples/example-shader/src/lib.rs Show resolved Hide resolved
examples/example-runner-cpu/src/main.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@Jasper-Bekkers Jasper-Bekkers left a comment

Choose a reason for hiding this comment

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

I love that we can do this :-)

@repi
Copy link
Contributor Author

repi commented Oct 26, 2020

Ah some cargo-deny stuff to fix with the minifb dependency

@repi
Copy link
Contributor Author

repi commented Oct 26, 2020

@Mergifyio rebase

@mergify
Copy link
Contributor

mergify bot commented Oct 26, 2020

Command rebase: success

Branch has been successfully rebased

@repi repi merged commit fe18434 into main Oct 26, 2020
@repi repi deleted the cpu-example branch October 26, 2020 14:49
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.

5 participants