فهرست منبع

vulkan: fix various compile issues

rdb 7 سال پیش
والد
کامیت
41718aeb5c

+ 1 - 1
panda/src/vulkandisplay/vulkanGraphicsPipe.cxx

@@ -265,7 +265,7 @@ VulkanGraphicsPipe() {
     vkEnumerateDeviceExtensionProperties(_gpu, nullptr, &num_dev_extensions, nullptr);
     vkEnumerateDeviceExtensionProperties(_gpu, nullptr, &num_dev_extensions, nullptr);
 
 
     VkExtensionProperties *extensions = (VkExtensionProperties *)
     VkExtensionProperties *extensions = (VkExtensionProperties *)
-      alloca(sizeof(VkExtensionProperties) * max(num_inst_extensions, num_dev_extensions));
+      alloca(sizeof(VkExtensionProperties) * std::max(num_inst_extensions, num_dev_extensions));
 
 
     vulkandisplay_cat.debug() << "Supported instance extensions:\n";
     vulkandisplay_cat.debug() << "Supported instance extensions:\n";
     vkEnumerateInstanceExtensionProperties(nullptr, &num_inst_extensions, extensions);
     vkEnumerateInstanceExtensionProperties(nullptr, &num_inst_extensions, extensions);

+ 17 - 17
panda/src/vulkandisplay/vulkanGraphicsStateGuardian.cxx

@@ -199,7 +199,7 @@ VulkanGraphicsStateGuardian(GraphicsEngine *engine, VulkanGraphicsPipe *pipe,
   // for attributes when they are not bound to a vertex buffer, as well as any
   // for attributes when they are not bound to a vertex buffer, as well as any
   // flat color assigned via ColorAttrib.
   // flat color assigned via ColorAttrib.
   VkDeviceMemory memory;
   VkDeviceMemory memory;
-  uint32_t palette_size = (uint32_t)min(2, vulkan_color_palette_size.get_value()) * 16;
+  uint32_t palette_size = (uint32_t)std::min(2, vulkan_color_palette_size.get_value()) * 16;
   if (!create_buffer(palette_size, _color_vertex_buffer, memory,
   if (!create_buffer(palette_size, _color_vertex_buffer, memory,
                      VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
                      VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
                      VK_BUFFER_USAGE_TRANSFER_DST_BIT,
                      VK_BUFFER_USAGE_TRANSFER_DST_BIT,
@@ -219,7 +219,7 @@ VulkanGraphicsStateGuardian(GraphicsEngine *engine, VulkanGraphicsPipe *pipe,
   const VkPhysicalDeviceFeatures &features = pipe->_gpu_features;
   const VkPhysicalDeviceFeatures &features = pipe->_gpu_features;
   _is_hardware = (pipe->_gpu_properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_CPU);
   _is_hardware = (pipe->_gpu_properties.deviceType != VK_PHYSICAL_DEVICE_TYPE_CPU);
 
 
-  _max_vertices_per_array = max((uint32_t)0x7fffffff, limits.maxDrawIndexedIndexValue);
+  _max_vertices_per_array = std::max((uint32_t)0x7fffffff, limits.maxDrawIndexedIndexValue);
   _max_vertices_per_primitive = INT_MAX;
   _max_vertices_per_primitive = INT_MAX;
 
 
   _max_texture_dimension = limits.maxImageDimension2D;
   _max_texture_dimension = limits.maxImageDimension2D;
@@ -390,6 +390,8 @@ get_driver_version() {
  */
  */
 TextureContext *VulkanGraphicsStateGuardian::
 TextureContext *VulkanGraphicsStateGuardian::
 prepare_texture(Texture *texture, int view) {
 prepare_texture(Texture *texture, int view) {
+  using std::swap;
+
   PStatTimer timer(_prepare_texture_pcollector);
   PStatTimer timer(_prepare_texture_pcollector);
 
 
   VulkanGraphicsPipe *vkpipe;
   VulkanGraphicsPipe *vkpipe;
@@ -493,9 +495,9 @@ prepare_texture(Texture *texture, int view) {
          image_info.extent.height > img_props.maxExtent.height ||
          image_info.extent.height > img_props.maxExtent.height ||
          image_info.extent.depth > img_props.maxExtent.depth) {
          image_info.extent.depth > img_props.maxExtent.depth) {
     // Reduce the size by bumping the first mipmap level uploaded.
     // Reduce the size by bumping the first mipmap level uploaded.
-    image_info.extent.width = max(1U, image_info.extent.width >> 1);
-    image_info.extent.height = max(1U, image_info.extent.height >> 1);
-    image_info.extent.depth = max(1U, image_info.extent.depth >> 1);
+    image_info.extent.width = std::max(1U, image_info.extent.width >> 1);
+    image_info.extent.height = std::max(1U, image_info.extent.height >> 1);
+    image_info.extent.depth = std::max(1U, image_info.extent.depth >> 1);
     ++mipmap_begin;
     ++mipmap_begin;
   }
   }
 
 
@@ -734,7 +736,6 @@ bool VulkanGraphicsStateGuardian::
 upload_texture(VulkanTextureContext *tc) {
 upload_texture(VulkanTextureContext *tc) {
   Texture *texture = tc->get_texture();
   Texture *texture = tc->get_texture();
   VkImage image = tc->_image;
   VkImage image = tc->_image;
-  uint32_t mip_levels = tc->_mipmap_end - tc->_mipmap_begin;
   VkResult err;
   VkResult err;
 
 
   //TODO: check if the image is currently in use on a different queue, and if
   //TODO: check if the image is currently in use on a different queue, and if
@@ -797,7 +798,7 @@ upload_texture(VulkanTextureContext *tc) {
       }
       }
     }
     }
   }
   }
-  nassertr(buffer_size > 0, nullptr);
+  nassertr(buffer_size > 0, false);
 
 
   VkBuffer buffer;
   VkBuffer buffer;
   VkDeviceMemory staging_mem;
   VkDeviceMemory staging_mem;
@@ -806,7 +807,7 @@ upload_texture(VulkanTextureContext *tc) {
                      VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
                      VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)) {
     vulkandisplay_cat.error()
     vulkandisplay_cat.error()
       << "Failed to create staging buffer for texture "
       << "Failed to create staging buffer for texture "
-      << texture->get_name() << endl;
+      << texture->get_name() << std::endl;
     return false;
     return false;
   }
   }
 
 
@@ -870,7 +871,7 @@ upload_texture(VulkanTextureContext *tc) {
     } else {
     } else {
       // We do have an image.  This means we can write it to the appropriate
       // We do have an image.  This means we can write it to the appropriate
       // location in the staging buffer, and schedule a copy to the image.
       // location in the staging buffer, and schedule a copy to the image.
-      nassertr(buffer != VK_NULL_HANDLE, nullptr);
+      nassertr(buffer != VK_NULL_HANDLE, false);
 
 
       // Pad for optimal alignment.
       // Pad for optimal alignment.
       VkDeviceSize remain = region.bufferOffset % optimal_align;
       VkDeviceSize remain = region.bufferOffset % optimal_align;
@@ -904,9 +905,9 @@ upload_texture(VulkanTextureContext *tc) {
       blit.srcOffsets[1].z = region.imageExtent.depth;
       blit.srcOffsets[1].z = region.imageExtent.depth;
     }
     }
 
 
-    region.imageExtent.width = max(1U, region.imageExtent.width >> 1);
-    region.imageExtent.height = max(1U, region.imageExtent.height >> 1);
-    region.imageExtent.depth = max(1U, region.imageExtent.depth >> 1);
+    region.imageExtent.width = std::max(1U, region.imageExtent.width >> 1);
+    region.imageExtent.height = std::max(1U, region.imageExtent.height >> 1);
+    region.imageExtent.depth = std::max(1U, region.imageExtent.depth >> 1);
     ++region.imageSubresource.mipLevel;
     ++region.imageSubresource.mipLevel;
   }
   }
 
 
@@ -959,7 +960,7 @@ update_texture(TextureContext *tc, bool force) {
       arrayLayers = tex->get_z_size();
       arrayLayers = tex->get_z_size();
     }
     }
 
 
-    VkFormat format = get_image_format(tex);
+    //VkFormat format = get_image_format(tex);
 
 
     if (//format != vtc->_format ||
     if (//format != vtc->_format ||
         extent.width != vtc->_extent.width ||
         extent.width != vtc->_extent.width ||
@@ -967,7 +968,7 @@ update_texture(TextureContext *tc, bool force) {
         extent.depth != vtc->_extent.depth ||
         extent.depth != vtc->_extent.depth ||
         arrayLayers != vtc->_array_layers) {
         arrayLayers != vtc->_array_layers) {
       // We need to recreate the image entirely. TODO!
       // We need to recreate the image entirely. TODO!
-      cerr << "have to recreate image\n";
+      std::cerr << "have to recreate image\n";
       return false;
       return false;
     }
     }
 
 
@@ -2043,7 +2044,6 @@ framebuffer_copy_to_texture(Texture *tex, int view, int z,
 
 
   //TODO: proper format checking and size calculation.
   //TODO: proper format checking and size calculation.
   tex->setup_2d_texture(fbtc->_extent.width, fbtc->_extent.height, Texture::T_unsigned_byte, Texture::F_rgba8);
   tex->setup_2d_texture(fbtc->_extent.width, fbtc->_extent.height, Texture::T_unsigned_byte, Texture::F_rgba8);
-  VkDeviceSize buffer_size = fbtc->_extent.width * fbtc->_extent.height * 4;
 
 
   VulkanTextureContext *tc;
   VulkanTextureContext *tc;
   DCAST_INTO_R(tc, tex->prepare_now(view, get_prepared_objects(), this), false);
   DCAST_INTO_R(tc, tex->prepare_now(view, get_prepared_objects(), this), false);
@@ -2575,7 +2575,7 @@ make_pipeline(const RenderState *state, const GeomVertexFormat *format,
   ds_info.flags = 0;
   ds_info.flags = 0;
   ds_info.depthTestEnable = (depth_test->get_mode() != RenderAttrib::M_none);
   ds_info.depthTestEnable = (depth_test->get_mode() != RenderAttrib::M_none);
   ds_info.depthWriteEnable = depth_write->get_mode();
   ds_info.depthWriteEnable = depth_write->get_mode();
-  ds_info.depthCompareOp = (VkCompareOp)max(0, depth_test->get_mode() - 1);
+  ds_info.depthCompareOp = (VkCompareOp)std::max(0, depth_test->get_mode() - 1);
   ds_info.depthBoundsTestEnable = VK_FALSE;
   ds_info.depthBoundsTestEnable = VK_FALSE;
   ds_info.stencilTestEnable = VK_FALSE;
   ds_info.stencilTestEnable = VK_FALSE;
   ds_info.front.failOp = VK_STENCIL_OP_KEEP;
   ds_info.front.failOp = VK_STENCIL_OP_KEEP;
@@ -2661,7 +2661,7 @@ make_pipeline(const RenderState *state, const GeomVertexFormat *format,
     default:
     default:
       att_state[0].blendEnable = VK_FALSE;
       att_state[0].blendEnable = VK_FALSE;
       vulkandisplay_cat.error()
       vulkandisplay_cat.error()
-        << "invalid transparency mode " << (int)transp->get_mode() << endl;
+        << "invalid transparency mode " << (int)transp->get_mode() << std::endl;
       break;
       break;
     }
     }
   }
   }

+ 7 - 9
panda/src/vulkandisplay/vulkanGraphicsWindow.cxx

@@ -278,12 +278,9 @@ void VulkanGraphicsWindow::
 begin_flip() {
 begin_flip() {
   VulkanGraphicsStateGuardian *vkgsg;
   VulkanGraphicsStateGuardian *vkgsg;
   DCAST_INTO_V(vkgsg, _gsg);
   DCAST_INTO_V(vkgsg, _gsg);
-  VkDevice device = vkgsg->_device;
   VkQueue queue = vkgsg->_queue;
   VkQueue queue = vkgsg->_queue;
   VkResult err;
   VkResult err;
 
 
-  SwapBuffer &buffer = _swap_buffers[_image_index];
-
   VkResult results[1];
   VkResult results[1];
   VkPresentInfoKHR present;
   VkPresentInfoKHR present;
   present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
   present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
@@ -297,10 +294,10 @@ begin_flip() {
 
 
   err = vkQueuePresentKHR(queue, &present);
   err = vkQueuePresentKHR(queue, &present);
   if (err == VK_ERROR_OUT_OF_DATE_KHR) {
   if (err == VK_ERROR_OUT_OF_DATE_KHR) {
-    cerr << "out of date.\n";
+    std::cerr << "out of date.\n";
 
 
   } else if (err == VK_SUBOPTIMAL_KHR) {
   } else if (err == VK_SUBOPTIMAL_KHR) {
-    cerr << "suboptimal.\n";
+    std::cerr << "suboptimal.\n";
 
 
   } else if (err != VK_SUCCESS) {
   } else if (err != VK_SUCCESS) {
     vulkan_error(err, "Error presenting queue");
     vulkan_error(err, "Error presenting queue");
@@ -442,6 +439,7 @@ open_window() {
     _gsg = vkgsg;
     _gsg = vkgsg;
   } else {
   } else {
     //TODO: check that the GSG's queue can present to our surface.
     //TODO: check that the GSG's queue can present to our surface.
+    _gsg = vkgsg;
   }
   }
 
 
   _fb_properties.set_force_hardware(vkgsg->is_hardware());
   _fb_properties.set_force_hardware(vkgsg->is_hardware());
@@ -762,12 +760,12 @@ create_swapchain() {
   }
   }
 
 
   uint32_t num_images = (uint32_t)(1 + _fb_properties.get_back_buffers());
   uint32_t num_images = (uint32_t)(1 + _fb_properties.get_back_buffers());
-  num_images = min(surf_caps.maxImageCount, num_images);
-  num_images = max(surf_caps.minImageCount, num_images);
+  num_images = std::min(surf_caps.maxImageCount, num_images);
+  num_images = std::max(surf_caps.minImageCount, num_images);
 
 
   _swapchain_size.set(
   _swapchain_size.set(
-    max(min((uint32_t)_size[0], surf_caps.maxImageExtent.width), surf_caps.minImageExtent.width),
-    max(min((uint32_t)_size[1], surf_caps.maxImageExtent.height), surf_caps.minImageExtent.height));
+    std::max(std::min((uint32_t)_size[0], surf_caps.maxImageExtent.width), surf_caps.minImageExtent.width),
+    std::max(std::min((uint32_t)_size[1], surf_caps.maxImageExtent.height), surf_caps.minImageExtent.height));
 
 
   // Get the supported presentation modes for this surface.
   // Get the supported presentation modes for this surface.
   uint32_t num_present_modes = 0;
   uint32_t num_present_modes = 0;