diff --git a/Source/Core/Common/GL/GLExtensions/gl_1_1.h b/Source/Core/Common/GL/GLExtensions/gl_1_1.h index 0a18c255ac..19cb74569c 100644 --- a/Source/Core/Common/GL/GLExtensions/gl_1_1.h +++ b/Source/Core/Common/GL/GLExtensions/gl_1_1.h @@ -21,6 +21,7 @@ #define GL_INT 0x1404 #define GL_UNSIGNED_INT 0x1405 #define GL_FLOAT 0x1406 +#define GL_HALF_FLOAT 0x140B #define GL_2_BYTES 0x1407 #define GL_3_BYTES 0x1408 #define GL_4_BYTES 0x1409 diff --git a/Source/Core/Common/GL/GLExtensions/gl_3_0.h b/Source/Core/Common/GL/GLExtensions/gl_3_0.h index d6d1cd6ab0..ff7dc38729 100644 --- a/Source/Core/Common/GL/GLExtensions/gl_3_0.h +++ b/Source/Core/Common/GL/GLExtensions/gl_3_0.h @@ -71,6 +71,7 @@ #define GL_RGB16I 0x8D89 #define GL_RGBA8I 0x8D8E #define GL_RGB8I 0x8D8F +#define GL_RGB10_A2 0x8059 #define GL_RED_INTEGER 0x8D94 #define GL_GREEN_INTEGER 0x8D95 #define GL_BLUE_INTEGER 0x8D96 @@ -108,6 +109,7 @@ #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_DEPTH32F_STENCIL8 0x8CAD #define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD +#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368 #define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 #define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210 #define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211 diff --git a/Source/Core/VideoBackends/D3DCommon/D3DCommon.cpp b/Source/Core/VideoBackends/D3DCommon/D3DCommon.cpp index 69014d8f2e..18406c2142 100644 --- a/Source/Core/VideoBackends/D3DCommon/D3DCommon.cpp +++ b/Source/Core/VideoBackends/D3DCommon/D3DCommon.cpp @@ -136,6 +136,10 @@ DXGI_FORMAT GetDXGIFormatForAbstractFormat(AbstractTextureFormat format, bool ty return typeless ? DXGI_FORMAT_R8G8B8A8_TYPELESS : DXGI_FORMAT_R8G8B8A8_UNORM; case AbstractTextureFormat::BGRA8: return typeless ? DXGI_FORMAT_B8G8R8A8_TYPELESS : DXGI_FORMAT_B8G8R8A8_UNORM; + case AbstractTextureFormat::RGB10_A2: + return typeless ? DXGI_FORMAT_R10G10B10A2_TYPELESS : DXGI_FORMAT_R10G10B10A2_UNORM; + case AbstractTextureFormat::RGBA16F: + return typeless ? DXGI_FORMAT_R16G16B16A16_TYPELESS : DXGI_FORMAT_R16G16B16A16_FLOAT; case AbstractTextureFormat::R16: return typeless ? DXGI_FORMAT_R16_TYPELESS : DXGI_FORMAT_R16_UNORM; case AbstractTextureFormat::R32F: @@ -169,6 +173,10 @@ DXGI_FORMAT GetSRVFormatForAbstractFormat(AbstractTextureFormat format) return DXGI_FORMAT_R8G8B8A8_UNORM; case AbstractTextureFormat::BGRA8: return DXGI_FORMAT_B8G8R8A8_UNORM; + case AbstractTextureFormat::RGB10_A2: + return DXGI_FORMAT_R10G10B10A2_UNORM; + case AbstractTextureFormat::RGBA16F: + return DXGI_FORMAT_R16G16B16A16_FLOAT; case AbstractTextureFormat::R16: return DXGI_FORMAT_R16_UNORM; case AbstractTextureFormat::R32F: @@ -195,6 +203,10 @@ DXGI_FORMAT GetRTVFormatForAbstractFormat(AbstractTextureFormat format, bool int return integer ? DXGI_FORMAT_R8G8B8A8_UINT : DXGI_FORMAT_R8G8B8A8_UNORM; case AbstractTextureFormat::BGRA8: return DXGI_FORMAT_B8G8R8A8_UNORM; + case AbstractTextureFormat::RGB10_A2: + return DXGI_FORMAT_R10G10B10A2_UNORM; + case AbstractTextureFormat::RGBA16F: + return DXGI_FORMAT_R16G16B16A16_FLOAT; case AbstractTextureFormat::R16: return integer ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R16_UNORM; case AbstractTextureFormat::R32F: @@ -235,6 +247,14 @@ AbstractTextureFormat GetAbstractFormatForDXGIFormat(DXGI_FORMAT format) case DXGI_FORMAT_B8G8R8A8_TYPELESS: return AbstractTextureFormat::BGRA8; + case DXGI_FORMAT_R10G10B10A2_UNORM: + case DXGI_FORMAT_R10G10B10A2_TYPELESS: + return AbstractTextureFormat::RGB10_A2; + + case DXGI_FORMAT_R16G16B16A16_FLOAT: + case DXGI_FORMAT_R16G16B16A16_TYPELESS: + return AbstractTextureFormat::RGBA16F; + case DXGI_FORMAT_R16_UINT: case DXGI_FORMAT_R16_UNORM: case DXGI_FORMAT_R16_TYPELESS: diff --git a/Source/Core/VideoBackends/Metal/MTLUtil.mm b/Source/Core/VideoBackends/Metal/MTLUtil.mm index c6b95d674f..d10aa4b5f0 100644 --- a/Source/Core/VideoBackends/Metal/MTLUtil.mm +++ b/Source/Core/VideoBackends/Metal/MTLUtil.mm @@ -263,6 +263,8 @@ AbstractTextureFormat Metal::Util::ToAbstract(MTLPixelFormat format) { case MTLPixelFormatRGBA8Unorm: return AbstractTextureFormat::RGBA8; case MTLPixelFormatBGRA8Unorm: return AbstractTextureFormat::BGRA8; + case MTLPixelFormatRGB10A2Unorm: return AbstractTextureFormat::RGB10_A2; + case MTLPixelFormatRGBA16Float: return AbstractTextureFormat::RGBA16F; case MTLPixelFormatBC1_RGBA: return AbstractTextureFormat::DXT1; case MTLPixelFormatBC2_RGBA: return AbstractTextureFormat::DXT3; case MTLPixelFormatBC3_RGBA: return AbstractTextureFormat::DXT5; @@ -289,6 +291,8 @@ MTLPixelFormat Metal::Util::FromAbstract(AbstractTextureFormat format) { case AbstractTextureFormat::RGBA8: return MTLPixelFormatRGBA8Unorm; case AbstractTextureFormat::BGRA8: return MTLPixelFormatBGRA8Unorm; + case AbstractTextureFormat::RGB10_A2: return MTLPixelFormatRGB10A2Unorm; + case AbstractTextureFormat::RGBA16F: return MTLPixelFormatRGBA16Float; case AbstractTextureFormat::DXT1: return MTLPixelFormatBC1_RGBA; case AbstractTextureFormat::DXT3: return MTLPixelFormatBC2_RGBA; case AbstractTextureFormat::DXT5: return MTLPixelFormatBC3_RGBA; diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp index d3274a3528..f356e52d32 100644 --- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp +++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp @@ -33,6 +33,10 @@ GLenum GetGLInternalFormatForTextureFormat(AbstractTextureFormat format, bool st return storage ? GL_RGBA8 : GL_RGBA; case AbstractTextureFormat::BGRA8: return storage ? GL_RGBA8 : GL_BGRA; + case AbstractTextureFormat::RGB10_A2: + return GL_RGB10_A2; + case AbstractTextureFormat::RGBA16F: + return GL_RGBA16F; case AbstractTextureFormat::R16: return GL_R16; case AbstractTextureFormat::R32F: @@ -59,6 +63,10 @@ GLenum GetGLFormatForTextureFormat(AbstractTextureFormat format) return GL_RGBA; case AbstractTextureFormat::BGRA8: return GL_BGRA; + case AbstractTextureFormat::RGB10_A2: + return GL_RGB10_A2; + case AbstractTextureFormat::RGBA16F: + return GL_RGBA16F; case AbstractTextureFormat::R16: case AbstractTextureFormat::R32F: return GL_RED; @@ -81,6 +89,10 @@ GLenum GetGLTypeForTextureFormat(AbstractTextureFormat format) case AbstractTextureFormat::RGBA8: case AbstractTextureFormat::BGRA8: return GL_UNSIGNED_BYTE; + case AbstractTextureFormat::RGB10_A2: + return GL_UNSIGNED_INT_2_10_10_10_REV; + case AbstractTextureFormat::RGBA16F: + return GL_HALF_FLOAT; case AbstractTextureFormat::R16: return GL_UNSIGNED_SHORT; case AbstractTextureFormat::R32F: diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp index 14b33d2376..201ee5f84f 100644 --- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp +++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp @@ -189,6 +189,12 @@ VkFormat VKTexture::GetVkFormatForHostTextureFormat(AbstractTextureFormat format case AbstractTextureFormat::BGRA8: return VK_FORMAT_B8G8R8A8_UNORM; + case AbstractTextureFormat::RGB10_A2: + return VK_FORMAT_A2R10G10B10_UNORM_PACK32; + + case AbstractTextureFormat::RGBA16F: + return VK_FORMAT_R16G16B16A16_SFLOAT; + case AbstractTextureFormat::R16: return VK_FORMAT_R16_UNORM; diff --git a/Source/Core/VideoCommon/AbstractTexture.cpp b/Source/Core/VideoCommon/AbstractTexture.cpp index 03b83b21cc..8c269b2101 100644 --- a/Source/Core/VideoCommon/AbstractTexture.cpp +++ b/Source/Core/VideoCommon/AbstractTexture.cpp @@ -26,6 +26,9 @@ bool AbstractTexture::Save(const std::string& filename, unsigned int level) // anyway, so this is fine for now. ASSERT(!IsCompressedFormat(m_config.format)); ASSERT(level < m_config.levels); + // We can't copy from float (HDR) textures to RGBA8 + // (most other formats would probably fail as well) + ASSERT(m_config.format != AbstractTextureFormat::RGBA16F); // Determine dimensions of image we want to save. u32 level_width = std::max(1u, m_config.width >> level); @@ -120,11 +123,13 @@ u32 AbstractTexture::CalculateStrideForFormat(AbstractTextureFormat format, u32 return static_cast(row_length) * 2; case AbstractTextureFormat::RGBA8: case AbstractTextureFormat::BGRA8: + case AbstractTextureFormat::RGB10_A2: case AbstractTextureFormat::R32F: case AbstractTextureFormat::D32F: case AbstractTextureFormat::D24_S8: return static_cast(row_length) * 4; case AbstractTextureFormat::D32F_S8: + case AbstractTextureFormat::RGBA16F: return static_cast(row_length) * 8; default: PanicAlertFmt("Unhandled texture format."); @@ -147,11 +152,13 @@ u32 AbstractTexture::GetTexelSizeForFormat(AbstractTextureFormat format) return 2; case AbstractTextureFormat::RGBA8: case AbstractTextureFormat::BGRA8: + case AbstractTextureFormat::RGB10_A2: case AbstractTextureFormat::D24_S8: case AbstractTextureFormat::R32F: case AbstractTextureFormat::D32F: return 4; case AbstractTextureFormat::D32F_S8: + case AbstractTextureFormat::RGBA16F: return 8; default: PanicAlertFmt("Unhandled texture format."); diff --git a/Source/Core/VideoCommon/TextureConfig.h b/Source/Core/VideoCommon/TextureConfig.h index 2ea0e4e4aa..c076ff85c0 100644 --- a/Source/Core/VideoCommon/TextureConfig.h +++ b/Source/Core/VideoCommon/TextureConfig.h @@ -13,6 +13,8 @@ enum class AbstractTextureFormat : u32 { RGBA8, BGRA8, + RGB10_A2, + RGBA16F, DXT1, DXT3, DXT5,