Reduce memory usage by adjusting default memory allocs for many MVKVectorInline uses.
MVKRenderPass use emplace_back() instead of push_back() when populating _subpasses & _attachments vectors. Add mvkLogSizeOf(T) development debugging function.
This commit is contained in:
parent
2ba65c50a3
commit
5c87700732
@ -189,6 +189,9 @@ do { \
|
||||
# define MVK_DEBUGGER() { kill( getpid(), SIGINT ) ; }
|
||||
#endif
|
||||
|
||||
// Log the size of a type, struct, or class
|
||||
#define MVKLogSizeOf(T) printf("sizeof(%s): %lu.\n", #T, sizeof(T))
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ Released TBD
|
||||
- Allow `MVK_CONFIG_SYNCHRONOUS_QUEUE_SUBMITS` build setting to be overridden.
|
||||
- Fix memory leaks of system classes during `VkInstance` and `VkQueue` creation.
|
||||
- Fix memory leaks when compiling shaders and pipelines without default OS autorelease pool.
|
||||
- Reduce memory usage by adjusting default memory allocs for many MVKVectorInline uses.
|
||||
|
||||
|
||||
|
||||
|
@ -117,7 +117,7 @@ protected:
|
||||
|
||||
MVKDescriptorSetLayout* _layout;
|
||||
VkDescriptorSetLayoutBinding _info;
|
||||
MVKVectorInline<MVKSampler*, 16> _immutableSamplers;
|
||||
MVKVectorDefault<MVKSampler*> _immutableSamplers;
|
||||
MVKShaderResourceBinding _mtlResourceIndexOffsets;
|
||||
bool _applyToStage[kMVKShaderStageMax];
|
||||
};
|
||||
@ -181,7 +181,7 @@ protected:
|
||||
void addDescriptorPool(MVKDescriptorPool* mvkDescPool) { _descriptorPools.insert(mvkDescPool); }
|
||||
void removeDescriptorPool(MVKDescriptorPool* mvkDescPool) { _descriptorPools.erase(mvkDescPool); }
|
||||
|
||||
MVKVectorInline<MVKDescriptorSetLayoutBinding, 8> _bindings;
|
||||
MVKVectorInline<MVKDescriptorSetLayoutBinding, 1> _bindings;
|
||||
std::unordered_map<uint32_t, uint32_t> _bindingToIndex;
|
||||
MVKShaderResourceBinding _mtlResourceCounts;
|
||||
std::unordered_set<MVKDescriptorPool*> _descriptorPools;
|
||||
@ -271,13 +271,13 @@ protected:
|
||||
|
||||
MVKDescriptorSet* _pDescSet;
|
||||
MVKDescriptorSetLayoutBinding* _pBindingLayout;
|
||||
MVKVectorInline<VkDescriptorImageInfo, 1> _imageBindings;
|
||||
MVKVectorInline<VkDescriptorBufferInfo, 1> _bufferBindings;
|
||||
MVKVectorInline<VkBufferView, 1> _texelBufferBindings;
|
||||
MVKVectorInline<id<MTLBuffer>, 1> _mtlBuffers;
|
||||
MVKVectorInline<NSUInteger, 1> _mtlBufferOffsets;
|
||||
MVKVectorInline<id<MTLTexture>, 1> _mtlTextures;
|
||||
MVKVectorInline<id<MTLSamplerState>, 1> _mtlSamplers;
|
||||
MVKVectorDefault<VkDescriptorImageInfo> _imageBindings;
|
||||
MVKVectorDefault<VkDescriptorBufferInfo> _bufferBindings;
|
||||
MVKVectorDefault<VkBufferView> _texelBufferBindings;
|
||||
MVKVectorDefault<id<MTLBuffer>> _mtlBuffers;
|
||||
MVKVectorDefault<NSUInteger> _mtlBufferOffsets;
|
||||
MVKVectorDefault<id<MTLTexture>> _mtlTextures;
|
||||
MVKVectorDefault<id<MTLSamplerState>> _mtlSamplers;
|
||||
bool _hasDynamicSamplers;
|
||||
};
|
||||
|
||||
@ -323,7 +323,7 @@ protected:
|
||||
MVKDescriptorBinding* getBinding(uint32_t binding);
|
||||
|
||||
MVKDescriptorSetLayout* _pLayout = nullptr;
|
||||
MVKVectorInline<MVKDescriptorBinding, 8> _bindings;
|
||||
MVKVectorInline<MVKDescriptorBinding, 1> _bindings;
|
||||
};
|
||||
|
||||
|
||||
@ -407,7 +407,7 @@ protected:
|
||||
void propogateDebugName() override {}
|
||||
|
||||
VkDescriptorUpdateTemplateTypeKHR _type;
|
||||
MVKVectorInline<VkDescriptorUpdateTemplateEntryKHR, 4> _entries;
|
||||
MVKVectorInline<VkDescriptorUpdateTemplateEntryKHR, 1> _entries;
|
||||
};
|
||||
|
||||
#pragma mark -
|
||||
|
@ -56,6 +56,6 @@ protected:
|
||||
|
||||
VkExtent2D _extent;
|
||||
uint32_t _layerCount;
|
||||
MVKVectorInline<MVKImageView*, 8> _attachments;
|
||||
MVKVectorInline<MVKImageView*, 4> _attachments;
|
||||
};
|
||||
|
||||
|
@ -257,7 +257,7 @@ protected:
|
||||
VkPipelineStageFlags dstStageMask,
|
||||
VkImageMemoryBarrier* pImageMemoryBarrier);
|
||||
|
||||
MVKVectorInline<MVKImageSubresource, 4> _subresources;
|
||||
MVKVectorInline<MVKImageSubresource, 1> _subresources;
|
||||
std::unordered_map<NSUInteger, id<MTLTexture>> _mtlTextureViews;
|
||||
VkExtent3D _extent;
|
||||
uint32_t _mipLevels;
|
||||
|
@ -187,9 +187,9 @@ protected:
|
||||
|
||||
MVKConfiguration _mvkConfig;
|
||||
VkApplicationInfo _appInfo;
|
||||
MVKVectorInline<MVKPhysicalDevice*, 4> _physicalDevices;
|
||||
MVKVectorInline<MVKDebugReportCallback*, 4> _debugReportCallbacks;
|
||||
MVKVectorInline<MVKDebugUtilsMessenger*, 4> _debugUtilMessengers;
|
||||
MVKVectorInline<MVKPhysicalDevice*, 1> _physicalDevices;
|
||||
MVKVectorDefault<MVKDebugReportCallback*> _debugReportCallbacks;
|
||||
MVKVectorDefault<MVKDebugUtilsMessenger*> _debugUtilMessengers;
|
||||
std::unordered_map<std::string, MVKEntryPoint> _entryPoints;
|
||||
std::mutex _dcbLock;
|
||||
bool _hasDebugReportCallbacks;
|
||||
|
@ -107,9 +107,9 @@ public:
|
||||
protected:
|
||||
void propogateDebugName() override {}
|
||||
|
||||
MVKVectorInline<MVKDescriptorSetLayout*, 8> _descriptorSetLayouts;
|
||||
MVKVectorInline<MVKShaderResourceBinding, 8> _dslMTLResourceIndexOffsets;
|
||||
MVKVectorInline<VkPushConstantRange, 8> _pushConstants;
|
||||
MVKVectorInline<MVKDescriptorSetLayout*, 1> _descriptorSetLayouts;
|
||||
MVKVectorInline<MVKShaderResourceBinding, 1> _dslMTLResourceIndexOffsets;
|
||||
MVKVectorDefault<VkPushConstantRange> _pushConstants;
|
||||
MVKShaderResourceBinding _pushConstantsMTLResourceIndexes;
|
||||
MVKShaderImplicitRezBinding _swizzleBufferIndex;
|
||||
MVKShaderImplicitRezBinding _bufferSizeBufferIndex;
|
||||
|
@ -206,8 +206,8 @@ protected:
|
||||
void commitActiveMTLCommandBuffer(bool signalCompletion = false);
|
||||
void finish();
|
||||
|
||||
MVKVectorInline<MVKCommandBuffer*, 16> _cmdBuffers;
|
||||
MVKVectorInline<MVKSemaphore*, 16> _signalSemaphores;
|
||||
MVKVectorInline<MVKCommandBuffer*, 32> _cmdBuffers;
|
||||
MVKVectorInline<MVKSemaphore*, 8> _signalSemaphores;
|
||||
MVKFence* _fence;
|
||||
id<MTLCommandBuffer> _activeMTLCommandBuffer;
|
||||
};
|
||||
|
@ -174,8 +174,8 @@ protected:
|
||||
void propogateDebugName() override {}
|
||||
|
||||
MVKVectorInline<MVKRenderPassAttachment, kMVKDefaultAttachmentCount> _attachments;
|
||||
MVKVectorInline<MVKRenderSubpass, 4> _subpasses;
|
||||
MVKVectorInline<VkSubpassDependency, 4 * 2> _subpassDependencies;
|
||||
MVKVectorInline<MVKRenderSubpass, 1> _subpasses;
|
||||
MVKVectorDefault<VkSubpassDependency> _subpassDependencies;
|
||||
|
||||
};
|
||||
|
||||
|
@ -348,7 +348,7 @@ MVKRenderPass::MVKRenderPass(MVKDevice* device,
|
||||
// Add subpasses and dependencies first
|
||||
_subpasses.reserve(pCreateInfo->subpassCount);
|
||||
for (uint32_t i = 0; i < pCreateInfo->subpassCount; i++) {
|
||||
_subpasses.push_back(MVKRenderSubpass(this, &pCreateInfo->pSubpasses[i]));
|
||||
_subpasses.emplace_back(this, &pCreateInfo->pSubpasses[i]);
|
||||
}
|
||||
_subpassDependencies.reserve(pCreateInfo->dependencyCount);
|
||||
for (uint32_t i = 0; i < pCreateInfo->dependencyCount; i++) {
|
||||
@ -358,7 +358,7 @@ MVKRenderPass::MVKRenderPass(MVKDevice* device,
|
||||
// Add attachments after subpasses, so each attachment can link to subpasses
|
||||
_attachments.reserve(pCreateInfo->attachmentCount);
|
||||
for (uint32_t i = 0; i < pCreateInfo->attachmentCount; i++) {
|
||||
_attachments.push_back(MVKRenderPassAttachment(this, &pCreateInfo->pAttachments[i]));
|
||||
_attachments.emplace_back(this, &pCreateInfo->pAttachments[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ protected:
|
||||
void merge(MVKShaderLibraryCache* other);
|
||||
|
||||
MVKVulkanAPIDeviceObject* _owner;
|
||||
MVKVectorInline<std::pair<SPIRVToMSLConversionConfiguration, MVKShaderLibrary*>, 4> _shaderLibraries;
|
||||
MVKVectorInline<std::pair<SPIRVToMSLConversionConfiguration, MVKShaderLibrary*>, 1> _shaderLibraries;
|
||||
};
|
||||
|
||||
|
||||
|
@ -112,7 +112,7 @@ protected:
|
||||
|
||||
struct Availability {
|
||||
MVKSwapchainImageAvailability status;
|
||||
MVKVectorInline<MVKSwapchainSignaler, 4> signalers;
|
||||
MVKVectorInline<MVKSwapchainSignaler, 1> signalers;
|
||||
MVKSwapchainSignaler preSignaled;
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user