mirror of https://git.suyu.dev/suyu/suyu
shaders: Track local memory usage
This commit is contained in:
parent
b198339580
commit
405eae3734
|
@ -424,6 +424,10 @@ void VisitUsages(Info& info, IR::Inst& inst) {
|
||||||
info.used_constant_buffer_types |= IR::Type::U32 | IR::Type::U32x2;
|
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;
|
info.used_storage_buffer_types |= IR::Type::U32 | IR::Type::U32x2 | IR::Type::U32x4;
|
||||||
break;
|
break;
|
||||||
|
case IR::Opcode::LoadLocal:
|
||||||
|
case IR::Opcode::WriteLocal:
|
||||||
|
info.uses_local_memory = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,6 +172,7 @@ struct Info {
|
||||||
bool stores_indexed_attributes{};
|
bool stores_indexed_attributes{};
|
||||||
|
|
||||||
bool stores_global_memory{};
|
bool stores_global_memory{};
|
||||||
|
bool uses_local_memory{};
|
||||||
|
|
||||||
bool uses_fp16{};
|
bool uses_fp16{};
|
||||||
bool uses_fp64{};
|
bool uses_fp64{};
|
||||||
|
|
|
@ -63,6 +63,7 @@ ComputePipeline::ComputePipeline(const Device& device, TextureCache& texture_cac
|
||||||
writes_global_memory = !use_storage_buffers &&
|
writes_global_memory = !use_storage_buffers &&
|
||||||
std::ranges::any_of(info.storage_buffers_descriptors,
|
std::ranges::any_of(info.storage_buffers_descriptors,
|
||||||
[](const auto& desc) { return desc.is_written; });
|
[](const auto& desc) { return desc.is_written; });
|
||||||
|
uses_local_memory = info.uses_local_memory;
|
||||||
if (force_context_flush) {
|
if (force_context_flush) {
|
||||||
std::scoped_lock lock{built_mutex};
|
std::scoped_lock lock{built_mutex};
|
||||||
built_fence.Create();
|
built_fence.Create();
|
||||||
|
|
|
@ -59,6 +59,10 @@ public:
|
||||||
return writes_global_memory;
|
return writes_global_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool UsesLocalMemory() const noexcept {
|
||||||
|
return uses_local_memory;
|
||||||
|
}
|
||||||
|
|
||||||
void SetEngine(Tegra::Engines::KeplerCompute* kepler_compute_,
|
void SetEngine(Tegra::Engines::KeplerCompute* kepler_compute_,
|
||||||
Tegra::MemoryManager* gpu_memory_) {
|
Tegra::MemoryManager* gpu_memory_) {
|
||||||
kepler_compute = kepler_compute_;
|
kepler_compute = kepler_compute_;
|
||||||
|
@ -84,6 +88,7 @@ private:
|
||||||
|
|
||||||
bool use_storage_buffers{};
|
bool use_storage_buffers{};
|
||||||
bool writes_global_memory{};
|
bool writes_global_memory{};
|
||||||
|
bool uses_local_memory{};
|
||||||
|
|
||||||
std::mutex built_mutex;
|
std::mutex built_mutex;
|
||||||
std::condition_variable built_condvar;
|
std::condition_variable built_condvar;
|
||||||
|
|
|
@ -215,6 +215,7 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
|
||||||
|
|
||||||
writes_global_memory |= std::ranges::any_of(
|
writes_global_memory |= std::ranges::any_of(
|
||||||
info.storage_buffers_descriptors, [](const auto& desc) { return desc.is_written; });
|
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_textures <= MAX_TEXTURES);
|
||||||
ASSERT(num_images <= MAX_IMAGES);
|
ASSERT(num_images <= MAX_IMAGES);
|
||||||
|
|
|
@ -98,6 +98,10 @@ public:
|
||||||
return writes_global_memory;
|
return writes_global_memory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool UsesLocalMemory() const noexcept {
|
||||||
|
return uses_local_memory;
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool IsBuilt() noexcept;
|
[[nodiscard]] bool IsBuilt() noexcept;
|
||||||
|
|
||||||
template <typename Spec>
|
template <typename Spec>
|
||||||
|
@ -146,6 +150,7 @@ private:
|
||||||
|
|
||||||
bool use_storage_buffers{};
|
bool use_storage_buffers{};
|
||||||
bool writes_global_memory{};
|
bool writes_global_memory{};
|
||||||
|
bool uses_local_memory{};
|
||||||
|
|
||||||
static constexpr std::size_t XFB_ENTRY_STRIDE = 3;
|
static constexpr std::size_t XFB_ENTRY_STRIDE = 3;
|
||||||
GLsizei num_xfb_attribs{};
|
GLsizei num_xfb_attribs{};
|
||||||
|
|
|
@ -222,7 +222,9 @@ void RasterizerOpenGL::PrepareDraw(bool is_indexed, Func&& draw_func) {
|
||||||
gpu.TickWork();
|
gpu.TickWork();
|
||||||
|
|
||||||
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
std::scoped_lock lock{buffer_cache.mutex, texture_cache.mutex};
|
||||||
|
if (pipeline->UsesLocalMemory()) {
|
||||||
program_manager.LocalMemoryWarmup();
|
program_manager.LocalMemoryWarmup();
|
||||||
|
}
|
||||||
pipeline->SetEngine(maxwell3d, gpu_memory);
|
pipeline->SetEngine(maxwell3d, gpu_memory);
|
||||||
pipeline->Configure(is_indexed);
|
pipeline->Configure(is_indexed);
|
||||||
|
|
||||||
|
@ -372,7 +374,9 @@ void RasterizerOpenGL::DispatchCompute() {
|
||||||
if (!pipeline) {
|
if (!pipeline) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (pipeline->UsesLocalMemory()) {
|
||||||
program_manager.LocalMemoryWarmup();
|
program_manager.LocalMemoryWarmup();
|
||||||
|
}
|
||||||
pipeline->SetEngine(kepler_compute, gpu_memory);
|
pipeline->SetEngine(kepler_compute, gpu_memory);
|
||||||
pipeline->Configure();
|
pipeline->Configure();
|
||||||
const auto& qmd{kepler_compute->launch_description};
|
const auto& qmd{kepler_compute->launch_description};
|
||||||
|
|
Loading…
Reference in New Issue