Skip to content

Commit

Permalink
code refine
Browse files Browse the repository at this point in the history
  • Loading branch information
K1ngst0m committed Oct 28, 2023
1 parent bba5825 commit 683eb24
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
6 changes: 3 additions & 3 deletions engine/api/gpuResource.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ enum class ImageDomain : uint8_t

enum class QueueType : uint8_t
{
GRAPHICS = 0,
COMPUTE = 1,
TRANSFER = 2,
Graphics = 0,
Compute = 1,
Transfer = 2,
};

enum class ShaderStage : uint8_t
Expand Down
12 changes: 6 additions & 6 deletions engine/api/vulkan/physicalDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ PhysicalDevice::PhysicalDevice(HandleType handle) : ResourceHandle(handle)
// universal queue
if(queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
m_queueFamilyMap[QueueType::GRAPHICS].push_back(queueFamilyIndex);
m_queueFamilyMap[QueueType::Graphics].push_back(queueFamilyIndex);
}
// compute queue
else if(queueFlags & VK_QUEUE_COMPUTE_BIT)
{
m_queueFamilyMap[QueueType::COMPUTE].push_back(queueFamilyIndex);
m_queueFamilyMap[QueueType::Compute].push_back(queueFamilyIndex);
}
// transfer queue
else if(queueFlags & VK_QUEUE_TRANSFER_BIT)
{
m_queueFamilyMap[QueueType::TRANSFER].push_back(queueFamilyIndex);
m_queueFamilyMap[QueueType::Transfer].push_back(queueFamilyIndex);
}
}
}
Expand Down Expand Up @@ -299,7 +299,7 @@ VkPipelineStageFlags utils::determinePipelineStageFlags(PhysicalDevice* pGPU, Vk
auto* gpuSupport = &pGPU->getSettings();
switch(queueType)
{
case aph::QueueType::GRAPHICS:
case aph::QueueType::Graphics:
{
if((accessFlags & (VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT)) != 0)
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
Expand Down Expand Up @@ -334,7 +334,7 @@ VkPipelineStageFlags utils::determinePipelineStageFlags(PhysicalDevice* pGPU, Vk

break;
}
case aph::QueueType::COMPUTE:
case aph::QueueType::Compute:
{
if((accessFlags & (VK_ACCESS_INDEX_READ_BIT | VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT)) != 0 ||
(accessFlags & VK_ACCESS_INPUT_ATTACHMENT_READ_BIT) != 0 ||
Expand All @@ -348,7 +348,7 @@ VkPipelineStageFlags utils::determinePipelineStageFlags(PhysicalDevice* pGPU, Vk

break;
}
case aph::QueueType::TRANSFER:
case aph::QueueType::Transfer:
return VK_PIPELINE_STAGE_ALL_COMMANDS_BIT;
default:
break;
Expand Down
6 changes: 3 additions & 3 deletions engine/api/vulkan/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ Queue::Queue(HandleType handle, uint32_t queueFamilyIndex, uint32_t index, const
{
if(m_properties.queueFlags & VK_QUEUE_GRAPHICS_BIT)
{
m_type = QueueType::GRAPHICS;
m_type = QueueType::Graphics;
}
else if(m_properties.queueFlags & VK_QUEUE_COMPUTE_BIT)
{
m_type = QueueType::COMPUTE;
m_type = QueueType::Compute;
}
else if(m_properties.queueFlags & VK_QUEUE_TRANSFER_BIT)
{
m_type = QueueType::TRANSFER;
m_type = QueueType::Transfer;
}
else
{
Expand Down
14 changes: 7 additions & 7 deletions engine/renderer/api/vulkan/renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,17 @@ Renderer::Renderer(WSI* wsi, const RenderConfig& config) : IRenderer(wsi, config
APH_ASSERT(m_pDevice != nullptr);

// get 3 type queue
m_queue[QueueType::GRAPHICS] = m_pDevice->getQueueByFlags(QueueType::GRAPHICS);
m_queue[QueueType::COMPUTE] = m_pDevice->getQueueByFlags(QueueType::COMPUTE);
m_queue[QueueType::TRANSFER] = m_pDevice->getQueueByFlags(QueueType::TRANSFER);
m_queue[QueueType::Graphics] = m_pDevice->getQueueByFlags(QueueType::Graphics);
m_queue[QueueType::Compute] = m_pDevice->getQueueByFlags(QueueType::Compute);
m_queue[QueueType::Transfer] = m_pDevice->getQueueByFlags(QueueType::Transfer);

if(!m_queue[QueueType::COMPUTE])
if(!m_queue[QueueType::Compute])
{
m_queue[QueueType::COMPUTE] = m_queue[QueueType::GRAPHICS];
m_queue[QueueType::Compute] = m_queue[QueueType::Graphics];
}
if(!m_queue[QueueType::TRANSFER])
if(!m_queue[QueueType::Transfer])
{
m_queue[QueueType::TRANSFER] = m_queue[QueueType::COMPUTE];
m_queue[QueueType::Transfer] = m_queue[QueueType::Compute];
}

// check sample count support
Expand Down
10 changes: 5 additions & 5 deletions engine/renderer/api/vulkan/sceneRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void SceneRenderer::load(Scene* scene)

_initSet();

auto* queue = getDefaultQueue(QueueType::GRAPHICS);
auto* queue = getDefaultQueue(QueueType::Graphics);
for(auto idx = 0; idx < m_config.maxFrames; idx++)
{
m_pDevice->allocateThreadCommandBuffers(COMMAND_BUFFER_MAX, cb[idx], queue);
Expand Down Expand Up @@ -108,7 +108,7 @@ void SceneRenderer::cleanup()

void SceneRenderer::recordAll()
{
auto* queue = getDefaultQueue(QueueType::GRAPHICS);
auto* queue = getDefaultQueue(QueueType::Graphics);
auto* currentCB = cb[m_frameIdx];

{
Expand Down Expand Up @@ -442,7 +442,7 @@ void SceneRenderer::_initGbuffer()
.format = m_pDevice->getDepthFormat(),
};
VK_CHECK_RESULT(m_pDevice->create(createInfo, &depth));
m_pDevice->executeSingleCommands(QueueType::GRAPHICS, [&](auto* cmd) {
m_pDevice->executeSingleCommands(QueueType::Graphics, [&](auto* cmd) {
aph::vk::ImageBarrier barrier{
.pImage = depth,
.currentState = depth->getResourceState(),
Expand Down Expand Up @@ -533,7 +533,7 @@ void SceneRenderer::_initGeneral()
createInfo.samples = m_sampleCount;
VK_CHECK_RESULT(m_pDevice->create(createInfo, &depthImageMS));

m_pDevice->executeSingleCommands(QueueType::GRAPHICS, [&](auto* cmd) {
m_pDevice->executeSingleCommands(QueueType::Graphics, [&](auto* cmd) {
cmd->transitionImageLayout(depthImage, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL);
cmd->transitionImageLayout(depthImageMS, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL);
});
Expand Down Expand Up @@ -1060,7 +1060,7 @@ void SceneRenderer::_initShadow()
.format = m_pDevice->getDepthFormat(),
};
VK_CHECK_RESULT(m_pDevice->create(createInfo, &depth));
m_pDevice->executeSingleCommands(QueueType::GRAPHICS, [&](auto* cmd) {
m_pDevice->executeSingleCommands(QueueType::Graphics, [&](auto* cmd) {
cmd->transitionImageLayout(depth, VK_IMAGE_LAYOUT_DEPTH_ATTACHMENT_OPTIMAL);
});
}
Expand Down
2 changes: 1 addition & 1 deletion engine/renderer/api/vulkan/uiRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ UI::UI(const UICreateInfo& ci) :

// getQueue
{
m_pDefaultQueue = m_pDevice->getQueueByFlags(QueueType::GRAPHICS);
m_pDefaultQueue = m_pDevice->getQueueByFlags(QueueType::Graphics);
}

// init imgui
Expand Down
4 changes: 2 additions & 2 deletions engine/resource/resourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ void ResourceLoader::load(const ImageLoadInfo& info, vk::Image** ppImage)

APH_CHECK_RESULT(m_pDevice->create(imageCI, &image, info.debugName));

auto queue = m_pDevice->getQueueByFlags(QueueType::GRAPHICS);
auto queue = m_pDevice->getQueueByFlags(QueueType::Graphics);
m_pDevice->executeSingleCommands(queue, [&](vk::CommandBuffer* cmd) {
cmd->transitionImageLayout(image, aph::RESOURCE_STATE_COPY_DST);

Expand Down Expand Up @@ -745,7 +745,7 @@ void ResourceLoader::update(const BufferUpdateInfo& info, vk::Buffer** ppBuffer)
m_pDevice->unMapMemory(stagingBuffer);
}

auto queue = m_pDevice->getQueueByFlags(QueueType::GRAPHICS);
auto queue = m_pDevice->getQueueByFlags(QueueType::Graphics);
m_pDevice->executeSingleCommands(
queue, [&](vk::CommandBuffer* cmd) { cmd->copyBuffer(stagingBuffer, *ppBuffer, copyRange); });

Expand Down
4 changes: 2 additions & 2 deletions examples/basic_texture/basic_texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void basic_texture::init()

m_renderer->m_pResourceLoader->load(loadInfo, &m_pImage);

m_pDevice->executeSingleCommands(m_pDevice->getQueueByFlags(aph::QueueType::GRAPHICS),
m_pDevice->executeSingleCommands(m_pDevice->getQueueByFlags(aph::QueueType::Graphics),
[&](aph::vk::CommandBuffer* cmd) {
aph::vk::ImageBarrier barrier{
.pImage = m_pImage,
Expand Down Expand Up @@ -140,7 +140,7 @@ void basic_texture::run()

m_renderer->update(deltaTime);

auto* queue = m_renderer->getDefaultQueue(aph::QueueType::GRAPHICS);
auto* queue = m_renderer->getDefaultQueue(aph::QueueType::Graphics);

// draw and submit
m_renderer->beginFrame();
Expand Down
2 changes: 1 addition & 1 deletion examples/triangle_demo/triangle_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void triangle_demo::run()

m_renderer->update(deltaTime);

auto* queue = m_renderer->getDefaultQueue(aph::QueueType::GRAPHICS);
auto* queue = m_renderer->getDefaultQueue(aph::QueueType::Graphics);

// draw and submit
m_renderer->beginFrame();
Expand Down

0 comments on commit 683eb24

Please sign in to comment.