Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc tiny changes #6046

Merged
merged 7 commits into from Jun 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion Utilities/Log.cpp
Expand Up @@ -640,7 +640,7 @@ void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::st
const u64 frac = (stamp % 1'000'000);
fmt::append(text, "%u:%02u:%02u.%06u ", hours, mins, secs, frac);

if (prefix.size() > 0)
if (!prefix.empty())
{
text += "{";
text += prefix;
Expand Down
2 changes: 1 addition & 1 deletion Utilities/Log.h
Expand Up @@ -110,7 +110,7 @@ namespace logs
void set_level(const std::string&, level);
}

#define LOG_CHANNEL(ch, ...) ::logs::channel ch(#ch, ##__VA_ARGS__);
#define LOG_CHANNEL(ch, ...) ::logs::channel ch(#ch, ##__VA_ARGS__)

// Legacy:

Expand Down
4 changes: 2 additions & 2 deletions Utilities/address_range.h
Expand Up @@ -572,7 +572,7 @@ namespace utils
return vec.overlaps(*this);
}

}; // namespace utils
} // namespace utils


namespace std {
Expand All @@ -587,4 +587,4 @@ namespace std {
return (size_t{ k.start } << 32) | size_t{ k.end };
}
};
};
}
2 changes: 1 addition & 1 deletion rpcs3/Crypto/unpkg.cpp
Expand Up @@ -201,7 +201,7 @@ bool pkg_install(const std::string& path, atomic_t<double>& sync)
bool was_null = true;

// Get full path and create the directory
const std::string dir = Emu.GetHddDir() + "game/" + install_id + '/';
const std::string dir = Emulator::GetHddDir() + "game/" + install_id + '/';

if (!fs::create_dir(dir))
{
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/Modules/cellMouse.cpp
Expand Up @@ -173,7 +173,7 @@ s32 cellMouseGetData(u32 port_no, vm::ptr<CellMouseData> data)

MouseDataList& data_list = handler->GetDataList(port_no);

if (data_list.size() == 0)
if (data_list.empty())
{
*data = {};
return CELL_OK;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Cell/Modules/sys_mempool.cpp
Expand Up @@ -184,7 +184,7 @@ vm::ptr<void> sys_mempool_allocate_block(ppu_thread& ppu, sys_mempool_t mempool)
}
sys_mutex_lock(ppu, memory_pool->mutexid, 0);

while (memory_pool->free_blocks.size() == 0) // while is to guard against spurious wakeups
while (memory_pool->free_blocks.empty()) // while is to guard against spurious wakeups
{
sys_cond_wait(ppu, memory_pool->condid, 0);
memory_pool = idm::get<memory_pool_t>(mempool);
Expand All @@ -206,7 +206,7 @@ vm::ptr<void> sys_mempool_try_allocate_block(ppu_thread& ppu, sys_mempool_t memp

auto memory_pool = idm::get<memory_pool_t>(mempool);

if (!memory_pool || memory_pool->free_blocks.size() == 0)
if (!memory_pool || memory_pool->free_blocks.empty())
{
return vm::null;
}
Expand Down
20 changes: 10 additions & 10 deletions rpcs3/Emu/Cell/PPUTranslator.h
Expand Up @@ -65,16 +65,16 @@ class PPUTranslator final : public cpu_translator
llvm::Value*& loc = m_locals[pos];\
llvm::Value*& glb = m_globals[pos];

DEF_VALUE(m_lr, m_g_lr, 163); // LR, Link Register
DEF_VALUE(m_ctr, m_g_ctr, 164); // CTR, Counter Register
DEF_VALUE(m_vrsave, m_g_vrsave, 165);
DEF_VALUE(m_cia, m_g_cia, 166);
DEF_VALUE(m_so, m_g_so, 167); // XER.SO bit, summary overflow
DEF_VALUE(m_ov, m_g_ov, 168); // XER.OV bit, overflow flag
DEF_VALUE(m_ca, m_g_ca, 169); // XER.CA bit, carry flag
DEF_VALUE(m_cnt, m_g_cnt, 170); // XER.CNT
DEF_VALUE(m_sat, m_g_sat, 171); // VSCR.SAT bit, sticky saturation flag
DEF_VALUE(m_nj, m_g_nj, 172); // VSCR.NJ bit, non-Java mode
DEF_VALUE(m_lr, m_g_lr, 163) // LR, Link Register
DEF_VALUE(m_ctr, m_g_ctr, 164) // CTR, Counter Register
DEF_VALUE(m_vrsave, m_g_vrsave, 165)
DEF_VALUE(m_cia, m_g_cia, 166)
DEF_VALUE(m_so, m_g_so, 167) // XER.SO bit, summary overflow
DEF_VALUE(m_ov, m_g_ov, 168) // XER.OV bit, overflow flag
DEF_VALUE(m_ca, m_g_ca, 169) // XER.CA bit, carry flag
DEF_VALUE(m_cnt, m_g_cnt, 170) // XER.CNT
DEF_VALUE(m_sat, m_g_sat, 171) // VSCR.SAT bit, sticky saturation flag
DEF_VALUE(m_nj, m_g_nj, 172) // VSCR.NJ bit, non-Java mode

#undef DEF_VALUE
public:
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/Cell/SPUThread.cpp
Expand Up @@ -62,7 +62,7 @@ static FORCE_INLINE void mov_rdata(u128* const dst, const u128* const src)
dst[6] = data0;
dst[7] = data1;
}
};
}

extern u64 get_timebased_time();
extern u64 get_system_time();
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Cell/lv2/sys_tty.cpp
Expand Up @@ -39,13 +39,13 @@ error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadle
{
std::lock_guard lock(g_tty_mutex);

if (g_tty_input[ch].size() > 0)
if (!g_tty_input[ch].empty())
{
// reference to our first queue element
std::string& input = g_tty_input[ch].front();

// we have to stop reading at either a new line, the param len, or our input string size
size_t new_line_pos = input.find_first_of("\n");
size_t new_line_pos = input.find_first_of('\n');

if (new_line_pos != input.npos)
{
Expand All @@ -62,7 +62,7 @@ error_code sys_tty_read(s32 ch, vm::ptr<char> buf, u32 len, vm::ptr<u32> preadle
// remove the just read text from the input string
input = input.substr(chars_to_read, input.size() - 1);

if (input.size() == 0)
if (input.empty())
{
// pop the first queue element if it was completely consumed
g_tty_input[ch].pop_front();
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/Io/PadHandler.cpp
Expand Up @@ -275,16 +275,16 @@ std::string PadHandlerBase::get_config_dir(pad_handler type, const std::string&
{
if (!title_id.empty())
{
return Emu.GetCustomInputConfigDir(title_id) + fmt::format("%s", type) + "/";
return Emulator::GetCustomInputConfigDir(title_id) + fmt::format("%s", type) + "/";
}
return fs::get_config_dir() + "/InputConfigs/" + fmt::format("%s", type) + "/";
}

std::string PadHandlerBase::get_config_filename(int i, const std::string& title_id)
{
if (!title_id.empty() && fs::is_file(Emu.GetCustomInputConfigPath(title_id)))
if (!title_id.empty() && fs::is_file(Emulator::GetCustomInputConfigPath(title_id)))
{
const std::string path = Emu.GetCustomInputConfigDir(title_id) + g_cfg_input.player[i]->handler.to_string() + "/" + g_cfg_input.player[i]->profile.to_string() + ".yml";
const std::string path = Emulator::GetCustomInputConfigDir(title_id) + g_cfg_input.player[i]->handler.to_string() + "/" + g_cfg_input.player[i]->profile.to_string() + ".yml";
if (fs::is_file(path))
{
return path;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/Io/PadHandler.h
Expand Up @@ -286,7 +286,7 @@ struct cfg_input final : cfg::node

bool load(const std::string& title_id = "")
{
cfg_name = Emu.GetCustomInputConfigPath(title_id);
cfg_name = Emulator::GetCustomInputConfigPath(title_id);

if (!fs::is_file(cfg_name))
{
Expand All @@ -308,7 +308,7 @@ struct cfg_input final : cfg::node
}
else
{
cfg_name = Emu.GetCustomInputConfigPath(title_id);
cfg_name = Emulator::GetCustomInputConfigPath(title_id);
}
fs::file(cfg_name, fs::rewrite).write(to_string());
}
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Capture/rsx_capture.cpp
Expand Up @@ -15,7 +15,7 @@ namespace rsx
{
void insert_mem_block_in_map(std::unordered_set<u64>& mem_changes, frame_capture_data::memory_block&& block, frame_capture_data::memory_block_data&& data)
{
if (data.data.size() > 0)
if (!data.data.empty())
{
u64 data_hash = XXH64(data.data.data(), data.data.size(), 0);
block.data_state = data_hash;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/Capture/rsx_replay.cpp
Expand Up @@ -65,7 +65,7 @@ namespace rsx
u32 currentOffset = 0x10000000;
for (const auto& rc : frame->replay_commands)
{
bool hasState = (rc.memory_state.size() > 0) || (rc.display_buffer_state != 0) || (rc.tile_state != 0);
bool hasState = (!rc.memory_state.empty()) || (rc.display_buffer_state != 0) || (rc.tile_state != 0);
if (hasState)
{
if (count != 0)
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace rsx
break;

// Loop and hunt down our next state change that needs to be done
if (!((replay_cmd.memory_state.size() > 0) || (replay_cmd.display_buffer_state != 0) || (replay_cmd.tile_state != 0)))
if (!(!replay_cmd.memory_state.empty() || (replay_cmd.display_buffer_state != 0) || (replay_cmd.tile_state != 0)))
continue;

// wait until rsx idle and at our first 'stop' to apply state
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/ProgramStateCache.h
Expand Up @@ -304,7 +304,7 @@ class program_state_cache

bool is_empty() const
{
return db.size() == 0;
return db.empty();
}
}
patch_table;
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/Common/ShaderParam.h
Expand Up @@ -190,7 +190,7 @@ class ShaderVariable
simple_var = var;
}

const auto brace_pos = var.find_last_of(")");
const auto brace_pos = var.find_last_of(')');
std::string prefix;
if (brace_pos != std::string::npos)
{
Expand All @@ -200,7 +200,7 @@ class ShaderVariable

auto var_blocks = fmt::split(simple_var, { "." });

verify(HERE), (var_blocks.size() != 0);
verify(HERE), (!var_blocks.empty());

name = prefix + var_blocks[0];

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/Common/texture_cache_utils.h
Expand Up @@ -263,7 +263,7 @@ namespace rsx
m_size = 0;
m_array_idx = 0;
m_capacity = 0;
m_data.resize(0);
m_data.clear();
m_data_it = m_data.end();
}

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/GL/GLGSRender.cpp
Expand Up @@ -436,7 +436,7 @@ void GLGSRender::end()
clear_depth = true;
}

if (clear_depth || buffers_to_clear.size() > 0)
if (clear_depth || !buffers_to_clear.empty())
{
gl_state.enable(GL_FALSE, GL_SCISSOR_TEST);
GLenum mask = 0;
Expand All @@ -454,7 +454,7 @@ void GLGSRender::end()

glClear(mask);

if (buffers_to_clear.size() > 0 && !clear_all_color)
if (!buffers_to_clear.empty() && !clear_all_color)
{
GLfloat colors[] = { 0.f, 0.f, 0.f, 0.f };
//It is impossible for the render target to be type A or B here (clear all would have been flagged)
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLTextureCache.h
Expand Up @@ -535,7 +535,7 @@ namespace gl

void clear_temporary_subresources()
{
m_temporary_surfaces.resize(0);
m_temporary_surfaces.clear();
}

gl::texture_view* create_temporary_subresource_impl(gl::command_context& cmd, gl::texture* src, GLenum sized_internal_fmt, GLenum dst_type, u32 gcm_format,
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/RSX/Overlays/overlay_controls.h
Expand Up @@ -604,7 +604,7 @@ namespace rsx
u16 clip_width = clip_text ? w : UINT16_MAX;
std::vector<vertex> result = renderer->render_text(string, clip_width, wrap_text);

if (result.size() > 0)
if (!result.empty())
{
for (auto &v : result)
{
Expand Down Expand Up @@ -702,7 +702,7 @@ namespace rsx
cmd_text.config.color = fore_color;
cmd_text.verts = render_text(text.c_str(), (f32)x, (f32)y);

if (cmd_text.verts.size() > 0)
if (!cmd_text.verts.empty())
compiled_resources.add(std::move(compiled_resources_temp), margin_left, margin_top);
}

Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/RSX/RSXThread.cpp
Expand Up @@ -1244,7 +1244,7 @@ namespace rsx
current_vertex_program.output_mask = rsx::method_registers.vertex_attrib_output_mask();
current_vertex_program.skip_vertex_input_check = skip_vertex_inputs;

current_vertex_program.rsx_vertex_inputs.resize(0);
current_vertex_program.rsx_vertex_inputs.clear();
current_vertex_program.data.reserve(512 * 4);
current_vertex_program.jump_table.clear();
current_vertex_program.texture_dimensions = 0;
Expand Down Expand Up @@ -2615,7 +2615,7 @@ namespace rsx
m_statistics_map[m_statistics_tag_id] = 1;

verify(HERE), m_pending_writes.front().sink == 0;
m_pending_writes.resize(0);
m_pending_writes.clear();

for (auto &query : m_occlusion_query_data)
{
Expand Down Expand Up @@ -2752,7 +2752,7 @@ namespace rsx
if (!has_unclaimed)
{
verify(HERE), processed == m_pending_writes.size();
m_pending_writes.resize(0);
m_pending_writes.clear();
}
else
{
Expand Down Expand Up @@ -2928,7 +2928,7 @@ namespace rsx
}
else
{
m_pending_writes.resize(0);
m_pending_writes.clear();
}

ptimer->async_tasks_pending -= processed;
Expand Down
8 changes: 4 additions & 4 deletions rpcs3/Emu/RSX/RSXThread.h
Expand Up @@ -269,9 +269,9 @@ namespace rsx

void clear()
{
interleaved_blocks.resize(0);
volatile_blocks.resize(0);
referenced_registers.resize(0);
interleaved_blocks.clear();
volatile_blocks.clear();
referenced_registers.clear();
}

bool validate() const
Expand Down Expand Up @@ -424,7 +424,7 @@ namespace rsx
void on_draw();

// Check for pending writes
bool has_pending() const { return (m_pending_writes.size() != 0); }
bool has_pending() const { return !m_pending_writes.empty(); }

// Backend methods (optional, will return everything as always visible by default)
virtual void begin_occlusion_query(occlusion_query_info* /*query*/) {}
Expand Down
10 changes: 5 additions & 5 deletions rpcs3/Emu/RSX/VK/VKGSRender.cpp
Expand Up @@ -394,7 +394,7 @@ VKGSRender::VKGSRender() : GSRender()

//Actually confirm that the loader found at least one compatible device
//This should not happen unless something is wrong with the driver setup on the target system
if (gpus.size() == 0)
if (gpus.empty())
{
//We can't throw in Emulator::Load, so we show error and return
LOG_FATAL(RSX, "No compatible GPU devices found");
Expand Down Expand Up @@ -2167,7 +2167,7 @@ void VKGSRender::clear_surface(u32 mask)
}
}

if (clear_descriptors.size() > 0)
if (!clear_descriptors.empty())
{
begin_render_pass();
vkCmdClearAttachments(*m_current_command_buffer, (u32)clear_descriptors.size(), clear_descriptors.data(), 1, &region);
Expand Down Expand Up @@ -3538,7 +3538,7 @@ bool VKGSRender::check_occlusion_query_status(rsx::reports::occlusion_query_info
return true;

auto &data = found->second;
if (data.indices.size() == 0)
if (data.indices.empty())
return true;

if (data.command_buffer_to_wait == m_current_command_buffer)
Expand Down Expand Up @@ -3568,7 +3568,7 @@ void VKGSRender::get_occlusion_query_result(rsx::reports::occlusion_query_info*
return;

auto &data = found->second;
if (data.indices.size() == 0)
if (data.indices.empty())
return;

if (query->num_draws)
Expand Down Expand Up @@ -3618,7 +3618,7 @@ void VKGSRender::discard_occlusion_query(rsx::reports::occlusion_query_info* que
return;

auto &data = found->second;
if (data.indices.size() == 0)
if (data.indices.empty())
return;

m_occlusion_query_pool.reset_queries(*m_current_command_buffer, data.indices);
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/VK/VKHelpers.cpp
Expand Up @@ -207,7 +207,7 @@ namespace vk
{
if (!g_scratch_buffer)
{
// 32M disposable scratch memory
// 128M disposable scratch memory
g_scratch_buffer = std::make_unique<vk::buffer>(*g_current_renderer, 128 * 0x100000,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kd-11 Can you confirm the value to set in the comment is 128 to match with the buffer's size (128 * 0x100000)?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, didn't change the comment when updating.

g_current_renderer->get_memory_mapping().device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
VK_BUFFER_USAGE_TRANSFER_SRC_BIT | VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT, 0);
Expand Down