2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2021-07-04 19:22:19 -06:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2008-12-07 22:30:24 -07:00
|
|
|
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/CPMemory.h"
|
2014-08-27 11:26:06 -06:00
|
|
|
#include "Common/ChunkFile.h"
|
2008-12-07 22:30:24 -07:00
|
|
|
|
|
|
|
// CP state
|
2014-08-27 11:26:06 -06:00
|
|
|
CPState g_main_cp_state;
|
2014-08-27 11:38:00 -06:00
|
|
|
CPState g_preprocess_cp_state;
|
2014-08-27 11:26:06 -06:00
|
|
|
|
|
|
|
void DoCPState(PointerWrap& p)
|
|
|
|
{
|
2014-08-27 11:38:00 -06:00
|
|
|
// We don't save g_preprocess_cp_state separately because the GPU should be
|
|
|
|
// synced around state save/load.
|
2015-09-29 10:35:30 -06:00
|
|
|
p.DoArray(g_main_cp_state.array_bases);
|
|
|
|
p.DoArray(g_main_cp_state.array_strides);
|
2014-08-27 11:26:06 -06:00
|
|
|
p.Do(g_main_cp_state.matrix_index_a);
|
|
|
|
p.Do(g_main_cp_state.matrix_index_b);
|
2021-06-08 22:35:43 -06:00
|
|
|
p.Do(g_main_cp_state.vtx_desc);
|
2015-09-29 10:35:30 -06:00
|
|
|
p.DoArray(g_main_cp_state.vtx_attr);
|
2014-08-27 11:26:06 -06:00
|
|
|
p.DoMarker("CP Memory");
|
2014-08-27 11:38:00 -06:00
|
|
|
if (p.mode == PointerWrap::MODE_READ)
|
2015-05-29 09:58:27 -06:00
|
|
|
{
|
2014-08-27 11:38:00 -06:00
|
|
|
CopyPreprocessCPStateFromMain();
|
2015-05-29 09:58:27 -06:00
|
|
|
g_main_cp_state.bases_dirty = true;
|
|
|
|
}
|
2014-08-27 11:38:00 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
void CopyPreprocessCPStateFromMain()
|
|
|
|
{
|
2015-01-07 13:48:59 -07:00
|
|
|
memcpy(&g_preprocess_cp_state, &g_main_cp_state, sizeof(CPState));
|
2014-08-27 11:26:06 -06:00
|
|
|
}
|
2021-02-08 16:22:48 -07:00
|
|
|
|
|
|
|
std::pair<std::string, std::string> GetCPRegInfo(u8 cmd, u32 value)
|
|
|
|
{
|
|
|
|
switch (cmd & CP_COMMAND_MASK)
|
|
|
|
{
|
|
|
|
case MATINDEX_A:
|
|
|
|
return std::make_pair("MATINDEX_A", fmt::to_string(TMatrixIndexA{.Hex = value}));
|
|
|
|
case MATINDEX_B:
|
|
|
|
return std::make_pair("MATINDEX_B", fmt::to_string(TMatrixIndexB{.Hex = value}));
|
|
|
|
case VCD_LO:
|
|
|
|
return std::make_pair("VCD_LO", fmt::to_string(TVtxDesc::Low{.Hex = value}));
|
|
|
|
case VCD_HI:
|
|
|
|
return std::make_pair("VCD_HI", fmt::to_string(TVtxDesc::High{.Hex = value}));
|
|
|
|
case CP_VAT_REG_A:
|
|
|
|
if (cmd - CP_VAT_REG_A >= CP_NUM_VAT_REG)
|
|
|
|
return std::make_pair("CP_VAT_REG_A invalid", "");
|
|
|
|
|
|
|
|
return std::make_pair(fmt::format("CP_VAT_REG_A - Format {}", cmd & CP_VAT_MASK),
|
|
|
|
fmt::to_string(UVAT_group0{.Hex = value}));
|
|
|
|
case CP_VAT_REG_B:
|
|
|
|
if (cmd - CP_VAT_REG_B >= CP_NUM_VAT_REG)
|
|
|
|
return std::make_pair("CP_VAT_REG_B invalid", "");
|
|
|
|
|
|
|
|
return std::make_pair(fmt::format("CP_VAT_REG_B - Format {}", cmd & CP_VAT_MASK),
|
|
|
|
fmt::to_string(UVAT_group1{.Hex = value}));
|
|
|
|
case CP_VAT_REG_C:
|
|
|
|
if (cmd - CP_VAT_REG_C >= CP_NUM_VAT_REG)
|
|
|
|
return std::make_pair("CP_VAT_REG_C invalid", "");
|
|
|
|
|
|
|
|
return std::make_pair(fmt::format("CP_VAT_REG_C - Format {}", cmd & CP_VAT_MASK),
|
|
|
|
fmt::to_string(UVAT_group2{.Hex = value}));
|
|
|
|
case ARRAY_BASE:
|
|
|
|
return std::make_pair(fmt::format("ARRAY_BASE Array {}", cmd & CP_ARRAY_MASK),
|
|
|
|
fmt::format("Base address {:08x}", value));
|
|
|
|
case ARRAY_STRIDE:
|
|
|
|
return std::make_pair(fmt::format("ARRAY_STRIDE Array {}", cmd - ARRAY_STRIDE),
|
|
|
|
fmt::format("Stride {:02x}", value & 0xff));
|
|
|
|
default:
|
|
|
|
return std::make_pair(fmt::format("Invalid CP register {:02x} = {:08x}", cmd, value), "");
|
|
|
|
}
|
|
|
|
}
|