Replace use of memcmp() with mvkAreEqual().

This commit is contained in:
Bill Hollings 2020-03-26 11:14:03 -04:00
parent 4f1cdef6af
commit 04ae0a61e0
2 changed files with 7 additions and 17 deletions

View File

@ -112,9 +112,9 @@ namespace std {
* This structure can be used as a key in a std::map and std::unordered_map.
*/
typedef struct MVKRPSKeyClearAtt {
uint16_t attachmentMTLPixelFormats[kMVKClearAttachmentCount];
uint16_t flags; // bitcount > kMVKClearAttachmentLayeredRenderingBitIndex
uint16_t mtlSampleCount;
uint16_t flags; // bitcount > kMVKClearAttachmentLayeredRenderingBitIndex
uint16_t attachmentMTLPixelFormats[kMVKClearAttachmentCount];
const static uint32_t bitFlag = 1;
@ -126,11 +126,7 @@ typedef struct MVKRPSKeyClearAtt {
bool isLayeredRenderingEnabled() { return mvkIsAnyFlagEnabled(flags, bitFlag << kMVKClearAttachmentLayeredRenderingBitIndex); }
bool operator==(const MVKRPSKeyClearAtt& rhs) const {
return ((flags == rhs.flags) &&
(mtlSampleCount == rhs.mtlSampleCount) &&
(memcmp(attachmentMTLPixelFormats, rhs.attachmentMTLPixelFormats, sizeof(attachmentMTLPixelFormats)) == 0));
}
bool operator==(const MVKRPSKeyClearAtt& rhs) const { return mvkAreEqual(this, &rhs); }
std::size_t hash() const {
std::size_t hash = mvkHash(&flags);
@ -212,9 +208,7 @@ typedef struct MVKMTLDepthStencilDescriptorData {
MVKMTLStencilDescriptorData frontFaceStencilData;
MVKMTLStencilDescriptorData backFaceStencilData;
bool operator==(const MVKMTLDepthStencilDescriptorData& rhs) const {
return (memcmp(this, &rhs, sizeof(*this)) == 0);
}
bool operator==(const MVKMTLDepthStencilDescriptorData& rhs) const { return mvkAreEqual(this, &rhs); }
std::size_t hash() const {
return mvkHash((uint64_t*)this, sizeof(*this) / sizeof(uint64_t));
@ -270,9 +264,7 @@ typedef struct MVKImageDescriptorData {
VkSampleCountFlagBits samples;
VkImageUsageFlags usage;
bool operator==(const MVKImageDescriptorData& rhs) const {
return (memcmp(this, &rhs, sizeof(*this)) == 0);
}
bool operator==(const MVKImageDescriptorData& rhs) const { return mvkAreEqual(this, &rhs); }
std::size_t hash() const {
return mvkHash((uint64_t*)this, sizeof(*this) / sizeof(uint64_t));
@ -307,9 +299,7 @@ typedef struct MVKBufferDescriptorData {
VkDeviceSize size;
VkBufferUsageFlags usage;
bool operator==(const MVKBufferDescriptorData& rhs) const {
return (memcmp(this, &rhs, sizeof(*this)) == 0);
}
bool operator==(const MVKBufferDescriptorData& rhs) const { return mvkAreEqual(this, &rhs); }
std::size_t hash() const {
return mvkHash((uint64_t*)this, sizeof(*this) / sizeof(uint64_t));

View File

@ -1544,7 +1544,7 @@ void MVKPipelineCache::readData(const VkPipelineCacheCreateInfo* pCreateInfo) {
if (NSSwapLittleIntToHost(hdrComponent) != pDevProps->deviceID) { return; }
reader(pcUUID); // Pipeline cache UUID
if (memcmp(pcUUID, pDevProps->pipelineCacheUUID, VK_UUID_SIZE) != 0) { return; }
if (mvkAreEqual(pcUUID, pDevProps->pipelineCacheUUID, VK_UUID_SIZE)) { return; }
bool done = false;
while ( !done ) {