diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 7d483f11ad..2cb47926f0 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -1,12 +1,12 @@ #define __STDC_LIMIT_MACROS #include #include -#include #include #include #include "base/basictypes.h" #include "base/display.h" +#include "Common/Log.h" #include "Common/Vulkan/VulkanContext.h" #include "Common/Vulkan/VulkanDebug.h" #include "GPU/Common/ShaderCommon.h" @@ -139,9 +139,9 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { } instance_extensions_enabled_.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME); extensionsLookup_.EXT_debug_utils = true; - ILOG("Vulkan debug_utils validation enabled."); + INFO_LOG(G3D, "Vulkan debug_utils validation enabled."); } else { - ELOG("Validation layer extension not available - not enabling Vulkan validation."); + ERROR_LOG(G3D, "Validation layer extension not available - not enabling Vulkan validation."); flags_ &= ~VULKAN_FLAG_VALIDATE; } } @@ -154,7 +154,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { // Validate that all the instance extensions we ask for are actually available. for (auto ext : instance_extensions_enabled_) { if (!IsInstanceExtensionAvailable(ext)) - WLOG("WARNING: Does not seem that instance extension '%s' is available. Trying to proceed anyway.", ext); + WARN_LOG(G3D, "WARNING: Does not seem that instance extension '%s' is available. Trying to proceed anyway.", ext); } VkApplicationInfo app_info{ VK_STRUCTURE_TYPE_APPLICATION_INFO }; @@ -180,7 +180,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { #endif if (res != VK_SUCCESS) { if (res == VK_ERROR_LAYER_NOT_PRESENT) { - WLOG("Validation on but instance layer not available - dropping layers"); + WARN_LOG(G3D, "Validation on but instance layer not available - dropping layers"); // Drop the validation layers and try again. instance_layer_names_.clear(); device_layer_names_.clear(); @@ -188,9 +188,9 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { inst_info.ppEnabledLayerNames = nullptr; res = vkCreateInstance(&inst_info, nullptr, &instance_); if (res != VK_SUCCESS) - ELOG("Failed to create instance even without validation: %d", res); + ERROR_LOG(G3D, "Failed to create instance even without validation: %d", res); } else { - ELOG("Failed to create instance : %d", res); + ERROR_LOG(G3D, "Failed to create instance : %d", res); } } if (res != VK_SUCCESS) { @@ -200,7 +200,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { VulkanLoadInstanceFunctions(instance_, extensionsLookup_); if (!CheckLayers(instance_layer_properties_, instance_layer_names_)) { - WLOG("CheckLayers for instance failed"); + WARN_LOG(G3D, "CheckLayers for instance failed"); // init_error_ = "Failed to validate instance layers"; // return; } @@ -212,14 +212,14 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { res = vkEnumeratePhysicalDevices(instance_, &gpu_count, nullptr); #endif if (gpu_count <= 0) { - ELOG("Vulkan driver found but no supported GPU is available"); + ERROR_LOG(G3D, "Vulkan driver found but no supported GPU is available"); init_error_ = "No Vulkan physical devices found"; vkDestroyInstance(instance_, nullptr); instance_ = nullptr; return VK_ERROR_INITIALIZATION_FAILED; } - assert(gpu_count > 0); + _dbg_assert_(gpu_count > 0); physical_devices_.resize(gpu_count); physicalDeviceProperties_.resize(gpu_count); res = vkEnumeratePhysicalDevices(instance_, &gpu_count, physical_devices_.data()); @@ -259,7 +259,7 @@ VkResult VulkanContext::CreateInstance(const CreateInfo &info) { } VulkanContext::~VulkanContext() { - assert(instance_ == VK_NULL_HANDLE); + _dbg_assert_(instance_ == VK_NULL_HANDLE); } void VulkanContext::DestroyInstance() { @@ -290,7 +290,7 @@ void VulkanContext::EndFrame() { } void VulkanContext::UpdateInflightFrames(int n) { - assert(n >= 1 && n <= MAX_INFLIGHT_FRAMES); + _dbg_assert_(n >= 1 && n <= MAX_INFLIGHT_FRAMES); inflightFrames_ = n; if (curFrame_ >= inflightFrames_) { curFrame_ = 0; @@ -508,19 +508,19 @@ int VulkanContext::GetBestPhysicalDevice() { void VulkanContext::ChooseDevice(int physical_device) { physical_device_ = physical_device; - ILOG("Chose physical device %d: %p", physical_device, physical_devices_[physical_device]); + INFO_LOG(G3D, "Chose physical device %d: %p", physical_device, physical_devices_[physical_device]); GetDeviceLayerProperties(); if (!CheckLayers(device_layer_properties_, device_layer_names_)) { - WLOG("CheckLayers for device %d failed", physical_device); + WARN_LOG(G3D, "CheckLayers for device %d failed", physical_device); } vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, nullptr); - assert(queue_count >= 1); + _dbg_assert_(queue_count >= 1); queueFamilyProperties_.resize(queue_count); vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[physical_device_], &queue_count, queueFamilyProperties_.data()); - assert(queue_count >= 1); + _dbg_assert_(queue_count >= 1); // Detect preferred formats, in this order. static const VkFormat depthStencilFormats[] = { @@ -539,17 +539,17 @@ void VulkanContext::ChooseDevice(int physical_device) { } if (deviceInfo_.preferredDepthStencilFormat == VK_FORMAT_UNDEFINED) { // WTF? This is bad. - ELOG("Could not find a usable depth stencil format."); + ERROR_LOG(G3D, "Could not find a usable depth stencil format."); } // This is as good a place as any to do this. vkGetPhysicalDeviceMemoryProperties(physical_devices_[physical_device_], &memory_properties); - ILOG("Memory Types (%d):", memory_properties.memoryTypeCount); + INFO_LOG(G3D, "Memory Types (%d):", memory_properties.memoryTypeCount); for (int i = 0; i < (int)memory_properties.memoryTypeCount; i++) { // Don't bother printing dummy memory types. if (!memory_properties.memoryTypes[i].propertyFlags) continue; - ILOG(" %d: Heap %d; Flags: %s%s%s%s ", i, memory_properties.memoryTypes[i].heapIndex, + INFO_LOG(G3D, " %d: Heap %d; Flags: %s%s%s%s ", i, memory_properties.memoryTypes[i].heapIndex, (memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) ? "DEVICE_LOCAL " : "", (memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) ? "HOST_VISIBLE " : "", (memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_CACHED_BIT) ? "HOST_CACHED " : "", @@ -611,7 +611,7 @@ bool VulkanContext::EnableDeviceExtension(const char *extension) { VkResult VulkanContext::CreateDevice() { if (!init_error_.empty() || physical_device_ < 0) { - ELOG("Vulkan init failed: %s", init_error_.c_str()); + ERROR_LOG(G3D, "Vulkan init failed: %s", init_error_.c_str()); return VK_ERROR_INITIALIZATION_FAILED; } @@ -627,7 +627,7 @@ VkResult VulkanContext::CreateDevice() { break; } } - assert(found); + _dbg_assert_(found); extensionsLookup_.KHR_maintenance1 = EnableDeviceExtension(VK_KHR_MAINTENANCE1_EXTENSION_NAME); extensionsLookup_.KHR_maintenance2 = EnableDeviceExtension(VK_KHR_MAINTENANCE2_EXTENSION_NAME); @@ -661,11 +661,11 @@ VkResult VulkanContext::CreateDevice() { VkResult res = vkCreateDevice(physical_devices_[physical_device_], &device_info, nullptr, &device_); if (res != VK_SUCCESS) { init_error_ = "Unable to create Vulkan device"; - ELOG("Unable to create Vulkan device"); + ERROR_LOG(G3D, "Unable to create Vulkan device"); } else { VulkanLoadDeviceFunctions(device_, extensionsLookup_); } - ILOG("Device created.\n"); + INFO_LOG(G3D, "Device created.\n"); VulkanSetAvailable(true); return res; } @@ -685,10 +685,10 @@ VkResult VulkanContext::InitDebugUtilsCallback() { VkDebugUtilsMessengerEXT messenger; VkResult res = vkCreateDebugUtilsMessengerEXT(instance_, &callback1, nullptr, &messenger); if (res != VK_SUCCESS) { - ELOG("Failed to register debug callback with vkCreateDebugUtilsMessengerEXT"); + ERROR_LOG(G3D, "Failed to register debug callback with vkCreateDebugUtilsMessengerEXT"); // Do error handling for VK_ERROR_OUT_OF_MEMORY } else { - ILOG("Debug callback registered with vkCreateDebugUtilsMessengerEXT."); + INFO_LOG(G3D, "Debug callback registered with vkCreateDebugUtilsMessengerEXT."); utils_callbacks.push_back(messenger); } return res; @@ -711,12 +711,12 @@ VkResult VulkanContext::InitSurface(WindowSystem winsys, void *data1, void *data VkResult VulkanContext::ReinitSurface() { if (surface_ != VK_NULL_HANDLE) { - ILOG("Destroying Vulkan surface (%d, %d)", swapChainExtent_.width, swapChainExtent_.height); + INFO_LOG(G3D, "Destroying Vulkan surface (%d, %d)", swapChainExtent_.width, swapChainExtent_.height); vkDestroySurfaceKHR(instance_, surface_, nullptr); surface_ = VK_NULL_HANDLE; } - ILOG("Creating Vulkan surface for window (%p %p)", winsysData1_, winsysData2_); + INFO_LOG(G3D, "Creating Vulkan surface for window (%p %p)", winsysData1_, winsysData2_); VkResult retval = VK_SUCCESS; @@ -842,7 +842,7 @@ bool VulkanContext::ChooseQueue() { // Generate error if could not find both a graphics and a present queue if (graphicsQueueNodeIndex == UINT32_MAX || presentQueueNodeIndex == UINT32_MAX) { - ELOG("Could not find a graphics and a present queue"); + ERROR_LOG(G3D, "Could not find a graphics and a present queue"); return false; } @@ -858,7 +858,7 @@ bool VulkanContext::ChooseQueue() { std::vector surfFormats(formatCount); res = vkGetPhysicalDeviceSurfaceFormatsKHR(physical_devices_[physical_device_], surface_, &formatCount, surfFormats.data()); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); if (res != VK_SUCCESS) { return false; } @@ -866,7 +866,7 @@ bool VulkanContext::ChooseQueue() { // the surface has no preferred format. Otherwise, at least one // supported format will be returned. if (formatCount == 0 || (formatCount == 1 && surfFormats[0].format == VK_FORMAT_UNDEFINED)) { - ILOG("swapchain_format: Falling back to B8G8R8A8_UNORM"); + INFO_LOG(G3D, "swapchain_format: Falling back to B8G8R8A8_UNORM"); swapchainFormat_ = VK_FORMAT_B8G8R8A8_UNORM; } else { swapchainFormat_ = VK_FORMAT_UNDEFINED; @@ -884,7 +884,7 @@ bool VulkanContext::ChooseQueue() { // Okay, take the first one then. swapchainFormat_ = surfFormats[0].format; } - ILOG("swapchain_format: %d (/%d)", swapchainFormat_, formatCount); + INFO_LOG(G3D, "swapchain_format: %d (/%d)", swapchainFormat_, formatCount); } vkGetDeviceQueue(device_, graphics_queue_family_index_, 0, &gfx_queue_); @@ -915,20 +915,20 @@ static std::string surface_transforms_to_string(VkSurfaceTransformFlagsKHR trans bool VulkanContext::InitSwapchain() { VkResult res = vkGetPhysicalDeviceSurfaceCapabilitiesKHR(physical_devices_[physical_device_], surface_, &surfCapabilities_); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); uint32_t presentModeCount; res = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_devices_[physical_device_], surface_, &presentModeCount, nullptr); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); VkPresentModeKHR *presentModes = new VkPresentModeKHR[presentModeCount]; - assert(presentModes); + _dbg_assert_(presentModes); res = vkGetPhysicalDeviceSurfacePresentModesKHR(physical_devices_[physical_device_], surface_, &presentModeCount, presentModes); - assert(res == VK_SUCCESS); + _dbg_assert_(res == VK_SUCCESS); swapChainExtent_.width = clamp(surfCapabilities_.currentExtent.width, surfCapabilities_.minImageExtent.width, surfCapabilities_.maxImageExtent.width); swapChainExtent_.height = clamp(surfCapabilities_.currentExtent.height, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.height); - ILOG("surfCapabilities_.current: %dx%d min: %dx%d max: %dx%d computed: %dx%d", + INFO_LOG(G3D, "surfCapabilities_.current: %dx%d min: %dx%d max: %dx%d computed: %dx%d", surfCapabilities_.currentExtent.width, surfCapabilities_.currentExtent.height, surfCapabilities_.minImageExtent.width, surfCapabilities_.minImageExtent.height, surfCapabilities_.maxImageExtent.width, surfCapabilities_.maxImageExtent.height, @@ -944,7 +944,7 @@ bool VulkanContext::InitSwapchain() { modes += ", "; } } - ILOG("Supported present modes: %s", modes.c_str()); + INFO_LOG(G3D, "Supported present modes: %s", modes.c_str()); for (size_t i = 0; i < presentModeCount; i++) { bool match = false; match = match || ((flags_ & VULKAN_FLAG_PRESENT_MAILBOX) && presentModes[i] == VK_PRESENT_MODE_MAILBOX_KHR); @@ -976,7 +976,7 @@ bool VulkanContext::InitSwapchain() { desiredNumberOfSwapChainImages = surfCapabilities_.maxImageCount; } - ILOG("Chosen present mode: %d (%s). numSwapChainImages: %d/%d", + INFO_LOG(G3D, "Chosen present mode: %d (%s). numSwapChainImages: %d/%d", swapchainPresentMode, PresentModeString(swapchainPresentMode), desiredNumberOfSwapChainImages, surfCapabilities_.maxImageCount); @@ -1011,7 +1011,7 @@ bool VulkanContext::InitSwapchain() { std::swap(swapChainExtent_.width, swapChainExtent_.height); break; default: - assert(false); + _dbg_assert_(false); } } else { // Let the OS rotate the image (potentially slow on many Android devices) @@ -1020,10 +1020,10 @@ bool VulkanContext::InitSwapchain() { std::string preTransformStr = surface_transforms_to_string(preTransform); - ILOG("Transform supported: %s current: %s chosen: %s", supportedTransforms.c_str(), currentTransform.c_str(), preTransformStr.c_str()); + INFO_LOG(G3D, "Transform supported: %s current: %s chosen: %s", supportedTransforms.c_str(), currentTransform.c_str(), preTransformStr.c_str()); if (physicalDeviceProperties_[physical_device_].properties.vendorID == VULKAN_VENDOR_IMGTEC) { - ILOG("Applying PowerVR hack (rounding off the width!)"); + INFO_LOG(G3D, "Applying PowerVR hack (rounding off the width!)"); // Swap chain width hack to avoid issue #11743 (PowerVR driver bug). // To keep the size consistent even with pretransform, do this after the swap. Should be fine. // This is fixed in newer PowerVR drivers but I don't know the cutoff. @@ -1068,10 +1068,10 @@ bool VulkanContext::InitSwapchain() { res = vkCreateSwapchainKHR(device_, &swap_chain_info, NULL, &swapchain_); if (res != VK_SUCCESS) { - ELOG("vkCreateSwapchainKHR failed!"); + ERROR_LOG(G3D, "vkCreateSwapchainKHR failed!"); return false; } - ILOG("Created swapchain: %dx%d", swap_chain_info.imageExtent.width, swap_chain_info.imageExtent.height); + INFO_LOG(G3D, "Created swapchain: %dx%d", swap_chain_info.imageExtent.width, swap_chain_info.imageExtent.height); return true; } @@ -1092,13 +1092,13 @@ void VulkanContext::PerformPendingDeletes() { void VulkanContext::DestroyDevice() { if (swapchain_) { - ELOG("DestroyDevice: Swapchain should have been destroyed."); + ERROR_LOG(G3D, "DestroyDevice: Swapchain should have been destroyed."); } if (surface_) { - ELOG("DestroyDevice: Surface should have been destroyed."); + ERROR_LOG(G3D, "DestroyDevice: Surface should have been destroyed."); } - ILOG("VulkanContext::DestroyDevice (performing deletes)"); + INFO_LOG(G3D, "VulkanContext::DestroyDevice (performing deletes)"); PerformPendingDeletes(); vkDestroyDevice(device_, nullptr); @@ -1274,22 +1274,22 @@ const char *VulkanResultToString(VkResult res) { } void VulkanDeleteList::Take(VulkanDeleteList &del) { - assert(cmdPools_.empty()); - assert(descPools_.empty()); - assert(modules_.empty()); - assert(buffers_.empty()); - assert(bufferViews_.empty()); - assert(images_.empty()); - assert(imageViews_.empty()); - assert(deviceMemory_.empty()); - assert(samplers_.empty()); - assert(pipelines_.empty()); - assert(pipelineCaches_.empty()); - assert(renderPasses_.empty()); - assert(framebuffers_.empty()); - assert(pipelineLayouts_.empty()); - assert(descSetLayouts_.empty()); - assert(callbacks_.empty()); + _dbg_assert_(cmdPools_.empty()); + _dbg_assert_(descPools_.empty()); + _dbg_assert_(modules_.empty()); + _dbg_assert_(buffers_.empty()); + _dbg_assert_(bufferViews_.empty()); + _dbg_assert_(images_.empty()); + _dbg_assert_(imageViews_.empty()); + _dbg_assert_(deviceMemory_.empty()); + _dbg_assert_(samplers_.empty()); + _dbg_assert_(pipelines_.empty()); + _dbg_assert_(pipelineCaches_.empty()); + _dbg_assert_(renderPasses_.empty()); + _dbg_assert_(framebuffers_.empty()); + _dbg_assert_(pipelineLayouts_.empty()); + _dbg_assert_(descSetLayouts_.empty()); + _dbg_assert_(callbacks_.empty()); cmdPools_ = std::move(del.cmdPools_); descPools_ = std::move(del.descPools_); modules_ = std::move(del.modules_); diff --git a/Common/Vulkan/VulkanContext.h b/Common/Vulkan/VulkanContext.h index 7c9174f38f..b1c998b8b5 100644 --- a/Common/Vulkan/VulkanContext.h +++ b/Common/Vulkan/VulkanContext.h @@ -1,11 +1,11 @@ #pragma once #include +#include #include #include #include -#include "base/logging.h" #include "Common/Vulkan/VulkanLoader.h" #include "Common/Vulkan/VulkanDebug.h" diff --git a/Common/Vulkan/VulkanImage.cpp b/Common/Vulkan/VulkanImage.cpp index 247df10ff9..82d07cd264 100644 --- a/Common/Vulkan/VulkanImage.cpp +++ b/Common/Vulkan/VulkanImage.cpp @@ -67,7 +67,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all VkResult res = vkCreateImage(vulkan_->GetDevice(), &image_create_info, NULL, &image_); if (res != VK_SUCCESS) { _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); - ELOG("vkCreateImage failed: %s", VulkanResultToString(res)); + ERROR_LOG(G3D, "vkCreateImage failed: %s", VulkanResultToString(res)); return false; } @@ -82,7 +82,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all allocator_ = allocator; offset_ = allocator_->Allocate(mem_reqs, &mem_, Tag()); if (offset_ == VulkanDeviceAllocator::ALLOCATE_FAILED) { - ELOG("Image memory allocation failed (mem_reqs.size=%d, typebits=%08x", (int)mem_reqs.size, (int)mem_reqs.memoryTypeBits); + ERROR_LOG(G3D, "Image memory allocation failed (mem_reqs.size=%d, typebits=%08x", (int)mem_reqs.size, (int)mem_reqs.memoryTypeBits); // Destructor will take care of the image. return false; } @@ -103,7 +103,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all res = vkAllocateMemory(vulkan_->GetDevice(), &mem_alloc, NULL, &mem_); if (res != VK_SUCCESS) { - ELOG("vkAllocateMemory failed: %s", VulkanResultToString(res)); + ERROR_LOG(G3D, "vkAllocateMemory failed: %s", VulkanResultToString(res)); _assert_msg_(res != VK_ERROR_TOO_MANY_OBJECTS, "Too many Vulkan memory objects!"); _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); return false; @@ -114,7 +114,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all res = vkBindImageMemory(vulkan_->GetDevice(), image_, mem_, offset_); if (res != VK_SUCCESS) { - ELOG("vkBindImageMemory failed: %s", VulkanResultToString(res)); + ERROR_LOG(G3D, "vkBindImageMemory failed: %s", VulkanResultToString(res)); // This leaks the image and memory. Should not really happen though... _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); return false; @@ -156,7 +156,7 @@ bool VulkanTexture::CreateDirect(VkCommandBuffer cmd, VulkanDeviceAllocator *all res = vkCreateImageView(vulkan_->GetDevice(), &view_info, NULL, &view_); if (res != VK_SUCCESS) { - ELOG("vkCreateImageView failed: %s", VulkanResultToString(res)); + ERROR_LOG(G3D, "vkCreateImageView failed: %s", VulkanResultToString(res)); // This leaks the image. _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); return false; diff --git a/Common/Vulkan/VulkanMemory.cpp b/Common/Vulkan/VulkanMemory.cpp index 9cead85745..062472c377 100644 --- a/Common/Vulkan/VulkanMemory.cpp +++ b/Common/Vulkan/VulkanMemory.cpp @@ -18,19 +18,20 @@ // Additionally, Common/Vulkan/* , including this file, are also licensed // under the public domain. -#include "Common/Log.h" -#include "Common/Vulkan/VulkanMemory.h" #include "base/timeutil.h" #include "math/math_util.h" +#include "Common/Log.h" +#include "Common/Vulkan/VulkanMemory.h" + VulkanPushBuffer::VulkanPushBuffer(VulkanContext *vulkan, size_t size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memoryPropertyMask) : vulkan_(vulkan), memoryPropertyMask_(memoryPropertyMask), size_(size), usage_(usage) { bool res = AddBuffer(); - assert(res); + _assert_(res); } VulkanPushBuffer::~VulkanPushBuffer() { - assert(buffers_.empty()); + _assert_(buffers_.empty()); } bool VulkanPushBuffer::AddBuffer() { @@ -68,7 +69,7 @@ bool VulkanPushBuffer::AddBuffer() { } res = vkBindBufferMemory(device, info.buffer, info.deviceMemory, 0); if (VK_SUCCESS != res) { - ELOG("vkBindBufferMemory failed! result=%d", (int)res); + ERROR_LOG(G3D, "vkBindBufferMemory failed! result=%d", (int)res); vkFreeMemory(device, info.deviceMemory, nullptr); vkDestroyBuffer(device, info.buffer, nullptr); return false; @@ -100,7 +101,7 @@ void VulkanPushBuffer::NextBuffer(size_t minSize) { } bool res = AddBuffer(); - assert(res); + _assert_(res); if (!res) { // Let's try not to crash at least? buf_ = 0; @@ -124,7 +125,7 @@ void VulkanPushBuffer::Defragment(VulkanContext *vulkan) { size_ = newSize; bool res = AddBuffer(); - assert(res); + _assert_(res); } size_t VulkanPushBuffer::GetTotalSize() const { @@ -139,7 +140,7 @@ void VulkanPushBuffer::Map() { _dbg_assert_(!writePtr_); VkResult res = vkMapMemory(vulkan_->GetDevice(), buffers_[buf_].deviceMemory, 0, size_, 0, (void **)(&writePtr_)); _dbg_assert_(writePtr_); - assert(VK_SUCCESS == res); + _assert_(VK_SUCCESS == res); } void VulkanPushBuffer::Unmap() { @@ -161,12 +162,12 @@ void VulkanPushBuffer::Unmap() { VulkanDeviceAllocator::VulkanDeviceAllocator(VulkanContext *vulkan, size_t minSlabSize, size_t maxSlabSize) : vulkan_(vulkan), minSlabSize_(minSlabSize), maxSlabSize_(maxSlabSize) { - assert((minSlabSize_ & (SLAB_GRAIN_SIZE - 1)) == 0); + _assert_((minSlabSize_ & (SLAB_GRAIN_SIZE - 1)) == 0); } VulkanDeviceAllocator::~VulkanDeviceAllocator() { - assert(destroyed_); - assert(slabs_.empty()); + _assert_(destroyed_); + _assert_(slabs_.empty()); } void VulkanDeviceAllocator::Destroy() { @@ -183,7 +184,7 @@ void VulkanDeviceAllocator::Destroy() { } } - assert(slab.deviceMemory); + _assert_(slab.deviceMemory); vulkan_->Delete().QueueDeleteDeviceMemory(slab.deviceMemory); } slabs_.clear(); @@ -191,11 +192,11 @@ void VulkanDeviceAllocator::Destroy() { } size_t VulkanDeviceAllocator::Allocate(const VkMemoryRequirements &reqs, VkDeviceMemory *deviceMemory, const std::string &tag) { - assert(!destroyed_); + _assert_(!destroyed_); uint32_t memoryTypeIndex; bool pass = vulkan_->MemoryTypeFromProperties(reqs.memoryTypeBits, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, &memoryTypeIndex); if (!pass) { - ELOG("Failed to pick an appropriate memory type (req: %08x)", reqs.memoryTypeBits); + ERROR_LOG(G3D, "Failed to pick an appropriate memory type (req: %08x)", reqs.memoryTypeBits); return ALLOCATE_FAILED; } @@ -244,7 +245,7 @@ size_t VulkanDeviceAllocator::Allocate(const VkMemoryRequirements &reqs, VkDevic } bool VulkanDeviceAllocator::AllocateFromSlab(Slab &slab, size_t &start, size_t blocks, const std::string &tag) { - assert(!destroyed_); + _assert_(!destroyed_); bool matched = true; if (start + blocks > slab.usage.size()) { @@ -320,7 +321,7 @@ void VulkanDeviceAllocator::DoTouch(VkDeviceMemory deviceMemory, size_t offset) } void VulkanDeviceAllocator::Free(VkDeviceMemory deviceMemory, size_t offset) { - assert(!destroyed_); + _assert_(!destroyed_); _assert_msg_(!slabs_.empty(), "No slabs - can't be anything to free! double-freed?"); @@ -401,7 +402,7 @@ void VulkanDeviceAllocator::ExecuteFree(FreeInfo *userdata) { } bool VulkanDeviceAllocator::AllocateSlab(VkDeviceSize minBytes, int memoryTypeIndex) { - assert(!destroyed_); + _assert_(!destroyed_); if (!slabs_.empty() && minSlabSize_ < maxSlabSize_) { // We're allocating an additional slab, so rachet up its size. // TODO: Maybe should not do this when we are allocating a new slab due to memoryTypeIndex not matching? @@ -420,7 +421,7 @@ bool VulkanDeviceAllocator::AllocateSlab(VkDeviceSize minBytes, int memoryTypeIn VkResult res = vkAllocateMemory(vulkan_->GetDevice(), &alloc, NULL, &deviceMemory); if (res != VK_SUCCESS) { // If it's something else, we used it wrong? - assert(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); + _assert_(res == VK_ERROR_OUT_OF_HOST_MEMORY || res == VK_ERROR_OUT_OF_DEVICE_MEMORY || res == VK_ERROR_TOO_MANY_OBJECTS); // Okay, so we ran out of memory. return false; } @@ -464,7 +465,7 @@ void VulkanDeviceAllocator::ReportOldUsage() { } void VulkanDeviceAllocator::Decimate() { - assert(!destroyed_); + _assert_(!destroyed_); bool foundFree = false; if (TRACK_TOUCH) { diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index 0e653be2b1..7e0ad69ba7 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -15,6 +15,7 @@ // Official git repository and contact information can be found at // https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. +#include "base/logging.h" // For OutputDebugStringUTF8. TODO: Move it. #include "base/basictypes.h" #include "base/stringutil.h" #include "Common/Log.h" diff --git a/ext/native/thin3d/VulkanQueueRunner.cpp b/ext/native/thin3d/VulkanQueueRunner.cpp index cffb65f8a5..6ce2eb4249 100644 --- a/ext/native/thin3d/VulkanQueueRunner.cpp +++ b/ext/native/thin3d/VulkanQueueRunner.cpp @@ -9,7 +9,7 @@ // Debug help: adb logcat -s DEBUG PPSSPPNativeActivity PPSSPP NativeGLView NativeRenderer NativeSurfaceView PowerSaveModeReceiver InputDeviceState void VulkanQueueRunner::CreateDeviceObjects() { - ILOG("VulkanQueueRunner::CreateDeviceObjects"); + INFO_LOG(G3D, "VulkanQueueRunner::CreateDeviceObjects"); InitBackbufferRenderPass(); framebufferRenderPass_ = GetRenderPass(VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR, VKRRenderPassAction::CLEAR, @@ -19,14 +19,14 @@ void VulkanQueueRunner::CreateDeviceObjects() { // Just to check whether it makes sense to split some of these. drawidx is way bigger than the others... // We should probably just move to variable-size data in a raw buffer anyway... VkRenderData rd; - ILOG("sizeof(pipeline): %d", (int)sizeof(rd.pipeline)); - ILOG("sizeof(draw): %d", (int)sizeof(rd.draw)); - ILOG("sizeof(drawidx): %d", (int)sizeof(rd.drawIndexed)); - ILOG("sizeof(clear): %d", (int)sizeof(rd.clear)); - ILOG("sizeof(viewport): %d", (int)sizeof(rd.viewport)); - ILOG("sizeof(scissor): %d", (int)sizeof(rd.scissor)); - ILOG("sizeof(blendColor): %d", (int)sizeof(rd.blendColor)); - ILOG("sizeof(push): %d", (int)sizeof(rd.push)); + INFO_LOG(G3D, "sizeof(pipeline): %d", (int)sizeof(rd.pipeline)); + INFO_LOG(G3D, "sizeof(draw): %d", (int)sizeof(rd.draw)); + INFO_LOG(G3D, "sizeof(drawidx): %d", (int)sizeof(rd.drawIndexed)); + INFO_LOG(G3D, "sizeof(clear): %d", (int)sizeof(rd.clear)); + INFO_LOG(G3D, "sizeof(viewport): %d", (int)sizeof(rd.viewport)); + INFO_LOG(G3D, "sizeof(scissor): %d", (int)sizeof(rd.scissor)); + INFO_LOG(G3D, "sizeof(blendColor): %d", (int)sizeof(rd.blendColor)); + INFO_LOG(G3D, "sizeof(push): %d", (int)sizeof(rd.push)); #endif } @@ -87,7 +87,7 @@ void VulkanQueueRunner::ResizeReadbackBuffer(VkDeviceSize requiredSize) { } void VulkanQueueRunner::DestroyDeviceObjects() { - ILOG("VulkanQueueRunner::DestroyDeviceObjects"); + INFO_LOG(G3D, "VulkanQueueRunner::DestroyDeviceObjects"); vulkan_->Delete().QueueDeleteDeviceMemory(readbackMemory_); vulkan_->Delete().QueueDeleteBuffer(readbackBuffer_); readbackBufferSize_ = 0; @@ -98,7 +98,7 @@ void VulkanQueueRunner::DestroyDeviceObjects() { }); renderPasses_.Clear(); - assert(backbufferRenderPass_ != VK_NULL_HANDLE); + _assert_(backbufferRenderPass_ != VK_NULL_HANDLE); vulkan_->Delete().QueueDeleteRenderPass(backbufferRenderPass_); backbufferRenderPass_ = VK_NULL_HANDLE; } @@ -559,7 +559,7 @@ void VulkanQueueRunner::ApplyMGSHack(std::vector &steps) { for (int j = 0; j < (int)renders.size(); j++) { steps[i + j + copies.size()] = renders[j]; } - assert(steps[i + copies.size()]->stepType == VKRStepType::RENDER); + _assert_(steps[i + copies.size()]->stepType == VKRStepType::RENDER); // Combine the renders. for (int j = 1; j < (int)renders.size(); j++) { for (int k = 0; k < (int)renders[j]->commands.size(); k++) { @@ -850,10 +850,10 @@ void VulkanQueueRunner::ApplyRenderPassMerge(std::vector &steps) { } void VulkanQueueRunner::LogSteps(const std::vector &steps) { - ILOG("======================================="); + INFO_LOG(G3D, "======================================="); for (size_t i = 0; i < steps.size(); i++) { const VKRStep &step = *steps[i]; - ILOG("%s", StepToString(step).c_str()); + INFO_LOG(G3D, "%s", StepToString(step).c_str()); switch (step.stepType) { case VKRStepType::RENDER: LogRenderPass(step); @@ -871,7 +871,7 @@ void VulkanQueueRunner::LogSteps(const std::vector &steps) { LogReadbackImage(step); break; case VKRStepType::RENDER_SKIP: - ILOG("(skipped render pass)"); + INFO_LOG(G3D, "(skipped render pass)"); break; } } @@ -892,62 +892,62 @@ const char *RenderPassActionName(VKRRenderPassAction a) { void VulkanQueueRunner::LogRenderPass(const VKRStep &pass) { const auto &r = pass.render; int fb = (int)(intptr_t)(r.framebuffer ? r.framebuffer->framebuf : 0); - ILOG("RenderPass Begin(%x, %s, %s, %s)", fb, RenderPassActionName(r.color), RenderPassActionName(r.depth), RenderPassActionName(r.stencil)); + INFO_LOG(G3D, "RenderPass Begin(%x, %s, %s, %s)", fb, RenderPassActionName(r.color), RenderPassActionName(r.depth), RenderPassActionName(r.stencil)); for (auto &cmd : pass.commands) { switch (cmd.cmd) { case VKRRenderCommand::REMOVED: - ILOG(" (Removed)"); + INFO_LOG(G3D, " (Removed)"); break; case VKRRenderCommand::BIND_PIPELINE: - ILOG(" BindPipeline(%x)", (int)(intptr_t)cmd.pipeline.pipeline); + INFO_LOG(G3D, " BindPipeline(%x)", (int)(intptr_t)cmd.pipeline.pipeline); break; case VKRRenderCommand::BLEND: - ILOG(" BlendColor(%08x)", cmd.blendColor.color); + INFO_LOG(G3D, " BlendColor(%08x)", cmd.blendColor.color); break; case VKRRenderCommand::CLEAR: - ILOG(" Clear"); + INFO_LOG(G3D, " Clear"); break; case VKRRenderCommand::DRAW: - ILOG(" Draw(%d)", cmd.draw.count); + INFO_LOG(G3D, " Draw(%d)", cmd.draw.count); break; case VKRRenderCommand::DRAW_INDEXED: - ILOG(" DrawIndexed(%d)", cmd.drawIndexed.count); + INFO_LOG(G3D, " DrawIndexed(%d)", cmd.drawIndexed.count); break; case VKRRenderCommand::SCISSOR: - ILOG(" Scissor(%d, %d, %d, %d)", (int)cmd.scissor.scissor.offset.x, (int)cmd.scissor.scissor.offset.y, (int)cmd.scissor.scissor.extent.width, (int)cmd.scissor.scissor.extent.height); + INFO_LOG(G3D, " Scissor(%d, %d, %d, %d)", (int)cmd.scissor.scissor.offset.x, (int)cmd.scissor.scissor.offset.y, (int)cmd.scissor.scissor.extent.width, (int)cmd.scissor.scissor.extent.height); break; case VKRRenderCommand::STENCIL: - ILOG(" Stencil(ref=%d, compare=%d, write=%d)", cmd.stencil.stencilRef, cmd.stencil.stencilCompareMask, cmd.stencil.stencilWriteMask); + INFO_LOG(G3D, " Stencil(ref=%d, compare=%d, write=%d)", cmd.stencil.stencilRef, cmd.stencil.stencilCompareMask, cmd.stencil.stencilWriteMask); break; case VKRRenderCommand::VIEWPORT: - ILOG(" Viewport(%f, %f, %f, %f, %f, %f)", cmd.viewport.vp.x, cmd.viewport.vp.y, cmd.viewport.vp.width, cmd.viewport.vp.height, cmd.viewport.vp.minDepth, cmd.viewport.vp.maxDepth); + INFO_LOG(G3D, " Viewport(%f, %f, %f, %f, %f, %f)", cmd.viewport.vp.x, cmd.viewport.vp.y, cmd.viewport.vp.width, cmd.viewport.vp.height, cmd.viewport.vp.minDepth, cmd.viewport.vp.maxDepth); break; case VKRRenderCommand::PUSH_CONSTANTS: - ILOG(" PushConstants(%d)", cmd.push.size); + INFO_LOG(G3D, " PushConstants(%d)", cmd.push.size); break; case VKRRenderCommand::NUM_RENDER_COMMANDS: break; } } - ILOG("RenderPass End(%x)", fb); + INFO_LOG(G3D, "RenderPass End(%x)", fb); } void VulkanQueueRunner::LogCopy(const VKRStep &step) { - ILOG("%s", StepToString(step).c_str()); + INFO_LOG(G3D, "%s", StepToString(step).c_str()); } void VulkanQueueRunner::LogBlit(const VKRStep &step) { - ILOG("%s", StepToString(step).c_str()); + INFO_LOG(G3D, "%s", StepToString(step).c_str()); } void VulkanQueueRunner::LogReadback(const VKRStep &step) { - ILOG("%s", StepToString(step).c_str()); + INFO_LOG(G3D, "%s", StepToString(step).c_str()); } void VulkanQueueRunner::LogReadbackImage(const VKRStep &step) { - ILOG("%s", StepToString(step).c_str()); + INFO_LOG(G3D, "%s", StepToString(step).c_str()); } void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer cmd) { @@ -1232,7 +1232,7 @@ void VulkanQueueRunner::PerformRenderPass(const VKRStep &step, VkCommandBuffer c break; } default: - ELOG("Unimpl queue command"); + ERROR_LOG(G3D, "Unimpl queue command"); ; } } @@ -1707,7 +1707,7 @@ void VulkanQueueRunner::CopyReadbackBuffer(int width, int height, Draw::DataForm } if (res != VK_SUCCESS) { - ELOG("CopyReadbackBuffer: vkMapMemory failed! result=%d", (int)res); + ERROR_LOG(G3D, "CopyReadbackBuffer: vkMapMemory failed! result=%d", (int)res); return; } @@ -1729,7 +1729,7 @@ void VulkanQueueRunner::CopyReadbackBuffer(int width, int height, Draw::DataForm ConvertToD32F(pixels, (const uint8_t *)mappedData, pixelStride, width, width, height, srcFormat); } else { // TODO: Maybe a depth conversion or something? - ELOG("CopyReadbackBuffer: Unknown format"); + ERROR_LOG(G3D, "CopyReadbackBuffer: Unknown format"); _assert_msg_(false, "CopyReadbackBuffer: Unknown src format %d", (int)srcFormat); } vkUnmapMemory(vulkan_->GetDevice(), readbackMemory_); diff --git a/ext/native/ui/screen.h b/ext/native/ui/screen.h index 0b97108afd..d269995880 100644 --- a/ext/native/ui/screen.h +++ b/ext/native/ui/screen.h @@ -17,7 +17,6 @@ #include #include "base/basictypes.h" -#include "base/logging.h" #include "base/NativeApp.h" #include "input/input_state.h" diff --git a/ext/native/ui/view.h b/ext/native/ui/view.h index e8baa55702..0f0976b12f 100644 --- a/ext/native/ui/view.h +++ b/ext/native/ui/view.h @@ -15,7 +15,6 @@ #include #include -#include "base/logging.h" #include "base/basictypes.h" #include "gfx/texture_atlas.h" #include "math/lin/matrix4x4.h" diff --git a/ext/native/ui/viewgroup.cpp b/ext/native/ui/viewgroup.cpp index e9f2f88176..82a74faad8 100644 --- a/ext/native/ui/viewgroup.cpp +++ b/ext/native/ui/viewgroup.cpp @@ -1080,6 +1080,12 @@ void AnchorLayout::Layout() { } } +GridLayout::GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams) + : ViewGroup(layoutParams), settings_(settings), numColumns_(1) { + if (settings.orientation != ORIENT_HORIZONTAL) + ELOG("GridLayout: Vertical layouts not yet supported"); +} + void GridLayout::Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) { MeasureSpecType measureType = settings_.fillCells ? EXACTLY : AT_MOST; diff --git a/ext/native/ui/viewgroup.h b/ext/native/ui/viewgroup.h index 286f922925..0eb3f39328 100644 --- a/ext/native/ui/viewgroup.h +++ b/ext/native/ui/viewgroup.h @@ -5,7 +5,6 @@ #include #include -#include "base/logging.h" #include "math/geom2d.h" #include "input/gesture_detector.h" #include "ui/view.h" @@ -209,11 +208,7 @@ struct GridLayoutSettings { class GridLayout : public ViewGroup { public: - GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams = 0) - : ViewGroup(layoutParams), settings_(settings), numColumns_(1) { - if (settings.orientation != ORIENT_HORIZONTAL) - ELOG("GridLayout: Vertical layouts not yet supported"); - } + GridLayout(GridLayoutSettings settings, LayoutParams *layoutParams = 0); void Measure(const UIContext &dc, MeasureSpec horiz, MeasureSpec vert) override; void Layout() override;