Skip to content
Draft
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
5 changes: 3 additions & 2 deletions ui/command_buffer_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <iostream>
#include <sstream>
#include "color_utils.h"
#include "dive_core/command_hierarchy.h"
#include "dive_tree_view.h"

Expand Down Expand Up @@ -92,7 +93,7 @@ QVariant CommandBufferModel::data(const QModelIndex &index, int role) const

uint64_t node_index = index.internalId();
if (role == Qt::ForegroundRole && IsSelected(node_index))
return QColor(255, 128, 128);
return GetTextAccentColor();

if (role != Qt::DisplayRole)
return QVariant();
Expand Down Expand Up @@ -457,4 +458,4 @@ bool CommandBufferModel::IsSelected(uint64_t node_index) const
uint32_t bit_element = node_index % 8;
uint8_t mask = 0x1 << bit_element;
return (m_node_is_selected_bit_list[array_index] & mask) != 0;
}
}
3 changes: 2 additions & 1 deletion ui/command_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <QStringList>
#include <QTreeWidget>

#include "color_utils.h"
#include "dive_core/command_hierarchy.h"

static_assert(sizeof(void *) == sizeof(uint64_t),
Expand Down Expand Up @@ -86,7 +87,7 @@ QVariant CommandModel::data(const QModelIndex &index, int role) const
if (marker_type == Dive::CommandHierarchy::MarkerType::kInsert ||
marker_type == Dive::CommandHierarchy::MarkerType::kBeginEnd)
{
return QVariant(QBrush(QColor(85, 139, 47))); // Shade of green
return QVariant(QBrush(GetTextAccentColor()));
}
}
}
Expand Down
30 changes: 30 additions & 0 deletions ui/dive_application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include "dive_application.h"

bool DiveApplication::event(QEvent* e)
{
if (e->type() == QEvent::ApplicationPaletteChange)
{
if (m_style_sheet)
{
// Re-apply style sheet, so palette change is propagated.
setStyleSheet(*m_style_sheet);
}
}
return QApplication::event(e);
}
41 changes: 41 additions & 0 deletions ui/dive_application.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
Copyright 2025 Google LLC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#pragma once

#include <optional>

#include <QApplication>
#include <QEvent>
#include <QString>

class DiveApplication : public QApplication
{
Q_OBJECT
public:
using QApplication::QApplication;
void SetStyleSheet(const QString& style_sheet)
{
m_style_sheet = style_sheet;
setStyleSheet(style_sheet);
}

protected:
virtual bool event(QEvent* e) Q_DECL_OVERRIDE;

private:
std::optional<QString> m_style_sheet;
};
4 changes: 3 additions & 1 deletion ui/draw_dispatch_stats_tab_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "draw_dispatch_stats_model.h"
#include "search_bar.h"
#include <QHBoxLayout>
#include <QHeaderView>
#include <QVBoxLayout>
#include <QIcon>
#include <QPoint>
Expand All @@ -29,6 +30,7 @@ DrawDispatchStatsTabView::DrawDispatchStatsTabView(const Dive::CaptureStats &sta
{
m_draw_dispatch_stats_model = new DrawDispatchStatsModel();
m_draw_dispatch_stats_view = new QTableView();
m_draw_dispatch_stats_view->verticalHeader()->hide();
m_draw_dispatch_stats_view->setModel(m_draw_dispatch_stats_model);
ResizeColumns(m_draw_dispatch_stats_model, m_draw_dispatch_stats_view);

Expand Down Expand Up @@ -60,4 +62,4 @@ void DrawDispatchStatsTabView::LoadStatistics()

m_draw_dispatch_stats_model->LoadData(m_stats.m_stats_list);
ResizeColumns(m_draw_dispatch_stats_model, m_draw_dispatch_stats_view);
}
}
105 changes: 63 additions & 42 deletions ui/event_state_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <QVBoxLayout>
#include <map>
#include <string>
#include "color_utils.h"
#include "dive_core/command_hierarchy.h"
#include "dive_core/data_core.h"
#include "dive_core/dive_strings.h"
Expand All @@ -41,7 +42,7 @@
_item->setText(1, _string); \
if (!prev_event_state_it->IsValid() || !_prev_field_set || \
QString::compare(_prev_string, _string) != 0) \
_item->setForeground(1, QBrush(QColor(Qt::cyan))); \
_item->setForeground(1, QBrush(m_accent_color)); \
_items.append(_item); \
}

Expand All @@ -51,7 +52,7 @@
_item->setText(0, QString(_field)); \
_item->setText(1, QString::number(_num)); \
if (!prev_event_state_it->IsValid() || !_prev_field_set || _prev_num != _num) \
_item->setForeground(1, QBrush(QColor(Qt::cyan))); \
_item->setForeground(1, QBrush(m_accent_color)); \
_items.append(_item); \
}

Expand All @@ -61,7 +62,7 @@
_item->setText(0, QString(_field)); \
_item->setText(1, "0x" + QString::number(static_cast<uint32_t>(_num), 16)); \
if (!prev_event_state_it->IsValid() || !_prev_field_set || _prev_num != _num) \
_item->setForeground(1, QBrush(QColor(Qt::cyan))); \
_item->setForeground(1, QBrush(m_accent_color)); \
_items.append(_item); \
}

Expand All @@ -81,7 +82,7 @@
_item->setText(0, QString(_field)); \
_item->setText(1, (_bool ? "true" : "false")); \
if (!prev_event_state_it->IsValid() || !_prev_field_set || _prev_bool != _bool) \
_item->setForeground(1, QBrush(QColor(Qt::cyan))); \
_item->setForeground(1, QBrush(m_accent_color)); \
_items.append(_item); \
}

Expand Down Expand Up @@ -164,6 +165,8 @@ void EventStateView::OnEventSelected(uint64_t node_index)
if (node_index == UINT64_MAX)
return;

m_accent_color = GetTextAccentColor();

auto &metadata = m_data_core.GetCaptureMetadata();
auto &command_hierarchy = m_data_core.GetCommandHierarchy();
auto &event_state = metadata.m_event_state;
Expand Down Expand Up @@ -901,66 +904,84 @@ void EventStateView::DisplayColorBlendState(Dive::EventStateInfo::ConstIterator
{
if (event_state_it->IsAttachmentSet(i))
{
QList<QTreeWidgetItem *> attachment_items;
// LogicOpEnabled
if (event_state_it->IsLogicOpEnabledSet(i))
ADD_FIELD_TYPE_BOOL(event_state_it->GetLogicOpEnabledName() +
QString::number(i),
ADD_FIELD_TYPE_BOOL(event_state_it->GetLogicOpEnabledName(),
event_state_it->LogicOpEnabled(i),
prev_event_state_it->IsLogicOpEnabledSet(i),
prev_event_state_it->LogicOpEnabled(i),
child_items)
attachment_items)
else
ADD_FIELD_NOT_SET(event_state_it->GetLogicOpEnabledName() + QString::number(i),
child_items)
ADD_FIELD_NOT_SET(event_state_it->GetLogicOpEnabledName(), attachment_items)

// LogicOp
if (event_state_it->IsLogicOpSet(i))
{
ADD_FIELD_TYPE_STRING(event_state_it->GetLogicOpName() + QString::number(i),
ADD_FIELD_TYPE_STRING(event_state_it->GetLogicOpName(),
GetVkLogicOp(event_state_it->LogicOp(i)),
prev_event_state_it->IsLogicOpSet(i),
GetVkLogicOp(prev_event_state_it->LogicOp(i)),
child_items)
attachment_items)
}
else
{
ADD_FIELD_NOT_SET(event_state_it->GetLogicOpName() + QString::number(i),
child_items)
ADD_FIELD_NOT_SET(event_state_it->GetLogicOpName(), attachment_items)
}

auto GetBlendString = [](VkPipelineColorBlendAttachmentState attach) {
return "blendEnabled: " + QString::number(attach.blendEnable) +
", srcColorBlendFactor: " +
QString(GetVkBlendFactor(attach.srcColorBlendFactor)) +
", dstColorBlendFactor: " +
QString(GetVkBlendFactor(attach.dstColorBlendFactor)) +
", colorBlendOp: " + QString(GetVkBlendOp(attach.colorBlendOp)) +
", srcAlphaBlendFactor: " +
QString(GetVkBlendFactor(attach.srcAlphaBlendFactor)) +
", dstAlphaBlendFactor: " +
QString(GetVkBlendFactor(attach.dstAlphaBlendFactor)) +
", alphaBlendOp: " + QString(GetVkBlendOp(attach.alphaBlendOp)) +
", colorWriteMask: 0x" + QString::number(attach.colorWriteMask, 16);
};

QString value;
VkPipelineColorBlendAttachmentState attach = event_state_it->Attachment(i);

value = GetBlendString(attach);

QString prev_value;
VkPipelineColorBlendAttachmentState prev_attach;
const VkPipelineColorBlendAttachmentState curr_attach = event_state_it->Attachment(i);
const bool prev_set = prev_event_state_it->IsAttachmentSet(i);
VkPipelineColorBlendAttachmentState prev_attach = {};
if (prev_event_state_it->IsValid())
{
prev_attach = prev_event_state_it->Attachment(i);
prev_value = GetBlendString(prev_attach);
}

ADD_FIELD_TYPE_STRING(QString::number(i),
value,
prev_event_state_it->IsAttachmentSet(i),
prev_value,
child_items);
ADD_FIELD_TYPE_NUMBER("BlendEnabled",
curr_attach.blendEnable,
prev_set,
prev_attach.blendEnable,
attachment_items);
ADD_FIELD_TYPE_NUMBER("SrcColorBlendFactor",
curr_attach.srcColorBlendFactor,
prev_set,
prev_attach.srcColorBlendFactor,
attachment_items);
ADD_FIELD_TYPE_NUMBER("DstColorBlendFactor",
curr_attach.dstColorBlendFactor,
prev_set,
prev_attach.dstColorBlendFactor,
attachment_items);
ADD_FIELD_TYPE_NUMBER("ColorBlendOp",
curr_attach.colorBlendOp,
prev_set,
prev_attach.colorBlendOp,
attachment_items);
ADD_FIELD_TYPE_NUMBER("SrcAlphaBlendFactor",
curr_attach.srcAlphaBlendFactor,
prev_set,
prev_attach.srcAlphaBlendFactor,
attachment_items);
ADD_FIELD_TYPE_NUMBER("DstAlphaBlendFactor",
curr_attach.dstAlphaBlendFactor,
prev_set,
prev_attach.dstAlphaBlendFactor,
attachment_items);
ADD_FIELD_TYPE_NUMBER("AlphaBlendOp",
curr_attach.alphaBlendOp,
prev_set,
prev_attach.alphaBlendOp,
attachment_items);
ADD_FIELD_TYPE_NUMBER_HEX("ColorWriteMask",
curr_attach.colorWriteMask,
prev_set,
prev_attach.colorWriteMask,
attachment_items);

QTreeWidgetItem *attachment_item = new QTreeWidgetItem((QTreeWidget *)0,
QStringList(
QString::number(i)));
attachment_item->insertChildren(0, attachment_items);
child_items.append(attachment_item);
}
else
ADD_FIELD_NOT_SET(QString::number(i), child_items);
Expand Down
3 changes: 2 additions & 1 deletion ui/event_state_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ private slots:
std::map<std::string, std::string> m_field_desc;
const Dive::DataCore &m_data_core;
QTreeWidget *m_event_state_tree;
QColor m_accent_color;

Dive::EventStateInfo::ConstIterator GetStateInfoForEvent(const Dive::EventStateInfo &state,
uint32_t event_id);
Expand Down Expand Up @@ -83,4 +84,4 @@ private slots:
void BuildResolveSysmemDescriptionMap(Dive::EventStateInfo::ConstIterator event_state_it);
void DisplayResolveSysmemInfo(Dive::EventStateInfo::ConstIterator event_state_it,
Dive::EventStateInfo::ConstIterator prev_event_state_it);
};
};
4 changes: 3 additions & 1 deletion ui/gpu_timing_tab_view.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <QAbstractItemModel>
#include <QDebug>
#include <QHeaderView>
#include <QItemSelectionModel>

#include "ui/gpu_timing_model.h"
Expand All @@ -27,6 +28,7 @@ GpuTimingTabView::GpuTimingTabView(GpuTimingModel &gpu_timing_mode
m_command_hierarchy(command_hierarchy)
{
m_table_view = new QTableView(this);
m_table_view->verticalHeader()->hide();
m_table_view->setModel(&m_model);

// Used otherwise the table does not expand to fit available space
Expand Down Expand Up @@ -190,4 +192,4 @@ void GpuTimingTabView::ClearSelection()
{
selection_model->clear();
}
}
}
Loading
Loading