Switch to PPSSPP's assert functions (don't use the system's)

This commit is contained in:
Henrik Rydgård 2020-08-16 00:38:55 +02:00
parent c5147c01a0
commit 5d64fc5ff1
49 changed files with 142 additions and 180 deletions

View File

@ -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"

View File

@ -17,16 +17,11 @@
#pragma once
#include <cassert>
#include <cstdio>
#include "CommonFuncs.h"
#include "Common/MsgHandler.h"
#if defined(__ANDROID__)
#include <android/log.h>
#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__)

View File

@ -1,6 +1,5 @@
#pragma once
#include <cassert>
#include <cstring>
#include <string>
#include <vector>

View File

@ -16,7 +16,6 @@
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
#include <string>
#include <cassert>
#include <sstream>
#include "Common/Log.h"

View File

@ -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;
}

View File

@ -2,6 +2,8 @@
#include <vector>
#include <unordered_map>
#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;

View File

@ -1,5 +1,4 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#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);
}
}

View File

@ -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<bool(const G
if (!func(buf)) {
return req.Fail("Could not download output");
}
assert(buf != nullptr);
_assert_(buf != nullptr);
if (type == "base64") {
StreamBufferToBase64(req, *buf);

View File

@ -17,7 +17,6 @@
#pragma once
#include <cassert>
#include <string>
#include "json/json_reader.h"

View File

@ -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");

View File

@ -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)));

View File

@ -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));
}

View File

@ -17,7 +17,6 @@
#include <algorithm>
#include <sstream>
#include <cassert>
#include <cmath>
#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;

View File

@ -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 <cassert>
#include <cmath>
#include <set>
#include <cstdint>
@ -407,7 +406,7 @@ Draw::Pipeline *PresentationCommon::CreatePipeline(std::vector<Draw::ShaderModul
void PresentationCommon::CreateDeviceObjects() {
using namespace Draw;
assert(vdata_ == nullptr);
_assert_(vdata_ == nullptr);
vdata_ = draw_->CreateBuffer(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);
}
}

View File

@ -21,7 +21,6 @@
#endif
#include <algorithm>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cmath>

View File

@ -17,7 +17,6 @@
#include <map>
#include <algorithm>
#include <cassert>
#include <cstring>
#include <d3d11.h>

View File

@ -17,7 +17,6 @@
#include <map>
#include <algorithm>
#include <cassert>
#include <cstring>
#include "Core/MemMap.h"

View File

@ -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) {

View File

@ -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 <cassert>
#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.

View File

@ -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() {

View File

@ -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);
}

View File

@ -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{};

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -16,7 +16,6 @@ SDLJoystick *joystick = NULL;
#include <atomic>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <thread>
#include <locale>

View File

@ -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);

View File

@ -1,6 +1,5 @@
#include <ctime>
#include <cassert>
#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{};

View File

@ -1,7 +1,6 @@
#include "pch.h"
#include "PPSSPP_UWPMain.h"
#include <cassert>
#include <mutex>
#include "base/basictypes.h"
@ -324,7 +323,7 @@ UWPGraphicsContext::UWPGraphicsContext(std::shared_ptr<DX::DeviceResources> 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() {

View File

@ -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;

View File

@ -230,7 +230,6 @@ void MainThreadFunc() {
}
INFO_LOG(BOOT, "Done.");
_dbg_update_();
if (coreState == CORE_POWERDOWN) {
INFO_LOG(BOOT, "Exit before core loop.");

View File

@ -3,7 +3,6 @@
#include "Common/CommonWindows.h"
#include <d3d11.h>
#include <WinError.h>
#include <cassert>
#include "Common/Log.h"
#include "base/display.h"

View File

@ -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 <cassert>
#include "Common/Log.h"
#include "Common/CommonWindows.h"
#include "gfx/gl_common.h"

View File

@ -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 <cassert>
#include <crtdbg.h>
#include <sstream>

View File

@ -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_);

View File

@ -1,5 +1,3 @@
#include <cassert>
#include "base/NativeApp.h"
#include "gfx_es2/gpu_features.h"
#include "thin3d/thin3d_create.h"

View File

@ -1,5 +1,3 @@
#include <cassert>
#include "AndroidJavaGLContext.h"
#include "base/display.h"
#include "base/NativeApp.h"

View File

@ -29,6 +29,7 @@ public:
void SwapBuffers() override {}
void SwapInterval(int interval) override {}
void Resize() override {}
Draw::DrawContext *GetDrawContext() override {
return draw_;
}

View File

@ -1,5 +1,3 @@
#include <cassert>
#include "AndroidVulkanContext.h"
#include "base/NativeApp.h"
#include "base/display.h"

View File

@ -192,7 +192,7 @@ void TextDrawerAndroid::DrawStringBitmap(std::vector<uint8_t> &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<uint8_t> &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);

View File

@ -1,5 +1,4 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstring>
@ -15,13 +14,15 @@
#include <winsock2.h>
#include <ws2tcpip.h>
#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<uint8_t> &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<uint8_t> &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<uint8_t> &paylo
}
void WebSocketServer::Ping(const std::vector<uint8_t> &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<uint8_t> &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),

View File

@ -248,7 +248,7 @@ void GLQueueRunner::RunInitSteps(const std::vector<GLRInitStep> &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();

View File

@ -1,5 +1,3 @@
#include <cassert>
#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<std::mutex> 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) {

View File

@ -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;

View File

@ -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;

View File

@ -12,7 +12,6 @@
#include "Common/ColorConv.h"
#include <cassert>
#include <cfloat>
#include <D3DCommon.h>
#include <d3d11.h>
@ -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;
}

View File

@ -19,7 +19,6 @@
#include <vector>
#include <string>
#include <map>
#include <cassert>
#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;
}
}

View File

@ -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

View File

@ -17,9 +17,8 @@
#ifdef SDL
#include <stdio.h>
#include <cstdio>
#include <SDL.h>
#include <cassert>
#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_);
});