mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Improve assert, cleanup
This commit is contained in:
parent
13abd4991a
commit
c0bc6446dd
5 changed files with 14 additions and 20 deletions
|
@ -63,8 +63,7 @@ bool GLRBuffer::Unmap() {
|
|||
}
|
||||
|
||||
GLPushBuffer::GLPushBuffer(GLRenderManager *render, GLuint target, size_t size, const char *tag) : render_(render), size_(size), target_(target), tag_(tag) {
|
||||
bool res = AddBuffer();
|
||||
_assert_(res);
|
||||
AddBuffer();
|
||||
RegisterGPUMemoryManager(this);
|
||||
}
|
||||
|
||||
|
@ -103,7 +102,6 @@ void GLPushBuffer::Unmap() {
|
|||
void GLPushBuffer::Flush() {
|
||||
// Must be called from the render thread.
|
||||
_dbg_assert_(OnRenderThread());
|
||||
|
||||
if (buf_ >= buffers_.size()) {
|
||||
_dbg_assert_msg_(false, "buf_ somehow got out of sync: %d vs %d", (int)buf_, (int)buffers_.size());
|
||||
return;
|
||||
|
@ -138,17 +136,15 @@ void GLPushBuffer::Flush() {
|
|||
}
|
||||
}
|
||||
|
||||
bool GLPushBuffer::AddBuffer() {
|
||||
void GLPushBuffer::AddBuffer() {
|
||||
// INFO_LOG(G3D, "GLPushBuffer(%s): Allocating %d bytes", tag_, size_);
|
||||
BufInfo info;
|
||||
info.localMemory = (uint8_t *)AllocateAlignedMemory(size_, 16);
|
||||
if (!info.localMemory)
|
||||
return false;
|
||||
_assert_msg_(info.localMemory != 0, "GLPushBuffer alloc fail: %d (%s)", (int)size_, tag_);
|
||||
info.buffer = render_->CreateBuffer(target_, size_, GL_DYNAMIC_DRAW);
|
||||
info.size = size_;
|
||||
buf_ = buffers_.size();
|
||||
buffers_.push_back(info);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GLPushBuffer::Destroy(bool onRenderThread) {
|
||||
|
@ -178,13 +174,7 @@ void GLPushBuffer::NextBuffer(size_t minSize) {
|
|||
while (size_ < minSize) {
|
||||
size_ <<= 1;
|
||||
}
|
||||
|
||||
bool res = AddBuffer();
|
||||
_assert_(res);
|
||||
if (!res) {
|
||||
// Let's try not to crash at least?
|
||||
buf_ = 0;
|
||||
}
|
||||
AddBuffer();
|
||||
}
|
||||
|
||||
// Now, move to the next buffer and map it.
|
||||
|
@ -219,8 +209,7 @@ void GLPushBuffer::Defragment() {
|
|||
|
||||
// Set some sane but very free limits. If there's another spike, we'll just allocate more anyway.
|
||||
size_ = std::min(std::max(newSize, (size_t)65536), (size_t)(512 * 1024 * 1024));
|
||||
bool res = AddBuffer();
|
||||
_assert_msg_(res, "AddBuffer failed");
|
||||
AddBuffer();
|
||||
}
|
||||
|
||||
size_t GLPushBuffer::GetTotalSize() const {
|
||||
|
|
|
@ -169,7 +169,7 @@ protected:
|
|||
void UnmapDevice();
|
||||
|
||||
private:
|
||||
bool AddBuffer();
|
||||
void AddBuffer(); // asserts on failure
|
||||
void NextBuffer(size_t minSize);
|
||||
void Defragment();
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ void FrameData::Submit(VulkanContext *vulkan, FrameSubmitType type, FrameDataSha
|
|||
}
|
||||
|
||||
if (hasPresentCommands) {
|
||||
_dbg_assert_(type == FrameSubmitType::FinishFrame);
|
||||
_dbg_assert_(type != FrameSubmitType::Pending);
|
||||
VkResult res = vkEndCommandBuffer(presentCmd);
|
||||
|
||||
_assert_msg_(res == VK_SUCCESS, "vkEndCommandBuffer failed (present)! result=%s", VulkanResultToString(res));
|
||||
|
|
|
@ -108,7 +108,11 @@ static std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std:
|
|||
std::set<std::string> matches;
|
||||
|
||||
std::string gameIni;
|
||||
if (ini.GetOrCreateSection("games")->Get(gameID.c_str(), &gameIni, "")) {
|
||||
|
||||
// TODO: Should just use getsection and fail the ini if not found, I guess.
|
||||
Section *games = ini.GetOrCreateSection("games");
|
||||
|
||||
if (games->Get(gameID.c_str(), &gameIni, "")) {
|
||||
if (!strcasecmp(gameIni.c_str(), "true")) {
|
||||
matches.insert("plugin.ini");
|
||||
} else if (!strcasecmp(gameIni.c_str(), "false")){
|
||||
|
@ -118,7 +122,7 @@ static std::vector<PluginInfo> FindPlugins(const std::string &gameID, const std:
|
|||
}
|
||||
}
|
||||
|
||||
if (ini.GetOrCreateSection("games")->Get("ALL", &gameIni, "")) {
|
||||
if (games->Get("ALL", &gameIni, "")) {
|
||||
if (!strcasecmp(gameIni.c_str(), "true")) {
|
||||
matches.insert("plugin.ini");
|
||||
} else if (!gameIni.empty()) {
|
||||
|
|
|
@ -224,6 +224,7 @@ void DrawEngineVulkan::DoFlush() {
|
|||
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
|
||||
textureCache_->SetTexture();
|
||||
gstate_c.Clean(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS);
|
||||
// NOTE: After this is set, we MUST call ApplyTexture before returning.
|
||||
textureNeedsApply = true;
|
||||
} else if (gstate.getTextureAddress(0) == (gstate.getFrameBufRawAddress() | 0x04000000)) {
|
||||
// This catches the case of clearing a texture.
|
||||
|
|
Loading…
Add table
Reference in a new issue