Add some extra accessors of state to common pipeline state abstraction

This commit is contained in:
baldurk
2026-05-08 14:07:59 +01:00
parent 73dc273810
commit fe0a8c55e6
4 changed files with 237 additions and 2 deletions
@@ -101,9 +101,15 @@ Rasterizer
.. autoclass:: renderdoc.ShadingRateCombiner
:members:
.. autoclass:: renderdoc.RasterState
:members:
Stencil
-------
Depth and Stencil
-----------------
.. autoclass:: renderdoc.DepthTestState
:members:
.. autoclass:: renderdoc.StencilFace
:members:
+68
View File
@@ -270,6 +270,74 @@ struct ColorBlend
DECLARE_REFLECTION_STRUCT(ColorBlend);
DOCUMENT("Describes a common subset of rasterizing state.");
struct RasterState
{
DOCUMENT("");
RasterState() = default;
RasterState(const RasterState &) = default;
RasterState &operator=(const RasterState &) = default;
DOCUMENT(R"(``True`` if counter-clockwise polygons are front-facing.
``False`` if clockwise polygons are front-facing.
:type: bool
)");
bool frontCCW = false;
DOCUMENT(R"(The polygon :class:`FillMode`.
:type: FillMode
)");
FillMode fillMode = FillMode::Solid;
DOCUMENT(R"(The polygon :class:`CullMode`.
:type: CullMode
)");
CullMode cullMode = CullMode::NoCull;
};
DOCUMENT("Describes a common subset of depth testing state.");
struct DepthTestState
{
DOCUMENT("");
DepthTestState() = default;
DepthTestState(const DepthTestState &) = default;
DepthTestState &operator=(const DepthTestState &) = default;
DOCUMENT(R"(``True`` if depth testing should be performed.
:type: bool
)");
bool depthEnable = false;
DOCUMENT(R"(The :class:`CompareFunction` to use for testing depth values.
:type: CompareFunction
)");
CompareFunction depthFunction = CompareFunction::AlwaysTrue;
DOCUMENT(R"(``True`` if depth values should be written to the depth target.
:type: bool
)");
bool depthWrites = false;
DOCUMENT(R"(``True`` if depth bounds tests should be applied.
:type: bool
)");
bool depthBounds = false;
DOCUMENT(R"(The near plane bounding value.
:type: float
)");
double minDepthBounds = 0.0;
DOCUMENT(R"(The far plane bounding value.
:type: float
)");
double maxDepthBounds = 0.0;
};
DOCUMENT("Describes the details of a stencil operation.");
struct StencilFace
{
+32
View File
@@ -432,6 +432,20 @@ convenience of access.
)");
rdcarray<ColorBlend> GetColorBlends() const;
DOCUMENT(R"(Retrieves the current fixed blend factor.
:return: The currently fixed blend factor.
:rtype: Tuple[float,float,float,float]
)");
rdcfixedarray<float, 4> GetBlendFactor() const;
DOCUMENT(R"(Checks whether stencil operations are enabled or not.
:return: The currently stencil states. Front facing first, back facing second.
:rtype: Tuple[StencilFace, StencilFace]
)");
bool IsStencilTestEnabled() const;
DOCUMENT(R"(Retrieves the current stencil states.
:return: The currently stencil states. Front facing first, back facing second.
@@ -439,6 +453,24 @@ convenience of access.
)");
rdcpair<StencilFace, StencilFace> GetStencilFaces() const;
DOCUMENT(R"(Retrieves some of the depth testing state.
This doesn't contain all properties from all APIs but a common subset.
:return: The currently depth testing state.
:rtype: DepthTestState
)");
DepthTestState GetDepthTestState() const;
DOCUMENT(R"(Retrieves some of the rasterizer state.
This doesn't contain all properties from all APIs but a common subset.
:return: The currently depth testing state.
:rtype: RasterState
)");
RasterState GetRasterState() const;
DOCUMENT(R"(Determines whether or not independent blending is enabled.
:return: A boolean indicating if independent blending is enabled.
+129
View File
@@ -1194,6 +1194,110 @@ rdcarray<Descriptor> PipeState::GetOutputTargets() const
return ret;
}
rdcfixedarray<float, 4> PipeState::GetBlendFactor() const
{
if(IsCaptureLoaded())
{
if(IsCaptureD3D11())
{
return m_D3D11->outputMerger.blendState.blendFactor;
}
else if(IsCaptureD3D12())
{
return m_D3D12->outputMerger.blendState.blendFactor;
}
else if(IsCaptureGL())
{
return m_GL->framebuffer.blendState.blendFactor;
}
else if(IsCaptureVK())
{
return m_Vulkan->colorBlend.blendFactor;
}
}
return {};
}
DepthTestState PipeState::GetDepthTestState() const
{
DepthTestState ret = {};
if(IsCaptureLoaded())
{
if(IsCaptureD3D11())
{
ret.depthEnable = m_D3D11->outputMerger.depthStencilState.depthEnable;
ret.depthWrites = m_D3D11->outputMerger.depthStencilState.depthWrites;
ret.depthFunction = m_D3D11->outputMerger.depthStencilState.depthFunction;
}
else if(IsCaptureD3D12())
{
ret.depthEnable = m_D3D12->outputMerger.depthStencilState.depthEnable;
ret.depthWrites = m_D3D12->outputMerger.depthStencilState.depthWrites;
ret.depthFunction = m_D3D12->outputMerger.depthStencilState.depthFunction;
ret.depthBounds = m_D3D12->outputMerger.depthStencilState.depthBoundsEnable;
ret.minDepthBounds = m_D3D12->outputMerger.depthStencilState.minDepthBounds;
ret.maxDepthBounds = m_D3D12->outputMerger.depthStencilState.maxDepthBounds;
}
else if(IsCaptureGL())
{
ret.depthEnable = m_GL->depthState.depthEnable;
ret.depthWrites = m_GL->depthState.depthWrites;
ret.depthFunction = m_GL->depthState.depthFunction;
ret.depthBounds = m_GL->depthState.depthBounds;
ret.minDepthBounds = m_GL->depthState.nearBound;
ret.maxDepthBounds = m_GL->depthState.farBound;
}
else if(IsCaptureVK())
{
ret.depthEnable = m_Vulkan->depthStencil.depthTestEnable;
ret.depthWrites = m_Vulkan->depthStencil.depthWriteEnable;
ret.depthFunction = m_Vulkan->depthStencil.depthFunction;
ret.depthBounds = m_Vulkan->depthStencil.depthBoundsEnable;
ret.minDepthBounds = m_Vulkan->depthStencil.minDepthBounds;
ret.maxDepthBounds = m_Vulkan->depthStencil.maxDepthBounds;
}
}
return ret;
}
RasterState PipeState::GetRasterState() const
{
RasterState ret = {};
if(IsCaptureLoaded())
{
if(IsCaptureD3D11())
{
ret.cullMode = m_D3D11->rasterizer.state.cullMode;
ret.fillMode = m_D3D11->rasterizer.state.fillMode;
ret.frontCCW = m_D3D11->rasterizer.state.frontCCW;
}
else if(IsCaptureD3D12())
{
ret.cullMode = m_D3D12->rasterizer.state.cullMode;
ret.fillMode = m_D3D12->rasterizer.state.fillMode;
ret.frontCCW = m_D3D12->rasterizer.state.frontCCW;
}
else if(IsCaptureGL())
{
ret.cullMode = m_GL->rasterizer.state.cullMode;
ret.fillMode = m_GL->rasterizer.state.fillMode;
ret.frontCCW = m_GL->rasterizer.state.frontCCW;
}
else if(IsCaptureVK())
{
ret.cullMode = m_Vulkan->rasterizer.cullMode;
ret.fillMode = m_Vulkan->rasterizer.fillMode;
ret.frontCCW = m_Vulkan->rasterizer.frontCCW;
}
}
return ret;
}
rdcarray<ColorBlend> PipeState::GetColorBlends() const
{
if(IsCaptureLoaded())
@@ -1231,6 +1335,31 @@ rdcarray<ColorBlend> PipeState::GetColorBlends() const
return {};
}
bool PipeState::IsStencilTestEnabled() const
{
if(IsCaptureLoaded())
{
if(IsCaptureD3D11())
{
return m_D3D11->outputMerger.depthStencilState.stencilEnable;
}
else if(IsCaptureD3D12())
{
return m_D3D12->outputMerger.depthStencilState.stencilEnable;
}
else if(IsCaptureGL())
{
return m_GL->stencilState.stencilEnable;
}
else if(IsCaptureVK())
{
return m_Vulkan->depthStencil.stencilTestEnable;
}
}
return false;
}
rdcpair<StencilFace, StencilFace> PipeState::GetStencilFaces() const
{
if(IsCaptureLoaded())