It suddenly works again?

This commit is contained in:
Dynamitos
2023-12-14 09:04:23 +01:00
parent 88004ce70f
commit 462999858f
10 changed files with 45 additions and 43 deletions
+2 -1
View File
@@ -4,6 +4,7 @@
namespace Seele
{
// Input codes matching GLFW for convenience, since its the primary windowing system
enum class KeyCode : size_t
{
/* Printable keys */
@@ -164,7 +165,7 @@ typedef uint32 KeyModifierFlags;
namespace Gfx
{
static constexpr bool useAsyncCompute = true;
static constexpr bool waitIdleOnSubmit = false;
static constexpr bool waitIdleOnSubmit = true;
static constexpr bool useMeshShading = true;
static constexpr uint32 numFramesBuffered = 3;
+2 -2
View File
@@ -116,9 +116,9 @@ void VertexData::loadMesh(MeshId id, Array<uint32> loadedIndices, Array<Meshlet>
});
}
meshData[id].add(MeshData{
.numMeshlets = numMeshlets,
.meshletOffset = meshletOffset,
.numMeshlets = (uint16)numMeshlets,
.indicesOffset = (uint16)meshOffsets[id],
.indicesOffset = (uint32)meshOffsets[id],
});
currentMesh += numMeshlets;
}
+4 -3
View File
@@ -41,13 +41,13 @@ public:
};
struct MeshData
{
uint32 numMeshlets = 0;
uint32 meshletOffset = 0;
uint16 numMeshlets = 0;
uint16 indicesOffset = 0;
uint32 firstIndex = 0;
uint32 numIndices = 0;
uint32 indicesOffset = 0;
uint32 pad0[3];
};
static_assert(sizeof(MeshData) == 16);
struct MeshInstanceData
{
InstanceData instance;
@@ -93,6 +93,7 @@ protected:
VertexData();
struct MeshletDescription
{
AABB boundingBox;
uint32_t vertexCount;
uint32_t primitiveCount;
uint32_t vertexOffset;
+20 -8
View File
@@ -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());
+2 -2
View File
@@ -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;
+4 -18
View File
@@ -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)
{
+1 -1
View File
@@ -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();
+2 -2
View File
@@ -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();