Fix possible division by zero in edge cases

* Reported by Coverity Scan
This commit is contained in:
baldurk
2017-11-22 12:05:59 +00:00
parent 7ec2c79e86
commit 25ea14c965
4 changed files with 14 additions and 5 deletions
+1 -1
View File
@@ -364,7 +364,7 @@ void RDHeaderView::cacheSectionMinSizes()
void RDHeaderView::resizeSectionsWithHints()
{
if(m_sectionMinSizes.count() == 0)
if(m_sectionMinSizes.count() == 0 || m_sectionStretchHintTotal <= 0)
return;
QVector<int> sizes = m_sectionMinSizes;
+5 -2
View File
@@ -758,6 +758,10 @@ void StatisticsViewer::GenerateReport()
largeTexH /= largeTexCount;
}
float drawRatio = 0.0f;
if(drawCount + dispatchCount > 0)
drawRatio = (float)numAPIcalls / (float)(drawCount + dispatchCount);
const FrameDescription &frameInfo = m_Ctx.FrameInfo();
float compressedMB = (float)frameInfo.compressedFileSize / (1024.0f * 1024.0f);
@@ -776,8 +780,7 @@ void StatisticsViewer::GenerateReport()
.arg(persistentMB, 2, 'f', 2)
.arg(initDataMB, 2, 'f', 2);
QString drawList = tr("Draw calls: %1\nDispatch calls: %2\n").arg(drawCount).arg(dispatchCount);
QString ratio = tr("API:Draw/Dispatch call ratio: %1\n\n")
.arg((float)numAPIcalls / (float)(drawCount + dispatchCount));
QString ratio = tr("API:Draw/Dispatch call ratio: %1\n\n").arg(drawRatio);
QString textures = tr("%1 Textures - %2 MB (%3 MB over 32x32), %4 RTs - %5 MB.\n"
"Avg. tex dimension: %6x%7 (%8x%9 over 32x32)\n")
.arg(numTextures)
+6
View File
@@ -3921,6 +3921,12 @@ void D3D12DebugManager::InitPostVSBuffers(uint32_t eventID)
sodecls.push_back(decl);
}
if(stride == 0)
{
RDCERR("Didn't get valid stride! Setting to 4 bytes");
stride = 4;
}
// shift position attribute up to first, keeping order otherwise
// the same
if(posidx > 0)
@@ -165,7 +165,7 @@ void WrappedVulkan::vkGetImageMemoryRequirements(VkDevice device, VkImage image,
// allow for this. The variability isn't quite clear, but for now we assume aligning size to
// alignment * 4 should be sufficient (adding on a fixed padding won't help the problem as it
// won't remove the variability, nor will adding then aligning for the same reason).
if(GetDriverVersion().IsAMD())
if(GetDriverVersion().IsAMD() && pMemoryRequirements->size > 0)
{
VkMemoryRequirements &memreq = *pMemoryRequirements;
@@ -247,7 +247,7 @@ void WrappedVulkan::vkGetImageMemoryRequirements2KHR(VkDevice device,
// allow for this. The variability isn't quite clear, but for now we assume aligning size to
// alignment * 4 should be sufficient (adding on a fixed padding won't help the problem as it
// won't remove the variability, nor will adding then aligning for the same reason).
if(GetDriverVersion().IsAMD())
if(GetDriverVersion().IsAMD() && pMemoryRequirements->memoryRequirements.size > 0)
{
VkMemoryRequirements &memreq = pMemoryRequirements->memoryRequirements;