refactor: 添加RHI Enums.h并在D3D12测试中替换部分D3D12枚举
This commit is contained in:
@@ -82,23 +82,9 @@ add_library(XCEngine STATIC
|
|||||||
src/Debug/Profiler.cpp
|
src/Debug/Profiler.cpp
|
||||||
|
|
||||||
# RHI
|
# RHI
|
||||||
include/XCEngine/RHI/RHIDefines.h
|
include/XCEngine/RHI/Enums.h
|
||||||
include/XCEngine/RHI/IRHIResources.h
|
|
||||||
include/XCEngine/RHI/ICommandList.h
|
|
||||||
include/XCEngine/RHI/IRHIDevice.h
|
|
||||||
include/XCEngine/RHI/IResourceViews.h
|
|
||||||
include/XCEngine/RHI/RHISystem.h
|
|
||||||
|
|
||||||
# Rendering
|
|
||||||
include/XCEngine/Rendering/Resources.h
|
|
||||||
include/XCEngine/Rendering/RenderTarget.h
|
|
||||||
include/XCEngine/Rendering/Shader.h
|
|
||||||
include/XCEngine/Rendering/RenderContext.h
|
|
||||||
include/XCEngine/Rendering/StaticMeshComponent.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_subdirectory(src/RHI/D3D12)
|
|
||||||
|
|
||||||
target_include_directories(XCEngine PUBLIC
|
target_include_directories(XCEngine PUBLIC
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include
|
${CMAKE_CURRENT_SOURCE_DIR}/include
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/include/XCEngine
|
${CMAKE_CURRENT_SOURCE_DIR}/include/XCEngine
|
||||||
|
|||||||
272
engine/include/XCEngine/RHI/Enums.h
Normal file
272
engine/include/XCEngine/RHI/Enums.h
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
namespace XCEngine {
|
||||||
|
namespace RHI {
|
||||||
|
|
||||||
|
enum class ShaderType : uint8_t {
|
||||||
|
Vertex,
|
||||||
|
Hull,
|
||||||
|
Domain,
|
||||||
|
Geometry,
|
||||||
|
Pixel,
|
||||||
|
Compute,
|
||||||
|
Amplification,
|
||||||
|
Mesh,
|
||||||
|
Library
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class CullMode : uint8_t {
|
||||||
|
None = 1,
|
||||||
|
Front = 2,
|
||||||
|
Back = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class FillMode : uint8_t {
|
||||||
|
Wireframe = 2,
|
||||||
|
Solid = 3
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BlendOp : uint8_t {
|
||||||
|
Add = 1,
|
||||||
|
Subtract = 2,
|
||||||
|
ReverseSubtract = 3,
|
||||||
|
Min = 4,
|
||||||
|
Max = 5
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BlendFactor : uint8_t {
|
||||||
|
Zero = 0,
|
||||||
|
One = 1,
|
||||||
|
SrcColor = 2,
|
||||||
|
InvSrcColor = 3,
|
||||||
|
SrcAlpha = 4,
|
||||||
|
InvSrcAlpha = 5,
|
||||||
|
DstAlpha = 6,
|
||||||
|
InvDstAlpha = 7,
|
||||||
|
DstColor = 8,
|
||||||
|
InvDstColor = 9,
|
||||||
|
SrcAlphaSat = 10,
|
||||||
|
BlendFactor = 11,
|
||||||
|
InvBlendFactor = 12,
|
||||||
|
Src1Color = 13,
|
||||||
|
InvSrc1Color = 14,
|
||||||
|
Src1Alpha = 15,
|
||||||
|
InvSrc1Alpha = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ComparisonFunc : uint8_t {
|
||||||
|
Never = 1,
|
||||||
|
Less = 2,
|
||||||
|
Equal = 3,
|
||||||
|
LessEqual = 4,
|
||||||
|
Greater = 5,
|
||||||
|
NotEqual = 6,
|
||||||
|
GreaterEqual = 7,
|
||||||
|
Always = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class StencilOp : uint8_t {
|
||||||
|
Keep = 1,
|
||||||
|
Zero = 2,
|
||||||
|
Replace = 3,
|
||||||
|
IncrSat = 4,
|
||||||
|
DecrSat = 5,
|
||||||
|
Invert = 6,
|
||||||
|
Incr = 7,
|
||||||
|
Decr = 8
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class TextureType : uint8_t {
|
||||||
|
Texture1D,
|
||||||
|
Texture2D,
|
||||||
|
Texture2DArray,
|
||||||
|
Texture3D,
|
||||||
|
TextureCube,
|
||||||
|
TextureCubeArray
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class BufferType : uint8_t {
|
||||||
|
Vertex,
|
||||||
|
Index,
|
||||||
|
Constant,
|
||||||
|
ReadBack,
|
||||||
|
Indirect,
|
||||||
|
RaytracingAccelerationStructure,
|
||||||
|
ShaderBindingTable
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class DescriptorType : uint8_t {
|
||||||
|
CBV,
|
||||||
|
SRV,
|
||||||
|
UAV,
|
||||||
|
Sampler,
|
||||||
|
RTV,
|
||||||
|
DSV
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class PipelineType : uint8_t {
|
||||||
|
Graphics,
|
||||||
|
Compute,
|
||||||
|
Raytracing
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class CommandQueueType : uint8_t {
|
||||||
|
Direct,
|
||||||
|
Compute,
|
||||||
|
Copy
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class LoadAction : uint8_t {
|
||||||
|
Undefined = 0,
|
||||||
|
Load = 1,
|
||||||
|
Clear = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class StoreAction : uint8_t {
|
||||||
|
Undefined = 0,
|
||||||
|
Store = 1,
|
||||||
|
Resolve = 2,
|
||||||
|
StoreAndResolve = 3,
|
||||||
|
Discard = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class PresentFlags : uint8_t {
|
||||||
|
None = 0,
|
||||||
|
AllowTearing = 1,
|
||||||
|
StrictlyTimedFrame = 2,
|
||||||
|
AllowDisplayLatencyWaitableObject = 4
|
||||||
|
};
|
||||||
|
|
||||||
|
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 {
|
||||||
|
Point = 0,
|
||||||
|
Linear = 1,
|
||||||
|
Anisotropic = 2,
|
||||||
|
ComparisonPoint = 3,
|
||||||
|
ComparisonLinear = 4,
|
||||||
|
ComparisonAnisotropic = 5,
|
||||||
|
MinimumPoint = 7,
|
||||||
|
MinimumLinear = 8,
|
||||||
|
MinimumAnisotropic = 9,
|
||||||
|
MaximumPoint = 11,
|
||||||
|
MaximumLinear = 12,
|
||||||
|
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,
|
||||||
|
OpaqueWhite = 2
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class LogicOp : uint8_t {
|
||||||
|
Clear = 0,
|
||||||
|
Set = 1,
|
||||||
|
Copy = 2,
|
||||||
|
CopyInverted = 3,
|
||||||
|
Noop = 4,
|
||||||
|
Invert = 5,
|
||||||
|
And = 6,
|
||||||
|
Nand = 7,
|
||||||
|
Or = 8,
|
||||||
|
Nor = 9,
|
||||||
|
Xor = 10,
|
||||||
|
Equiv = 11,
|
||||||
|
AndReverse = 12,
|
||||||
|
AndInverted = 13,
|
||||||
|
OrReverse = 14,
|
||||||
|
OrInverted = 15
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class ColorWriteMask : uint8_t {
|
||||||
|
Red = 1,
|
||||||
|
Green = 2,
|
||||||
|
Blue = 4,
|
||||||
|
Alpha = 8,
|
||||||
|
All = 15
|
||||||
|
};
|
||||||
|
|
||||||
|
inline ColorWriteMask operator|(ColorWriteMask a, ColorWriteMask b) {
|
||||||
|
return static_cast<ColorWriteMask>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
|
||||||
|
}
|
||||||
|
|
||||||
|
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 {
|
||||||
|
DescriptorTable,
|
||||||
|
Constants,
|
||||||
|
CBV,
|
||||||
|
SRV,
|
||||||
|
UAV
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class DescriptorHeapType : uint8_t {
|
||||||
|
CBV_SRV_UAV,
|
||||||
|
Sampler,
|
||||||
|
RTV,
|
||||||
|
DSV
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class QueryType : uint8_t {
|
||||||
|
Occlusion,
|
||||||
|
Timestamp,
|
||||||
|
PipelineStatistics
|
||||||
|
};
|
||||||
|
|
||||||
|
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
|
||||||
|
} // namespace XCEngine
|
||||||
@@ -33,23 +33,7 @@ enum class BlendOp : uint8_t {
|
|||||||
Subtract = 2,
|
Subtract = 2,
|
||||||
ReverseSubtract = 3,
|
ReverseSubtract = 3,
|
||||||
Min = 4,
|
Min = 4,
|
||||||
Max = 5,
|
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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class BlendFactor : uint8_t {
|
enum class BlendFactor : uint8_t {
|
||||||
@@ -155,44 +139,18 @@ enum class PresentFlags : uint8_t {
|
|||||||
AllowDisplayLatencyWaitableObject = 4
|
AllowDisplayLatencyWaitableObject = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class IndirectDrawArguments : uint32_t {
|
enum class PrimitiveTopology : uint8_t {
|
||||||
VertexCountPerInstance = 0,
|
Undefined = 0,
|
||||||
InstanceCount = 4,
|
PointList = 1,
|
||||||
StartVertexLocation = 8,
|
LineList = 2,
|
||||||
StartInstanceLocation = 12
|
LineStrip = 3,
|
||||||
};
|
TriangleList = 4,
|
||||||
|
TriangleStrip = 5,
|
||||||
enum class IndirectDispatchArguments : uint32_t {
|
LineListAdj = 10,
|
||||||
ThreadGroupCountX = 0,
|
LineStripAdj = 11,
|
||||||
ThreadGroupCountY = 4,
|
TriangleListAdj = 12,
|
||||||
ThreadGroupCountZ = 8
|
TriangleStripAdj = 13,
|
||||||
};
|
PatchList = 33
|
||||||
|
|
||||||
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 FilterMode : uint8_t {
|
enum class FilterMode : uint8_t {
|
||||||
@@ -210,6 +168,14 @@ enum class FilterMode : uint8_t {
|
|||||||
MaximumAnisotropic = 13
|
MaximumAnisotropic = 13
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class TextureAddressMode : uint8_t {
|
||||||
|
Wrap = 1,
|
||||||
|
Mirror = 2,
|
||||||
|
Clamp = 3,
|
||||||
|
Border = 4,
|
||||||
|
MirrorOnce = 5
|
||||||
|
};
|
||||||
|
|
||||||
enum class BorderColor : uint8_t {
|
enum class BorderColor : uint8_t {
|
||||||
TransparentBlack = 0,
|
TransparentBlack = 0,
|
||||||
OpaqueBlack = 1,
|
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));
|
return static_cast<ColorWriteMask>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class ResourceBarrierType : uint8_t {
|
enum class ShaderVisibility : uint8_t {
|
||||||
Transition,
|
All = 0,
|
||||||
Aliasing,
|
Vertex = 1,
|
||||||
UAV
|
Hull = 2,
|
||||||
|
Domain = 3,
|
||||||
|
Geometry = 4,
|
||||||
|
Pixel = 5,
|
||||||
|
Amplification = 6,
|
||||||
|
Mesh = 7
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RootParameterType : uint8_t {
|
enum class RootParameterType : uint8_t {
|
||||||
@@ -261,58 +232,40 @@ enum class RootParameterType : uint8_t {
|
|||||||
UAV
|
UAV
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ShaderRegisterType : uint8_t {
|
enum class DescriptorHeapType : uint8_t {
|
||||||
CBV,
|
CBV_SRV_UAV,
|
||||||
SRV,
|
Sampler,
|
||||||
UAV,
|
RTV,
|
||||||
Sampler
|
DSV
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class RootSignatureVersion : uint8_t {
|
enum class QueryType : uint8_t {
|
||||||
Version1,
|
Occlusion,
|
||||||
Version1_0 = Version1,
|
Timestamp,
|
||||||
Version1_1
|
PipelineStatistics
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class ClearDepthStencilFlags : uint8_t {
|
enum class Format : uint32_t {
|
||||||
Depth = 1,
|
Unknown = 0,
|
||||||
Stencil = 2,
|
R8_UNorm = 61,
|
||||||
DepthAndStencil = 3
|
R8G8_UNorm = 49,
|
||||||
};
|
R8G8B8A8_UNorm = 28,
|
||||||
|
R16G16B16A16_Float = 10,
|
||||||
enum class QueryHeapFlags : uint8_t {
|
R32G32B32A32_Float = 2,
|
||||||
None = 0,
|
R16_Float = 54,
|
||||||
Precision = 1
|
R32_Float = 41,
|
||||||
};
|
D16_UNorm = 55,
|
||||||
|
D24_UNorm_S8_UInt = 45,
|
||||||
enum class PipelineStateFlags : uint8_t {
|
D32_Float = 40,
|
||||||
None = 0,
|
BC1_UNorm = 71,
|
||||||
DebugName = 1
|
BC2_UNorm = 74,
|
||||||
};
|
BC3_UNorm = 77,
|
||||||
|
BC4_UNorm = 80,
|
||||||
enum class BufferUAVFlags : uint8_t {
|
BC5_UNorm = 83,
|
||||||
None = 0,
|
BC6H_UF16 = 95,
|
||||||
Raw = 1,
|
BC7_UNorm = 98,
|
||||||
Append = 2,
|
R32G32B32A32_UInt = 23,
|
||||||
Counter = 4
|
R32_UInt = 39
|
||||||
};
|
|
||||||
|
|
||||||
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
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace RHI
|
} // namespace RHI
|
||||||
|
|||||||
@@ -11,6 +11,9 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "stbi/stb_image.h"
|
#include "stbi/stb_image.h"
|
||||||
|
#include "RHI/Enums.h"
|
||||||
|
|
||||||
|
using namespace XCEngine::RHI;
|
||||||
|
|
||||||
#pragma comment(lib,"d3d12.lib")
|
#pragma comment(lib,"d3d12.lib")
|
||||||
#pragma comment(lib,"dxgi.lib")
|
#pragma comment(lib,"dxgi.lib")
|
||||||
@@ -205,13 +208,13 @@ D3D12_RESOURCE_BARRIER InitResourceBarrier(
|
|||||||
ID3D12RootSignature* InitRootSignature() {
|
ID3D12RootSignature* InitRootSignature() {
|
||||||
D3D12_ROOT_PARAMETER rootParameters[4];
|
D3D12_ROOT_PARAMETER rootParameters[4];
|
||||||
rootParameters[1].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS;
|
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.RegisterSpace = 0;
|
||||||
rootParameters[1].Constants.ShaderRegister = 0;
|
rootParameters[1].Constants.ShaderRegister = 0;
|
||||||
rootParameters[1].Constants.Num32BitValues = 4;
|
rootParameters[1].Constants.Num32BitValues = 4;
|
||||||
|
|
||||||
rootParameters[0].ParameterType = D3D12_ROOT_PARAMETER_TYPE_CBV;
|
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.RegisterSpace = 0;
|
||||||
rootParameters[0].Descriptor.ShaderRegister = 1;
|
rootParameters[0].Descriptor.ShaderRegister = 1;
|
||||||
|
|
||||||
@@ -223,26 +226,26 @@ ID3D12RootSignature* InitRootSignature() {
|
|||||||
descriptorRange[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
|
descriptorRange[0].OffsetInDescriptorsFromTableStart = D3D12_DESCRIPTOR_RANGE_OFFSET_APPEND;
|
||||||
|
|
||||||
rootParameters[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE;
|
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.pDescriptorRanges = descriptorRange;
|
||||||
rootParameters[2].DescriptorTable.NumDescriptorRanges = _countof(descriptorRange);
|
rootParameters[2].DescriptorTable.NumDescriptorRanges = _countof(descriptorRange);
|
||||||
|
|
||||||
rootParameters[3].ParameterType = D3D12_ROOT_PARAMETER_TYPE_SRV;
|
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.RegisterSpace = 1;
|
||||||
rootParameters[3].Descriptor.ShaderRegister = 0;
|
rootParameters[3].Descriptor.ShaderRegister = 0;
|
||||||
|
|
||||||
D3D12_STATIC_SAMPLER_DESC samplerDesc[1];
|
D3D12_STATIC_SAMPLER_DESC samplerDesc[1];
|
||||||
memset(samplerDesc, 0, sizeof(D3D12_STATIC_SAMPLER_DESC) * _countof(samplerDesc));
|
memset(samplerDesc, 0, sizeof(D3D12_STATIC_SAMPLER_DESC) * _countof(samplerDesc));
|
||||||
samplerDesc[0].Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
|
samplerDesc[0].Filter = static_cast<D3D12_FILTER>(FilterMode::Linear);
|
||||||
samplerDesc[0].AddressU = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
samplerDesc[0].AddressU = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||||
samplerDesc[0].AddressV = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
samplerDesc[0].AddressV = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||||
samplerDesc[0].AddressW = D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
samplerDesc[0].AddressW = static_cast<D3D12_TEXTURE_ADDRESS_MODE>(TextureAddressMode::Clamp);
|
||||||
samplerDesc[0].BorderColor = D3D12_STATIC_BORDER_COLOR_OPAQUE_BLACK;
|
samplerDesc[0].BorderColor = static_cast<D3D12_STATIC_BORDER_COLOR>(BorderColor::OpaqueBlack);
|
||||||
samplerDesc[0].MaxLOD = D3D12_FLOAT32_MAX;
|
samplerDesc[0].MaxLOD = D3D12_FLOAT32_MAX;
|
||||||
samplerDesc[0].RegisterSpace = 0;
|
samplerDesc[0].RegisterSpace = 0;
|
||||||
samplerDesc[0].ShaderRegister = 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 = {};
|
D3D12_ROOT_SIGNATURE_DESC rootSignatureDesc = {};
|
||||||
rootSignatureDesc.NumParameters = _countof(rootParameters);
|
rootSignatureDesc.NumParameters = _countof(rootParameters);
|
||||||
@@ -512,21 +515,21 @@ ID3D12PipelineState* CreatePSO(ID3D12RootSignature* inID3D12RootSignature,
|
|||||||
psoDesc.InputLayout = vertexDataLayoutDesc;
|
psoDesc.InputLayout = vertexDataLayoutDesc;
|
||||||
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
|
|
||||||
psoDesc.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
|
psoDesc.RasterizerState.FillMode = static_cast<D3D12_FILL_MODE>(FillMode::Solid);
|
||||||
psoDesc.RasterizerState.CullMode = D3D12_CULL_MODE_BACK;
|
psoDesc.RasterizerState.CullMode = static_cast<D3D12_CULL_MODE>(CullMode::Back);
|
||||||
psoDesc.RasterizerState.DepthClipEnable = TRUE;
|
psoDesc.RasterizerState.DepthClipEnable = TRUE;
|
||||||
|
|
||||||
psoDesc.DepthStencilState.DepthEnable = true;
|
psoDesc.DepthStencilState.DepthEnable = true;
|
||||||
psoDesc.DepthStencilState.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ALL;
|
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 };
|
psoDesc.BlendState = { 0 };
|
||||||
D3D12_RENDER_TARGET_BLEND_DESC rtBlendDesc = {
|
D3D12_RENDER_TARGET_BLEND_DESC rtBlendDesc = {
|
||||||
FALSE,FALSE,
|
FALSE,FALSE,
|
||||||
D3D12_BLEND_SRC_ALPHA,D3D12_BLEND_INV_SRC_ALPHA,D3D12_BLEND_OP_ADD,
|
static_cast<D3D12_BLEND>(BlendFactor::SrcAlpha),static_cast<D3D12_BLEND>(BlendFactor::InvSrcAlpha),static_cast<D3D12_BLEND_OP>(BlendOp::Add),
|
||||||
D3D12_BLEND_SRC_ALPHA,D3D12_BLEND_INV_SRC_ALPHA,D3D12_BLEND_OP_ADD,
|
static_cast<D3D12_BLEND>(BlendFactor::SrcAlpha),static_cast<D3D12_BLEND>(BlendFactor::InvSrcAlpha),static_cast<D3D12_BLEND_OP>(BlendOp::Add),
|
||||||
D3D12_LOGIC_OP_NOOP,
|
static_cast<D3D12_LOGIC_OP>(LogicOp::Noop),
|
||||||
D3D12_COLOR_WRITE_ENABLE_ALL,
|
static_cast<UINT8>(ColorWriteMask::All),
|
||||||
};
|
};
|
||||||
for (int i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
|
for (int i = 0; i < D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT; ++i)
|
||||||
psoDesc.BlendState.RenderTarget[i] = rtBlendDesc;
|
psoDesc.BlendState.RenderTarget[i] = rtBlendDesc;
|
||||||
|
|||||||
Reference in New Issue
Block a user