diff --git a/gpu/Makefile b/gpu/Makefile index 8f02861..7b1e1c7 100644 --- a/gpu/Makefile +++ b/gpu/Makefile @@ -1,29 +1,50 @@ CC = arm-none-eabi-gcc -LINK = arm-none-eabi-ld +LINK = arm-none-eabi-gcc +AS = arm-none-eabi-as OBJCOPY = arm-none-eabi-objcopy CTRULIB = "../libctru" +AEMSTROPATH = "../../aemstro" CFLAGS += -Wall -std=c99 -march=armv6 -O3 -I"$(CTRULIB)/include" -I$(DEVKITPRO)/libnds/include -LDFLAGS += --script=ccd00.ld -L"$(DEVKITARM)/arm-none-eabi/lib" -L"$(CTRULIB)/lib" +# LDFLAGS += --script=ccd00.ld -L"$(DEVKITARM)/arm-none-eabi/lib" -L"$(DEVKITARM)/lib/gcc/arm-none-eabi/4.7.1" -L"$(CTRULIB)/lib" +# LDFLAGS += --script=ccd00.ld -L"$(DEVKITARM)/arm-none-eabi/lib" -L"$(CTRULIB)/lib" +LDFLAGS += -nostartfiles --specs=ccd00.specs -L"$(DEVKITARM)/arm-none-eabi/lib" -L"$(CTRULIB)/lib" CFILES = $(wildcard source/*.c) -OFILES = $(CFILES:source/%.c=build/%.o) +VSHFILES = $(wildcard source/*.vsh) +VSHBINFILES = $(VSHFILES:source/%.vsh=data/%.vsh.bin) +BINFILES = $(wildcard data/*.bin) +BINFILES += $(VSHBINFILES) +OFILES = $(BINFILES:data/%.bin=build/%.bin.o) +OFILES += $(CFILES:source/%.c=build/%.o) DFILES = $(CFILES:source/%.c=build/%.d) SFILES = $(wildcard source/*.s) OFILES += $(SFILES:source/%.s=build/%.o) PROJECTNAME = ${shell basename "$(CURDIR)"} +#--------------------------------------------------------------------------------- +# canned command sequence for binary data, taken from devkitARM +#--------------------------------------------------------------------------------- +define bin2o + bin2s $< | $(AS) -o $(@) + echo "extern const u8" `(echo $( source/`(echo $(> source/`(echo $(> source/`(echo $( build/$*.d @@ -39,3 +63,7 @@ build/%.o: source/%.c build/%.o: source/%.s $(CC) $(CFLAGS) -c $< -o $@ @$(CC) -MM $< > build/$*.d + +build/%.bin.o: data/%.bin + @echo $(notdir $<) + @$(bin2o) diff --git a/gpu/source/main.c b/gpu/source/main.c index 06d499b..6edcc23 100644 --- a/gpu/source/main.c +++ b/gpu/source/main.c @@ -8,13 +8,17 @@ #include #include #include +#include #include #include "costable.h" +#include "test_vsh_bin.h" u8* gspHeap; u32* gxCmdBuf; u8 currentBuffer; +u8* topLeftFramebuffers[2]; +u8* topLeftFramebuffersPA[2]; Handle gspEvent, gspSharedMemHandle; @@ -29,6 +33,13 @@ void gspGpuInit() u32 regData=0x01FF0000; GSPGPU_WriteHWRegs(NULL, 0x202A04, ®Data, 4); + //grab main left screen framebuffer addresses + GSPGPU_ReadHWRegs(NULL, 0x400468, (u32*)&topLeftFramebuffersPA, 8); + + //convert PA to VA (assuming FB in VRAM) + topLeftFramebuffers[0]=topLeftFramebuffersPA[0]+0x7000000; + topLeftFramebuffers[1]=topLeftFramebuffersPA[1]+0x7000000; + //setup our gsp shared mem section u8 threadID; svc_createEvent(&gspEvent, 0x0); @@ -88,6 +99,8 @@ int main() u32* gpuCmd=(u32*)gspHeap; u32 gpuCmdSize=0x10000; + DVLB_s* shader=SHDR_ParseSHBIN((u32*)test_vsh_bin,test_vsh_bin_size); + APP_STATUS status; while((status=aptGetStatus())!=APP_EXITING) { diff --git a/gpu/source/test.vsh b/gpu/source/test.vsh new file mode 100644 index 0000000..e674bcd --- /dev/null +++ b/gpu/source/test.vsh @@ -0,0 +1,43 @@ +; setup constants + .const 5, 0.0, 1.0, 2.0, 3.0 + +; setup outmap + .out o0, result.position + .out o1, result.color + .out o2, result.texcoord0 + .out o3, result.texcoord1 + .out o4, result.texcoord2 + +; setup uniform map (not required) + .uniform 0x10, 0x13, mdlvMtx + .uniform 0x14, 0x17, projMtx + +;code + main: + ; result.pos = mdlvMtx * in.pos + dp4 d40, d40, d00 (0x0) + dp4 d40, d41, d00 (0x1) + dp4 d40, d42, d00 (0x2) + mov d40, d25 (0x4) + ; result.pos = projMtx * in.pos + dp4 d00, d44, d40 (0x0) + dp4 d00, d45, d40 (0x1) + dp4 d00, d46, d40 (0x2) + dp4 d00, d47, d40 (0x3) + ; result.color = in.pos + mov d04, d25 (0x5) + ; result.texcoord = const + mov d08, d25 (0x5) + mov d0C, d25 (0x5) + mov d10, d25 (0x5) + flush + end + endmain: + +;operand descriptors + .opdesc x___, xyzw, xyzw ; 0x0 + .opdesc _y__, xyzw, xyzw ; 0x1 + .opdesc __z_, xyzw, xyzw ; 0x2 + .opdesc ___w, xyzw, xyzw ; 0x3 + .opdesc ___w, yyyy, xyzw ; 0x4 + .opdesc xyzw, xyzw, xyzw ; 0x5