Initial refactoring of gpu/.
Runs too fast - now there are ringbuffer wrapping issues.
This commit is contained in:
@@ -18,8 +18,82 @@ namespace xe {
|
||||
namespace gpu {
|
||||
|
||||
|
||||
struct MemoryRange {
|
||||
uint8_t* host_base;
|
||||
uint32_t guest_base;
|
||||
uint32_t length;
|
||||
|
||||
MemoryRange() : host_base(nullptr), guest_base(0), length(0) {}
|
||||
MemoryRange(const MemoryRange& other)
|
||||
: host_base(other.host_base), guest_base(other.guest_base),
|
||||
length(other.length) {}
|
||||
MemoryRange(uint8_t* _host_base, uint32_t _guest_base, uint32_t _length)
|
||||
: host_base(_host_base), guest_base(_guest_base), length(_length) {}
|
||||
};
|
||||
|
||||
|
||||
class Resource {
|
||||
public:
|
||||
virtual ~Resource() = default;
|
||||
|
||||
virtual void* handle() const = 0;
|
||||
|
||||
template <typename T>
|
||||
T* handle_as() {
|
||||
return reinterpret_cast<T*>(handle());
|
||||
}
|
||||
|
||||
protected:
|
||||
Resource() = default;
|
||||
|
||||
// last use/LRU stuff
|
||||
};
|
||||
|
||||
|
||||
class HashedResource : public Resource {
|
||||
public:
|
||||
~HashedResource() override;
|
||||
|
||||
const MemoryRange& memory_range() const { return memory_range_; }
|
||||
|
||||
protected:
|
||||
HashedResource(const MemoryRange& memory_range);
|
||||
|
||||
MemoryRange memory_range_;
|
||||
// key
|
||||
};
|
||||
|
||||
|
||||
class PagedResource : public Resource {
|
||||
public:
|
||||
~PagedResource() override;
|
||||
|
||||
const MemoryRange& memory_range() const { return memory_range_; }
|
||||
|
||||
template <typename T>
|
||||
bool Equals(const T& info) {
|
||||
return Equals(&info, sizeof(info));
|
||||
}
|
||||
virtual bool Equals(const void* info_ptr, size_t info_length) = 0;
|
||||
|
||||
bool is_dirty() const { return dirtied_; }
|
||||
void MarkDirty(uint32_t lo_address, uint32_t hi_address);
|
||||
|
||||
protected:
|
||||
PagedResource(const MemoryRange& memory_range);
|
||||
|
||||
MemoryRange memory_range_;
|
||||
bool dirtied_;
|
||||
// dirtied pages list
|
||||
};
|
||||
|
||||
|
||||
class StaticResource : public Resource {
|
||||
public:
|
||||
~StaticResource() override;
|
||||
|
||||
protected:
|
||||
StaticResource();
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user