mirror of
https://github.com/Takiiiiiiii/strato.git
synced 2025-07-17 08:46:39 +00:00
Implement CPU-only Maxwell3D Inline Constant Buffer Updates
Implements inline constant buffer updates that are written to the CPU copy of the buffer rather than generating an actual inline buffer write, this works for TIC/TSC index updates but won't work when the buffer is expected to actually be updated inline with regard to sequence rather than just as a buffer upload prior to rendering. GPU-sided constant buffer updates will be implemented later with optimizations for updating an entire range by handling GPFIFO `Inc`/`NonInc`directly and submitting it as a host inline buffer update.
This commit is contained in:
@ -543,9 +543,33 @@ namespace skyline::gpu::interconnect {
|
||||
}
|
||||
throw exception("Object extent ({} + {} = {}) is larger than constant buffer size: {}", size + offset, sizeof(T), size + offset + sizeof(T), size);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Writes an object to the supplied offset in the constant buffer
|
||||
* @note This must only be called when the GuestBuffer is resolved correctly
|
||||
*/
|
||||
template<typename T>
|
||||
void Write(const T &object, size_t offset) {
|
||||
size_t objectOffset{};
|
||||
for (auto &mapping: guest.mappings) {
|
||||
if (offset < mapping.size_bytes()) {
|
||||
auto copySize{std::min(mapping.size_bytes() - offset, sizeof(T))};
|
||||
std::memcpy(mapping.data() + offset, reinterpret_cast<const u8 *>(&object) + objectOffset, copySize);
|
||||
objectOffset += copySize;
|
||||
if (objectOffset == sizeof(T))
|
||||
return;
|
||||
offset = mapping.size_bytes();
|
||||
} else {
|
||||
offset -= mapping.size_bytes();
|
||||
}
|
||||
}
|
||||
throw exception("Object extent ({} + {} = {}) is larger than constant buffer size: {}", size + offset, sizeof(T), size + offset + sizeof(T), size);
|
||||
}
|
||||
};
|
||||
ConstantBuffer constantBufferSelector; //!< The constant buffer selector is used to bind a constant buffer to a stage or update data in it
|
||||
|
||||
u32 constantBufferUpdateOffset{}; //!< The offset at which any inline constant buffer updata data is written
|
||||
|
||||
public:
|
||||
void SetConstantBufferSelectorSize(u32 size) {
|
||||
constantBufferSelector.size = size;
|
||||
@ -575,6 +599,15 @@ namespace skyline::gpu::interconnect {
|
||||
return constantBufferSelector;
|
||||
}
|
||||
|
||||
void SetConstantBufferUpdateOffset(u32 offset) {
|
||||
constantBufferUpdateOffset = offset;
|
||||
}
|
||||
|
||||
void ConstantBufferUpdate(u32 data) {
|
||||
auto constantBuffer{GetConstantBufferSelector().value()};
|
||||
constantBuffer.Write(data, constantBufferUpdateOffset);
|
||||
}
|
||||
|
||||
/* Shader Program */
|
||||
private:
|
||||
struct Shader {
|
||||
|
Reference in New Issue
Block a user