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

Make depth_stencil_attachment follow the spec #611

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

Conversation

fyellin
Copy link
Contributor

@fyellin fyellin commented Oct 3, 2024

https://www.w3.org/TR/webgpu/#depth-stencil-attachments

Make depth_stencil_attachment more closely follow the specification. No longer do we need to specify stencil_xxx if it's a depth, and no need to specify depth_xxx if it's a stencil. We only need to specify "color" if it's a "clear".

depth_keys_okay = True
depth_load_op = ds_attachment["depth_load_op"]
depth_store_op = ds_attachment["depth_store_op"]
if depth_load_op == "clear":
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a better way of doing this? Will anyone specify "clear" by its integer value?

Copy link
Member

Choose a reason for hiding this comment

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

This is fine, the integer values of enums from wgpu-native are an implementation detail and should not be usable by the caller.

Copy link
Member

@almarklein almarklein 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 this!

depth_keys_okay = True
depth_load_op = ds_attachment["depth_load_op"]
depth_store_op = ds_attachment["depth_store_op"]
if depth_load_op == "clear":
Copy link
Member

Choose a reason for hiding this comment

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

This is fine, the integer values of enums from wgpu-native are an implementation detail and should not be usable by the caller.

Comment on lines 2766 to 2770
warnings.warn(
f"Unexpected key {key} in depth_stencil_attachment",
DeprecationWarning,
stacklevel=2,
)
Copy link
Member

@almarklein almarklein Oct 3, 2024

Choose a reason for hiding this comment

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

We use logger.warning() instead of the warnings module.

Another thing is that (I think) this warning would be shown on each draw, which may be a bit much. Perhaps we can do something like:

if not getattr(self._device, "_showed_depth_stencilwarning", False):
    self._device._showed_depth_stencilwarning = True
    logger.warning(....)

Simplify test_wgpu_native_render.py
Add test that warnings occur, but only once.
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