Skip to content

Commit

Permalink
Merge branch 'clshortfuse:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
marat569 authored Aug 13, 2024
2 parents 2591088 + a2f8794 commit 6c845f1
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 13 deletions.
40 changes: 36 additions & 4 deletions src/devkit/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ void RenderMenuBar(reshade::api::device* device, DeviceData& data) {
ImGui::PopID();

ImGui::PushID("##menu_shaders_dump");
if (ImGui::MenuItem(std::format("Shaders Dump ({})", renodx::utils::shader::dump::pending_dump_count.load()).c_str(), "", false, setting_auto_dump)) {
if (ImGui::MenuItem(std::format("Dump Shaders ({})", renodx::utils::shader::dump::pending_dump_count.load()).c_str(), "", false, !setting_auto_dump)) {
renodx::utils::shader::dump::DumpAllPending();
}
ImGui::PopID();
Expand Down Expand Up @@ -734,20 +734,25 @@ void RenderShadersPane(reshade::api::device* device, DeviceData& data) {
static ImGuiTreeNodeFlags tree_node_flags = ImGuiTreeNodeFlags_SpanAllColumns | ImGuiTreeNodeFlags_SpanFullWidth;
if (ImGui::BeginTable(
"##ShadersPaneTable",
3,
4,
ImGuiTableFlags_BordersInner | ImGuiTableFlags_Resizable | ImGuiTableFlags_ScrollY
| ImGuiTableFlags_Sortable | ImGuiTableFlags_SortMulti,
ImVec2(0, 0))) {
ImGui::TableSetupColumn("Hash", ImGuiTableColumnFlags_NoHide);
ImGui::TableSetupColumn("Alias", ImGuiTableColumnFlags_NoHide);
ImGui::TableSetupColumn("Source", ImGuiTableColumnFlags_DefaultHide);
ImGui::TableSetupColumn("Snapshot", ImGuiTableColumnFlags_DefaultHide);
ImGui::TableSetupScrollFreeze(0, 1);
ImGui::TableHeadersRow();

int cell_index_id = 0x10000;
int current_snapshot_index = 0;

for (auto& [shader_hash, shader_details] : data.shader_details) {
SettingSelection search = {.shader_hash = shader_hash};
std::unordered_set<uint32_t> drawn_hashes;

auto draw_row = [&](ShaderDetails& shader_details, int snapshot_index = -1) {
if (drawn_hashes.contains(shader_details.shader_hash)) return;
SettingSelection search = {.shader_hash = shader_details.shader_hash};
auto& selection = GetSelection(search);

// Undocumented ImGui Combo height
Expand Down Expand Up @@ -801,6 +806,33 @@ void RenderShadersPane(reshade::api::device* device, DeviceData& data) {
};
ImGui::PopID();
}

if (ImGui::TableSetColumnIndex(3)) {
ImGui::PushID(cell_index_id++);
if (snapshot_index == -1) {
ImGui::TextUnformatted("");
} else {
ImGui::Text("%03d", snapshot_index);
}
ImGui::PopID();
}
drawn_hashes.emplace(shader_details.shader_hash);
};

for (auto& command_list_data : data.command_list_data) {
for (auto& draw_details : command_list_data.draw_details) {
for (const auto& pipeline_bind : draw_details.pipeline_binds) {
for (const auto& shader_hash : pipeline_bind.shader_hashes) {
auto& shader_details = data.GetShaderDetails(shader_hash);
draw_row(shader_details, current_snapshot_index);
}
}
current_snapshot_index++;
}
}

for (auto& [shader_hash, shader_details] : data.shader_details) {
draw_row(shader_details);
}

ImGui::EndTable();
Expand Down
8 changes: 2 additions & 6 deletions src/template/addon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,8 @@ void OnPresetOff() {

} // namespace

// NOLINTBEGIN(readability-identifier-naming)

extern "C" __declspec(dllexport) const char* NAME = "RenoDX";
extern "C" __declspec(dllexport) const char* DESCRIPTION = "RenoDX for {Game}";

// NOLINTEND(readability-identifier-naming)
extern "C" __declspec(dllexport) constexpr const char* NAME = "RenoDX";
extern "C" __declspec(dllexport) constexpr const char* DESCRIPTION = "RenoDX for {Game}";

BOOL APIENTRY DllMain(HMODULE h_module, DWORD fdw_reason, LPVOID lpv_reserved) {
switch (fdw_reason) {
Expand Down
6 changes: 3 additions & 3 deletions src/utils/shader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ struct PipelineShaderDetails {
std::optional<std::string> tag;
bool destroyed = false;

std::optional<std::vector<uint8_t>> GetShaderData(uint32_t shader_hash, size_t index = -1) const {
[[nodiscard]] std::optional<std::vector<uint8_t>> GetShaderData(uint32_t shader_hash, size_t index = -1) const {
if (index == -1) {
for (const auto& [item_index, item_shader_hash] : shader_hashes_by_index) {
if (item_shader_hash != shader_hash) continue;
Expand Down Expand Up @@ -497,7 +497,7 @@ static void OnBindPipeline(
reshade::api::pipeline pipeline) {
auto& cmd_list_data = cmd_list->get_private_data<CommandListData>();

if (pipeline.handle == 0) {
if (pipeline.handle == 0 || (stage == reshade::api::pipeline_stage::all)) {
for (auto compatible_stage : COMPATIBLE_STAGES) {
if ((stage & compatible_stage) == compatible_stage) {
cmd_list_data.current_shaders_hashes.erase(compatible_stage);
Expand All @@ -506,7 +506,7 @@ static void OnBindPipeline(
}
}
}
return;
if (pipeline.handle == 0) return;
}

auto* device = cmd_list->get_device();
Expand Down

0 comments on commit 6c845f1

Please sign in to comment.