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
@ -17,16 +17,19 @@ template <typename VertexType>
|
|||||||
void PrimitiveAssembler<VertexType>::SubmitVertex(const VertexType& vtx,
|
void PrimitiveAssembler<VertexType>::SubmitVertex(const VertexType& vtx,
|
||||||
TriangleHandler triangle_handler) {
|
TriangleHandler triangle_handler) {
|
||||||
switch (topology) {
|
switch (topology) {
|
||||||
// TODO: Figure out what's different with TriangleTopology::Shader.
|
|
||||||
case PipelineRegs::TriangleTopology::List:
|
case PipelineRegs::TriangleTopology::List:
|
||||||
case PipelineRegs::TriangleTopology::Shader:
|
case PipelineRegs::TriangleTopology::Shader:
|
||||||
if (buffer_index < 2) {
|
if (buffer_index < 2) {
|
||||||
buffer[buffer_index++] = vtx;
|
buffer[buffer_index++] = vtx;
|
||||||
} else {
|
} else {
|
||||||
buffer_index = 0;
|
buffer_index = 0;
|
||||||
|
if (topology == PipelineRegs::TriangleTopology::Shader && winding) {
|
||||||
|
triangle_handler(buffer[1], buffer[0], vtx);
|
||||||
|
winding = false;
|
||||||
|
} else {
|
||||||
triangle_handler(buffer[0], buffer[1], vtx);
|
triangle_handler(buffer[0], buffer[1], vtx);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PipelineRegs::TriangleTopology::Strip:
|
case PipelineRegs::TriangleTopology::Strip:
|
||||||
@ -50,10 +53,16 @@ void PrimitiveAssembler<VertexType>::SubmitVertex(const VertexType& vtx,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename VertexType>
|
||||||
|
void PrimitiveAssembler<VertexType>::SetWinding() {
|
||||||
|
winding = true;
|
||||||
|
}
|
||||||
|
|
||||||
template <typename VertexType>
|
template <typename VertexType>
|
||||||
void PrimitiveAssembler<VertexType>::Reset() {
|
void PrimitiveAssembler<VertexType>::Reset() {
|
||||||
buffer_index = 0;
|
buffer_index = 0;
|
||||||
strip_ready = false;
|
strip_ready = false;
|
||||||
|
winding = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename VertexType>
|
template <typename VertexType>
|
||||||
|
@ -29,6 +29,12 @@ struct PrimitiveAssembler {
|
|||||||
*/
|
*/
|
||||||
void SubmitVertex(const VertexType& vtx, TriangleHandler triangle_handler);
|
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.
|
* Resets the internal state of the PrimitiveAssembler.
|
||||||
*/
|
*/
|
||||||
@ -45,6 +51,7 @@ private:
|
|||||||
int buffer_index;
|
int buffer_index;
|
||||||
VertexType buffer[2];
|
VertexType buffer[2];
|
||||||
bool strip_ready = false;
|
bool strip_ready = false;
|
||||||
|
bool winding = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Loading…
Reference in New Issue
Block a user