diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index 12c93090f..d111e32e0 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -1707,7 +1707,6 @@ static void RT_FetchMeshData(IReplayController *r, ICaptureContext &ctx, Populat if(data->vsoutConfig.displayIndices) data->vsoutConfig.displayIndices->deref(); - if(data->vsinConfig.indices) { // display the same index values data->vsoutConfig.displayIndices = data->vsinConfig.indices; diff --git a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp index c2a17d2f5..80cf71f0d 100644 --- a/qrenderdoc/Windows/Dialogs/LiveCapture.cpp +++ b/qrenderdoc/Windows/Dialogs/LiveCapture.cpp @@ -417,7 +417,7 @@ void LiveCapture::deleteCapture_triggered() m_Ctx.Replay().DeleteCapture(cap->path, cap->local); } - if(cap->saved || cap->local) + if(cap->local) { m_Main->RemoveRecentCapture(cap->path); } @@ -910,7 +910,7 @@ void LiveCapture::cleanItems() m_Ctx.Replay().DeleteCapture(cap->path, cap->local); } - if(cap->saved || cap->local) + if(cap->local) { m_Main->RemoveRecentCapture(cap->path); } diff --git a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp index 08e11f52b..e8e4d43f2 100644 --- a/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D11PipelineStateViewer.cpp @@ -764,8 +764,8 @@ bool D3D11PipelineStateViewer::showNode(bool usedSlot, bool filledSlot) if(usedSlot) return true; - // it's bound, but not referenced, and we have "show unused" - if(showUnused && !usedSlot && filledSlot) + // it's not referenced, but if it's bound and we have "show unused" then show it + if(showUnused && filledSlot) return true; // it's empty, and we have "show empty" diff --git a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp index 1af7798fc..39c683eda 100644 --- a/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/D3D12PipelineStateViewer.cpp @@ -805,8 +805,8 @@ bool D3D12PipelineStateViewer::showNode(bool usedSlot, bool filledSlot) if(usedSlot) return true; - // it's bound, but not referenced, and we have "show unused" - if(showUnused && !usedSlot && filledSlot) + // it's not referenced, but if it's bound and we have "show unused" then show it + if(showUnused && filledSlot) return true; // it's empty, and we have "show empty" diff --git a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp index 646b1fca1..6fd72119a 100644 --- a/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/GLPipelineStateViewer.cpp @@ -506,8 +506,8 @@ bool GLPipelineStateViewer::showNode(bool usedSlot, bool filledSlot) if(usedSlot) return true; - // it's bound, but not referenced, and we have "show unused" - if(showUnused && !usedSlot && filledSlot) + // it's not referenced, but if it's bound and we have "show unused" then show it + if(showUnused && filledSlot) return true; // it's empty, and we have "show empty" @@ -2614,7 +2614,7 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Shad { QString slotname = QString::number(i); - if(shaderInput && !shaderInput->name.isEmpty()) + if(!shaderInput->name.isEmpty()) slotname += QFormatStr(": %1").arg(shaderInput->name); uint32_t w = 1, h = 1, d = 1; @@ -2668,7 +2668,7 @@ void GLPipelineStateViewer::exportHTML(QXmlStreamWriter &xml, const GLPipe::Shad { QString slotname = QString::number(i); - if(shaderInput && !shaderInput->name.isEmpty()) + if(!shaderInput->name.isEmpty()) slotname += QFormatStr(": %1").arg(shaderInput->name); QString borderColor = QFormatStr("%1, %2, %3, %4") diff --git a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp index 6acd02cb3..8a0d57445 100644 --- a/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp +++ b/qrenderdoc/Windows/PipelineState/VulkanPipelineStateViewer.cpp @@ -583,8 +583,8 @@ bool VulkanPipelineStateViewer::showNode(bool usedSlot, bool filledSlot) if(usedSlot) return true; - // it's bound, but not referenced, and we have "show unused" - if(showUnused && !usedSlot && filledSlot) + // it's not referenced, but if it's bound and we have "show unused" then show it + if(showUnused && filledSlot) return true; // it's empty, and we have "show empty" @@ -1299,11 +1299,9 @@ void VulkanPipelineStateViewer::addResourceRow(ShaderReflection *shaderDetails, sampData.node = samplerNode; samplerNode->setTag(QVariant::fromValue(sampData)); - if(node) - samplers.insert(descriptorBind->samplerResourceId, samplerNode); + samplers.insert(descriptorBind->samplerResourceId, samplerNode); } - if(node) { RDTreeWidgetItem *combinedSamp = m_CombinedImageSamplers[node] = samplers[descriptorBind->samplerResourceId]; diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index 25cd9db72..cddb75839 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -2315,7 +2315,7 @@ void TextureViewer::InitStageResourcePreviews(ShaderStage stage, bool show = used; // it's bound, but not referenced, and we have "show disabled" - show = show || (m_ShowUnused && !used && res.resourceId != ResourceId()); + show = show || (m_ShowUnused && res.resourceId != ResourceId()); // it's empty, and we have "show empty" show = show || (m_ShowEmpty && res.resourceId == ResourceId()); diff --git a/renderdoc/android/android.cpp b/renderdoc/android/android.cpp index 1f6d3872f..a46577a2e 100644 --- a/renderdoc/android/android.cpp +++ b/renderdoc/android/android.cpp @@ -1146,7 +1146,7 @@ ExecuteResult AndroidRemoteServer::ExecuteAndInject(const char *a, const char *w // without ever opening a connection. int curpid = Android::GetCurrentPID(m_deviceID, packageName); - if(pid != 0 && curpid == 0) + if(curpid == 0) { RDCERR("APK has crashed or never opened target control connection before closing."); break; diff --git a/renderdoc/core/core.h b/renderdoc/core/core.h index f18fae13b..c9d908cc3 100644 --- a/renderdoc/core/core.h +++ b/renderdoc/core/core.h @@ -666,7 +666,7 @@ private: return wnd == NULL || o.wnd == NULL || wnd == o.wnd; if(wnd == NULL || o.wnd == NULL) - return dev == NULL || o.dev == NULL || dev == o.dev; + return dev == o.dev; return *this == o; } diff --git a/renderdoc/core/image_viewer.cpp b/renderdoc/core/image_viewer.cpp index f7feec993..f89829a2f 100644 --- a/renderdoc/core/image_viewer.cpp +++ b/renderdoc/core/image_viewer.cpp @@ -730,7 +730,7 @@ void ImageViewer::RefreshFile() if(m_TexDetails.width != texDetails.width || m_TexDetails.height != texDetails.height || m_TexDetails.depth != texDetails.depth || m_TexDetails.cubemap != texDetails.cubemap || m_TexDetails.mips != texDetails.mips || m_TexDetails.arraysize != texDetails.arraysize || - m_TexDetails.width != texDetails.width || m_TexDetails.format != texDetails.format) + m_TexDetails.format != texDetails.format) { m_TextureID = ResourceId(); } diff --git a/renderdoc/core/target_control.cpp b/renderdoc/core/target_control.cpp index 8a448ed1f..b6666cd67 100644 --- a/renderdoc/core/target_control.cpp +++ b/renderdoc/core/target_control.cpp @@ -151,7 +151,7 @@ void RenderDoc::TargetControlClientThread(uint32_t version, Network::Socket *cli while(client) { - if(RenderDoc::Inst().m_ControlClientThreadShutdown || (client && !client->Connected())) + if(RenderDoc::Inst().m_ControlClientThreadShutdown || !client->Connected()) { SAFE_DELETE(client); break; diff --git a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp index 414c9fd94..d9d1fa80a 100644 --- a/renderdoc/driver/d3d11/d3d11_context_wrap.cpp +++ b/renderdoc/driver/d3d11/d3d11_context_wrap.cpp @@ -6175,23 +6175,19 @@ bool WrappedID3D11DeviceContext::Serialise_CopyStructureCount(SerialiserType &se DrawcallDescription draw; draw.name = "CopyStructureCount(" + ToStr(dstOrigID) + ", " + ToStr(srcOrigID) + ")"; draw.flags |= DrawFlags::Copy; + draw.copySource = srcOrigID; + draw.copyDestination = dstOrigID; - if(pDstBuffer && pSrcView) + if(m_CurEventID) { - draw.copySource = srcOrigID; - draw.copyDestination = dstOrigID; - - if(m_CurEventID) + if(dstLiveID == srcLiveID) { - if(dstLiveID == srcLiveID) - { - m_ResourceUses[dstLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::Copy)); - } - else - { - m_ResourceUses[dstLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::CopyDst)); - m_ResourceUses[srcLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::CopySrc)); - } + m_ResourceUses[dstLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::Copy)); + } + else + { + m_ResourceUses[dstLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::CopyDst)); + m_ResourceUses[srcLiveID].push_back(EventUsage(m_CurEventID, ResourceUsage::CopySrc)); } } @@ -6569,12 +6565,8 @@ void WrappedID3D11DeviceContext::ClearRenderTargetView(ID3D11RenderTargetView *p SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_ClearRenderTargetView(GET_SERIALISER, pRenderTargetView, ColorRGBA); - if(pRenderTargetView) - { - MarkResourceReferenced(GetViewResourceResID(pRenderTargetView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pRenderTargetView), eFrameRef_Read); - } - + MarkResourceReferenced(GetViewResourceResID(pRenderTargetView), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForResource(pRenderTargetView), eFrameRef_Read); MarkDirtyResource(GetViewResourceResID(pRenderTargetView)); m_ContextRecord->AddChunk(scope.Get()); @@ -6822,12 +6814,8 @@ void WrappedID3D11DeviceContext::ClearDepthStencilView(ID3D11DepthStencilView *p SERIALISE_ELEMENT(m_ResourceID).Named("Context"_lit).TypedAs("ID3D11DeviceContext *"_lit); Serialise_ClearDepthStencilView(GET_SERIALISER, pDepthStencilView, ClearFlags, Depth, Stencil); - if(pDepthStencilView) - { - MarkResourceReferenced(GetViewResourceResID(pDepthStencilView), eFrameRef_PartialWrite); - MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read); - } - + MarkResourceReferenced(GetViewResourceResID(pDepthStencilView), eFrameRef_PartialWrite); + MarkResourceReferenced(GetIDForResource(pDepthStencilView), eFrameRef_Read); MarkDirtyResource(GetViewResourceResID(pDepthStencilView)); m_ContextRecord->AddChunk(scope.Get()); diff --git a/renderdoc/driver/d3d11/d3d11_device.cpp b/renderdoc/driver/d3d11/d3d11_device.cpp index 2afd32c3b..7e834aef4 100644 --- a/renderdoc/driver/d3d11/d3d11_device.cpp +++ b/renderdoc/driver/d3d11/d3d11_device.cpp @@ -1504,7 +1504,7 @@ bool WrappedID3D11Device::Serialise_WrapSwapchainBuffer(SerialiserType &ser, IDX D3D11_TEXTURE2D_DESC BackbufferDescriptor; - if(ser.IsWriting() && pTex) + if(ser.IsWriting()) pTex->GetDesc(&BackbufferDescriptor); SERIALISE_ELEMENT(BackbufferDescriptor); diff --git a/renderdoc/driver/d3d12/d3d12_debug.cpp b/renderdoc/driver/d3d12/d3d12_debug.cpp index 0ffa599ca..e40cab2d3 100644 --- a/renderdoc/driver/d3d12/d3d12_debug.cpp +++ b/renderdoc/driver/d3d12/d3d12_debug.cpp @@ -824,7 +824,7 @@ void D3D12DebugManager::GetBufferData(ID3D12Resource *buffer, uint64_t offset, u length = desc.Width - offset; } - if(length > 0 && offset + length > desc.Width) + if(offset + length > desc.Width) { RDCWARN("Attempting to read off the end of the buffer (%llu %llu). Will be clamped (%llu)", offset, length, desc.Width); diff --git a/renderdoc/driver/d3d12/d3d12_device.cpp b/renderdoc/driver/d3d12/d3d12_device.cpp index 2588fb08f..15a0c31f8 100644 --- a/renderdoc/driver/d3d12/d3d12_device.cpp +++ b/renderdoc/driver/d3d12/d3d12_device.cpp @@ -1759,7 +1759,7 @@ void WrappedID3D12Device::StartFrameCapture(void *dev, void *wnd) m_SubmitCounter = 0; FrameDescription frame; - frame.frameNumber = m_AppControlledCapture ? ~0U : m_FrameCounter; + frame.frameNumber = ~0U; frame.captureTime = Timing::GetUnixTimestamp(); RDCEraseEl(frame.stats); m_CapturedFrames.push_back(frame); diff --git a/renderdoc/driver/d3d12/d3d12_device_wrap2.cpp b/renderdoc/driver/d3d12/d3d12_device_wrap2.cpp index a8531ac44..5f93a22c6 100644 --- a/renderdoc/driver/d3d12/d3d12_device_wrap2.cpp +++ b/renderdoc/driver/d3d12/d3d12_device_wrap2.cpp @@ -160,8 +160,7 @@ HRESULT WrappedID3D12Device::CreatePipelineState(const D3D12_PIPELINE_STATE_STRE unwrappedDesc.Unwrap(); if(ppPipelineState == NULL) - return m_pDevice3->CreatePipelineState(pDesc ? unwrappedDesc.AsDescStream() : NULL, riid, - ppPipelineState); + return m_pDevice3->CreatePipelineState(unwrappedDesc.AsDescStream(), riid, ppPipelineState); if(riid != __uuidof(ID3D12PipelineState)) return E_NOINTERFACE; diff --git a/renderdoc/driver/d3d8/d3d8_debug.cpp b/renderdoc/driver/d3d8/d3d8_debug.cpp index 43808234b..dcbab6300 100644 --- a/renderdoc/driver/d3d8/d3d8_debug.cpp +++ b/renderdoc/driver/d3d8/d3d8_debug.cpp @@ -291,7 +291,6 @@ void D3D8DebugManager::RenderTextInternal(float x, float y, const rdcstr &text) 0.f, textPositionX, textPositionY + 3.f, 0.f, 0.f); } - if(quads != NULL) { // overlay render states res |= m_WrappedDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); diff --git a/renderdoc/driver/d3d9/d3d9_debug.cpp b/renderdoc/driver/d3d9/d3d9_debug.cpp index cc17c6d5e..f134677a3 100644 --- a/renderdoc/driver/d3d9/d3d9_debug.cpp +++ b/renderdoc/driver/d3d9/d3d9_debug.cpp @@ -298,7 +298,6 @@ void D3D9DebugManager::RenderTextInternal(float x, float y, const rdcstr &text) 0.f, textPositionX, textPositionY + 3.f, 0.f, 0.f); } - if(quads != NULL) { // overlay render states res |= m_WrappedDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE); diff --git a/renderdoc/driver/gl/gl_driver.cpp b/renderdoc/driver/gl/gl_driver.cpp index f7c3e9668..5c2d344ea 100644 --- a/renderdoc/driver/gl/gl_driver.cpp +++ b/renderdoc/driver/gl/gl_driver.cpp @@ -1262,334 +1262,331 @@ bool WrappedOpenGL::Serialise_ContextConfiguration(SerialiserType &ser, void *ct void WrappedOpenGL::ActivateContext(GLWindowingData winData) { m_ActiveContexts[Threading::GetCurrentID()] = winData; - if(winData.ctx) + + if(!winData.ctx) + return; + + void *contextHandle = winData.ctx; + m_LastContexts.removeOneIf( + [contextHandle](const GLWindowingData &ctx) { return ctx.ctx == contextHandle; }); + + m_LastContexts.push_back(winData); + + if(m_LastContexts.size() > 10) + m_LastContexts.erase(0); + + if(IsActiveCapturing(m_State)) { - void *contextHandle = winData.ctx; - m_LastContexts.removeOneIf( - [contextHandle](const GLWindowingData &ctx) { return ctx.ctx == contextHandle; }); + // fetch any initial states needed. Note this is insufficient, and doesn't handle the case + // where we might just suddenly start getting commands on a thread that already has a context + // active. For now we assume we'll only get GL commands from a single thread + // + // First we process any queued fetches from the context itself (i.e. non-shared resources), + // then from the context's share group. + for(void *ctx : {(void *)winData.ctx, (void *)GetShareGroup(winData.ctx)}) + { + QueuedResource fetch; + fetch.res.ContextShareGroup = ctx; + size_t before = m_QueuedInitialFetches.size(); + auto it = std::lower_bound(m_QueuedInitialFetches.begin(), m_QueuedInitialFetches.end(), fetch); + size_t i = it - m_QueuedInitialFetches.begin(); + while(i < m_QueuedInitialFetches.size() && it->res.ContextShareGroup == ctx) + { + GetResourceManager()->ContextPrepare_InitialState(it->res); + m_QueuedInitialFetches.erase(i); + } + size_t after = m_QueuedInitialFetches.size(); - m_LastContexts.push_back(winData); - - if(m_LastContexts.size() > 10) - m_LastContexts.erase(0); + (void)before; + (void)after; + RDCDEBUG("Prepared %zu resources on context/sharegroup %p, %zu left", before - after, ctx, + after); + } } - if(winData.ctx) + // also if there are any queued releases, process them now + if(!m_QueuedReleases.empty()) { - if(IsActiveCapturing(m_State)) + for(void *ctx : {(void *)winData.ctx, (void *)GetShareGroup(winData.ctx)}) { - // fetch any initial states needed. Note this is insufficient, and doesn't handle the case - // where we might just suddenly start getting commands on a thread that already has a context - // active. For now we assume we'll only get GL commands from a single thread - // - // First we process any queued fetches from the context itself (i.e. non-shared resources), - // then from the context's share group. - for(void *ctx : {(void *)winData.ctx, (void *)GetShareGroup(winData.ctx)}) + QueuedResource fetch; + fetch.res.ContextShareGroup = ctx; + size_t before = m_QueuedReleases.size(); + auto it = std::lower_bound(m_QueuedReleases.begin(), m_QueuedReleases.end(), fetch); + size_t i = it - m_QueuedReleases.begin(); + while(it != m_QueuedReleases.end() && it->res.ContextShareGroup == ctx) { - QueuedResource fetch; - fetch.res.ContextShareGroup = ctx; - size_t before = m_QueuedInitialFetches.size(); - auto it = - std::lower_bound(m_QueuedInitialFetches.begin(), m_QueuedInitialFetches.end(), fetch); - size_t i = it - m_QueuedInitialFetches.begin(); - while(i < m_QueuedInitialFetches.size() && it->res.ContextShareGroup == ctx) - { - GetResourceManager()->ContextPrepare_InitialState(it->res); - m_QueuedInitialFetches.erase(i); - } - size_t after = m_QueuedInitialFetches.size(); + ReleaseResource(it->res); + m_QueuedReleases.erase(i); + } + size_t after = m_QueuedReleases.size(); - (void)before; - (void)after; - RDCDEBUG("Prepared %zu resources on context/sharegroup %p, %zu left", before - after, ctx, - after); + (void)before; + (void)after; + RDCDEBUG("Released %zu resources on context/sharegroup %p, %zu left", before - after, ctx, + after); + } + } + + ContextData &ctxdata = m_ContextData[winData.ctx]; + + ctxdata.CreateResourceRecord(this, winData.ctx); + + // update thread-local context pair + { + GLContextTLSData *tlsData = (GLContextTLSData *)Threading::GetTLSValue(m_CurCtxDataTLS); + + if(tlsData) + { + tlsData->ctxPair = {winData.ctx, GetShareGroup(winData.ctx)}; + tlsData->ctxRecord = ctxdata.m_ContextDataRecord; + } + else + { + tlsData = new GLContextTLSData(ContextPair({winData.ctx, GetShareGroup(winData.ctx)}), + ctxdata.m_ContextDataRecord); + m_CtxDataVector.push_back(tlsData); + + Threading::SetTLSValue(m_CurCtxDataTLS, tlsData); + } + } + + if(!ctxdata.built) + { + ctxdata.built = true; + + if(IsCaptureMode(m_State)) + RDCLOG("Activating new GL context: %s / %s / %s", GL.glGetString(eGL_VENDOR), + GL.glGetString(eGL_RENDERER), GL.glGetString(eGL_VERSION)); + + const rdcarray &globalExts = IsGLES ? m_GLESExtensions : m_GLExtensions; + + if(HasExt[KHR_debug] && GL.glDebugMessageCallback && + RenderDoc::Inst().GetCaptureOptions().apiValidation) + { + GL.glDebugMessageCallback(&DebugSnoopStatic, this); + GL.glEnable(eGL_DEBUG_OUTPUT_SYNCHRONOUS); + } + + rdcarray implExts; + + int ctxVersion = 0; + bool ctxGLES = false; + GetContextVersion(ctxGLES, ctxVersion); + + // only use glGetStringi on 3.0 contexts and above (ES and GL), even if we have the function + // pointer + if(GL.glGetIntegerv && GL.glGetStringi && ctxVersion >= 30) + { + GLuint numExts = 0; + GL.glGetIntegerv(eGL_NUM_EXTENSIONS, (GLint *)&numExts); + + for(GLuint i = 0; i < numExts; i++) + implExts.push_back((const char *)GL.glGetStringi(eGL_EXTENSIONS, i)); + } + else if(GL.glGetString) + { + rdcstr implExtString = (const char *)GL.glGetString(eGL_EXTENSIONS); + + split(implExtString, implExts, ' '); + } + else + { + RDCERR("No functions to fetch implementation's extensions!"); + } + + std::sort(implExts.begin(), implExts.end()); + + // intersection of implExts and globalExts into ctx.glExts + { + for(size_t i = 0, j = 0; i < implExts.size() && j < globalExts.size();) + { + const rdcstr &a = implExts[i]; + const rdcstr &b = globalExts[j]; + + if(a == b) + { + ctxdata.glExts.push_back(a); + i++; + j++; + } + else if(a < b) + { + i++; + } + else if(b < a) + { + j++; + } } } - // also if there are any queued releases, process them now - if(!m_QueuedReleases.empty()) - { - for(void *ctx : {(void *)winData.ctx, (void *)GetShareGroup(winData.ctx)}) - { - QueuedResource fetch; - fetch.res.ContextShareGroup = ctx; - size_t before = m_QueuedReleases.size(); - auto it = std::lower_bound(m_QueuedReleases.begin(), m_QueuedReleases.end(), fetch); - size_t i = it - m_QueuedReleases.begin(); - while(it != m_QueuedReleases.end() && it->res.ContextShareGroup == ctx) - { - ReleaseResource(it->res); - m_QueuedReleases.erase(i); - } - size_t after = m_QueuedReleases.size(); + // this extension is something RenderDoc will support even if the impl + // doesn't. https://renderdoc.org/debug_tool.txt + ctxdata.glExts.push_back("GL_EXT_debug_tool"); - (void)before; - (void)after; - RDCDEBUG("Released %zu resources on context/sharegroup %p, %zu left", before - after, ctx, - after); + // similarly we report all the debug extensions so that applications can use them freely - we + // don't call into the driver so we don't need to care if the driver supports them + ctxdata.glExts.push_back("GL_KHR_debug"); + ctxdata.glExts.push_back("GL_EXT_debug_label"); + ctxdata.glExts.push_back("GL_EXT_debug_marker"); + + if(!IsGLES) + { + ctxdata.glExts.push_back("GL_GREMEDY_frame_terminator"); + ctxdata.glExts.push_back("GL_GREMEDY_string_marker"); + } + + merge(ctxdata.glExts, ctxdata.glExtsString, ' '); + + if(GL.glGetIntegerv) + { + GLint mj = 0, mn = 0; + GL.glGetIntegerv(eGL_MAJOR_VERSION, &mj); + GL.glGetIntegerv(eGL_MINOR_VERSION, &mn); + + int ver = mj * 10 + mn; + + ctxdata.version = ver; + + if(ver > GLCoreVersion || (!GLIsCore && ctxdata.isCore)) + { + GLCoreVersion = ver; + GLIsCore = ctxdata.isCore; + DoVendorChecks(m_Platform, winData); } } - ContextData &ctxdata = m_ContextData[winData.ctx]; - - ctxdata.CreateResourceRecord(this, winData.ctx); - - // update thread-local context pair + if(IsCaptureMode(m_State)) { - GLContextTLSData *tlsData = (GLContextTLSData *)Threading::GetTLSValue(m_CurCtxDataTLS); + // check if we already have VAO 0 registered for this context. This could be possible if + // VAOs are shared and a previous context in the share group created it. + GLResource vao0 = VertexArrayRes(GetCtx(), 0); - if(tlsData) + if(!GetResourceManager()->HasCurrentResource(vao0)) { - tlsData->ctxPair = {winData.ctx, GetShareGroup(winData.ctx)}; - tlsData->ctxRecord = ctxdata.m_ContextDataRecord; - } - else - { - tlsData = new GLContextTLSData(ContextPair({winData.ctx, GetShareGroup(winData.ctx)}), - ctxdata.m_ContextDataRecord); - m_CtxDataVector.push_back(tlsData); + ResourceId id = GetResourceManager()->RegisterResource(vao0); - Threading::SetTLSValue(m_CurCtxDataTLS, tlsData); + GLResourceRecord *record = GetResourceManager()->AddResourceRecord(id); + RDCASSERT(record); + + { + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::glGenVertexArrays); + GLuint zero = 0; + Serialise_glGenVertexArrays(ser, 1, &zero); + + record->AddChunk(scope.Get()); + } + + // give it a name + { + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::glObjectLabel); + Serialise_glObjectLabel(ser, eGL_VERTEX_ARRAY, 0, -1, "Default VAO"); + + record->AddChunk(scope.Get()); + } + + // we immediately mark it dirty since the vertex array tracking functions expect a proper + // VAO + GetResourceManager()->MarkDirtyResource(id); } + + // we also do the same for FBO 0, but we must force it not to be shared as even if FBOs are + // shared the FBO0 may not be :(. + GLResource fbo0 = FramebufferRes({GetCtx().ctx, GetCtx().ctx}, 0); + + if(!GetResourceManager()->HasCurrentResource(fbo0)) + ctxdata.m_ContextFBOID = GetResourceManager()->RegisterResource(fbo0); + } + } + + // if we're capturing, we need to serialise out the changed state vector + if(IsActiveCapturing(m_State)) + { + { + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::MakeContextCurrent); + Serialise_BeginCaptureFrame(ser); + GetContextRecord()->AddChunk(scope.Get()); } - if(!ctxdata.built) + // also serialise out this context's backbuffer params { - ctxdata.built = true; - - if(IsCaptureMode(m_State)) - RDCLOG("Activating new GL context: %s / %s / %s", GL.glGetString(eGL_VENDOR), - GL.glGetString(eGL_RENDERER), GL.glGetString(eGL_VERSION)); - - const rdcarray &globalExts = IsGLES ? m_GLESExtensions : m_GLExtensions; - - if(HasExt[KHR_debug] && GL.glDebugMessageCallback && - RenderDoc::Inst().GetCaptureOptions().apiValidation) - { - GL.glDebugMessageCallback(&DebugSnoopStatic, this); - GL.glEnable(eGL_DEBUG_OUTPUT_SYNCHRONOUS); - } - - rdcarray implExts; - - int ctxVersion = 0; - bool ctxGLES = false; - GetContextVersion(ctxGLES, ctxVersion); - - // only use glGetStringi on 3.0 contexts and above (ES and GL), even if we have the function - // pointer - if(GL.glGetIntegerv && GL.glGetStringi && ctxVersion >= 30) - { - GLuint numExts = 0; - GL.glGetIntegerv(eGL_NUM_EXTENSIONS, (GLint *)&numExts); - - for(GLuint i = 0; i < numExts; i++) - implExts.push_back((const char *)GL.glGetStringi(eGL_EXTENSIONS, i)); - } - else if(GL.glGetString) - { - rdcstr implExtString = (const char *)GL.glGetString(eGL_EXTENSIONS); - - split(implExtString, implExts, ' '); - } - else - { - RDCERR("No functions to fetch implementation's extensions!"); - } - - std::sort(implExts.begin(), implExts.end()); - - // intersection of implExts and globalExts into ctx.glExts - { - for(size_t i = 0, j = 0; i < implExts.size() && j < globalExts.size();) - { - const rdcstr &a = implExts[i]; - const rdcstr &b = globalExts[j]; - - if(a == b) - { - ctxdata.glExts.push_back(a); - i++; - j++; - } - else if(a < b) - { - i++; - } - else if(b < a) - { - j++; - } - } - } - - // this extension is something RenderDoc will support even if the impl - // doesn't. https://renderdoc.org/debug_tool.txt - ctxdata.glExts.push_back("GL_EXT_debug_tool"); - - // similarly we report all the debug extensions so that applications can use them freely - we - // don't call into the driver so we don't need to care if the driver supports them - ctxdata.glExts.push_back("GL_KHR_debug"); - ctxdata.glExts.push_back("GL_EXT_debug_label"); - ctxdata.glExts.push_back("GL_EXT_debug_marker"); - - if(!IsGLES) - { - ctxdata.glExts.push_back("GL_GREMEDY_frame_terminator"); - ctxdata.glExts.push_back("GL_GREMEDY_string_marker"); - } - - merge(ctxdata.glExts, ctxdata.glExtsString, ' '); - - if(GL.glGetIntegerv) - { - GLint mj = 0, mn = 0; - GL.glGetIntegerv(eGL_MAJOR_VERSION, &mj); - GL.glGetIntegerv(eGL_MINOR_VERSION, &mn); - - int ver = mj * 10 + mn; - - ctxdata.version = ver; - - if(ver > GLCoreVersion || (!GLIsCore && ctxdata.isCore)) - { - GLCoreVersion = ver; - GLIsCore = ctxdata.isCore; - DoVendorChecks(m_Platform, winData); - } - } - - if(IsCaptureMode(m_State)) - { - // check if we already have VAO 0 registered for this context. This could be possible if - // VAOs are shared and a previous context in the share group created it. - GLResource vao0 = VertexArrayRes(GetCtx(), 0); - - if(!GetResourceManager()->HasCurrentResource(vao0)) - { - ResourceId id = GetResourceManager()->RegisterResource(vao0); - - GLResourceRecord *record = GetResourceManager()->AddResourceRecord(id); - RDCASSERT(record); - - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::glGenVertexArrays); - GLuint zero = 0; - Serialise_glGenVertexArrays(ser, 1, &zero); - - record->AddChunk(scope.Get()); - } - - // give it a name - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::glObjectLabel); - Serialise_glObjectLabel(ser, eGL_VERTEX_ARRAY, 0, -1, "Default VAO"); - - record->AddChunk(scope.Get()); - } - - // we immediately mark it dirty since the vertex array tracking functions expect a proper - // VAO - GetResourceManager()->MarkDirtyResource(id); - } - - // we also do the same for FBO 0, but we must force it not to be shared as even if FBOs are - // shared the FBO0 may not be :(. - GLResource fbo0 = FramebufferRes({GetCtx().ctx, GetCtx().ctx}, 0); - - if(!GetResourceManager()->HasCurrentResource(fbo0)) - ctxdata.m_ContextFBOID = GetResourceManager()->RegisterResource(fbo0); - } + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::ContextConfiguration); + Serialise_ContextConfiguration(ser, winData.ctx); + GetContextRecord()->AddChunk(scope.Get()); } + } - // if we're capturing, we need to serialise out the changed state vector - if(IsActiveCapturing(m_State)) + // we create these buffers last after serialising the apply of the new state, so that in the + // event that this context is created mid-capture, we don't serialise out buffer binding calls + // that trash the state of the previous context while creating these buffers. + if(ctxdata.m_ClientMemoryIBO == 0 && IsCaptureMode(m_State)) + { + PUSH_CURRENT_CHUNK; + GLuint prevArrayBuffer = 0; + glGetIntegerv(eGL_ARRAY_BUFFER_BINDING, (GLint *)&prevArrayBuffer); + + GLuint prevElementArrayBuffer = 0; + glGetIntegerv(eGL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint *)&prevElementArrayBuffer); + + // Initialize VBOs used in case we copy from client memory. + gl_CurChunk = GLChunk::glGenBuffers; + glGenBuffers(ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs), ctxdata.m_ClientMemoryVBOs); + + for(size_t i = 0; i < ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs); i++) { - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::MakeContextCurrent); - Serialise_BeginCaptureFrame(ser); - GetContextRecord()->AddChunk(scope.Get()); - } - - // also serialise out this context's backbuffer params - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::ContextConfiguration); - Serialise_ContextConfiguration(ser, winData.ctx); - GetContextRecord()->AddChunk(scope.Get()); - } - } - - // we create these buffers last after serialising the apply of the new state, so that in the - // event that this context is created mid-capture, we don't serialise out buffer binding calls - // that trash the state of the previous context while creating these buffers. - if(ctxdata.m_ClientMemoryIBO == 0 && IsCaptureMode(m_State)) - { - PUSH_CURRENT_CHUNK; - GLuint prevArrayBuffer = 0; - glGetIntegerv(eGL_ARRAY_BUFFER_BINDING, (GLint *)&prevArrayBuffer); - - GLuint prevElementArrayBuffer = 0; - glGetIntegerv(eGL_ELEMENT_ARRAY_BUFFER_BINDING, (GLint *)&prevElementArrayBuffer); - - // Initialize VBOs used in case we copy from client memory. - gl_CurChunk = GLChunk::glGenBuffers; - glGenBuffers(ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs), ctxdata.m_ClientMemoryVBOs); - - for(size_t i = 0; i < ARRAY_COUNT(ctxdata.m_ClientMemoryVBOs); i++) - { - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ARRAY_BUFFER, ctxdata.m_ClientMemoryVBOs[i]); - - gl_CurChunk = GLChunk::glBufferData; - glBufferData(eGL_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW); - - // we mark these buffers as internal since initial contents are not needed - they're - // entirely handled internally and buffer data is uploaded immediately before draws - and - // we don't want them to be pulled in unless explicitly referenced. - GetResourceManager()->SetInternalResource(BufferRes(GetCtx(), ctxdata.m_ClientMemoryVBOs[i])); - - if(HasExt[KHR_debug]) - { - gl_CurChunk = GLChunk::glObjectLabel; - glObjectLabel(eGL_BUFFER, ctxdata.m_ClientMemoryVBOs[i], -1, - StringFormat::Fmt("Client-memory pointer data (VB %zu)", i).c_str()); - } - } - - gl_CurChunk = GLChunk::glGenBuffers; - glGenBuffers(1, &ctxdata.m_ClientMemoryIBO); - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ctxdata.m_ClientMemoryIBO); - - GetResourceManager()->SetInternalResource(BufferRes(GetCtx(), ctxdata.m_ClientMemoryIBO)); + glBindBuffer(eGL_ARRAY_BUFFER, ctxdata.m_ClientMemoryVBOs[i]); gl_CurChunk = GLChunk::glBufferData; - glBufferData(eGL_ELEMENT_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW); + glBufferData(eGL_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW); + + // we mark these buffers as internal since initial contents are not needed - they're + // entirely handled internally and buffer data is uploaded immediately before draws - and + // we don't want them to be pulled in unless explicitly referenced. + GetResourceManager()->SetInternalResource(BufferRes(GetCtx(), ctxdata.m_ClientMemoryVBOs[i])); if(HasExt[KHR_debug]) { gl_CurChunk = GLChunk::glObjectLabel; - glObjectLabel(eGL_BUFFER, ctxdata.m_ClientMemoryIBO, -1, "Client-memory pointer data (IB)"); + glObjectLabel(eGL_BUFFER, ctxdata.m_ClientMemoryVBOs[i], -1, + StringFormat::Fmt("Client-memory pointer data (VB %zu)", i).c_str()); } - - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ARRAY_BUFFER, prevArrayBuffer); - - gl_CurChunk = GLChunk::glBindBuffer; - glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, prevElementArrayBuffer); } - // this is hack but GL context creation is an *utter mess*. For first-frame captures, only - // consider an attribs created context, to avoid starting capturing when the user is creating - // dummy contexts to be able to create the real one. - if(ctxdata.attribsCreate) - FirstFrame(ctxdata.ctx, (void *)winData.wnd); + gl_CurChunk = GLChunk::glGenBuffers; + glGenBuffers(1, &ctxdata.m_ClientMemoryIBO); + + gl_CurChunk = GLChunk::glBindBuffer; + glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, ctxdata.m_ClientMemoryIBO); + + GetResourceManager()->SetInternalResource(BufferRes(GetCtx(), ctxdata.m_ClientMemoryIBO)); + + gl_CurChunk = GLChunk::glBufferData; + glBufferData(eGL_ELEMENT_ARRAY_BUFFER, 64, NULL, eGL_DYNAMIC_DRAW); + + if(HasExt[KHR_debug]) + { + gl_CurChunk = GLChunk::glObjectLabel; + glObjectLabel(eGL_BUFFER, ctxdata.m_ClientMemoryIBO, -1, "Client-memory pointer data (IB)"); + } + + gl_CurChunk = GLChunk::glBindBuffer; + glBindBuffer(eGL_ARRAY_BUFFER, prevArrayBuffer); + + gl_CurChunk = GLChunk::glBindBuffer; + glBindBuffer(eGL_ELEMENT_ARRAY_BUFFER, prevElementArrayBuffer); } + + // this is hack but GL context creation is an *utter mess*. For first-frame captures, only + // consider an attribs created context, to avoid starting capturing when the user is creating + // dummy contexts to be able to create the real one. + if(ctxdata.attribsCreate) + FirstFrame(ctxdata.ctx, (void *)winData.wnd); } struct ReplacementSearch @@ -3049,14 +3046,14 @@ bool WrappedOpenGL::RecordUpdateCheck(GLResourceRecord *record) return false; // if we've already stopped tracking this object, return as such - if(record && record->UpdateCount > 64) + if(record->UpdateCount > 64) return false; // increase update count record->UpdateCount++; // if update count is high, mark as dirty - if(record && record->UpdateCount > 64) + if(record->UpdateCount > 64) { GetResourceManager()->MarkDirtyResource(record->GetResourceID()); @@ -3108,7 +3105,7 @@ void WrappedOpenGL::DebugSnoop(GLenum source, GLenum type, GLuint id, GLenum sev default: msg.severity = MessageSeverity::Info; break; } - if(source == eGL_DEBUG_SOURCE_APPLICATION || type == eGL_DEBUG_TYPE_MARKER) + if(source == eGL_DEBUG_SOURCE_APPLICATION) { msg.category = MessageCategory::Application_Defined; } diff --git a/renderdoc/driver/gl/gl_msaa_array_conv.cpp b/renderdoc/driver/gl/gl_msaa_array_conv.cpp index 874df35aa..0a11ca036 100644 --- a/renderdoc/driver/gl/gl_msaa_array_conv.cpp +++ b/renderdoc/driver/gl/gl_msaa_array_conv.cpp @@ -124,7 +124,7 @@ void WrappedOpenGL::CopyTex2DMSToArray(GLuint &destArray, GLuint srcMS, GLint wi bool failed = false; - if(!failed && !HasExt[ARB_compute_shader]) + if(!HasExt[ARB_compute_shader]) { RDCWARN( "Can't copy multisampled texture to array for serialisation without ARB_compute_shader."); diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 04dfd562e..e5b4b7ea8 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -255,8 +255,7 @@ rdcarray GLReplay::GetTextures() void GLReplay::SetReplayData(GLWindowingData data) { m_ReplayCtx = data; - if(m_pDriver != NULL) - m_pDriver->RegisterReplayContext(m_ReplayCtx, NULL, true, true); + m_pDriver->RegisterReplayContext(m_ReplayCtx, NULL, true, true); m_pDriver->RegisterDebugCallback(); @@ -3340,7 +3339,6 @@ bool GLReplay::IsTextureSupported(const TextureDescription &tex) // don't support 1D/3D block compressed textures if(tex.dimension != 2 && (tex.format.type == ResourceFormatType::BC1 || tex.format.type == ResourceFormatType::BC2 || - tex.format.type == ResourceFormatType::BC1 || tex.format.type == ResourceFormatType::BC2 || tex.format.type == ResourceFormatType::BC3 || tex.format.type == ResourceFormatType::BC4 || tex.format.type == ResourceFormatType::BC5 || tex.format.type == ResourceFormatType::BC6 || tex.format.type == ResourceFormatType::BC7 || tex.format.type == ResourceFormatType::ASTC || diff --git a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp index 6330082a6..23d05029c 100644 --- a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp @@ -212,7 +212,7 @@ bool WrappedOpenGL::Serialise_glBindBuffer(SerialiserType &ser, GLenum target, G // if we're just loading, make sure not to trample state (e.g. element array buffer // binding in a VAO), since this is just a bind-to-create chunk. GLuint prevbuf = 0; - if(IsLoading(m_State) && m_CurEventID == 0 && target != eGL_NONE) + if(IsLoading(m_State) && m_CurEventID == 0) GL.glGetIntegerv(BufferBinding(target), (GLint *)&prevbuf); GL.glBindBuffer(target, buffer.name); @@ -220,7 +220,7 @@ bool WrappedOpenGL::Serialise_glBindBuffer(SerialiserType &ser, GLenum target, G m_Buffers[GetResourceManager()->GetID(buffer)].curType = target; m_Buffers[GetResourceManager()->GetID(buffer)].creationFlags |= MakeBufferCategory(target); - if(IsLoading(m_State) && m_CurEventID == 0 && target != eGL_NONE) + if(IsLoading(m_State) && m_CurEventID == 0) GL.glBindBuffer(target, prevbuf); } diff --git a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp index 1d7792d8c..a0e0077d0 100644 --- a/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_draw_funcs.cpp @@ -2242,7 +2242,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawArrays(SerialiserType &ser, GLenum mode // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the drawcount parameter to however many we want to replay. This only @@ -2407,7 +2407,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElements(SerialiserType &ser, GLenum mo // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only @@ -2577,7 +2577,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsBaseVertex(SerialiserType &ser, // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only @@ -2765,7 +2765,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirect(SerialiserType &ser, GLe // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only @@ -2991,7 +2991,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirect(SerialiserType &ser, G // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only @@ -3217,7 +3217,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawArraysIndirectCount(SerialiserType &ser // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only @@ -3452,7 +3452,7 @@ bool WrappedOpenGL::Serialise_glMultiDrawElementsIndirectCount(SerialiserType &s // then we'll replay up to N but not N+1, so just do nothing - we DON'T want to draw // the first sub-draw in that range. } - else if(m_FirstEventID <= baseEventID && m_LastEventID >= baseEventID) + else if(m_FirstEventID <= baseEventID) { // if we're replaying part-way into a multidraw, we can replay the first part 'easily' // by just reducing the Count parameter to however many we want to replay. This only diff --git a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp index 4f78f7f47..37ff6a9bb 100644 --- a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp @@ -3811,21 +3811,19 @@ void WrappedOpenGL::Common_glCopyTextureImage1DEXT(GLResourceRecord *record, GLe { // add a fake teximage1D chunk to create the texture properly on live (as we won't replay this // copy chunk). - if(record) - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::glTextureImage1DEXT); - Serialise_glTextureImage1DEXT(ser, record->Resource.name, target, level, internalformat, - width, border, GetBaseFormat(internalformat), - GetDataType(internalformat), NULL); - record->AddChunk(scope.Get()); + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::glTextureImage1DEXT); + Serialise_glTextureImage1DEXT(ser, record->Resource.name, target, level, internalformat, width, + border, GetBaseFormat(internalformat), + GetDataType(internalformat), NULL); - // illegal to re-type textures - record->VerifyDataType(target); + record->AddChunk(scope.Get()); - GetResourceManager()->MarkDirtyResource(record->GetResourceID()); - } + // illegal to re-type textures + record->VerifyDataType(target); + + GetResourceManager()->MarkDirtyResource(record->GetResourceID()); } else if(IsActiveCapturing(m_State)) { @@ -3973,21 +3971,18 @@ void WrappedOpenGL::Common_glCopyTextureImage2DEXT(GLResourceRecord *record, GLe { // add a fake teximage1D chunk to create the texture properly on live (as we won't replay this // copy chunk). - if(record) - { - USE_SCRATCH_SERIALISER(); - SCOPED_SERIALISE_CHUNK(GLChunk::glTextureImage2DEXT); - Serialise_glTextureImage2DEXT(ser, record->Resource.name, target, level, internalformat, - width, height, border, GetBaseFormat(internalformat), - GetDataType(internalformat), NULL); + USE_SCRATCH_SERIALISER(); + SCOPED_SERIALISE_CHUNK(GLChunk::glTextureImage2DEXT); + Serialise_glTextureImage2DEXT(ser, record->Resource.name, target, level, internalformat, width, + height, border, GetBaseFormat(internalformat), + GetDataType(internalformat), NULL); - record->AddChunk(scope.Get()); + record->AddChunk(scope.Get()); - // illegal to re-type textures - record->VerifyDataType(target); + // illegal to re-type textures + record->VerifyDataType(target); - GetResourceManager()->MarkDirtyResource(record->GetResourceID()); - } + GetResourceManager()->MarkDirtyResource(record->GetResourceID()); } else if(IsActiveCapturing(m_State)) { diff --git a/renderdoc/driver/ihv/amd/amd_rgp.cpp b/renderdoc/driver/ihv/amd/amd_rgp.cpp index 91aead79c..1ad8361d6 100644 --- a/renderdoc/driver/ihv/amd/amd_rgp.cpp +++ b/renderdoc/driver/ihv/amd/amd_rgp.cpp @@ -35,7 +35,7 @@ uint64_t MakeTagFromMarker(const char *marker) uint64_t ret = 0; - for(int i = 0; i < 7 && marker && marker[i]; i++) + for(int i = 0; i < 7 && marker[i]; i++) ret |= uint64_t(marker[i]) << (i * 8); return ret; diff --git a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp index 41e7ecacc..8788377ae 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_container.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_container.cpp @@ -1083,7 +1083,7 @@ DXBCContainer::DXBCContainer(const void *ByteCode, size_t ByteCodeLength) // pixel shader outputs with registers are always targets if(m_Type == DXBC::ShaderType::Pixel && output && - desc.systemValue == ShaderBuiltin::Undefined && desc.regIndex >= 0 && desc.regIndex <= 16) + desc.systemValue == ShaderBuiltin::Undefined && desc.regIndex <= 16) desc.systemValue = ShaderBuiltin::ColorOutput; // check system value semantics diff --git a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp index 41cd0c53d..289e5c7f0 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_debug.cpp @@ -2006,8 +2006,7 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua ShaderVariable dot = mul(srcOpers[0], srcOpers[1], optype); float sum = dot.value.f.x; - if(op.operation >= OPCODE_DP2) - sum += dot.value.f.y; + sum += dot.value.f.y; if(op.operation >= OPCODE_DP3) sum += dot.value.f.z; if(op.operation >= OPCODE_DP4) @@ -2886,10 +2885,10 @@ State State::GetNext(GlobalState &global, DebugAPIWrapper *apiWrapper, State qua } // not verified below since by definition the operations that expect usrc1 will have it - uint32_t *usrc0 = src0 ? src0->value.uv : NULL; - uint32_t *usrc1 = src1 ? src1->value.uv : NULL; + uint32_t *usrc0 = src0->value.uv; + uint32_t *usrc1 = src1->value.uv; - int32_t *isrc0 = src0 ? src0->value.iv : NULL; + int32_t *isrc0 = src0->value.iv; switch(op.operation) { diff --git a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp index 91efde9e0..77193b65d 100644 --- a/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp +++ b/renderdoc/driver/shaders/dxbc/dxbc_disassemble.cpp @@ -541,9 +541,8 @@ void Program::MakeDisassemblyString() m_DebugInfo->GetLineInfo(debugInst, m_Instructions[i].offset, lineInfo); - if(lineInfo.fileIndex >= 0 && lineInfo.lineStart >= 0 && - (lineInfo.fileIndex != prevLineInfo.fileIndex || - lineInfo.lineStart != prevLineInfo.lineStart)) + if(lineInfo.fileIndex >= 0 && (lineInfo.fileIndex != prevLineInfo.fileIndex || + lineInfo.lineStart != prevLineInfo.lineStart)) { rdcstr line = ""; if(lineInfo.fileIndex >= (int32_t)fileLines.size()) @@ -1163,7 +1162,7 @@ rdcstr Operand::toString(const DXBC::Reflection *reflection, ToString flags) con { for(size_t i = 0; i < indices.size(); i++) { - if(i == 0 && (type == TYPE_CONSTANT_BUFFER || type == TYPE_INDEXABLE_TEMP)) + if(i == 0 && type == TYPE_INDEXABLE_TEMP) { str += indices[i].str; continue; diff --git a/renderdoc/driver/shaders/dxil/llvm_bitreader.h b/renderdoc/driver/shaders/dxil/llvm_bitreader.h index fc66a1b39..1735bf9fa 100644 --- a/renderdoc/driver/shaders/dxil/llvm_bitreader.h +++ b/renderdoc/driver/shaders/dxil/llvm_bitreader.h @@ -55,11 +55,11 @@ public: byte c = 0; ReadBits(6, &c); - if(c >= 0 && c <= 25) + if(c <= 25) return char('a' + c); - else if(c >= 26 && c <= 51) + else if(c <= 51) return char('A' + c - 26); - else if(c >= 52 && c <= 61) + else if(c <= 61) return char('0' + c - 52); else if(c == 62) return '.'; diff --git a/renderdoc/driver/vulkan/vk_core.cpp b/renderdoc/driver/vulkan/vk_core.cpp index 57821a80b..5159471ff 100644 --- a/renderdoc/driver/vulkan/vk_core.cpp +++ b/renderdoc/driver/vulkan/vk_core.cpp @@ -1600,7 +1600,7 @@ void WrappedVulkan::StartFrameCapture(void *dev, void *wnd) m_SubmitCounter = 0; FrameDescription frame; - frame.frameNumber = m_AppControlledCapture ? ~0U : m_FrameCounter; + frame.frameNumber = ~0U; frame.captureTime = Timing::GetUnixTimestamp(); RDCEraseEl(frame.stats); m_CapturedFrames.push_back(frame); diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index 9ded877d4..573d5daa9 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -1531,7 +1531,7 @@ void VulkanDebugManager::GetBufferData(ResourceId buff, uint64_t offset, uint64_ len = bufsize - offset; } - if(len > 0 && VkDeviceSize(offset + len) > bufsize) + if(VkDeviceSize(offset + len) > bufsize) { RDCWARN("Attempting to read off the end of the buffer (%llu %llu). Will be clamped (%llu)", offset, len, bufsize); diff --git a/renderdoc/driver/vulkan/vk_serialise.cpp b/renderdoc/driver/vulkan/vk_serialise.cpp index 6ef7c3e66..7d5edb42c 100644 --- a/renderdoc/driver/vulkan/vk_serialise.cpp +++ b/renderdoc/driver/vulkan/vk_serialise.cpp @@ -1253,8 +1253,7 @@ static void SerialiseNext(SerialiserType &ser, VkStructureType &sType, const voi case VK_STRUCTURE_TYPE_MAX_ENUM: break; } - if(!handled) - RDCERR("Invalid pNext structure sType: %u", next->sType); + RDCERR("Invalid pNext structure sType: %u", next->sType); // walk to the next item if we didn't serialise the current one next = (VkBaseInStructure *)next->pNext; diff --git a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp index b774477f1..8f836e8bc 100644 --- a/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp +++ b/renderdoc/driver/vulkan/wrappers/vk_device_funcs.cpp @@ -521,7 +521,7 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo while(report) { - if(report && report->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT) + if(report->sType == VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT) report->pfnCallback(VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT, 0, 1, 1, "RDOC", "RenderDoc does not support a requested instance extension.", @@ -543,7 +543,7 @@ VkResult WrappedVulkan::vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo while(messenger) { - if(messenger && messenger->sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) + if(messenger->sType == VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT) messenger->pfnUserCallback(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, VK_DEBUG_UTILS_MESSAGE_TYPE_VALIDATION_BIT_EXT, &messengerData, messenger->pUserData); diff --git a/renderdoc/os/win32/win32_callstack.cpp b/renderdoc/os/win32/win32_callstack.cpp index 2a5915971..05c2b0663 100644 --- a/renderdoc/os/win32/win32_callstack.cpp +++ b/renderdoc/os/win32/win32_callstack.cpp @@ -633,7 +633,7 @@ BOOL CALLBACK EnumModule(PCWSTR ModuleName, DWORD64 BaseOfDll, PVOID UserContext WCHAR *pdb = ModInfo.CVData; - if(pdb == NULL || pdb[0] == 0) + if(pdb[0] == 0) pdb = ModInfo.ImageName; chunk.imageNameLen = wcslen(pdb) + 1; // include null terminator diff --git a/renderdoc/os/win32/win32_hook.cpp b/renderdoc/os/win32/win32_hook.cpp index f8c243bd6..f52533b3f 100644 --- a/renderdoc/os/win32/win32_hook.cpp +++ b/renderdoc/os/win32/win32_hook.cpp @@ -338,7 +338,7 @@ struct CachedHookData if(!_stricmp(it->first.c_str(), dllName)) hookset = &it->second; - if(hookset && importDesc->OriginalFirstThunk > 0 && importDesc->FirstThunk > 0) + if(hookset && importDesc->OriginalFirstThunk > 0) { IMAGE_THUNK_DATA *origFirst = (IMAGE_THUNK_DATA *)(baseAddress + importDesc->OriginalFirstThunk); diff --git a/renderdoc/replay/replay_output.cpp b/renderdoc/replay/replay_output.cpp index 007c56076..619539c72 100644 --- a/renderdoc/replay/replay_output.cpp +++ b/renderdoc/replay/replay_output.cpp @@ -768,7 +768,7 @@ void ReplayOutput::DisplayMesh() return; } - if(draw && m_OverlayDirty) + if(m_OverlayDirty) { m_pDevice->ReplayLog(m_EventID, eReplay_WithoutDraw); RefreshOverlay(); diff --git a/renderdoc/strings/utf8printf.cpp b/renderdoc/strings/utf8printf.cpp index 254841d22..3a820c087 100644 --- a/renderdoc/strings/utf8printf.cpp +++ b/renderdoc/strings/utf8printf.cpp @@ -496,7 +496,7 @@ void PrintFloat0(bool e, bool f, FormatterParams formatter, char prepend, char * { addchar(output, actualsize, end, '0'); - if(!e && !f && (formatter.Flags & AlwaysDecimal)) + if(formatter.Flags & AlwaysDecimal) { addchar(output, actualsize, end, '.'); addchar(output, actualsize, end, '0'); @@ -812,7 +812,7 @@ void PrintFloat(double argd, FormatterParams &formatter, bool e, bool f, bool g, else if(expon > ndigits) { numwidth += (expon + 1 - ndigits); // 0s between digits and decimal place - if((!g || (formatter.Flags & AlternateForm))) + if(!g || (formatter.Flags & AlternateForm)) numwidth++; // . if(padtrailing0s > 0 && (!g || (formatter.Flags & AlternateForm))) @@ -902,7 +902,7 @@ void PrintFloat(double argd, FormatterParams &formatter, bool e, bool f, bool g, if(padtrailing0s > 0) addchars(output, actualsize, end, size_t(padtrailing0s), '0'); } - else if(g && (formatter.Flags & AlwaysDecimal)) + else if(formatter.Flags & AlwaysDecimal) { addchar(output, actualsize, end, '.'); addchar(output, actualsize, end, '0'); @@ -911,7 +911,7 @@ void PrintFloat(double argd, FormatterParams &formatter, bool e, bool f, bool g, else if(expon > ndigits) { addchars(output, actualsize, end, size_t(expon + 1 - ndigits), '0'); - if((!g || (formatter.Flags & AlternateForm))) + if(!g || (formatter.Flags & AlternateForm)) addchar(output, actualsize, end, '.'); if(padtrailing0s > 0 && (!g || (formatter.Flags & AlternateForm)))