Skip to content

Conversation

jamienicol
Copy link
Contributor

P010 is a 4:2:0 chroma subsampled planar format, similar to NV12. Each component uses 16 bits of storage, of which only the high 10 bits are used. On DX12 this maps to DXGI_FORMAT_P010, and on Vulkan this maps to G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16.

The existing "nv12" gpu test module has been renamed to "planar_texture", and a new test P010_TEXTURE_CREATION_SAMPLING has been added similar to the existing NV12_TEXTURE_CREATION_SAMPLING. The remaining tests in this module have been converted to validation tests, and now test both NV12 and P010 formats.

Testing
Added GPU and validation tests. Have manually tested it works on Direct X in my firefox external textures branch

Squash or Rebase?

Squash

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.

@jamienicol jamienicol requested a review from a team as a code owner August 12, 2025 14:01
@jimblandy
Copy link
Member

I've filed #8088 for the cargo-deny failure.

hr.is_ok()
&& p010_info
.Support1
.contains(Direct3D12::D3D12_FORMAT_SUPPORT1_TEXTURE2D)
Copy link
Member

Choose a reason for hiding this comment

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

We should probably check shader load and sample as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Genuine question as I don't know the answer. We don't sample or load directly from this texture, but via R16 and Rg16 views. So is this handled by the Feature::TEXTURE_FORMAT_16BIT_NORM check? Or do we have to specifically check for this format too? Would checking this perhaps return false even if sampling/loading from R16/Rg16 is actually supported? (I will test this)

Copy link
Member

Choose a reason for hiding this comment

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

That's a good question, and for D3D12, I don't know how to easily find the answer. I saw load and sample are supported (if the format is) in the table here: https://learn.microsoft.com/en-us/windows/win32/direct3ddxgi/format-support-for-direct3d-11-0-feature-level-hardware#dxgi_format_p010v-104 but I don't know for sure if they are needed since as you mentioned, we never bind views of that format to the shader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I'll manually test whether my PC supports says it supports loads and samples witht his format. If it does, I'll add the check. If it does not, but given we know it works when loading and sampling from the views, then I'll leave the check out. Sound good?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think NV12/P010 formats be used directly as view formats, so I assume the requirements are the intersection of capabilities of the NV12/P010 formats and the capabilities of the view format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Both CI and my desktop report that they support shader load and sample for P010. so let's include the check. have force pushed an update. LMK if you're happy for me to land once CI comes back green

Copy link
Member

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@teoxoy teoxoy left a comment

Choose a reason for hiding this comment

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

Besides the one comment, it looks good!

P010 is a 4:2:0 chroma subsampled planar format, similar to NV12. Each
component uses 16 bits of storage, of which only the high 10 bits are
used. On DX12 this maps to DXGI_FORMAT_P010, and on Vulkan this maps to
G10X6_B10X6R10X6_2PLANE_420_UNORM_3PACK16.

The existing "nv12" gpu test module has been renamed to
"planar_texture", and a new test P010_TEXTURE_CREATION_SAMPLING has
been added similar to the existing NV12_TEXTURE_CREATION_SAMPLING. The
remaining tests in this module have been converted to validation tests,
and now test both NV12 and P010 formats.
@teoxoy teoxoy merged commit 486c151 into gfx-rs:trunk Aug 13, 2025
40 checks passed
@jamienicol jamienicol deleted the p010-format branch August 13, 2025 14:38
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