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

Added Texture Blitting Utility #6852

Open
wants to merge 18 commits into
base: trunk
Choose a base branch
from

Conversation

AbdullahElsheshtawy
Copy link

@AbdullahElsheshtawy AbdullahElsheshtawy commented Jan 3, 2025

Connections
#6819

Checklist

  • Run cargo fmt.
  • Run cargo clippy.
  • Add change to CHANGELOG.md. See simple instructions inside file.
  • Add tests.
  • Make the tests pass.

@AbdullahElsheshtawy AbdullahElsheshtawy requested a review from a team as a code owner January 3, 2025 17:59
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

Overall structure is good, have a few comments.

We also need a test to make sure things are working correctly. Our tests are in tests/tests and you make a module in the file root.rs. What we need to test is that things pass validation with both kinds of FilterMode. We don't need to actually test the result.

wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
wgpu/src/util/mod.rs Outdated Show resolved Hide resolved
AbdullahElsheshtawy and others added 3 commits January 4, 2025 01:15
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
Co-authored-by: Connor Fitzgerald <[email protected]>
@cwfitzgerald cwfitzgerald self-assigned this Jan 3, 2025
@AbdullahElsheshtawy
Copy link
Author

Thanks for the PR!

Overall structure is good, have a few comments.

We also need a test to make sure things are working correctly. Our tests are in tests/tests and you make a module in the file root.rs. What we need to test is that things pass validation with both kinds of FilterMode. We don't need to actually test the result.

Should be all good now.

compilation_options: PipelineCompilationOptions::default(),
targets: &[Some(ColorTargetState {
format,
blend: None,

Choose a reason for hiding this comment

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

Very cool. Configuring blending might also be nice

Copy link
Author

Choose a reason for hiding this comment

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

Yeah this would be nice.

Copy link
Author

Choose a reason for hiding this comment

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

Implemented and tested.

Choose a reason for hiding this comment

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

Awesome thank you ❤️

@AbdullahElsheshtawy
Copy link
Author

Looks like emscripten does not support wgsl (atleast in ci). Is this intentional?

@cwfitzgerald
Copy link
Member

This actually has nothing to do with emscripten, it seems like that is the only platform that has a compile job that tests without the wgsl feature, scarily enough. We need to gate the blit tool on having the wgsl feature.

wgpu/src/util/texture_blitter.rs Outdated Show resolved Hide resolved
wgpu/src/util/texture_blitter.rs Outdated Show resolved Hide resolved
wgpu/src/util/texture_blitter.rs Outdated Show resolved Hide resolved
Comment on lines +30 to +35
pub fn new(
device: &Device,
format: TextureFormat,
sample_type: FilterMode,
blend_state: Option<BlendState>,
) -> Self {
Copy link
Member

Choose a reason for hiding this comment

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

I feel like this is an easy way to get a million arguments - there are a bunch of reasonable additions we could add to this blitting utility. I would suggest that we build a Builder-Pattern constructor for this. Specifically:

  • Have a TextureBlitter::new(&Device, TextureFormat) which calls TextureBlitterBuilder::new(&Device, TextureFormat).build().
  • Then have methods on the builder which allow setting sample_type and blend_state.

Then we can add functionality here without needing to break users.

Copy link
Author

Choose a reason for hiding this comment

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

Was late because exams. Hope I didn't cause any inconvenience.

Regarding the TextureBlitterBuilder and TextureBlitter can you elaborate on how the user interface would be like? I don't think I quite get what you mean. Do you mean something like this

use wgpu::util::TextureBlitterBuilder;

let blitter = TextureBlitterBuilder::new(&device, format).sample_type(type).blend_state(blend_state).build();

or do you want something like this

use wgpu::util::TextureBlitter;

let blitter = TextureBlitter::new(&device, format).blend_state(blend_state).sample_type(type).build(); 

wgpu/src/util/texture_blitter.rs Show resolved Hide resolved
@AbdullahElsheshtawy AbdullahElsheshtawy requested a review from a team as a code owner January 9, 2025 16:42
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