Skip to content

Commit

Permalink
Implement fill_array() utility
Browse files Browse the repository at this point in the history
  • Loading branch information
Nekotekina committed Apr 19, 2021
1 parent ccb89bd commit 7dae376
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 65 deletions.
6 changes: 3 additions & 3 deletions rpcs3/Emu/GDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ void set_nonblocking(int s)

struct gdb_cmd
{
std::string cmd;
std::string data;
u8 checksum;
std::string cmd{};
std::string data{};
u8 checksum{};
};

bool check_errno_again()
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/GDB.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class gdb_thread

int server_socket = -1;
int client_socket = -1;
std::weak_ptr<cpu_thread> selected_thread;
std::weak_ptr<cpu_thread> selected_thread{};
u64 continue_ops_thread_id = ANY_THREAD;
u64 general_ops_thread_id = ANY_THREAD;

Expand Down
4 changes: 2 additions & 2 deletions rpcs3/Emu/IdManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,8 @@ namespace id_manager
template <typename T>
struct id_map
{
std::vector<std::pair<id_key, std::shared_ptr<void>>> vec;
shared_mutex mutex; // TODO: Use this instead of global mutex
std::vector<std::pair<id_key, std::shared_ptr<void>>> vec{};
shared_mutex mutex{}; // TODO: Use this instead of global mutex

id_map()
{
Expand Down
17 changes: 9 additions & 8 deletions rpcs3/Emu/RSX/Capture/rsx_replay.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ namespace rsx
{
struct memory_block_data
{
std::vector<u8> data;
std::vector<u8> data{};

template<typename Archive>
void serialize(Archive& ar)
{
Expand Down Expand Up @@ -96,8 +97,8 @@ namespace rsx
// bleh, may need to break these out, might be unnecessary to do both always
struct tile_state
{
tile_info tiles[15];
zcull_info zculls[8];
tile_info tiles[15]{};
zcull_info zculls[8]{};

template<typename Archive>
void serialize(Archive & ar)
Expand Down Expand Up @@ -126,7 +127,7 @@ namespace rsx

struct display_buffers_state
{
std::array<buffer_state, 8> buffers;
std::array<buffer_state, 8> buffers{};
u32 count{0};

template<typename Archive>
Expand Down Expand Up @@ -195,12 +196,12 @@ namespace rsx
{
u64 tile_hash{0};
u64 display_buffer_hash{0};
frame_capture_data::display_buffers_state buffer_state;
frame_capture_data::tile_state tile_state;
frame_capture_data::display_buffers_state buffer_state{};
frame_capture_data::tile_state tile_state{};
};

u32 user_mem_addr;
current_state cs;
u32 user_mem_addr{};
current_state cs{};
std::unique_ptr<frame_capture_data> frame;

public:
Expand Down
5 changes: 3 additions & 2 deletions rpcs3/Emu/RSX/Overlays/Shaders/shader_loading_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ namespace rsx
{
struct shader_loading_dialog
{
std::shared_ptr<MsgDialogBase> dlg;
atomic_t<int> ref_cnt;
std::shared_ptr<MsgDialogBase> dlg{};
atomic_t<int> ref_cnt{0};

virtual ~shader_loading_dialog() = default;
virtual void create(const std::string& msg, const std::string& title);
virtual void update_msg(u32 index, const std::string& msg);
virtual void inc_value(u32 index, u32 value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace rsx
struct shader_loading_dialog_native : rsx::shader_loading_dialog
{
rsx::thread* owner = nullptr;
std::shared_ptr<rsx::overlays::message_dialog> dlg;
std::shared_ptr<rsx::overlays::message_dialog> dlg{};

shader_loading_dialog_native(GSRender* ptr);

Expand Down
7 changes: 3 additions & 4 deletions rpcs3/Emu/RSX/RSXFragmentProgram.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ struct RSXFragmentProgram
struct data_storage_helper
{
void* data_ptr = nullptr;
std::vector<char> local_storage;
std::vector<char> local_storage{};

data_storage_helper() = default;

Expand Down Expand Up @@ -292,7 +292,7 @@ struct RSXFragmentProgram
}
}

} mutable data;
} mutable data{};

u32 offset = 0;
u32 ucode_length = 0;
Expand All @@ -305,7 +305,7 @@ struct RSXFragmentProgram
u32 texture_dimensions = 0;
u32 texcoord_control_mask = 0;

float texture_scale[16][4];
float texture_scale[16][4]{};

bool valid = false;

Expand All @@ -327,7 +327,6 @@ struct RSXFragmentProgram

RSXFragmentProgram()
{
std::memset(texture_scale, 0, sizeof(float) * 16 * 4);
}

static RSXFragmentProgram clone(const RSXFragmentProgram& prog)
Expand Down
3 changes: 3 additions & 0 deletions rpcs3/Emu/RSX/RSXOffload.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ namespace rsx
transport_packet(u32 command, void* args)
: type(op::callback), src(args), aux_param0(command)
{}

transport_packet(const transport_packet&) = delete;
transport_packet& operator=(const transport_packet&) = delete;
};

atomic_t<bool> m_mem_fault_flag = false;
Expand Down
18 changes: 14 additions & 4 deletions rpcs3/Emu/RSX/RSXTexture.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ namespace rsx
{
protected:
const u8 m_index;
std::array<u32, 0x10000 / 4> &registers;
std::array<u32, 0x10000 / 4>& registers;

public:
fragment_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
fragment_texture(u8 idx, std::array<u32, 0x10000 / 4>& r)
: m_index(idx)
, registers(r)
{
}

fragment_texture() = delete;

// Offset
Expand Down Expand Up @@ -87,10 +92,15 @@ namespace rsx
{
protected:
const u8 m_index;
std::array<u32, 0x10000 / 4> &registers;
std::array<u32, 0x10000 / 4>& registers;

public:
vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r) : m_index(idx), registers(r) { }
vertex_texture(u8 idx, std::array<u32, 0x10000 / 4> &r)
: m_index(idx)
, registers(r)
{
}

vertex_texture() = delete;

// Offset
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/RSXThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@ namespace rsx
{
std::array<atomic_t<u32>, 4096> ea;
std::array<atomic_t<u32>, 4096> io;
std::array<shared_mutex, 4096> rs;
std::array<shared_mutex, 4096> rs{};

rsx_iomap_table() noexcept
: ea(fill_array(-1))
, io(fill_array(-1))
{
std::memset(ea.data(), -1, sizeof(ea));
std::memset(io.data(), -1, sizeof(io));
}

// Try to get the real address given a mapped address
Expand Down
32 changes: 16 additions & 16 deletions rpcs3/Emu/RSX/rsx_methods.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,16 @@ namespace rsx
class draw_clause
{
// Stores the first and count argument from draw/draw indexed parameters between begin/end clauses.
simple_array<draw_range_t> draw_command_ranges;
simple_array<draw_range_t> draw_command_ranges{};

// Stores rasterization barriers for primitive types sensitive to adjacency
simple_array<barrier_t> draw_command_barriers;
simple_array<barrier_t> draw_command_barriers{};

// Counter used to parse the commands in order
u32 current_range_index;
u32 current_range_index{};

// Location of last execution barrier
u32 last_execution_barrier_index;
u32 last_execution_barrier_index{};

// Helper functions
// Add a new draw command
Expand Down Expand Up @@ -102,14 +102,14 @@ namespace rsx
}

public:
primitive_type primitive;
draw_command command;
primitive_type primitive{};
draw_command command{};

bool is_immediate_draw; // Set if part of the draw is submitted via push registers
bool is_disjoint_primitive; // Set if primitive type does not rely on adjacency information
bool primitive_barrier_enable; // Set once to signal that a primitive restart barrier can be inserted
bool is_immediate_draw{}; // Set if part of the draw is submitted via push registers
bool is_disjoint_primitive{}; // Set if primitive type does not rely on adjacency information
bool primitive_barrier_enable{}; // Set once to signal that a primitive restart barrier can be inserted

simple_array<u32> inline_vertex_array;
simple_array<u32> inline_vertex_array{};

void insert_command_barrier(command_barrier_type type, u32 arg)
{
Expand Down Expand Up @@ -457,8 +457,8 @@ namespace rsx
struct rsx_state
{
public:
std::array<u32, 0x10000 / 4> registers;
u32 register_previous_value;
std::array<u32, 0x10000 / 4> registers{};
u32 register_previous_value{};

template<u32 opcode>
using decoded_type = typename registers_decoder<opcode>::decoded_type;
Expand Down Expand Up @@ -492,10 +492,10 @@ namespace rsx
std::array<vertex_texture, 4> vertex_textures;


std::array<u32, 512 * 4> transform_program;
std::array<u32[4], 512> transform_constants;
std::array<u32, 512 * 4> transform_program{};
std::array<u32[4], 512> transform_constants{};

draw_clause current_draw_clause;
draw_clause current_draw_clause{};

/**
* RSX can sources vertex attributes from 2 places:
Expand All @@ -514,7 +514,7 @@ namespace rsx
* Note that behavior when both vertex array and immediate value system are disabled but vertex attrib mask
* request inputs is unknown.
*/
std::array<register_vertex_data_info, 16> register_vertex_info;
std::array<register_vertex_data_info, 16> register_vertex_info{};
std::array<data_array_format_info, 16> vertex_arrays_info;

private:
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/Emu/RSX/rsx_vertex_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ struct data_array_format_info

public:
data_array_format_info(int id, std::array<u32, 0x10000 / 4>& r)
: index(id)
, registers(r)
: index(id)
, registers(r)
{
}

Expand Down Expand Up @@ -124,7 +124,7 @@ struct register_vertex_data_info
vertex_base_type type = vertex_base_type::f;

register_vertex_data_info() = default;
std::array<u32, 4> data;
std::array<u32, 4> data{};
};

}
1 change: 1 addition & 0 deletions rpcs3/cmake_modules/ConfigureCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ else()
#add_compile_options(-Wpadded)
add_compile_options(-Wempty-body)
add_compile_options(-Wredundant-decls)
#add_compile_options(-Weffc++)

add_compile_options(-Wstrict-aliasing=1)
#add_compile_options(-Wnull-dereference)
Expand Down
4 changes: 2 additions & 2 deletions rpcs3/util/auto_typemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace stx
// Save default constructor and destructor
struct typeinfo
{
bool(*create)(uchar* ptr, auto_typemap&) noexcept;
void(*destroy)(void* ptr) noexcept;
bool(*create)(uchar* ptr, auto_typemap&) noexcept = nullptr;
void(*destroy)(void* ptr) noexcept = nullptr;

template <typename T>
static bool call_ctor(uchar* ptr, auto_typemap& _this) noexcept
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/util/fixed_typemap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace stx
// Save default constructor and destructor
struct typeinfo
{
bool(*create)(uchar* ptr, manual_typemap&) noexcept;
void(*destroy)(void* ptr) noexcept;
std::string_view name;
bool(*create)(uchar* ptr, manual_typemap&) noexcept = nullptr;
void(*destroy)(void* ptr) noexcept = nullptr;
std::string_view name{};

template <typename T>
static bool call_ctor(uchar* ptr, manual_typemap& _this) noexcept
Expand Down
6 changes: 3 additions & 3 deletions rpcs3/util/shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ namespace stx
class alignas(T) shared_data final : align_filler<sizeof(shared_counter), alignof(T)>
{
public:
shared_counter m_ctr;
shared_counter m_ctr{};

T m_data;

Expand All @@ -128,9 +128,9 @@ namespace stx
class alignas(T) shared_data<T[]> final : align_filler<sizeof(shared_counter) + sizeof(usz), alignof(T)>
{
public:
usz m_count;
usz m_count{};

shared_counter m_ctr;
shared_counter m_ctr{};

constexpr shared_data() noexcept = default;
};
Expand Down

0 comments on commit 7dae376

Please sign in to comment.