cellGcmSys changes and minor fixes

This commit is contained in:
Alexandro Sánchez Bach 2014-08-17 11:22:36 +02:00
parent b7be8b19ef
commit bb1749d3da
8 changed files with 78 additions and 53 deletions

View File

@ -14,7 +14,6 @@
#define CMD_LOG(...)
#endif
CellGcmDisplayInfo gcmBuffers[8];
GLuint g_flip_tex, g_depth_tex, g_pbo[6];
int last_width = 0, last_height = 0, last_depth_format = 0;

View File

@ -1321,8 +1321,8 @@ void RSXThread::DoCmd(const u32 fcmd, const u32 cmd, mem32_ptr_t args, const u32
}
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(m_gcm_buffers_addr);
m_width = re(buffers[m_gcm_current_buffer].width);
m_height = re(buffers[m_gcm_current_buffer].height);
m_width = buffers[m_gcm_current_buffer].width;
m_height = buffers[m_gcm_current_buffer].height;
// Rescale native resolution to fit 1080p/720p/480p/576p window size
nativeRescale((float)m_width, (float)m_height);

View File

@ -5,6 +5,7 @@
#include "Emu/SysCalls/Modules.h"
#include "Emu/SysCalls/SysCalls.h"
#include "Emu/RSX/GCM.h"
#include "Emu/SysCalls/lv2/sys_process.h"
#include "sysPrxForUser.h"
#include "cellGcmSys.h"
@ -37,6 +38,29 @@ gcmInfo gcm_info;
u32 map_offset_addr = 0;
u32 map_offset_pos = 0;
// Auxiliary functions
/*
* Get usable local memory size for a specific game SDK version
* Example: For 0x00446000 (FW 4.46) we get a localSize of 0x0F900000 (249MB)
*/
u32 gcmGetLocalMemorySize(u32 sdk_version)
{
if (sdk_version >= 0x00220000) {
return 0x0F900000; // 249MB
}
if (sdk_version >= 0x00200000) {
return 0x0F200000; // 242MB
}
if (sdk_version >= 0x00190000) {
return 0x0EA00000; // 234MB
}
if (sdk_version >= 0x00180000) {
return 0x0E800000; // 232MB
}
return 0x0E000000; // 224MB
}
//----------------------------------------------------------------------------
// Data Retrieval
//----------------------------------------------------------------------------
@ -273,16 +297,29 @@ u32 cellGcmGetTiledPitchSize(u32 size)
return 0;
}
int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress)
void _cellGcmFunc1()
{
cellGcmSys->Warning("cellGcmInit(context_addr=0x%x,cmdSize=0x%x,ioSize=0x%x,ioAddress=0x%x)", context_addr, cmdSize, ioSize, ioAddress);
cellGcmSys->Todo("_cellGcmFunc1()");
return;
}
void _cellGcmFunc15(mem_ptr_t<CellGcmContextData> context)
{
cellGcmSys->Todo("_cellGcmFunc15(context_addr=0x%x)", context.GetAddr());
return;
}
// Called by cellGcmInit
s32 _cellGcmInitBody(mem_ptr_t<CellGcmContextData> context, u32 cmdSize, u32 ioSize, u32 ioAddress)
{
cellGcmSys->Warning("_cellGcmInitBody(context_addr=0x%x, cmdSize=0x%x, ioSize=0x%x, ioAddress=0x%x)", context.GetAddr(), cmdSize, ioSize, ioAddress);
if(!cellGcmSys->IsLoaded())
cellGcmSys->Load();
if(!local_size && !local_addr)
{
local_size = 0xf900000; //TODO
local_size = 0xf900000; // TODO: Get sdk_version in _cellGcmFunc15 and pass it to gcmGetLocalMemorySize
local_addr = Memory.RSXFBMem.GetStartAddr();
Memory.RSXFBMem.AllocAlign(local_size);
}
@ -329,7 +366,7 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress)
gcm_info.control_addr = gcm_info.context_addr + 0x40;
Memory.WriteData(gcm_info.context_addr, current_context);
Memory.Write32(context_addr, gcm_info.context_addr);
Memory.Write32(context.GetAddr(), gcm_info.context_addr);
CellGcmControl& ctrl = (CellGcmControl&)Memory[gcm_info.control_addr];
ctrl.put = 0;
@ -337,8 +374,8 @@ int cellGcmInit(u32 context_addr, u32 cmdSize, u32 ioSize, u32 ioAddress)
ctrl.ref = -1;
auto& render = Emu.GetGSManager().GetRender();
render.m_ctxt_addr = context_addr;
render.m_gcm_buffers_addr = Memory.Alloc(sizeof(gcmBuffer) * 8, sizeof(gcmBuffer));
render.m_ctxt_addr = context.GetAddr();
render.m_gcm_buffers_addr = Memory.Alloc(sizeof(CellGcmDisplayInfo) * 8, sizeof(CellGcmDisplayInfo));
render.m_zculls_addr = Memory.Alloc(sizeof(CellGcmZcullInfo) * 8, sizeof(CellGcmZcullInfo));
render.m_tiles_addr = Memory.Alloc(sizeof(CellGcmTileInfo) * 15, sizeof(CellGcmTileInfo));
render.m_gcm_buffers_count = 0;
@ -380,21 +417,19 @@ int cellGcmSetDisplayBuffer(u32 id, u32 offset, u32 pitch, u32 width, u32 height
{
cellGcmSys->Log("cellGcmSetDisplayBuffer(id=0x%x,offset=0x%x,pitch=%d,width=%d,height=%d)", id, offset, width ? pitch / width : pitch, width, height);
if (id > 7)
{
if (id > 7) {
cellGcmSys->Error("cellGcmSetDisplayBuffer : CELL_EINVAL");
return CELL_EINVAL;
}
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr);
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(Emu.GetGSManager().GetRender().m_gcm_buffers_addr);
buffers[id].offset = re(offset);
buffers[id].pitch = re(pitch);
buffers[id].width = re(width);
buffers[id].height = re(height);
buffers[id].offset = offset;
buffers[id].pitch = pitch;
buffers[id].width = width;
buffers[id].height = height;
if(id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count)
{
if (id + 1 > Emu.GetGSManager().GetRender().m_gcm_buffers_count) {
Emu.GetGSManager().GetRender().m_gcm_buffers_count = id + 1;
}
@ -1071,18 +1106,6 @@ int cellGcmSetFlipCommand(u32 ctx, u32 id)
return cellGcmSetPrepareFlip(ctx, id);
}
s64 cellGcmFunc15(u32 unk_addr)
{
cellGcmSys->Todo("cellGcmFunc15(unk_addr=0x%x)", unk_addr);
if (0/*TODO: If what?*/) {
_sys_memset(unk_addr, 0, 0x84);
}
// TODO
return 0;
}
int cellGcmSetFlipCommandWithWaitLabel(u32 ctx, u32 id, u32 label_index, u32 label_value)
{
int res = cellGcmSetPrepareFlip(ctx, id);
@ -1201,7 +1224,9 @@ void cellGcmSys_init()
cellGcmSys->AddFunc(0x23ae55a3, cellGcmGetLastSecondVTime);
cellGcmSys->AddFunc(0x055bd74d, cellGcmGetTiledPitchSize);
cellGcmSys->AddFunc(0x723bbc7e, cellGcmGetVBlankCount);
cellGcmSys->AddFunc(0x15bae46b, cellGcmInit);
cellGcmSys->AddFunc(0x5f909b17, _cellGcmFunc1);
cellGcmSys->AddFunc(0x3a33c1fd, _cellGcmFunc15);
cellGcmSys->AddFunc(0x15bae46b, _cellGcmInitBody);
cellGcmSys->AddFunc(0xfce9e764, cellGcmInitSystemMode);
cellGcmSys->AddFunc(0xb2e761d4, cellGcmResetFlipStatus);
cellGcmSys->AddFunc(0x51c9d62b, cellGcmSetDebugOutputLevel);
@ -1263,7 +1288,6 @@ void cellGcmSys_init()
// Other
cellGcmSys->AddFunc(0x21397818, cellGcmSetFlipCommand);
cellGcmSys->AddFunc(0x3a33c1fd, cellGcmFunc15);
cellGcmSys->AddFunc(0xd8f88e1a, cellGcmSetFlipCommandWithWaitLabel);
cellGcmSys->AddFunc(0xd0b1d189, cellGcmSetTile);
}

View File

@ -7,7 +7,7 @@ enum
CELL_GCM_ERROR_INVALID_ENUM = 0x80210002,
CELL_GCM_ERROR_INVALID_VALUE = 0x80210003,
CELL_GCM_ERROR_INVALID_ALIGNMENT = 0x80210004,
CELL_GCM_ERROR_ADDRESS_OVERWRAP = 0x80210005
CELL_GCM_ERROR_ADDRESS_OVERWRAP = 0x80210005,
};
struct gcm_offset
@ -18,6 +18,8 @@ struct gcm_offset
// Auxiliary functions
void InitOffsetTable();
u32 gcmGetLocalMemorySize();
// SysCalls
s32 cellGcmSetPrepareFlip(mem_ptr_t<CellGcmContextData> ctxt, u32 id);

View File

@ -1026,10 +1026,10 @@ int cellRescGcmSurface2RescSrc(mem_ptr_t<CellGcmSurface> gcmSurface, mem_ptr_t<C
}
rescSrc->format = textureFormat;
rescSrc->pitch = re(gcmSurface->colorPitch[0]);
rescSrc->width = re(gcmSurface->width) * xW;
rescSrc->height = re(gcmSurface->height) * xH;
rescSrc->offset = re(gcmSurface->colorOffset[0]);
rescSrc->pitch = gcmSurface->colorPitch[0];
rescSrc->width = gcmSurface->width * xW;
rescSrc->height = gcmSurface->height * xH;
rescSrc->offset = gcmSurface->colorOffset[0];
return CELL_OK;
}

View File

@ -120,7 +120,7 @@ s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u6
break;
default:
break;
}
return CELL_OK;
}

View File

@ -3,13 +3,13 @@
// SysCalls
s32 sys_rsx_device_open();
s32 sys_rsx_device_close();
s32 sys_rsx_memory_allocate();
s32 sys_rsx_memory_free();
s32 sys_rsx_context_allocate();
s32 sys_rsx_context_free();
s32 sys_rsx_memory_allocate(mem32_t mem_handle, mem32_t mem_addr, u32 size, u64 flags, u64 a5, u64 a6, u64 a7);
s32 sys_rsx_memory_free(u32 mem_handle);
s32 sys_rsx_context_allocate(mem32_t context_id, mem32_t lpar_dma_control, mem32_t lpar_driver_info, mem32_t lpar_reports, u64 mem_ctx, u64 system_mode);
s32 sys_rsx_context_free(u32 context_id);
s32 sys_rsx_context_iomap();
s32 sys_rsx_context_iounmap();
s32 sys_rsx_context_attribute(s32 context_id, u64 a2, u64 a3, u64 a4, u64 a5, u64 a6);
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 a3);
s32 sys_rsx_device_unmap();
s32 sys_rsx_context_attribute(s32 context_id, u32 package_id, u64 a3, u64 a4, u64 a5, u64 a6);
s32 sys_rsx_device_map(mem32_t a1, mem32_t a2, u32 dev_id);
s32 sys_rsx_device_unmap(u32 dev_id);
s32 sys_rsx_attribute();

View File

@ -292,7 +292,7 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
{
if (!RSXReady()) return;
const GSRender& render = Emu.GetGSManager().GetRender();
const mem_ptr_t<gcmBuffer> buffers = render.m_gcm_buffers_addr;
const mem_ptr_t<CellGcmDisplayInfo> buffers = render.m_gcm_buffers_addr;
if(!buffers.IsGood())
return;
@ -300,9 +300,9 @@ void RSXDebugger::OnClickBuffer(wxMouseEvent& event)
// TODO: Is there any better way to choose the color buffers
#define SHOW_BUFFER(id) \
{ \
u32 addr = render.m_local_mem_addr + re(buffers[id].offset); \
if(Memory.IsGoodAddr(addr) && buffers[id].width && buffers[id].height) \
MemoryViewerPanel::ShowImage(this, addr, 3, re(buffers[id].width), re(buffers[id].height), true); \
u32 addr = render.m_local_mem_addr + buffers[id].offset; \
if (Memory.IsGoodAddr(addr) && buffers[id].width && buffers[id].height) \
MemoryViewerPanel::ShowImage(this, addr, 3, buffers[id].width, buffers[id].height, true); \
return; \
} \
@ -409,16 +409,16 @@ void RSXDebugger::GetBuffers()
if(!Memory.IsGoodAddr(render.m_gcm_buffers_addr))
continue;
gcmBuffer* buffers = (gcmBuffer*)Memory.GetMemFromAddr(render.m_gcm_buffers_addr);
u32 RSXbuffer_addr = render.m_local_mem_addr + re(buffers[bufferId].offset);
CellGcmDisplayInfo* buffers = (CellGcmDisplayInfo*)Memory.GetMemFromAddr(render.m_gcm_buffers_addr);
u32 RSXbuffer_addr = render.m_local_mem_addr + buffers[bufferId].offset;
if(!Memory.IsGoodAddr(RSXbuffer_addr))
continue;
unsigned char* RSXbuffer = (unsigned char*)Memory.VirtualToRealAddr(RSXbuffer_addr);
u32 width = re(buffers[bufferId].width);
u32 height = re(buffers[bufferId].height);
u32 width = buffers[bufferId].width;
u32 height = buffers[bufferId].height;
unsigned char* buffer = (unsigned char*)malloc(width * height * 3);
// ABGR to RGB and flip vertically