Remove nested structs from D3D11 pipeline state and move to namespace

* Moving into a namespace makes it easier to give the structs non-clumsy
  names while still being unique and not overlapping with the other API
  pipeline states.
This commit is contained in:
baldurk
2017-04-18 14:57:33 +01:00
parent b271eb3103
commit b4d3401866
19 changed files with 448 additions and 432 deletions
+334 -302
View File
@@ -27,308 +27,340 @@
#include "shader_types.h"
struct D3D11PipelineState
namespace D3D11Pipe
{
D3D11PipelineState() {}
struct InputAssembler
struct Layout
{
Layout()
: SemanticIndex(0), InputSlot(0), ByteOffset(0), PerInstance(false), InstanceDataStepRate(0)
{
InputAssembler() : Bytecode(NULL), customName(false) {}
struct LayoutInput
{
LayoutInput()
: SemanticIndex(0), InputSlot(0), ByteOffset(0), PerInstance(false), InstanceDataStepRate(0)
{
}
rdctype::str SemanticName;
uint32_t SemanticIndex;
ResourceFormat Format;
uint32_t InputSlot;
uint32_t ByteOffset;
bool32 PerInstance;
uint32_t InstanceDataStepRate;
};
rdctype::array<LayoutInput> layouts;
ResourceId layout;
ShaderReflection *Bytecode;
bool32 customName;
rdctype::str LayoutName;
struct VertexBuffer
{
VertexBuffer() : Buffer(), Stride(0), Offset(0) {}
ResourceId Buffer;
uint32_t Stride;
uint32_t Offset;
};
rdctype::array<VertexBuffer> vbuffers;
struct IndexBuffer
{
IndexBuffer() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
} ibuffer;
} m_IA;
struct Shader
{
Shader() : Object(), customName(false), ShaderDetails(NULL), stage(ShaderStage::Vertex) {}
ResourceId Object;
rdctype::str ShaderName;
bool32 customName;
ShaderReflection *ShaderDetails;
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
struct ResourceView
{
ResourceView()
: View(),
Resource(),
Format(),
Structured(false),
BufferStructCount(0),
ElementSize(0),
ElementOffset(0),
ElementWidth(0),
FirstElement(0),
NumElements(1),
Flags(D3DBufferViewFlags::NoFlags),
HighestMip(0),
NumMipLevels(1),
ArraySize(1),
FirstArraySlice(0)
{
}
ResourceId View;
ResourceId Resource;
rdctype::str Type;
ResourceFormat Format;
bool32 Structured;
uint32_t BufferStructCount;
uint32_t ElementSize;
// Buffer (SRV)
uint32_t ElementOffset;
uint32_t ElementWidth;
// Buffer (UAV)
uint32_t FirstElement;
uint32_t NumElements;
// BufferEx
D3DBufferViewFlags Flags;
// Texture
uint32_t HighestMip;
uint32_t NumMipLevels;
// Texture Array
uint32_t ArraySize;
uint32_t FirstArraySlice;
};
rdctype::array<ResourceView> SRVs;
rdctype::array<ResourceView> UAVs;
struct Sampler
{
Sampler()
: Samp(),
customSamplerName(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 SamplerName;
bool32 customSamplerName;
rdctype::str AddressU, AddressV, AddressW;
float BorderColor[4];
rdctype::str Comparison;
rdctype::str Filter;
bool32 UseBorder;
bool32 UseComparison;
uint32_t MaxAniso;
float MaxLOD;
float MinLOD;
float MipLODBias;
};
rdctype::array<Sampler> Samplers;
struct CBuffer
{
CBuffer() : Buffer(), VecOffset(0), VecCount(0) {}
ResourceId Buffer;
uint32_t VecOffset;
uint32_t VecCount;
};
rdctype::array<CBuffer> ConstantBuffers;
rdctype::array<rdctype::str> ClassInstances;
} m_VS, m_HS, m_DS, m_GS, m_PS, m_CS;
struct Streamout
{
struct Output
{
Output() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
};
rdctype::array<Output> Outputs;
} m_SO;
struct Rasterizer
{
struct Viewport
{
Viewport() : Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f), Enabled(false)
{
TopLeft[0] = 0.0f;
TopLeft[1] = 0.0f;
}
Viewport(float TX, float TY, float W, float H, float MN, float MX, bool en)
: Width(W), Height(H), MinDepth(MN), MaxDepth(MX), Enabled(en)
{
TopLeft[0] = TX;
TopLeft[1] = TY;
}
float TopLeft[2];
float Width, Height;
float MinDepth, MaxDepth;
bool32 Enabled;
};
rdctype::array<Viewport> Viewports;
struct Scissor
{
Scissor() : left(0), top(0), right(0), bottom(0), Enabled(false) {}
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;
};
rdctype::array<Scissor> Scissors;
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;
} m_State;
} m_RS;
struct OutputMerger
{
OutputMerger() : UAVStartSlot(0), DepthReadOnly(false), StencilReadOnly(false) {}
struct DepthStencilState
{
DepthStencilState()
: State(),
DepthEnable(false),
DepthWrites(false),
StencilEnable(false),
StencilReadMask(0),
StencilWriteMask(0),
StencilRef(0)
{
}
ResourceId State;
bool32 DepthEnable;
rdctype::str DepthFunc;
bool32 DepthWrites;
bool32 StencilEnable;
byte StencilReadMask;
byte StencilWriteMask;
struct StencilOp
{
rdctype::str FailOp;
rdctype::str DepthFailOp;
rdctype::str PassOp;
rdctype::str Func;
} m_FrontFace, m_BackFace;
uint32_t StencilRef;
} m_State;
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;
struct RTBlend
{
RTBlend() : Enabled(false), LogicEnabled(false), WriteMask(0) {}
struct BlendOp
{
rdctype::str Source;
rdctype::str Destination;
rdctype::str Operation;
} m_Blend, m_AlphaBlend;
rdctype::str LogicOp;
bool32 Enabled;
bool32 LogicEnabled;
byte WriteMask;
};
rdctype::array<RTBlend> Blends;
float BlendFactor[4];
uint32_t SampleMask;
} m_BlendState;
rdctype::array<Shader::ResourceView> RenderTargets;
uint32_t UAVStartSlot;
rdctype::array<Shader::ResourceView> UAVs;
Shader::ResourceView DepthTarget;
bool32 DepthReadOnly;
bool32 StencilReadOnly;
} m_OM;
}
rdctype::str SemanticName;
uint32_t SemanticIndex;
ResourceFormat Format;
uint32_t InputSlot;
uint32_t ByteOffset;
bool32 PerInstance;
uint32_t InstanceDataStepRate;
};
struct VB
{
VB() : Buffer(), Stride(0), Offset(0) {}
ResourceId Buffer;
uint32_t Stride;
uint32_t Offset;
};
struct IB
{
IB() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
};
struct IA
{
IA() : Bytecode(NULL), customName(false) {}
rdctype::array<Layout> layouts;
ResourceId layout;
ShaderReflection *Bytecode;
bool32 customName;
rdctype::str LayoutName;
rdctype::array<VB> vbuffers;
IB ibuffer;
};
struct View
{
View()
: Object(),
Resource(),
Format(),
Structured(false),
BufferStructCount(0),
ElementSize(0),
ElementOffset(0),
ElementWidth(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;
// Buffer (SRV)
uint32_t ElementOffset;
uint32_t ElementWidth;
// Buffer (UAV)
uint32_t FirstElement;
uint32_t NumElements;
// BufferEx
D3DBufferViewFlags Flags;
// Texture
uint32_t HighestMip;
uint32_t NumMipLevels;
// Texture Array
uint32_t ArraySize;
uint32_t FirstArraySlice;
};
struct Sampler
{
Sampler()
: Samp(),
customSamplerName(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 SamplerName;
bool32 customSamplerName;
rdctype::str AddressU, AddressV, AddressW;
float BorderColor[4];
rdctype::str Comparison;
rdctype::str Filter;
bool32 UseBorder;
bool32 UseComparison;
uint32_t MaxAniso;
float MaxLOD;
float MinLOD;
float MipLODBias;
};
struct CBuffer
{
CBuffer() : Buffer(), VecOffset(0), VecCount(0) {}
ResourceId Buffer;
uint32_t VecOffset;
uint32_t VecCount;
};
struct Shader
{
Shader() : Object(), customName(false), ShaderDetails(NULL), stage(ShaderStage::Vertex) {}
ResourceId Object;
rdctype::str ShaderName;
bool32 customName;
ShaderReflection *ShaderDetails;
ShaderBindpointMapping BindpointMapping;
ShaderStage stage;
rdctype::array<View> SRVs;
rdctype::array<View> UAVs;
rdctype::array<Sampler> Samplers;
rdctype::array<CBuffer> ConstantBuffers;
rdctype::array<rdctype::str> ClassInstances;
};
struct SOBind
{
SOBind() : Buffer(), Offset(0) {}
ResourceId Buffer;
uint32_t Offset;
};
struct SO
{
rdctype::array<SOBind> Outputs;
};
struct Viewport
{
Viewport() : Width(0.0f), Height(0.0f), MinDepth(0.0f), MaxDepth(0.0f), Enabled(false)
{
TopLeft[0] = 0.0f;
TopLeft[1] = 0.0f;
}
Viewport(float TX, float TY, float W, float H, float MN, float MX, bool en)
: Width(W), Height(H), MinDepth(MN), MaxDepth(MX), Enabled(en)
{
TopLeft[0] = TX;
TopLeft[1] = TY;
}
float TopLeft[2];
float Width, Height;
float MinDepth, MaxDepth;
bool32 Enabled;
};
struct Scissor
{
Scissor() : left(0), top(0), right(0), bottom(0), Enabled(false) {}
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;
};
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;
};
struct Rasterizer
{
rdctype::array<Viewport> Viewports;
rdctype::array<Scissor> Scissors;
RasterizerState m_State;
};
struct StencilOp
{
rdctype::str FailOp;
rdctype::str DepthFailOp;
rdctype::str PassOp;
rdctype::str Func;
};
struct DepthStencilState
{
DepthStencilState()
: State(),
DepthEnable(false),
DepthWrites(false),
StencilEnable(false),
StencilReadMask(0),
StencilWriteMask(0),
StencilRef(0)
{
}
ResourceId State;
bool32 DepthEnable;
rdctype::str DepthFunc;
bool32 DepthWrites;
bool32 StencilEnable;
byte StencilReadMask;
byte StencilWriteMask;
StencilOp m_FrontFace, m_BackFace;
uint32_t StencilRef;
};
struct BlendOp
{
rdctype::str Source;
rdctype::str Destination;
rdctype::str Operation;
};
struct Blend
{
Blend() : Enabled(false), LogicEnabled(false), WriteMask(0) {}
BlendOp m_Blend, m_AlphaBlend;
rdctype::str LogicOp;
bool32 Enabled;
bool32 LogicEnabled;
byte WriteMask;
};
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;
rdctype::array<Blend> Blends;
float BlendFactor[4];
uint32_t SampleMask;
};
struct OM
{
OM() : UAVStartSlot(0), DepthReadOnly(false), StencilReadOnly(false) {}
DepthStencilState m_State;
BlendState m_BlendState;
rdctype::array<View> RenderTargets;
uint32_t UAVStartSlot;
rdctype::array<View> UAVs;
View DepthTarget;
bool32 DepthReadOnly;
bool32 StencilReadOnly;
};
struct State
{
State() {}
IA m_IA;
Shader m_VS, m_HS, m_DS, m_GS, m_PS, m_CS;
SO m_SO;
Rasterizer m_RS;
OM m_OM;
};
}; // namespace D3D11Pipe
+2 -2
View File
@@ -222,7 +222,7 @@ struct IReplayRenderer
virtual bool InitResolver() = 0;
virtual bool SetFrameEvent(uint32_t eventID, bool force) = 0;
virtual bool GetD3D11PipelineState(D3D11PipelineState *state) = 0;
virtual bool GetD3D11PipelineState(D3D11Pipe::State *state) = 0;
virtual bool GetD3D12PipelineState(D3D12PipelineState *state) = 0;
virtual bool GetGLPipelineState(GLPipelineState *state) = 0;
virtual bool GetVulkanPipelineState(VulkanPipelineState *state) = 0;
@@ -298,7 +298,7 @@ extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayRenderer_SetFrameEvent(IRepla
uint32_t eventID,
bool32 force);
extern "C" RENDERDOC_API bool32 RENDERDOC_CC
ReplayRenderer_GetD3D11PipelineState(IReplayRenderer *rend, D3D11PipelineState *state);
ReplayRenderer_GetD3D11PipelineState(IReplayRenderer *rend, D3D11Pipe::State *state);
extern "C" RENDERDOC_API bool32 RENDERDOC_CC
ReplayRenderer_GetD3D12PipelineState(IReplayRenderer *rend, D3D12PipelineState *state);
extern "C" RENDERDOC_API bool32 RENDERDOC_CC ReplayRenderer_GetGLPipelineState(IReplayRenderer *rend,