shaders: Track local memory usage

This commit is contained in:
ameerj 2023-06-25 18:59:33 -04:00
parent b198339580
commit 405eae3734
7 changed files with 23 additions and 2 deletions

View file

@ -424,6 +424,10 @@ void VisitUsages(Info& info, IR::Inst& inst) {
info.used_constant_buffer_types |= IR::Type::U32 | IR::Type::U32x2;
info.used_storage_buffer_types |= IR::Type::U32 | IR::Type::U32x2 | IR::Type::U32x4;
break;
case IR::Opcode::LoadLocal:
case IR::Opcode::WriteLocal:
info.uses_local_memory = true;
break;
default:
break;
}

View file

@ -172,6 +172,7 @@ struct Info {
bool stores_indexed_attributes{};
bool stores_global_memory{};
bool uses_local_memory{};
bool uses_fp16{};
bool uses_fp64{};

View file

@ -63,6 +63,7 @@ ComputePipeline::ComputePipeline(const Device& device, TextureCache& texture_cac
writes_global_memory = !use_storage_buffers &&
std::ranges::any_of(info.storage_buffers_descriptors,
[](const auto& desc) { return desc.is_written; });
uses_local_memory = info.uses_local_memory;
if (force_context_flush) {
std::scoped_lock lock{built_mutex};
built_fence.Create();

View file

@ -59,6 +59,10 @@ public:
return writes_global_memory;
}
[[nodiscard]] bool UsesLocalMemory() const noexcept {
return uses_local_memory;
}
void SetEngine(Tegra::Engines::KeplerCompute* kepler_compute_,
Tegra::MemoryManager* gpu_memory_) {
kepler_compute = kepler_compute_;
@ -84,6 +88,7 @@ private:
bool use_storage_buffers{};
bool writes_global_memory{};
bool uses_local_memory{};
std::mutex built_mutex;
std::condition_variable built_condvar;

View file

@ -215,6 +215,7 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
writes_global_memory |= std::ranges::any_of(
info.storage_buffers_descriptors, [](const auto& desc) { return desc.is_written; });
uses_local_memory |= info.uses_local_memory;
}
ASSERT(num_textures <= MAX_TEXTURES);
ASSERT(num_images <= MAX_IMAGES);

View file

@ -98,6 +98,10 @@ public:
return writes_global_memory;
}
[[nodiscard]] bool UsesLocalMemory() const noexcept {
return uses_local_memory;
}
[[nodiscard]] bool IsBuilt() noexcept;
template <typename Spec>
@ -146,6 +150,7 @@ private:
bool use_storage_buffers{};
bool writes_global_memory{};
bool uses_local_memory{};
static constexpr std::size_t XFB_ENTRY_STRIDE = 3;
GLsizei num_xfb_attribs{};

View file

@ -222,7 +222,9 @@ void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) {
gpu.TickWork();
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
program_manager.LocalMemoryWarmup();
if (pipeline->UsesLocalMemory()) {
program_manager.LocalMemoryWarmup();
}
pipeline->SetEngine(maxwell3d, gpu_memory);
pipeline->Configure(is_indexed);
@ -372,7 +374,9 @@ void RasterizerOpenGL::DispatchCompute() {
if (!pipeline) {
return;
}
program_manager.LocalMemoryWarmup();
if (pipeline->UsesLocalMemory()) {
program_manager.LocalMemoryWarmup();
}
pipeline->SetEngine(kepler_compute, gpu_memory);
pipeline->Configure();
const auto& qmd{kepler_compute->launch_description};