Expose way to check inter-pipeline descriptor compatibility

Allows users to skip/use quick descriptor sync even after switching pipelines.
This commit is contained in:
Billy Laws 2022-09-18 16:31:25 +01:00
parent 943a38e168
commit 3b26f4f48a
2 changed files with 31 additions and 0 deletions

View File

@ -561,6 +561,21 @@ namespace skyline::gpu::interconnect::maxwell3d {
transitionCacheNextIdx = (transitionCacheNextIdx + 1) % transitionCache.size();
}
bool Pipeline::CheckBindingMatch(Pipeline *other) {
if (auto it{bindingMatchCache.find(other)}; it != bindingMatchCache.end())
return it->second;
for (size_t i{}; i < shaderStages.size(); i++) {
if (!shaderStages[i].BindingsEqual(other->shaderStages[i])) {
bindingMatchCache[other] = false;
return false;
}
}
bindingMatchCache[other] = true;
return true;
}
static DynamicBufferBinding GetConstantBufferBinding(InterconnectContext &ctx, const Shader::Info &info, BufferView view, size_t idx) {
ctx.executor.AttachBuffer(view);

View File

@ -26,6 +26,18 @@ namespace skyline::gpu::interconnect::maxwell3d {
vk::ShaderStageFlagBits stage;
vk::ShaderModule module;
Shader::Info info;
/**
* @return Whether the bindings for this stage match those of the input stage
*/
bool BindingsEqual(const ShaderStage &other) const {
return info.constant_buffer_descriptors == other.info.constant_buffer_descriptors &&
info.storage_buffers_descriptors == other.info.storage_buffers_descriptors &&
info.texture_buffer_descriptors == other.info.texture_buffer_descriptors &&
info.image_buffer_descriptors == other.info.image_buffer_descriptors &&
info.texture_descriptors == other.info.texture_descriptors &&
info.image_descriptors == other.info.image_descriptors;
}
};
struct DescriptorInfo {
@ -69,6 +81,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
std::array<Pipeline *, 4> transitionCache{};
size_t transitionCacheNextIdx{};
tsl::robin_map<Pipeline *, bool> bindingMatchCache; //!< Cache of which pipelines have bindings that match this pipeline
public:
PackedPipelineState sourcePackedState;
@ -78,6 +92,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
void AddTransition(Pipeline *next);
bool CheckBindingMatch(Pipeline *other);
void SyncDescriptors(InterconnectContext &ctx, ConstantBufferSet &constantBuffers);
void SyncDescriptorsQuickBind(InterconnectContext &ctx, ConstantBufferSet &constantBuffers, ConstantBuffers::QuickBind quickBind);