summaryrefslogtreecommitdiff
path: root/src/video_core/surface.h
diff options
context:
space:
mode:
authorGravatar FernandoS272018-10-29 22:46:09 -0400
committerGravatar FernandoS272018-11-01 19:22:12 -0400
commit60a184455c5aef7cce7e6232cab738f66cb0aac0 (patch)
tree7421f8289ad911124dd68ad5c8059ebc8ba3a017 /src/video_core/surface.h
parentFix ASTC formats (diff)
downloadyuzu-60a184455c5aef7cce7e6232cab738f66cb0aac0.tar.gz
yuzu-60a184455c5aef7cce7e6232cab738f66cb0aac0.tar.xz
yuzu-60a184455c5aef7cce7e6232cab738f66cb0aac0.zip
Fix ASTC Decompressor to support depth parameter
Diffstat (limited to 'src/video_core/surface.h')
-rw-r--r--src/video_core/surface.h107
1 files changed, 94 insertions, 13 deletions
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index 3232e437f..0ef7849a4 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -72,19 +72,21 @@ enum class PixelFormat {
72 ASTC_2D_8X8_SRGB = 54, 72 ASTC_2D_8X8_SRGB = 54,
73 ASTC_2D_8X5_SRGB = 55, 73 ASTC_2D_8X5_SRGB = 55,
74 ASTC_2D_5X4_SRGB = 56, 74 ASTC_2D_5X4_SRGB = 56,
75 ASTC_2D_5X5 = 57,
76 ASTC_2D_5X5_SRGB = 58,
75 77
76 MaxColorFormat, 78 MaxColorFormat,
77 79
78 // Depth formats 80 // Depth formats
79 Z32F = 57, 81 Z32F = 59,
80 Z16 = 58, 82 Z16 = 60,
81 83
82 MaxDepthFormat, 84 MaxDepthFormat,
83 85
84 // DepthStencil formats 86 // DepthStencil formats
85 Z24S8 = 59, 87 Z24S8 = 61,
86 S8Z24 = 60, 88 S8Z24 = 62,
87 Z32FS8 = 61, 89 Z32FS8 = 63,
88 90
89 MaxDepthStencilFormat, 91 MaxDepthStencilFormat,
90 92
@@ -188,6 +190,8 @@ static constexpr u32 GetCompressionFactor(PixelFormat format) {
188 4, // ASTC_2D_8X8_SRGB 190 4, // ASTC_2D_8X8_SRGB
189 4, // ASTC_2D_8X5_SRGB 191 4, // ASTC_2D_8X5_SRGB
190 4, // ASTC_2D_5X4_SRGB 192 4, // ASTC_2D_5X4_SRGB
193 4, // ASTC_2D_5X5
194 4, // ASTC_2D_5X5_SRGB
191 1, // Z32F 195 1, // Z32F
192 1, // Z16 196 1, // Z16
193 1, // Z24S8 197 1, // Z24S8
@@ -199,6 +203,79 @@ static constexpr u32 GetCompressionFactor(PixelFormat format) {
199 return compression_factor_table[static_cast<std::size_t>(format)]; 203 return compression_factor_table[static_cast<std::size_t>(format)];
200} 204}
201 205
206static constexpr u32 GetDefaultBlockWidth(PixelFormat format) {
207 if (format == PixelFormat::Invalid)
208 return 0;
209 constexpr std::array<u32, MaxPixelFormat> block_width_table = {{
210 1, // ABGR8U
211 1, // ABGR8S
212 1, // ABGR8UI
213 1, // B5G6R5U
214 1, // A2B10G10R10U
215 1, // A1B5G5R5U
216 1, // R8U
217 1, // R8UI
218 1, // RGBA16F
219 1, // RGBA16U
220 1, // RGBA16UI
221 1, // R11FG11FB10F
222 1, // RGBA32UI
223 4, // DXT1
224 4, // DXT23
225 4, // DXT45
226 4, // DXN1
227 4, // DXN2UNORM
228 4, // DXN2SNORM
229 4, // BC7U
230 4, // BC6H_UF16
231 4, // BC6H_SF16
232 4, // ASTC_2D_4X4
233 1, // G8R8U
234 1, // G8R8S
235 1, // BGRA8
236 1, // RGBA32F
237 1, // RG32F
238 1, // R32F
239 1, // R16F
240 1, // R16U
241 1, // R16S
242 1, // R16UI
243 1, // R16I
244 1, // RG16
245 1, // RG16F
246 1, // RG16UI
247 1, // RG16I
248 1, // RG16S
249 1, // RGB32F
250 1, // RGBA8_SRGB
251 1, // RG8U
252 1, // RG8S
253 1, // RG32UI
254 1, // R32UI
255 8, // ASTC_2D_8X8
256 8, // ASTC_2D_8X5
257 5, // ASTC_2D_5X4
258 1, // BGRA8_SRGB
259 4, // DXT1_SRGB
260 4, // DXT23_SRGB
261 4, // DXT45_SRGB
262 4, // BC7U_SRGB
263 4, // ASTC_2D_4X4_SRGB
264 8, // ASTC_2D_8X8_SRGB
265 8, // ASTC_2D_8X5_SRGB
266 5, // ASTC_2D_5X4_SRGB
267 5, // ASTC_2D_5X5
268 5, // ASTC_2D_5X5_SRGB
269 1, // Z32F
270 1, // Z16
271 1, // Z24S8
272 1, // S8Z24
273 1, // Z32FS8
274 }};
275 ASSERT(static_cast<std::size_t>(format) < block_width_table.size());
276 return block_width_table[static_cast<std::size_t>(format)];
277}
278
202static constexpr u32 GetDefaultBlockHeight(PixelFormat format) { 279static constexpr u32 GetDefaultBlockHeight(PixelFormat format) {
203 if (format == PixelFormat::Invalid) 280 if (format == PixelFormat::Invalid)
204 return 0; 281 return 0;
@@ -261,6 +338,8 @@ static constexpr u32 GetDefaultBlockHeight(PixelFormat format) {
261 8, // ASTC_2D_8X8_SRGB 338 8, // ASTC_2D_8X8_SRGB
262 5, // ASTC_2D_8X5_SRGB 339 5, // ASTC_2D_8X5_SRGB
263 4, // ASTC_2D_5X4_SRGB 340 4, // ASTC_2D_5X4_SRGB
341 5, // ASTC_2D_5X5
342 5, // ASTC_2D_5X5_SRGB
264 1, // Z32F 343 1, // Z32F
265 1, // Z16 344 1, // Z16
266 1, // Z24S8 345 1, // Z24S8
@@ -299,7 +378,7 @@ static constexpr u32 GetFormatBpp(PixelFormat format) {
299 128, // BC7U 378 128, // BC7U
300 128, // BC6H_UF16 379 128, // BC6H_UF16
301 128, // BC6H_SF16 380 128, // BC6H_SF16
302 32, // ASTC_2D_4X4 381 128, // ASTC_2D_4X4
303 16, // G8R8U 382 16, // G8R8U
304 16, // G8R8S 383 16, // G8R8S
305 32, // BGRA8 384 32, // BGRA8
@@ -322,18 +401,20 @@ static constexpr u32 GetFormatBpp(PixelFormat format) {
322 16, // RG8S 401 16, // RG8S
323 64, // RG32UI 402 64, // RG32UI
324 32, // R32UI 403 32, // R32UI
325 16, // ASTC_2D_8X8 404 128, // ASTC_2D_8X8
326 16, // ASTC_2D_8X5 405 128, // ASTC_2D_8X5
327 32, // ASTC_2D_5X4 406 128, // ASTC_2D_5X4
328 32, // BGRA8_SRGB 407 32, // BGRA8_SRGB
329 64, // DXT1_SRGB 408 64, // DXT1_SRGB
330 128, // DXT23_SRGB 409 128, // DXT23_SRGB
331 128, // DXT45_SRGB 410 128, // DXT45_SRGB
332 128, // BC7U 411 128, // BC7U
333 32, // ASTC_2D_4X4_SRGB 412 128, // ASTC_2D_4X4_SRGB
334 16, // ASTC_2D_8X8_SRGB 413 128, // ASTC_2D_8X8_SRGB
335 16, // ASTC_2D_8X5_SRGB 414 128, // ASTC_2D_8X5_SRGB
336 32, // ASTC_2D_5X4_SRGB 415 128, // ASTC_2D_5X4_SRGB
416 128, // ASTC_2D_5X5
417 128, // ASTC_2D_5X5_SRGB
337 32, // Z32F 418 32, // Z32F
338 16, // Z16 419 16, // Z16
339 32, // Z24S8 420 32, // Z24S8