15#define VULKAN_HPP_DISPATCH_LOADER_DYNAMIC 1 
   16#include <vulkan/vulkan.hpp> 
   17VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
 
   40    auto tmp_internal_retVal = cmd;                                                                         \ 
   41    if ((int32_t)tmp_internal_retVal < 0) {                                                                 \ 
   42      GPUError("VULKAN ERROR: %d: %s (%s: %d)", (int32_t)tmp_internal_retVal, "ERROR", __FILE__, __LINE__); \ 
   43      throw std::runtime_error("Vulkan Failure");                                                           \ 
 
   56static int32_t checkVulkanLayersSupported(
const std::vector<const char*>& validationLayers)
 
   58  std::vector<vk::LayerProperties> availableLayers = vk::enumerateInstanceLayerProperties();
 
   59  for (
const char* layerName : validationLayers) {
 
   60    bool layerFound = 
false;
 
   62    for (
const auto& layerProperties : availableLayers) {
 
   63      if (strcmp(layerName, layerProperties.layerName) == 0) {
 
   76static uint32_t findMemoryType(uint32_t typeFilter, vk::MemoryPropertyFlags properties, vk::PhysicalDevice physDev)
 
   78  vk::PhysicalDeviceMemoryProperties memProperties = physDev.getMemoryProperties();
 
   80  for (uint32_t 
i = 0; 
i < memProperties.memoryTypeCount; 
i++) {
 
   81    if ((typeFilter & (1 << 
i)) && (memProperties.memoryTypes[
i].propertyFlags & properties) == properties) {
 
   86  throw std::runtime_error(
"failed to find suitable memory type!");
 
   89static vk::SurfaceFormatKHR chooseSwapSurfaceFormat(
const std::vector<vk::SurfaceFormatKHR>& availableFormats)
 
   91  for (
const auto& availableFormat : availableFormats) {
 
   92    if (availableFormat.format == vk::Format::eB8G8R8A8Unorm && availableFormat.colorSpace == vk::ColorSpaceKHR::eSrgbNonlinear) {
 
   93      return availableFormat;
 
   96  return availableFormats[0];
 
   99static vk::PresentModeKHR chooseSwapPresentMode(
const std::vector<vk::PresentModeKHR>& availablePresentModes, vk::PresentModeKHR desiredMode = vk::PresentModeKHR::eMailbox)
 
  101  for (
const auto& availablePresentMode : availablePresentModes) {
 
  102    if (availablePresentMode == desiredMode) {
 
  103      return availablePresentMode;
 
  106  static bool errorShown = 
false;
 
  109    GPUError(
"VULKAN ERROR: Desired present mode not available, using FIFO mode");
 
  111  return vk::PresentModeKHR::eFifo;
 
  116  if (capabilities.currentExtent.width != std::numeric_limits<uint32_t>::max()) {
 
  117    return capabilities.currentExtent;
 
  121    vk::Extent2D actualExtent = {(uint32_t)
width, (uint32_t)
height};
 
  122    actualExtent.width = std::clamp(actualExtent.width, capabilities.minImageExtent.width, capabilities.maxImageExtent.width);
 
  123    actualExtent.height = std::clamp(actualExtent.height, capabilities.minImageExtent.height, capabilities.maxImageExtent.height);
 
 
  128static vk::ShaderModule createShaderModule(
const char* code, 
size_t size, vk::Device device)
 
  130  vk::ShaderModuleCreateInfo createInfo{};
 
  131  createInfo.codeSize = 
size;
 
  132  createInfo.pCode = 
reinterpret_cast<const uint32_t*
>(code);
 
  133  return device.createShaderModule(createInfo, 
nullptr);
 
  136static void cmdImageMemoryBarrier(vk::CommandBuffer cmdbuffer, vk::Image 
image, vk::AccessFlags srcAccessMask, vk::AccessFlags dstAccessMask, vk::ImageLayout oldLayout, vk::ImageLayout newLayout, vk::PipelineStageFlags srcStageMask, vk::PipelineStageFlags dstStageMask)
 
  138  vk::ImageSubresourceRange 
range{vk::ImageAspectFlagBits::eColor, 0, 1, 0, 1};
 
  139  vk::ImageMemoryBarrier barrier{};
 
  140  barrier.srcAccessMask = srcAccessMask;
 
  141  barrier.dstAccessMask = dstAccessMask;
 
  142  barrier.oldLayout = oldLayout;
 
  143  barrier.newLayout = newLayout;
 
  144  barrier.image = 
image;
 
  145  barrier.subresourceRange = 
range;
 
  146  cmdbuffer.pipelineBarrier(srcStageMask, dstStageMask, {}, 0, 
nullptr, 0, 
nullptr, 1, &barrier);
 
  158  vk::CommandBufferAllocateInfo allocInfo{};
 
  159  allocInfo.level = vk::CommandBufferLevel::ePrimary;
 
  161  allocInfo.commandBufferCount = 1;
 
  162  vk::CommandBuffer commandBuffer = 
mDevice.allocateCommandBuffers(allocInfo)[0];
 
  163  vk::CommandBufferBeginInfo beginInfo{};
 
  164  beginInfo.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
 
  165  commandBuffer.begin(beginInfo);
 
  166  return commandBuffer;
 
 
  172  vk::SubmitInfo submitInfo{};
 
  173  submitInfo.commandBufferCount = 1;
 
  174  submitInfo.pCommandBuffers = &commandBuffer;
 
  175  static std::mutex fenceMutex;
 
  177    std::lock_guard<std::mutex> guard(fenceMutex);
 
 
  185static vk::ImageView createImageViewI(vk::Device device, vk::Image 
image, vk::Format 
format, vk::ImageAspectFlags aspectFlags = vk::ImageAspectFlagBits::eColor, uint32_t mipLevels = 1)
 
  187  vk::ImageViewCreateInfo viewInfo{};
 
  188  viewInfo.image = 
image;
 
  189  viewInfo.viewType = vk::ImageViewType::e2D;
 
  191  viewInfo.subresourceRange.aspectMask = aspectFlags;
 
  192  viewInfo.subresourceRange.baseMipLevel = 0;
 
  193  viewInfo.subresourceRange.levelCount = mipLevels;
 
  194  viewInfo.subresourceRange.baseArrayLayer = 0;
 
  195  viewInfo.subresourceRange.layerCount = 1;
 
  196  return device.createImageView(viewInfo, 
nullptr);
 
  199static void createImageI(vk::Device device, vk::PhysicalDevice physicalDevice, vk::Image& 
image, vk::DeviceMemory& imageMemory, uint32_t 
width, uint32_t 
height, vk::Format 
format, vk::ImageUsageFlags 
usage, vk::MemoryPropertyFlags properties, vk::ImageTiling tiling = vk::ImageTiling::eOptimal, vk::SampleCountFlagBits numSamples = vk::SampleCountFlagBits::e1, vk::ImageLayout layout = vk::ImageLayout::eUndefined, uint32_t mipLevels = 1)
 
  201  vk::ImageCreateInfo imageInfo{};
 
  202  imageInfo.imageType = vk::ImageType::e2D;
 
  203  imageInfo.extent.width = 
width;
 
  204  imageInfo.extent.height = 
height;
 
  205  imageInfo.extent.depth = 1;
 
  206  imageInfo.mipLevels = mipLevels;
 
  207  imageInfo.arrayLayers = 1;
 
  208  imageInfo.format = 
format;
 
  209  imageInfo.tiling = tiling;
 
  210  imageInfo.initialLayout = layout;
 
  211  imageInfo.usage = 
usage;
 
  212  imageInfo.samples = numSamples;
 
  213  imageInfo.sharingMode = vk::SharingMode::eExclusive;
 
  214  image = device.createImage(imageInfo);
 
  216  vk::MemoryRequirements memRequirements;
 
  217  memRequirements = device.getImageMemoryRequirements(
image);
 
  219  vk::MemoryAllocateInfo allocInfo{};
 
  220  allocInfo.allocationSize = memRequirements.size;
 
  221  allocInfo.memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties, physicalDevice);
 
  222  imageMemory = device.allocateMemory(allocInfo, 
nullptr);
 
  224  device.bindImageMemory(
image, imageMemory, 0);
 
  227static uint32_t getMaxUsableSampleCount(vk::PhysicalDeviceProperties& physicalDeviceProperties)
 
  229  vk::SampleCountFlags counts = physicalDeviceProperties.limits.framebufferColorSampleCounts & physicalDeviceProperties.limits.framebufferDepthSampleCounts;
 
  230  if (counts & vk::SampleCountFlagBits::e64) {
 
  232  } 
else if (counts & vk::SampleCountFlagBits::e32) {
 
  234  } 
else if (counts & vk::SampleCountFlagBits::e16) {
 
  236  } 
else if (counts & vk::SampleCountFlagBits::e8) {
 
  238  } 
else if (counts & vk::SampleCountFlagBits::e4) {
 
  240  } 
else if (counts & vk::SampleCountFlagBits::e2) {
 
  246static vk::SampleCountFlagBits getMSAASamplesFlag(uint32_t msaa)
 
  249    return vk::SampleCountFlagBits::e2;
 
  250  } 
else if (msaa == 4) {
 
  251    return vk::SampleCountFlagBits::e4;
 
  252  } 
else if (msaa == 8) {
 
  253    return vk::SampleCountFlagBits::e8;
 
  254  } 
else if (msaa == 16) {
 
  255    return vk::SampleCountFlagBits::e16;
 
  256  } 
else if (msaa == 32) {
 
  257    return vk::SampleCountFlagBits::e32;
 
  258  } 
else if (msaa == 64) {
 
  259    return vk::SampleCountFlagBits::e64;
 
  261  return vk::SampleCountFlagBits::e1;
 
  264template <
class T, 
class S>
 
  265static inline void clearVector(T& 
v, 
S func, 
bool downsize = 
true)
 
  267  std::for_each(
v.begin(), 
v.end(), 
func);
 
  278  vk::PhysicalDeviceProperties deviceProperties = device.getProperties();
 
  279  vk::PhysicalDeviceFeatures deviceFeatures = device.getFeatures();
 
  280  vk::PhysicalDeviceMemoryProperties memoryProperties = device.getMemoryProperties();
 
  281  if (!deviceFeatures.geometryShader || !deviceFeatures.wideLines || !deviceFeatures.largePoints) {
 
  285  std::vector<vk::QueueFamilyProperties> queueFamilies = device.getQueueFamilyProperties();
 
  287  for (uint32_t 
i = 0; 
i < queueFamilies.size(); 
i++) {
 
  288    if (!(queueFamilies[
i].queueFlags & vk::QueueFlagBits::eGraphics)) {
 
  291    vk::Bool32 presentSupport = device.getSurfaceSupportKHR(
i, 
mSurface);
 
  292    if (!presentSupport) {
 
  300    GPUInfo(
"%s ignored due to missing queue properties", &deviceProperties.deviceName[0]);
 
  304  std::vector<vk::ExtensionProperties> availableExtensions = device.enumerateDeviceExtensionProperties(
nullptr);
 
  305  uint32_t extensionsFound = 0;
 
  306  for (uint32_t 
i = 0; 
i < reqDeviceExtensions.size(); 
i++) {
 
  307    for (uint32_t 
j = 0; 
j < availableExtensions.size(); 
j++) {
 
  308      if (strcmp(reqDeviceExtensions[
i], availableExtensions[
j].extensionName) == 0) {
 
  314  if (extensionsFound < reqDeviceExtensions.size()) {
 
  315    GPUInfo(
"%s ignored due to missing extensions", &deviceProperties.deviceName[0]);
 
  321    GPUInfo(
"%s ignored due to incompatible swap chain", &deviceProperties.deviceName[0]);
 
  326  if (deviceProperties.deviceType == vk::PhysicalDeviceType::eDiscreteGpu) {
 
  328  } 
else if (deviceProperties.deviceType == vk::PhysicalDeviceType::eIntegratedGpu) {
 
  332  for (uint32_t 
i = 0; 
i < memoryProperties.memoryHeapCount; 
i++) {
 
  333    if (memoryProperties.memoryHeaps[
i].flags & vk::MemoryHeapFlagBits::eDeviceLocal) {
 
  334      score += memoryProperties.memoryHeaps[
i].size;
 
 
  343  VULKAN_HPP_DEFAULT_DISPATCHER.init(vkGetInstanceProcAddr);
 
  344  vk::ApplicationInfo appInfo{};
 
  345  appInfo.pApplicationName = 
"GPU CA Standalone display";
 
  346  appInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0);
 
  347  appInfo.pEngineName = 
"GPU CI Standalone Engine";
 
  348  appInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0);
 
  349  appInfo.apiVersion = VK_API_VERSION_1_0;
 
  351  vk::InstanceCreateInfo instanceCreateInfo;
 
  352  instanceCreateInfo.pApplicationInfo = &appInfo;
 
  354  const char** frontendExtensions;
 
  356  std::vector<const char*> reqInstanceExtensions(frontendExtensions, frontendExtensions + frontendExtensionCount);
 
  358  const std::vector<const char*> reqValidationLayers = {
"VK_LAYER_KHRONOS_validation"};
 
  359  auto debugCallback = [](vk::DebugUtilsMessageSeverityFlagBitsEXT messageSeverity, vk::DebugUtilsMessageTypeFlagsEXT messageType, 
const vk::DebugUtilsMessengerCallbackDataEXT* pCallbackData, 
void* pUserData) -> VkBool32 {
 
  360    static int32_t throwOnError = getenv(
"GPUCA_VULKAN_VALIDATION_THROW") ? atoi(getenv(
"GPUCA_VULKAN_VALIDATION_THROW")) : 0;
 
  361    static bool showVulkanValidationInfo = getenv(
"GPUCA_VULKAN_VALIDATION_INFO") && atoi(getenv(
"GPUCA_VULKAN_VALIDATION_INFO"));
 
  362    switch (messageSeverity) {
 
  363      case vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose:
 
  364        if (showVulkanValidationInfo) {
 
  365          GPUInfo(
"%s", pCallbackData->pMessage);
 
  368      case vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning:
 
  369        GPUWarning(
"%s", pCallbackData->pMessage);
 
  370        if (throwOnError > 1) {
 
  371          throw std::logic_error(
"break_on_validation_warning");
 
  374      case vk::DebugUtilsMessageSeverityFlagBitsEXT::eError:
 
  375        GPUError(
"%s", pCallbackData->pMessage);
 
  377          throw std::logic_error(
"break_on_validation_error");
 
  380      case vk::DebugUtilsMessageSeverityFlagBitsEXT::eInfo:
 
  382        GPUInfo(
"%s", pCallbackData->pMessage);
 
  387  vk::DebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
 
  389    if (checkVulkanLayersSupported(reqValidationLayers)) {
 
  390      throw std::runtime_error(
"Requested validation layer support not available");
 
  392    reqInstanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
 
  393    instanceCreateInfo.enabledLayerCount = 
static_cast<uint32_t
>(reqValidationLayers.size());
 
  394    instanceCreateInfo.ppEnabledLayerNames = reqValidationLayers.data();
 
  395    instanceCreateInfo.pNext = (VkDebugUtilsMessengerCreateInfoEXT*)&debugCreateInfo;
 
  397    debugCreateInfo.messageSeverity = vk::DebugUtilsMessageSeverityFlagBitsEXT::eVerbose | vk::DebugUtilsMessageSeverityFlagBitsEXT::eWarning | vk::DebugUtilsMessageSeverityFlagBitsEXT::eError;
 
  398    debugCreateInfo.messageType = vk::DebugUtilsMessageTypeFlagBitsEXT::eGeneral | vk::DebugUtilsMessageTypeFlagBitsEXT::eValidation | vk::DebugUtilsMessageTypeFlagBitsEXT::ePerformance;
 
  399    debugCreateInfo.pfnUserCallback = debugCallback;
 
  400    debugCreateInfo.pUserData = 
nullptr;
 
  402    instanceCreateInfo.enabledLayerCount = 0;
 
  405  instanceCreateInfo.enabledExtensionCount = 
static_cast<uint32_t
>(reqInstanceExtensions.size());
 
  406  instanceCreateInfo.ppEnabledExtensionNames = reqInstanceExtensions.data();
 
  408  mInstance = vk::createInstance(instanceCreateInfo, 
nullptr);
 
  409  VULKAN_HPP_DEFAULT_DISPATCHER.init(
mInstance);
 
  412    GPUInfo(
"Enabling Vulkan Validation Layers");
 
  415  std::vector<vk::ExtensionProperties> extensions = vk::enumerateInstanceExtensionProperties(
nullptr);
 
  417    std::cout << 
"available instance extensions: " << extensions.size() << 
"\n";
 
  418    for (
const auto& extension : extensions) {
 
  419      std::cout << 
'\t' << extension.extensionName << 
'\n';
 
  424    throw std::runtime_error(
"Frontend does not provide Vulkan surface");
 
  427  const std::vector<const char*> reqDeviceExtensions = {
 
  428    VK_KHR_SWAPCHAIN_EXTENSION_NAME};
 
  431  std::vector<vk::PhysicalDevice> devices = 
mInstance.enumeratePhysicalDevices();
 
  432  if (devices.size() == 0) {
 
  433    throw std::runtime_error(
"No Vulkan device present!");
 
  435  double bestScore = -1.;
 
  436  for (uint32_t 
i = 0; 
i < devices.size(); 
i++) {
 
  437    double score = 
checkDevice(devices[
i], reqDeviceExtensions);
 
  439      vk::PhysicalDeviceProperties deviceProperties = devices[
i].getProperties();
 
  440      GPUInfo(
"Available Vulkan device %d: %s - Score %f", 
i, &deviceProperties.deviceName[0], score);
 
  442    if (score > bestScore && score > 0) {
 
  448    if (
mDisplay->
cfg().vulkan.forceDevice < 0 || 
mDisplay->
cfg().vulkan.forceDevice >= (int32_t)devices.size()) {
 
  449      throw std::runtime_error(
"Invalid Vulkan device selected");
 
  454    throw std::runtime_error(
"All available Vulkan devices unsuited");
 
  458  vk::PhysicalDeviceProperties deviceProperties = 
mPhysicalDevice.getProperties();
 
  459  vk::PhysicalDeviceFeatures deviceFeatures = 
mPhysicalDevice.getFeatures();
 
  460  vk::FormatProperties depth32FormatProperties = 
mPhysicalDevice.getFormatProperties(vk::Format::eD32Sfloat);
 
  461  vk::FormatProperties depth64FormatProperties = 
mPhysicalDevice.getFormatProperties(vk::Format::eD32SfloatS8Uint);
 
  463  GPUInfo(
"Using physical Vulkan device %s", &deviceProperties.deviceName[0]);
 
  465  mZSupported = (bool)(depth32FormatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eDepthStencilAttachment);
 
  466  mStencilSupported = (bool)(depth64FormatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eDepthStencilAttachment);
 
  467  mCubicFilterSupported = (bool)(formatProperties.optimalTilingFeatures & vk::FormatFeatureFlagBits::eSampledImageFilterCubicEXT);
 
  473  vk::DeviceQueueCreateInfo queueCreateInfo{};
 
  475  queueCreateInfo.queueCount = 1;
 
  476  float queuePriority = 1.0f;
 
  477  queueCreateInfo.pQueuePriorities = &queuePriority;
 
  478  vk::DeviceCreateInfo deviceCreateInfo{};
 
  479  deviceCreateInfo.pQueueCreateInfos = &queueCreateInfo;
 
  480  deviceCreateInfo.queueCreateInfoCount = 1;
 
  481  deviceCreateInfo.pEnabledFeatures = &deviceFeatures;
 
  482  deviceCreateInfo.enabledExtensionCount = 
static_cast<uint32_t
>(reqDeviceExtensions.size());
 
  483  deviceCreateInfo.ppEnabledExtensionNames = reqDeviceExtensions.data();
 
  484  deviceCreateInfo.enabledLayerCount = instanceCreateInfo.enabledLayerCount;
 
  485  deviceCreateInfo.ppEnabledLayerNames = instanceCreateInfo.ppEnabledLayerNames;
 
  487  VULKAN_HPP_DEFAULT_DISPATCHER.init(
mDevice);
 
  490  vk::CommandPoolCreateInfo poolInfo{};
 
  491  poolInfo.flags = vk::CommandPoolCreateFlagBits::eResetCommandBuffer;
 
 
  510  vk::CommandBufferAllocateInfo allocInfo{};
 
  512  allocInfo.level = vk::CommandBufferLevel::ePrimary;
 
 
  535  vk::SemaphoreCreateInfo semaphoreInfo{};
 
  536  vk::FenceCreateInfo fenceInfo{};
 
  537  fenceInfo.flags = vk::FenceCreateFlagBits::eSignaled;
 
  552  fenceInfo.flags = {};
 
 
  571  for (int32_t 
j = 0; 
j < 3; 
j++) {
 
  580  std::array<vk::DescriptorPoolSize, 2> poolSizes{};
 
  581  poolSizes[0].type = vk::DescriptorType::eUniformBuffer;
 
  583  poolSizes[1].type = vk::DescriptorType::eCombinedImageSampler;
 
  585  vk::DescriptorPoolCreateInfo poolInfo{};
 
  586  poolInfo.poolSizeCount = poolSizes.
size();
 
  587  poolInfo.pPoolSizes = poolSizes.data();
 
  591  vk::DescriptorSetLayoutBinding uboLayoutBindingMat{};
 
  592  uboLayoutBindingMat.binding = 0;
 
  593  uboLayoutBindingMat.descriptorType = vk::DescriptorType::eUniformBuffer;
 
  594  uboLayoutBindingMat.descriptorCount = 1;
 
  595  uboLayoutBindingMat.stageFlags = vk::ShaderStageFlagBits::eVertex;
 
  596  vk::DescriptorSetLayoutBinding uboLayoutBindingCol = uboLayoutBindingMat;
 
  597  uboLayoutBindingCol.binding = 1;
 
  598  uboLayoutBindingCol.stageFlags = vk::ShaderStageFlagBits::eFragment;
 
  599  vk::DescriptorSetLayoutBinding samplerLayoutBinding{};
 
  600  samplerLayoutBinding.binding = 2;
 
  601  samplerLayoutBinding.descriptorCount = 1;
 
  602  samplerLayoutBinding.descriptorType = vk::DescriptorType::eCombinedImageSampler;
 
  603  samplerLayoutBinding.stageFlags = vk::ShaderStageFlagBits::eFragment;
 
  604  vk::DescriptorSetLayoutBinding bindings[3] = {uboLayoutBindingMat, uboLayoutBindingCol, samplerLayoutBinding};
 
  606  vk::DescriptorSetLayoutCreateInfo layoutInfo{};
 
  607  layoutInfo.bindingCount = 2;
 
  608  layoutInfo.pBindings = bindings;
 
  610  layoutInfo.bindingCount = 3;
 
  613  vk::DescriptorSetAllocateInfo allocInfo{};
 
  616  for (int32_t 
j = 0; 
j < 3; 
j++) { 
 
  618    allocInfo.pSetLayouts = layouts.data();
 
  621    for (int32_t k = 0; k < 2; k++) {
 
  624        vk::DescriptorBufferInfo bufferInfo{};
 
  625        bufferInfo.buffer = mUniformBuffers[
i].buffer;
 
  626        bufferInfo.offset = 0;
 
  627        bufferInfo.range = mUniformBuffers[
i].size;
 
  629        vk::WriteDescriptorSet descriptorWrite{};
 
  631        descriptorWrite.dstBinding = k;
 
  632        descriptorWrite.dstArrayElement = 0;
 
  633        descriptorWrite.descriptorType = vk::DescriptorType::eUniformBuffer;
 
  634        descriptorWrite.descriptorCount = 1;
 
  635        descriptorWrite.pBufferInfo = &bufferInfo;
 
  636        descriptorWrite.pImageInfo = 
nullptr;
 
  637        descriptorWrite.pTexelBufferView = 
nullptr;
 
  638        mDevice.updateDescriptorSets(1, &descriptorWrite, 0, 
nullptr);
 
 
  653  for (int32_t 
j = 0; 
j < 3; 
j++) {
 
 
  661  vk::DescriptorImageInfo imageInfo{};
 
  662  imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
 
  665  vk::WriteDescriptorSet descriptorWrite{};
 
  667  descriptorWrite.dstBinding = 2;
 
  668  descriptorWrite.dstArrayElement = 0;
 
  669  descriptorWrite.descriptorType = vk::DescriptorType::eCombinedImageSampler;
 
  670  descriptorWrite.descriptorCount = 1;
 
  671  descriptorWrite.pImageInfo = &imageInfo;
 
  672  mDevice.updateDescriptorSets(1, &descriptorWrite, 0, 
nullptr);
 
 
  679  vk::SamplerCreateInfo samplerInfo{};
 
  680  samplerInfo.magFilter = vk::Filter::eLinear;
 
  681  samplerInfo.minFilter = vk::Filter::eLinear;
 
  682  samplerInfo.addressModeU = vk::SamplerAddressMode::eRepeat;
 
  683  samplerInfo.addressModeV = vk::SamplerAddressMode::eRepeat;
 
  684  samplerInfo.addressModeW = vk::SamplerAddressMode::eRepeat;
 
  685  samplerInfo.compareEnable = 
false;
 
  686  samplerInfo.compareOp = vk::CompareOp::eAlways;
 
  687  samplerInfo.borderColor = vk::BorderColor::eIntOpaqueBlack;
 
  688  samplerInfo.unnormalizedCoordinates = 
false;
 
  689  samplerInfo.mipmapMode = vk::SamplerMipmapMode::eLinear;
 
  690  samplerInfo.mipLodBias = 0.0f;
 
  691  samplerInfo.minLod = 0.0f;
 
  692  samplerInfo.maxLod = 0.0f;
 
 
  724  vk::SwapchainCreateInfoKHR swapCreateInfo{};
 
  726  swapCreateInfo.minImageCount = imageCount;
 
  729  swapCreateInfo.imageExtent = extent;
 
  730  swapCreateInfo.imageArrayLayers = 1;
 
  731  swapCreateInfo.imageUsage = vk::ImageUsageFlagBits::eColorAttachment;
 
  732  swapCreateInfo.imageSharingMode = vk::SharingMode::eExclusive;
 
  733  swapCreateInfo.queueFamilyIndexCount = 0;     
 
  734  swapCreateInfo.pQueueFamilyIndices = 
nullptr; 
 
  736  swapCreateInfo.compositeAlpha = vk::CompositeAlphaFlagBitsKHR::eOpaque;
 
  738  swapCreateInfo.clipped = 
true;
 
  739  swapCreateInfo.oldSwapchain = VkSwapchainKHR(VK_NULL_HANDLE);
 
  741    swapCreateInfo.imageUsage |= vk::ImageUsageFlagBits::eTransferSrc;
 
  744    swapCreateInfo.imageUsage |= vk::ImageUsageFlagBits::eTransferDst;
 
 
  784  if (needUpdateOffscreenBuffers) {
 
  786    if (needUpdateSwapChain) {
 
 
  804  vk::AttachmentDescription colorAttachment{};
 
  807  colorAttachment.loadOp = vk::AttachmentLoadOp::eClear;
 
  808  colorAttachment.storeOp = vk::AttachmentStoreOp::eStore;
 
  809  colorAttachment.stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
 
  810  colorAttachment.stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
 
  811  colorAttachment.initialLayout = vk::ImageLayout::eUndefined;
 
  812  colorAttachment.finalLayout = (
mMSAASampleCount != vk::SampleCountFlagBits::e1 || 
mDownsampleFSAA) ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR;
 
  813  vk::AttachmentDescription depthAttachment{};
 
  814  depthAttachment.format = vk::Format::eD32Sfloat;
 
  816  depthAttachment.loadOp = vk::AttachmentLoadOp::eClear;
 
  817  depthAttachment.storeOp = vk::AttachmentStoreOp::eDontCare;
 
  818  depthAttachment.stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
 
  819  depthAttachment.stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
 
  820  depthAttachment.initialLayout = vk::ImageLayout::eUndefined;
 
  821  depthAttachment.finalLayout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
 
  822  vk::AttachmentDescription colorAttachmentResolve{};
 
  824  colorAttachmentResolve.samples = vk::SampleCountFlagBits::e1;
 
  825  colorAttachmentResolve.loadOp = vk::AttachmentLoadOp::eDontCare;
 
  826  colorAttachmentResolve.storeOp = vk::AttachmentStoreOp::eStore;
 
  827  colorAttachmentResolve.stencilLoadOp = vk::AttachmentLoadOp::eDontCare;
 
  828  colorAttachmentResolve.stencilStoreOp = vk::AttachmentStoreOp::eDontCare;
 
  829  colorAttachmentResolve.initialLayout = vk::ImageLayout::eUndefined;
 
  830  colorAttachmentResolve.finalLayout = 
mDownsampleFSAA ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR;
 
  831  int32_t nAttachments = 0;
 
  832  vk::AttachmentReference colorAttachmentRef{};
 
  833  colorAttachmentRef.attachment = nAttachments++;
 
  834  colorAttachmentRef.layout = vk::ImageLayout::eColorAttachmentOptimal;
 
  835  vk::AttachmentReference depthAttachmentRef{};
 
  837  depthAttachmentRef.layout = vk::ImageLayout::eDepthStencilAttachmentOptimal;
 
  838  vk::AttachmentReference colorAttachmentResolveRef{};
 
  840  colorAttachmentResolveRef.layout = vk::ImageLayout::eColorAttachmentOptimal;
 
  841  vk::SubpassDescription subpass{};
 
  842  subpass.pipelineBindPoint = vk::PipelineBindPoint::eGraphics;
 
  843  subpass.colorAttachmentCount = 1;
 
  844  subpass.pColorAttachments = &colorAttachmentRef;
 
  845  vk::SubpassDependency dependency{};
 
  846  dependency.srcSubpass = VK_SUBPASS_EXTERNAL;
 
  847  dependency.dstSubpass = 0;
 
  848  dependency.srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput | vk::PipelineStageFlagBits::eEarlyFragmentTests;
 
  849  dependency.srcAccessMask = {};
 
  850  dependency.dstStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput | vk::PipelineStageFlagBits::eEarlyFragmentTests;
 
  851  dependency.dstAccessMask = vk::AccessFlagBits::eColorAttachmentWrite | vk::AccessFlagBits::eDepthStencilAttachmentWrite;
 
  853  std::vector<vk::AttachmentDescription> 
attachments = {colorAttachment};
 
  856    depthAttachmentRef.attachment = nAttachments++;
 
  857    subpass.pDepthStencilAttachment = &depthAttachmentRef;
 
  861    colorAttachmentResolveRef.attachment = nAttachments++;
 
  862    subpass.pResolveAttachments = &colorAttachmentResolveRef;
 
  865  vk::RenderPassCreateInfo renderPassInfo{};
 
  866  renderPassInfo.attachmentCount = 
attachments.size();
 
  868  renderPassInfo.subpassCount = 1;
 
  869  renderPassInfo.pSubpasses = &subpass;
 
  870  renderPassInfo.dependencyCount = 1;
 
  871  renderPassInfo.pDependencies = &dependency;
 
  884    mZImages.resize(imageCountWithMixImages);
 
  899  renderPassInfo.attachmentCount = 1; 
 
  900  renderPassInfo.pAttachments = &colorAttachment;
 
  901  subpass.pDepthStencilAttachment = 
nullptr;
 
  902  subpass.pResolveAttachments = 
nullptr;
 
  904    dependency.srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput; 
 
  905    dependency.dstStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
 
  906    dependency.dstAccessMask = vk::AccessFlagBits::eColorAttachmentWrite; 
 
  908  colorAttachment.loadOp = vk::AttachmentLoadOp::eLoad;            
 
  909  colorAttachment.initialLayout = vk::ImageLayout::ePresentSrcKHR; 
 
  910  colorAttachment.samples = vk::SampleCountFlagBits::e1;           
 
  911  colorAttachment.finalLayout = vk::ImageLayout::ePresentSrcKHR;   
 
  916      colorAttachment.initialLayout = vk::ImageLayout::eColorAttachmentOptimal;
 
  917      colorAttachment.finalLayout = 
mDownsampleFSAA ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR;
 
  920      dependency.srcStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput; 
 
  921      dependency.dstStageMask = vk::PipelineStageFlagBits::eColorAttachmentOutput;
 
  922      dependency.dstAccessMask = vk::AccessFlagBits::eColorAttachmentWrite; 
 
  927  for (uint32_t 
i = 0; 
i < imageCountWithMixImages; 
i++) {
 
  934    std::vector<vk::ImageView> att;
 
  936      vk::ImageUsageFlags 
usage = vk::ImageUsageFlagBits::eColorAttachment | (
i >= 
mImageCount ? vk::ImageUsageFlagBits::eSampled : vk::ImageUsageFlagBits::eTransferSrc);
 
  944      createImageI(
mDevice, 
mPhysicalDevice, 
mMSAAImages[
i].
image, 
mMSAAImages[
i].
memory, 
mRenderWidth, 
mRenderHeight, 
mSurfaceFormat.format, vk::ImageUsageFlagBits::eColorAttachment, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal, 
mMSAASampleCount);
 
  951      createImageI(
mDevice, 
mPhysicalDevice, 
mZImages[
i].
image, 
mZImages[
i].
memory, 
mRenderWidth, 
mRenderHeight, vk::Format::eD32Sfloat, vk::ImageUsageFlagBits::eDepthStencilAttachment, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal, 
mMSAASampleCount);
 
  959    vk::FramebufferCreateInfo framebufferInfo{};
 
  961    framebufferInfo.attachmentCount = att.size();
 
  962    framebufferInfo.pAttachments = att.data();
 
  965    framebufferInfo.layers = 1;
 
  969      framebufferInfo.attachmentCount = 1;
 
  978      framebufferInfo.attachmentCount = 1;
 
  988    float vertices[6][4] = {
 
 
 1028  vk::PipelineShaderStageCreateInfo shaderStages[2] = {vk::PipelineShaderStageCreateInfo{}, vk::PipelineShaderStageCreateInfo{}};
 
 1029  vk::PipelineShaderStageCreateInfo& vertShaderStageInfo = shaderStages[0];
 
 1030  vertShaderStageInfo.stage = vk::ShaderStageFlagBits::eVertex;
 
 1032  vertShaderStageInfo.pName = 
"main";
 
 1033  vk::PipelineShaderStageCreateInfo& fragShaderStageInfo = shaderStages[1];
 
 1034  fragShaderStageInfo.stage = vk::ShaderStageFlagBits::eFragment;
 
 1036  fragShaderStageInfo.pName = 
"main";
 
 1038  vk::VertexInputBindingDescription bindingDescription{};
 
 1039  bindingDescription.binding = 0;
 
 1041  bindingDescription.inputRate = vk::VertexInputRate::eVertex;
 
 1043  vk::VertexInputAttributeDescription attributeDescriptions{};
 
 1044  attributeDescriptions.binding = 0;
 
 1045  attributeDescriptions.location = 0;
 
 1047  attributeDescriptions.offset = 0;
 
 1049  vk::PipelineVertexInputStateCreateInfo vertexInputInfo{};
 
 1050  vertexInputInfo.vertexBindingDescriptionCount = 1;
 
 1051  vertexInputInfo.pVertexBindingDescriptions = &bindingDescription;
 
 1052  vertexInputInfo.vertexAttributeDescriptionCount = 1;
 
 1053  vertexInputInfo.pVertexAttributeDescriptions = &attributeDescriptions;
 
 1054  vk::PipelineInputAssemblyStateCreateInfo inputAssembly{};
 
 1056  inputAssembly.primitiveRestartEnable = 
false;
 
 1058  vk::Viewport viewport{};
 
 1063  viewport.minDepth = 0.0f;
 
 1064  viewport.maxDepth = 1.0f;
 
 1066  vk::Rect2D scissor{};
 
 1067  scissor.offset = vk::Offset2D{0, 0};
 
 1070  vk::PipelineViewportStateCreateInfo viewportState{};
 
 1071  viewportState.viewportCount = 1;
 
 1072  viewportState.pViewports = &viewport;
 
 1073  viewportState.scissorCount = 1;
 
 1074  viewportState.pScissors = &scissor;
 
 1076  vk::PipelineRasterizationStateCreateInfo rasterizer{};
 
 1077  rasterizer.depthClampEnable = 
false;
 
 1078  rasterizer.rasterizerDiscardEnable = 
false;
 
 1079  rasterizer.polygonMode = vk::PolygonMode::eFill;
 
 1081  rasterizer.cullMode = vk::CullModeFlagBits::eBack;
 
 1082  rasterizer.frontFace = vk::FrontFace::eClockwise;
 
 1083  rasterizer.depthBiasEnable = 
false;
 
 1084  rasterizer.depthBiasConstantFactor = 0.0f; 
 
 1085  rasterizer.depthBiasClamp = 0.0f;          
 
 1086  rasterizer.depthBiasSlopeFactor = 0.0f;    
 
 1088  vk::PipelineMultisampleStateCreateInfo multisampling{};
 
 1089  multisampling.sampleShadingEnable = 
false;
 
 1091  multisampling.minSampleShading = 1.0f;       
 
 1092  multisampling.pSampleMask = 
nullptr;         
 
 1093  multisampling.alphaToCoverageEnable = 
false; 
 
 1094  multisampling.alphaToOneEnable = 
false;      
 
 1096  vk::PipelineColorBlendAttachmentState colorBlendAttachment{};
 
 1097  colorBlendAttachment.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA;
 
 1099  colorBlendAttachment.colorWriteMask = vk::ColorComponentFlagBits::eR | vk::ColorComponentFlagBits::eG | vk::ColorComponentFlagBits::eB | vk::ColorComponentFlagBits::eA;
 
 1100  colorBlendAttachment.srcColorBlendFactor = vk::BlendFactor::eSrcAlpha;
 
 1101  colorBlendAttachment.dstColorBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha;
 
 1102  colorBlendAttachment.colorBlendOp = vk::BlendOp::eAdd;
 
 1103  colorBlendAttachment.srcAlphaBlendFactor = vk::BlendFactor::eOneMinusSrcAlpha;
 
 1104  colorBlendAttachment.dstAlphaBlendFactor = vk::BlendFactor::eZero;
 
 1105  colorBlendAttachment.alphaBlendOp = vk::BlendOp::eAdd;
 
 1107  vk::PipelineColorBlendStateCreateInfo colorBlending{};
 
 1108  colorBlending.logicOpEnable = 
false;
 
 1109  colorBlending.logicOp = vk::LogicOp::eCopy;
 
 1110  colorBlending.attachmentCount = 1;
 
 1111  colorBlending.pAttachments = &colorBlendAttachment;
 
 1112  colorBlending.blendConstants[0] = 0.0f;
 
 1113  colorBlending.blendConstants[1] = 0.0f;
 
 1114  colorBlending.blendConstants[2] = 0.0f;
 
 1115  colorBlending.blendConstants[3] = 0.0f;
 
 1117  vk::PipelineDepthStencilStateCreateInfo depthStencil{};
 
 1118  depthStencil.depthTestEnable = 
true;
 
 1119  depthStencil.depthWriteEnable = 
true;
 
 1120  depthStencil.depthCompareOp = vk::CompareOp::eLess;
 
 1121  depthStencil.depthBoundsTestEnable = 
false;
 
 1122  depthStencil.stencilTestEnable = 
false;
 
 1124  vk::DynamicState dynamicStates[] = {vk::DynamicState::eLineWidth};
 
 1125  vk::PipelineDynamicStateCreateInfo dynamicState{};
 
 1126  dynamicState.dynamicStateCount = 1;
 
 1127  dynamicState.pDynamicStates = dynamicStates;
 
 1129  vk::PushConstantRange pushConstantRanges[2] = {vk::PushConstantRange{}, vk::PushConstantRange{}};
 
 1130  pushConstantRanges[0].stageFlags = vk::ShaderStageFlagBits::eFragment;
 
 1131  pushConstantRanges[0].offset = 0;
 
 1132  pushConstantRanges[0].size = 
sizeof(float) * 4;
 
 1133  pushConstantRanges[1].stageFlags = vk::ShaderStageFlagBits::eVertex;
 
 1134  pushConstantRanges[1].offset = pushConstantRanges[0].size;
 
 1135  pushConstantRanges[1].size = 
sizeof(float);
 
 1136  vk::PipelineLayoutCreateInfo pipelineLayoutInfo{};
 
 1137  pipelineLayoutInfo.setLayoutCount = 1;
 
 1139  pipelineLayoutInfo.pushConstantRangeCount = 2;
 
 1140  pipelineLayoutInfo.pPushConstantRanges = pushConstantRanges;
 
 1142  pipelineLayoutInfo.setLayoutCount = 1;
 
 1146  vk::GraphicsPipelineCreateInfo pipelineInfo{};
 
 1147  pipelineInfo.stageCount = 2;
 
 1148  pipelineInfo.pVertexInputState = &vertexInputInfo;
 
 1149  pipelineInfo.pInputAssemblyState = &inputAssembly;
 
 1150  pipelineInfo.pViewportState = &viewportState;
 
 1151  pipelineInfo.pRasterizationState = &rasterizer;
 
 1152  pipelineInfo.pMultisampleState = &multisampling;
 
 1154  pipelineInfo.pColorBlendState = &colorBlending;
 
 1155  pipelineInfo.pDynamicState = &dynamicState;
 
 1158  pipelineInfo.subpass = 0;
 
 1159  pipelineInfo.pStages = shaderStages;
 
 1160  pipelineInfo.basePipelineHandle = VkPipeline(VK_NULL_HANDLE); 
 
 1161  pipelineInfo.basePipelineIndex = -1;                          
 
 1164  static constexpr vk::PrimitiveTopology 
types[3] = {vk::PrimitiveTopology::ePointList, vk::PrimitiveTopology::eLineList, vk::PrimitiveTopology::eLineStrip};
 
 1167      bindingDescription.stride = 4 * 
sizeof(float);
 
 1168      attributeDescriptions.format = vk::Format::eR32G32B32A32Sfloat;
 
 1169      inputAssembly.topology = vk::PrimitiveTopology::eTriangleList;
 
 1170      vertShaderStageInfo.module = 
mShaders[
"vertexTexture"];
 
 1171      fragShaderStageInfo.module = 
mShaders[
"fragmentTexture"];
 
 1174      pipelineInfo.pDepthStencilState = 
nullptr;
 
 1175      colorBlendAttachment.blendEnable = 
true;
 
 1176      multisampling.rasterizationSamples = vk::SampleCountFlagBits::e1;
 
 1179    } 
else if (
i == 3) { 
 
 1180      bindingDescription.stride = 4 * 
sizeof(float);
 
 1181      attributeDescriptions.format = vk::Format::eR32G32B32A32Sfloat;
 
 1182      inputAssembly.topology = vk::PrimitiveTopology::eTriangleList;
 
 1183      vertShaderStageInfo.module = 
mShaders[
"vertexTexture"];
 
 1184      fragShaderStageInfo.module = 
mShaders[
"fragmentText"];
 
 1187      pipelineInfo.pDepthStencilState = 
nullptr;
 
 1188      colorBlendAttachment.blendEnable = 
true;
 
 1189      multisampling.rasterizationSamples = vk::SampleCountFlagBits::e1;
 
 1193      bindingDescription.stride = 3 * 
sizeof(float);
 
 1194      attributeDescriptions.format = vk::Format::eR32G32B32Sfloat;
 
 1195      inputAssembly.topology = 
types[
i];
 
 1196      vertShaderStageInfo.module = 
mShaders[
types[
i] == vk::PrimitiveTopology::ePointList ? 
"vertexPoint" : 
"vertex"];
 
 1197      fragShaderStageInfo.module = 
mShaders[
"fragment"];
 
 1200      pipelineInfo.pDepthStencilState = 
mZActive ? &depthStencil : 
nullptr;
 
 1201      colorBlendAttachment.blendEnable = 
true;
 
 1207    CHKERR(
mDevice.createGraphicsPipelines(VkPipelineCache(VK_NULL_HANDLE), 1, &pipelineInfo, 
nullptr, &
mPipelines[
i])); 
 
 
 1213  commandBuffer.reset({});
 
 1215  vk::CommandBufferBeginInfo beginInfo{};
 
 1216  beginInfo.flags = {};
 
 1217  commandBuffer.begin(beginInfo);
 
 1219  vk::ClearValue clearValues[2];
 
 1220  clearValues[0].color = 
mDisplay->
cfgL().invertColors ? vk::ClearColorValue{std::array<float, 4>{1.0f, 1.0f, 1.0f, 1.0f}} : vk::ClearColorValue{std::array<float, 4>{0.0f, 0.0f, 0.0f, 1.0f}};
 
 1221  clearValues[1].depthStencil = vk::ClearDepthStencilValue{{1.0f, 0}};
 
 1223  vk::RenderPassBeginInfo renderPassInfo{};
 
 1226  renderPassInfo.renderArea.offset = vk::Offset2D{0, 0};
 
 1228  renderPassInfo.clearValueCount = 
mZActive ? 2 : 1;
 
 1229  renderPassInfo.pClearValues = clearValues;
 
 1230  commandBuffer.beginRenderPass(&renderPassInfo, vk::SubpassContents::eInline);
 
 1232  vk::DeviceSize 
offsets[] = {0};
 
 
 1239  commandBuffer.endRenderPass();
 
 1240  commandBuffer.end();
 
 
 1252#define LOAD_SHADER(file, ext) \ 
 1253  mShaders[#file] = createShaderModule(_binary_shaders_shaders_##file##_##ext##_spv_start, _binary_shaders_shaders_##file##_##ext##_spv_len, mDevice) 
 
 1267  clearVector(
mShaders, [&](
auto& 
x) { 
mDevice.destroyShaderModule(
x.second, 
nullptr); });
 
 
 1274  if (
buffer.deviceMemory != 1) {
 
 1277    memcpy(dstData, srcData, 
size);
 
 1280    auto tmp = 
createBuffer(
size, srcData, vk::BufferUsageFlagBits::eTransferSrc, 0);
 
 1283    vk::BufferCopy copyRegion{};
 
 1284    copyRegion.size = 
size;
 
 1285    commandBuffer.copyBuffer(tmp.buffer, 
buffer.buffer, 1, ©Region);
 
 
 1294  vk::MemoryPropertyFlags properties;
 
 1296    properties |= vk::MemoryPropertyFlagBits::eDeviceLocal;
 
 1298  if (deviceMemory == 0 || deviceMemory == 2) {
 
 1299    properties |= (vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent);
 
 1301  if (deviceMemory == 1) {
 
 1302    type |= vk::BufferUsageFlagBits::eTransferDst;
 
 1306  vk::BufferCreateInfo bufferInfo{};
 
 1308  bufferInfo.usage = 
type;
 
 1309  bufferInfo.sharingMode = vk::SharingMode::eExclusive;
 
 1312  vk::MemoryRequirements memRequirements;
 
 1313  memRequirements = 
mDevice.getBufferMemoryRequirements(
buffer.buffer);
 
 1314  vk::MemoryAllocateInfo allocInfo{};
 
 1315  allocInfo.allocationSize = memRequirements.size;
 
 1316  allocInfo.memoryTypeIndex = findMemoryType(memRequirements.memoryTypeBits, properties, 
mPhysicalDevice);
 
 1322  buffer.deviceMemory = deviceMemory;
 
 1324  if (srcData != 
nullptr) {
 
 
 1359  auto tmp = 
createBuffer(srcSize, srcData, vk::BufferUsageFlagBits::eTransferSrc, 0);
 
 1362  cmdImageMemoryBarrier(commandBuffer, 
image.image, {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTopOfPipe, vk::PipelineStageFlagBits::eTransfer);
 
 1363  vk::BufferImageCopy region{};
 
 1364  region.bufferOffset = 0;
 
 1365  region.bufferRowLength = 0;
 
 1366  region.bufferImageHeight = 0;
 
 1367  region.imageSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1368  region.imageSubresource.mipLevel = 0;
 
 1369  region.imageSubresource.baseArrayLayer = 0;
 
 1370  region.imageSubresource.layerCount = 1;
 
 1371  region.imageOffset = vk::Offset3D{0, 0, 0};
 
 1372  region.imageExtent = vk::Extent3D{
image.sizex, 
image.sizey, 1};
 
 1373  commandBuffer.copyBufferToImage(tmp.buffer, 
image.image, vk::ImageLayout::eTransferDstOptimal, 1, ®ion);
 
 1374  cmdImageMemoryBarrier(commandBuffer, 
image.image, vk::AccessFlagBits::eTransferWrite, vk::AccessFlagBits::eShaderRead, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eShaderReadOnlyOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eFragmentShader);
 
 
 1383  createImageI(
mDevice, 
mPhysicalDevice, 
image.image, 
image.memory, sizex, sizey, 
format, vk::ImageUsageFlagBits::eTransferDst | vk::ImageUsageFlagBits::eSampled, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal, vk::SampleCountFlagBits::e1);
 
 1387  image.sizex = sizex;
 
 1388  image.sizey = sizey;
 
 
 1471  auto first = std::get<0>(
v);
 
 1472  auto count = std::get<1>(
v);
 
 1473  auto iSector = std::get<2>(
v);
 
 1488    for (uint32_t k = 0; k < 
count; k++) {
 
 
 1502  if (includeMixImage == 0.f) {
 
 1505    auto getImage = [&]() {
 
 1506      vk::Fence fen = VkFence(VK_NULL_HANDLE);
 
 1507      vk::Semaphore sem = VkSemaphore(VK_NULL_HANDLE);
 
 1517    vk::Result 
retVal = vk::Result::eSuccess;
 
 1520      mustUpdateRendering = 
true;
 
 1525      if (!mustUpdateRendering) {
 
 1526        GPUInfo(
"Pipeline out of data / suboptimal, recreating");
 
 1540    const hmm_mat4 modelViewProj = proj * view;
 
 
 1564  const vk::Fence noFence = VkFence(VK_NULL_HANDLE);
 
 1566  vk::SubmitInfo submitInfo{};
 
 1567  vk::PipelineStageFlags waitStages[] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
 
 1569  submitInfo.waitSemaphoreCount = submitInfo.pWaitSemaphores != 
nullptr ? 1 : 0;
 
 1570  submitInfo.pWaitDstStageMask = waitStages;
 
 1571  submitInfo.commandBufferCount = 1;
 
 1573  submitInfo.signalSemaphoreCount = 1;
 
 1574  submitInfo.pSignalSemaphores = stageFinishedSemaphore;
 
 1577    if (includeMixImage > 0.f) {
 
 1579      submitInfo.pWaitSemaphores = stageFinishedSemaphore;
 
 1580      waitStages[0] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
 
 1581      submitInfo.waitSemaphoreCount = 1;
 
 1584      submitInfo.pSignalSemaphores = stageFinishedSemaphore;
 
 1591      submitInfo.pWaitSemaphores = stageFinishedSemaphore;
 
 1592      waitStages[0] = {vk::PipelineStageFlagBits::eTransfer};
 
 1593      submitInfo.waitSemaphoreCount = 1;
 
 1595      submitInfo.pSignalSemaphores = stageFinishedSemaphore;
 
 1609      submitInfo.pWaitSemaphores = stageFinishedSemaphore;
 
 1610      waitStages[0] = {vk::PipelineStageFlagBits::eColorAttachmentOutput};
 
 1611      submitInfo.waitSemaphoreCount = 1;
 
 1614      submitInfo.pSignalSemaphores = stageFinishedSemaphore;
 
 1619    vk::PresentInfoKHR presentInfo{};
 
 1620    presentInfo.waitSemaphoreCount = 1;
 
 1621    presentInfo.pWaitSemaphores = stageFinishedSemaphore;
 
 1622    presentInfo.swapchainCount = 1;
 
 1625    presentInfo.pResults = 
nullptr;
 
 1627    if (
retVal == vk::Result::eErrorOutOfDateKHR) {
 
 
 1637  commandBuffer.reset({});
 
 1638  vk::CommandBufferBeginInfo beginInfo{};
 
 1639  beginInfo.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
 
 1640  commandBuffer.begin(beginInfo);
 
 1642  cmdImageMemoryBarrier(commandBuffer, 
mSwapChainImages[
mCurrentImageIndex], {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1643  cmdImageMemoryBarrier(commandBuffer, 
mDownsampleImages[
mCurrentImageIndex].
image, vk::AccessFlagBits::eMemoryRead, vk::AccessFlagBits::eTransferRead, vk::ImageLayout::eColorAttachmentOptimal, vk::ImageLayout::eTransferSrcOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1645  vk::Offset3D blitSizeSrc;
 
 1649  vk::Offset3D blitSizeDst;
 
 1653  vk::ImageBlit imageBlitRegion{};
 
 1654  imageBlitRegion.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1655  imageBlitRegion.srcSubresource.layerCount = 1;
 
 1656  imageBlitRegion.srcOffsets[1] = blitSizeSrc;
 
 1657  imageBlitRegion.dstSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1658  imageBlitRegion.dstSubresource.layerCount = 1;
 
 1659  imageBlitRegion.dstOffsets[1] = blitSizeDst;
 
 1662  cmdImageMemoryBarrier(commandBuffer, 
mSwapChainImages[
mCurrentImageIndex], vk::AccessFlagBits::eTransferWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::ePresentSrcKHR, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1663  cmdImageMemoryBarrier(commandBuffer, 
mDownsampleImages[
mCurrentImageIndex].
image, vk::AccessFlagBits::eTransferRead, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eUndefined, vk::ImageLayout::eColorAttachmentOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1665  commandBuffer.end();
 
 
 1685  vk::CommandBufferBeginInfo beginInfo{};
 
 1686  beginInfo.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
 
 1689  vk::RenderPassBeginInfo renderPassInfo{};
 
 1692  renderPassInfo.renderArea.offset = vk::Offset2D{0, 0};
 
 1694  renderPassInfo.clearValueCount = 0;
 
 1704  vk::DeviceSize 
offsets[] = {0};
 
 
 1723  commandBuffer.reset({});
 
 1724  vk::CommandBufferBeginInfo beginInfo{};
 
 1725  beginInfo.flags = vk::CommandBufferUsageFlagBits::eOneTimeSubmit;
 
 1726  commandBuffer.begin(beginInfo);
 
 1729  vk::ImageLayout srcLayout = 
mDownsampleFSAA ? vk::ImageLayout::eColorAttachmentOptimal : vk::ImageLayout::ePresentSrcKHR;
 
 1730  cmdImageMemoryBarrier(commandBuffer, 
image, {}, vk::AccessFlagBits::eMemoryRead, srcLayout, vk::ImageLayout::eShaderReadOnlyOptimal, vk::PipelineStageFlagBits::eAllCommands, vk::PipelineStageFlagBits::eFragmentShader);
 
 1732  vk::RenderPassBeginInfo renderPassInfo{};
 
 1735  renderPassInfo.renderArea.offset = vk::Offset2D{0, 0};
 
 1737  renderPassInfo.clearValueCount = 0;
 
 1738  commandBuffer.beginRenderPass(renderPassInfo, vk::SubpassContents::eInline);
 
 1740  commandBuffer.bindPipeline(vk::PipelineBindPoint::eGraphics, 
mPipelines[4]);
 
 1745  vk::DeviceSize 
offsets[] = {0};
 
 1748  commandBuffer.pushConstants(
mPipelineLayoutTexture, vk::ShaderStageFlagBits::eFragment, 0, 
sizeof(mixSlaveImage), &mixSlaveImage);
 
 1749  commandBuffer.draw(6, 1, 0, 0);
 
 1751  commandBuffer.endRenderPass();
 
 1752  commandBuffer.end();
 
 
 1788    throw std::runtime_error(
"Incorrect symbol ID");
 
 1792  if (sizex && sizey) {
 
 1793    buffer.reset(
new char[sizex * sizey]);
 
 
 1800  int32_t maxSizeX = 0, maxSizeY = 0, maxBigX = 0, maxBigY = 0, maxRowY = 0;
 
 1804    maxSizeX = std::max(maxSizeX, symbol.size[0]);
 
 1805    maxSizeY = std::max(maxSizeY, symbol.size[1]);
 
 1808  int32_t sizex = nn * maxSizeX;
 
 1809  int32_t sizey = nn * maxSizeY;
 
 1810  std::unique_ptr<char[]> bigImage{
new char[sizex * sizey]};
 
 1811  memset(bigImage.get(), 0, sizex * sizey);
 
 1812  int32_t rowy = 0, colx = 0;
 
 1815    if (colx + s.size[0] > sizex) {
 
 1820    for (int32_t k = 0; k < s.size[1]; k++) {
 
 1821      for (int32_t 
j = 0; 
j < s.size[0]; 
j++) {
 
 1822        int8_t 
val = s.data.get()[
j + k * s.size[0]];
 
 1824          val = 
val < 0 ? 0xFF : 0;
 
 1826        bigImage.get()[(colx + 
j) + (rowy + k) * sizex] = 
val;
 
 1831    s.x1 = colx + s.size[0];
 
 1833    s.y1 = rowy + s.size[1];
 
 1834    maxBigX = std::max(maxBigX, colx + s.size[0]);
 
 1835    maxBigY = std::max(maxBigY, rowy + s.size[1]);
 
 1836    maxRowY = std::max(maxRowY, s.size[1]);
 
 1839  if (maxBigX != sizex) {
 
 1840    for (int32_t 
y = 1; 
y < maxBigY; 
y++) {
 
 1841      memmove(bigImage.get() + 
y * maxBigX, bigImage.get() + 
y * sizex, maxBigX);
 
 
 1860  vk::DescriptorImageInfo imageInfo{};
 
 1861  imageInfo.imageLayout = vk::ImageLayout::eShaderReadOnlyOptimal;
 
 1865    vk::WriteDescriptorSet descriptorWrite{};
 
 1867    descriptorWrite.dstBinding = 2;
 
 1868    descriptorWrite.dstArrayElement = 0;
 
 1869    descriptorWrite.descriptorType = vk::DescriptorType::eCombinedImageSampler;
 
 1870    descriptorWrite.descriptorCount = 1;
 
 1871    descriptorWrite.pImageInfo = &imageInfo;
 
 1872    mDevice.updateDescriptorSets(1, &descriptorWrite, 0, 
nullptr);
 
 
 1887  for (
const char* 
c = s; *
c; 
c++) {
 
 1889      GPUError(
"Trying to draw unsupported symbol: %d > %d\n", (int32_t)*
c, (int32_t)
mFontSymbols.size());
 
 1895      float xpos = 
x + sym.
offset[0] * scale;
 
 1896      float ypos = 
y - (sym.
size[1] - sym.
offset[1]) * scale;
 
 1897      float w = sym.
size[0] * scale;
 
 1898      float h = sym.
size[1] * scale;
 
 1899      float vertices[6][4] = {
 
 1917    if (
c.size() && 
c.back().color[0] == 
color[0] && 
c.back().color[1] == 
color[1] && 
c.back().color[2] == 
color[2] && 
c.back().color[3] == 
color[3]) {
 
 1918      c.back().nVertices += nVertices;
 
 
 1929  static constexpr int32_t bytesPerPixel = 4;
 
 1932  vk::Image dstImage, dstImage2, src2;
 
 1933  vk::DeviceMemory dstImageMemory, dstImageMemory2;
 
 1934  createImageI(
mDevice, 
mPhysicalDevice, dstImage, dstImageMemory, 
width, 
height, vk::Format::eR8G8B8A8Unorm, vk::ImageUsageFlagBits::eTransferDst, vk::MemoryPropertyFlagBits::eHostVisible | vk::MemoryPropertyFlagBits::eHostCoherent, vk::ImageTiling::eLinear);
 
 1936  cmdImageMemoryBarrier(cmdBuffer, 
image, vk::AccessFlagBits::eMemoryRead, vk::AccessFlagBits::eTransferRead, layout, vk::ImageLayout::eTransferSrcOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1938    createImageI(
mDevice, 
mPhysicalDevice, dstImage2, dstImageMemory2, 
width, 
height, 
mSurfaceFormat.format, vk::ImageUsageFlagBits::eColorAttachment | vk::ImageUsageFlagBits::eTransferSrc | vk::ImageUsageFlagBits::eTransferDst, vk::MemoryPropertyFlagBits::eDeviceLocal, vk::ImageTiling::eOptimal);
 
 1939    cmdImageMemoryBarrier(cmdBuffer, dstImage2, {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1941    vk::Offset3D blitSizeDst = {(int32_t)
width, (int32_t)
height, 1};
 
 1942    vk::ImageBlit imageBlitRegion{};
 
 1943    imageBlitRegion.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1944    imageBlitRegion.srcSubresource.layerCount = 1;
 
 1945    imageBlitRegion.srcOffsets[1] = blitSizeSrc;
 
 1946    imageBlitRegion.dstSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1947    imageBlitRegion.dstSubresource.layerCount = 1;
 
 1948    imageBlitRegion.dstOffsets[1] = blitSizeDst;
 
 1949    cmdBuffer.blitImage(
image, vk::ImageLayout::eTransferSrcOptimal, dstImage2, vk::ImageLayout::eTransferDstOptimal, 1, &imageBlitRegion, vk::Filter::eLinear);
 
 1951    cmdImageMemoryBarrier(cmdBuffer, dstImage2, vk::AccessFlagBits::eMemoryRead, vk::AccessFlagBits::eTransferRead, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eTransferSrcOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1956  cmdImageMemoryBarrier(cmdBuffer, dstImage, {}, vk::AccessFlagBits::eTransferWrite, vk::ImageLayout::eUndefined, vk::ImageLayout::eTransferDstOptimal, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1957  vk::ImageCopy imageCopyRegion{};
 
 1958  imageCopyRegion.srcSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1959  imageCopyRegion.srcSubresource.layerCount = 1;
 
 1960  imageCopyRegion.dstSubresource.aspectMask = vk::ImageAspectFlagBits::eColor;
 
 1961  imageCopyRegion.dstSubresource.layerCount = 1;
 
 1962  imageCopyRegion.extent.width = 
width;
 
 1963  imageCopyRegion.extent.height = 
height;
 
 1964  imageCopyRegion.extent.depth = 1;
 
 1965  cmdBuffer.copyImage(src2, vk::ImageLayout::eTransferSrcOptimal, dstImage, vk::ImageLayout::eTransferDstOptimal, 1, &imageCopyRegion);
 
 1967  cmdImageMemoryBarrier(cmdBuffer, dstImage, vk::AccessFlagBits::eTransferWrite, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eTransferDstOptimal, vk::ImageLayout::eGeneral, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1968  cmdImageMemoryBarrier(cmdBuffer, 
image, vk::AccessFlagBits::eTransferRead, vk::AccessFlagBits::eMemoryRead, vk::ImageLayout::eTransferSrcOptimal, layout, vk::PipelineStageFlagBits::eTransfer, vk::PipelineStageFlagBits::eTransfer);
 
 1971  vk::ImageSubresource subResource{vk::ImageAspectFlagBits::eColor, 0, 0};
 
 1972  vk::SubresourceLayout subResourceLayout = 
mDevice.getImageSubresourceLayout(dstImage, subResource);
 
 1975  data += subResourceLayout.offset;
 
 1979  mDevice.unmapMemory(dstImageMemory);
 
 1980  mDevice.freeMemory(dstImageMemory, 
nullptr);
 
 1981  mDevice.destroyImage(dstImage, 
nullptr);
 
 1983    mDevice.freeMemory(dstImageMemory2, 
nullptr);
 
 1984    mDevice.destroyImage(dstImage2, 
nullptr);
 
 
#define LOAD_SHADER(file, ext)
 
HMM_INLINE hmm_mat4 HMM_Orthographic(float Left, float Right, float Bottom, float Top, float Near, float Far)
 
Class for time synchronization of RawReader instances.
 
void OpenGLPrint(const char *s, float x, float y, float *color, float scale) override
 
vk::CommandBuffer getSingleTimeCommandBuffer()
 
std::vector< vk::Fence > mInFlightFence
 
std::vector< vk::CommandBuffer > mCommandBuffersMix
 
vk::RenderPass mRenderPassTexture
 
std::vector< vk::CommandBuffer > mCommandBuffers
 
void setMixDescriptor(int32_t descriptorIndex, int32_t imageIndex)
 
std::vector< vk::Semaphore > mRenderFinishedSemaphore
 
vk::DescriptorPool mDescriptorPool
 
vk::DescriptorSetLayout mUniformDescriptor
 
VulkanBuffer mIndirectCommandBuffer
 
void prepareDraw(const hmm_mat4 &proj, const hmm_mat4 &view, bool requestScreenshot, bool toMixBuffer, float includeMixImage) override
 
std::vector< vk::Pipeline > mPipelines
 
vk::CommandBuffer mCurrentCommandBuffer
 
void createCommandBuffers()
 
void resizeScene(uint32_t width, uint32_t height) override
 
vk::Fence mSingleCommitFence
 
int32_t mCurrentCommandBufferLastPipeline
 
uint32_t DepthBits() override
 
void submitSingleTimeCommandBuffer(vk::CommandBuffer commandBuffer)
 
std::vector< VulkanImage > mDownsampleImages
 
void clearUniformLayoutsAndBuffers()
 
void writeToBuffer(VulkanBuffer &buffer, size_t size, const void *srcData)
 
std::vector< vk::ImageView > mSwapChainImageViews
 
std::vector< VulkanImage > mMSAAImages
 
void pointSizeFactor(float factor) override
 
std::vector< FontSymbolVulkan > mFontSymbols
 
vk::SwapchainKHR mSwapChain
 
int32_t InitBackendA() override
 
void clearImage(VulkanImage &image)
 
std::vector< vk::ImageView * > mRenderTargetView
 
std::vector< vk::Framebuffer > mFramebuffersTexture
 
void finishText() override
 
void addFontSymbol(int32_t symbol, int32_t sizex, int32_t sizey, int32_t offsetx, int32_t offsety, int32_t advance, void *data) override
 
bool backendNeedRedraw() override
 
vk::SampleCountFlagBits mMSAASampleCount
 
std::vector< vk::Framebuffer > mFramebuffersText
 
void mixImages(vk::CommandBuffer cmdBuffer, float mixSlaveImage)
 
void clearVertexBuffers()
 
void createTextureSampler()
 
void recreateRendering(bool forScreenshot=false, bool forMixing=false)
 
std::vector< VulkanBuffer > mFontVertexBuffer
 
void endFillCommandBuffer(vk::CommandBuffer &commandBuffer)
 
uint32_t drawVertices(const vboList &v, const drawType t) override
 
vk::SurfaceFormatKHR mSurfaceFormat
 
bool mCommandBufferPerImage
 
std::vector< vk::CommandBuffer > mCommandBuffersDownsample
 
void ActivateColor(std::array< float, 4 > &color) override
 
std::vector< vk::Image > mSwapChainImages
 
void initializeTextDrawing() override
 
void clearBuffer(VulkanBuffer &buffer)
 
VulkanBuffer mMixingTextureVertexArray
 
std::vector< vk::Semaphore > mMixFinishedSemaphore
 
vk::Sampler mTextureSampler
 
std::vector< vk::Semaphore > mTextFinishedSemaphore
 
uint32_t mCurrentImageIndex
 
void updateFontTextureDescriptor()
 
void createUniformLayoutsAndBuffers()
 
void needRecordCommandBuffers()
 
std::vector< VulkanBuffer > mUniformBuffersMat[3]
 
double checkDevice(vk::PhysicalDevice device, const std::vector< const char * > &reqDeviceExtensions)
 
bool mCommandInfrastructureCreated
 
void updateSwapChainDetails(const vk::PhysicalDevice &device)
 
std::vector< VulkanImage > mMixImages
 
vk::CommandPool mCommandPool
 
void finishDraw(bool doScreenshot, bool toMixBuffer, float includeMixImage) override
 
bool mCubicFilterSupported
 
void writeToImage(VulkanImage &image, const void *srcData, size_t srcSize)
 
vk::RenderPass mRenderPass
 
void createSemaphoresAndFences()
 
std::vector< vk::DescriptorSet > mDescriptorSets[3]
 
vecpod< float > mFontVertexBufferHost
 
vk::PipelineLayout mPipelineLayout
 
void clearOffscreenBuffers()
 
vk::DescriptorSetLayout mUniformDescriptorTexture
 
bool mSwapchainImageReadable
 
void downsampleToFramebuffer(vk::CommandBuffer &commandBuffer)
 
void ExitBackendA() override
 
vk::Extent2D chooseSwapExtent(const vk::SurfaceCapabilitiesKHR &capabilities)
 
vk::RenderPass mRenderPassText
 
void clearSemaphoresAndFences()
 
~GPUDisplayBackendVulkan() override
 
std::vector< vk::Framebuffer > mFramebuffers
 
void readImageToPixels(vk::Image image, vk::ImageLayout layout, std::vector< char > &pixels)
 
VulkanImage createImage(uint32_t sizex, uint32_t sizey, const void *srcData=nullptr, size_t srcSize=0, vk::Format format=vk::Format::eR8G8B8A8Srgb)
 
std::vector< vk::Semaphore > mDownsampleFinishedSemaphore
 
std::vector< TextDrawCommand > mTextDrawCommands
 
void clearTextureSampler()
 
vk::PipelineLayout mPipelineLayoutTexture
 
SwapChainSupportDetails mSwapChainDetails
 
uint32_t mMaxMSAAsupported
 
std::unordered_map< std::string, vk::ShaderModule > mShaders
 
void finishFrame(bool doScreenshot, bool toMixBuffer, float includeMixImage) override
 
void createSwapChain(bool forScreenshot=false, bool forMixing=false)
 
std::vector< vk::Semaphore > mImageAvailableSemaphore
 
int32_t mCurrentBufferSet
 
void startFillCommandBuffer(vk::CommandBuffer &commandBuffer, uint32_t imageIndex, bool toMixBuffer=false)
 
std::vector< vk::CommandBuffer > mCommandBuffersTexture
 
vk::PhysicalDevice mPhysicalDevice
 
vk::DebugUtilsMessengerEXT mDebugMessenger
 
GPUDisplayBackendVulkan()
 
VulkanBuffer createBuffer(size_t size, const void *srcData=nullptr, vk::BufferUsageFlags type=vk::BufferUsageFlagBits::eVertexBuffer, int32_t deviceMemory=1)
 
std::vector< VulkanImage > mZImages
 
void createOffscreenBuffers(bool forScreenshot=false, bool forMixing=false)
 
bool mEnableValidationLayers
 
std::vector< bool > mCommandBufferUpToDate
 
void lineWidthFactor(float factor) override
 
void prepareText() override
 
void clearCommandBuffers()
 
std::vector< vk::CommandBuffer > mCommandBuffersText
 
bool mMustUpdateSwapChain
 
vk::PresentModeKHR mPresentMode
 
void loadDataToGPU(size_t totalVertizes) override
 
std::vector< VulkanBuffer > mUniformBuffersCol[3]
 
vecpod< DrawArraysIndirectCommand > mCmdBuffer
 
std::vector< int32_t > mIndirectSectorOffset
 
void fillIndirectCmdBuffer()
 
bool mFreetypeInitialized
 
std::vector< char > mScreenshotPixels
 
backendTypes mBackendType
 
const char * mBackendName
 
float getDownsampleFactor(bool screenshot=false)
 
int32_t mDownsampleFactor
 
std::tuple< uint32_t, uint32_t, int32_t > vboList
 
virtual uint32_t getReqVulkanExtensions(const char **&p)
 
virtual void getSize(int32_t &width, int32_t &height)
 
virtual int32_t getVulkanSurface(void *instance, void *surface)
 
const GPUSettingsDisplayLight & cfgL() const
 
int32_t updateRenderPipeline() const
 
const GPUSettingsDisplayRenderer & cfgR() const
 
vecpod< vtx > * vertexBuffer()
 
bool drawTextInCompatMode() const
 
int32_t updateDrawCommands() const
 
GPUDisplayFrontend * frontend()
 
const vecpod< uint32_t > * vertexBufferCount() const
 
const GPUSettingsDisplay & cfg() const
 
vecpod< int32_t > * vertexBufferStart()
 
const GPUSettingsProcessing & GetProcessingSettings() const
 
GLuint GLsizei const GLuint const GLintptr * offsets
 
GLsizei GLenum GLenum * types
 
GLint GLsizei GLsizei height
 
GLint GLint GLsizei GLint GLenum GLenum type
 
GLint GLint GLsizei GLint GLenum GLenum const void * pixels
 
GLsizei const GLenum * attachments
 
GLenum GLuint GLenum GLsizei const GLchar * buf
 
GLubyte GLubyte GLubyte GLubyte w
 
GLint GLint GLsizei GLint GLenum format
 
GLsizeiptr const void GLenum usage
 
#define QGET_LD_BINARY_SYMBOLS(filename)
 
std::vector< vk::SurfaceFormatKHR > formats
 
vk::SurfaceCapabilitiesKHR capabilities
 
std::vector< vk::PresentModeKHR > presentModes