refactor: 添加RHI Enums.h并在D3D12测试中替换部分D3D12枚举
This commit is contained in:
@@ -33,23 +33,7 @@ enum class BlendOp : uint8_t {
|
||||
Subtract = 2,
|
||||
ReverseSubtract = 3,
|
||||
Min = 4,
|
||||
Max = 5,
|
||||
LogicalClear = 8,
|
||||
LogicalSet = 9,
|
||||
LogicalCopy = 10,
|
||||
LogicalCopyInverted = 11,
|
||||
LogicalNoop = 12,
|
||||
LogicalInvert = 13,
|
||||
LogicalAnd = 14,
|
||||
LogicalNand = 15,
|
||||
LogicalOr = 16,
|
||||
LogicalNor = 17,
|
||||
LogicalXor = 18,
|
||||
LogicalEquiv = 19,
|
||||
LogicalAndReverse = 20,
|
||||
LogicalAndInverted = 21,
|
||||
LogicalOrReverse = 22,
|
||||
LogicalOrInverted = 23
|
||||
Max = 5
|
||||
};
|
||||
|
||||
enum class BlendFactor : uint8_t {
|
||||
@@ -155,44 +139,18 @@ enum class PresentFlags : uint8_t {
|
||||
AllowDisplayLatencyWaitableObject = 4
|
||||
};
|
||||
|
||||
enum class IndirectDrawArguments : uint32_t {
|
||||
VertexCountPerInstance = 0,
|
||||
InstanceCount = 4,
|
||||
StartVertexLocation = 8,
|
||||
StartInstanceLocation = 12
|
||||
};
|
||||
|
||||
enum class IndirectDispatchArguments : uint32_t {
|
||||
ThreadGroupCountX = 0,
|
||||
ThreadGroupCountY = 4,
|
||||
ThreadGroupCountZ = 8
|
||||
};
|
||||
|
||||
enum class StencilOpDesc : uint8_t {
|
||||
StencilFailOp,
|
||||
StencilDepthFailOp,
|
||||
StencilPassOp,
|
||||
StencilFunc
|
||||
};
|
||||
|
||||
enum class BlendStateFlag : uint8_t {
|
||||
None = 0,
|
||||
IndependentBlendEnable = 1,
|
||||
IndependentBlendEnable_8Targets = 2
|
||||
};
|
||||
|
||||
enum class DepthStencilStateFlag : uint8_t {
|
||||
None = 0,
|
||||
DepthWrite = 1,
|
||||
StencilWrite = 2
|
||||
};
|
||||
|
||||
enum class TextureAddressMode : uint8_t {
|
||||
Wrap = 1,
|
||||
Mirror = 2,
|
||||
Clamp = 3,
|
||||
Border = 4,
|
||||
MirrorOnce = 5
|
||||
enum class PrimitiveTopology : uint8_t {
|
||||
Undefined = 0,
|
||||
PointList = 1,
|
||||
LineList = 2,
|
||||
LineStrip = 3,
|
||||
TriangleList = 4,
|
||||
TriangleStrip = 5,
|
||||
LineListAdj = 10,
|
||||
LineStripAdj = 11,
|
||||
TriangleListAdj = 12,
|
||||
TriangleStripAdj = 13,
|
||||
PatchList = 33
|
||||
};
|
||||
|
||||
enum class FilterMode : uint8_t {
|
||||
@@ -210,6 +168,14 @@ enum class FilterMode : uint8_t {
|
||||
MaximumAnisotropic = 13
|
||||
};
|
||||
|
||||
enum class TextureAddressMode : uint8_t {
|
||||
Wrap = 1,
|
||||
Mirror = 2,
|
||||
Clamp = 3,
|
||||
Border = 4,
|
||||
MirrorOnce = 5
|
||||
};
|
||||
|
||||
enum class BorderColor : uint8_t {
|
||||
TransparentBlack = 0,
|
||||
OpaqueBlack = 1,
|
||||
@@ -247,10 +213,15 @@ inline ColorWriteMask operator|(ColorWriteMask a, ColorWriteMask b) {
|
||||
return static_cast<ColorWriteMask>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
|
||||
}
|
||||
|
||||
enum class ResourceBarrierType : uint8_t {
|
||||
Transition,
|
||||
Aliasing,
|
||||
UAV
|
||||
enum class ShaderVisibility : uint8_t {
|
||||
All = 0,
|
||||
Vertex = 1,
|
||||
Hull = 2,
|
||||
Domain = 3,
|
||||
Geometry = 4,
|
||||
Pixel = 5,
|
||||
Amplification = 6,
|
||||
Mesh = 7
|
||||
};
|
||||
|
||||
enum class RootParameterType : uint8_t {
|
||||
@@ -261,58 +232,40 @@ enum class RootParameterType : uint8_t {
|
||||
UAV
|
||||
};
|
||||
|
||||
enum class ShaderRegisterType : uint8_t {
|
||||
CBV,
|
||||
SRV,
|
||||
UAV,
|
||||
Sampler
|
||||
enum class DescriptorHeapType : uint8_t {
|
||||
CBV_SRV_UAV,
|
||||
Sampler,
|
||||
RTV,
|
||||
DSV
|
||||
};
|
||||
|
||||
enum class RootSignatureVersion : uint8_t {
|
||||
Version1,
|
||||
Version1_0 = Version1,
|
||||
Version1_1
|
||||
enum class QueryType : uint8_t {
|
||||
Occlusion,
|
||||
Timestamp,
|
||||
PipelineStatistics
|
||||
};
|
||||
|
||||
enum class ClearDepthStencilFlags : uint8_t {
|
||||
Depth = 1,
|
||||
Stencil = 2,
|
||||
DepthAndStencil = 3
|
||||
};
|
||||
|
||||
enum class QueryHeapFlags : uint8_t {
|
||||
None = 0,
|
||||
Precision = 1
|
||||
};
|
||||
|
||||
enum class PipelineStateFlags : uint8_t {
|
||||
None = 0,
|
||||
DebugName = 1
|
||||
};
|
||||
|
||||
enum class BufferUAVFlags : uint8_t {
|
||||
None = 0,
|
||||
Raw = 1,
|
||||
Append = 2,
|
||||
Counter = 4
|
||||
};
|
||||
|
||||
enum class TextureLayout : uint8_t {
|
||||
Unknown,
|
||||
RowMajor,
|
||||
_64KB_UNDEFINED_SWIZZLE,
|
||||
Standard64KB
|
||||
};
|
||||
|
||||
enum class CommandListFlags : uint8_t {
|
||||
None = 0,
|
||||
DisallowSetName = 1
|
||||
};
|
||||
|
||||
enum class FenceFlags : uint8_t {
|
||||
None = 0,
|
||||
Signal = 1,
|
||||
Wait = 2
|
||||
enum class Format : uint32_t {
|
||||
Unknown = 0,
|
||||
R8_UNorm = 61,
|
||||
R8G8_UNorm = 49,
|
||||
R8G8B8A8_UNorm = 28,
|
||||
R16G16B16A16_Float = 10,
|
||||
R32G32B32A32_Float = 2,
|
||||
R16_Float = 54,
|
||||
R32_Float = 41,
|
||||
D16_UNorm = 55,
|
||||
D24_UNorm_S8_UInt = 45,
|
||||
D32_Float = 40,
|
||||
BC1_UNorm = 71,
|
||||
BC2_UNorm = 74,
|
||||
BC3_UNorm = 77,
|
||||
BC4_UNorm = 80,
|
||||
BC5_UNorm = 83,
|
||||
BC6H_UF16 = 95,
|
||||
BC7_UNorm = 98,
|
||||
R32G32B32A32_UInt = 23,
|
||||
R32_UInt = 39
|
||||
};
|
||||
|
||||
} // namespace RHI
|
||||
|
||||
@@ -11,6 +11,9 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
#include "stbi/stb_image.h"
|
||||
#include "RHI/Enums.h"
|
||||
|
||||
using namespace XCEngine::RHI;
|
||||
|
||||
#pragma comment(lib,"d3d12.lib")
|
||||
#pragma comment(lib,"dxgi.lib")
|
||||
@@ -205,13 +208,13 @@ D3D12_RESOURCE_BARRIER InitResourceBarrier(
|
||||
ID3D12RootSignature* InitRootSignature() {
|
||||
D3D12_ROOT_PARAMETER rootParameters[4];
|
||||
rootParameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
|
||||
rootParameters[1].ShaderVisibility = D3D12_SHADER_VISIBILITY_VERTEX;
|
||||
rootParameters[1].ShaderVisibility = static_cast<D3D12_SHADER_VISIBILITY>(ShaderVisibility::Vertex);
|
||||
rootParameters[1].Constants.RegisterSpace = 0;
|
||||
rootParameters[1].Constants.ShaderRegister = 0;
|
||||
rootParameters[1].Constants.Num32BitValues = 4;
|
||||
|
||||
rootParameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
|
||||
rootParameters[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
|
||||
rootParameters[0].ShaderVisibility = static_cast<D3D12_SHADER_VISIBILITY>(ShaderVisibility::All);
|
||||
rootParameters[0].Descriptor.RegisterSpace = 0;
|
||||
rootParameters[0].Descriptor.ShaderRegister = 1;
|
||||
|
||||
@@ -223,26 +226,26 @@ ID3D12RootSignature* InitRootSignature() {
|
||||
descriptorRange[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
|
||||
|
||||
rootParameters[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
|
||||
rootParameters[2].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||
rootParameters[2].ShaderVisibility = static_cast<D3D12_SHADER_VISIBILITY>(ShaderVisibility::Pixel);
|
||||
rootParameters[2].DescriptorTable.pDescriptorRanges = descriptorRange;
|
||||
rootParameters[2].DescriptorTable.NumDescriptorRanges = _countof(descriptorRange);
|
||||
|
||||
rootParameters[3].ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
|
||||
rootParameters[3].ShaderVisibility = D3D12_SHADER_VISIBILITY_ALL;
|
||||
rootParameters[3].ShaderVisibility = static_cast<D3D12_SHADER_VISIBILITY>(ShaderVisibility::All);
|
||||
rootParameters[3].Descriptor.RegisterSpace = 1;
|
||||
rootParameters[3].Descriptor.ShaderRegister = 0;
|
||||
|
||||
D3D12_STATIC_SAMPLER_DESC samplerDesc[1];
|
||||
memset(samplerDesc, 0, sizeof(D3D12_STATIC_SAMPLER_DESC) * _countof(samplerDesc));
|
||||
samplerDesc[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
||||
samplerDesc[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
samplerDesc[0].AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
samplerDesc[0].AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
samplerDesc[0].BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK;
|
||||
samplerDesc[0].Filter = static_cast<D3D12_FILTER>(FilterMode::Linear);
|
||||
samplerDesc[0].AddressU = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||
samplerDesc[0].AddressV = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||
samplerDesc[0].AddressW = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||
samplerDesc[0].BorderColor = static_cast<D3D12_STATIC_BORDER_COLOR>(BorderColor::OpaqueBlack);
|
||||
samplerDesc[0].MaxLOD = D3D12_FLOAT32_MAX;
|
||||
samplerDesc[0].RegisterSpace = 0;
|
||||
samplerDesc[0].ShaderRegister = 0;
|
||||
samplerDesc[0].ShaderVisibility = D3D12_SHADER_VISIBILITY_PIXEL;
|
||||
samplerDesc[0].ShaderVisibility = static_cast<D3D12_SHADER_VISIBILITY>(ShaderVisibility::Pixel);
|
||||
|
||||
D3D12_ROOT_SIGNATURE_DESC rootSignatureDesc = {};
|
||||
rootSignatureDesc.NumParameters = _countof(rootParameters);
|
||||
@@ -512,21 +515,21 @@ ID3D12PipelineState* CreatePSO(ID3D12RootSignature* inID3D12RootSignature,
|
||||
psoDesc.InputLayout = vertexDataLayoutDesc;
|
||||
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||
|
||||
psoDesc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
|
||||
psoDesc.RasterizerState.CullMode = D3D12_CULL_MODE_BACK;
|
||||
psoDesc.RasterizerState.FillMode = static_cast<D3D12_FILL_MODE>(FillMode::Solid);
|
||||
psoDesc.RasterizerState.CullMode = static_cast<D3D12_CULL_MODE>(CullMode::Back);
|
||||
psoDesc.RasterizerState.DepthClipEnable = TRUE;
|
||||
|
||||
psoDesc.DepthStencilState.DepthEnable = true;
|
||||
psoDesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
|
||||
psoDesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
||||
psoDesc.DepthStencilState.DepthFunc = static_cast<D3D12_COMPARISON_FUNC>(ComparisonFunc::LessEqual);
|
||||
|
||||
psoDesc.BlendState = { 0 };
|
||||
D3D12_RENDER_TARGET_BLEND_DESC rtBlendDesc = {
|
||||
FALSE,FALSE,
|
||||
D3D12_BLEND_SRC_ALPHA,D3D12_BLEND_INV_SRC_ALPHA,D3D12_BLEND_OP_ADD,
|
||||
D3D12_BLEND_SRC_ALPHA,D3D12_BLEND_INV_SRC_ALPHA,D3D12_BLEND_OP_ADD,
|
||||
D3D12_LOGIC_OP_NOOP,
|
||||
D3D12_COLOR_WRITE_ENABLE_ALL,
|
||||
static_cast<D3D12_BLEND>(BlendFactor::SrcAlpha),static_cast<D3D12_BLEND>(BlendFactor::InvSrcAlpha),static_cast<D3D12_BLEND_OP>(BlendOp::Add),
|
||||
static_cast<D3D12_BLEND>(BlendFactor::SrcAlpha),static_cast<D3D12_BLEND>(BlendFactor::InvSrcAlpha),static_cast<D3D12_BLEND_OP>(BlendOp::Add),
|
||||
static_cast<D3D12_LOGIC_OP>(LogicOp::Noop),
|
||||
static_cast<UINT8>(ColorWriteMask::All),
|
||||
};
|
||||
for (int i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
|
||||
psoDesc.BlendState.RenderTarget[i] = rtBlendDesc;
|
||||
|
||||
Reference in New Issue
Block a user