Replace use of memcmp() with mvkAreEqual().
diff --git a/MoltenVK/MoltenVK/Commands/MVKCommandResourceFactory.h b/MoltenVK/MoltenVK/Commands/MVKCommandResourceFactory.h
index 3f1e769..1bf9bd1 100644
--- a/MoltenVK/MoltenVK/Commands/MVKCommandResourceFactory.h
+++ b/MoltenVK/MoltenVK/Commands/MVKCommandResourceFactory.h
@@ -112,9 +112,9 @@
* 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 @@
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 @@
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 @@
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 @@
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));
diff --git a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
index c7a1aad..cadf19b 100644
--- a/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
+++ b/MoltenVK/MoltenVK/GPUObjects/MVKPipeline.mm
@@ -1544,7 +1544,7 @@
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 ) {