@@ -78,6 +78,9 @@ Vulkan::Vulkan(asio::io_context &ioc)
Screen . Width = 1920 / 2 ;
Screen . Height = 1080 / 2 ;
getSettingsNext ( ) = getBestSettings ( ) ;
# ifdef NDEBUG
SettingsNext . Debug = false ;
# endif
reInit ( ) ;
Game . ImGuiInterfaces . push_back ( & Vulkan : : gui_MainMenu ) ;
@@ -132,8 +135,8 @@ void Vulkan::run()
VkSemaphoreCreateInfo semaphoreCreateInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO , nullptr , 0 } ;
VkSemaphore SemaphoreImageAcquired , SemaphoreDrawComplete ;
a ssert( ! vkCreateSemaphore ( Graphics . Device , & semaphoreCreateInfo , NULL , & SemaphoreImageAcquired ) ) ;
a ssert( ! vkCreateSemaphore ( Graphics . Device , & semaphoreCreateInfo , NULL , & SemaphoreDrawComplete ) ) ;
vkA ssert( ! vkCreateSemaphore ( Graphics . Device , & semaphoreCreateInfo , NULL , & SemaphoreImageAcquired ) ) ;
vkA ssert( ! vkCreateSemaphore ( Graphics . Device , & semaphoreCreateInfo , NULL , & SemaphoreDrawComplete ) ) ;
double prevTime = glfwGetTime ( ) ;
@@ -221,7 +224,7 @@ void Vulkan::run()
. pInheritanceInfo = nullptr
} ;
a ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferRender , & cmd_buf_info ) ) ;
vkA ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferRender , & cmd_buf_info ) ) ;
}
{
@@ -452,7 +455,7 @@ void Vulkan::run()
ImGui : : SetNextWindowPos ( { 0 , 0 } ) ;
ImGui : : SetNextWindowSize ( { ( float ) Screen . Width , ( float ) Screen . Height } ) ;
a ssert( Game . ImGuiInterfaces . size ( ) ) ;
vkA ssert( Game . ImGuiInterfaces . size ( ) ) ;
( this - > * Game . ImGuiInterfaces . back ( ) ) ( ) ;
ImGui : : Render ( ) ;
@@ -480,7 +483,7 @@ void Vulkan::run()
0 , 0 , nullptr , 0 , nullptr , 1 , & prePresentBarrier ) ;
}
a ssert( ! vkEndCommandBuffer ( Graphics . CommandBufferRender ) ) ;
vkA ssert( ! vkEndCommandBuffer ( Graphics . CommandBufferRender ) ) ;
{
VkFence nullFence = VK_NULL_HANDLE ;
@@ -499,7 +502,7 @@ void Vulkan::run()
} ;
//Рисуем, когда получим картинку
a ssert( ! vkQueueSubmit ( Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
vkA ssert( ! vkQueueSubmit ( Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
}
{
@@ -523,16 +526,16 @@ void Vulkan::run()
} else if ( err = = VK_SUBOPTIMAL_KHR )
LOGGER . debug ( ) < < " VK_SUBOPTIMAL_KHR Post " ;
else
a ssert( ! err ) ;
vkA ssert( ! err ) ;
}
} else
a ssert( err = = VK_TIMEOUT ) ;
vkA ssert( err = = VK_TIMEOUT ) ;
if ( Game . Session ) {
Game . Session - > atFreeDrawTime ( gTime , dTime ) ;
}
a ssert( ! vkQueueWaitIdle ( Graphics . DeviceQueueGraphic ) ) ;
vkA ssert( ! vkQueueWaitIdle ( Graphics . DeviceQueueGraphic ) ) ;
vkDeviceWaitIdle ( Graphics . Device ) ;
Screen . State = DrawState : : End ;
@@ -646,16 +649,16 @@ static void check_vk_result(VkResult err)
void Vulkan : : buildSwapchains ( )
{
a ssert( Graphics . PhysicalDevice ) ;
a ssert( Graphics . Surface ) ;
a ssert( Graphics . Window ) ;
vkA ssert( Graphics . PhysicalDevice ) ;
vkA ssert( Graphics . Surface ) ;
vkA ssert( Graphics . Window ) ;
// Определение нового размера буфера
std : : stringstream report ;
report < < " Пересоздание цепочки вывода, текущий размер окна: " < < Screen . Width < < " x " < < Screen . Height < < ' \n ' ;
VkSurfaceCapabilitiesKHR surfaceCapabilities ;
a ssert( ! vkGetPhysicalDeviceSurfaceCapabilitiesKHR ( Graphics . PhysicalDevice , Graphics . Surface , & surfaceCapabilities ) ) ;
vkA ssert( ! vkGetPhysicalDeviceSurfaceCapabilitiesKHR ( Graphics . PhysicalDevice , Graphics . Surface , & surfaceCapabilities ) ) ;
uint32_t count = - 1 ;
VkExtent2D swapchainExtent ;
@@ -735,15 +738,15 @@ void Vulkan::buildSwapchains()
. oldSwapchain = oldSwapchain
} ;
a ssert( ! vkCreateSwapchainKHR ( Graphics . Device , & swapchainInfo , nullptr , & Graphics . Swapchain ) ) ;
vkA ssert( ! vkCreateSwapchainKHR ( Graphics . Device , & swapchainInfo , nullptr , & Graphics . Swapchain ) ) ;
if ( oldSwapchain ! = VK_NULL_HANDLE )
vkDestroySwapchainKHR ( Graphics . Device , oldSwapchain , nullptr ) ;
// Получение сменных буферов
a ssert( ! vkGetSwapchainImagesKHR ( Graphics . Device , Graphics . Swapchain , & count , nullptr ) ) ;
vkA ssert( ! vkGetSwapchainImagesKHR ( Graphics . Device , Graphics . Swapchain , & count , nullptr ) ) ;
std : : vector < VkImage > swapchainImages ( count ) ;
a ssert( ! vkGetSwapchainImagesKHR ( Graphics . Device , Graphics . Swapchain , & count , swapchainImages . data ( ) ) ) ;
vkA ssert( ! vkGetSwapchainImagesKHR ( Graphics . Device , Graphics . Swapchain , & count , swapchainImages . data ( ) ) ) ;
Graphics . DrawBuffers . resize ( count ) ;
Graphics . DrawBufferCount = count ;
@@ -779,7 +782,7 @@ void Vulkan::buildSwapchains()
} ;
Graphics . DrawBuffers [ iter ] . Image = swapchainImages [ iter ] ;
a ssert( ! vkCreateImageView ( Graphics . Device , & color_attachment_view , nullptr , & Graphics . DrawBuffers [ iter ] . View ) ) ;
vkA ssert( ! vkCreateImageView ( Graphics . Device , & color_attachment_view , nullptr , & Graphics . DrawBuffers [ iter ] . View ) ) ;
}
// Текущий рабочий буфер обнуляется
@@ -801,7 +804,7 @@ void Vulkan::buildSwapchains()
. usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT ,
} ;
a ssert( ! vkCreateImage ( Graphics . Device , & depthImage , nullptr , & Graphics . DepthImage ) ) ;
vkA ssert( ! vkCreateImage ( Graphics . Device , & depthImage , nullptr , & Graphics . DepthImage ) ) ;
// Самостоятельно выделяем память под буфер
VkMemoryRequirements memReqs ;
@@ -815,8 +818,8 @@ void Vulkan::buildSwapchains()
. memoryTypeIndex = memoryTypeFromProperties ( memReqs . memoryTypeBits , 0 )
} ;
a ssert( ! vkAllocateMemory ( Graphics . Device , & memAlloc , nullptr , & Graphics . DepthMemory ) ) ;
a ssert( ! vkBindImageMemory ( Graphics . Device , Graphics . DepthImage , Graphics . DepthMemory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Graphics . Device , & memAlloc , nullptr , & Graphics . DepthMemory ) ) ;
vkA ssert( ! vkBindImageMemory ( Graphics . Device , Graphics . DepthImage , Graphics . DepthMemory , 0 ) ) ;
// Синхронизация формата изображения
VkImageMemoryBarrier infoImageMemoryBarrier =
@@ -857,7 +860,7 @@ void Vulkan::buildSwapchains()
}
} ;
a ssert( ! vkCreateImageView ( Graphics . Device , & view , nullptr , & Graphics . DepthView ) ) ;
vkA ssert( ! vkCreateImageView ( Graphics . Device , & view , nullptr , & Graphics . DepthView ) ) ;
if ( ! Graphics . InlineTexture . Image ) {
VkImageCreateInfo imageCreateInfo = {
@@ -882,7 +885,7 @@ void Vulkan::buildSwapchains()
. initialLayout = VK_IMAGE_LAYOUT_UNDEFINED
} ;
a ssert( ! vkCreateImage ( Graphics . Device , & imageCreateInfo , nullptr , & Graphics . InlineTexture . Image ) ) ;
vkA ssert( ! vkCreateImage ( Graphics . Device , & imageCreateInfo , nullptr , & Graphics . InlineTexture . Image ) ) ;
}
if ( ! Graphics . InlineTexture . Memory ) {
@@ -899,8 +902,8 @@ void Vulkan::buildSwapchains()
. memoryTypeIndex = memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT )
} ;
a ssert( ! vkAllocateMemory ( Graphics . Device , & memoryAlloc , nullptr , & Graphics . InlineTexture . Memory ) ) ;
a ssert( ! vkBindImageMemory ( Graphics . Device , Graphics . InlineTexture . Image , Graphics . InlineTexture . Memory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Graphics . Device , & memoryAlloc , nullptr , & Graphics . InlineTexture . Memory ) ) ;
vkA ssert( ! vkBindImageMemory ( Graphics . Device , Graphics . InlineTexture . Image , Graphics . InlineTexture . Memory , 0 ) ) ;
VkImageMemoryBarrier prePresentBarrier =
{
@@ -927,8 +930,8 @@ void Vulkan::buildSwapchains()
view . subresourceRange . aspectMask = VK_IMAGE_ASPECT_COLOR_BIT ;
view . components = {
VK_COMPONENT_SWIZZLE_IDENTITY
} ,
a ssert( ! vkCreateImageView ( Graphics . Device , & view , nullptr , & Graphics . InlineTexture . View ) ) ;
} ;
vkA ssert( ! vkCreateImageView ( Graphics . Device , & view , nullptr , & Graphics . InlineTexture . View ) ) ;
}
if ( ! Graphics . InlineTexture . Frame ) {
@@ -948,7 +951,7 @@ void Vulkan::buildSwapchains()
. layers = 1
} ;
a ssert( ! vkCreateFramebuffer ( Graphics . Device , & infoFb , nullptr , & Graphics . InlineTexture . Frame ) ) ;
vkA ssert( ! vkCreateFramebuffer ( Graphics . Device , & infoFb , nullptr , & Graphics . InlineTexture . Frame ) ) ;
}
// Создаём экранные буферы глубины, связанные с одним кадровым буфером глубины
@@ -971,7 +974,7 @@ void Vulkan::buildSwapchains()
for ( uint32_t iter = 0 ; iter < Graphics . DrawBufferCount ; iter + + )
{
attachments [ 0 ] = Graphics . DrawBuffers [ iter ] . View ;
a ssert( ! vkCreateFramebuffer ( Graphics . Device , & infoFb , nullptr , & Graphics . DrawBuffers [ iter ] . FrameBuffer ) ) ;
vkA ssert( ! vkCreateFramebuffer ( Graphics . Device , & infoFb , nullptr , & Graphics . DrawBuffers [ iter ] . FrameBuffer ) ) ;
}
// Передача информации о количестве сменных буферов в ImGui
@@ -1096,13 +1099,13 @@ void Vulkan::checkLibrary()
{
uint32_t count = - 1 ;
a ssert( ! vkEnumerateInstanceLayerProperties ( & count , nullptr ) ) ;
a ssert( count ! = - 1 ) ;
vkA ssert( ! vkEnumerateInstanceLayerProperties ( & count , nullptr ) ) ;
vkA ssert( count ! = - 1 ) ;
if ( count )
{
std : : vector < VkLayerProperties > layerProperties ( count ) ;
a ssert( ! vkEnumerateInstanceLayerProperties ( & count , layerProperties . data ( ) ) ) ;
vkA ssert( ! vkEnumerateInstanceLayerProperties ( & count , layerProperties . data ( ) ) ) ;
Graphics . InstanceLayers . resize ( count ) ;
@@ -1123,13 +1126,13 @@ void Vulkan::checkLibrary()
{
uint32_t count = - 1 ;
a ssert( ! vkEnumerateInstanceExtensionProperties ( nullptr , & count , nullptr ) ) ;
a ssert( count ! = - 1 ) ;
vkA ssert( ! vkEnumerateInstanceExtensionProperties ( nullptr , & count , nullptr ) ) ;
vkA ssert( count ! = - 1 ) ;
if ( count )
{
std : : vector < VkExtensionProperties > extensionProperties ( count ) ;
a ssert( ! vkEnumerateInstanceExtensionProperties ( nullptr , & count , extensionProperties . data ( ) ) ) ;
vkA ssert( ! vkEnumerateInstanceExtensionProperties ( nullptr , & count , extensionProperties . data ( ) ) ) ;
Graphics . InstanceExtensions . resize ( count ) ;
@@ -1155,7 +1158,7 @@ void Vulkan::checkLibrary()
goto onError ;
}
a ssert( count ! = - 1 ) ;
vkA ssert( count ! = - 1 ) ;
if ( count )
{
@@ -1176,7 +1179,7 @@ void Vulkan::checkLibrary()
uint32_t count = - 1 ;
VkResult res ;
a ssert( ! vkEnumeratePhysicalDevices ( localInstance . getInstance ( ) , & count , nullptr ) ) ;
vkA ssert( ! vkEnumeratePhysicalDevices ( localInstance . getInstance ( ) , & count , nullptr ) ) ;
if ( ! count )
{
@@ -1185,7 +1188,7 @@ void Vulkan::checkLibrary()
}
devices . resize ( count ) ;
a ssert( ! vkEnumeratePhysicalDevices ( localInstance . getInstance ( ) , & count , devices . data ( ) ) ) ;
vkA ssert( ! vkEnumeratePhysicalDevices ( localInstance . getInstance ( ) , & count , devices . data ( ) ) ) ;
Graphics . Devices . resize ( count ) ;
// Перебор устройств
@@ -1471,8 +1474,8 @@ void Vulkan::initNextSettings()
" VK_LAYER_LUNARG_monitor "
} ;
//if(! SettingsNext. Debug)
// knownDebugLayers.clear();
if ( ! SettingsNext. Debug)
knownDebugLayers. clear ( ) ;
std : : vector < vkInstanceLayer > enableDebugLayers ;
@@ -1489,7 +1492,7 @@ void Vulkan::initNextSettings()
if ( ! Graphics . Surface )
{
a ssert( Graphics . Window ) ;
vkA ssert( Graphics . Window ) ;
VkResult res = glfwCreateWindowSurface ( Graphics . Instance - > getInstance ( ) , Graphics . Window , nullptr , & Graphics . Surface ) ;
if ( res )
MAKE_ERROR ( " glfwCreateWindowSurface: " < < res ) ;
@@ -1501,12 +1504,12 @@ void Vulkan::initNextSettings()
uint32_t count = - 1 ;
VkResult res ;
a ssert( ! vkEnumeratePhysicalDevices ( Graphics . Instance - > getInstance ( ) , & count , nullptr ) ) ;
vkA ssert( ! vkEnumeratePhysicalDevices ( Graphics . Instance - > getInstance ( ) , & count , nullptr ) ) ;
if ( ! count )
MAKE_ERROR ( " vkEnumeratePhysicalDevices сообщил о б отсутствии подходящего устройства " ) ;
std : : vector < VkPhysicalDevice > devices ( count ) ;
a ssert( ! vkEnumeratePhysicalDevices ( Graphics . Instance - > getInstance ( ) , & count , devices . data ( ) ) ) ;
vkA ssert( ! vkEnumeratePhysicalDevices ( Graphics . Instance - > getInstance ( ) , & count , devices . data ( ) ) ) ;
for ( size_t iter = 0 ; iter < count ; iter + + )
{
VkPhysicalDeviceProperties deviceProperties ;
@@ -1571,16 +1574,16 @@ void Vulkan::initNextSettings()
. pEnabledFeatures = nullptr
} ;
a ssert( ! vkCreateDevice ( Graphics . PhysicalDevice , & infoDevice , nullptr , & Graphics . Device ) ) ;
vkA ssert( ! vkCreateDevice ( Graphics . PhysicalDevice , & infoDevice , nullptr , & Graphics . Device ) ) ;
vkGetDeviceQueue ( Graphics . Device , SettingsNext . QueueGraphics , 0 , & Graphics . DeviceQueueGraphic ) ;
}
// Определяемся с форматом экранного буфера
uint32_t count = - 1 ;
a ssert( ! vkGetPhysicalDeviceSurfaceFormatsKHR ( Graphics . PhysicalDevice , Graphics . Surface , & count , VK_NULL_HANDLE ) ) ;
vkA ssert( ! vkGetPhysicalDeviceSurfaceFormatsKHR ( Graphics . PhysicalDevice , Graphics . Surface , & count , VK_NULL_HANDLE ) ) ;
std : : vector < VkSurfaceFormatKHR > surfFormats ( count ) ;
a ssert( ! vkGetPhysicalDeviceSurfaceFormatsKHR ( Graphics . PhysicalDevice , Graphics . Surface , & count , surfFormats . data ( ) ) ) ;
a ssert( surfFormats . size ( ) ) ;
vkA ssert( ! vkGetPhysicalDeviceSurfaceFormatsKHR ( Graphics . PhysicalDevice , Graphics . Surface , & count , surfFormats . data ( ) ) ) ;
vkA ssert( surfFormats . size ( ) ) ;
if ( count = = 1 & & surfFormats [ 0 ] . format = = VK_FORMAT_UNDEFINED ) {
Graphics . SurfaceFormat = VK_FORMAT_R32G32B32_UINT ;
@@ -1589,7 +1592,7 @@ void Vulkan::initNextSettings()
LOGGER . debug ( ) < < " Формат экранного буфера не определён устройством, используется: VK_FORMAT_B8G8R8A8_UNORM & VK_COLOR_SPACE_SRGB_NONLINEAR_KHR " ;
} else {
a ssert( count > = 1 & & " Отсутствуют подходящие форматы экранного буфера vkGetPhysicalDeviceSurfaceFormatsKHR " ) ;
vkA ssert( count > = 1 & & " Отсутствуют подходящие форматы экранного буфера vkGetPhysicalDeviceSurfaceFormatsKHR " ) ;
bool find = false ;
for ( size_t iter = 0 ; iter < count ; iter + + )
@@ -1626,7 +1629,7 @@ void Vulkan::initNextSettings()
. queueFamilyIndex = SettingsNext . QueueGraphics
} ;
a ssert( ! vkCreateCommandPool ( Graphics . Device , & infoCmdPool , nullptr , & Graphics . Pool ) ) ;
vkA ssert( ! vkCreateCommandPool ( Graphics . Device , & infoCmdPool , nullptr , & Graphics . Pool ) ) ;
}
// Создание буферов команд (подготовка данных CommandBufferData, рендер CommandBufferRender)
@@ -1642,7 +1645,7 @@ void Vulkan::initNextSettings()
if ( ! Graphics . CommandBufferData )
{
a ssert( ! vkAllocateCommandBuffers ( Graphics . Device , & infoCmd , & Graphics . CommandBufferData ) ) ;
vkA ssert( ! vkAllocateCommandBuffers ( Graphics . Device , & infoCmd , & Graphics . CommandBufferData ) ) ;
// Старт очереди команд
VkCommandBufferBeginInfo infoCmdBuffer =
@@ -1653,11 +1656,11 @@ void Vulkan::initNextSettings()
. pInheritanceInfo = nullptr
} ;
a ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferData , & infoCmdBuffer ) ) ;
vkA ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferData , & infoCmdBuffer ) ) ;
}
if ( ! Graphics . CommandBufferRender )
a ssert( ! vkAllocateCommandBuffers ( Graphics . Device , & infoCmd , & Graphics . CommandBufferRender ) ) ;
vkA ssert( ! vkAllocateCommandBuffers ( Graphics . Device , & infoCmd , & Graphics . CommandBufferRender ) ) ;
}
// Создание RenderPass для экранного буфера
@@ -1755,7 +1758,7 @@ void Vulkan::initNextSettings()
. pDependencies = nullptr
} ;
a ssert( ! vkCreateRenderPass ( Graphics . Device , & rp_info , nullptr , & Graphics . RenderPass ) ) ;
vkA ssert( ! vkCreateRenderPass ( Graphics . Device , & rp_info , nullptr , & Graphics . RenderPass ) ) ;
}
// Цепочки рендера
@@ -1787,7 +1790,7 @@ void Vulkan::initNextSettings()
descriptor_pool . poolSizeCount = ( uint32_t ) IM_ARRAYSIZE ( pool_sizes ) ;
descriptor_pool . pPoolSizes = pool_sizes ;
a ssert( ! vkCreateDescriptorPool ( Graphics . Device , & descriptor_pool , nullptr , & Graphics . ImGuiDescPool ) ) ;
vkA ssert( ! vkCreateDescriptorPool ( Graphics . Device , & descriptor_pool , nullptr , & Graphics . ImGuiDescPool ) ) ;
ImGui : : CreateContext ( ) ;
@@ -1931,7 +1934,7 @@ void Vulkan::deInitVulkan()
void Vulkan : : flushCommandBufferData ( )
{
a ssert( ! vkEndCommandBuffer ( Graphics . CommandBufferData ) ) ;
vkA ssert( ! vkEndCommandBuffer ( Graphics . CommandBufferData ) ) ;
const VkCommandBuffer cmd_bufs [ ] = { Graphics . CommandBufferData } ;
VkFence nullFence = { VK_NULL_HANDLE } ;
@@ -1948,8 +1951,8 @@ void Vulkan::flushCommandBufferData()
. pSignalSemaphores = nullptr
} ;
a ssert( ! vkQueueSubmit ( Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
a ssert( ! vkQueueWaitIdle ( Graphics . DeviceQueueGraphic ) ) ;
vkA ssert( ! vkQueueSubmit ( Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
vkA ssert( ! vkQueueWaitIdle ( Graphics . DeviceQueueGraphic ) ) ;
VkCommandBufferBeginInfo infoCmdBuffer =
{
@@ -1959,7 +1962,7 @@ void Vulkan::flushCommandBufferData()
. pInheritanceInfo = nullptr
} ;
a ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferData , & infoCmdBuffer ) ) ;
vkA ssert( ! vkBeginCommandBuffer ( Graphics . CommandBufferData , & infoCmdBuffer ) ) ;
}
Settings Vulkan : : getBestSettings ( )
@@ -1982,8 +1985,8 @@ bool Vulkan::needFullVulkanRebuild()
std : : shared_ptr < ShaderModule > Vulkan : : createShader ( std : : string_view data )
{
a ssert( Graphics . Device ) ;
a ssert( data . size ( ) ) ;
vkA ssert( Graphics . Device ) ;
vkA ssert( data . size ( ) ) ;
std : : shared_ptr < ShaderModule > module = std : : make_shared < ShaderModule > ( data ) ;
std : : dynamic_pointer_cast < IVulkanDependent > ( module ) - > init ( this ) ;
ROS_Dependents . insert ( module ) ;
@@ -1992,7 +1995,7 @@ std::shared_ptr<ShaderModule> Vulkan::createShader(std::string_view data)
void Vulkan : : registerDependent ( std : : shared_ptr < IVulkanDependent > dependent )
{
a ssert( Graphics . Device ) ;
vkA ssert( Graphics . Device ) ;
dependent - > init ( this ) ;
ROS_Dependents . insert ( dependent ) ;
}
@@ -2151,8 +2154,8 @@ void Vulkan::updateResources()
Vulkan : : vkInstance : : vkInstance ( Vulkan * handler , std : : vector < vkInstanceLayer > layers , std : : vector < vkInstanceExtension > extensions )
: Handler ( handler )
{
a ssert( handler ) ;
//TOS_ASSERT (getShared(), "Должен быть Shared");
vkA ssert( handler ) ;
//TOS_vkAssert (getShared(), "Должен быть Shared");
size_t glfwExtensions = handler - > Graphics . GLFWExtensions . size ( ) ;
std : : vector < const char * > rawLayers ( layers . size ( ) ) , rawExtensions ( extensions . size ( ) + glfwExtensions ) ;
@@ -2276,7 +2279,7 @@ void DescriptorLayout::init(Vulkan *instance)
. pBindings = ShaderLayoutBindings . data ( )
} ;
a ssert( ! vkCreateDescriptorSetLayout ( instance - > Graphics . Device , & descriptor_layout , nullptr , & DescLayout ) ) ;
vkA ssert( ! vkCreateDescriptorSetLayout ( instance - > Graphics . Device , & descriptor_layout , nullptr , & DescLayout ) ) ;
}
if ( ! Layout )
@@ -2293,7 +2296,7 @@ void DescriptorLayout::init(Vulkan *instance)
. pPushConstantRanges = ShaderPushConstants . data ( )
} ;
a ssert( ! vkCreatePipelineLayout ( instance - > Graphics . Device , & pPipelineLayoutCreateInfo , nullptr , & Layout ) ) ;
vkA ssert( ! vkCreatePipelineLayout ( instance - > Graphics . Device , & pPipelineLayoutCreateInfo , nullptr , & Layout ) ) ;
}
}
@@ -2320,7 +2323,7 @@ void DescriptorLayout::free(Vulkan *instance)
Pipeline : : Pipeline ( std : : shared_ptr < DescriptorLayout > layout )
{
a ssert( layout ) ;
vkA ssert( layout ) ;
Settings . ShaderLayoutBindings = layout ;
// Информация о буферах и размере вершины
@@ -2458,8 +2461,8 @@ void Pipeline::free(Vulkan *instance)
void Pipeline : : init ( Vulkan * instance )
{
a ssert( instance ) ;
a ssert( Settings . ShaderLayoutBindings & & Settings . ShaderLayoutBindings - > DescLayout ) ;
vkA ssert( instance ) ;
vkA ssert( Settings . ShaderLayoutBindings & & Settings . ShaderLayoutBindings - > DescLayout ) ;
// Топология вершин на входе (треугольники, линии, точки)
VkPipelineInputAssemblyStateCreateInfo ia =
@@ -2520,7 +2523,7 @@ void Pipeline::init(Vulkan *instance)
} ;
for ( auto & obj : Settings . ShaderStages )
a ssert( obj . module & & " Шейдер не назначен " ) ;
vkA ssert( obj . module & & " Шейдер не назначен " ) ;
VkGraphicsPipelineCreateInfo pipeline =
{
@@ -2549,7 +2552,7 @@ void Pipeline::init(Vulkan *instance)
memset ( & infoPipelineCache , 0 , sizeof ( infoPipelineCache ) ) ;
infoPipelineCache . sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO ;
a ssert( ! vkCreateGraphicsPipelines ( instance - > Graphics . Device , VK_NULL_HANDLE , 1 , & pipeline , nullptr , & PipelineObj ) ) ;
vkA ssert( ! vkCreateGraphicsPipelines ( instance - > Graphics . Device , VK_NULL_HANDLE , 1 , & pipeline , nullptr , & PipelineObj ) ) ;
}
@@ -2591,8 +2594,8 @@ ShaderModule::~ShaderModule() = default;
Buffer : : Buffer ( Vulkan * instance , VkDeviceSize bufferSize , VkBufferUsageFlags usage , VkMemoryPropertyFlags flags )
: Instance ( instance )
{
a ssert( instance ) ;
a ssert( instance - > Graphics . Device ) ;
vkA ssert( instance ) ;
vkA ssert( instance - > Graphics . Device ) ;
const VkBufferCreateInfo buf_info =
{
@@ -2683,8 +2686,8 @@ void Buffer::unMapMemory() const
CommandBuffer : : CommandBuffer ( Vulkan * instance )
: Instance ( instance )
{
a ssert( instance ) ;
a ssert( instance - > Graphics . Device ) ;
vkA ssert( instance ) ;
vkA ssert( instance - > Graphics . Device ) ;
if ( ! instance - > isRenderThread ( ) )
{
@@ -2697,10 +2700,10 @@ CommandBuffer::CommandBuffer(Vulkan *instance)
. queueFamilyIndex = instance - > getSettings ( ) . QueueGraphics
} ;
a ssert( ! vkCreateCommandPool ( instance - > Graphics . Device , & infoCmdPool , nullptr , & OffthreadPool ) ) ;
vkA ssert( ! vkCreateCommandPool ( instance - > Graphics . Device , & infoCmdPool , nullptr , & OffthreadPool ) ) ;
}
a ssert( instance - > Graphics . Pool ) ;
vkA ssert( instance - > Graphics . Pool ) ;
const VkCommandBufferAllocateInfo infoCmd =
{
. sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO ,
@@ -2710,7 +2713,7 @@ CommandBuffer::CommandBuffer(Vulkan *instance)
. commandBufferCount = 1
} ;
a ssert( ! vkAllocateCommandBuffers ( instance - > Graphics . Device , & infoCmd , & Buffer ) ) ;
vkA ssert( ! vkAllocateCommandBuffers ( instance - > Graphics . Device , & infoCmd , & Buffer ) ) ;
VkCommandBufferBeginInfo infoCmdBuffer =
{
@@ -2720,7 +2723,7 @@ CommandBuffer::CommandBuffer(Vulkan *instance)
. pInheritanceInfo = nullptr
} ;
a ssert( ! vkBeginCommandBuffer ( Buffer , & infoCmdBuffer ) ) ;
vkA ssert( ! vkBeginCommandBuffer ( Buffer , & infoCmdBuffer ) ) ;
}
CommandBuffer : : ~ CommandBuffer ( )
@@ -2729,7 +2732,8 @@ CommandBuffer::~CommandBuffer()
{
if ( Instance - > Graphics . DeviceQueueGraphic )
{
assert ( ! vkEndCommandBuffer( Buffer) ) ;
//vkAssert(! vkEndCommandBuffer( Buffer));
vkEndCommandBuffer ( Buffer ) ;
const VkCommandBuffer cmd_bufs [ ] = { Buffer } ;
VkFence nullFence = { VK_NULL_HANDLE } ;
VkSubmitInfo submit_info =
@@ -2745,8 +2749,10 @@ CommandBuffer::~CommandBuffer()
. pSignalSemaphores = nullptr
} ;
assert ( ! vkQueueSubmit( Instance- > Graphics. DeviceQueueGraphic, 1 , & submit_info, nullFence) ) ;
assert ( ! vkQueueWaitIdle ( Instance - > Graphics . DeviceQueueGraphic ) ) ;
//vkAssert(! vkQueueSubmit( Instance-> Graphics. DeviceQueueGraphic, 1, & submit_info, nullFence));
vkQueueSubmit ( Instance - > Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ;
//vkAssert(!vkQueueWaitIdle(Instance->Graphics.DeviceQueueGraphic));
vkQueueWaitIdle ( Instance - > Graphics . DeviceQueueGraphic ) ;
auto toExecute = std : : move ( AfterExecute ) ;
for ( auto & iter : toExecute )
@@ -2762,8 +2768,8 @@ CommandBuffer::~CommandBuffer()
void CommandBuffer : : execute ( )
{
a ssert( Instance - > Graphics . DeviceQueueGraphic ) ;
a ssert( ! vkEndCommandBuffer ( Buffer ) ) ;
vkA ssert( Instance - > Graphics . DeviceQueueGraphic ) ;
vkA ssert( ! vkEndCommandBuffer ( Buffer ) ) ;
const VkCommandBuffer cmd_bufs [ ] = { Buffer } ;
VkFence nullFence = { VK_NULL_HANDLE } ;
@@ -2780,8 +2786,8 @@ void CommandBuffer::execute()
. pSignalSemaphores = nullptr
} ;
a ssert( ! vkQueueSubmit ( Instance - > Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
a ssert( ! vkQueueWaitIdle ( Instance - > Graphics . DeviceQueueGraphic ) ) ;
vkA ssert( ! vkQueueSubmit ( Instance - > Graphics . DeviceQueueGraphic , 1 , & submit_info , nullFence ) ) ;
vkA ssert( ! vkQueueWaitIdle ( Instance - > Graphics . DeviceQueueGraphic ) ) ;
VkCommandBufferBeginInfo infoCmdBuffer =
{
. sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO ,
@@ -2790,7 +2796,7 @@ void CommandBuffer::execute()
. pInheritanceInfo = nullptr
} ;
a ssert( ! vkBeginCommandBuffer ( Buffer , & infoCmdBuffer ) ) ;
vkA ssert( ! vkBeginCommandBuffer ( Buffer , & infoCmdBuffer ) ) ;
auto toExecute = std : : move ( AfterExecute ) ;
for ( auto & iter : toExecute )
@@ -2871,21 +2877,21 @@ void SimpleImage::postInit(const ByteBuffer &pixels, size_t width, size_t height
infoImageCreate . tiling = VK_IMAGE_TILING_LINEAR ;
infoImageCreate . usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT ;
infoImageCreate . initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED ;
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , tempImage , & memoryReqs ) ;
memoryAlloc . allocationSize = memoryReqs . size ;
memoryAlloc . memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT ) ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
// Заполняем данными
VkSubresourceLayout layout ;
vkGetImageSubresourceLayout ( Instance - > Graphics . Device , tempImage , & memorySubres , & layout ) ;
void * data ;
a ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
vkA ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
for ( size_t y = 0 ; y < Height ; y + + ) {
uint32_t * row = ( uint32_t * ) ( ( ( uint8_t * ) data ) + layout . rowPitch * y ) ;
@@ -2915,19 +2921,19 @@ void SimpleImage::postInit(const ByteBuffer &pixels, size_t width, size_t height
infoImageCreate . tiling = VK_IMAGE_TILING_LINEAR ;
else
/* Can't support VK_FORMAT_B8G8R8A8_UNORM */
a ssert( ! " No support for B8G8R8A8_UNORM as texture image format " ) ;
vkA ssert( ! " No support for B8G8R8A8_UNORM as texture image format " ) ;
/* Создаём конечную картинку */
infoImageCreate . usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT ;
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , Image , & memoryReqs ) ;
memoryAlloc . allocationSize = memoryReqs . size ;
memoryAlloc . memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT ) ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
// Задаём нужный layout
infoImageMemoryBarrier . srcAccessMask = VK_ACCESS_NONE ;
@@ -2987,7 +2993,7 @@ void SimpleImage::postInit(const ByteBuffer &pixels, size_t width, size_t height
. unnormalizedCoordinates = VK_FALSE
} ;
a ssert( ! vkCreateSampler ( Instance - > Graphics . Device , & ciSampler , nullptr , & Sampler ) ) ;
vkA ssert( ! vkCreateSampler ( Instance - > Graphics . Device , & ciSampler , nullptr , & Sampler ) ) ;
}
{
@@ -3010,7 +3016,7 @@ void SimpleImage::postInit(const ByteBuffer &pixels, size_t width, size_t height
. subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT , 0 , 1 , 0 , 1 }
} ;
a ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
vkA ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
}
}
@@ -3057,7 +3063,7 @@ SimpleImage::~SimpleImage()
DynamicImage : : DynamicImage ( Vulkan * instance , uint32_t width , uint32_t height , const uint32_t * rgba )
: Instance ( instance )
{
a ssert( instance ) ;
vkA ssert( instance ) ;
ImageLayout = VK_IMAGE_LAYOUT_GENERAL ; // Т о как будем использовать графический буфер, в данном случае как текстура
@@ -3086,7 +3092,7 @@ DynamicImage::DynamicImage(Vulkan *instance, uint32_t width, uint32_t height, co
} ;
changeSampler ( & ciSampler ) ;
//TOS_ASSERT (!vkCreateSampler(Instance->Graphics.Device, sampler, nullptr, &Sampler), "vkCreateSampler");
//TOS_vkAssert (!vkCreateSampler(Instance->Graphics.Device, sampler, nullptr, &Sampler), "vkCreateSampler");
// При создании картинки вне потока графики, нужно дождаться, когда картинка будет создана
if ( ! Instance - > isRenderThread ( ) & & Instance - > isAlive ( ) )
@@ -3156,7 +3162,7 @@ void DynamicImage::changeSampler(const VkSamplerCreateInfo *sampler)
std : : shared_ptr < DynamicImage > obj = shared_from_this ( ) ;
if ( ! IsFirstCreate )
a ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
vkA ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
Instance - > beforeDraw ( [ obj , info = * sampler ] ( Vulkan * instance )
{
@@ -3167,7 +3173,7 @@ void DynamicImage::changeSampler(const VkSamplerCreateInfo *sampler)
}
auto oldSampler = Sampler ;
a ssert( ! vkCreateSampler ( Instance - > Graphics . Device , sampler , nullptr , & Sampler ) ) ;
vkA ssert( ! vkCreateSampler ( Instance - > Graphics . Device , sampler , nullptr , & Sampler ) ) ;
// Обновляем дескрипторы
for ( size_t iter = 0 ; iter < AfterRecreate . size ( ) ; iter + + )
@@ -3191,7 +3197,7 @@ void DynamicImage::recreateImage(uint16_t width, uint16_t height, const uint32_t
std : : shared_ptr < DynamicImage > obj = shared_from_this ( ) ;
if ( ! IsFirstCreate )
a ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
vkA ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
ByteBuffer buff ( size_t ( width ) * size_t ( height ) * 4 ) ;
if ( rgba )
@@ -3253,9 +3259,9 @@ void DynamicImage::recreateImage(uint16_t width, uint16_t height, const uint32_t
infoImageCreate . tiling = VK_IMAGE_TILING_LINEAR ;
else
/* Can't support VK_FORMAT_B8G8R8A8_UNORM */
a ssert( ! " No support for B8G8R8A8_UNORM as texture image format " ) ;
vkA ssert( ! " No support for B8G8R8A8_UNORM as texture image format " ) ;
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
// Выделяем память
VkMemoryRequirements memoryReqs ;
@@ -3271,8 +3277,8 @@ void DynamicImage::recreateImage(uint16_t width, uint16_t height, const uint32_t
. memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT )
} ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
// Порядок пикселей и привязка к картинке
VkImageViewCreateInfo ciView =
@@ -3293,7 +3299,7 @@ void DynamicImage::recreateImage(uint16_t width, uint16_t height, const uint32_t
. subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT , 0 , 1 , 0 , 1 }
} ;
a ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
vkA ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
// Обновляем дескрипторы
for ( size_t iter = 0 ; iter < AfterRecreate . size ( ) ; iter + + )
@@ -3325,7 +3331,7 @@ void DynamicImage::changeData(const uint32_t *rgba)
void DynamicImage : : changeData ( int32_t x , int32_t y , uint16_t width , uint16_t height , const uint32_t * rgba )
{
a ssert( width < = Width & & height < = Height & & " Превышен размер обновляемых данных width <= Width && height <= Height " ) ;
vkA ssert( width < = Width & & height < = Height & & " Превышен размер обновляемых данных width <= Width && height <= Height " ) ;
if ( IsFirstCreate )
{
@@ -3355,7 +3361,7 @@ void DynamicImage::changeData(int32_t x, int32_t y, uint16_t width, uint16_t hei
{
// Нельзя обновить картинку сейчас
std : : shared_ptr < DynamicImage > obj = shared_from_this ( ) ;
a ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
vkA ssert( obj & & " Чтобы изменять картинку во время рендера сцены, она должна быть Shared " ) ;
ByteBuffer buff ( size_t ( width ) * size_t ( height ) * 4 , ( const uint8_t * ) rgba ) ;
@@ -3410,7 +3416,7 @@ void DynamicImage::changeData(int32_t x, int32_t y, uint16_t width, uint16_t hei
} ;
VkMemoryRequirements memoryReqs ;
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , tempImage , & memoryReqs ) ;
VkMemoryAllocateInfo memoryAlloc =
@@ -3421,15 +3427,15 @@ void DynamicImage::changeData(int32_t x, int32_t y, uint16_t width, uint16_t hei
. memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT )
} ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
// Заполняем данными
VkSubresourceLayout layout ;
vkGetImageSubresourceLayout ( Instance - > Graphics . Device , tempImage , & memorySubres , & layout ) ;
void * data ;
a ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
vkA ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
if ( rgba )
{
@@ -3542,7 +3548,7 @@ void DynamicImage::readData(int32_t x, int32_t y, uint16_t width, uint16_t heigh
} ;
VkMemoryRequirements memoryReqs ;
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , tempImage , & memoryReqs ) ;
VkMemoryAllocateInfo memoryAlloc =
@@ -3553,8 +3559,8 @@ void DynamicImage::readData(int32_t x, int32_t y, uint16_t width, uint16_t heigh
. memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT )
} ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
// Подготавливаем изображение к приёму данных
infoImageMemoryBarrier . srcAccessMask = VK_ACCESS_NONE ;
@@ -3600,7 +3606,7 @@ void DynamicImage::readData(int32_t x, int32_t y, uint16_t width, uint16_t heigh
vkGetImageSubresourceLayout ( Instance - > Graphics . Device , tempImage , & memorySubres , & layout ) ;
void * data ;
a ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
vkA ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryAlloc . allocationSize , 0 , & data ) ) ;
for ( size_t y = 0 ; y < height ; y + + )
{
@@ -3865,7 +3871,7 @@ void AtlasImage::atlasAddCallbackOnUniformChange(std::function<bool()> &&callbac
void AtlasImage : : atlasUpdateDynamicData ( )
{
a ssert( Instance - > isRenderThread ( ) & & " Обновление должно вызываться в потоке рендера " ) ;
vkA ssert( Instance - > isRenderThread ( ) & & " Обновление должно вызываться в потоке рендера " ) ;
std : : lock_guard lock ( Changes ) ;
@@ -4039,7 +4045,7 @@ void AtlasImage::atlasUpdateDynamicData()
// for(auto &iter : SubTextures)
// {
// TOS_ASSERT (iter.first < count, "Ключи таблицы отсортированы не верно");
// TOS_vkAssert (iter.first < count, "Ключи таблицы отсортированы не верно");
// subs[iter.first] = iter.second;
// subs[iter.first].isExist = 1;
@@ -4187,15 +4193,15 @@ ArrayImage::ArrayImage(Vulkan *instance, std::filesystem::path directory)
infoImageCreate . tiling = VK_IMAGE_TILING_LINEAR ;
infoImageCreate . usage = VK_IMAGE_USAGE_TRANSFER_SRC_BIT ;
infoImageCreate . initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED ;
infoImageCreate . arrayLayers = 1 ,
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
infoImageCreate . arrayLayers = 1 ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & tempImage ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , tempImage , & memoryReqsTemp ) ;
memoryAlloc . allocationSize = memoryReqsTemp . size ;
memoryAlloc . memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqsTemp . memoryTypeBits , VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT ) ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & tempMemory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , tempImage , tempMemory , 0 ) ) ;
// Создаём конечную картинку
if ( props . optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT )
@@ -4205,15 +4211,15 @@ ArrayImage::ArrayImage(Vulkan *instance, std::filesystem::path directory)
infoImageCreate . usage = VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT ;
infoImageCreate . initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED ;
infoImageCreate . arrayLayers = uint32_t ( images . size ( ) ) ,
a ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
infoImageCreate . arrayLayers = uint32_t ( images . size ( ) ) ;
vkA ssert( ! vkCreateImage ( Instance - > Graphics . Device , & infoImageCreate , nullptr , & Image ) ) ;
vkGetImageMemoryRequirements ( Instance - > Graphics . Device , Image , & memoryReqs ) ;
memoryAlloc . allocationSize = memoryReqs . size ;
memoryAlloc . memoryTypeIndex = Instance - > memoryTypeFromProperties ( memoryReqs . memoryTypeBits , VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT ) ;
a ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
a ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
vkA ssert( ! vkAllocateMemory ( Instance - > Graphics . Device , & memoryAlloc , nullptr , & Memory ) ) ;
vkA ssert( ! vkBindImageMemory ( Instance - > Graphics . Device , Image , Memory , 0 ) ) ;
// Задаём нужный layout
infoImageMemoryBarrier . srcAccessMask = VK_ACCESS_NONE ;
@@ -4234,7 +4240,7 @@ ArrayImage::ArrayImage(Vulkan *instance, std::filesystem::path directory)
{
// Загружаем по одной картинке
void * data ;
a ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryReqsTemp . size , 0 , & data ) ) ;
vkA ssert( ! vkMapMemory ( Instance - > Graphics . Device , tempMemory , 0 , memoryReqsTemp . size , 0 , & data ) ) ;
for ( int32_t y = 0 ; y < Width ; y + + )
{
@@ -4331,7 +4337,7 @@ ArrayImage::ArrayImage(Vulkan *instance, std::filesystem::path directory)
. unnormalizedCoordinates = VK_FALSE
} ;
a ssert( ! vkCreateSampler ( Instance - > Graphics . Device , & ciSampler , nullptr , & Sampler ) ) ;
vkA ssert( ! vkCreateSampler ( Instance - > Graphics . Device , & ciSampler , nullptr , & Sampler ) ) ;
}
{
@@ -4354,7 +4360,7 @@ ArrayImage::ArrayImage(Vulkan *instance, std::filesystem::path directory)
. subresourceRange = { VK_IMAGE_ASPECT_COLOR_BIT , 0 , 1 , 0 , uint32_t ( images . size ( ) ) }
} ;
a ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
vkA ssert( ! vkCreateImageView ( Instance - > Graphics . Device , & ciView , nullptr , & View ) ) ;
}
}