forked from suyu/suyu
pica/primitive_assembly: Handle winding for GS primitive
hwtest shows that, although GS always emit a group of three vertices as one primitive, it still respects to the topology type, as if the three vertices are input into the primitive assembler independently and sequentially. It is also shown that the winding flag in SETEMIT only takes effect for Shader topology type, which is believed to be the actual difference between List and Shader (hence removed the TODO). However, only Shader topology type is observed in official games when GS is in use, so the other mode seems to be just unintended usage.
This commit is contained in:
parent
bb63ae3052
commit
36981a5aa6
2 changed files with 19 additions and 3 deletions
|
@ -17,15 +17,18 @@ template <typename VertexType>
|
|||
void PrimitiveAssembler<VertexType>::SubmitVertex(const VertexType& vtx,
|
||||
TriangleHandler triangle_handler) {
|
||||
switch (topology) {
|
||||
// TODO: Figure out what's different with TriangleTopology::Shader.
|
||||
case PipelineRegs::TriangleTopology::List:
|
||||
case PipelineRegs::TriangleTopology::Shader:
|
||||
if (buffer_index < 2) {
|
||||
buffer[buffer_index++] = vtx;
|
||||
} else {
|
||||
buffer_index = 0;
|
||||
|
||||
triangle_handler(buffer[0], buffer[1], vtx);
|
||||
if (topology == PipelineRegs::TriangleTopology::Shader && winding) {
|
||||
triangle_handler(buffer[1], buffer[0], vtx);
|
||||
winding = false;
|
||||
} else {
|
||||
triangle_handler(buffer[0], buffer[1], vtx);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -50,10 +53,16 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(const VertexType& vtx,
|
|||
}
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
void PrimitiveAssembler<VertexType>::SetWinding() {
|
||||
winding = true;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
void PrimitiveAssembler<VertexType>::Reset() {
|
||||
buffer_index = 0;
|
||||
strip_ready = false;
|
||||
winding = false;
|
||||
}
|
||||
|
||||
template <typename VertexType>
|
||||
|
|
|
@ -29,6 +29,12 @@ struct PrimitiveAssembler {
|
|||
*/
|
||||
void SubmitVertex(const VertexType& vtx, TriangleHandler triangle_handler);
|
||||
|
||||
/**
|
||||
* Invert the vertex order of the next triangle. Called by geometry shader emitter.
|
||||
* This only takes effect for TriangleTopology::Shader.
|
||||
*/
|
||||
void SetWinding();
|
||||
|
||||
/**
|
||||
* Resets the internal state of the PrimitiveAssembler.
|
||||
*/
|
||||
|
@ -45,6 +51,7 @@ private:
|
|||
int buffer_index;
|
||||
VertexType buffer[2];
|
||||
bool strip_ready = false;
|
||||
bool winding = false;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue