Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
TextureType.h
Go to the documentation of this file.
1#pragma once
2#include <vulkan/vulkan_core.h>
3#include <cstdint>
4
5namespace EngineCore {
6
26
43constexpr VkFormat getVkFormat(TextureType type, int bits, int components) {
44 // For 8-bit textures, type determines SRGB vs UNORM
45 if (bits == 8) {
46 switch (components) {
47 case 1:
48 // Single channel
49 switch (type) {
53 return VK_FORMAT_R8_SRGB;
57 return VK_FORMAT_R8_UNORM;
58 }
59 break;
60 case 2:
61 // Two channels
62 switch (type) {
66 return VK_FORMAT_R8G8_SRGB;
70 return VK_FORMAT_R8G8_UNORM;
71 }
72 break;
73 case 3:
74 // Three channels (RGB)
75 switch (type) {
79 return VK_FORMAT_R8G8B8_SRGB;
83 return VK_FORMAT_R8G8B8_UNORM;
84 }
85 break;
86 case 4:
87 default:
88 // Four channels (RGBA) - most common case
89 switch (type) {
93 return VK_FORMAT_R8G8B8A8_SRGB;
97 return VK_FORMAT_R8G8B8A8_UNORM;
98 }
99 break;
100 }
101 }
102
103 // For 16-bit textures, always use SFLOAT (linear HDR data)
104 if (bits == 16) {
105 switch (components) {
106 case 1: return VK_FORMAT_R16_SFLOAT;
107 case 2: return VK_FORMAT_R16G16_SFLOAT;
108 case 3: return VK_FORMAT_R16G16B16_SFLOAT;
109 case 4:
110 default: return VK_FORMAT_R16G16B16A16_SFLOAT;
111 }
112 }
113
114 // For 32-bit textures, always use SFLOAT (linear HDR data)
115 if (bits == 32) {
116 switch (components) {
117 case 1: return VK_FORMAT_R32_SFLOAT;
118 case 2: return VK_FORMAT_R32G32_SFLOAT;
119 case 3: return VK_FORMAT_R32G32B32_SFLOAT;
120 case 4:
121 default: return VK_FORMAT_R32G32B32A32_SFLOAT;
122 }
123 }
124
125 // Fallback for unknown bit depths
126 return VK_FORMAT_R8G8B8A8_SRGB;
127}
128
135constexpr bool requiresLinearFormat(TextureType type) {
136 switch (type) {
140 return true;
144 default:
145 return false;
146 }
147}
148
149} // namespace EngineCore
Log category system implementation.
constexpr VkFormat getVkFormat(TextureType type, int bits, int components)
Get the correct VkFormat based on texture type and image properties.
Definition TextureType.h:43
constexpr bool requiresLinearFormat(TextureType type)
Check if a texture type requires linear (non-SRGB) format.
TextureType
Represents the semantic type of a texture, determining its Vulkan format.
Definition TextureType.h:18
@ Lightmap
HDR baked lighting data (SFLOAT format)
Definition TextureType.h:23
@ Emissive
Color data with gamma (SRGB format for 8-bit)
Definition TextureType.h:22
@ BaseColor
Color data with gamma (SRGB format for 8-bit)
Definition TextureType.h:19
@ Unknown
Fallback type, uses SRGB as default.
Definition TextureType.h:24
@ Normal
Linear data for normal maps (UNORM format for 8-bit)
Definition TextureType.h:20
@ MetallicRoughness
Linear data for PBR parameters (UNORM format for 8-bit)
Definition TextureType.h:21