citra-emu
/
citra-canary
Archived
1
0
Fork 0

Pica/CommandProcessor: Implement parameter masking.

This commit is contained in:
Tony Wasserka 2014-08-14 23:23:55 +02:00
parent f37e39deb9
commit 0465adf206
2 changed files with 25 additions and 6 deletions

View File

@ -24,9 +24,14 @@ static u32 uniform_write_buffer[4];
static u32 vs_binary_write_offset = 0;
static u32 vs_swizzle_write_offset = 0;
static inline void WritePicaReg(u32 id, u32 value) {
static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
if (id >= registers.NumIds())
return;
// TODO: Figure out how register masking acts on e.g. vs_uniform_setup.set_value
u32 old_value = registers[id];
registers[id] = value;
registers[id] = (old_value & ~mask) | (value & mask);
switch(id) {
// It seems like these trigger vertex rendering
@ -215,14 +220,17 @@ static std::ptrdiff_t ExecuteCommandBlock(const u32* first_command_word) {
u32* read_pointer = (u32*)first_command_word;
// TODO: Take parameter mask into consideration!
const u32 write_mask = ((header.parameter_mask & 0x1) ? (0xFFu << 0) : 0u) |
((header.parameter_mask & 0x2) ? (0xFFu << 8) : 0u) |
((header.parameter_mask & 0x4) ? (0xFFu << 16) : 0u) |
((header.parameter_mask & 0x8) ? (0xFFu << 24) : 0u);
WritePicaReg(header.cmd_id, *read_pointer);
WritePicaReg(header.cmd_id, *read_pointer, write_mask);
read_pointer += 2;
for (int i = 1; i < 1+header.extra_data_length; ++i) {
u32 cmd = header.cmd_id + ((header.group_commands) ? i : 0);
WritePicaReg(cmd, *read_pointer);
WritePicaReg(cmd, *read_pointer, write_mask);
++read_pointer;
}

View File

@ -17,11 +17,22 @@ union CommandHeader {
u32 hex;
BitField< 0, 16, u32> cmd_id;
// parameter_mask:
// Mask applied to the input value to make it possible to update
// parts of a register without overwriting its other fields.
// first bit: 0x000000FF
// second bit: 0x0000FF00
// third bit: 0x00FF0000
// fourth bit: 0xFF000000
BitField<16, 4, u32> parameter_mask;
BitField<20, 11, u32> extra_data_length;
BitField<31, 1, u32> group_commands;
};
static_assert(std::is_standard_layout<CommandHeader>::value == true, "CommandHeader does not use standard layout");
static_assert(std::is_standard_layout<CommandHeader>::value == true,
"CommandHeader does not use standard layout");
static_assert(sizeof(CommandHeader) == sizeof(u32), "CommandHeader has incorrect size!");
void ProcessCommandList(const u32* list, u32 size);