Merge remote-tracking branch 'upstream/master'

This commit is contained in:
EGAMatsu 2025-07-11 15:01:15 -05:00
commit fe3d18e7bc
34 changed files with 376 additions and 364 deletions

View File

@ -19,14 +19,18 @@ jobs:
image: ghcr.io/kos-builds/kos-dc:sha-20149ee-14.2.0
steps:
- uses: actions/checkout@v4
- name: Compile Dreamcast build
id: compile
- name: Install prerequisites
shell: bash
run: |
apt-get update
apt-get -y install genisoimage
wget https://github.com/ClassiCube/rpi-compiling-stuff/raw/main/cdi4dc -O /opt/toolchains/dc/kos/utils/cdi4dc
chmod +x /opt/toolchains/dc/kos/utils/cdi4dc
- name: Compile Dreamcast build
id: compile
shell: bash
run: |
export PATH=/opt/toolchains/dc/kos/utils/:$PATH
make dreamcast

View File

@ -19,11 +19,14 @@ jobs:
image: ghcr.io/volkertb/debian-djgpp
steps:
- uses: actions/checkout@v4
- name: Compile MS dos build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get -y install curl
- name: Compile MS dos build
id: compile
run: |
make CC=gcc dos RELEASE=1

View File

@ -19,11 +19,14 @@ jobs:
image: ghcr.io/dragonminded/libdragon:preview
steps:
- uses: actions/checkout@v4
- name: Compile N64 build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get -y install curl
- name: Compile N64 build
id: compile
run: |
REAL_DIR=`pwd`
cd /tmp
git clone -b opengl https://github.com/DragonMinded/libdragon.git --depth=1

View File

@ -19,11 +19,14 @@ jobs:
image: skylyrac/blocksds:dev-latest
steps:
- uses: actions/checkout@v4
- name: Compile NDS build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get -y install curl
- name: Compile NDS build
id: compile
run: |
make ds
export BUILD_DSI=1
make ds

View File

@ -19,11 +19,14 @@ jobs:
image: ghcr.io/classicube/minimal-psn00b:latest
steps:
- uses: actions/checkout@v4
- name: Compile PS1 build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get install -y curl
- name: Compile PS1 build
id: compile
run: |
export PSN00BSDK_ROOT=/usr/local/psnoob
make ps1

View File

@ -19,10 +19,13 @@ jobs:
image: ghcr.io/ps2dev/ps2sdk:latest
steps:
- uses: actions/checkout@v4
- name: Install prerequisites
run: |
apk add make mpc1 curl
- name: Compile PS2 build
id: compile
run: |
apk add make mpc1 curl
make ps2

View File

@ -19,11 +19,14 @@ jobs:
image: ghcr.io/classicube/minimal-psl1ght:latest
steps:
- uses: actions/checkout@v4
- name: Compile PS3 build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get install -y curl
- name: Compile PS3 build
id: compile
run: |
export PS3DEV=/usr/local/ps3dev
export PSL1GHT=/usr/local/ps3dev
export PATH=$PATH:$PS3DEV/bin

View File

@ -19,11 +19,13 @@ jobs:
image: pspdev/pspdev:latest
steps:
- uses: actions/checkout@v4
- name: Install prerequisites
run: |
apk add curl curl-dev
- name: Compile PSP build
id: compile
run: |
apk add curl curl-dev
export PSPSDK=$(psp-config --pspsdk-path)
make psp

View File

@ -19,11 +19,14 @@ jobs:
image: ijacquez/yaul:1.0.10
steps:
- uses: actions/checkout@v4
- name: Compile Saturn build
id: compile
- name: Install prerequisites
run: |
apt-get update
apt-get -y install curl
- name: Compile Saturn build
id: compile
run: |
make saturn
- uses: ./.github/actions/notify_failure

View File

@ -23,6 +23,7 @@ jobs:
run: Invoke-WebRequest https://nnp.nnchan.ru/dl/symbiansr1_gcce_workflow.zip -OutFile symbiansdk.zip
- name: Extract Symbian SDK
run: Expand-Archive symbiansdk.zip -DestinationPath .
- name: Compile Symbian build
id: compile
run: |

View File

@ -23,7 +23,6 @@ jobs:
id: compile
run: |
make wii
make clean
make gamecube
- name: Create Wii homebrew

View File

@ -19,10 +19,13 @@ jobs:
image: ghcr.io/xboxdev/nxdk:git-e955705a
steps:
- uses: actions/checkout@v4
- name: Install prerequisites
run: |
apk add curl curl-dev
- name: Compile Xbox build
id: compile
run: |
apk add curl curl-dev
eval $(/usr/src/nxdk/bin/activate -s)
make xbox

View File

@ -19,12 +19,15 @@ jobs:
image: free60/libxenon
steps:
- uses: actions/checkout@v4
- name: Compile 360 build
id: compile
- name: Install prerequisites
run: |
sed -i -e 's/archive.ubuntu.com\|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list
apt-get update
apt-get install -y curl
- name: Compile 360 build
id: compile
run: |
export DEVKITXENON=/usr/local/xenon
export PATH=$PATH:$DEVKITXENON/bin:$DEVKITXENON/usr/bin
make xbox360

View File

@ -26,7 +26,8 @@ INCLUDES =
S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
CFLAGS := -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno
CFLAGS = -g -DNDEBUG -O3 -fipa-pta -fno-pie -flto=auto -fomit-frame-pointer -fbuiltin -ffast-math -ffp-contract=fast -mfsrra -mfsca -pipe -fno-math-errno
LDFLAGS = -g
# Dependency tracking

View File

@ -95,7 +95,7 @@ static int gpu_stride;
#define GPU_ATTR_TEX (1 << 9)
#define GPU_ATTR_SHADE (1 << 10)
#define GPU_ATTR_EDGE (1 << 11)
static bool gpu_attr_z, gpu_attr_tex;
static uint8_t gpu_attr_z, gpu_attr_tex;
static void gpuUpdateFormat(void)
{

View File

@ -1,11 +1,9 @@
ifeq ($(strip $(PSPSDK)),)
$(warning "Please set PSPSDK variables in your environment. For example:")
$(warning export PSPSDK=/usr/local/pspsk/psp/sdk)
$(warning export PATH=/usr/local/pspsk/bin:$$PATH)
$(warning Or)
$(warning export PSPSDK=$$(shell psp-config --pspsdk-path))
ifeq ($(strip $(PSPDEV)),)
$(warning "Please set PSPDEV variables in your environment. For example:")
$(warning export PSPDEV=/usr/local/pspsdk)
$(error Failed to find PSPSDK installation)
endif
PSPSDK=$(PSPDEV)/psp/sdk
#---------------------------------------------------------------------------------
@ -36,13 +34,10 @@ S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
INCDIR := $(PSPDEV)/psp/include $(PSPSDK)/include
LIBDIR := $(PSPDEV)/psp/lib $(PSPSDK)/lib
CFLAGS := -I$(PSPSDK)/include -g -O1 -fno-math-errno -D_PSP_FW_VERSION=600
ASFLAGS := -I$(PSPSDK)/include -g
CFLAGS := $(addprefix -I,$(INCDIR)) -g -O1 -fno-math-errno -D_PSP_FW_VERSION=600
ASFLAGS := $(addprefix -I,$(INCDIR)) -g
LDFLAGS := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -Wl,-zmax-page-size=128
LDFLAGS := -L$(PSPSDK)/lib -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx -Wl,-zmax-page-size=128
LIBS := -lm -lpspgum -lpspgu -lpspge -lpspdisplay -lpspctrl -lpspdebug -lpspnet -lpspnet_apctl
# Dependency tracking
@ -53,12 +48,13 @@ DEPFILES := $(OBJS:%.o=%.d)
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
CC = psp-gcc
AS = psp-gcc
LD = psp-gcc
MKSFO = mksfoex
PACK_PBP = pack-pbp
FIXUP = psp-fixup-imports
CC = $(PSPDEV)/bin/psp-gcc
AS = $(PSPDEV)/bin/psp-gcc
LD = $(PSPDEV)/bin/psp-gcc
MKSFO = $(PSPDEV)/bin/mksfoex
PACK_PBP = $(PSPDEV)/bin/pack-pbp
FIXUP = $(PSPDEV)/bin/psp-fixup-imports
PRXGEN = $(PSPDEV)/bin/psp-prxgen
#---------------------------------------------------------------------------------
@ -81,7 +77,7 @@ $(TARGET).elf: $(OBJS)
$(FIXUP) $@
$(TARGET).prx: $(TARGET).elf
psp-prxgen $< $@
$(PRXGEN) $< $@
$(PSP_EBOOT_SFO):
$(MKSFO) -d MEMSIZE=1 '$(PSP_EBOOT_TITLE)' $@
@ -99,7 +95,7 @@ $(BUILD_DIR)/%.o : src/%.c
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o : src/psp/%.c
$(VITA_CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
$(BUILD_DIR)/%.o : third_party/bearssl/%.c
$(CC) $(CFLAGS) -c $< -o $@

View File

@ -2,28 +2,131 @@ ifeq ($(strip $(YAUL_INSTALL_ROOT)),)
$(error Undefined YAUL_INSTALL_ROOT (install root directory))
endif
SH_BUILD_DIR := build-saturn
include $(YAUL_INSTALL_ROOT)/share/build.pre.mk
#---------------------------------------------------------------------------------
# Configurable options
#---------------------------------------------------------------------------------
# Directory where object files are placed
BUILD_DIR = build/saturn
# List of directories containing source code
SOURCE_DIRS = src src/saturn
# Name of the final output
TARGET = ClassiCube-saturn
# Each asset follows the format: <path>;<symbol>. Duplicates are removed
BUILTIN_ASSETS=
IP_VERSION = V1.370
IP_RELEASE_DATE = 20250101
IP_AREAS = JTUBKAEL
IP_PERIPHERALS = JAMKST
IP_TITLE = ClassiCube
#IP_MASTER_STACK_ADDR = 0x06004000
IP_MASTER_STACK_ADDR = 0x06100000
IP_SLAVE_STACK_ADDR = 0x06001E00
IP_1ST_READ_ADDR = 0x06004000
IP_1ST_READ_SIZE = 0
SH_PROGRAM := ClassiCube-saturn
SH_SRCS := $(wildcard src/*.c)
CD_PATH = $(BUILD_DIR)/cd
AUDIO_TRACKS_DIRECTORY = audio-tracks
IMAGE_1ST_READ_BIN = A.BIN
SH_CFLAGS+= -Os -I. -DPLAT_SATURN -Wno-sign-compare -Wno-unused-parameter -Wno-missing-field-initializers
SH_LDFLAGS+=
IP_VERSION:= V1.000
IP_RELEASE_DATE:= 20230101
IP_AREAS:= JTUBKAEL
IP_PERIPHERALS:= JAMKST
IP_TITLE:= ClassiCube
#IP_MASTER_STACK_ADDR:= 0x06004000
IP_MASTER_STACK_ADDR:= 0x06100000
IP_SLAVE_STACK_ADDR:= 0x06001E00
IP_1ST_READ_ADDR:= 0x06004000
IP_1ST_READ_SIZE:= 0
#---------------------------------------------------------------------------------
# Code generation
#---------------------------------------------------------------------------------
S_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.S))
C_FILES := $(foreach dir,$(SOURCE_DIRS),$(wildcard $(dir)/*.c))
SH_OBJS := $(addprefix $(BUILD_DIR)/, $(notdir $(C_FILES:%.c=%.o) $(S_FILES:%.S=%.o)))
include $(YAUL_INSTALL_ROOT)/share/build.post.iso-cue.mk
SH_CFLAGS = -Os -DPLAT_SATURN -Wstrict-aliasing \
-I$(YAUL_INSTALL_ROOT)/$(YAUL_ARCH_SH_PREFIX)/include/yaul
SH_LDFLAGS = -static -Wl,--gc-sections \
-Wl,--defsym=___master_stack=$(IP_MASTER_STACK_ADDR) \
-Wl,--defsym=___slave_stack=$(IP_SLAVE_STACK_ADDR)
SH_SPECS = yaul.specs yaul-main.specs
# Dependency tracking
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d
DEPFILES := $(SH_OBJS:%.o=%.d)
#---------------------------------------------------------------------------------
# Compiler tools
#---------------------------------------------------------------------------------
SH_AS:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-as
SH_CC:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-gcc
SH_LD:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-gcc
SH_OBJCOPY:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_SH_PREFIX)-objcopy
M68K_AS:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-as
M68K_CC:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-gcc
M68K_LD:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-gcc
M68K_OBJCOPY:= $(YAUL_INSTALL_ROOT)/bin/$(YAUL_ARCH_M68K_PREFIX)-objcopy
#---------------------------------------------------------------------------------
# Main targets
#---------------------------------------------------------------------------------
default: $(BUILD_DIR) $(TARGET).cue
$(BUILD_DIR):
mkdir -p $(BUILD_DIR)
clean:
rm -f $(SH_OBJS) $(TARGET).bin $(TARGET).cue $(TARGET).iso \
$(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).bin $(BUILD_DIR)/IP.BIN
#---------------------------------------------------------------------------------
# executable generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/$(TARGET).elf: $(SH_OBJS)
$(SH_LD) $(foreach specs,$(SH_SPECS),-specs=$(specs)) $(SH_OBJS) $(SH_LDFLAGS) -o $@
$(BUILD_DIR)/$(TARGET).bin: $(BUILD_DIR)/$(TARGET).elf
$(SH_OBJCOPY) -O binary $< $@
@[ -z "${SILENT}" ] && du -hs $@ | awk '{ print $$1; }' || true
$(TARGET).bin: $(BUILD_DIR)/$(TARGET).bin
cp $< $@
$(BUILD_DIR)/IP.BIN: $(TARGET).bin
$(YAUL_INSTALL_ROOT)/bin/make-ip \
"$(BUILD_DIR)/$(TARGET).bin" \
$(IP_VERSION) $(IP_RELEASE_DATE) $(IP_AREAS) $(IP_PERIPHERALS) \
'"$(IP_TITLE)"' \
$(IP_MASTER_STACK_ADDR) $(IP_SLAVE_STACK_ADDR) \
$(IP_1ST_READ_ADDR) $(IP_1ST_READ_SIZE)
$(TARGET).iso: $(TARGET).bin $(BUILD_DIR)/IP.BIN
mkdir -p $(CD_PATH)
cp $(TARGET).bin $(CD_PATH)/$(IMAGE_1ST_READ_BIN)
printf "empty\n" > $(CD_PATH)/"ABS.TXT"
printf "empty\n" > $(CD_PATH)/"BIB.TXT"
printf "empty\n" > $(CD_PATH)/"CPY.TXT"
$(YAUL_INSTALL_ROOT)/bin/make-iso $(CD_PATH) $(BUILD_DIR)/IP.BIN . $(TARGET)
$(TARGET).cue: $(TARGET).iso
mkdir -p $(AUDIO_TRACKS_DIRECTORY)
$(YAUL_INSTALL_ROOT)/bin/make-cue $(AUDIO_TRACKS_DIRECTORY) $(TARGET).iso
#---------------------------------------------------------------------------------
# object generation
#---------------------------------------------------------------------------------
$(BUILD_DIR)/%.o : src/%.c
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) $(foreach specs,$(SH_SPECS),-specs=$(specs)) -c $< -o $@
$(BUILD_DIR)/%.o : src/saturn/%.c
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) $(foreach specs,$(SH_SPECS),-specs=$(specs)) -c $< -o $@
$(BUILD_DIR)/%.o : src/saturn/%.S
$(SH_CC) $(SH_CFLAGS) $(DEPFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# Dependency tracking
#---------------------------------------------------------------------------------
$(DEPFILES):
include $(wildcard $(DEPFILES))

View File

@ -159,6 +159,13 @@ static void InitCitro3D(void) {
C3D_RenderTargetColor(&bottomTarget, GPU_RB_RGBA8);
C3D_RenderTargetSetOutput(&bottomTarget, GFX_BOTTOM, GFX_LEFT, DISPLAY_TRANSFER_FLAGS);
// Allocate right framebuffer (for stereoscopic 3D) in advance even when it doesn't actually used
// Although this means a bit less VRAM available for textures, this ensures that if the user later
// turns on stereoscopic 3D, don't have to try handling the case when insufficient VRAM for it
C3D_RenderTargetInit(&topTargetRight, 240, 400);
C3D_RenderTargetColor(&topTargetRight, GPU_RB_RGBA8);
C3D_RenderTargetDepth(&topTargetRight, GPU_RB_DEPTH24);
gfxSetDoubleBuffering(GFX_TOP, true);
SetDefaultState();
AllocShaders();
@ -178,6 +185,7 @@ void Gfx_Create(void) {
Gfx.Created = true;
gfx_vsync = true;
Gfx.NonPowTwoTexturesSupport = GFX_NONPOW2_UPLOAD;
Gfx_RestoreState();
}
@ -239,9 +247,6 @@ void Gfx_Set3DRight(struct Matrix* proj, struct Matrix* view) {
Calc3DProjection(+1, proj);
if (!createdTopTargetRight) {
C3D_RenderTargetInit(&topTargetRight, 240, 400);
C3D_RenderTargetColor(&topTargetRight, GPU_RB_RGBA8);
C3D_RenderTargetDepth(&topTargetRight, GPU_RB_DEPTH24);
C3D_RenderTargetSetOutput(&topTargetRight, GFX_TOP, GFX_RIGHT, DISPLAY_TRANSFER_FLAGS);
createdTopTargetRight = true;
}
@ -292,7 +297,13 @@ static void GPUTexture_Unref(GfxResourceID* resource) {
}
static void GPUTexture_Free(struct GPUTexture* tex) {
C3D_TexDelete(&tex->texture);
void* addr = tex->texture.data;
if (addrIsVRAM(addr)) {
vramFree(addr);
} else {
linearFree(addr);
}
Mem_Free(tex);
}
@ -330,10 +341,13 @@ static void GPUTextures_DeleteUnreferenced(void) {
/*########################################################################################################################*
*---------------------------------------------------------Textures--------------------------------------------------------*
*#########################################################################################################################*/
static bool CreateNativeTexture(C3D_Tex* tex, u32 width, u32 height) {
static bool CreateNativeTexture(C3D_Tex* tex, u32 width, u32 height, int vram) {
width = Math_NextPowOf2(width);
height = Math_NextPowOf2(height);
u32 size = width * height * 4;
//tex->data = p.onVram ? vramAlloc(total_size) : linearAlloc(total_size);
tex->data = linearAlloc(size);
tex->data = vram ? vramAlloc(size) : NULL;
if (!tex->data) tex->data = linearAlloc(size);
if (!tex->data) return false;
tex->width = width;
@ -351,67 +365,58 @@ static bool CreateNativeTexture(C3D_Tex* tex, u32 width, u32 height) {
return true;
}
static void TryTransferToVRAM(C3D_Tex* tex) {
return;
// NOTE: the linearFree below results in broken texture. maybe no DMA?
void* vram = vramAlloc(tex->size);
if (!vram) return;
C3D_SyncTextureCopy((u32*)tex->data, 0, (u32*)vram, 0, tex->size, 8);
linearFree(tex->data);
tex->data = vram;
}
/*static inline cc_uint32 CalcZOrder(cc_uint32 x, cc_uint32 y) {
// Simplified "Interleave bits by Binary Magic Numbers" from
// http://graphics.stanford.edu/~seander/bithacks.html#InterleaveTableObvious
// TODO: Simplify to array lookup?
x = (x | (x << 2)) & 0x33;
x = (x | (x << 1)) & 0x55;
y = (y | (y << 2)) & 0x33;
y = (y | (y << 1)) & 0x55;
return x | (y << 1);
}*/
static inline cc_uint32 CalcZOrder(cc_uint32 a) {
// Simplified "Interleave bits by Binary Magic Numbers" from
// http://graphics.stanford.edu/~seander/bithacks.html#InterleaveBMN
// TODO: Simplify to array lookup?
a = (a | (a << 2)) & 0x33;
a = (a | (a << 1)) & 0x55;
return a;
// equivalent to return (a & 1) | ((a & 2) << 1) | (a & 4) << 2;
// but compiles to less instructions
}
// Pixels are arranged in a recursive Z-order curve / Morton offset
// They are arranged into 8x8 tiles, where each 8x8 tile is composed of
// four 4x4 subtiles, which are in turn composed of four 2x2 subtiles
static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
struct Bitmap* bmp, int rowWidth) {
unsigned int pixel, mortonX, mortonY;
unsigned int dstX, dstY, tileX, tileY;
// http://problemkaputt.de/gbatek-3ds-video-texture-swizzling.htm
static CC_INLINE void TwiddleCalcFactors(unsigned w, unsigned h,
unsigned* maskX, unsigned* maskY) {
*maskX = 0b010101; // 3 interleaved X bits
*maskY = 0b101010; // 3 interleaved Y bits
int width = bmp->width, height = bmp->height;
// Lower 3 X and Y bits are always interleaved
w >>= 4;
h >>= 4;
int shift = 6;
for (; w > 0; w >>= 1) {
*maskX += 0x01 << shift;
shift += 1;
}
for (; h > 0; h >>= 1) {
*maskY += 0x01 << shift;
shift += 1;
}
}
static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
struct Bitmap* bmp, int rowWidth) {
int src_w = bmp->width, dst_w = tex->width;
int src_h = bmp->height, dst_h = tex->height;
cc_uint32* dst = tex->data;
cc_uint32* src = bmp->scan0;
for (int y = 0; y < height; y++)
unsigned maskX, maskY;
TwiddleCalcFactors(dst_w, dst_h, &maskX, &maskY);
unsigned begX = 0, begY = 0;
// Calculate start twiddled X and Y values
for (int x = 0; x < originX; x++) { begX = (begX - maskX) & maskX; }
for (int y = 0; y < originY; y++) { begY = (begY - maskY) & maskY; }
unsigned Y = begY;
for (int y = 0; y < src_h; y++)
{
dstY = tex->height - 1 - (y + originY);
tileY = dstY & ~0x07;
mortonY = CalcZOrder(dstY & 0x07) << 1;
for (int x = 0; x < width; x++)
unsigned X = begX;
for (int x = 0; x < src_w; x++)
{
dstX = x + originX;
tileX = dstX & ~0x07;
mortonX = CalcZOrder(dstX & 0x07);
pixel = src[x + (y * rowWidth)];
dst[(mortonX | mortonY) + (tileX * 8) + (tileY * tex->width)] = pixel;
// need to flip image vertically
dst[X | (maskY - Y)] = src[x];
X = (X - maskX) & maskX;
}
Y = (Y - maskY) & maskY;
src += rowWidth;
}
// TODO flush data cache GSPGPU_FlushDataCache
}
@ -419,11 +424,11 @@ static void ToMortonTexture(C3D_Tex* tex, int originX, int originY,
GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags, cc_bool mipmaps) {
struct GPUTexture* tex = GPUTexture_Alloc();
bool success = CreateNativeTexture(&tex->texture, bmp->width, bmp->height);
int can_vram = !(flags & TEXTURE_FLAG_DYNAMIC);
bool success = CreateNativeTexture(&tex->texture, bmp->width, bmp->height, can_vram);
if (!success) return NULL;
ToMortonTexture(&tex->texture, 0, 0, bmp, rowWidth);
if (!(flags & TEXTURE_FLAG_DYNAMIC)) TryTransferToVRAM(&tex->texture);
return tex;
}

View File

@ -260,7 +260,9 @@ static void D3D9_SetTextureData(IDirect3DTexture9* texture, struct Bitmap* bmp,
cc_result res = IDirect3DTexture9_LockRect(texture, lvl, &rect, NULL, 0);
if (res) Process_Abort2(res, "D3D9_LockTextureData");
CopyTextureData(rect.pBits, rect.Pitch, bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(rect.pBits, rect.Pitch,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
res = IDirect3DTexture9_UnlockRect(texture, lvl);
if (res) Process_Abort2(res, "D3D9_UnlockTextureData");
@ -276,7 +278,9 @@ static void D3D9_SetTexturePartData(IDirect3DTexture9* texture, int x, int y, co
res = IDirect3DTexture9_LockRect(texture, lvl, &rect, &part, 0);
if (res) Process_Abort2(res, "D3D9_LockTexturePartData");
CopyTextureData(rect.pBits, rect.Pitch, bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(rect.pBits, rect.Pitch,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
res = IDirect3DTexture9_UnlockRect(texture, lvl);
if (res) Process_Abort2(res, "D3D9_UnlockTexturePartData");

View File

@ -19,8 +19,8 @@ void Gfx_Create(void) {
rspq_init();
//rspq_profile_start();
rdpq_init();
//rdpq_debug_start(); // TODO debug
//rdpq_debug_log(true);
//rdpq_debug_start(); // TODO debug
//rdpq_debug_log(true);
rdpq_set_mode_standard();
__rdpq_mode_change_som(SOM_TEXTURE_PERSP, SOM_TEXTURE_PERSP);
@ -96,7 +96,7 @@ void Gfx_BeginFrame(void) {
surface_t* disp = display_get();
rdpq_attach(disp, &zbuffer);
Platform_LogConst("GFX ctx beg");
//Platform_LogConst("== BEGIN frame");
}
extern void __rdpq_autosync_change(int mode);
@ -120,9 +120,7 @@ void Gfx_ClearColor(PackedCol color) {
}
void Gfx_EndFrame(void) {
Platform_LogConst("GFX ctx end");
rdpq_detach_show();
//Platform_LogConst("GFX END");
//rspq_profile_dump();
//rspq_profile_next_frame();
@ -154,9 +152,7 @@ void Gfx_BindTexture(GfxResourceID texId) {
static void UploadTexture(CCTexture* tex, rdpq_texparms_t* params) {
rspq_block_begin();
rdpq_tex_multi_begin();
rdpq_tex_upload(TILE0, &tex->surface, params);
rdpq_tex_multi_end();
tex->upload_block = rspq_block_end();
}
@ -189,8 +185,9 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
}
} else {
// 32 bpp can just be copied straight across
CopyTextureData(fb->buffer, fb->stride,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(fb->buffer, fb->stride,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
}
rdpq_texparms_t params =
@ -205,6 +202,7 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, int rowWidth, cc_bool mipmaps) {
CCTexture* tex = (CCTexture*)texId;
surface_t* fb = &tex->surface;
cc_uint32* src = (cc_uint32*)part->scan0 + x;
cc_uint8* dst = (cc_uint8*)fb->buffer + (x * 4) + (y * fb->stride);
@ -214,14 +212,6 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
src + srcY * rowWidth,
part->width * 4);
}
rdpq_texparms_t params = (rdpq_texparms_t){
.s.repeats = REPEAT_INFINITE,
.t.repeats = REPEAT_INFINITE,
};
rdpq_call_deferred((void (*)(void*))rspq_block_free, tex->upload_block);
UploadTexture(tex, &params);
}
void Gfx_DeleteTexture(GfxResourceID* texId) {
@ -261,14 +251,21 @@ static void SetColorWrite(cc_bool r, cc_bool g, cc_bool b, cc_bool a) {
//gpuColorMask(r, g, b, a); TODO
}
#define FLAG_Z_WRITE 0x02
void Gfx_SetDepthWrite(cc_bool enabled) {
__rdpq_mode_change_som(SOM_Z_WRITE, enabled ? SOM_Z_WRITE : 0);
gpu_attr_z &= ~FLAG_Z_WRITE;
gpu_attr_z |= enabled ? FLAG_Z_WRITE : 0;
gpuUpdateFormat();
}
#define FLAG_Z_READ 0x01
void Gfx_SetDepthTest(cc_bool enabled) {
__rdpq_mode_change_som(SOM_Z_COMPARE, enabled ? SOM_Z_COMPARE : 0);
gpu_attr_z = enabled;
gpu_attr_z &= ~FLAG_Z_READ;
gpu_attr_z |= enabled ? FLAG_Z_READ : 0;
gpuUpdateFormat();
}

View File

@ -106,8 +106,10 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
tex->width = bmp->width;
tex->height = bmp->height;
CopyTextureData(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
return tex;
}
@ -115,8 +117,9 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
CCTexture* tex = (CCTexture*)texId;
BitmapCol* dst = (tex->pixels + x) + y * tex->width;
CopyTextureData(dst, tex->width * BITMAPCOLOR_SIZE,
part, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(dst, tex->width * BITMAPCOLOR_SIZE,
part->scan0, rowWidth * BITMAPCOLOR_SIZE,
part->width, part->height);
}
void Gfx_EnableMipmaps(void) { }

View File

@ -207,8 +207,9 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
tex->surface.image = MEMAllocFromDefaultHeapEx(tex->surface.imageSize, tex->surface.alignment);
if (!tex->surface.image) { Mem_Free(tex); return NULL; }
CopyTextureData(tex->surface.image, tex->surface.pitch << 2,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(tex->surface.image, tex->surface.pitch << 2,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, tex->surface.image, tex->surface.imageSize);
return tex;
}
@ -217,8 +218,9 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
GX2Texture* tex = (GX2Texture*)texId;
uint32_t* dst = (uint32_t*)tex->surface.image + (y * tex->surface.pitch) + x;
CopyTextureData(dst, tex->surface.pitch << 2,
part, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(dst, tex->surface.pitch << 2,
part->scan0, rowWidth * BITMAPCOLOR_SIZE,
part->width, part->height);
GX2Invalidate(GX2_INVALIDATE_MODE_CPU_TEXTURE, tex->surface.image, tex->surface.imageSize);
}

View File

@ -96,8 +96,9 @@ static void Gfx_RestoreState(void) {
static void SetTextureData(struct XenosSurface* xtex, int x, int y, const struct Bitmap* bmp, int rowWidth, int lvl) {
void* dst = Xe_Surface_LockRect(xe, xtex, x, y, bmp->width, bmp->height, XE_LOCK_WRITE);
CopyTextureData(dst, bmp->width * BITMAPCOLOR_SIZE,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(dst, bmp->width * BITMAPCOLOR_SIZE,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
Xe_Surface_Unlock(xe, xtex);
}

View File

@ -163,8 +163,9 @@ static CC_NOINLINE void UpdateTextureSlow(int x, int y, struct Bitmap* part, int
ptr = Mem_Alloc(count, 4, "Gfx_UpdateTexture temp");
}
CopyTextureData(ptr, part->width * BITMAPCOLOR_SIZE,
part, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(ptr, part->width * BITMAPCOLOR_SIZE,
part->scan0, rowWidth * BITMAPCOLOR_SIZE,
part->width, part->height);
if (full) {
CallTexImage2D(0, part->width, part->height, ptr);

View File

@ -321,17 +321,20 @@ void Gfx_UpdateTexturePart(GfxResourceID texId, int x, int y, struct Bitmap* par
Gfx_UpdateTexture(texId, x, y, part, part->width, mipmaps);
}
static CC_INLINE void CopyTextureData(void* dst, int dstStride, const struct Bitmap* src, int srcStride) {
cc_uint8* src_ = (cc_uint8*)src->scan0;
static CC_INLINE void CopyPixels(void* dst, int dstStride,
const void* src, int srcStride,
int pixelsPerRow, int rows) {
cc_uint8* src_ = (cc_uint8*)src;
cc_uint8* dst_ = (cc_uint8*)dst;
int y;
if (srcStride == dstStride) {
Mem_Copy(dst_, src_, Bitmap_DataSize(src->width, src->height));
Mem_Copy(dst_, src_, Bitmap_DataSize(pixelsPerRow, rows));
} else {
/* Have to copy scanline by scanline */
for (y = 0; y < src->height; y++) {
Mem_Copy(dst_, src_, src->width * BITMAPCOLOR_SIZE);
for (y = 0; y < rows; y++)
{
Mem_Copy(dst_, src_, pixelsPerRow * BITMAPCOLOR_SIZE);
src_ += srcStride;
dst_ += dstStride;
}

View File

@ -377,8 +377,9 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
ConvertTexture_Palette((cc_uint8*)tex->pixels, bmp, rowWidth, palette, pal_count);
} else {
tex->format = GS_PSM_32;
CopyTextureData(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
}
return tex;
}
@ -436,8 +437,9 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
CCTexture* tex = (CCTexture*)texId;
BitmapCol* dst = (tex->pixels + x) + y * tex->width;
CopyTextureData(dst, tex->width * BITMAPCOLOR_SIZE,
part, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(dst, tex->width * BITMAPCOLOR_SIZE,
part->scan0, rowWidth * BITMAPCOLOR_SIZE,
part->width, part->height);
}
void Gfx_EnableMipmaps(void) { }

View File

@ -1,9 +1,7 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#include "_GraphicsBase.h"
#include "Errors.h"
#include "Logger.h"
#include "Window.h"
#include "../_GraphicsBase.h"
#include "../Errors.h"
#include "../Logger.h"
#include "../Window.h"
#include <malloc.h>
#include <pspkernel.h>
@ -120,8 +118,10 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
tex->width = bmp->width;
tex->height = bmp->height;
CopyTextureData(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(tex->pixels, bmp->width * BITMAPCOLOR_SIZE,
bmp->scan0, rowWidth * BITMAPCOLOR_SIZE,
bmp->width, bmp->height);
return tex;
}
@ -129,8 +129,9 @@ void Gfx_UpdateTexture(GfxResourceID texId, int x, int y, struct Bitmap* part, i
CCTexture* tex = (CCTexture*)texId;
BitmapCol* dst = (tex->pixels + x) + y * tex->width;
CopyTextureData(dst, tex->width * BITMAPCOLOR_SIZE,
part, rowWidth * BITMAPCOLOR_SIZE);
CopyPixels(dst, tex->width * BITMAPCOLOR_SIZE,
part->scan0, rowWidth * BITMAPCOLOR_SIZE,
part->width, part->height);
// TODO: Do line by line and only invalidate the actually changed parts of lines?
sceKernelDcacheWritebackInvalidateRange(dst, (tex->width * part->height) * 4);
}
@ -454,4 +455,3 @@ void Gfx_DrawIndexedTris_T2fC4b(int verticesCount, int startVertex) {
sceGuDrawArray(GU_TRIANGLES, gfx_fields | GU_INDEX_16BIT, ICOUNT(verticesCount),
gfx_indices, gfx_vertices + startVertex * SIZEOF_VERTEX_TEXTURED);
}
#endif

View File

@ -1,14 +1,11 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include <errno.h>
#include <stdlib.h>
@ -22,7 +19,7 @@
#include <pspnet_resolver.h>
#include <pspnet_apctl.h>
#include <psprtc.h>
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = ENOENT;
@ -496,4 +493,3 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,16 +1,15 @@
#include "Core.h"
#if defined CC_BUILD_PSP
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "VirtualKeyboard.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include "../VirtualKeyboard.h"
#include <pspdisplay.h>
#include <pspge.h>
#include <pspctrl.h>
@ -201,4 +200,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

View File

@ -142,10 +142,6 @@ void Window_DisableRawMouse(void) { Input.RawMode = false; }
*-------------------------------------------------------Gamepads----------------------------------------------------------*
*#########################################################################################################################*/
static const BindMapping vita_padbinds[BIND_COUNT] = {
[BIND_FORWARD] = { CCPAD_UP },
[BIND_BACK] = { CCPAD_DOWN },
[BIND_LEFT] = { CCPAD_LEFT },
[BIND_RIGHT] = { CCPAD_RIGHT },
[BIND_JUMP] = { CCPAD_1 },
[BIND_SET_SPAWN] = { CCPAD_START },
[BIND_CHAT] = { CCPAD_4 },
@ -154,10 +150,12 @@ static const BindMapping vita_padbinds[BIND_COUNT] = {
[BIND_SPEED] = { CCPAD_2, CCPAD_L },
[BIND_NOCLIP] = { CCPAD_2, CCPAD_3 },
[BIND_FLY] = { CCPAD_2, CCPAD_R },
[BIND_FLY_UP] = { CCPAD_2, CCPAD_UP },
[BIND_FLY_DOWN] = { CCPAD_2, CCPAD_DOWN },
[BIND_PLACE_BLOCK] = { CCPAD_L },
[BIND_DELETE_BLOCK] = { CCPAD_R },
[BIND_FLY_UP] = { CCPAD_UP },
[BIND_FLY_DOWN] = { CCPAD_DOWN },
[BIND_HOTBAR_LEFT] = { CCPAD_LEFT },
[BIND_HOTBAR_RIGHT] = { CCPAD_RIGHT },
};
static cc_bool circle_main;

View File

@ -1,11 +1,10 @@
#include "Core.h"
#if defined CC_BUILD_SATURN
#include "_GraphicsBase.h"
#include "Errors.h"
#include "Window.h"
#include "../_GraphicsBase.h"
#include "../Errors.h"
#include "../Window.h"
#include "../_BlockAlloc.h"
#include <stdint.h>
#include <yaul.h>
#include "_BlockAlloc.h"
#define SCREEN_WIDTH 320
#define SCREEN_HEIGHT 224
@ -790,4 +789,3 @@ void Gfx_End2D(void) {
Gfx_SetAlphaBlending(false);
gfx_rendering2D = false;
}
#endif

View File

@ -1,16 +1,14 @@
#include "Core.h"
#if defined PLAT_SATURN
#define CC_XTEA_ENCRYPTION
#include "_PlatformBase.h"
#include "Stream.h"
#include "ExtMath.h"
#include "Funcs.h"
#include "Window.h"
#include "Utils.h"
#include "Errors.h"
#include "Options.h"
#include "PackedCol.h"
#include "../_PlatformBase.h"
#include "../Stream.h"
#include "../ExtMath.h"
#include "../Funcs.h"
#include "../Window.h"
#include "../Utils.h"
#include "../Errors.h"
#include "../Options.h"
#include "../PackedCol.h"
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
@ -24,7 +22,7 @@ void* calloc(size_t num, size_t size) {
return ptr;
}
#include "_PlatformConsole.h"
#include "../_PlatformConsole.h"
const cc_result ReturnCode_FileShareViolation = 1000000000; // not used
const cc_result ReturnCode_FileNotFound = 99999;
@ -308,4 +306,3 @@ static cc_result GetMachineID(cc_uint32* key) {
Mem_Copy(key, MACHINE_KEY, sizeof(MACHINE_KEY) - 1);
return 0;
}
#endif

View File

@ -1,16 +1,14 @@
#include "Core.h"
#if defined CC_BUILD_SATURN
#include "Window.h"
#include "Platform.h"
#include "Input.h"
#include "Event.h"
#include "Graphics.h"
#include "String.h"
#include "Funcs.h"
#include "Bitmap.h"
#include "Errors.h"
#include "ExtMath.h"
#include "Logger.h"
#include "../Window.h"
#include "../Platform.h"
#include "../Input.h"
#include "../Event.h"
#include "../Graphics.h"
#include "../String.h"
#include "../Funcs.h"
#include "../Bitmap.h"
#include "../Errors.h"
#include "../ExtMath.h"
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
@ -274,4 +272,3 @@ cc_result Window_OpenFileDialog(const struct OpenFileDialogArgs* args) {
cc_result Window_SaveFileDialog(const struct SaveFileDialogArgs* args) {
return ERR_NOT_SUPPORTED;
}
#endif

123
third_party/citro3d.c vendored
View File

@ -97,66 +97,7 @@ typedef struct
};
} C3D_Tex;
static void C3D_TexLoadImage(C3D_Tex* tex, const void* data, GPU_TEXFACE face, int level);
static void C3D_TexGenerateMipmap(C3D_Tex* tex, GPU_TEXFACE face);
static void C3D_TexBind(int unitId, C3D_Tex* tex);
static void C3D_TexFlush(C3D_Tex* tex);
static void C3D_TexDelete(C3D_Tex* tex);
static inline int C3D_TexCalcMaxLevel(u32 width, u32 height)
{
return (31-__builtin_clz(width < height ? width : height)) - 3; // avoid sizes smaller than 8
}
static inline u32 C3D_TexCalcLevelSize(u32 size, int level)
{
return size >> (2*level);
}
static inline u32 C3D_TexCalcTotalSize(u32 size, int maxLevel)
{
/*
S = s + sr + sr^2 + sr^3 + ... + sr^n
Sr = sr + sr^2 + sr^3 + ... + sr^(n+1)
S-Sr = s - sr^(n+1)
S(1-r) = s(1 - r^(n+1))
S = s (1 - r^(n+1)) / (1-r)
r = 1/4
1-r = 3/4
S = 4s (1 - (1/4)^(n+1)) / 3
S = 4s (1 - 1/4^(n+1)) / 3
S = (4/3) (s - s/4^(n+1))
S = (4/3) (s - s/(1<<(2n+2)))
S = (4/3) (s - s>>(2n+2))
*/
return (size - C3D_TexCalcLevelSize(size,maxLevel+1)) * 4 / 3;
}
static inline void* C3D_TexGetImagePtr(C3D_Tex* tex, void* data, int level, u32* size)
{
if (size) *size = level >= 0 ? C3D_TexCalcLevelSize(tex->size, level) : C3D_TexCalcTotalSize(tex->size, tex->maxLevel);
if (!level) return data;
return (u8*)data + (level > 0 ? C3D_TexCalcTotalSize(tex->size, level-1) : 0);
}
static inline void* C3D_Tex2DGetImagePtr(C3D_Tex* tex, int level, u32* size)
{
return C3D_TexGetImagePtr(tex, tex->data, level, size);
}
static inline void C3D_TexUpload(C3D_Tex* tex, const void* data)
{
C3D_TexLoadImage(tex, data, GPU_TEXFACE_2D, 0);
}
static void C3D_DepthMap(bool bIsZBuffer, float zScale, float zOffset);
@ -257,7 +198,6 @@ typedef enum
static u32 C3D_CalcColorBufSize(u32 width, u32 height, GPU_COLORBUF fmt);
static u32 C3D_CalcDepthBufSize(u32 width, u32 height, GPU_DEPTHBUF fmt);
static C3D_FrameBuf* C3D_GetFrameBuf(void);
static void C3D_SetFrameBuf(C3D_FrameBuf* fb);
static void C3D_FrameBufClear(C3D_FrameBuf* fb, C3D_ClearBits clearBits, u32 clearColor, u32 clearDepth);
static void C3D_FrameBufTransfer(C3D_FrameBuf* fb, gfxScreen_t screen, gfx3dSide_t side, u32 transferFlags);
@ -337,8 +277,6 @@ static inline void C3D_RenderTargetClear(C3D_RenderTarget* target, C3D_ClearBits
C3D_FrameBufClear(&target->frameBuf, clearBits, clearColor, clearDepth);
}
static void C3D_SyncTextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
@ -818,14 +756,6 @@ static u32 C3D_CalcDepthBufSize(u32 width, u32 height, GPU_DEPTHBUF fmt)
return size*(2+depthFmtSizes[fmt]);
}
static C3D_FrameBuf* C3D_GetFrameBuf(void)
{
C3D_Context* ctx = C3Di_GetContext();
ctx->flags |= C3DiF_FrameBuf;
return &ctx->fb;
}
static void C3D_SetFrameBuf(C3D_FrameBuf* fb)
{
C3D_Context* ctx = C3Di_GetContext();
@ -1205,32 +1135,6 @@ static void C3D_RenderTargetSetOutput(C3D_RenderTarget* target, gfxScreen_t scre
}
}
static void C3Di_SafeTextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags)
{
C3Di_WaitAndClearQueue(-1);
inSafeTransfer = true;
GX_TextureCopy(inadr, indim, outadr, outdim, size, flags);
gxCmdQueueRun(&C3Di_GetContext()->gxQueue);
}
static void C3D_SyncTextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags)
{
if (inFrame)
{
C3D_FrameSplit(0);
GX_TextureCopy(inadr, indim, outadr, outdim, size, flags);
} else
{
C3Di_SafeTextureCopy(inadr, indim, outadr, outdim, size, flags);
gspWaitForPPF();
}
}
static void C3Di_TexEnvBind(int id, C3D_TexEnv* env)
{
@ -1241,18 +1145,6 @@ static void C3Di_TexEnvBind(int id, C3D_TexEnv* env)
static void C3D_TexLoadImage(C3D_Tex* tex, const void* data, GPU_TEXFACE face, int level)
{
u32 size = 0;
void* out = C3D_TexGetImagePtr(tex, tex->data, level, &size);
if (!addrIsVRAM(out))
memcpy(out, data, size);
else
C3D_SyncTextureCopy((u32*)data, 0, (u32*)out, 0, size, 8);
}
static void C3D_TexBind(int unitId, C3D_Tex* tex)
{
C3D_Context* ctx = C3Di_GetContext();
@ -1261,21 +1153,6 @@ static void C3D_TexBind(int unitId, C3D_Tex* tex)
ctx->tex[unitId] = tex;
}
static void C3D_TexFlush(C3D_Tex* tex)
{
if (!addrIsVRAM(tex->data))
GSPGPU_FlushDataCache(tex->data, C3D_TexCalcTotalSize(tex->size, tex->maxLevel));
}
static void C3D_TexDelete(C3D_Tex* tex)
{
void* addr = tex->data;
if (addrIsVRAM(addr))
vramFree(addr);
else
linearFree(addr);
}
static void C3Di_SetTex(int unit, C3D_Tex* tex)
{
u32 reg[10];