SlideShare a Scribd company logo
1 of 21
Download to read offline
Fun with border colors in Vulkan
A story about VK_EXT_border_color_swizzle
Ricardo Garcia
2022-02-06 FOSDEM
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Sampling in Vulkan
GLSL
vec4 color = texture(sampler, coords);
Image View (B8G8R8_UNORM)
B G R
00010000 11110111 00010110
color.r = 0.0862745098039216
color.g = 0.9686274509803922
color.b = 0.0627450980392157
color.a = 1.0
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Normalized Coordinates
GLSL
vec4 color = texture(sampler, coords); 0,0
1,1
x
x
x
x
VkSamplerCreateInfo
.addressModeU
.addressModeV
.addressModeW
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Address Mode
Image source: Aras Pranckevičius, https://twitter.com/aras_p/status/1480199231772237826
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Border Color
VkSamplerCreateInfo::borderColor
VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK
VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK
VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE
// VK_EXT_custom_border_color
VK_BORDER_COLOR_FLOAT_CUSTOM_EXT
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Image View Swizzle
GLSL
vec4 color = texture(sampler, coords);
color.r = 0.0862745098039216
color.g = 0.9686274509803922
color.b = 0.0627450980392157
color.a = 1.0
// Component reordering,
// replacement or duplication.
VkImageViewCreateInfo::components
{ VkComponentSwizzle r, g, b, a; }
Image View (B8G8R8_UNORM)
B G R
00010000 11110111 00010110
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Border Color and Swizzle
https://github.com/KhronosGroup/Vulkan-Docs/issues/1421
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Border Color and Swizzle
VkImageViewCreateInfo::components
{
VK_COMPONENT_SWIZZLE_B,
VK_COMPONENT_SWIZZLE_ZERO,
VK_COMPONENT_SWIZZLE_G,
VK_COMPONENT_SWIZZLE_IDENTITY,
}
VkSamplerCreateInfo::addressMode*
VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER
Border color: (0, 0, 1, 1)
?
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Border Color and Swizzle
https://github.com/KhronosGroup/Vulkan-Docs/issues/1421
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Texel Input Operations
1)Coordinate conversion
2)Coordinate validation (will Texel Replacement happen?)
3)Reading texel from image memory (and rearrange components)
4)Format conversion (e.g. UNORM or sRGB)
5)Texel Replacement (border colors are replaced here)
6)Expansion to RGBA
7)Component swizzle
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Coordinate Conversion
Converting normalized coordinates to integer texel coordinates.
Clamping and modifying values depending on the addressing mode.
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Coordinate Validation
Deciding if texel replacement will take place.
Related to border colors as well as robustness features.
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Reading Texel from Image
Actually getting the value from image memory.
Implies reordering the existing components (R, RG, RGB, RGBA)
to standard RGBA order (e.g. BGR to RGB).
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Format Conversion
Conversion of integer values to float.
Applying sRGB curve if needed.
Texel in RGB order, UNORM
R G B
00010110 11110111 00010000
color.r = 0.0862745098039216
color.g = 0.9686274509803922
color.b = 0.0627450980392157
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Texel Replacement
Includes taking the border color and cutting it short so it only
has the components present in the original image, to act “as if”
the border color was actually part of the image.
Example: BGR_UNORM format
Border color: (0.0, 0.0, 1.0, 0.5)
Components used: (0.0, 0.0, 1.0)
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Expansion to RGBA
Expanding the texel color (which may come from the border) to
the 4 standard components: RGBA. Missing color components are
filled with zeros and if the alpha is missing it’s filled with one.
Example: BGR_UNORM format
Border color: (0.0, 0.0, 1.0, 0.5)
Components used: (0.0, 0.0, 1.0)
Expanded to RGBA: (0.0, 0.0, 1.0, 1.0)
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
Component Swizzle
Apply component swizzle from image view.
Example: BGR_UNORM format. Swizzle B, Zero, One, Identity.
Border color: (0.0, 0.0, 1.0, 0.5)
Components used: (0.0, 0.0, 1.0)
Expanded to RGBA: (0.0, 0.0, 1.0, 1.0)
Swizzle applied: (1.0, 0.0, 1.0, 1.0)
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
VK_EXT_custom_border_color
Already out. No restrictions on non-identity swizzle. What to do?
Option A) Vendors should fix their implementations!
Can they do this? What if not possible/practical?
Option B) Backpedal a bit, make behavior undefined unless some
other feature is present. Allow implementations to ship custom
border colors.
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
VK_EXT_border_color_swizzle
Allows indicating the implementation does not support rearranging
color components with problematic colors, including custom ones.
VkPhysicalDeviceBorderColorSwizzleFeaturesEXT::borderColorSwizzle
Allows indicating the implementation supports that, but applications
need to provide the color swizzle also when creating the sampler.
...BorderColorSwizzleFeaturesEXT::borderColorSwizzleFromImage
VkSamplerBorderColorComponentMappingCreateInfoEXT
Drawback: lowers the bar for applications wanting to use a single
code path.
Questions?
Fun with border colors in Vulkan
Ricardo Garcia, 2022-06-02 FOSDEM
We’re hiring!
https://www.igalia.com/jobs/
Fun with border colors in Vulkan -  Ricardo Garcia

More Related Content

More from Igalia

Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesIgalia
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSIgalia
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webIgalia
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersIgalia
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...Igalia
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on RaspberryIgalia
 
Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...Igalia
 
Async page flip in DRM atomic API
Async page flip in DRM  atomic APIAsync page flip in DRM  atomic API
Async page flip in DRM atomic APIIgalia
 
From the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by StepFrom the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by StepIgalia
 
Migrating Babel from CommonJS to ESM
Migrating Babel     from CommonJS to ESMMigrating Babel     from CommonJS to ESM
Migrating Babel from CommonJS to ESMIgalia
 
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...Igalia
 
Freedreno on Android – XDC 2023
Freedreno on Android          – XDC 2023Freedreno on Android          – XDC 2023
Freedreno on Android – XDC 2023Igalia
 
On-going challenges in the Raspberry Pi driver stack – XDC 2023
On-going challenges in the Raspberry Pi driver stack – XDC 2023On-going challenges in the Raspberry Pi driver stack – XDC 2023
On-going challenges in the Raspberry Pi driver stack – XDC 2023Igalia
 
Status Update of the VKMS DRM driver – XDC 2023
Status Update of the VKMS DRM driver – XDC 2023Status Update of the VKMS DRM driver – XDC 2023
Status Update of the VKMS DRM driver – XDC 2023Igalia
 
Having fun with GPU resets in Linux – XDC 2023
Having fun with GPU resets in Linux – XDC  2023Having fun with GPU resets in Linux – XDC  2023
Having fun with GPU resets in Linux – XDC 2023Igalia
 
Etnaviv: Status update –  XDC 2023
Etnaviv: Status update     –    XDC 2023Etnaviv: Status update     –    XDC 2023
Etnaviv: Status update –  XDC 2023Igalia
 
Debugging GPU faults: QoL tools for your driver – XDC 2023
Debugging GPU faults: QoL tools for your driver – XDC 2023Debugging GPU faults: QoL tools for your driver – XDC 2023
Debugging GPU faults: QoL tools for your driver – XDC 2023Igalia
 
To crash or not to crash: If you do at least recover fast! – XC 2023
To crash or not to crash: If you do at least recover fast! – XC 2023To crash or not to crash: If you do at least recover fast! – XC 2023
To crash or not to crash: If you do at least recover fast! – XC 2023Igalia
 
Status of the Vulkan Video ecosystem – XDC 2023
Status of the Vulkan Video ecosystem – XDC 2023Status of the Vulkan Video ecosystem – XDC 2023
Status of the Vulkan Video ecosystem – XDC 2023Igalia
 
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluation
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluationv3dv: Experience using gfxreconstruct/apitrace traces for performance evaluation
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluationIgalia
 

More from Igalia (20)

Graphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devicesGraphics stack updates for Raspberry Pi devices
Graphics stack updates for Raspberry Pi devices
 
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOSDelegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
Delegated Compositing - Utilizing Wayland Protocols for Chromium on ChromeOS
 
MessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the webMessageFormat: The future of i18n on the web
MessageFormat: The future of i18n on the web
 
Replacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shadersReplacing the geometry pipeline with mesh shaders
Replacing the geometry pipeline with mesh shaders
 
I'm not an AMD expert, but...
I'm not an AMD expert, but...I'm not an AMD expert, but...
I'm not an AMD expert, but...
 
Status of Vulkan on Raspberry
Status of Vulkan on RaspberryStatus of Vulkan on Raspberry
Status of Vulkan on Raspberry
 
Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...Enable hardware acceleration for GL applications without glamor on Xorg modes...
Enable hardware acceleration for GL applications without glamor on Xorg modes...
 
Async page flip in DRM atomic API
Async page flip in DRM  atomic APIAsync page flip in DRM  atomic API
Async page flip in DRM atomic API
 
From the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by StepFrom the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by Step
 
Migrating Babel from CommonJS to ESM
Migrating Babel     from CommonJS to ESMMigrating Babel     from CommonJS to ESM
Migrating Babel from CommonJS to ESM
 
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...
The rainbow treasure map: Advanced color management on Linux with AMD/Steam D...
 
Freedreno on Android – XDC 2023
Freedreno on Android          – XDC 2023Freedreno on Android          – XDC 2023
Freedreno on Android – XDC 2023
 
On-going challenges in the Raspberry Pi driver stack – XDC 2023
On-going challenges in the Raspberry Pi driver stack – XDC 2023On-going challenges in the Raspberry Pi driver stack – XDC 2023
On-going challenges in the Raspberry Pi driver stack – XDC 2023
 
Status Update of the VKMS DRM driver – XDC 2023
Status Update of the VKMS DRM driver – XDC 2023Status Update of the VKMS DRM driver – XDC 2023
Status Update of the VKMS DRM driver – XDC 2023
 
Having fun with GPU resets in Linux – XDC 2023
Having fun with GPU resets in Linux – XDC  2023Having fun with GPU resets in Linux – XDC  2023
Having fun with GPU resets in Linux – XDC 2023
 
Etnaviv: Status update –  XDC 2023
Etnaviv: Status update     –    XDC 2023Etnaviv: Status update     –    XDC 2023
Etnaviv: Status update –  XDC 2023
 
Debugging GPU faults: QoL tools for your driver – XDC 2023
Debugging GPU faults: QoL tools for your driver – XDC 2023Debugging GPU faults: QoL tools for your driver – XDC 2023
Debugging GPU faults: QoL tools for your driver – XDC 2023
 
To crash or not to crash: If you do at least recover fast! – XC 2023
To crash or not to crash: If you do at least recover fast! – XC 2023To crash or not to crash: If you do at least recover fast! – XC 2023
To crash or not to crash: If you do at least recover fast! – XC 2023
 
Status of the Vulkan Video ecosystem – XDC 2023
Status of the Vulkan Video ecosystem – XDC 2023Status of the Vulkan Video ecosystem – XDC 2023
Status of the Vulkan Video ecosystem – XDC 2023
 
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluation
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluationv3dv: Experience using gfxreconstruct/apitrace traces for performance evaluation
v3dv: Experience using gfxreconstruct/apitrace traces for performance evaluation
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024BookNet Canada
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC BiblioShare - Tech Forum 2024
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Panjabi Bagh 🔝 9953056974 🔝 Delhi escort Service
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 

Fun with border colors in Vulkan - Ricardo Garcia

  • 1. Fun with border colors in Vulkan A story about VK_EXT_border_color_swizzle Ricardo Garcia 2022-02-06 FOSDEM
  • 2. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Sampling in Vulkan GLSL vec4 color = texture(sampler, coords); Image View (B8G8R8_UNORM) B G R 00010000 11110111 00010110 color.r = 0.0862745098039216 color.g = 0.9686274509803922 color.b = 0.0627450980392157 color.a = 1.0
  • 3. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Normalized Coordinates GLSL vec4 color = texture(sampler, coords); 0,0 1,1 x x x x VkSamplerCreateInfo .addressModeU .addressModeV .addressModeW
  • 4. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Address Mode Image source: Aras Pranckevičius, https://twitter.com/aras_p/status/1480199231772237826
  • 5. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Border Color VkSamplerCreateInfo::borderColor VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE // VK_EXT_custom_border_color VK_BORDER_COLOR_FLOAT_CUSTOM_EXT
  • 6. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Image View Swizzle GLSL vec4 color = texture(sampler, coords); color.r = 0.0862745098039216 color.g = 0.9686274509803922 color.b = 0.0627450980392157 color.a = 1.0 // Component reordering, // replacement or duplication. VkImageViewCreateInfo::components { VkComponentSwizzle r, g, b, a; } Image View (B8G8R8_UNORM) B G R 00010000 11110111 00010110
  • 7. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Border Color and Swizzle https://github.com/KhronosGroup/Vulkan-Docs/issues/1421
  • 8. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Border Color and Swizzle VkImageViewCreateInfo::components { VK_COMPONENT_SWIZZLE_B, VK_COMPONENT_SWIZZLE_ZERO, VK_COMPONENT_SWIZZLE_G, VK_COMPONENT_SWIZZLE_IDENTITY, } VkSamplerCreateInfo::addressMode* VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER Border color: (0, 0, 1, 1) ?
  • 9. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Border Color and Swizzle https://github.com/KhronosGroup/Vulkan-Docs/issues/1421
  • 10. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Texel Input Operations 1)Coordinate conversion 2)Coordinate validation (will Texel Replacement happen?) 3)Reading texel from image memory (and rearrange components) 4)Format conversion (e.g. UNORM or sRGB) 5)Texel Replacement (border colors are replaced here) 6)Expansion to RGBA 7)Component swizzle
  • 11. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Coordinate Conversion Converting normalized coordinates to integer texel coordinates. Clamping and modifying values depending on the addressing mode.
  • 12. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Coordinate Validation Deciding if texel replacement will take place. Related to border colors as well as robustness features.
  • 13. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Reading Texel from Image Actually getting the value from image memory. Implies reordering the existing components (R, RG, RGB, RGBA) to standard RGBA order (e.g. BGR to RGB).
  • 14. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Format Conversion Conversion of integer values to float. Applying sRGB curve if needed. Texel in RGB order, UNORM R G B 00010110 11110111 00010000 color.r = 0.0862745098039216 color.g = 0.9686274509803922 color.b = 0.0627450980392157
  • 15. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Texel Replacement Includes taking the border color and cutting it short so it only has the components present in the original image, to act “as if” the border color was actually part of the image. Example: BGR_UNORM format Border color: (0.0, 0.0, 1.0, 0.5) Components used: (0.0, 0.0, 1.0)
  • 16. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Expansion to RGBA Expanding the texel color (which may come from the border) to the 4 standard components: RGBA. Missing color components are filled with zeros and if the alpha is missing it’s filled with one. Example: BGR_UNORM format Border color: (0.0, 0.0, 1.0, 0.5) Components used: (0.0, 0.0, 1.0) Expanded to RGBA: (0.0, 0.0, 1.0, 1.0)
  • 17. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM Component Swizzle Apply component swizzle from image view. Example: BGR_UNORM format. Swizzle B, Zero, One, Identity. Border color: (0.0, 0.0, 1.0, 0.5) Components used: (0.0, 0.0, 1.0) Expanded to RGBA: (0.0, 0.0, 1.0, 1.0) Swizzle applied: (1.0, 0.0, 1.0, 1.0)
  • 18. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM VK_EXT_custom_border_color Already out. No restrictions on non-identity swizzle. What to do? Option A) Vendors should fix their implementations! Can they do this? What if not possible/practical? Option B) Backpedal a bit, make behavior undefined unless some other feature is present. Allow implementations to ship custom border colors.
  • 19. Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM VK_EXT_border_color_swizzle Allows indicating the implementation does not support rearranging color components with problematic colors, including custom ones. VkPhysicalDeviceBorderColorSwizzleFeaturesEXT::borderColorSwizzle Allows indicating the implementation supports that, but applications need to provide the color swizzle also when creating the sampler. ...BorderColorSwizzleFeaturesEXT::borderColorSwizzleFromImage VkSamplerBorderColorComponentMappingCreateInfoEXT Drawback: lowers the bar for applications wanting to use a single code path.
  • 20. Questions? Fun with border colors in Vulkan Ricardo Garcia, 2022-06-02 FOSDEM We’re hiring! https://www.igalia.com/jobs/