Skip to content

Conversation

noituri
Copy link

@noituri noituri commented Oct 6, 2025

Connections
Closes #8205

Description
Currently it was not possible to render onto planes of multiplanar textures (in this case, it's only possible for NV12).

To make it work:

  • I changed how allowed usages are checked on texture creation. For multiplanar textures I check features of underlying planes' formats instead of the multi planar texture's itself.
  • Changed how render_extent is calculated for texture views

Testing
I tried to render on both Vulkan and DX12 (the only supported backends) + I've added tests.
987 tests run: 982 passed, 5 failed, 12 skipped.
On my machine 5 tests were failing before and after my changes.

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy --tests. If applicable, add:
    • --target wasm32-unknown-unknown
  • Run cargo xtask test to run tests.
  • If this contains user-facing changes, add a CHANGELOG.md entry.

@noituri noituri force-pushed the @noituri/renderable-nv12-texture branch 2 times, most recently from 658925c to 5a10d31 Compare October 6, 2025 07:44
@noituri noituri marked this pull request as ready for review October 6, 2025 07:49
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 writing all the tests, helps me feel good about getting this in! Some comments.

Comment on lines 708 to 711
if desc.format.is_multi_planar_format() {
raw_flags |= vk::ImageCreateFlags::MUTABLE_FORMAT;
raw_flags |=
vk::ImageCreateFlags::MUTABLE_FORMAT | vk::ImageCreateFlags::EXTENDED_USAGE;
}
Copy link
Member

Choose a reason for hiding this comment

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

Nit regarding extended usage, do we already ensure that we have vulkan 1.1 before we allow multi-planar textures? If not we should add that check.

Copy link
Author

Choose a reason for hiding this comment

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

If I'm reading the code correctly, TEXTURE_FORMAT_NV12 and TEXTURE_FORMAT_P010 features require VK_KHR_sampler_ycbcr_conversion extension which depends on:

  • Vulkan 1.1, OR
  • VK_KHR_maintenance1 and VK_KHR_bind_memory2 and VK_KHR_get_memory_requirements2 and VK_KHR_get_physical_device_properties2

From what I checked, wgpu does not require all of those extensions so the only way we could use multi-planar textures would be if we had at least vulkan 1.1 and I think wgpu ensures that (unless I read the code wrong)

Comment on lines 6390 to 6423
let (width, height) = match (self.format, plane) {
(TextureFormat::NV12 | TextureFormat::P010, Some(0)) => (width, height),
(TextureFormat::NV12 | TextureFormat::P010, Some(1)) => (width / 2, height / 2),
_ => (width, height),
};
Copy link
Member

@cwfitzgerald cwfitzgerald Oct 16, 2025

Choose a reason for hiding this comment

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

My only worry here is that when we add future multi-planar formats, there will be no error to tell us to populate this. Maybe a (debug) assert in the catchall branch to assert that the format is single-planar and maybe a test which calls this function on all texture formats?

Copy link
Author

Choose a reason for hiding this comment

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

I added the test but I'm not sure if I put it in the right file. I wanted to reuse TEXTURE_FORMAT_LIST from wgpu-info but it's not available from wgpu-types so the test is in wgpu-info which seems wrong to me

@noituri noituri force-pushed the @noituri/renderable-nv12-texture branch from 5a10d31 to a87815a Compare October 17, 2025 12:14
@noituri noituri force-pushed the @noituri/renderable-nv12-texture branch from a87815a to 201c251 Compare October 17, 2025 12:46
@noituri noituri requested a review from cwfitzgerald October 17, 2025 13:12
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.

Allow RENDER_ATTACHMENT on multi planar texture formats

2 participants