2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

gl_texture_cache: Rename BGRCopyPass to FormatConversionPass

This commit is contained in:
ameerj 2021-11-16 18:19:47 -05:00
parent 71313509f7
commit 35ca6274f4
2 changed files with 18 additions and 21 deletions

View file

@ -538,7 +538,7 @@ void TextureCacheRuntime::EmulateCopyImage(Image& dst, Image& src,
ASSERT(src.info.type == ImageType::e3D); ASSERT(src.info.type == ImageType::e3D);
util_shaders.CopyBC4(dst, src, copies); util_shaders.CopyBC4(dst, src, copies);
} else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) { } else if (IsPixelFormatBGR(dst.info.format) || IsPixelFormatBGR(src.info.format)) {
bgr_copy_pass.CopyBGR(dst, src, copies); format_conversion_pass.ConvertImage(dst, src, copies);
} else { } else {
UNREACHABLE(); UNREACHABLE();
} }
@ -1286,32 +1286,29 @@ Framebuffer::Framebuffer(TextureCacheRuntime& runtime, std::span<ImageView*, NUM
Framebuffer::~Framebuffer() = default; Framebuffer::~Framebuffer() = default;
void BGRCopyPass::CopyBGR(Image& dst_image, Image& src_image, void FormatConversionPass::ConvertImage(Image& dst_image, Image& src_image,
std::span<const VideoCommon::ImageCopy> copies) { std::span<const VideoCommon::ImageCopy> copies) {
static constexpr VideoCommon::Offset3D zero_offset{0, 0, 0};
const u32 img_bpp = BytesPerBlock(src_image.info.format); const u32 img_bpp = BytesPerBlock(src_image.info.format);
for (const ImageCopy& copy : copies) { for (const ImageCopy& copy : copies) {
ASSERT(copy.src_offset == zero_offset);
ASSERT(copy.dst_offset == zero_offset);
const u32 num_src_layers = static_cast<u32>(copy.src_subresource.num_layers); const u32 num_src_layers = static_cast<u32>(copy.src_subresource.num_layers);
const u32 copy_size = copy.extent.width * copy.extent.height * num_src_layers * img_bpp; const u32 copy_size = copy.extent.width * copy.extent.height * num_src_layers * img_bpp;
if (bgr_pbo_size < copy_size) { if (pbo_size < copy_size) {
bgr_pbo.Create(); intermediate_pbo.Create();
bgr_pbo_size = copy_size; pbo_size = copy_size;
glNamedBufferData(bgr_pbo.handle, bgr_pbo_size, nullptr, GL_STREAM_COPY); glNamedBufferData(intermediate_pbo.handle, pbo_size, nullptr, GL_STREAM_COPY);
} }
// Copy from source to PBO // Copy from source to PBO
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width);
glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr_pbo.handle); glBindBuffer(GL_PIXEL_PACK_BUFFER, intermediate_pbo.handle);
glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height,
num_src_layers, src_image.GlFormat(), src_image.GlType(), num_src_layers, src_image.GlFormat(), src_image.GlType(),
static_cast<GLsizei>(bgr_pbo_size), nullptr); static_cast<GLsizei>(pbo_size), nullptr);
// Copy from PBO to destination in desired GL format // Copy from PBO to destination in desired GL format
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr_pbo.handle); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, intermediate_pbo.handle);
glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height,
copy.dst_subresource.num_layers, dst_image.GlFormat(), copy.dst_subresource.num_layers, dst_image.GlFormat(),
dst_image.GlType(), nullptr); dst_image.GlType(), nullptr);

View file

@ -52,17 +52,17 @@ struct FormatProperties {
bool is_compressed; bool is_compressed;
}; };
class BGRCopyPass { class FormatConversionPass {
public: public:
BGRCopyPass() = default; FormatConversionPass() = default;
~BGRCopyPass() = default; ~FormatConversionPass() = default;
void CopyBGR(Image& dst_image, Image& src_image, void ConvertImage(Image& dst_image, Image& src_image,
std::span<const VideoCommon::ImageCopy> copies); std::span<const VideoCommon::ImageCopy> copies);
private: private:
OGLBuffer bgr_pbo; OGLBuffer intermediate_pbo;
size_t bgr_pbo_size{}; size_t pbo_size{};
}; };
class TextureCacheRuntime { class TextureCacheRuntime {
@ -144,7 +144,7 @@ private:
const Device& device; const Device& device;
StateTracker& state_tracker; StateTracker& state_tracker;
UtilShaders util_shaders; UtilShaders util_shaders;
BGRCopyPass bgr_copy_pass; FormatConversionPass format_conversion_pass;
std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties; std::array<std::unordered_map<GLenum, FormatProperties>, 3> format_properties;
bool has_broken_texture_view_formats = false; bool has_broken_texture_view_formats = false;