Merge branch 'linuxfix' of https://github.com/sephiroth99/xenia into sephiroth99-linuxfix

This commit is contained in:
Ben Vanik 2015-12-31 14:39:23 -08:00
commit a95be25e2f
16 changed files with 124 additions and 64 deletions

View File

@ -10,6 +10,7 @@
#ifndef XENIA_BASE_BIT_MAP_H_ #ifndef XENIA_BASE_BIT_MAP_H_
#define XENIA_BASE_BIT_MAP_H_ #define XENIA_BASE_BIT_MAP_H_
#include <cstddef>
#include <cstdint> #include <cstdint>
#include <vector> #include <vector>
@ -52,4 +53,4 @@ class BitMap {
} // namespace xe } // namespace xe
#endif // XENIA_BASE_BIT_MAP_H_ #endif // XENIA_BASE_BIT_MAP_H_

View File

@ -9,6 +9,8 @@
#include "xenia/base/byte_stream.h" #include "xenia/base/byte_stream.h"
#include <cstring>
#include "xenia/base/assert.h" #include "xenia/base/assert.h"
namespace xe { namespace xe {
@ -34,4 +36,24 @@ void ByteStream::Write(const uint8_t* buf, size_t len) {
Advance(len); Advance(len);
} }
} // namespace xe template <>
std::string ByteStream::Read() {
std::string str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len);
return str;
}
template <>
std::wstring ByteStream::Read() {
std::wstring str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len * 2);
return str;
}
} // namespace xe

View File

@ -46,26 +46,6 @@ class ByteStream {
return data; return data;
} }
template <>
std::string Read() {
std::string str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len);
return str;
}
template <>
std::wstring Read() {
std::wstring str;
uint32_t len = Read<uint32_t>();
str.resize(len);
Read(reinterpret_cast<uint8_t*>(&str[0]), len * 2);
return str;
}
template <typename T> template <typename T>
void Write(T data) { void Write(T data) {
Write(reinterpret_cast<uint8_t*>(&data), sizeof(T)); Write(reinterpret_cast<uint8_t*>(&data), sizeof(T));
@ -87,6 +67,12 @@ class ByteStream {
size_t offset_ = 0; size_t offset_ = 0;
}; };
template <>
std::string ByteStream::Read();
template <>
std::wstring ByteStream::Read();
} // namespace xe } // namespace xe
#endif // XENIA_BASE_BYTE_STREAM_H_ #endif // XENIA_BASE_BYTE_STREAM_H_

View File

@ -261,7 +261,9 @@ void Profiler::OnMouseDown(bool left_button, bool right_button) {}
void Profiler::OnMouseUp() {} void Profiler::OnMouseUp() {}
void Profiler::OnMouseMove(int x, int y) {} void Profiler::OnMouseMove(int x, int y) {}
void Profiler::OnMouseWheel(int x, int y, int dy) {} void Profiler::OnMouseWheel(int x, int y, int dy) {}
void Profiler::set_display(std::unique_ptr<ui::MicroprofilerDrawer> display) {} void Profiler::ToggleDisplay() {}
void Profiler::TogglePause() {}
void Profiler::set_window(ui::Window* window) {}
void Profiler::Present() {} void Profiler::Present() {}
#endif // XE_OPTION_PROFILING #endif // XE_OPTION_PROFILING

View File

@ -45,8 +45,7 @@ std::string X64Context::GetStringFromValue(X64Register reg, bool hex) const {
static_cast<int>(X64Register::kXmm15)) { static_cast<int>(X64Register::kXmm15)) {
auto value = xmm_registers[static_cast<int>(reg) - auto value = xmm_registers[static_cast<int>(reg) -
static_cast<int>(X64Register::kXmm0)]; static_cast<int>(X64Register::kXmm0)];
return hex ? string_util::to_hex_string(value) return hex ? string_util::to_hex_string(value) : xe::to_string(value);
: string_util::to_string(value);
} else { } else {
assert_unhandled_case(reg); assert_unhandled_case(reg);
return ""; return "";

View File

@ -15,6 +15,8 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include "xenia/base/vec128.h"
namespace xe { namespace xe {
enum class X64Register { enum class X64Register {
@ -84,24 +86,24 @@ class X64Context {
union { union {
struct { struct {
__m128 xmm0; vec128_t xmm0;
__m128 xmm1; vec128_t xmm1;
__m128 xmm2; vec128_t xmm2;
__m128 xmm3; vec128_t xmm3;
__m128 xmm4; vec128_t xmm4;
__m128 xmm5; vec128_t xmm5;
__m128 xmm6; vec128_t xmm6;
__m128 xmm7; vec128_t xmm7;
__m128 xmm8; vec128_t xmm8;
__m128 xmm9; vec128_t xmm9;
__m128 xmm10; vec128_t xmm10;
__m128 xmm11; vec128_t xmm11;
__m128 xmm12; vec128_t xmm12;
__m128 xmm13; vec128_t xmm13;
__m128 xmm14; vec128_t xmm14;
__m128 xmm15; vec128_t xmm15;
}; };
__m128 xmm_registers[16]; vec128_t xmm_registers[16];
}; };
static const char* GetRegisterName(X64Register reg); static const char* GetRegisterName(X64Register reg);

View File

@ -206,6 +206,9 @@ void Value::Convert(TypeName target_type, RoundMode round_mode) {
type = target_type; type = target_type;
constant.f64 = constant.f32; constant.f64 = constant.f32;
return; return;
default:
assert_unhandled_case(target_type);
return;
} }
case FLOAT64_TYPE: case FLOAT64_TYPE:
switch (target_type) { switch (target_type) {
@ -213,9 +216,12 @@ void Value::Convert(TypeName target_type, RoundMode round_mode) {
type = target_type; type = target_type;
constant.f32 = (float)constant.f64; constant.f32 = (float)constant.f64;
return; return;
default:
assert_unhandled_case(target_type);
return;
} }
default: default:
assert_unhandled_case(target_type); assert_unhandled_case(type);
return; return;
} }
} }

View File

@ -338,7 +338,7 @@ uint64_t Processor::Execute(ThreadState* thread_state, uint32_t address,
SCOPE_profile_cpu_f("cpu"); SCOPE_profile_cpu_f("cpu");
auto context = thread_state->context(); auto context = thread_state->context();
for (size_t i = 0; i < std::min(arg_count, 8ull); ++i) { for (size_t i = 0; i < std::min(arg_count, static_cast<size_t>(8)); ++i) {
context->r[3 + i] = args[i]; context->r[3 + i] = args[i];
} }

View File

@ -318,7 +318,7 @@ void DebugWindow::DrawSourcePane() {
// name text box (editable) // name text box (editable)
// combo for interleaved + [ppc, hir, opt hir, x64 + byte with sizes] // combo for interleaved + [ppc, hir, opt hir, x64 + byte with sizes]
ImGui::AlignFirstTextHeightToWidgets(); ImGui::AlignFirstTextHeightToWidgets();
ImGui::Text(function->module()->name().c_str()); ImGui::Text("%s", function->module()->name().c_str());
ImGui::SameLine(); ImGui::SameLine();
ImGui::Dummy(ImVec2(4, 0)); ImGui::Dummy(ImVec2(4, 0));
ImGui::SameLine(); ImGui::SameLine();
@ -657,7 +657,7 @@ bool DebugWindow::DrawRegisterTextBox(int id, uint32_t* value) {
auto alt_value = state_.register_input_hex auto alt_value = state_.register_input_hex
? std::to_string(*value) ? std::to_string(*value)
: string_util::to_hex_string(*value); : string_util::to_hex_string(*value);
ImGui::SetTooltip(alt_value.c_str()); ImGui::SetTooltip("%s", alt_value.c_str());
} }
return any_changed; return any_changed;
} }
@ -697,7 +697,7 @@ bool DebugWindow::DrawRegisterTextBox(int id, uint64_t* value) {
auto alt_value = state_.register_input_hex auto alt_value = state_.register_input_hex
? std::to_string(*value) ? std::to_string(*value)
: string_util::to_hex_string(*value); : string_util::to_hex_string(*value);
ImGui::SetTooltip(alt_value.c_str()); ImGui::SetTooltip("%s", alt_value.c_str());
} }
return any_changed; return any_changed;
} }
@ -715,7 +715,7 @@ bool DebugWindow::DrawRegisterTextBox(int id, double* value) {
} else { } else {
input_flags |= input_flags |=
ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll; ImGuiInputTextFlags_CharsDecimal | ImGuiInputTextFlags_AutoSelectAll;
std::snprintf(buffer, xe::countof(buffer), "%.8LF", *value); std::snprintf(buffer, xe::countof(buffer), "%.8F", *value);
} }
char label[16] = {0}; char label[16] = {0};
std::snprintf(label, xe::countof(label), "##dregister%d", id); std::snprintf(label, xe::countof(label), "##dregister%d", id);
@ -736,7 +736,7 @@ bool DebugWindow::DrawRegisterTextBox(int id, double* value) {
auto alt_value = state_.register_input_hex auto alt_value = state_.register_input_hex
? std::to_string(*value) ? std::to_string(*value)
: string_util::to_hex_string(*value); : string_util::to_hex_string(*value);
ImGui::SetTooltip(alt_value.c_str()); ImGui::SetTooltip("%s", alt_value.c_str());
} }
return any_changed; return any_changed;
} }
@ -779,7 +779,7 @@ bool DebugWindow::DrawRegisterTextBoxes(int id, float* value) {
auto alt_value = state_.register_input_hex auto alt_value = state_.register_input_hex
? std::to_string(value[i]) ? std::to_string(value[i])
: string_util::to_hex_string(value[i]); : string_util::to_hex_string(value[i]);
ImGui::SetTooltip(alt_value.c_str()); ImGui::SetTooltip("%s", alt_value.c_str());
} }
if (i < 3) { if (i < 3) {
ImGui::SameLine(); ImGui::SameLine();
@ -968,7 +968,7 @@ void DebugWindow::DrawRegistersPane() {
ImGui::Dummy(ImVec2(4, 0)); ImGui::Dummy(ImVec2(4, 0));
ImGui::SameLine(); ImGui::SameLine();
dirty_host_context |= DrawRegisterTextBoxes( dirty_host_context |= DrawRegisterTextBoxes(
i, thread_info->host_context.xmm_registers[i].m128_f32); i, thread_info->host_context.xmm_registers[i].f32);
ImGui::EndGroup(); ImGui::EndGroup();
} }
ImGui::EndChild(); ImGui::EndChild();
@ -1067,9 +1067,9 @@ void DebugWindow::DrawThreadsPane() {
ImGui::Dummy(ImVec2(8, 0)); ImGui::Dummy(ImVec2(8, 0));
ImGui::SameLine(); ImGui::SameLine();
if (frame.guest_function) { if (frame.guest_function) {
ImGui::Text(frame.guest_function->name().c_str()); ImGui::Text("%s", frame.guest_function->name().c_str());
} else { } else {
ImGui::Text(frame.name); ImGui::Text("%s", frame.name);
} }
if (is_current_thread && !frame.guest_pc) { if (is_current_thread && !frame.guest_pc) {
ImGui::PopStyleColor(); ImGui::PopStyleColor();
@ -1259,7 +1259,7 @@ void DebugWindow::DrawBreakpointsPane() {
ImGui::SameLine(); ImGui::SameLine();
ImGui::Dummy(ImVec2(4, 0)); ImGui::Dummy(ImVec2(4, 0));
ImGui::SameLine(); ImGui::SameLine();
ImGui::Text(export_entry->name); ImGui::Text("%s", export_entry->name);
ImGui::Dummy(ImVec2(0, 1)); ImGui::Dummy(ImVec2(0, 1));
ImGui::PopID(); ImGui::PopID();
} }
@ -1344,6 +1344,10 @@ void DebugWindow::DrawBreakpointsPane() {
} }
break; break;
} }
default: {
// Ignored.
break;
}
} }
} }
if (ImGui::BeginPopupContextItem("##breakpoint_context_menu")) { if (ImGui::BeginPopupContextItem("##breakpoint_context_menu")) {

View File

@ -504,8 +504,7 @@ X_STATUS Emulator::CompleteLaunch(const std::wstring& path,
XELOGI("Launching module %s", next_module.c_str()); XELOGI("Launching module %s", next_module.c_str());
auto module = kernel_state_->LoadUserModule(next_module.c_str()); auto module = kernel_state_->LoadUserModule(next_module.c_str());
if (!module) { if (!module) {
auto path_str = xe::to_string(path); XELOGE("Failed to load user module %S", path.c_str());
XELOGE("Failed to load user module %s", path.c_str());
return X_STATUS_NOT_FOUND; return X_STATUS_NOT_FOUND;
} }

View File

@ -559,6 +559,9 @@ void GlslShaderTranslator::ProcessVertexFetchInstruction(
EmitSource(" = vf%u_%d;\n", instr.operands[1].storage_index, EmitSource(" = vf%u_%d;\n", instr.operands[1].storage_index,
instr.attributes.offset); instr.attributes.offset);
break; break;
default:
assert_always();
break;
} }
} }
@ -676,6 +679,9 @@ void GlslShaderTranslator::ProcessTextureFetchInstruction(
EmitUnimplementedTranslationError(); EmitUnimplementedTranslationError();
EmitSourceDepth("pv = vec4(0.0);\n"); EmitSourceDepth("pv = vec4(0.0);\n");
break; break;
case FetchOpcode::kVertexFetch:
assert_always();
break;
} }
EmitStoreVectorResult(instr.result); EmitStoreVectorResult(instr.result);
@ -728,6 +734,10 @@ void GlslShaderTranslator::EmitLoadOperand(size_t i,
case InstructionStorageSource::kConstantBool: case InstructionStorageSource::kConstantBool:
EmitSource("state.bool_consts"); EmitSource("state.bool_consts");
break; break;
case InstructionStorageSource::kTextureFetchConstant:
case InstructionStorageSource::kVertexFetchConstant:
assert_always();
break;
} }
switch (op.storage_addressing_mode) { switch (op.storage_addressing_mode) {
case InstructionStorageAddressingMode::kStatic: case InstructionStorageAddressingMode::kStatic:
@ -815,6 +825,8 @@ void GlslShaderTranslator::EmitStoreResult(const InstructionResult& result,
case InstructionStorageTarget::kDepth: case InstructionStorageTarget::kDepth:
EmitSourceDepth("gl_FragDepth"); EmitSourceDepth("gl_FragDepth");
break; break;
case InstructionStorageTarget::kNone:
break;
} }
if (uses_storage_index) { if (uses_storage_index) {
switch (result.storage_addressing_mode) { switch (result.storage_addressing_mode) {

View File

@ -9,6 +9,7 @@
#include "xenia/gpu/shader.h" #include "xenia/gpu/shader.h"
#include <cinttypes>
#include <cstring> #include <cstring>
#include "xenia/base/filesystem.h" #include "xenia/base/filesystem.h"
@ -47,8 +48,8 @@ void Shader::Dump(const std::string& base_path, const char* path_prefix) {
char txt_file_name[kMaxPath]; char txt_file_name[kMaxPath];
std::snprintf(txt_file_name, xe::countof(txt_file_name), std::snprintf(txt_file_name, xe::countof(txt_file_name),
"%s/shader_%s_%.16llX.%s", base_path.c_str(), path_prefix, "%s/shader_%s_%.16" PRIX64 ".%s", base_path.c_str(),
ucode_data_hash_, path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag"); shader_type_ == ShaderType::kVertex ? "vert" : "frag");
FILE* f = fopen(txt_file_name, "w"); FILE* f = fopen(txt_file_name, "w");
if (f) { if (f) {
@ -70,8 +71,8 @@ void Shader::Dump(const std::string& base_path, const char* path_prefix) {
char bin_file_name[kMaxPath]; char bin_file_name[kMaxPath];
std::snprintf(bin_file_name, xe::countof(bin_file_name), std::snprintf(bin_file_name, xe::countof(bin_file_name),
"%s/shader_%s_%.16llX.bin.%s", base_path.c_str(), path_prefix, "%s/shader_%s_%.16" PRIX64 ".bin.%s", base_path.c_str(),
ucode_data_hash_, path_prefix, ucode_data_hash_,
shader_type_ == ShaderType::kVertex ? "vert" : "frag"); shader_type_ == ShaderType::kVertex ? "vert" : "frag");
f = fopen(bin_file_name, "w"); f = fopen(bin_file_name, "w");
if (f) { if (f) {

View File

@ -159,7 +159,7 @@ void ShaderTranslator::GatherBindingInformation(
case ControlFlowOpcode::kCondExecPred: case ControlFlowOpcode::kCondExecPred:
case ControlFlowOpcode::kCondExecPredEnd: case ControlFlowOpcode::kCondExecPredEnd:
case ControlFlowOpcode::kCondExecPredClean: case ControlFlowOpcode::kCondExecPredClean:
case ControlFlowOpcode::kCondExecPredCleanEnd: case ControlFlowOpcode::kCondExecPredCleanEnd: {
uint32_t sequence = cf.exec.sequence(); uint32_t sequence = cf.exec.sequence();
for (uint32_t instr_offset = cf.exec.address(); for (uint32_t instr_offset = cf.exec.address();
instr_offset < cf.exec.address() + cf.exec.count(); instr_offset < cf.exec.address() + cf.exec.count();
@ -184,17 +184,19 @@ void ShaderTranslator::GatherBindingInformation(
auto& op = *reinterpret_cast<const AluInstruction*>(ucode_dwords_ + auto& op = *reinterpret_cast<const AluInstruction*>(ucode_dwords_ +
instr_offset * 3); instr_offset * 3);
if (op.has_vector_op() && op.is_export()) { if (op.has_vector_op() && op.is_export()) {
if (op.vector_dest() >= 0 && op.vector_dest() <= 3) { if (op.vector_dest() <= 3) {
writes_color_targets_[op.vector_dest()] = true; writes_color_targets_[op.vector_dest()] = true;
} }
} }
if (op.has_scalar_op() && op.is_export()) { if (op.has_scalar_op() && op.is_export()) {
if (op.vector_dest() >= 0 && op.vector_dest() <= 3) { if (op.vector_dest() <= 3) {
writes_color_targets_[op.vector_dest()] = true; writes_color_targets_[op.vector_dest()] = true;
} }
} }
} }
} }
} break;
default:
break; break;
} }
} }
@ -248,6 +250,9 @@ void ShaderTranslator::GatherTextureBindingInformation(
case FetchOpcode::kSetTextureGradientsVert: case FetchOpcode::kSetTextureGradientsVert:
// Doesn't use bindings. // Doesn't use bindings.
return; return;
default:
// Continue.
break;
} }
Shader::TextureBinding binding; Shader::TextureBinding binding;
binding.binding_index = texture_bindings_.size(); binding.binding_index = texture_bindings_.size();
@ -271,6 +276,9 @@ void AddControlFlowTargetLabel(const ControlFlowInstruction& cf,
case ControlFlowOpcode::kCondJmp: case ControlFlowOpcode::kCondJmp:
label_addresses->insert(cf.cond_jmp.address()); label_addresses->insert(cf.cond_jmp.address());
break; break;
default:
// Ignored.
break;
} }
} }
@ -435,6 +443,8 @@ void ShaderTranslator::TranslateControlFlowCondExec(
i.opcode_name = "cexece"; i.opcode_name = "cexece";
i.is_end = true; i.is_end = true;
break; break;
default:
break;
} }
i.instruction_address = cf.address(); i.instruction_address = cf.address();
i.instruction_count = cf.count(); i.instruction_count = cf.count();
@ -446,6 +456,8 @@ void ShaderTranslator::TranslateControlFlowCondExec(
case ControlFlowOpcode::kCondExecEnd: case ControlFlowOpcode::kCondExecEnd:
i.clean = false; i.clean = false;
break; break;
default:
break;
} }
i.is_yield = cf.is_yield(); i.is_yield = cf.is_yield();
i.sequence = cf.sequence(); i.sequence = cf.sequence();

View File

@ -45,6 +45,8 @@ void DisassembleResultOperand(const InstructionResult& result,
case InstructionStorageTarget::kDepth: case InstructionStorageTarget::kDepth:
out->Append("oDepth"); out->Append("oDepth");
break; break;
case InstructionStorageTarget::kNone:
break;
} }
if (uses_storage_index) { if (uses_storage_index) {
switch (result.storage_addressing_mode) { switch (result.storage_addressing_mode) {
@ -90,6 +92,10 @@ void DisassembleSourceOperand(const InstructionOperand& op, StringBuffer* out) {
case InstructionStorageSource::kConstantBool: case InstructionStorageSource::kConstantBool:
out->Append('b'); out->Append('b');
break; break;
case InstructionStorageSource::kTextureFetchConstant:
case InstructionStorageSource::kVertexFetchConstant:
assert_always();
break;
} }
if (op.is_absolute_value) { if (op.is_absolute_value) {
out->Append("_abs"); out->Append("_abs");

View File

@ -274,6 +274,9 @@ void ImGuiDrawer::OnMouseDown(MouseEvent* e) {
case xe::ui::MouseEvent::Button::kRight: { case xe::ui::MouseEvent::Button::kRight: {
io.MouseDown[1] = true; io.MouseDown[1] = true;
} break; } break;
default: {
// Ignored.
} break;
} }
} }
@ -292,6 +295,9 @@ void ImGuiDrawer::OnMouseUp(MouseEvent* e) {
case xe::ui::MouseEvent::Button::kRight: { case xe::ui::MouseEvent::Button::kRight: {
io.MouseDown[1] = false; io.MouseDown[1] = false;
} break; } break;
default: {
// Ignored.
} break;
} }
} }

View File

@ -9,6 +9,8 @@
#include "xenia/ui/window.h" #include "xenia/ui/window.h"
#include <algorithm>
#include "third_party/imgui/imgui.h" #include "third_party/imgui/imgui.h"
#include "xenia/base/assert.h" #include "xenia/base/assert.h"
#include "xenia/base/clock.h" #include "xenia/base/clock.h"