Reduce heap allocations during rendering
This commit is contained in:
parent
d4506cc41e
commit
d87b71887e
@ -129,7 +129,7 @@ private:
|
||||
MVKPipelineLayout* _pipelineLayout;
|
||||
VkShaderStageFlags _stageFlags;
|
||||
uint32_t _offset;
|
||||
MVKVector<char> _pushConstants;
|
||||
MVKVector128<char> _pushConstants;
|
||||
};
|
||||
|
||||
|
||||
@ -157,7 +157,7 @@ private:
|
||||
|
||||
VkPipelineBindPoint _pipelineBindPoint;
|
||||
MVKPipelineLayout* _pipelineLayout;
|
||||
std::vector<VkWriteDescriptorSet> _descriptorWrites;
|
||||
MVKVector<VkWriteDescriptorSet> _descriptorWrites;
|
||||
uint32_t _set;
|
||||
};
|
||||
|
||||
|
@ -189,7 +189,7 @@ class MVKPushConstantsCommandEncoderState : public MVKCommandEncoderState {
|
||||
public:
|
||||
|
||||
/** Sets the specified push constants. */
|
||||
void setPushConstants(uint32_t offset, MVKVector<char>& pushConstants);
|
||||
void setPushConstants(uint32_t offset, MVKVector128<char>& pushConstants);
|
||||
|
||||
/** Sets the index of the Metal buffer used to hold the push constants. */
|
||||
void setMTLBufferIndex(uint32_t mtlBufferIndex);
|
||||
@ -203,7 +203,7 @@ protected:
|
||||
void encodeImpl() override;
|
||||
void resetImpl() override;
|
||||
|
||||
MVKVector<char> _pushConstants;
|
||||
MVKVector128<char> _pushConstants;
|
||||
VkShaderStageFlagBits _shaderStage;
|
||||
uint32_t _mtlBufferIndex = 0;
|
||||
};
|
||||
|
@ -136,7 +136,7 @@ void MVKScissorCommandEncoderState::resetImpl() {
|
||||
#pragma mark -
|
||||
#pragma mark MVKPushConstantsCommandEncoderState
|
||||
|
||||
void MVKPushConstantsCommandEncoderState:: setPushConstants(uint32_t offset, MVKVector<char>& pushConstants) {
|
||||
void MVKPushConstantsCommandEncoderState:: setPushConstants(uint32_t offset, MVKVector128<char>& pushConstants) {
|
||||
uint32_t pcCnt = (uint32_t)pushConstants.size();
|
||||
mvkEnsureSize(_pushConstants, offset + pcCnt);
|
||||
copy(pushConstants.begin(), pushConstants.end(), _pushConstants.begin() + offset);
|
||||
|
@ -138,7 +138,7 @@ public:
|
||||
|
||||
/** Encodes this descriptor set layout and the specified descriptor updates on the specified command encoder immediately. */
|
||||
void pushDescriptorSet(MVKCommandEncoder* cmdEncoder,
|
||||
std::vector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKVector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKShaderResourceBinding& dslMTLRezIdxOffsets);
|
||||
|
||||
|
||||
|
@ -542,7 +542,7 @@ static const void* getWriteParameters(VkDescriptorType type, const VkDescriptorI
|
||||
}
|
||||
|
||||
void MVKDescriptorSetLayout::pushDescriptorSet(MVKCommandEncoder* cmdEncoder,
|
||||
vector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKVector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKShaderResourceBinding& dslMTLRezIdxOffsets) {
|
||||
|
||||
if (!_isPushDescriptorLayout) return;
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "MVKResource.h"
|
||||
#include "MVKSync.h"
|
||||
#include "MVKVector.h"
|
||||
#include <mutex>
|
||||
#include <list>
|
||||
|
||||
#import <IOSurface/IOSurfaceRef.h>
|
||||
|
||||
@ -397,7 +397,7 @@ protected:
|
||||
uint32_t _swapchainIndex;
|
||||
id<CAMetalDrawable> _mtlDrawable;
|
||||
std::mutex _availabilityLock;
|
||||
std::list<MVKSwapchainSignaler> _availabilitySignalers;
|
||||
MVKVector<MVKSwapchainSignaler> _availabilitySignalers;
|
||||
MVKSwapchainSignaler _preSignaled;
|
||||
MVKSwapchainImageAvailability _availability;
|
||||
};
|
||||
|
@ -1000,7 +1000,8 @@ void MVKSwapchainImage::makeAvailable() {
|
||||
// If this image is not yet available, extract and signal the first semaphore and fence.
|
||||
|
||||
signaler = _availabilitySignalers.front();
|
||||
_availabilitySignalers.pop_front();
|
||||
_availabilitySignalers.erase( _availabilitySignalers.begin() );
|
||||
//_availabilitySignalers.pop_front();
|
||||
}
|
||||
|
||||
// Signal the semaphore and fence, and let them know they are no longer being tracked.
|
||||
|
@ -25,7 +25,6 @@
|
||||
#include "MVKVector.h"
|
||||
#include <MoltenVKSPIRVToMSLConverter/SPIRVToMSLConverter.h>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
#include <ostream>
|
||||
|
||||
#import <Metal/Metal.h>
|
||||
@ -63,7 +62,7 @@ public:
|
||||
|
||||
/** Updates a descriptor set in a command encoder. */
|
||||
void pushDescriptorSet(MVKCommandEncoder* cmdEncoder,
|
||||
std::vector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKVector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
uint32_t set);
|
||||
|
||||
/** Updates a descriptor set from a template in a command encoder. */
|
||||
@ -82,9 +81,9 @@ public:
|
||||
MVKPipelineLayout(MVKDevice* device, const VkPipelineLayoutCreateInfo* pCreateInfo);
|
||||
|
||||
protected:
|
||||
std::vector<MVKDescriptorSetLayout> _descriptorSetLayouts;
|
||||
std::vector<MVKShaderResourceBinding> _dslMTLResourceIndexOffsets;
|
||||
std::vector<VkPushConstantRange> _pushConstants;
|
||||
MVKVector<MVKDescriptorSetLayout> _descriptorSetLayouts;
|
||||
MVKVector<MVKShaderResourceBinding> _dslMTLResourceIndexOffsets;
|
||||
MVKVector<VkPushConstantRange> _pushConstants;
|
||||
MVKShaderResourceBinding _pushConstantsMTLResourceIndexes;
|
||||
MVKShaderAuxBufferBinding _auxBufferIndex;
|
||||
};
|
||||
|
@ -55,7 +55,7 @@ void MVKPipelineLayout::bindDescriptorSets(MVKCommandEncoder* cmdEncoder,
|
||||
}
|
||||
|
||||
void MVKPipelineLayout::pushDescriptorSet(MVKCommandEncoder* cmdEncoder,
|
||||
vector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
MVKVector<VkWriteDescriptorSet>& descriptorWrites,
|
||||
uint32_t set) {
|
||||
|
||||
_descriptorSetLayouts[set].pushDescriptorSet(cmdEncoder, descriptorWrites,
|
||||
|
@ -456,7 +456,7 @@ public:
|
||||
{
|
||||
--alc.num_elements_used;
|
||||
|
||||
for( size_t i = it.GetIndex(); i < alc.num_elements_used; ++i )
|
||||
for( size_t i = it.get_position(); i < alc.num_elements_used; ++i )
|
||||
{
|
||||
alc.ptr[i] = std::move( alc.ptr[i + 1] );
|
||||
}
|
||||
@ -524,5 +524,10 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<typename Type>
|
||||
using MVKVector128 = MVKVector<Type, mvk_vector_allocator_with_stack<Type, 128>>;
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user