diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/memory.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/surface.h | 552 |
2 files changed, 285 insertions, 275 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 70abd856a..41fd2a6a0 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -53,6 +53,14 @@ void PageTable::Resize(std::size_t address_space_width_in_bits) { | |||
| 53 | 53 | ||
| 54 | pointers.resize(num_page_table_entries); | 54 | pointers.resize(num_page_table_entries); |
| 55 | attributes.resize(num_page_table_entries); | 55 | attributes.resize(num_page_table_entries); |
| 56 | |||
| 57 | // The default is a 39-bit address space, which causes an initial 1GB allocation size. If the | ||
| 58 | // vector size is subsequently decreased (via resize), the vector might not automatically | ||
| 59 | // actually reallocate/resize its underlying allocation, which wastes up to ~800 MB for | ||
| 60 | // 36-bit titles. Call shrink_to_fit to reduce capacity to what's actually in use. | ||
| 61 | |||
| 62 | pointers.shrink_to_fit(); | ||
| 63 | attributes.shrink_to_fit(); | ||
| 56 | } | 64 | } |
| 57 | 65 | ||
| 58 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { | 66 | static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, PageType type) { |
diff --git a/src/video_core/surface.h b/src/video_core/surface.h index 0dd3eb2e4..e23cfecbc 100644 --- a/src/video_core/surface.h +++ b/src/video_core/surface.h | |||
| @@ -125,6 +125,75 @@ enum class SurfaceTarget { | |||
| 125 | TextureCubeArray, | 125 | TextureCubeArray, |
| 126 | }; | 126 | }; |
| 127 | 127 | ||
| 128 | constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ | ||
| 129 | 1, // ABGR8U | ||
| 130 | 1, // ABGR8S | ||
| 131 | 1, // ABGR8UI | ||
| 132 | 1, // B5G6R5U | ||
| 133 | 1, // A2B10G10R10U | ||
| 134 | 1, // A1B5G5R5U | ||
| 135 | 1, // R8U | ||
| 136 | 1, // R8UI | ||
| 137 | 1, // RGBA16F | ||
| 138 | 1, // RGBA16U | ||
| 139 | 1, // RGBA16UI | ||
| 140 | 1, // R11FG11FB10F | ||
| 141 | 1, // RGBA32UI | ||
| 142 | 4, // DXT1 | ||
| 143 | 4, // DXT23 | ||
| 144 | 4, // DXT45 | ||
| 145 | 4, // DXN1 | ||
| 146 | 4, // DXN2UNORM | ||
| 147 | 4, // DXN2SNORM | ||
| 148 | 4, // BC7U | ||
| 149 | 4, // BC6H_UF16 | ||
| 150 | 4, // BC6H_SF16 | ||
| 151 | 4, // ASTC_2D_4X4 | ||
| 152 | 1, // G8R8U | ||
| 153 | 1, // G8R8S | ||
| 154 | 1, // BGRA8 | ||
| 155 | 1, // RGBA32F | ||
| 156 | 1, // RG32F | ||
| 157 | 1, // R32F | ||
| 158 | 1, // R16F | ||
| 159 | 1, // R16U | ||
| 160 | 1, // R16S | ||
| 161 | 1, // R16UI | ||
| 162 | 1, // R16I | ||
| 163 | 1, // RG16 | ||
| 164 | 1, // RG16F | ||
| 165 | 1, // RG16UI | ||
| 166 | 1, // RG16I | ||
| 167 | 1, // RG16S | ||
| 168 | 1, // RGB32F | ||
| 169 | 1, // RGBA8_SRGB | ||
| 170 | 1, // RG8U | ||
| 171 | 1, // RG8S | ||
| 172 | 1, // RG32UI | ||
| 173 | 1, // R32UI | ||
| 174 | 4, // ASTC_2D_8X8 | ||
| 175 | 4, // ASTC_2D_8X5 | ||
| 176 | 4, // ASTC_2D_5X4 | ||
| 177 | 1, // BGRA8_SRGB | ||
| 178 | 4, // DXT1_SRGB | ||
| 179 | 4, // DXT23_SRGB | ||
| 180 | 4, // DXT45_SRGB | ||
| 181 | 4, // BC7U_SRGB | ||
| 182 | 4, // ASTC_2D_4X4_SRGB | ||
| 183 | 4, // ASTC_2D_8X8_SRGB | ||
| 184 | 4, // ASTC_2D_8X5_SRGB | ||
| 185 | 4, // ASTC_2D_5X4_SRGB | ||
| 186 | 4, // ASTC_2D_5X5 | ||
| 187 | 4, // ASTC_2D_5X5_SRGB | ||
| 188 | 4, // ASTC_2D_10X8 | ||
| 189 | 4, // ASTC_2D_10X8_SRGB | ||
| 190 | 1, // Z32F | ||
| 191 | 1, // Z16 | ||
| 192 | 1, // Z24S8 | ||
| 193 | 1, // S8Z24 | ||
| 194 | 1, // Z32FS8 | ||
| 195 | }}; | ||
| 196 | |||
| 128 | /** | 197 | /** |
| 129 | * Gets the compression factor for the specified PixelFormat. This applies to just the | 198 | * Gets the compression factor for the specified PixelFormat. This applies to just the |
| 130 | * "compressed width" and "compressed height", not the overall compression factor of a | 199 | * "compressed width" and "compressed height", not the overall compression factor of a |
| @@ -135,304 +204,237 @@ static constexpr u32 GetCompressionFactor(PixelFormat format) { | |||
| 135 | if (format == PixelFormat::Invalid) | 204 | if (format == PixelFormat::Invalid) |
| 136 | return 0; | 205 | return 0; |
| 137 | 206 | ||
| 138 | constexpr std::array<u32, MaxPixelFormat> compression_factor_table = {{ | ||
| 139 | 1, // ABGR8U | ||
| 140 | 1, // ABGR8S | ||
| 141 | 1, // ABGR8UI | ||
| 142 | 1, // B5G6R5U | ||
| 143 | 1, // A2B10G10R10U | ||
| 144 | 1, // A1B5G5R5U | ||
| 145 | 1, // R8U | ||
| 146 | 1, // R8UI | ||
| 147 | 1, // RGBA16F | ||
| 148 | 1, // RGBA16U | ||
| 149 | 1, // RGBA16UI | ||
| 150 | 1, // R11FG11FB10F | ||
| 151 | 1, // RGBA32UI | ||
| 152 | 4, // DXT1 | ||
| 153 | 4, // DXT23 | ||
| 154 | 4, // DXT45 | ||
| 155 | 4, // DXN1 | ||
| 156 | 4, // DXN2UNORM | ||
| 157 | 4, // DXN2SNORM | ||
| 158 | 4, // BC7U | ||
| 159 | 4, // BC6H_UF16 | ||
| 160 | 4, // BC6H_SF16 | ||
| 161 | 4, // ASTC_2D_4X4 | ||
| 162 | 1, // G8R8U | ||
| 163 | 1, // G8R8S | ||
| 164 | 1, // BGRA8 | ||
| 165 | 1, // RGBA32F | ||
| 166 | 1, // RG32F | ||
| 167 | 1, // R32F | ||
| 168 | 1, // R16F | ||
| 169 | 1, // R16U | ||
| 170 | 1, // R16S | ||
| 171 | 1, // R16UI | ||
| 172 | 1, // R16I | ||
| 173 | 1, // RG16 | ||
| 174 | 1, // RG16F | ||
| 175 | 1, // RG16UI | ||
| 176 | 1, // RG16I | ||
| 177 | 1, // RG16S | ||
| 178 | 1, // RGB32F | ||
| 179 | 1, // RGBA8_SRGB | ||
| 180 | 1, // RG8U | ||
| 181 | 1, // RG8S | ||
| 182 | 1, // RG32UI | ||
| 183 | 1, // R32UI | ||
| 184 | 4, // ASTC_2D_8X8 | ||
| 185 | 4, // ASTC_2D_8X5 | ||
| 186 | 4, // ASTC_2D_5X4 | ||
| 187 | 1, // BGRA8_SRGB | ||
| 188 | 4, // DXT1_SRGB | ||
| 189 | 4, // DXT23_SRGB | ||
| 190 | 4, // DXT45_SRGB | ||
| 191 | 4, // BC7U_SRGB | ||
| 192 | 4, // ASTC_2D_4X4_SRGB | ||
| 193 | 4, // ASTC_2D_8X8_SRGB | ||
| 194 | 4, // ASTC_2D_8X5_SRGB | ||
| 195 | 4, // ASTC_2D_5X4_SRGB | ||
| 196 | 4, // ASTC_2D_5X5 | ||
| 197 | 4, // ASTC_2D_5X5_SRGB | ||
| 198 | 4, // ASTC_2D_10X8 | ||
| 199 | 4, // ASTC_2D_10X8_SRGB | ||
| 200 | 1, // Z32F | ||
| 201 | 1, // Z16 | ||
| 202 | 1, // Z24S8 | ||
| 203 | 1, // S8Z24 | ||
| 204 | 1, // Z32FS8 | ||
| 205 | }}; | ||
| 206 | |||
| 207 | ASSERT(static_cast<std::size_t>(format) < compression_factor_table.size()); | 207 | ASSERT(static_cast<std::size_t>(format) < compression_factor_table.size()); |
| 208 | return compression_factor_table[static_cast<std::size_t>(format)]; | 208 | return compression_factor_table[static_cast<std::size_t>(format)]; |
| 209 | } | 209 | } |
| 210 | 210 | ||
| 211 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ | ||
| 212 | 1, // ABGR8U | ||
| 213 | 1, // ABGR8S | ||
| 214 | 1, // ABGR8UI | ||
| 215 | 1, // B5G6R5U | ||
| 216 | 1, // A2B10G10R10U | ||
| 217 | 1, // A1B5G5R5U | ||
| 218 | 1, // R8U | ||
| 219 | 1, // R8UI | ||
| 220 | 1, // RGBA16F | ||
| 221 | 1, // RGBA16U | ||
| 222 | 1, // RGBA16UI | ||
| 223 | 1, // R11FG11FB10F | ||
| 224 | 1, // RGBA32UI | ||
| 225 | 4, // DXT1 | ||
| 226 | 4, // DXT23 | ||
| 227 | 4, // DXT45 | ||
| 228 | 4, // DXN1 | ||
| 229 | 4, // DXN2UNORM | ||
| 230 | 4, // DXN2SNORM | ||
| 231 | 4, // BC7U | ||
| 232 | 4, // BC6H_UF16 | ||
| 233 | 4, // BC6H_SF16 | ||
| 234 | 4, // ASTC_2D_4X4 | ||
| 235 | 1, // G8R8U | ||
| 236 | 1, // G8R8S | ||
| 237 | 1, // BGRA8 | ||
| 238 | 1, // RGBA32F | ||
| 239 | 1, // RG32F | ||
| 240 | 1, // R32F | ||
| 241 | 1, // R16F | ||
| 242 | 1, // R16U | ||
| 243 | 1, // R16S | ||
| 244 | 1, // R16UI | ||
| 245 | 1, // R16I | ||
| 246 | 1, // RG16 | ||
| 247 | 1, // RG16F | ||
| 248 | 1, // RG16UI | ||
| 249 | 1, // RG16I | ||
| 250 | 1, // RG16S | ||
| 251 | 1, // RGB32F | ||
| 252 | 1, // RGBA8_SRGB | ||
| 253 | 1, // RG8U | ||
| 254 | 1, // RG8S | ||
| 255 | 1, // RG32UI | ||
| 256 | 1, // R32UI | ||
| 257 | 8, // ASTC_2D_8X8 | ||
| 258 | 8, // ASTC_2D_8X5 | ||
| 259 | 5, // ASTC_2D_5X4 | ||
| 260 | 1, // BGRA8_SRGB | ||
| 261 | 4, // DXT1_SRGB | ||
| 262 | 4, // DXT23_SRGB | ||
| 263 | 4, // DXT45_SRGB | ||
| 264 | 4, // BC7U_SRGB | ||
| 265 | 4, // ASTC_2D_4X4_SRGB | ||
| 266 | 8, // ASTC_2D_8X8_SRGB | ||
| 267 | 8, // ASTC_2D_8X5_SRGB | ||
| 268 | 5, // ASTC_2D_5X4_SRGB | ||
| 269 | 5, // ASTC_2D_5X5 | ||
| 270 | 5, // ASTC_2D_5X5_SRGB | ||
| 271 | 10, // ASTC_2D_10X8 | ||
| 272 | 10, // ASTC_2D_10X8_SRGB | ||
| 273 | 1, // Z32F | ||
| 274 | 1, // Z16 | ||
| 275 | 1, // Z24S8 | ||
| 276 | 1, // S8Z24 | ||
| 277 | 1, // Z32FS8 | ||
| 278 | }}; | ||
| 279 | |||
| 211 | static constexpr u32 GetDefaultBlockWidth(PixelFormat format) { | 280 | static constexpr u32 GetDefaultBlockWidth(PixelFormat format) { |
| 212 | if (format == PixelFormat::Invalid) | 281 | if (format == PixelFormat::Invalid) |
| 213 | return 0; | 282 | return 0; |
| 214 | constexpr std::array<u32, MaxPixelFormat> block_width_table = {{ | 283 | |
| 215 | 1, // ABGR8U | ||
| 216 | 1, // ABGR8S | ||
| 217 | 1, // ABGR8UI | ||
| 218 | 1, // B5G6R5U | ||
| 219 | 1, // A2B10G10R10U | ||
| 220 | 1, // A1B5G5R5U | ||
| 221 | 1, // R8U | ||
| 222 | 1, // R8UI | ||
| 223 | 1, // RGBA16F | ||
| 224 | 1, // RGBA16U | ||
| 225 | 1, // RGBA16UI | ||
| 226 | 1, // R11FG11FB10F | ||
| 227 | 1, // RGBA32UI | ||
| 228 | 4, // DXT1 | ||
| 229 | 4, // DXT23 | ||
| 230 | 4, // DXT45 | ||
| 231 | 4, // DXN1 | ||
| 232 | 4, // DXN2UNORM | ||
| 233 | 4, // DXN2SNORM | ||
| 234 | 4, // BC7U | ||
| 235 | 4, // BC6H_UF16 | ||
| 236 | 4, // BC6H_SF16 | ||
| 237 | 4, // ASTC_2D_4X4 | ||
| 238 | 1, // G8R8U | ||
| 239 | 1, // G8R8S | ||
| 240 | 1, // BGRA8 | ||
| 241 | 1, // RGBA32F | ||
| 242 | 1, // RG32F | ||
| 243 | 1, // R32F | ||
| 244 | 1, // R16F | ||
| 245 | 1, // R16U | ||
| 246 | 1, // R16S | ||
| 247 | 1, // R16UI | ||
| 248 | 1, // R16I | ||
| 249 | 1, // RG16 | ||
| 250 | 1, // RG16F | ||
| 251 | 1, // RG16UI | ||
| 252 | 1, // RG16I | ||
| 253 | 1, // RG16S | ||
| 254 | 1, // RGB32F | ||
| 255 | 1, // RGBA8_SRGB | ||
| 256 | 1, // RG8U | ||
| 257 | 1, // RG8S | ||
| 258 | 1, // RG32UI | ||
| 259 | 1, // R32UI | ||
| 260 | 8, // ASTC_2D_8X8 | ||
| 261 | 8, // ASTC_2D_8X5 | ||
| 262 | 5, // ASTC_2D_5X4 | ||
| 263 | 1, // BGRA8_SRGB | ||
| 264 | 4, // DXT1_SRGB | ||
| 265 | 4, // DXT23_SRGB | ||
| 266 | 4, // DXT45_SRGB | ||
| 267 | 4, // BC7U_SRGB | ||
| 268 | 4, // ASTC_2D_4X4_SRGB | ||
| 269 | 8, // ASTC_2D_8X8_SRGB | ||
| 270 | 8, // ASTC_2D_8X5_SRGB | ||
| 271 | 5, // ASTC_2D_5X4_SRGB | ||
| 272 | 5, // ASTC_2D_5X5 | ||
| 273 | 5, // ASTC_2D_5X5_SRGB | ||
| 274 | 10, // ASTC_2D_10X8 | ||
| 275 | 10, // ASTC_2D_10X8_SRGB | ||
| 276 | 1, // Z32F | ||
| 277 | 1, // Z16 | ||
| 278 | 1, // Z24S8 | ||
| 279 | 1, // S8Z24 | ||
| 280 | 1, // Z32FS8 | ||
| 281 | }}; | ||
| 282 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); | 284 | ASSERT(static_cast<std::size_t>(format) < block_width_table.size()); |
| 283 | return block_width_table[static_cast<std::size_t>(format)]; | 285 | return block_width_table[static_cast<std::size_t>(format)]; |
| 284 | } | 286 | } |
| 285 | 287 | ||
| 288 | constexpr std::array<u32, MaxPixelFormat> block_height_table = {{ | ||
| 289 | 1, // ABGR8U | ||
| 290 | 1, // ABGR8S | ||
| 291 | 1, // ABGR8UI | ||
| 292 | 1, // B5G6R5U | ||
| 293 | 1, // A2B10G10R10U | ||
| 294 | 1, // A1B5G5R5U | ||
| 295 | 1, // R8U | ||
| 296 | 1, // R8UI | ||
| 297 | 1, // RGBA16F | ||
| 298 | 1, // RGBA16U | ||
| 299 | 1, // RGBA16UI | ||
| 300 | 1, // R11FG11FB10F | ||
| 301 | 1, // RGBA32UI | ||
| 302 | 4, // DXT1 | ||
| 303 | 4, // DXT23 | ||
| 304 | 4, // DXT45 | ||
| 305 | 4, // DXN1 | ||
| 306 | 4, // DXN2UNORM | ||
| 307 | 4, // DXN2SNORM | ||
| 308 | 4, // BC7U | ||
| 309 | 4, // BC6H_UF16 | ||
| 310 | 4, // BC6H_SF16 | ||
| 311 | 4, // ASTC_2D_4X4 | ||
| 312 | 1, // G8R8U | ||
| 313 | 1, // G8R8S | ||
| 314 | 1, // BGRA8 | ||
| 315 | 1, // RGBA32F | ||
| 316 | 1, // RG32F | ||
| 317 | 1, // R32F | ||
| 318 | 1, // R16F | ||
| 319 | 1, // R16U | ||
| 320 | 1, // R16S | ||
| 321 | 1, // R16UI | ||
| 322 | 1, // R16I | ||
| 323 | 1, // RG16 | ||
| 324 | 1, // RG16F | ||
| 325 | 1, // RG16UI | ||
| 326 | 1, // RG16I | ||
| 327 | 1, // RG16S | ||
| 328 | 1, // RGB32F | ||
| 329 | 1, // RGBA8_SRGB | ||
| 330 | 1, // RG8U | ||
| 331 | 1, // RG8S | ||
| 332 | 1, // RG32UI | ||
| 333 | 1, // R32UI | ||
| 334 | 8, // ASTC_2D_8X8 | ||
| 335 | 5, // ASTC_2D_8X5 | ||
| 336 | 4, // ASTC_2D_5X4 | ||
| 337 | 1, // BGRA8_SRGB | ||
| 338 | 4, // DXT1_SRGB | ||
| 339 | 4, // DXT23_SRGB | ||
| 340 | 4, // DXT45_SRGB | ||
| 341 | 4, // BC7U_SRGB | ||
| 342 | 4, // ASTC_2D_4X4_SRGB | ||
| 343 | 8, // ASTC_2D_8X8_SRGB | ||
| 344 | 5, // ASTC_2D_8X5_SRGB | ||
| 345 | 4, // ASTC_2D_5X4_SRGB | ||
| 346 | 5, // ASTC_2D_5X5 | ||
| 347 | 5, // ASTC_2D_5X5_SRGB | ||
| 348 | 8, // ASTC_2D_10X8 | ||
| 349 | 8, // ASTC_2D_10X8_SRGB | ||
| 350 | 1, // Z32F | ||
| 351 | 1, // Z16 | ||
| 352 | 1, // Z24S8 | ||
| 353 | 1, // S8Z24 | ||
| 354 | 1, // Z32FS8 | ||
| 355 | }}; | ||
| 356 | |||
| 286 | static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { | 357 | static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { |
| 287 | if (format == PixelFormat::Invalid) | 358 | if (format == PixelFormat::Invalid) |
| 288 | return 0; | 359 | return 0; |
| 289 | 360 | ||
| 290 | constexpr std::array<u32, MaxPixelFormat> block_height_table = {{ | ||
| 291 | 1, // ABGR8U | ||
| 292 | 1, // ABGR8S | ||
| 293 | 1, // ABGR8UI | ||
| 294 | 1, // B5G6R5U | ||
| 295 | 1, // A2B10G10R10U | ||
| 296 | 1, // A1B5G5R5U | ||
| 297 | 1, // R8U | ||
| 298 | 1, // R8UI | ||
| 299 | 1, // RGBA16F | ||
| 300 | 1, // RGBA16U | ||
| 301 | 1, // RGBA16UI | ||
| 302 | 1, // R11FG11FB10F | ||
| 303 | 1, // RGBA32UI | ||
| 304 | 4, // DXT1 | ||
| 305 | 4, // DXT23 | ||
| 306 | 4, // DXT45 | ||
| 307 | 4, // DXN1 | ||
| 308 | 4, // DXN2UNORM | ||
| 309 | 4, // DXN2SNORM | ||
| 310 | 4, // BC7U | ||
| 311 | 4, // BC6H_UF16 | ||
| 312 | 4, // BC6H_SF16 | ||
| 313 | 4, // ASTC_2D_4X4 | ||
| 314 | 1, // G8R8U | ||
| 315 | 1, // G8R8S | ||
| 316 | 1, // BGRA8 | ||
| 317 | 1, // RGBA32F | ||
| 318 | 1, // RG32F | ||
| 319 | 1, // R32F | ||
| 320 | 1, // R16F | ||
| 321 | 1, // R16U | ||
| 322 | 1, // R16S | ||
| 323 | 1, // R16UI | ||
| 324 | 1, // R16I | ||
| 325 | 1, // RG16 | ||
| 326 | 1, // RG16F | ||
| 327 | 1, // RG16UI | ||
| 328 | 1, // RG16I | ||
| 329 | 1, // RG16S | ||
| 330 | 1, // RGB32F | ||
| 331 | 1, // RGBA8_SRGB | ||
| 332 | 1, // RG8U | ||
| 333 | 1, // RG8S | ||
| 334 | 1, // RG32UI | ||
| 335 | 1, // R32UI | ||
| 336 | 8, // ASTC_2D_8X8 | ||
| 337 | 5, // ASTC_2D_8X5 | ||
| 338 | 4, // ASTC_2D_5X4 | ||
| 339 | 1, // BGRA8_SRGB | ||
| 340 | 4, // DXT1_SRGB | ||
| 341 | 4, // DXT23_SRGB | ||
| 342 | 4, // DXT45_SRGB | ||
| 343 | 4, // BC7U_SRGB | ||
| 344 | 4, // ASTC_2D_4X4_SRGB | ||
| 345 | 8, // ASTC_2D_8X8_SRGB | ||
| 346 | 5, // ASTC_2D_8X5_SRGB | ||
| 347 | 4, // ASTC_2D_5X4_SRGB | ||
| 348 | 5, // ASTC_2D_5X5 | ||
| 349 | 5, // ASTC_2D_5X5_SRGB | ||
| 350 | 8, // ASTC_2D_10X8 | ||
| 351 | 8, // ASTC_2D_10X8_SRGB | ||
| 352 | 1, // Z32F | ||
| 353 | 1, // Z16 | ||
| 354 | 1, // Z24S8 | ||
| 355 | 1, // S8Z24 | ||
| 356 | 1, // Z32FS8 | ||
| 357 | }}; | ||
| 358 | |||
| 359 | ASSERT(static_cast<std::size_t>(format) < block_height_table.size()); | 361 | ASSERT(static_cast<std::size_t>(format) < block_height_table.size()); |
| 360 | return block_height_table[static_cast<std::size_t>(format)]; | 362 | return block_height_table[static_cast<std::size_t>(format)]; |
| 361 | } | 363 | } |
| 362 | 364 | ||
| 365 | constexpr std::array<u32, MaxPixelFormat> bpp_table = {{ | ||
| 366 | 32, // ABGR8U | ||
| 367 | 32, // ABGR8S | ||
| 368 | 32, // ABGR8UI | ||
| 369 | 16, // B5G6R5U | ||
| 370 | 32, // A2B10G10R10U | ||
| 371 | 16, // A1B5G5R5U | ||
| 372 | 8, // R8U | ||
| 373 | 8, // R8UI | ||
| 374 | 64, // RGBA16F | ||
| 375 | 64, // RGBA16U | ||
| 376 | 64, // RGBA16UI | ||
| 377 | 32, // R11FG11FB10F | ||
| 378 | 128, // RGBA32UI | ||
| 379 | 64, // DXT1 | ||
| 380 | 128, // DXT23 | ||
| 381 | 128, // DXT45 | ||
| 382 | 64, // DXN1 | ||
| 383 | 128, // DXN2UNORM | ||
| 384 | 128, // DXN2SNORM | ||
| 385 | 128, // BC7U | ||
| 386 | 128, // BC6H_UF16 | ||
| 387 | 128, // BC6H_SF16 | ||
| 388 | 128, // ASTC_2D_4X4 | ||
| 389 | 16, // G8R8U | ||
| 390 | 16, // G8R8S | ||
| 391 | 32, // BGRA8 | ||
| 392 | 128, // RGBA32F | ||
| 393 | 64, // RG32F | ||
| 394 | 32, // R32F | ||
| 395 | 16, // R16F | ||
| 396 | 16, // R16U | ||
| 397 | 16, // R16S | ||
| 398 | 16, // R16UI | ||
| 399 | 16, // R16I | ||
| 400 | 32, // RG16 | ||
| 401 | 32, // RG16F | ||
| 402 | 32, // RG16UI | ||
| 403 | 32, // RG16I | ||
| 404 | 32, // RG16S | ||
| 405 | 96, // RGB32F | ||
| 406 | 32, // RGBA8_SRGB | ||
| 407 | 16, // RG8U | ||
| 408 | 16, // RG8S | ||
| 409 | 64, // RG32UI | ||
| 410 | 32, // R32UI | ||
| 411 | 128, // ASTC_2D_8X8 | ||
| 412 | 128, // ASTC_2D_8X5 | ||
| 413 | 128, // ASTC_2D_5X4 | ||
| 414 | 32, // BGRA8_SRGB | ||
| 415 | 64, // DXT1_SRGB | ||
| 416 | 128, // DXT23_SRGB | ||
| 417 | 128, // DXT45_SRGB | ||
| 418 | 128, // BC7U | ||
| 419 | 128, // ASTC_2D_4X4_SRGB | ||
| 420 | 128, // ASTC_2D_8X8_SRGB | ||
| 421 | 128, // ASTC_2D_8X5_SRGB | ||
| 422 | 128, // ASTC_2D_5X4_SRGB | ||
| 423 | 128, // ASTC_2D_5X5 | ||
| 424 | 128, // ASTC_2D_5X5_SRGB | ||
| 425 | 128, // ASTC_2D_10X8 | ||
| 426 | 128, // ASTC_2D_10X8_SRGB | ||
| 427 | 32, // Z32F | ||
| 428 | 16, // Z16 | ||
| 429 | 32, // Z24S8 | ||
| 430 | 32, // S8Z24 | ||
| 431 | 64, // Z32FS8 | ||
| 432 | }}; | ||
| 433 | |||
| 363 | static constexpr u32 GetFormatBpp(PixelFormat format) { | 434 | static constexpr u32 GetFormatBpp(PixelFormat format) { |
| 364 | if (format == PixelFormat::Invalid) | 435 | if (format == PixelFormat::Invalid) |
| 365 | return 0; | 436 | return 0; |
| 366 | 437 | ||
| 367 | constexpr std::array<u32, MaxPixelFormat> bpp_table = {{ | ||
| 368 | 32, // ABGR8U | ||
| 369 | 32, // ABGR8S | ||
| 370 | 32, // ABGR8UI | ||
| 371 | 16, // B5G6R5U | ||
| 372 | 32, // A2B10G10R10U | ||
| 373 | 16, // A1B5G5R5U | ||
| 374 | 8, // R8U | ||
| 375 | 8, // R8UI | ||
| 376 | 64, // RGBA16F | ||
| 377 | 64, // RGBA16U | ||
| 378 | 64, // RGBA16UI | ||
| 379 | 32, // R11FG11FB10F | ||
| 380 | 128, // RGBA32UI | ||
| 381 | 64, // DXT1 | ||
| 382 | 128, // DXT23 | ||
| 383 | 128, // DXT45 | ||
| 384 | 64, // DXN1 | ||
| 385 | 128, // DXN2UNORM | ||
| 386 | 128, // DXN2SNORM | ||
| 387 | 128, // BC7U | ||
| 388 | 128, // BC6H_UF16 | ||
| 389 | 128, // BC6H_SF16 | ||
| 390 | 128, // ASTC_2D_4X4 | ||
| 391 | 16, // G8R8U | ||
| 392 | 16, // G8R8S | ||
| 393 | 32, // BGRA8 | ||
| 394 | 128, // RGBA32F | ||
| 395 | 64, // RG32F | ||
| 396 | 32, // R32F | ||
| 397 | 16, // R16F | ||
| 398 | 16, // R16U | ||
| 399 | 16, // R16S | ||
| 400 | 16, // R16UI | ||
| 401 | 16, // R16I | ||
| 402 | 32, // RG16 | ||
| 403 | 32, // RG16F | ||
| 404 | 32, // RG16UI | ||
| 405 | 32, // RG16I | ||
| 406 | 32, // RG16S | ||
| 407 | 96, // RGB32F | ||
| 408 | 32, // RGBA8_SRGB | ||
| 409 | 16, // RG8U | ||
| 410 | 16, // RG8S | ||
| 411 | 64, // RG32UI | ||
| 412 | 32, // R32UI | ||
| 413 | 128, // ASTC_2D_8X8 | ||
| 414 | 128, // ASTC_2D_8X5 | ||
| 415 | 128, // ASTC_2D_5X4 | ||
| 416 | 32, // BGRA8_SRGB | ||
| 417 | 64, // DXT1_SRGB | ||
| 418 | 128, // DXT23_SRGB | ||
| 419 | 128, // DXT45_SRGB | ||
| 420 | 128, // BC7U | ||
| 421 | 128, // ASTC_2D_4X4_SRGB | ||
| 422 | 128, // ASTC_2D_8X8_SRGB | ||
| 423 | 128, // ASTC_2D_8X5_SRGB | ||
| 424 | 128, // ASTC_2D_5X4_SRGB | ||
| 425 | 128, // ASTC_2D_5X5 | ||
| 426 | 128, // ASTC_2D_5X5_SRGB | ||
| 427 | 128, // ASTC_2D_10X8 | ||
| 428 | 128, // ASTC_2D_10X8_SRGB | ||
| 429 | 32, // Z32F | ||
| 430 | 16, // Z16 | ||
| 431 | 32, // Z24S8 | ||
| 432 | 32, // S8Z24 | ||
| 433 | 64, // Z32FS8 | ||
| 434 | }}; | ||
| 435 | |||
| 436 | ASSERT(static_cast<std::size_t>(format) < bpp_table.size()); | 438 | ASSERT(static_cast<std::size_t>(format) < bpp_table.size()); |
| 437 | return bpp_table[static_cast<std::size_t>(format)]; | 439 | return bpp_table[static_cast<std::size_t>(format)]; |
| 438 | } | 440 | } |