Changing queue acquisition
This commit is contained in:
Vendored
+3
@@ -38,6 +38,9 @@
|
|||||||
"value": "/opt/homebrew/opt/vulkan-validationlayers/share/vulkan/explicit_layer.d"
|
"value": "/opt/homebrew/opt/vulkan-validationlayers/share/vulkan/explicit_layer.d"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"logging": {
|
||||||
|
"moduleLoad": false
|
||||||
|
},
|
||||||
"externalConsole": false,
|
"externalConsole": false,
|
||||||
"MIMode": "lldb",
|
"MIMode": "lldb",
|
||||||
"targetArchitecture": "arm64"
|
"targetArchitecture": "arm64"
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ void TextureAsset::load(ArchiveBuffer& buffer)
|
|||||||
.sourceData = {
|
.sourceData = {
|
||||||
.size = ktxTexture_GetDataSize(ktxTexture(kTexture)),
|
.size = ktxTexture_GetDataSize(ktxTexture(kTexture)),
|
||||||
.data = ktxTexture_GetData(ktxTexture(kTexture)),
|
.data = ktxTexture_GetData(ktxTexture(kTexture)),
|
||||||
.owner = Gfx::QueueType::DEDICATED_TRANSFER,
|
.owner = Gfx::QueueType::TRANSFER,
|
||||||
},
|
},
|
||||||
.format = Vulkan::cast((VkFormat)kTexture->vkFormat),
|
.format = Vulkan::cast((VkFormat)kTexture->vkFormat),
|
||||||
.width = kTexture->baseWidth,
|
.width = kTexture->baseWidth,
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ typedef uint32 KeyModifierFlags;
|
|||||||
|
|
||||||
namespace Gfx
|
namespace Gfx
|
||||||
{
|
{
|
||||||
static constexpr bool useAsyncCompute = true;
|
static constexpr bool useAsyncCompute = false;
|
||||||
static constexpr bool useMeshShading = true;
|
static constexpr bool useMeshShading = true;
|
||||||
static constexpr uint32 numFramesBuffered = 3;
|
static constexpr uint32 numFramesBuffered = 3;
|
||||||
|
|
||||||
@@ -179,7 +179,6 @@ enum class QueueType
|
|||||||
GRAPHICS = 1,
|
GRAPHICS = 1,
|
||||||
COMPUTE = 2,
|
COMPUTE = 2,
|
||||||
TRANSFER = 3,
|
TRANSFER = 3,
|
||||||
DEDICATED_TRANSFER = 4
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef uint32_t SeFlags;
|
typedef uint32_t SeFlags;
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ void BasePass::createRenderPass()
|
|||||||
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
depthAttachment = resources->requestRenderTarget("DEPTHPREPASS_DEPTH");
|
||||||
depthAttachment->setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
depthAttachment->setLoadOp(Gfx::SE_ATTACHMENT_LOAD_OP_LOAD);
|
||||||
depthAttachment->setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
depthAttachment->setInitialLayout(Gfx::SE_IMAGE_LAYOUT_GENERAL);
|
||||||
|
depthAttachment->setFinalLayout(Gfx::SE_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL);
|
||||||
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
Gfx::RenderTargetLayout layout = Gfx::RenderTargetLayout{
|
||||||
.colorAttachments = { colorAttachment },
|
.colorAttachments = { colorAttachment },
|
||||||
.depthAttachment = depthAttachment,
|
.depthAttachment = depthAttachment,
|
||||||
|
|||||||
@@ -37,6 +37,12 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
|
|||||||
};
|
};
|
||||||
oLightIndexCounter->updateContents(counterReset);
|
oLightIndexCounter->updateContents(counterReset);
|
||||||
tLightIndexCounter->updateContents(counterReset);
|
tLightIndexCounter->updateContents(counterReset);
|
||||||
|
oLightIndexCounter->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
|
tLightIndexCounter->pipelineBarrier(
|
||||||
|
Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
||||||
|
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
|
|
||||||
cullingDescriptorLayout->reset();
|
cullingDescriptorLayout->reset();
|
||||||
cullingDescriptorSet = cullingDescriptorLayout->allocateDescriptorSet();
|
cullingDescriptorSet = cullingDescriptorLayout->allocateDescriptorSet();
|
||||||
@@ -47,24 +53,6 @@ void LightCullingPass::beginFrame(const Component::Camera& cam)
|
|||||||
|
|
||||||
void LightCullingPass::render()
|
void LightCullingPass::render()
|
||||||
{
|
{
|
||||||
oLightIndexCounter->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
|
||||||
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
oLightIndexList->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
oLightGrid->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
tLightIndexCounter->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_MEMORY_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_TRANSFER_BIT,
|
|
||||||
Gfx::SE_ACCESS_MEMORY_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
tLightIndexList->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
tLightGrid->pipelineBarrier(
|
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_FRAGMENT_SHADER_BIT,
|
|
||||||
Gfx::SE_ACCESS_SHADER_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
|
||||||
depthAttachment->pipelineBarrier(
|
depthAttachment->pipelineBarrier(
|
||||||
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
Gfx::SE_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT, Gfx::SE_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT | Gfx::SE_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT,
|
||||||
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
Gfx::SE_ACCESS_SHADER_READ_BIT, Gfx::SE_PIPELINE_STAGE_COMPUTE_SHADER_BIT);
|
||||||
@@ -82,7 +70,7 @@ void LightCullingPass::render()
|
|||||||
computeCommand->bindDescriptor({ viewParamsSet, dispatchParamsSet, cullingDescriptorSet, lightEnv->getDescriptorSet() });
|
computeCommand->bindDescriptor({ viewParamsSet, dispatchParamsSet, cullingDescriptorSet, lightEnv->getDescriptorSet() });
|
||||||
computeCommand->dispatch(dispatchParams.numThreadGroups.x, dispatchParams.numThreadGroups.y, dispatchParams.numThreadGroups.z);
|
computeCommand->dispatch(dispatchParams.numThreadGroups.x, dispatchParams.numThreadGroups.y, dispatchParams.numThreadGroups.z);
|
||||||
Array<Gfx::PComputeCommand> commands = {computeCommand};
|
Array<Gfx::PComputeCommand> commands = {computeCommand};
|
||||||
std::cout << "Execute" << std::endl;
|
//std::cout << "Execute" << std::endl;
|
||||||
graphics->executeCommands(commands);
|
graphics->executeCommands(commands);
|
||||||
//std::cout << "LightCulling render()" << std::endl;
|
//std::cout << "LightCulling render()" << std::endl;
|
||||||
//co_return;
|
//co_return;
|
||||||
@@ -157,10 +145,10 @@ void LightCullingPass::publishOutputs()
|
|||||||
},
|
},
|
||||||
.numElements = 1,
|
.numElements = 1,
|
||||||
.dynamic = true,
|
.dynamic = true,
|
||||||
//.name = "oLightIndexCounter",
|
.name = "oLightIndexCounter",
|
||||||
};
|
};
|
||||||
oLightIndexCounter = graphics->createShaderBuffer(structInfo);
|
oLightIndexCounter = graphics->createShaderBuffer(structInfo);
|
||||||
//structInfo.name = "tLightIndexCounter";
|
structInfo.name = "tLightIndexCounter";
|
||||||
tLightIndexCounter = graphics->createShaderBuffer(structInfo);
|
tLightIndexCounter = graphics->createShaderBuffer(structInfo);
|
||||||
structInfo = {
|
structInfo = {
|
||||||
.sourceData = {
|
.sourceData = {
|
||||||
@@ -172,10 +160,10 @@ void LightCullingPass::publishOutputs()
|
|||||||
.owner = Gfx::QueueType::COMPUTE
|
.owner = Gfx::QueueType::COMPUTE
|
||||||
},
|
},
|
||||||
.dynamic = false,
|
.dynamic = false,
|
||||||
//.name = "oLightIndexList",
|
.name = "oLightIndexList",
|
||||||
};
|
};
|
||||||
oLightIndexList = graphics->createShaderBuffer(structInfo);
|
oLightIndexList = graphics->createShaderBuffer(structInfo);
|
||||||
//structInfo.name = "tLightIndexList";
|
structInfo.name = "tLightIndexList";
|
||||||
tLightIndexList = graphics->createShaderBuffer(structInfo);
|
tLightIndexList = graphics->createShaderBuffer(structInfo);
|
||||||
resources->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
resources->registerBufferOutput("LIGHTCULLING_OLIGHTLIST", oLightIndexList);
|
||||||
resources->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
resources->registerBufferOutput("LIGHTCULLING_TLIGHTLIST", tLightIndexList);
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ struct QueueFamilyMapping
|
|||||||
uint32 graphicsFamily;
|
uint32 graphicsFamily;
|
||||||
uint32 computeFamily;
|
uint32 computeFamily;
|
||||||
uint32 transferFamily;
|
uint32 transferFamily;
|
||||||
uint32 dedicatedTransferFamily;
|
|
||||||
uint32 getQueueTypeFamilyIndex(Gfx::QueueType type) const
|
uint32 getQueueTypeFamilyIndex(Gfx::QueueType type) const
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -49,8 +48,6 @@ struct QueueFamilyMapping
|
|||||||
return computeFamily;
|
return computeFamily;
|
||||||
case Gfx::QueueType::TRANSFER:
|
case Gfx::QueueType::TRANSFER:
|
||||||
return transferFamily;
|
return transferFamily;
|
||||||
case Gfx::QueueType::DEDICATED_TRANSFER:
|
|
||||||
return dedicatedTransferFamily;
|
|
||||||
default:
|
default:
|
||||||
return 0x7fff;
|
return 0x7fff;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ Buffer::Buffer(PGraphics graphics,
|
|||||||
.object = (uint64)buffers[i].buffer,
|
.object = (uint64)buffers[i].buffer,
|
||||||
.pObjectName = this->name.c_str()
|
.pObjectName = this->name.c_str()
|
||||||
};
|
};
|
||||||
graphics->vkDebugMarkerSetObjectNameEXT(&nameInfo);
|
//graphics->vkDebugMarkerSetObjectNameEXT(&nameInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,7 +85,7 @@ void Buffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
|||||||
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||||
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
|
||||||
assert(barrier.srcQueueFamilyIndex != barrier.dstQueueFamilyIndex);
|
assert(barrier.srcQueueFamilyIndex != barrier.dstQueueFamilyIndex);
|
||||||
if (owner == Gfx::QueueType::TRANSFER || owner == Gfx::QueueType::DEDICATED_TRANSFER)
|
if (owner == Gfx::QueueType::TRANSFER)
|
||||||
{
|
{
|
||||||
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
barrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
@@ -106,12 +106,6 @@ void Buffer::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
|||||||
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
dstPool = graphics->getTransferCommands();
|
dstPool = graphics->getTransferCommands();
|
||||||
}
|
}
|
||||||
else if (newOwner == Gfx::QueueType::DEDICATED_TRANSFER)
|
|
||||||
{
|
|
||||||
barrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
|
||||||
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
|
||||||
dstPool = graphics->getDedicatedTransferCommands();
|
|
||||||
}
|
|
||||||
else if (newOwner == Gfx::QueueType::COMPUTE)
|
else if (newOwner == Gfx::QueueType::COMPUTE)
|
||||||
{
|
{
|
||||||
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
barrier.dstAccessMask = VK_ACCESS_SHADER_READ_BIT;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ VkBool32 Seele::Vulkan::debugCallback(
|
|||||||
void* pUserData)
|
void* pUserData)
|
||||||
{
|
{
|
||||||
std::cerr << pCallbackData->pMessage << std::endl;
|
std::cerr << pCallbackData->pMessage << std::endl;
|
||||||
if(messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT)
|
if ((messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) || (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT))
|
||||||
{
|
{
|
||||||
return VK_FALSE;
|
return VK_FALSE;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ using namespace Seele::Vulkan;
|
|||||||
thread_local PCommandPool Seele::Vulkan::Graphics::graphicsCommands = nullptr;
|
thread_local PCommandPool Seele::Vulkan::Graphics::graphicsCommands = nullptr;
|
||||||
thread_local PCommandPool Seele::Vulkan::Graphics::computeCommands = nullptr;
|
thread_local PCommandPool Seele::Vulkan::Graphics::computeCommands = nullptr;
|
||||||
thread_local PCommandPool Seele::Vulkan::Graphics::transferCommands = nullptr;
|
thread_local PCommandPool Seele::Vulkan::Graphics::transferCommands = nullptr;
|
||||||
thread_local PCommandPool Seele::Vulkan::Graphics::dedicatedTransferCommands = nullptr;
|
|
||||||
|
|
||||||
Graphics::Graphics()
|
Graphics::Graphics()
|
||||||
: instance(VK_NULL_HANDLE)
|
: instance(VK_NULL_HANDLE)
|
||||||
@@ -309,8 +308,6 @@ PCommandPool Graphics::getQueueCommands(Gfx::QueueType queueType)
|
|||||||
return getComputeCommands();
|
return getComputeCommands();
|
||||||
case Gfx::QueueType::TRANSFER:
|
case Gfx::QueueType::TRANSFER:
|
||||||
return getTransferCommands();
|
return getTransferCommands();
|
||||||
case Gfx::QueueType::DEDICATED_TRANSFER:
|
|
||||||
return getDedicatedTransferCommands();
|
|
||||||
default:
|
default:
|
||||||
throw new std::logic_error("invalid queue type");
|
throw new std::logic_error("invalid queue type");
|
||||||
}
|
}
|
||||||
@@ -320,16 +317,23 @@ PCommandPool Graphics::getGraphicsCommands()
|
|||||||
if(graphicsCommands == nullptr)
|
if(graphicsCommands == nullptr)
|
||||||
{
|
{
|
||||||
std::unique_lock l(poolLock);
|
std::unique_lock l(poolLock);
|
||||||
graphicsCommands = pools.add(new CommandPool(this, graphicsQueue));
|
graphicsCommands = pools.add(new CommandPool(this, queues[graphicsQueue]));
|
||||||
}
|
}
|
||||||
return graphicsCommands;
|
return graphicsCommands;
|
||||||
}
|
}
|
||||||
PCommandPool Graphics::getComputeCommands()
|
PCommandPool Graphics::getComputeCommands()
|
||||||
{
|
{
|
||||||
if(computeCommands == nullptr)
|
if(computeCommands == nullptr)
|
||||||
|
{
|
||||||
|
if(graphicsQueue == computeQueue)
|
||||||
|
{
|
||||||
|
computeCommands = getGraphicsCommands();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
std::unique_lock l(poolLock);
|
std::unique_lock l(poolLock);
|
||||||
computeCommands = pools.add(new CommandPool(this, computeQueue));
|
computeCommands = pools.add(new CommandPool(this, queues[computeQueue]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return computeCommands;
|
return computeCommands;
|
||||||
}
|
}
|
||||||
@@ -337,19 +341,17 @@ PCommandPool Graphics::getTransferCommands()
|
|||||||
{
|
{
|
||||||
if(transferCommands == nullptr)
|
if(transferCommands == nullptr)
|
||||||
{
|
{
|
||||||
std::unique_lock l(poolLock);
|
if(graphicsQueue == transferQueue)
|
||||||
transferCommands = pools.add(new CommandPool(this, transferQueue));
|
{
|
||||||
|
transferCommands = getGraphicsCommands();
|
||||||
}
|
}
|
||||||
return transferCommands;
|
else
|
||||||
}
|
|
||||||
PCommandPool Graphics::getDedicatedTransferCommands()
|
|
||||||
{
|
|
||||||
if(dedicatedTransferCommands == nullptr)
|
|
||||||
{
|
{
|
||||||
std::unique_lock l(poolLock);
|
std::unique_lock l(poolLock);
|
||||||
dedicatedTransferCommands = pools.add(new CommandPool(this, dedicatedTransferQueue != nullptr ? dedicatedTransferQueue : transferQueue));
|
transferCommands = pools.add(new CommandPool(this, queues[transferQueue]));
|
||||||
}
|
}
|
||||||
return dedicatedTransferCommands;
|
}
|
||||||
|
return transferCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
VmaAllocator Graphics::getAllocator()
|
VmaAllocator Graphics::getAllocator()
|
||||||
@@ -428,7 +430,6 @@ void Graphics::setupDebugCallback()
|
|||||||
.pUserData = nullptr,
|
.pUserData = nullptr,
|
||||||
};
|
};
|
||||||
VK_CHECK(CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &callback));
|
VK_CHECK(CreateDebugUtilsMessengerEXT(instance, &createInfo, nullptr, &callback));
|
||||||
cmdDebugMarkerSetObjectName = (PFN_vkDebugMarkerSetObjectNameEXT)vkGetInstanceProcAddr(instance, "vkDebugMarkerSetObjectNameEXT");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Graphics::pickPhysicalDevice()
|
void Graphics::pickPhysicalDevice()
|
||||||
@@ -504,18 +505,19 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
};
|
};
|
||||||
QueueCreateInfo graphicsQueueInfo;
|
QueueCreateInfo graphicsQueueInfo;
|
||||||
QueueCreateInfo transferQueueInfo;
|
QueueCreateInfo transferQueueInfo;
|
||||||
QueueCreateInfo dedicatedTransferQueueInfo;
|
|
||||||
QueueCreateInfo computeQueueInfo;
|
QueueCreateInfo computeQueueInfo;
|
||||||
QueueCreateInfo asyncComputeInfo;
|
|
||||||
uint32 numPriorities = 0;
|
uint32 numPriorities = 0;
|
||||||
auto checkFamilyProperty = [](VkQueueFamilyProperties currProps, uint32 checkBit){
|
auto checkFamilyProperty = [](VkQueueFamilyProperties currProps, uint32 checkBit){
|
||||||
return (currProps.queueFlags & checkBit) == checkBit;
|
return (currProps.queueFlags & checkBit) == checkBit;
|
||||||
};
|
};
|
||||||
auto updateQueueInfo = [&queueProperties](uint32 familyIndex, QueueCreateInfo& info, uint32& numQueues) {
|
auto updateQueueInfo = [&queueProperties](uint32 familyIndex, QueueCreateInfo& info, uint32& numQueues) {
|
||||||
if(info.familyIndex == -1) {
|
if(info.familyIndex == -1) {
|
||||||
|
if(queueProperties[familyIndex].queueCount == numQueues)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
info.familyIndex = familyIndex;
|
info.familyIndex = familyIndex;
|
||||||
numQueues = std::min(numQueues + 1, queueProperties[familyIndex].queueCount);
|
info.queueIndex = numQueues++;
|
||||||
info.queueIndex = numQueues - 1;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
for (uint32 familyIndex = 0; familyIndex < queueProperties.size(); ++familyIndex)
|
for (uint32 familyIndex = 0; familyIndex < queueProperties.size(); ++familyIndex)
|
||||||
@@ -525,46 +527,20 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
|
|
||||||
if (checkFamilyProperty(currProps, VK_QUEUE_GRAPHICS_BIT))
|
if (checkFamilyProperty(currProps, VK_QUEUE_GRAPHICS_BIT))
|
||||||
{
|
{
|
||||||
updateQueueInfo(familyIndex, graphicsQueueInfo, numQueueFamilies);
|
updateQueueInfo(familyIndex, graphicsQueueInfo, numQueuesForFamily);
|
||||||
}
|
}
|
||||||
if (currProps.queueFlags & VK_QUEUE_COMPUTE_BIT)
|
if(Gfx::useAsyncCompute)
|
||||||
{
|
{
|
||||||
if (computeQueueInfo.familyIndex == -1)
|
if(checkFamilyProperty(currProps, VK_QUEUE_COMPUTE_BIT))
|
||||||
{
|
{
|
||||||
computeQueueInfo.familyIndex = familyIndex;
|
updateQueueInfo(familyIndex, computeQueueInfo, numQueuesForFamily);
|
||||||
}
|
}
|
||||||
if (Gfx::useAsyncCompute && numQueueFamilies > 1)
|
|
||||||
{
|
|
||||||
if (asyncComputeInfo.familyIndex == -1)
|
|
||||||
{
|
|
||||||
if (familyIndex == (uint32)graphicsQueueInfo.familyIndex)
|
|
||||||
{
|
|
||||||
if (currProps.queueCount > 1)
|
|
||||||
{
|
|
||||||
asyncComputeInfo.familyIndex = familyIndex;
|
|
||||||
numQueuesForFamily++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
asyncComputeInfo.familyIndex = familyIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (currProps.queueFlags & VK_QUEUE_TRANSFER_BIT)
|
|
||||||
{
|
|
||||||
if (transferQueueInfo.familyIndex == -1)
|
|
||||||
{
|
|
||||||
transferQueueInfo.familyIndex = familyIndex;
|
|
||||||
numQueuesForFamily++;
|
|
||||||
}
|
}
|
||||||
if ((currProps.queueFlags ^ VK_QUEUE_TRANSFER_BIT) == 0)
|
if ((currProps.queueFlags ^ VK_QUEUE_TRANSFER_BIT) == 0)
|
||||||
{
|
{
|
||||||
dedicatedTransferQueueInfo.familyIndex = familyIndex;
|
updateQueueInfo(familyIndex, transferQueueInfo, numQueuesForFamily);
|
||||||
numQueuesForFamily++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numQueuesForFamily > 0)
|
if (numQueuesForFamily > 0)
|
||||||
{
|
{
|
||||||
VkDeviceQueueCreateInfo info = {
|
VkDeviceQueueCreateInfo info = {
|
||||||
@@ -616,35 +592,50 @@ void Graphics::createDevice(GraphicsInitializer initializer)
|
|||||||
};
|
};
|
||||||
|
|
||||||
VK_CHECK(vkCreateDevice(physicalDevice, &deviceInfo, nullptr, &handle));
|
VK_CHECK(vkCreateDevice(physicalDevice, &deviceInfo, nullptr, &handle));
|
||||||
std::cout << "Vulkan handle: " << handle << std::endl;
|
//std::cout << "Vulkan handle: " << handle << std::endl;
|
||||||
|
|
||||||
cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT");
|
cmdDrawMeshTasks = (PFN_vkCmdDrawMeshTasksEXT)vkGetDeviceProcAddr(handle, "vkCmdDrawMeshTasksEXT");
|
||||||
|
|
||||||
graphicsQueue = new Queue(this, graphicsQueueInfo.familyIndex, 0);
|
graphicsQueue = 0;
|
||||||
if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1)
|
computeQueue = 0;
|
||||||
|
transferQueue = 0;
|
||||||
|
queues.add(new Queue(this, graphicsQueueInfo.familyIndex, graphicsQueueInfo.queueIndex));
|
||||||
|
if(computeQueueInfo.familyIndex != -1)
|
||||||
{
|
{
|
||||||
if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex)
|
computeQueue = queues.size();
|
||||||
|
queues.add(new Queue(this, computeQueueInfo.familyIndex, computeQueueInfo.queueIndex));
|
||||||
|
}
|
||||||
|
if(transferQueueInfo.familyIndex != -1)
|
||||||
{
|
{
|
||||||
// Same family as graphics, but different queue
|
transferQueue = queues.size();
|
||||||
computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 1);
|
queues.add(new Queue(this, transferQueueInfo.familyIndex, transferQueueInfo.queueIndex));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
// if (Gfx::useAsyncCompute && asyncComputeInfo.familyIndex != -1)
|
||||||
// Different family
|
// {
|
||||||
computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 0);
|
// if (asyncComputeInfo.familyIndex == graphicsQueueInfo.familyIndex)
|
||||||
}
|
// {
|
||||||
}
|
// // Same family as graphics, but different queue
|
||||||
else
|
// computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 1);
|
||||||
{
|
// }
|
||||||
computeQueue = new Queue(this, computeQueueInfo.familyIndex, 0);
|
// else
|
||||||
}
|
// {
|
||||||
transferQueue = new Queue(this, transferQueueInfo.familyIndex, 0);
|
// // Different family
|
||||||
if (dedicatedTransferQueueInfo.familyIndex != -1)
|
// computeQueue = new Queue(this, asyncComputeInfo.familyIndex, 0);
|
||||||
{
|
// }
|
||||||
dedicatedTransferQueue = new Queue(this, dedicatedTransferQueueInfo.familyIndex, 0);
|
// }
|
||||||
}
|
// else
|
||||||
queueMapping.graphicsFamily = graphicsQueue->getFamilyIndex();
|
// {
|
||||||
queueMapping.computeFamily = computeQueue->getFamilyIndex();
|
// computeQueue = new Queue(this, computeQueueInfo.familyIndex, 0);
|
||||||
queueMapping.transferFamily = transferQueue->getFamilyIndex();
|
// }
|
||||||
queueMapping.dedicatedTransferFamily = dedicatedTransferQueue != nullptr ? dedicatedTransferQueue->getFamilyIndex() : transferQueue->getFamilyIndex();
|
// transferQueue = new Queue(this, transferQueueInfo.familyIndex, 0);
|
||||||
|
// if (dedicatedTransferQueueInfo.familyIndex != -1)
|
||||||
|
// {
|
||||||
|
// dedicatedTransferQueue = new Queue(this, dedicatedTransferQueueInfo.familyIndex, 0);
|
||||||
|
// }
|
||||||
|
queueMapping.graphicsFamily = queues[graphicsQueue]->getFamilyIndex();
|
||||||
|
queueMapping.computeFamily = queues[computeQueue]->getFamilyIndex();
|
||||||
|
queueMapping.transferFamily = queues[transferQueue]->getFamilyIndex();
|
||||||
|
cmdDebugMarkerSetObjectName = (PFN_vkDebugMarkerSetObjectNameEXT)vkGetInstanceProcAddr(instance, "vkDebugMarkerSetObjectNameEXT");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,6 @@ public:
|
|||||||
PCommandPool getGraphicsCommands();
|
PCommandPool getGraphicsCommands();
|
||||||
PCommandPool getComputeCommands();
|
PCommandPool getComputeCommands();
|
||||||
PCommandPool getTransferCommands();
|
PCommandPool getTransferCommands();
|
||||||
PCommandPool getDedicatedTransferCommands();
|
|
||||||
|
|
||||||
VmaAllocator getAllocator();
|
VmaAllocator getAllocator();
|
||||||
PDestructionManager getDestructionManager();
|
PDestructionManager getDestructionManager();
|
||||||
@@ -86,14 +85,13 @@ protected:
|
|||||||
VkDevice handle;
|
VkDevice handle;
|
||||||
VkPhysicalDevice physicalDevice;
|
VkPhysicalDevice physicalDevice;
|
||||||
|
|
||||||
OQueue graphicsQueue;
|
Array<OQueue> queues;
|
||||||
OQueue computeQueue;
|
uint32 graphicsQueue;
|
||||||
OQueue transferQueue;
|
uint32 computeQueue;
|
||||||
OQueue dedicatedTransferQueue;
|
uint32 transferQueue;
|
||||||
thread_local static PCommandPool graphicsCommands;
|
thread_local static PCommandPool graphicsCommands;
|
||||||
thread_local static PCommandPool computeCommands;
|
thread_local static PCommandPool computeCommands;
|
||||||
thread_local static PCommandPool transferCommands;
|
thread_local static PCommandPool transferCommands;
|
||||||
thread_local static PCommandPool dedicatedTransferCommands;
|
|
||||||
std::mutex poolLock;
|
std::mutex poolLock;
|
||||||
Array<OCommandPool> pools;
|
Array<OCommandPool> pools;
|
||||||
VkPhysicalDeviceProperties props;
|
VkPhysicalDeviceProperties props;
|
||||||
|
|||||||
@@ -321,13 +321,17 @@ void TextureBase::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
|||||||
.image = image,
|
.image = image,
|
||||||
.subresourceRange = {
|
.subresourceRange = {
|
||||||
.aspectMask = aspect,
|
.aspectMask = aspect,
|
||||||
|
.baseArrayLayer = 0,
|
||||||
|
.layerCount = arrayCount,
|
||||||
|
.baseMipLevel = 0,
|
||||||
|
.levelCount = mipLevels,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
PCommandPool sourcePool = graphics->getQueueCommands(currentOwner);
|
PCommandPool sourcePool = graphics->getQueueCommands(currentOwner);
|
||||||
PCommandPool dstPool = nullptr;
|
PCommandPool dstPool = nullptr;
|
||||||
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
VkPipelineStageFlags srcStage = VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT;
|
||||||
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
VkPipelineStageFlags dstStage = VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT;
|
||||||
if (currentOwner == Gfx::QueueType::TRANSFER || currentOwner == Gfx::QueueType::DEDICATED_TRANSFER)
|
if (currentOwner == Gfx::QueueType::TRANSFER)
|
||||||
{
|
{
|
||||||
imageBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
imageBarrier.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||||
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
srcStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
@@ -348,12 +352,6 @@ void TextureBase::executeOwnershipBarrier(Gfx::QueueType newOwner)
|
|||||||
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
||||||
dstPool = graphics->getTransferCommands();
|
dstPool = graphics->getTransferCommands();
|
||||||
}
|
}
|
||||||
else if (newOwner == Gfx::QueueType::DEDICATED_TRANSFER)
|
|
||||||
{
|
|
||||||
imageBarrier.dstAccessMask = VK_ACCESS_TRANSFER_READ_BIT;
|
|
||||||
dstStage = VK_PIPELINE_STAGE_TRANSFER_BIT;
|
|
||||||
dstPool = graphics->getDedicatedTransferCommands();
|
|
||||||
}
|
|
||||||
else if (newOwner == Gfx::QueueType::COMPUTE)
|
else if (newOwner == Gfx::QueueType::COMPUTE)
|
||||||
{
|
{
|
||||||
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
imageBarrier.dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
|
||||||
|
|||||||
Reference in New Issue
Block a user