Pica: Add fog state

This commit is contained in:
Jannik Vogel 2016-05-11 13:39:28 +02:00
parent c900c092e3
commit 57855a1701
3 changed files with 69 additions and 14 deletions

View file

@ -423,6 +423,20 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
break; break;
} }
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[0], 0xe8):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[1], 0xe9):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[2], 0xea):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[3], 0xeb):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[4], 0xec):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[5], 0xed):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[6], 0xee):
case PICA_REG_INDEX_WORKAROUND(fog_lut_data[7], 0xef):
{
g_state.fog.lut[regs.fog_lut_offset % 128].raw = value;
regs.fog_lut_offset.Assign(regs.fog_lut_offset + 1);
break;
}
default: default:
break; break;
} }

View file

@ -401,6 +401,16 @@ struct Regs {
TevStageConfig tev_stage3; TevStageConfig tev_stage3;
INSERT_PADDING_WORDS(0x3); INSERT_PADDING_WORDS(0x3);
enum class FogMode : u32 {
None = 0,
Fog = 5,
Gas = 7,
};
union {
BitField<0, 3, FogMode> fog_mode;
BitField<16, 1, u32> fog_flip;
union { union {
// Tev stages 0-3 write their output to the combiner buffer if the corresponding bit in // Tev stages 0-3 write their output to the combiner buffer if the corresponding bit in
// these masks are set // these masks are set
@ -415,8 +425,23 @@ struct Regs {
return (stage_index < 4) && (update_mask_a & (1 << stage_index)); return (stage_index < 4) && (update_mask_a & (1 << stage_index));
} }
} tev_combiner_buffer_input; } tev_combiner_buffer_input;
};
union {
u32 raw;
BitField< 0, 8, u32> r;
BitField< 8, 8, u32> g;
BitField<16, 8, u32> b;
} fog_color;
INSERT_PADDING_WORDS(0x4);
BitField<0, 16, u32> fog_lut_offset;
INSERT_PADDING_WORDS(0x1);
u32 fog_lut_data[8];
INSERT_PADDING_WORDS(0xf);
TevStageConfig tev_stage4; TevStageConfig tev_stage4;
INSERT_PADDING_WORDS(0x3); INSERT_PADDING_WORDS(0x3);
TevStageConfig tev_stage5; TevStageConfig tev_stage5;
@ -1318,6 +1343,10 @@ ASSERT_REG_POSITION(tev_stage1, 0xc8);
ASSERT_REG_POSITION(tev_stage2, 0xd0); ASSERT_REG_POSITION(tev_stage2, 0xd0);
ASSERT_REG_POSITION(tev_stage3, 0xd8); ASSERT_REG_POSITION(tev_stage3, 0xd8);
ASSERT_REG_POSITION(tev_combiner_buffer_input, 0xe0); ASSERT_REG_POSITION(tev_combiner_buffer_input, 0xe0);
ASSERT_REG_POSITION(fog_mode, 0xe0);
ASSERT_REG_POSITION(fog_color, 0xe1);
ASSERT_REG_POSITION(fog_lut_offset, 0xe6);
ASSERT_REG_POSITION(fog_lut_data, 0xe8);
ASSERT_REG_POSITION(tev_stage4, 0xf0); ASSERT_REG_POSITION(tev_stage4, 0xf0);
ASSERT_REG_POSITION(tev_stage5, 0xf8); ASSERT_REG_POSITION(tev_stage5, 0xf8);
ASSERT_REG_POSITION(tev_combiner_buffer_color, 0xfd); ASSERT_REG_POSITION(tev_combiner_buffer_color, 0xfd);

View file

@ -33,10 +33,10 @@ struct State {
u32 raw; u32 raw;
// LUT value, encoded as 12-bit fixed point, with 12 fraction bits // LUT value, encoded as 12-bit fixed point, with 12 fraction bits
BitField< 0, 12, u32> value; BitField< 0, 12, u32> value; // 0.0.12 fixed point
// Used by HW for efficient interpolation, Citra does not use these // Used by HW for efficient interpolation, Citra does not use these
BitField<12, 12, u32> difference; BitField<12, 12, s32> difference; // 1.0.11 fixed point
float ToFloat() { float ToFloat() {
return static_cast<float>(value) / 4095.f; return static_cast<float>(value) / 4095.f;
@ -46,6 +46,18 @@ struct State {
std::array<std::array<LutEntry, 256>, 24> luts; std::array<std::array<LutEntry, 256>, 24> luts;
} lighting; } lighting;
struct {
union LutEntry {
// Used for raw access
u32 raw;
BitField< 0, 13, s32> difference; // 1.1.11 fixed point
BitField<13, 11, u32> value; // 0.0.11 fixed point
};
std::array<LutEntry, 128> lut;
} fog;
/// Current Pica command list /// Current Pica command list
struct { struct {
const u32* head_ptr; const u32* head_ptr;