public static class PixelFormatsWhat the RHI needs to know about a PixelFormat.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
A lookup rather than a switch at every call site. Every one of these questions is asked while validating a copy, sizing a staging buffer or choosing an attachment layout, and getting block size wrong is the bug where a compressed texture uploads as a quarter of an image.
Methods (13)
public static int BlockSize(this PixelFormat format)Bytes per block — per pixel for uncompressed formats.
public static (int Width, int Height) BlockExtent(this PixelFormat format)How many pixels wide and tall one block covers.
public static bool IsCompressed(this PixelFormat format)Whether the format is block-compressed.
public static bool HasDepth(this PixelFormat format)Whether the format carries depth.
public static bool HasStencil(this PixelFormat format)Whether the format carries stencil.
public static bool IsDepthStencil(this PixelFormat format)Whether the format is a depth or stencil format, and therefore not a colour one.
public static DescriptorSampleType SampleTypeOf(this PixelFormat format)How a shader reads a texture in this format, for the layout that declares it.
public static bool Accepts(this DescriptorSampleType declared, PixelFormat format)Whether a texture in this format may be read through a binding declared that way.
public static bool IsSrgb(this PixelFormat format)Whether the hardware converts to and from sRGB on access.
public static PixelFormat ToSrgb(this PixelFormat format)The sRGB form of a format, or the format itself if it has none.
public static PixelFormat ToLinear(this PixelFormat format)The linear form of a format, or the format itself if it is already linear.
public static long LevelSize(this PixelFormat format, int width, int height, int depth = 1)How many bytes one mip level of a texture occupies, tightly packed.
public static int MipLevelCount(int width, int height, int depth = 1)How many mip levels a texture of this size can have, down to 1×1.
Used by (22)
- BlockCompressorVixen.Core.Imaging
- BlockEncoderTestsVixen.Core.Imaging.Tests
- CubeMapVixen.Core.Imaging
- DataFormatDescriptorVixen.Core.Imaging
- GlDeviceVixen.Graphics.OpenGL
- GlFormatsVixen.Graphics.OpenGL
- GlSwapChainVixen.Graphics.OpenGL
- GraphicsPipelineDescriptionVixen.Graphics
- HiZPyramidVixen.Rendering
- Ktx2Vixen.Core.Imaging
- OpenXrFormatsVixen.Xr.OpenXR
- PixelFormatTestsVixen.Graphics.Tests
- TextureDataVixen.Core.Imaging
- TextureDescriptionVixen.Graphics
- VulkanCommandListVixen.Graphics.Vulkan
- VulkanDeviceVixen.Graphics.Vulkan
- VulkanFormatTestsVixen.Graphics.Vulkan.Tests
- VulkanFormatsVixen.Graphics.Vulkan
- WebGpuCommandListVixen.Graphics.WebGPU
- WebGpuDeviceVixen.Graphics.WebGPU
- WebGpuFormatsVixen.Graphics.WebGPU
- TextureImporterVixen.Editor.Assets