From 32cf361f870dbbf644f7286b70424a6e531ef914 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Sat, 22 Nov 2025 19:31:17 +0530 Subject: [PATCH 01/15] Added hwinfo library for replacing br --- .gitmodules | 3 +++ Karma/CMakeLists.txt | 9 ++++++--- Karma/vendor/hwinfo | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) create mode 160000 Karma/vendor/hwinfo diff --git a/.gitmodules b/.gitmodules index 0c374ed6..031d1de0 100644 --- a/.gitmodules +++ b/.gitmodules @@ -23,3 +23,6 @@ [submodule "Karma/vendor/BiosReader"] path = Karma/vendor/BiosReader url = https://github.com/ravimohan1991/BiosReader.git +[submodule "Karma/vendor/hwinfo"] + path = Karma/vendor/hwinfo + url = https://github.com/ravimohan1991/hwinfo.git diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index f91ae11a..42a0578d 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -181,6 +181,7 @@ add_subdirectory(vendor/assimp) add_subdirectory(vendor/glslang) add_subdirectory(vendor/stb) add_subdirectory(vendor/BiosReader) +add_subdirectory(vendor/hwinfo) list(APPEND ESSENTIAL_LIBS Glad) list(APPEND ESSENTIAL_LIBS GLFW) @@ -190,13 +191,14 @@ if(BUILD_SHARED_LIBS AND NOT MSVC) else() list(APPEND ESSENTIAL_LIBS SDL2-static) endif() -# list(APPEND ESSENTIAL_LIBS ImGUI) list(APPEND ESSENTIAL_LIBS spdlog) list(APPEND ESSENTIAL_LIBS AssImp) list(APPEND ESSENTIAL_LIBS ${Vulkan_LIBRARY}) list(APPEND ESSENTIAL_LIBS GlSlang) list(APPEND ESSENTIAL_LIBS stbimage) list(APPEND ESSENTIAL_LIBS BiosReader) +list(APPEND ESSENTIAL_LIBS hwinfo) + # Print Karma's libraries message(STATUS "########################") @@ -250,18 +252,17 @@ if(BUILD_SHARED_LIBS AND NOT MSVC) else() target_link_libraries(KarmaEngine PUBLIC SDL2-static) endif() -# target_link_libraries(KarmaEngine PUBLIC ImGUI) target_link_libraries(KarmaEngine PUBLIC spdlogging) target_link_libraries(KarmaEngine PUBLIC AssImp) target_link_libraries(KarmaEngine PUBLIC ${Vulkan_LIBRARY}) target_link_libraries(KarmaEngine PUBLIC GlSlang) target_link_libraries(KarmaEngine PUBLIC stbimage) target_link_libraries(KarmaEngine PUBLIC BiosReader) +target_link_libraries(KarmaEngine PUBLIC hwinfo) # Cluster Karma's libraries into a single folder for project/solution visualization set_property(TARGET Glad PROPERTY FOLDER "${KARMALIBRARYFOLDER}") set_property(TARGET AssImp PROPERTY FOLDER "${KARMALIBRARYFOLDER}") -# set_property(TARGET ImGUI PROPERTY FOLDER "${KARMALIBRARYFOLDER}") set_property(TARGET GlSlang PROPERTY FOLDER "${KARMALIBRARYFOLDER}") set_property(TARGET spdlogging PROPERTY FOLDER "${KARMALIBRARYFOLDER}") set_property(TARGET stbimage PROPERTY FOLDER "${KARMALIBRARYFOLDER}") @@ -280,6 +281,7 @@ else() endif() set_property(TARGET BiosReader PROPERTY FOLDER "${KARMALIBRARYFOLDER}") +set_property(TARGET hwinfo PROPERTY FOLDER "${KARMALIBRARYFOLDER}") # INTERFACE (Something that Consumers require but Producers don't) # Since I am a library coder here, I am the Producer @@ -293,6 +295,7 @@ target_include_directories(KarmaEngine ${CMAKE_CURRENT_SOURCE_DIR}/vendor/assimp/contrib ${CMAKE_CURRENT_SOURCE_DIR}/vendor/assimp/include ${CMAKE_CURRENT_SOURCE_DIR}/vendor/BiosReader/src/public + ${CMAKE_CURRENT_SOURCE_DIR}/vendor/hwinfo/include ${Vulkan_INCLUDE_DIR} PUBLIC # where top-level project will look for the library's public headers diff --git a/Karma/vendor/hwinfo b/Karma/vendor/hwinfo new file mode 160000 index 00000000..2577d97b --- /dev/null +++ b/Karma/vendor/hwinfo @@ -0,0 +1 @@ +Subproject commit 2577d97bbe62708ceb4e31bd173aebd3e9f0bfc8 From 13e1218cbcde98bcfca5bdb2c8d93c47408a3c9a Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Sat, 22 Nov 2025 20:02:09 +0530 Subject: [PATCH 02/15] Added basic GPU identification from hwinfo in Karma's about --- Pranjal/Source/Private/KarmaGuiMesa.cpp | 30 +++++++++++++++---------- Pranjal/Source/Public/KarmaGuiMesa.h | 3 +++ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index b5498d67..a1b0d2f0 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -11,7 +11,8 @@ #include "KarmaGuiMesa.h" #include "Karma/Application.h" - +#include "hwinfo/hwinfo.h" +#include "hwinfo/utils/unit.h" #include "spdlog/sinks/callback_sink.h" // Experimental @@ -750,8 +751,6 @@ namespace Karma height = backendData->GetTextureHeightAtIndex(0); { - //KGVec2 position = KarmaGui::GetCursorScreenPos(); - KGVec2 uvMin = KGVec2(0.0f, 0.0f); // Top-left KGVec2 uvMax = KGVec2(1.0f, 1.0f); // Lower-right KGVec4 tint_col = KGVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint @@ -791,7 +790,7 @@ namespace Karma KarmaGuiIO& io = KarmaGui::GetIO(); KarmaGuiStyle& style = KarmaGui::GetStyle(); - /*bool copy_to_clipboard =*/ KarmaGui::Button("Copy to clipboard"); + /*bool copy_to_clipboard =*/ KarmaGui::Button("Copy to clipboard"); } KarmaGui::Separator(); @@ -923,6 +922,7 @@ namespace Karma KarmaGui::Text("Manufacturer: %s", electronicsItems.gpuVendor.c_str()); KarmaGui::Text("Model: %s", electronicsItems.gpuModelIdentification.c_str()); + KarmaGui::Text("VRam: %s", electronicsItems.gpuVMemory.c_str()); KarmaGui::Separator(); @@ -1049,17 +1049,23 @@ namespace Karma KR_WARN("BiosReader isn't behaving normally"); } - catcher = electronics_spit(ps_graphicscard); - - if (graphics_processing_unit* gInfo = static_cast(catcher)) + auto gpus = hwinfo::getAllGPUs(); + + if(gpus.size() == 0) { - electronicsItems.gpuModelIdentification = gInfo->gpuModel != nullptr ? gInfo->gpuModel : notAvailableText; - electronicsItems.gpuVendor = gInfo->vendor ? gInfo->vendor : notAvailableText; - electronicsItems.gpuVMemory = gInfo->grandtotalvideomemory ? gInfo->grandtotalvideomemory : notAvailableText; + electronicsItems.gpuModelIdentification = notAvailableText; + electronicsItems.gpuVendor = notAvailableText; + + electronicsItems.gpuVMemory = notAvailableText; } - else + + for(const auto& gpu : gpus) { - KR_WARN("BiosReader isn't behaving normally"); + electronicsItems.gpuModelIdentification = gpu.name() != "" ? gpu.name() : notAvailableText; + electronicsItems.gpuVendor = gpu.vendor() != "" ? gpu.vendor() : notAvailableText; + + electronicsItems.gpuVMemory = gpu.memory_Bytes() != 0 ? std::to_string(hwinfo::unit::bytes_to_MiB(gpu.memory_Bytes())) : notAvailableText; + break; } electronicsItems.bHasQueried = true; diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index f6d1e37c..855ca401 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -261,8 +261,11 @@ namespace Karma // For now, with due respect, let there be enough content with just model number // und vendor. Would be dope to read the GPU just like RAM or CPU, from SMBIOS!! + + // Ok thanks to shadPS4 emulator, we are using dope library hwinfo std::string gpuVendor; std::string gpuModelIdentification; + std::string gpuVMemory; KarmaTuringMachineElectronics() From a95ca8973a92156ba3461b991e556504e19275ce Mon Sep 17 00:00:00 2001 From: pc_boy Date: Sat, 22 Nov 2025 20:24:12 +0530 Subject: [PATCH 03/15] hwinfo dll output to KarmaBin --- Karma/CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index 42a0578d..dc99b22c 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -170,12 +170,14 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_compile_definitions(KR_DEBUG) endif() +# Telling hwinfo to output library dll to our KarmaBin folder +set(HWINFO_CMAKE_BINARY_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}) + # Involved libraries and essentials add_subdirectory(vendor/Glad) add_subdirectory(vendor/GLFW) add_subdirectory(vendor/GLM) add_subdirectory(vendor/SDL) -# add_subdirectory(vendor/ImGui) add_subdirectory(vendor/spdlog) add_subdirectory(vendor/assimp) add_subdirectory(vendor/glslang) From d78233fddf721d13608b17ac9788d4ce43e3b473 Mon Sep 17 00:00:00 2001 From: pcboy Date: Sun, 23 Nov 2025 07:19:50 +0530 Subject: [PATCH 04/15] hwinfo trial on Ubuntu --- CMakeLists.txt | 4 +- Karma/vendor/BiosReader | 2 +- Pranjal/CMakeLists.txt | 22 ----------- Pranjal/Source/Private/KarmaGuiMesa.cpp | 49 ++++++------------------- Pranjal/Source/Public/KarmaGuiMesa.h | 7 +--- 5 files changed, 16 insertions(+), 68 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 10c21118..f1f0793c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,6 +24,7 @@ set(KARMALIBRARYFOLDER "CompanionLibraries") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${REPOSITORYROOT}/KarmaBin") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${REPOSITORYROOT}/KarmaBin") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${REPOSITORYROOT}/KarmaBin") # Set the GameName @@ -75,9 +76,6 @@ add_subdirectory(Pranjal) target_link_libraries(SandBox PUBLIC KarmaEngine) target_link_libraries(Pranjal PUBLIC KarmaEngine) -# Need to find a way to give access to the resources (assets and whatnot) to the built binaries - - #[[ * /\ * / / diff --git a/Karma/vendor/BiosReader b/Karma/vendor/BiosReader index cd54c508..1dfc58b1 160000 --- a/Karma/vendor/BiosReader +++ b/Karma/vendor/BiosReader @@ -1 +1 @@ -Subproject commit cd54c508c3f08ee0b6f27707dd78554981b2595e +Subproject commit 1dfc58b10106941fe878b9718bd369ca397ec3b1 diff --git a/Pranjal/CMakeLists.txt b/Pranjal/CMakeLists.txt index 516a104b..b3790725 100644 --- a/Pranjal/CMakeLists.txt +++ b/Pranjal/CMakeLists.txt @@ -73,28 +73,6 @@ elseif(XCODE) XCODE_SCHEME_WORKING_DIRECTORY "${REPOSITORYROOT}/KarmaBin") endif() - -# Post build commands -#[[ -if(UNIX AND NOT APPLE) - if (BUILD_SHARED_LIBS) - set(Library_NAME "libBiosReader.so") - else() - set(Library_NAME "BiosReader") - endif() - - add_custom_command(TARGET Pranjal POST_BUILD - COMMAND cd ${REPOSITORYROOT}/KarmaBin - COMMAND mkdir temp - COMMAND cp ${Library_NAME} temp/${Library_NAME} - COMMAND cd temp - COMMAND sudo install -o root -g root -m u=rxs,g-rx,o=x -t ${REPOSITORYROOT}/KarmaBin/ ${Library_NAME} - COMMAND rm ${Library_NAME} - COMMAND cd ${REPOSITORYROOT}/KarmaBin - COMMAND sudo rmdir temp - ) -endif() -]] #[[ * /\ * / / diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index a1b0d2f0..cd197e6c 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -830,16 +830,9 @@ namespace Karma KarmaGui::Separator(); KarmaGui::Text("Vendor: %s", electronicsItems.biosVendorName.c_str()); - KarmaGui::Text("Supplied On: %s", electronicsItems.biosReleaseDate.c_str()); - KarmaGui::Text("ROM Size: %s", electronicsItems.biosROMSize.c_str()); - KarmaGui::Text("Current Language: %s", electronicsItems.biosCurrentSetLanguage.c_str()); - KarmaGui::Text("Supported Languages:"); - KarmaGui::Indent(); - KarmaGui::Text("%s", electronicsItems.biosRestOfTheSupportedLanguages.c_str()); - KarmaGui::Unindent(); - KarmaGui::Text("BIOS Characteristics:"); - KarmaGui::Indent(); - KarmaGui::Text("%s", electronicsItems.biosCharacteristics.c_str()); + KarmaGui::Text("MotherBoard: %s", electronicsItems.biosBoardName.c_str()); + KarmaGui::Text("MotherBoard Serial: %s", electronicsItems.biosSerialNumber.c_str()); + KarmaGui::Text("BIOS Version: %s", electronicsItems.biosVersion.c_str()); KarmaGui::Unindent(); KarmaGui::Separator(); @@ -950,34 +943,16 @@ namespace Karma } // Catcher rhymes with Hatcher, the Topologist, just for information! - void* catcher = electronics_spit(ss_bios); - - if (bios_information* bInfo = static_cast(catcher)) - { - electronicsItems.biosVendorName = bInfo->vendor != nullptr ? bInfo->vendor : notAvailableText; - electronicsItems.biosVersion = bInfo->version != nullptr ? bInfo->version : notAvailableText; - electronicsItems.biosReleaseDate = bInfo->biosreleasedate != nullptr ? bInfo->biosreleasedate : notAvailableText; - electronicsItems.biosROMSize = bInfo->biosromsize != nullptr ? bInfo->biosromsize : notAvailableText; - electronicsItems.biosCharacteristics = bInfo->bioscharacteristics[0] != '\0' ? bInfo->bioscharacteristics : notAvailableText; - } - else - { - KR_WARN("BiosReader isn't behaving normally."); - } + void* catcher = nullptr;// = electronics_spit(ss_bios); - catcher = electronics_spit(pi_bioslanguages); + hwinfo::MainBoard mainboard; - if (mb_language_modules* mbLangModules = static_cast(catcher)) - { - electronicsItems.biosCurrentSetLanguage = mbLangModules->currentactivemodule != nullptr ? mbLangModules->currentactivemodule : notAvailableText; - electronicsItems.biosRestOfTheSupportedLanguages = mbLangModules->supportedlanguagemodules != nullptr ? mbLangModules->supportedlanguagemodules : notAvailableText; - } - else - { - KR_WARN("BiosReader isn't behaving normally."); - } + electronicsItems.biosVendorName = mainboard.vendor() != "" ? mainboard.vendor() : notAvailableText; + electronicsItems.biosBoardName = mainboard.name() != "" ? mainboard.name() : notAvailableText; + electronicsItems.biosVersion = mainboard.version() != "" ? mainboard.version() : notAvailableText; + electronicsItems.biosSerialNumber = mainboard.serialNumber() != "" ? mainboard.serialNumber() : notAvailableText; - catcher = electronics_spit(pi_systemmemory); + //catcher = electronics_spit(pi_systemmemory); if (turing_machine_system_memory* tInfo = static_cast(catcher)) { electronicsItems.estimatedCapacity = tInfo->total_grand_capacity != nullptr ? tInfo->total_grand_capacity : notAvailableText; @@ -989,7 +964,7 @@ namespace Karma KR_WARN("BiosReader isn't behaving normally."); } - catcher = electronics_spit(ps_systemmemory); + //catcher = electronics_spit(ps_systemmemory); // Now since there may be more than one Ram type of electronics, and given that BIOS lies, we need a mechanism // to gauge the true amount of every estimation we obtained earlier @@ -1021,7 +996,7 @@ namespace Karma KR_WARN("BiosReader isn't behaving normally."); } - catcher = electronics_spit(ps_processor); + //catcher = electronics_spit(ps_processor); if (central_processing_unit* pInfo = static_cast(catcher)) { diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index 855ca401..84e7c06d 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -186,12 +186,9 @@ namespace Karma // Bios Information std::string biosVendorName; + std::string biosSerialNumber; std::string biosVersion; - std::string biosReleaseDate; - std::string biosCharacteristics; - std::string biosROMSize; - std::string biosCurrentSetLanguage; - std::string biosRestOfTheSupportedLanguages; + std::string biosBoardName; // System Memory (RAM) overview uint32_t numberOfMemoryDevices;// An estimation. I shall manually introduce logical checks From ab21eed6ece1a41601dff1e4a4fd7c691ca5111f Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Sun, 23 Nov 2025 10:11:53 +0530 Subject: [PATCH 05/15] White spacing and minor comment --- Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp | 272 +++++++++--------- Pranjal/Source/Private/KarmaGuiMesa.cpp | 31 +- Pranjal/Source/Public/KarmaGuiMesa.h | 4 +- 3 files changed, 143 insertions(+), 164 deletions(-) diff --git a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp index 0bc03a81..6a56f828 100644 --- a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp +++ b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp @@ -455,71 +455,65 @@ namespace Karma return; } - vkResetCommandBuffer(frameOnFlightData->CommandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); + vkResetCommandBuffer(frameOnFlightData->CommandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); // recording begins: - { - VkCommandBufferBeginInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; - - result = vkBeginCommandBuffer(frameOnFlightData->CommandBuffer, &info); - KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't begin commandbuffer recording"); - } - - for(auto it = backendData->Elements3DTo2D.begin(); it != backendData->Elements3DTo2D.end(); ++it) - { - { - VkRenderPassBeginInfo renderPassInfo{}; - renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - renderPassInfo.renderPass = it->RenderPass; - renderPassInfo.framebuffer = it->FrameBuffers[windowData->ImageFrameIndex]; - renderPassInfo.renderArea.offset = {0, 0}; - renderPassInfo.renderArea.extent.width = it->Size.x; - renderPassInfo.renderArea.extent.height = it->Size.y; - - // Define clear values for the color and depth attachments - std::vector clearValues(2); - clearValues[0].color = {{0.0f, 0.0f, 0.0f, 1.0f}}; // Clear color to black - clearValues[1].depthStencil = {1.0f, 0}; // Clear depth to 1.0 (farthest) - - renderPassInfo.clearValueCount = static_cast(clearValues.size()); - renderPassInfo.pClearValues = clearValues.data(); - - // The pass starts here and all commands until vkCmdEndRenderPass are recorded into it - vkCmdBeginRenderPass(frameOnFlightData->CommandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); - - std::shared_ptr vulkanVA = static_pointer_cast(it->Scene3D->GetRenderableVertexArray()); - - vkCmdBindPipeline(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetKarmaGuiGraphicsPipeline()); - - // Bind 3D Vertex And Index Buffers: - { - VkBuffer vertexBuffers[1] = { vulkanVA->GetVertexBuffer()->GetVertexBuffer() }; - VkDeviceSize vertexOffset[1] = { 0 }; - vkCmdBindVertexBuffers(frameOnFlightData->CommandBuffer, 0, 1, vertexBuffers, vertexOffset); - vkCmdBindIndexBuffer(frameOnFlightData->CommandBuffer, vulkanVA->GetIndexBuffer()->GetIndexBuffer(), 0, VK_INDEX_TYPE_UINT32); - } - - vulkanVA->UpdateProcessAndSetReadyForSubmission(); - vulkanVA->Bind(); - - VulkanHolder::GetVulkanContext()->UploadUBO(windowData->SemaphoreIndex); - - // Bind descriptor sets (e.g., uniforms for MVP matrices, lighting) - // Assumes layout compatibility between pipeline and descriptor set - vkCmdBindDescriptorSets(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetGraphicsPipelineLayout(), 0, 1, &vulkanVA->GetDescriptorSets()[windowData->SemaphoreIndex], 0, nullptr); - - // --- 4. Issue Draw Commands --- - - // Draw 3D scene geometry on 2D rendertarget (it->FrameBuffers) - vkCmdDrawIndexed(frameOnFlightData->CommandBuffer, vulkanVA->GetIndexBuffer()->GetCount(), 1, 0, 0, 0); - - // --- 5. End the Offscreen Render Pass --- + { + VkCommandBufferBeginInfo info = {}; + info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; + info.flags = VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT; + + result = vkBeginCommandBuffer(frameOnFlightData->CommandBuffer, &info); + KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't begin commandbuffer recording"); + } - vkCmdEndRenderPass(frameOnFlightData->CommandBuffer); - } - } + for(auto it = backendData->Elements3DTo2D.begin(); it != backendData->Elements3DTo2D.end(); ++it) + { + { + VkRenderPassBeginInfo renderPassInfo{}; + renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; + renderPassInfo.renderPass = it->RenderPass; + renderPassInfo.framebuffer = it->FrameBuffers[windowData->ImageFrameIndex]; + renderPassInfo.renderArea.offset = {0, 0}; + renderPassInfo.renderArea.extent.width = it->Size.x; + renderPassInfo.renderArea.extent.height = it->Size.y; + // Define clear values for the color and depth attachments + std::vector clearValues(2); + clearValues[0].color = {{0.0f, 0.0f, 0.0f, 0.0f}}; // Clear color to transparent + clearValues[1].depthStencil = {1.0f, 0}; // Clear depth to 1.0 (farthest) + renderPassInfo.clearValueCount = static_cast(clearValues.size()); + renderPassInfo.pClearValues = clearValues.data(); + + // The pass starts here and all commands until vkCmdEndRenderPass are recorded into it + vkCmdBeginRenderPass(frameOnFlightData->CommandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE); + std::shared_ptr vulkanVA = static_pointer_cast(it->Scene3D->GetRenderableVertexArray()); + vkCmdBindPipeline(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetKarmaGuiGraphicsPipeline()); + + // Bind 3D Vertex And Index Buffers: + { + VkBuffer vertexBuffers[1] = { vulkanVA->GetVertexBuffer()->GetVertexBuffer() }; + VkDeviceSize vertexOffset[1] = { 0 }; + vkCmdBindVertexBuffers(frameOnFlightData->CommandBuffer, 0, 1, vertexBuffers, vertexOffset); + vkCmdBindIndexBuffer(frameOnFlightData->CommandBuffer, vulkanVA->GetIndexBuffer()->GetIndexBuffer(), 0, VK_INDEX_TYPE_UINT32); + } + + vulkanVA->UpdateProcessAndSetReadyForSubmission(); + vulkanVA->Bind(); + + VulkanHolder::GetVulkanContext()->UploadUBO(windowData->SemaphoreIndex); + + // Bind descriptor sets (e.g., uniforms for MVP matrices, lighting) + // Assumes layout compatibility between pipeline and descriptor set + vkCmdBindDescriptorSets(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetGraphicsPipelineLayout(), 0, 1, &vulkanVA->GetDescriptorSets()[windowData->SemaphoreIndex], 0, nullptr); + + // --- 4. Issue Draw Commands --- + // Draw 3D scene geometry on 2D rendertarget (it->FrameBuffers) + vkCmdDrawIndexed(frameOnFlightData->CommandBuffer, vulkanVA->GetIndexBuffer()->GetCount(), 1, 0, 0, 0); + + // --- 5. End the Offscreen Render Pass --- + vkCmdEndRenderPass(frameOnFlightData->CommandBuffer); + } + } // Render Pass VkRenderPassBeginInfo renderPassInfo = {}; @@ -540,8 +534,8 @@ namespace Karma { // Record KarmaGui primitives into command buffer - KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_RenderDrawData(drawData, frameOnFlightData->CommandBuffer, VK_NULL_HANDLE, windowData->SemaphoreIndex); - } + KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_RenderDrawData(drawData, frameOnFlightData->CommandBuffer, VK_NULL_HANDLE, windowData->SemaphoreIndex); + } vkCmdEndRenderPass(frameOnFlightData->CommandBuffer); @@ -553,19 +547,19 @@ namespace Karma // Submit command buffer VkPipelineStageFlags waitStage = VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT; - VkSubmitInfo submitInfo = {}; + VkSubmitInfo submitInfo = {}; submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; submitInfo.waitSemaphoreCount = 1; submitInfo.pWaitSemaphores = &imageAcquiredSemaphore; submitInfo.pWaitDstStageMask = &waitStage; - submitInfo.commandBufferCount = 1; - submitInfo.pCommandBuffers = &frameOnFlightData->CommandBuffer; + submitInfo.commandBufferCount = 1; + submitInfo.pCommandBuffers = &frameOnFlightData->CommandBuffer; submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &renderCompleteSemaphore; result = vkQueueSubmit(vulkanInfo->Queue, 1, &submitInfo, frameOnFlightData->Fence); KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to submit queue"); - } + } void KarmaGuiRenderer::FramePresent(KarmaGui_ImplVulkanH_Window* windowData) { @@ -605,7 +599,7 @@ namespace Karma { if(it->Scene3D == scene) { - return it->KarmaGui_Textures[m_VulkanWindowData.ImageFrameIndex]; + return it->KarmaGui_Textures[m_VulkanWindowData.ImageFrameIndex]; } } @@ -637,85 +631,85 @@ namespace Karma result = vkCreateSampler(vulkanInfo->Device, &samplerInfo, vulkanInfo->Allocator, &SceneToTexture.Sampler); KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't create sampler"); - uint32_t numberOfSwapChainImages = VulkanHolder::GetVulkanContext()->GetSwapChainImages().size(); - - SceneToTexture.Images.resize(numberOfSwapChainImages); - SceneToTexture.DeviceMemory.resize(numberOfSwapChainImages); - SceneToTexture.Image_Views.resize(numberOfSwapChainImages); - SceneToTexture.KarmaGui_Textures.resize(numberOfSwapChainImages); - - for(uint32_t i = 0; i < numberOfSwapChainImages; i++) - { - // Create images (along with appropriate memory) - { - VkImageCreateInfo imageCreateCI{}; - imageCreateCI.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - imageCreateCI.imageType = VK_IMAGE_TYPE_2D; - imageCreateCI.format = VK_FORMAT_R8G8B8A8_UNORM; - imageCreateCI.extent.width = dimensions.x; - imageCreateCI.extent.height = dimensions.y; - imageCreateCI.extent.depth = 1; - imageCreateCI.arrayLayers = 1; - imageCreateCI.mipLevels = 1; - imageCreateCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; - imageCreateCI.samples = VK_SAMPLE_COUNT_1_BIT; - imageCreateCI.tiling = VK_IMAGE_TILING_OPTIMAL; - imageCreateCI.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; - imageCreateCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; - - result = vkCreateImage(vulkanInfo->Device, &imageCreateCI, vulkanInfo->Allocator, &SceneToTexture.Images[i]); - KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't create a image"); - - VkMemoryRequirements req; - vkGetImageMemoryRequirements(vulkanInfo->Device, SceneToTexture.Images[i], &req); - VkMemoryAllocateInfo allocInfo = {}; - allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - allocInfo.allocationSize = req.size; - allocInfo.memoryTypeIndex = KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits); - - result = vkAllocateMemory(vulkanInfo->Device, &allocInfo, vulkanInfo->Allocator, &SceneToTexture.DeviceMemory[i]); - KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't allocate memory"); - - result = vkBindImageMemory(vulkanInfo->Device, SceneToTexture.Images[i], SceneToTexture.DeviceMemory[i], 0); - KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't bind image memory"); - } - - // insert image memory barrier for VK_IMAGE_LAYOUT_UNDEFINED -> VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL? - - // Create image view: - { - VkImageViewCreateInfo viewInfo{}; - viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - viewInfo.image = SceneToTexture.Images[i]; - viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; - viewInfo.format = VK_FORMAT_R8G8B8A8_UNORM; - viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; - viewInfo.subresourceRange.baseMipLevel = 0; - viewInfo.subresourceRange.levelCount = 1; - viewInfo.subresourceRange.baseArrayLayer = 0; - viewInfo.subresourceRange.layerCount = 1; - - result = vkCreateImageView(vulkanInfo->Device, &viewInfo, vulkanInfo->Allocator, &SceneToTexture.Image_Views[i]); - KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't create image view"); - } - - SceneToTexture.KarmaGui_Textures[i] = KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_AddTexture(SceneToTexture.Sampler, SceneToTexture.Image_Views[i], VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); - } + uint32_t numberOfSwapChainImages = VulkanHolder::GetVulkanContext()->GetSwapChainImages().size(); + + SceneToTexture.Images.resize(numberOfSwapChainImages); + SceneToTexture.DeviceMemory.resize(numberOfSwapChainImages); + SceneToTexture.Image_Views.resize(numberOfSwapChainImages); + SceneToTexture.KarmaGui_Textures.resize(numberOfSwapChainImages); + + for(uint32_t i = 0; i < numberOfSwapChainImages; i++) + { + // Create images (along with appropriate memory) + { + VkImageCreateInfo imageCreateCI{}; + imageCreateCI.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; + imageCreateCI.imageType = VK_IMAGE_TYPE_2D; + imageCreateCI.format = VK_FORMAT_R8G8B8A8_UNORM; + imageCreateCI.extent.width = dimensions.x; + imageCreateCI.extent.height = dimensions.y; + imageCreateCI.extent.depth = 1; + imageCreateCI.arrayLayers = 1; + imageCreateCI.mipLevels = 1; + imageCreateCI.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED; + imageCreateCI.samples = VK_SAMPLE_COUNT_1_BIT; + imageCreateCI.tiling = VK_IMAGE_TILING_OPTIMAL; + imageCreateCI.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT; + imageCreateCI.sharingMode = VK_SHARING_MODE_EXCLUSIVE; + + result = vkCreateImage(vulkanInfo->Device, &imageCreateCI, vulkanInfo->Allocator, &SceneToTexture.Images[i]); + KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't create a image"); + + VkMemoryRequirements req; + vkGetImageMemoryRequirements(vulkanInfo->Device, SceneToTexture.Images[i], &req); + VkMemoryAllocateInfo allocInfo = {}; + allocInfo.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; + allocInfo.allocationSize = req.size; + allocInfo.memoryTypeIndex = KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_MemoryType(VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, req.memoryTypeBits); + + result = vkAllocateMemory(vulkanInfo->Device, &allocInfo, vulkanInfo->Allocator, &SceneToTexture.DeviceMemory[i]); + KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't allocate memory"); + + result = vkBindImageMemory(vulkanInfo->Device, SceneToTexture.Images[i], SceneToTexture.DeviceMemory[i], 0); + KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't bind image memory"); + } + + // insert image memory barrier for VK_IMAGE_LAYOUT_UNDEFINED -> VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL? + + // Create image view: + { + VkImageViewCreateInfo viewInfo{}; + viewInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; + viewInfo.image = SceneToTexture.Images[i]; + viewInfo.viewType = VK_IMAGE_VIEW_TYPE_2D; + viewInfo.format = VK_FORMAT_R8G8B8A8_UNORM; + viewInfo.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; + viewInfo.subresourceRange.baseMipLevel = 0; + viewInfo.subresourceRange.levelCount = 1; + viewInfo.subresourceRange.baseArrayLayer = 0; + viewInfo.subresourceRange.layerCount = 1; + + result = vkCreateImageView(vulkanInfo->Device, &viewInfo, vulkanInfo->Allocator, &SceneToTexture.Image_Views[i]); + KR_CORE_ASSERT(result == VK_SUCCESS, "Couldn't create image view"); + } + + SceneToTexture.KarmaGui_Textures[i] = KarmaGuiVulkanHandler::KarmaGui_ImplVulkan_AddTexture(SceneToTexture.Sampler, SceneToTexture.Image_Views[i], VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); + } backendData->Elements3DTo2D.push_back(SceneToTexture); // OffScreen texture (3D scene to 2D texture) resources like renderpass, framebuffers, and depth resources - // for the SceneToTexture element. We may be creating some resources again when not required, when new element is added - // resources for previous elements are also created. So take care of that. + // for the SceneToTexture element. We may be creating some resources again when not required, when new element is added + // resources for previous elements are also created. So take care of that. KarmaGuiVulkanHandler::CreateOffScreenTextureResources(); - // Set the renderpass for vulkanvertexarrays because graphicspipeline needs rebuilt (or be of different use) - KarmaGuiVulkanHandler::PrepareVertexArrayaForKarmaGuiWindowRendering(); + // Set the renderpass for vulkanvertexarrays because graphicspipeline needs rebuilt (or be of different use) + KarmaGuiVulkanHandler::PrepareVertexArrayaForKarmaGuiWindowRendering(); - return SceneToTexture.KarmaGui_Textures[m_VulkanWindowData.ImageFrameIndex]; + return SceneToTexture.KarmaGui_Textures[m_VulkanWindowData.ImageFrameIndex]; } - return nullptr; + return nullptr; } KGTextureID KarmaGuiBackendRendererUserData::GetTextureIDAtIndex(uint32_t index) diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index cd197e6c..97ae18c4 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -524,30 +524,17 @@ namespace Karma KarmaGuiBackendRendererUserData* backendData = KarmaGuiRenderer::GetBackendRendererUserData(); backgroundImageTextureID = backendData->GetTextureIDAtIndex(1); - //width = backendData->GetTextureWidthAtIndex(1); - //height = backendData->GetTextureHeightAtIndex(1); - KGTextureID TextureID3D = KarmaGuiRenderer::Add3DSceneFor2DRendering(scene, KGVec2(window->Size.x, window->Size.y)); - KarmaGui::Image(TextureID3D, KGVec2(window->Size.x, window->Size.y)); - - //ImGui::GetCurrentWindow()->DrawList->SetWindowBackgroundColor(bgColor); - - KGDrawCallback sceneCallBack = [](const KGDrawList* parentList, const KGDrawCmd* drawCommand) - { - //KR_INFO("Scene Callback"); - }; - - //KGGuiWindow* theWindow = KarmaGuiInternal::GetCurrentWindow(); + KGTextureID textureID3D = KarmaGuiRenderer::Add3DSceneFor2DRendering(scene, KGVec2(window->Size.x, window->Size.y)); + + KGDrawList* drawList = KarmaGui::GetWindowDrawList(); + KGVec2 pos = KarmaGui::GetCursorScreenPos(); + + drawList->AddImage((void*)backgroundImageTextureID, pos, KGVec2(pos.x + window->Size.x, pos.y + window->Size.y)); + drawList->AddImage((void*)textureID3D, pos, KGVec2(pos.x + window->Size.x, pos.y + window->Size.y)); + scene->SetRenderWindow(window); - { - KGVec2 uvMin = KGVec2(0.0f, 0.0f); // Top-left - KGVec2 uvMax = KGVec2(1.0f, 1.0f); // Lower-right - KGVec4 tint_col = KGVec4(1.0f, 1.0f, 1.0f, 1.0f); // No tint - KGVec4 border_col = KGVec4(1.0f, 1.0f, 1.0f, 0.5f); // 50% opaque white - KarmaGui::Image(backgroundImageTextureID, KGVec2(window->Size.x, window->Size.y), uvMin, uvMax, tint_col, border_col); - } - if(window->Size.x != m_3DExhibitor.widthCache || window->Size.y != m_3DExhibitor.heightCache) { scene->SetWindowToRenderWithinResize(true); @@ -574,8 +561,6 @@ namespace Karma scene->SetWindowToRenderWithinResize(false); } - //KarmaGui::GetWindowDrawList()->AddCallback(sceneCallBack, (void*)scene.get()); - if (m_RefreshRenderingResources) { scene->SetWindowToRenderWithinResize(true); diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index 84e7c06d..c90cac17 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -186,9 +186,9 @@ namespace Karma // Bios Information std::string biosVendorName; - std::string biosSerialNumber; + std::string biosSerialNumber; std::string biosVersion; - std::string biosBoardName; + std::string biosBoardName; // System Memory (RAM) overview uint32_t numberOfMemoryDevices;// An estimation. I shall manually introduce logical checks From c243b0901e07481f23cd648dda79854fdcab4553 Mon Sep 17 00:00:00 2001 From: pcboy Date: Sun, 23 Nov 2025 14:16:29 +0530 Subject: [PATCH 06/15] CPU information gauging by hwinfo --- Pranjal/Source/Private/KarmaGuiMesa.cpp | 112 ++++++++++-------------- Pranjal/Source/Public/KarmaGuiMesa.h | 48 ++++------ 2 files changed, 63 insertions(+), 97 deletions(-) diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index 97ae18c4..112c7322 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -818,15 +818,16 @@ namespace Karma KarmaGui::Text("MotherBoard: %s", electronicsItems.biosBoardName.c_str()); KarmaGui::Text("MotherBoard Serial: %s", electronicsItems.biosSerialNumber.c_str()); KarmaGui::Text("BIOS Version: %s", electronicsItems.biosVersion.c_str()); - KarmaGui::Unindent(); KarmaGui::Separator(); - KarmaGui::Text("Machine System Memory (RAM and all that)"); + KarmaGui::Text("Machine System Memory (RAM)"); KarmaGui::Separator(); - KarmaGui::Text("Supporting Area: %s", electronicsItems.supportingArea.c_str()); - KarmaGui::Text("Estimated Capacity: %s", electronicsItems.estimatedCapacity.c_str()); - KarmaGui::Text("Total such devices (est): %d", electronicsItems.numberOfMemoryDevices); + KarmaGui::Text("Total Capacity (MiB): %s", electronicsItems.memoryCapacity.c_str()); + KarmaGui::Text("Free Memory (MiB): %s", electronicsItems.freeMemory.c_str()); + + KarmaGui::Text("Total modules: %d", electronicsItems.numberOfMemoryDevices); + KarmaGui::Text("Physical devices present:"); for (uint32_t counter = 0; counter < electronicsItems.ramSoftSlots.size(); counter++) @@ -865,33 +866,20 @@ namespace Karma KarmaGui::Text("Central Processor Unit"); KarmaGui::Separator(); - KarmaGui::Text("Manufacturer: %s", electronicsItems.cpuManufacturer.c_str()); - KarmaGui::Text("Processor Family: %s", electronicsItems.cpuProcessingfamily.c_str()); - KarmaGui::Text("Version: %s", electronicsItems.cpuVersion.c_str()); + KarmaGui::Text("Manufacturer: %s", electronicsItems.cpuInformation.cpuVendor.c_str()); + KarmaGui::Text("Processor Family: %s", electronicsItems.cpuInformation.cpuModel.c_str()); KarmaGui::Text("CPU Conditions"); KarmaGui::Indent(); - KarmaGui::Text("Speed (Current | Maximum): %s | %s", electronicsItems.cpuCurrentSpeed.c_str(), electronicsItems.cpuMaximumSpeed.c_str()); - KarmaGui::Text("External Clock: %s", electronicsItems.cpuExternalClock.c_str()); - KarmaGui::Text("Cores (Current | Maximum): %s | %s", electronicsItems.cpuEnabledCoresCount.c_str(), electronicsItems.cpuCorescount.c_str()); - KarmaGui::Text("Threads Count: %s", electronicsItems.cpuThreadCount.c_str()); - KarmaGui::Text("Operating Voltage: %s", electronicsItems.cpuOperatingVoltage.c_str()); + KarmaGui::Text("Speed (MHz): %s", electronicsItems.cpuInformation.cpuFrequency.c_str()); + KarmaGui::Text("Cores (Logical | Physical): %s | %s", electronicsItems.cpuInformation.cpuLogicalCores.c_str(), electronicsItems.cpuInformation.cpuPhysicalCores.c_str()); KarmaGui::Unindent(); KarmaGui::Text("CPU Tags or Numbers"); KarmaGui::Indent(); - KarmaGui::Text("Signature: %s", electronicsItems.cpuSignature.c_str()); - KarmaGui::Text("ID: %s", electronicsItems.cpuid.c_str()); - KarmaGui::Text("Part Number: %s", electronicsItems.cpuPartNumber.c_str()); - KarmaGui::Text("Serial Number: %s", electronicsItems.cpuSerialNumber.c_str()); - KarmaGui::Text("Asset Tag: %s", electronicsItems.cpuAssettag.c_str()); - KarmaGui::Unindent(); - KarmaGui::Text("CPU Characteristics"); - KarmaGui::Indent(); - KarmaGui::Text("%s", electronicsItems.cpuTheCharacterstics.c_str()); - KarmaGui::Unindent(); - KarmaGui::Text("Flags:"); - KarmaGui::Indent(); - KarmaGui::Text("%s", electronicsItems.cpuFlags.c_str()); - KarmaGui::Unindent(); + KarmaGui::Text("Caches (MegaBytes)"); + KarmaGui::Text("L1 Cache : %s", electronicsItems.cpuInformation.cpuCacheSizeL1.c_str()); + KarmaGui::Text("L2 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL2.c_str()); + KarmaGui::Text("L3 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL3.c_str()); + KarmaGui::Unindent(); KarmaGui::Separator(); @@ -937,17 +925,23 @@ namespace Karma electronicsItems.biosVersion = mainboard.version() != "" ? mainboard.version() : notAvailableText; electronicsItems.biosSerialNumber = mainboard.serialNumber() != "" ? mainboard.serialNumber() : notAvailableText; - //catcher = electronics_spit(pi_systemmemory); - if (turing_machine_system_memory* tInfo = static_cast(catcher)) - { - electronicsItems.estimatedCapacity = tInfo->total_grand_capacity != nullptr ? tInfo->total_grand_capacity : notAvailableText; - electronicsItems.numberOfMemoryDevices = tInfo->number_of_ram_or_system_memory_devices != 0 ? tInfo->number_of_ram_or_system_memory_devices : 0; - electronicsItems.supportingArea = tInfo->mounting_location != nullptr ? tInfo->mounting_location : notAvailableText; - } - else - { - KR_WARN("BiosReader isn't behaving normally."); - } + hwinfo::Memory memory; + + electronicsItems.memoryCapacity = std::to_string(hwinfo::unit::bytes_to_MiB(memory.total_Bytes())); + electronicsItems.freeMemory = std::to_string(hwinfo::unit::bytes_to_MiB(memory.free_Bytes())); + + electronicsItems.numberOfMemoryDevices = memory.modules().size(); + + for(const auto& module : memory.modules()) + { + KR_INFO("ID: {0}", module.id); + KR_INFO("Frequencey (Hz): {0}", module.frequency_Hz == -1 ? -1 : static_cast(module.frequency_Hz) / 1e6); + KR_INFO("Name: {0}", module.name); + KR_INFO("Serial Number: {0}", module.serial_number); + KR_INFO("Vendor: {0}", module.vendor); + KR_INFO("Model: {0}", module.model); + KR_INFO("Capacity: {0}", hwinfo::unit::bytes_to_MiB(module.total_Bytes)); + } //catcher = electronics_spit(ps_systemmemory); @@ -981,33 +975,21 @@ namespace Karma KR_WARN("BiosReader isn't behaving normally."); } - //catcher = electronics_spit(ps_processor); - - if (central_processing_unit* pInfo = static_cast(catcher)) - { - //electronicsItems.cpuDesignation = pInfo->designation; <----- Please refer to central_processing_unit struct - electronicsItems.cpuFlags = pInfo->cpuflags != nullptr ? pInfo->cpuflags : notAvailableText; - electronicsItems.cpuid = pInfo->cpuid != nullptr ? pInfo->cpuid : notAvailableText; - electronicsItems.cpuManufacturer = pInfo->manufacturer ? pInfo->manufacturer : notAvailableText; - electronicsItems.cpuProcessingfamily = pInfo->processingfamily ? pInfo->processingfamily : notAvailableText; - electronicsItems.cpuVersion = pInfo->version ? pInfo->version : notAvailableText; - electronicsItems.cpuPartNumber = pInfo->partnumber ? pInfo->partnumber : notAvailableText; - electronicsItems.cpuSerialNumber = pInfo->serialnumber ? pInfo->serialnumber : notAvailableText; - electronicsItems.cpuAssettag = pInfo->assettag ? pInfo->assettag : notAvailableText; - electronicsItems.cpuOperatingVoltage = pInfo->operatingvoltage ? pInfo->operatingvoltage : notAvailableText; - electronicsItems.cpuCurrentSpeed = pInfo->currentspeed ? pInfo->currentspeed : notAvailableText; - electronicsItems.cpuMaximumSpeed = pInfo->maximumspeed ? pInfo->maximumspeed : notAvailableText; - electronicsItems.cpuExternalClock = pInfo->externalclock ? pInfo->externalclock : notAvailableText; - electronicsItems.cpuCorescount = pInfo->corescount ? pInfo->corescount : notAvailableText; - electronicsItems.cpuThreadCount = pInfo->threadcount ? pInfo->threadcount : notAvailableText; - electronicsItems.cpuEnabledCoresCount = pInfo->enabledcorescount ? pInfo->enabledcorescount : notAvailableText; - electronicsItems.cpuTheCharacterstics = pInfo->characterstics ? pInfo->characterstics : notAvailableText; - electronicsItems.cpuSignature = pInfo->signature ? pInfo->signature : notAvailableText; - } - else - { - KR_WARN("BiosReader isn't behaving normally"); - } + const auto cpus = hwinfo::getAllCPUs(); + + for(const auto& cpu : cpus) + { + electronicsItems.cpuInformation.cpuVendor = cpu.vendor(); + electronicsItems.cpuInformation.cpuModel = cpu.modelName(); + electronicsItems.cpuInformation.cpuLogicalCores = std::to_string(cpu.numLogicalCores()); + electronicsItems.cpuInformation.cpuPhysicalCores = std::to_string(cpu.numPhysicalCores()); + electronicsItems.cpuInformation.cpuFrequency = std::to_string(cpu.currentClockSpeed_MHz()[0]); // ponder over how to display all frequencies + electronicsItems.cpuInformation.cpuCacheSizeL1 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L1CacheSize_Bytes() > 0 ? cpu.L1CacheSize_Bytes() : 0)); + electronicsItems.cpuInformation.cpuCacheSizeL2 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L2CacheSize_Bytes() > 0 ? cpu.L2CacheSize_Bytes() : 0)); + electronicsItems.cpuInformation.cpuCacheSizeL3 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L3CacheSize_Bytes() > 0 ? cpu.L3CacheSize_Bytes() : 0)); + + break; + } auto gpus = hwinfo::getAllGPUs(); diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index c90cac17..98cd4288 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -191,12 +191,10 @@ namespace Karma std::string biosBoardName; // System Memory (RAM) overview - uint32_t numberOfMemoryDevices;// An estimation. I shall manually introduce logical checks + uint32_t numberOfMemoryDevices; - // I named estimated because of the lies - // https://github.com/ravimohan1991/BiosReader/wiki/The-Life-and-Lies-of-the-BIOS - std::string estimatedCapacity; - std::string supportingArea; + std::string memoryCapacity; + std::string freeMemory; struct SystemRAM { @@ -228,33 +226,19 @@ namespace Karma std::string ramSizeDimensions; // Processor information - // Asssuming only 1 processor - std::string cpuDesignation;// Socket designation - std::string cpuType; // In order to distinguish from GPU processor :) or DSP https://en.wikipedia.org/wiki/Digital_signal_processor - std::string cpuProcessingfamily; - std::string cpuManufacturer; - std::string cpuFlags; - // Kind of the most important element of this struct. eg Intel(R) Core(TM) i5-7400 CPU @ 3.00GHz (completeprocessingunitidentifier) - std::string cpuVersion; - - std::string cpuOperatingVoltage; - std::string cpuExternalClock; - std::string cpuMaximumSpeed; - std::string cpuCurrentSpeed; - - // Some OEM specific numbers - std::string cpuSerialNumber; - std::string cpuPartNumber; - std::string cpuAssettag; - - std::string cpuCorescount; - std::string cpuEnabledCoresCount; - std::string cpuThreadCount; - std::string cpuTheCharacterstics; - - // The Cpu ID field contains processor - specific information that describes the processor’s features. - std::string cpuid; // in the context of motherboard components - std::string cpuSignature; + + struct CPU + { + std::string cpuVendor; + std::string cpuModel; + std::string cpuFrequency; + std::string cpuPhysicalCores; + std::string cpuLogicalCores; + std::string cpuCacheSizeL1; + std::string cpuCacheSizeL2; + std::string cpuCacheSizeL3; + }; + CPU cpuInformation; // For now, with due respect, let there be enough content with just model number // und vendor. Would be dope to read the GPU just like RAM or CPU, from SMBIOS!! From 4f9024e777d953a72b3cae6152b5a7791bd66242 Mon Sep 17 00:00:00 2001 From: pcboy Date: Mon, 24 Nov 2025 09:26:21 +0530 Subject: [PATCH 07/15] Experimenting with the ordering of vk calls in FrameRender for resizing --- Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp index 6a56f828..fc8a359f 100644 --- a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp +++ b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp @@ -441,8 +441,6 @@ namespace Karma result = vkWaitForFences(vulkanInfo->Device, 1, &frameOnFlightData->Fence, VK_TRUE, UINT64_MAX); KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to wait"); - result = vkResetFences(vulkanInfo->Device, 1, &frameOnFlightData->Fence); - KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to reset fence"); // ImageAcquiredSemaphore is m_ImageAvailableSemaphores equivalent VkSemaphore imageAcquiredSemaphore = frameOnFlightData->ImageAcquiredSemaphore; @@ -455,6 +453,8 @@ namespace Karma return; } + KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to acquire next image"); + vkResetCommandBuffer(frameOnFlightData->CommandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); // recording begins: @@ -513,7 +513,7 @@ namespace Karma // --- 5. End the Offscreen Render Pass --- vkCmdEndRenderPass(frameOnFlightData->CommandBuffer); } - } + } // Render Pass VkRenderPassBeginInfo renderPassInfo = {}; @@ -557,6 +557,10 @@ namespace Karma submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &renderCompleteSemaphore; + // We reset the fence here or else the swapchain rebuild seemingly fails + result = vkResetFences(vulkanInfo->Device, 1, &frameOnFlightData->Fence); + KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to reset fence"); + result = vkQueueSubmit(vulkanInfo->Queue, 1, &submitInfo, frameOnFlightData->Fence); KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to submit queue"); } @@ -583,6 +587,12 @@ namespace Karma VkResult result = vkQueuePresentKHR(vulkanInfo->Queue, &info); + if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) + { + m_SwapChainRebuild = true; + return; + } + KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to submit queue"); windowData->SemaphoreIndex = (windowData->SemaphoreIndex + 1) % windowData->MAX_FRAMES_IN_FLIGHT; // Now we can use the next set of semaphores From 65607f693fd7c3aa538eaf7ad18db5fe8ba62987 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 09:33:59 +0530 Subject: [PATCH 08/15] Whitespacing --- Pranjal/Source/Private/KarmaGuiMesa.cpp | 88 ++++++++++++------------- 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index 112c7322..8d092065 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -815,18 +815,18 @@ namespace Karma KarmaGui::Separator(); KarmaGui::Text("Vendor: %s", electronicsItems.biosVendorName.c_str()); - KarmaGui::Text("MotherBoard: %s", electronicsItems.biosBoardName.c_str()); - KarmaGui::Text("MotherBoard Serial: %s", electronicsItems.biosSerialNumber.c_str()); - KarmaGui::Text("BIOS Version: %s", electronicsItems.biosVersion.c_str()); + KarmaGui::Text("MotherBoard: %s", electronicsItems.biosBoardName.c_str()); + KarmaGui::Text("MotherBoard Serial: %s", electronicsItems.biosSerialNumber.c_str()); + KarmaGui::Text("BIOS Version: %s", electronicsItems.biosVersion.c_str()); KarmaGui::Separator(); - KarmaGui::Text("Machine System Memory (RAM)"); + KarmaGui::Text("Machine System Memory (RAM)"); KarmaGui::Separator(); - KarmaGui::Text("Total Capacity (MiB): %s", electronicsItems.memoryCapacity.c_str()); - KarmaGui::Text("Free Memory (MiB): %s", electronicsItems.freeMemory.c_str()); + KarmaGui::Text("Total Capacity (MiB): %s", electronicsItems.memoryCapacity.c_str()); + KarmaGui::Text("Free Memory (MiB): %s", electronicsItems.freeMemory.c_str()); - KarmaGui::Text("Total modules: %d", electronicsItems.numberOfMemoryDevices); + KarmaGui::Text("Total modules: %d", electronicsItems.numberOfMemoryDevices); KarmaGui::Text("Physical devices present:"); @@ -866,20 +866,20 @@ namespace Karma KarmaGui::Text("Central Processor Unit"); KarmaGui::Separator(); - KarmaGui::Text("Manufacturer: %s", electronicsItems.cpuInformation.cpuVendor.c_str()); - KarmaGui::Text("Processor Family: %s", electronicsItems.cpuInformation.cpuModel.c_str()); + KarmaGui::Text("Manufacturer: %s", electronicsItems.cpuInformation.cpuVendor.c_str()); + KarmaGui::Text("Processor Family: %s", electronicsItems.cpuInformation.cpuModel.c_str()); KarmaGui::Text("CPU Conditions"); KarmaGui::Indent(); - KarmaGui::Text("Speed (MHz): %s", electronicsItems.cpuInformation.cpuFrequency.c_str()); - KarmaGui::Text("Cores (Logical | Physical): %s | %s", electronicsItems.cpuInformation.cpuLogicalCores.c_str(), electronicsItems.cpuInformation.cpuPhysicalCores.c_str()); + KarmaGui::Text("Speed (MHz): %s", electronicsItems.cpuInformation.cpuFrequency.c_str()); + KarmaGui::Text("Cores (Logical | Physical): %s | %s", electronicsItems.cpuInformation.cpuLogicalCores.c_str(), electronicsItems.cpuInformation.cpuPhysicalCores.c_str()); KarmaGui::Unindent(); KarmaGui::Text("CPU Tags or Numbers"); KarmaGui::Indent(); - KarmaGui::Text("Caches (MegaBytes)"); - KarmaGui::Text("L1 Cache : %s", electronicsItems.cpuInformation.cpuCacheSizeL1.c_str()); - KarmaGui::Text("L2 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL2.c_str()); - KarmaGui::Text("L3 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL3.c_str()); - KarmaGui::Unindent(); + KarmaGui::Text("Caches (MegaBytes)"); + KarmaGui::Text("L1 Cache : %s", electronicsItems.cpuInformation.cpuCacheSizeL1.c_str()); + KarmaGui::Text("L2 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL2.c_str()); + KarmaGui::Text("L3 Cache: %s", electronicsItems.cpuInformation.cpuCacheSizeL3.c_str()); + KarmaGui::Unindent(); KarmaGui::Separator(); @@ -916,34 +916,34 @@ namespace Karma } // Catcher rhymes with Hatcher, the Topologist, just for information! - void* catcher = nullptr;// = electronics_spit(ss_bios); - - hwinfo::MainBoard mainboard; - - electronicsItems.biosVendorName = mainboard.vendor() != "" ? mainboard.vendor() : notAvailableText; - electronicsItems.biosBoardName = mainboard.name() != "" ? mainboard.name() : notAvailableText; - electronicsItems.biosVersion = mainboard.version() != "" ? mainboard.version() : notAvailableText; - electronicsItems.biosSerialNumber = mainboard.serialNumber() != "" ? mainboard.serialNumber() : notAvailableText; - - hwinfo::Memory memory; - - electronicsItems.memoryCapacity = std::to_string(hwinfo::unit::bytes_to_MiB(memory.total_Bytes())); - electronicsItems.freeMemory = std::to_string(hwinfo::unit::bytes_to_MiB(memory.free_Bytes())); - - electronicsItems.numberOfMemoryDevices = memory.modules().size(); - - for(const auto& module : memory.modules()) - { - KR_INFO("ID: {0}", module.id); - KR_INFO("Frequencey (Hz): {0}", module.frequency_Hz == -1 ? -1 : static_cast(module.frequency_Hz) / 1e6); - KR_INFO("Name: {0}", module.name); - KR_INFO("Serial Number: {0}", module.serial_number); - KR_INFO("Vendor: {0}", module.vendor); - KR_INFO("Model: {0}", module.model); - KR_INFO("Capacity: {0}", hwinfo::unit::bytes_to_MiB(module.total_Bytes)); - } - - //catcher = electronics_spit(ps_systemmemory); + void* catcher = nullptr;// = electronics_spit(ss_bios); + + hwinfo::MainBoard mainboard; + + electronicsItems.biosVendorName = mainboard.vendor() != "" ? mainboard.vendor() : notAvailableText; + electronicsItems.biosBoardName = mainboard.name() != "" ? mainboard.name() : notAvailableText; + electronicsItems.biosVersion = mainboard.version() != "" ? mainboard.version() : notAvailableText; + electronicsItems.biosSerialNumber = mainboard.serialNumber() != "" ? mainboard.serialNumber() : notAvailableText; + + hwinfo::Memory memory; + + electronicsItems.memoryCapacity = std::to_string(hwinfo::unit::bytes_to_MiB(memory.total_Bytes())); + electronicsItems.freeMemory = std::to_string(hwinfo::unit::bytes_to_MiB(memory.free_Bytes() > 0 ? memory.free_Bytes() : 0)); + + electronicsItems.numberOfMemoryDevices = memory.modules().size(); + + for(const auto& module : memory.modules()) + { + KR_INFO("ID: {0}", module.id); + KR_INFO("Frequencey (Hz): {0}", module.frequency_Hz == -1 ? -1 : static_cast(module.frequency_Hz) / 1e6); + KR_INFO("Name: {0}", module.name); + KR_INFO("Serial Number: {0}", module.serial_number); + KR_INFO("Vendor: {0}", module.vendor); + KR_INFO("Model: {0}", module.model); + KR_INFO("Capacity: {0}", hwinfo::unit::bytes_to_MiB(module.total_Bytes)); + } + + //catcher = electronics_spit(ps_systemmemory); // Now since there may be more than one Ram type of electronics, and given that BIOS lies, we need a mechanism // to gauge the true amount of every estimation we obtained earlier From 1427eb0ec80f988a03c8acefdb1a0c8ac0dc7ad2 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 09:43:00 +0530 Subject: [PATCH 09/15] Removing traces of now redundant br --- .gitmodules | 3 - Karma/vendor/BiosReader | 1 - Pranjal/Source/Private/KarmaGuiMesa.cpp | 103 ++++-------------------- Pranjal/Source/Public/KarmaGuiMesa.h | 15 ---- 4 files changed, 17 insertions(+), 105 deletions(-) delete mode 160000 Karma/vendor/BiosReader diff --git a/.gitmodules b/.gitmodules index 031d1de0..f6a1bc48 100644 --- a/.gitmodules +++ b/.gitmodules @@ -20,9 +20,6 @@ path = Karma/vendor/SDL url = https://github.com/ravimohan1991/SDL.git ignore = dirty -[submodule "Karma/vendor/BiosReader"] - path = Karma/vendor/BiosReader - url = https://github.com/ravimohan1991/BiosReader.git [submodule "Karma/vendor/hwinfo"] path = Karma/vendor/hwinfo url = https://github.com/ravimohan1991/hwinfo.git diff --git a/Karma/vendor/BiosReader b/Karma/vendor/BiosReader deleted file mode 160000 index 1dfc58b1..00000000 --- a/Karma/vendor/BiosReader +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 1dfc58b10106941fe878b9718bd369ca397ec3b1 diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index 8d092065..e5942101 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -611,8 +611,8 @@ namespace Karma // Should be called when "about" mesa is closed, the first time if (electronicsItems.bHasQueried) { - reset_electronics_structures(); KarmaGuiMesa::SetElectronicsRamInformationToNull(); + electronicsItems.ramSoftSlots.clear(); electronicsItems.bHasQueried = false; } @@ -948,7 +948,7 @@ namespace Karma // Now since there may be more than one Ram type of electronics, and given that BIOS lies, we need a mechanism // to gauge the true amount of every estimation we obtained earlier // Please see https://github.com/ravimohan1991/BiosReader/blob/37e1179f876b940b3f483a398091f44a479692ea/src/private/dmidecode.c#L4980 - if (random_access_memory* rInfo = static_cast(catcher)) + /*if (random_access_memory* rInfo = static_cast(catcher)) { KarmaTuringMachineElectronics::GaugeSystemMemoryDevices(rInfo); @@ -973,23 +973,23 @@ namespace Karma else { KR_WARN("BiosReader isn't behaving normally."); - } + }*/ - const auto cpus = hwinfo::getAllCPUs(); + const auto cpus = hwinfo::getAllCPUs(); - for(const auto& cpu : cpus) - { - electronicsItems.cpuInformation.cpuVendor = cpu.vendor(); - electronicsItems.cpuInformation.cpuModel = cpu.modelName(); - electronicsItems.cpuInformation.cpuLogicalCores = std::to_string(cpu.numLogicalCores()); - electronicsItems.cpuInformation.cpuPhysicalCores = std::to_string(cpu.numPhysicalCores()); - electronicsItems.cpuInformation.cpuFrequency = std::to_string(cpu.currentClockSpeed_MHz()[0]); // ponder over how to display all frequencies - electronicsItems.cpuInformation.cpuCacheSizeL1 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L1CacheSize_Bytes() > 0 ? cpu.L1CacheSize_Bytes() : 0)); - electronicsItems.cpuInformation.cpuCacheSizeL2 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L2CacheSize_Bytes() > 0 ? cpu.L2CacheSize_Bytes() : 0)); - electronicsItems.cpuInformation.cpuCacheSizeL3 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L3CacheSize_Bytes() > 0 ? cpu.L3CacheSize_Bytes() : 0)); + for(const auto& cpu : cpus) + { + electronicsItems.cpuInformation.cpuVendor = cpu.vendor(); + electronicsItems.cpuInformation.cpuModel = cpu.modelName(); + electronicsItems.cpuInformation.cpuLogicalCores = std::to_string(cpu.numLogicalCores()); + electronicsItems.cpuInformation.cpuPhysicalCores = std::to_string(cpu.numPhysicalCores()); + electronicsItems.cpuInformation.cpuFrequency = std::to_string(cpu.currentClockSpeed_MHz()[0]); // ponder over how to display all frequencies + electronicsItems.cpuInformation.cpuCacheSizeL1 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L1CacheSize_Bytes() > 0 ? cpu.L1CacheSize_Bytes() : 0)); + electronicsItems.cpuInformation.cpuCacheSizeL2 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L2CacheSize_Bytes() > 0 ? cpu.L2CacheSize_Bytes() : 0)); + electronicsItems.cpuInformation.cpuCacheSizeL3 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L3CacheSize_Bytes() > 0 ? cpu.L3CacheSize_Bytes() : 0)); - break; - } + break; + } auto gpus = hwinfo::getAllGPUs(); @@ -1071,75 +1071,6 @@ namespace Karma } } - void KarmaTuringMachineElectronics::FindRealCapacityOfRam() - { - uint32_t ramSizeFound = 0; - - // Assumption dimension of memory is GB only - for (uint32_t counter = 0; counter < KarmaGuiMesa::GetGatheredElectronicsInformation().ramSoftSlots.size(); counter++) - { - ramSizeFound += KarmaGuiMesa::ChurnUint32FromString(KarmaGuiMesa::GetGatheredElectronicsInformation().ramInformation[counter].ramSize); - } - - KarmaGuiMesa::GetGatheredElectronicsInformationForModification().totalRamSize = ramSizeFound; - - // Hoping for GB only dimension - KarmaGuiMesa::GetGatheredElectronicsInformationForModification().ramSizeDimensions = KarmaGuiMesa::ChurnDimensionsFromString(KarmaGuiMesa::GetGatheredElectronicsInformation().ramInformation[0].ramSize); - } - - void KarmaTuringMachineElectronics::GaugeSystemMemoryDevices(random_access_memory* ramCluster) - { - if (ramCluster == nullptr) - { - KR_WARN("Memory devices pointer is null. No Ram(s) shall be detected and reported"); - return; - } - - KarmaTuringMachineElectronics selfRefrentialVariable = KarmaGuiMesa::GetGatheredElectronicsInformationForModification(); - - uint32_t biosReportedNumber = selfRefrentialVariable.numberOfMemoryDevices; - - for (uint32_t counter = 0; counter < biosReportedNumber; counter++) - { - random_access_memory* aMemoryBeingScanned = fetch_access_memory_members(counter); - - if (aMemoryBeingScanned != nullptr && IsPhysicalRamPresent(*aMemoryBeingScanned)) - { - KarmaGuiMesa::GetGatheredElectronicsInformationForModification().ramSoftSlots.push_back(counter); - } - } - } - - void KarmaTuringMachineElectronics::FillTheSystemRamStructure(SystemRAM& destinationStructure, random_access_memory& sourceStructure) - { - destinationStructure.assetTag = sourceStructure.assettag != nullptr ? sourceStructure.assettag : KarmaGuiMesa::notAvailableText; - destinationStructure.bankLocator = sourceStructure.banklocator != nullptr ? sourceStructure.banklocator : KarmaGuiMesa::notAvailableText; - destinationStructure.configuredMemorySpeed = sourceStructure.configuredmemoryspeed != nullptr ? sourceStructure.configuredmemoryspeed : KarmaGuiMesa::notAvailableText; - destinationStructure.memorySpeed = sourceStructure.memoryspeed != nullptr ? sourceStructure.memoryspeed : KarmaGuiMesa::notAvailableText; - destinationStructure.formFactor = sourceStructure.formfactor != nullptr ? sourceStructure.formfactor : KarmaGuiMesa::notAvailableText; - destinationStructure.locator = sourceStructure.locator != nullptr ? sourceStructure.locator : KarmaGuiMesa::notAvailableText; - destinationStructure.manufacturer = sourceStructure.manufacturer != nullptr ? sourceStructure.manufacturer : KarmaGuiMesa::notAvailableText; - destinationStructure.operatingVoltage = sourceStructure.operatingvoltage != nullptr ? sourceStructure.operatingvoltage : KarmaGuiMesa::notAvailableText; - destinationStructure.partNumber = sourceStructure.partnumber != nullptr ? sourceStructure.partnumber : KarmaGuiMesa::notAvailableText; - destinationStructure.ramSize = sourceStructure.ramsize != nullptr ? sourceStructure.ramsize : KarmaGuiMesa::notAvailableText; - destinationStructure.ramType = sourceStructure.ramtype != nullptr ? sourceStructure.ramtype : KarmaGuiMesa::notAvailableText; - //destinationStructure.rank = sourceStructure.rank; Not a big fan of rank, reminds me of my JEE AIR 4729 - destinationStructure.serialNumber = sourceStructure.serialnumber != nullptr ? sourceStructure.serialnumber : KarmaGuiMesa::notAvailableText; - } - - bool KarmaTuringMachineElectronics::IsPhysicalRamPresent(const random_access_memory& ramScam) - { - if (ramScam.memoryspeed == nullptr || ramScam.configuredmemoryspeed == nullptr || ramScam.banklocator == nullptr - || ramScam.formfactor == nullptr || ramScam.operatingvoltage == nullptr) - { - return false; - } - else - { - return true; - } - } - double KarmaGuiMesa::HexStringToDecimal(const std::string& hexString) { return (double)std::stoll(hexString, 0, 16); @@ -1188,8 +1119,8 @@ namespace Karma { if (electronicsItems.bHasQueried) { - reset_electronics_structures(); KarmaGuiMesa::SetElectronicsRamInformationToNull(); + electronicsItems.ramSoftSlots.clear(); electronicsItems.bHasQueried = false; } diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index 98cd4288..96311f50 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -11,10 +11,6 @@ #include "Karma.h" -extern "C" { -#include "dmidecode.h" -} - namespace Karma { struct CallbacksFromEditor @@ -258,17 +254,6 @@ namespace Karma ~KarmaTuringMachineElectronics(); - // Gauging Ram devices - static void GaugeSystemMemoryDevices(random_access_memory* ramCluster); - - // Obtain the real RAM information - static void FindRealCapacityOfRam(); - - // No-ram conditions. Bit'o hacky stuff - static bool IsPhysicalRamPresent(const random_access_memory& ramScam); - - // Filling the SystemRAM structure with relevant information - static void FillTheSystemRamStructure(SystemRAM& destinationStructure, random_access_memory& sourceStructure); }; struct WindowManipulationGaugeData From 92a9e887ae411af5f6b9a2644bcdf112d4aa52a9 Mon Sep 17 00:00:00 2001 From: pcboy Date: Mon, 24 Nov 2025 10:27:09 +0530 Subject: [PATCH 10/15] Removing br from build system and linking with opengl --- Karma/CMakeLists.txt | 7 +------ Pranjal/CMakeLists.txt | 2 -- 2 files changed, 1 insertion(+), 8 deletions(-) diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index dc99b22c..6f04f6a7 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -182,7 +182,6 @@ add_subdirectory(vendor/spdlog) add_subdirectory(vendor/assimp) add_subdirectory(vendor/glslang) add_subdirectory(vendor/stb) -add_subdirectory(vendor/BiosReader) add_subdirectory(vendor/hwinfo) list(APPEND ESSENTIAL_LIBS Glad) @@ -198,7 +197,6 @@ list(APPEND ESSENTIAL_LIBS AssImp) list(APPEND ESSENTIAL_LIBS ${Vulkan_LIBRARY}) list(APPEND ESSENTIAL_LIBS GlSlang) list(APPEND ESSENTIAL_LIBS stbimage) -list(APPEND ESSENTIAL_LIBS BiosReader) list(APPEND ESSENTIAL_LIBS hwinfo) @@ -257,9 +255,9 @@ endif() target_link_libraries(KarmaEngine PUBLIC spdlogging) target_link_libraries(KarmaEngine PUBLIC AssImp) target_link_libraries(KarmaEngine PUBLIC ${Vulkan_LIBRARY}) +target_link_libraries(KarmaEngine PUBLIC OpenGL::OpenGL) target_link_libraries(KarmaEngine PUBLIC GlSlang) target_link_libraries(KarmaEngine PUBLIC stbimage) -target_link_libraries(KarmaEngine PUBLIC BiosReader) target_link_libraries(KarmaEngine PUBLIC hwinfo) # Cluster Karma's libraries into a single folder for project/solution visualization @@ -281,8 +279,6 @@ else() set_property(TARGET glm_static PROPERTY FOLDER "${KARMALIBRARYFOLDER}") ]] endif() - -set_property(TARGET BiosReader PROPERTY FOLDER "${KARMALIBRARYFOLDER}") set_property(TARGET hwinfo PROPERTY FOLDER "${KARMALIBRARYFOLDER}") # INTERFACE (Something that Consumers require but Producers don't) @@ -296,7 +292,6 @@ target_include_directories(KarmaEngine ${CMAKE_CURRENT_SOURCE_DIR}/vendor/spdlog/include ${CMAKE_CURRENT_SOURCE_DIR}/vendor/assimp/contrib ${CMAKE_CURRENT_SOURCE_DIR}/vendor/assimp/include - ${CMAKE_CURRENT_SOURCE_DIR}/vendor/BiosReader/src/public ${CMAKE_CURRENT_SOURCE_DIR}/vendor/hwinfo/include ${Vulkan_INCLUDE_DIR} PUBLIC diff --git a/Pranjal/CMakeLists.txt b/Pranjal/CMakeLists.txt index b3790725..c6ef1852 100644 --- a/Pranjal/CMakeLists.txt +++ b/Pranjal/CMakeLists.txt @@ -47,8 +47,6 @@ if(MSVC) ${CMAKE_CURRENT_SOURCE_DIR}/../Karma/vendor/GLFW/include ${CMAKE_CURRENT_SOURCE_DIR}/../Karma/src/Karma/ ${CMAKE_CURRENT_SOURCE_DIR}/../Karma/vendor/SDL/include - ${CMAKE_CURRENT_SOURCE_DIR}/../Karma/vendor/ImGui/ - ${CMAKE_CURRENT_SOURCE_DIR}/../Karma/vendor/ImGui/backends ${CMAKE_CURRENT_SOURCE_DIR}/Source/Public ) endif() From 0ba9d053ce3d477f859d29992d63e7ccf4ba3ef6 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 10:47:58 +0530 Subject: [PATCH 11/15] Taking care of Mac opengl --- Karma/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index 6f04f6a7..20cf28b4 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -255,7 +255,11 @@ endif() target_link_libraries(KarmaEngine PUBLIC spdlogging) target_link_libraries(KarmaEngine PUBLIC AssImp) target_link_libraries(KarmaEngine PUBLIC ${Vulkan_LIBRARY}) -target_link_libraries(KarmaEngine PUBLIC OpenGL::OpenGL) +if(APPLE) + target_link_libraries(KarmaEngine PUBLIC OpenGL) +else() + target_link_libraries(KarmaEngine PUBLIC OpenGL::OpenGL) +endif() target_link_libraries(KarmaEngine PUBLIC GlSlang) target_link_libraries(KarmaEngine PUBLIC stbimage) target_link_libraries(KarmaEngine PUBLIC hwinfo) From adcd7c722430178deffd9bfb6e0cb0c5750e2b5c Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 11:06:50 +0530 Subject: [PATCH 12/15] Rectifying the name of opengl on mac --- Karma/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index 20cf28b4..346a139d 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -57,7 +57,9 @@ ENDMACRO(PRINT_LIST) # Then the checks find_package(Vulkan REQUIRED) -find_package(OpenGL REQUIRED) +if(NOT APPLE) + find_package(OpenGL REQUIRED) +endif() find_package(Threads REQUIRED) message(STATUS "Checks are satisfied, we are good to proceed!") @@ -256,7 +258,7 @@ target_link_libraries(KarmaEngine PUBLIC spdlogging) target_link_libraries(KarmaEngine PUBLIC AssImp) target_link_libraries(KarmaEngine PUBLIC ${Vulkan_LIBRARY}) if(APPLE) - target_link_libraries(KarmaEngine PUBLIC OpenGL) + target_link_libraries(KarmaEngine PUBLIC "-framework OpenGL") else() target_link_libraries(KarmaEngine PUBLIC OpenGL::OpenGL) endif() From 2b3c1bb261a5cdba7c2feaf8b9cb254386c72197 Mon Sep 17 00:00:00 2001 From: pc_boy Date: Mon, 24 Nov 2025 06:10:33 +0530 Subject: [PATCH 13/15] Windows likes ${OPENGL_LIBRARIES} for linking with opengl -need to see this on ubuntu --- Karma/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Karma/CMakeLists.txt b/Karma/CMakeLists.txt index 346a139d..c286496e 100644 --- a/Karma/CMakeLists.txt +++ b/Karma/CMakeLists.txt @@ -260,7 +260,7 @@ target_link_libraries(KarmaEngine PUBLIC ${Vulkan_LIBRARY}) if(APPLE) target_link_libraries(KarmaEngine PUBLIC "-framework OpenGL") else() - target_link_libraries(KarmaEngine PUBLIC OpenGL::OpenGL) + target_link_libraries(KarmaEngine PUBLIC ${OPENGL_LIBRARIES}) endif() target_link_libraries(KarmaEngine PUBLIC GlSlang) target_link_libraries(KarmaEngine PUBLIC stbimage) From 4ba5b7462ea8eef0fffc0c845ec6de58658190a2 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 14:50:15 +0530 Subject: [PATCH 14/15] Added ram electronics information --- Pranjal/Source/Private/KarmaGuiMesa.cpp | 77 ++++++++++++------------- Pranjal/Source/Public/KarmaGuiMesa.h | 60 +++++++------------ 2 files changed, 59 insertions(+), 78 deletions(-) diff --git a/Pranjal/Source/Private/KarmaGuiMesa.cpp b/Pranjal/Source/Private/KarmaGuiMesa.cpp index e5942101..1234c503 100644 --- a/Pranjal/Source/Private/KarmaGuiMesa.cpp +++ b/Pranjal/Source/Private/KarmaGuiMesa.cpp @@ -612,8 +612,6 @@ namespace Karma if (electronicsItems.bHasQueried) { KarmaGuiMesa::SetElectronicsRamInformationToNull(); - - electronicsItems.ramSoftSlots.clear(); electronicsItems.bHasQueried = false; } } @@ -827,40 +825,20 @@ namespace Karma KarmaGui::Text("Free Memory (MiB): %s", electronicsItems.freeMemory.c_str()); KarmaGui::Text("Total modules: %d", electronicsItems.numberOfMemoryDevices); - - KarmaGui::Text("Physical devices present:"); - - for (uint32_t counter = 0; counter < electronicsItems.ramSoftSlots.size(); counter++) + + for(uint32_t counter = 0; counter < electronicsItems.numberOfMemoryDevices; counter++) { KarmaGui::Text("RAM %d", counter + 1); - KarmaGui::Text("Manufacturer: %s", electronicsItems.ramInformation[counter].manufacturer.c_str()); - - KarmaGui::Text("Identification Parameters"); - KarmaGui::Indent(); - KarmaGui::Text("Ram Type: %s", electronicsItems.ramInformation[counter].ramType.c_str()); - KarmaGui::Text("Part Number: %s", electronicsItems.ramInformation[counter].partNumber.c_str()); - KarmaGui::Text("Serial Number: %s", electronicsItems.ramInformation[counter].serialNumber.c_str()); - KarmaGui::Text("(Bank | Device) Locator: %s | %s", electronicsItems.ramInformation[counter].bankLocator.c_str(), - electronicsItems.ramInformation[counter].locator.c_str()); - KarmaGui::Text("Asset Tag: %s", electronicsItems.ramInformation[counter].assetTag.c_str()); - KarmaGui::Unindent(); - - KarmaGui::Text("Ram Conditions"); - KarmaGui::Indent(); - KarmaGui::Text("Size: %s", electronicsItems.ramInformation[counter].ramSize.c_str()); - KarmaGui::Text("Operating Voltage: %s", electronicsItems.ramInformation[counter].operatingVoltage.c_str()); - KarmaGui::Text("Speed (Current | Maximum): %s | %s", electronicsItems.ramInformation[counter].configuredMemorySpeed.c_str(), - electronicsItems.ramInformation[counter].memorySpeed.c_str()); - KarmaGui::Text("Form Factor: %s", electronicsItems.ramInformation[counter].formFactor.c_str()); + KarmaGui::Text("Vendor: %s", electronicsItems.ramInformation[counter].vendor.c_str()); + KarmaGui::Text("Name: %s", electronicsItems.ramInformation[counter].vendor.c_str()); + KarmaGui::Text("Model: %s", electronicsItems.ramInformation[counter].vendor.c_str()); + KarmaGui::Text("Serial Number: %s", electronicsItems.ramInformation[counter].vendor.c_str()); + KarmaGui::Text("Frequency (MHz): %s", electronicsItems.ramInformation[counter].vendor.c_str()); + KarmaGui::Text("Capacity: %s", electronicsItems.ramInformation[counter].vendor.c_str()); KarmaGui::Unindent(); } - - KarmaGui::Text("RAM Logistics"); - KarmaGui::Indent(); - KarmaGui::Text("Total Ram Size: %d %s", electronicsItems.totalRamSize, electronicsItems.ramSizeDimensions.c_str()); - KarmaGui::Unindent(); - + KarmaGui::Separator(); KarmaGui::Text("Central Processor Unit"); @@ -870,7 +848,7 @@ namespace Karma KarmaGui::Text("Processor Family: %s", electronicsItems.cpuInformation.cpuModel.c_str()); KarmaGui::Text("CPU Conditions"); KarmaGui::Indent(); - KarmaGui::Text("Speed (MHz): %s", electronicsItems.cpuInformation.cpuFrequency.c_str()); + KarmaGui::Text("Speed : %s (MHz) | %s (MHz)", electronicsItems.cpuInformation.cpuCurrentFrequency.c_str(), electronicsItems.cpuInformation.cpuMaximumFrequency.c_str()); KarmaGui::Text("Cores (Logical | Physical): %s | %s", electronicsItems.cpuInformation.cpuLogicalCores.c_str(), electronicsItems.cpuInformation.cpuPhysicalCores.c_str()); KarmaGui::Unindent(); KarmaGui::Text("CPU Tags or Numbers"); @@ -930,7 +908,7 @@ namespace Karma electronicsItems.memoryCapacity = std::to_string(hwinfo::unit::bytes_to_MiB(memory.total_Bytes())); electronicsItems.freeMemory = std::to_string(hwinfo::unit::bytes_to_MiB(memory.free_Bytes() > 0 ? memory.free_Bytes() : 0)); - electronicsItems.numberOfMemoryDevices = memory.modules().size(); + electronicsItems.numberOfMemoryDevices = static_cast(memory.modules().size()); for(const auto& module : memory.modules()) { @@ -943,11 +921,21 @@ namespace Karma KR_INFO("Capacity: {0}", hwinfo::unit::bytes_to_MiB(module.total_Bytes)); } - //catcher = electronics_spit(ps_systemmemory); + electronicsItems.ramInformation = new KarmaTuringMachineElectronics::SystemRAM[memory.modules().size()]; + uint32_t counter = 0; + + for(const auto& mod : memory.modules()) + { + electronicsItems.ramInformation[counter].name = mod.name; + electronicsItems.ramInformation[counter].vendor = mod.vendor; + electronicsItems.ramInformation[counter].model = mod.model; + electronicsItems.ramInformation[counter].serialNumber = mod.serial_number; + electronicsItems.ramInformation[counter].frequency = mod.frequency_Hz == -1 ? -1 : static_cast(mod.frequency_Hz) / 1e6; + electronicsItems.ramInformation[counter].id = mod.id; + electronicsItems.ramInformation[counter].capacity = std::to_string(hwinfo::unit::bytes_to_MiB(mod.total_Bytes)); + counter++; + } - // Now since there may be more than one Ram type of electronics, and given that BIOS lies, we need a mechanism - // to gauge the true amount of every estimation we obtained earlier - // Please see https://github.com/ravimohan1991/BiosReader/blob/37e1179f876b940b3f483a398091f44a479692ea/src/private/dmidecode.c#L4980 /*if (random_access_memory* rInfo = static_cast(catcher)) { KarmaTuringMachineElectronics::GaugeSystemMemoryDevices(rInfo); @@ -983,7 +971,18 @@ namespace Karma electronicsItems.cpuInformation.cpuModel = cpu.modelName(); electronicsItems.cpuInformation.cpuLogicalCores = std::to_string(cpu.numLogicalCores()); electronicsItems.cpuInformation.cpuPhysicalCores = std::to_string(cpu.numPhysicalCores()); - electronicsItems.cpuInformation.cpuFrequency = std::to_string(cpu.currentClockSpeed_MHz()[0]); // ponder over how to display all frequencies + + int64_t averageFrequency = 0; + for(uint32_t counter = 0; counter < cpu.numLogicalCores(); counter++) + { + averageFrequency += cpu.currentClockSpeed_MHz()[counter]; + } + + averageFrequency = averageFrequency / cpu.numLogicalCores(); + + electronicsItems.cpuInformation.cpuCurrentFrequency = std::to_string(averageFrequency); + electronicsItems.cpuInformation.cpuMaximumFrequency = std::to_string(cpu.maxClockSpeed_MHz()); + KR_INFO("CPU frequency: {0}", cpu.maxClockSpeed_MHz()); electronicsItems.cpuInformation.cpuCacheSizeL1 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L1CacheSize_Bytes() > 0 ? cpu.L1CacheSize_Bytes() : 0)); electronicsItems.cpuInformation.cpuCacheSizeL2 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L2CacheSize_Bytes() > 0 ? cpu.L2CacheSize_Bytes() : 0)); electronicsItems.cpuInformation.cpuCacheSizeL3 = std::to_string(hwinfo::unit::bytes_to_MiB(cpu.L3CacheSize_Bytes() > 0 ? cpu.L3CacheSize_Bytes() : 0)); @@ -1120,8 +1119,6 @@ namespace Karma if (electronicsItems.bHasQueried) { KarmaGuiMesa::SetElectronicsRamInformationToNull(); - - electronicsItems.ramSoftSlots.clear(); electronicsItems.bHasQueried = false; } } diff --git a/Pranjal/Source/Public/KarmaGuiMesa.h b/Pranjal/Source/Public/KarmaGuiMesa.h index 96311f50..f156e232 100644 --- a/Pranjal/Source/Public/KarmaGuiMesa.h +++ b/Pranjal/Source/Public/KarmaGuiMesa.h @@ -187,54 +187,38 @@ namespace Karma std::string biosBoardName; // System Memory (RAM) overview - uint32_t numberOfMemoryDevices; + uint32_t numberOfMemoryDevices; - std::string memoryCapacity; - std::string freeMemory; + std::string memoryCapacity; + std::string freeMemory; struct SystemRAM { - std::string formFactor; - std::string ramSize; - std::string locator; - std::string ramType; - std::string bankLocator; - std::string manufacturer; - + uint32_t id; + std::string vendor; + std::string model; + std::string name; std::string serialNumber; - std::string partNumber; - std::string assetTag; - - std::string memorySpeed; - std::string configuredMemorySpeed; - - std::string operatingVoltage; - std::string rank; + std::string frequency; + std::string capacity; }; SystemRAM* ramInformation; - // Let me tell the story of naming. Since the physical slots are the ones - // present on board, the array slots in software side, getting filled on a query to BIOS, - // naturally get the name "...SoftSlots" from BiosReader's allocation POV - std::vector ramSoftSlots; - - uint32_t totalRamSize; - std::string ramSizeDimensions; // Processor information - - struct CPU - { - std::string cpuVendor; - std::string cpuModel; - std::string cpuFrequency; - std::string cpuPhysicalCores; - std::string cpuLogicalCores; - std::string cpuCacheSizeL1; - std::string cpuCacheSizeL2; - std::string cpuCacheSizeL3; - }; - CPU cpuInformation; + struct CPU + { + std::string cpuVendor; + std::string cpuModel; + std::string cpuCurrentFrequency; + std::string cpuMaximumFrequency; + std::string cpuPhysicalCores; + std::string cpuLogicalCores; + std::string cpuCacheSizeL1; + std::string cpuCacheSizeL2; + std::string cpuCacheSizeL3; + }; + CPU cpuInformation; // For now, with due respect, let there be enough content with just model number // und vendor. Would be dope to read the GPU just like RAM or CPU, from SMBIOS!! From cd8a46a7092f950d98f0b1edf08e8de32d9fde47 Mon Sep 17 00:00:00 2001 From: the_cowboy Date: Mon, 24 Nov 2025 15:57:14 +0530 Subject: [PATCH 15/15] Whitespace and some minor comments --- Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp | 30 ++++++++++--------- .../Platform/Vulkan/KarmaGuiVulkanHandler.cpp | 18 +++++------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp index fc8a359f..6dd720ca 100644 --- a/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp +++ b/Karma/src/Karma/KarmaGui/KarmaGuiRenderer.cpp @@ -453,7 +453,7 @@ namespace Karma return; } - KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to acquire next image"); + KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to acquire next image"); vkResetCommandBuffer(frameOnFlightData->CommandBuffer, VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT); @@ -477,10 +477,12 @@ namespace Karma renderPassInfo.renderArea.offset = {0, 0}; renderPassInfo.renderArea.extent.width = it->Size.x; renderPassInfo.renderArea.extent.height = it->Size.y; + // Define clear values for the color and depth attachments std::vector clearValues(2); clearValues[0].color = {{0.0f, 0.0f, 0.0f, 0.0f}}; // Clear color to transparent clearValues[1].depthStencil = {1.0f, 0}; // Clear depth to 1.0 (farthest) + renderPassInfo.clearValueCount = static_cast(clearValues.size()); renderPassInfo.pClearValues = clearValues.data(); @@ -489,7 +491,7 @@ namespace Karma std::shared_ptr vulkanVA = static_pointer_cast(it->Scene3D->GetRenderableVertexArray()); vkCmdBindPipeline(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetKarmaGuiGraphicsPipeline()); - // Bind 3D Vertex And Index Buffers: + // ---- Bind 3D Vertex And Index Buffers ---- { VkBuffer vertexBuffers[1] = { vulkanVA->GetVertexBuffer()->GetVertexBuffer() }; VkDeviceSize vertexOffset[1] = { 0 }; @@ -502,18 +504,18 @@ namespace Karma VulkanHolder::GetVulkanContext()->UploadUBO(windowData->SemaphoreIndex); - // Bind descriptor sets (e.g., uniforms for MVP matrices, lighting) + // ---- Bind descriptor sets (e.g., uniforms for MVP matrices, lighting) ---- // Assumes layout compatibility between pipeline and descriptor set vkCmdBindDescriptorSets(frameOnFlightData->CommandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, vulkanVA->GetGraphicsPipelineLayout(), 0, 1, &vulkanVA->GetDescriptorSets()[windowData->SemaphoreIndex], 0, nullptr); - // --- 4. Issue Draw Commands --- + // ---- Issue Draw Commands ---- // Draw 3D scene geometry on 2D rendertarget (it->FrameBuffers) vkCmdDrawIndexed(frameOnFlightData->CommandBuffer, vulkanVA->GetIndexBuffer()->GetCount(), 1, 0, 0, 0); - // --- 5. End the Offscreen Render Pass --- + // ---- End the Offscreen Render Pass ---- vkCmdEndRenderPass(frameOnFlightData->CommandBuffer); } - } + } // Render Pass VkRenderPassBeginInfo renderPassInfo = {}; @@ -557,9 +559,9 @@ namespace Karma submitInfo.signalSemaphoreCount = 1; submitInfo.pSignalSemaphores = &renderCompleteSemaphore; - // We reset the fence here or else the swapchain rebuild seemingly fails - result = vkResetFences(vulkanInfo->Device, 1, &frameOnFlightData->Fence); - KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to reset fence"); + // We reset the fence here or else the swapchain rebuild seemingly fails + result = vkResetFences(vulkanInfo->Device, 1, &frameOnFlightData->Fence); + KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to reset fence"); result = vkQueueSubmit(vulkanInfo->Queue, 1, &submitInfo, frameOnFlightData->Fence); KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to submit queue"); @@ -587,11 +589,11 @@ namespace Karma VkResult result = vkQueuePresentKHR(vulkanInfo->Queue, &info); - if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) - { - m_SwapChainRebuild = true; - return; - } + if (result == VK_ERROR_OUT_OF_DATE_KHR || result == VK_SUBOPTIMAL_KHR) + { + m_SwapChainRebuild = true; + return; + } KR_CORE_ASSERT(result == VK_SUCCESS, "Failed to submit queue"); diff --git a/Karma/src/Platform/Vulkan/KarmaGuiVulkanHandler.cpp b/Karma/src/Platform/Vulkan/KarmaGuiVulkanHandler.cpp index 2d681715..cae151c6 100644 --- a/Karma/src/Platform/Vulkan/KarmaGuiVulkanHandler.cpp +++ b/Karma/src/Platform/Vulkan/KarmaGuiVulkanHandler.cpp @@ -1489,16 +1489,16 @@ namespace Karma } } - void KarmaGuiVulkanHandler::PrepareVertexArrayaForKarmaGuiWindowRendering() - { - KarmaGui_ImplVulkan_Data* backendData = KarmaGuiRenderer::GetBackendRendererUserData(); + void KarmaGuiVulkanHandler::PrepareVertexArrayaForKarmaGuiWindowRendering() + { + KarmaGui_ImplVulkan_Data* backendData = KarmaGuiRenderer::GetBackendRendererUserData(); - for(auto textureData = backendData->Elements3DTo2D.begin(); textureData != backendData->Elements3DTo2D.end(); ++textureData) - { - std::shared_ptr vulkanVA = static_pointer_cast(textureData->Scene3D->GetRenderableVertexArray()); - vulkanVA->CreateKarmaGuiGraphicsPipeline(textureData->RenderPass, textureData->Size.x, textureData->Size.y); - } - } + for(auto textureData = backendData->Elements3DTo2D.begin(); textureData != backendData->Elements3DTo2D.end(); ++textureData) + { + std::shared_ptr vulkanVA = static_pointer_cast(textureData->Scene3D->GetRenderableVertexArray()); + vulkanVA->CreateKarmaGuiGraphicsPipeline(textureData->RenderPass, textureData->Size.x, textureData->Size.y); + } + } void KarmaGuiVulkanHandler::ShareVulkanContextResourcesOfMainWindow(KarmaGui_ImplVulkanH_Window* windowData, bool bCreateSyncronicity) {