diff --git a/Common/Common.h b/Common/Common.h index 9894771c53..471bef4bdf 100644 --- a/Common/Common.h +++ b/Common/Common.h @@ -26,13 +26,6 @@ #pragma warning (disable:4100) #endif -// Force enable logging in the right modes. For some reason, something had changed -// so that debugfast no longer logged. -#if defined(_DEBUG) || defined(DEBUGFAST) -#undef LOGGING -#define LOGGING 1 -#endif - #include "Log.h" #include "CommonTypes.h" #include "CommonFuncs.h" diff --git a/Common/Log.h b/Common/Log.h index 8dc232319c..3bd39e5c10 100644 --- a/Common/Log.h +++ b/Common/Log.h @@ -17,16 +17,11 @@ #pragma once -#include #include #include "CommonFuncs.h" #include "Common/MsgHandler.h" -#if defined(__ANDROID__) -#include -#endif - #define NOTICE_LEVEL 1 // VERY important information that is NOT errors. Like startup and debugprintfs from the game itself. #define ERROR_LEVEL 2 // Important errors. #define WARNING_LEVEL 3 // Something is suspicious. @@ -34,7 +29,6 @@ #define DEBUG_LEVEL 5 // Detailed debugging - might make things slow. #define VERBOSE_LEVEL 6 // Noisy debugging - sometimes needed but usually unimportant. - namespace LogTypes { enum LOG_TYPE { @@ -92,15 +86,20 @@ void GenericLog(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type, ; bool GenericLogEnabled(LogTypes::LOG_LEVELS level, LogTypes::LOG_TYPE type); -#if defined(LOGGING) || defined(_DEBUG) || defined(DEBUGFAST) || defined(_WIN32) +#if defined(_DEBUG) || defined(_WIN32) + #define MAX_LOGLEVEL DEBUG_LEVEL + #else + #ifndef MAX_LOGLEVEL #define MAX_LOGLEVEL INFO_LEVEL #endif // loglevel + #endif // logging -// Let the compiler optimize this out +// Let the compiler optimize this out. +// TODO: Compute a dynamic max level as well that can be checked here. #define GENERIC_LOG(t, v, ...) { \ if (v <= MAX_LOGLEVEL) \ GenericLog(v, t, __FILE__, __LINE__, __VA_ARGS__); \ @@ -121,7 +120,9 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * #endif +// If we're in "debug" assert mode #if MAX_LOGLEVEL >= DEBUG_LEVEL + #define _dbg_assert_(_a_) \ if (!(_a_)) {\ printf(#_a_ "\n\nError...\n\n Line: %d\n File: %s\n\n", \ @@ -151,15 +152,13 @@ void AndroidAssertLog(const char *func, const char *file, int line, const char * #endif // __ANDROID__ -#define _dbg_update_() ; //Host_UpdateLogDisplay(); - #else // not debug -#define _dbg_update_() ; #ifndef _dbg_assert_ #define _dbg_assert_(_a_) {} #define _dbg_assert_msg_(_a_, _desc_, ...) {} #endif // dbg_assert + #endif // MAX_LOGLEVEL DEBUG #if defined(__ANDROID__) diff --git a/Common/Vulkan/VulkanContext.h b/Common/Vulkan/VulkanContext.h index b1c998b8b5..17509f6c72 100644 --- a/Common/Vulkan/VulkanContext.h +++ b/Common/Vulkan/VulkanContext.h @@ -1,6 +1,5 @@ #pragma once -#include #include #include #include diff --git a/Common/Vulkan/VulkanDebug.cpp b/Common/Vulkan/VulkanDebug.cpp index 687070640f..47a82b63a7 100644 --- a/Common/Vulkan/VulkanDebug.cpp +++ b/Common/Vulkan/VulkanDebug.cpp @@ -16,7 +16,6 @@ // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. #include -#include #include #include "Common/Log.h" diff --git a/Common/Vulkan/VulkanImage.cpp b/Common/Vulkan/VulkanImage.cpp index 82d07cd264..1b856dcff2 100644 --- a/Common/Vulkan/VulkanImage.cpp +++ b/Common/Vulkan/VulkanImage.cpp @@ -243,7 +243,7 @@ VkImageView VulkanTexture::CreateViewForMip(int mip) { view_info.subresourceRange.layerCount = 1; VkImageView view; VkResult res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &view); - assert(res == VK_SUCCESS); + _assert_(res == VK_SUCCESS); return view; } diff --git a/Common/Vulkan/VulkanMemory.h b/Common/Vulkan/VulkanMemory.h index 5c4cec8b1e..d2f41e2d12 100644 --- a/Common/Vulkan/VulkanMemory.h +++ b/Common/Vulkan/VulkanMemory.h @@ -2,6 +2,8 @@ #include #include + +#include "Common/Log.h" #include "Common/Vulkan/VulkanContext.h" // VulkanMemory @@ -73,14 +75,14 @@ public: // Returns the offset that should be used when binding this buffer to get this data. size_t Push(const void *data, size_t size, VkBuffer *vkbuf) { - assert(writePtr_); + _dbg_assert_(writePtr_); size_t off = Allocate(size, vkbuf); memcpy(writePtr_ + off, data, size); return off; } uint32_t PushAligned(const void *data, size_t size, int align, VkBuffer *vkbuf) { - assert(writePtr_); + _dbg_assert_(writePtr_); offset_ = (offset_ + align - 1) & ~(align - 1); size_t off = Allocate(size, vkbuf); memcpy(writePtr_ + off, data, size); @@ -94,13 +96,13 @@ public: // "Zero-copy" variant - you can write the data directly as you compute it. // Recommended. void *Push(size_t size, uint32_t *bindOffset, VkBuffer *vkbuf) { - assert(writePtr_); + _dbg_assert_(writePtr_); size_t off = Allocate(size, vkbuf); *bindOffset = (uint32_t)off; return writePtr_ + off; } void *PushAligned(size_t size, uint32_t *bindOffset, VkBuffer *vkbuf, int align) { - assert(writePtr_); + _dbg_assert_(writePtr_); offset_ = (offset_ + align - 1) & ~(align - 1); size_t off = Allocate(size, vkbuf); *bindOffset = (uint32_t)off; diff --git a/Core/CwCheat.cpp b/Core/CwCheat.cpp index 131c739ce1..7ed008f886 100644 --- a/Core/CwCheat.cpp +++ b/Core/CwCheat.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include "i18n/i18n.h" @@ -777,7 +776,7 @@ CheatOperation CWCheatEngine::InterpretNextCwCheat(const CheatCode &cheat, size_ CheatOperation CWCheatEngine::InterpretNextTempAR(const CheatCode &cheat, size_t &i) { // TODO - assert(false); + _assert_(false); return { CheatOp::Invalid }; } @@ -787,7 +786,7 @@ CheatOperation CWCheatEngine::InterpretNextOp(const CheatCode &cheat, size_t &i) else if (cheat.fmt == CheatCodeFormat::TEMPAR) return InterpretNextTempAR(cheat, i); else - assert(false); + _assert_(false); return { CheatOp::Invalid }; } @@ -1178,7 +1177,7 @@ void CWCheatEngine::ExecuteOp(const CheatOperation &op, const CheatCode &cheat, break; default: - assert(false); + _assert_(false); } } diff --git a/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp b/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp index ec9a226508..7e6d03966e 100644 --- a/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp +++ b/Core/Debugger/WebSocket/GPUBufferSubscriber.cpp @@ -113,7 +113,7 @@ static bool StreamBufferToDataURI(DebuggerRequest &req, const GPUDebugBuffer &bu req.ws->AddFragment(false, Base64Encode(ctx->buf, ctx->bufSize)); ctx->bufSize = 0; } - assert(ctx->bufSize == 0 || length == 0); + _assert_(ctx->bufSize == 0 || length == 0); // Save bytes that would result in padding for next time. size_t toBuffer = length % 3; @@ -241,7 +241,7 @@ static void GenericStreamBuffer(DebuggerRequest &req, std::function #include #include "json/json_reader.h" diff --git a/Core/HLE/sceIo.cpp b/Core/HLE/sceIo.cpp index 16206298f2..9316bae16f 100644 --- a/Core/HLE/sceIo.cpp +++ b/Core/HLE/sceIo.cpp @@ -1483,7 +1483,7 @@ static u32 sceIoOpen(const char *filename, int flags, int mode) { int error; FileNode *f = __IoOpen(error, filename, flags, mode); if (!f) { - assert(error != 0); + _assert_(error != 0); if (error == (int)SCE_KERNEL_ERROR_NOCWD) { // TODO: Timing is not accurate. return hleLogError(SCEIO, hleDelayResult(error, "file opened", 10000), "no current working directory"); @@ -2063,7 +2063,7 @@ static u32 sceIoOpenAsync(const char *filename, int flags, int mode) { // We have to return an fd here, which may have been destroyed when we reach Wait if it failed. if (f == nullptr) { - assert(error != 0); + _assert_(error != 0); if (error == SCE_KERNEL_ERROR_NODEV) return hleLogError(SCEIO, error, "device not found"); diff --git a/Core/HLE/sceKernelThread.cpp b/Core/HLE/sceKernelThread.cpp index c11bf8b2ad..e995528d02 100644 --- a/Core/HLE/sceKernelThread.cpp +++ b/Core/HLE/sceKernelThread.cpp @@ -1529,7 +1529,7 @@ void __KernelWaitCurThread(WaitType type, SceUID waitID, u32 waitValue, u32 time } PSPThread *thread = __GetCurrentThread(); - assert(thread != nullptr); + _assert_(thread != nullptr); thread->nt.waitID = waitID; thread->nt.waitType = type; __KernelChangeThreadState(thread, ThreadStatus(THREADSTATUS_WAIT | (thread->nt.status & THREADSTATUS_SUSPEND))); diff --git a/Core/Util/PPGeDraw.cpp b/Core/Util/PPGeDraw.cpp index 356bd4ef90..05484bd8af 100644 --- a/Core/Util/PPGeDraw.cpp +++ b/Core/Util/PPGeDraw.cpp @@ -142,7 +142,7 @@ void PPGeSetTexture(u32 dataAddr, int width, int height); static void WriteCmd(u8 cmd, u32 data) { Memory::Write_U32((cmd << 24) | (data & 0xFFFFFF), dlWritePtr); dlWritePtr += 4; - assert(dlWritePtr <= dlPtr + dlSize); + _dbg_assert_(dlWritePtr <= dlPtr + dlSize); } static void WriteCmdAddrWithBase(u8 cmd, u32 addr) { @@ -181,7 +181,7 @@ static void Vertex(float x, float y, float u, float v, int tw, int th, u32 color Memory::WriteStruct(dataWritePtr, &vtx); dataWritePtr += sizeof(vtx); } - assert(dataWritePtr <= dataPtr + dataSize); + _dbg_assert_(dataWritePtr <= dataPtr + dataSize); vertexCount++; } @@ -420,8 +420,8 @@ void PPGeEnd() } void PPGeScissor(int x1, int y1, int x2, int y2) { - assert(x1 >= 0 && x1 <= 480 && x2 >= 0 && x2 <= 480); - assert(y1 >= 0 && y1 <= 272 && y2 >= 0 && y2 <= 272); + _dbg_assert_(x1 >= 0 && x1 <= 480 && x2 >= 0 && x2 <= 480); + _dbg_assert_(y1 >= 0 && y1 <= 272 && y2 >= 0 && y2 <= 272); WriteCmd(GE_CMD_SCISSOR1, (y1 << 10) | x1); WriteCmd(GE_CMD_SCISSOR2, ((y2 - 1) << 10) | (x2 - 1)); } diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 864cf678e6..be46d3d620 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include "ext/native/thin3d/thin3d.h" @@ -1025,8 +1024,8 @@ void FramebufferManagerCommon::DecimateFBOs() { } void FramebufferManagerCommon::ResizeFramebufFBO(VirtualFramebuffer *vfb, int w, int h, bool force, bool skipCopy) { - assert(w > 0); - assert(h > 0); + _dbg_assert_(w > 0); + _dbg_assert_(h > 0); VirtualFramebuffer old = *vfb; int oldWidth = vfb->bufferWidth; diff --git a/GPU/Common/PresentationCommon.cpp b/GPU/Common/PresentationCommon.cpp index a1fd204c6a..f78bc00d68 100644 --- a/GPU/Common/PresentationCommon.cpp +++ b/GPU/Common/PresentationCommon.cpp @@ -15,7 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include #include #include #include @@ -407,7 +406,7 @@ Draw::Pipeline *PresentationCommon::CreatePipeline(std::vectorCreateBuffer(sizeof(Vertex) * 8, BufferUsageFlag::DYNAMIC | BufferUsageFlag::VERTEXDATA); @@ -531,7 +530,7 @@ void PresentationCommon::BindSource(int binding) { } else if (srcFramebuffer_) { draw_->BindFramebufferAsTexture(srcFramebuffer_, binding, Draw::FB_COLOR_BIT, 0); } else { - assert(false); + _assert_(false); } } diff --git a/GPU/Common/TextureScalerCommon.cpp b/GPU/Common/TextureScalerCommon.cpp index 4b9bf8f307..63b972403e 100644 --- a/GPU/Common/TextureScalerCommon.cpp +++ b/GPU/Common/TextureScalerCommon.cpp @@ -21,7 +21,6 @@ #endif #include -#include #include #include #include diff --git a/GPU/D3D11/TextureCacheD3D11.cpp b/GPU/D3D11/TextureCacheD3D11.cpp index 70fee76b59..538c0d46be 100644 --- a/GPU/D3D11/TextureCacheD3D11.cpp +++ b/GPU/D3D11/TextureCacheD3D11.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include diff --git a/GPU/Directx9/TextureCacheDX9.cpp b/GPU/Directx9/TextureCacheDX9.cpp index fcafb02685..50006f3505 100644 --- a/GPU/Directx9/TextureCacheDX9.cpp +++ b/GPU/Directx9/TextureCacheDX9.cpp @@ -17,7 +17,6 @@ #include #include -#include #include #include "Core/MemMap.h" diff --git a/GPU/Vulkan/DepalettizeShaderVulkan.cpp b/GPU/Vulkan/DepalettizeShaderVulkan.cpp index e1cc53fd09..f0ab47eb1c 100644 --- a/GPU/Vulkan/DepalettizeShaderVulkan.cpp +++ b/GPU/Vulkan/DepalettizeShaderVulkan.cpp @@ -84,7 +84,7 @@ void DepalShaderCacheVulkan::DeviceRestore(Draw::DrawContext *draw, VulkanContex vulkan_ = vulkan; std::string errors; vshader_ = CompileShaderModule(vulkan_, VK_SHADER_STAGE_VERTEX_BIT, depal_vs, &errors); - assert(vshader_ != VK_NULL_HANDLE); + _assert_(vshader_ != VK_NULL_HANDLE); } DepalShaderVulkan *DepalShaderCacheVulkan::GetDepalettizeShader(uint32_t clutMode, GEBufferFormat pixelFormat) { diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index b241affff0..db98dcca5c 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -15,8 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include - #include "math/dataconv.h" #include "profiler/profiler.h" #include "thin3d/VulkanRenderManager.h" @@ -142,7 +140,7 @@ void DrawEngineVulkan::InitDeviceObjects() { dsl.bindingCount = ARRAY_SIZE(bindings); dsl.pBindings = bindings; VkResult res = vkCreateDescriptorSetLayout(device, &dsl, nullptr, &descriptorSetLayout_); - assert(VK_SUCCESS == res); + _dbg_assert_(VK_SUCCESS == res); // We are going to use one-shot descriptors in the initial implementation. Might look into caching them // if creating and updating them turns out to be expensive. @@ -164,7 +162,7 @@ void DrawEngineVulkan::InitDeviceObjects() { pl.pSetLayouts = &descriptorSetLayout_; pl.flags = 0; res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); - assert(VK_SUCCESS == res); + _dbg_assert_(VK_SUCCESS == res); VkSamplerCreateInfo samp{ VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; samp.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; @@ -176,7 +174,7 @@ void DrawEngineVulkan::InitDeviceObjects() { samp.minFilter = VK_FILTER_NEAREST; res = vkCreateSampler(device, &samp, nullptr, &samplerSecondary_); res = vkCreateSampler(device, &samp, nullptr, &nullSampler_); - assert(VK_SUCCESS == res); + _dbg_assert_(VK_SUCCESS == res); vertexCache_ = new VulkanPushBuffer(vulkan_, VERTEX_CACHE_SIZE, VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT); @@ -407,7 +405,7 @@ VkDescriptorSet DrawEngineVulkan::GetOrCreateDescriptorSet(VkImageView imageView if (!frame.descPool || frame.descPoolSize < frame.descCount + 1) { VkResult res = RecreateDescriptorPool(frame, frame.descPoolSize * 2); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); } // Didn't find one in the frame descriptor set cache, let's make a new one. diff --git a/GPU/Vulkan/FramebufferManagerVulkan.cpp b/GPU/Vulkan/FramebufferManagerVulkan.cpp index 5c4d0f0b51..17ad7045d0 100644 --- a/GPU/Vulkan/FramebufferManagerVulkan.cpp +++ b/GPU/Vulkan/FramebufferManagerVulkan.cpp @@ -107,8 +107,8 @@ void FramebufferManagerVulkan::InitDeviceObjects() { std::string fs_errors, vs_errors; fsBasicTex_ = CompileShaderModule(vulkan_, VK_SHADER_STAGE_FRAGMENT_BIT, tex_fs, &fs_errors); vsBasicTex_ = CompileShaderModule(vulkan_, VK_SHADER_STAGE_VERTEX_BIT, tex_vs, &vs_errors); - assert(fsBasicTex_ != VK_NULL_HANDLE); - assert(vsBasicTex_ != VK_NULL_HANDLE); + _assert_(fsBasicTex_ != VK_NULL_HANDLE); + _assert_(vsBasicTex_ != VK_NULL_HANDLE); VkSamplerCreateInfo samp = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; samp.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; @@ -117,11 +117,11 @@ void FramebufferManagerVulkan::InitDeviceObjects() { samp.magFilter = VK_FILTER_NEAREST; samp.minFilter = VK_FILTER_NEAREST; VkResult res = vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &nearestSampler_); - assert(res == VK_SUCCESS); + _assert_(res == VK_SUCCESS); samp.magFilter = VK_FILTER_LINEAR; samp.minFilter = VK_FILTER_LINEAR; res = vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &linearSampler_); - assert(res == VK_SUCCESS); + _assert_(res == VK_SUCCESS); } void FramebufferManagerVulkan::DestroyDeviceObjects() { diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 93488cfc55..97b1f82ecc 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -474,7 +474,7 @@ void GPU_Vulkan::InitDeviceObjects() { INFO_LOG(G3D, "GPU_Vulkan::InitDeviceObjects"); // Initialize framedata for (int i = 0; i < VulkanContext::MAX_INFLIGHT_FRAMES; i++) { - assert(!frameData_[i].push_); + _assert_(!frameData_[i].push_); VkBufferUsageFlags usage = VK_BUFFER_USAGE_INDEX_BUFFER_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT | VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; frameData_[i].push_ = new VulkanPushBuffer(vulkan_, 64 * 1024, usage); } diff --git a/GPU/Vulkan/PipelineManagerVulkan.cpp b/GPU/Vulkan/PipelineManagerVulkan.cpp index 9986f1a523..520ea6305b 100644 --- a/GPU/Vulkan/PipelineManagerVulkan.cpp +++ b/GPU/Vulkan/PipelineManagerVulkan.cpp @@ -77,8 +77,8 @@ static const DeclTypeInfo VComp[] = { }; static void VertexAttribSetup(VkVertexInputAttributeDescription *attr, int fmt, int offset, PspAttributeLocation location) { - assert(fmt != DEC_NONE); - assert(fmt < ARRAY_SIZE(VComp)); + _assert_(fmt != DEC_NONE); + _assert_(fmt < ARRAY_SIZE(VComp)); attr->location = (uint32_t)location; attr->binding = 0; attr->format = VComp[fmt].type; @@ -332,7 +332,7 @@ VulkanPipeline *PipelineManagerVulkan::GetOrCreatePipeline(VkPipelineLayout layo if (!pipelineCache_) { VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } VulkanPipelineKey key{}; diff --git a/GPU/Vulkan/TextureCacheVulkan.cpp b/GPU/Vulkan/TextureCacheVulkan.cpp index 202c8a839c..d0fc324a25 100644 --- a/GPU/Vulkan/TextureCacheVulkan.cpp +++ b/GPU/Vulkan/TextureCacheVulkan.cpp @@ -254,7 +254,7 @@ VkSampler SamplerCache::GetOrCreateSampler(const SamplerCacheKey &key) { samp.mipLodBias = (float)(int32_t)key.lodBias * (1.0f / 256.0f); VkResult res = vkCreateSampler(vulkan_->GetDevice(), &samp, nullptr, &sampler); - assert(res == VK_SUCCESS); + _assert_(res == VK_SUCCESS); cache_.Insert(key, sampler); return sampler; } @@ -351,7 +351,7 @@ void TextureCacheVulkan::DeviceRestore(VulkanContext *vulkan, Draw::DrawContext vulkan_ = vulkan; draw_ = draw; - assert(!allocator_); + _assert_(!allocator_); allocator_ = new VulkanDeviceAllocator(vulkan_, TEXCACHE_MIN_SLAB_SIZE, TEXCACHE_MAX_SLAB_SIZE); samplerCache_.DeviceRestore(vulkan); @@ -1124,7 +1124,7 @@ void TextureCacheVulkan::LoadTextureLevel(TexCacheEntry &entry, uint8_t *writePt dstFmt = (VkFormat)fmt; // We always end up at 8888. Other parts assume this. - assert(dstFmt == VULKAN_8888_FORMAT); + _assert_(dstFmt == VULKAN_8888_FORMAT); bpp = sizeof(u32); decPitch = w * bpp; diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 0e653be2b1..9a617645d1 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -65,7 +65,7 @@ void Vulkan2D::DestroyDeviceObjects() { void Vulkan2D::InitDeviceObjects() { VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkDescriptorSetLayoutBinding bindings[2] = {}; // Texture. @@ -85,7 +85,7 @@ void Vulkan2D::InitDeviceObjects() { dsl.bindingCount = 2; dsl.pBindings = bindings; res = vkCreateDescriptorSetLayout(device, &dsl, nullptr, &descriptorSetLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkDescriptorPoolSize dpTypes[1]; dpTypes[0].descriptorCount = 3000; @@ -98,7 +98,7 @@ void Vulkan2D::InitDeviceObjects() { dp.poolSizeCount = ARRAY_SIZE(dpTypes); for (int i = 0; i < vulkan_->GetInflightFrames(); i++) { VkResult res = vkCreateDescriptorPool(vulkan_->GetDevice(), &dp, nullptr, &frameData_[i].descPool); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } VkPushConstantRange push = {}; @@ -113,7 +113,7 @@ void Vulkan2D::InitDeviceObjects() { pl.pSetLayouts = &descriptorSetLayout_; pl.flags = 0; res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } void Vulkan2D::DeviceLost() { @@ -188,7 +188,7 @@ VkDescriptorSet Vulkan2D::GetDescriptorSet(VkImageView tex1, VkSampler sampler1, descAlloc.descriptorPool = frame->descPool; descAlloc.descriptorSetCount = 1; VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc); - assert(result == VK_SUCCESS); + _assert_(result == VK_SUCCESS); // We just don't write to the slots we don't care about. VkWriteDescriptorSet writes[2]{}; @@ -406,7 +406,7 @@ VulkanComputeShaderManager::~VulkanComputeShaderManager() {} void VulkanComputeShaderManager::InitDeviceObjects() { VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; VkResult res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkDescriptorSetLayoutBinding bindings[3] = {}; bindings[0].descriptorCount = 1; @@ -428,7 +428,7 @@ void VulkanComputeShaderManager::InitDeviceObjects() { dsl.bindingCount = ARRAY_SIZE(bindings); dsl.pBindings = bindings; res = vkCreateDescriptorSetLayout(device, &dsl, nullptr, &descriptorSetLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkDescriptorPoolSize dpTypes[2]; dpTypes[0].descriptorCount = 8192; @@ -443,7 +443,7 @@ void VulkanComputeShaderManager::InitDeviceObjects() { dp.poolSizeCount = ARRAY_SIZE(dpTypes); for (int i = 0; i < ARRAY_SIZE(frameData_); i++) { VkResult res = vkCreateDescriptorPool(vulkan_->GetDevice(), &dp, nullptr, &frameData_[i].descPool); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } VkPushConstantRange push = {}; @@ -458,7 +458,7 @@ void VulkanComputeShaderManager::InitDeviceObjects() { pl.pSetLayouts = &descriptorSetLayout_; pl.flags = 0; res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } void VulkanComputeShaderManager::DestroyDeviceObjects() { @@ -491,7 +491,7 @@ VkDescriptorSet VulkanComputeShaderManager::GetDescriptorSet(VkImageView image, descAlloc.descriptorPool = frameData.descPool; descAlloc.descriptorSetCount = 1; VkResult result = vkAllocateDescriptorSets(vulkan_->GetDevice(), &descAlloc, &desc); - assert(result == VK_SUCCESS); + _assert_(result == VK_SUCCESS); VkWriteDescriptorSet writes[2]{}; int n = 0; diff --git a/SDL/SDLGLGraphicsContext.cpp b/SDL/SDLGLGraphicsContext.cpp index e99c15ed75..b5650590b7 100644 --- a/SDL/SDLGLGraphicsContext.cpp +++ b/SDL/SDLGLGraphicsContext.cpp @@ -412,7 +412,7 @@ int SDLGLGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, std: renderManager_ = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); SetGPUBackend(GPUBackend::OPENGL); bool success = draw_->CreatePresets(); - assert(success); + _assert_(success); renderManager_->SetSwapFunction([&]() { #ifdef USING_EGL if (useEGLSwap) diff --git a/SDL/SDLMain.cpp b/SDL/SDLMain.cpp index 878d2da2ce..119ea7419b 100644 --- a/SDL/SDLMain.cpp +++ b/SDL/SDLMain.cpp @@ -16,7 +16,6 @@ SDLJoystick *joystick = NULL; #include #include -#include #include #include #include diff --git a/SDL/SDLVulkanGraphicsContext.cpp b/SDL/SDLVulkanGraphicsContext.cpp index 06f253c6d5..76361240ce 100644 --- a/SDL/SDLVulkanGraphicsContext.cpp +++ b/SDL/SDLVulkanGraphicsContext.cpp @@ -117,7 +117,7 @@ bool SDLVulkanGraphicsContext::Init(SDL_Window *&window, int x, int y, int mode, draw_ = Draw::T3DCreateVulkanContext(vulkan_, false); SetGPUBackend(GPUBackend::VULKAN); bool success = draw_->CreatePresets(); - assert(success); + _assert_(success); draw_->HandleEvent(Draw::Event::GOT_BACKBUFFER, vulkan_->GetBackbufferWidth(), vulkan_->GetBackbufferHeight()); renderManager_ = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER); diff --git a/UI/DiscordIntegration.cpp b/UI/DiscordIntegration.cpp index b872b21e01..ccc2a16e7a 100644 --- a/UI/DiscordIntegration.cpp +++ b/UI/DiscordIntegration.cpp @@ -1,6 +1,5 @@ #include -#include #include "ppsspp_config.h" #include "Common/Log.h" @@ -50,8 +49,8 @@ bool Discord::IsEnabled() const { } void Discord::Init() { - assert(IsEnabled()); - assert(!initialized_); + _assert_(IsEnabled()); + _assert_(!initialized_); #ifdef ENABLE_DISCORD DiscordEventHandlers eventHandlers{}; diff --git a/UWP/PPSSPP_UWPMain.cpp b/UWP/PPSSPP_UWPMain.cpp index 373f164eaf..0b9d191aa0 100644 --- a/UWP/PPSSPP_UWPMain.cpp +++ b/UWP/PPSSPP_UWPMain.cpp @@ -1,7 +1,6 @@ #include "pch.h" #include "PPSSPP_UWPMain.h" -#include #include #include "base/basictypes.h" @@ -324,7 +323,7 @@ UWPGraphicsContext::UWPGraphicsContext(std::shared_ptr reso draw_ = Draw::T3DCreateD3D11Context( resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetD3DDevice(), resources->GetD3DDeviceContext(), resources->GetDeviceFeatureLevel(), 0, adapterNames); bool success = draw_->CreatePresets(); - assert(success); + _assert_(success); } void UWPGraphicsContext::Shutdown() { diff --git a/Windows/Debugger/Debugger_Disasm.cpp b/Windows/Debugger/Debugger_Disasm.cpp index 112f854ab1..d519dffa7c 100644 --- a/Windows/Debugger/Debugger_Disasm.cpp +++ b/Windows/Debugger/Debugger_Disasm.cpp @@ -238,7 +238,6 @@ void CDisasm::stepInto() Sleep(1); } - _dbg_update_(); ptr->gotoPC(); UpdateDialog(); vfpudlg->Update(); @@ -292,7 +291,6 @@ void CDisasm::stepOver() SetDebugMode(false, true); CBreakPoints::AddBreakPoint(breakpointAddress,true); - _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoAddr(breakpointAddress); @@ -331,7 +329,6 @@ void CDisasm::stepOut() SetDebugMode(false, true); CBreakPoints::AddBreakPoint(breakpointAddress,true); - _dbg_update_(); Core_EnableStepping(false); Sleep(1); ptr->gotoAddr(breakpointAddress); @@ -351,7 +348,6 @@ void CDisasm::runToLine() ptr->setDontRedraw(true); SetDebugMode(false, true); CBreakPoints::AddBreakPoint(pos,true); - _dbg_update_(); Core_EnableStepping(false); } @@ -533,7 +529,6 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) ptr->setDontRedraw(false); SetDebugMode(true, true); Core_EnableStepping(true); - _dbg_update_(); Sleep(1); //let cpu catch up ptr->gotoPC(); UpdateDialog(); @@ -573,7 +568,6 @@ BOOL CDisasm::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) hleDebugBreak(); SetDebugMode(false, true); - _dbg_update_(); Core_EnableStepping(false); } break; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 2e314b0f14..32af670d4a 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -230,7 +230,6 @@ void MainThreadFunc() { } INFO_LOG(BOOT, "Done."); - _dbg_update_(); if (coreState == CORE_POWERDOWN) { INFO_LOG(BOOT, "Exit before core loop."); diff --git a/Windows/GPU/D3D11Context.cpp b/Windows/GPU/D3D11Context.cpp index 19fdd64dd1..7ed3969444 100644 --- a/Windows/GPU/D3D11Context.cpp +++ b/Windows/GPU/D3D11Context.cpp @@ -3,7 +3,6 @@ #include "Common/CommonWindows.h" #include #include -#include #include "Common/Log.h" #include "base/display.h" diff --git a/Windows/GPU/WindowsGLContext.cpp b/Windows/GPU/WindowsGLContext.cpp index 9646cf25e9..dc9037a783 100644 --- a/Windows/GPU/WindowsGLContext.cpp +++ b/Windows/GPU/WindowsGLContext.cpp @@ -15,7 +15,6 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. -#include #include "Common/Log.h" #include "Common/CommonWindows.h" #include "gfx/gl_common.h" diff --git a/Windows/GPU/WindowsVulkanContext.cpp b/Windows/GPU/WindowsVulkanContext.cpp index c74fa27024..7b10b5e7c8 100644 --- a/Windows/GPU/WindowsVulkanContext.cpp +++ b/Windows/GPU/WindowsVulkanContext.cpp @@ -46,7 +46,6 @@ // and use the same render pass configuration (clear to black). However, we can later change this so we switch // to a non-clearing render pass in buffered mode, which might be a tiny bit faster. -#include #include #include diff --git a/Windows/WASAPIStream.cpp b/Windows/WASAPIStream.cpp index 9662bf2891..17be143334 100644 --- a/Windows/WASAPIStream.cpp +++ b/Windows/WASAPIStream.cpp @@ -1,4 +1,5 @@ #include "stdafx.h" + #include "WindowsAudio.h" #include "WASAPIStream.h" #include "Common/Log.h" @@ -234,12 +235,12 @@ WASAPIAudioThread::~WASAPIAudioThread() { } bool WASAPIAudioThread::ActivateDefaultDevice() { - assert(device_ == nullptr); + _assert_(device_ == nullptr); HRESULT hresult = deviceEnumerator_->GetDefaultAudioEndpoint(eRender, eMultimedia, &device_); if (FAILED(hresult) || device_ == nullptr) return false; - assert(audioInterface_ == nullptr); + _assert_(audioInterface_ == nullptr); hresult = device_->Activate(IID_IAudioClient, CLSCTX_ALL, nullptr, (void **)&audioInterface_); if (FAILED(hresult) || audioInterface_ == nullptr) return false; @@ -249,7 +250,7 @@ bool WASAPIAudioThread::ActivateDefaultDevice() { bool WASAPIAudioThread::InitAudioDevice() { REFERENCE_TIME hnsBufferDuration = REFTIMES_PER_SEC; - assert(deviceFormat_ == nullptr); + _assert_(deviceFormat_ == nullptr); HRESULT hresult = audioInterface_->GetMixFormat((WAVEFORMATEX **)&deviceFormat_); if (FAILED(hresult) || !deviceFormat_) return false; @@ -262,7 +263,7 @@ bool WASAPIAudioThread::InitAudioDevice() { hresult = audioInterface_->Initialize(AUDCLNT_SHAREMODE_SHARED, 0, hnsBufferDuration, 0, &deviceFormat_->Format, nullptr); if (FAILED(hresult)) return false; - assert(renderClient_ == nullptr); + _assert_(renderClient_ == nullptr); hresult = audioInterface_->GetService(IID_IAudioRenderClient, (void **)&renderClient_); if (FAILED(hresult) || !renderClient_) return false; @@ -389,7 +390,7 @@ bool WASAPIAudioThread::PrepareFormat() { void WASAPIAudioThread::Run() { // Adapted from http://msdn.microsoft.com/en-us/library/windows/desktop/dd316756(v=vs.85).aspx - assert(deviceEnumerator_ == nullptr); + _assert_(deviceEnumerator_ == nullptr); HRESULT hresult = CoCreateInstance(CLSID_MMDeviceEnumerator, nullptr, /* Object is not created as the part of the aggregate */ CLSCTX_ALL, IID_IMMDeviceEnumerator, (void **)&deviceEnumerator_); diff --git a/android/jni/AndroidEGLContext.cpp b/android/jni/AndroidEGLContext.cpp index 97b4ecd55a..c84a79db01 100644 --- a/android/jni/AndroidEGLContext.cpp +++ b/android/jni/AndroidEGLContext.cpp @@ -1,5 +1,3 @@ -#include - #include "base/NativeApp.h" #include "gfx_es2/gpu_features.h" #include "thin3d/thin3d_create.h" diff --git a/android/jni/AndroidJavaGLContext.cpp b/android/jni/AndroidJavaGLContext.cpp index 36a2259f43..ffd5564494 100644 --- a/android/jni/AndroidJavaGLContext.cpp +++ b/android/jni/AndroidJavaGLContext.cpp @@ -1,5 +1,3 @@ -#include - #include "AndroidJavaGLContext.h" #include "base/display.h" #include "base/NativeApp.h" diff --git a/android/jni/AndroidJavaGLContext.h b/android/jni/AndroidJavaGLContext.h index 05d3966896..9e4b07dd1b 100644 --- a/android/jni/AndroidJavaGLContext.h +++ b/android/jni/AndroidJavaGLContext.h @@ -29,6 +29,7 @@ public: void SwapBuffers() override {} void SwapInterval(int interval) override {} void Resize() override {} + Draw::DrawContext *GetDrawContext() override { return draw_; } diff --git a/android/jni/AndroidVulkanContext.cpp b/android/jni/AndroidVulkanContext.cpp index b61ad99b84..c3d490e3b1 100644 --- a/android/jni/AndroidVulkanContext.cpp +++ b/android/jni/AndroidVulkanContext.cpp @@ -1,5 +1,3 @@ -#include - #include "AndroidVulkanContext.h" #include "base/NativeApp.h" #include "base/display.h" diff --git a/ext/native/gfx_es2/draw_text_android.cpp b/ext/native/gfx_es2/draw_text_android.cpp index 91298f6de4..34e4295bd3 100644 --- a/ext/native/gfx_es2/draw_text_android.cpp +++ b/ext/native/gfx_es2/draw_text_android.cpp @@ -192,7 +192,7 @@ void TextDrawerAndroid::DrawStringBitmap(std::vector &bitmapData, TextS entry.lastUsedFrame = frameCount_; jint *jimage = env->GetIntArrayElements(imageData, nullptr); - assert(env->GetArrayLength(imageData) == imageWidth * imageHeight); + _assert_(env->GetArrayLength(imageData) == imageWidth * imageHeight); if (texFormat == Draw::DataFormat::B4G4R4A4_UNORM_PACK16 || texFormat == Draw::DataFormat::R4G4B4A4_UNORM_PACK16) { bitmapData.resize(entry.bmWidth * entry.bmHeight * sizeof(uint16_t)); uint16_t *bitmapData16 = (uint16_t *)&bitmapData[0]; @@ -213,8 +213,7 @@ void TextDrawerAndroid::DrawStringBitmap(std::vector &bitmapData, TextS } } } else { - ERROR_LOG(G3D, "Bad TextDrawer format"); - assert(false); + _assert_msg_(false, "Bad TextDrawer format"); } env->ReleaseIntArrayElements(imageData, jimage, 0); env->DeleteLocalRef(imageData); diff --git a/ext/native/net/websocket_server.cpp b/ext/native/net/websocket_server.cpp index dc9b361884..c45b266222 100644 --- a/ext/native/net/websocket_server.cpp +++ b/ext/native/net/websocket_server.cpp @@ -1,5 +1,4 @@ #include -#include #include #include #include @@ -15,13 +14,15 @@ #include #include #endif + #include "base/stringutil.h" #include "data/base64.h" #include "net/http_server.h" #include "net/sinks.h" #include "net/websocket_server.h" -// TODO: Not a great cross dependency. + #include "Common/Crypto/sha1.h" +#include "Common/Log.h" static const char *const WEBSOCKET_GUID = "258EAFA5-E914-47DA-95CA-C5AB0DC85B11"; @@ -125,28 +126,28 @@ WebSocketServer *WebSocketServer::CreateAsUpgrade(const http::Request &request, } void WebSocketServer::Send(const std::string &str) { - assert(open_); - assert(fragmentOpcode_ == -1); + _assert_(open_); + _assert_(fragmentOpcode_ == -1); SendHeader(true, (int)Opcode::TEXT, str.size()); SendBytes(str.c_str(), str.size()); } void WebSocketServer::Send(const std::vector &payload) { - assert(open_); - assert(fragmentOpcode_ == -1); + _assert_(open_); + _assert_(fragmentOpcode_ == -1); SendHeader(true, (int)Opcode::BINARY, payload.size()); SendBytes((const char *)&payload[0], payload.size()); } void WebSocketServer::AddFragment(bool finish, const std::string &str) { - assert(open_); + _assert_(open_); if (fragmentOpcode_ == -1) { SendHeader(finish, (int)Opcode::TEXT, str.size()); fragmentOpcode_ = (int)Opcode::TEXT; } else if (fragmentOpcode_ == (int)Opcode::TEXT) { SendHeader(finish, (int)Opcode::CONTINUE, str.size()); } else { - assert(fragmentOpcode_ == (int)Opcode::TEXT || fragmentOpcode_ == -1); + _assert_(fragmentOpcode_ == (int)Opcode::TEXT || fragmentOpcode_ == -1); } SendBytes(str.c_str(), str.size()); if (finish) { @@ -155,14 +156,14 @@ void WebSocketServer::AddFragment(bool finish, const std::string &str) { } void WebSocketServer::AddFragment(bool finish, const std::vector &payload) { - assert(open_); + _assert_(open_); if (fragmentOpcode_ == -1) { SendHeader(finish, (int)Opcode::BINARY, payload.size()); fragmentOpcode_ = (int)Opcode::BINARY; } else if (fragmentOpcode_ == (int)Opcode::BINARY) { SendHeader(finish, (int)Opcode::CONTINUE, payload.size()); } else { - assert(fragmentOpcode_ == (int)Opcode::BINARY || fragmentOpcode_ == -1); + _assert_(fragmentOpcode_ == (int)Opcode::BINARY || fragmentOpcode_ == -1); } SendBytes((const char *)&payload[0], payload.size()); if (finish) { @@ -171,15 +172,15 @@ void WebSocketServer::AddFragment(bool finish, const std::vector &paylo } void WebSocketServer::Ping(const std::vector &payload) { - assert(open_); - assert(payload.size() <= 125); + _assert_(open_); + _assert_(payload.size() <= 125); SendHeader(true, (int)Opcode::PING, payload.size()); SendBytes((const char *)&payload[0], payload.size()); } void WebSocketServer::Pong(const std::vector &payload) { - assert(open_); - assert(payload.size() <= 125); + _assert_(open_); + _assert_(payload.size() <= 125); SendHeader(true, (int)Opcode::PONG, payload.size()); SendBytes((const char *)&payload[0], payload.size()); } @@ -275,7 +276,7 @@ bool WebSocketServer::ReadFrames() { } bool WebSocketServer::ReadFrame() { - assert(pendingLeft_ == 0); + _assert_(pendingLeft_ == 0); // TODO: For now blocking on header trickle, shouldn't be common. auto readExact = [&](void *p, size_t sz) { @@ -408,7 +409,7 @@ bool WebSocketServer::ReadPending() { binary_(pendingBuf_); } } else { - assert(false); + _assert_(false); } // All done, clear it out. @@ -455,14 +456,14 @@ bool WebSocketServer::ReadControlFrame(int opcode, size_t sz) { // Don't read anything more. return false; } else { - assert(false); + _assert_(false); } return true; } void WebSocketServer::SendHeader(bool fin, int opcode, size_t sz) { - assert((opcode & 0x0F) == opcode); + _assert_((opcode & 0x0F) == opcode); uint8_t frameHeader = (fin ? 0x80 : 0x00) | opcode; SendBytes(&frameHeader, 1); @@ -479,7 +480,7 @@ void WebSocketServer::SendHeader(bool fin, int opcode, size_t sz) { SendBytes(frameSize, sizeof(frameSize)); } else { uint64_t sz64 = sz; - assert((sz64 & 0x8000000000000000ULL) == 0); + _assert_((sz64 & 0x8000000000000000ULL) == 0); uint8_t frameSize[] = { 127, (uint8_t)((sz64 >> 56) & 0xFF), diff --git a/ext/native/thin3d/GLQueueRunner.cpp b/ext/native/thin3d/GLQueueRunner.cpp index 49698384bd..9c380ee622 100644 --- a/ext/native/thin3d/GLQueueRunner.cpp +++ b/ext/native/thin3d/GLQueueRunner.cpp @@ -248,7 +248,7 @@ void GLQueueRunner::RunInitSteps(const std::vector &steps, bool ski // Query all the uniforms. for (size_t j = 0; j < program->queries_.size(); j++) { auto &x = program->queries_[j]; - assert(x.name); + _dbg_assert_(x.name); *x.dest = glGetUniformLocation(program->program, x.name); } @@ -984,7 +984,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last } case GLRRenderCommand::UNIFORM4I: { - assert(curProgram); + _dbg_assert_(curProgram); int loc = c.uniform4.loc ? *c.uniform4.loc : -1; if (c.uniform4.name) { loc = curProgram->GetUniformLoc(c.uniform4.name); @@ -1010,7 +1010,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last } case GLRRenderCommand::UNIFORMMATRIX: { - assert(curProgram); + _dbg_assert_(curProgram); int loc = c.uniformMatrix4.loc ? *c.uniformMatrix4.loc : -1; if (c.uniformMatrix4.name) { loc = curProgram->GetUniformLoc(c.uniformMatrix4.name); @@ -1076,7 +1076,7 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last // TODO: Add fast path for glBindVertexBuffer GLRInputLayout *layout = c.bindVertexBuffer.inputLayout; GLuint buf = c.bindVertexBuffer.buffer ? c.bindVertexBuffer.buffer->buffer_ : 0; - assert(!c.bindVertexBuffer.buffer->Mapped()); + _dbg_assert_(!c.bindVertexBuffer.buffer->Mapped()); if (buf != curArrayBuffer) { glBindBuffer(GL_ARRAY_BUFFER, buf); curArrayBuffer = buf; @@ -1105,14 +1105,14 @@ void GLQueueRunner::PerformRenderPass(const GLRStep &step, bool first, bool last Crash(); } else if (c.bind_buffer.target == GL_ELEMENT_ARRAY_BUFFER) { GLuint buf = c.bind_buffer.buffer ? c.bind_buffer.buffer->buffer_ : 0; - assert(!c.bind_buffer.buffer->Mapped()); + _dbg_assert_(!c.bind_buffer.buffer->Mapped()); if (buf != curElemArrayBuffer) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf); curElemArrayBuffer = buf; } } else { GLuint buf = c.bind_buffer.buffer ? c.bind_buffer.buffer->buffer_ : 0; - assert(!c.bind_buffer.buffer->Mapped()); + _dbg_assert_(!c.bind_buffer.buffer->Mapped()); glBindBuffer(c.bind_buffer.target, buf); } CHECK_GL_ERROR_IF_DEBUG(); diff --git a/ext/native/thin3d/GLRenderManager.cpp b/ext/native/thin3d/GLRenderManager.cpp index 19a3ac0053..bc2e9a9a3c 100644 --- a/ext/native/thin3d/GLRenderManager.cpp +++ b/ext/native/thin3d/GLRenderManager.cpp @@ -1,5 +1,3 @@ -#include - #include "GLRenderManager.h" #include "gfx_es2/gpu_features.h" #include "thin3d/thin3d.h" @@ -213,7 +211,7 @@ bool GLRenderManager::ThreadFrame() { // Only increment next time if we're done. nextFrame = frameData.type == GLRRunType::END; - assert(frameData.type == GLRRunType::END || frameData.type == GLRRunType::SYNC); + _assert_(frameData.type == GLRRunType::END || frameData.type == GLRRunType::SYNC); } VLOG("PULL: Running frame %d", threadFrame_); if (firstFrame) { @@ -279,7 +277,7 @@ void GLRenderManager::StopThread() { } void GLRenderManager::BindFramebufferAsRenderTarget(GLRFramebuffer *fb, GLRRenderPassAction color, GLRRenderPassAction depth, GLRRenderPassAction stencil, uint32_t clearColor, float clearDepth, uint8_t clearStencil, const char *tag) { - assert(insideFrame_); + _assert_(insideFrame_); #ifdef _DEBUG curProgram_ = nullptr; #endif @@ -509,7 +507,7 @@ void GLRenderManager::Submit(int frame, bool triggerFence) { VLOG("PULL: Frame %d.readyForFence = true", frame); std::unique_lock lock(frameData.push_mutex); - assert(frameData.readyForSubmit); + _assert_(frameData.readyForSubmit); frameData.readyForFence = true; frameData.readyForSubmit = false; frameData.push_condVar.notify_all(); @@ -577,7 +575,7 @@ void GLRenderManager::Run(int frame) { break; default: - assert(false); + _assert_(false); } VLOG("PULL: Finished running frame %d", frame); @@ -597,7 +595,7 @@ void GLRenderManager::FlushSync() { frameData.steps = std::move(steps_); steps_.clear(); frameData.readyForRun = true; - assert(frameData.readyForFence == false); + _assert_(frameData.readyForFence == false); frameData.type = GLRRunType::SYNC; frameData.pull_condVar.notify_all(); } @@ -666,7 +664,7 @@ GLPushBuffer::~GLPushBuffer() { } void GLPushBuffer::Map() { - assert(!writePtr_); + _assert_(!writePtr_); auto &info = buffers_[buf_]; writePtr_ = info.deviceMemory ? info.deviceMemory : info.localMemory; info.flushOffset = 0; @@ -676,11 +674,11 @@ void GLPushBuffer::Map() { offset_++; info.flushOffset++; } - assert(writePtr_); + _assert_(writePtr_); } void GLPushBuffer::Unmap() { - assert(writePtr_); + _assert_(writePtr_); if (!buffers_[buf_].deviceMemory) { // Here we simply upload the data to the last buffer. // Might be worth trying with size_ instead of offset_, so the driver can replace @@ -700,7 +698,7 @@ void GLPushBuffer::Flush() { if (!buffers_[buf_].deviceMemory && writePtr_) { auto &info = buffers_[buf_]; if (info.flushOffset != 0) { - assert(info.buffer->buffer_); + _assert_(info.buffer->buffer_); glBindBuffer(target_, info.buffer->buffer_); glBufferSubData(target_, 0, info.flushOffset, info.localMemory); } @@ -766,7 +764,7 @@ void GLPushBuffer::NextBuffer(size_t minSize) { } bool res = AddBuffer(); - assert(res); + _assert_(res); if (!res) { // Let's try not to crash at least? buf_ = 0; @@ -857,7 +855,7 @@ void GLPushBuffer::UnmapDevice() { } void *GLRBuffer::Map(GLBufferStrategy strategy) { - assert(buffer_ != 0); + _assert_(buffer_ != 0); GLbitfield access = GL_MAP_WRITE_BIT; if ((strategy & GLBufferStrategy::MASK_FLUSH) != 0) { diff --git a/ext/native/thin3d/VulkanRenderManager.cpp b/ext/native/thin3d/VulkanRenderManager.cpp index 4756b4bd09..1ba685ee70 100644 --- a/ext/native/thin3d/VulkanRenderManager.cpp +++ b/ext/native/thin3d/VulkanRenderManager.cpp @@ -74,7 +74,7 @@ void CreateImage(VulkanContext *vulkan, VkCommandBuffer cmd, VKRImage &img, int ivci.subresourceRange.layerCount = 1; ivci.subresourceRange.levelCount = 1; res = vkCreateImageView(vulkan->GetDevice(), &ivci, nullptr, &img.imageView); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); VkPipelineStageFlags dstStage; VkAccessFlagBits dstAccessMask; @@ -109,9 +109,9 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan VkSemaphoreCreateInfo semaphoreCreateInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; semaphoreCreateInfo.flags = 0; VkResult res = vkCreateSemaphore(vulkan_->GetDevice(), &semaphoreCreateInfo, nullptr, &acquireSemaphore_); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); res = vkCreateSemaphore(vulkan_->GetDevice(), &semaphoreCreateInfo, nullptr, &renderingCompleteSemaphore_); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); inflightFramesAtStart_ = vulkan_->GetInflightFrames(); for (int i = 0; i < inflightFramesAtStart_; i++) { @@ -119,9 +119,9 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan cmd_pool_info.queueFamilyIndex = vulkan_->GetGraphicsQueueFamilyIndex(); cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT | VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; VkResult res = vkCreateCommandPool(vulkan_->GetDevice(), &cmd_pool_info, nullptr, &frameData_[i].cmdPoolInit); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); res = vkCreateCommandPool(vulkan_->GetDevice(), &cmd_pool_info, nullptr, &frameData_[i].cmdPoolMain); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); VkCommandBufferAllocateInfo cmd_alloc = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; cmd_alloc.commandPool = frameData_[i].cmdPoolInit; @@ -129,10 +129,10 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan cmd_alloc.commandBufferCount = 1; res = vkAllocateCommandBuffers(vulkan_->GetDevice(), &cmd_alloc, &frameData_[i].initCmd); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); cmd_alloc.commandPool = frameData_[i].cmdPoolMain; res = vkAllocateCommandBuffers(vulkan_->GetDevice(), &cmd_alloc, &frameData_[i].mainCmd); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); // Creating the frame fence with true so they can be instantly waited on the first frame frameData_[i].fence = vulkan_->CreateFence(true); @@ -156,7 +156,7 @@ VulkanRenderManager::VulkanRenderManager(VulkanContext *vulkan) : vulkan_(vulkan void VulkanRenderManager::CreateBackbuffers() { VkResult res = vkGetSwapchainImagesKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), &swapchainImageCount_, nullptr); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); VkImage *swapchainImages = new VkImage[swapchainImageCount_]; res = vkGetSwapchainImagesKHR(vulkan_->GetDevice(), vulkan_->GetSwapchain(), &swapchainImageCount_, swapchainImages); @@ -193,7 +193,7 @@ void VulkanRenderManager::CreateBackbuffers() { res = vkCreateImageView(vulkan_->GetDevice(), &color_image_view, nullptr, &sc_buffer.view); swapchainImages_.push_back(sc_buffer); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); } delete[] swapchainImages; @@ -289,7 +289,7 @@ void VulkanRenderManager::DestroyBackbuffers() { vulkan_->Delete().QueueDeleteImage(depth_.image); vulkan_->Delete().QueueDeleteDeviceMemory(depth_.mem); for (uint32_t i = 0; i < framebuffers_.size(); i++) { - assert(framebuffers_[i] != VK_NULL_HANDLE); + _dbg_assert_(framebuffers_[i] != VK_NULL_HANDLE); vulkan_->Delete().QueueDeleteFramebuffer(framebuffers_[i]); } framebuffers_.clear(); @@ -347,7 +347,7 @@ void VulkanRenderManager::ThreadFunc() { // Only increment next time if we're done. nextFrame = frameData.type == VKRRunType::END; - assert(frameData.type == VKRRunType::END || frameData.type == VKRRunType::SYNC); + _dbg_assert_(frameData.type == VKRRunType::END || frameData.type == VKRRunType::SYNC); } VLOG("PULL: Running frame %d", threadFrame); if (firstFrame) { @@ -511,7 +511,7 @@ void VulkanRenderManager::BindFramebufferAsRenderTarget(VKRFramebuffer *fb, VKRR // More redundant bind elimination. if (curRenderStep_ && curRenderStep_->commands.size() == 0 && curRenderStep_->render.color != VKRRenderPassAction::CLEAR && curRenderStep_->render.depth != VKRRenderPassAction::CLEAR && curRenderStep_->render.stencil != VKRRenderPassAction::CLEAR) { // Can trivially kill the last empty render step. - assert(steps_.back() == curRenderStep_); + _dbg_assert_(steps_.back() == curRenderStep_); delete steps_.back(); steps_.pop_back(); curRenderStep_ = nullptr; diff --git a/ext/native/thin3d/VulkanRenderManager.h b/ext/native/thin3d/VulkanRenderManager.h index c1607354f4..f5ff60e3ad 100644 --- a/ext/native/thin3d/VulkanRenderManager.h +++ b/ext/native/thin3d/VulkanRenderManager.h @@ -192,7 +192,7 @@ public: void PushConstants(VkPipelineLayout pipelineLayout, VkShaderStageFlags stages, int offset, int size, void *constants) { _dbg_assert_(curRenderStep_ && curRenderStep_->stepType == VKRStepType::RENDER); - assert(size + offset < 40); + _dbg_assert_(size + offset < 40); VkRenderData data{ VKRRenderCommand::PUSH_CONSTANTS }; data.push.pipelineLayout = pipelineLayout; data.push.stages = stages; @@ -214,7 +214,7 @@ public: data.draw.vbuffer = vbuffer; data.draw.voffset = voffset; data.draw.numUboOffsets = numUboOffsets; - assert(numUboOffsets <= ARRAY_SIZE(data.draw.uboOffsets)); + _dbg_assert_(numUboOffsets <= ARRAY_SIZE(data.draw.uboOffsets)); for (int i = 0; i < numUboOffsets; i++) data.draw.uboOffsets[i] = uboOffsets[i]; curRenderStep_->commands.push_back(data); @@ -233,7 +233,7 @@ public: data.drawIndexed.ibuffer = ibuffer; data.drawIndexed.ioffset = ioffset; data.drawIndexed.numUboOffsets = numUboOffsets; - assert(numUboOffsets <= ARRAY_SIZE(data.drawIndexed.uboOffsets)); + _dbg_assert_(numUboOffsets <= ARRAY_SIZE(data.drawIndexed.uboOffsets)); for (int i = 0; i < numUboOffsets; i++) data.drawIndexed.uboOffsets[i] = uboOffsets[i]; data.drawIndexed.indexType = indexType; diff --git a/ext/native/thin3d/thin3d_d3d11.cpp b/ext/native/thin3d/thin3d_d3d11.cpp index 9c371678e0..1f589e3856 100644 --- a/ext/native/thin3d/thin3d_d3d11.cpp +++ b/ext/native/thin3d/thin3d_d3d11.cpp @@ -12,7 +12,6 @@ #include "Common/ColorConv.h" -#include #include #include #include @@ -288,7 +287,7 @@ D3D11DrawContext::D3D11DrawContext(ID3D11Device *device, ID3D11DeviceContext *de packDesc.SampleDesc.Count = 1; packDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; hr = device_->CreateTexture2D(&packDesc, nullptr, &packTexture_); - assert(SUCCEEDED(hr)); + _assert_(SUCCEEDED(hr)); } D3D11DrawContext::~D3D11DrawContext() { @@ -1420,7 +1419,7 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel D3D11Framebuffer *fb = (D3D11Framebuffer *)src; if (fb) { - assert(fb->colorFormat == DXGI_FORMAT_R8G8B8A8_UNORM); + _assert_(fb->colorFormat == DXGI_FORMAT_R8G8B8A8_UNORM); // TODO: Figure out where the badness really comes from. if (bx + bw > fb->width) { @@ -1461,7 +1460,7 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel packDesc.Format = fb->depthStencilFormat; break; default: - assert(false); + _assert_(false); } device_->CreateTexture2D(&packDesc, nullptr, &packTex); } else { @@ -1484,11 +1483,11 @@ bool D3D11DrawContext::CopyFramebufferToMemorySync(Framebuffer *src, int channel case FB_DEPTH_BIT: case FB_STENCIL_BIT: // For depth/stencil buffers, we can't reliably copy subrectangles, so just copy the whole resource. - assert(fb); // Can't copy depth/stencil from backbuffer. Shouldn't happen thanks to checks above. + _assert_(fb); // Can't copy depth/stencil from backbuffer. Shouldn't happen thanks to checks above. context_->CopyResource(packTex, fb->depthStencilTex); break; default: - assert(false); + _assert_(false); break; } diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index f6c4dc18b9..d31620e655 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include "base/display.h" #include "base/stringutil.h" @@ -858,7 +857,7 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) dsl.bindingCount = ARRAY_SIZE(bindings); dsl.pBindings = bindings; VkResult res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &descriptorSetLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; @@ -866,11 +865,11 @@ VKContext::VKContext(VulkanContext *vulkan, bool splitSubmit) pl.setLayoutCount = 1; pl.pSetLayouts = &descriptorSetLayout_; res = vkCreatePipelineLayout(device_, &pl, nullptr, &pipelineLayout_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); VkPipelineCacheCreateInfo pc{ VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; res = vkCreatePipelineCache(vulkan_->GetDevice(), &pc, nullptr, &pipelineCache_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); renderManager_.SetSplitSubmit(splitSubmit); @@ -1580,7 +1579,7 @@ void VKContext::HandleEvent(Event ev, int width, int height, void *param1, void renderManager_.CreateBackbuffers(); break; default: - assert(false); + _assert_(false); break; } } diff --git a/ext/native/thin3d/vulkan_utils.cpp b/ext/native/thin3d/vulkan_utils.cpp index ec46b011a9..80f7086c7f 100644 --- a/ext/native/thin3d/vulkan_utils.cpp +++ b/ext/native/thin3d/vulkan_utils.cpp @@ -65,7 +65,7 @@ void VulkanImage::Create2D(VulkanContext *vulkan, VkFormat format, VkFlags requi VkMemoryRequirements mem_reqs; VkResult err = vkCreateImage(device, &i, nullptr, &image_); - assert(!err); + _assert_(!err); vkGetImageMemoryRequirements(device, image_, &mem_reqs); @@ -75,13 +75,13 @@ void VulkanImage::Create2D(VulkanContext *vulkan, VkFormat format, VkFlags requi mem_alloc_.memoryTypeIndex = 0; bool res = vulkan->MemoryTypeFromProperties(mem_reqs.memoryTypeBits, required_props, &mem_alloc_.memoryTypeIndex); - assert(res); + _assert_(res); err = vkAllocateMemory(device, &mem_alloc_, nullptr, &memory_); - assert(!err); + _assert_(!err); err = vkBindImageMemory(device, image_, memory_, 0); // at offset 0. - assert(!err); + _assert_(!err); } void VulkanImage::SetImageData2D(VkDevice device, const uint8_t *data, int width, int height, int pitch) { @@ -95,7 +95,7 @@ void VulkanImage::SetImageData2D(VkDevice device, const uint8_t *data, int width vkGetImageSubresourceLayout(device, image_, &subres, &layout); VkResult err = vkMapMemory(device, memory_, 0, mem_alloc_.allocationSize, 0, &destData); - assert(!err); + _assert_(!err); uint8_t *writePtr = (uint8_t *)destData + layout.offset; int bpp = 4; // TODO diff --git a/headless/SDLHeadlessHost.cpp b/headless/SDLHeadlessHost.cpp index 75b39e9c78..56e6ddc9d2 100644 --- a/headless/SDLHeadlessHost.cpp +++ b/headless/SDLHeadlessHost.cpp @@ -17,9 +17,8 @@ #ifdef SDL -#include +#include #include -#include #include "headless/SDLHeadlessHost.h" #include "gfx/gl_common.h" @@ -29,6 +28,7 @@ #include "thin3d/thin3d_create.h" #include "thin3d/GLRenderManager.h" +#include "Common/Log.h" #include "Common/FileUtil.h" #include "Common/GraphicsContext.h" #include "Common/TimeUtil.h" @@ -156,7 +156,7 @@ bool GLDummyGraphicsContext::InitFromRenderThread(std::string *errorMessage) { renderManager_->SetInflightFrames(g_Config.iInflightFrames); SetGPUBackend(GPUBackend::OPENGL); bool success = draw_->CreatePresets(); - assert(success); + _assert_(success); renderManager_->SetSwapFunction([&]() { SDL_GL_SwapWindow(screen_); });