Refactor pipeline states to use in-class initialisers, not constructors

This commit is contained in:
baldurk
2017-04-06 00:02:32 +01:00
parent 8262bd2770
commit ebb398ae00
4 changed files with 377 additions and 674 deletions
+77 -149
View File
@@ -31,41 +31,34 @@ namespace D3D11Pipe
{
struct Layout
{
Layout()
: SemanticIndex(0), InputSlot(0), ByteOffset(0), PerInstance(false), InstanceDataStepRate(0)
{
}
rdctype::str SemanticName;
uint32_t SemanticIndex;
uint32_t SemanticIndex = 0;
ResourceFormat Format;
uint32_t InputSlot;
uint32_t ByteOffset;
bool32 PerInstance;
uint32_t InstanceDataStepRate;
uint32_t InputSlot = 0;
uint32_t ByteOffset = 0;
bool32 PerInstance = false;
uint32_t InstanceDataStepRate = 0;
};
struct VB
{
VB() : Buffer(), Stride(0), Offset(0) {}
ResourceId Buffer;
uint32_t Stride;
uint32_t Offset;
uint32_t Stride = 0;
uint32_t Offset = 0;
};
struct IB
{
IB() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
uint32_t Offset = 0;
};
struct IA
{
IA() : Bytecode(NULL), customName(false) {}
rdctype::array<Layout> layouts;
ResourceId layout;
ShaderReflection *Bytecode;
bool32 customName;
ShaderReflection *Bytecode = NULL;
bool32 customName = false;
rdctype::str name;
rdctype::array<VB> vbuffers;
@@ -75,97 +68,66 @@ struct IA
struct View
{
View()
: Object(),
Resource(),
Format(),
Structured(false),
BufferStructCount(0),
ElementSize(0),
FirstElement(0),
NumElements(1),
Flags(D3DBufferViewFlags::NoFlags),
HighestMip(0),
NumMipLevels(1),
ArraySize(1),
FirstArraySlice(0)
{
}
ResourceId Object;
ResourceId Resource;
rdctype::str Type;
ResourceFormat Format;
bool32 Structured;
uint32_t BufferStructCount;
uint32_t ElementSize;
bool32 Structured = false;
uint32_t BufferStructCount = 0;
uint32_t ElementSize = 0;
// Buffer (UAV)
uint32_t FirstElement;
uint32_t NumElements;
uint32_t FirstElement = 0;
uint32_t NumElements = 1;
// BufferEx
D3DBufferViewFlags Flags;
D3DBufferViewFlags Flags = D3DBufferViewFlags::NoFlags;
// Texture
uint32_t HighestMip;
uint32_t NumMipLevels;
uint32_t HighestMip = 0;
uint32_t NumMipLevels = 0;
// Texture Array
uint32_t ArraySize;
uint32_t FirstArraySlice;
uint32_t ArraySize = 1;
uint32_t FirstArraySlice = 0;
};
struct Sampler
{
Sampler()
: Samp(),
customName(false),
UseBorder(false),
UseComparison(false),
MaxAniso(0),
MaxLOD(0.0f),
MinLOD(0.0f),
MipLODBias(0.0f)
{
BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0.0f;
}
ResourceId Samp;
rdctype::str name;
bool32 customName;
bool32 customName = false;
rdctype::str AddressU;
rdctype::str AddressV;
rdctype::str AddressW;
float BorderColor[4];
float BorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
rdctype::str Comparison;
rdctype::str Filter;
bool32 UseBorder;
bool32 UseComparison;
uint32_t MaxAniso;
float MaxLOD;
float MinLOD;
float MipLODBias;
bool32 UseBorder = false;
bool32 UseComparison = false;
uint32_t MaxAniso = 0;
float MaxLOD = 0.0f;
float MinLOD = 0.0f;
float MipLODBias = 0.0f;
};
struct CBuffer
{
CBuffer() : Buffer(), VecOffset(0), VecCount(0) {}
ResourceId Buffer;
uint32_t VecOffset;
uint32_t VecCount;
uint32_t VecOffset = 0;
uint32_t VecCount = 0;
};
struct Shader
{
Shader() : Object(), customName(false), ShaderDetails(NULL), stage(ShaderStage::Vertex) {}
ResourceId Object;
rdctype::str name;
bool32 customName;
ShaderReflection *ShaderDetails;
bool32 customName = false;
ShaderReflection *ShaderDetails = NULL;
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
ShaderStage stage = ShaderStage::Vertex;
rdctype::array<View> SRVs;
rdctype::array<View> UAVs;
@@ -179,9 +141,8 @@ struct Shader
struct SOBind
{
SOBind() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
uint32_t Offset = 0;
};
struct SO
@@ -191,64 +152,49 @@ struct SO
struct Viewport
{
Viewport()
: X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f), Enabled(false)
{
}
Viewport() = default;
Viewport(float TX, float TY, float W, float H, float MN, float MX, bool en)
: X(TX), Y(TY), Width(W), Height(H), MinDepth(MN), MaxDepth(MX), Enabled(en)
{
}
float X;
float Y;
float Width;
float Height;
float MinDepth;
float MaxDepth;
bool32 Enabled;
float X = 0.0f;
float Y = 0.0f;
float Width = 0.0f;
float Height = 0.0f;
float MinDepth = 0.0f;
float MaxDepth = 0.0f;
bool32 Enabled = false;
};
struct Scissor
{
Scissor() : left(0), top(0), right(0), bottom(0), Enabled(false) {}
Scissor() = default;
Scissor(int l, int t, int r, int b, bool en) : left(l), top(t), right(r), bottom(b), Enabled(en)
{
}
int32_t left, top, right, bottom;
bool32 Enabled;
int32_t left = 0;
int32_t top = 0;
int32_t right = 0;
int32_t bottom = 0;
bool32 Enabled = false;
};
struct RasterizerState
{
RasterizerState()
: State(),
fillMode(FillMode::Solid),
cullMode(CullMode::NoCull),
FrontCCW(false),
DepthBias(0),
DepthBiasClamp(0.0f),
SlopeScaledDepthBias(0.0f),
DepthClip(false),
ScissorEnable(false),
MultisampleEnable(false),
AntialiasedLineEnable(false),
ForcedSampleCount(0),
ConservativeRasterization(false)
{
}
ResourceId State;
FillMode fillMode;
CullMode cullMode;
bool32 FrontCCW;
int32_t DepthBias;
float DepthBiasClamp;
float SlopeScaledDepthBias;
bool32 DepthClip;
bool32 ScissorEnable;
bool32 MultisampleEnable;
bool32 AntialiasedLineEnable;
uint32_t ForcedSampleCount;
bool32 ConservativeRasterization;
FillMode fillMode = FillMode::Solid;
CullMode cullMode = CullMode::NoCull;
bool32 FrontCCW = false;
int32_t DepthBias = 0;
float DepthBiasClamp = 0.0f;
float SlopeScaledDepthBias = 0.0f;
bool32 DepthClip = false;
bool32 ScissorEnable = false;
bool32 MultisampleEnable = false;
bool32 AntialiasedLineEnable = false;
uint32_t ForcedSampleCount = 0;
bool32 ConservativeRasterization = false;
};
struct Rasterizer
@@ -269,27 +215,17 @@ struct StencilOp
struct DepthStencilState
{
DepthStencilState()
: State(),
DepthEnable(false),
DepthWrites(false),
StencilEnable(false),
StencilReadMask(0),
StencilWriteMask(0),
StencilRef(0)
{
}
ResourceId State;
bool32 DepthEnable;
bool32 DepthEnable = false;
rdctype::str DepthFunc;
bool32 DepthWrites;
bool32 StencilEnable;
byte StencilReadMask;
byte StencilWriteMask;
bool32 DepthWrites = false;
bool32 StencilEnable = false;
byte StencilReadMask = 0;
byte StencilWriteMask = 0;
StencilOp m_FrontFace, m_BackFace;
uint32_t StencilRef;
uint32_t StencilRef = 0;
};
struct BlendOp
@@ -301,53 +237,45 @@ struct BlendOp
struct Blend
{
Blend() : Enabled(false), LogicEnabled(false), WriteMask(0) {}
BlendOp m_Blend, m_AlphaBlend;
rdctype::str LogicOp;
bool32 Enabled;
bool32 LogicEnabled;
byte WriteMask;
bool32 Enabled = false;
bool32 LogicEnabled = false;
byte WriteMask = 0;
};
struct BlendState
{
BlendState() : AlphaToCoverage(false), IndependentBlend(false), SampleMask(0)
{
BlendFactor[0] = BlendFactor[1] = BlendFactor[2] = BlendFactor[3] = 0.0f;
}
ResourceId State;
bool32 AlphaToCoverage;
bool32 IndependentBlend;
bool32 AlphaToCoverage = false;
bool32 IndependentBlend = false;
rdctype::array<Blend> Blends;
float BlendFactor[4];
uint32_t SampleMask;
float BlendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
uint32_t SampleMask = ~0U;
};
struct OM
{
OM() : UAVStartSlot(0), DepthReadOnly(false), StencilReadOnly(false) {}
DepthStencilState m_State;
BlendState m_BlendState;
rdctype::array<View> RenderTargets;
uint32_t UAVStartSlot;
uint32_t UAVStartSlot = 0;
rdctype::array<View> UAVs;
View DepthTarget;
bool32 DepthReadOnly;
bool32 StencilReadOnly;
bool32 DepthReadOnly = false;
bool32 StencilReadOnly = false;
};
struct State
{
State() {}
IA m_IA;
Shader m_VS, m_HS, m_DS, m_GS, m_PS, m_CS;
+104 -176
View File
@@ -30,46 +30,39 @@ namespace D3D12Pipe
{
struct Layout
{
Layout()
: SemanticIndex(0), InputSlot(0), ByteOffset(0), PerInstance(false), InstanceDataStepRate(0)
{
}
rdctype::str SemanticName;
uint32_t SemanticIndex;
uint32_t SemanticIndex = 0;
ResourceFormat Format;
uint32_t InputSlot;
uint32_t ByteOffset;
bool32 PerInstance;
uint32_t InstanceDataStepRate;
uint32_t InputSlot = 0;
uint32_t ByteOffset = 0;
bool32 PerInstance = false;
uint32_t InstanceDataStepRate = 0;
};
struct VB
{
VB() : Buffer(), Offset(0), Stride(0) {}
ResourceId Buffer;
uint64_t Offset;
uint32_t Size;
uint32_t Stride;
uint64_t Offset = 0;
uint32_t Size = 0;
uint32_t Stride = 0;
};
struct IB
{
IB() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint64_t Offset;
uint32_t Size;
uint64_t Offset = 0;
uint32_t Size = 0;
};
struct IA
{
IA() : indexStripCutValue(0) {}
rdctype::array<Layout> layouts;
rdctype::array<VB> vbuffers;
IB ibuffer;
uint32_t indexStripCutValue;
uint32_t indexStripCutValue = 0;
};
// Immediate indicates either a root parameter (not in a table), or static samplers
@@ -77,107 +70,63 @@ struct IA
struct View
{
View()
: Immediate(0),
RootElement(~0U),
TableIndex(~0U),
Resource(),
Format(),
BufferFlags(D3DBufferViewFlags::NoFlags),
BufferStructCount(0),
ElementSize(0),
FirstElement(0),
NumElements(1),
CounterByteOffset(0),
HighestMip(0),
NumMipLevels(1),
ArraySize(1),
FirstArraySlice(0),
MinLODClamp(0.0f)
{
swizzle[0] = TextureSwizzle::Red;
swizzle[1] = TextureSwizzle::Green;
swizzle[2] = TextureSwizzle::Blue;
swizzle[3] = TextureSwizzle::Alpha;
}
bool32 Immediate = false;
uint32_t RootElement = ~0U;
uint32_t TableIndex = ~0U;
// parameters from descriptor
bool32 Immediate;
uint32_t RootElement;
uint32_t TableIndex;
// parameters from resource/view
ResourceId Resource;
rdctype::str Type;
ResourceFormat Format;
TextureSwizzle swizzle[4];
D3DBufferViewFlags BufferFlags;
uint32_t BufferStructCount;
uint32_t ElementSize;
uint64_t FirstElement;
uint32_t NumElements;
TextureSwizzle swizzle[4] = {TextureSwizzle::Red, TextureSwizzle::Green, TextureSwizzle::Blue,
TextureSwizzle::Alpha};
D3DBufferViewFlags BufferFlags = D3DBufferViewFlags::NoFlags;
uint32_t BufferStructCount = 0;
uint32_t ElementSize = 0;
uint64_t FirstElement = 0;
uint32_t NumElements = 1;
ResourceId CounterResource;
uint64_t CounterByteOffset;
uint64_t CounterByteOffset = 0;
// Texture
uint32_t HighestMip;
uint32_t NumMipLevels;
uint32_t HighestMip = 0;
uint32_t NumMipLevels = 1;
// Texture Array
uint32_t ArraySize;
uint32_t FirstArraySlice;
uint32_t ArraySize = 1;
uint32_t FirstArraySlice = 0;
float MinLODClamp;
float MinLODClamp = 0.0f;
};
struct Sampler
{
Sampler()
: Immediate(0),
RootElement(~0U),
TableIndex(~0U),
UseBorder(false),
UseComparison(false),
MaxAniso(0),
MaxLOD(0.0f),
MinLOD(0.0f),
MipLODBias(0.0f)
{
BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0.0f;
}
bool32 Immediate = 0;
uint32_t RootElement = ~0U;
uint32_t TableIndex = ~0U;
// parameters from descriptor
bool32 Immediate;
uint32_t RootElement;
uint32_t TableIndex;
// parameters from resource/view
rdctype::str AddressU, AddressV, AddressW;
float BorderColor[4];
rdctype::str AddressU;
rdctype::str AddressV;
rdctype::str AddressW;
float BorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
rdctype::str Comparison;
rdctype::str Filter;
bool32 UseBorder;
bool32 UseComparison;
uint32_t MaxAniso;
float MaxLOD;
float MinLOD;
float MipLODBias;
bool32 UseBorder = false;
bool32 UseComparison = false;
uint32_t MaxAniso = 0;
float MaxLOD = 0.0f;
float MinLOD = 0.0f;
float MipLODBias = 0.0f;
};
struct CBuffer
{
CBuffer() : Immediate(0), RootElement(~0U), TableIndex(~0U), Buffer(), Offset(0), ByteSize(0) {}
// parameters from descriptor
bool32 Immediate;
uint32_t RootElement;
uint32_t TableIndex;
bool32 Immediate = false;
uint32_t RootElement = ~0U;
uint32_t TableIndex = ~0U;
// parameters from resource/view
ResourceId Buffer;
uint64_t Offset;
uint32_t ByteSize;
uint64_t Offset = 0;
uint32_t ByteSize = 0;
rdctype::array<uint32_t> RootValues;
};
@@ -192,25 +141,25 @@ struct RegisterSpace
struct Shader
{
Shader() : ShaderDetails(NULL), stage(ShaderStage::Vertex) {}
ResourceId Object;
ShaderReflection *ShaderDetails;
ShaderReflection *ShaderDetails = NULL;
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
ShaderStage stage = ShaderStage::Vertex;
rdctype::array<RegisterSpace> Spaces;
};
struct SOBind
{
SOBind() : Buffer(), Offset(0), Size(0), WrittenCountBuffer(), WrittenCountOffset(0) {}
ResourceId Buffer;
uint64_t Offset;
uint64_t Size;
uint64_t Offset = 0;
uint64_t Size = 0;
ResourceId WrittenCountBuffer;
uint64_t WrittenCountOffset;
uint64_t WrittenCountOffset = 0;
};
struct Streamout
@@ -220,59 +169,48 @@ struct Streamout
struct Viewport
{
Viewport() : X(0.0f), Y(0.0f), Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f) {}
Viewport() = default;
Viewport(float TX, float TY, float W, float H, float MN, float MX)
: X(TX), Y(TY), Width(W), Height(H), MinDepth(MN), MaxDepth(MX)
{
}
float X;
float Y;
float Width;
float Height;
float MinDepth;
float MaxDepth;
float X = 0.0f;
float Y = 0.0f;
float Width = 0.0f;
float Height = 0.0f;
float MinDepth = 0.0f;
float MaxDepth = 0.0f;
};
struct Scissor
{
Scissor() : left(0), top(0), right(0), bottom(0) {}
Scissor() = default;
Scissor(int l, int t, int r, int b) : left(l), top(t), right(r), bottom(b) {}
int32_t left, top, right, bottom;
int32_t left = 0;
int32_t top = 0;
int32_t right = 0;
int32_t bottom = 0;
};
struct RasterizerState
{
RasterizerState()
: fillMode(FillMode::Solid),
cullMode(CullMode::NoCull),
FrontCCW(false),
DepthBias(0),
DepthBiasClamp(0.0f),
SlopeScaledDepthBias(0.0f),
DepthClip(false),
MultisampleEnable(false),
AntialiasedLineEnable(false),
ForcedSampleCount(0),
ConservativeRasterization(false)
{
}
FillMode fillMode;
CullMode cullMode;
bool32 FrontCCW;
int32_t DepthBias;
float DepthBiasClamp;
float SlopeScaledDepthBias;
bool32 DepthClip;
bool32 MultisampleEnable;
bool32 AntialiasedLineEnable;
uint32_t ForcedSampleCount;
bool32 ConservativeRasterization;
FillMode fillMode = FillMode::Solid;
CullMode cullMode = CullMode::NoCull;
bool32 FrontCCW = false;
int32_t DepthBias = 0;
float DepthBiasClamp = 0.0f;
float SlopeScaledDepthBias = 0.0f;
bool32 DepthClip = false;
bool32 MultisampleEnable = false;
bool32 AntialiasedLineEnable = false;
uint32_t ForcedSampleCount = 0;
bool32 ConservativeRasterization = false;
};
struct Rasterizer
{
Rasterizer() : SampleMask(~0U) {}
uint32_t SampleMask;
uint32_t SampleMask = ~0U;
rdctype::array<Viewport> Viewports;
@@ -291,25 +229,17 @@ struct StencilOp
struct DepthStencilState
{
DepthStencilState()
: DepthEnable(false),
DepthWrites(false),
StencilEnable(false),
StencilReadMask(0),
StencilWriteMask(0),
StencilRef(0)
{
}
bool32 DepthEnable;
bool32 DepthWrites;
bool32 DepthEnable = false;
bool32 DepthWrites = false;
rdctype::str DepthFunc;
bool32 StencilEnable;
byte StencilReadMask;
byte StencilWriteMask;
bool32 StencilEnable = false;
byte StencilReadMask = 0;
byte StencilWriteMask = 0;
StencilOp m_FrontFace, m_BackFace;
StencilOp m_FrontFace;
StencilOp m_BackFace;
uint32_t StencilRef;
uint32_t StencilRef = 0;
};
struct BlendOp
@@ -321,44 +251,38 @@ struct BlendOp
struct Blend
{
Blend() : Enabled(false), LogicEnabled(false), WriteMask(0) {}
BlendOp m_Blend, m_AlphaBlend;
BlendOp m_Blend;
BlendOp m_AlphaBlend;
rdctype::str LogicOp;
bool32 Enabled;
bool32 LogicEnabled;
byte WriteMask;
bool32 Enabled = false;
bool32 LogicEnabled = false;
byte WriteMask = 0;
};
struct BlendState
{
BlendState() : AlphaToCoverage(false), IndependentBlend(false)
{
BlendFactor[0] = BlendFactor[1] = BlendFactor[2] = BlendFactor[3] = 0.0f;
}
bool32 AlphaToCoverage;
bool32 IndependentBlend;
bool32 AlphaToCoverage = false;
bool32 IndependentBlend = false;
rdctype::array<Blend> Blends;
float BlendFactor[4];
float BlendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
};
struct OM
{
OM() : DepthReadOnly(false), StencilReadOnly(false), multiSampleCount(1), multiSampleQuality(0) {}
DepthStencilState m_State;
BlendState m_BlendState;
rdctype::array<View> RenderTargets;
View DepthTarget;
bool32 DepthReadOnly;
bool32 StencilReadOnly;
bool32 DepthReadOnly = false;
bool32 StencilReadOnly = false;
uint32_t multiSampleCount;
uint32_t multiSampleQuality;
uint32_t multiSampleCount = 1;
uint32_t multiSampleQuality = 0;
};
struct ResourceState
@@ -375,16 +299,20 @@ struct ResourceData
struct State
{
State() : customName(false) {}
ResourceId pipeline;
bool32 customName;
bool32 customName = false;
rdctype::str name;
ResourceId rootSig;
IA m_IA;
Shader m_VS, m_HS, m_DS, m_GS, m_PS, m_CS;
Shader m_VS;
Shader m_HS;
Shader m_DS;
Shader m_GS;
Shader m_PS;
Shader m_CS;
Streamout m_SO;
+105 -211
View File
@@ -31,252 +31,172 @@ namespace GLPipe
{
struct VertexAttribute
{
VertexAttribute() : BufferSlot(0), RelativeOffset(0) {}
bool32 Enabled;
bool32 Enabled = false;
ResourceFormat Format;
PixelValue GenericValue;
uint32_t BufferSlot;
uint32_t RelativeOffset;
uint32_t BufferSlot = 0;
uint32_t RelativeOffset = 0;
};
struct VB
{
VB() : Buffer(), Stride(0), Offset(0), Divisor(0) {}
ResourceId Buffer;
uint32_t Stride;
uint32_t Offset;
uint32_t Divisor;
uint32_t Stride = 0;
uint32_t Offset = 0;
uint32_t Divisor = 0;
};
struct VertexInput
{
VertexInput() : ibuffer(), primitiveRestart(false), restartIndex(0), provokingVertexLast(false) {}
rdctype::array<VertexAttribute> attributes;
rdctype::array<VB> vbuffers;
ResourceId ibuffer;
bool32 primitiveRestart;
uint32_t restartIndex;
bool32 primitiveRestart = false;
uint32_t restartIndex = 0;
bool32 provokingVertexLast;
bool32 provokingVertexLast = false;
};
struct Shader
{
Shader()
: Object(),
customShaderName(false),
customProgramName(false),
PipelineActive(false),
customPipelineName(false),
ShaderDetails(NULL),
stage(ShaderStage::Vertex)
{
}
ResourceId Object;
rdctype::str ShaderName;
bool32 customShaderName;
bool32 customShaderName = false;
rdctype::str ProgramName;
bool32 customProgramName;
bool32 customProgramName = false;
bool32 PipelineActive;
bool32 PipelineActive = false;
rdctype::str PipelineName;
bool32 customPipelineName;
bool32 customPipelineName = false;
ShaderReflection *ShaderDetails;
ShaderReflection *ShaderDetails = NULL;
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
ShaderStage stage = ShaderStage::Vertex;
rdctype::array<uint32_t> Subroutines;
};
struct FixedVertexProcessing
{
FixedVertexProcessing() : discard(0), clipOriginLowerLeft(0), clipNegativeOneToOne(0)
{
defaultInnerLevel[0] = defaultInnerLevel[1] = 0.0f;
defaultOuterLevel[0] = defaultOuterLevel[1] = defaultOuterLevel[2] = defaultOuterLevel[3] = 0.0f;
clipPlanes[0] = clipPlanes[1] = clipPlanes[2] = clipPlanes[3] = clipPlanes[4] = clipPlanes[5] =
clipPlanes[6] = clipPlanes[7] = 0;
}
float defaultInnerLevel[2] = {0.0f, 0.0f};
float defaultOuterLevel[4] = {0.0f, 0.0f, 0.0f, 0.0f};
bool32 discard = false;
float defaultInnerLevel[2];
float defaultOuterLevel[4];
bool32 discard;
bool32 clipPlanes[8];
bool32 clipOriginLowerLeft;
bool32 clipNegativeOneToOne;
bool32 clipPlanes[8] = {false, false, false, false, false, false, false, false};
bool32 clipOriginLowerLeft = false;
bool32 clipNegativeOneToOne = false;
};
struct Texture
{
Texture() : Resource(), FirstSlice(0), ResType(TextureDim::Unknown), DepthReadChannel(-1)
{
Swizzle[0] = TextureSwizzle::Red;
Swizzle[1] = TextureSwizzle::Green;
Swizzle[2] = TextureSwizzle::Blue;
Swizzle[3] = TextureSwizzle::Alpha;
}
ResourceId Resource;
uint32_t FirstSlice;
uint32_t HighestMip;
TextureDim ResType;
uint32_t FirstSlice = 0;
uint32_t HighestMip = 0;
TextureDim ResType = TextureDim::Unknown;
TextureSwizzle Swizzle[4];
int32_t DepthReadChannel;
TextureSwizzle Swizzle[4] = {TextureSwizzle::Red, TextureSwizzle::Green, TextureSwizzle::Blue,
TextureSwizzle::Alpha};
int32_t DepthReadChannel = -1;
};
struct Sampler
{
Sampler()
: Samp(),
UseBorder(false),
UseComparison(false),
SeamlessCube(false),
MaxAniso(0.0f),
MaxLOD(0.0f),
MinLOD(0.0f),
MipLODBias(0.0f)
{
BorderColor[0] = BorderColor[1] = BorderColor[2] = BorderColor[3] = 0.0f;
}
ResourceId Samp;
rdctype::str AddressS, AddressT, AddressR;
float BorderColor[4];
float BorderColor[4] = {0.0f, 0.0f, 0.0f, 0.0f};
rdctype::str Comparison;
rdctype::str MinFilter;
rdctype::str MagFilter;
bool32 UseBorder;
bool32 UseComparison;
bool32 SeamlessCube;
float MaxAniso;
float MaxLOD;
float MinLOD;
float MipLODBias;
bool32 UseBorder = false;
bool32 UseComparison = false;
bool32 SeamlessCube = false;
float MaxAniso = 0.0f;
float MaxLOD = 0.0f;
float MinLOD = 0.0f;
float MipLODBias = 0.0f;
};
struct Buffer
{
Buffer() : Resource(), Offset(0), Size(0) {}
ResourceId Resource;
uint64_t Offset;
uint64_t Size;
uint64_t Offset = 0;
uint64_t Size = 0;
};
struct ImageLoadStore
{
ImageLoadStore()
: Resource(),
Level(0),
Layered(false),
Layer(0),
ResType(TextureDim::Unknown),
readAllowed(false),
writeAllowed(false)
{
}
ResourceId Resource;
uint32_t Level;
bool32 Layered;
uint32_t Layer;
TextureDim ResType;
bool32 readAllowed;
bool32 writeAllowed;
uint32_t Level = 0;
bool32 Layered = false;
uint32_t Layer = 0;
TextureDim ResType = TextureDim::Unknown;
bool32 readAllowed = false;
bool32 writeAllowed = false;
ResourceFormat Format;
};
struct Feedback
{
Feedback() : Active(false), Paused(false)
{
Offset[0] = Offset[1] = Offset[2] = Offset[3] = 0;
Size[0] = Size[1] = Size[2] = Size[3] = 0;
}
ResourceId Obj;
ResourceId BufferBinding[4];
uint64_t Offset[4];
uint64_t Size[4];
bool32 Active;
bool32 Paused;
uint64_t Offset[4] = {0, 0, 0, 0};
uint64_t Size[4] = {0, 0, 0, 0};
bool32 Active = false;
bool32 Paused = false;
};
struct Viewport
{
Viewport() : Left(0.0f), Bottom(0.0f), Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f)
{
}
float Left, Bottom;
float Width, Height;
double MinDepth, MaxDepth;
float Left = 0.0f;
float Bottom = 0.0f;
float Width = 0.0f;
float Height = 0.0f;
double MinDepth = 0.0;
double MaxDepth = 0.0;
};
struct Scissor
{
Scissor() : Left(0), Bottom(0), Width(0), Height(0), Enabled(false) {}
int32_t Left, Bottom;
int32_t Width, Height;
bool32 Enabled;
int32_t Left = 0;
int32_t Bottom = 0;
int32_t Width = 0;
int32_t Height = 0;
bool32 Enabled = false;
};
struct RasterizerState
{
RasterizerState()
: fillMode(FillMode::Solid),
cullMode(CullMode::NoCull),
FrontCCW(false),
DepthBias(0),
SlopeScaledDepthBias(0.0f),
OffsetClamp(0.0f),
DepthClamp(false),
MultisampleEnable(false),
SampleShading(false),
SampleMask(false),
SampleMaskValue(~0U),
SampleCoverage(false),
SampleCoverageInvert(false),
SampleCoverageValue(1.0f),
SampleAlphaToCoverage(false),
SampleAlphaToOne(false),
MinSampleShadingRate(0.0f),
ProgrammablePointSize(false),
PointSize(1.0f),
LineWidth(1.0f),
PointFadeThreshold(0.0f),
PointOriginUpperLeft(false)
{
}
FillMode fillMode;
CullMode cullMode;
bool32 FrontCCW;
float DepthBias;
float SlopeScaledDepthBias;
float OffsetClamp;
bool32 DepthClamp;
FillMode fillMode = FillMode::Solid;
CullMode cullMode = CullMode::NoCull;
bool32 FrontCCW = false;
float DepthBias = 0.0f;
float SlopeScaledDepthBias = 0.0f;
float OffsetClamp = 0.0f;
bool32 DepthClamp = false;
bool32 MultisampleEnable;
bool32 SampleShading;
bool32 SampleMask;
uint32_t SampleMaskValue;
bool32 SampleCoverage;
bool32 SampleCoverageInvert;
float SampleCoverageValue;
bool32 SampleAlphaToCoverage;
bool32 SampleAlphaToOne;
float MinSampleShadingRate;
bool32 MultisampleEnable = false;
bool32 SampleShading = false;
bool32 SampleMask = false;
uint32_t SampleMaskValue = ~0U;
bool32 SampleCoverage = false;
bool32 SampleCoverageInvert = false;
float SampleCoverageValue = 1.0f;
bool32 SampleAlphaToCoverage = false;
bool32 SampleAlphaToOne = false;
float MinSampleShadingRate = 0.0f;
bool32 ProgrammablePointSize;
float PointSize;
float LineWidth;
float PointFadeThreshold;
bool32 PointOriginUpperLeft;
bool32 ProgrammablePointSize = false;
float PointSize = 1.0f;
float LineWidth = 1.0f;
float PointFadeThreshold = 0.0f;
bool32 PointOriginUpperLeft = false;
};
struct Rasterizer
@@ -290,62 +210,50 @@ struct Rasterizer
struct DepthState
{
DepthState()
: DepthEnable(false), DepthWrites(false), DepthBounds(false), NearBound(0), FarBound(0)
{
}
bool32 DepthEnable;
bool32 DepthEnable = false;
rdctype::str DepthFunc;
bool32 DepthWrites;
bool32 DepthBounds;
double NearBound, FarBound;
bool32 DepthWrites = false;
bool32 DepthBounds = false;
double NearBound = 0.0;
double FarBound = 0.0;
};
struct StencilOp
{
StencilOp() : Ref(0), ValueMask(0), WriteMask(0) {}
rdctype::str FailOp;
rdctype::str DepthFailOp;
rdctype::str PassOp;
rdctype::str Func;
uint32_t Ref;
uint32_t ValueMask;
uint32_t WriteMask;
uint32_t Ref = 0;
uint32_t ValueMask = 0;
uint32_t WriteMask = 0;
};
struct StencilState
{
StencilState() : StencilEnable(false) {}
bool32 StencilEnable;
bool32 StencilEnable = false;
StencilOp m_FrontFace, m_BackFace;
};
struct Attachment
{
Attachment() : Obj(), Layer(0), Mip(0)
{
Swizzle[0] = TextureSwizzle::Red;
Swizzle[1] = TextureSwizzle::Green;
Swizzle[2] = TextureSwizzle::Blue;
Swizzle[3] = TextureSwizzle::Alpha;
}
ResourceId Obj;
uint32_t Layer;
uint32_t Mip;
TextureSwizzle Swizzle[4];
uint32_t Layer = 0;
uint32_t Mip = 0;
TextureSwizzle Swizzle[4] = {TextureSwizzle::Red, TextureSwizzle::Green, TextureSwizzle::Blue,
TextureSwizzle::Alpha};
};
struct FBO
{
FBO() : Obj(), Depth(), Stencil(), ReadBuffer(0) {}
ResourceId Obj;
rdctype::array<Attachment> Color;
Attachment Depth;
Attachment Stencil;
rdctype::array<int32_t> DrawBuffers;
int32_t ReadBuffer;
int32_t ReadBuffer = 0;
};
struct BlendOp
@@ -357,28 +265,25 @@ struct BlendOp
struct Blend
{
Blend() : Enabled(false), WriteMask(0) {}
BlendOp m_Blend, m_AlphaBlend;
rdctype::str LogicOp;
bool32 Enabled;
byte WriteMask;
bool32 Enabled = false;
byte WriteMask = 0;
};
struct BlendState
{
BlendState() { BlendFactor[0] = BlendFactor[1] = BlendFactor[2] = BlendFactor[3] = 0.0f; }
rdctype::array<Blend> Blends;
float BlendFactor[4];
float BlendFactor[4] = {1.0f, 1.0f, 1.0f, 1.0f};
};
struct FrameBuffer
{
FrameBuffer() : FramebufferSRGB(false), Dither(false) {}
bool32 FramebufferSRGB;
bool32 Dither;
bool32 FramebufferSRGB = false;
bool32 Dither = false;
FBO m_DrawFBO, m_ReadFBO;
@@ -387,27 +292,16 @@ struct FrameBuffer
struct Hints
{
Hints()
: Derivatives(QualityHint::DontCare),
LineSmooth(QualityHint::DontCare),
PolySmooth(QualityHint::DontCare),
TexCompression(QualityHint::DontCare),
LineSmoothEnabled(0),
PolySmoothEnabled(0)
{
}
QualityHint Derivatives;
QualityHint LineSmooth;
QualityHint PolySmooth;
QualityHint TexCompression;
bool32 LineSmoothEnabled;
bool32 PolySmoothEnabled;
QualityHint Derivatives = QualityHint::DontCare;
QualityHint LineSmooth = QualityHint::DontCare;
QualityHint PolySmooth = QualityHint::DontCare;
QualityHint TexCompression = QualityHint::DontCare;
bool32 LineSmoothEnabled = false;
bool32 PolySmoothEnabled = false;
};
struct State
{
State() {}
VertexInput m_VtxIn;
Shader m_VS, m_TCS, m_TES, m_GS, m_FS, m_CS;
+91 -138
View File
@@ -28,65 +28,46 @@ namespace VKPipe
{
struct BindingElement
{
BindingElement()
: immutableSampler(false),
customName(false),
baseMip(0),
baseLayer(0),
offset(0),
size(0),
mipBias(0.0f),
maxAniso(0.0f),
compareEnable(false),
minlod(0.0f),
maxlod(0.0f),
borderEnable(false),
unnormalized(false)
{
swizzle[0] = TextureSwizzle::Red;
swizzle[1] = TextureSwizzle::Green;
swizzle[2] = TextureSwizzle::Blue;
swizzle[3] = TextureSwizzle::Alpha;
}
ResourceId view; // bufferview, imageview, attachmentview
ResourceId res; // buffer, image, attachment
ResourceId sampler;
bool32 immutableSampler;
bool32 immutableSampler = false;
rdctype::str name;
bool32 customName;
bool32 customName = false;
// image views
ResourceFormat viewfmt;
TextureSwizzle swizzle[4];
uint32_t baseMip;
uint32_t baseLayer;
uint32_t numMip;
uint32_t numLayer;
TextureSwizzle swizzle[4] = {TextureSwizzle::Red, TextureSwizzle::Green, TextureSwizzle::Blue,
TextureSwizzle::Alpha};
uint32_t baseMip = 0;
uint32_t baseLayer = 0;
uint32_t numMip = 0;
uint32_t numLayer = 0;
// buffers
uint64_t offset;
uint64_t size;
uint64_t offset = 0;
uint64_t size = 0;
// sampler info
rdctype::str mag, min, mip;
rdctype::str addrU, addrV, addrW;
float mipBias;
float maxAniso;
bool32 compareEnable;
float mipBias = 0.0f;
float maxAniso = 0.0f;
bool32 compareEnable = false;
rdctype::str comparison;
float minlod, maxlod;
bool32 borderEnable;
float minlod = 0.0f;
float maxlod = 0.0f;
bool32 borderEnable = false;
rdctype::str border;
bool32 unnormalized;
bool32 unnormalized = false;
};
struct DescriptorBinding
{
uint32_t descriptorCount;
BindType type;
ShaderStageMask stageFlags;
uint32_t descriptorCount = 0;
BindType type = BindType::Unknown;
ShaderStageMask stageFlags = ShaderStageMask::Unknown;
// may only be one element if not an array
rdctype::array<BindingElement> binds;
@@ -102,50 +83,44 @@ struct DescriptorSet
struct Pipeline
{
Pipeline() : flags(0) {}
ResourceId obj;
uint32_t flags;
uint32_t flags = 0;
rdctype::array<DescriptorSet> DescSets;
};
struct IB
{
IB() : offs(0) {}
ResourceId buf;
uint64_t offs;
uint64_t offs = 0;
};
struct InputAssembly
{
InputAssembly() : primitiveRestartEnable(false) {}
bool32 primitiveRestartEnable;
bool32 primitiveRestartEnable = false;
IB ibuffer;
};
struct VertexAttribute
{
VertexAttribute() : location(0), binding(0), format(), byteoffset(0) {}
uint32_t location;
uint32_t binding;
uint32_t location = 0;
uint32_t binding = 0;
ResourceFormat format;
uint32_t byteoffset;
uint32_t byteoffset = 0;
};
struct VertexBinding
{
VertexBinding() : vbufferBinding(0), bytestride(0), perInstance(false) {}
uint32_t vbufferBinding;
uint32_t bytestride;
bool32 perInstance;
uint32_t vbufferBinding = 0;
uint32_t bytestride = 0;
bool32 perInstance = false;
};
struct VB
{
VB() : offset(0) {}
ResourceId buffer;
uint64_t offset;
uint64_t offset = 0;
};
struct VertexInput
@@ -157,47 +132,50 @@ struct VertexInput
struct SpecInfo
{
SpecInfo() : specID(0) {}
uint32_t specID;
uint32_t specID = 0;
rdctype::array<byte> data;
};
struct Shader
{
Shader() : Object(), customName(false), ShaderDetails(NULL), stage(ShaderStage::Vertex) {}
ResourceId Object;
rdctype::str entryPoint;
rdctype::str name;
bool32 customName;
ShaderReflection *ShaderDetails;
bool32 customName = false;
ShaderReflection *ShaderDetails = NULL;
// this is no longer dynamic, like GL, but it's also not trivial, like D3D11.
// this contains the mapping between the shader objects in the reflection data
// and the descriptor set and binding that they use
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
ShaderStage stage = ShaderStage::Vertex;
rdctype::array<SpecInfo> specialization;
};
struct Tessellation
{
Tessellation() : numControlPoints(0) {}
uint32_t numControlPoints;
uint32_t numControlPoints = 0;
};
struct Viewport
{
Viewport() : x(0), y(0), width(0), height(0), minDepth(0), maxDepth(0) {}
float x, y, width, height, minDepth, maxDepth;
float x = 0.0f;
float y = 0.0f;
float width = 0.0f;
float height = 0.0f;
float minDepth = 0.0f;
float maxDepth = 0.0f;
};
struct Scissor
{
Scissor() : x(0), y(0), width(0), height(0) {}
int32_t x, y, width, height;
int32_t x = 0;
int32_t y = 0;
int32_t width = 0;
int32_t height = 0;
};
struct ViewportScissor
@@ -213,36 +191,25 @@ struct ViewState
struct Raster
{
Raster()
: depthClampEnable(false),
rasterizerDiscardEnable(false),
FrontCCW(false),
fillMode(FillMode::Solid),
cullMode(CullMode::NoCull),
depthBias(0),
depthBiasClamp(0),
slopeScaledDepthBias(0),
lineWidth(0)
{
}
bool32 depthClampEnable, rasterizerDiscardEnable, FrontCCW;
FillMode fillMode;
CullMode cullMode;
bool32 depthClampEnable = false;
bool32 rasterizerDiscardEnable = false;
bool32 FrontCCW = false;
FillMode fillMode = FillMode::Solid;
CullMode cullMode = CullMode::NoCull;
// dynamic
float depthBias, depthBiasClamp, slopeScaledDepthBias, lineWidth;
float depthBias = 0.0f;
float depthBiasClamp = 0.0f;
float slopeScaledDepthBias = 0.0f;
float lineWidth = 0.0f;
};
struct MultiSample
{
MultiSample() : rasterSamples(0), sampleShadingEnable(false), minSampleShading(0), sampleMask(~0U)
{
}
uint32_t rasterSamples;
bool32 sampleShadingEnable;
float minSampleShading;
uint32_t sampleMask;
uint32_t rasterSamples = 0;
bool32 sampleShadingEnable = false;
float minSampleShading = 0.0f;
uint32_t sampleMask = 0;
};
struct BlendOp
@@ -254,110 +221,96 @@ struct BlendOp
struct Blend
{
Blend() : blendEnable(false), writeMask(0) {}
bool32 blendEnable;
bool32 blendEnable = false;
BlendOp blend, alphaBlend;
uint8_t writeMask;
uint8_t writeMask = 0;
};
struct ColorBlend
{
ColorBlend() : alphaToCoverageEnable(false), alphaToOneEnable(false), logicOpEnable(false)
{
blendConst[0] = blendConst[1] = blendConst[2] = blendConst[3] = 0.0f;
}
bool32 alphaToCoverageEnable, alphaToOneEnable, logicOpEnable;
bool32 alphaToCoverageEnable = false;
bool32 alphaToOneEnable = false;
bool32 logicOpEnable = false;
rdctype::str logicOp;
rdctype::array<Blend> attachments;
// dynamic
float blendConst[4];
float blendConst[4] = {1.0f, 1.0f, 1.0f, 1.0f};
};
struct StencilOp
{
StencilOp() : ref(0), compareMask(0xff), writeMask(0xff) {}
rdctype::str failOp;
rdctype::str depthFailOp;
rdctype::str passOp;
rdctype::str func;
// dynamic
uint32_t ref, compareMask, writeMask;
uint32_t ref = 0;
uint32_t compareMask = 0xff;
uint32_t writeMask = 0xff;
};
struct DepthStencil
{
DepthStencil()
: depthTestEnable(false),
depthWriteEnable(false),
depthBoundsEnable(false),
stencilTestEnable(false),
minDepthBounds(0),
maxDepthBounds(0)
{
}
bool32 depthTestEnable, depthWriteEnable, depthBoundsEnable;
bool32 depthTestEnable = false;
bool32 depthWriteEnable = false;
bool32 depthBoundsEnable = false;
rdctype::str depthCompareOp;
bool32 stencilTestEnable;
bool32 stencilTestEnable = false;
StencilOp front, back;
// dynamic
float minDepthBounds, maxDepthBounds;
float minDepthBounds = 0.0f;
float maxDepthBounds = 0.0f;
};
struct RenderPass
{
RenderPass() : depthstencilAttachment(-1) {}
ResourceId obj;
// VKTODOMED renderpass and subpass information here
rdctype::array<uint32_t> inputAttachments;
rdctype::array<uint32_t> colorAttachments;
int32_t depthstencilAttachment;
int32_t depthstencilAttachment = -1;
};
struct Attachment
{
Attachment() : baseMip(0), baseLayer(0), numMip(1), numLayer(1)
{
swizzle[0] = TextureSwizzle::Red;
swizzle[1] = TextureSwizzle::Green;
swizzle[2] = TextureSwizzle::Blue;
swizzle[3] = TextureSwizzle::Alpha;
}
ResourceId view;
ResourceId img;
ResourceFormat viewfmt;
TextureSwizzle swizzle[4];
uint32_t baseMip;
uint32_t baseLayer;
uint32_t numMip;
uint32_t numLayer;
TextureSwizzle swizzle[4] = {TextureSwizzle::Red, TextureSwizzle::Green, TextureSwizzle::Blue,
TextureSwizzle::Alpha};
uint32_t baseMip = 0;
uint32_t baseLayer = 0;
uint32_t numMip = 1;
uint32_t numLayer = 1;
};
struct Framebuffer
{
Framebuffer() : width(0), height(0), layers(0) {}
ResourceId obj;
rdctype::array<Attachment> attachments;
uint32_t width, height, layers;
uint32_t width = 0;
uint32_t height = 0;
uint32_t layers = 0;
};
struct RenderArea
{
RenderArea() : x(0), y(0), width(0), height(0) {}
int32_t x, y, width, height;
int32_t x = 0;
int32_t y = 0;
int32_t width = 0;
int32_t height = 0;
};
struct CurrentPass
@@ -369,10 +322,10 @@ struct CurrentPass
struct ImageLayout
{
uint32_t baseMip;
uint32_t baseLayer;
uint32_t numMip;
uint32_t numLayer;
uint32_t baseMip = 0;
uint32_t baseLayer = 0;
uint32_t numMip = 1;
uint32_t numLayer = 1;
rdctype::str name;
};