MCPcopy Create free account
hub / github.com/baldurk/renderdoc / getMeshOutputs

Function getMeshOutputs

docs/python_api/examples/renderdoc/decode_mesh.py:112–168  ·  view source on GitHub ↗
(controller, postvs)

Source from the content-addressed store, hash-verified

110
111# Get a list of MeshData objects describing the vertex outputs at this draw
112def getMeshOutputs(controller, postvs):
113 meshOutputs = []
114 posidx = 0
115
116 vs = controller.GetPipelineState().GetShaderReflection(rd.ShaderStage.Vertex)
117
118 # Repeat the process, but this time sourcing the data from postvs.
119 # Since these are outputs, we iterate over the list of outputs from the
120 # vertex shader's reflection data
121 for attr in vs.outputSignature:
122 # Copy most properties from the postvs struct
123 meshOutput = MeshData()
124 meshOutput.indexResourceId = postvs.indexResourceId
125 meshOutput.indexByteOffset = postvs.indexByteOffset
126 meshOutput.indexByteStride = postvs.indexByteStride
127 meshOutput.baseVertex = postvs.baseVertex
128 meshOutput.indexOffset = 0
129 meshOutput.numIndices = postvs.numIndices
130
131 # The total offset is the attribute offset from the base of the vertex,
132 # as calculated by the stride per index
133 meshOutput.vertexByteOffset = postvs.vertexByteOffset
134 meshOutput.vertexResourceId = postvs.vertexResourceId
135 meshOutput.vertexByteStride = postvs.vertexByteStride
136
137 # Construct a resource format for this element
138 meshOutput.format = rd.ResourceFormat()
139 meshOutput.format.compByteWidth = rd.VarTypeByteSize(attr.varType)
140 meshOutput.format.compCount = attr.compCount
141 meshOutput.format.compType = rd.VarTypeCompType(attr.varType)
142 meshOutput.format.type = rd.ResourceFormatType.Regular
143
144 meshOutput.name = attr.semanticIdxName if attr.varName == '' else attr.varName
145
146 if attr.systemValue == rd.ShaderBuiltin.Position:
147 posidx = len(meshOutputs)
148
149 meshOutputs.append(meshOutput)
150
151 # Shuffle the position element to the front
152 if posidx > 0:
153 pos = meshOutputs[posidx]
154 del meshOutputs[posidx]
155 meshOutputs.insert(0, pos)
156
157 accumOffset = 0
158
159 for i in range(0, len(meshOutputs)):
160 meshOutputs[i].vertexByteOffset = accumOffset
161
162 # Note that some APIs such as Vulkan will pad the size of the attribute here
163 # while others will tightly pack
164 fmt = meshOutputs[i].format
165
166 accumOffset += (8 if fmt.compByteWidth > 4 else 4) * fmt.compCount
167
168 return meshOutputs
169

Callers 1

sampleCodeFunction · 0.85

Calls 4

MeshDataClass · 0.85
rangeFunction · 0.50
appendMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected