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 { struct Config {
int gpuIndex = 0; int gpuIndex = 0;
bool validateGpu = false; bool validateGpu = false;
bool disableGpuCache = false;
bool debugGpu = false;
}; };
extern Config g_config; extern Config g_config;

View file

@ -1,6 +1,7 @@
#include "rx/watchdog.hpp" #include "rx/watchdog.hpp"
#include "gpu/DeviceCtl.hpp" #include "gpu/DeviceCtl.hpp"
#include "orbis/KernelContext.hpp" #include "orbis/KernelContext.hpp"
#include "rx/Config.hpp"
#include <bit> #include <bit>
#include <chrono> #include <chrono>
#include <csignal> #include <csignal>
@ -18,8 +19,6 @@
#include <unistd.h> #include <unistd.h>
#include <utility> #include <utility>
static constexpr bool kDebugGpu = false;
static std::atomic<bool> g_exitRequested; static std::atomic<bool> g_exitRequested;
static std::atomic<bool> g_runGpuRequested; static std::atomic<bool> g_runGpuRequested;
static pid_t g_watchdogPid; static pid_t g_watchdogPid;
@ -39,7 +38,7 @@ static void runGPU() {
auto childPid = ::fork(); auto childPid = ::fork();
if (kDebugGpu) { if (rx::g_config.debugGpu) {
if (childPid == 0) { if (childPid == 0) {
return; return;
} }
@ -113,7 +112,7 @@ std::filesystem::path rx::getShmGuestPath(std::string_view path) {
} }
void rx::createGpuDevice() { void rx::createGpuDevice() {
if (kDebugGpu) { if (rx::g_config.debugGpu) {
runGPU(); runGPU();
} else { } else {
sendMessage(MessageId::RunGPU, 0); sendMessage(MessageId::RunGPU, 0);
@ -166,7 +165,7 @@ void rx::startWatchdog() {
pid_t initProcessPid = fork(); pid_t initProcessPid = fork();
if (kDebugGpu) { if (rx::g_config.debugGpu) {
if (initProcessPid == 0) { if (initProcessPid == 0) {
initProcessPid = watchdogPid; initProcessPid = watchdogPid;
} else { } else {

View file

@ -2,6 +2,7 @@
#include "Device.hpp" #include "Device.hpp"
#include "amdgpu/tiler.hpp" #include "amdgpu/tiler.hpp"
#include "gnm/vulkan.hpp" #include "gnm/vulkan.hpp"
#include "rx/Config.hpp"
#include "rx/hexdump.hpp" #include "rx/hexdump.hpp"
#include "rx/mem.hpp" #include "rx/mem.hpp"
#include "shader/Evaluator.hpp" #include "shader/Evaluator.hpp"
@ -24,8 +25,6 @@
using namespace amdgpu; using namespace amdgpu;
using namespace shader; using namespace shader;
static constexpr bool kDisableCache = false;
static bool testHostInvalidations(Device *device, int vmId, static bool testHostInvalidations(Device *device, int vmId,
std::uint64_t address, std::uint64_t size) { std::uint64_t address, std::uint64_t size) {
auto firstPage = address / rx::mem::pageSize; auto firstPage = address / rx::mem::pageSize;
@ -703,7 +702,7 @@ struct CachedHostVisibleBuffer : CachedBuffer {
using CachedBuffer::update; using CachedBuffer::update;
bool expensive() { 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) { bool flush(void *target, rx::AddressRange range) {
@ -779,7 +778,7 @@ struct CachedImageBuffer : Cache::Entry {
unsigned depth = 1; unsigned depth = 1;
bool expensive() { bool expensive() {
if (kDisableCache) { if (rx::g_config.disableGpuCache) {
return false; return false;
} }
@ -954,7 +953,7 @@ struct CachedImage : Cache::Entry {
bool expensive() { bool expensive() {
return false; return false;
if (kDisableCache) { if (rx::g_config.disableGpuCache) {
return false; return false;
} }

View file

@ -688,6 +688,7 @@ static void usage(const char *argv0) {
std::println(" --fw <path to firmware root>"); std::println(" --fw <path to firmware root>");
std::println( std::println(
" --gpu <index> - specify physical gpu index to use, default is 0"); " --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(" --presenter <window>");
std::println(" --trace"); std::println(" --trace");
} }
@ -912,6 +913,18 @@ int main(int argc, const char *argv[]) {
continue; 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 (argv[argIndex] == std::string_view("--gpu")) {
if (argc <= argIndex + 1) { if (argc <= argIndex + 1) {
usage(argv[0]); usage(argv[0]);