Mark other makeVertexWriter checks as unlikely/likely
We usually don't run out of memory, so this can perhaps improve
branching behavior.
Change-Id: Ia11cbd73fa4d4c6aa9caa5cf4265dea931923546
Bug: b/467843949
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1123217
Reviewed-by: Robert Phillips <robertphillips@google.com>
diff --git a/src/gpu/ganesh/GrVertexChunkArray.cpp b/src/gpu/ganesh/GrVertexChunkArray.cpp
index b920c81..337e394 100644
--- a/src/gpu/ganesh/GrVertexChunkArray.cpp
+++ b/src/gpu/ganesh/GrVertexChunkArray.cpp
@@ -30,7 +30,7 @@
minAllocCount, &chunk->fBuffer,
&chunk->fBase,
&fCurrChunkVertexCapacity);
- if (!fCurrChunkVertexWriter || !chunk->fBuffer || fCurrChunkVertexCapacity < minCount) {
+ if (!fCurrChunkVertexWriter || !chunk->fBuffer || fCurrChunkVertexCapacity < minCount) SK_UNLIKELY {
SkDebugf("WARNING: Failed to allocate vertex buffer for GrVertexChunk.\n");
fChunks->pop_back();
SkASSERT(fCurrChunkVertexCount == 0);
diff --git a/src/gpu/ganesh/ops/AAConvexPathRenderer.cpp b/src/gpu/ganesh/ops/AAConvexPathRenderer.cpp
index 541a37f..460ea28 100644
--- a/src/gpu/ganesh/ops/AAConvexPathRenderer.cpp
+++ b/src/gpu/ganesh/ops/AAConvexPathRenderer.cpp
@@ -859,7 +859,7 @@
&vertexBuffer,
&firstVertex);
- if (!verts) {
+ if (!verts) SK_UNLIKELY {
SkDebugf("Could not allocate vertices\n");
return;
}
@@ -868,7 +868,7 @@
int firstIndex;
uint16_t *idxs = target->makeIndexSpace(indexCount, &indexBuffer, &firstIndex);
- if (!idxs) {
+ if (!idxs) SK_UNLIKELY {
SkDebugf("Could not allocate indices\n");
return;
}
diff --git a/src/gpu/ganesh/ops/DrawAtlasPathOp.cpp b/src/gpu/ganesh/ops/DrawAtlasPathOp.cpp
index 99fcbe6..a58d6eb 100644
--- a/src/gpu/ganesh/ops/DrawAtlasPathOp.cpp
+++ b/src/gpu/ganesh/ops/DrawAtlasPathOp.cpp
@@ -225,7 +225,7 @@
if (VertexWriter instanceWriter = flushState->makeVertexWriter(
fProgram->geomProc().instanceStride(), fInstanceCount, &fInstanceBuffer,
- &fBaseInstance)) {
+ &fBaseInstance)) SK_LIKELY {
for (const Instance* i = fHeadInstance; i; i = i->fNext) {
instanceWriter << SkRect::Make(i->fFillBounds)
<< VertexWriter::If(fUsesLocalCoords,
diff --git a/src/gpu/ganesh/ops/DrawMeshOp.cpp b/src/gpu/ganesh/ops/DrawMeshOp.cpp
index 6a2a9ed..4e8dd71 100644
--- a/src/gpu/ganesh/ops/DrawMeshOp.cpp
+++ b/src/gpu/ganesh/ops/DrawMeshOp.cpp
@@ -1127,7 +1127,7 @@
fVertexCount,
&vertexBuffer,
&firstVertex);
- if (!verts) {
+ if (!verts) SK_UNLIKELY {
SkDebugf("Could not allocate vertices.\n");
return;
}
@@ -1149,7 +1149,7 @@
if (fIndexCount && !indexBuffer) {
uint16_t* indices = nullptr;
indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex);
- if (!indices) {
+ if (!indices) SK_UNLIKELY {
SkDebugf("Could not allocate indices.\n");
return;
}
diff --git a/src/gpu/ganesh/ops/FillRRectOp.cpp b/src/gpu/ganesh/ops/FillRRectOp.cpp
index 8897cda..f66cc17 100644
--- a/src/gpu/ganesh/ops/FillRRectOp.cpp
+++ b/src/gpu/ganesh/ops/FillRRectOp.cpp
@@ -645,7 +645,7 @@
size_t instanceStride = fProgramInfo->geomProc().instanceStride();
if (VertexWriter instanceWriter = target->makeVertexWriter(instanceStride, fInstanceCount,
- &fInstanceBuffer, &fBaseInstance)) {
+ &fInstanceBuffer, &fBaseInstance)) SK_LIKELY {
SkDEBUGCODE(auto end = instanceWriter.mark(instanceStride * fInstanceCount));
for (Instance* i = fHeadInstance; i; i = i->fNext) {
auto [l, t, r, b] = i->fRRect.rect();
diff --git a/src/gpu/ganesh/ops/GrOvalOpFactory.cpp b/src/gpu/ganesh/ops/GrOvalOpFactory.cpp
index 5d2db48..462ec9c 100644
--- a/src/gpu/ganesh/ops/GrOvalOpFactory.cpp
+++ b/src/gpu/ganesh/ops/GrOvalOpFactory.cpp
@@ -1333,7 +1333,7 @@
int firstVertex;
VertexWriter vertices = target->makeVertexWriter(fProgramInfo->geomProc().vertexStride(),
fVertCount, &vertexBuffer, &firstVertex);
- if (!vertices) {
+ if (!vertices) SK_UNLIKELY {
SkDebugf("Could not allocate vertices\n");
return;
}
@@ -1341,7 +1341,7 @@
sk_sp<const GrBuffer> indexBuffer = nullptr;
int firstIndex = 0;
uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex);
- if (!indices) {
+ if (!indices) SK_UNLIKELY {
SkDebugf("Could not allocate indices\n");
return;
}
@@ -1705,7 +1705,7 @@
int firstVertex;
VertexWriter vertices = target->makeVertexWriter(fProgramInfo->geomProc().vertexStride(),
fVertCount, &vertexBuffer, &firstVertex);
- if (!vertices) {
+ if (!vertices) SK_UNLIKELY {
SkDebugf("Could not allocate vertices\n");
return;
}
@@ -1713,7 +1713,7 @@
sk_sp<const GrBuffer> indexBuffer;
int firstIndex = 0;
uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex);
- if (!indices) {
+ if (!indices) SK_UNLIKELY {
SkDebugf("Could not allocate indices\n");
return;
}
@@ -2735,7 +2735,7 @@
VertexWriter verts = target->makeVertexWriter(fProgramInfo->geomProc().vertexStride(),
fVertCount, &vertexBuffer, &firstVertex);
- if (!verts) {
+ if (!verts) SK_UNLIKELY {
SkDebugf("Could not allocate vertices\n");
return;
}
@@ -2743,7 +2743,7 @@
sk_sp<const GrBuffer> indexBuffer;
int firstIndex = 0;
uint16_t* indices = target->makeIndexSpace(fIndexCount, &indexBuffer, &firstIndex);
- if (!indices) {
+ if (!indices) SK_UNLIKELY {
SkDebugf("Could not allocate indices\n");
return;
}
diff --git a/src/gpu/ganesh/ops/SmallPathRenderer.cpp b/src/gpu/ganesh/ops/SmallPathRenderer.cpp
index 4b76480..345f4e7 100644
--- a/src/gpu/ganesh/ops/SmallPathRenderer.cpp
+++ b/src/gpu/ganesh/ops/SmallPathRenderer.cpp
@@ -264,7 +264,7 @@
&flushInfo.fVertexBuffer, &flushInfo.fVertexOffset);
flushInfo.fIndexBuffer = target->resourceProvider()->refNonAAQuadIndexBuffer();
- if (!vertices || !flushInfo.fIndexBuffer) {
+ if (!vertices || !flushInfo.fIndexBuffer) SK_UNLIKELY {
SkDebugf("Could not allocate vertices\n");
return;
}