summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2018-05-31 18:16:32 -0400
committerGravatar GitHub2018-05-31 18:16:32 -0400
commitf1bded1270d5c9c3db75d132a4e1849e48aa4cd0 (patch)
tree9f70cf62366d300bb0d2a8dae32c34a52b98a09b /src
parentMerge pull request #489 from Subv/vertexid (diff)
parentgl_rasterizer_cache: Assert that component type is UNorm or format is RGBA16F. (diff)
downloadyuzu-f1bded1270d5c9c3db75d132a4e1849e48aa4cd0.tar.gz
yuzu-f1bded1270d5c9c3db75d132a4e1849e48aa4cd0.tar.xz
yuzu-f1bded1270d5c9c3db75d132a4e1849e48aa4cd0.zip
Merge pull request #491 from bunnei/rgba16f
gl_rasterizer_cache: Implement PixelFormat RGBA16F.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.cpp11
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer_cache.h17
-rw-r--r--src/video_core/textures/decoders.cpp3
3 files changed, 24 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
index ac3e4bf27..10a460a82 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp
@@ -49,6 +49,7 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form
49 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10 49 {GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, false}, // A2B10G10R10
50 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5 50 {GL_RGB5_A1, GL_RGBA, GL_UNSIGNED_SHORT_1_5_5_5_REV, false}, // A1B5G5R5
51 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8 51 {GL_R8, GL_RED, GL_UNSIGNED_BYTE, false}, // R8
52 {GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, false}, // RGBA16F
52 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1 53 {GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT1
53 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23 54 {GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT23
54 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45 55 {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, true}, // DXT45
@@ -58,8 +59,8 @@ static const FormatTuple& GetFormatTuple(PixelFormat pixel_format, ComponentType
58 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format); 59 const SurfaceType type = SurfaceParams::GetFormatType(pixel_format);
59 if (type == SurfaceType::ColorTexture) { 60 if (type == SurfaceType::ColorTexture) {
60 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size()); 61 ASSERT(static_cast<size_t>(pixel_format) < tex_format_tuples.size());
61 // For now only UNORM components are supported 62 // For now only UNORM components are supported, or RGBA16F which is type FLOAT
62 ASSERT(component_type == ComponentType::UNorm); 63 ASSERT(component_type == ComponentType::UNorm || pixel_format == PixelFormat::RGBA16F);
63 return tex_format_tuples[static_cast<unsigned int>(pixel_format)]; 64 return tex_format_tuples[static_cast<unsigned int>(pixel_format)];
64 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) { 65 } else if (type == SurfaceType::Depth || type == SurfaceType::DepthStencil) {
65 // TODO(Subv): Implement depth formats 66 // TODO(Subv): Implement depth formats
@@ -110,8 +111,9 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
110 morton_to_gl_fns = { 111 morton_to_gl_fns = {
111 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>, 112 MortonCopy<true, PixelFormat::ABGR8>, MortonCopy<true, PixelFormat::B5G6R5>,
112 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>, 113 MortonCopy<true, PixelFormat::A2B10G10R10>, MortonCopy<true, PixelFormat::A1B5G5R5>,
113 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::DXT1>, 114 MortonCopy<true, PixelFormat::R8>, MortonCopy<true, PixelFormat::RGBA16F>,
114 MortonCopy<true, PixelFormat::DXT23>, MortonCopy<true, PixelFormat::DXT45>, 115 MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>,
116 MortonCopy<true, PixelFormat::DXT45>,
115}; 117};
116 118
117static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr, 119static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra::GPUVAddr,
@@ -123,6 +125,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr, Tegra:
123 MortonCopy<false, PixelFormat::A2B10G10R10>, 125 MortonCopy<false, PixelFormat::A2B10G10R10>,
124 MortonCopy<false, PixelFormat::A1B5G5R5>, 126 MortonCopy<false, PixelFormat::A1B5G5R5>,
125 MortonCopy<false, PixelFormat::R8>, 127 MortonCopy<false, PixelFormat::R8>,
128 MortonCopy<false, PixelFormat::RGBA16F>,
126 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported 129 // TODO(Subv): Swizzling the DXT1/DXT23/DXT45 formats is not yet supported
127 nullptr, 130 nullptr,
128 nullptr, 131 nullptr,
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
index fc09f108c..07461017d 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h
+++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h
@@ -59,9 +59,10 @@ struct SurfaceParams {
59 A2B10G10R10 = 2, 59 A2B10G10R10 = 2,
60 A1B5G5R5 = 3, 60 A1B5G5R5 = 3,
61 R8 = 4, 61 R8 = 4,
62 DXT1 = 5, 62 RGBA16F = 5,
63 DXT23 = 6, 63 DXT1 = 6,
64 DXT45 = 7, 64 DXT23 = 7,
65 DXT45 = 8,
65 66
66 Max, 67 Max,
67 Invalid = 255, 68 Invalid = 255,
@@ -102,6 +103,7 @@ struct SurfaceParams {
102 1, // A2B10G10R10 103 1, // A2B10G10R10
103 1, // A1B5G5R5 104 1, // A1B5G5R5
104 1, // R8 105 1, // R8
106 2, // RGBA16F
105 4, // DXT1 107 4, // DXT1
106 4, // DXT23 108 4, // DXT23
107 4, // DXT45 109 4, // DXT45
@@ -124,6 +126,7 @@ struct SurfaceParams {
124 32, // A2B10G10R10 126 32, // A2B10G10R10
125 16, // A1B5G5R5 127 16, // A1B5G5R5
126 8, // R8 128 8, // R8
129 64, // RGBA16F
127 64, // DXT1 130 64, // DXT1
128 128, // DXT23 131 128, // DXT23
129 128, // DXT45 132 128, // DXT45
@@ -143,6 +146,8 @@ struct SurfaceParams {
143 return PixelFormat::ABGR8; 146 return PixelFormat::ABGR8;
144 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 147 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
145 return PixelFormat::A2B10G10R10; 148 return PixelFormat::A2B10G10R10;
149 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
150 return PixelFormat::RGBA16F;
146 default: 151 default:
147 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 152 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
148 UNREACHABLE(); 153 UNREACHABLE();
@@ -172,6 +177,8 @@ struct SurfaceParams {
172 return PixelFormat::A1B5G5R5; 177 return PixelFormat::A1B5G5R5;
173 case Tegra::Texture::TextureFormat::R8: 178 case Tegra::Texture::TextureFormat::R8:
174 return PixelFormat::R8; 179 return PixelFormat::R8;
180 case Tegra::Texture::TextureFormat::R16_G16_B16_A16:
181 return PixelFormat::RGBA16F;
175 case Tegra::Texture::TextureFormat::DXT1: 182 case Tegra::Texture::TextureFormat::DXT1:
176 return PixelFormat::DXT1; 183 return PixelFormat::DXT1;
177 case Tegra::Texture::TextureFormat::DXT23: 184 case Tegra::Texture::TextureFormat::DXT23:
@@ -197,6 +204,8 @@ struct SurfaceParams {
197 return Tegra::Texture::TextureFormat::A1B5G5R5; 204 return Tegra::Texture::TextureFormat::A1B5G5R5;
198 case PixelFormat::R8: 205 case PixelFormat::R8:
199 return Tegra::Texture::TextureFormat::R8; 206 return Tegra::Texture::TextureFormat::R8;
207 case PixelFormat::RGBA16F:
208 return Tegra::Texture::TextureFormat::R16_G16_B16_A16;
200 case PixelFormat::DXT1: 209 case PixelFormat::DXT1:
201 return Tegra::Texture::TextureFormat::DXT1; 210 return Tegra::Texture::TextureFormat::DXT1;
202 case PixelFormat::DXT23: 211 case PixelFormat::DXT23:
@@ -226,6 +235,8 @@ struct SurfaceParams {
226 case Tegra::RenderTargetFormat::RGBA8_SRGB: 235 case Tegra::RenderTargetFormat::RGBA8_SRGB:
227 case Tegra::RenderTargetFormat::RGB10_A2_UNORM: 236 case Tegra::RenderTargetFormat::RGB10_A2_UNORM:
228 return ComponentType::UNorm; 237 return ComponentType::UNorm;
238 case Tegra::RenderTargetFormat::RGBA16_FLOAT:
239 return ComponentType::Float;
229 default: 240 default:
230 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); 241 NGLOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format));
231 UNREACHABLE(); 242 UNREACHABLE();
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp
index 9d7b73b73..0179663e8 100644
--- a/src/video_core/textures/decoders.cpp
+++ b/src/video_core/textures/decoders.cpp
@@ -60,6 +60,8 @@ u32 BytesPerPixel(TextureFormat format) {
60 return 2; 60 return 2;
61 case TextureFormat::R8: 61 case TextureFormat::R8:
62 return 1; 62 return 1;
63 case TextureFormat::R16_G16_B16_A16:
64 return 8;
63 default: 65 default:
64 UNIMPLEMENTED_MSG("Format not implemented"); 66 UNIMPLEMENTED_MSG("Format not implemented");
65 break; 67 break;
@@ -86,6 +88,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width,
86 case TextureFormat::A1B5G5R5: 88 case TextureFormat::A1B5G5R5:
87 case TextureFormat::B5G6R5: 89 case TextureFormat::B5G6R5:
88 case TextureFormat::R8: 90 case TextureFormat::R8:
91 case TextureFormat::R16_G16_B16_A16:
89 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data, 92 CopySwizzledData(width, height, bytes_per_pixel, bytes_per_pixel, data,
90 unswizzled_data.data(), true, block_height); 93 unswizzled_data.data(), true, block_height);
91 break; 94 break;