- Fix D3D12Texture::GetTextureType() to return correct type based on D3D12 resource dimension - Fix OpenGL CommandQueue::Signal() to properly call fence->Signal() - Fix OpenGL CommandQueue::GetTimestampFrequency() using GL_TIMESTAMP - Fix OpenGL Device::GetNativeDevice() to return m_hglrc - Fix OpenGL Fence::Signal() to create GL sync object and update completedValue - Fix OpenGL Fence::Wait() to properly wait for fence - Fix OpenGL Fence::GetNativeHandle() to create sync on first call - Fix OpenGL SwapChain::GetCurrentBackBuffer() to return backbuffer texture - Fix OpenGL SwapChain::Initialize() to create backbuffer texture - Fix OpenGL SwapChain::Shutdown() to cleanup backbuffer texture - Fix RHI unit tests: add missing sampleCount/sampleQuality/depth/arraySize fields - Fix RHI unit tests: add complete TextureDesc fields where needed
67 lines
2.6 KiB
C++
67 lines
2.6 KiB
C++
#pragma once
|
|
|
|
#include <d3d12.h>
|
|
#include <wrl/client.h>
|
|
#include <string>
|
|
|
|
#include "../RHITexture.h"
|
|
#include "D3D12Enums.h"
|
|
|
|
using Microsoft::WRL::ComPtr;
|
|
|
|
namespace XCEngine {
|
|
namespace RHI {
|
|
|
|
class D3D12Texture : public RHITexture {
|
|
public:
|
|
D3D12Texture();
|
|
~D3D12Texture() override;
|
|
|
|
bool Initialize(ID3D12Device* device, const D3D12_RESOURCE_DESC& desc, D3D12_RESOURCE_STATES initialState = D3D12_RESOURCE_STATE_COMMON);
|
|
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);
|
|
void Shutdown() override;
|
|
|
|
ID3D12Resource* GetResource() const { return m_resource.Get(); }
|
|
D3D12_RESOURCE_DESC GetDesc() const { return m_resource->GetDesc(); }
|
|
|
|
uint32_t GetWidth() const override { return static_cast<uint32_t>(GetDesc().Width); }
|
|
uint32_t GetHeight() const override { return GetDesc().Height; }
|
|
uint32_t GetDepth() const override { return GetDesc().DepthOrArraySize; }
|
|
uint32_t GetMipLevels() const override { return GetDesc().MipLevels; }
|
|
|
|
void* GetNativeHandle() override { return m_resource.Get(); }
|
|
ResourceStates GetState() const override { return m_state; }
|
|
void SetState(ResourceStates state) override { m_state = state; }
|
|
|
|
uint64_t GetGPUAddress() const { return m_resource->GetGPUVirtualAddress(); }
|
|
size_t GetSize() const { return GetDesc().Width * GetDesc().Height * GetDesc().DepthOrArraySize; }
|
|
|
|
const std::string& GetName() const override { return m_name; }
|
|
void SetName(const std::string& name) override { m_name = name; }
|
|
|
|
uint32_t GetArraySize() const { return GetDesc().DepthOrArraySize; }
|
|
Format GetFormat() const override { return static_cast<Format>(GetDesc().Format); }
|
|
TextureType GetTextureType() const override {
|
|
switch (GetDesc().Dimension) {
|
|
case D3D12_RESOURCE_DIMENSION_TEXTURE1D: return TextureType::Texture1D;
|
|
case D3D12_RESOURCE_DIMENSION_TEXTURE2D: return TextureType::Texture2D;
|
|
case D3D12_RESOURCE_DIMENSION_TEXTURE3D: return TextureType::Texture3D;
|
|
default: 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
|
|
} // namespace XCEngine
|