Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GS: Triangle/sprite edge rasterzation to find UV range for draw in SW renderer. #12192

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 30 additions & 0 deletions pcsx2-gsrunner/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
#include "pcsx2/VMManager.h"

#include "svnrev.h"
#include "debug.h"
#if MY_DEBUG == 1
#include <cstdlib>
extern bool savePoints;
extern bool dumpAll;
extern std::string debugDumpDir;
#endif

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

#if MY_DEBUG == 1
if (dumpAll)
{
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", debugDumpDir.c_str());
si.SetStringValue("EmuCore/GS", "SWDumpDirectory", debugDumpDir.c_str());
}
std::string x = "as" "db";
#endif
VMManager::Internal::LoadStartupSettings();
return true;
}
Expand Down Expand Up @@ -857,8 +879,16 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
return DefWindowProcW(hwnd, msg, wParam, lParam);
}

#if MY_DEBUG == 1
extern void dumpRanges();
#endif

int wmain(int argc, wchar_t** argv)
{
#if MY_DEBUG == 1
if (savePoints)
atexit(dumpRanges);
#endif
std::vector<std::string> u8_args;
u8_args.reserve(static_cast<size_t>(argc));
for (int i = 0; i < argc; i++)
Expand Down
18 changes: 10 additions & 8 deletions pcsx2/GS/GSDrawingContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
#include "GS/GSGL.h"
#include "GS/GS.h"
#include "GS/GSUtil.h"
#include "GS/GSState.h"


// FIXME: RENAME THIS FUNCTION AND CHANGE ARGS NAMES TO BE NICER!
// MAKE SURE BEING CALLED WITH ARGS IN THE RIGHT ORDER!
static int findmax(int tl, int br, int limit, int wm, int minuv, int maxuv)
{
// return max possible texcoord.
Expand Down Expand Up @@ -38,10 +42,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(maxuv, minuv, tl, br, &ignore, &uv);
}

return uv;
Expand Down Expand Up @@ -130,18 +132,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
Loading