Add XCUI new editor sandbox phase 1
This commit is contained in:
120
new_editor/src/XCUIBackend/XCUIRHIRenderBackend.h
Normal file
120
new_editor/src/XCUIBackend/XCUIRHIRenderBackend.h
Normal file
@@ -0,0 +1,120 @@
|
||||
#pragma once
|
||||
|
||||
#include "IXCUITextAtlasProvider.h"
|
||||
|
||||
#include <XCEngine/Rendering/RenderContext.h>
|
||||
#include <XCEngine/Rendering/RenderSurface.h>
|
||||
#include <XCEngine/RHI/RHIBuffer.h>
|
||||
#include <XCEngine/RHI/RHICommandList.h>
|
||||
#include <XCEngine/RHI/RHIDescriptorPool.h>
|
||||
#include <XCEngine/RHI/RHIDescriptorSet.h>
|
||||
#include <XCEngine/RHI/RHIEnums.h>
|
||||
#include <XCEngine/RHI/RHIPipelineLayout.h>
|
||||
#include <XCEngine/RHI/RHIPipelineState.h>
|
||||
#include <XCEngine/RHI/RHIResourceView.h>
|
||||
#include <XCEngine/RHI/RHISampler.h>
|
||||
#include <XCEngine/RHI/RHITexture.h>
|
||||
#include <XCEngine/UI/DrawData.h>
|
||||
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace XCEngine {
|
||||
namespace Editor {
|
||||
namespace XCUIBackend {
|
||||
|
||||
class XCUIRHIRenderBackend {
|
||||
public:
|
||||
struct OverlayStats {
|
||||
std::size_t drawListCount = 0;
|
||||
std::size_t commandCount = 0;
|
||||
std::size_t batchCount = 0;
|
||||
std::size_t colorBatchCount = 0;
|
||||
std::size_t texturedBatchCount = 0;
|
||||
std::size_t scissoredBatchCount = 0;
|
||||
std::size_t renderedCommandCount = 0;
|
||||
std::size_t skippedCommandCount = 0;
|
||||
std::size_t textureResolveCount = 0;
|
||||
std::size_t textureCacheHitCount = 0;
|
||||
std::size_t vertexCount = 0;
|
||||
std::size_t triangleCount = 0;
|
||||
};
|
||||
|
||||
void SetTextAtlasProvider(const IXCUITextAtlasProvider* provider);
|
||||
const IXCUITextAtlasProvider* GetTextAtlasProvider() const { return m_textAtlasProvider; }
|
||||
void Shutdown();
|
||||
void ResetStats();
|
||||
bool Render(
|
||||
const ::XCEngine::Rendering::RenderContext& renderContext,
|
||||
const ::XCEngine::Rendering::RenderSurface& surface,
|
||||
const ::XCEngine::UI::UIDrawData& drawData);
|
||||
const OverlayStats& GetLastStats() const { return m_lastOverlayStats; }
|
||||
const OverlayStats& GetLastOverlayStats() const { return m_lastOverlayStats; }
|
||||
|
||||
private:
|
||||
using TextFontHandle = IXCUITextAtlasProvider::FontHandle;
|
||||
|
||||
struct ExternalTextureBinding {
|
||||
std::uintptr_t handleKey = 0;
|
||||
::XCEngine::RHI::RHIResourceView* shaderView = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorSet* textureSet = nullptr;
|
||||
};
|
||||
|
||||
bool EnsureInitialized(const ::XCEngine::Rendering::RenderContext& renderContext);
|
||||
bool CreateResources(const ::XCEngine::Rendering::RenderContext& renderContext);
|
||||
bool CreateOverlayResources();
|
||||
bool CreateTexturedOverlayResources();
|
||||
const IXCUITextAtlasProvider* ResolveActiveTextAtlasProvider(bool& outFontAtlasReady);
|
||||
bool EnsureOverlayVertexBufferCapacity(std::size_t requiredVertexCount);
|
||||
bool EnsureTexturedOverlayVertexBufferCapacity(std::size_t requiredVertexCount);
|
||||
bool EnsureFontAtlasResources(const IXCUITextAtlasProvider& atlasProvider);
|
||||
void ResetFontAtlasResources();
|
||||
::XCEngine::RHI::RHIDescriptorSet* ResolveTextureSet(
|
||||
const ::XCEngine::UI::UITextureHandle& texture,
|
||||
bool* outCacheHit = nullptr);
|
||||
bool RenderCompiledDrawData(
|
||||
::XCEngine::RHI::RHICommandList& commandList,
|
||||
::XCEngine::RHI::RHIResourceView* renderTarget,
|
||||
const ::XCEngine::Rendering::RenderSurface& surface,
|
||||
const ::XCEngine::UI::UIDrawData& drawData,
|
||||
const IXCUITextAtlasProvider* atlasProvider,
|
||||
bool fontAtlasReady);
|
||||
void DestroyResources();
|
||||
|
||||
const IXCUITextAtlasProvider* m_textAtlasProvider = nullptr;
|
||||
::XCEngine::RHI::RHIDevice* m_device = nullptr;
|
||||
::XCEngine::RHI::RHIType m_backendType = ::XCEngine::RHI::RHIType::D3D12;
|
||||
::XCEngine::RHI::RHIPipelineLayout* m_overlayPipelineLayout = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorPool* m_overlayConstantPool = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorSet* m_overlayConstantSet = nullptr;
|
||||
::XCEngine::RHI::RHIPipelineState* m_overlayPipelineState = nullptr;
|
||||
::XCEngine::RHI::RHIPipelineLayout* m_texturedOverlayPipelineLayout = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorPool* m_overlayTexturePool = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorSet* m_overlayFontTextureSet = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorPool* m_overlaySamplerPool = nullptr;
|
||||
::XCEngine::RHI::RHIDescriptorSet* m_overlaySamplerSet = nullptr;
|
||||
::XCEngine::RHI::RHIPipelineState* m_texturedOverlayPipelineState = nullptr;
|
||||
::XCEngine::RHI::RHISampler* m_overlaySampler = nullptr;
|
||||
::XCEngine::RHI::RHITexture* m_overlayFontTexture = nullptr;
|
||||
::XCEngine::RHI::RHIResourceView* m_overlayFontTextureView = nullptr;
|
||||
::XCEngine::UI::UITextureHandle m_overlayFontTextureHandle = {};
|
||||
::XCEngine::RHI::RHIBuffer* m_overlayVertexBuffer = nullptr;
|
||||
::XCEngine::RHI::RHIResourceView* m_overlayVertexBufferView = nullptr;
|
||||
::XCEngine::RHI::RHIBuffer* m_texturedOverlayVertexBuffer = nullptr;
|
||||
::XCEngine::RHI::RHIResourceView* m_texturedOverlayVertexBufferView = nullptr;
|
||||
std::uint64_t m_overlayVertexBufferCapacity = 0;
|
||||
std::uint64_t m_texturedOverlayVertexBufferCapacity = 0;
|
||||
TextFontHandle m_overlayFont = {};
|
||||
std::uintptr_t m_fontAtlasStorageKey = 0;
|
||||
std::uintptr_t m_fontAtlasPixelDataKey = 0;
|
||||
int m_fontAtlasWidth = 0;
|
||||
int m_fontAtlasHeight = 0;
|
||||
int m_fontAtlasStride = 0;
|
||||
std::vector<ExternalTextureBinding> m_externalTextureBindings = {};
|
||||
OverlayStats m_lastOverlayStats = {};
|
||||
};
|
||||
|
||||
} // namespace XCUIBackend
|
||||
} // namespace Editor
|
||||
} // namespace XCEngine
|
||||
Reference in New Issue
Block a user