Skip to content

Commit

Permalink
[misc] some minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
PanosK92 committed Dec 12, 2024
1 parent 3a7f686 commit 54d5813
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 30 deletions.
10 changes: 0 additions & 10 deletions editor/Widgets/Profiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,3 @@ void Profiler::OnTickVisible()
ImGui::ProgressBar((float)memory_used / (float)memory_available, ImVec2(-1, 0), overlay.c_str());
}
}

void Profiler::OnVisible()
{
Spartan::Debugging::SetGpuTimingEnabled(true);
}

void Profiler::OnInvisible()
{
Spartan::Debugging::SetGpuTimingEnabled(true);
}
3 changes: 0 additions & 3 deletions editor/Widgets/Profiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,7 @@ class Profiler : public Widget
{
public:
Profiler(Editor* editor);

void OnTickVisible() override;
void OnVisible() override;
void OnInvisible() override;

private:
std::array<float, 400> m_plot;
Expand Down
22 changes: 8 additions & 14 deletions runtime/Core/Debugging.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,14 @@ namespace Spartan
class Debugging
{
public:
static void Initialize(const bool is_amd)
{
m_breadcrumbs_enabled = m_breadcrumbs_enabled ? is_amd : false;
}

static bool IsValidationLayerEnabled() { return m_validation_layer_enabled; }
static bool IsGpuAssistedValidationEnabled() { return m_gpu_assisted_validation_enabled; }
static bool IsGpuMarkingEnabled() { return m_gpu_marking_enabled; }
static bool IsGpuTimingEnabled() { return m_gpu_timing_enabled; }
static void SetGpuTimingEnabled(const bool enabled) { m_gpu_timing_enabled = enabled; }
static bool IsRenderdocEnabled() { return m_renderdoc_enabled; }
static bool IsShaderOptimizationEnabled() { return m_shader_optimization_enabled; }
static bool IsLoggingToFileEnabled() { return m_logging_to_file_enabled; }
static bool IsBreadcrumbsEnabled() { return m_breadcrumbs_enabled; }
static bool IsValidationLayerEnabled() { return m_validation_layer_enabled; }
static bool IsGpuAssistedValidationEnabled() { return m_gpu_assisted_validation_enabled; }
static bool IsGpuMarkingEnabled() { return m_gpu_marking_enabled; }
static bool IsGpuTimingEnabled() { return m_gpu_timing_enabled; }
static bool IsRenderdocEnabled() { return m_renderdoc_enabled; }
static bool IsShaderOptimizationEnabled() { return m_shader_optimization_enabled; }
static bool IsLoggingToFileEnabled() { return m_logging_to_file_enabled; }
static bool IsBreadcrumbsEnabled() { return m_breadcrumbs_enabled; }

private:
inline static bool m_validation_layer_enabled = false; // Enables Vulkan diagnostic layers, incurs significant per-draw CPU performance overhead
Expand Down
9 changes: 6 additions & 3 deletions runtime/RHI/Vulkan/Vulkan_Device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1354,7 +1354,10 @@ namespace Spartan

// gpu dependent actions
{
Debugging::Initialize(GetPrimaryPhysicalDevice()->IsAmd());
if (Debugging::IsBreadcrumbsEnabled())
{
SP_ASSERT_MSG(GetPrimaryPhysicalDevice()->IsAmd(), "Breadcrumbs are only supported on AMD GPUs");
}

if (RHI_Device::GetPrimaryPhysicalDevice()->IsBelowMinimumRequirments())
{
Expand Down Expand Up @@ -1447,7 +1450,7 @@ namespace Spartan
if (device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_VIRTUAL_GPU) type = RHI_PhysicalDevice_Type::Virtual;
if (device_properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_CPU) type = RHI_PhysicalDevice_Type::Cpu;

// Find the local device memory heap size
// find the local device memory heap size
uint64_t vram_size_bytes = 0;
for (uint32_t i = 0; i < device_memory_properties.memoryHeapCount; i++)
{
Expand All @@ -1457,7 +1460,7 @@ namespace Spartan
break;
}
}
SP_ASSERT(vram_size_bytes >0);
SP_ASSERT(vram_size_bytes > 0);

PhysicalDeviceRegister(PhysicalDevice
(
Expand Down

0 comments on commit 54d5813

Please sign in to comment.