mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
WiiU: WIP graphics stuff, doesn't actually work though
This commit is contained in:
parent
4c21c1c072
commit
d43693f3dd
@ -32,7 +32,8 @@ include $(DEVKITPRO)/wut/share/wut_rules
|
|||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
TARGET := ClassiCube-wiiu
|
TARGET := ClassiCube-wiiu
|
||||||
BUILD := build-wiiu
|
BUILD := build-wiiu
|
||||||
SOURCES := src misc/wiiu third_party/bearssl/src
|
SOURCES := src third_party/bearssl/src
|
||||||
|
SHADERS := misc/wiiu
|
||||||
DATA := data
|
DATA := data
|
||||||
INCLUDES := third_party/bearssl/inc
|
INCLUDES := third_party/bearssl/inc
|
||||||
CONTENT :=
|
CONTENT :=
|
||||||
@ -78,7 +79,8 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
|||||||
|
|
||||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*))) \
|
||||||
|
$(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.gsh)))
|
||||||
|
|
||||||
export LD := $(CC)
|
export LD := $(CC)
|
||||||
|
|
||||||
@ -152,13 +154,17 @@ $(OUTPUT).elf : $(OFILES)
|
|||||||
|
|
||||||
$(OFILES_SRC) : $(HFILES_BIN)
|
$(OFILES_SRC) : $(HFILES_BIN)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
|
||||||
# you need a rule like this for each extension you use as binary data
|
# you need a rule like this for each extension you use as binary data
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
%.bin.o %_bin.h : %.bin
|
%.bin.o %_bin.h : %.bin
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
@echo $(notdir $<)
|
@echo $(notdir $<)
|
||||||
@$(bin2o)
|
@$(bin2o)
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
%.gsh.o %_gsh.h : ../misc/wiiu/%.gsh
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
echo $(notdir $<)
|
||||||
|
$(bin2o)
|
||||||
|
|
||||||
-include $(DEPENDS)
|
-include $(DEPENDS)
|
||||||
|
|
||||||
|
Binary file not shown.
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
; -------- Disassembly --------------------
|
; -------- Disassembly --------------------
|
||||||
00 CALL_FS NO_BARRIER
|
00 CALL_FS NO_BARRIER
|
||||||
01 ALU: ADDR(32) CNT(16)
|
01 ALU: ADDR(32) CNT(18)
|
||||||
0 x: MUL ____, C3.w, 1.0f
|
0 x: MUL ____, C3.w, 1.0f
|
||||||
y: MUL ____, C3.z, 1.0f
|
y: MUL ____, C3.z, 1.0f
|
||||||
z: MUL ____, C3.y, 1.0f
|
z: MUL ____, C3.y, 1.0f
|
||||||
@ -42,8 +42,5 @@
|
|||||||
w: MULADD R2.w, R2.x, C0.w, PV2.x
|
w: MULADD R2.w, R2.x, C0.w, PV2.x
|
||||||
02 EXP_DONE: POS0, R2
|
02 EXP_DONE: POS0, R2
|
||||||
03 EXP_DONE: PARAM0, R1 NO_BARRIER
|
03 EXP_DONE: PARAM0, R1 NO_BARRIER
|
||||||
04 ALU: ADDR(48) CNT(1)
|
|
||||||
4 x: NOP ____
|
|
||||||
05 NOP NO_BARRIER
|
|
||||||
END_OF_PROGRAM
|
END_OF_PROGRAM
|
||||||
|
|
||||||
|
BIN
misc/wiiu/textured.gsh
Normal file
BIN
misc/wiiu/textured.gsh
Normal file
Binary file not shown.
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
; -------- Disassembly --------------------
|
; -------- Disassembly --------------------
|
||||||
00 CALL_FS NO_BARRIER
|
00 CALL_FS NO_BARRIER
|
||||||
01 ALU: ADDR(32) CNT(18)
|
01 ALU: ADDR(32) CNT(20)
|
||||||
0 x: MUL ____, C3.y, 1.0f
|
0 x: MUL ____, C3.y, 1.0f
|
||||||
y: MUL ____, C3.x, 1.0f
|
y: MUL ____, C3.x, 1.0f
|
||||||
z: MUL ____, C3.w, 1.0f
|
z: MUL ____, C3.w, 1.0f
|
||||||
@ -51,8 +51,5 @@
|
|||||||
02 EXP_DONE: POS0, R2
|
02 EXP_DONE: POS0, R2
|
||||||
03 EXP: PARAM0, R1 NO_BARRIER
|
03 EXP: PARAM0, R1 NO_BARRIER
|
||||||
04 EXP_DONE: PARAM1, R0.xyzz NO_BARRIER
|
04 EXP_DONE: PARAM1, R0.xyzz NO_BARRIER
|
||||||
05 ALU: ADDR(50) CNT(1)
|
|
||||||
4 x: NOP ____
|
|
||||||
06 NOP NO_BARRIER
|
|
||||||
END_OF_PROGRAM
|
END_OF_PROGRAM
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include <gx2/clear.h>
|
#include <gx2/clear.h>
|
||||||
#include <gx2/context.h>
|
#include <gx2/context.h>
|
||||||
#include <gx2/display.h>
|
#include <gx2/display.h>
|
||||||
|
#include <gx2/draw.h>
|
||||||
#include <gx2/event.h>
|
#include <gx2/event.h>
|
||||||
#include <gx2/mem.h>
|
#include <gx2/mem.h>
|
||||||
#include <gx2/registers.h>
|
#include <gx2/registers.h>
|
||||||
@ -14,15 +15,37 @@
|
|||||||
#include <gx2/surface.h>
|
#include <gx2/surface.h>
|
||||||
#include <gx2/swap.h>
|
#include <gx2/swap.h>
|
||||||
#include <gx2/temp.h>
|
#include <gx2/temp.h>
|
||||||
|
#include <gx2r/draw.h>
|
||||||
#include <gx2r/mem.h>
|
#include <gx2r/mem.h>
|
||||||
#include <gx2r/buffer.h>
|
#include <gx2r/buffer.h>
|
||||||
#include <whb/gfx.h>
|
#include <whb/gfx.h>
|
||||||
|
#include "../build-wiiu/coloured_gsh.h"
|
||||||
|
#include "../build-wiiu/textured_gsh.h"
|
||||||
|
|
||||||
|
static WHBGfxShaderGroup colorShader;
|
||||||
|
static WHBGfxShaderGroup textureShader;
|
||||||
|
|
||||||
|
static void InitGfx(void) {
|
||||||
|
WHBGfxInit();
|
||||||
|
|
||||||
|
WHBGfxLoadGFDShaderGroup(&colorShader, 0, coloured_gsh);
|
||||||
|
WHBGfxInitShaderAttribute(&colorShader, "in_pos", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
|
||||||
|
WHBGfxInitShaderAttribute(&colorShader, "in_col", 0, 12, GX2_ATTRIB_FORMAT_UNORM_8_8_8_8);
|
||||||
|
WHBGfxInitFetchShader(&colorShader);
|
||||||
|
|
||||||
|
WHBGfxLoadGFDShaderGroup(&textureShader, 0, textured_gsh);
|
||||||
|
WHBGfxInitShaderAttribute(&textureShader, "in_pos", 0, 0, GX2_ATTRIB_FORMAT_FLOAT_32_32_32);
|
||||||
|
WHBGfxInitShaderAttribute(&textureShader, "in_col", 0, 12, GX2_ATTRIB_FORMAT_UNORM_8_8_8_8);
|
||||||
|
WHBGfxInitShaderAttribute(&textureShader, "in_pos", 0, 16, GX2_ATTRIB_FORMAT_FLOAT_32_32);
|
||||||
|
WHBGfxInitFetchShader(&textureShader);
|
||||||
|
}
|
||||||
|
|
||||||
void Gfx_Create(void) {
|
void Gfx_Create(void) {
|
||||||
|
if (!Gfx.Created) InitGfx();
|
||||||
|
|
||||||
Gfx.Created = true;
|
Gfx.Created = true;
|
||||||
Gfx.MaxTexWidth = 512;
|
Gfx.MaxTexWidth = 1024;
|
||||||
Gfx.MaxTexHeight = 512;
|
Gfx.MaxTexHeight = 1024;
|
||||||
WHBGfxInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cc_bool Gfx_TryRestoreContext(void) {
|
cc_bool Gfx_TryRestoreContext(void) {
|
||||||
@ -63,8 +86,6 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
|||||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_SetTexturing(cc_bool enabled) { }
|
|
||||||
|
|
||||||
void Gfx_EnableMipmaps(void) { } // TODO
|
void Gfx_EnableMipmaps(void) { } // TODO
|
||||||
|
|
||||||
void Gfx_DisableMipmaps(void) { } // TODO
|
void Gfx_DisableMipmaps(void) { } // TODO
|
||||||
@ -172,6 +193,9 @@ void Gfx_DeleteVb(GfxResourceID* vb) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_BindVb(GfxResourceID vb) {
|
void Gfx_BindVb(GfxResourceID vb) {
|
||||||
|
GX2RBuffer* buf = (GX2RBuffer*)vb;
|
||||||
|
GX2RSetAttributeBuffer(buf, 0, buf->elemSize, 0);
|
||||||
|
//GX2SetAttribBuffer(0,
|
||||||
}
|
}
|
||||||
|
|
||||||
void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
void* Gfx_LockVb(GfxResourceID vb, VertexFormat fmt, int count) {
|
||||||
@ -206,27 +230,61 @@ void Gfx_UnlockDynamicVb(GfxResourceID vb) { Gfx_UnlockVb(vb); Gfx_BindVb(vb);
|
|||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*-----------------------------------------------------Vertex rendering----------------------------------------------------*
|
*-----------------------------------------------------Vertex rendering----------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
static WHBGfxShaderGroup* group;
|
||||||
|
|
||||||
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
void Gfx_SetVertexFormat(VertexFormat fmt) {
|
||||||
|
if (fmt == gfx_format) return;
|
||||||
|
gfx_format = fmt;
|
||||||
|
gfx_stride = strideSizes[fmt];
|
||||||
|
|
||||||
|
group = fmt == VERTEX_FORMAT_TEXTURED ? &textureShader : &colorShader;
|
||||||
|
GX2SetFetchShader(&group->fetchShader);
|
||||||
|
GX2SetVertexShader(group->vertexShader);
|
||||||
|
GX2SetPixelShader(group->pixelShader);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawVb_Lines(int verticesCount) {
|
void Gfx_DrawVb_Lines(int verticesCount) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
void Gfx_DrawVb_IndexedTris(int verticesCount) {
|
||||||
|
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, verticesCount, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
void Gfx_DrawVb_IndexedTris_Range(int verticesCount, int startVertex) {
|
||||||
|
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, verticesCount, startVertex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
|
||||||
|
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, verticesCount, startVertex, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*########################################################################################################################*
|
/*########################################################################################################################*
|
||||||
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
||||||
*#########################################################################################################################*/
|
*#########################################################################################################################*/
|
||||||
|
static struct Matrix _view, _proj;
|
||||||
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
void Gfx_LoadMatrix(MatrixType type, const struct Matrix* matrix) {
|
||||||
// TODO
|
if (type == MATRIX_VIEW) _view = *matrix;
|
||||||
|
if (type == MATRIX_PROJECTION) _proj = *matrix;
|
||||||
|
struct Matrix mvp __attribute__((aligned(64)));
|
||||||
|
Matrix_Mul(&mvp, &_view, &_proj);
|
||||||
|
if (!group) return;
|
||||||
|
|
||||||
|
|
||||||
|
static float transposed_mvp[4*4] __attribute__((aligned(64)));
|
||||||
|
float* m = &mvp;
|
||||||
|
|
||||||
|
// Transpose matrix
|
||||||
|
for (int i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
transposed_mvp[i * 4 + 0] = m[0 + i];
|
||||||
|
transposed_mvp[i * 4 + 1] = m[4 + i];
|
||||||
|
transposed_mvp[i * 4 + 2] = m[8 + i];
|
||||||
|
transposed_mvp[i * 4 + 3] = m[12 + i];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Platform_LogConst("MVP");
|
||||||
|
GX2SetVertexUniformReg(group->vertexShader->uniformVars[0].offset, 16, &mvp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
void Gfx_LoadIdentityMatrix(MatrixType type) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user