From f0fa3c5861f4156402a05775a65bebdc7d1e953c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 10 Apr 2021 19:42:59 +0200 Subject: [PATCH] (slang C++ files) take out using namespace std, explicitly refer to std namespace --- gfx/drivers_shader/shader_gl_core.cpp | 98 ++++++++--------- gfx/drivers_shader/shader_vulkan.cpp | 140 ++++++++++++------------ gfx/drivers_shader/slang_process.cpp | 43 ++++---- gfx/drivers_shader/slang_reflection.cpp | 23 ++-- 4 files changed, 149 insertions(+), 155 deletions(-) diff --git a/gfx/drivers_shader/shader_gl_core.cpp b/gfx/drivers_shader/shader_gl_core.cpp index d4dc68ecc0..97ce3dcbad 100644 --- a/gfx/drivers_shader/shader_gl_core.cpp +++ b/gfx/drivers_shader/shader_gl_core.cpp @@ -37,8 +37,6 @@ #include "../../verbosity.h" #include "../../msg_hash.h" -using namespace std; - GLuint gl_core_cross_compile_program( const uint32_t *vertex, size_t vertex_size, const uint32_t *fragment, size_t fragment_size, @@ -255,7 +253,7 @@ GLuint gl_core_cross_compile_program( glUseProgram(0); } - catch (const exception &e) + catch (const std::exception &e) { RARCH_ERR("[GLCore]: Failed to cross compile program: %s\n", e.what()); if (program != 0) @@ -387,7 +385,7 @@ static GLenum convert_glslang_format(glslang_format fmt) class StaticTexture { public: - StaticTexture(string id, + StaticTexture(std::string id, GLuint image, unsigned width, unsigned height, bool linear, @@ -398,17 +396,17 @@ public: StaticTexture(StaticTexture&&) = delete; void operator=(StaticTexture&&) = delete; - void set_id(string name) { id = move(name); } - const string &get_id() const { return id; } + void set_id(std::string name) { id = std::move(name); } + const std::string &get_id() const { return id; } const Texture &get_texture() const { return texture; } private: - string id; + std::string id; GLuint image; Texture texture; }; -StaticTexture::StaticTexture(string id_, GLuint image_, +StaticTexture::StaticTexture(std::string id_, GLuint image_, unsigned width, unsigned height, bool linear, bool mipmap, glslang_filter_chain_address address) : id(std::move(id_)), image(image_) @@ -464,14 +462,14 @@ struct CommonResources CommonResources(); ~CommonResources(); - vector original_history; - vector framebuffer_feedback; - vector pass_outputs; - vector> luts; + std::vector original_history; + std::vector framebuffer_feedback; + std::vector pass_outputs; + std::vector> luts; - unordered_map texture_semantic_map; - unordered_map texture_semantic_uniform_map; - unique_ptr shader_preset; + std::unordered_map texture_semantic_map; + std::unordered_map texture_semantic_uniform_map; + std::unique_ptr shader_preset; GLuint quad_program = 0; GLuint quad_vbo = 0; @@ -716,7 +714,7 @@ public: pass_name = name; } - const string &get_name() const + const std::string &get_name() const { return pass_name; } @@ -769,10 +767,10 @@ private: gl_core_viewport current_viewport; gl_core_filter_chain_pass_info pass_info; - vector vertex_shader; - vector fragment_shader; - unique_ptr framebuffer; - unique_ptr framebuffer_feedback; + std::vector vertex_shader; + std::vector fragment_shader; + std::unique_ptr framebuffer; + std::unique_ptr framebuffer_feedback; bool init_pipeline(); @@ -811,18 +809,18 @@ private: unsigned pass_number = 0; size_t ubo_offset = 0; - string pass_name; + std::string pass_name; struct Parameter { - string id; + std::string id; unsigned index; unsigned semantic_index; }; - vector parameters; - vector filtered_parameters; - vector push_constant_buffer; + std::vector parameters; + std::vector filtered_parameters; + std::vector push_constant_buffer; gl_core_buffer_locations locations = {}; UBORing ubo_ring; @@ -833,7 +831,7 @@ private: bool Pass::build() { - unordered_map semantic_map; + std::unordered_map semantic_map; unsigned i; unsigned j = 0; @@ -841,7 +839,7 @@ bool Pass::build() framebuffer_feedback.reset(); if (!final_pass) - framebuffer = unique_ptr( + framebuffer = std::unique_ptr( new Framebuffer(pass_info.rt_format, pass_info.max_levels)); for (i = 0; i < parameters.size(); i++) @@ -1310,7 +1308,7 @@ bool Pass::init_feedback() if (final_pass) return false; - framebuffer_feedback = unique_ptr( + framebuffer_feedback = std::unique_ptr( new Framebuffer(pass_info.rt_format, pass_info.max_levels)); return true; } @@ -1597,9 +1595,9 @@ struct gl_core_filter_chain public: gl_core_filter_chain(unsigned num_passes) { set_num_passes(num_passes); } - inline void set_shader_preset(unique_ptr shader) + inline void set_shader_preset(std::unique_ptr shader) { - common.shader_preset = move(shader); + common.shader_preset = std::move(shader); } inline video_shader *get_shader_preset() @@ -1624,14 +1622,14 @@ public: void set_frame_direction(int32_t direction); void set_pass_name(unsigned pass, const char *name); - void add_static_texture(unique_ptr texture); + void add_static_texture(std::unique_ptr texture); void add_parameter(unsigned pass, unsigned parameter_index, const std::string &id); void set_num_passes(unsigned passes); private: - vector> passes; - vector pass_info; - vector>> deferred_calls; + std::vector> passes; + std::vector pass_info; + std::vector>> deferred_calls; std::unique_ptr copy_framebuffer; gl_core_shader::CommonResources common; @@ -1640,7 +1638,7 @@ private: bool init_history(); bool init_feedback(); bool init_alias(); - vector> original_history; + std::vector> original_history; bool require_clear = false; void clear_history_and_feedback(); void update_feedback_info(); @@ -1744,8 +1742,8 @@ void gl_core_filter_chain::end_frame() if (!original_history.empty()) { /* Update history */ - unique_ptr tmp; - unique_ptr &back = original_history.back(); + std::unique_ptr tmp; + std::unique_ptr &back = original_history.back(); swap(back, tmp); if (input_texture.width != tmp->get_size().width || @@ -1831,7 +1829,7 @@ bool gl_core_filter_chain::init_history() for (i = 0; i < passes.size(); i++) required_images = - max(required_images, + std::max(required_images, passes[i]->get_reflection().semantic_textures[ SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY].size()); @@ -1910,7 +1908,7 @@ bool gl_core_filter_chain::init_alias() for (i = 0; i < passes.size(); i++) { - const string name = passes[i]->get_name(); + const std::string name = passes[i]->get_name(); if (name.empty()) continue; @@ -2064,9 +2062,9 @@ void gl_core_filter_chain::set_input_texture( } } -void gl_core_filter_chain::add_static_texture(unique_ptr texture) +void gl_core_filter_chain::add_static_texture(std::unique_ptr texture) { - common.luts.push_back(move(texture)); + common.luts.push_back(std::move(texture)); } void gl_core_filter_chain::set_frame_count(uint64_t count) @@ -2093,7 +2091,7 @@ void gl_core_filter_chain::set_pass_name(unsigned pass, const char *name) passes[pass]->set_name(name); } -static unique_ptr gl_core_filter_chain_load_lut( +static std::unique_ptr gl_core_filter_chain_load_lut( gl_core_filter_chain *chain, const video_shader_lut *shader) { @@ -2129,7 +2127,7 @@ static unique_ptr gl_core_filter_chain_load_lut( if (image.pixels) image_texture_free(&image); - return unique_ptr(new gl_core_shader::StaticTexture(shader->id, + return std::unique_ptr(new gl_core_shader::StaticTexture(shader->id, tex, image.width, image.height, shader->filter != RARCH_FILTER_NEAREST, levels > 1, @@ -2143,14 +2141,14 @@ static bool gl_core_filter_chain_load_luts( unsigned i; for (i = 0; i < shader->luts; i++) { - unique_ptr image = gl_core_filter_chain_load_lut(chain, &shader->lut[i]); + std::unique_ptr image = gl_core_filter_chain_load_lut(chain, &shader->lut[i]); if (!image) { RARCH_ERR("[GLCore]: Failed to load LUT \"%s\".\n", shader->lut[i].path); return false; } - chain->add_static_texture(move(image)); + chain->add_static_texture(std::move(image)); } return true; @@ -2161,7 +2159,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_default( { struct gl_core_filter_chain_pass_info pass_info; - unique_ptr chain{ new gl_core_filter_chain(1) }; + std::unique_ptr chain{ new gl_core_filter_chain(1) }; if (!chain) return nullptr; @@ -2194,7 +2192,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset( const char *path, glslang_filter_chain_filter filter) { unsigned i; - unique_ptr shader{ new video_shader() }; + std::unique_ptr shader{ new video_shader() }; if (!shader) return nullptr; @@ -2203,7 +2201,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset( bool last_pass_is_fbo = shader->pass[shader->passes - 1].fbo.valid; - unique_ptr chain{ new gl_core_filter_chain(shader->passes + (last_pass_is_fbo ? 1 : 0)) }; + std::unique_ptr chain{ new gl_core_filter_chain(shader->passes + (last_pass_is_fbo ? 1 : 0)) }; if (!chain) return nullptr; @@ -2246,7 +2244,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset( return nullptr; } - auto itr = find_if(shader->parameters, shader->parameters + shader->num_parameters, + auto itr = std::find_if(shader->parameters, shader->parameters + shader->num_parameters, [&](const video_shader_parameter ¶m) { return meta_param.id == param.id; @@ -2444,7 +2442,7 @@ gl_core_filter_chain_t *gl_core_filter_chain_create_from_preset( sizeof(gl_core_shader::opaque_frag) / sizeof(uint32_t)); } - chain->set_shader_preset(move(shader)); + chain->set_shader_preset(std::move(shader)); if (!chain->init()) return nullptr; diff --git a/gfx/drivers_shader/shader_vulkan.cpp b/gfx/drivers_shader/shader_vulkan.cpp index d5e40210ba..0a4e5cc8e2 100644 --- a/gfx/drivers_shader/shader_vulkan.cpp +++ b/gfx/drivers_shader/shader_vulkan.cpp @@ -35,8 +35,6 @@ #include "../../verbosity.h" #include "../../msg_hash.h" -using namespace std; - static const uint32_t opaque_vert[] = #include "../drivers/vulkan_shaders/opaque.vert.inc" ; @@ -56,15 +54,15 @@ struct Texture class DeferredDisposer { public: - DeferredDisposer(vector> &calls) : calls(calls) {} + DeferredDisposer(std::vector> &calls) : calls(calls) {} - void defer(function func) + void defer(std::function func) { - calls.push_back(move(func)); + calls.push_back(std::move(func)); } private: - vector> &calls; + std::vector> &calls; }; class Buffer @@ -95,12 +93,12 @@ class Buffer class StaticTexture { public: - StaticTexture(string id, + StaticTexture(std::string id, VkDevice device, VkImage image, VkImageView view, VkDeviceMemory memory, - unique_ptr buffer, + std::unique_ptr buffer, unsigned width, unsigned height, bool linear, bool mipmap, @@ -111,8 +109,8 @@ class StaticTexture void operator=(StaticTexture&&) = delete; void release_staging_buffer() { buffer.reset(); } - void set_id(string name) { id = move(name); } - const string &get_id() const { return id; } + void set_id(std::string name) { id = std::move(name); } + const std::string &get_id() const { return id; } const Texture &get_texture() const { return texture; } private: @@ -120,8 +118,8 @@ class StaticTexture VkImage image; VkImageView view; VkDeviceMemory memory; - unique_ptr buffer; - string id; + std::unique_ptr buffer; + std::string id; Texture texture; }; @@ -177,8 +175,8 @@ struct CommonResources const VkPhysicalDeviceMemoryProperties &memory_properties); ~CommonResources(); - unique_ptr vbo; - unique_ptr ubo; + std::unique_ptr vbo; + std::unique_ptr ubo; uint8_t *ubo_mapped = nullptr; size_t ubo_sync_index_stride = 0; size_t ubo_offset = 0; @@ -186,14 +184,14 @@ struct CommonResources VkSampler samplers[GLSLANG_FILTER_CHAIN_COUNT][GLSLANG_FILTER_CHAIN_COUNT][GLSLANG_FILTER_CHAIN_ADDRESS_COUNT]; - vector original_history; - vector fb_feedback; - vector pass_outputs; - vector> luts; + std::vector original_history; + std::vector fb_feedback; + std::vector pass_outputs; + std::vector> luts; - unordered_map texture_semantic_map; - unordered_map texture_semantic_uniform_map; - unique_ptr shader_preset; + std::unordered_map texture_semantic_map; + std::unordered_map texture_semantic_uniform_map; + std::unique_ptr shader_preset; VkDevice device; }; @@ -245,7 +243,7 @@ class Pass void set_frame_count_period(unsigned p) { frame_count_period = p; } void set_frame_direction(int32_t dir) { frame_direction = dir; } void set_name(const char *name) { pass_name = name; } - const string &get_name() const { return pass_name; } + const std::string &get_name() const { return pass_name; } glslang_filter_chain_filter get_source_filter() const { return pass_info.source_filter; } @@ -284,17 +282,17 @@ class Pass VkDescriptorSetLayout set_layout = VK_NULL_HANDLE; VkDescriptorPool pool = VK_NULL_HANDLE; - vector sets; + std::vector sets; CommonResources *common = nullptr; Size2D current_framebuffer_size; VkViewport current_viewport; vulkan_filter_chain_pass_info pass_info; - vector vertex_shader; - vector fragment_shader; - unique_ptr framebuffer; - unique_ptr fb_feedback; + std::vector vertex_shader; + std::vector fragment_shader; + std::unique_ptr framebuffer; + std::unique_ptr fb_feedback; VkRenderPass swapchain_render_pass; void clear_vk(); @@ -333,22 +331,22 @@ class Pass unsigned pass_number = 0; size_t ubo_offset = 0; - string pass_name; + std::string pass_name; struct Parameter { - string id; + std::string id; unsigned index; unsigned semantic_index; }; - vector parameters; - vector filtered_parameters; + std::vector parameters; + std::vector filtered_parameters; struct PushConstant { VkShaderStageFlags stages = 0; - vector buffer; /* uint32_t to have correct alignment. */ + std::vector buffer; /* uint32_t to have correct alignment. */ }; PushConstant push; }; @@ -360,9 +358,9 @@ struct vulkan_filter_chain vulkan_filter_chain(const vulkan_filter_chain_create_info &info); ~vulkan_filter_chain(); - inline void set_shader_preset(unique_ptr shader) + inline void set_shader_preset(std::unique_ptr shader) { - common.shader_preset = move(shader); + common.shader_preset = std::move(shader); } inline video_shader *get_shader_preset() @@ -391,7 +389,7 @@ struct vulkan_filter_chain void set_frame_direction(int32_t direction); void set_pass_name(unsigned pass, const char *name); - void add_static_texture(unique_ptr texture); + void add_static_texture(std::unique_ptr texture); void add_parameter(unsigned pass, unsigned parameter_index, const std::string &id); void release_staging_buffers(); @@ -400,9 +398,9 @@ struct vulkan_filter_chain VkPhysicalDevice gpu; const VkPhysicalDeviceMemoryProperties &memory_properties; VkPipelineCache cache; - vector> passes; - vector pass_info; - vector>> deferred_calls; + std::vector> passes; + std::vector pass_info; + std::vector>> deferred_calls; CommonResources common; VkFormat original_format; @@ -424,7 +422,7 @@ struct vulkan_filter_chain bool init_feedback(); bool init_alias(); void update_history(DeferredDisposer &disposer, VkCommandBuffer cmd); - vector> original_history; + std::vector> original_history; bool require_clear = false; void clear_history_and_feedback(VkCommandBuffer cmd); void update_feedback_info(); @@ -512,7 +510,7 @@ static VkFormat glslang_format_to_vk(glslang_format fmt) return VK_FORMAT_UNDEFINED; } -static unique_ptr vulkan_filter_chain_load_lut( +static std::unique_ptr vulkan_filter_chain_load_lut( VkCommandBuffer cmd, const struct vulkan_filter_chain_create_info *info, vulkan_filter_chain *chain, @@ -520,7 +518,7 @@ static unique_ptr vulkan_filter_chain_load_lut( { unsigned i; texture_image image; - unique_ptr buffer; + std::unique_ptr buffer; VkMemoryRequirements mem_reqs; VkImageCreateInfo image_info = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; VkImageViewCreateInfo view_info = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; @@ -581,7 +579,7 @@ static unique_ptr vulkan_filter_chain_load_lut( vkCreateImageView(info->device, &view_info, nullptr, &view); buffer = - unique_ptr(new Buffer(info->device, *info->memory_properties, + std::unique_ptr(new Buffer(info->device, *info->memory_properties, image.width * image.height * sizeof(uint32_t), VK_BUFFER_USAGE_TRANSFER_SRC_BIT)); ptr = buffer->map(); memcpy(ptr, image.pixels, image.width * image.height * sizeof(uint32_t)); @@ -682,8 +680,8 @@ static unique_ptr vulkan_filter_chain_load_lut( image_texture_free(&image); image.pixels = nullptr; - return unique_ptr(new StaticTexture(shader->id, info->device, - tex, view, memory, move(buffer), image.width, image.height, + return std::unique_ptr(new StaticTexture(shader->id, info->device, + tex, view, memory, std::move(buffer), image.width, image.height, shader->filter != RARCH_FILTER_NEAREST, image_info.mipLevels > 1, rarch_wrap_to_address(shader->wrap))); @@ -726,7 +724,7 @@ static bool vulkan_filter_chain_load_luts( for (i = 0; i < shader->luts; i++) { - unique_ptr image = + std::unique_ptr image = vulkan_filter_chain_load_lut(cmd, info, chain, &shader->lut[i]); if (!image) { @@ -734,7 +732,7 @@ static bool vulkan_filter_chain_load_luts( goto error; } - chain->add_static_texture(move(image)); + chain->add_static_texture(std::move(image)); } vkEndCommandBuffer(cmd); @@ -931,7 +929,7 @@ void vulkan_filter_chain::build_offscreen_passes(VkCommandBuffer cmd, void vulkan_filter_chain::update_history(DeferredDisposer &disposer, VkCommandBuffer cmd) { - unique_ptr tmp; + std::unique_ptr tmp; VkImageLayout src_layout = input_texture.layout; /* Transition input texture to something appropriate. */ @@ -951,7 +949,7 @@ void vulkan_filter_chain::update_history(DeferredDisposer &disposer, src_layout = VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL; } - unique_ptr &back = original_history.back(); + std::unique_ptr &back = original_history.back(); swap(back, tmp); if (input_texture.width != tmp->get_size().width || @@ -1057,7 +1055,7 @@ bool vulkan_filter_chain::init_history() for (i = 0; i < passes.size(); i++) required_images = - max(required_images, + std::max(required_images, passes[i]->get_reflection().semantic_textures[ SLANG_TEXTURE_SEMANTIC_ORIGINAL_HISTORY].size()); @@ -1144,7 +1142,7 @@ bool vulkan_filter_chain::init_alias() for (i = 0; i < passes.size(); i++) { - const string name = passes[i]->get_name(); + const std::string name = passes[i]->get_name(); if (name.empty()) continue; @@ -1251,7 +1249,7 @@ bool vulkan_filter_chain::init_ubo() common.ubo_sync_index_stride = common.ubo_offset; if (common.ubo_offset != 0) - common.ubo = unique_ptr(new Buffer(device, + common.ubo = std::unique_ptr(new Buffer(device, memory_properties, common.ubo_offset * deferred_calls.size(), VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT)); @@ -1269,7 +1267,7 @@ bool vulkan_filter_chain::init() for (i = 0; i < passes.size(); i++) { - const string name = passes[i]->get_name(); + const std::string name = passes[i]->get_name(); #ifdef VULKAN_DEBUG RARCH_LOG("[slang]: Building pass #%u (%s)\n", i, name.empty() ? @@ -1314,9 +1312,9 @@ void vulkan_filter_chain::set_input_texture( } void vulkan_filter_chain::add_static_texture( - unique_ptr texture) + std::unique_ptr texture) { - common.luts.push_back(move(texture)); + common.luts.push_back(std::move(texture)); } void vulkan_filter_chain::set_frame_count(uint64_t count) @@ -1344,12 +1342,12 @@ void vulkan_filter_chain::set_pass_name(unsigned pass, const char *name) passes[pass]->set_name(name); } -StaticTexture::StaticTexture(string id, +StaticTexture::StaticTexture(std::string id, VkDevice device, VkImage image, VkImageView view, VkDeviceMemory memory, - unique_ptr buffer, + std::unique_ptr buffer, unsigned width, unsigned height, bool linear, bool mipmap, @@ -1358,8 +1356,8 @@ StaticTexture::StaticTexture(string id, image(image), view(view), memory(memory), - buffer(move(buffer)), - id(move(id)) + buffer(std::move(buffer)), + id(std::move(id)) { texture.filter = GLSLANG_FILTER_CHAIN_NEAREST; texture.mip_filter = GLSLANG_FILTER_CHAIN_NEAREST; @@ -1561,8 +1559,8 @@ void Pass::clear_vk() bool Pass::init_pipeline_layout() { unsigned i; - vector bindings; - vector desc_counts; + std::vector bindings; + std::vector desc_counts; VkPushConstantRange push_range = {}; VkDescriptorSetLayoutCreateInfo set_layout_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; @@ -1821,7 +1819,7 @@ CommonResources::CommonResources(VkDevice device, }; vbo = - unique_ptr(new Buffer(device, + std::unique_ptr(new Buffer(device, memory_properties, sizeof(vbo_data), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT)); void *ptr = vbo->map(); @@ -1947,7 +1945,7 @@ bool Pass::init_feedback() if (final_pass) return false; - fb_feedback = unique_ptr( + fb_feedback = std::unique_ptr( new Framebuffer(device, memory_properties, current_framebuffer_size, pass_info.rt_format, pass_info.max_levels)); @@ -1958,13 +1956,13 @@ bool Pass::build() { unsigned i; unsigned j = 0; - unordered_map semantic_map; + std::unordered_map semantic_map; framebuffer.reset(); fb_feedback.reset(); if (!final_pass) - framebuffer = unique_ptr( + framebuffer = std::unique_ptr( new Framebuffer(device, memory_properties, current_framebuffer_size, pass_info.rt_format, pass_info.max_levels)); @@ -2374,7 +2372,7 @@ Framebuffer::Framebuffer( unsigned max_levels) : size(max_size), format(format), - max_levels(max(max_levels, 1u)), + max_levels(std::max(max_levels, 1u)), memory_properties(mem_props), device(device) { @@ -2397,7 +2395,7 @@ void Framebuffer::init(DeferredDisposer *disposer) info.extent.width = size.width; info.extent.height = size.height; info.extent.depth = 1; - info.mipLevels = min(max_levels, + info.mipLevels = std::min(max_levels, glslang_num_miplevels(size.width, size.height)); info.arrayLayers = 1; info.samples = VK_SAMPLE_COUNT_1_BIT; @@ -2543,7 +2541,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_default( tmpinfo.num_passes = 1; - unique_ptr chain{ new vulkan_filter_chain(tmpinfo) }; + std::unique_ptr chain{ new vulkan_filter_chain(tmpinfo) }; if (!chain) return nullptr; @@ -2577,7 +2575,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset( const char *path, glslang_filter_chain_filter filter) { unsigned i; - unique_ptr shader{ new video_shader() }; + std::unique_ptr shader{ new video_shader() }; if (!shader) return nullptr; @@ -2589,7 +2587,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset( auto tmpinfo = *info; tmpinfo.num_passes = shader->passes + (last_pass_is_fbo ? 1 : 0); - unique_ptr chain{ new vulkan_filter_chain(tmpinfo) }; + std::unique_ptr chain{ new vulkan_filter_chain(tmpinfo) }; if (!chain) goto error; @@ -2631,7 +2629,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset( goto error; } - auto itr = find_if(shader->parameters, shader->parameters + shader->num_parameters, + auto itr = std::find_if(shader->parameters, shader->parameters + shader->num_parameters, [&](const video_shader_parameter ¶m) { return meta_param.id == param.id; @@ -2825,7 +2823,7 @@ vulkan_filter_chain_t *vulkan_filter_chain_create_from_preset( sizeof(opaque_frag) / sizeof(uint32_t)); } - chain->set_shader_preset(move(shader)); + chain->set_shader_preset(std::move(shader)); if (!chain->init()) goto error; diff --git a/gfx/drivers_shader/slang_process.cpp b/gfx/drivers_shader/slang_process.cpp index 508955f9e4..5c8b7bad8b 100644 --- a/gfx/drivers_shader/slang_process.cpp +++ b/gfx/drivers_shader/slang_process.cpp @@ -34,10 +34,9 @@ #ifdef HAVE_SPIRV_CROSS using namespace spirv_cross; #endif -using namespace std; template -static string get_semantic_name(const unordered_map* map, +static std::string get_semantic_name(const std::unordered_map* map, S semantic, unsigned index) { for (const auto& m : *map) @@ -45,10 +44,10 @@ static string get_semantic_name(const unordered_map* map, if (m.second.semantic == semantic && m.second.index == index) return m.first; } - return string(); + return std::string(); } -static string +static std::string get_semantic_name(slang_reflection& reflection, slang_semantic semantic, unsigned index) { @@ -66,7 +65,7 @@ get_semantic_name(slang_reflection& reflection, return get_semantic_name(reflection.semantic_map, semantic, index); } -static string +static std::string get_semantic_name(slang_reflection& reflection, slang_texture_semantic semantic, unsigned index) { @@ -78,12 +77,12 @@ get_semantic_name(slang_reflection& reflection, return std::string(names[semantic]); size = sizeof(names) / sizeof(*names); if ((int)semantic < size) - return std::string(names[semantic]) + to_string(index); + return std::string(names[semantic]) + std::to_string(index); return get_semantic_name(reflection.texture_semantic_map, semantic, index); } -static string get_size_semantic_name( +static std::string get_size_semantic_name( slang_reflection& reflection, slang_texture_semantic semantic, unsigned index) { @@ -95,7 +94,7 @@ static string get_size_semantic_name( return std::string(names[semantic]); size = sizeof(names) / sizeof(*names); if ((int)semantic < size) - return std::string(names[semantic]) + to_string(index); + return std::string(names[semantic]) + std::to_string(index); return get_semantic_name(reflection.texture_semantic_uniform_map, semantic, index); } @@ -112,17 +111,17 @@ static bool slang_process_reflection( { int semantic; unsigned i; - vector textures; - vector uniforms[SLANG_CBUFFER_MAX]; - unordered_map texture_semantic_map; - unordered_map texture_semantic_uniform_map; + std::vector textures; + std::vector uniforms[SLANG_CBUFFER_MAX]; + std::unordered_map texture_semantic_map; + std::unordered_map texture_semantic_uniform_map; for (i = 0; i <= pass_number; i++) { if (!*shader_info->pass[i].alias) continue; - string name = shader_info->pass[i].alias; + std::string name = shader_info->pass[i].alias; if (!slang_set_unique_map( texture_semantic_map, name, @@ -159,13 +158,13 @@ static bool slang_process_reflection( if (!slang_set_unique_map( texture_semantic_uniform_map, - string(shader_info->lut[i].id) + "Size", + std::string(shader_info->lut[i].id) + "Size", slang_texture_semantic_map{ SLANG_TEXTURE_SEMANTIC_USER, i })) return false; } - unordered_map uniform_semantic_map; + std::unordered_map uniform_semantic_map; for (i = 0; i < shader_info->num_parameters; i++) { @@ -205,7 +204,7 @@ static bool slang_process_reflection( uniform_sem_t uniform = { map->uniforms[semantic], src.num_components * (unsigned)sizeof(float) }; - string uniform_id = get_semantic_name( + std::string uniform_id = get_semantic_name( sl_reflection, (slang_semantic)semantic, 0); strlcpy(uniform.id, uniform_id.c_str(), sizeof(uniform.id)); @@ -232,7 +231,7 @@ static bool slang_process_reflection( uniform_sem_t uniform = { &shader_info->parameters[i].current, sizeof(float) }; - string uniform_id = get_semantic_name( + std::string uniform_id = get_semantic_name( sl_reflection, SLANG_SEMANTIC_FLOAT_PARAMETER, i); strlcpy(uniform.id, uniform_id.c_str(), sizeof(uniform.id)); @@ -262,7 +261,7 @@ static bool slang_process_reflection( if (src.stage_mask) { texture_sem_t texture; - string id = get_semantic_name( + std::string id = get_semantic_name( sl_reflection, (slang_texture_semantic)semantic, index); texture.texture_data = (void*)((uintptr_t)map->textures[semantic].image + index * map->textures[semantic].image_stride); @@ -301,7 +300,7 @@ static bool slang_process_reflection( 4 * sizeof(float) }; - string uniform_id = + std::string uniform_id = get_size_semantic_name( sl_reflection, (slang_texture_semantic)semantic, index); @@ -362,7 +361,7 @@ bool slang_preprocess_parse_parameters(glslang_meta& meta, { bool mismatch_dup = false; bool dup = false; - auto itr = find_if(shader->parameters, + auto itr = std::find_if(shader->parameters, shader->parameters + shader->num_parameters, [&](const video_shader_parameter &parsed_param) { @@ -478,8 +477,8 @@ bool slang_process( { ShaderResources vs_resources; ShaderResources ps_resources; - string vs_code; - string ps_code; + std::string vs_code; + std::string ps_code; switch (dst_type) { diff --git a/gfx/drivers_shader/slang_reflection.cpp b/gfx/drivers_shader/slang_reflection.cpp index 7e6179f512..7a226cfdb2 100644 --- a/gfx/drivers_shader/slang_reflection.cpp +++ b/gfx/drivers_shader/slang_reflection.cpp @@ -23,7 +23,6 @@ #include "glslang_util.h" #include "../../verbosity.h" -using namespace std; using namespace spirv_cross; static const char *texture_semantic_names[] = { @@ -55,8 +54,8 @@ static const char *semantic_uniform_names[] = { }; static slang_texture_semantic slang_name_to_texture_semantic( - const unordered_map &semantic_map, - const string &name, unsigned *index) + const std::unordered_map &semantic_map, + const std::string &name, unsigned *index) { auto itr = semantic_map.find(name); if (itr != end(semantic_map)) @@ -70,8 +69,8 @@ static slang_texture_semantic slang_name_to_texture_semantic( } static slang_texture_semantic slang_uniform_name_to_texture_semantic( - const unordered_map &semantic_map, - const string &name, unsigned *index) + const std::unordered_map &semantic_map, + const std::string &name, unsigned *index) { auto itr = semantic_map.find(name); if (itr != end(semantic_map)) @@ -85,8 +84,8 @@ static slang_texture_semantic slang_uniform_name_to_texture_semantic( } static slang_semantic slang_uniform_name_to_semantic( - const unordered_map &semantic_map, - const string &name, unsigned *index) + const std::unordered_map &semantic_map, + const std::string &name, unsigned *index) { unsigned i = 0; auto itr = semantic_map.find(name); @@ -277,7 +276,7 @@ static bool add_active_buffer_ranges( { unsigned sem_index = 0; unsigned tex_sem_index = 0; - const string &name = compiler.get_member_name( + const std::string &name = compiler.get_member_name( resource.base_type_id, ranges[i].index); const SPIRType &type = compiler.get_type( compiler.get_type(resource.base_type_id).member_types[ @@ -495,7 +494,7 @@ bool slang_reflect( if (vertex_ubo) { reflection->ubo_stage_mask |= SLANG_STAGE_VERTEX_MASK; - reflection->ubo_size = max(reflection->ubo_size, + reflection->ubo_size = std::max(reflection->ubo_size, vertex_compiler.get_declared_struct_size( vertex_compiler.get_type( vertex.uniform_buffers[0].base_type_id))); @@ -504,7 +503,7 @@ bool slang_reflect( if (fragment_ubo) { reflection->ubo_stage_mask |= SLANG_STAGE_FRAGMENT_MASK; - reflection->ubo_size = max(reflection->ubo_size, + reflection->ubo_size = std::max(reflection->ubo_size, fragment_compiler.get_declared_struct_size( fragment_compiler.get_type( fragment.uniform_buffers[0].base_type_id))); @@ -513,7 +512,7 @@ bool slang_reflect( if (vertex_push) { reflection->push_constant_stage_mask |= SLANG_STAGE_VERTEX_MASK; - reflection->push_constant_size = max( + reflection->push_constant_size = std::max( reflection->push_constant_size, vertex_compiler.get_declared_struct_size( vertex_compiler.get_type( @@ -523,7 +522,7 @@ bool slang_reflect( if (fragment_push) { reflection->push_constant_stage_mask |= SLANG_STAGE_FRAGMENT_MASK; - reflection->push_constant_size = max( + reflection->push_constant_size = std::max( reflection->push_constant_size, fragment_compiler.get_declared_struct_size( fragment_compiler.get_type(