Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(887)

Unified Diff: src/gpu/vk/GrVkCommandBuffer.h

Issue 2338963004: Use STDArray to for tracked resources in vulkan command buffer (Closed)
Patch Set: review fixes Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/gpu/vk/GrVkCommandBuffer.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/vk/GrVkCommandBuffer.h
diff --git a/src/gpu/vk/GrVkCommandBuffer.h b/src/gpu/vk/GrVkCommandBuffer.h
index 67b09c7a8272c72175ce92c79f3c1d9d4df8677f..e593b2d542d7da2cae733279136b3abd64bf172c 100644
--- a/src/gpu/vk/GrVkCommandBuffer.h
+++ b/src/gpu/vk/GrVkCommandBuffer.h
@@ -114,31 +114,33 @@ public:
// command buffer finishes execution
void addResource(const GrVkResource* resource) {
resource->ref();
- fTrackedResources.push_back(resource);
+ fTrackedResources.append(1, &resource);
}
// Add ref-counted resource that will be tracked and released when this command buffer finishes
// execution. When it is released, it will signal that the resource can be recycled for reuse.
void addRecycledResource(const GrVkRecycledResource* resource) {
resource->ref();
- fTrackedRecycledResources.push_back(resource);
+ fTrackedRecycledResources.append(1, &resource);
}
void reset(GrVkGpu* gpu);
protected:
GrVkCommandBuffer(VkCommandBuffer cmdBuffer, const GrVkRenderPass* rp = VK_NULL_HANDLE)
- : fTrackedResources(kInitialTrackedResourcesCount)
- , fTrackedRecycledResources(kInitialTrackedResourcesCount)
- , fIsActive(false)
+ : fIsActive(false)
, fActiveRenderPass(rp)
, fCmdBuffer(cmdBuffer)
, fBoundVertexBufferIsValid(false)
- , fBoundIndexBufferIsValid(false) {
+ , fBoundIndexBufferIsValid(false)
+ , fNumResets(0) {
+ fTrackedResources.setReserve(kInitialTrackedResourcesCount);
+ fTrackedRecycledResources.setReserve(kInitialTrackedResourcesCount);
this->invalidateState();
}
- SkTArray<const GrVkResource*, true> fTrackedResources;
- SkTArray<const GrVkRecycledResource*, true> fTrackedRecycledResources;
+
+ SkTDArray<const GrVkResource*> fTrackedResources;
+ SkTDArray<const GrVkRecycledResource*> fTrackedRecycledResources;
// Tracks whether we are in the middle of a command buffer begin/end calls and thus can add
// new commands to the buffer;
@@ -166,6 +168,13 @@ private:
VkBuffer fBoundIndexBuffer;
bool fBoundIndexBufferIsValid;
+ // When resetting the command buffer, we remove the tracked resources from their arrays, and
+ // we prefer to not free all the memory every time so usually we just rewind. However, to avoid
+ // all arrays growing to the max size, after so many resets we'll do a full reset of the tracked
+ // resource arrays.
+ static const int kNumRewindResetsBeforeFullReset = 8;
+ int fNumResets;
+
// Cached values used for dynamic state updates
VkViewport fCachedViewport;
VkRect2D fCachedScissor;
« no previous file with comments | « no previous file | src/gpu/vk/GrVkCommandBuffer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698