Compare commits

...
7 Commits
5 changed files with 87 additions and 26 deletions
+11 -11
View File
@@ -5,23 +5,23 @@
// clang-format off
#define VM_SIZE 4194304u
#define HALF_VM_SIZE (VM_SIZE / 2u)
#define GS_PAGE_SIZE 8192u
#define GS_BLOCK_SIZE 256u
#define GS_COLUMN_SIZE 64u
#define GS_BLOCKS_PER_PAGE (GS_PAGE_SIZE / GS_BLOCK_SIZE)
#define GS_MAX_PAGES (VM_SIZE / GS_PAGE_SIZE)
#define GS_MAX_BLOCKS (VM_SIZE / GS_BLOCK_SIZE)
#define GS_MAX_COLUMNS (VM_SIZE / GS_COLUMN_SIZE)
//if defined, will send much info in reply to the API title info queri from PCSX2
//default should be undefined
//#define GSTITLEINFO_API_FORCE_VERBOSE
#include "GSVector.h"
constexpr u32 VM_SIZE = 4194304u;
constexpr u32 HALF_VM_SIZE = (VM_SIZE / 2u);
constexpr u32 GS_PAGE_SIZE = 8192u;
constexpr u32 GS_BLOCK_SIZE = 256u;
constexpr u32 GS_COLUMN_SIZE = 64u;
constexpr u32 GS_BLOCKS_PER_PAGE = (GS_PAGE_SIZE / GS_BLOCK_SIZE);
constexpr u32 GS_MAX_PAGES = (VM_SIZE / GS_PAGE_SIZE);
constexpr u32 GS_MAX_BLOCKS = (VM_SIZE / GS_BLOCK_SIZE);
constexpr u32 GS_MAX_COLUMNS = (VM_SIZE / GS_COLUMN_SIZE);
#pragma pack(push, 1)
enum GS_PRIM
+1 -1
View File
@@ -805,7 +805,7 @@ GSTexture* GSDevice::CreateTexture(int w, int h, int mipmap_levels, GSTexture::F
{
pxAssert(mipmap_levels != 0 && (mipmap_levels < 0 || mipmap_levels <= GetMipmapLevelsForSize(w, h)));
const int levels = mipmap_levels < 0 ? GetMipmapLevelsForSize(w, h) : mipmap_levels;
return FetchSurface(GSTexture::Texture, w, h, levels, format, false, m_features.prefer_new_textures && prefer_reuse);
return FetchSurface(GSTexture::Texture, w, h, levels, format, false, !m_features.prefer_new_textures || prefer_reuse);
}
GSTexture* GSDevice::CreateTexture(const GSVector2i& size, int mipmap_levels, GSTexture::Format format, bool prefer_reuse)
+18 -8
View File
@@ -3225,8 +3225,10 @@ void GSRendererHW::Draw()
// Be careful of being 1 pixel from filled.
const bool page_aligned = (m_r.w % pgs.y) == (pgs.y - 1) || (m_r.w % pgs.y) == 0;
const bool is_zero_color_clear = (GetConstantDirectWriteMemClearColor() == 0 && !preserve_rt_color && page_aligned);
const bool is_zero_depth_clear = (GetConstantDirectWriteMemClearDepth() == 0 && !preserve_depth && page_aligned);
const bool is_full_color_cover = !preserve_rt_color && page_aligned;
const bool is_full_depth_cover = !preserve_depth && page_aligned;
const bool is_zero_color_clear = (GetConstantDirectWriteMemClearColor() == 0 && is_full_color_cover);
const bool is_zero_depth_clear = (GetConstantDirectWriteMemClearDepth() == 0 && is_full_depth_cover);
bool gs_mem_cleared = false;
// If it's an invalid-sized draw, do the mem clear on the CPU, we don't want to create huge targets.
// If clearing to zero, don't bother creating the target. Games tend to clear more than they use, wasting VRAM/bandwidth.
@@ -3261,8 +3263,8 @@ void GSRendererHW::Draw()
}
gs_mem_cleared |= overwriting_whole_rt && overwriting_whole_ds && (!no_rt || !no_ds);
if (overwriting_whole_rt && overwriting_whole_ds &&
TryGSMemClear(no_rt, preserve_rt_color, is_zero_color_clear, rt_end_bp,
no_ds, preserve_depth, is_zero_depth_clear, ds_end_bp))
TryGSMemClear(no_rt, preserve_rt_color, is_full_color_cover, rt_end_bp,
no_ds, preserve_depth, is_full_depth_cover, ds_end_bp))
{
GL_INS("HW: Skipping (%d,%d=>%d,%d) draw at FBP %x/ZBP %x due to invalid height or zero clear.", m_r.x, m_r.y,
m_r.z, m_r.w, m_cached_ctx.FRAME.Block(), m_cached_ctx.ZBUF.Block());
@@ -3285,8 +3287,14 @@ void GSRendererHW::Draw()
}
}
CleanupDraw(false);
return;
no_rt |= is_zero_color_clear;
no_ds |= is_zero_depth_clear;
if (no_rt && no_ds)
{
CleanupDraw(false);
return;
}
}
}
@@ -9975,9 +9983,11 @@ bool GSRendererHW::DetectDoubleHalfClear(bool& no_rt, bool& no_ds)
// path write out FRAME and Z separately, with their associated masks. Limit it to black to avoid false positives.
if (write_color == 0)
{
// Don't check the *entire* size for the end, as some games (X-Men) decide it's done with Z and starts overwriting
// the end with other things, which causes a resize, so the end point is no longer in the right place.
// So let's just check there's at least one page over the half way point, at worst it means 2 targets overlap.
const GSTextureCache::Target* base_tgt = g_texture_cache->GetExactTarget(base * GS_BLOCKS_PER_PAGE,
m_cached_ctx.FRAME.FBW, clear_depth ? GSTextureCache::DepthStencil : GSTextureCache::RenderTarget,
GSLocalMemory::GetEndBlockAddress(half * GS_BLOCKS_PER_PAGE, m_cached_ctx.FRAME.FBW, m_cached_ctx.FRAME.PSM, m_r));
m_cached_ctx.FRAME.FBW, clear_depth ? GSTextureCache::DepthStencil : GSTextureCache::RenderTarget, (half + 1) * GS_BLOCKS_PER_PAGE);
if (base_tgt)
{
GL_INS("HW: DetectDoubleHalfClear(): Invalidating targets at 0x%x/0x%x due to different formats, and clear to black.",
+56 -6
View File
@@ -3565,16 +3565,62 @@ bool GSTextureCache::PreloadTarget(GIFRegTEX0 TEX0, const GSVector2i& size, cons
// Make sure there's sufficient compatibility/overlap between the old target and the new target
// to warrant loading from the old target.
const u32 old_buffer_width = std::max(1U, old_dst->m_TEX0.TBW);
if (old_dst->m_TEX0.PSM != dst->m_TEX0.PSM ||
!old_dst->Overlaps(dst->m_TEX0.TBP0, dst->m_TEX0.TBW, dst->m_TEX0.PSM, dst_valid))
{
if (old_dst->m_TEX0.TBP0 == dst->m_TEX0.TBP0 && dst_end_block >= old_dst->m_end_block && (!src || !src->m_target || src->m_from_target != old_dst))
{
InvalidateSourcesFromTarget(old_dst);
i = list.erase(j);
delete old_dst;
continue;
}
if (old_dst->Overlaps(dst->m_TEX0.TBP0, dst->m_TEX0.TBW, dst->m_TEX0.PSM, dst_valid))
{
const GSLocalMemory::psm_t& psm_o = GSLocalMemory::m_psm[old_dst->m_TEX0.PSM];
if (dst->m_TEX0.TBP0 > old_dst->m_TEX0.TBP0)
{
const int block_diff = dst->m_TEX0.TBP0 - old_dst->m_TEX0.TBP0;
const u32 old_pages_wide = old_buffer_width * 64 / psm_o.pgs.x;
if ((block_diff % (GS_BLOCKS_PER_PAGE * old_pages_wide)) == 0) // Check for left alignment.
{
const int new_height = block_diff / (GS_BLOCKS_PER_PAGE * old_pages_wide) * psm_o.pgs.y;
old_dst->m_valid = old_dst->m_valid.rintersect(GSVector4i(old_dst->m_valid.x, old_dst->m_valid.y, old_dst->m_valid.z, new_height));
old_dst->ResizeValidity(old_dst->m_valid);
}
}
else // new target is behind the old one, so need to move the start of the old one to the end block of the new.
{
const int block_diff = dst_end_block - old_dst->m_TEX0.TBP0;
const u32 old_pages_wide = old_buffer_width * 64 / psm_o.pgs.x;
if ((block_diff % (GS_BLOCKS_PER_PAGE * old_pages_wide)) == 0) // Check for left alignment.
{
const int change_height = block_diff / (GS_BLOCKS_PER_PAGE * old_pages_wide) * psm_o.pgs.y;
old_dst->m_valid = old_dst->m_valid.rintersect(GSVector4i(old_dst->m_valid.x, old_dst->m_valid.y, old_dst->m_valid.z, old_dst->m_valid.w - change_height));
old_dst->m_TEX0.TBP0 += block_diff;
const GSVector2i new_scaled_size = GSVector2i(old_dst->m_unscaled_size * old_dst->m_scale);
if (GSTexture* tex = g_gs_device->CreateCompatible(dst->m_texture, new_scaled_size, true))
{
const int height_offset = change_height * old_dst->m_scale;
g_gs_device->CopyRect(old_dst->m_texture, tex, GSVector4i(0, height_offset, old_dst->GetUnscaledWidth() * old_dst->m_scale, old_dst->GetUnscaledHeight() * old_dst->m_scale), 0, 0);
g_gs_device->Recycle(old_dst->m_texture);
old_dst->m_texture = tex;
}
}
}
}
i++;
continue;
}
const int page_diff = std::abs(static_cast<int>(old_dst->m_TEX0.TBP0 - dst->m_TEX0.TBP0)) >> 5;
const u32 new_buffer_width = std::max(1U, dst->m_TEX0.TBW);
const u32 old_buffer_width = std::max(1U, old_dst->m_TEX0.TBW);
// Handle cases where the buffer widths don't match.
if (new_buffer_width != old_buffer_width)
@@ -3592,7 +3638,7 @@ bool GSTextureCache::PreloadTarget(GIFRegTEX0 TEX0, const GSVector2i& size, cons
const u32 old_pages_wide = old_buffer_width * 64 / psm_s.pgs.x;
if ((block_diff % (32 * old_pages_wide)) == 0) // Check for left alignment.
{
const int new_height = block_diff / (32 * old_pages_wide) * psm_s.pgs.y;
const int new_height = block_diff / (GS_BLOCKS_PER_PAGE * old_pages_wide) * psm_s.pgs.y;
old_dst->m_valid = old_dst->m_valid.rintersect(GSVector4i(0, 0, old_dst->GetUnscaledWidth(), new_height));
if (old_dst->m_valid.rempty())
{
@@ -4543,10 +4589,14 @@ void GSTextureCache::InvalidateContainedTargets(u32 start_bp, u32 end_bp, u32 wr
InvalidateSourcesFromTarget(t);
t->m_valid_alpha_low &= preserve_alpha;
t->m_valid_alpha_high &= preserve_alpha;
t->m_valid_rgb &= (fb_mask & 0x00FFFFFF) != 0;
t->m_was_dst_matched = false;
if (type == DepthStencil || start_bp == t->m_TEX0.TBP0 || (start_bp < t->m_TEX0.TBP0 && t->UnwrappedEndBlock() <= end_bp))
{
const bool compatible_channel_swizzle = GSLocalMemory::m_psm[t->m_TEX0.PSM].bpp == GSLocalMemory::m_psm[write_psm].bpp;
t->m_valid_alpha_low &= preserve_alpha && compatible_channel_swizzle;
t->m_valid_alpha_high &= preserve_alpha && compatible_channel_swizzle;
t->m_valid_rgb &= (fb_mask & 0x00FFFFFF) != 0 && compatible_channel_swizzle;
t->m_was_dst_matched = false;
}
// Don't keep partial depth buffers around.
if ((!t->m_valid_alpha_low && !t->m_valid_alpha_high && !t->m_valid_rgb) || type == DepthStencil)
+1
View File
@@ -92,6 +92,7 @@ namespace usb_lightgun
{"SLPS-25077", 90.0f, 97.5f, 422, 118, 640, 240}, // Vampire Night (J)
{"SLUS-20221", 89.8f, 102.5f, 422, 124, 640, 228}, // Vampire Night (U)
{"SLES-51229", 110.15f, 100.0f, 433, 159, 512, 256}, // Virtua Cop - Elite Edition (E,J) (480i)
{"SLPM-62205", 110.15f, 100.0f, 433, 159, 512, 256}, // Virtua Cop Re-Birth (J) (480i)
// {"SLES-51229", 85.75f, 92.0f, 456, 164, 640, 256}, // Virtua Cop - Elite Edition (E,J) (480p)
};