summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_texture_cache.cpp185
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.cpp142
-rw-r--r--src/video_core/renderer_vulkan/maxwell_to_vk.h3
-rw-r--r--src/video_core/surface.cpp85
-rw-r--r--src/video_core/surface.h15
-rw-r--r--src/video_core/texture_cache/surface_params.cpp12
-rw-r--r--src/video_core/texture_cache/surface_params.h1
-rw-r--r--src/video_core/texture_cache/texture_cache.h9
8 files changed, 158 insertions, 294 deletions
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.cpp b/src/video_core/renderer_opengl/gl_texture_cache.cpp
index 55b3e58b2..4659e098f 100644
--- a/src/video_core/renderer_opengl/gl_texture_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_texture_cache.cpp
@@ -23,7 +23,6 @@ namespace OpenGL {
23using Tegra::Texture::SwizzleSource; 23using Tegra::Texture::SwizzleSource;
24using VideoCore::MortonSwizzleMode; 24using VideoCore::MortonSwizzleMode;
25 25
26using VideoCore::Surface::ComponentType;
27using VideoCore::Surface::PixelFormat; 26using VideoCore::Surface::PixelFormat;
28using VideoCore::Surface::SurfaceCompression; 27using VideoCore::Surface::SurfaceCompression;
29using VideoCore::Surface::SurfaceTarget; 28using VideoCore::Surface::SurfaceTarget;
@@ -40,114 +39,95 @@ struct FormatTuple {
40 GLint internal_format; 39 GLint internal_format;
41 GLenum format; 40 GLenum format;
42 GLenum type; 41 GLenum type;
43 ComponentType component_type;
44 bool compressed; 42 bool compressed;
45}; 43};
46 44
47constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{ 45constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{
48 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8U 46 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8U
49 {GL_RGBA8, GL_RGBA, GL_BYTE, ComponentType::SNorm, false}, // ABGR8S 47 {GL_RGBA8, GL_RGBA, GL_BYTE, false}, // ABGR8S
50 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // ABGR8UI 48 {GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, false}, // ABGR8UI
51 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5U 49 {GL_RGB565, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5U
52 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm, 50 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10U
53 false}, // A2B10G10R10U 51 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5U
54 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, ComponentType::UNorm, false}, // A1B5G5R5U 52 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8U
55 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // R8U 53 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, false}, // R8UI
56 {GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, ComponentType::UInt, false}, // R8UI 54 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F
57 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBA16F 55 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, false}, // RGBA16U
58 {GL_RGBA16, GL_RGBA, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RGBA16U 56 {GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, false}, // RGBA16UI
59 {GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RGBA16UI 57 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, false}, // R11FG11FB10F
60 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, ComponentType::Float, 58 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, false}, // RGBA32UI
61 false}, // R11FG11FB10F 59 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
62 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RGBA32UI 60 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
63 {GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 61 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
64 true}, // DXT1 62 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN1
65 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 63 {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN2UNORM
66 true}, // DXT23 64 {GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, true}, // DXN2SNORM
67 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 65 {GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // BC7U
68 true}, // DXT45 66 {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // BC6H_UF16
69 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 67 {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // BC6H_SF16
70 {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 68 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_4X4
71 true}, // DXN2UNORM 69 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, false}, // BGRA8
72 {GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, ComponentType::SNorm, true}, // DXN2SNORM 70 {GL_RGBA32F, GL_RGBA, GL_FLOAT, false}, // RGBA32F
73 {GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 71 {GL_RG32F, GL_RG, GL_FLOAT, false}, // RG32F
74 true}, // BC7U 72 {GL_R32F, GL_RED, GL_FLOAT, false}, // R32F
75 {GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float, 73 {GL_R16F, GL_RED, GL_HALF_FLOAT, false}, // R16F
76 true}, // BC6H_UF16 74 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, false}, // R16U
77 {GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::Float, 75 {GL_R16_SNORM, GL_RED, GL_SHORT, false}, // R16S
78 true}, // BC6H_SF16 76 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, false}, // R16UI
79 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 77 {GL_R16I, GL_RED_INTEGER, GL_SHORT, false}, // R16I
80 {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8 78 {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, false}, // RG16
81 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F 79 {GL_RG16F, GL_RG, GL_HALF_FLOAT, false}, // RG16F
82 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F 80 {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, false}, // RG16UI
83 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F 81 {GL_RG16I, GL_RG_INTEGER, GL_SHORT, false}, // RG16I
84 {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F 82 {GL_RG16_SNORM, GL_RG, GL_SHORT, false}, // RG16S
85 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16U 83 {GL_RGB32F, GL_RGB, GL_FLOAT, false}, // RGB32F
86 {GL_R16_SNORM, GL_RED, GL_SHORT, ComponentType::SNorm, false}, // R16S 84 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // RGBA8_SRGB
87 {GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // R16UI 85 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, false}, // RG8U
88 {GL_R16I, GL_RED_INTEGER, GL_SHORT, ComponentType::SInt, false}, // R16I 86 {GL_RG8, GL_RG, GL_BYTE, false}, // RG8S
89 {GL_RG16, GL_RG, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // RG16 87 {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, false}, // RG32UI
90 {GL_RG16F, GL_RG, GL_HALF_FLOAT, ComponentType::Float, false}, // RG16F 88 {GL_RGB16F, GL_RGBA16, GL_HALF_FLOAT, false}, // RGBX16F
91 {GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, ComponentType::UInt, false}, // RG16UI 89 {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, false}, // R32UI
92 {GL_RG16I, GL_RG_INTEGER, GL_SHORT, ComponentType::SInt, false}, // RG16I 90 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X8
93 {GL_RG16_SNORM, GL_RG, GL_SHORT, ComponentType::SNorm, false}, // RG16S 91 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X5
94 {GL_RGB32F, GL_RGB, GL_FLOAT, ComponentType::Float, false}, // RGB32F 92 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X4
95 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, 93 {GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, false}, // BGRA8
96 false}, // RGBA8_SRGB
97 {GL_RG8, GL_RG, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // RG8U
98 {GL_RG8, GL_RG, GL_BYTE, ComponentType::SNorm, false}, // RG8S
99 {GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RG32UI
100 {GL_RGB16F, GL_RGBA16, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBX16F
101 {GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // R32UI
102 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X8
103 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X5
104 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4
105 {GL_SRGB8_ALPHA8, GL_BGRA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // BGRA8
106 // Compressed sRGB formats 94 // Compressed sRGB formats
107 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 95 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1_SRGB
108 true}, // DXT1_SRGB 96 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23_SRGB
109 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 97 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45_SRGB
110 true}, // DXT23_SRGB 98 {GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // BC7U_SRGB
111 {GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 99 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, false}, // R4G4B4A4U
112 true}, // DXT45_SRGB 100 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_4X4_SRGB
113 {GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, 101 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X8_SRGB
114 true}, // BC7U_SRGB 102 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X5_SRGB
115 {GL_RGBA4, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4_REV, ComponentType::UNorm, false}, // R4G4B4A4U 103 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X4_SRGB
116 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4_SRGB 104 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X5
117 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X8_SRGB 105 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_5X5_SRGB
118 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X5_SRGB 106 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X8
119 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X4_SRGB 107 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X8_SRGB
120 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5 108 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X6
121 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_5X5_SRGB 109 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X6_SRGB
122 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8 110 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X10
123 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X8_SRGB 111 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_10X10_SRGB
124 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X6 112 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_12X12
125 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X6_SRGB 113 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_12X12_SRGB
126 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X10 114 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X6
127 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_10X10_SRGB 115 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_8X6_SRGB
128 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_12X12 116 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X5
129 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_12X12_SRGB 117 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_6X5_SRGB
130 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X6 118 {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, false}, // E5B9G9R9F
131 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_8X6_SRGB
132 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X5
133 {GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_6X5_SRGB
134 {GL_RGB9_E5, GL_RGB, GL_UNSIGNED_INT_5_9_9_9_REV, ComponentType::Float, false}, // E5B9G9R9F
135 119
136 // Depth formats 120 // Depth formats
137 {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, ComponentType::Float, false}, // Z32F 121 {GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT, false}, // Z32F
138 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, ComponentType::UNorm, 122 {GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, false}, // Z16
139 false}, // Z16
140 123
141 // DepthStencil formats 124 // DepthStencil formats
142 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 125 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false}, // Z24S8
143 false}, // Z24S8 126 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, false}, // S8Z24
144 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 127 {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, false}, // Z32FS8
145 false}, // S8Z24
146 {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV,
147 ComponentType::Float, false}, // Z32FS8
148}}; 128}};
149 129
150const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { 130const FormatTuple& GetFormatTuple(PixelFormat pixel_format) {
151 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size()); 131 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size());
152 const auto& format{tex_format_tuples[static_cast<std::size_t>(pixel_format)]}; 132 const auto& format{tex_format_tuples[static_cast<std::size_t>(pixel_format)]};
153 return format; 133 return format;
@@ -249,7 +229,7 @@ OGLTexture CreateTexture(const SurfaceParams& params, GLenum target, GLenum inte
249 229
250CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& params) 230CachedSurface::CachedSurface(const GPUVAddr gpu_addr, const SurfaceParams& params)
251 : VideoCommon::SurfaceBase<View>(gpu_addr, params) { 231 : VideoCommon::SurfaceBase<View>(gpu_addr, params) {
252 const auto& tuple{GetFormatTuple(params.pixel_format, params.component_type)}; 232 const auto& tuple{GetFormatTuple(params.pixel_format)};
253 internal_format = tuple.internal_format; 233 internal_format = tuple.internal_format;
254 format = tuple.format; 234 format = tuple.format;
255 type = tuple.type; 235 type = tuple.type;
@@ -451,8 +431,7 @@ OGLTextureView CachedSurfaceView::CreateTextureView() const {
451 texture_view.Create(); 431 texture_view.Create();
452 432
453 const GLuint handle{texture_view.handle}; 433 const GLuint handle{texture_view.handle};
454 const FormatTuple& tuple{ 434 const FormatTuple& tuple{GetFormatTuple(owner_params.pixel_format)};
455 GetFormatTuple(owner_params.pixel_format, owner_params.component_type)};
456 435
457 glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level, 436 glTextureView(handle, target, surface.texture.handle, tuple.internal_format, params.base_level,
458 params.num_levels, params.base_layer, params.num_layers); 437 params.num_levels, params.base_layer, params.num_layers);
@@ -562,8 +541,8 @@ void TextureCacheOpenGL::BufferCopy(Surface& src_surface, Surface& dst_surface)
562 const auto& dst_params = dst_surface->GetSurfaceParams(); 541 const auto& dst_params = dst_surface->GetSurfaceParams();
563 UNIMPLEMENTED_IF(src_params.num_levels > 1 || dst_params.num_levels > 1); 542 UNIMPLEMENTED_IF(src_params.num_levels > 1 || dst_params.num_levels > 1);
564 543
565 const auto source_format = GetFormatTuple(src_params.pixel_format, src_params.component_type); 544 const auto source_format = GetFormatTuple(src_params.pixel_format);
566 const auto dest_format = GetFormatTuple(dst_params.pixel_format, dst_params.component_type); 545 const auto dest_format = GetFormatTuple(dst_params.pixel_format);
567 546
568 const std::size_t source_size = src_surface->GetHostSizeInBytes(); 547 const std::size_t source_size = src_surface->GetHostSizeInBytes();
569 const std::size_t dest_size = dst_surface->GetHostSizeInBytes(); 548 const std::size_t dest_size = dst_surface->GetHostSizeInBytes();
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
index 3c5acda3e..463ed43ae 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.cpp
@@ -95,83 +95,82 @@ vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compar
95} // namespace Sampler 95} // namespace Sampler
96 96
97struct FormatTuple { 97struct FormatTuple {
98 vk::Format format; ///< Vulkan format 98 vk::Format format; ///< Vulkan format
99 ComponentType component_type; ///< Abstracted component type 99 bool attachable; ///< True when this format can be used as an attachment
100 bool attachable; ///< True when this format can be used as an attachment
101}; 100};
102 101
103static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{ 102static constexpr std::array<FormatTuple, VideoCore::Surface::MaxPixelFormat> tex_format_tuples = {{
104 {vk::Format::eA8B8G8R8UnormPack32, ComponentType::UNorm, true}, // ABGR8U 103 {vk::Format::eA8B8G8R8UnormPack32, true}, // ABGR8U
105 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ABGR8S 104 {vk::Format::eUndefined, false}, // ABGR8S
106 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ABGR8UI 105 {vk::Format::eUndefined, false}, // ABGR8UI
107 {vk::Format::eB5G6R5UnormPack16, ComponentType::UNorm, false}, // B5G6R5U 106 {vk::Format::eB5G6R5UnormPack16, false}, // B5G6R5U
108 {vk::Format::eA2B10G10R10UnormPack32, ComponentType::UNorm, true}, // A2B10G10R10U 107 {vk::Format::eA2B10G10R10UnormPack32, true}, // A2B10G10R10U
109 {vk::Format::eUndefined, ComponentType::Invalid, false}, // A1B5G5R5U 108 {vk::Format::eUndefined, false}, // A1B5G5R5U
110 {vk::Format::eR8Unorm, ComponentType::UNorm, true}, // R8U 109 {vk::Format::eR8Unorm, true}, // R8U
111 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R8UI 110 {vk::Format::eUndefined, false}, // R8UI
112 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16F 111 {vk::Format::eUndefined, false}, // RGBA16F
113 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16U 112 {vk::Format::eUndefined, false}, // RGBA16U
114 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA16UI 113 {vk::Format::eUndefined, false}, // RGBA16UI
115 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R11FG11FB10F 114 {vk::Format::eUndefined, false}, // R11FG11FB10F
116 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA32UI 115 {vk::Format::eUndefined, false}, // RGBA32UI
117 {vk::Format::eBc1RgbaUnormBlock, ComponentType::UNorm, false}, // DXT1 116 {vk::Format::eBc1RgbaUnormBlock, false}, // DXT1
118 {vk::Format::eBc2UnormBlock, ComponentType::UNorm, false}, // DXT23 117 {vk::Format::eBc2UnormBlock, false}, // DXT23
119 {vk::Format::eBc3UnormBlock, ComponentType::UNorm, false}, // DXT45 118 {vk::Format::eBc3UnormBlock, false}, // DXT45
120 {vk::Format::eBc4UnormBlock, ComponentType::UNorm, false}, // DXN1 119 {vk::Format::eBc4UnormBlock, false}, // DXN1
121 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXN2UNORM 120 {vk::Format::eUndefined, false}, // DXN2UNORM
122 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXN2SNORM 121 {vk::Format::eUndefined, false}, // DXN2SNORM
123 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC7U 122 {vk::Format::eUndefined, false}, // BC7U
124 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC6H_UF16 123 {vk::Format::eUndefined, false}, // BC6H_UF16
125 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC6H_SF16 124 {vk::Format::eUndefined, false}, // BC6H_SF16
126 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_4X4 125 {vk::Format::eUndefined, false}, // ASTC_2D_4X4
127 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BGRA8 126 {vk::Format::eUndefined, false}, // BGRA8
128 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBA32F 127 {vk::Format::eUndefined, false}, // RGBA32F
129 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG32F 128 {vk::Format::eUndefined, false}, // RG32F
130 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R32F 129 {vk::Format::eUndefined, false}, // R32F
131 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16F 130 {vk::Format::eUndefined, false}, // R16F
132 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16U 131 {vk::Format::eUndefined, false}, // R16U
133 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16S 132 {vk::Format::eUndefined, false}, // R16S
134 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16UI 133 {vk::Format::eUndefined, false}, // R16UI
135 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R16I 134 {vk::Format::eUndefined, false}, // R16I
136 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16 135 {vk::Format::eUndefined, false}, // RG16
137 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16F 136 {vk::Format::eUndefined, false}, // RG16F
138 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16UI 137 {vk::Format::eUndefined, false}, // RG16UI
139 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16I 138 {vk::Format::eUndefined, false}, // RG16I
140 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG16S 139 {vk::Format::eUndefined, false}, // RG16S
141 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGB32F 140 {vk::Format::eUndefined, false}, // RGB32F
142 {vk::Format::eA8B8G8R8SrgbPack32, ComponentType::UNorm, true}, // RGBA8_SRGB 141 {vk::Format::eA8B8G8R8SrgbPack32, true}, // RGBA8_SRGB
143 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG8U 142 {vk::Format::eUndefined, false}, // RG8U
144 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG8S 143 {vk::Format::eUndefined, false}, // RG8S
145 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RG32UI 144 {vk::Format::eUndefined, false}, // RG32UI
146 {vk::Format::eUndefined, ComponentType::Invalid, false}, // RGBX16F 145 {vk::Format::eUndefined, false}, // RGBX16F
147 {vk::Format::eUndefined, ComponentType::Invalid, false}, // R32UI 146 {vk::Format::eUndefined, false}, // R32UI
148 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X8 147 {vk::Format::eUndefined, false}, // ASTC_2D_8X8
149 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X5 148 {vk::Format::eUndefined, false}, // ASTC_2D_8X5
150 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X4 149 {vk::Format::eUndefined, false}, // ASTC_2D_5X4
151 150
152 // Compressed sRGB formats 151 // Compressed sRGB formats
153 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BGRA8_SRGB 152 {vk::Format::eUndefined, false}, // BGRA8_SRGB
154 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT1_SRGB 153 {vk::Format::eUndefined, false}, // DXT1_SRGB
155 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT23_SRGB 154 {vk::Format::eUndefined, false}, // DXT23_SRGB
156 {vk::Format::eUndefined, ComponentType::Invalid, false}, // DXT45_SRGB 155 {vk::Format::eUndefined, false}, // DXT45_SRGB
157 {vk::Format::eUndefined, ComponentType::Invalid, false}, // BC7U_SRGB 156 {vk::Format::eUndefined, false}, // BC7U_SRGB
158 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_4X4_SRGB 157 {vk::Format::eUndefined, false}, // ASTC_2D_4X4_SRGB
159 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X8_SRGB 158 {vk::Format::eUndefined, false}, // ASTC_2D_8X8_SRGB
160 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_8X5_SRGB 159 {vk::Format::eUndefined, false}, // ASTC_2D_8X5_SRGB
161 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X4_SRGB 160 {vk::Format::eUndefined, false}, // ASTC_2D_5X4_SRGB
162 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X5 161 {vk::Format::eUndefined, false}, // ASTC_2D_5X5
163 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_5X5_SRGB 162 {vk::Format::eUndefined, false}, // ASTC_2D_5X5_SRGB
164 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_10X8 163 {vk::Format::eUndefined, false}, // ASTC_2D_10X8
165 {vk::Format::eUndefined, ComponentType::Invalid, false}, // ASTC_2D_10X8_SRGB 164 {vk::Format::eUndefined, false}, // ASTC_2D_10X8_SRGB
166 165
167 // Depth formats 166 // Depth formats
168 {vk::Format::eD32Sfloat, ComponentType::Float, true}, // Z32F 167 {vk::Format::eD32Sfloat, true}, // Z32F
169 {vk::Format::eD16Unorm, ComponentType::UNorm, true}, // Z16 168 {vk::Format::eD16Unorm, true}, // Z16
170 169
171 // DepthStencil formats 170 // DepthStencil formats
172 {vk::Format::eD24UnormS8Uint, ComponentType::UNorm, true}, // Z24S8 171 {vk::Format::eD24UnormS8Uint, true}, // Z24S8
173 {vk::Format::eD24UnormS8Uint, ComponentType::UNorm, true}, // S8Z24 (emulated) 172 {vk::Format::eD24UnormS8Uint, true}, // S8Z24 (emulated)
174 {vk::Format::eUndefined, ComponentType::Invalid, false}, // Z32FS8 173 {vk::Format::eUndefined, false}, // Z32FS8
175}}; 174}};
176 175
177static constexpr bool IsZetaFormat(PixelFormat pixel_format) { 176static constexpr bool IsZetaFormat(PixelFormat pixel_format) {
@@ -180,14 +179,13 @@ static constexpr bool IsZetaFormat(PixelFormat pixel_format) {
180} 179}
181 180
182std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, 181std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type,
183 PixelFormat pixel_format, ComponentType component_type) { 182 PixelFormat pixel_format) {
184 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size()); 183 ASSERT(static_cast<std::size_t>(pixel_format) < tex_format_tuples.size());
185 184
186 const auto tuple = tex_format_tuples[static_cast<u32>(pixel_format)]; 185 const auto tuple = tex_format_tuples[static_cast<u32>(pixel_format)];
187 UNIMPLEMENTED_IF_MSG(tuple.format == vk::Format::eUndefined, 186 UNIMPLEMENTED_IF_MSG(tuple.format == vk::Format::eUndefined,
188 "Unimplemented texture format with pixel format={} and component type={}", 187 "Unimplemented texture format with pixel format={}",
189 static_cast<u32>(pixel_format), static_cast<u32>(component_type)); 188 static_cast<u32>(pixel_format));
190 ASSERT_MSG(component_type == tuple.component_type, "Component type mismatch");
191 189
192 auto usage = vk::FormatFeatureFlagBits::eSampledImage | 190 auto usage = vk::FormatFeatureFlagBits::eSampledImage |
193 vk::FormatFeatureFlagBits::eTransferDst | vk::FormatFeatureFlagBits::eTransferSrc; 191 vk::FormatFeatureFlagBits::eTransferDst | vk::FormatFeatureFlagBits::eTransferSrc;
diff --git a/src/video_core/renderer_vulkan/maxwell_to_vk.h b/src/video_core/renderer_vulkan/maxwell_to_vk.h
index 4cadc0721..5b0ffd87a 100644
--- a/src/video_core/renderer_vulkan/maxwell_to_vk.h
+++ b/src/video_core/renderer_vulkan/maxwell_to_vk.h
@@ -16,7 +16,6 @@ namespace Vulkan::MaxwellToVK {
16 16
17using Maxwell = Tegra::Engines::Maxwell3D::Regs; 17using Maxwell = Tegra::Engines::Maxwell3D::Regs;
18using PixelFormat = VideoCore::Surface::PixelFormat; 18using PixelFormat = VideoCore::Surface::PixelFormat;
19using ComponentType = VideoCore::Surface::ComponentType;
20 19
21namespace Sampler { 20namespace Sampler {
22 21
@@ -31,7 +30,7 @@ vk::CompareOp DepthCompareFunction(Tegra::Texture::DepthCompareFunc depth_compar
31} // namespace Sampler 30} // namespace Sampler
32 31
33std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type, 32std::pair<vk::Format, bool> SurfaceFormat(const VKDevice& device, FormatType format_type,
34 PixelFormat pixel_format, ComponentType component_type); 33 PixelFormat pixel_format);
35 34
36vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage); 35vk::ShaderStageFlagBits ShaderStage(Maxwell::ShaderStage stage);
37 36
diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp
index 4b6846113..20bcda6bc 100644
--- a/src/video_core/surface.cpp
+++ b/src/video_core/surface.cpp
@@ -404,75 +404,6 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
404 return PixelFormat::ABGR8U; 404 return PixelFormat::ABGR8U;
405} 405}
406 406
407ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type) {
408 // TODO(Subv): Implement more component types
409 switch (type) {
410 case Tegra::Texture::ComponentType::UNORM:
411 return ComponentType::UNorm;
412 case Tegra::Texture::ComponentType::FLOAT:
413 return ComponentType::Float;
414 case Tegra::Texture::ComponentType::SNORM:
415 return ComponentType::SNorm;
416 case Tegra::Texture::ComponentType::UINT:
417 return ComponentType::UInt;
418 case Tegra::Texture::ComponentType::SINT:
419 return ComponentType::SInt;
420 default:
421 LOG_CRITICAL(HW_GPU, "Unimplemented component type={}", static_cast<u32>(type));
422 UNREACHABLE();
423 return ComponentType::UNorm;
424 }
425}
426
427ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format) {
428 // TODO(Subv): Implement more render targets
429 switch (format) {
430 case Tegra::RenderTargetFormat::RGBA8_UNORM:
431 case Tegra::RenderTargetFormat::RGBA8_SRGB:
432 case Tegra::RenderTargetFormat::BGRA8_UNORM:
433 case Tegra::RenderTargetFormat::BGRA8_SRGB:
434 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
435 case Tegra::RenderTargetFormat::R8_UNORM:
436 case Tegra::RenderTargetFormat::RG16_UNORM:
437 case Tegra::RenderTargetFormat::R16_UNORM:
438 case Tegra::RenderTargetFormat::B5G6R5_UNORM:
439 case Tegra::RenderTargetFormat::BGR5A1_UNORM:
440 case Tegra::RenderTargetFormat::RG8_UNORM:
441 case Tegra::RenderTargetFormat::RGBA16_UNORM:
442 return ComponentType::UNorm;
443 case Tegra::RenderTargetFormat::RGBA8_SNORM:
444 case Tegra::RenderTargetFormat::RG16_SNORM:
445 case Tegra::RenderTargetFormat::R16_SNORM:
446 case Tegra::RenderTargetFormat::RG8_SNORM:
447 return ComponentType::SNorm;
448 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
449 case Tegra::RenderTargetFormat::RGBX16_FLOAT:
450 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
451 case Tegra::RenderTargetFormat::RGBA32_FLOAT:
452 case Tegra::RenderTargetFormat::RG32_FLOAT:
453 case Tegra::RenderTargetFormat::RG16_FLOAT:
454 case Tegra::RenderTargetFormat::R16_FLOAT:
455 case Tegra::RenderTargetFormat::R32_FLOAT:
456 return ComponentType::Float;
457 case Tegra::RenderTargetFormat::RGBA32_UINT:
458 case Tegra::RenderTargetFormat::RGBA16_UINT:
459 case Tegra::RenderTargetFormat::RG16_UINT:
460 case Tegra::RenderTargetFormat::R8_UINT:
461 case Tegra::RenderTargetFormat::R16_UINT:
462 case Tegra::RenderTargetFormat::RG32_UINT:
463 case Tegra::RenderTargetFormat::R32_UINT:
464 case Tegra::RenderTargetFormat::RGBA8_UINT:
465 return ComponentType::UInt;
466 case Tegra::RenderTargetFormat::RG16_SINT:
467 case Tegra::RenderTargetFormat::R16_SINT:
468 return ComponentType::SInt;
469 default:
470 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
471 UNREACHABLE();
472 return ComponentType::UNorm;
473 }
474}
475
476PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) { 407PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format) {
477 switch (format) { 408 switch (format) {
478 case Tegra::FramebufferConfig::PixelFormat::ABGR8: 409 case Tegra::FramebufferConfig::PixelFormat::ABGR8:
@@ -487,22 +418,6 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat
487 } 418 }
488} 419}
489 420
490ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format) {
491 switch (format) {
492 case Tegra::DepthFormat::Z16_UNORM:
493 case Tegra::DepthFormat::S8_Z24_UNORM:
494 case Tegra::DepthFormat::Z24_S8_UNORM:
495 return ComponentType::UNorm;
496 case Tegra::DepthFormat::Z32_FLOAT:
497 case Tegra::DepthFormat::Z32_S8_X24_FLOAT:
498 return ComponentType::Float;
499 default:
500 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
501 UNREACHABLE();
502 return ComponentType::UNorm;
503 }
504}
505
506SurfaceType GetFormatType(PixelFormat pixel_format) { 421SurfaceType GetFormatType(PixelFormat pixel_format) {
507 if (static_cast<std::size_t>(pixel_format) < 422 if (static_cast<std::size_t>(pixel_format) <
508 static_cast<std::size_t>(PixelFormat::MaxColorFormat)) { 423 static_cast<std::size_t>(PixelFormat::MaxColorFormat)) {
diff --git a/src/video_core/surface.h b/src/video_core/surface.h
index d3bcd38c5..a3bf2a5b2 100644
--- a/src/video_core/surface.h
+++ b/src/video_core/surface.h
@@ -109,15 +109,6 @@ enum class PixelFormat {
109 109
110static constexpr std::size_t MaxPixelFormat = static_cast<std::size_t>(PixelFormat::Max); 110static constexpr std::size_t MaxPixelFormat = static_cast<std::size_t>(PixelFormat::Max);
111 111
112enum class ComponentType {
113 Invalid = 0,
114 SNorm = 1,
115 UNorm = 2,
116 SInt = 3,
117 UInt = 4,
118 Float = 5,
119};
120
121enum class SurfaceType { 112enum class SurfaceType {
122 ColorTexture = 0, 113 ColorTexture = 0,
123 Depth = 1, 114 Depth = 1,
@@ -613,14 +604,8 @@ PixelFormat PixelFormatFromTextureFormat(Tegra::Texture::TextureFormat format,
613 Tegra::Texture::ComponentType component_type, 604 Tegra::Texture::ComponentType component_type,
614 bool is_srgb); 605 bool is_srgb);
615 606
616ComponentType ComponentTypeFromTexture(Tegra::Texture::ComponentType type);
617
618ComponentType ComponentTypeFromRenderTarget(Tegra::RenderTargetFormat format);
619
620PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format); 607PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat format);
621 608
622ComponentType ComponentTypeFromDepthFormat(Tegra::DepthFormat format);
623
624SurfaceType GetFormatType(PixelFormat pixel_format); 609SurfaceType GetFormatType(PixelFormat pixel_format);
625 610
626bool IsPixelFormatASTC(PixelFormat format); 611bool IsPixelFormatASTC(PixelFormat format);
diff --git a/src/video_core/texture_cache/surface_params.cpp b/src/video_core/texture_cache/surface_params.cpp
index 1e4d3fb79..04b5e8ba3 100644
--- a/src/video_core/texture_cache/surface_params.cpp
+++ b/src/video_core/texture_cache/surface_params.cpp
@@ -13,9 +13,6 @@
13 13
14namespace VideoCommon { 14namespace VideoCommon {
15 15
16using VideoCore::Surface::ComponentTypeFromDepthFormat;
17using VideoCore::Surface::ComponentTypeFromRenderTarget;
18using VideoCore::Surface::ComponentTypeFromTexture;
19using VideoCore::Surface::PixelFormat; 16using VideoCore::Surface::PixelFormat;
20using VideoCore::Surface::PixelFormatFromDepthFormat; 17using VideoCore::Surface::PixelFormatFromDepthFormat;
21using VideoCore::Surface::PixelFormatFromRenderTargetFormat; 18using VideoCore::Surface::PixelFormatFromRenderTargetFormat;
@@ -99,7 +96,6 @@ SurfaceParams SurfaceParams::CreateForTexture(const Tegra::Texture::TICEntry& ti
99 } 96 }
100 params.type = GetFormatType(params.pixel_format); 97 params.type = GetFormatType(params.pixel_format);
101 } 98 }
102 params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
103 params.type = GetFormatType(params.pixel_format); 99 params.type = GetFormatType(params.pixel_format);
104 // TODO: on 1DBuffer we should use the tic info. 100 // TODO: on 1DBuffer we should use the tic info.
105 if (tic.IsBuffer()) { 101 if (tic.IsBuffer()) {
@@ -140,7 +136,6 @@ SurfaceParams SurfaceParams::CreateForImage(const Tegra::Texture::TICEntry& tic,
140 params.pixel_format = 136 params.pixel_format =
141 PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion); 137 PixelFormatFromTextureFormat(tic.format, tic.r_type.Value(), params.srgb_conversion);
142 params.type = GetFormatType(params.pixel_format); 138 params.type = GetFormatType(params.pixel_format);
143 params.component_type = ComponentTypeFromTexture(tic.r_type.Value());
144 params.type = GetFormatType(params.pixel_format); 139 params.type = GetFormatType(params.pixel_format);
145 params.target = ImageTypeToSurfaceTarget(entry.GetType()); 140 params.target = ImageTypeToSurfaceTarget(entry.GetType());
146 // TODO: on 1DBuffer we should use the tic info. 141 // TODO: on 1DBuffer we should use the tic info.
@@ -181,7 +176,6 @@ SurfaceParams SurfaceParams::CreateForDepthBuffer(
181 params.block_depth = std::min(block_depth, 5U); 176 params.block_depth = std::min(block_depth, 5U);
182 params.tile_width_spacing = 1; 177 params.tile_width_spacing = 1;
183 params.pixel_format = PixelFormatFromDepthFormat(format); 178 params.pixel_format = PixelFormatFromDepthFormat(format);
184 params.component_type = ComponentTypeFromDepthFormat(format);
185 params.type = GetFormatType(params.pixel_format); 179 params.type = GetFormatType(params.pixel_format);
186 params.width = zeta_width; 180 params.width = zeta_width;
187 params.height = zeta_height; 181 params.height = zeta_height;
@@ -206,7 +200,6 @@ SurfaceParams SurfaceParams::CreateForFramebuffer(Core::System& system, std::siz
206 params.block_depth = config.memory_layout.block_depth; 200 params.block_depth = config.memory_layout.block_depth;
207 params.tile_width_spacing = 1; 201 params.tile_width_spacing = 1;
208 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 202 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
209 params.component_type = ComponentTypeFromRenderTarget(config.format);
210 params.type = GetFormatType(params.pixel_format); 203 params.type = GetFormatType(params.pixel_format);
211 if (params.is_tiled) { 204 if (params.is_tiled) {
212 params.pitch = 0; 205 params.pitch = 0;
@@ -236,7 +229,6 @@ SurfaceParams SurfaceParams::CreateForFermiCopySurface(
236 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0, 229 params.block_depth = params.is_tiled ? std::min(config.BlockDepth(), 5U) : 0,
237 params.tile_width_spacing = 1; 230 params.tile_width_spacing = 1;
238 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format); 231 params.pixel_format = PixelFormatFromRenderTargetFormat(config.format);
239 params.component_type = ComponentTypeFromRenderTarget(config.format);
240 params.type = GetFormatType(params.pixel_format); 232 params.type = GetFormatType(params.pixel_format);
241 params.width = config.width; 233 params.width = config.width;
242 params.height = config.height; 234 params.height = config.height;
@@ -355,10 +347,10 @@ std::size_t SurfaceParams::GetInnerMipmapMemorySize(u32 level, bool as_host_size
355 347
356bool SurfaceParams::operator==(const SurfaceParams& rhs) const { 348bool SurfaceParams::operator==(const SurfaceParams& rhs) const {
357 return std::tie(is_tiled, block_width, block_height, block_depth, tile_width_spacing, width, 349 return std::tie(is_tiled, block_width, block_height, block_depth, tile_width_spacing, width,
358 height, depth, pitch, num_levels, pixel_format, component_type, type, target) == 350 height, depth, pitch, num_levels, pixel_format, type, target) ==
359 std::tie(rhs.is_tiled, rhs.block_width, rhs.block_height, rhs.block_depth, 351 std::tie(rhs.is_tiled, rhs.block_width, rhs.block_height, rhs.block_depth,
360 rhs.tile_width_spacing, rhs.width, rhs.height, rhs.depth, rhs.pitch, 352 rhs.tile_width_spacing, rhs.width, rhs.height, rhs.depth, rhs.pitch,
361 rhs.num_levels, rhs.pixel_format, rhs.component_type, rhs.type, rhs.target); 353 rhs.num_levels, rhs.pixel_format, rhs.type, rhs.target);
362} 354}
363 355
364std::string SurfaceParams::TargetName() const { 356std::string SurfaceParams::TargetName() const {
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h
index c58e7f8a4..a84058869 100644
--- a/src/video_core/texture_cache/surface_params.h
+++ b/src/video_core/texture_cache/surface_params.h
@@ -248,7 +248,6 @@ public:
248 u32 num_levels; 248 u32 num_levels;
249 u32 emulated_levels; 249 u32 emulated_levels;
250 VideoCore::Surface::PixelFormat pixel_format; 250 VideoCore::Surface::PixelFormat pixel_format;
251 VideoCore::Surface::ComponentType component_type;
252 VideoCore::Surface::SurfaceType type; 251 VideoCore::Surface::SurfaceType type;
253 VideoCore::Surface::SurfaceTarget target; 252 VideoCore::Surface::SurfaceTarget target;
254 253
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 6a92b22d3..8074cc945 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -485,15 +485,13 @@ private:
485 GetSiblingFormat(cr_params.pixel_format) == params.pixel_format) { 485 GetSiblingFormat(cr_params.pixel_format) == params.pixel_format) {
486 SurfaceParams new_params = params; 486 SurfaceParams new_params = params;
487 new_params.pixel_format = cr_params.pixel_format; 487 new_params.pixel_format = cr_params.pixel_format;
488 new_params.component_type = cr_params.component_type;
489 new_params.type = cr_params.type; 488 new_params.type = cr_params.type;
490 new_surface = GetUncachedSurface(gpu_addr, new_params); 489 new_surface = GetUncachedSurface(gpu_addr, new_params);
491 } else { 490 } else {
492 new_surface = GetUncachedSurface(gpu_addr, params); 491 new_surface = GetUncachedSurface(gpu_addr, params);
493 } 492 }
494 const auto& final_params = new_surface->GetSurfaceParams(); 493 const auto& final_params = new_surface->GetSurfaceParams();
495 if (cr_params.type != final_params.type || 494 if (cr_params.type != final_params.type) {
496 (cr_params.component_type != final_params.component_type)) {
497 BufferCopy(current_surface, new_surface); 495 BufferCopy(current_surface, new_surface);
498 } else { 496 } else {
499 std::vector<CopyParams> bricks = current_surface->BreakDown(final_params); 497 std::vector<CopyParams> bricks = current_surface->BreakDown(final_params);
@@ -835,12 +833,11 @@ private:
835 } 833 }
836 } 834 }
837 835
838 const auto inherit_format = ([](SurfaceParams& to, TSurface from) { 836 const auto inherit_format = [](SurfaceParams& to, TSurface from) {
839 const SurfaceParams& params = from->GetSurfaceParams(); 837 const SurfaceParams& params = from->GetSurfaceParams();
840 to.pixel_format = params.pixel_format; 838 to.pixel_format = params.pixel_format;
841 to.component_type = params.component_type;
842 to.type = params.type; 839 to.type = params.type;
843 }); 840 };
844 // Now we got the cases where one or both is Depth and the other is not known 841 // Now we got the cases where one or both is Depth and the other is not known
845 if (!incomplete_src) { 842 if (!incomplete_src) {
846 inherit_format(src_params, deduced_src.surface); 843 inherit_format(src_params, deduced_src.surface);