Move API-agnostic pipeline state wrapper into core interface

* There's no need for this to be in the UI, and moving it allows it to be used
  from script which is very useful.
This commit is contained in:
baldurk
2018-06-18 17:33:48 +01:00
parent 7ae6581a65
commit 14e3a3d360
48 changed files with 1057 additions and 1203 deletions
@@ -3,19 +3,17 @@ Decoding Mesh Data
In this example we will fetch the geometry inputs to and outputs from a vertex shader. While this sample does not handle all possible edge cases, it is more complex than most others.
First we gather the API state that describes the vertex input data. In this example we will use the D3D11 pipeline state, but the same can be done for other APIs:
First we gather the API state that describes the vertex input data. In this example we will use the API abstraction :py:class:`~renderdoc.PipeState` so that this code works on a capture from any API:
.. highlight:: python
.. code:: python
# This work is API-specific, but the APIs have a lot of similarities.
# Here we implement support for D3D11 since it's relatively simple
state = controller.GetD3D11PipelineState()
state = controller.GetPipelineState()
# Get the index & vertex buffers, and fixed vertex inputs
ib = state.inputAssembly.indexBuffer
vbs = state.inputAssembly.vertexBuffers
attrs = state.inputAssembly.layouts
ib = state.GetIBuffer()
vbs = state.GetVBuffers()
attrs = state.GetVertexInputs()
We iterate over every attribute defined, and create an object that describes where to source it from, based on :py:class:`~renderdoc.MeshFormat` - since that is the format returned by :py:meth:`~renderdoc.ReplayController.GetPostVSData` this allows us to re-use code.
@@ -42,13 +40,11 @@ In the object we pass both the indices (which does not vary per attribute in our
meshInput.indexResourceId = rd.ResourceId.Null()
# The total offset is the attribute offset from the base of the vertex
meshInput.vertexByteOffset = attr.byteOffset + vbs[attr.inputSlot].byteOffset
meshInput.vertexByteOffset = attr.byteOffset + vbs[attr.vertexBuffer].byteOffset
meshInput.format = attr.format
meshInput.vertexResourceId = vbs[attr.inputSlot].resourceId
meshInput.vertexByteStride = vbs[attr.inputSlot].byteStride
# We don't go into the details of semantic matching here, just use both as the name
meshInput.name = '%s%d' % (attr.semanticName, attr.semanticIndex)
meshInput.vertexResourceId = vbs[attr.vertexBuffer].resourceId
meshInput.vertexByteStride = vbs[attr.vertexBuffer].byteStride
meshInput.name = attr.name
meshInputs.append(meshInput)
@@ -174,8 +170,7 @@ The position output is also treated specially - it always appears first, regardl
posidx = 0
state = controller.GetD3D11PipelineState()
vs = state.vertexShader.reflection
vs = controller.GetPipelineState().GetShaderReflection(rd.ShaderStage.Vertex)
# Repeat the process, but this time sourcing the data from postvs.
# Since these are outputs, we iterate over the list of outputs from the