Adapt to the great-refactor libctru branch
This commit is contained in:
parent
a8ce19c3b5
commit
3e42b1a9a4
1
Makefile
1
Makefile
@ -28,6 +28,7 @@ INCLUDES := include
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
|
@ -46,7 +46,7 @@ CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map) -Wl,--gc-sections
|
||||
|
||||
LIBS := -lcitro3d -lctru -lm
|
||||
|
||||
|
@ -2,25 +2,6 @@
|
||||
|
||||
C3D_Context __C3D_Context;
|
||||
|
||||
u32 C3Di_Float24(float f)
|
||||
{
|
||||
if (!f) return 0;
|
||||
union { float t; u32 v; } u;
|
||||
u.t = f;
|
||||
u32 s = u.v >> 31;
|
||||
u32 exp = ((u.v >> 23) & 0xFF) - 0x40;
|
||||
u32 man = (u.v >> 7) & 0xFFFF;
|
||||
|
||||
return (exp >= 0) ? (man | (exp << 16) | (s << 23)) : (s << 23);
|
||||
}
|
||||
|
||||
u32 C3Di_FloatInv24(u32 val)
|
||||
{
|
||||
// Too lazy to copy & paste & cleanup the libctru function
|
||||
extern u32 computeInvValue(u32 val);
|
||||
return computeInvValue(val);
|
||||
}
|
||||
|
||||
static void C3Di_SetTex(GPU_TEXUNIT unit, C3D_Tex* tex)
|
||||
{
|
||||
u32 reg[4];
|
||||
@ -86,7 +67,6 @@ bool C3D_Init(size_t cmdBufSize)
|
||||
ctx->cmdBuf = linearAlloc(cmdBufSize);
|
||||
if (!ctx->cmdBuf) return false;
|
||||
|
||||
GPU_Reset(NULL, ctx->cmdBuf, ctx->cmdBufSize);
|
||||
GPUCMD_SetBuffer(ctx->cmdBuf, ctx->cmdBufSize, 0);
|
||||
|
||||
ctx->flags = C3DiF_Active | C3DiF_TexEnvAll | C3DiF_Effect | C3DiF_TexAll;
|
||||
@ -116,10 +96,10 @@ void C3D_SetViewport(u32 x, u32 y, u32 w, u32 h)
|
||||
{
|
||||
C3D_Context* ctx = C3Di_GetContext();
|
||||
ctx->flags |= C3DiF_Viewport | C3DiF_Scissor;
|
||||
ctx->viewport[0] = C3Di_Float24((float)w/2);
|
||||
ctx->viewport[1] = C3Di_FloatInv24(w);
|
||||
ctx->viewport[2] = C3Di_Float24((float)h/2);
|
||||
ctx->viewport[3] = C3Di_FloatInv24(h);
|
||||
ctx->viewport[0] = f32tof24(w / 2.0f);
|
||||
ctx->viewport[1] = f32tof31(2.0f / w) << 1;
|
||||
ctx->viewport[2] = f32tof24(h / 2.0f);
|
||||
ctx->viewport[3] = f32tof31(2.0f / h) << 1;
|
||||
ctx->viewport[4] = (y << 16) | (x & 0xFFFF);
|
||||
ctx->scissor[0] = GPU_SCISSOR_DISABLE;
|
||||
}
|
||||
@ -199,7 +179,8 @@ void C3Di_UpdateContext(void)
|
||||
}
|
||||
|
||||
ctx->flags &= ~C3DiF_TexAll;
|
||||
GPU_SetTextureEnable(units);
|
||||
GPUCMD_AddMaskedWrite(GPUREG_006F, 0x2, units<<8); // enables texcoord outputs
|
||||
GPUCMD_AddWrite(GPUREG_TEXUNITS_CONFIG, 0x00011000|units); // enables texture units
|
||||
}
|
||||
|
||||
if (ctx->flags & C3DiF_TexEnvAll)
|
||||
@ -226,11 +207,13 @@ void C3D_FlushAsync(void)
|
||||
if (ctx->flags & C3DiF_NeedFinishDrawing)
|
||||
{
|
||||
ctx->flags &= ~C3DiF_NeedFinishDrawing;
|
||||
GPU_FinishDrawing();
|
||||
GPUCMD_AddWrite(GPUREG_0111, 0x00000001);
|
||||
GPUCMD_AddWrite(GPUREG_0110, 0x00000001);
|
||||
GPUCMD_AddWrite(GPUREG_0063, 0x00000001);
|
||||
}
|
||||
|
||||
GPUCMD_Finalize();
|
||||
GPUCMD_FlushAndRun(NULL);
|
||||
GPUCMD_FlushAndRun();
|
||||
GPUCMD_SetBuffer(ctx->cmdBuf, ctx->cmdBufSize, 0);
|
||||
}
|
||||
|
||||
|
@ -65,8 +65,6 @@ static inline C3D_Context* C3Di_GetContext(void)
|
||||
return &__C3D_Context;
|
||||
}
|
||||
|
||||
u32 C3Di_Float24(float f);
|
||||
u32 C3Di_FloatInv24(u32 val);
|
||||
void C3Di_UpdateContext(void);
|
||||
void C3Di_IBOBind(C3D_IBO* ibo);
|
||||
void C3Di_AttrInfoBind(C3D_AttrInfo* info);
|
||||
|
@ -10,8 +10,8 @@ static inline C3D_Effect* getEffect()
|
||||
void C3D_DepthMap(float zScale, float zOffset)
|
||||
{
|
||||
C3D_Effect* e = getEffect();
|
||||
e->zScale = C3Di_Float24(zScale);
|
||||
e->zOffset = C3Di_Float24(zOffset);
|
||||
e->zScale = f32tof24(zScale);
|
||||
e->zOffset = f32tof24(zOffset);
|
||||
}
|
||||
|
||||
void C3D_CullFace(GPU_CULLMODE mode)
|
||||
|
@ -27,7 +27,7 @@ bool C3D_IBOAddData(C3D_IBO* ibo, const void* data, int indexCount)
|
||||
void C3D_IBOFlush(C3D_IBO* ibo)
|
||||
{
|
||||
int stride = ibo->format+1;
|
||||
GSPGPU_FlushDataCache(NULL, ibo->data, ibo->indexCount*stride);
|
||||
GSPGPU_FlushDataCache(ibo->data, ibo->indexCount*stride);
|
||||
}
|
||||
|
||||
void C3Di_IBOBind(C3D_IBO* ibo)
|
||||
|
@ -41,15 +41,15 @@ void C3D_RenderBufClearAsync(C3D_RenderBuf* rb)
|
||||
{
|
||||
u32 colorBufSize = calcColorBufSize(rb->width, rb->height, rb->colorFmt);
|
||||
u32 depthBufSize = calcDepthBufSize(rb->width, rb->height, rb->depthFmt);
|
||||
GX_SetMemoryFill(NULL,
|
||||
GX_SetMemoryFill(
|
||||
(u32*)rb->colorBuf, rb->clearColor, (u32*)((u8*)rb->colorBuf+colorBufSize), BIT(0) | ((u32)colorFmtSizes[rb->colorFmt] << 8),
|
||||
(u32*)rb->depthBuf, rb->clearDepth, (u32*)((u8*)rb->depthBuf+depthBufSize), BIT(0) | ((u32)colorFmtSizes[rb->depthFmt] << 8));
|
||||
(u32*)rb->depthBuf, rb->clearDepth, (u32*)((u8*)rb->depthBuf+depthBufSize), BIT(0) | ((u32)depthFmtSizes[rb->depthFmt] << 8));
|
||||
}
|
||||
|
||||
void C3D_RenderBufTransferAsync(C3D_RenderBuf* rb, u32* frameBuf, u32 flags)
|
||||
{
|
||||
u32 dim = GX_BUFFER_DIM((u32)rb->width, (u32)rb->height);
|
||||
GX_SetDisplayTransfer(NULL, (u32*)rb->colorBuf, dim, frameBuf, dim, flags);
|
||||
GX_SetDisplayTransfer((u32*)rb->colorBuf, dim, frameBuf, dim, flags);
|
||||
}
|
||||
|
||||
void C3D_RenderBufBind(C3D_RenderBuf* rb)
|
||||
|
@ -69,7 +69,7 @@ void C3D_TexBind(int unitId, C3D_Tex* tex)
|
||||
void C3D_TexFlush(C3D_Tex* tex)
|
||||
{
|
||||
if (tex->data)
|
||||
GSPGPU_FlushDataCache(NULL, tex->data, tex->size);
|
||||
GSPGPU_FlushDataCache(tex->data, tex->size);
|
||||
}
|
||||
|
||||
void C3D_TexDelete(C3D_Tex* tex)
|
||||
|
@ -36,7 +36,8 @@ void C3D_UpdateUniforms(GPU_SHADER_TYPE type)
|
||||
*/
|
||||
|
||||
// Upload the uniforms
|
||||
GPU_SetFloatUniform(type, i, (u32*)&C3D_FVUnif[i], j-i);
|
||||
GPUCMD_AddWrite(GPUREG_VSH_FLOATUNIFORM_CONFIG+offset, 0x80000000|i);
|
||||
GPUCMD_AddWrites(GPUREG_VSH_FLOATUNIFORM_DATA+offset, (u32*)&C3D_FVUnif[i], (j-i)*4);
|
||||
|
||||
// Clear the dirty flag
|
||||
int k;
|
||||
|
@ -27,7 +27,7 @@ bool C3D_VBOAddData(C3D_VBO* vbo, const void* data, size_t size, int vertexCount
|
||||
void C3D_VBOFlush(C3D_VBO* vbo)
|
||||
{
|
||||
if (vbo->data)
|
||||
GSPGPU_FlushDataCache(NULL, vbo->data, vbo->size);
|
||||
GSPGPU_FlushDataCache(vbo->data, vbo->size);
|
||||
}
|
||||
|
||||
void C3D_VBOBind(C3D_VBO* vbo)
|
||||
|
Loading…
Reference in New Issue
Block a user