D3D12: Fix texture ownership semantics and remove GetSwapChain() exposure
This commit fixes the D3D12 texture architecture issues: 1. D3D12Texture ownership semantics: - Add m_ownsResource member to track resource ownership - InitializeFromExisting() now takes ownsResource parameter (default false) - Shutdown() only releases resource if ownsResource is true - Initialize() sets m_ownsResource = true for created resources 2. D3D12SwapChain changes: - Remove GetSwapChain() method (was exposing native D3D12 API) - Change GetBackBuffer() to return reference instead of pointer - Back buffers initialized with ownsResource = false 3. minimal/main.cpp updates: - Remove gColorRTs[2] array (was duplicating back buffer wrapping) - Direct use of gSwapChain.GetBackBuffer(i) instead - All references updated to use encapsulated API 4. Documentation: - Update TEST_SPEC.md v1.3 - Remove known limitation 7.2 (minimal GetBuffer issue fixed) - Add D3D12_Texture_Architecture_Fix_Plan.md design document
This commit is contained in:
@@ -25,7 +25,8 @@ public:
|
||||
|
||||
uint32_t GetCurrentBackBufferIndex() const override;
|
||||
RHITexture* GetCurrentBackBuffer() override;
|
||||
D3D12Texture* GetBackBuffer(uint32_t index) const;
|
||||
D3D12Texture& GetBackBuffer(uint32_t index);
|
||||
const D3D12Texture& GetBackBuffer(uint32_t index) const;
|
||||
void Present(uint32_t syncInterval = 1, uint32_t flags = 0) override;
|
||||
void Resize(uint32_t width, uint32_t height) override;
|
||||
void SetFullscreen(bool fullscreen) override;
|
||||
@@ -36,8 +37,6 @@ public:
|
||||
void SetShouldClose(bool shouldClose) override;
|
||||
void PollEvents() override;
|
||||
|
||||
IDXGISwapChain3* GetSwapChain() const { return m_swapChain.Get(); }
|
||||
|
||||
private:
|
||||
ComPtr<IDXGISwapChain3> m_swapChain;
|
||||
ComPtr<ID3D12CommandQueue> m_commandQueue;
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
~D3D12Texture() override;
|
||||
|
||||
bool Initialize(ID3D12Device* device, const D3D12_RESOURCE_DESC& desc, D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON);
|
||||
bool InitializeFromExisting(ID3D12Resource* resource);
|
||||
bool InitializeFromExisting(ID3D12Resource* resource, bool ownsResource = false);
|
||||
bool InitializeFromData(ID3D12Device* device, ID3D12GraphicsCommandList* commandList,
|
||||
const void* pixelData, uint32_t width, uint32_t height, DXGI_FORMAT format);
|
||||
bool InitializeDepthStencil(ID3D12Device* device, uint32_t width, uint32_t height, DXGI_FORMAT format = DXGI_FORMAT_D24_UNORM_S8_UINT);
|
||||
@@ -46,10 +46,13 @@ public:
|
||||
Format GetFormat() const override { return static_cast<Format>(GetDesc().Format); }
|
||||
TextureType GetTextureType() const override { return TextureType::Texture2D; }
|
||||
|
||||
bool OwnsResource() const { return m_ownsResource; }
|
||||
|
||||
private:
|
||||
ComPtr<ID3D12Resource> m_resource;
|
||||
ResourceStates m_state = ResourceStates::Common;
|
||||
std::string m_name;
|
||||
bool m_ownsResource = false;
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
|
||||
Reference in New Issue
Block a user