Clear up random register writes in array/element/immediate drawing
This commit is contained in:
parent
959f250f4e
commit
413cfe004f
@ -6,21 +6,26 @@ void C3D_DrawArrays(GPU_Primitive_t primitive, int first, int size)
|
|||||||
|
|
||||||
// Set primitive type
|
// Set primitive type
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_RESTART_PRIMITIVE, 2, 0x00000001);
|
// Start a new primitive (breaks off a triangle strip/fan)
|
||||||
// The index buffer is not used, but 0x000F0227 is still required
|
GPUCMD_AddWrite(GPUREG_RESTART_PRIMITIVE, 1);
|
||||||
|
// The index buffer is not used, but this command is still required
|
||||||
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, 0x80000000);
|
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, 0x80000000);
|
||||||
// Number of vertices
|
// Number of vertices
|
||||||
GPUCMD_AddWrite(GPUREG_NUMVERTICES, size);
|
GPUCMD_AddWrite(GPUREG_NUMVERTICES, size);
|
||||||
// First vertex
|
// First vertex
|
||||||
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, first);
|
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, first);
|
||||||
|
// Enable array drawing mode
|
||||||
// Unknown commands
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 3, 0x001);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 0x00000001);
|
// Enable drawing mode
|
||||||
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000000);
|
// Trigger array drawing
|
||||||
GPUCMD_AddWrite(GPUREG_DRAWARRAYS, 0x00000001);
|
GPUCMD_AddWrite(GPUREG_DRAWARRAYS, 1);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000001);
|
// Go back to configuration mode
|
||||||
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 0x00000001);
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 1);
|
||||||
|
// Disable array drawing mode
|
||||||
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 0);
|
||||||
|
// Clear the post-vertex cache
|
||||||
|
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 1);
|
||||||
|
|
||||||
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
||||||
}
|
}
|
||||||
|
@ -11,22 +11,25 @@ void C3D_DrawElements(GPU_Primitive_t primitive, int count, int type, const void
|
|||||||
|
|
||||||
// Set primitive type
|
// Set primitive type
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_RESTART_PRIMITIVE, 2, 0x00000001);
|
// Start a new primitive (breaks off a triangle strip/fan)
|
||||||
|
GPUCMD_AddWrite(GPUREG_RESTART_PRIMITIVE, 1);
|
||||||
// Configure the index buffer
|
// Configure the index buffer
|
||||||
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, (pa - base) | (type << 31));
|
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, (pa - base) | (type << 31));
|
||||||
// Number of vertices
|
// Number of vertices
|
||||||
GPUCMD_AddWrite(GPUREG_NUMVERTICES, count);
|
GPUCMD_AddWrite(GPUREG_NUMVERTICES, count);
|
||||||
// First vertex
|
// First vertex
|
||||||
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, 0);
|
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, 0);
|
||||||
|
// Disable "triangles" mode (otherwise stuff breaks)
|
||||||
// Unknown commands
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG, 2, 0x000);
|
||||||
//GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG, 2, 0x00000100);
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 3, 0x000);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 2, 0x00000100);
|
// Enable drawing mode
|
||||||
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000000);
|
// Trigger element drawing
|
||||||
GPUCMD_AddWrite(GPUREG_DRAWELEMENTS, 0x00000001);
|
GPUCMD_AddWrite(GPUREG_DRAWELEMENTS, 1);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000001);
|
// Go back to configuration mode
|
||||||
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 0x00000001);
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 1);
|
||||||
|
// Clear the post-vertex cache
|
||||||
|
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 1);
|
||||||
|
|
||||||
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,16 @@ void C3D_ImmDrawBegin(GPU_Primitive_t primitive)
|
|||||||
{
|
{
|
||||||
C3Di_UpdateContext();
|
C3Di_UpdateContext();
|
||||||
|
|
||||||
// Set primitive type & restart the primitive
|
// Set primitive type
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_RESTART_PRIMITIVE, 2, 0x00000001);
|
// Start a new primitive (breaks off a triangle strip/fan)
|
||||||
// Not sure if GPUREG_INDEXBUFFER_CONFIG is necessary
|
GPUCMD_AddWrite(GPUREG_RESTART_PRIMITIVE, 1);
|
||||||
|
// Not sure if this command is necessary
|
||||||
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, 0x80000000);
|
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, 0x80000000);
|
||||||
|
// Enable submitting vertex data
|
||||||
// Unknown commands
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 3, 0x001);
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 0x00000001);
|
// Enable drawing mode
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000000);
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0);
|
||||||
|
|
||||||
// Begin immediate-mode vertex submission
|
// Begin immediate-mode vertex submission
|
||||||
GPUCMD_AddWrite(GPUREG_FIXEDATTRIB_INDEX, 0xF);
|
GPUCMD_AddWrite(GPUREG_FIXEDATTRIB_INDEX, 0xF);
|
||||||
}
|
}
|
||||||
@ -56,8 +56,12 @@ void C3D_ImmSendAttrib(float x, float y, float z, float w)
|
|||||||
|
|
||||||
void C3D_ImmDrawEnd(void)
|
void C3D_ImmDrawEnd(void)
|
||||||
{
|
{
|
||||||
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 0x00000001);
|
// Go back to configuration mode
|
||||||
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 0x00000001);
|
GPUCMD_AddMaskedWrite(GPUREG_START_DRAW_FUNC0, 1, 1);
|
||||||
|
// Disable array drawing mode
|
||||||
|
GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG2, 1, 0);
|
||||||
|
// Clear the post-vertex cache
|
||||||
|
GPUCMD_AddWrite(GPUREG_VTX_FUNC, 1);
|
||||||
|
|
||||||
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user