1
0
Fork 0
forked from suyu/suyu

Build: Fixed some warnings

This commit is contained in:
Subv 2015-02-01 15:31:21 -05:00
parent f990728ad4
commit 8e2b248e05
11 changed files with 69 additions and 51 deletions

View file

@ -426,7 +426,7 @@ std::u16string UTF8ToUTF16(const std::string& input)
static std::string UTF16ToUTF8(const std::wstring& input) static std::string UTF16ToUTF8(const std::wstring& input)
{ {
auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), input.size(), nullptr, 0, nullptr, nullptr); auto const size = WideCharToMultiByte(CP_UTF8, 0, input.data(), static_cast<int>(input.size()), nullptr, 0, nullptr, nullptr);
std::string output; std::string output;
output.resize(size); output.resize(size);
@ -439,12 +439,12 @@ static std::string UTF16ToUTF8(const std::wstring& input)
static std::wstring CPToUTF16(u32 code_page, const std::string& input) static std::wstring CPToUTF16(u32 code_page, const std::string& input)
{ {
auto const size = MultiByteToWideChar(code_page, 0, input.data(), input.size(), nullptr, 0); auto const size = MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
std::wstring output; std::wstring output;
output.resize(size); output.resize(size);
if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), input.size(), &output[0], output.size())) if (size == 0 || size != MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), &output[0], static_cast<int>(output.size())))
output.clear(); output.clear();
return output; return output;

View file

@ -459,7 +459,7 @@ void MoveEvents() {
} }
void ForceCheck() { void ForceCheck() {
int cycles_executed = g_slice_length - Core::g_app_core->down_count; s64 cycles_executed = g_slice_length - Core::g_app_core->down_count;
global_timer += cycles_executed; global_timer += cycles_executed;
// This will cause us to check for new events immediately. // This will cause us to check for new events immediately.
Core::g_app_core->down_count = 0; Core::g_app_core->down_count = 0;
@ -468,7 +468,7 @@ void ForceCheck() {
} }
void Advance() { void Advance() {
int cycles_executed = g_slice_length - Core::g_app_core->down_count; s64 cycles_executed = g_slice_length - Core::g_app_core->down_count;
global_timer += cycles_executed; global_timer += cycles_executed;
Core::g_app_core->down_count = g_slice_length; Core::g_app_core->down_count = g_slice_length;
@ -504,13 +504,13 @@ void LogPendingEvents() {
} }
void Idle(int max_idle) { void Idle(int max_idle) {
int cycles_down = Core::g_app_core->down_count; s64 cycles_down = Core::g_app_core->down_count;
if (max_idle != 0 && cycles_down > max_idle) if (max_idle != 0 && cycles_down > max_idle)
cycles_down = max_idle; cycles_down = max_idle;
if (first && cycles_down > 0) { if (first && cycles_down > 0) {
int cycles_executed = g_slice_length - Core::g_app_core->down_count; s64 cycles_executed = g_slice_length - Core::g_app_core->down_count;
int cycles_next_event = (int)(first->time - global_timer); s64 cycles_next_event = first->time - global_timer;
if (cycles_next_event < cycles_executed + cycles_down) { if (cycles_next_event < cycles_executed + cycles_down) {
cycles_down = cycles_next_event - cycles_executed; cycles_down = cycles_next_event - cycles_executed;

View file

@ -96,7 +96,7 @@ ResultCode HandleTable::Close(Handle handle) {
if (!IsValid(handle)) if (!IsValid(handle))
return ERR_INVALID_HANDLE; return ERR_INVALID_HANDLE;
size_t slot = GetSlot(handle); u16 slot = GetSlot(handle);
objects[slot] = nullptr; objects[slot] = nullptr;
@ -127,7 +127,7 @@ SharedPtr<Object> HandleTable::GetGeneric(Handle handle) const {
} }
void HandleTable::Clear() { void HandleTable::Clear() {
for (size_t i = 0; i < MAX_COUNT; ++i) { for (u16 i = 0; i < MAX_COUNT; ++i) {
generations[i] = i + 1; generations[i] = i + 1;
objects[i] = nullptr; objects[i] = nullptr;
} }

View file

@ -253,7 +253,7 @@ private:
*/ */
static const size_t MAX_COUNT = 4096; static const size_t MAX_COUNT = 4096;
static size_t GetSlot(Handle handle) { return handle >> 15; } static u16 GetSlot(Handle handle) { return handle >> 15; }
static u16 GetGeneration(Handle handle) { return handle & 0x7FFF; } static u16 GetGeneration(Handle handle) { return handle & 0x7FFF; }
/// Stores the Object referenced by the handle or null if the slot is empty. /// Stores the Object referenced by the handle or null if the slot is empty.

View file

@ -63,7 +63,7 @@ void Timer::Clear() {
/// The timer callback event, called when a timer is fired /// The timer callback event, called when a timer is fired
static void TimerCallback(u64 timer_handle, int cycles_late) { static void TimerCallback(u64 timer_handle, int cycles_late) {
SharedPtr<Timer> timer = timer_callback_handle_table.Get<Timer>(timer_handle); SharedPtr<Timer> timer = timer_callback_handle_table.Get<Timer>(static_cast<Handle>(timer_handle));
if (timer == nullptr) { if (timer == nullptr) {
LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08X", timer_handle); LOG_CRITICAL(Kernel, "Callback fired for invalid timer %08X", timer_handle);

View file

@ -85,7 +85,7 @@ static void GetCountryCodeID(Service::Interface* self) {
// The following algorithm will fail if the first country code isn't 0. // The following algorithm will fail if the first country code isn't 0.
DEBUG_ASSERT(country_codes[0] == 0); DEBUG_ASSERT(country_codes[0] == 0);
for (size_t id = 0; id < country_codes.size(); ++id) { for (u16 id = 0; id < country_codes.size(); ++id) {
if (country_codes[id] == country_code) { if (country_codes[id] == country_code) {
country_code_id = id; country_code_id = id;
break; break;

View file

@ -87,8 +87,8 @@ ResultVal<bool> File::SyncRequest() {
u32 length = cmd_buff[3]; u32 length = cmd_buff[3];
u32 address = cmd_buff[5]; u32 address = cmd_buff[5];
LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x", LOG_TRACE(Service_FS, "Read %s %s: offset=0x%llx length=%d address=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address); GetTypeName().c_str(), GetName().c_str(), offset, length, address);
cmd_buff[2] = backend->Read(offset, length, Memory::GetPointer(address)); cmd_buff[2] = static_cast<u32>(backend->Read(offset, length, Memory::GetPointer(address)));
break; break;
} }
@ -100,8 +100,8 @@ ResultVal<bool> File::SyncRequest() {
u32 flush = cmd_buff[4]; u32 flush = cmd_buff[4];
u32 address = cmd_buff[6]; u32 address = cmd_buff[6];
LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x", LOG_TRACE(Service_FS, "Write %s %s: offset=0x%llx length=%d address=0x%x, flush=0x%x",
GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush); GetTypeName().c_str(), GetName().c_str(), offset, length, address, flush);
cmd_buff[2] = backend->Write(offset, length, flush, Memory::GetPointer(address)); cmd_buff[2] = static_cast<u32>(backend->Write(offset, length, flush, Memory::GetPointer(address)));
break; break;
} }

View file

@ -199,15 +199,22 @@ static void ReadHWRegs(Service::Interface* self) {
static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) { static void SetBufferSwap(u32 screen_id, const FrameBufferInfo& info) {
u32 base_address = 0x400000; u32 base_address = 0x400000;
if (info.active_fb == 0) { if (info.active_fb == 0) {
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_left1), 4, &info.address_left); WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left1)), 4,
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_right1), 4, &info.address_right); &info.address_left);
WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right1)), 4,
&info.address_right);
} else { } else {
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_left2), 4, &info.address_left); WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_left2)), 4,
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].address_right2), 4, &info.address_right); &info.address_left);
WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].address_right2)), 4,
&info.address_right);
} }
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].stride), 4, &info.stride); WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].stride)), 4,
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].color_format), 4, &info.format); &info.stride);
WriteHWRegs(base_address + 4 * GPU_REG_INDEX(framebuffer_config[screen_id].active_fb), 4, &info.shown_fb); WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].color_format)), 4,
&info.format);
WriteHWRegs(base_address + 4 * static_cast<u32>(GPU_REG_INDEX(framebuffer_config[screen_id].active_fb)), 4,
&info.shown_fb);
} }
/** /**
@ -346,11 +353,12 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
{ {
auto& params = command.set_command_list_last; auto& params = command.set_command_list_last;
WriteGPURegister(GPU_REG_INDEX(command_processor_config.address), Memory::VirtualToPhysicalAddress(params.address) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.address)),
WriteGPURegister(GPU_REG_INDEX(command_processor_config.size), params.size); Memory::VirtualToPhysicalAddress(params.address) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.size)), params.size);
// TODO: Not sure if we are supposed to always write this .. seems to trigger processing though // TODO: Not sure if we are supposed to always write this .. seems to trigger processing though
WriteGPURegister(GPU_REG_INDEX(command_processor_config.trigger), 1); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(command_processor_config.trigger)), 1);
break; break;
} }
@ -360,27 +368,33 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
case CommandId::SET_MEMORY_FILL: case CommandId::SET_MEMORY_FILL:
{ {
auto& params = command.memory_fill; auto& params = command.memory_fill;
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[0].address_start), Memory::VirtualToPhysicalAddress(params.start1) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_start)),
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[0].address_end), Memory::VirtualToPhysicalAddress(params.end1) >> 3); Memory::VirtualToPhysicalAddress(params.start1) >> 3);
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[0].size), params.end1 - params.start1); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].address_end)),
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[0].value), params.value1); Memory::VirtualToPhysicalAddress(params.end1) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].size)), params.end1 - params.start1);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[0].value)), params.value1);
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[1].address_start), Memory::VirtualToPhysicalAddress(params.start2) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_start)),
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[1].address_end), Memory::VirtualToPhysicalAddress(params.end2) >> 3); Memory::VirtualToPhysicalAddress(params.start2) >> 3);
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[1].size), params.end2 - params.start2); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].address_end)),
WriteGPURegister(GPU_REG_INDEX(memory_fill_config[1].value), params.value2); Memory::VirtualToPhysicalAddress(params.end2) >> 3);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].size)), params.end2 - params.start2);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(memory_fill_config[1].value)), params.value2);
break; break;
} }
case CommandId::SET_DISPLAY_TRANSFER: case CommandId::SET_DISPLAY_TRANSFER:
{ {
auto& params = command.image_copy; auto& params = command.image_copy;
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.input_address), Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_address)),
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.output_address), Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3); Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.input_size), params.in_buffer_size); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_address)),
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.output_size), params.out_buffer_size); Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.flags), params.flags); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)), params.in_buffer_size);
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.trigger), 1); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)), params.out_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)), params.flags);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.trigger)), 1);
break; break;
} }
@ -388,14 +402,16 @@ static void ExecuteCommand(const Command& command, u32 thread_id) {
case CommandId::SET_TEXTURE_COPY: case CommandId::SET_TEXTURE_COPY:
{ {
auto& params = command.image_copy; auto& params = command.image_copy;
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.input_address), Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_address)),
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.output_address), Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3); Memory::VirtualToPhysicalAddress(params.in_buffer_address) >> 3);
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.input_size), params.in_buffer_size); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_address)),
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.output_size), params.out_buffer_size); Memory::VirtualToPhysicalAddress(params.out_buffer_address) >> 3);
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.flags), params.flags); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.input_size)), params.in_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.output_size)), params.out_buffer_size);
WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.flags)), params.flags);
// TODO: Should this register be set to 1 or should instead its value be OR-ed with 1? // TODO: Should this register be set to 1 or should instead its value be OR-ed with 1?
WriteGPURegister(GPU_REG_INDEX(display_transfer_config.trigger), 1); WriteGPURegister(static_cast<u32>(GPU_REG_INDEX(display_transfer_config.trigger)), 1);
break; break;
} }

View file

@ -86,8 +86,10 @@ static const char* GetFileTypeString(FileType type) {
return "raw"; return "raw";
case FileType::Error: case FileType::Error:
case FileType::Unknown: case FileType::Unknown:
return "unknown"; break;
} }
return "unknown";
} }
ResultStatus LoadFile(const std::string& filename) { ResultStatus LoadFile(const std::string& filename) {

View file

@ -64,7 +64,7 @@ public:
memcpy(&cmd, command_data, sizeof(GSP_GPU::Command)); memcpy(&cmd, command_data, sizeof(GSP_GPU::Command));
ForEachObserver([this](DebuggerObserver* observer) { ForEachObserver([this](DebuggerObserver* observer) {
observer->GXCommandProcessed(this->gx_command_history.size()); observer->GXCommandProcessed(static_cast<int>(this->gx_command_history.size()));
} ); } );
} }

View file

@ -252,7 +252,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
// TODO: Be stable against division by zero! // TODO: Be stable against division by zero!
// TODO: I think this might be wrong... we should only use one component here // TODO: I think this might be wrong... we should only use one component here
dest[i] = float24::FromFloat32(1.0 / src1[i].ToFloat32()); dest[i] = float24::FromFloat32(1.0f / src1[i].ToFloat32());
} }
break; break;
@ -267,7 +267,7 @@ static void ProcessShaderCode(VertexShaderState& state) {
// TODO: Be stable against division by zero! // TODO: Be stable against division by zero!
// TODO: I think this might be wrong... we should only use one component here // TODO: I think this might be wrong... we should only use one component here
dest[i] = float24::FromFloat32(1.0 / sqrt(src1[i].ToFloat32())); dest[i] = float24::FromFloat32(1.0f / sqrt(src1[i].ToFloat32()));
} }
break; break;