Trying to add fluid simulation
This commit is contained in:
@@ -175,7 +175,6 @@ Gfx::ODescriptorSet DescriptorPool::allocateDescriptorSet() {
|
||||
};
|
||||
vkSetDebugUtilsObjectNameEXT(graphics->getDevice(), &nameInfo);
|
||||
}
|
||||
cachedHandles[setIndex]->isUsed = true;
|
||||
// Found set, stop searching
|
||||
return new DescriptorSet(graphics, this, cachedHandles[setIndex]);
|
||||
}
|
||||
@@ -191,13 +190,11 @@ void DescriptorPool::reset() {}
|
||||
|
||||
DescriptorSetHandle::DescriptorSetHandle(PGraphics graphics, const std::string& name) : CommandBoundResource(graphics, name) {}
|
||||
|
||||
DescriptorSetHandle::~DescriptorSetHandle() {
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(constantsBuffer));
|
||||
}
|
||||
DescriptorSetHandle::~DescriptorSetHandle() { graphics->getDestructionManager()->queueResourceForDestruction(std::move(constantsBuffer)); }
|
||||
|
||||
DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner, PDescriptorSetHandle setHandle)
|
||||
: Gfx::DescriptorSet(owner->getLayout()), setHandle(setHandle),
|
||||
graphics(graphics), owner(owner) {
|
||||
: Gfx::DescriptorSet(owner->getLayout()), setHandle(setHandle), graphics(graphics), owner(owner) {
|
||||
setHandle->isUsed = true;
|
||||
boundResources.resize(owner->getLayout()->bindings.size());
|
||||
for (uint32 i = 0; i < boundResources.size(); ++i) {
|
||||
boundResources[i].resize(owner->getLayout()->bindings[i].descriptorCount);
|
||||
@@ -208,8 +205,10 @@ DescriptorSet::DescriptorSet(PGraphics graphics, PDescriptorPool owner, PDescrip
|
||||
constantData.resize(owner->getLayout()->constantsSize);
|
||||
}
|
||||
|
||||
DescriptorSet::~DescriptorSet() {
|
||||
setHandle->isUsed = false;
|
||||
DescriptorSet::~DescriptorSet() {
|
||||
if (setHandle != nullptr) {
|
||||
setHandle->isUsed = false;
|
||||
}
|
||||
}
|
||||
|
||||
void DescriptorSet::updateConstants(const std::string& mappingName, uint32 offset, const void* data) {
|
||||
@@ -406,20 +405,21 @@ void DescriptorSet::writeChanges() {
|
||||
if (setHandle->constantsBuffer != nullptr) {
|
||||
graphics->getDestructionManager()->queueResourceForDestruction(std::move(setHandle->constantsBuffer));
|
||||
}
|
||||
setHandle->constantsBuffer = new BufferAllocation(graphics, owner->getLayout()->getName(),
|
||||
VkBufferCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.size = constantData.size(),
|
||||
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
Gfx::QueueType::GRAPHICS);
|
||||
setHandle->constantsBuffer =
|
||||
new BufferAllocation(graphics, owner->getLayout()->getName(),
|
||||
VkBufferCreateInfo{
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
|
||||
.pNext = nullptr,
|
||||
.size = constantData.size(),
|
||||
.usage = VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT,
|
||||
},
|
||||
VmaAllocationCreateInfo{
|
||||
.usage = VMA_MEMORY_USAGE_AUTO,
|
||||
},
|
||||
Gfx::QueueType::GRAPHICS);
|
||||
setHandle->constantsBuffer->updateContents(0, constantData.size(), constantData.data());
|
||||
setHandle->constantsBuffer->pipelineBarrier(Gfx::SE_ACCESS_TRANSFER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
Gfx::SE_ACCESS_UNIFORM_READ_BIT, Gfx::SE_PIPELINE_STAGE_ALL_COMMANDS_BIT);
|
||||
bufferInfos.add(VkDescriptorBufferInfo{
|
||||
.buffer = setHandle->constantsBuffer->buffer,
|
||||
.offset = 0,
|
||||
|
||||
Reference in New Issue
Block a user