TextureCache: Extract BP enum check to VideoCommon.

We have TOO many video backends.
This commit is contained in:
degasus
2016-12-26 20:54:37 +01:00
parent d07d9ba499
commit 04f319066d
23 changed files with 112 additions and 135 deletions

View File

@ -88,13 +88,8 @@ void TextureCache::ConvertTexture(TCacheEntryBase* base_entry, TCacheEntryBase*
m_texture_converter->ConvertTexture(entry, unconverted, m_render_pass, palette, format);
}
static bool IsDepthCopyFormat(PEControl::PixelFormat format)
{
return format == PEControl::Z24;
}
void TextureCache::CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row,
u32 num_blocks_y, u32 memory_stride, PEControl::PixelFormat src_format,
u32 num_blocks_y, u32 memory_stride, bool is_depth_copy,
const EFBRectangle& src_rect, bool is_intensity, bool scale_by_half)
{
// Flush EFB pokes first, as they're expected to be included.
@ -107,7 +102,7 @@ void TextureCache::CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_
{static_cast<u32>(scaled_src_rect.GetWidth()),
static_cast<u32>(scaled_src_rect.GetHeight())}};
Texture2D* src_texture;
if (IsDepthCopyFormat(src_format))
if (is_depth_copy)
src_texture = FramebufferManager::GetInstance()->ResolveEFBDepthTexture(region);
else
src_texture = FramebufferManager::GetInstance()->ResolveEFBColorTexture(region);
@ -124,8 +119,8 @@ void TextureCache::CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_
VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL);
m_texture_converter->EncodeTextureToMemory(src_texture->GetView(), dst, format, native_width,
bytes_per_row, num_blocks_y, memory_stride, src_format,
is_intensity, scale_by_half, src_rect);
bytes_per_row, num_blocks_y, memory_stride,
is_depth_copy, is_intensity, scale_by_half, src_rect);
// Transition back to original state
src_texture->TransitionToLayout(g_command_buffer_mgr->GetCurrentCommandBuffer(), original_layout);
@ -436,7 +431,7 @@ void TextureCache::TCacheEntry::Load(const u8* buffer, unsigned int width, unsig
}
}
void TextureCache::TCacheEntry::FromRenderTarget(u8* dst, PEControl::PixelFormat src_format,
void TextureCache::TCacheEntry::FromRenderTarget(u8* dst, bool is_depth_copy,
const EFBRectangle& src_rect, bool scale_by_half,
unsigned int cbufid, const float* colmat)
{
@ -444,7 +439,6 @@ void TextureCache::TCacheEntry::FromRenderTarget(u8* dst, PEControl::PixelFormat
FramebufferManager* framebuffer_mgr =
static_cast<FramebufferManager*>(g_framebuffer_manager.get());
TargetRectangle scaled_src_rect = g_renderer->ConvertEFBRectangle(src_rect);
bool is_depth_copy = IsDepthCopyFormat(src_format);
// Flush EFB pokes first, as they're expected to be included.
framebuffer_mgr->FlushEFBPokes();

View File

@ -29,7 +29,7 @@ public:
VkFramebuffer GetFramebuffer() const { return m_framebuffer; }
void Load(const u8* buffer, unsigned int width, unsigned int height,
unsigned int expanded_width, unsigned int level) override;
void FromRenderTarget(u8* dst, PEControl::PixelFormat src_format, const EFBRectangle& src_rect,
void FromRenderTarget(u8* dst, bool is_depth_copy, const EFBRectangle& src_rect,
bool scale_by_half, unsigned int cbufid, const float* colmat) override;
void CopyRectangleFromTexture(const TCacheEntryBase* source,
const MathUtil::Rectangle<int>& src_rect,
@ -60,7 +60,7 @@ public:
TlutFormat format) override;
void CopyEFB(u8* dst, u32 format, u32 native_width, u32 bytes_per_row, u32 num_blocks_y,
u32 memory_stride, PEControl::PixelFormat src_format, const EFBRectangle& src_rect,
u32 memory_stride, bool is_depth_copy, const EFBRectangle& src_rect,
bool is_intensity, bool scale_by_half) override;
void CopyRectangleFromTexture(TCacheEntry* dst_texture, const MathUtil::Rectangle<int>& dst_rect,

View File

@ -207,7 +207,7 @@ void TextureConverter::ConvertTexture(TextureCache::TCacheEntry* dst_entry,
void TextureConverter::EncodeTextureToMemory(VkImageView src_texture, u8* dest_ptr, u32 format,
u32 native_width, u32 bytes_per_row, u32 num_blocks_y,
u32 memory_stride, PEControl::PixelFormat src_format,
u32 memory_stride, bool is_depth_copy,
bool is_intensity, int scale_by_half,
const EFBRectangle& src_rect)
{
@ -234,7 +234,7 @@ void TextureConverter::EncodeTextureToMemory(VkImageView src_texture, u8* dest_p
draw.SetPushConstants(position_uniform, sizeof(position_uniform));
// Doesn't make sense to linear filter depth values
draw.SetPSSampler(0, src_texture, (scale_by_half && src_format != PEControl::Z24) ?
draw.SetPSSampler(0, src_texture, (scale_by_half && !is_depth_copy) ?
g_object_cache->GetLinearSampler() :
g_object_cache->GetPointSampler());

View File

@ -35,8 +35,8 @@ public:
// NOTE: Executes the current command buffer.
void EncodeTextureToMemory(VkImageView src_texture, u8* dest_ptr, u32 format, u32 native_width,
u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride,
PEControl::PixelFormat src_format, bool is_intensity,
int scale_by_half, const EFBRectangle& source);
bool is_depth_copy, bool is_intensity, int scale_by_half,
const EFBRectangle& source);
// Encodes texture to guest memory in XFB (YUYV) format.
void EncodeTextureToMemoryYUYV(void* dst_ptr, u32 dst_width, u32 dst_stride, u32 dst_height,