[D3D12] Don't decompress unaligned BC textures if supported
This commit is contained in:
@@ -1442,19 +1442,30 @@ D3D12TextureCache::D3D12Texture::~D3D12Texture() {
|
||||
}
|
||||
|
||||
bool D3D12TextureCache::IsDecompressionNeeded(xenos::TextureFormat format,
|
||||
uint32_t width, uint32_t height) {
|
||||
uint32_t width,
|
||||
uint32_t height) const {
|
||||
DXGI_FORMAT dxgi_format_uncompressed =
|
||||
host_formats_[uint32_t(format)].dxgi_format_uncompressed;
|
||||
if (dxgi_format_uncompressed == DXGI_FORMAT_UNKNOWN) {
|
||||
return false;
|
||||
}
|
||||
const FormatInfo* format_info = FormatInfo::Get(format);
|
||||
return (width & (format_info->block_width - 1)) != 0 ||
|
||||
(height & (format_info->block_height - 1)) != 0;
|
||||
if (!(width & (format_info->block_width - 1)) &&
|
||||
!(height & (format_info->block_height - 1))) {
|
||||
return false;
|
||||
}
|
||||
// UnalignedBlockTexturesSupported is for block-compressed textures with the
|
||||
// block size of 4x4, but not for 2x1 (4:2:2) subsampled formats.
|
||||
if (format_info->block_width == 4 && format_info->block_height == 4 &&
|
||||
command_processor_.GetD3D12Provider()
|
||||
.AreUnalignedBlockTexturesSupported()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
TextureCache::LoadShaderIndex D3D12TextureCache::GetLoadShaderIndex(
|
||||
TextureKey key) {
|
||||
TextureKey key) const {
|
||||
const HostFormat& host_format = host_formats_[uint32_t(key.format)];
|
||||
if (key.signed_separate) {
|
||||
return host_format.load_shader_signed;
|
||||
|
||||
@@ -361,30 +361,30 @@ class D3D12TextureCache final : public TextureCache {
|
||||
|
||||
// Whether decompression is needed on the host (Direct3D only allows creation
|
||||
// of block-compressed textures with 4x4-aligned dimensions on PC).
|
||||
static bool IsDecompressionNeeded(xenos::TextureFormat format, uint32_t width,
|
||||
uint32_t height);
|
||||
static DXGI_FORMAT GetDXGIResourceFormat(xenos::TextureFormat format,
|
||||
uint32_t width, uint32_t height) {
|
||||
bool IsDecompressionNeeded(xenos::TextureFormat format, uint32_t width,
|
||||
uint32_t height) const;
|
||||
DXGI_FORMAT GetDXGIResourceFormat(xenos::TextureFormat format, uint32_t width,
|
||||
uint32_t height) const {
|
||||
const HostFormat& host_format = host_formats_[uint32_t(format)];
|
||||
return IsDecompressionNeeded(format, width, height)
|
||||
? host_format.dxgi_format_uncompressed
|
||||
: host_format.dxgi_format_resource;
|
||||
}
|
||||
static DXGI_FORMAT GetDXGIResourceFormat(TextureKey key) {
|
||||
DXGI_FORMAT GetDXGIResourceFormat(TextureKey key) const {
|
||||
return GetDXGIResourceFormat(key.format, key.GetWidth(), key.GetHeight());
|
||||
}
|
||||
static DXGI_FORMAT GetDXGIUnormFormat(xenos::TextureFormat format,
|
||||
uint32_t width, uint32_t height) {
|
||||
DXGI_FORMAT GetDXGIUnormFormat(xenos::TextureFormat format, uint32_t width,
|
||||
uint32_t height) const {
|
||||
const HostFormat& host_format = host_formats_[uint32_t(format)];
|
||||
return IsDecompressionNeeded(format, width, height)
|
||||
? host_format.dxgi_format_uncompressed
|
||||
: host_format.dxgi_format_unsigned;
|
||||
}
|
||||
static DXGI_FORMAT GetDXGIUnormFormat(TextureKey key) {
|
||||
DXGI_FORMAT GetDXGIUnormFormat(TextureKey key) const {
|
||||
return GetDXGIUnormFormat(key.format, key.GetWidth(), key.GetHeight());
|
||||
}
|
||||
|
||||
static LoadShaderIndex GetLoadShaderIndex(TextureKey key);
|
||||
LoadShaderIndex GetLoadShaderIndex(TextureKey key) const;
|
||||
|
||||
static constexpr bool AreDimensionsCompatible(
|
||||
xenos::FetchOpDimension binding_dimension,
|
||||
|
||||
Reference in New Issue
Block a user