[Bf-blender-cvs] [816bd8bed62] tmp-vulkan: GHOST: Vulkan: Rework support for MSVC

Clément Foucault noreply at git.blender.org
Wed Sep 16 22:05:41 CEST 2020


Commit: 816bd8bed624fe601da1a9f9bcc07c9b08b16b94
Author: Clément Foucault
Date:   Wed Sep 16 22:01:04 2020 +0200
Branches: tmp-vulkan
https://developer.blender.org/rB816bd8bed624fe601da1a9f9bcc07c9b08b16b94

GHOST: Vulkan: Rework support for MSVC

This removes designated initializer because not supported by MSVC for our
current C++ version.

Fixes some other compile errors and add usage of the `ContextVK` context in
the Win32 backend.

===================================================================

M	intern/ghost/intern/GHOST_ContextVK.cpp
M	intern/ghost/intern/GHOST_ContextVK.h
M	intern/ghost/intern/GHOST_SystemWin32.cpp
M	intern/ghost/intern/GHOST_WindowWin32.cpp

===================================================================

diff --git a/intern/ghost/intern/GHOST_ContextVK.cpp b/intern/ghost/intern/GHOST_ContextVK.cpp
index b013952124c..a931f993ead 100644
--- a/intern/ghost/intern/GHOST_ContextVK.cpp
+++ b/intern/ghost/intern/GHOST_ContextVK.cpp
@@ -130,7 +130,6 @@ GHOST_ContextVK::GHOST_ContextVK(bool stereoVisual,
                                  int debug)
     : GHOST_Context(stereoVisual),
 #ifdef _WIN32
-      m_hinstance(hinstance),
       m_hwnd(hwnd),
 #elif defined(__APPLE__)
       m_metal_layer(metal_layer),
@@ -246,30 +245,28 @@ GHOST_TSuccess GHOST_ContextVK::swapBuffers()
 
   VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT};
 
-  VkSubmitInfo submit_info{
-      .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
-      .waitSemaphoreCount = 1,
-      .pWaitSemaphores = &m_image_available_semaphores[m_currentFrame],
-      .pWaitDstStageMask = wait_stages,
-      .commandBufferCount = 1,
-      .pCommandBuffers = &m_command_buffers[image_id],
-      .signalSemaphoreCount = 1,
-      .pSignalSemaphores = &m_render_finished_semaphores[m_currentFrame],
-  };
+  VkSubmitInfo submit_info = {};
+  submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+  submit_info.waitSemaphoreCount = 1;
+  submit_info.pWaitSemaphores = &m_image_available_semaphores[m_currentFrame];
+  submit_info.pWaitDstStageMask = wait_stages;
+  submit_info.commandBufferCount = 1;
+  submit_info.pCommandBuffers = &m_command_buffers[image_id];
+  submit_info.signalSemaphoreCount = 1;
+  submit_info.pSignalSemaphores = &m_render_finished_semaphores[m_currentFrame];
 
   vkResetFences(m_device, 1, &m_in_flight_fences[m_currentFrame]);
 
   VK_CHECK(vkQueueSubmit(m_graphic_queue, 1, &submit_info, m_in_flight_fences[m_currentFrame]));
 
-  VkPresentInfoKHR present_info{
-      .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
-      .waitSemaphoreCount = 1,
-      .pWaitSemaphores = &m_render_finished_semaphores[m_currentFrame],
-      .swapchainCount = 1,
-      .pSwapchains = &m_swapchain,
-      .pImageIndices = &image_id,
-      .pResults = NULL,
-  };
+  VkPresentInfoKHR present_info{};
+  present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+  present_info.waitSemaphoreCount = 1;
+  present_info.pWaitSemaphores = &m_render_finished_semaphores[m_currentFrame];
+  present_info.swapchainCount = 1;
+  present_info.pSwapchains = &m_swapchain;
+  present_info.pImageIndices = &image_id;
+  present_info.pResults = NULL;
 
   result = vkQueuePresentKHR(m_present_queue, &present_info);
 
@@ -531,35 +528,31 @@ static GHOST_TSuccess create_render_pass(VkDevice device,
                                          VkFormat format,
                                          VkRenderPass *r_renderPass)
 {
-  VkAttachmentDescription colorAttachment = {
-      .format = format,
-      .samples = VK_SAMPLE_COUNT_1_BIT,
-      .loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR,
-      .storeOp = VK_ATTACHMENT_STORE_OP_STORE,
-      .stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE,
-      .stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE,
-      .initialLayout = VK_IMAGE_LAYOUT_UNDEFINED,
-      .finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR,
-  };
-
-  VkAttachmentReference colorAttachmentRef = {
-      .attachment = 0,
-      .layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
-  };
-
-  VkSubpassDescription subpass = {
-      .pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
-      .colorAttachmentCount = 1,
-      .pColorAttachments = &colorAttachmentRef,
-  };
-
-  VkRenderPassCreateInfo renderPassInfo = {
-      .sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
-      .attachmentCount = 1,
-      .pAttachments = &colorAttachment,
-      .subpassCount = 1,
-      .pSubpasses = &subpass,
-  };
+  VkAttachmentDescription colorAttachment = {};
+  colorAttachment.format = format;
+  colorAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
+  colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
+  colorAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
+  colorAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
+  colorAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
+  colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
+  colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
+
+  VkAttachmentReference colorAttachmentRef = {};
+  colorAttachmentRef.attachment = 0;
+  colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
+
+  VkSubpassDescription subpass = {};
+  subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+  subpass.colorAttachmentCount = 1;
+  subpass.pColorAttachments = &colorAttachmentRef;
+
+  VkRenderPassCreateInfo renderPassInfo = {};
+  renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+  renderPassInfo.attachmentCount = 1;
+  renderPassInfo.pAttachments = &colorAttachment;
+  renderPassInfo.subpassCount = 1;
+  renderPassInfo.pSubpasses = &subpass;
 
   VK_CHECK(vkCreateRenderPass(device, &renderPassInfo, NULL, r_renderPass));
 
@@ -598,27 +591,24 @@ static GHOST_TSuccess selectPresentMode(VkPhysicalDevice device,
 GHOST_TSuccess GHOST_ContextVK::recordCommandBuffers(void)
 {
   for (int i = 0; i < m_command_buffers.size(); i++) {
-    VkCommandBufferBeginInfo begin_info = {
-        .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
-        .flags = 0,
-        .pInheritanceInfo = NULL,
-    };
+    VkCommandBufferBeginInfo begin_info = {};
+    begin_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+    begin_info.flags = 0;
+    begin_info.pInheritanceInfo = NULL;
 
     VK_CHECK(vkBeginCommandBuffer(m_command_buffers[i], &begin_info));
     {
-      VkRect2D area = {
-          .offset = {0, 0},
-          .extent = m_render_extent,
-      };
+      VkRect2D area = {};
+      area.offset = {0, 0};
+      area.extent = m_render_extent;
       VkClearValue clearColor = {{{0.0f, 0.5f, 0.3f, 1.0f}}};
-      VkRenderPassBeginInfo render_pass_info = {
-          .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
-          .renderPass = m_render_pass,
-          .framebuffer = m_swapchain_framebuffers[i],
-          .renderArea = area,
-          .clearValueCount = 1,
-          .pClearValues = &clearColor,
-      };
+      VkRenderPassBeginInfo render_pass_info = {};
+      render_pass_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
+      render_pass_info.renderPass = m_render_pass;
+      render_pass_info.framebuffer = m_swapchain_framebuffers[i];
+      render_pass_info.renderArea = area;
+      render_pass_info.clearValueCount = 1;
+      render_pass_info.pClearValues = &clearColor;
 
       vkCmdBeginRenderPass(m_command_buffers[i], &render_pass_info, VK_SUBPASS_CONTENTS_INLINE);
 
@@ -635,20 +625,18 @@ GHOST_TSuccess GHOST_ContextVK::createCommandBuffers(void)
 {
   m_command_buffers.resize(m_swapchain_image_views.size());
 
-  VkCommandPoolCreateInfo poolInfo = {
-      .sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
-      .flags = 0,
-      .queueFamilyIndex = m_queue_family_graphic,
-  };
+  VkCommandPoolCreateInfo poolInfo = {};
+  poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+  poolInfo.flags = 0;
+  poolInfo.queueFamilyIndex = m_queue_family_graphic;
 
   VK_CHECK(vkCreateCommandPool(m_device, &poolInfo, NULL, &m_command_pool));
 
-  VkCommandBufferAllocateInfo alloc_info = {
-      .sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
-      .commandPool = m_command_pool,
-      .level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
-      .commandBufferCount = static_cast<uint32_t>(m_command_buffers.size()),
-  };
+  VkCommandBufferAllocateInfo alloc_info = {};
+  alloc_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+  alloc_info.commandPool = m_command_pool;
+  alloc_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
+  alloc_info.commandBufferCount = static_cast<uint32_t>(m_command_buffers.size());
 
   VK_CHECK(vkAllocateCommandBuffers(m_device, &alloc_info, m_command_buffers.data()));
 
@@ -698,21 +686,20 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain(void)
     image_count = capabilities.maxImageCount;
   }
 
-  VkSwapchainCreateInfoKHR create_info = {
-      .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
-      .surface = m_surface,
-      .minImageCount = image_count,
-      .imageFormat = format.format,
-      .imageColorSpace = format.colorSpace,
-      .imageExtent = m_render_extent,
-      .imageArrayLayers = 1,
-      .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
-      .preTransform = capabilities.currentTransform,
-      .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
-      .presentMode = present_mode,
-      .clipped = VK_TRUE,
-      .oldSwapchain = VK_NULL_HANDLE, /* TODO Window resize */
-  };
+  VkSwapchainCreateInfoKHR create_info = {};
+  create_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+  create_info.surface = m_surface;
+  create_info.minImageCount = image_count;
+  create_info.imageFormat = format.format;
+  create_info.imageColorSpace = format.colorSpace;
+  create_info.imageExtent = m_render_extent;
+  create_info.imageArrayLayers = 1;
+  create_info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+  create_info.preTransform = capabilities.currentTransform;
+  create_info.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
+  create_info.presentMode = present_mode;
+  create_info.clipped = VK_TRUE;
+  create_info.oldSwapchain = VK_NULL_HANDLE; /* TODO Window resize */
 
   uint32_t queueFamilyIndices[] = {m_queue_family_graphic, m_queue_family_present};
 
@@ -740,41 +727,35 @@ GHOST_TSuccess GHOST_ContextVK::createSwapchain(void)
   m_swapchain_image_views.resize(image_count);
   m_swapchain_framebuffers.resize(image_count);
   for (int i = 0; i < image_count; i++) {
-    VkImageViewCreateInfo view_create_info = {
-        .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
-        .image = m_swapchain_images[i],
-        .viewType = VK_IMAGE_VIEW_TYPE_2D,
-        .format = format.format,
-        .components =
-            {
-                .r = VK_COMPONENT_SWIZZLE_IDENTITY,
-                .g = VK_COMPONENT_SWIZZLE_IDENTITY,
-                .b = VK_COMPONENT_SWIZZLE_IDENTITY,
-                .a = VK_COMPONENT_SWIZZLE_IDENTITY,
-            },
-        .subresourceRange =
-            {
-     

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list