3DS: Embed citro3d source directly into the graphics backend

This commit is contained in:
UnknownShadow200 2024-04-07 09:06:34 +10:00
parent ad5804344c
commit efa38fe4f4
3 changed files with 2023 additions and 11 deletions

View File

@ -48,7 +48,7 @@ CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
LIBS := -lcitro3d -lctru -lm
LIBS := -lctru -lm
#---------------------------------------------------------------------------------
@ -133,4 +133,4 @@ $(OUTPUT).elf : $(OFILES)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------
#---------------------------------------------------------------------------------------

View File

@ -5,8 +5,8 @@
#include "Logger.h"
#include "Window.h"
#include <3ds.h>
#include <citro3d.h>
#define BUFFER_BASE_PADDR OS_VRAM_PADDR // VRAM physical address
#include "../third_party/citro3d.c"
// autogenerated from the .v.pica files by Makefile
extern const u8 coloured_shbin[];
@ -204,7 +204,6 @@ static void Calc3DProjection(int dir, struct Matrix* proj) {
float slider = osGet3DSliderState();
float iod = (slider / 3) * dir;
float shift = iod / (2.0f * 2.0f);
Platform_Log2("ADJ: %f3, %f3", &shift, &proj->row1.y);
proj_adj.row3.y = 1.0f * shift * -proj->row1.y;
Gfx.Projection = proj_adj;
@ -596,19 +595,20 @@ static void GPUBuffers_DeleteUnreferenced(void) {
static cc_uint16* gfx_indices;
GfxResourceID Gfx_CreateIb2(int count, Gfx_FillIBFunc fillFunc, void* obj) {
struct GPUBuffer* buffer = GPUBuffer_Alloc(count, sizeof(cc_uint16));
if (!buffer) Logger_Abort("Failed to allocate memory for index buffer");
if (!gfx_indices) {
gfx_indices = linearAlloc(count * sizeof(cc_uint16));
if (!gfx_indices) Logger_Abort("Failed to allocate memory for index buffer");
}
fillFunc((cc_uint16*)buffer->data, count, obj);
return buffer;
fillFunc(gfx_indices, count, obj);
return gfx_indices;
}
void Gfx_BindIb(GfxResourceID ib) {
struct GPUBuffer* buffer = (struct GPUBuffer*)ib;
gfx_indices = (cc_uint16*)buffer->data;
// No need to bind again
}
void Gfx_DeleteIb(GfxResourceID* ib) { GPUBuffer_Unref(ib); }
void Gfx_DeleteIb(GfxResourceID* ib) { }
/*########################################################################################################################*

2012
third_party/citro3d.c vendored Normal file

File diff suppressed because it is too large Load Diff