summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-07-24 17:41:02 -0700
committerGravatar GitHub2018-07-24 17:41:02 -0700
commit5d4ad999cfa578dfdbdd0568ca4c7e094b91d0c5 (patch)
tree055f787c3c64975ca720d92d5a90d58d4a51ce07 /src
parentMerge pull request #805 from lioncash/sign (diff)
parentGPU: Implemented the R16 and R16F texture formats. (diff)
downloadyuzu-5d4ad999cfa578dfdbdd0568ca4c7e094b91d0c5.tar.gz
yuzu-5d4ad999cfa578dfdbdd0568ca4c7e094b91d0c5.tar.xz
yuzu-5d4ad999cfa578dfdbdd0568ca4c7e094b91d0c5.zip
Merge pull request #810 from Subv/r16
GPU: Implemented the R16 and R16F texture formats.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp7
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h27
-rw-r--r--src/video_core/textures/decoders.cpp3
3 files changed, 32 insertions, 5 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index 1d3aff97b..0f5006383 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -111,6 +111,8 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
111 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F 111 {GL_RGBA32F, GL_RGBA, GL_FLOAT, ComponentType::Float, false}, // RGBA32F
112 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F 112 {GL_RG32F, GL_RG, GL_FLOAT, ComponentType::Float, false}, // RG32F
113 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F 113 {GL_R32F, GL_RED, GL_FLOAT, ComponentType::Float, false}, // R32F
114 {GL_R16F, GL_RED, GL_HALF_FLOAT, ComponentType::Float, false}, // R16F
115 {GL_R16, GL_RED, GL_UNSIGNED_SHORT, ComponentType::UNorm, false}, // R16UNORM
114 116
115 // DepthStencil formats 117 // DepthStencil formats
116 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm, 118 {GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ComponentType::UNorm,
@@ -204,7 +206,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
204 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, 206 MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>,
205 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, 207 MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>,
206 MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, 208 MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>,
207 MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::Z24S8>, 209 MortonCopy<true, PixelFormat::R32F>, MortonCopy<true, PixelFormat::R16F>,
210 MortonCopy<true, PixelFormat::R16UNORM>, MortonCopy<true, PixelFormat::Z24S8>,
208 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>, 211 MortonCopy<true, PixelFormat::S8Z24>, MortonCopy<true, PixelFormat::Z32F>,
209 MortonCopy<true, PixelFormat::Z16>, 212 MortonCopy<true, PixelFormat::Z16>,
210}; 213};
@@ -232,6 +235,8 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr),
232 MortonCopy<false, PixelFormat::RGBA32F>, 235 MortonCopy<false, PixelFormat::RGBA32F>,
233 MortonCopy<false, PixelFormat::RG32F>, 236 MortonCopy<false, PixelFormat::RG32F>,
234 MortonCopy<false, PixelFormat::R32F>, 237 MortonCopy<false, PixelFormat::R32F>,
238 MortonCopy<false, PixelFormat::R16F>,
239 MortonCopy<false, PixelFormat::R16UNORM>,
235 MortonCopy<false, PixelFormat::Z24S8>, 240 MortonCopy<false, PixelFormat::Z24S8>,
236 MortonCopy<false, PixelFormat::S8Z24>, 241 MortonCopy<false, PixelFormat::S8Z24>,
237 MortonCopy<false, PixelFormat::Z32F>, 242 MortonCopy<false, PixelFormat::Z32F>,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index 800d239d9..e1d3670d9 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -41,14 +41,16 @@ struct SurfaceParams {
41 RGBA32F = 16, 41 RGBA32F = 16,
42 RG32F = 17, 42 RG32F = 17,
43 R32F = 18, 43 R32F = 18,
44 R16F = 19,
45 R16UNORM = 20,
44 46
45 MaxColorFormat, 47 MaxColorFormat,
46 48
47 // DepthStencil formats 49 // DepthStencil formats
48 Z24S8 = 19, 50 Z24S8 = 21,
49 S8Z24 = 20, 51 S8Z24 = 22,
50 Z32F = 21, 52 Z32F = 23,
51 Z16 = 22, 53 Z16 = 24,
52 54
53 MaxDepthStencilFormat, 55 MaxDepthStencilFormat,
54 56
@@ -105,6 +107,8 @@ struct SurfaceParams {
105 1, // RGBA32F 107 1, // RGBA32F
106 1, // RG32F 108 1, // RG32F
107 1, // R32F 109 1, // R32F
110 1, // R16F
111 1, // R16UNORM
108 1, // Z24S8 112 1, // Z24S8
109 1, // S8Z24 113 1, // S8Z24
110 1, // Z32F 114 1, // Z32F
@@ -139,6 +143,8 @@ struct SurfaceParams {
139 128, // RGBA32F 143 128, // RGBA32F
140 64, // RG32F 144 64, // RG32F
141 32, // R32F 145 32, // R32F
146 16, // R16F
147 16, // R16UNORM
142 32, // Z24S8 148 32, // Z24S8
143 32, // S8Z24 149 32, // S8Z24
144 32, // Z32F 150 32, // Z32F
@@ -226,6 +232,16 @@ struct SurfaceParams {
226 UNREACHABLE(); 232 UNREACHABLE();
227 case Tegra::Texture::TextureFormat::R32_G32: 233 case Tegra::Texture::TextureFormat::R32_G32:
228 return PixelFormat::RG32F; 234 return PixelFormat::RG32F;
235 case Tegra::Texture::TextureFormat::R16:
236 switch (component_type) {
237 case Tegra::Texture::ComponentType::FLOAT:
238 return PixelFormat::R16F;
239 case Tegra::Texture::ComponentType::UNORM:
240 return PixelFormat::R16UNORM;
241 }
242 LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}",
243 static_cast<u32>(component_type));
244 UNREACHABLE();
229 case Tegra::Texture::TextureFormat::R32: 245 case Tegra::Texture::TextureFormat::R32:
230 return PixelFormat::R32F; 246 return PixelFormat::R32F;
231 case Tegra::Texture::TextureFormat::DXT1: 247 case Tegra::Texture::TextureFormat::DXT1:
@@ -290,6 +306,9 @@ struct SurfaceParams {
290 return Tegra::Texture::TextureFormat::R32_G32; 306 return Tegra::Texture::TextureFormat::R32_G32;
291 case PixelFormat::R32F: 307 case PixelFormat::R32F:
292 return Tegra::Texture::TextureFormat::R32; 308 return Tegra::Texture::TextureFormat::R32;
309 case PixelFormat::R16F:
310 case PixelFormat::R16UNORM:
311 return Tegra::Texture::TextureFormat::R16;
293 default: 312 default:
294 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 313 LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
295 UNREACHABLE(); 314 UNREACHABLE();
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index cda2646ad..970c06e71 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -66,6 +66,7 @@ u32 BytesPerPixel(TextureFormat format) {
66 case TextureFormat::A1B5G5R5: 66 case TextureFormat::A1B5G5R5:
67 case TextureFormat::B5G6R5: 67 case TextureFormat::B5G6R5:
68 case TextureFormat::G8R8: 68 case TextureFormat::G8R8:
69 case TextureFormat::R16:
69 return 2; 70 return 2;
70 case TextureFormat::R8: 71 case TextureFormat::R8:
71 return 1; 72 return 1;
@@ -123,6 +124,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
123 case TextureFormat::R32_G32_B32_A32: 124 case TextureFormat::R32_G32_B32_A32:
124 case TextureFormat::R32_G32: 125 case TextureFormat::R32_G32:
125 case TextureFormat::R32: 126 case TextureFormat::R32:
127 case TextureFormat::R16:
126 case TextureFormat::BF10GF11RF11: 128 case TextureFormat::BF10GF11RF11:
127 case TextureFormat::ASTC_2D_4X4: 129 case TextureFormat::ASTC_2D_4X4:
128 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 130 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
@@ -181,6 +183,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat
181 case TextureFormat::R32_G32_B32_A32: 183 case TextureFormat::R32_G32_B32_A32:
182 case TextureFormat::R32_G32: 184 case TextureFormat::R32_G32:
183 case TextureFormat::R32: 185 case TextureFormat::R32:
186 case TextureFormat::R16:
184 // TODO(Subv): For the time being just forward the same data without any decoding. 187 // TODO(Subv): For the time being just forward the same data without any decoding.
185 rgba_data = texture_data; 188 rgba_data = texture_data;
186 break; 189 break;