Xbox: Keep generated vs/ps ASM files

This commit is contained in:
UnknownShadow200 2025-09-16 07:34:35 +10:00
parent c6fada2c1f
commit 9283b69c00
15 changed files with 157 additions and 48 deletions

View File

@ -139,6 +139,10 @@ $(BUILD_DIR)/%.o: src/ps3/%.S
$(BUILD_DIR)/%.o: third_party/bearssl/%.c $(BUILD_DIR)/%.o: third_party/bearssl/%.c
$(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
# prevent the .asm files from being deleted
.PRECIOUS: $(BUILD_DIR)/%.vpo $(BUILD_DIR)/%.fpo
$(BUILD_DIR)/%.vpo: $(SHADERS)/%.vcg $(BUILD_DIR)/%.vpo: $(SHADERS)/%.vcg
$(CGCOMP) -v $(CGCFLAGS) $^ $@ $(CGCOMP) -v $(CGCFLAGS) $^ $@
$(BUILD_DIR)/%.fpo: $(SHADERS)/%.fcg $(BUILD_DIR)/%.fpo: $(SHADERS)/%.fcg

View File

@ -82,7 +82,7 @@ $(BUILD_DIR):
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# Executable generation # Executable generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(OBJS) : $(SHADER_OBJS) $(BUILD_DIR)/Graphics_Xbox.o : $(SHADER_OBJS)
$(TARGET).iso: $(TARGET).xbe $(TARGET).iso: $(TARGET).xbe
mkdir -p $(BUILD_DIR)/cd mkdir -p $(BUILD_DIR)/cd
@ -111,15 +111,21 @@ $(BUILD_DIR)/%.o: src/xbox/%.S
$(BUILD_DIR)/%.o: third_party/bearssl/%.c $(BUILD_DIR)/%.o: third_party/bearssl/%.c
nxdk-cc $(NXDK_CFLAGS) $(CFLAGS) -c $< -o $@ nxdk-cc $(NXDK_CFLAGS) $(CFLAGS) -c $< -o $@
%.inl: %.vs.cg
$(CGC) -profile vp20 -o $@.$$$$ $< && \
$(VP20COMPILER) $@.$$$$ > $@ && \
rm -rf $@.$$$$
%.inl: %.ps.cg # prevent the .asm files from being deleted
$(CGC) -profile fp20 -o $@.$$$$ $< && \ .PRECIOUS: vs_%.asm ps_%.asm
$(FP20COMPILER) $@.$$$$ > $@ && \
rm -rf $@.$$$$ vs_%.inl: vs_%.asm
$(VP20COMPILER) $< > $@
vs_%.asm: vs_%.cg
$(CGC) -profile vp20 $< -o $@
ps_%.inl: ps_%.asm
$(FP20COMPILER) $< > $@
ps_%.asm: ps_%.cg
$(CGC) -profile fp20 $< -o $@
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------

View File

@ -5,3 +5,7 @@ To see debug log messages in Xemu:
---- ----
To launch directly, `-dvd_path cc-xbox.iso` To launch directly, `-dvd_path cc-xbox.iso`
####
The .asm files are auto generated from the .cg files, and shouldn't be manually edited.

14
misc/xbox/ps_coloured.asm Normal file
View File

@ -0,0 +1,14 @@
// nvparse 1.0 output generated by NVIDIA Cg compiler
// cgc version 3.1.0013, build date Apr 24 2012
// command line args: -profile fp20
// source file: misc/xbox/ps_coloured.cg
//vendor NVIDIA Corporation
//version 3.1.0.13
//profile fp20
//program main
//var float4 input.color : $vin.COLOR : COLOR0 : 0 : 1
//var float4 main : $vout.COLOR : COLOR : -1 : 1
!!RC1.0
out.rgb = unsigned(col0.rgb);
out.a = unsigned(col0.a);
// 0 instructions

30
misc/xbox/ps_textured.asm Normal file
View File

@ -0,0 +1,30 @@
// nvparse 1.0 output generated by NVIDIA Cg compiler
// cgc version 3.1.0013, build date Apr 24 2012
// command line args: -profile fp20
// source file: misc/xbox/ps_textured.cg
//vendor NVIDIA Corporation
//version 3.1.0.13
//profile fp20
//program main
//semantic main.tex
//var sampler2D tex : : 0 : 1 : 1
//var float4 input.color : $vin.COLOR : COLOR0 : 0 : 1
//var float2 input.tex0 : $vin.TEXCOORD0 : TEXCOORD0 : 0 : 1
//var float4 main : $vout.COLOR : COLOR : -1 : 1
!!TS1.0
texture_2d();
// End of program
!!RC1.0
{
rgb
{
col0 = tex0.rgb * col0.rgb;
}
alpha
{
col0 = tex0.a * col0.a;
}
}
out.rgb = unsigned(col0.rgb);
out.a = unsigned(col0.a);
// 3 instructions

24
misc/xbox/vs_coloured.asm Normal file
View File

@ -0,0 +1,24 @@
!!VP1.1
# cgc version 3.1.0013, build date Apr 24 2012
# command line args: -profile vp20
# source file: misc/xbox/vs_coloured.cg
#vendor NVIDIA Corporation
#version 3.1.0.13
#profile vp20
#program main
#semantic main.mvp
#var float4 input.col : $vin.DIFFUSE : ATTR3 : 0 : 1
#var float4 input.pos : $vin.POSITION : ATTR0 : 0 : 1
#var float4x4 mvp : : c[0], 4 : 1 : 1
#var float4 main.col : $vout.COLOR : COL0 : -1 : 1
#var float4 main.pos : $vout.POSITION : HPOS : -1 : 1
MUL R0, v[0].y, c[1];
MAD R0, v[0].x, c[0], R0;
MAD R0, v[0].z, c[2], R0;
ADD R0, R0, c[3];
RCP R1.x, R0.w;
MUL o[HPOS].xyz, R0, R1.x;
MOV o[COL0], v[3];
MOV o[HPOS].w, R0;
END
# 8 instructions, 0 R-regs

29
misc/xbox/vs_offset.asm Normal file
View File

@ -0,0 +1,29 @@
!!VP1.1
# cgc version 3.1.0013, build date Apr 24 2012
# command line args: -profile vp20
# source file: misc/xbox/vs_offset.cg
#vendor NVIDIA Corporation
#version 3.1.0.13
#profile vp20
#program main
#semantic main.mvp
#semantic main.tex_offset
#var float4 input.tex : $vin.TEXCOORD : TEXCOORD0 : 0 : 1
#var float4 input.col : $vin.DIFFUSE : ATTR3 : 0 : 1
#var float4 input.pos : $vin.POSITION : ATTR0 : 0 : 1
#var float4x4 mvp : : c[0], 4 : 1 : 1
#var float4 tex_offset : : c[4] : 2 : 1
#var float4 main.pos : $vout.POSITION : HPOS : -1 : 1
#var float4 main.col : $vout.COLOR : COL0 : -1 : 1
#var float4 main.tex : $vout.TEXCOORD0 : TEX0 : -1 : 1
MUL R0, v[0].y, c[1];
MAD R0, v[0].x, c[0], R0;
MAD R0, v[0].z, c[2], R0;
ADD R0, R0, c[3];
RCP R1.x, R0.w;
MUL o[HPOS].xyz, R0, R1.x;
MOV o[HPOS].w, R0;
MOV o[COL0], v[3];
ADD o[TEX0], v[8], c[4];
END
# 9 instructions, 0 R-regs

View File

@ -1,6 +1,6 @@
// cgc version 3.1.0013, build date Apr 24 2012 // cgc version 3.1.0013, build date Apr 24 2012
// command line args: -profile vp20 // command line args: -profile vp20
// source file: misc/xbox/vs_offset.vs.cg // source file: misc/xbox/vs_offset.cg
//vendor NVIDIA Corporation //vendor NVIDIA Corporation
//version 3.1.0.13 //version 3.1.0.13
//profile vp20 //profile vp20

27
misc/xbox/vs_textured.asm Normal file
View File

@ -0,0 +1,27 @@
!!VP1.1
# cgc version 3.1.0013, build date Apr 24 2012
# command line args: -profile vp20
# source file: misc/xbox/vs_textured.cg
#vendor NVIDIA Corporation
#version 3.1.0.13
#profile vp20
#program main
#semantic main.mvp
#var float4 input.tex : $vin.TEXCOORD : TEXCOORD0 : 0 : 1
#var float4 input.col : $vin.DIFFUSE : ATTR3 : 0 : 1
#var float4 input.pos : $vin.POSITION : ATTR0 : 0 : 1
#var float4x4 mvp : : c[0], 4 : 1 : 1
#var float4 main.pos : $vout.POSITION : HPOS : -1 : 1
#var float4 main.col : $vout.COLOR : COL0 : -1 : 1
#var float4 main.tex : $vout.TEXCOORD0 : TEX0 : -1 : 1
MUL R0, v[0].y, c[1];
MAD R0, v[0].x, c[0], R0;
MAD R0, v[0].z, c[2], R0;
ADD R0, R0, c[3];
RCP R1.x, R0.w;
MUL o[HPOS].xyz, R0, R1.x;
MOV o[HPOS].w, R0;
MOV o[COL0], v[3];
MOV o[TEX0], v[8];
END
# 9 instructions, 0 R-regs

47
third_party/citro3d.c vendored
View File

@ -250,10 +250,8 @@ enum
static bool C3D_FrameBegin(u8 flags); static bool C3D_FrameBegin(u8 flags);
static bool C3D_FrameDrawOn(C3D_RenderTarget* target); static bool C3D_FrameDrawOn(C3D_RenderTarget* target);
static void C3D_FrameSplit(u8 flags);
static void C3D_FrameEnd(u8 flags); static void C3D_FrameEnd(u8 flags);
static void C3D_RenderTargetDelete(C3D_RenderTarget* target);
static void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags); static void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags);
static inline void C3D_RenderTargetDetachOutput(C3D_RenderTarget* target) static inline void C3D_RenderTargetDetachOutput(C3D_RenderTarget* target)
@ -832,8 +830,6 @@ static C3D_RenderTarget *linkedTarget[3];
static bool inFrame, inSafeTransfer; static bool inFrame, inSafeTransfer;
static bool swapPending, isTopStereo; static bool swapPending, isTopStereo;
static void C3Di_RenderTargetDestroy(C3D_RenderTarget* target);
static void onQueueFinish(gxCmdQueue_s* queue) static void onQueueFinish(gxCmdQueue_s* queue)
{ {
if (inSafeTransfer) if (inSafeTransfer)
@ -907,20 +903,15 @@ static bool C3D_FrameDrawOn(C3D_RenderTarget* target)
return true; return true;
} }
static void C3D_FrameSplit(u8 flags)
{
u32 *cmdBuf, cmdBufSize;
if (!inFrame) return;
if (C3Di_SplitFrame(&cmdBuf, &cmdBufSize))
GX_ProcessCommandList(cmdBuf, cmdBufSize*4, flags);
}
static void C3D_FrameEnd(u8 flags) static void C3D_FrameEnd(u8 flags)
{ {
C3D_Context* ctx = C3Di_GetContext(); C3D_Context* ctx = C3Di_GetContext();
if (!inFrame) return; if (!inFrame) return;
C3D_FrameSplit(flags); u32 *cmdBuf, cmdBufSize;
if (C3Di_SplitFrame(&cmdBuf, &cmdBufSize))
GX_ProcessCommandList(cmdBuf, cmdBufSize*4, flags);
GPUCMD_SetBuffer(NULL, 0, 0); GPUCMD_SetBuffer(NULL, 0, 0);
inFrame = false; inFrame = false;
@ -984,23 +975,6 @@ static void C3D_RenderTargetDepth(C3D_RenderTarget* target, GPU_DEPTHBUF depthFm
C3D_FrameBufDepth(fb, depthBuf, depthFmt); C3D_FrameBufDepth(fb, depthBuf, depthFmt);
} }
static void C3Di_RenderTargetDestroy(C3D_RenderTarget* target)
{
vramFree(target->frameBuf.colorBuf);
vramFree(target->frameBuf.depthBuf);
}
static void C3D_RenderTargetDelete(C3D_RenderTarget* target)
{
if (inFrame)
svcBreak(USERBREAK_PANIC); // Shouldn't happen.
if (target->linked)
C3D_RenderTargetDetachOutput(target);
else
C3Di_WaitAndClearQueue(-1);
C3Di_RenderTargetDestroy(target);
}
static void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags) static void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags)
{ {
int id = 0; int id = 0;
@ -1079,6 +1053,9 @@ static void C3Di_OnRestore(void)
ctx->flags |= C3DiF_FogLut; ctx->flags |= C3DiF_FogLut;
} }
#define GXQUEUE_MAX_ENTRIES 32
static gxCmdEntry_s queue_entries[GXQUEUE_MAX_ENTRIES];
static bool C3D_Init(size_t cmdBufSize) static bool C3D_Init(size_t cmdBufSize)
{ {
int i; int i;
@ -1093,13 +1070,8 @@ static bool C3D_Init(size_t cmdBufSize)
if (!ctx->cmdBuf) if (!ctx->cmdBuf)
return false; return false;
ctx->gxQueue.maxEntries = 32; ctx->gxQueue.maxEntries = GXQUEUE_MAX_ENTRIES;
ctx->gxQueue.entries = (gxCmdEntry_s*)malloc(ctx->gxQueue.maxEntries*sizeof(gxCmdEntry_s)); ctx->gxQueue.entries = queue_entries;
if (!ctx->gxQueue.entries)
{
linearFree(ctx->cmdBuf);
return false;
}
ctx->flags = C3DiF_Active | C3DiF_TexEnvBuf | C3DiF_Effect | C3DiF_TexStatus | C3DiF_TexAll | C3DiF_Reset; ctx->flags = C3DiF_Active | C3DiF_TexEnvBuf | C3DiF_Effect | C3DiF_TexStatus | C3DiF_TexAll | C3DiF_Reset;
@ -1308,7 +1280,6 @@ static void C3D_Fini(void)
return; return;
C3Di_RenderQueueExit(); C3Di_RenderQueueExit();
free(ctx->gxQueue.entries);
linearFree(ctx->cmdBuf); linearFree(ctx->cmdBuf);
ctx->flags = 0; ctx->flags = 0;
} }