From f3a391e9c361e99e219deaa6db361af3bfb4955a Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Sun, 17 Mar 2024 09:23:20 +1100 Subject: [PATCH] Xbox: Try to fix texture allocation failure --- src/Graphics_Xbox.c | 9 ++++----- src/Platform_Xbox.c | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Graphics_Xbox.c b/src/Graphics_Xbox.c index 5dcbf96a9..f2af14a9d 100644 --- a/src/Graphics_Xbox.c +++ b/src/Graphics_Xbox.c @@ -141,8 +141,7 @@ void Gfx_FreeState(void) { } *#########################################################################################################################*/ typedef struct CCTexture_ { cc_uint32 width, height; - cc_uint32 pitch, pad; - cc_uint32 pixels[]; + cc_uint32* pixels; } CCTexture; // See Graphics_Dreamcast.c for twiddling explanation @@ -195,12 +194,12 @@ static void ConvertTexture(cc_uint32* dst, struct Bitmap* bmp) { } static GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, cc_uint8 flags, cc_bool mipmaps) { - int size = 16 + bmp->width * bmp->height * 4; - CCTexture* tex = MmAllocateContiguousMemoryEx(size, 0, MAX_RAM_ADDR, 16, PAGE_WRITECOMBINE | PAGE_READWRITE); + int size = bmp->width * bmp->height * 4; + CCTexture* tex = Mem_Alloc(1, sizeof(struct CCTexture), "GPU texture"); + tex->pixels = MmAllocateContiguousMemoryEx(size, 0, MAX_RAM_ADDR, 0, PAGE_WRITECOMBINE | PAGE_READWRITE); tex->width = bmp->width; tex->height = bmp->height; - tex->pitch = bmp->width * 4; ConvertTexture(tex->pixels, bmp); return tex; } diff --git a/src/Platform_Xbox.c b/src/Platform_Xbox.c index 5cb8c223e..f53fe1dd0 100644 --- a/src/Platform_Xbox.c +++ b/src/Platform_Xbox.c @@ -234,7 +234,7 @@ static DWORD WINAPI ExecThread(void* param) { void Thread_Run(void** handle, Thread_StartFunc func, int stackSize, const char* name) { DWORD threadID; - HANDLE thread = CreateThread(NULL, 0, ExecThread, (void*)func, CREATE_SUSPENDED, &threadID); + HANDLE thread = CreateThread(NULL, stackSize, ExecThread, (void*)func, CREATE_SUSPENDED, &threadID); if (!thread) Logger_Abort2(GetLastError(), "Creating thread"); *handle = thread;