mirror of https://github.com/PCSX2/pcsx2.git
GS/TextureReplacements: Disable generated mipmaps on compressed textures
They should be provided in the file.
This commit is contained in:
parent
1beb5517a7
commit
866e5bd929
|
@ -131,7 +131,7 @@ u32 GSTexture::CalcUploadSize(u32 height, u32 pitch) const
|
||||||
|
|
||||||
void GSTexture::GenerateMipmapsIfNeeded()
|
void GSTexture::GenerateMipmapsIfNeeded()
|
||||||
{
|
{
|
||||||
if (!m_needs_mipmaps_generated || m_mipmap_levels <= 1)
|
if (!m_needs_mipmaps_generated || m_mipmap_levels <= 1 || IsCompressedFormat())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_needs_mipmaps_generated = false;
|
m_needs_mipmaps_generated = false;
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
|
|
||||||
Type GetType() const { return m_type; }
|
Type GetType() const { return m_type; }
|
||||||
Format GetFormat() const { return m_format; }
|
Format GetFormat() const { return m_format; }
|
||||||
bool IsCompressedFormat() const { return (m_format >= Format::BC1 && m_format <= Format::BC7); }
|
bool IsCompressedFormat() const { return IsCompressedFormat(m_format); }
|
||||||
|
|
||||||
u32 GetCompressedBytesPerBlock() const;
|
u32 GetCompressedBytesPerBlock() const;
|
||||||
u32 GetCompressedBlockSize() const;
|
u32 GetCompressedBlockSize() const;
|
||||||
|
@ -149,4 +149,7 @@ public:
|
||||||
|
|
||||||
// Typical size of a RGBA texture
|
// Typical size of a RGBA texture
|
||||||
virtual u32 GetMemUsage() { return m_size.x * m_size.y * (m_format == Format::UNorm8 ? 1 : 4); }
|
virtual u32 GetMemUsage() { return m_size.x * m_size.y * (m_format == Format::UNorm8 ? 1 : 4); }
|
||||||
|
|
||||||
|
// Helper routines for formats/types
|
||||||
|
static bool IsCompressedFormat(Format format) { return (format >= Format::BC1 && format <= Format::BC7); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -484,8 +484,8 @@ GSTexture* GSDevice11::CreateSurface(GSTexture::Type type, int width, int height
|
||||||
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = D3D11_BIND_DEPTH_STENCIL | D3D11_BIND_SHADER_RESOURCE;
|
||||||
break;
|
break;
|
||||||
case GSTexture::Type::Texture:
|
case GSTexture::Type::Texture:
|
||||||
desc.BindFlags = (levels > 1) ? (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE) : D3D11_BIND_SHADER_RESOURCE;
|
desc.BindFlags = (levels > 1 && !GSTexture::IsCompressedFormat(format)) ? (D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE) : D3D11_BIND_SHADER_RESOURCE;
|
||||||
desc.MiscFlags = (levels > 1) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
|
desc.MiscFlags = (levels > 1 && !GSTexture::IsCompressedFormat(format)) ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
|
||||||
break;
|
break;
|
||||||
case GSTexture::Type::Offscreen:
|
case GSTexture::Type::Offscreen:
|
||||||
desc.Usage = D3D11_USAGE_STAGING;
|
desc.Usage = D3D11_USAGE_STAGING;
|
||||||
|
|
|
@ -490,6 +490,20 @@ void GSTextureReplacements::ClearReplacementTextures()
|
||||||
|
|
||||||
GSTexture* GSTextureReplacements::CreateReplacementTexture(const ReplacementTexture& rtex, const GSVector2& scale, bool mipmap)
|
GSTexture* GSTextureReplacements::CreateReplacementTexture(const ReplacementTexture& rtex, const GSVector2& scale, bool mipmap)
|
||||||
{
|
{
|
||||||
|
// can't use generated mipmaps with compressed formats, because they can't be rendered to
|
||||||
|
// in the future I guess we could decompress the dds and generate them... but there's no reason that modders can't generate mips in dds
|
||||||
|
if (mipmap && GSTexture::IsCompressedFormat(rtex.format) && rtex.mips.empty())
|
||||||
|
{
|
||||||
|
static bool log_once = false;
|
||||||
|
if (!log_once)
|
||||||
|
{
|
||||||
|
Console.Warning("Disabling mipmaps on one or more compressed replacement textures.");
|
||||||
|
log_once = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
mipmap = false;
|
||||||
|
}
|
||||||
|
|
||||||
GSTexture* tex = g_gs_device->CreateTexture(rtex.width, rtex.height, mipmap, rtex.format);
|
GSTexture* tex = g_gs_device->CreateTexture(rtex.width, rtex.height, mipmap, rtex.format);
|
||||||
if (!tex)
|
if (!tex)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
Loading…
Reference in New Issue