mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-11-01 12:47:52 +00:00
GSP: Define more GX commands.
This commit is contained in:
parent
b1c8bad9a6
commit
82d3260359
2 changed files with 54 additions and 14 deletions
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include "core/hw/lcd.h"
|
#include "core/hw/lcd.h"
|
||||||
|
|
||||||
|
#include "video_core/gpu_debugger.h"
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/// GSP shared memory GX command buffer header
|
/// GSP shared memory GX command buffer header
|
||||||
|
@ -28,7 +30,6 @@ union GX_CmdBufferHeader {
|
||||||
// writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only
|
// writing a command to shared memory, after increasing this value TriggerCmdReqQueue is only
|
||||||
// used if this field is value 1.
|
// used if this field is value 1.
|
||||||
BitField<8,8,u32> number_commands;
|
BitField<8,8,u32> number_commands;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Gets the address of the start (header) of a command buffer in GSP shared memory
|
/// Gets the address of the start (header) of a command buffer in GSP shared memory
|
||||||
|
@ -45,6 +46,7 @@ static inline u8* GX_GetCmdBufferPointer(u32 thread_id, u32 offset=0) {
|
||||||
void GX_FinishCommand(u32 thread_id) {
|
void GX_FinishCommand(u32 thread_id) {
|
||||||
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id);
|
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(thread_id);
|
||||||
header->number_commands = header->number_commands - 1;
|
header->number_commands = header->number_commands - 1;
|
||||||
|
// TODO: Increment header->index?
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -54,10 +56,6 @@ namespace GSP_GPU {
|
||||||
|
|
||||||
u32 g_thread_id = 0;
|
u32 g_thread_id = 0;
|
||||||
|
|
||||||
enum {
|
|
||||||
CMD_GX_REQUEST_DMA = 0x00000000,
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
REG_FRAMEBUFFER_1 = 0x00400468,
|
REG_FRAMEBUFFER_1 = 0x00400468,
|
||||||
REG_FRAMEBUFFER_2 = 0x00400494,
|
REG_FRAMEBUFFER_2 = 0x00400494,
|
||||||
|
@ -101,21 +99,46 @@ void RegisterInterruptRelayQueue(Service::Interface* self) {
|
||||||
u32* cmd_buff = Service::GetCommandBuffer();
|
u32* cmd_buff = Service::GetCommandBuffer();
|
||||||
u32 flags = cmd_buff[1];
|
u32 flags = cmd_buff[1];
|
||||||
u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling
|
u32 event_handle = cmd_buff[3]; // TODO(bunnei): Implement event handling
|
||||||
|
|
||||||
cmd_buff[2] = g_thread_id; // ThreadID
|
cmd_buff[2] = g_thread_id; // ThreadID
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// This triggers handling of the GX command written to the command buffer in shared memory.
|
/// This triggers handling of the GX command written to the command buffer in shared memory.
|
||||||
void TriggerCmdReqQueue(Service::Interface* self) {
|
void TriggerCmdReqQueue(Service::Interface* self) {
|
||||||
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id);
|
GX_CmdBufferHeader* header = (GX_CmdBufferHeader*)GX_GetCmdBufferPointer(g_thread_id);
|
||||||
u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20));
|
u32* cmd_buff = (u32*)GX_GetCmdBufferPointer(g_thread_id, 0x20 + (header->index * 0x20));
|
||||||
|
|
||||||
switch (cmd_buff[0]) {
|
switch (static_cast<GXCommandId>(cmd_buff[0])) {
|
||||||
|
|
||||||
// GX request DMA - typically used for copying memory from GSP heap to VRAM
|
// GX request DMA - typically used for copying memory from GSP heap to VRAM
|
||||||
case CMD_GX_REQUEST_DMA:
|
case GXCommandId::REQUEST_DMA:
|
||||||
memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]);
|
memcpy(Memory::GetPointer(cmd_buff[2]), Memory::GetPointer(cmd_buff[1]), cmd_buff[3]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case GXCommandId::SET_COMMAND_LIST_LAST:
|
||||||
|
LCD::Write<u32>(LCD::CommandListAddress, cmd_buff[1] >> 3);
|
||||||
|
LCD::Write<u32>(LCD::CommandListSize, cmd_buff[2] >> 3);
|
||||||
|
LCD::Write<u32>(LCD::ProcessCommandList, 1); // TODO: Not sure if we are supposed to always write this
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GXCommandId::SET_MEMORY_FILL:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GXCommandId::SET_DISPLAY_TRANSFER:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GXCommandId::SET_TEXTURE_COPY:
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GXCommandId::SET_COMMAND_LIST_FIRST:
|
||||||
|
{
|
||||||
|
//u32* buf0_data = (u32*)Memory::GetPointer(cmd_buff[1]);
|
||||||
|
//u32* buf1_data = (u32*)Memory::GetPointer(cmd_buff[3]);
|
||||||
|
//u32* buf2_data = (u32*)Memory::GetPointer(cmd_buff[5]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]);
|
ERROR_LOG(GSP, "TriggerCmdReqQueue unknown command 0x%08X", cmd_buff[0]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,23 @@
|
||||||
|
|
||||||
namespace GSP_GPU {
|
namespace GSP_GPU {
|
||||||
|
|
||||||
|
enum class GXCommandId : u32 {
|
||||||
|
REQUEST_DMA = 0x00000000,
|
||||||
|
SET_COMMAND_LIST_LAST = 0x00000001,
|
||||||
|
SET_MEMORY_FILL = 0x00000002, // TODO: Confirm? (lictru uses 0x01000102)
|
||||||
|
SET_DISPLAY_TRANSFER = 0x00000003,
|
||||||
|
SET_TEXTURE_COPY = 0x00000004,
|
||||||
|
SET_COMMAND_LIST_FIRST = 0x00000005,
|
||||||
|
};
|
||||||
|
|
||||||
|
union GXCommand {
|
||||||
|
struct {
|
||||||
|
GXCommandId id;
|
||||||
|
};
|
||||||
|
|
||||||
|
u32 data[0x20];
|
||||||
|
};
|
||||||
|
|
||||||
/// Interface to "srv:" service
|
/// Interface to "srv:" service
|
||||||
class Interface : public Service::Interface {
|
class Interface : public Service::Interface {
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue