Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #10549 from Pokechu22/sw-tev-enum-map
Refactor various bits of graphics code for readability
  • Loading branch information
Pokechu22 committed Sep 8, 2022
2 parents 74851fe + 698def6 commit 2dfe913
Show file tree
Hide file tree
Showing 13 changed files with 517 additions and 470 deletions.
2 changes: 1 addition & 1 deletion Source/Core/Common/EnumMap.h
Expand Up @@ -58,7 +58,7 @@ class EnumMap final
constexpr V& operator[](BitField<position, bits, T, StorageType> key)
{
static_assert(1 << bits == s_size, "Unsafe indexing into EnumMap (may go out of bounds)");
return m_array[static_cast<std::size_t>(key.value())];
return m_array[static_cast<std::size_t>(key.Value())];
}

constexpr bool InBounds(T key) const { return static_cast<std::size_t>(key) < s_size; }
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/FIFO/FIFOAnalyzer.cpp
Expand Up @@ -224,7 +224,7 @@ class DetailCallback : public OpcodeDecoder::Callback
const auto [name, desc] = GetXFTransferInfo(address, count, data);
ASSERT(!name.empty());

const u32 command = address | (count << 16);
const u32 command = address | ((count - 1) << 16);

text = QStringLiteral("XF %1 ").arg(command, 8, 16, QLatin1Char('0'));

Expand Down
13 changes: 4 additions & 9 deletions Source/Core/VideoBackends/Software/Rasterizer.cpp
Expand Up @@ -108,8 +108,6 @@ static std::vector<BPFunctions::ScissorRect> scissors;

void Init()
{
tev.Init();

// The other slopes are set each for each primitive drawn, but zfreeze means that the z slope
// needs to be set to an (untested) default value.
ZSlope = Slope();
Expand Down Expand Up @@ -142,9 +140,9 @@ static inline int iround(float x)
return t;
}

void SetTevReg(int reg, int comp, s16 color)
void SetTevKonstColors()
{
tev.SetRegColor(reg, comp, color);
tev.SetKonstColors();
}

static void Draw(s32 x, s32 y, s32 xi, s32 yi)
Expand Down Expand Up @@ -288,13 +286,10 @@ static void BuildBlock(s32 blockX, s32 blockY)
}
}

u32 indref = bpmem.tevindref.hex;
for (unsigned int i = 0; i < bpmem.genMode.numindstages; i++)
{
u32 texmap = indref & 7;
indref >>= 3;
u32 texcoord = indref & 7;
indref >>= 3;
u32 texmap = bpmem.tevindref.getTexMap(i);
u32 texcoord = bpmem.tevindref.getTexCoord(i);

CalculateLOD(&rasterBlock.IndirectLod[i], &rasterBlock.IndirectLinear[i], texmap, texcoord);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/Software/Rasterizer.h
Expand Up @@ -17,7 +17,7 @@ void UpdateZSlope(const OutputVertexData* v0, const OutputVertexData* v1,
void DrawTriangleFrontFace(const OutputVertexData* v0, const OutputVertexData* v1,
const OutputVertexData* v2);

void SetTevReg(int reg, int comp, s16 color);
void SetTevKonstColors();

struct RasterBlockPixel
{
Expand Down
10 changes: 1 addition & 9 deletions Source/Core/VideoBackends/Software/SWVertexLoader.cpp
Expand Up @@ -67,15 +67,7 @@ void SWVertexLoader::DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_
g_renderer->BBoxFlush();

m_setup_unit.Init(primitive_type);

// set all states with are stored within video sw
for (int i = 0; i < 4; i++)
{
Rasterizer::SetTevReg(i, Tev::RED_C, PixelShaderManager::constants.kcolors[i][0]);
Rasterizer::SetTevReg(i, Tev::GRN_C, PixelShaderManager::constants.kcolors[i][1]);
Rasterizer::SetTevReg(i, Tev::BLU_C, PixelShaderManager::constants.kcolors[i][2]);
Rasterizer::SetTevReg(i, Tev::ALP_C, PixelShaderManager::constants.kcolors[i][3]);
}
Rasterizer::SetTevKonstColors();

for (u32 i = 0; i < m_index_generator.GetIndexLen(); i++)
{
Expand Down

0 comments on commit 2dfe913

Please sign in to comment.