(controller, postvs)
| 110 | |
| 111 | # Get a list of MeshData objects describing the vertex outputs at this draw |
| 112 | def 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 |
no test coverage detected