OpenGL: Add an assert to catch a class of crash bugs early. Also assorted paranoia.

This commit is contained in:
Henrik Rydgård 2023-05-01 11:56:26 +02:00
parent a41fc74dba
commit d4249c1d73
4 changed files with 13 additions and 0 deletions

View file

@ -532,6 +532,10 @@ public:
pushbuffer->End();
}
bool IsInRenderPass() const {
return curRenderStep_ && curRenderStep_->stepType == GLRStepType::RENDER;
}
// This starts a new step (like a "render pass" in Vulkan).
//
// After a "CopyFramebuffer" or the other functions that start "steps", you need to call this before

View file

@ -1487,6 +1487,11 @@ void VKContext::DrawIndexed(int vertexCount, int offset) {
}
void VKContext::DrawUP(const void *vdata, int vertexCount) {
_dbg_assert_(vertexCount >= 0);
if (vertexCount <= 0) {
return;
}
VkBuffer vulkanVbuf, vulkanUBObuf;
size_t vbBindOffset = push_->Push(vdata, vertexCount * curPipeline_->stride[0], 4, &vulkanVbuf);
uint32_t ubo_offset = (uint32_t)curPipeline_->PushUBO(push_, vulkan_, &vulkanUBObuf);

View file

@ -250,6 +250,9 @@ void DrawEngineGLES::DoFlush() {
PROFILE_THIS_SCOPE("flush");
FrameData &frameData = frameData_[render_->GetCurFrame()];
// Attempt to gather some information (asserts now upload the game name).
_assert_(render_->IsInRenderPass());
bool textureNeedsApply = false;
if (gstate_c.IsDirty(DIRTY_TEXTURE_IMAGE | DIRTY_TEXTURE_PARAMS) && !gstate.isModeClear() && gstate.isTextureMapEnabled()) {
textureCache_->SetTexture();

View file

@ -171,6 +171,7 @@ public:
int n = i & 3;
ui_draw2d.DrawImageRotated(symbols[n], x, y, 1.0f, angle, colorAlpha(colors[n], alpha * 0.1f));
}
dc.Flush();
}
private: