diff --git a/parallel-rdp-standalone/COMMIT b/parallel-rdp-standalone/COMMIT index 41a11ea..5336a15 100644 --- a/parallel-rdp-standalone/COMMIT +++ b/parallel-rdp-standalone/COMMIT @@ -1 +1 @@ -07c3d161dbeb78121be5eebdab7c810b72af822a +0f0f9446470f4d0aa018b88ff6280bbc4137b6f6 diff --git a/parallel-rdp-standalone/vulkan/buffer_pool.cpp b/parallel-rdp-standalone/vulkan/buffer_pool.cpp index c746d43..7bae132 100644 --- a/parallel-rdp-standalone/vulkan/buffer_pool.cpp +++ b/parallel-rdp-standalone/vulkan/buffer_pool.cpp @@ -24,8 +24,6 @@ #include "device.hpp" #include -using namespace std; - namespace Vulkan { void BufferPool::init(Device *device_, VkDeviceSize block_size_, @@ -106,11 +104,11 @@ BufferBlock BufferPool::request_block(VkDeviceSize minimum_size) { if ((minimum_size > block_size) || blocks.empty()) { - return allocate_block(max(block_size, minimum_size)); + return allocate_block(std::max(block_size, minimum_size)); } else { - auto back = move(blocks.back()); + auto back = std::move(blocks.back()); blocks.pop_back(); back.mapped = static_cast(device->map_host_buffer(*back.cpu, MEMORY_ACCESS_WRITE_BIT)); @@ -124,7 +122,7 @@ void BufferPool::recycle_block(BufferBlock &block) VK_ASSERT(block.size == block_size); if (blocks.size() < max_retained_blocks) - blocks.push_back(move(block)); + blocks.push_back(std::move(block)); else block = {}; } diff --git a/parallel-rdp-standalone/vulkan/command_buffer.cpp b/parallel-rdp-standalone/vulkan/command_buffer.cpp index 149b312..8407c41 100644 --- a/parallel-rdp-standalone/vulkan/command_buffer.cpp +++ b/parallel-rdp-standalone/vulkan/command_buffer.cpp @@ -36,7 +36,6 @@ #include #endif -using namespace std; using namespace Util; namespace Vulkan @@ -534,9 +533,9 @@ void CommandBuffer::generate_mipmap(const Image &image) for (unsigned i = 1; i < create_info.levels; i++) { VkOffset3D src_size = size; - size.x = max(size.x >> 1, 1); - size.y = max(size.y >> 1, 1); - size.z = max(size.z >> 1, 1); + size.x = std::max(size.x >> 1, 1); + size.y = std::max(size.y >> 1, 1); + size.z = std::max(size.z >> 1, 1); blit_image(image, image, origin, size, origin, src_size, i, i - 1, 0, 0, create_info.layers, VK_FILTER_LINEAR); @@ -631,10 +630,10 @@ void CommandBuffer::init_viewport_scissor(const RenderPassInfo &info, const Fram uint32_t fb_width = fb->get_width(); uint32_t fb_height = fb->get_height(); - rect.offset.x = min(fb_width, uint32_t(rect.offset.x)); - rect.offset.y = min(fb_height, uint32_t(rect.offset.y)); - rect.extent.width = min(fb_width - rect.offset.x, rect.extent.width); - rect.extent.height = min(fb_height - rect.offset.y, rect.extent.height); + rect.offset.x = std::min(fb_width, uint32_t(rect.offset.x)); + rect.offset.y = std::min(fb_height, uint32_t(rect.offset.y)); + rect.extent.width = std::min(fb_width - rect.offset.x, rect.extent.width); + rect.extent.height = std::min(fb_height - rect.offset.y, rect.extent.height); if (surface_transform_swaps_xy(current_framebuffer_surface_transform)) rect2d_swap_xy(rect); diff --git a/parallel-rdp-standalone/vulkan/context.cpp b/parallel-rdp-standalone/vulkan/context.cpp index f4eae5e..d6efd21 100644 --- a/parallel-rdp-standalone/vulkan/context.cpp +++ b/parallel-rdp-standalone/vulkan/context.cpp @@ -36,8 +36,6 @@ //#undef VULKAN_DEBUG -using namespace std; - namespace Vulkan { void Context::set_application_info(const VkApplicationInfo *app_info) @@ -71,7 +69,7 @@ bool Context::init_instance_and_device(const char **instance_ext, uint32_t insta return true; } -static mutex loader_init_lock; +static std::mutex loader_init_lock; static bool loader_init_once; static PFN_vkGetInstanceProcAddr instance_proc_addr; @@ -82,7 +80,7 @@ PFN_vkGetInstanceProcAddr Context::get_instance_proc_addr() bool Context::init_loader(PFN_vkGetInstanceProcAddr addr) { - lock_guard holder(loader_init_lock); + std::lock_guard holder(loader_init_lock); if (loader_init_once && !addr) return true; @@ -223,9 +221,9 @@ void Context::notify_validation_error(const char *msg) message_callback(msg); } -void Context::set_notification_callback(function func) +void Context::set_notification_callback(std::function func) { - message_callback = move(func); + message_callback = std::move(func); } #ifdef VULKAN_DEBUG @@ -306,20 +304,20 @@ bool Context::create_instance(const char **instance_ext, uint32_t instance_ext_c VkInstanceCreateInfo info = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; info.pApplicationInfo = &get_application_info(); - vector instance_exts; - vector instance_layers; + std::vector instance_exts; + std::vector instance_layers; for (uint32_t i = 0; i < instance_ext_count; i++) instance_exts.push_back(instance_ext[i]); uint32_t ext_count = 0; vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, nullptr); - vector queried_extensions(ext_count); + std::vector queried_extensions(ext_count); if (ext_count) vkEnumerateInstanceExtensionProperties(nullptr, &ext_count, queried_extensions.data()); uint32_t layer_count = 0; vkEnumerateInstanceLayerProperties(&layer_count, nullptr); - vector queried_layers(layer_count); + std::vector queried_layers(layer_count); if (layer_count) vkEnumerateInstanceLayerProperties(&layer_count, queried_layers.data()); @@ -344,7 +342,7 @@ bool Context::create_instance(const char **instance_ext, uint32_t instance_ext_c ext.supports_debug_utils = true; } - auto itr = find_if(instance_ext, instance_ext + instance_ext_count, [](const char *name) { + auto itr = std::find_if(instance_ext, instance_ext + instance_ext_count, [](const char *name) { return strcmp(name, VK_KHR_SURFACE_EXTENSION_NAME) == 0; }); bool has_surface_extension = itr != (instance_ext + instance_ext_count); @@ -482,7 +480,7 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface, const c if (gpu_count == 0) return false; - vector gpus(gpu_count); + std::vector gpus(gpu_count); if (vkEnumeratePhysicalDevices(instance, &gpu_count, gpus.data()) != VK_SUCCESS) return false; @@ -533,13 +531,13 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface, const c uint32_t ext_count = 0; vkEnumerateDeviceExtensionProperties(gpu, nullptr, &ext_count, nullptr); - vector queried_extensions(ext_count); + std::vector queried_extensions(ext_count); if (ext_count) vkEnumerateDeviceExtensionProperties(gpu, nullptr, &ext_count, queried_extensions.data()); uint32_t layer_count = 0; vkEnumerateDeviceLayerProperties(gpu, &layer_count, nullptr); - vector queried_layers(layer_count); + std::vector queried_layers(layer_count); if (layer_count) vkEnumerateDeviceLayerProperties(gpu, &layer_count, queried_layers.data()); @@ -700,8 +698,8 @@ bool Context::create_device(VkPhysicalDevice gpu_, VkSurfaceKHR surface, const c device_info.pQueueCreateInfos = queue_infos.data(); device_info.queueCreateInfoCount = uint32_t(queue_infos.size()); - vector enabled_extensions; - vector enabled_layers; + std::vector enabled_extensions; + std::vector enabled_layers; for (uint32_t i = 0; i < num_required_device_extensions; i++) enabled_extensions.push_back(required_device_extensions[i]); diff --git a/parallel-rdp-standalone/vulkan/descriptor_set.cpp b/parallel-rdp-standalone/vulkan/descriptor_set.cpp index d3324da..8398dba 100644 --- a/parallel-rdp-standalone/vulkan/descriptor_set.cpp +++ b/parallel-rdp-standalone/vulkan/descriptor_set.cpp @@ -24,7 +24,6 @@ #include "device.hpp" #include -using namespace std; using namespace Util; namespace Vulkan @@ -54,7 +53,7 @@ DescriptorSetAllocator::DescriptorSetAllocator(Hash hash, Device *device_, const VkDescriptorSetLayoutCreateInfo info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; VkDescriptorSetLayoutBindingFlagsCreateInfoEXT flags = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_BINDING_FLAGS_CREATE_INFO_EXT }; VkSampler vk_immutable_samplers[VULKAN_NUM_BINDINGS] = {}; - vector bindings; + std::vector bindings; VkDescriptorBindingFlagsEXT binding_flags = 0; if (bindless) @@ -252,7 +251,7 @@ void DescriptorSetAllocator::begin_frame() } } -pair DescriptorSetAllocator::find(unsigned thread_index, Hash hash) +std::pair DescriptorSetAllocator::find(unsigned thread_index, Hash hash) { VK_ASSERT(!bindless); @@ -288,7 +287,7 @@ pair DescriptorSetAllocator::find(unsigned thread_index, VkDescriptorSet sets[VULKAN_NUM_SETS_PER_POOL]; VkDescriptorSetLayout layouts[VULKAN_NUM_SETS_PER_POOL]; - fill(begin(layouts), end(layouts), set_layout); + std::fill(std::begin(layouts), std::end(layouts), set_layout); VkDescriptorSetAllocateInfo alloc = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; alloc.descriptorPool = pool; diff --git a/parallel-rdp-standalone/vulkan/device.cpp b/parallel-rdp-standalone/vulkan/device.cpp index 533d4bf..33e7684 100644 --- a/parallel-rdp-standalone/vulkan/device.cpp +++ b/parallel-rdp-standalone/vulkan/device.cpp @@ -60,7 +60,6 @@ static unsigned get_thread_index() } #endif -using namespace std; using namespace Util; namespace Vulkan @@ -317,7 +316,7 @@ LinearHostImageHandle Device::create_linear_host_image(const LinearHostImageCrea else gpu_image->set_layout(Layout::General); - return LinearHostImageHandle(handle_pool.linear_images.allocate(this, move(gpu_image), move(cpu_image), info.stages)); + return LinearHostImageHandle(handle_pool.linear_images.allocate(this, std::move(gpu_image), std::move(cpu_image), info.stages)); } void *Device::map_linear_host_image(const LinearHostImage &image, MemoryAccessFlags access) @@ -1117,7 +1116,7 @@ void Device::submit(CommandBufferHandle &cmd, Fence *fence, unsigned semaphore_c cmd->end_debug_channel(); LOCK(); - submit_nolock(move(cmd), fence, semaphore_count, semaphores); + submit_nolock(std::move(cmd), fence, semaphore_count, semaphores); } void Device::submit_discard_nolock(CommandBufferHandle &cmd) @@ -1181,7 +1180,7 @@ void Device::submit_nolock(CommandBufferHandle cmd, Fence *fence, unsigned semap } cmd->end(); - submissions.push_back(move(cmd)); + submissions.push_back(std::move(cmd)); InternalFence signalled_fence; @@ -1972,7 +1971,7 @@ CommandBufferHandle Device::request_secondary_command_buffer_for_thread(unsigned void Device::set_acquire_semaphore(unsigned index, Semaphore acquire) { - wsi.acquire = move(acquire); + wsi.acquire = std::move(acquire); wsi.index = index; wsi.consumed = false; @@ -1985,7 +1984,7 @@ void Device::set_acquire_semaphore(unsigned index, Semaphore acquire) Semaphore Device::consume_release_semaphore() { - auto ret = move(wsi.release); + auto ret = std::move(wsi.release); wsi.release.reset(); return ret; } @@ -2067,12 +2066,12 @@ void Device::init_frame_contexts(unsigned count) for (unsigned i = 0; i < count; i++) { - auto frame = unique_ptr(new PerFrame(this, i)); - per_frame.emplace_back(move(frame)); + auto frame = std::unique_ptr(new PerFrame(this, i)); + per_frame.emplace_back(std::move(frame)); } } -void Device::init_external_swapchain(const vector &swapchain_images) +void Device::init_external_swapchain(const std::vector &swapchain_images) { DRAIN_FRAME_LOCK(); wsi.swapchain.clear(); @@ -2110,7 +2109,7 @@ void Device::set_swapchain_queue_family_support(uint32_t queue_family_support) wsi.queue_family_support_mask = queue_family_support; } -void Device::init_swapchain(const vector &swapchain_images, unsigned width, unsigned height, VkFormat format, +void Device::init_swapchain(const std::vector &swapchain_images, unsigned width, unsigned height, VkFormat format, VkSurfaceTransformFlagBitsKHR transform, VkImageUsageFlags usage) { DRAIN_FRAME_LOCK(); @@ -2173,7 +2172,7 @@ Device::PerFrame::PerFrame(Device *device_, unsigned frame_index_) void Device::keep_handle_alive(ImageHandle handle) { LOCK(); - frame().keep_alive_images.push_back(move(handle)); + frame().keep_alive_images.push_back(std::move(handle)); } void Device::free_memory_nolock(const DeviceAllocation &alloc) @@ -2649,7 +2648,7 @@ void Device::register_time_interval_nolock(std::string tid, QueryPoolHandle star if (start_ts->is_signalled() && end_ts->is_signalled()) VK_ASSERT(end_ts->get_timestamp_ticks() >= start_ts->get_timestamp_ticks()); #endif - frame().timestamp_intervals.push_back({ std::move(tid), move(start_ts), move(end_ts), timestamp_tag, std::move(extra) }); + frame().timestamp_intervals.push_back({ std::move(tid), std::move(start_ts), std::move(end_ts), timestamp_tag, std::move(extra) }); } } @@ -3060,7 +3059,7 @@ public: VkImageView unorm_view = VK_NULL_HANDLE; VkImageView srgb_view = VK_NULL_HANDLE; VkImageViewType default_view_type = VK_IMAGE_VIEW_TYPE_MAX_ENUM; - vector rt_views; + std::vector rt_views; DeviceAllocation allocation; DeviceAllocator *allocator = nullptr; bool owned = true; @@ -3358,7 +3357,7 @@ ImageViewHandle Device::create_image_view(const ImageViewCreateInfo &create_info { holder.owned = false; ret->set_alt_views(holder.depth_view, holder.stencil_view); - ret->set_render_target_views(move(holder.rt_views)); + ret->set_render_target_views(std::move(holder.rt_views)); return ret; } else @@ -3903,7 +3902,7 @@ ImageHandle Device::create_image_from_staging_buffer(const ImageCreateInfo &crea if (has_view) { handle->get_view().set_alt_views(holder.depth_view, holder.stencil_view); - handle->get_view().set_render_target_views(move(holder.rt_views)); + handle->get_view().set_render_target_views(std::move(holder.rt_views)); handle->get_view().set_unorm_view(holder.unorm_view); handle->get_view().set_srgb_view(holder.srgb_view); } @@ -4607,7 +4606,7 @@ uint64_t Device::allocate_cookie() { // Reserve lower bits for "special purposes". #ifdef GRANITE_VULKAN_MT - return cookie.fetch_add(16, memory_order_relaxed) + 16; + return cookie.fetch_add(16, std::memory_order_relaxed) + 16; #else cookie += 16; return cookie; @@ -4777,8 +4776,8 @@ RenderPassInfo Device::get_swapchain_render_pass(SwapchainRenderPass style) void Device::set_queue_lock(std::function lock_callback, std::function unlock_callback) { - queue_lock_callback = move(lock_callback); - queue_unlock_callback = move(unlock_callback); + queue_lock_callback = std::move(lock_callback); + queue_unlock_callback = std::move(unlock_callback); } void Device::set_name(const Buffer &buffer, const char *name) @@ -4832,7 +4831,7 @@ void Device::report_checkpoints() uint32_t count; table->vkGetQueueCheckpointDataNV(queue_info.queues[i], &count, nullptr); - vector checkpoint_data(count); + std::vector checkpoint_data(count); for (auto &data : checkpoint_data) data.sType = VK_STRUCTURE_TYPE_CHECKPOINT_DATA_NV; table->vkGetQueueCheckpointDataNV(queue_info.queues[i], &count, checkpoint_data.data()); diff --git a/parallel-rdp-standalone/vulkan/device_fossilize.cpp b/parallel-rdp-standalone/vulkan/device_fossilize.cpp index a424a46..5d0b9a1 100644 --- a/parallel-rdp-standalone/vulkan/device_fossilize.cpp +++ b/parallel-rdp-standalone/vulkan/device_fossilize.cpp @@ -24,8 +24,6 @@ #include "timer.hpp" #include "thread_group.hpp" -using namespace std; - namespace Vulkan { #if 0 diff --git a/parallel-rdp-standalone/vulkan/image.cpp b/parallel-rdp-standalone/vulkan/image.cpp index f3e4b27..ab96336 100644 --- a/parallel-rdp-standalone/vulkan/image.cpp +++ b/parallel-rdp-standalone/vulkan/image.cpp @@ -24,8 +24,6 @@ #include "device.hpp" #include "buffer.hpp" -using namespace std; - namespace Vulkan { ImageView::ImageView(Device *device_, VkImageView view_, const ImageViewCreateInfo &info_) @@ -207,7 +205,7 @@ VkPipelineStageFlags LinearHostImage::get_used_pipeline_stages() const } LinearHostImage::LinearHostImage(Device *device_, ImageHandle gpu_image_, BufferHandle cpu_image_, VkPipelineStageFlags stages_) - : device(device_), gpu_image(move(gpu_image_)), cpu_image(move(cpu_image_)), stages(stages_) + : device(device_), gpu_image(std::move(gpu_image_)), cpu_image(std::move(cpu_image_)), stages(stages_) { if (gpu_image->get_create_info().domain == ImageDomain::LinearHostCached || gpu_image->get_create_info().domain == ImageDomain::LinearHost) diff --git a/parallel-rdp-standalone/vulkan/memory_allocator.cpp b/parallel-rdp-standalone/vulkan/memory_allocator.cpp index cc08c20..6515738 100644 --- a/parallel-rdp-standalone/vulkan/memory_allocator.cpp +++ b/parallel-rdp-standalone/vulkan/memory_allocator.cpp @@ -31,8 +31,6 @@ #include #endif -using namespace std; - #ifdef GRANITE_VULKAN_MT #define ALLOCATOR_LOCK() std::lock_guard holder__{lock} #else diff --git a/parallel-rdp-standalone/vulkan/query_pool.cpp b/parallel-rdp-standalone/vulkan/query_pool.cpp index 0061eac..de24178 100644 --- a/parallel-rdp-standalone/vulkan/query_pool.cpp +++ b/parallel-rdp-standalone/vulkan/query_pool.cpp @@ -24,8 +24,6 @@ #include "device.hpp" #include -using namespace std; - namespace Vulkan { static const char *storage_to_str(VkPerformanceCounterStorageKHR storage) @@ -382,7 +380,7 @@ void QueryPool::add_pool() if (device->get_device_features().host_query_reset_features.hostQueryReset) table.vkResetQueryPoolEXT(device->get_device(), pool.pool, 0, pool.size); - pools.push_back(move(pool)); + pools.push_back(std::move(pool)); } QueryPoolHandle QueryPool::write_timestamp(VkCommandBuffer cmd, VkPipelineStageFlagBits stage) @@ -460,7 +458,7 @@ double TimestampInterval::get_time_per_accumulation() const return 0.0; } -const string &TimestampInterval::get_tag() const +const std::string &TimestampInterval::get_tag() const { return tag; } @@ -472,8 +470,8 @@ void TimestampInterval::reset() total_frame_iterations = 0; } -TimestampInterval::TimestampInterval(string tag_) - : tag(move(tag_)) +TimestampInterval::TimestampInterval(std::string tag_) + : tag(std::move(tag_)) { } diff --git a/parallel-rdp-standalone/vulkan/render_pass.cpp b/parallel-rdp-standalone/vulkan/render_pass.cpp index 2a012e7..dd137c5 100644 --- a/parallel-rdp-standalone/vulkan/render_pass.cpp +++ b/parallel-rdp-standalone/vulkan/render_pass.cpp @@ -27,7 +27,6 @@ #include #include -using namespace std; using namespace Util; #ifdef GRANITE_VULKAN_MT @@ -121,7 +120,7 @@ RenderPass::RenderPass(Hash hash, Device *device_, const RenderPassInfo &info) : IntrusiveHashMapEnabled(hash) , device(device_) { - fill(begin(color_attachments), end(color_attachments), VK_FORMAT_UNDEFINED); + std::fill(std::begin(color_attachments), std::end(color_attachments), VK_FORMAT_UNDEFINED); VK_ASSERT(info.num_color_attachments || info.depth_stencil); @@ -307,8 +306,8 @@ RenderPass::RenderPass(Hash hash, Device *device_, const RenderPassInfo &info) Util::StackAllocator reference_allocator; Util::StackAllocator preserve_allocator; - vector subpasses(num_subpasses); - vector external_dependencies; + std::vector subpasses(num_subpasses); + std::vector external_dependencies; for (unsigned i = 0; i < num_subpasses; i++) { auto *colors = reference_allocator.allocate_cleared(subpass_infos[i].num_color_attachments); @@ -789,7 +788,7 @@ RenderPass::RenderPass(Hash hash, Device *device_, const RenderPassInfo &info) setup_subpasses(rp_info); VkRenderPassMultiviewCreateInfo multiview_info = { VK_STRUCTURE_TYPE_RENDER_PASS_MULTIVIEW_CREATE_INFO }; - vector multiview_view_mask; + std::vector multiview_view_mask; if (multiview && device->get_device_features().multiview_features.multiview) { multiview_view_mask.resize(num_subpasses); @@ -874,14 +873,14 @@ void Framebuffer::compute_dimensions(const RenderPassInfo &info, uint32_t &width for (unsigned i = 0; i < info.num_color_attachments; i++) { VK_ASSERT(info.color_attachments[i]); - width = min(width, info.color_attachments[i]->get_view_width()); - height = min(height, info.color_attachments[i]->get_view_height()); + width = std::min(width, info.color_attachments[i]->get_view_width()); + height = std::min(height, info.color_attachments[i]->get_view_height()); } if (info.depth_stencil) { - width = min(width, info.depth_stencil->get_view_width()); - height = min(height, info.depth_stencil->get_view_height()); + width = std::min(width, info.depth_stencil->get_view_width()); + height = std::min(height, info.depth_stencil->get_view_height()); } } diff --git a/parallel-rdp-standalone/vulkan/shader.cpp b/parallel-rdp-standalone/vulkan/shader.cpp index 1f792e3..b3052f3 100644 --- a/parallel-rdp-standalone/vulkan/shader.cpp +++ b/parallel-rdp-standalone/vulkan/shader.cpp @@ -27,7 +27,6 @@ using namespace spirv_cross; #endif -using namespace std; using namespace Util; namespace Vulkan diff --git a/parallel-rdp-standalone/vulkan/texture_format.cpp b/parallel-rdp-standalone/vulkan/texture_format.cpp index 95cc255..f5e39e1 100644 --- a/parallel-rdp-standalone/vulkan/texture_format.cpp +++ b/parallel-rdp-standalone/vulkan/texture_format.cpp @@ -24,13 +24,11 @@ #include "format.hpp" #include -using namespace std; - namespace Vulkan { uint32_t TextureFormatLayout::num_miplevels(uint32_t width, uint32_t height, uint32_t depth) { - uint32_t size = unsigned(max(max(width, height), depth)); + uint32_t size = unsigned(std::max(std::max(width, height), depth)); uint32_t levels = 0; while (size) { @@ -379,9 +377,9 @@ void TextureFormatLayout::fill_mipinfo(uint32_t width, uint32_t height, uint32_t offset += mip_size; - width = max((width >> 1u), 1u); - height = max((height >> 1u), 1u); - depth = max((depth >> 1u), 1u); + width = std::max((width >> 1u), 1u); + height = std::max((height >> 1u), 1u); + depth = std::max((depth >> 1u), 1u); } required_size = offset;