add --disable-cache option

This commit is contained in:
DH 2024-10-22 19:41:30 +03:00
parent 6a2507c777
commit fc12bee2cb
4 changed files with 23 additions and 10 deletions

View file

@ -5,6 +5,8 @@ namespace rx {
struct Config {
int gpuIndex = 0;
bool validateGpu = false;
bool disableGpuCache = false;
bool debugGpu = false;
};
extern Config g_config;

View file

@ -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>
@ -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;
@ -39,7 +38,7 @@ static void runGPU() {
auto childPid = ::fork();
if (kDebugGpu) {
if (rx::g_config.debugGpu) {
if (childPid == 0) {
return;
}
@ -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);
@ -166,7 +165,7 @@ void rx::startWatchdog() {
pid_t initProcessPid = fork();
if (kDebugGpu) {
if (rx::g_config.debugGpu) {
if (initProcessPid == 0) {
initProcessPid = watchdogPid;
} else {

View file

@ -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"
@ -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;
@ -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) {
@ -779,7 +778,7 @@ struct CachedImageBuffer : Cache::Entry {
unsigned depth = 1;
bool expensive() {
if (kDisableCache) {
if (rx::g_config.disableGpuCache) {
return false;
}
@ -954,7 +953,7 @@ struct CachedImage : Cache::Entry {
bool expensive() {
return false;
if (kDisableCache) {
if (rx::g_config.disableGpuCache) {
return false;
}

View file

@ -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");
}
@ -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]);