summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authoriwubcode <iwubcode@users.noreply.github.com>2017-06-12 12:37:28 -0500
committeriwubcode <iwubcode@users.noreply.github.com>2017-06-13 00:41:56 -0500
commite4896d39bd927b0b8e109e0334fa15cdb8e004f3 (patch)
tree60375e0e8c776699b146bc26c3018be03b459225 /Source/Core
parent2cdc93f4ab690279df064832d4c9688741556f0c (diff)
Video Backends: Move and rename HostTextureFormat to AbstractTextureFormat
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/VideoBackends/D3D/DXTexture.cpp12
-rw-r--r--Source/Core/VideoBackends/OGL/OGLTexture.cpp20
-rw-r--r--Source/Core/VideoBackends/Vulkan/Util.cpp10
-rw-r--r--Source/Core/VideoBackends/Vulkan/Util.h3
-rw-r--r--Source/Core/VideoBackends/Vulkan/VKTexture.cpp2
-rw-r--r--Source/Core/VideoCommon/AbstractTexture.cpp14
-rw-r--r--Source/Core/VideoCommon/AbstractTexture.h4
-rw-r--r--Source/Core/VideoCommon/HiresTextures.cpp4
-rw-r--r--Source/Core/VideoCommon/HiresTextures.h6
-rw-r--r--Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp10
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.cpp2
-rw-r--r--Source/Core/VideoCommon/TextureCacheBase.h2
-rw-r--r--Source/Core/VideoCommon/TextureConfig.h11
-rw-r--r--Source/Core/VideoCommon/VideoCommon.h9
14 files changed, 54 insertions, 55 deletions
diff --git a/Source/Core/VideoBackends/D3D/DXTexture.cpp b/Source/Core/VideoBackends/D3D/DXTexture.cpp
index 29b8824f5c..765438d679 100644
--- a/Source/Core/VideoBackends/D3D/DXTexture.cpp
+++ b/Source/Core/VideoBackends/D3D/DXTexture.cpp
@@ -27,17 +27,17 @@ namespace DX11
{
namespace
{
-DXGI_FORMAT GetDXGIFormatForHostFormat(HostTextureFormat format)
+DXGI_FORMAT GetDXGIFormatForHostFormat(AbstractTextureFormat format)
{
switch (format)
{
- case HostTextureFormat::DXT1:
+ case AbstractTextureFormat::DXT1:
return DXGI_FORMAT_BC1_UNORM;
- case HostTextureFormat::DXT3:
+ case AbstractTextureFormat::DXT3:
return DXGI_FORMAT_BC2_UNORM;
- case HostTextureFormat::DXT5:
+ case AbstractTextureFormat::DXT5:
return DXGI_FORMAT_BC3_UNORM;
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
default:
return DXGI_FORMAT_R8G8B8A8_UNORM;
}
@@ -96,7 +96,7 @@ bool DXTexture::Save(const std::string& filename, unsigned int level)
// We can't dump compressed textures currently (it would mean drawing them to a RGBA8
// framebuffer, and saving that). TextureCache does not call Save for custom textures
// anyway, so this is fine for now.
- _assert_(m_config.format == HostTextureFormat::RGBA8);
+ _assert_(m_config.format == AbstractTextureFormat::RGBA8);
// Create a staging/readback texture with the dimensions of the specified mip level.
u32 mip_width = std::max(m_config.width >> level, 1u);
diff --git a/Source/Core/VideoBackends/OGL/OGLTexture.cpp b/Source/Core/VideoBackends/OGL/OGLTexture.cpp
index 3d6c04926d..242e19888e 100644
--- a/Source/Core/VideoBackends/OGL/OGLTexture.cpp
+++ b/Source/Core/VideoBackends/OGL/OGLTexture.cpp
@@ -23,27 +23,27 @@ namespace
std::array<u32, 8> s_Textures;
u32 s_ActiveTexture;
-GLenum GetGLInternalFormatForTextureFormat(HostTextureFormat format, bool storage)
+GLenum GetGLInternalFormatForTextureFormat(AbstractTextureFormat format, bool storage)
{
switch (format)
{
- case HostTextureFormat::DXT1:
+ case AbstractTextureFormat::DXT1:
return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
- case HostTextureFormat::DXT3:
+ case AbstractTextureFormat::DXT3:
return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
- case HostTextureFormat::DXT5:
+ case AbstractTextureFormat::DXT5:
return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
default:
return storage ? GL_RGBA8 : GL_RGBA;
}
}
-GLenum GetGLFormatForTextureFormat(HostTextureFormat format)
+GLenum GetGLFormatForTextureFormat(AbstractTextureFormat format)
{
switch (format)
{
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
return GL_RGBA;
// Compressed texture formats don't use this parameter.
default:
@@ -51,11 +51,11 @@ GLenum GetGLFormatForTextureFormat(HostTextureFormat format)
}
}
-GLenum GetGLTypeForTextureFormat(HostTextureFormat format)
+GLenum GetGLTypeForTextureFormat(AbstractTextureFormat format)
{
switch (format)
{
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
return GL_UNSIGNED_BYTE;
// Compressed texture formats don't use this parameter.
default:
@@ -167,7 +167,7 @@ bool OGLTexture::Save(const std::string& filename, unsigned int level)
// We can't dump compressed textures currently (it would mean drawing them to a RGBA8
// framebuffer, and saving that). TextureCache does not call Save for custom textures
// anyway, so this is fine for now.
- _assert_(m_config.format == HostTextureFormat::RGBA8);
+ _assert_(m_config.format == AbstractTextureFormat::RGBA8);
return SaveTexture(filename, GL_TEXTURE_2D_ARRAY, m_texId, m_config.width, m_config.height,
level);
diff --git a/Source/Core/VideoBackends/Vulkan/Util.cpp b/Source/Core/VideoBackends/Vulkan/Util.cpp
index 7ce433a79e..dd676d0b6c 100644
--- a/Source/Core/VideoBackends/Vulkan/Util.cpp
+++ b/Source/Core/VideoBackends/Vulkan/Util.cpp
@@ -88,20 +88,20 @@ VkFormat GetLinearFormat(VkFormat format)
}
}
-VkFormat GetVkFormatForHostTextureFormat(HostTextureFormat format)
+VkFormat GetVkFormatForHostTextureFormat(AbstractTextureFormat format)
{
switch (format)
{
- case HostTextureFormat::DXT1:
+ case AbstractTextureFormat::DXT1:
return VK_FORMAT_BC1_RGBA_UNORM_BLOCK;
- case HostTextureFormat::DXT3:
+ case AbstractTextureFormat::DXT3:
return VK_FORMAT_BC2_UNORM_BLOCK;
- case HostTextureFormat::DXT5:
+ case AbstractTextureFormat::DXT5:
return VK_FORMAT_BC3_UNORM_BLOCK;
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
default:
return VK_FORMAT_R8G8B8A8_UNORM;
}
diff --git a/Source/Core/VideoBackends/Vulkan/Util.h b/Source/Core/VideoBackends/Vulkan/Util.h
index 85d447cf75..79b070cbb8 100644
--- a/Source/Core/VideoBackends/Vulkan/Util.h
+++ b/Source/Core/VideoBackends/Vulkan/Util.h
@@ -11,6 +11,7 @@
#include "VideoBackends/Vulkan/Constants.h"
#include "VideoBackends/Vulkan/ObjectCache.h"
#include "VideoCommon/RenderState.h"
+#include "VideoCommon/TextureConfig.h"
namespace Vulkan
{
@@ -27,7 +28,7 @@ u32 MakeRGBA8Color(float r, float g, float b, float a);
bool IsDepthFormat(VkFormat format);
bool IsCompressedFormat(VkFormat format);
VkFormat GetLinearFormat(VkFormat format);
-VkFormat GetVkFormatForHostTextureFormat(HostTextureFormat format);
+VkFormat GetVkFormatForHostTextureFormat(AbstractTextureFormat format);
u32 GetTexelSize(VkFormat format);
u32 GetBlockSize(VkFormat format);
diff --git a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp
index a493518101..e937f06f33 100644
--- a/Source/Core/VideoBackends/Vulkan/VKTexture.cpp
+++ b/Source/Core/VideoBackends/Vulkan/VKTexture.cpp
@@ -120,7 +120,7 @@ bool VKTexture::Save(const std::string& filename, unsigned int level)
// We can't dump compressed textures currently (it would mean drawing them to a RGBA8
// framebuffer, and saving that). TextureCache does not call Save for custom textures
// anyway, so this is fine for now.
- _assert_(m_config.format == HostTextureFormat::RGBA8);
+ _assert_(m_config.format == AbstractTextureFormat::RGBA8);
// Determine dimensions of image we want to save.
u32 level_width = std::max(1u, m_config.width >> level);
diff --git a/Source/Core/VideoCommon/AbstractTexture.cpp b/Source/Core/VideoCommon/AbstractTexture.cpp
index 53cf84ae0d..1b6fac8bff 100644
--- a/Source/Core/VideoCommon/AbstractTexture.cpp
+++ b/Source/Core/VideoCommon/AbstractTexture.cpp
@@ -17,22 +17,22 @@ bool AbstractTexture::Save(const std::string& filename, unsigned int level)
return false;
}
-bool AbstractTexture::IsCompressedHostTextureFormat(HostTextureFormat format)
+bool AbstractTexture::IsCompressedHostTextureFormat(AbstractTextureFormat format)
{
// This will need to be changed if we add any other uncompressed formats.
- return format != HostTextureFormat::RGBA8;
+ return format != AbstractTextureFormat::RGBA8;
}
-size_t AbstractTexture::CalculateHostTextureLevelPitch(HostTextureFormat format, u32 row_length)
+size_t AbstractTexture::CalculateHostTextureLevelPitch(AbstractTextureFormat format, u32 row_length)
{
switch (format)
{
- case HostTextureFormat::DXT1:
+ case AbstractTextureFormat::DXT1:
return static_cast<size_t>(std::max(1u, row_length / 4)) * 8;
- case HostTextureFormat::DXT3:
- case HostTextureFormat::DXT5:
+ case AbstractTextureFormat::DXT3:
+ case AbstractTextureFormat::DXT5:
return static_cast<size_t>(std::max(1u, row_length / 4)) * 16;
- case HostTextureFormat::RGBA8:
+ case AbstractTextureFormat::RGBA8:
default:
return static_cast<size_t>(row_length) * 4;
}
diff --git a/Source/Core/VideoCommon/AbstractTexture.h b/Source/Core/VideoCommon/AbstractTexture.h
index 8679d03b82..2b06d9c401 100644
--- a/Source/Core/VideoCommon/AbstractTexture.h
+++ b/Source/Core/VideoCommon/AbstractTexture.h
@@ -23,8 +23,8 @@ public:
virtual void Load(u32 level, u32 width, u32 height, u32 row_length, const u8* buffer,
size_t buffer_size) = 0;
- static bool IsCompressedHostTextureFormat(HostTextureFormat format);
- static size_t CalculateHostTextureLevelPitch(HostTextureFormat format, u32 row_length);
+ static bool IsCompressedHostTextureFormat(AbstractTextureFormat format);
+ static size_t CalculateHostTextureLevelPitch(AbstractTextureFormat format, u32 row_length);
const TextureConfig GetConfig() const;
diff --git a/Source/Core/VideoCommon/HiresTextures.cpp b/Source/Core/VideoCommon/HiresTextures.cpp
index 654530dc20..5b9cbd0370 100644
--- a/Source/Core/VideoCommon/HiresTextures.cpp
+++ b/Source/Core/VideoCommon/HiresTextures.cpp
@@ -532,7 +532,7 @@ bool HiresTexture::LoadTexture(Level& level, const std::vector<u8>& buffer)
// Images loaded by SOIL are converted to RGBA.
level.width = static_cast<u32>(width);
level.height = static_cast<u32>(height);
- level.format = HostTextureFormat::RGBA8;
+ level.format = AbstractTextureFormat::RGBA8;
level.data = ImageDataPointer(data, SOIL_free_image_data);
level.row_length = level.width;
level.data_size = static_cast<size_t>(level.row_length) * 4 * level.height;
@@ -554,7 +554,7 @@ HiresTexture::~HiresTexture()
{
}
-HostTextureFormat HiresTexture::GetFormat() const
+AbstractTextureFormat HiresTexture::GetFormat() const
{
return m_levels.at(0).format;
}
diff --git a/Source/Core/VideoCommon/HiresTextures.h b/Source/Core/VideoCommon/HiresTextures.h
index 30bb96d40c..3e7625c993 100644
--- a/Source/Core/VideoCommon/HiresTextures.h
+++ b/Source/Core/VideoCommon/HiresTextures.h
@@ -9,7 +9,7 @@
#include <vector>
#include "Common/CommonTypes.h"
-#include "VideoCommon/VideoCommon.h"
+#include "VideoCommon/TextureConfig.h"
class HiresTexture
{
@@ -32,13 +32,13 @@ public:
~HiresTexture();
- HostTextureFormat GetFormat() const;
+ AbstractTextureFormat GetFormat() const;
struct Level
{
Level();
ImageDataPointer data;
- HostTextureFormat format = HostTextureFormat::RGBA8;
+ AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
u32 width = 0;
u32 height = 0;
u32 row_length = 0;
diff --git a/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp b/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp
index d58d699a56..163c67fc3c 100644
--- a/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp
+++ b/Source/Core/VideoCommon/HiresTextures_DDSLoader.cpp
@@ -140,7 +140,7 @@ struct DDSLoadInfo
u32 width = 0;
u32 height = 0;
u32 mip_count = 0;
- HostTextureFormat format = HostTextureFormat::RGBA8;
+ AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
size_t first_mip_offset = 0;
size_t first_mip_size = 0;
u32 first_mip_row_length = 0;
@@ -298,21 +298,21 @@ bool ParseDDSHeader(File::IOFile& file, DDSLoadInfo* info)
// In the future, this could be extended, but these isn't much benefit in doing so currently.
if (header.ddspf.dwFourCC == MAKEFOURCC('D', 'X', 'T', '1') || dxt10_format == 71)
{
- info->format = HostTextureFormat::DXT1;
+ info->format = AbstractTextureFormat::DXT1;
info->block_size = 4;
info->bytes_per_block = 8;
needs_s3tc = true;
}
else if (header.ddspf.dwFourCC == MAKEFOURCC('D', 'X', 'T', '3') || dxt10_format == 74)
{
- info->format = HostTextureFormat::DXT3;
+ info->format = AbstractTextureFormat::DXT3;
info->block_size = 4;
info->bytes_per_block = 16;
needs_s3tc = true;
}
else if (header.ddspf.dwFourCC == MAKEFOURCC('D', 'X', 'T', '5') || dxt10_format == 77)
{
- info->format = HostTextureFormat::DXT5;
+ info->format = AbstractTextureFormat::DXT5;
info->block_size = 4;
info->bytes_per_block = 16;
needs_s3tc = true;
@@ -351,7 +351,7 @@ bool ParseDDSHeader(File::IOFile& file, DDSLoadInfo* info)
}
// All these formats are RGBA, just with byte swapping.
- info->format = HostTextureFormat::RGBA8;
+ info->format = AbstractTextureFormat::RGBA8;
info->block_size = 1;
info->bytes_per_block = header.ddspf.dwRGBBitCount / 8;
}
diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp
index ebb5f3830b..c61fa1fe5e 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.cpp
+++ b/Source/Core/VideoCommon/TextureCacheBase.cpp
@@ -753,7 +753,7 @@ TextureCacheBase::TCacheEntry* TextureCacheBase::Load(const u32 stage)
config.width = width;
config.height = height;
config.levels = texLevels;
- config.format = hires_tex ? hires_tex->GetFormat() : HostTextureFormat::RGBA8;
+ config.format = hires_tex ? hires_tex->GetFormat() : AbstractTextureFormat::RGBA8;
TCacheEntry* entry = AllocateCacheEntry(config);
GFX_DEBUGGER_PAUSE_AT(NEXT_NEW_TEXTURE, true);
diff --git a/Source/Core/VideoCommon/TextureCacheBase.h b/Source/Core/VideoCommon/TextureCacheBase.h
index 7556e43ffa..23f25f48fc 100644
--- a/Source/Core/VideoCommon/TextureCacheBase.h
+++ b/Source/Core/VideoCommon/TextureCacheBase.h
@@ -104,7 +104,7 @@ public:
u32 GetHeight() const { return texture->GetConfig().height; }
u32 GetNumLevels() const { return texture->GetConfig().levels; }
u32 GetNumLayers() const { return texture->GetConfig().layers; }
- HostTextureFormat GetFormat() const { return texture->GetConfig().format; }
+ AbstractTextureFormat GetFormat() const { return texture->GetConfig().format; }
};
virtual ~TextureCacheBase(); // needs virtual for DX11 dtor
diff --git a/Source/Core/VideoCommon/TextureConfig.h b/Source/Core/VideoCommon/TextureConfig.h
index b1cb513fd9..27a0c935a1 100644
--- a/Source/Core/VideoCommon/TextureConfig.h
+++ b/Source/Core/VideoCommon/TextureConfig.h
@@ -9,7 +9,14 @@
#include "Common/CommonTypes.h"
#include "Common/MathUtil.h"
-#include "VideoCommon/VideoCommon.h"
+
+enum class AbstractTextureFormat : u32
+{
+ RGBA8,
+ DXT1,
+ DXT3,
+ DXT5
+};
struct TextureConfig
{
@@ -21,7 +28,7 @@ struct TextureConfig
u32 height = 0;
u32 levels = 1;
u32 layers = 1;
- HostTextureFormat format = HostTextureFormat::RGBA8;
+ AbstractTextureFormat format = AbstractTextureFormat::RGBA8;
bool rendertarget = false;
struct Hasher : std::hash<u64>
diff --git a/Source/Core/VideoCommon/VideoCommon.h b/Source/Core/VideoCommon/VideoCommon.h
index cff2883318..e25b2b66a5 100644
--- a/Source/Core/VideoCommon/VideoCommon.h
+++ b/Source/Core/VideoCommon/VideoCommon.h
@@ -77,15 +77,6 @@ enum class APIType
Nothing
};
-// Texture formats that videocommon can upload/use.
-enum class HostTextureFormat : u32
-{
- RGBA8,
- DXT1,
- DXT3,
- DXT5
-};
-
inline u32 RGBA8ToRGBA6ToRGBA8(u32 src)
{
u32 color = src;