Skip to content

Commit

Permalink
add --disable-cache option
Browse files Browse the repository at this point in the history
  • Loading branch information
DHrpcs3 committed Oct 22, 2024
1 parent 6a2507c commit fc12bee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
2 changes: 2 additions & 0 deletions rpcsx/core/include/rx/Config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace rx {
struct Config {
int gpuIndex = 0;
bool validateGpu = false;
bool disableGpuCache = false;
bool debugGpu = false;
};

extern Config g_config;
Expand Down
9 changes: 4 additions & 5 deletions rpcsx/core/src/watchdog.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "rx/watchdog.hpp"
#include "gpu/DeviceCtl.hpp"
#include "orbis/KernelContext.hpp"
#include "rx/Config.hpp"
#include <bit>
#include <chrono>
#include <csignal>
Expand All @@ -18,8 +19,6 @@
#include <unistd.h>
#include <utility>

static constexpr bool kDebugGpu = false;

static std::atomic<bool> g_exitRequested;
static std::atomic<bool> g_runGpuRequested;
static pid_t g_watchdogPid;
Expand All @@ -39,7 +38,7 @@ static void runGPU() {

auto childPid = ::fork();

if (kDebugGpu) {
if (rx::g_config.debugGpu) {
if (childPid == 0) {
return;
}
Expand Down Expand Up @@ -113,7 +112,7 @@ std::filesystem::path rx::getShmGuestPath(std::string_view path) {
}

void rx::createGpuDevice() {
if (kDebugGpu) {
if (rx::g_config.debugGpu) {
runGPU();
} else {
sendMessage(MessageId::RunGPU, 0);
Expand Down Expand Up @@ -166,7 +165,7 @@ void rx::startWatchdog() {

pid_t initProcessPid = fork();

if (kDebugGpu) {
if (rx::g_config.debugGpu) {
if (initProcessPid == 0) {
initProcessPid = watchdogPid;
} else {
Expand Down
9 changes: 4 additions & 5 deletions rpcsx/gpu/Cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Device.hpp"
#include "amdgpu/tiler.hpp"
#include "gnm/vulkan.hpp"
#include "rx/Config.hpp"
#include "rx/hexdump.hpp"
#include "rx/mem.hpp"
#include "shader/Evaluator.hpp"
Expand All @@ -24,8 +25,6 @@
using namespace amdgpu;
using namespace shader;

static constexpr bool kDisableCache = false;

static bool testHostInvalidations(Device *device, int vmId,
std::uint64_t address, std::uint64_t size) {
auto firstPage = address / rx::mem::pageSize;
Expand Down Expand Up @@ -703,7 +702,7 @@ struct CachedHostVisibleBuffer : CachedBuffer {
using CachedBuffer::update;

bool expensive() {
return !kDisableCache && addressRange.size() >= rx::mem::pageSize;
return !rx::g_config.disableGpuCache && addressRange.size() >= rx::mem::pageSize;
}

bool flush(void *target, rx::AddressRange range) {
Expand Down Expand Up @@ -779,7 +778,7 @@ struct CachedImageBuffer : Cache::Entry {
unsigned depth = 1;

bool expensive() {
if (kDisableCache) {
if (rx::g_config.disableGpuCache) {
return false;
}

Expand Down Expand Up @@ -954,7 +953,7 @@ struct CachedImage : Cache::Entry {

bool expensive() {
return false;
if (kDisableCache) {
if (rx::g_config.disableGpuCache) {
return false;
}

Expand Down
13 changes: 13 additions & 0 deletions rpcsx/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ static void usage(const char *argv0) {
std::println(" --fw <path to firmware root>");
std::println(
" --gpu <index> - specify physical gpu index to use, default is 0");
std::println(" --disable-cache - disable cache of gpu resources");
// std::println(" --presenter <window>");
std::println(" --trace");
}
Expand Down Expand Up @@ -912,6 +913,18 @@ int main(int argc, const char *argv[]) {
continue;
}

if (argv[argIndex] == std::string_view("--disable-cache")) {
argIndex++;
rx::g_config.disableGpuCache = true;
continue;
}

if (argv[argIndex] == std::string_view("--debug-gpu")) {
argIndex++;
rx::g_config.debugGpu = true;
continue;
}

if (argv[argIndex] == std::string_view("--gpu")) {
if (argc <= argIndex + 1) {
usage(argv[0]);
Expand Down

0 comments on commit fc12bee

Please sign in to comment.