From 11571cf2a40bfbbd479368aef683b977cd68c7fe Mon Sep 17 00:00:00 2001 From: elisha464 Date: Mon, 3 Mar 2014 22:45:27 +0200 Subject: [PATCH 1/2] fix memory alignment added eaIOMap with flags (draft) changed gcmInit to throw an error when not being able to map to io address --- rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp | 19 ++++++++++++++++--- rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp index 6133a6b111..877075b86f 100644 --- a/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp +++ b/rpcs3/Emu/SysCalls/Modules/cellGcmSys.cpp @@ -37,6 +37,7 @@ uint32_t cellGcmGetMaxIoMapSize(); void cellGcmGetOffsetTable(mem_ptr_t table); int32_t cellGcmIoOffsetToAddress(u32 ioOffset, u64 address); int32_t cellGcmMapEaIoAddress(const u32 ea, const u32 io, const u32 size); +int32_t cellGcmMapEaIoAddressWithFlags(const u32 ea, const u32 io, const u32 size, const u32 flags); int32_t cellGcmMapMainMemory(u64 ea, u32 size, mem32_t offset); int32_t cellGcmReserveIoMapSize(const u32 size); int32_t cellGcmUnmapEaIoAddress(u64 ea); @@ -68,6 +69,14 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) cellGcmSys.Warning("*** local memory(addr=0x%x, size=0x%x)", local_addr, local_size); + InitOffsetTable(); + Memory.MemoryBlocks.push_back(Memory.RSXIOMem.SetRange(0x50000000, 0x10000000/*256MB*/));//TODO: implement allocateAdressSpace in memoryBase + if(cellGcmMapEaIoAddress(ioAddress, 0, ioSize) != CELL_OK) + { + Memory.MemoryBlocks.pop_back(); + return CELL_GCM_ERROR_FAILURE; + } + map_offset_addr = 0; map_offset_pos = 0; current_config.ioSize = ioSize; @@ -77,10 +86,7 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress) current_config.memoryFrequency = 650000000; current_config.coreFrequency = 500000000; - InitOffsetTable(); Memory.RSXCMDMem.AllocAlign(cmdSize); - Memory.MemoryBlocks.push_back(Memory.RSXIOMem.SetRange(0x50000000, 0x10000000/*256MB*/));//TODO: implement allocateAdressSpace in memoryBase - cellGcmMapEaIoAddress(ioAddress, 0, ioSize); u32 ctx_begin = ioAddress/* + 0x1000*/; u32 ctx_size = 0x6ffc; @@ -677,6 +683,12 @@ int32_t cellGcmMapEaIoAddress(const u32 ea, const u32 io, const u32 size) return CELL_OK; } +int32_t cellGcmMapEaIoAddressWithFlags(const u32 ea, const u32 io, const u32 size, const u32 flags) +{ + cellGcmSys.Warning("cellGcmMapEaIoAddressWithFlags(ea=0x%x, io=0x%x, size=0x%x, flags=0x%x)", ea, io, size, flags); + return cellGcmMapEaIoAddress(ea, io, size); // TODO: strict ordering +} + int32_t cellGcmMapLocalMemory(u64 address, u64 size) { if(!local_size && !local_addr) @@ -855,6 +867,7 @@ void cellGcmSys_init() cellGcmSys.AddFunc(0x2922aed0, cellGcmGetOffsetTable); cellGcmSys.AddFunc(0x2a6fba9c, cellGcmIoOffsetToAddress); cellGcmSys.AddFunc(0x63441cb4, cellGcmMapEaIoAddress); + cellGcmSys.AddFunc(0x626e8518, cellGcmMapEaIoAddressWithFlags); cellGcmSys.AddFunc(0xdb769b32, cellGcmMapLocalMemory); cellGcmSys.AddFunc(0xa114ec67, cellGcmMapMainMemory); cellGcmSys.AddFunc(0xa7ede268, cellGcmReserveIoMapSize); diff --git a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp index 04e2c958d3..5c4f5b9761 100644 --- a/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp +++ b/rpcs3/Emu/SysCalls/lv2/SC_Memory.cpp @@ -52,12 +52,12 @@ int sys_memory_allocate(u32 size, u32 flags, u32 alloc_addr_addr) { case SYS_MEMORY_PAGE_SIZE_1M: if(size & 0xfffff) return CELL_EALIGN; - addr = Memory.Alloc(size, 1); + addr = Memory.Alloc(size, 0x100000); break; case SYS_MEMORY_PAGE_SIZE_64K: if(size & 0xffff) return CELL_EALIGN; - addr = Memory.Alloc(size, 1); + addr = Memory.Alloc(size, 0x10000); break; default: return CELL_EINVAL; From c08c5eef10b87a9b256ba065f21d007aece0b04f Mon Sep 17 00:00:00 2001 From: elisha464 Date: Tue, 11 Mar 2014 20:52:14 +0200 Subject: [PATCH 2/2] disabled a few stuff and changed color to white before rendering to main window (fix fw_stencil_reflect) --- rpcs3/Emu/GS/GL/GLGSRender.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rpcs3/Emu/GS/GL/GLGSRender.cpp b/rpcs3/Emu/GS/GL/GLGSRender.cpp index 9e1b4a6fd0..db574da08f 100644 --- a/rpcs3/Emu/GS/GL/GLGSRender.cpp +++ b/rpcs3/Emu/GS/GL/GLGSRender.cpp @@ -1151,6 +1151,14 @@ void GLGSRender::Flip() if(src_buffer) { + glDisable(GL_STENCIL_TEST); + glDisable(GL_DEPTH_TEST); + glDisable(GL_CLIP_PLANE0); + glDisable(GL_CLIP_PLANE1); + glDisable(GL_CLIP_PLANE2); + glDisable(GL_CLIP_PLANE3); + glDisable(GL_CLIP_PLANE4); + glDisable(GL_CLIP_PLANE5); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, g_flip_tex); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, format, GL_UNSIGNED_INT_8_8_8_8, src_buffer); @@ -1170,6 +1178,7 @@ void GLGSRender::Flip() m_program.Use(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_ACCUM_BUFFER_BIT); + glColor3f(1, 1, 1); glBegin(GL_QUADS); glTexCoord2i(0, 1); glVertex2i(0, 0);