video_core: Add more ASTC formats
This commit is contained in:
@ -42,7 +42,11 @@ CustomPixelFormat ToCustomPixelFormat(ddsktx_format format) {
|
||||
case DDSKTX_FORMAT_BC7:
|
||||
return CustomPixelFormat::BC7;
|
||||
case DDSKTX_FORMAT_ASTC4x4:
|
||||
return CustomPixelFormat::ASTC;
|
||||
return CustomPixelFormat::ASTC4;
|
||||
case DDSKTX_FORMAT_ASTC6x6:
|
||||
return CustomPixelFormat::ASTC6;
|
||||
case DDSKTX_FORMAT_ASTC8x6:
|
||||
return CustomPixelFormat::ASTC8;
|
||||
default:
|
||||
LOG_ERROR(Common, "Unknown dds/ktx pixel format {}", format);
|
||||
return CustomPixelFormat::RGBA8;
|
||||
@ -83,8 +87,8 @@ void CustomTexManager::FindCustomTextures() {
|
||||
|
||||
u32 width{};
|
||||
u32 height{};
|
||||
u64 hash{};
|
||||
u32 format{};
|
||||
unsigned long long hash{};
|
||||
std::string ext(3, ' ');
|
||||
|
||||
for (const FSTEntry& file : textures) {
|
||||
|
@ -59,8 +59,12 @@ std::string_view CustomPixelFormatAsString(CustomPixelFormat format) {
|
||||
return "BC5";
|
||||
case CustomPixelFormat::BC7:
|
||||
return "BC7";
|
||||
case CustomPixelFormat::ASTC:
|
||||
return "ASTC";
|
||||
case CustomPixelFormat::ASTC4:
|
||||
return "ASTC4";
|
||||
case CustomPixelFormat::ASTC6:
|
||||
return "ASTC6";
|
||||
case CustomPixelFormat::ASTC8:
|
||||
return "ASTC8";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,9 @@ enum class CustomPixelFormat : u32 {
|
||||
BC3 = 2,
|
||||
BC5 = 3,
|
||||
BC7 = 4,
|
||||
ASTC = 5,
|
||||
ASTC4 = 5,
|
||||
ASTC6 = 6,
|
||||
ASTC8 = 7,
|
||||
};
|
||||
|
||||
enum class SurfaceType : u32 {
|
||||
|
@ -107,7 +107,9 @@ bool Driver::IsCustomFormatSupported(VideoCore::CustomPixelFormat format) const
|
||||
return ext_texture_compression_s3tc;
|
||||
case VideoCore::CustomPixelFormat::BC7:
|
||||
return arb_texture_compression_bptc;
|
||||
case VideoCore::CustomPixelFormat::ASTC:
|
||||
case VideoCore::CustomPixelFormat::ASTC4:
|
||||
case VideoCore::CustomPixelFormat::ASTC6:
|
||||
case VideoCore::CustomPixelFormat::ASTC8:
|
||||
return is_gles;
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
// Licensed under GPLv2 or any later version
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include "common/microprofile.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/settings.h"
|
||||
#include "video_core/rasterizer_cache/utils.h"
|
||||
@ -53,6 +52,8 @@ static constexpr std::array CUSTOM_TUPLES = {
|
||||
FormatTuple{GL_COMPRESSED_RGBA_BPTC_UNORM_ARB, GL_COMPRESSED_RGBA_BPTC_UNORM_ARB,
|
||||
GL_UNSIGNED_BYTE},
|
||||
FormatTuple{GL_COMPRESSED_RGBA_ASTC_4x4, GL_COMPRESSED_RGBA_ASTC_4x4, GL_UNSIGNED_BYTE},
|
||||
FormatTuple{GL_COMPRESSED_RGBA_ASTC_6x6, GL_COMPRESSED_RGBA_ASTC_6x6, GL_UNSIGNED_BYTE},
|
||||
FormatTuple{GL_COMPRESSED_RGBA_ASTC_8x6, GL_COMPRESSED_RGBA_ASTC_8x6, GL_UNSIGNED_BYTE},
|
||||
};
|
||||
|
||||
[[nodiscard]] GLbitfield MakeBufferMask(VideoCore::SurfaceType type) {
|
||||
@ -72,15 +73,10 @@ static constexpr std::array CUSTOM_TUPLES = {
|
||||
return GL_COLOR_BUFFER_BIT;
|
||||
}
|
||||
|
||||
constexpr std::size_t UPLOAD_BUFFER_SIZE = 32 * 1024 * 1024;
|
||||
constexpr std::size_t DOWNLOAD_BUFFER_SIZE = 4 * 1024 * 1024;
|
||||
|
||||
TextureRuntime::TextureRuntime(Driver& driver)
|
||||
: driver{driver}, filterer{Settings::values.texture_filter_name.GetValue(),
|
||||
VideoCore::GetResolutionScaleFactor()},
|
||||
upload_buffer{GL_PIXEL_UNPACK_BUFFER, UPLOAD_BUFFER_SIZE} {
|
||||
VideoCore::GetResolutionScaleFactor()} {
|
||||
|
||||
download_buffer.resize(DOWNLOAD_BUFFER_SIZE);
|
||||
read_fbo.Create();
|
||||
draw_fbo.Create();
|
||||
|
||||
@ -102,22 +98,13 @@ void TextureRuntime::Clear() {
|
||||
}
|
||||
|
||||
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||
if (!upload) {
|
||||
if (size > download_buffer.size()) {
|
||||
download_buffer.resize(size);
|
||||
}
|
||||
return StagingData{
|
||||
.size = size,
|
||||
.mapped = std::span{download_buffer.data(), size},
|
||||
.buffer_offset = 0,
|
||||
};
|
||||
if (size > staging_buffer.size()) {
|
||||
staging_buffer.resize(size);
|
||||
}
|
||||
|
||||
auto [data, offset, invalidate] = upload_buffer.Map(size, 4);
|
||||
return StagingData{
|
||||
.size = size,
|
||||
.mapped = std::span{data, size},
|
||||
.buffer_offset = offset,
|
||||
.mapped = std::span{staging_buffer.data(), size},
|
||||
.buffer_offset = 0,
|
||||
};
|
||||
}
|
||||
|
||||
@ -378,10 +365,6 @@ void Surface::Upload(const VideoCore::BufferTextureCopy& upload, const StagingDa
|
||||
} else {
|
||||
const VideoCore::Rect2D rect = upload.texture_rect;
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, static_cast<GLint>(rect.GetWidth()));
|
||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, runtime.upload_buffer.Handle());
|
||||
|
||||
// Unmap the buffer FindStaging mapped beforehand
|
||||
runtime.upload_buffer.Unmap(staging.size);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, Handle());
|
||||
@ -390,11 +373,11 @@ void Surface::Upload(const VideoCore::BufferTextureCopy& upload, const StagingDa
|
||||
if (is_custom && custom_format != VideoCore::CustomPixelFormat::RGBA8) {
|
||||
glCompressedTexSubImage2D(GL_TEXTURE_2D, upload.texture_level, rect.left, rect.bottom,
|
||||
rect.GetWidth(), rect.GetHeight(), tuple.format, staging.size,
|
||||
reinterpret_cast<void*>(staging.buffer_offset));
|
||||
staging.mapped.data());
|
||||
} else {
|
||||
glTexSubImage2D(GL_TEXTURE_2D, upload.texture_level, rect.left, rect.bottom,
|
||||
rect.GetWidth(), rect.GetHeight(), tuple.format, tuple.type,
|
||||
reinterpret_cast<void*>(staging.buffer_offset));
|
||||
staging.mapped.data());
|
||||
}
|
||||
|
||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
|
||||
|
@ -147,8 +147,7 @@ private:
|
||||
std::array<ReinterpreterList, VideoCore::PIXEL_FORMAT_COUNT> reinterpreters;
|
||||
std::unordered_multimap<HostTextureTag, Allocation> texture_recycler;
|
||||
std::unordered_map<u64, OGLFramebuffer, Common::IdentityHash<u64>> framebuffer_cache;
|
||||
StreamBuffer upload_buffer;
|
||||
std::vector<u8> download_buffer;
|
||||
std::vector<u8> staging_buffer;
|
||||
OGLFramebuffer read_fbo, draw_fbo;
|
||||
};
|
||||
|
||||
|
@ -121,8 +121,12 @@ vk::Format MakeCustomFormat(VideoCore::CustomPixelFormat format) {
|
||||
return vk::Format::eBc5UnormBlock;
|
||||
case VideoCore::CustomPixelFormat::BC7:
|
||||
return vk::Format::eBc7UnormBlock;
|
||||
case VideoCore::CustomPixelFormat::ASTC:
|
||||
case VideoCore::CustomPixelFormat::ASTC4:
|
||||
return vk::Format::eAstc4x4UnormBlock;
|
||||
case VideoCore::CustomPixelFormat::ASTC6:
|
||||
return vk::Format::eAstc6x6UnormBlock;
|
||||
case VideoCore::CustomPixelFormat::ASTC8:
|
||||
return vk::Format::eAstc8x6UnormBlock;
|
||||
}
|
||||
LOG_ERROR(Render_Vulkan, "Unknown custom format {}", format);
|
||||
return vk::Format::eR8G8B8A8Unorm;
|
||||
@ -518,9 +522,10 @@ void Instance::CreateCustomFormatTable() {
|
||||
custom_format_table[0] = format_table[static_cast<u32>(VideoCore::PixelFormat::RGBA8)];
|
||||
|
||||
constexpr std::array custom_formats = {
|
||||
VideoCore::CustomPixelFormat::BC1, VideoCore::CustomPixelFormat::BC3,
|
||||
VideoCore::CustomPixelFormat::BC5, VideoCore::CustomPixelFormat::BC7,
|
||||
VideoCore::CustomPixelFormat::ASTC,
|
||||
VideoCore::CustomPixelFormat::BC1, VideoCore::CustomPixelFormat::BC3,
|
||||
VideoCore::CustomPixelFormat::BC5, VideoCore::CustomPixelFormat::BC7,
|
||||
VideoCore::CustomPixelFormat::ASTC4, VideoCore::CustomPixelFormat::ASTC6,
|
||||
VideoCore::CustomPixelFormat::ASTC8,
|
||||
};
|
||||
|
||||
for (const auto& custom_format : custom_formats) {
|
||||
|
Reference in New Issue
Block a user