mirror of
https://github.com/MobileGL-Dev/MobileGL
synced 2026-09-09 12:48:32 +09:00
[Chore] (MG_Test/Backend/DirectVulkan/TestExec): FramebufferManager -> RenderTargetManager
This commit is contained in:
+1
-1
@@ -225,7 +225,7 @@ set(SOURCE_FILES
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateBuilder.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VertexInputStateFactory.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VkBufferObject.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VkFramebufferManager.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderTargetManager.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VkRenderPassManager.cpp
|
||||
MobileGL/MG_Backend/DirectVulkan/Renderer/VkTextureSamplerManager.cpp
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "UniformDescriptorBinder.h"
|
||||
|
||||
#include "VkFramebufferManager.h"
|
||||
#include "VkRenderTargetManager.h"
|
||||
#include "MG_State/GLState/Core.h"
|
||||
#include "MG_State/GLState/ProgramState/ProgramObject.h"
|
||||
#include "MG_Util/ShaderTranspiler/Types.h"
|
||||
@@ -139,7 +139,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VkDeviceSize minUniformBufferOffsetAlignment, Uint32 frameCount,
|
||||
Uint32 maxBindings, Uint32 setsPerFrame, VkDeviceSize perFrameUploadBytes,
|
||||
VkTextureSamplerManager* textureSamplerManager,
|
||||
VkFramebufferManager* framebufferManager) {
|
||||
VkRenderTargetManager* framebufferManager) {
|
||||
Shutdown();
|
||||
|
||||
MOBILEGL_ASSERT(device != VK_NULL_HANDLE, "UniformDescriptorBinder::Initialize requires valid VkDevice");
|
||||
@@ -481,8 +481,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
|
||||
if (m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColorTexture,
|
||||
VkFramebufferManager::TransitionUsage::ShaderRead,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColorTexture,
|
||||
VkRenderTargetManager::TransitionUsage::ShaderRead,
|
||||
texture->GetExternalIndex())) {
|
||||
VkImageView offscreenView = VK_NULL_HANDLE;
|
||||
if (m_framebufferManager->GetOffscreenColorViewByTexture(texture->GetExternalIndex(), offscreenView) &&
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace MobileGL::MG_State::GLState {
|
||||
}
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
class VkFramebufferManager;
|
||||
class VkRenderTargetManager;
|
||||
|
||||
class UniformDescriptorBinder {
|
||||
public:
|
||||
@@ -33,7 +33,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
Uint32 frameCount, Uint32 maxBindings = 16, Uint32 setsPerFrame = 64,
|
||||
VkDeviceSize perFrameUploadBytes = 4 * 1024 * 1024,
|
||||
VkTextureSamplerManager* textureSamplerManager = nullptr,
|
||||
VkFramebufferManager* framebufferManager = nullptr);
|
||||
VkRenderTargetManager* framebufferManager = nullptr);
|
||||
void Shutdown();
|
||||
|
||||
void BeginFrame(Uint32 frameIndex);
|
||||
@@ -98,7 +98,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
Uint32 m_setsPerFrame = 0;
|
||||
Uint32 m_peakDescriptorSetsObserved = 0;
|
||||
VkTextureSamplerManager* m_textureSamplerManager = nullptr;
|
||||
VkFramebufferManager* m_framebufferManager = nullptr;
|
||||
VkRenderTargetManager* m_framebufferManager = nullptr;
|
||||
};
|
||||
} // namespace MobileGL::MG_Backend::DirectVulkan
|
||||
|
||||
|
||||
+16
-16
@@ -6,19 +6,19 @@
|
||||
// SPDX-License-Identifier: LGPL-3.0-only
|
||||
// End of Source File Header
|
||||
|
||||
#include "VkFramebufferManager.h"
|
||||
#include "VkRenderTargetManager.h"
|
||||
|
||||
#include <MG_State/GLState/RenderbufferState/RenderbufferObject.h>
|
||||
#include <MG_State/GLState/TextureState/TextureEnum.h>
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
Bool VkFramebufferManager::Initialize(const InitInfo& initInfo) {
|
||||
Bool VkRenderTargetManager::Initialize(const InitInfo& initInfo) {
|
||||
m_device = initInfo.device;
|
||||
m_physicalDevice = initInfo.physicalDevice;
|
||||
return m_device != VK_NULL_HANDLE && m_physicalDevice != VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
void VkFramebufferManager::Shutdown() {
|
||||
void VkRenderTargetManager::Shutdown() {
|
||||
for (auto& [_, target] : m_offscreenColorTargets) {
|
||||
DestroyOffscreenColorTarget(target);
|
||||
}
|
||||
@@ -27,7 +27,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
m_physicalDevice = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::EnsureOffscreenColorTarget(Uint glFboExternalIndex,
|
||||
Bool VkRenderTargetManager::EnsureOffscreenColorTarget(Uint glFboExternalIndex,
|
||||
const MG_State::GLState::FramebufferObject& glFbo) {
|
||||
const auto& colorAttachment = glFbo.GetAttachment(FramebufferAttachmentType::Color0);
|
||||
if (!colorAttachment.IsValid() || colorAttachment.IsEmpty()) {
|
||||
@@ -44,7 +44,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return RecreateOffscreenColorTarget(target, glFbo, colorAttachment, objectVersion);
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::Transition(VkCommandBuffer commandBuffer, TransitionResource resource,
|
||||
Bool VkRenderTargetManager::Transition(VkCommandBuffer commandBuffer, TransitionResource resource,
|
||||
TransitionUsage usage, Uint externalIndex) {
|
||||
auto resolveDepthStencilAspectMask = [](VkFormat format) {
|
||||
VkImageAspectFlags aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||
@@ -169,7 +169,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::GetOffscreenColorImage(Uint glFboExternalIndex, VkImage& outImage,
|
||||
Bool VkRenderTargetManager::GetOffscreenColorImage(Uint glFboExternalIndex, VkImage& outImage,
|
||||
VkExtent2D& outExtent) const {
|
||||
auto it = m_offscreenColorTargets.find(glFboExternalIndex);
|
||||
if (it == m_offscreenColorTargets.end() || it->second.image == VK_NULL_HANDLE) {
|
||||
@@ -180,7 +180,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::GetOffscreenDepthStencilImage(Uint glFboExternalIndex, VkImage& outImage,
|
||||
Bool VkRenderTargetManager::GetOffscreenDepthStencilImage(Uint glFboExternalIndex, VkImage& outImage,
|
||||
VkExtent2D& outExtent, VkFormat& outFormat) const {
|
||||
auto it = m_offscreenColorTargets.find(glFboExternalIndex);
|
||||
if (it == m_offscreenColorTargets.end() || it->second.depthStencilImage == VK_NULL_HANDLE) {
|
||||
@@ -192,7 +192,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::GetOffscreenColorViewByTexture(Uint textureExternalIndex,
|
||||
Bool VkRenderTargetManager::GetOffscreenColorViewByTexture(Uint textureExternalIndex,
|
||||
VkImageView& outImageView) const {
|
||||
for (const auto& [_, target] : m_offscreenColorTargets) {
|
||||
if (target.colorTextureExternalIndex != textureExternalIndex || target.imageView == VK_NULL_HANDLE) {
|
||||
@@ -204,7 +204,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return false;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::GetOffscreenRenderSurface(Uint glFboExternalIndex, VkImageView& outColorView,
|
||||
Bool VkRenderTargetManager::GetOffscreenRenderSurface(Uint glFboExternalIndex, VkImageView& outColorView,
|
||||
VkFormat& outColorFormat, VkImageView& outDepthStencilView,
|
||||
VkFormat& outDepthStencilFormat, VkExtent2D& outExtent) const {
|
||||
auto it = m_offscreenColorTargets.find(glFboExternalIndex);
|
||||
@@ -219,7 +219,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::RecreateOffscreenColorTarget(
|
||||
Bool VkRenderTargetManager::RecreateOffscreenColorTarget(
|
||||
OffscreenColorTarget& target, const MG_State::GLState::FramebufferObject& glFbo,
|
||||
const MG_State::GLState::FramebufferAttachmentObject& colorAttachment, Uint16 glObjectVersion) {
|
||||
DestroyOffscreenColorTarget(target);
|
||||
@@ -354,7 +354,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
void VkFramebufferManager::DestroyOffscreenColorTarget(OffscreenColorTarget& target) {
|
||||
void VkRenderTargetManager::DestroyOffscreenColorTarget(OffscreenColorTarget& target) {
|
||||
if (target.imageView != VK_NULL_HANDLE) {
|
||||
vkDestroyImageView(m_device, target.imageView, nullptr);
|
||||
target.imageView = VK_NULL_HANDLE;
|
||||
@@ -388,7 +388,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
target.colorTextureExternalIndex = 0;
|
||||
}
|
||||
|
||||
Bool VkFramebufferManager::TransitionImageLayout(VkCommandBuffer commandBuffer, VkImage image,
|
||||
Bool VkRenderTargetManager::TransitionImageLayout(VkCommandBuffer commandBuffer, VkImage image,
|
||||
VkImageLayout& trackedLayout, VkImageLayout newLayout,
|
||||
VkPipelineStageFlags srcStageMask,
|
||||
VkPipelineStageFlags dstStageMask, VkAccessFlags srcAccessMask,
|
||||
@@ -420,7 +420,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return true;
|
||||
}
|
||||
|
||||
Uint32 VkFramebufferManager::FindMemoryType(Uint32 typeFilter, VkMemoryPropertyFlags properties) const {
|
||||
Uint32 VkRenderTargetManager::FindMemoryType(Uint32 typeFilter, VkMemoryPropertyFlags properties) const {
|
||||
VkPhysicalDeviceMemoryProperties memoryProperties{};
|
||||
vkGetPhysicalDeviceMemoryProperties(m_physicalDevice, &memoryProperties);
|
||||
for (Uint32 i = 0; i < memoryProperties.memoryTypeCount; ++i) {
|
||||
@@ -433,7 +433,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return 0;
|
||||
}
|
||||
|
||||
VkFormat VkFramebufferManager::ResolveColorFormat(
|
||||
VkFormat VkRenderTargetManager::ResolveColorFormat(
|
||||
const MG_State::GLState::FramebufferAttachmentObject& colorAttachment) {
|
||||
TextureInternalFormat internalFormat = TextureInternalFormat::Unknown;
|
||||
if (colorAttachment.IsTexture()) {
|
||||
@@ -454,7 +454,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
}
|
||||
|
||||
VkFormat VkFramebufferManager::ResolveDepthStencilFormat(
|
||||
VkFormat VkRenderTargetManager::ResolveDepthStencilFormat(
|
||||
const MG_State::GLState::FramebufferAttachmentObject& depthAttachment,
|
||||
const MG_State::GLState::FramebufferAttachmentObject& stencilAttachment) {
|
||||
const auto resolveAttachmentFormat = [](const MG_State::GLState::FramebufferAttachmentObject& attachment) {
|
||||
@@ -498,7 +498,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
}
|
||||
|
||||
VkFormat VkFramebufferManager::FindSupportedDepthStencilFormat(const Vector<VkFormat>& candidates) const {
|
||||
VkFormat VkRenderTargetManager::FindSupportedDepthStencilFormat(const Vector<VkFormat>& candidates) const {
|
||||
for (auto format : candidates) {
|
||||
VkFormatProperties properties{};
|
||||
vkGetPhysicalDeviceFormatProperties(m_physicalDevice, format, &properties);
|
||||
+3
-3
@@ -13,7 +13,7 @@
|
||||
#include <MG_State/GLState/FramebufferState/FramebufferObject.h>
|
||||
|
||||
namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
class VkFramebufferManager {
|
||||
class VkRenderTargetManager {
|
||||
public:
|
||||
enum class TransitionResource {
|
||||
OffscreenColor,
|
||||
@@ -34,8 +34,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE;
|
||||
};
|
||||
|
||||
VkFramebufferManager() = default;
|
||||
~VkFramebufferManager() = default;
|
||||
VkRenderTargetManager() = default;
|
||||
~VkRenderTargetManager() = default;
|
||||
|
||||
Bool Initialize(const InitInfo& initInfo);
|
||||
void Shutdown();
|
||||
@@ -222,7 +222,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
&m_config});
|
||||
MOBILEGL_ASSERT(succeeded, "VkTextureSamplerManager initialization failed.");
|
||||
|
||||
m_framebufferManager = MakeUnique<VkFramebufferManager>();
|
||||
m_framebufferManager = MakeUnique<VkRenderTargetManager>();
|
||||
MOBILEGL_ASSERT(m_framebufferManager != nullptr, "VkFramebufferManager creation failed.");
|
||||
succeeded = m_framebufferManager->Initialize({m_device, m_physicalDevice.handle});
|
||||
MOBILEGL_ASSERT(succeeded, "VkFramebufferManager initialization failed.");
|
||||
@@ -510,8 +510,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!m_framebufferManager->Transition(commandBuffer, VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::Attachment,
|
||||
if (!m_framebufferManager->Transition(commandBuffer, VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::Attachment,
|
||||
drawFboExternalIndex)) {
|
||||
MGLOG_D("EnsureFrameRecordingStarted skipped: failed to transition offscreen FBO %u for attachment",
|
||||
drawFboExternalIndex);
|
||||
@@ -1280,8 +1280,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
EnsureOffscreenRenderTarget(targetFboExternalIndex, *targetFbo, offscreenRenderPass,
|
||||
offscreenFramebuffer, offscreenExtent, offscreenDepthStencilFormat) &&
|
||||
m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::Attachment,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::Attachment,
|
||||
targetFboExternalIndex)) {
|
||||
m_renderPassManager->BeginRenderPass(commandBuffer, offscreenRenderPass, offscreenFramebuffer,
|
||||
offscreenExtent);
|
||||
@@ -1434,8 +1434,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VK_ACCESS_TRANSFER_READ_BIT);
|
||||
}
|
||||
} else if (!m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::TransferSrc,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::TransferSrc,
|
||||
readFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer skipped: failed to transition read FBO %u to transfer src",
|
||||
readFboExternalIndex);
|
||||
@@ -1452,16 +1452,16 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
} else if (sameImage) {
|
||||
if (!m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::General,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::General,
|
||||
drawFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer skipped: failed to transition draw FBO %u to general",
|
||||
drawFboExternalIndex);
|
||||
return false;
|
||||
}
|
||||
} else if (!m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::TransferDst,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::TransferDst,
|
||||
drawFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer skipped: failed to transition draw FBO %u to transfer dst",
|
||||
drawFboExternalIndex);
|
||||
@@ -1670,8 +1670,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
VK_ACCESS_TRANSFER_READ_BIT);
|
||||
}
|
||||
} else if (!m_framebufferManager->Transition(
|
||||
commandBuffer, VkFramebufferManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkFramebufferManager::TransitionUsage::TransferSrc, readFboExternalIndex)) {
|
||||
commandBuffer, VkRenderTargetManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkRenderTargetManager::TransitionUsage::TransferSrc, readFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer: failed to transition read depth/stencil FBO %u to transfer src",
|
||||
readFboExternalIndex);
|
||||
}
|
||||
@@ -1688,14 +1688,14 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
}
|
||||
} else if (sameDepthImage) {
|
||||
if (!m_framebufferManager->Transition(
|
||||
commandBuffer, VkFramebufferManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkFramebufferManager::TransitionUsage::General, drawFboExternalIndex)) {
|
||||
commandBuffer, VkRenderTargetManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkRenderTargetManager::TransitionUsage::General, drawFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer: failed to transition draw depth/stencil FBO %u to general",
|
||||
drawFboExternalIndex);
|
||||
}
|
||||
} else if (!m_framebufferManager->Transition(
|
||||
commandBuffer, VkFramebufferManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkFramebufferManager::TransitionUsage::TransferDst, drawFboExternalIndex)) {
|
||||
commandBuffer, VkRenderTargetManager::TransitionResource::OffscreenDepthStencil,
|
||||
VkRenderTargetManager::TransitionUsage::TransferDst, drawFboExternalIndex)) {
|
||||
MGLOG_W("BlitFramebuffer: failed to transition draw depth/stencil FBO %u to transfer dst",
|
||||
drawFboExternalIndex);
|
||||
}
|
||||
@@ -1851,8 +1851,8 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
return false;
|
||||
}
|
||||
if (!m_framebufferManager->Transition(commandBuffer,
|
||||
VkFramebufferManager::TransitionResource::OffscreenColor,
|
||||
VkFramebufferManager::TransitionUsage::Attachment,
|
||||
VkRenderTargetManager::TransitionResource::OffscreenColor,
|
||||
VkRenderTargetManager::TransitionUsage::Attachment,
|
||||
targetFboExternalIndex)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "UniformDescriptorBinder.h"
|
||||
#include "VertexInputStateFactory.h"
|
||||
#include "VkBufferObject.h"
|
||||
#include "VkFramebufferManager.h"
|
||||
#include "VkRenderTargetManager.h"
|
||||
#include "VkRenderPassManager.h"
|
||||
#include "VkTextureSamplerManager.h"
|
||||
#include "MG_Util/Math/VectorTypes.h"
|
||||
@@ -152,7 +152,7 @@ namespace MobileGL::MG_Backend::DirectVulkan {
|
||||
UniquePtr<ProgramFactory> m_programFactory;
|
||||
UniquePtr<UniformDescriptorBinder> m_uniformDescriptorBinder;
|
||||
UniquePtr<VertexInputStateFactory> m_vertexInputStateFactory;
|
||||
UniquePtr<VkFramebufferManager> m_framebufferManager;
|
||||
UniquePtr<VkRenderTargetManager> m_framebufferManager;
|
||||
UniquePtr<VkRenderPassManager> m_renderPassManager;
|
||||
UniquePtr<VkTextureSamplerManager> m_textureSamplerManager;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user