From 107f3f537fc73dae22608b3d4a9c486210ad3e9e Mon Sep 17 00:00:00 2001 From: shawnz Date: Mon, 19 May 2025 17:38:22 +0800 Subject: [PATCH 1/3] Update the include files sequence for vulkan samples on Windows --- .../simpleVulkan/VulkanBaseApp.h | 22 ++++++++++--------- .../simpleVulkanMMAP/VulkanBaseApp.h | 4 +++- .../vulkanImageCUDA/vulkanImageCUDA.cu | 4 +++- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h index efb5fac4..616b1c14 100644 --- a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h +++ b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h @@ -34,8 +34,10 @@ #include #ifdef _WIN64 #define NOMINMAX -#include +// Add windows.h to the include path firstly as dependency for other Windows headers #include +// Add other Windows headers +#include #endif /* _WIN64 */ /* remove _VK_TIMELINE_SEMAPHORE to use binary semaphores */ @@ -54,6 +56,7 @@ public: void init(); void *getMemHandle(VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBits handleType); void *getSemaphoreHandle(VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBits handleType); + bool isVkPhysicalDeviceUuid(void *Uuid); void createExternalSemaphore(VkSemaphore &semaphore, VkExternalSemaphoreHandleTypeFlagBits handleType); void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, @@ -85,6 +88,7 @@ protected: VkDebugUtilsMessengerEXT m_debugMessenger; VkSurfaceKHR m_surface; VkPhysicalDevice m_physicalDevice; + uint8_t m_deviceUUID[VK_UUID_SIZE]; VkDevice m_device; VkQueue m_graphicsQueue; VkQueue m_presentQueue; @@ -105,17 +109,15 @@ protected: std::vector m_inFlightFences; std::vector m_uniformBuffers; std::vector m_uniformMemory; - VkSemaphore m_vkPresentationSemaphore; - VkSemaphore m_vkTimelineSemaphore; VkDescriptorSetLayout m_descriptorSetLayout; VkDescriptorPool m_descriptorPool; std::vector m_descriptorSets; - VkImage m_depthImage; - VkDeviceMemory m_depthImageMemory; - VkImageView m_depthImageView; - size_t m_currentFrame; - bool m_framebufferResized; - uint8_t m_vkDeviceUUID[VK_UUID_SIZE]; + + VkImage m_depthImage; + VkDeviceMemory m_depthImageMemory; + VkImageView m_depthImageView; + size_t m_currentFrame; + bool m_framebufferResized; virtual void initVulkanApp() {} virtual void fillRenderingCommandBuffer(VkCommandBuffer &buffer) {} @@ -128,7 +130,7 @@ protected: std::vector &waitStages) const; virtual void getSignalFrameSemaphores(std::vector &signal) const; virtual VkDeviceSize getUniformSize() const; - virtual void updateUniformBuffer(uint32_t imageIndex); + virtual void updateUniformBuffer(uint32_t imageIndex, size_t globalFrame); virtual void drawFrame(); private: diff --git a/Samples/5_Domain_Specific/simpleVulkanMMAP/VulkanBaseApp.h b/Samples/5_Domain_Specific/simpleVulkanMMAP/VulkanBaseApp.h index 814e321e..4f4425bd 100644 --- a/Samples/5_Domain_Specific/simpleVulkanMMAP/VulkanBaseApp.h +++ b/Samples/5_Domain_Specific/simpleVulkanMMAP/VulkanBaseApp.h @@ -34,8 +34,10 @@ #include #ifdef _WIN64 #define NOMINMAX -#include +// Add windows.h to the include path firstly as dependency for other Windows headers #include +// Add other Windows headers +#include #endif /* _WIN64 */ struct GLFWwindow; diff --git a/Samples/5_Domain_Specific/vulkanImageCUDA/vulkanImageCUDA.cu b/Samples/5_Domain_Specific/vulkanImageCUDA/vulkanImageCUDA.cu index f782bbb9..b94487fc 100644 --- a/Samples/5_Domain_Specific/vulkanImageCUDA/vulkanImageCUDA.cu +++ b/Samples/5_Domain_Specific/vulkanImageCUDA/vulkanImageCUDA.cu @@ -27,10 +27,12 @@ #define GLFW_INCLUDE_VULKAN #ifdef _WIN64 +// Add windows.h to the include path firstly as dependency for other Windows headers +#include +// Add other Windows headers #include #include #include -#include #define _USE_MATH_DEFINES #endif From 5987a9e9fa5197079ae38117fe7533a199e25f76 Mon Sep 17 00:00:00 2001 From: shawnz Date: Mon, 19 May 2025 17:38:42 +0800 Subject: [PATCH 2/3] Update transpose for code format check --- Samples/6_Performance/transpose/transpose.cu | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Samples/6_Performance/transpose/transpose.cu b/Samples/6_Performance/transpose/transpose.cu index 8a1d8bec..09c7582e 100644 --- a/Samples/6_Performance/transpose/transpose.cu +++ b/Samples/6_Performance/transpose/transpose.cu @@ -597,17 +597,16 @@ int main(int argc, char **argv) 1, TILE_DIM * BLOCK_ROWS); - // Reset d_odata to zero before starting the next loop iteration to avoid - // carrying over results from previous kernels. Without this reset, residual - // data from a prior kernel (e.g., 'copy') could make a subsequent - // kernel (e.g., 'copySharedMem') appear correct even if it performs no work, + // Reset d_odata to zero before starting the next loop iteration to avoid + // carrying over results from previous kernels. Without this reset, residual + // data from a prior kernel (e.g., 'copy') could make a subsequent + // kernel (e.g., 'copySharedMem') appear correct even if it performs no work, // leading to false positives in compareData. for (int i = 0; i < (size_x * size_y); ++i) { h_odata[i] = 0; } // copy host data to device - checkCudaErrors( - cudaMemcpy(d_odata, h_odata, mem_size, cudaMemcpyHostToDevice)); + checkCudaErrors(cudaMemcpy(d_odata, h_odata, mem_size, cudaMemcpyHostToDevice)); } // cleanup From da3b7a2b3cecd5f73a19bcc7fa502169b72c90bf Mon Sep 17 00:00:00 2001 From: shawnz Date: Mon, 19 May 2025 17:43:08 +0800 Subject: [PATCH 3/3] Update the vulkanImageCUDA/vulkanImageCUDA.cu for Windows headers --- .../simpleVulkan/VulkanBaseApp.h | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h index 616b1c14..7354881d 100644 --- a/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h +++ b/Samples/5_Domain_Specific/simpleVulkan/VulkanBaseApp.h @@ -34,9 +34,9 @@ #include #ifdef _WIN64 #define NOMINMAX -// Add windows.h to the include path firstly as dependency for other Windows headers +// Add windows.h to the include path #include -// Add other Windows headers +// Add vulkan_win32.h to the include path #include #endif /* _WIN64 */ @@ -56,7 +56,6 @@ public: void init(); void *getMemHandle(VkDeviceMemory memory, VkExternalMemoryHandleTypeFlagBits handleType); void *getSemaphoreHandle(VkSemaphore semaphore, VkExternalSemaphoreHandleTypeFlagBits handleType); - bool isVkPhysicalDeviceUuid(void *Uuid); void createExternalSemaphore(VkSemaphore &semaphore, VkExternalSemaphoreHandleTypeFlagBits handleType); void createBuffer(VkDeviceSize size, VkBufferUsageFlags usage, @@ -88,7 +87,6 @@ protected: VkDebugUtilsMessengerEXT m_debugMessenger; VkSurfaceKHR m_surface; VkPhysicalDevice m_physicalDevice; - uint8_t m_deviceUUID[VK_UUID_SIZE]; VkDevice m_device; VkQueue m_graphicsQueue; VkQueue m_presentQueue; @@ -109,15 +107,17 @@ protected: std::vector m_inFlightFences; std::vector m_uniformBuffers; std::vector m_uniformMemory; + VkSemaphore m_vkPresentationSemaphore; + VkSemaphore m_vkTimelineSemaphore; VkDescriptorSetLayout m_descriptorSetLayout; VkDescriptorPool m_descriptorPool; std::vector m_descriptorSets; - - VkImage m_depthImage; - VkDeviceMemory m_depthImageMemory; - VkImageView m_depthImageView; - size_t m_currentFrame; - bool m_framebufferResized; + VkImage m_depthImage; + VkDeviceMemory m_depthImageMemory; + VkImageView m_depthImageView; + size_t m_currentFrame; + bool m_framebufferResized; + uint8_t m_vkDeviceUUID[VK_UUID_SIZE]; virtual void initVulkanApp() {} virtual void fillRenderingCommandBuffer(VkCommandBuffer &buffer) {} @@ -130,7 +130,7 @@ protected: std::vector &waitStages) const; virtual void getSignalFrameSemaphores(std::vector &signal) const; virtual VkDeviceSize getUniformSize() const; - virtual void updateUniformBuffer(uint32_t imageIndex, size_t globalFrame); + virtual void updateUniformBuffer(uint32_t imageIndex); virtual void drawFrame(); private: