Skip to content

Shader Development

Carsten Rudolph edited this page Feb 6, 2024 · 8 revisions

This page guides you on how to write portable shader code, that can be shared between the Vulkan and DirectX 12 APIs.

Shader Development

Summary

  • Do write your shaders in HLSL, except if you only ever want to target Vulkan.
  • Do prefer compiling your HLSL shaders using DXC over glslc.
  • Do define each descriptor set in a separate space.
  • Do define all samplers in a separate descriptor set.
  • Don't use combined image samplers.
  • Do use the SPIRV/DXIL macros defined by the intergrated shader targets to write API-specific code.
  • Do keep in mind the different definitions for push constants and input attachments between Vulkan and DirectX.
  • Do define root signatures explicitly when you want to use shader reflection.
  • Don't use static/immutable samplers for anything else than DirectX input attachments when using shader reflection.

Shader Language

Shader Interface

Descriptor Sets and Spaces

Samplers

Render Pass Input Attachments

Combined Image Samplers

Using Shader Reflection