- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.1k
Make multi-planar textures renderable #8307
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
          
     Merged
      
      
            cwfitzgerald
  merged 1 commit into
  gfx-rs:trunk
from
noituri:@noituri/renderable-nv12-texture
  
      
      
   
  Oct 29, 2025 
      
    
      
        
          +358
        
        
          −15
        
        
          
        
      
    
  
  
     Merged
                    Changes from all commits
      Commits
    
    
  File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            35 changes: 35 additions & 0 deletions
          
          35 
        
  tests/tests/wgpu-gpu/planar_texture/planar_texture_rendering.wgsl
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| struct VertexOutput { | ||
| @builtin(position) position: vec4<f32>, | ||
| } | ||
|  | ||
| const VERTICES: array<vec3<f32>, 3> = array<vec3<f32>, 3>( | ||
| vec3<f32>(-0.5, 0.0, 0.0), | ||
| vec3<f32>(0.5, 0.0, 0.0), | ||
| vec3<f32>(0.0, 1.0, 0.0), | ||
| ); | ||
|  | ||
| @vertex | ||
| fn vs_main(@builtin(vertex_index) idx: u32) -> VertexOutput { | ||
| var output: VertexOutput; | ||
| output.position = vec4(VERTICES[idx], 1.0); | ||
| return output; | ||
| } | ||
|  | ||
| @fragment | ||
| fn fs_y_main(input: VertexOutput) -> @location(0) f32 { | ||
| let color = vec3<f32>(1.0); | ||
| let conversion_weights = vec3<f32>(0.2126, 0.7152, 0.0722); | ||
| return clamp(dot(color, conversion_weights), 0.0, 1.0); | ||
| } | ||
|  | ||
| @fragment | ||
| fn fs_uv_main(input: VertexOutput) -> @location(0) vec2<f32> { | ||
| let color = vec3<f32>(1.0); | ||
| let conversion_weights = mat3x2<f32>( | ||
| -0.1146, 0.5, | ||
| -0.3854, -0.4542, | ||
| 0.5, -0.0458, | ||
| ); | ||
| let conversion_bias = vec2<f32>(0.5, 0.5); | ||
| return clamp(conversion_weights * color + conversion_bias, vec2(0.0, 0.0), vec2(1.0, 1.0)); | ||
| } | 
            File renamed without changes.
          
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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_NV12andTEXTURE_FORMAT_P010features requireVK_KHR_sampler_ycbcr_conversionextension which depends on:VK_KHR_maintenance1andVK_KHR_bind_memory2andVK_KHR_get_memory_requirements2andVK_KHR_get_physical_device_properties2From 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)