Fixing more macos things
This commit is contained in:
@@ -30,10 +30,11 @@ void VertexData::resetMeshData()
|
||||
void VertexData::updateMesh(PMesh mesh, Component::Transform& transform)
|
||||
{
|
||||
std::unique_lock l(materialDataLock);
|
||||
PMaterial mat = mesh->referencedMaterial->getHandle()->getBaseMaterial();
|
||||
PMaterialInstance referencedInstance = mesh->referencedMaterial->getHandle();
|
||||
PMaterial mat = referencedInstance->getBaseMaterial();
|
||||
MaterialData& matData = materialData[mat->getName()];
|
||||
matData.material = mat;
|
||||
MaterialInstanceData& matInstanceData = matData.instances[mesh->referencedMaterial->getHandle()->getId()];
|
||||
MaterialInstanceData& matInstanceData = matData.instances[referencedInstance->getId()];
|
||||
for (const auto& data : meshData[mesh->id])
|
||||
{
|
||||
matInstanceData.meshes.add(MeshInstanceData{
|
||||
@@ -43,7 +44,8 @@ void VertexData::updateMesh(PMesh mesh, Component::Transform& transform)
|
||||
.data = data,
|
||||
});
|
||||
}
|
||||
matInstanceData.materialInstance = mesh->referencedMaterial->getHandle();
|
||||
matInstanceData.materialInstance = referencedInstance;
|
||||
referencedInstance->updateDescriptor();
|
||||
}
|
||||
|
||||
void VertexData::createDescriptors()
|
||||
|
||||
@@ -10,7 +10,6 @@ struct PendingBuffer
|
||||
uint64 size;
|
||||
VkBuffer stagingBuffer;
|
||||
VmaAllocation allocation;
|
||||
void *mappedMemory;
|
||||
Gfx::QueueType prevQueue;
|
||||
bool writeOnly;
|
||||
};
|
||||
@@ -163,7 +162,7 @@ void *Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly)
|
||||
{
|
||||
if (buffers[currentBuffer].properties & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
|
||||
{
|
||||
VK_CHECK(vmaMapMemory(graphics->getAllocator(), buffers[currentBuffer].allocation, &pending.mappedMemory));
|
||||
VK_CHECK(vmaMapMemory(graphics->getAllocator(), buffers[currentBuffer].allocation, &data));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -177,9 +176,10 @@ void *Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly)
|
||||
};
|
||||
VmaAllocationCreateInfo allocInfo = {
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
.requiredFlags = VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT,
|
||||
};
|
||||
VK_CHECK(vmaCreateBuffer(graphics->getAllocator(), &stagingInfo, &allocInfo, &pending.stagingBuffer, &pending.allocation, nullptr));
|
||||
vmaMapMemory(graphics->getAllocator(), pending.allocation, &pending.mappedMemory);
|
||||
vmaMapMemory(graphics->getAllocator(), pending.allocation, &data);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -247,7 +247,7 @@ void TextureBase::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Arra
|
||||
void* data;
|
||||
VkBuffer stagingBuffer = VK_NULL_HANDLE;
|
||||
VmaAllocation stagingAlloc;
|
||||
|
||||
// always create a staging buffer since we do buffer -> image copy and the image may be in any tiling format
|
||||
VkBufferCreateInfo stagingInfo = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
@@ -258,6 +258,7 @@ void TextureBase::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Arra
|
||||
};
|
||||
VmaAllocationCreateInfo alloc = {
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
.flags = VMA_ALLOCATION_CREATE_MAPPED_BIT | VMA_ALLOCATION_CREATE_HOST_ACCESS_RANDOM_BIT,
|
||||
};
|
||||
VK_CHECK(vmaCreateBuffer(graphics->getAllocator(), &stagingInfo, &alloc, &stagingBuffer, &stagingAlloc, nullptr));
|
||||
|
||||
@@ -286,10 +287,11 @@ void TextureBase::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Arra
|
||||
};
|
||||
vkCmdCopyImageToBuffer(cmdBuffer->getHandle(), image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, stagingBuffer, 1, ®ion);
|
||||
changeLayout(prevLayout);
|
||||
VK_CHECK(vmaMapMemory(graphics->getAllocator(), stagingAlloc, &data));
|
||||
buffer.resize(imageSize);
|
||||
std::memcpy(buffer.data(), data, buffer.size());
|
||||
vmaUnmapMemory(graphics->getAllocator(), stagingAlloc);
|
||||
vmaDestroyBuffer(graphics->getAllocator(), stagingBuffer, stagingAlloc);
|
||||
graphics->getDestructionManager()->queueBuffer(cmdBuffer, stagingBuffer, stagingAlloc);
|
||||
}
|
||||
|
||||
void TextureBase::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||
|
||||
Reference in New Issue
Block a user