Skip to content

Conversation

@atlv24
Copy link
Collaborator

@atlv24 atlv24 commented Oct 9, 2025

Description
Implements shader barycentrics for vk 1.3+ via VK_KHR_fragment_shader_barycentric BaryCoordKHR, dx12 via SV_Barycentrics, and metal 2.2 via barycentric_coord

Testing
There's a wgpu-gpu test.

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.

@atlv24 atlv24 force-pushed the ad/barycentrics branch 4 times, most recently from 1dba169 to c6b729b Compare October 9, 2025 14:02
@cwfitzgerald cwfitzgerald self-assigned this Oct 9, 2025
@inner-daemons
Copy link
Collaborator

inner-daemons commented Oct 13, 2025

Just going to link #2900 here, glad to see progress on this!

Also, #8342 is probably relevant, since I don't think this PR checks for DXC support before exposing barycentrics on DX12.

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.

Great stuff! Some small comments.

@cwfitzgerald
Copy link
Member

Unfortunately lavapipe doesn't support barycentrics, weirdly.

Getting this when running it locally:

──── STDERR:             wgpu-test::wgpu-gpu [Executed] [Vulkan/NVIDIA GeForce RTX 4070 Laptop GPU/1] wgpu_gpu::shader_barycentric::barycentric
[2025-10-16T19:51:53Z ERROR wgpu_hal::vulkan::instance] VALIDATION [VUID-VkShaderModuleCreateInfo-pCode-08737 (0xa5625282)]
        vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
    Capability FragmentBarycentricKHR is not allowed by Vulkan 1.3 specification (or requires extension)
      OpCapability FragmentBarycentricKHR
    The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.4.321.0/windows/antora/spec/latest/chapters/shaders.html#VUID-VkShaderModuleCreateInfo-pCode-08737)
[2025-10-16T19:51:54Z ERROR wgpu_test::expectations] Validation Error: vkCreateShaderModule(): pCreateInfo->pCode (spirv-val produced an error):
    Capability FragmentBarycentricKHR is not allowed by Vulkan 1.3 specification (or requires extension)
      OpCapability FragmentBarycentricKHR
    The Vulkan spec states: If pCode is a pointer to SPIR-V code, pCode must adhere to the validation rules described by the Validation Rules within a Module section of the SPIR-V Environment appendix (https://vulkan.lunarg.com/doc/view/1.4.321.0/windows/antora/spec/latest/chapters/shaders.html#VUID-VkShaderModuleCreateInfo-pCode-08737)

thread '<unnamed>' panicked at tests\src\run.rs:121:9:
tests\tests\wgpu-gpu\shader_barycentric\mod.rs:33:44: test "wgpu_gpu::shader_barycentric::barycentric" did not behave as expected
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

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