Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS

#include "imgui_breakdown_ex.h"
#include "imgui_ex.h"
#include <imgui_internal.h>

#include <random>
Expand Down Expand Up @@ -130,6 +131,8 @@ namespace ImGuiX
else
color = col_base + random();

color = ColorAlpha( color, style.Alpha, ColorAlphaOp_Multiply );

window->DrawList->AddRectFilled( rect.Min, rect.Max, color );

t0 = t1;
Expand Down
22 changes: 18 additions & 4 deletions VkLayer_profiler_layer/profiler_overlay/imgui_widgets/imgui_ex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,25 @@ namespace ImGuiX
Set color alpha.

\*************************************************************************/
ImU32 ColorAlpha( ImU32 color, float alpha )
ImU32 ColorAlpha( ImU32 color, float alpha, ColorAlphaOp op )
{
ImU32 c = color & 0x00FFFFFF;
ImU8 a = ImClamp( 255.f * alpha, 0.f, 255.f );
return ( c & 0x00FFFFFF ) | ( a << 24 );
ImU32 a = ( color & IM_COL32_A_MASK ) >> IM_COL32_A_SHIFT;
switch( op )
{
case ColorAlphaOp_Set:
a = ImClamp<ImU32>( 255 * alpha, 0, 255 );
break;
case ColorAlphaOp_Add:
a = ImClamp<ImU32>( a + 255 * alpha, 0, 255 );
break;
case ColorAlphaOp_Multiply:
a = ImClamp<ImU32>( a * alpha, 0, 255 );
break;
default:
IM_ASSERT( false );
break;
}
return ( color & ~IM_COL32_A_MASK ) | ( a << IM_COL32_A_SHIFT );
}

/*************************************************************************\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

namespace ImGuiX
{
enum ColorAlphaOp
{
ColorAlphaOp_Set,
ColorAlphaOp_Add,
ColorAlphaOp_Multiply
};

/*************************************************************************\

Function:
Expand Down Expand Up @@ -87,7 +94,7 @@ namespace ImGuiX
Set color alpha.

\*************************************************************************/
ImU32 ColorAlpha( ImU32, float );
ImU32 ColorAlpha( ImU32, float, ColorAlphaOp = ColorAlphaOp_Set );

/*************************************************************************\

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#define IMGUI_DEFINE_MATH_OPERATORS

#include "imgui_histogram_ex.h"
#include "imgui_ex.h"
#include <imgui_internal.h>
#include <algorithm>

Expand Down Expand Up @@ -242,7 +243,7 @@ namespace ImGuiX
{ x_pos - 5.0f * g.IO.FontGlobalScale, y_pos },
{ x_pos + 5.0f * g.IO.FontGlobalScale, y_pos },
{ x_pos, y_pos + 5.0f * g.IO.FontGlobalScale },
data.color );
ColorAlpha( data.color, style.Alpha, ColorAlphaOp_Multiply ) );

// Check if mouse is over the event
const ImRect event_bb(
Expand Down Expand Up @@ -292,10 +293,14 @@ namespace ImGuiX
( data.flags & HistogramColumnFlags_NoHover ) == 0 &&
column_bb.ContainsWithPad( g.IO.MousePos, style.TouchExtraPadding );

ImU32 color = ColorAlpha( data.color, style.Alpha, ColorAlphaOp_Multiply );
if( hovered_column )
color = ColorSaturation( color, 1.5f );

window->DrawList->AddRectFilled(
column_bb.Min,
column_bb.Max,
hovered_column ? ColorSaturation( data.color, 1.5f ) : data.color );
color );

if( hovered_column )
{
Expand Down
1 change: 1 addition & 0 deletions VkLayer_profiler_layer/profiler_overlay/lang/en_us.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ namespace Profiler
inline static constexpr char SamplingMode[] = "Sampling mode";
inline static constexpr char FrameDelimiter[] = "Frame delimiter";
inline static constexpr char InterfaceScale[] = "Interface scale";
inline static constexpr char InterfaceOpacity[] = "Interface opacity";
inline static constexpr char CollectedFrameCount[] = "Collected frame count";
inline static constexpr char ShowDebugLabels[] = "Show debug labels";
inline static constexpr char ShowShaderCapabilities[] = "Show shader capabilities";
Expand Down
32 changes: 27 additions & 5 deletions VkLayer_profiler_layer/profiler_overlay/profiler_overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,8 @@ namespace Profiler
m_HasNewSnapshots = false;

m_pData = nullptr;

m_Opacity = 0.9f;
m_Pause = false;
m_Fullscreen = false;
m_ShowDebugLabels = true;
Expand Down Expand Up @@ -925,6 +927,7 @@ namespace Profiler

// Begin main window
ImGui::PushFont( m_Resources.GetDefaultFont() );
ImGui::PushStyleVar( ImGuiStyleVar_Alpha, m_Opacity );
ImGui::Begin( m_Title.c_str(), nullptr, mainWindowFlags );

if( !m_Fullscreen )
Expand Down Expand Up @@ -1163,6 +1166,7 @@ namespace Profiler
pForegroundDrawList->AddCircleFilled( ImGui::GetIO().MousePos, 2.f, 0xffffffff, 4 );
}

ImGui::PopStyleVar();
ImGui::PopFont();
ImGui::Render();

Expand All @@ -1185,6 +1189,12 @@ namespace Profiler
// Round window corners
style.WindowRounding = 7.f;

// Disable default window transparency
for( ImGuiCol col : { ImGuiCol_WindowBg, ImGuiCol_TitleBg, ImGuiCol_TitleBgActive } )
{
style.Colors[col].w = 1.0f;
}

// Performance graph colors
m_RenderPassColumnColor = ImGui::GetColorU32( { 0.9f, 0.7f, 0.0f, 1.0f } ); // #e6b200
m_GraphicsPipelineColumnColor = ImGui::GetColorU32( { 0.9f, 0.7f, 0.0f, 1.0f } ); // #e6b200
Expand Down Expand Up @@ -4921,6 +4931,11 @@ namespace Profiler
ImGui::PushStyleColor( ImGuiCol_ChildBg, ImGui::GetStyleColorVec4( ImGuiCol_ScrollbarBg ) );
ImGui::PushStyleColor( ImGuiCol_ScrollbarBg, 0 );

const ImU32 gridColor = ImGuiX::ColorAlpha( IM_COL32( 128, 128, 128, 64 ), m_Opacity, ImGuiX::ColorAlphaOp_Multiply );
const ImU32 blockColor = ImGuiX::ColorAlpha( m_GraphicsPipelineColumnColor, m_Opacity, ImGuiX::ColorAlphaOp_Multiply );
const ImU32 hoveredBlockColor = ImGuiX::ColorAlpha( ImGuiX::Darker( m_GraphicsPipelineColumnColor, 1.5f ), m_Opacity, ImGuiX::ColorAlphaOp_Multiply );
const ImU32 blockBorderColor = ImGuiX::ColorAlpha( ImGuiX::Darker( m_GraphicsPipelineColumnColor ), m_Opacity, ImGuiX::ColorAlphaOp_Multiply );

if( ImGui::BeginChild( "##ImageMemoryMap",
ImVec2( 0, blockMapSize.y + 25.f * interfaceScale ),
ImGuiChildFlags_Border,
Expand All @@ -4937,7 +4952,7 @@ namespace Profiler
lt.x += x * blockSize;
lt.y += y * blockSize;
ImVec2 rb = ImVec2( lt.x + blockSize, lt.y + blockSize );
dl->AddRect( lt, rb, IM_COL32( 128, 128, 128, 64 ) );
dl->AddRect( lt, rb, gridColor );
}
}

Expand All @@ -4963,12 +4978,12 @@ namespace Profiler
rb.x += ( (float)binding.m_Block.m_ImageExtent.width / formatProperties.imageGranularity.width ) * blockSize;
rb.y += ( (float)binding.m_Block.m_ImageExtent.height / formatProperties.imageGranularity.height ) * blockSize;
ImRect bb( lt, rb );
dl->AddRect( lt, rb, ImGuiX::Darker( m_GraphicsPipelineColumnColor ) );
dl->AddRect( lt, rb, blockBorderColor );

ImU32 color = m_GraphicsPipelineColumnColor;
ImU32 color = blockColor;
bool hovered = bb.Contains( mousePos );
if( hovered )
color = ImGuiX::Darker( color, 1.5f );
color = hoveredBlockColor;

bb.Expand( ImVec2( -1, -1 ) );
dl->AddRectFilled( bb.Min, bb.Max, color );
Expand Down Expand Up @@ -5023,7 +5038,7 @@ namespace Profiler
rb.y += formatProperties.imageGranularity.height * blockSize - 2;

ImRect bb( lt, rb );
dl->AddRectFilled( bb.Min, bb.Max, m_GraphicsPipelineColumnColor );
dl->AddRectFilled( bb.Min, bb.Max, blockColor );

ImVec2 cp = ImGui::GetMousePos();
if( bb.Contains( cp ) )
Expand Down Expand Up @@ -6465,6 +6480,13 @@ namespace Profiler
ImGui::GetIO().FontGlobalScale = std::clamp( interfaceScale, 0.25f, 4.0f );
}

// Set interface opacity.
float interfaceOpacity = m_Opacity;
if( ImGui::InputFloat( Lang::InterfaceOpacity, &interfaceOpacity, 0.1f, 0, "%.1f", ImGuiInputTextFlags_CharsDecimal ) )
{
m_Opacity = std::clamp( interfaceOpacity, 0.1f, 1.0f );
}

// Set number of collected frames
int maxFrameCount = static_cast<int>( m_MaxFrameCount );
if( ImGui::InputInt( Lang::CollectedFrameCount, &maxFrameCount ) )
Expand Down
2 changes: 2 additions & 0 deletions VkLayer_profiler_layer/profiler_overlay/profiler_overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ namespace Profiler
bool m_HasNewSnapshots;

std::shared_ptr<DeviceProfilerFrameData> m_pData;

float m_Opacity;
bool m_Pause;
bool m_Fullscreen;
bool m_ShowDebugLabels;
Expand Down