early-access version 1501

This commit is contained in:
pineappleEA 2021-03-05 09:48:55 +01:00
parent 8335337d32
commit 7d721a51b8
4 changed files with 23 additions and 36 deletions

View file

@ -1,7 +1,7 @@
yuzu emulator early access yuzu emulator early access
============= =============
This is the source code for early-access 1500. This is the source code for early-access 1501.
## Legal Notice ## Legal Notice

View file

@ -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. // If format views are broken, only accept formats that are identical.
return format_a == format_b; return format_a == format_b;
} }
if (native_bgr) { static constexpr Table BGR_TABLE = MakeNativeBgrViewTable();
static constexpr Table TABLE = MakeNativeBgrViewTable(); static constexpr Table NO_BGR_TABLE = MakeNonNativeBgrViewTable();
return IsSupported(TABLE, format_a, format_b); return IsSupported(native_bgr ? BGR_TABLE : NO_BGR_TABLE, format_a, format_b);
} else {
static constexpr Table TABLE = MakeNonNativeBgrViewTable();
return IsSupported(TABLE, format_a, format_b);
}
} }
bool IsCopyCompatible(PixelFormat format_a, PixelFormat format_b, bool native_bgr) { bool IsCopyCompatible(PixelFormat format_a, PixelFormat format_b, bool native_bgr) {
if (native_bgr) { static constexpr Table BGR_TABLE = MakeNativeBgrCopyTable();
static constexpr Table TABLE = MakeNativeBgrCopyTable(); static constexpr Table NO_BGR_TABLE = MakeNonNativeBgrCopyTable();
return IsSupported(TABLE, format_a, format_b); return IsSupported(native_bgr ? BGR_TABLE : NO_BGR_TABLE, format_a, format_b);
} else {
static constexpr Table TABLE = MakeNonNativeBgrCopyTable();
return IsSupported(TABLE, format_a, format_b);
}
} }
} // namespace VideoCore::Surface } // namespace VideoCore::Surface

View file

@ -51,10 +51,9 @@ OGLProgram MakeProgram(std::string_view source) {
return program; return program;
} }
size_t CopyBufferSize(const VideoCommon::ImageCopy& copy) { size_t NumPixelsInCopy(const VideoCommon::ImageCopy& copy) {
const size_t size = static_cast<size_t>(copy.extent.width * copy.extent.height * return static_cast<size_t>(copy.extent.width * copy.extent.height *
copy.src_subresource.num_layers); copy.src_subresource.num_layers);
return size;
} }
} // Anonymous namespace } // 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); const u32 bytes_per_block = BytesPerBlock(dst_image.info.format);
switch (bytes_per_block) { switch (bytes_per_block) {
case 2: case 2:
// BGR565 Copy // BGR565 copy
for (const ImageCopy& copy : copies) { for (const ImageCopy& copy : copies) {
ASSERT(copy.src_offset == zero_offset); ASSERT(copy.src_offset == zero_offset);
ASSERT(copy.dst_offset == zero_offset); ASSERT(copy.dst_offset == zero_offset);
@ -298,7 +297,7 @@ void UtilShaders::CopyBGR(Image& dst_image, Image& src_image,
} }
break; break;
case 4: { case 4: {
// BGRA8 Copy // BGRA8 copy
program_manager.BindHostCompute(copy_bgra_program.handle); program_manager.BindHostCompute(copy_bgra_program.handle);
constexpr GLenum FORMAT = GL_RGBA8; constexpr GLenum FORMAT = GL_RGBA8;
for (const ImageCopy& copy : copies) { 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 // Copy from source to PBO
glPixelStorei(GL_PACK_ALIGNMENT, 1); glPixelStorei(GL_PACK_ALIGNMENT, 1);
glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle);
glPixelStorei(GL_PACK_ROW_LENGTH, copy.extent.width); 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, 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, copy.src_subresource.num_layers, GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
static_cast<GLsizei>(bgr16_pbo_size), 0); static_cast<GLsizei>(bgr16_pbo_size), nullptr);
// Copy from PBO to destination in reverse order // Copy from PBO to destination in reverse order
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, bgr16_pbo.handle);
glPixelStorei(GL_UNPACK_ROW_LENGTH, copy.extent.width); 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, 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) { 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) { void Bgr565CopyPass::CreateNewCopyBuffer(const ImageCopy& copy, GLenum target, GLuint format) {
bgr16_pbo.Release();
bgr16_pbo.Create(); bgr16_pbo.Create();
bgr16_pbo_size = CopyBufferSize(copy) * sizeof(u16); bgr16_pbo_size = NumPixelsInCopy(copy) * sizeof(u16);
glBindBuffer(GL_PIXEL_PACK_BUFFER, bgr16_pbo.handle); glNamedBufferData(bgr16_pbo.handle, bgr16_pbo_size, nullptr, GL_STREAM_COPY);
glNamedBufferData(bgr16_pbo.handle, bgr16_pbo_size, 0, GL_STREAM_COPY);
} }
} // namespace OpenGL } // namespace OpenGL

View file

@ -24,10 +24,7 @@ ImageViewBase::ImageViewBase(const ImageViewInfo& info, const ImageInfo& image_i
.height = std::max(image_info.size.height >> range.base.level, 1u), .height = std::max(image_info.size.height >> range.base.level, 1u),
.depth = std::max(image_info.size.depth >> range.base.level, 1u), .depth = std::max(image_info.size.depth >> range.base.level, 1u),
} { } {
const bool native_bgr = ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false, true),
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 view format {} is incompatible with image format {}", info.format,
image_info.format); image_info.format);
const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue(); const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue();