From dd047c16447344a3b73e4c25ea2d50e42d59b83f Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sun, 9 Jul 2023 22:32:14 +0800 Subject: [PATCH 1/2] added WinVulkan.cpp --- CMCore | 2 +- CMPlatform | 2 +- CMUtil | 2 +- src/SceneGraph/CMakeLists.txt | 7 ++++- src/SceneGraph/Vulkan/platform/WinVulkan.cpp | 30 ++++++++++++++++++++ 5 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 src/SceneGraph/Vulkan/platform/WinVulkan.cpp diff --git a/CMCore b/CMCore index ca3f7eb5..b43c2368 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit ca3f7eb55f9e4c1fad44993b70a473f8e3c2ed00 +Subproject commit b43c236894f0740591d38916411b4bbd83bf351a diff --git a/CMPlatform b/CMPlatform index fdd40d7c..1199a44d 160000 --- a/CMPlatform +++ b/CMPlatform @@ -1 +1 @@ -Subproject commit fdd40d7c7685c674541279154f0decb3fe156c36 +Subproject commit 1199a44dd3138eb0e65bf464b5e221c8a405ab80 diff --git a/CMUtil b/CMUtil index f4d19fc8..9ed3f1b6 160000 --- a/CMUtil +++ b/CMUtil @@ -1 +1 @@ -Subproject commit f4d19fc898e9434e93f77843975369744e59350a +Subproject commit 9ed3f1b6c33a881e8cca30313294f16c44fce368 diff --git a/src/SceneGraph/CMakeLists.txt b/src/SceneGraph/CMakeLists.txt index d0ac8ae2..0e319986 100644 --- a/src/SceneGraph/CMakeLists.txt +++ b/src/SceneGraph/CMakeLists.txt @@ -249,8 +249,12 @@ IF(WIN32) IF(FORCE_DISCETE_GPU) SET(RENDER_DEVICE_SOURCE ForceDiscreteGPU.c) ENDIF() + + SET(VK_PLATFORM_SOURCE Vulkan/Platform/WinVulkan.cpp) ENDIF(WIN32) +SOURCE_GROUP("Vulkan\\Platform" FILES ${VK_PLATFORM_SOURCE}) + SET(VULKAN_RENDER_SOURCE ${VK_RR_SOURCE} ${VK_RR_SHADER_FILES} ${VK_RR_MATERIAL_FILES} @@ -270,7 +274,8 @@ SET(VULKAN_RENDER_SOURCE ${VK_RR_SOURCE} #${VK_RENDER_CONTEXT_SOURCE} ${VK_CMD_BUFFER_SOURCE} ${VK_RENDERABLE_SOURCE} - ${VK_RENDER_DEVICE_SOURCE}) + ${VK_RENDER_DEVICE_SOURCE} + ${VK_PLATFORM_SOURCE}) add_cm_library(ULRE.SceneGraph "ULRE" ${SCENE_GRAPH_HEADER} ${SCENE_GRAPH_SOURCE} diff --git a/src/SceneGraph/Vulkan/platform/WinVulkan.cpp b/src/SceneGraph/Vulkan/platform/WinVulkan.cpp new file mode 100644 index 00000000..cf6fad81 --- /dev/null +++ b/src/SceneGraph/Vulkan/platform/WinVulkan.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +namespace hgl +{ + VkSurfaceKHR CreateVulkanSurface(VkInstance vk_inst,Window *w) + { + if(vk_inst==VK_NULL_HANDLE)return(VK_NULL_HANDLE); + if(!w)return(VK_NULL_HANDLE); + + WinWindow *win=(WinWindow *)w; + + VkWin32SurfaceCreateInfoKHR createInfo; + createInfo.sType =VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; + createInfo.pNext =nullptr; + createInfo.flags =0; + createInfo.hinstance=win->GetInstance(); + createInfo.hwnd =win->GetWnd(); + + VkSurfaceKHR surface; + + VkResult res=vkCreateWin32SurfaceKHR(vk_inst,&createInfo,nullptr,&surface); + + if(res!=VK_SUCCESS) + return(VK_NULL_HANDLE); + + return(surface); + } +}//namespace hgl \ No newline at end of file From 51a6da3d9fd954b2e8c91dc283e16c18c8038534 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Sat, 22 Jul 2023 12:16:26 +0800 Subject: [PATCH 2/2] update #include, but the codes can't compile. --- CMCore | 2 +- CMPlatform | 2 +- CMUtil | 2 +- inc/hgl/graph/SceneNode.h | 2 +- inc/hgl/graph/VKDescriptorSet.h | 1 + inc/hgl/graph/VKInstance.h | 2 +- inc/hgl/graph/VKRenderResource.h | 18 +++++++++--------- src/SceneGraph/MaterialRenderList.cpp | 2 +- 8 files changed, 16 insertions(+), 15 deletions(-) diff --git a/CMCore b/CMCore index b43c2368..b0d404bb 160000 --- a/CMCore +++ b/CMCore @@ -1 +1 @@ -Subproject commit b43c236894f0740591d38916411b4bbd83bf351a +Subproject commit b0d404bb11e83511b553c14960f5b67066d365bb diff --git a/CMPlatform b/CMPlatform index 1199a44d..07bc3eff 160000 --- a/CMPlatform +++ b/CMPlatform @@ -1 +1 @@ -Subproject commit 1199a44dd3138eb0e65bf464b5e221c8a405ab80 +Subproject commit 07bc3effc35dac639f40521c3fc58f0ed00faaf3 diff --git a/CMUtil b/CMUtil index 9ed3f1b6..31033215 160000 --- a/CMUtil +++ b/CMUtil @@ -1 +1 @@ -Subproject commit 9ed3f1b6c33a881e8cca30313294f16c44fce368 +Subproject commit 31033215854f68b2c3b690cc215423dd6b44856c diff --git a/inc/hgl/graph/SceneNode.h b/inc/hgl/graph/SceneNode.h index 5f01d131..1cc4f395 100644 --- a/inc/hgl/graph/SceneNode.h +++ b/inc/hgl/graph/SceneNode.h @@ -1,7 +1,7 @@ #ifndef HGL_GRAPH_SCENE_NODE_INCLUDE #define HGL_GRAPH_SCENE_NODE_INCLUDE -#include +#include #include #include #include diff --git a/inc/hgl/graph/VKDescriptorSet.h b/inc/hgl/graph/VKDescriptorSet.h index e5edbba9..b07404ce 100644 --- a/inc/hgl/graph/VKDescriptorSet.h +++ b/inc/hgl/graph/VKDescriptorSet.h @@ -3,6 +3,7 @@ #include #include +#include #include VK_NAMESPACE_BEGIN class DeviceBuffer; diff --git a/inc/hgl/graph/VKInstance.h b/inc/hgl/graph/VKInstance.h index 8e3590ee..5991eb3f 100644 --- a/inc/hgl/graph/VKInstance.h +++ b/inc/hgl/graph/VKInstance.h @@ -2,7 +2,7 @@ #define HGL_GRAPH_VULKAN_INSTANCE_INCLUDE #include -#include +#include #include #include #include diff --git a/inc/hgl/graph/VKRenderResource.h b/inc/hgl/graph/VKRenderResource.h index f0d72c7f..bc35a0ab 100644 --- a/inc/hgl/graph/VKRenderResource.h +++ b/inc/hgl/graph/VKRenderResource.h @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include @@ -43,14 +43,14 @@ class RenderResource Map material_by_name; Map texture_by_name; - IDResManage rm_material; ///<材质合集 - IDResManage rm_material_instance; ///<材质实例合集 - IDResManage rm_desc_sets; ///<描述符合集 - IDResManage rm_primitives; ///<图元合集 - IDResManage rm_buffers; ///<顶点缓冲区合集 - IDResManage rm_samplers; ///<采样器合集 - IDResManage rm_textures; ///<纹理合集 - IDResManage rm_renderables; ///<渲染实例集合集 + IDObjectManage rm_material; ///<材质合集 + IDObjectManage rm_material_instance; ///<材质实例合集 + IDObjectManage rm_desc_sets; ///<描述符合集 + IDObjectManage rm_primitives; ///<图元合集 + IDObjectManage rm_buffers; ///<顶点缓冲区合集 + IDObjectManage rm_samplers; ///<采样器合集 + IDObjectManage rm_textures; ///<纹理合集 + IDObjectManage rm_renderables; ///<渲染实例集合集 public: diff --git a/src/SceneGraph/MaterialRenderList.cpp b/src/SceneGraph/MaterialRenderList.cpp index e4808338..0e6dca9b 100644 --- a/src/SceneGraph/MaterialRenderList.cpp +++ b/src/SceneGraph/MaterialRenderList.cpp @@ -133,7 +133,7 @@ void MaterialRenderList::Stat() RenderNode *rn=rn_list.GetData(); ri_list.ClearData(); - ri_list.PreMalloc(count); + ri_list.PreAlloc(count); mi_set.ClearData();