diff options
| -rw-r--r-- | src/common/color.h | 50 | ||||
| -rw-r--r-- | src/common/vector_math.h | 6 | ||||
| -rw-r--r-- | src/video_core/gpu.h | 1 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer_cache.h | 64 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/maxwell_to_gl.h | 3 | ||||
| -rw-r--r-- | src/video_core/textures/decoders.cpp | 3 |
9 files changed, 115 insertions, 57 deletions
diff --git a/src/common/color.h b/src/common/color.h index 24a445dac..0379040be 100644 --- a/src/common/color.h +++ b/src/common/color.h | |||
| @@ -4,6 +4,8 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstring> | ||
| 8 | |||
| 7 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 8 | #include "common/swap.h" | 10 | #include "common/swap.h" |
| 9 | #include "common/vector_math.h" | 11 | #include "common/vector_math.h" |
| @@ -55,7 +57,7 @@ constexpr u8 Convert8To6(u8 value) { | |||
| 55 | * @param bytes Pointer to encoded source color | 57 | * @param bytes Pointer to encoded source color |
| 56 | * @return Result color decoded as Math::Vec4<u8> | 58 | * @return Result color decoded as Math::Vec4<u8> |
| 57 | */ | 59 | */ |
| 58 | inline const Math::Vec4<u8> DecodeRGBA8(const u8* bytes) { | 60 | inline Math::Vec4<u8> DecodeRGBA8(const u8* bytes) { |
| 59 | return {bytes[3], bytes[2], bytes[1], bytes[0]}; | 61 | return {bytes[3], bytes[2], bytes[1], bytes[0]}; |
| 60 | } | 62 | } |
| 61 | 63 | ||
| @@ -64,7 +66,7 @@ inline const Math::Vec4<u8> DecodeRGBA8(const u8* bytes) { | |||
| 64 | * @param bytes Pointer to encoded source color | 66 | * @param bytes Pointer to encoded source color |
| 65 | * @return Result color decoded as Math::Vec4<u8> | 67 | * @return Result color decoded as Math::Vec4<u8> |
| 66 | */ | 68 | */ |
| 67 | inline const Math::Vec4<u8> DecodeRGB8(const u8* bytes) { | 69 | inline Math::Vec4<u8> DecodeRGB8(const u8* bytes) { |
| 68 | return {bytes[2], bytes[1], bytes[0], 255}; | 70 | return {bytes[2], bytes[1], bytes[0], 255}; |
| 69 | } | 71 | } |
| 70 | 72 | ||
| @@ -73,7 +75,7 @@ inline const Math::Vec4<u8> DecodeRGB8(const u8* bytes) { | |||
| 73 | * @param bytes Pointer to encoded source color | 75 | * @param bytes Pointer to encoded source color |
| 74 | * @return Result color decoded as Math::Vec4<u8> | 76 | * @return Result color decoded as Math::Vec4<u8> |
| 75 | */ | 77 | */ |
| 76 | inline const Math::Vec4<u8> DecodeRG8(const u8* bytes) { | 78 | inline Math::Vec4<u8> DecodeRG8(const u8* bytes) { |
| 77 | return {bytes[1], bytes[0], 0, 255}; | 79 | return {bytes[1], bytes[0], 0, 255}; |
| 78 | } | 80 | } |
| 79 | 81 | ||
| @@ -82,8 +84,9 @@ inline const Math::Vec4<u8> DecodeRG8(const u8* bytes) { | |||
| 82 | * @param bytes Pointer to encoded source color | 84 | * @param bytes Pointer to encoded source color |
| 83 | * @return Result color decoded as Math::Vec4<u8> | 85 | * @return Result color decoded as Math::Vec4<u8> |
| 84 | */ | 86 | */ |
| 85 | inline const Math::Vec4<u8> DecodeRGB565(const u8* bytes) { | 87 | inline Math::Vec4<u8> DecodeRGB565(const u8* bytes) { |
| 86 | const u16_le pixel = *reinterpret_cast<const u16_le*>(bytes); | 88 | u16_le pixel; |
| 89 | std::memcpy(&pixel, bytes, sizeof(pixel)); | ||
| 87 | return {Convert5To8((pixel >> 11) & 0x1F), Convert6To8((pixel >> 5) & 0x3F), | 90 | return {Convert5To8((pixel >> 11) & 0x1F), Convert6To8((pixel >> 5) & 0x3F), |
| 88 | Convert5To8(pixel & 0x1F), 255}; | 91 | Convert5To8(pixel & 0x1F), 255}; |
| 89 | } | 92 | } |
| @@ -93,8 +96,9 @@ inline const Math::Vec4<u8> DecodeRGB565(const u8* bytes) { | |||
| 93 | * @param bytes Pointer to encoded source color | 96 | * @param bytes Pointer to encoded source color |
| 94 | * @return Result color decoded as Math::Vec4<u8> | 97 | * @return Result color decoded as Math::Vec4<u8> |
| 95 | */ | 98 | */ |
| 96 | inline const Math::Vec4<u8> DecodeRGB5A1(const u8* bytes) { | 99 | inline Math::Vec4<u8> DecodeRGB5A1(const u8* bytes) { |
| 97 | const u16_le pixel = *reinterpret_cast<const u16_le*>(bytes); | 100 | u16_le pixel; |
| 101 | std::memcpy(&pixel, bytes, sizeof(pixel)); | ||
| 98 | return {Convert5To8((pixel >> 11) & 0x1F), Convert5To8((pixel >> 6) & 0x1F), | 102 | return {Convert5To8((pixel >> 11) & 0x1F), Convert5To8((pixel >> 6) & 0x1F), |
| 99 | Convert5To8((pixel >> 1) & 0x1F), Convert1To8(pixel & 0x1)}; | 103 | Convert5To8((pixel >> 1) & 0x1F), Convert1To8(pixel & 0x1)}; |
| 100 | } | 104 | } |
| @@ -104,8 +108,9 @@ inline const Math::Vec4<u8> DecodeRGB5A1(const u8* bytes) { | |||
| 104 | * @param bytes Pointer to encoded source color | 108 | * @param bytes Pointer to encoded source color |
| 105 | * @return Result color decoded as Math::Vec4<u8> | 109 | * @return Result color decoded as Math::Vec4<u8> |
| 106 | */ | 110 | */ |
| 107 | inline const Math::Vec4<u8> DecodeRGBA4(const u8* bytes) { | 111 | inline Math::Vec4<u8> DecodeRGBA4(const u8* bytes) { |
| 108 | const u16_le pixel = *reinterpret_cast<const u16_le*>(bytes); | 112 | u16_le pixel; |
| 113 | std::memcpy(&pixel, bytes, sizeof(pixel)); | ||
| 109 | return {Convert4To8((pixel >> 12) & 0xF), Convert4To8((pixel >> 8) & 0xF), | 114 | return {Convert4To8((pixel >> 12) & 0xF), Convert4To8((pixel >> 8) & 0xF), |
| 110 | Convert4To8((pixel >> 4) & 0xF), Convert4To8(pixel & 0xF)}; | 115 | Convert4To8((pixel >> 4) & 0xF), Convert4To8(pixel & 0xF)}; |
| 111 | } | 116 | } |
| @@ -116,7 +121,9 @@ inline const Math::Vec4<u8> DecodeRGBA4(const u8* bytes) { | |||
| 116 | * @return Depth value as an u32 | 121 | * @return Depth value as an u32 |
| 117 | */ | 122 | */ |
| 118 | inline u32 DecodeD16(const u8* bytes) { | 123 | inline u32 DecodeD16(const u8* bytes) { |
| 119 | return *reinterpret_cast<const u16_le*>(bytes); | 124 | u16_le data; |
| 125 | std::memcpy(&data, bytes, sizeof(data)); | ||
| 126 | return data; | ||
| 120 | } | 127 | } |
| 121 | 128 | ||
| 122 | /** | 129 | /** |
| @@ -133,7 +140,7 @@ inline u32 DecodeD24(const u8* bytes) { | |||
| 133 | * @param bytes Pointer to encoded source values | 140 | * @param bytes Pointer to encoded source values |
| 134 | * @return Resulting values stored as a Math::Vec2 | 141 | * @return Resulting values stored as a Math::Vec2 |
| 135 | */ | 142 | */ |
| 136 | inline const Math::Vec2<u32> DecodeD24S8(const u8* bytes) { | 143 | inline Math::Vec2<u32> DecodeD24S8(const u8* bytes) { |
| 137 | return {static_cast<u32>((bytes[2] << 16) | (bytes[1] << 8) | bytes[0]), bytes[3]}; | 144 | return {static_cast<u32>((bytes[2] << 16) | (bytes[1] << 8) | bytes[0]), bytes[3]}; |
| 138 | } | 145 | } |
| 139 | 146 | ||
| @@ -175,8 +182,10 @@ inline void EncodeRG8(const Math::Vec4<u8>& color, u8* bytes) { | |||
| 175 | * @param bytes Destination pointer to store encoded color | 182 | * @param bytes Destination pointer to store encoded color |
| 176 | */ | 183 | */ |
| 177 | inline void EncodeRGB565(const Math::Vec4<u8>& color, u8* bytes) { | 184 | inline void EncodeRGB565(const Math::Vec4<u8>& color, u8* bytes) { |
| 178 | *reinterpret_cast<u16_le*>(bytes) = | 185 | const u16_le data = |
| 179 | (Convert8To5(color.r()) << 11) | (Convert8To6(color.g()) << 5) | Convert8To5(color.b()); | 186 | (Convert8To5(color.r()) << 11) | (Convert8To6(color.g()) << 5) | Convert8To5(color.b()); |
| 187 | |||
| 188 | std::memcpy(bytes, &data, sizeof(data)); | ||
| 180 | } | 189 | } |
| 181 | 190 | ||
| 182 | /** | 191 | /** |
| @@ -185,9 +194,10 @@ inline void EncodeRGB565(const Math::Vec4<u8>& color, u8* bytes) { | |||
| 185 | * @param bytes Destination pointer to store encoded color | 194 | * @param bytes Destination pointer to store encoded color |
| 186 | */ | 195 | */ |
| 187 | inline void EncodeRGB5A1(const Math::Vec4<u8>& color, u8* bytes) { | 196 | inline void EncodeRGB5A1(const Math::Vec4<u8>& color, u8* bytes) { |
| 188 | *reinterpret_cast<u16_le*>(bytes) = (Convert8To5(color.r()) << 11) | | 197 | const u16_le data = (Convert8To5(color.r()) << 11) | (Convert8To5(color.g()) << 6) | |
| 189 | (Convert8To5(color.g()) << 6) | | 198 | (Convert8To5(color.b()) << 1) | Convert8To1(color.a()); |
| 190 | (Convert8To5(color.b()) << 1) | Convert8To1(color.a()); | 199 | |
| 200 | std::memcpy(bytes, &data, sizeof(data)); | ||
| 191 | } | 201 | } |
| 192 | 202 | ||
| 193 | /** | 203 | /** |
| @@ -196,9 +206,10 @@ inline void EncodeRGB5A1(const Math::Vec4<u8>& color, u8* bytes) { | |||
| 196 | * @param bytes Destination pointer to store encoded color | 206 | * @param bytes Destination pointer to store encoded color |
| 197 | */ | 207 | */ |
| 198 | inline void EncodeRGBA4(const Math::Vec4<u8>& color, u8* bytes) { | 208 | inline void EncodeRGBA4(const Math::Vec4<u8>& color, u8* bytes) { |
| 199 | *reinterpret_cast<u16_le*>(bytes) = (Convert8To4(color.r()) << 12) | | 209 | const u16 data = (Convert8To4(color.r()) << 12) | (Convert8To4(color.g()) << 8) | |
| 200 | (Convert8To4(color.g()) << 8) | | 210 | (Convert8To4(color.b()) << 4) | Convert8To4(color.a()); |
| 201 | (Convert8To4(color.b()) << 4) | Convert8To4(color.a()); | 211 | |
| 212 | std::memcpy(bytes, &data, sizeof(data)); | ||
| 202 | } | 213 | } |
| 203 | 214 | ||
| 204 | /** | 215 | /** |
| @@ -207,7 +218,8 @@ inline void EncodeRGBA4(const Math::Vec4<u8>& color, u8* bytes) { | |||
| 207 | * @param bytes Pointer where to store the encoded value | 218 | * @param bytes Pointer where to store the encoded value |
| 208 | */ | 219 | */ |
| 209 | inline void EncodeD16(u32 value, u8* bytes) { | 220 | inline void EncodeD16(u32 value, u8* bytes) { |
| 210 | *reinterpret_cast<u16_le*>(bytes) = value & 0xFFFF; | 221 | const u16_le data = static_cast<u16>(value); |
| 222 | std::memcpy(bytes, &data, sizeof(data)); | ||
| 211 | } | 223 | } |
| 212 | 224 | ||
| 213 | /** | 225 | /** |
diff --git a/src/common/vector_math.h b/src/common/vector_math.h index 5c94fcda3..8feb49941 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h | |||
| @@ -78,7 +78,7 @@ public: | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | template <typename U = T> | 80 | template <typename U = T> |
| 81 | constexpr Vec2<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | 81 | constexpr Vec2<std::enable_if_t<std::is_signed_v<U>, U>> operator-() const { |
| 82 | return {-x, -y}; | 82 | return {-x, -y}; |
| 83 | } | 83 | } |
| 84 | constexpr Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const { | 84 | constexpr Vec2<decltype(T{} * T{})> operator*(const Vec2& other) const { |
| @@ -227,7 +227,7 @@ public: | |||
| 227 | } | 227 | } |
| 228 | 228 | ||
| 229 | template <typename U = T> | 229 | template <typename U = T> |
| 230 | constexpr Vec3<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | 230 | constexpr Vec3<std::enable_if_t<std::is_signed_v<U>, U>> operator-() const { |
| 231 | return {-x, -y, -z}; | 231 | return {-x, -y, -z}; |
| 232 | } | 232 | } |
| 233 | 233 | ||
| @@ -436,7 +436,7 @@ public: | |||
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | template <typename U = T> | 438 | template <typename U = T> |
| 439 | constexpr Vec4<std::enable_if_t<std::is_signed<U>::value, U>> operator-() const { | 439 | constexpr Vec4<std::enable_if_t<std::is_signed_v<U>, U>> operator-() const { |
| 440 | return {-x, -y, -z, -w}; | 440 | return {-x, -y, -z, -w}; |
| 441 | } | 441 | } |
| 442 | 442 | ||
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 440505c9d..874eddd78 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -34,6 +34,7 @@ enum class RenderTargetFormat : u32 { | |||
| 34 | RG16_FLOAT = 0xDE, | 34 | RG16_FLOAT = 0xDE, |
| 35 | R11G11B10_FLOAT = 0xE0, | 35 | R11G11B10_FLOAT = 0xE0, |
| 36 | R32_FLOAT = 0xE5, | 36 | R32_FLOAT = 0xE5, |
| 37 | B5G6R5_UNORM = 0xE8, | ||
| 37 | R16_FLOAT = 0xF2, | 38 | R16_FLOAT = 0xF2, |
| 38 | R8_UNORM = 0xF3, | 39 | R8_UNORM = 0xF3, |
| 39 | }; | 40 | }; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index bf6b5c3a0..546e86532 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -324,6 +324,11 @@ std::pair<Surface, Surface> RasterizerOpenGL::ConfigureFramebuffers(bool using_c | |||
| 324 | bool using_depth_fb) { | 324 | bool using_depth_fb) { |
| 325 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; | 325 | const auto& regs = Core::System::GetInstance().GPU().Maxwell3D().regs; |
| 326 | 326 | ||
| 327 | if (regs.rt[0].format == Tegra::RenderTargetFormat::NONE) { | ||
| 328 | LOG_ERROR(HW_GPU, "RenderTargetFormat is not configured"); | ||
| 329 | using_color_fb = false; | ||
| 330 | } | ||
| 331 | |||
| 327 | // TODO(bunnei): Implement this | 332 | // TODO(bunnei): Implement this |
| 328 | const bool has_stencil = false; | 333 | const bool has_stencil = false; |
| 329 | 334 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 257aa9571..f6efce818 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp | |||
| @@ -109,6 +109,9 @@ static constexpr std::array<FormatTuple, SurfaceParams::MaxPixelFormat> tex_form | |||
| 109 | {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, | 109 | {GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, |
| 110 | true}, // DXT45 | 110 | true}, // DXT45 |
| 111 | {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 | 111 | {GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, true}, // DXN1 |
| 112 | {GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, | ||
| 113 | true}, // DXN2UNORM | ||
| 114 | {GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_INT, ComponentType::SNorm, true}, // DXN2SNORM | ||
| 112 | {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, | 115 | {GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_RGB, GL_UNSIGNED_INT_8_8_8_8, ComponentType::UNorm, |
| 113 | true}, // BC7U | 116 | true}, // BC7U |
| 114 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 | 117 | {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, ComponentType::UNorm, false}, // ASTC_2D_4X4 |
| @@ -218,6 +221,7 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | |||
| 218 | MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>, | 221 | MortonCopy<true, PixelFormat::R11FG11FB10F>, MortonCopy<true, PixelFormat::RGBA32UI>, |
| 219 | MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, | 222 | MortonCopy<true, PixelFormat::DXT1>, MortonCopy<true, PixelFormat::DXT23>, |
| 220 | MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, | 223 | MortonCopy<true, PixelFormat::DXT45>, MortonCopy<true, PixelFormat::DXN1>, |
| 224 | MortonCopy<true, PixelFormat::DXN2UNORM>, MortonCopy<true, PixelFormat::DXN2SNORM>, | ||
| 221 | MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, | 225 | MortonCopy<true, PixelFormat::BC7U>, MortonCopy<true, PixelFormat::ASTC_2D_4X4>, |
| 222 | MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, | 226 | MortonCopy<true, PixelFormat::G8R8>, MortonCopy<true, PixelFormat::BGRA8>, |
| 223 | MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, | 227 | MortonCopy<true, PixelFormat::RGBA32F>, MortonCopy<true, PixelFormat::RG32F>, |
| @@ -242,7 +246,10 @@ static constexpr std::array<void (*)(u32, u32, u32, u8*, Tegra::GPUVAddr), | |||
| 242 | MortonCopy<false, PixelFormat::RGBA16F>, | 246 | MortonCopy<false, PixelFormat::RGBA16F>, |
| 243 | MortonCopy<false, PixelFormat::R11FG11FB10F>, | 247 | MortonCopy<false, PixelFormat::R11FG11FB10F>, |
| 244 | MortonCopy<false, PixelFormat::RGBA32UI>, | 248 | MortonCopy<false, PixelFormat::RGBA32UI>, |
| 245 | // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/BC7U/ASTC_2D_4X4 formats is not supported | 249 | // TODO(Subv): Swizzling DXT1/DXT23/DXT45/DXN1/DXN2/BC7U/ASTC_2D_4X4 formats is not |
| 250 | // supported | ||
| 251 | nullptr, | ||
| 252 | nullptr, | ||
| 246 | nullptr, | 253 | nullptr, |
| 247 | nullptr, | 254 | nullptr, |
| 248 | nullptr, | 255 | nullptr, |
| @@ -447,22 +454,24 @@ MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 64 | |||
| 447 | void CachedSurface::LoadGLBuffer() { | 454 | void CachedSurface::LoadGLBuffer() { |
| 448 | ASSERT(params.type != SurfaceType::Fill); | 455 | ASSERT(params.type != SurfaceType::Fill); |
| 449 | 456 | ||
| 450 | u8* const texture_src_data = Memory::GetPointer(params.GetCpuAddr()); | 457 | const u8* const texture_src_data = Memory::GetPointer(params.GetCpuAddr()); |
| 451 | 458 | ||
| 452 | ASSERT(texture_src_data); | 459 | ASSERT(texture_src_data); |
| 453 | 460 | ||
| 454 | gl_buffer.resize(params.width * params.height * GetGLBytesPerPixel(params.pixel_format)); | 461 | const u32 bytes_per_pixel = GetGLBytesPerPixel(params.pixel_format); |
| 462 | const u32 copy_size = params.width * params.height * bytes_per_pixel; | ||
| 455 | 463 | ||
| 456 | MICROPROFILE_SCOPE(OpenGL_SurfaceLoad); | 464 | MICROPROFILE_SCOPE(OpenGL_SurfaceLoad); |
| 457 | 465 | ||
| 458 | if (!params.is_tiled) { | 466 | if (params.is_tiled) { |
| 459 | const u32 bytes_per_pixel{params.GetFormatBpp() >> 3}; | 467 | gl_buffer.resize(copy_size); |
| 460 | 468 | ||
| 461 | std::memcpy(gl_buffer.data(), texture_src_data, | ||
| 462 | bytes_per_pixel * params.width * params.height); | ||
| 463 | } else { | ||
| 464 | morton_to_gl_fns[static_cast<size_t>(params.pixel_format)]( | 469 | morton_to_gl_fns[static_cast<size_t>(params.pixel_format)]( |
| 465 | params.width, params.block_height, params.height, gl_buffer.data(), params.addr); | 470 | params.width, params.block_height, params.height, gl_buffer.data(), params.addr); |
| 471 | } else { | ||
| 472 | const u8* const texture_src_data_end = texture_src_data + copy_size; | ||
| 473 | |||
| 474 | gl_buffer.assign(texture_src_data, texture_src_data_end); | ||
| 466 | } | 475 | } |
| 467 | 476 | ||
| 468 | ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer, params.pixel_format, params.width, params.height); | 477 | ConvertFormatAsNeeded_LoadGLBuffer(gl_buffer, params.pixel_format, params.width, params.height); |
| @@ -757,10 +766,12 @@ void RasterizerCacheOpenGL::FlushRegion(Tegra::GPUVAddr /*addr*/, size_t /*size* | |||
| 757 | } | 766 | } |
| 758 | 767 | ||
| 759 | void RasterizerCacheOpenGL::InvalidateRegion(Tegra::GPUVAddr addr, size_t size) { | 768 | void RasterizerCacheOpenGL::InvalidateRegion(Tegra::GPUVAddr addr, size_t size) { |
| 760 | for (const auto& pair : surface_cache) { | 769 | for (auto iter = surface_cache.cbegin(); iter != surface_cache.cend();) { |
| 761 | const auto& surface{pair.second}; | 770 | const auto& surface{iter->second}; |
| 762 | const auto& params{surface->GetSurfaceParams()}; | 771 | const auto& params{surface->GetSurfaceParams()}; |
| 763 | 772 | ||
| 773 | ++iter; | ||
| 774 | |||
| 764 | if (params.IsOverlappingRegion(addr, size)) { | 775 | if (params.IsOverlappingRegion(addr, size)) { |
| 765 | UnregisterSurface(surface); | 776 | UnregisterSurface(surface); |
| 766 | } | 777 | } |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 0c6652c7a..26e2ee203 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h | |||
| @@ -35,31 +35,33 @@ struct SurfaceParams { | |||
| 35 | DXT23 = 9, | 35 | DXT23 = 9, |
| 36 | DXT45 = 10, | 36 | DXT45 = 10, |
| 37 | DXN1 = 11, // This is also known as BC4 | 37 | DXN1 = 11, // This is also known as BC4 |
| 38 | BC7U = 12, | 38 | DXN2UNORM = 12, |
| 39 | ASTC_2D_4X4 = 13, | 39 | DXN2SNORM = 13, |
| 40 | G8R8 = 14, | 40 | BC7U = 14, |
| 41 | BGRA8 = 15, | 41 | ASTC_2D_4X4 = 15, |
| 42 | RGBA32F = 16, | 42 | G8R8 = 16, |
| 43 | RG32F = 17, | 43 | BGRA8 = 17, |
| 44 | R32F = 18, | 44 | RGBA32F = 18, |
| 45 | R16F = 19, | 45 | RG32F = 19, |
| 46 | R16UNORM = 20, | 46 | R32F = 20, |
| 47 | RG16 = 21, | 47 | R16F = 21, |
| 48 | RG16F = 22, | 48 | R16UNORM = 22, |
| 49 | RG16UI = 23, | 49 | RG16 = 23, |
| 50 | RG16I = 24, | 50 | RG16F = 24, |
| 51 | RG16S = 25, | 51 | RG16UI = 25, |
| 52 | RGB32F = 26, | 52 | RG16I = 26, |
| 53 | SRGBA8 = 27, | 53 | RG16S = 27, |
| 54 | RGB32F = 28, | ||
| 55 | SRGBA8 = 29, | ||
| 54 | 56 | ||
| 55 | MaxColorFormat, | 57 | MaxColorFormat, |
| 56 | 58 | ||
| 57 | // DepthStencil formats | 59 | // DepthStencil formats |
| 58 | Z24S8 = 28, | 60 | Z24S8 = 30, |
| 59 | S8Z24 = 29, | 61 | S8Z24 = 31, |
| 60 | Z32F = 30, | 62 | Z32F = 32, |
| 61 | Z16 = 31, | 63 | Z16 = 33, |
| 62 | Z32FS8 = 32, | 64 | Z32FS8 = 34, |
| 63 | 65 | ||
| 64 | MaxDepthStencilFormat, | 66 | MaxDepthStencilFormat, |
| 65 | 67 | ||
| @@ -109,6 +111,8 @@ struct SurfaceParams { | |||
| 109 | 4, // DXT23 | 111 | 4, // DXT23 |
| 110 | 4, // DXT45 | 112 | 4, // DXT45 |
| 111 | 4, // DXN1 | 113 | 4, // DXN1 |
| 114 | 4, // DXN2UNORM | ||
| 115 | 4, // DXN2SNORM | ||
| 112 | 4, // BC7U | 116 | 4, // BC7U |
| 113 | 4, // ASTC_2D_4X4 | 117 | 4, // ASTC_2D_4X4 |
| 114 | 1, // G8R8 | 118 | 1, // G8R8 |
| @@ -153,6 +157,8 @@ struct SurfaceParams { | |||
| 153 | 128, // DXT23 | 157 | 128, // DXT23 |
| 154 | 128, // DXT45 | 158 | 128, // DXT45 |
| 155 | 64, // DXN1 | 159 | 64, // DXN1 |
| 160 | 128, // DXN2UNORM | ||
| 161 | 128, // DXN2SNORM | ||
| 156 | 128, // BC7U | 162 | 128, // BC7U |
| 157 | 32, // ASTC_2D_4X4 | 163 | 32, // ASTC_2D_4X4 |
| 158 | 16, // G8R8 | 164 | 16, // G8R8 |
| @@ -221,6 +227,8 @@ struct SurfaceParams { | |||
| 221 | return PixelFormat::RG32F; | 227 | return PixelFormat::RG32F; |
| 222 | case Tegra::RenderTargetFormat::R11G11B10_FLOAT: | 228 | case Tegra::RenderTargetFormat::R11G11B10_FLOAT: |
| 223 | return PixelFormat::R11FG11FB10F; | 229 | return PixelFormat::R11FG11FB10F; |
| 230 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: | ||
| 231 | return PixelFormat::B5G6R5; | ||
| 224 | case Tegra::RenderTargetFormat::RGBA32_UINT: | 232 | case Tegra::RenderTargetFormat::RGBA32_UINT: |
| 225 | return PixelFormat::RGBA32UI; | 233 | return PixelFormat::RGBA32UI; |
| 226 | case Tegra::RenderTargetFormat::R8_UNORM: | 234 | case Tegra::RenderTargetFormat::R8_UNORM: |
| @@ -303,6 +311,16 @@ struct SurfaceParams { | |||
| 303 | return PixelFormat::DXT45; | 311 | return PixelFormat::DXT45; |
| 304 | case Tegra::Texture::TextureFormat::DXN1: | 312 | case Tegra::Texture::TextureFormat::DXN1: |
| 305 | return PixelFormat::DXN1; | 313 | return PixelFormat::DXN1; |
| 314 | case Tegra::Texture::TextureFormat::DXN2: | ||
| 315 | switch (component_type) { | ||
| 316 | case Tegra::Texture::ComponentType::UNORM: | ||
| 317 | return PixelFormat::DXN2UNORM; | ||
| 318 | case Tegra::Texture::ComponentType::SNORM: | ||
| 319 | return PixelFormat::DXN2SNORM; | ||
| 320 | } | ||
| 321 | LOG_CRITICAL(HW_GPU, "Unimplemented component_type={}", | ||
| 322 | static_cast<u32>(component_type)); | ||
| 323 | UNREACHABLE(); | ||
| 306 | case Tegra::Texture::TextureFormat::BC7U: | 324 | case Tegra::Texture::TextureFormat::BC7U: |
| 307 | return PixelFormat::BC7U; | 325 | return PixelFormat::BC7U; |
| 308 | case Tegra::Texture::TextureFormat::ASTC_2D_4X4: | 326 | case Tegra::Texture::TextureFormat::ASTC_2D_4X4: |
| @@ -360,6 +378,9 @@ struct SurfaceParams { | |||
| 360 | return Tegra::Texture::TextureFormat::DXT45; | 378 | return Tegra::Texture::TextureFormat::DXT45; |
| 361 | case PixelFormat::DXN1: | 379 | case PixelFormat::DXN1: |
| 362 | return Tegra::Texture::TextureFormat::DXN1; | 380 | return Tegra::Texture::TextureFormat::DXN1; |
| 381 | case PixelFormat::DXN2UNORM: | ||
| 382 | case PixelFormat::DXN2SNORM: | ||
| 383 | return Tegra::Texture::TextureFormat::DXN2; | ||
| 363 | case PixelFormat::BC7U: | 384 | case PixelFormat::BC7U: |
| 364 | return Tegra::Texture::TextureFormat::BC7U; | 385 | return Tegra::Texture::TextureFormat::BC7U; |
| 365 | case PixelFormat::ASTC_2D_4X4: | 386 | case PixelFormat::ASTC_2D_4X4: |
| @@ -441,6 +462,7 @@ struct SurfaceParams { | |||
| 441 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: | 462 | case Tegra::RenderTargetFormat::RGB10_A2_UNORM: |
| 442 | case Tegra::RenderTargetFormat::R8_UNORM: | 463 | case Tegra::RenderTargetFormat::R8_UNORM: |
| 443 | case Tegra::RenderTargetFormat::RG16_UNORM: | 464 | case Tegra::RenderTargetFormat::RG16_UNORM: |
| 465 | case Tegra::RenderTargetFormat::B5G6R5_UNORM: | ||
| 444 | return ComponentType::UNorm; | 466 | return ComponentType::UNorm; |
| 445 | case Tegra::RenderTargetFormat::RG16_SNORM: | 467 | case Tegra::RenderTargetFormat::RG16_SNORM: |
| 446 | return ComponentType::SNorm; | 468 | return ComponentType::SNorm; |
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index dd240a4ce..ea7779429 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -657,16 +657,17 @@ private: | |||
| 657 | * @param instr Instruction to generate the if condition for. | 657 | * @param instr Instruction to generate the if condition for. |
| 658 | * @returns string containing the predicate condition. | 658 | * @returns string containing the predicate condition. |
| 659 | */ | 659 | */ |
| 660 | std::string GetPredicateCondition(u64 index, bool negate) const { | 660 | std::string GetPredicateCondition(u64 index, bool negate) { |
| 661 | using Tegra::Shader::Pred; | 661 | using Tegra::Shader::Pred; |
| 662 | std::string variable; | 662 | std::string variable; |
| 663 | 663 | ||
| 664 | // Index 7 is used as an 'Always True' condition. | 664 | // Index 7 is used as an 'Always True' condition. |
| 665 | if (index == static_cast<u64>(Pred::UnusedIndex)) | 665 | if (index == static_cast<u64>(Pred::UnusedIndex)) { |
| 666 | variable = "true"; | 666 | variable = "true"; |
| 667 | else | 667 | } else { |
| 668 | variable = 'p' + std::to_string(index) + '_' + suffix; | 668 | variable = 'p' + std::to_string(index) + '_' + suffix; |
| 669 | 669 | declr_predicates.insert(variable); | |
| 670 | } | ||
| 670 | if (negate) { | 671 | if (negate) { |
| 671 | return "!(" + variable + ')'; | 672 | return "!(" + variable + ')'; |
| 672 | } | 673 | } |
diff --git a/src/video_core/renderer_opengl/maxwell_to_gl.h b/src/video_core/renderer_opengl/maxwell_to_gl.h index 500d4d4b1..43be69dd1 100644 --- a/src/video_core/renderer_opengl/maxwell_to_gl.h +++ b/src/video_core/renderer_opengl/maxwell_to_gl.h | |||
| @@ -31,6 +31,7 @@ inline GLenum VertexType(Maxwell::VertexAttribute attrib) { | |||
| 31 | case Maxwell::VertexAttribute::Size::Size_8_8_8_8: | 31 | case Maxwell::VertexAttribute::Size::Size_8_8_8_8: |
| 32 | return GL_UNSIGNED_BYTE; | 32 | return GL_UNSIGNED_BYTE; |
| 33 | case Maxwell::VertexAttribute::Size::Size_16_16: | 33 | case Maxwell::VertexAttribute::Size::Size_16_16: |
| 34 | case Maxwell::VertexAttribute::Size::Size_16_16_16_16: | ||
| 34 | return GL_UNSIGNED_SHORT; | 35 | return GL_UNSIGNED_SHORT; |
| 35 | case Maxwell::VertexAttribute::Size::Size_10_10_10_2: | 36 | case Maxwell::VertexAttribute::Size::Size_10_10_10_2: |
| 36 | return GL_UNSIGNED_INT_2_10_10_10_REV; | 37 | return GL_UNSIGNED_INT_2_10_10_10_REV; |
| @@ -85,6 +86,8 @@ inline GLenum IndexFormat(Maxwell::IndexFormat index_format) { | |||
| 85 | 86 | ||
| 86 | inline GLenum PrimitiveTopology(Maxwell::PrimitiveTopology topology) { | 87 | inline GLenum PrimitiveTopology(Maxwell::PrimitiveTopology topology) { |
| 87 | switch (topology) { | 88 | switch (topology) { |
| 89 | case Maxwell::PrimitiveTopology::Points: | ||
| 90 | return GL_POINTS; | ||
| 88 | case Maxwell::PrimitiveTopology::Triangles: | 91 | case Maxwell::PrimitiveTopology::Triangles: |
| 89 | return GL_TRIANGLES; | 92 | return GL_TRIANGLES; |
| 90 | case Maxwell::PrimitiveTopology::TriangleStrip: | 93 | case Maxwell::PrimitiveTopology::TriangleStrip: |
diff --git a/src/video_core/textures/decoders.cpp b/src/video_core/textures/decoders.cpp index 65db84ad3..7ea66584c 100644 --- a/src/video_core/textures/decoders.cpp +++ b/src/video_core/textures/decoders.cpp | |||
| @@ -54,6 +54,7 @@ u32 BytesPerPixel(TextureFormat format) { | |||
| 54 | return 8; | 54 | return 8; |
| 55 | case TextureFormat::DXT23: | 55 | case TextureFormat::DXT23: |
| 56 | case TextureFormat::DXT45: | 56 | case TextureFormat::DXT45: |
| 57 | case TextureFormat::DXN2: | ||
| 57 | case TextureFormat::BC7U: | 58 | case TextureFormat::BC7U: |
| 58 | // In this case a 'pixel' actually refers to a 4x4 tile. | 59 | // In this case a 'pixel' actually refers to a 4x4 tile. |
| 59 | return 16; | 60 | return 16; |
| @@ -113,6 +114,7 @@ std::vector<u8> UnswizzleTexture(VAddr address, TextureFormat format, u32 width, | |||
| 113 | case TextureFormat::DXT23: | 114 | case TextureFormat::DXT23: |
| 114 | case TextureFormat::DXT45: | 115 | case TextureFormat::DXT45: |
| 115 | case TextureFormat::DXN1: | 116 | case TextureFormat::DXN1: |
| 117 | case TextureFormat::DXN2: | ||
| 116 | case TextureFormat::BC7U: | 118 | case TextureFormat::BC7U: |
| 117 | // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel | 119 | // In the DXT and DXN formats, each 4x4 tile is swizzled instead of just individual pixel |
| 118 | // values. | 120 | // values. |
| @@ -179,6 +181,7 @@ std::vector<u8> DecodeTexture(const std::vector<u8>& texture_data, TextureFormat | |||
| 179 | case TextureFormat::DXT23: | 181 | case TextureFormat::DXT23: |
| 180 | case TextureFormat::DXT45: | 182 | case TextureFormat::DXT45: |
| 181 | case TextureFormat::DXN1: | 183 | case TextureFormat::DXN1: |
| 184 | case TextureFormat::DXN2: | ||
| 182 | case TextureFormat::BC7U: | 185 | case TextureFormat::BC7U: |
| 183 | case TextureFormat::ASTC_2D_4X4: | 186 | case TextureFormat::ASTC_2D_4X4: |
| 184 | case TextureFormat::A8R8G8B8: | 187 | case TextureFormat::A8R8G8B8: |