From 7d721a51b852f314e6fb290df593a659e830b444 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Fri, 5 Mar 2021 09:48:55 +0100 Subject: [PATCH] early-access version 1501 --- README.md | 2 +- src/video_core/compatible_formats.cpp | 20 ++++--------- .../renderer_opengl/util_shaders.cpp | 28 +++++++++---------- .../texture_cache/image_view_base.cpp | 9 ++---- 4 files changed, 23 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c143d21b2..bf1006bdb 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1500. +This is the source code for early-access 1501. ## Legal Notice diff --git a/src/video_core/compatible_formats.cpp b/src/video_core/compatible_formats.cpp index 7b73f9886..8317d0636 100755 --- a/src/video_core/compatible_formats.cpp +++ b/src/video_core/compatible_formats.cpp @@ -271,23 +271,15 @@ bool IsViewCompatible(PixelFormat format_a, PixelFormat format_b, bool broken_vi // If format views are broken, only accept formats that are identical. return format_a == format_b; } - if (native_bgr) { - static constexpr Table TABLE = MakeNativeBgrViewTable(); - return IsSupported(TABLE, format_a, format_b); - } else { - static constexpr Table TABLE = MakeNonNativeBgrViewTable(); - return IsSupported(TABLE, format_a, format_b); - } + static constexpr Table BGR_TABLE = MakeNativeBgrViewTable(); + static constexpr Table NO_BGR_TABLE = MakeNonNativeBgrViewTable(); + return IsSupported(native_bgr ? BGR_TABLE : NO_BGR_TABLE, format_a, format_b); } bool IsCopyCompatible(PixelFormat format_a, PixelFormat format_b, bool native_bgr) { - if (native_bgr) { - static constexpr Table TABLE = MakeNativeBgrCopyTable(); - return IsSupported(TABLE, format_a, format_b); - } else { - static constexpr Table TABLE = MakeNonNativeBgrCopyTable(); - return IsSupported(TABLE, format_a, format_b); - } + static constexpr Table BGR_TABLE = MakeNativeBgrCopyTable(); + static constexpr Table NO_BGR_TABLE = MakeNonNativeBgrCopyTable(); + return IsSupported(native_bgr ? BGR_TABLE : NO_BGR_TABLE, format_a, format_b); } } // namespace VideoCore::Surface diff --git a/src/video_core/renderer_opengl/util_shaders.cpp b/src/video_core/renderer_opengl/util_shaders.cpp index 4e21bd1bc..2e3f0ba5b 100755 --- a/src/video_core/renderer_opengl/util_shaders.cpp +++ b/src/video_core/renderer_opengl/util_shaders.cpp @@ -51,10 +51,9 @@ OGLProgram MakeProgram(std::string_view source) { return program; } -size_t CopyBufferSize(const VideoCommon::ImageCopy& copy) { - const size_t size = static_cast(copy.extent.width * copy.extent.height * - copy.src_subresource.num_layers); - return size; +size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) { + return static_cast(copy.extent.width * copy.extent.height * + copy.src_subresource.num_layers); } } // Anonymous namespace @@ -290,7 +289,7 @@ void UtilShaders::CopyBGR(Image& dst_image, Image& src_image, const u32 bytes_per_block = BytesPerBlock(dst_image.info.format); switch (bytes_per_block) { case 2: - // BGR565 Copy + // BGR565 copy for (const ImageCopy& copy : copies) { ASSERT(copy.src_offset == zero_offset); ASSERT(copy.dst_offset == zero_offset); @@ -298,7 +297,7 @@ void UtilShaders::CopyBGR(Image& dst_image, Image& src_image, } break; case 4: { - // BGRA8 Copy + // BGRA8 copy program_manager.BindHostCompute(copy_bgra_program.handle); constexpr GLenum FORMAT = GL_RGBA8; for (const ImageCopy& copy : copies) { @@ -343,30 +342,29 @@ void Bgr565CopyPass::Execute(const Image& dst_image, const Image& src_image, } // Copy from source to PBO glPixelStorei(GL_PACK_ALIGNMENT, 1); - glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle); glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); + glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle); glGetTextureSubImage(src_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, copy.src_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, - static_cast(bgr16_pbo_size), 0); + static_cast(bgr16_pbo_size), nullptr); // Copy from PBO to destination in reverse order glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr16_pbo.handle); glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); + glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr16_pbo.handle); glTextureSubImage3D(dst_image.Handle(), 0, 0, 0, 0, copy.extent.width, copy.extent.height, - copy.dst_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, 0); + copy.dst_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5_REV, + nullptr); } bool Bgr565CopyPass::CopyBufferCreationNeeded(const ImageCopy& copy) { - return bgr16_pbo_size < CopyBufferSize(copy) * sizeof(u16); + return bgr16_pbo_size < NumPixelsInCopy(copy) * sizeof(u16); } void Bgr565CopyPass::CreateNewCopyBuffer(const ImageCopy& copy, GLenum target, GLuint format) { - bgr16_pbo.Release(); bgr16_pbo.Create(); - bgr16_pbo_size = CopyBufferSize(copy) * sizeof(u16); - glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle); - glNamedBufferData(bgr16_pbo.handle, bgr16_pbo_size, 0, GL_STREAM_COPY); + bgr16_pbo_size = NumPixelsInCopy(copy) * sizeof(u16); + glNamedBufferData(bgr16_pbo.handle, bgr16_pbo_size, nullptr, GL_STREAM_COPY); } } // namespace OpenGL diff --git a/src/video_core/texture_cache/image_view_base.cpp b/src/video_core/texture_cache/image_view_base.cpp index d80ad9a87..f89a40b4c 100755 --- a/src/video_core/texture_cache/image_view_base.cpp +++ b/src/video_core/texture_cache/image_view_base.cpp @@ -24,12 +24,9 @@ ImageViewBase::ImageViewBase(const ImageViewInfo& info, const ImageInfo& image_i .height = std::max(image_info.size.height >> range.base.level, 1u), .depth = std::max(image_info.size.depth >> range.base.level, 1u), } { - const bool native_bgr = - Settings::values.renderer_backend.GetValue() == Settings::RendererBackend::Vulkan; - ASSERT_MSG( - VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, native_bgr), - "Image view format {} is incompatible with image format {}", info.format, - image_info.format); + ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, true), + "Image view format {} is incompatible with image format {}", info.format, + image_info.format); const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue(); if (image_info.type == ImageType::Linear && is_async) { flags |= ImageViewFlagBits::PreemtiveDownload;