Skip to content

Commit

Permalink
GS: UV calculation using triangle edge rasterization.
Browse files Browse the repository at this point in the history
  • Loading branch information
TJnotJT committed Jan 15, 2025
1 parent f509fb6 commit 1cd648d
Show file tree
Hide file tree
Showing 10 changed files with 963 additions and 47 deletions.
6 changes: 3 additions & 3 deletions common/vsprops/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@

<!-- MSVC automatically adds __AVX__ and __AVX2__ appropriately -->
<PreprocessorDefinitions Condition="'$(Platform)'=='x64'">_M_X86;__SSE4_1__;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<EnableEnhancedInstructionSet Condition="!$(Configuration.Contains(AVX2)) Or $(Configuration.Contains(Clang))">NotSet</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="$(Configuration.Contains(AVX2)) And !$(Configuration.Contains(Clang))">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='ARM64' Or !$(Configuration.Contains(AVX2))">NotSet</EnableEnhancedInstructionSet>
<EnableEnhancedInstructionSet Condition="'$(Platform)'=='x64' And $(Configuration.Contains(AVX2))">AdvancedVectorExtensions2</EnableEnhancedInstructionSet>
<!-- Allow SSE4 intrinsics on non-AVX Clang-cl builds -->
<AdditionalOptions Condition="'$(Platform)'=='x64' And $(Configuration.Contains(Clang)) And !$(Configuration.Contains(AVX2))"> -march=nehalem %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Platform)'=='x64' And $(Configuration.Contains(Clang)) And $(Configuration.Contains(AVX2))"> -march=haswell %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="'$(Platform)'=='ARM64' And $(Configuration.Contains(Clang))"> -march=armv8.4-a %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions Condition="!$(Configuration.Contains(Clang))">%(AdditionalOptions) /Zc:externConstexpr /Zc:__cplusplus /Zo /utf-8</AdditionalOptions>

Expand Down
22 changes: 22 additions & 0 deletions pcsx2-gsrunner/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@

#include "svnrev.h"

// TODO: REMOVE DEBUG CODE
#include <cstdlib>

namespace GSRunner
{
static void InitializeConsole();
Expand Down Expand Up @@ -141,6 +144,19 @@ bool GSRunner::InitializeConfig()
si.SetStringValue("MemoryCards", fmt::format("Slot{}_Filename", i + 1).c_str(), "");
}

// TODO: REMOVE DEBUG CODE
// if (true)
// {
// si.SetBoolValue("EmuCore/GS", "dump", true);
// si.SetIntValue("EmuCore/GS", "saven", 0);
// si.SetIntValue("EmuCore/GS", "savel", 100);
// si.SetBoolValue("EmuCore/GS", "save", true);
// si.SetBoolValue("EmuCore/GS", "savef", true);
// si.SetBoolValue("EmuCore/GS", "savet", true);
// si.SetBoolValue("EmuCore/GS", "savez", true);
// si.SetStringValue("EmuCore/GS", "HWDumpDirectory", "C:\\Users\\XXX\\Desktop\\ps2_debug");
// si.SetStringValue("EmuCore/GS", "SWDumpDirectory", "C:\\Users\\XXX\\Desktop\\ps2_debug");
// }
VMManager::Internal::LoadStartupSettings();
return true;
}
Expand Down Expand Up @@ -857,8 +873,14 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return DefWindowProcW(hwnd, msg, wParam, lParam);
}

// TODO: REMOVE DEBUG CODE
extern void dumpRanges();

int wmain(int argc, wchar_t** argv)
{
// TODO: REMOVE DEBUG CODE
//atexit(dumpRanges);

std::vector<std::string> u8_args;
u8_args.reserve(static_cast<size_t>(argc));
for (int i = 0; i < argc; i++)
Expand Down
15 changes: 7 additions & 8 deletions pcsx2/GS/GSDrawingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "GS/GSGL.h"
#include "GS/GS.h"
#include "GS/GSUtil.h"
#include "GS/GSState.h"

static int findmax(int tl, int br, int limit, int wm, int minuv, int maxuv)
{
Expand Down Expand Up @@ -38,10 +39,8 @@ static int findmax(int tl, int br, int limit, int wm, int minuv, int maxuv)
{
// REGION_REPEAT adhears to the original texture size, even if offset outside the texture (with MAXUV).
minuv &= limit;
if (tl < 0)
uv = minuv | maxuv; // wrap around, just use (any & mask) | fix.
else
uv = std::min(uv, minuv) | maxuv; // (any & mask) cannot be larger than mask, select br if that is smaller (not br & mask because there might be a larger value between tl and br when &'ed with the mask).
int ignore;
GSState::UsesRegionRepeat(minuv, maxuv, tl, br, &ignore, &uv);
}

return uv;
Expand Down Expand Up @@ -130,18 +129,18 @@ GIFRegTEX0 GSDrawingContext::GetSizeFixedTEX0(const GSVector4& st, bool linear,

if (tw + th >= 19) // smaller sizes aren't worth, they just create multiple entries in the textue cache and the saved memory is less
{
tw = reduce(uv.x, tw);
th = reduce(uv.y, th);
tw = reduce(uv.x + 1, tw);
th = reduce(uv.y + 1, th);
}

if (wms == CLAMP_REGION_CLAMP || wms == CLAMP_REGION_REPEAT)
{
tw = extend(uv.x, tw);
tw = extend(uv.x + 1, tw);
}

if (wmt == CLAMP_REGION_CLAMP || wmt == CLAMP_REGION_REPEAT)
{
th = extend(uv.y, th);
th = extend(uv.y + 1, th);
}

GIFRegTEX0 res = TEX0;
Expand Down
Loading

0 comments on commit 1cd648d

Please sign in to comment.