vulkan: revert to using 3 swap images. fix crash when switching gl/vk

Fix Hello Kitty crash with empty first TR polygon
Fix Test Drive Le Mans crash on invalid textures
Fix wldkickspw crash with invalid TA data
This commit is contained in:
Flyinghead 2020-07-11 17:38:41 +02:00
parent 1713124711
commit 4ecf43a08d
4 changed files with 18 additions and 13 deletions

View File

@ -448,7 +448,6 @@ public:
ta_list_start(data->pcw.ListType); //start a list ;)
VertexDataFP = ta_sprite_data;
//printf("Sprite \n");
AppendSpriteParam((TA_SpriteParam*)data);
data+=SZ32;
}
@ -1210,6 +1209,8 @@ public:
PolyParam* d_pp=CurrentPP;
if (CurrentPP == NULL || CurrentPP->count != 0)
{
if (CurrentPPlist == nullptr) // wldkickspw
return;
d_pp=CurrentPPlist->Append();
CurrentPP=d_pp;
}

View File

@ -459,11 +459,9 @@ void BaseTextureCacheData::Create()
}
//Planar textures support stride selection, mostly used for non power of 2 textures (videos)
int stride = 0;
int stride = w;
if (tcw.StrideSel)
stride = (TEXT_CONTROL & 31) * 32;
if (stride == 0)
stride = w;
//Call the format specific conversion code
texconv = tex->PL;
@ -551,7 +549,7 @@ void BaseTextureCacheData::Update()
u32 original_h = h;
if (sa_tex > VRAM_SIZE || size == 0 || sa + size > VRAM_SIZE)
{
if (sa + size > VRAM_SIZE)
if (sa < VRAM_SIZE && sa + size > VRAM_SIZE && tcw.ScanOrder && stride > 0)
{
// Shenmue Space Harrier mini-arcade loads a texture that goes beyond the end of VRAM
// but only uses the top portion of it
@ -578,7 +576,7 @@ void BaseTextureCacheData::Update()
// Figure out if we really need to use a 32-bit pixel buffer
bool textureUpscaling = settings.rend.TextureUpscale > 1
// Don't process textures that are too big
&& w * h <= settings.rend.MaxFilteredTextureSize * settings.rend.MaxFilteredTextureSize
&& (int)(w * h) <= settings.rend.MaxFilteredTextureSize * settings.rend.MaxFilteredTextureSize
// Don't process YUV textures
&& tcw.PixelFmt != PixelYUV;
bool need_32bit_buffer = true;

View File

@ -211,20 +211,24 @@ void GenSorted(int first, int count, std::vector<SortTrigDrawParam>& pidx_sort,
if (pvrrc.verts.used() == 0 || count == 0)
return;
const Vertex *vtx_base = pvrrc.verts.head();
const u32 *idx_base = pvrrc.idx.head();
const Vertex * const vtx_base = pvrrc.verts.head();
const u32 * const idx_base = pvrrc.idx.head();
const PolyParam *pp_base = &pvrrc.global_param_tr.head()[first];
const PolyParam * const pp_base = &pvrrc.global_param_tr.head()[first];
const PolyParam *pp = pp_base;
const PolyParam *pp_end = pp + count;
const PolyParam * const pp_end = pp + count;
while (pp->count == 0 && pp < pp_end)
pp++;
if (pp == pp_end)
return;
vtx_sort_base=vtx_base;
static u32 vtx_cnt;
int vtx_count = pvrrc.verts.used() - idx_base[pp->first];
if (vtx_count>vtx_cnt)
vtx_cnt=vtx_count;
if ((u32)vtx_count > vtx_cnt)
vtx_cnt = vtx_count;
#if PRINT_SORT_STATS
printf("TVTX: %d || %d\n",vtx_cnt,vtx_count);

View File

@ -566,7 +566,7 @@ void VulkanContext::CreateSwapChain()
(surfaceCapabilities.supportedCompositeAlpha & vk::CompositeAlphaFlagBitsKHR::ePreMultiplied) ? vk::CompositeAlphaFlagBitsKHR::ePreMultiplied :
(surfaceCapabilities.supportedCompositeAlpha & vk::CompositeAlphaFlagBitsKHR::ePostMultiplied) ? vk::CompositeAlphaFlagBitsKHR::ePostMultiplied :
(surfaceCapabilities.supportedCompositeAlpha & vk::CompositeAlphaFlagBitsKHR::eInherit) ? vk::CompositeAlphaFlagBitsKHR::eInherit : vk::CompositeAlphaFlagBitsKHR::eOpaque;
u32 imageCount = std::max(2u, surfaceCapabilities.minImageCount);
u32 imageCount = std::max(3u, surfaceCapabilities.minImageCount);
if (surfaceCapabilities.maxImageCount != 0)
imageCount = std::min(imageCount, surfaceCapabilities.maxImageCount);
vk::ImageUsageFlags usage = vk::ImageUsageFlagBits::eColorAttachment;
@ -821,6 +821,8 @@ void VulkanContext::PresentLastFrame()
void VulkanContext::Term()
{
lastFrameView = nullptr;
if (!device)
return;
device->waitIdle();
ImGui_ImplVulkan_Shutdown();
gui_term();