citro3d/source/drawElements.c

33 lines
1.0 KiB
C
Raw Normal View History

2014-12-20 21:34:19 +01:00
#include "context.h"
void C3D_DrawElements(GPU_Primitive_t primitive, int count, int type, const void* indices)
2014-12-20 21:34:19 +01:00
{
C3D_Context* ctx = C3Di_GetContext();
u32 pa = osConvertVirtToPhys(indices);
u32 base = ctx->bufInfo.base_paddr;
if (pa < base) return;
2014-12-20 21:34:19 +01:00
C3Di_UpdateContext();
// Set primitive type
2015-03-05 17:56:33 +01:00
GPUCMD_AddMaskedWrite(GPUREG_PRIMITIVE_CONFIG, 2, primitive);
2015-09-07 19:31:48 +02:00
GPUCMD_AddMaskedWrite(GPUREG_RESTART_PRIMITIVE, 2, 0x00000001);
// Configure the index buffer
GPUCMD_AddWrite(GPUREG_INDEXBUFFER_CONFIG, (pa - base) | (type << 31));
2014-12-20 21:34:19 +01:00
// Number of vertices
GPUCMD_AddWrite(GPUREG_NUMVERTICES, count);
2015-09-07 19:31:48 +02:00
// First vertex
GPUCMD_AddWrite(GPUREG_VERTEX_OFFSET, 0);
2014-12-20 21:34:19 +01:00
// Unknown commands
2015-09-07 19:31:48 +02:00
//GPUCMD_AddMaskedWrite(GPUREG_GEOSTAGE_CONFIG, 2, 0x00000100);
2015-03-05 17:56:33 +01:00
GPUCMD_AddMaskedWrite(GPUREG_0253, 2, 0x00000100);
2014-12-20 21:34:19 +01:00
2015-03-05 17:56:33 +01:00
GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000000);
GPUCMD_AddWrite(GPUREG_DRAWELEMENTS, 0x00000001);
GPUCMD_AddMaskedWrite(GPUREG_0245, 1, 0x00000001);
GPUCMD_AddWrite(GPUREG_0231, 0x00000001);
2014-12-20 21:34:19 +01:00
2015-09-20 14:04:50 +02:00
C3Di_GetContext()->flags |= C3DiF_DrawUsed;
2014-12-20 21:34:19 +01:00
}