mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Split FindOrCreate
functionality across BufferManager
`FindOrCreate` ended up being monolithic function with poor readability, this commit addresses those concerns by refactoring the function to split it up into multiple member functions of `BufferManager`, while some of these member functions may only have a single call-site they are important to logically categorize tasks into individual functions. The end result is far neater logic which is far more readable and slightly better optimized by virtue of being abstracted better.
This commit is contained in:
@ -33,6 +33,44 @@ namespace skyline::gpu {
|
||||
MegaBufferSlot(GPU &gpu);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A wrapper around a Buffer which locks it with the specified ContextTag
|
||||
*/
|
||||
struct LockedBuffer {
|
||||
std::shared_ptr<Buffer> buffer;
|
||||
ContextLock<Buffer> lock;
|
||||
|
||||
LockedBuffer(std::shared_ptr<Buffer> pBuffer, ContextTag tag);
|
||||
|
||||
Buffer *operator->() const;
|
||||
|
||||
std::shared_ptr<Buffer> &operator*();
|
||||
};
|
||||
|
||||
using LockedBuffers = boost::container::small_vector<LockedBuffer, 4>;
|
||||
|
||||
/**
|
||||
* @return A vector of buffers locked with the supplied tag which are contained within the supplied range
|
||||
*/
|
||||
LockedBuffers Lookup(span<u8> range, ContextTag tag);
|
||||
|
||||
/**
|
||||
* @brief Inserts the supplied buffer into the map based on its guest address
|
||||
*/
|
||||
void InsertBuffer(std::shared_ptr<Buffer> buffer);
|
||||
|
||||
/**
|
||||
* @brief Deletes the supplied buffer from the map, the lifetime of the buffer will no longer be extended by the map
|
||||
*/
|
||||
void DeleteBuffer(const std::shared_ptr<Buffer> &buffer);
|
||||
|
||||
/**
|
||||
* @brief Coalesce the supplied buffers into a single buffer encompassing the specified range and locks it with the supplied tag
|
||||
* @param range The range of memory that the newly created buffer will cover, this will be extended to cover the entirety of the supplied buffers automatically and can be null
|
||||
* @note The supplied buffers **must** be in the map and locked with the supplied tag
|
||||
*/
|
||||
LockedBuffer CoalesceBuffers(span<u8> range, const LockedBuffers &srcBuffers, ContextTag tag);
|
||||
|
||||
/**
|
||||
* @return If the end of the supplied buffer is less than the supplied pointer
|
||||
*/
|
||||
|
Reference in New Issue
Block a user