mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 02:25:32 -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
|
||||
BUILD := build-wiiu
|
||||
SOURCES := src misc/wiiu third_party/bearssl/src
|
||||
SOURCES := src third_party/bearssl/src
|
||||
SHADERS := misc/wiiu
|
||||
DATA := data
|
||||
INCLUDES := third_party/bearssl/inc
|
||||
CONTENT :=
|
||||
@ -78,7 +79,8 @@ export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
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)
|
||||
|
||||
@ -152,13 +154,17 @@ $(OUTPUT).elf : $(OFILES)
|
||||
|
||||
$(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#-------------------------------------------------------------------------------
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#-------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
#-------------------------------------------------------------------------------
|
||||
%.gsh.o %_gsh.h : ../misc/wiiu/%.gsh
|
||||
#-------------------------------------------------------------------------------
|
||||
echo $(notdir $<)
|
||||
$(bin2o)
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
|
Binary file not shown.
@ -23,7 +23,7 @@
|
||||
|
||||
; -------- Disassembly --------------------
|
||||
00 CALL_FS NO_BARRIER
|
||||
01 ALU: ADDR(32) CNT(16)
|
||||
01 ALU: ADDR(32) CNT(18)
|
||||
0 x: MUL ____, C3.w, 1.0f
|
||||
y: MUL ____, C3.z, 1.0f
|
||||
z: MUL ____, C3.y, 1.0f
|
||||
@ -42,8 +42,5 @@
|
||||
w: MULADD R2.w, R2.x, C0.w, PV2.x
|
||||
02 EXP_DONE: POS0, R2
|
||||
03 EXP_DONE: PARAM0, R1 NO_BARRIER
|
||||
04 ALU: ADDR(48) CNT(1)
|
||||
4 x: NOP ____
|
||||
05 NOP NO_BARRIER
|
||||
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 --------------------
|
||||
00 CALL_FS NO_BARRIER
|
||||
01 ALU: ADDR(32) CNT(18)
|
||||
01 ALU: ADDR(32) CNT(20)
|
||||
0 x: MUL ____, C3.y, 1.0f
|
||||
y: MUL ____, C3.x, 1.0f
|
||||
z: MUL ____, C3.w, 1.0f
|
||||
@ -38,7 +38,7 @@
|
||||
1 x: MULADD R127.x, R2.z, C2.y, PV0.x
|
||||
y: MULADD R127.y, R2.z, C2.x, PV0.y
|
||||
z: MULADD R127.z, R2.z, C2.w, PV0.z
|
||||
w: MULADD R127.w, R2.z, C2.z, PV0.w
|
||||
w: MULADD R127.w, R2.z, C2.z, PV0.w
|
||||
t: MOV R0.y, R3.y
|
||||
2 x: MULADD R127.x, R2.y, C1.y, PV1.x
|
||||
y: MULADD R127.y, R2.y, C1.x, PV1.y
|
||||
@ -51,8 +51,5 @@
|
||||
02 EXP_DONE: POS0, R2
|
||||
03 EXP: PARAM0, R1 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
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <gx2/clear.h>
|
||||
#include <gx2/context.h>
|
||||
#include <gx2/display.h>
|
||||
#include <gx2/draw.h>
|
||||
#include <gx2/event.h>
|
||||
#include <gx2/mem.h>
|
||||
#include <gx2/registers.h>
|
||||
@ -14,15 +15,37 @@
|
||||
#include <gx2/surface.h>
|
||||
#include <gx2/swap.h>
|
||||
#include <gx2/temp.h>
|
||||
#include <gx2r/draw.h>
|
||||
#include <gx2r/mem.h>
|
||||
#include <gx2r/buffer.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) {
|
||||
if (!Gfx.Created) InitGfx();
|
||||
|
||||
Gfx.Created = true;
|
||||
Gfx.MaxTexWidth = 512;
|
||||
Gfx.MaxTexHeight = 512;
|
||||
WHBGfxInit();
|
||||
Gfx.MaxTexWidth = 1024;
|
||||
Gfx.MaxTexHeight = 1024;
|
||||
}
|
||||
|
||||
cc_bool Gfx_TryRestoreContext(void) {
|
||||
@ -63,8 +86,6 @@ void Gfx_BindTexture(GfxResourceID texId) {
|
||||
void Gfx_DeleteTexture(GfxResourceID* texId) {
|
||||
}
|
||||
|
||||
void Gfx_SetTexturing(cc_bool enabled) { }
|
||||
|
||||
void Gfx_EnableMipmaps(void) { } // TODO
|
||||
|
||||
void Gfx_DisableMipmaps(void) { } // TODO
|
||||
@ -172,6 +193,9 @@ void Gfx_DeleteVb(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) {
|
||||
@ -206,27 +230,61 @@ void Gfx_UnlockDynamicVb(GfxResourceID vb) { Gfx_UnlockVb(vb); Gfx_BindVb(vb);
|
||||
/*########################################################################################################################*
|
||||
*-----------------------------------------------------Vertex rendering----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static WHBGfxShaderGroup* group;
|
||||
|
||||
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_IndexedTris(int verticesCount) {
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, verticesCount, 0, 1);
|
||||
}
|
||||
|
||||
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) {
|
||||
GX2DrawEx(GX2_PRIMITIVE_MODE_QUADS, verticesCount, startVertex, 1);
|
||||
}
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Matrices--------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
static struct Matrix _view, _proj;
|
||||
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) {
|
||||
@ -316,4 +374,4 @@ void Gfx_GetApiInfo(cc_string* info) {
|
||||
void Gfx_OnWindowResize(void) {
|
||||
|
||||
}
|
||||
#endif
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user