It suddenly works again?
This commit is contained in:
@@ -246,8 +246,8 @@ uint32 Allocator::findMemoryType(uint32 typeFilter, VkMemoryPropertyFlags proper
|
||||
throw std::runtime_error("error finding memory");
|
||||
}
|
||||
|
||||
StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size)
|
||||
: QueueOwnedResource(graphics->getFamilyMapping(), Gfx::QueueType::DEDICATED_TRANSFER)
|
||||
StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner)
|
||||
: QueueOwnedResource(graphics->getFamilyMapping(), owner)
|
||||
, graphics(graphics)
|
||||
, allocation(std::move(allocation))
|
||||
, buffer(buffer)
|
||||
@@ -258,10 +258,9 @@ StagingBuffer::StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBu
|
||||
StagingBuffer::~StagingBuffer()
|
||||
{
|
||||
graphics->getDestructionManager()->queueBuffer(
|
||||
graphics->getDedicatedTransferCommands()->getCommands(), buffer);
|
||||
graphics->getQueueCommands(currentOwner)->getCommands(), buffer);
|
||||
graphics->getDestructionManager()->queueAllocation(
|
||||
graphics->getDedicatedTransferCommands()->getCommands(), std::move(allocation));
|
||||
graphics->getDedicatedTransferCommands()->submitCommands();
|
||||
graphics->getQueueCommands(currentOwner)->getCommands(), std::move(allocation));
|
||||
}
|
||||
|
||||
void* StagingBuffer::map()
|
||||
@@ -296,7 +295,19 @@ void StagingBuffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
||||
void StagingBuffer::executePipelineBarrier(Gfx::SeAccessFlags srcAccess, Gfx::SePipelineStageFlags srcStage,
|
||||
Gfx::SeAccessFlags dstAccess, Gfx::SePipelineStageFlags dstStage)
|
||||
{
|
||||
assert(false);
|
||||
PCommand commandBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
||||
VkBufferMemoryBarrier barrier = {
|
||||
.sType = VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER,
|
||||
.pNext = nullptr,
|
||||
.srcAccessMask = srcAccess,
|
||||
.dstAccessMask = dstAccess,
|
||||
.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED,
|
||||
.buffer = buffer,
|
||||
.offset = 0,
|
||||
.size = size,
|
||||
};
|
||||
vkCmdPipelineBarrier(commandBuffer->getHandle(), srcStage, dstStage, 0, 0, nullptr, 1, &barrier, 0, nullptr);
|
||||
}
|
||||
|
||||
StagingManager::StagingManager(PGraphics graphics, PAllocator pool)
|
||||
@@ -308,7 +319,7 @@ StagingManager::~StagingManager()
|
||||
{
|
||||
}
|
||||
|
||||
OStagingBuffer StagingManager::create(uint64 size)
|
||||
OStagingBuffer StagingManager::create(uint64 size, Gfx::QueueType owner)
|
||||
{
|
||||
//std::cout << "Creating new stagingbuffer" << std::endl;
|
||||
uint32 queueIndex = graphics->getFamilyMapping().getQueueTypeFamilyIndex(Gfx::QueueType::DEDICATED_TRANSFER);
|
||||
@@ -345,7 +356,8 @@ OStagingBuffer StagingManager::create(uint64 size)
|
||||
graphics,
|
||||
pool->allocate(memReqs, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_CACHED_BIT, buffer),
|
||||
buffer,
|
||||
size
|
||||
size,
|
||||
owner
|
||||
);
|
||||
vkBindBufferMemory(graphics->getDevice(), buffer, stagingBuffer->getMemory(), stagingBuffer->getOffset());
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ DEFINE_REF(Allocator)
|
||||
class StagingBuffer : public Gfx::QueueOwnedResource
|
||||
{
|
||||
public:
|
||||
StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size);
|
||||
StagingBuffer(PGraphics graphics, OSubAllocation allocation, VkBuffer buffer, VkDeviceSize size, Gfx::QueueType owner);
|
||||
~StagingBuffer();
|
||||
void* map();
|
||||
void flush();
|
||||
@@ -176,7 +176,7 @@ class StagingManager
|
||||
public:
|
||||
StagingManager(PGraphics graphics, PAllocator pool);
|
||||
~StagingManager();
|
||||
OStagingBuffer create(uint64 size);
|
||||
OStagingBuffer create(uint64 size, Gfx::QueueType owner);
|
||||
|
||||
private:
|
||||
PGraphics graphics;
|
||||
|
||||
@@ -176,20 +176,6 @@ void * Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly)
|
||||
{
|
||||
void *data = nullptr;
|
||||
|
||||
/*if (bVolatile)
|
||||
{
|
||||
if (lockMode == RLM_ReadOnly)
|
||||
{
|
||||
assert(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new std::logic_error("TODO implement volatile buffers");
|
||||
//device->getRHIDevice()->getTemp
|
||||
}
|
||||
}*/
|
||||
//assert(bStatic || bDynamic || bUAV);
|
||||
|
||||
PendingBuffer pending;
|
||||
pending.writeOnly = writeOnly;
|
||||
pending.prevQueue = owner;
|
||||
@@ -198,7 +184,7 @@ void * Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly)
|
||||
if (writeOnly)
|
||||
{
|
||||
//requestOwnershipTransfer(Gfx::QueueType::DEDICATED_TRANSFER);
|
||||
OStagingBuffer stagingBuffer = graphics->getStagingManager()->create(regionSize);
|
||||
OStagingBuffer stagingBuffer = graphics->getStagingManager()->create(regionSize, owner);
|
||||
data = stagingBuffer->map();
|
||||
pending.stagingBuffer = std::move(stagingBuffer);
|
||||
}
|
||||
@@ -223,7 +209,7 @@ void * Buffer::mapRegion(uint64 regionOffset, uint64 regionSize, bool writeOnly)
|
||||
};
|
||||
vkCmdPipelineBarrier(handle, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, nullptr, 1, &barrier, 0, nullptr);
|
||||
|
||||
OStagingBuffer stagingBuffer = graphics->getStagingManager()->create(size);
|
||||
OStagingBuffer stagingBuffer = graphics->getStagingManager()->create(size, owner);
|
||||
|
||||
VkBufferCopy regions = {
|
||||
.srcOffset = 0,
|
||||
@@ -280,7 +266,7 @@ UniformBuffer::UniformBuffer(PGraphics graphics, const UniformBufferCreateInfo &
|
||||
{
|
||||
if(createInfo.dynamic)
|
||||
{
|
||||
dedicatedStagingBuffer = graphics->getStagingManager()->create(createInfo.sourceData.size);
|
||||
dedicatedStagingBuffer = graphics->getStagingManager()->create(createInfo.sourceData.size, owner);
|
||||
}
|
||||
if (createInfo.sourceData.data != nullptr)
|
||||
{
|
||||
@@ -367,7 +353,7 @@ ShaderBuffer::ShaderBuffer(PGraphics graphics, const ShaderBufferCreateInfo &sou
|
||||
{
|
||||
if(sourceData.dynamic)
|
||||
{
|
||||
dedicatedStagingBuffer = graphics->getStagingManager()->create(sourceData.sourceData.size);
|
||||
dedicatedStagingBuffer = graphics->getStagingManager()->create(sourceData.sourceData.size, currentOwner);
|
||||
}
|
||||
if (sourceData.sourceData.data != nullptr)
|
||||
{
|
||||
|
||||
@@ -52,7 +52,7 @@ void Queue::submitCommandBuffer(PCommand command, const Array<VkSemaphore>& sign
|
||||
|
||||
if (Gfx::waitIdleOnSubmit)
|
||||
{
|
||||
command->fence->wait(200 * 1000ull);
|
||||
command->fence->wait(1000 * 1000ull);
|
||||
}
|
||||
|
||||
command->checkFence();
|
||||
|
||||
@@ -124,7 +124,7 @@ TextureBase::TextureBase(PGraphics graphics, VkImageViewType viewType,
|
||||
if(sourceData.size > 0)
|
||||
{
|
||||
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL);
|
||||
OStagingBuffer staging = graphics->getStagingManager()->create(sourceData.size);
|
||||
OStagingBuffer staging = graphics->getStagingManager()->create(sourceData.size, owner);
|
||||
void* data = staging->map();
|
||||
std::memcpy(data, sourceData.data, sourceData.size);
|
||||
staging->flush();
|
||||
@@ -228,7 +228,7 @@ void TextureBase::download(uint32 mipLevel, uint32 arrayLayer, uint32 face, Arra
|
||||
{
|
||||
uint64 imageSize = width * height * depth * Gfx::getFormatInfo(format).blockSize;
|
||||
|
||||
OStagingBuffer stagingbuffer = graphics->getStagingManager()->create(imageSize);
|
||||
OStagingBuffer stagingbuffer = graphics->getStagingManager()->create(imageSize, currentOwner);
|
||||
auto prevlayout = layout;
|
||||
changeLayout(Gfx::SE_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
|
||||
PCommand cmdBuffer = graphics->getQueueCommands(currentOwner)->getCommands();
|
||||
|
||||
Reference in New Issue
Block a user