Implement Maxwell3D Constant Buffer Selector

The Constant Buffer Selector is used to point to a constant buffer that will be bound to a shader stage or updated with inline data.
This commit is contained in:
PixelyIon
2021-12-11 12:57:30 +05:30
parent afa34e320a
commit 9af9f1d41a
3 changed files with 61 additions and 0 deletions

View File

@ -511,6 +511,47 @@ namespace skyline::gpu::interconnect {
}
}
/* Constant Buffers */
private:
struct ConstantBuffer {
IOVA iova;
u32 size;
GuestBuffer guest;
std::shared_ptr<BufferView> view;
};
ConstantBuffer constantBufferSelector; //!< The constant buffer selector is used to bind a constant buffer to a stage or update data in it
public:
void SetConstantBufferSelectorSize(u32 size) {
constantBufferSelector.size = size;
constantBufferSelector.view.reset();
}
void SetConstantBufferSelectorIovaHigh(u32 high) {
constantBufferSelector.iova.high = high;
constantBufferSelector.view.reset();
}
void SetConstantBufferSelectorIovaLow(u32 low) {
constantBufferSelector.iova.low = low;
constantBufferSelector.view.reset();
}
BufferView *GetConstantBufferSelectorView() {
if (constantBufferSelector.size == 0)
return nullptr;
else if (constantBufferSelector.view)
return &*constantBufferSelector.view;
if (constantBufferSelector.guest.mappings.empty()) {
auto mappings{channelCtx.asCtx->gmmu.TranslateRange(constantBufferSelector.iova, constantBufferSelector.size)};
constantBufferSelector.guest.mappings.assign(mappings.begin(), mappings.end());
}
constantBufferSelector.view = gpu.buffer.FindOrCreate(constantBufferSelector.guest);
return constantBufferSelector.view.get();
}
/* Shader Program */
private:
struct Shader {