Skip to content

GPU invert node #2690

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 10 commits into
base: pre-texture-removal
Choose a base branch
from
Draft

GPU invert node #2690

wants to merge 10 commits into from

Conversation

Firestar99
Copy link
Collaborator

@Firestar99 Firestar99 commented Jun 5, 2025

image

Code below shows how much I had to change the gpu invert node. Most of the changes are due to not wanting to depend on gcore, as it currently doesn't compile for no_std. I think we could probably get away without changing it at all.

// #[node_macro::node(category("Raster: Adjustment"))]
fn invert_copy(
// _: impl Ctx,
// #[implementations(
// Color,
// ImageFrameTable<Color>,
// GradientStops,
// )]
// mut input: T,
color: Color,
) -> Color {
// input.adjust(|color| {
let color = color.to_gamma_srgb();
let color = color.map_rgb(|c| color.a() - c);
color.to_linear_srgb()
// });
// input
}

The rust-gpu shader calling it:

#[spirv(fragment)]
pub fn gpu_invert_fragment(#[spirv(frag_coord)] frag_coord: Vec4, #[spirv(descriptor_set = 0, binding = 0)] texture: &Image2d, color_out: &mut Vec4) {
let color = Color::from(texture.fetch_with(frag_coord.xy().as_uvec2(), lod(0)));
let color = invert_copy(color);
*color_out = Vec4::from(color);
}

@Firestar99
Copy link
Collaborator Author

Firestar99 commented Jun 5, 2025

The linker is erroring due to the wasm-specific flags somehow ending up in a native compile, probably env leaking again. Doesn't trigger locally, likely due to me using the mold linker. Will play around with it a bit more tomorrow.

@Keavon Keavon closed this Jun 7, 2025
@Keavon Keavon reopened this Jun 7, 2025
@Keavon Keavon changed the base branch from master to pre-texture-removal June 7, 2025 11:14
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.

2 participants