mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-29 00:33:01 +00:00
common/d3d12: emulate polygon mode
This commit is contained in:
parent
6221fecf3b
commit
1cda2977bb
@ -180,14 +180,19 @@ bool is_primitive_native(unsigned m_draw_mode) noexcept
|
|||||||
case CELL_GCM_PRIMITIVE_TRIANGLES:
|
case CELL_GCM_PRIMITIVE_TRIANGLES:
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP:
|
||||||
case CELL_GCM_PRIMITIVE_QUAD_STRIP:
|
case CELL_GCM_PRIMITIVE_QUAD_STRIP:
|
||||||
case CELL_GCM_PRIMITIVE_POLYGON:
|
|
||||||
return true;
|
return true;
|
||||||
|
case CELL_GCM_PRIMITIVE_POLYGON:
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
||||||
case CELL_GCM_PRIMITIVE_QUADS:
|
case CELL_GCM_PRIMITIVE_QUADS:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** We assume that polygon is convex in polygon mode (constraints in OpenGL)
|
||||||
|
*In such case polygon triangulation equates to triangle fan with arbitrary start vertex
|
||||||
|
* see http://www.gamedev.net/page/resources/_/technical/graphics-programming-and-theory/polygon-triangulation-r3334
|
||||||
|
*/
|
||||||
|
|
||||||
size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexcept
|
size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexcept
|
||||||
{
|
{
|
||||||
// Index count
|
// Index count
|
||||||
@ -196,6 +201,7 @@ size_t get_index_count(unsigned m_draw_mode, unsigned initial_index_count) noexc
|
|||||||
|
|
||||||
switch (m_draw_mode)
|
switch (m_draw_mode)
|
||||||
{
|
{
|
||||||
|
case CELL_GCM_PRIMITIVE_POLYGON:
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
||||||
return (initial_index_count - 2) * 3;
|
return (initial_index_count - 2) * 3;
|
||||||
case CELL_GCM_PRIMITIVE_QUADS:
|
case CELL_GCM_PRIMITIVE_QUADS:
|
||||||
@ -221,6 +227,7 @@ void write_index_array_for_non_indexed_non_native_primitive_to_buffer(char* dst,
|
|||||||
switch (draw_mode)
|
switch (draw_mode)
|
||||||
{
|
{
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
||||||
|
case CELL_GCM_PRIMITIVE_POLYGON:
|
||||||
for (unsigned i = 0; i < (count - 2); i++)
|
for (unsigned i = 0; i < (count - 2); i++)
|
||||||
{
|
{
|
||||||
typedDst[3 * i] = first;
|
typedDst[3 * i] = first;
|
||||||
|
@ -301,10 +301,10 @@ D3D12_PRIMITIVE_TOPOLOGY get_primitive_topology(u8 draw_mode) noexcept
|
|||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
||||||
// Emulated
|
// Emulated
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
||||||
case CELL_GCM_PRIMITIVE_QUADS: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
case CELL_GCM_PRIMITIVE_QUADS:
|
||||||
|
|
||||||
case CELL_GCM_PRIMITIVE_QUAD_STRIP:
|
|
||||||
case CELL_GCM_PRIMITIVE_POLYGON: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
case CELL_GCM_PRIMITIVE_POLYGON: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
|
|
||||||
|
case CELL_GCM_PRIMITIVE_QUAD_STRIP: return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||||
}
|
}
|
||||||
unreachable("Wrong draw mode");
|
unreachable("Wrong draw mode");
|
||||||
}
|
}
|
||||||
@ -318,11 +318,12 @@ D3D12_PRIMITIVE_TOPOLOGY_TYPE get_primitive_topology_type(u8 draw_mode) noexcept
|
|||||||
case CELL_GCM_PRIMITIVE_LINE_STRIP: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
case CELL_GCM_PRIMITIVE_LINE_STRIP: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLES:
|
case CELL_GCM_PRIMITIVE_TRIANGLES:
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP:
|
case CELL_GCM_PRIMITIVE_TRIANGLE_STRIP:
|
||||||
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
case CELL_GCM_PRIMITIVE_TRIANGLE_FAN:
|
||||||
case CELL_GCM_PRIMITIVE_QUADS:
|
case CELL_GCM_PRIMITIVE_POLYGON:
|
||||||
|
case CELL_GCM_PRIMITIVE_QUADS: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
// unsupported
|
// unsupported
|
||||||
case CELL_GCM_PRIMITIVE_QUAD_STRIP:
|
case CELL_GCM_PRIMITIVE_QUAD_STRIP:
|
||||||
case CELL_GCM_PRIMITIVE_POLYGON: return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||||
}
|
}
|
||||||
unreachable("Wrong draw mode");
|
unreachable("Wrong draw mode");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user