From ca0fb770800fc87748bdf2a287003c9e27097b5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 6 Apr 2018 23:29:44 +0200 Subject: [PATCH] Assorted cleanups. Don't assert on no clear mask. --- .gitignore | 1 + GPU/GLES/DrawEngineGLES.cpp | 6 ------ GPU/Vulkan/FramebufferVulkan.cpp | 3 --- ext/native/thin3d/GLRenderManager.cpp | 4 +++- ext/native/thin3d/GLRenderManager.h | 13 +++++++------ ext/native/thin3d/VulkanRenderManager.cpp | 2 ++ ext/native/thin3d/thin3d_d3d9.cpp | 4 +++- ext/native/thin3d/thin3d_vulkan.cpp | 3 +-- 8 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.gitignore b/.gitignore index 26321f6cf4..b0bc906ca8 100644 --- a/.gitignore +++ b/.gitignore @@ -38,6 +38,7 @@ PPSSPPDebug.exe.manifest assets/flash0 UWP/icph UWP/.vs +.vs # For Mac .DS_Store diff --git a/GPU/GLES/DrawEngineGLES.cpp b/GPU/GLES/DrawEngineGLES.cpp index b8499b50c8..0acda4bd4d 100644 --- a/GPU/GLES/DrawEngineGLES.cpp +++ b/GPU/GLES/DrawEngineGLES.cpp @@ -587,12 +587,6 @@ rotateVBO: } else if (result.action == SW_CLEAR) { u32 clearColor = result.color; float clearDepth = result.depth; - const float col[4] = { - ((clearColor & 0xFF)) / 255.0f, - ((clearColor & 0xFF00) >> 8) / 255.0f, - ((clearColor & 0xFF0000) >> 16) / 255.0f, - ((clearColor & 0xFF000000) >> 24) / 255.0f, - }; bool colorMask = gstate.isClearModeColorMask(); bool alphaMask = gstate.isClearModeAlphaMask(); diff --git a/GPU/Vulkan/FramebufferVulkan.cpp b/GPU/Vulkan/FramebufferVulkan.cpp index 3c2abde969..98753526fa 100644 --- a/GPU/Vulkan/FramebufferVulkan.cpp +++ b/GPU/Vulkan/FramebufferVulkan.cpp @@ -167,9 +167,6 @@ void FramebufferManagerVulkan::DestroyDeviceObjects() { } void FramebufferManagerVulkan::NotifyClear(bool clearColor, bool clearAlpha, bool clearDepth, uint32_t color, float depth) { - float x, y, w, h; - CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL); - int mask = 0; // The Clear detection takes care of doing a regular draw instead if separate masking // of color and alpha is needed, so we can just treat them as the same. diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index da06102ccd..94b5e7b664 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -327,7 +327,7 @@ bool GLRenderManager::CopyFramebufferToMemorySync(GLRFramebuffer *src, int aspec // TODO: Do this properly. srcFormat = Draw::DataFormat::D24_S8; } else { - _assert_(false); + return false; } queueRunner_.CopyReadbackBuffer(w, h, srcFormat, destFormat, pixelStride, pixels); return true; @@ -638,6 +638,8 @@ void GLPushBuffer::Flush() { bool GLPushBuffer::AddBuffer() { BufInfo info; info.localMemory = (uint8_t *)AllocateAlignedMemory(size_, 16); + if (!info.localMemory) + return false; info.buffer = render_->CreateBuffer(target_, size_, GL_DYNAMIC_DRAW); buf_ = buffers_.size(); buffers_.push_back(info); diff --git a/ext/native/thin3d/GLRenderManager.h b/ext/native/thin3d/GLRenderManager.h index 164cdc4dc4..b54697b432 100644 --- a/ext/native/thin3d/GLRenderManager.h +++ b/ext/native/thin3d/GLRenderManager.h @@ -164,7 +164,7 @@ public: void *Map(GLBufferStrategy strategy); bool Unmap(); - bool Mapped() { + bool Mapped() const { return mapped_; } @@ -768,8 +768,9 @@ public: // If scissorW == 0, no scissor is applied. void Clear(uint32_t clearColor, float clearZ, int clearStencil, int clearMask, int colorMask, int scissorX, int scissorY, int scissorW, int scissorH) { _dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER); + if (!clearMask) + return; GLRRenderData data{ GLRRenderCommand::CLEAR }; - _assert_(clearMask != 0); // What would be the point? data.clear.clearMask = clearMask; data.clear.clearColor = clearColor; data.clear.clearZ = clearZ; @@ -825,15 +826,15 @@ public: } void UnregisterPushBuffer(GLPushBuffer *buffer) { - bool found = false; + int foundCount = 0; for (int i = 0; i < MAX_INFLIGHT_FRAMES; i++) { auto iter = frameData_[i].activePushBuffers.find(buffer); if (iter != frameData_[i].activePushBuffers.end()) { frameData_[i].activePushBuffers.erase(iter); - found = true; + foundCount++; } } - assert(found); + assert(foundCount == 1); } void SetSwapFunction(std::function swapFunction) { @@ -920,7 +921,7 @@ private: GLQueueRunner queueRunner_; // Thread state - int threadFrame_; + int threadFrame_ = -1; bool nextFrame = false; bool firstFrame = true; diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index 3c325bf288..373b911161 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -614,6 +614,8 @@ bool VulkanRenderManager::InitDepthStencilBuffer(VkCommandBuffer cmd) { void VulkanRenderManager::Clear(uint32_t clearColor, float clearZ, int clearStencil, int clearMask) { _dbg_assert_(G3D, curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); + if (!clearMask) + return; // If this is the first drawing command, merge it into the pass. if (curRenderStep_->render.numDraws == 0) { curRenderStep_->render.clearColor = clearColor; diff --git a/ext/native/thin3d/thin3d_d3d9.cpp b/ext/native/thin3d/thin3d_d3d9.cpp index 62321d36c7..8f8396798b 100644 --- a/ext/native/thin3d/thin3d_d3d9.cpp +++ b/ext/native/thin3d/thin3d_d3d9.cpp @@ -937,7 +937,9 @@ void D3D9Context::Clear(int mask, uint32_t colorval, float depthVal, int stencil if (mask & FBChannel::FB_COLOR_BIT) d3dMask |= D3DCLEAR_TARGET; if (mask & FBChannel::FB_DEPTH_BIT) d3dMask |= D3DCLEAR_ZBUFFER; if (mask & FBChannel::FB_STENCIL_BIT) d3dMask |= D3DCLEAR_STENCIL; - device_->Clear(0, NULL, d3dMask, (D3DCOLOR)SwapRB(colorval), depthVal, stencilVal); + if (d3dMask) { + device_->Clear(0, NULL, d3dMask, (D3DCOLOR)SwapRB(colorval), depthVal, stencilVal); + } } void D3D9Context::SetScissorRect(int left, int top, int width, int height) { diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index 19e6161844..4fc6823eac 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "Common/Vulkan/SPIRVDisasm.h" #include "Core/Config.h" @@ -1189,7 +1189,6 @@ void VKContext::Clear(int clearMask, uint32_t colorval, float depthVal, int sten mask |= VK_IMAGE_ASPECT_DEPTH_BIT; if (clearMask & FBChannel::FB_STENCIL_BIT) mask |= VK_IMAGE_ASPECT_STENCIL_BIT; - renderManager_.Clear(colorval, depthVal, stencilVal, mask); }