GPU: Mask variable sprite/rectangle sizes

Fixes broken sprites in Gradius Deluxe Pack (Gradius II).
This commit is contained in:
Connor McLaughlin 2020-05-21 12:04:53 +10:00
parent c583459c6f
commit 237f469baa
2 changed files with 20 additions and 10 deletions

View file

@ -304,18 +304,19 @@ void GPU_HW::LoadVertices()
default:
{
const u32 width_and_height = m_fifo.Pop();
rectangle_width = static_cast<s32>(width_and_height & 0xFFFF);
rectangle_height = static_cast<s32>(width_and_height >> 16);
rectangle_width = static_cast<s32>(width_and_height & VRAM_WIDTH_MASK);
rectangle_height = static_cast<s32>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
if (rectangle_width >= MAX_PRIMITIVE_WIDTH || rectangle_height >= MAX_PRIMITIVE_HEIGHT)
{
Log_DebugPrintf("Culling too-large rectangle: %d,%d %dx%d", pos_x, pos_y, rectangle_width,
rectangle_height);
return;
}
}
break;
}
if (rectangle_width >= MAX_PRIMITIVE_WIDTH || rectangle_height >= MAX_PRIMITIVE_HEIGHT)
{
Log_DebugPrintf("Culling too-large rectangle: %d,%d %dx%d", pos_x, pos_y, rectangle_width, rectangle_height);
return;
}
// we can split the rectangle up into potentially 8 quads
DebugAssert(GetBatchVertexSpace() >= MAX_VERTICES_FOR_RECTANGLE);

View file

@ -1,8 +1,10 @@
#include "gpu_sw.h"
#include "common/assert.h"
#include "common/log.h"
#include "host_display.h"
#include "system.h"
#include <algorithm>
Log_SetChannel(GPU_SW);
GPU_SW::GPU_SW()
{
@ -277,8 +279,15 @@ void GPU_SW::DispatchRenderCommand()
default:
{
const u32 width_and_height = m_fifo.Pop();
width = static_cast<s32>(width_and_height & UINT32_C(0xFFFF));
height = static_cast<s32>(width_and_height >> 16);
width = static_cast<s32>(width_and_height & VRAM_WIDTH_MASK);
height = static_cast<s32>((width_and_height >> 16) & VRAM_HEIGHT_MASK);
if (width >= MAX_PRIMITIVE_WIDTH || height >= MAX_PRIMITIVE_HEIGHT)
{
Log_DebugPrintf("Culling too-large rectangle: %d,%d %dx%d", vp.x.GetValue(), vp.y.GetValue(), width,
height);
return;
}
}
break;
}