mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
Added amdgpu hw project
This commit is contained in:
parent
1fdadaaee9
commit
a8af9198bf
49 changed files with 28342 additions and 1 deletions
12
hw/amdgpu/include/amdgpu/RemoteMemory.hpp
Normal file
12
hw/amdgpu/include/amdgpu/RemoteMemory.hpp
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
#pragma once
|
||||
#include <cstdint>
|
||||
|
||||
namespace amdgpu {
|
||||
struct RemoteMemory {
|
||||
char *shmPointer;
|
||||
|
||||
template <typename T = void> T *getPointer(std::uint64_t address) const {
|
||||
return address ? reinterpret_cast<T *>(shmPointer + address) : nullptr;
|
||||
}
|
||||
};
|
||||
} // namespace amdgpu
|
||||
31
hw/amdgpu/include/util/SourceLocation.hpp
Normal file
31
hw/amdgpu/include/util/SourceLocation.hpp
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
#pragma once
|
||||
|
||||
namespace util {
|
||||
class SourceLocation {
|
||||
public:
|
||||
const char *mFileName = {};
|
||||
const char *mFunctionName = {};
|
||||
unsigned mLine = 0;
|
||||
unsigned mColumn = 0;
|
||||
|
||||
public:
|
||||
constexpr SourceLocation(const char *fileName = __builtin_FILE(),
|
||||
const char *functionName = __builtin_FUNCTION(),
|
||||
unsigned line = __builtin_LINE(),
|
||||
unsigned column =
|
||||
#if __has_builtin(__builtin_COLUMN)
|
||||
__builtin_COLUMN()
|
||||
#else
|
||||
0
|
||||
#endif
|
||||
) noexcept
|
||||
: mFileName(fileName), mFunctionName(functionName), mLine(line),
|
||||
mColumn(column) {
|
||||
}
|
||||
|
||||
constexpr unsigned line() const noexcept { return mLine; }
|
||||
constexpr unsigned column() const noexcept { return mColumn; }
|
||||
constexpr const char *file_name() const noexcept { return mFileName; }
|
||||
constexpr const char *function_name() const noexcept { return mFunctionName; }
|
||||
};
|
||||
} // namespace util
|
||||
26
hw/amdgpu/include/util/Verify.hpp
Normal file
26
hw/amdgpu/include/util/Verify.hpp
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
|
||||
#include "SourceLocation.hpp"
|
||||
#include "unreachable.hpp"
|
||||
|
||||
class Verify {
|
||||
util::SourceLocation mLocation;
|
||||
|
||||
public:
|
||||
util::SourceLocation location() const {
|
||||
return mLocation;
|
||||
}
|
||||
|
||||
Verify(util::SourceLocation location = util::SourceLocation())
|
||||
: mLocation(location) {}
|
||||
|
||||
Verify &operator<<(bool result) {
|
||||
if (!result) {
|
||||
util::unreachable("Verification failed at %s: %s:%u:%u",
|
||||
mLocation.function_name(), mLocation.file_name(),
|
||||
mLocation.line(), mLocation.column());
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
29
hw/amdgpu/include/util/unreachable.hpp
Normal file
29
hw/amdgpu/include/util/unreachable.hpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include "SourceLocation.hpp"
|
||||
#include <cstdio>
|
||||
#include <cstdarg>
|
||||
|
||||
namespace util {
|
||||
[[noreturn]] inline void unreachable_impl() { std::fflush(stdout); __builtin_trap(); }
|
||||
|
||||
[[noreturn]] inline void unreachable(SourceLocation location = {}) {
|
||||
std::printf("\n");
|
||||
std::fflush(stdout);
|
||||
std::fprintf(stderr, "Unreachable at %s:%u:%u %s\n", location.file_name(),
|
||||
location.line(), location.column(), location.function_name());
|
||||
unreachable_impl();
|
||||
}
|
||||
|
||||
[[noreturn]] inline void unreachable(const char *fmt, ...) {
|
||||
std::printf("\n");
|
||||
std::fflush(stdout);
|
||||
va_list list;
|
||||
va_start(list, fmt);
|
||||
std::vfprintf(stderr, fmt, list);
|
||||
va_end(list);
|
||||
std::fprintf(stderr, "\n");
|
||||
|
||||
unreachable_impl();
|
||||
}
|
||||
} // namespace util
|
||||
Loading…
Add table
Add a link
Reference in a new issue