Skip to content

Commit

Permalink
Vulkan: Update ImGui and CImGui to version 1.91.4
Browse files Browse the repository at this point in the history
  • Loading branch information
JKSunny committed Oct 19, 2024
1 parent bd94493 commit aa214c6
Show file tree
Hide file tree
Showing 24 changed files with 19,530 additions and 8,978 deletions.
11 changes: 5 additions & 6 deletions codemp/rd-vulkan/inspector/vk_imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ void vk_imgui_clear_inspector( qboolean reset )
Com_Memset( &inspector.entity, 0, sizeof(inspector.entity) );
Com_Memset( &inspector.node, 0, sizeof(inspector.node) );
Com_Memset( &inspector.surface, 0, sizeof(inspector.surface) );

windows.shader.text_mode = true;
}

// handler to set/update ptrs and info for the current object selected
Expand Down Expand Up @@ -132,7 +130,7 @@ static void vk_imgui_draw_objects( void )
ImGui::Dummy( ImVec2( 0.0f, 15.0f ) );

ImGui::PushStyleColor( ImGuiCol_FrameBg , ImVec4(0.10f, 0.10f, 0.10f, 1.00f) );
if( ImGui::ListBoxHeader( "##Objects", ImGui::GetContentRegionAvail() ) )
if( ImGui::BeginListBox( "##Objects", ImGui::GetContentRegionAvail() ) )
{
if ( tr.registered && tr.world ) {
//vk_imgui_draw_objects_cubemaps();
Expand All @@ -143,7 +141,7 @@ static void vk_imgui_draw_objects( void )

vk_imgui_draw_objects_shaders();

ImGui::ListBoxFooter();
ImGui::EndListBox();
}
ImGui::PopStyleColor();

Expand Down Expand Up @@ -416,13 +414,14 @@ void vk_imgui_create_gui( void )

if ( !inspector.init ) {
vk_imgui_clear_inspector( qtrue );

inspector.merge_shaders = true;
inspector.outline_selected = true;

// windows
Com_Memset( &windows, 0, sizeof(windows) );
windows.viewport.p_open = true;
windows.shader.text_mode = true;

// render image
vk_imgui_bind_game_color_image();
Expand Down
23 changes: 16 additions & 7 deletions codemp/rd-vulkan/inspector/vk_imgui_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ You should have received a copy of the GNU General Public License
along with this program; if not, see <http://www.gnu.org/licenses/>.
===========================================================================
*/
#include "tr_local.h"

#define VK_NO_PROTOTYPES
#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui.cpp>
#include <backends/imgui_impl_vulkan.cpp>
#include <backends/imgui_impl_sdl.cpp>
#include <backends/imgui_impl_sdl2.cpp>

#include "tr_local.h"
#include "vk_imgui.h"

#include <icons/FontAwesome5/IconsFontAwesome5.h>
Expand Down Expand Up @@ -225,8 +228,17 @@ void vk_imgui_initialize( void )
init_info.MinImageCount = 2;
init_info.ImageCount = vk.swapchain_image_count;
init_info.MSAASamples = VK_SAMPLE_COUNT_1_BIT;
init_info.RenderPass = vk.render_pass.inspector;

ImGui_ImplVulkan_Init( &init_info, vk.render_pass.inspector );
ImGui_ImplVulkan_LoadFunctions( []( const char* func, void *instance )
{
Vk_Instance* vk_instance = reinterpret_cast<Vk_Instance*>(instance);
PFN_vkVoidFunction instanceAddr = qvkGetInstanceProcAddr( vk_instance->instance, func );
PFN_vkVoidFunction deviceAddr = qvkGetDeviceProcAddr( vk_instance->device, func );
return deviceAddr ? deviceAddr : instanceAddr;
}, &vk );

ImGui_ImplVulkan_Init( &init_info );

{
command_buffer = vk.cmd->command_buffer;
Expand All @@ -238,7 +250,7 @@ void vk_imgui_initialize( void )
begin_info.pInheritanceInfo = NULL;
VK_CHECK( qvkBeginCommandBuffer( command_buffer, &begin_info ) );

ImGui_ImplVulkan_CreateFontsTexture( command_buffer );
ImGui_ImplVulkan_CreateFontsTexture();

VK_CHECK(qvkEndCommandBuffer(command_buffer));

Expand All @@ -249,14 +261,11 @@ void vk_imgui_initialize( void )
VK_CHECK( qvkQueueSubmit( vk.queue, 1, &end_info, VK_NULL_HANDLE ) );

vk_wait_idle();

ImGui_ImplVulkan_DestroyFontUploadObjects();
}
}

void vk_imgui_shutdown( void )
{
ImGui_ImplVulkan_DestroyFontUploadObjects();
qvkDestroyDescriptorPool( vk.device, imguiPool, nullptr );
ImGui_ImplVulkan_Shutdown();
ImGui_ImplSDL2_Shutdown();
Expand Down
6 changes: 4 additions & 2 deletions codemp/rd-vulkan/inspector/vk_imgui_globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,13 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "tr_local.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>
#include <imgui_draw.cpp>
#include <imgui_widgets.cpp>
#include <imgui_tables.cpp>
#include <inspector/vk_imgui.h>

#include "vk_imgui.h"

ImVector<ImRect> s_GroupPanelLabelStack;

Expand Down Expand Up @@ -268,7 +270,7 @@ qboolean imgui_draw_text_with_button( const char *label, const char *value, cons
drawList->AddRect(
ImVec2(pos.x, pos.y),
ImVec2(pos.x + region.x, pos.y + height),
RGBA_LE(0x333436ffu), 2.0f, ImDrawCornerFlags_Left, 1.0);
RGBA_LE(0x333436ffu), 2.0f, ImDrawFlags_RoundCornersLeft, 1.0);

drawList->AddText( ImVec2( pos.x + 4.0f, pos.y + 5.0f ), RGBA_LE(0x44454effu), value );

Expand Down
9 changes: 5 additions & 4 deletions codemp/rd-vulkan/inspector/vk_imgui_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "tr_local.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>

#include "vk_imgui.h"
Expand Down Expand Up @@ -167,7 +168,7 @@ static void vk_imgui_draw_shader_editor_toolbar( shader_t *sh, shader_t *sh_rema
drawList->AddRect(
ImVec2(pos.x, pos.y),
ImVec2((pos.x + region.x) - (sh_updated ? 80.0f : 0), pos.y + height),
RGBA_LE(0x333436ffu), 2.0f, ImDrawCornerFlags_Left, 1.0);
RGBA_LE(0x333436ffu), 2.0f, ImDrawFlags_RoundCornersLeft, 1.0);

drawList->AddText( ImVec2( pos.x + 8.0f, pos.y + 8.0f ), RGBA_LE(0x8f909cffu), sh->name );
}
Expand Down Expand Up @@ -382,7 +383,7 @@ static void vk_imgui_draw_inspector_shader_visualize_surface_params( const char
drawList->AddRect(
ImVec2(tag_pos.x, tag_pos.y),
ImVec2(tag_pos.x + textWidth, tag_pos.y + textHeight),
color_palette[ i % MAX_SHADER_STAGES ], 10.0f, ImDrawCornerFlags_All, 1.0);
color_palette[ i % MAX_SHADER_STAGES ], 10.0f, ImDrawFlags_RoundCornersAll, 1.0);

drawList->AddText( ImVec2( tag_pos.x + 4.0f, tag_pos.y + 3.0f ), color_palette[ i % MAX_SHADER_STAGES ], sh->surfaceParams[i] );

Expand Down Expand Up @@ -442,7 +443,7 @@ static void vk_imgui_draw_inspector_shader_visualize_deforms( const char *label,
drawList->AddRect(
ImVec2(tag_pos.x, tag_pos.y),
ImVec2(tag_pos.x + textWidth, tag_pos.y + textHeight),
color_palette[ i % MAX_SHADER_STAGES ], 10.0f, ImDrawCornerFlags_All, 1.0);
color_palette[ i % MAX_SHADER_STAGES ], 10.0f, ImDrawFlags_RoundCornersAll, 1.0);

drawList->AddText( ImVec2( tag_pos.x + 4.0f, tag_pos.y + 3.0f ), color_palette[ i % MAX_SHADER_STAGES ], vk_deform_string[ (int)sh->deforms[i]->deformation ] );

Expand Down Expand Up @@ -504,7 +505,7 @@ static void vk_imgui_draw_inspector_shader_visualize_tcmod( const char *label, c
drawList->AddRect(
ImVec2(tag_pos.x, tag_pos.y),
ImVec2(tag_pos.x + textWidth, tag_pos.y + textHeight),
color_palette[i], 10.0f, ImDrawCornerFlags_All, 1.0);
color_palette[i], 10.0f, ImDrawFlags_RoundCornersAll, 1.0);

drawList->AddText( ImVec2( tag_pos.x + 4.0f, tag_pos.y + 3.0f ), color_palette[i], name );

Expand Down
2 changes: 2 additions & 0 deletions codemp/rd-vulkan/inspector/vk_imgui_shader_nodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "tr_local.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>

#include "vk_imgui.h"
#include <utils/ImGuiColorTextEdit/TextEditor.h>
#include <utils/ImNodeFlow/include/ImNodeFlow.h>
Expand Down
2 changes: 2 additions & 0 deletions codemp/rd-vulkan/inspector/vk_imgui_shader_nodes_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "tr_local.h"

#define IMGUI_DEFINE_MATH_OPERATORS
#include <imgui.h>

#include "vk_imgui.h"
#include <utils/ImGuiColorTextEdit/TextEditor.h>
#include <utils/ImNodeFlow/include/ImNodeFlow.h>
Expand Down
1 change: 1 addition & 0 deletions codemp/rd-vulkan/utils/ImNodeFlow/include/ImNodeFlow.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define IM_NODE_FLOW

// sunny
#define IMGUI_DEFINE_MATH_OPERATORS
#define USE_ID3_NODE_EDITOR

#ifdef USE_ID3_NODE_EDITOR
Expand Down
2 changes: 1 addition & 1 deletion lib/imgui/include/LICENSE_IMGUI.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014-2022 Omar Cornut
Copyright (c) 2014-2024 Omar Cornut

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading

0 comments on commit aa214c6

Please sign in to comment.