summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/gpu.h1
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp47
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h21
-rw-r--r--src/video_core/textures/decoders.cpp4
4 files changed, 48 insertions, 25 deletions
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index 7b4e9b842..d0a4ac267 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -16,6 +16,7 @@ namespace Tegra {
16enum class RenderTargetFormat : u32 { 16enum class RenderTargetFormat : u32 {
17 NONE = 0x0, 17 NONE = 0x0,
18 RGBA32_FLOAT = 0xC0, 18 RGBA32_FLOAT = 0xC0,
19 RGBA32_UINT = 0xC2,
19 RGBA16_FLOAT = 0xCA, 20 RGBA16_FLOAT = 0xCA,
20 RGB10_A2_UNORM = 0xD1, 21 RGB10_A2_UNORM = 0xD1,
21 RGBA8_UNORM = 0xD5, 22 RGBA8_UNORM = 0xD5,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 63f5999ea..ae48378f3 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -27,6 +27,7 @@ struct FormatTuple {
27 GLint internal_format; 27 GLint internal_format;
28 GLenum format; 28 GLenum format;
29 GLenum type; 29 GLenum type;
30 ComponentType component_type;
30 bool compressed; 31 bool compressed;
31}; 32};
32 33
@@ -65,29 +66,33 @@ struct FormatTuple {
65} 66}
66 67
67static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{ 68static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_format_tuples = {{
68 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, false}, // ABGR8 69 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, ComponentType::UNorm, false}, // ABGR8
69 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, false}, // B5G6R5 70 {GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, ComponentType::UNorm, false}, // B5G6R5
70 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10 71 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, ComponentType::UNorm,
71 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5 72 false}, // A2B10G10R10
72 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8 73 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, ComponentType::UNorm, false}, // A1B5G5R5
73 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F 74 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // R8
74 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, false}, // R11FG11FB10F 75 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, ComponentType::Float, false}, // RGBA16F
75 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 76 {GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, ComponentType::Float,
76 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23 77 false}, // R11FG11FB10F
77 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45 78 {GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, ComponentType::UInt, false}, // RGBA32UI
78 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, true}, // DXN1 79 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
79 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, false}, // ASTC_2D_4X4 80 true}, // DXT1
81 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
82 true}, // DXT23
83 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm,
84 true}, // DXT45
85 {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1
86 {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4
80}}; 87}};
81 88
82static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) { 89static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType component_type) {
83 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); 90 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format);
84 if (type == SurfaceType::ColorTexture) { 91 if (type == SurfaceType::ColorTexture) {
85 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size()); 92 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size());
86 // For now only UNORM components are supported, or either R11FG11FB10F or RGBA16F which 93 auto& format = tex_format_tuples[static_cast<unsigned int>(pixel_format)];
87 // are type FLOAT 94 ASSERT(component_type == format.component_type);
88 ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F || 95 return format;
89 pixel_format == PixelFormat::R11FG11FB10F);
90 return tex_format_tuples[static_cast<unsigned int>(pixel_format)];
91 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { 96 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) {
92 // TODO(Subv): Implement depth formats 97 // TODO(Subv): Implement depth formats
93 ASSERT_MSG(false, "Unimplemented"); 98 ASSERT_MSG(false, "Unimplemented");
@@ -166,9 +171,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
166 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, 171 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>,
167 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>, 172 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
168 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>, 173 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
169 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::DXT1>, 174 MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>,
170 MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>, 175 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
171 MortonCopy<true, PixelFormat::DXN1>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 176 MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>,
177 MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
172}; 178};
173 179
174static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), 180static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
@@ -181,6 +187,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
181 MortonCopy<false, PixelFormat::R8>, 187 MortonCopy<false, PixelFormat::R8>,
182 MortonCopy<false, PixelFormat::RGBA16F>, 188 MortonCopy<false, PixelFormat::RGBA16F>,
183 MortonCopy<false, PixelFormat::R11FG11FB10F>, 189 MortonCopy<false, PixelFormat::R11FG11FB10F>,
190 MortonCopy<false, PixelFormat::RGBA32UI>,
184 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported 191 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45/DXN1 formats is not yet supported
185 nullptr, 192 nullptr,
186 nullptr, 193 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 85e7c8888..99be250b4 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -30,11 +30,12 @@ struct SurfaceParams {
30 R8 = 4, 30 R8 = 4,
31 RGBA16F = 5, 31 RGBA16F = 5,
32 R11FG11FB10F = 6, 32 R11FG11FB10F = 6,
33 DXT1 = 7, 33 RGBA32UI = 7,
34 DXT23 = 8, 34 DXT1 = 8,
35 DXT45 = 9, 35 DXT23 = 9,
36 DXN1 = 10, // This is also known as BC4 36 DXT45 = 10,
37 ASTC_2D_4X4 = 11, 37 DXN1 = 11, // This is also known as BC4
38 ASTC_2D_4X4 = 12,
38 39
39 Max, 40 Max,
40 Invalid = 255, 41 Invalid = 255,
@@ -77,6 +78,7 @@ struct SurfaceParams {
77 1, // R8 78 1, // R8
78 1, // RGBA16F 79 1, // RGBA16F
79 1, // R11FG11FB10F 80 1, // R11FG11FB10F
81 1, // RGBA32UI
80 4, // DXT1 82 4, // DXT1
81 4, // DXT23 83 4, // DXT23
82 4, // DXT45 84 4, // DXT45
@@ -100,6 +102,7 @@ struct SurfaceParams {
100 8, // R8 102 8, // R8
101 64, // RGBA16F 103 64, // RGBA16F
102 32, // R11FG11FB10F 104 32, // R11FG11FB10F
105 128, // RGBA32UI
103 64, // DXT1 106 64, // DXT1
104 128, // DXT23 107 128, // DXT23
105 128, // DXT45 108 128, // DXT45
@@ -125,6 +128,8 @@ struct SurfaceParams {
125 return PixelFormat::RGBA16F; 128 return PixelFormat::RGBA16F;
126 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 129 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
127 return PixelFormat::R11FG11FB10F; 130 return PixelFormat::R11FG11FB10F;
131 case Tegra::RenderTargetFormat::RGBA32_UINT:
132 return PixelFormat::RGBA32UI;
128 default: 133 default:
129 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 134 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
130 UNREACHABLE(); 135 UNREACHABLE();
@@ -148,6 +153,8 @@ struct SurfaceParams {
148 return PixelFormat::RGBA16F; 153 return PixelFormat::RGBA16F;
149 case Tegra::Texture::TextureFormat::BF10GF11RF11: 154 case Tegra::Texture::TextureFormat::BF10GF11RF11:
150 return PixelFormat::R11FG11FB10F; 155 return PixelFormat::R11FG11FB10F;
156 case Tegra::Texture::TextureFormat::R32_G32_B32_A32:
157 return PixelFormat::RGBA32UI;
151 case Tegra::Texture::TextureFormat::DXT1: 158 case Tegra::Texture::TextureFormat::DXT1:
152 return PixelFormat::DXT1; 159 return PixelFormat::DXT1;
153 case Tegra::Texture::TextureFormat::DXT23: 160 case Tegra::Texture::TextureFormat::DXT23:
@@ -181,6 +188,8 @@ struct SurfaceParams {
181 return Tegra::Texture::TextureFormat::R16_G16_B16_A16; 188 return Tegra::Texture::TextureFormat::R16_G16_B16_A16;
182 case PixelFormat::R11FG11FB10F: 189 case PixelFormat::R11FG11FB10F:
183 return Tegra::Texture::TextureFormat::BF10GF11RF11; 190 return Tegra::Texture::TextureFormat::BF10GF11RF11;
191 case PixelFormat::RGBA32UI:
192 return Tegra::Texture::TextureFormat::R32_G32_B32_A32;
184 case PixelFormat::DXT1: 193 case PixelFormat::DXT1:
185 return Tegra::Texture::TextureFormat::DXT1; 194 return Tegra::Texture::TextureFormat::DXT1;
186 case PixelFormat::DXT23: 195 case PixelFormat::DXT23:
@@ -217,6 +226,8 @@ struct SurfaceParams {
217 case Tegra::RenderTargetFormat::RGBA16_FLOAT: 226 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
218 case Tegra::RenderTargetFormat::R11G11B10_FLOAT: 227 case Tegra::RenderTargetFormat::R11G11B10_FLOAT:
219 return ComponentType::Float; 228 return ComponentType::Float;
229 case Tegra::RenderTargetFormat::RGBA32_UINT:
230 return ComponentType::UInt;
220 default: 231 default:
221 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 232 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
222 UNREACHABLE(); 233 UNREACHABLE();
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 0db4367f1..eaf15da32 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -65,6 +65,8 @@ u32 BytesPerPixel(TextureFormat format) {
65 return 1; 65 return 1;
66 case TextureFormat::R16_G16_B16_A16: 66 case TextureFormat::R16_G16_B16_A16:
67 return 8; 67 return 8;
68 case TextureFormat::R32_G32_B32_A32:
69 return 16;
68 default: 70 default:
69 UNIMPLEMENTED_MSG("Format not implemented"); 71 UNIMPLEMENTED_MSG("Format not implemented");
70 break; 72 break;
@@ -94,6 +96,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
94 case TextureFormat::B5G6R5: 96 case TextureFormat::B5G6R5:
95 case TextureFormat::R8: 97 case TextureFormat::R8:
96 case TextureFormat::R16_G16_B16_A16: 98 case TextureFormat::R16_G16_B16_A16:
99 case TextureFormat::R32_G32_B32_A32:
97 case TextureFormat::BF10GF11RF11: 100 case TextureFormat::BF10GF11RF11:
98 case TextureFormat::ASTC_2D_4X4: 101 case TextureFormat::ASTC_2D_4X4:
99 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 102 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
@@ -124,6 +127,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
124 case TextureFormat::B5G6R5: 127 case TextureFormat::B5G6R5:
125 case TextureFormat::R8: 128 case TextureFormat::R8:
126 case TextureFormat::BF10GF11RF11: 129 case TextureFormat::BF10GF11RF11:
130 case TextureFormat::R32_G32_B32_A32:
127 // TODO(Subv): For the time being just forward the same data without any decoding. 131 // TODO(Subv): For the time being just forward the same data without any decoding.
128 rgba_data = texture_data; 132 rgba_data = texture_data;
129 break; 133 break;