From 041d9ea4227af260c3b7fbc3f7c64a2b04a1c88c Mon Sep 17 00:00:00 2001 From: ssdfasd <2156608475@qq.com> Date: Sun, 15 Mar 2026 20:20:32 +0800 Subject: [PATCH] Add Types.h with generic cross-platform types for RHI abstraction layer --- engine/include/XCEngine/RHI/Types.h | 224 ++++++++++++++++++++++++++++ 1 file changed, 224 insertions(+) create mode 100644 engine/include/XCEngine/RHI/Types.h diff --git a/engine/include/XCEngine/RHI/Types.h b/engine/include/XCEngine/RHI/Types.h new file mode 100644 index 00000000..f890096f --- /dev/null +++ b/engine/include/XCEngine/RHI/Types.h @@ -0,0 +1,224 @@ +#pragma once + +#include +#include +#include + +namespace XCEngine { +namespace RHI { + +struct Viewport { + float topLeftX; + float topLeftY; + float width; + float height; + float minDepth; + float maxDepth; +}; + +struct Rect { + int32_t left; + int32_t top; + int32_t right; + int32_t bottom; +}; + +struct Color { + float r; + float g; + float b; + float a; +}; + +struct ClearValue { + Color color; + float depth; + uint8_t stencil; +}; + +struct ShaderCompileMacro { + std::wstring name; + std::wstring definition; +}; + +struct ShaderCompileDesc { + std::wstring entryPoint; + std::wstring profile; + std::wstring fileName; + std::vector macros; +}; + +struct InputElementDesc { + std::string semanticName; + uint32_t semanticIndex; + uint32_t format; + uint32_t inputSlot; + uint32_t alignedByteOffset; + uint32_t inputSlotClass; + uint32_t instanceDataStepRate; +}; + +struct InputLayoutDesc { + std::vector elements; +}; + +struct VertexBufferBinding { + uint64_t bufferLocation; + uint32_t sizeInBytes; + uint32_t strideInBytes; +}; + +struct TextureCopyLocation { + uint64_t plSubresourceIndex; + void* pResource; +}; + +struct DescriptorHandle { + uint64_t ptr; +}; + +struct GPUDescriptorHandle { + uint64_t ptr; +}; + +struct CPUDescriptorHandle { + uint64_t ptr; +}; + +struct SubresourceRange { + uint32_t baseMipLevel; + uint32_t mipLevels; + uint32_t baseArraySlice; + uint32_t arraySize; +}; + +struct TextureDesc { + uint32_t width; + uint32_t height; + uint32_t depth; + uint32_t mipLevels; + uint32_t arraySize; + uint32_t format; + uint32_t textureType; + uint32_t sampleCount; + uint32_t sampleQuality; + uint64_t flags; +}; + +struct BufferDesc { + uint64_t size; + uint32_t stride; + uint32_t bufferType; + uint64_t flags; +}; + +struct RenderTargetDesc { + uint32_t width; + uint32_t height; + uint32_t format; + uint32_t sampleCount; + uint32_t sampleQuality; +}; + +struct DepthStencilDesc { + uint32_t width; + uint32_t height; + uint32_t format; + uint32_t sampleCount; + uint32_t sampleQuality; + bool depthEnable; + bool stencilEnable; +}; + +struct DescriptorHeapDesc { + uint32_t descriptorCount; + uint32_t heapType; + uint32_t flags; + uint32_t nodeMask; +}; + +struct CommandQueueDesc { + uint32_t queueType; + uint32_t priority; + uint32_t nodeMask; + uint64_t flags; +}; + +struct CommandListDesc { + uint32_t commandListType; + uint32_t nodeMask; +}; + +struct CommandAllocatorDesc { + uint32_t commandListType; +}; + +struct FenceDesc { + uint64_t initialValue; + uint32_t flags; +}; + +struct QueryHeapDesc { + uint32_t queryType; + uint32_t count; + uint32_t nodeMask; +}; + +struct SamplerDesc { + uint32_t filter; + uint32_t addressU; + uint32_t addressV; + uint32_t addressW; + float mipLodBias; + uint32_t maxAnisotropy; + uint32_t comparisonFunc; + float borderColorR; + float borderColorG; + float borderColorB; + float borderColorA; + float minLod; + float maxLod; +}; + +struct SwapChainDesc { + uint32_t width; + uint32_t height; + uint32_t bufferCount; + uint32_t format; + uint32_t refreshRate; + uint32_t sampleCount; + uint32_t sampleQuality; + uint32_t swapEffect; + uint32_t flags; +}; + +struct RenderTargetViewDesc { + uint32_t format; + uint32_t viewDimension; + uint32_t mipSlice; + uint32_t firstArraySlice; + uint32_t arraySize; +}; + +struct DepthStencilViewDesc { + uint32_t format; + uint32_t viewDimension; + uint32_t mipSlice; + uint32_t firstArraySlice; + uint32_t arraySize; +}; + +struct ShaderResourceViewDesc { + uint32_t format; + uint32_t viewDimension; + uint32_t shader4ComponentMapping; + TextureDesc textureDesc; +}; + +struct ConstantBufferViewDesc { + uint64_t bufferLocation; + uint32_t sizeInBytes; +}; + +} // namespace RHI +} // namespace XCEngine