refactor: move viewport texture bridge into imgui backend
This commit is contained in:
@@ -10,8 +10,7 @@
|
||||
|
||||
#include <XCEngine/Components/CameraComponent.h>
|
||||
#include <XCEngine/Components/GameObject.h>
|
||||
#include <XCEngine/RHI/D3D12/D3D12Device.h>
|
||||
#include <XCEngine/RHI/D3D12/D3D12Texture.h>
|
||||
#include <XCEngine/RHI/RHIDevice.h>
|
||||
#include <XCEngine/RHI/RHIEnums.h>
|
||||
#include <XCEngine/RHI/RHIResourceView.h>
|
||||
#include <XCEngine/RHI/RHITexture.h>
|
||||
@@ -127,7 +126,7 @@ public:
|
||||
void Initialize(UI::ImGuiBackendBridge& backend, RHI::RHIDevice* device) {
|
||||
Shutdown();
|
||||
m_backend = &backend;
|
||||
m_device = device ? static_cast<RHI::D3D12Device*>(device) : nullptr;
|
||||
m_device = device;
|
||||
}
|
||||
|
||||
void Shutdown() {
|
||||
@@ -497,24 +496,12 @@ private:
|
||||
}
|
||||
|
||||
bool CreateViewportTextureDescriptor(ViewportEntry& entry) {
|
||||
m_backend->AllocateTextureDescriptor(&entry.imguiCpuHandle, &entry.imguiGpuHandle);
|
||||
if (entry.imguiCpuHandle.ptr == 0 || entry.imguiGpuHandle.ptr == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto* nativeTexture = static_cast<RHI::D3D12Texture*>(entry.colorTexture);
|
||||
D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = {};
|
||||
srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
|
||||
srvDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
srvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
|
||||
srvDesc.Texture2D.MipLevels = 1;
|
||||
m_device->GetDevice()->CreateShaderResourceView(
|
||||
nativeTexture->GetResource(),
|
||||
&srvDesc,
|
||||
entry.imguiCpuHandle);
|
||||
|
||||
entry.textureId = static_cast<ImTextureID>(entry.imguiGpuHandle.ptr);
|
||||
return true;
|
||||
return m_backend->CreateTextureDescriptor(
|
||||
m_device,
|
||||
entry.colorTexture,
|
||||
&entry.imguiCpuHandle,
|
||||
&entry.imguiGpuHandle,
|
||||
&entry.textureId);
|
||||
}
|
||||
|
||||
bool EnsureViewportResources(ViewportEntry& entry) {
|
||||
@@ -1016,7 +1003,7 @@ private:
|
||||
}
|
||||
|
||||
UI::ImGuiBackendBridge* m_backend = nullptr;
|
||||
RHI::D3D12Device* m_device = nullptr;
|
||||
RHI::RHIDevice* m_device = nullptr;
|
||||
std::unique_ptr<Rendering::SceneRenderer> m_sceneRenderer;
|
||||
Rendering::RenderContext m_sceneViewLastRenderContext = {};
|
||||
std::array<ViewportEntry, 2> m_entries = {};
|
||||
|
||||
Reference in New Issue
Block a user