Merge branch 'master' of github.com:benvanik/xenia

This commit is contained in:
Ben Vanik 2014-08-22 18:39:34 -07:00
commit eebe68b77a
25 changed files with 289 additions and 439 deletions

View File

@ -22,6 +22,17 @@ and set the 'Command' to `$(SolutionDir)$(TargetPath)` and the
'Working Directory' to `$(SolutionDir)..\..`. You can specify flags and 'Working Directory' to `$(SolutionDir)..\..`. You can specify flags and
the file to run in the 'Command Arguments' field (or use `--flagfile=flags.txt`). the file to run in the 'Command Arguments' field (or use `--flagfile=flags.txt`).
### OSX
* Mac OSX 10.9+
* Xcode 5.1+
#### Debugging
Choose `Product > Scheme > Edit Scheme`. For xenia-run, alloy-sandbox, and the
other executables select the Run action on the left and set
`Options > Working Directory` to your root xenia/ git path.
## xenia-build ## xenia-build
A simple build script is included to manage basic tasks such as building A simple build script is included to manage basic tasks such as building

View File

@ -10,6 +10,7 @@
#ifndef ALLOY_ARENA_H_ #ifndef ALLOY_ARENA_H_
#define ALLOY_ARENA_H_ #define ALLOY_ARENA_H_
#include <cstddef>
#include <cstdint> #include <cstdint>
namespace alloy { namespace alloy {

View File

@ -13,6 +13,7 @@
#include <poly/assert.h> #include <poly/assert.h>
#include <poly/math.h> #include <poly/math.h>
#include <xenia/profiling.h>
namespace alloy { namespace alloy {
namespace backend { namespace backend {

View File

@ -528,7 +528,7 @@ template <typename SEQ, typename T>
struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> { struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
typedef Sequence<SingleSequence<SEQ, T>, T> BASE; typedef Sequence<SingleSequence<SEQ, T>, T> BASE;
typedef T EmitArgType; typedef T EmitArgType;
static const uint32_t head_key = T::key; static constexpr uint32_t head_key() { return T::key; }
static void Emit(X64Emitter& e, const typename BASE::EmitArgs& _) { static void Emit(X64Emitter& e, const typename BASE::EmitArgs& _) {
SEQ::Emit(e, _.i1); SEQ::Emit(e, _.i1);
} }
@ -734,7 +734,7 @@ static const tag_t TAG7 = 7;
template <typename T> template <typename T>
void Register() { void Register() {
sequence_table.insert({ T::head_key, T::Select }); sequence_table.insert({ T::head_key(), T::Select });
} }
template <typename T, typename Tn, typename... Ts> template <typename T, typename Tn, typename... Ts>
void Register() { void Register() {

View File

@ -10,6 +10,7 @@
#ifndef ALLOY_FRONTEND_CONTEXT_INFO_H_ #ifndef ALLOY_FRONTEND_CONTEXT_INFO_H_
#define ALLOY_FRONTEND_CONTEXT_INFO_H_ #define ALLOY_FRONTEND_CONTEXT_INFO_H_
#include <cstddef>
#include <cstdint> #include <cstdint>
namespace alloy { namespace alloy {

View File

@ -9,7 +9,7 @@
#include <alloy/runtime/debug_info.h> #include <alloy/runtime/debug_info.h>
#include <memory> #include <cstdlib>
namespace alloy { namespace alloy {
namespace runtime { namespace runtime {

View File

@ -10,6 +10,7 @@
#ifndef ALLOY_RUNTIME_DEBUG_INFO_H_ #ifndef ALLOY_RUNTIME_DEBUG_INFO_H_
#define ALLOY_RUNTIME_DEBUG_INFO_H_ #define ALLOY_RUNTIME_DEBUG_INFO_H_
#include <cstddef>
#include <cstdint> #include <cstdint>
namespace alloy { namespace alloy {

View File

@ -10,6 +10,7 @@
#include <alloy/runtime/raw_module.h> #include <alloy/runtime/raw_module.h>
#include <poly/platform.h> #include <poly/platform.h>
#include <poly/string.h>
namespace alloy { namespace alloy {
namespace runtime { namespace runtime {
@ -19,8 +20,9 @@ RawModule::RawModule(Runtime* runtime)
RawModule::~RawModule() {} RawModule::~RawModule() {}
int RawModule::LoadFile(uint64_t base_address, const std::string& path) { int RawModule::LoadFile(uint64_t base_address, const std::wstring& path) {
FILE* file = fopen(path.c_str(), "rb"); auto fixed_path = poly::to_string(poly::fix_path_separators(path));
FILE* file = fopen(fixed_path.c_str(), "rb");
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
size_t file_length = ftell(file); size_t file_length = ftell(file);
fseek(file, 0, SEEK_SET); fseek(file, 0, SEEK_SET);
@ -37,11 +39,11 @@ int RawModule::LoadFile(uint64_t base_address, const std::string& path) {
fclose(file); fclose(file);
// Setup debug info. // Setup debug info.
auto last_slash = path.find_last_of(poly::path_separator); auto last_slash = fixed_path.find_last_of(poly::path_separator);
if (last_slash != std::string::npos) { if (last_slash != std::string::npos) {
name_ = path.substr(last_slash + 1); name_ = fixed_path.substr(last_slash + 1);
} else { } else {
name_ = path; name_ = fixed_path;
} }
// TODO(benvanik): debug info // TODO(benvanik): debug info

View File

@ -22,7 +22,7 @@ class RawModule : public Module {
RawModule(Runtime* runtime); RawModule(Runtime* runtime);
~RawModule() override; ~RawModule() override;
int LoadFile(uint64_t base_address, const std::string& path); int LoadFile(uint64_t base_address, const std::wstring& path);
const std::string& name() const override { return name_; } const std::string& name() const override { return name_; }

View File

@ -79,7 +79,7 @@ void log_line(const char* file_path, const uint32_t line_number,
#if 0 // defined(OutputDebugString) #if 0 // defined(OutputDebugString)
OutputDebugStringA(buffer); OutputDebugStringA(buffer);
#else #else
fprintf(stdout, buffer); fprintf(stdout, "%s", buffer);
fflush(stdout); fflush(stdout);
#endif // OutputDebugString #endif // OutputDebugString
if (!FLAGS_fast_stdout) { if (!FLAGS_fast_stdout) {
@ -102,7 +102,7 @@ void handle_fatal(const char* file_path, const uint32_t line_number,
#if defined(OutputDebugString) #if defined(OutputDebugString)
OutputDebugStringA(buffer); OutputDebugStringA(buffer);
#else #else
fprintf(stderr, buffer); fprintf(stderr, "%s", buffer);
fflush(stderr); fflush(stderr);
#endif // OutputDebugString #endif // OutputDebugString
if (!FLAGS_fast_stdout) { if (!FLAGS_fast_stdout) {

View File

@ -89,142 +89,6 @@ static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
static const uint64_t k1 = 0xb492b66fbe98f273ULL; static const uint64_t k1 = 0xb492b66fbe98f273ULL;
static const uint64_t k2 = 0x9ae16a3b2f90404fULL; static const uint64_t k2 = 0x9ae16a3b2f90404fULL;
// Magic numbers for 32-bit hashing. Copied from Murmur3.
static const uint32_t c1 = 0xcc9e2d51;
static const uint32_t c2 = 0x1b873593;
// A 32-bit to 32-bit integer hash copied from Murmur3.
static uint32_t fmix(uint32_t h) {
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
static uint32_t Rotate32(uint32_t val, int shift) {
// Avoid shifting by 32: doing so yields an undefined result.
return shift == 0 ? val : ((val >> shift) | (val << (32 - shift)));
}
#undef PERMUTE3
#define PERMUTE3(a, b, c) \
do { \
std::swap(a, b); \
std::swap(a, c); \
} while (0)
static uint32_t Mur(uint32_t a, uint32_t h) {
// Helper from Murmur3 for combining two 32-bit values.
a *= c1;
a = Rotate32(a, 17);
a *= c2;
h ^= a;
h = Rotate32(h, 19);
return h * 5 + 0xe6546b64;
}
static uint32_t Hash32Len13to24(const char *s, size_t len) {
uint32_t a = Fetch32(s - 4 + (len >> 1));
uint32_t b = Fetch32(s + 4);
uint32_t c = Fetch32(s + len - 8);
uint32_t d = Fetch32(s + (len >> 1));
uint32_t e = Fetch32(s);
uint32_t f = Fetch32(s + len - 4);
uint32_t h = (uint32_t)len;
return fmix(Mur(f, Mur(e, Mur(d, Mur(c, Mur(b, Mur(a, h)))))));
}
static uint32_t Hash32Len0to4(const char *s, size_t len) {
uint32_t b = 0;
uint32_t c = 9;
for (size_t i = 0; i < len; i++) {
signed char v = s[i];
b = b * c1 + v;
c ^= b;
}
return fmix(Mur(b, Mur((uint32_t)len, c)));
}
static uint32_t Hash32Len5to12(const char *s, size_t len) {
uint32_t a = (uint32_t)len, b = (uint32_t)len * 5, c = 9, d = b;
a += Fetch32(s);
b += Fetch32(s + len - 4);
c += Fetch32(s + ((len >> 1) & 4));
return fmix(Mur(c, Mur(b, Mur(a, d))));
}
uint32_t CityHash32(const char *s, size_t len) {
if (len <= 24) {
return len <= 12
? (len <= 4 ? Hash32Len0to4(s, len) : Hash32Len5to12(s, len))
: Hash32Len13to24(s, len);
}
// len > 24
uint32_t h = (uint32_t)len, g = c1 * (uint32_t)len, f = g;
uint32_t a0 = Rotate32(Fetch32(s + len - 4) * c1, 17) * c2;
uint32_t a1 = Rotate32(Fetch32(s + len - 8) * c1, 17) * c2;
uint32_t a2 = Rotate32(Fetch32(s + len - 16) * c1, 17) * c2;
uint32_t a3 = Rotate32(Fetch32(s + len - 12) * c1, 17) * c2;
uint32_t a4 = Rotate32(Fetch32(s + len - 20) * c1, 17) * c2;
h ^= a0;
h = Rotate32(h, 19);
h = h * 5 + 0xe6546b64;
h ^= a2;
h = Rotate32(h, 19);
h = h * 5 + 0xe6546b64;
g ^= a1;
g = Rotate32(g, 19);
g = g * 5 + 0xe6546b64;
g ^= a3;
g = Rotate32(g, 19);
g = g * 5 + 0xe6546b64;
f += a4;
f = Rotate32(f, 19);
f = f * 5 + 0xe6546b64;
size_t iters = (len - 1) / 20;
do {
uint32_t a0 = Rotate32(Fetch32(s) * c1, 17) * c2;
uint32_t a1 = Fetch32(s + 4);
uint32_t a2 = Rotate32(Fetch32(s + 8) * c1, 17) * c2;
uint32_t a3 = Rotate32(Fetch32(s + 12) * c1, 17) * c2;
uint32_t a4 = Fetch32(s + 16);
h ^= a0;
h = Rotate32(h, 18);
h = h * 5 + 0xe6546b64;
f += a1;
f = Rotate32(f, 19);
f = f * c1;
g += a2;
g = Rotate32(g, 18);
g = g * 5 + 0xe6546b64;
h ^= a3 + a1;
h = Rotate32(h, 19);
h = h * 5 + 0xe6546b64;
g ^= a4;
g = poly::byte_swap(g) * 5;
h += a4 * 5;
h = poly::byte_swap(h);
f += a0;
PERMUTE3(f, h, g);
s += 20;
} while (--iters != 0);
g = Rotate32(g, 11) * c1;
g = Rotate32(g, 17) * c1;
f = Rotate32(f, 11) * c1;
f = Rotate32(f, 17) * c1;
h = Rotate32(h + g, 19);
h = h * 5 + 0xe6546b64;
h = Rotate32(h, 17) * c1;
h = Rotate32(h + f, 19);
h = h * 5 + 0xe6546b64;
h = Rotate32(h, 17) * c1;
return h;
}
// Bitwise right rotate. Normally this will compile to a single // Bitwise right rotate. Normally this will compile to a single
// instruction, especially if the shift is a manifest constant. // instruction, especially if the shift is a manifest constant.
static uint64_t Rotate(uint64_t val, int shift) { static uint64_t Rotate(uint64_t val, int shift) {

View File

@ -9,11 +9,15 @@
#include <xenia/core/socket.h> #include <xenia/core/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <poll.h>
#include <sys/socket.h> #include <sys/socket.h>
#include <unistd.h>
#include <poly/math.h>
void xe_socket_init() { void xe_socket_init() {
// No-op. // No-op.
@ -81,7 +85,7 @@ int xe_socket_bind_loopback(socket_t socket) {
socket_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK); socket_addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
socket_addr.sin_port = htons(0); socket_addr.sin_port = htons(0);
int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr)); int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr));
if (r == SOCKET_ERROR) { if (r == -1) {
return 1; return 1;
} }
return 0; return 0;
@ -108,7 +112,7 @@ int xe_socket_accept(socket_t socket, xe_socket_connection_t* out_client_info) {
int client_ip = client_addr.sin_addr.s_addr; int client_ip = client_addr.sin_addr.s_addr;
inet_ntop(AF_INET, &client_ip, out_client_info->addr, inet_ntop(AF_INET, &client_ip, out_client_info->addr,
XECOUNT(out_client_info->addr)); poly::countof(out_client_info->addr));
return 0; return 0;
} }
@ -177,7 +181,7 @@ int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read,
// Poll. // Poll.
int r; int r;
while ((r = poll(loop->events, XECOUNT(loop->events), -1)) == -1 && while ((r = poll(loop->events, poly::countof(loop->events), -1)) == -1 &&
errno == EINTR) errno == EINTR)
; ;
if (r == -1) { if (r == -1) {
@ -193,7 +197,7 @@ int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read,
loop->pending_queued_write = loop->events[1].revents != 0; loop->pending_queued_write = loop->events[1].revents != 0;
if (loop->pending_queued_write) { if (loop->pending_queued_write) {
uint8_t dummy; uint8_t dummy;
XEIGNORE(recv(loop->notify_rd_id, &dummy, 1, 0)); recv(loop->notify_rd_id, &dummy, 1, 0);
} }
loop->events[1].revents = 0; loop->events[1].revents = 0;
loop->events[1].events = POLLIN; loop->events[1].events = POLLIN;

View File

@ -15,7 +15,6 @@
#include <xenia/cpu/xenon_runtime.h> #include <xenia/cpu/xenon_runtime.h>
#include <xenia/cpu/xex_module.h> #include <xenia/cpu/xex_module.h>
using namespace alloy; using namespace alloy;
using namespace alloy::backend; using namespace alloy::backend;
using namespace alloy::frontend::ppc; using namespace alloy::frontend::ppc;
@ -23,37 +22,35 @@ using namespace alloy::runtime;
using namespace xe; using namespace xe;
using namespace xe::cpu; using namespace xe::cpu;
namespace { namespace {
void InitializeIfNeeded(); void InitializeIfNeeded();
void CleanupOnShutdown(); void CleanupOnShutdown();
void InitializeIfNeeded() { void InitializeIfNeeded() {
static bool has_initialized = false; static bool has_initialized = false;
if (has_initialized) { if (has_initialized) {
return; return;
}
has_initialized = true;
//ppc::RegisterDisasmCategoryAltivec();
//ppc::RegisterDisasmCategoryALU();
//ppc::RegisterDisasmCategoryControl();
//ppc::RegisterDisasmCategoryFPU();
//ppc::RegisterDisasmCategoryMemory();
atexit(CleanupOnShutdown);
} }
has_initialized = true;
void CleanupOnShutdown() { // ppc::RegisterDisasmCategoryAltivec();
} // ppc::RegisterDisasmCategoryALU();
// ppc::RegisterDisasmCategoryControl();
// ppc::RegisterDisasmCategoryFPU();
// ppc::RegisterDisasmCategoryMemory();
atexit(CleanupOnShutdown);
} }
void CleanupOnShutdown() {}
}
Processor::Processor(Emulator* emulator) : Processor::Processor(Emulator* emulator)
emulator_(emulator), export_resolver_(emulator->export_resolver()), : export_resolver_(emulator->export_resolver()),
runtime_(0), memory_(emulator->memory()), runtime_(0),
interrupt_thread_state_(NULL), memory_(emulator->memory()),
interrupt_thread_block_(0) { interrupt_thread_state_(NULL),
interrupt_thread_block_(0) {
InitializeIfNeeded(); InitializeIfNeeded();
} }
@ -101,11 +98,9 @@ int Processor::Setup() {
return result; return result;
} }
interrupt_thread_state_ = new XenonThreadState( interrupt_thread_state_ = new XenonThreadState(runtime_, 0, 16 * 1024, 0);
runtime_, 0, 16 * 1024, 0);
interrupt_thread_state_->set_name("Interrupt"); interrupt_thread_state_->set_name("Interrupt");
interrupt_thread_block_ = memory_->HeapAlloc( interrupt_thread_block_ = memory_->HeapAlloc(0, 2048, MEMORY_FLAG_ZERO);
0, 2048, MEMORY_FLAG_ZERO);
interrupt_thread_state_->context()->r[13] = interrupt_thread_block_; interrupt_thread_state_->context()->r[13] = interrupt_thread_block_;
return 0; return 0;
@ -136,9 +131,8 @@ int Processor::Execute(XenonThreadState* thread_state, uint64_t address) {
return 0; return 0;
} }
uint64_t Processor::Execute( uint64_t Processor::Execute(XenonThreadState* thread_state, uint64_t address,
XenonThreadState* thread_state, uint64_t address, uint64_t args[], uint64_t args[], size_t arg_count) {
size_t arg_count) {
SCOPE_profile_cpu_f("cpu"); SCOPE_profile_cpu_f("cpu");
PPCContext* context = thread_state->context(); PPCContext* context = thread_state->context();
@ -163,8 +157,8 @@ void Processor::LowerIrql(Irql old_value) {
reinterpret_cast<volatile uint32_t*>(&irql_)); reinterpret_cast<volatile uint32_t*>(&irql_));
} }
uint64_t Processor::ExecuteInterrupt( uint64_t Processor::ExecuteInterrupt(uint32_t cpu, uint64_t address,
uint32_t cpu, uint64_t address, uint64_t args[], size_t arg_count) { uint64_t args[], size_t arg_count) {
SCOPE_profile_cpu_f("cpu"); SCOPE_profile_cpu_f("cpu");
// Acquire lock on interrupt thread (we can only dispatch one at a time). // Acquire lock on interrupt thread (we can only dispatch one at a time).

View File

@ -53,7 +53,6 @@ class Processor {
size_t arg_count); size_t arg_count);
private: private:
Emulator* emulator_;
ExportResolver* export_resolver_; ExportResolver* export_resolver_;
XenonRuntime* runtime_; XenonRuntime* runtime_;

View File

@ -12,31 +12,25 @@
#include <xenia/core.h> #include <xenia/core.h>
namespace xe { namespace xe {
namespace gpu { namespace gpu {
namespace xenos { namespace xenos {
#if XE_COMPILER_MSVC #if XE_COMPILER_MSVC
#define XEPACKEDSTRUCT(name, value) \ #define XEPACKEDSTRUCT(name, value) \
__pragma(pack(push, 1)) struct name##_s value __pragma(pack(pop)); \ __pragma(pack(push, 1)) struct name##_s value __pragma(pack(pop)); \
typedef struct name##_s name; typedef struct name##_s name;
#define XEPACKEDSTRUCTANONYMOUS(value) \ #define XEPACKEDSTRUCTANONYMOUS(value) \
__pragma(pack(push, 1)) struct value __pragma(pack(pop)); __pragma(pack(push, 1)) struct value __pragma(pack(pop));
#define XEPACKEDUNION(name, value) \ #define XEPACKEDUNION(name, value) \
__pragma(pack(push, 1)) union name##_s value __pragma(pack(pop)); \ __pragma(pack(push, 1)) union name##_s value __pragma(pack(pop)); \
typedef union name##_s name; typedef union name##_s name;
#elif XE_COMPILER_GNUC #else
#define XEPACKEDSTRUCT(name, value) \ #define XEPACKEDSTRUCT(name, value) struct __attribute__((packed)) name
struct __attribute__((packed)) name #define XEPACKEDSTRUCTANONYMOUS(value) struct __attribute__((packed))
#define XEPACKEDSTRUCTANONYMOUS(value) \ #define XEPACKEDUNION(name, value) union __attribute__((packed)) name
struct __attribute__((packed))
#define XEPACKEDUNION(name, value) \
union __attribute__((packed)) name
#endif // MSVC #endif // MSVC
// This code comes from the freedreno project: // This code comes from the freedreno project:
// https://github.com/freedreno/freedreno/blob/master/includes/instr-a2xx.h // https://github.com/freedreno/freedreno/blob/master/includes/instr-a2xx.h
/* /*
@ -62,7 +56,6 @@ namespace xenos {
* SOFTWARE. * SOFTWARE.
*/ */
enum a2xx_sq_surfaceformat { enum a2xx_sq_surfaceformat {
FMT_1_REVERSE = 0, FMT_1_REVERSE = 0,
FMT_1 = 1, FMT_1 = 1,
@ -127,7 +120,6 @@ enum a2xx_sq_surfaceformat {
FMT_DXT3A_AS_1_1_1_1 = 61, FMT_DXT3A_AS_1_1_1_1 = 61,
}; };
/* /*
* ALU instructions: * ALU instructions:
*/ */
@ -221,51 +213,49 @@ typedef enum {
XEPACKEDSTRUCT(instr_alu_t, { XEPACKEDSTRUCT(instr_alu_t, {
/* dword0: */ /* dword0: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t vector_dest : 6; uint32_t vector_dest : 6;
uint32_t vector_dest_rel : 1; uint32_t vector_dest_rel : 1;
uint32_t low_precision_16b_fp : 1; uint32_t low_precision_16b_fp : 1;
uint32_t scalar_dest : 6; uint32_t scalar_dest : 6;
uint32_t scalar_dest_rel : 1; uint32_t scalar_dest_rel : 1;
uint32_t export_data : 1; uint32_t export_data : 1;
uint32_t vector_write_mask : 4; uint32_t vector_write_mask : 4;
uint32_t scalar_write_mask : 4; uint32_t scalar_write_mask : 4;
uint32_t vector_clamp : 1; uint32_t vector_clamp : 1;
uint32_t scalar_clamp : 1; uint32_t scalar_clamp : 1;
uint32_t scalar_opc : 6; // instr_scalar_opc_t uint32_t scalar_opc : 6; // instr_scalar_opc_t
}); });
/* dword1: */ /* dword1: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t src3_swiz : 8; uint32_t src3_swiz : 8;
uint32_t src2_swiz : 8; uint32_t src2_swiz : 8;
uint32_t src1_swiz : 8; uint32_t src1_swiz : 8;
uint32_t src3_reg_negate : 1; uint32_t src3_reg_negate : 1;
uint32_t src2_reg_negate : 1; uint32_t src2_reg_negate : 1;
uint32_t src1_reg_negate : 1; uint32_t src1_reg_negate : 1;
uint32_t pred_select : 2; uint32_t pred_select : 2;
uint32_t relative_addr : 1; uint32_t relative_addr : 1;
uint32_t const_1_rel_abs : 1; uint32_t const_1_rel_abs : 1;
uint32_t const_0_rel_abs : 1; uint32_t const_0_rel_abs : 1;
}); });
/* dword2: */ /* dword2: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t src3_reg : 6; uint32_t src3_reg : 6;
uint32_t src3_reg_select : 1; uint32_t src3_reg_select : 1;
uint32_t src3_reg_abs : 1; uint32_t src3_reg_abs : 1;
uint32_t src2_reg : 6; uint32_t src2_reg : 6;
uint32_t src2_reg_select : 1; uint32_t src2_reg_select : 1;
uint32_t src2_reg_abs : 1; uint32_t src2_reg_abs : 1;
uint32_t src1_reg : 6; uint32_t src1_reg : 6;
uint32_t src1_reg_select : 1; uint32_t src1_reg_select : 1;
uint32_t src1_reg_abs : 1; uint32_t src1_reg_abs : 1;
uint32_t vector_opc : 5; // instr_vector_opc_t uint32_t vector_opc : 5; // instr_vector_opc_t
uint32_t src3_sel : 1; uint32_t src3_sel : 1;
uint32_t src2_sel : 1; uint32_t src2_sel : 1;
uint32_t src1_sel : 1; uint32_t src1_sel : 1;
}); });
}); });
/* /*
* CF instructions: * CF instructions:
*/ */
@ -303,24 +293,22 @@ typedef enum {
XEPACKEDSTRUCT(instr_cf_exec_t, { XEPACKEDSTRUCT(instr_cf_exec_t, {
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t address : 12; uint32_t address : 12;
uint32_t count : 3; uint32_t count : 3;
uint32_t yeild : 1; uint32_t yeild : 1;
uint32_t serialize : 12; uint32_t serialize : 12;
uint32_t vc_hi : 4; uint32_t vc_hi : 4;
}); });
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t vc_lo : 2; /* vertex cache? */ uint32_t vc_lo : 2; /* vertex cache? */
uint32_t bool_addr : 8; uint32_t bool_addr : 8;
uint32_t condition : 1; uint32_t condition : 1;
uint32_t address_mode : 1; // instr_addr_mode_t uint32_t address_mode : 1; // instr_addr_mode_t
uint32_t opc : 4; // instr_cf_opc_t uint32_t opc : 4; // instr_cf_opc_t
}); });
bool is_cond_exec() const { bool is_cond_exec() const {
return (this->opc == COND_EXEC) || return (this->opc == COND_EXEC) || (this->opc == COND_EXEC_END) ||
(this->opc == COND_EXEC_END) || (this->opc == COND_PRED_EXEC) || (this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_PRED_EXEC) ||
(this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_EXEC_PRED_CLEAN) || (this->opc == COND_EXEC_PRED_CLEAN) ||
(this->opc == COND_EXEC_PRED_CLEAN_END); (this->opc == COND_EXEC_PRED_CLEAN_END);
} }
@ -328,89 +316,84 @@ XEPACKEDSTRUCT(instr_cf_exec_t, {
XEPACKEDSTRUCT(instr_cf_loop_t, { XEPACKEDSTRUCT(instr_cf_loop_t, {
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t address : 13; uint32_t address : 13;
uint32_t repeat : 1; uint32_t repeat : 1;
uint32_t reserved0 : 2; uint32_t reserved0 : 2;
uint32_t loop_id : 5; uint32_t loop_id : 5;
uint32_t pred_break : 1; uint32_t pred_break : 1;
uint32_t reserved1_hi : 10; uint32_t reserved1_hi : 10;
}); });
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t reserved1_lo : 10; uint32_t reserved1_lo : 10;
uint32_t condition : 1; uint32_t condition : 1;
uint32_t address_mode : 1; // instr_addr_mode_t uint32_t address_mode : 1; // instr_addr_mode_t
uint32_t opc : 4; // instr_cf_opc_t uint32_t opc : 4; // instr_cf_opc_t
}); });
}); });
XEPACKEDSTRUCT(instr_cf_jmp_call_t, { XEPACKEDSTRUCT(instr_cf_jmp_call_t, {
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t address : 13; uint32_t address : 13;
uint32_t force_call : 1; uint32_t force_call : 1;
uint32_t predicated_jmp : 1; uint32_t predicated_jmp : 1;
uint32_t reserved1_hi : 17; uint32_t reserved1_hi : 17;
}); });
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t reserved1_lo : 1; uint32_t reserved1_lo : 1;
uint32_t direction : 1; uint32_t direction : 1;
uint32_t bool_addr : 8; uint32_t bool_addr : 8;
uint32_t condition : 1; uint32_t condition : 1;
uint32_t address_mode : 1; // instr_addr_mode_t uint32_t address_mode : 1; // instr_addr_mode_t
uint32_t opc : 4; // instr_cf_opc_t uint32_t opc : 4; // instr_cf_opc_t
}); });
}); });
XEPACKEDSTRUCT(instr_cf_alloc_t, { XEPACKEDSTRUCT(instr_cf_alloc_t, {
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t size : 3; uint32_t size : 3;
uint32_t reserved0_hi : 29; uint32_t reserved0_hi : 29;
}); });
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t reserved0_lo : 8; uint32_t reserved0_lo : 8;
uint32_t no_serial : 1; uint32_t no_serial : 1;
uint32_t buffer_select : 2; // instr_alloc_type_t uint32_t buffer_select : 2; // instr_alloc_type_t
uint32_t alloc_mode : 1; uint32_t alloc_mode : 1;
uint32_t opc : 4; // instr_cf_opc_t uint32_t opc : 4; // instr_cf_opc_t
}); });
}); });
XEPACKEDUNION(instr_cf_t, { XEPACKEDUNION(instr_cf_t, {
instr_cf_exec_t exec; instr_cf_exec_t exec;
instr_cf_loop_t loop; instr_cf_loop_t loop;
instr_cf_jmp_call_t jmp_call; instr_cf_jmp_call_t jmp_call;
instr_cf_alloc_t alloc; instr_cf_alloc_t alloc;
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t : 32; uint32_t:
uint32_t : 12; 32;
uint32_t opc : 4; // instr_cf_opc_t uint32_t:
12;
uint32_t opc : 4; // instr_cf_opc_t
}); });
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t dword_0; uint32_t dword_0;
uint32_t dword_1; uint32_t dword_1;
}); });
bool is_exec() const { bool is_exec() const {
return (this->opc == EXEC) || return (this->opc == EXEC) || (this->opc == EXEC_END) ||
(this->opc == EXEC_END) || (this->opc == COND_EXEC) || (this->opc == COND_EXEC_END) ||
(this->opc == COND_EXEC) || (this->opc == COND_PRED_EXEC) || (this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_EXEC_END) ||
(this->opc == COND_PRED_EXEC) ||
(this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_EXEC_PRED_CLEAN) || (this->opc == COND_EXEC_PRED_CLEAN) ||
(this->opc == COND_EXEC_PRED_CLEAN_END); (this->opc == COND_EXEC_PRED_CLEAN_END);
} }
bool is_cond_exec() const { bool is_cond_exec() const {
return (this->opc == COND_EXEC) || return (this->opc == COND_EXEC) || (this->opc == COND_EXEC_END) ||
(this->opc == COND_EXEC_END) || (this->opc == COND_PRED_EXEC) || (this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_PRED_EXEC) ||
(this->opc == COND_PRED_EXEC_END) ||
(this->opc == COND_EXEC_PRED_CLEAN) || (this->opc == COND_EXEC_PRED_CLEAN) ||
(this->opc == COND_EXEC_PRED_CLEAN_END); (this->opc == COND_EXEC_PRED_CLEAN_END);
} }
}); });
/* /*
* FETCH instructions: * FETCH instructions:
*/ */
@ -431,7 +414,7 @@ typedef enum {
typedef enum { typedef enum {
TEX_FILTER_POINT = 0, TEX_FILTER_POINT = 0,
TEX_FILTER_LINEAR = 1, TEX_FILTER_LINEAR = 1,
TEX_FILTER_BASEMAP = 2, /* only applicable for mip-filter */ TEX_FILTER_BASEMAP = 2, /* only applicable for mip-filter */
TEX_FILTER_USE_FETCH_CONST = 3, TEX_FILTER_USE_FETCH_CONST = 3,
} instr_tex_filter_t; } instr_tex_filter_t;
@ -472,104 +455,105 @@ typedef enum a2xx_sq_surfaceformat instr_surf_fmt_t;
XEPACKEDSTRUCT(instr_fetch_tex_t, { XEPACKEDSTRUCT(instr_fetch_tex_t, {
/* dword0: */ /* dword0: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t opc : 5; // instr_fetch_opc_t uint32_t opc : 5; // instr_fetch_opc_t
uint32_t src_reg : 6; uint32_t src_reg : 6;
uint32_t src_reg_am : 1; uint32_t src_reg_am : 1;
uint32_t dst_reg : 6; uint32_t dst_reg : 6;
uint32_t dst_reg_am : 1; uint32_t dst_reg_am : 1;
uint32_t fetch_valid_only : 1; uint32_t fetch_valid_only : 1;
uint32_t const_idx : 5; uint32_t const_idx : 5;
uint32_t tx_coord_denorm : 1; uint32_t tx_coord_denorm : 1;
uint32_t src_swiz : 6; // xyz uint32_t src_swiz : 6; // xyz
}); });
/* dword1: */ /* dword1: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t dst_swiz : 12; // xyzw uint32_t dst_swiz : 12; // xyzw
uint32_t mag_filter : 2; // instr_tex_filter_t uint32_t mag_filter : 2; // instr_tex_filter_t
uint32_t min_filter : 2; // instr_tex_filter_t uint32_t min_filter : 2; // instr_tex_filter_t
uint32_t mip_filter : 2; // instr_tex_filter_t uint32_t mip_filter : 2; // instr_tex_filter_t
uint32_t aniso_filter : 3; // instr_aniso_filter_t uint32_t aniso_filter : 3; // instr_aniso_filter_t
uint32_t arbitrary_filter : 3; // instr_arbitrary_filter_t uint32_t arbitrary_filter : 3; // instr_arbitrary_filter_t
uint32_t vol_mag_filter : 2; // instr_tex_filter_t uint32_t vol_mag_filter : 2; // instr_tex_filter_t
uint32_t vol_min_filter : 2; // instr_tex_filter_t uint32_t vol_min_filter : 2; // instr_tex_filter_t
uint32_t use_comp_lod : 1; uint32_t use_comp_lod : 1;
uint32_t use_reg_lod : 1; uint32_t use_reg_lod : 1;
uint32_t unk : 1; uint32_t unk : 1;
uint32_t pred_select : 1; uint32_t pred_select : 1;
}); });
/* dword2: */ /* dword2: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t use_reg_gradients : 1; uint32_t use_reg_gradients : 1;
uint32_t sample_location : 1; // instr_sample_loc_t uint32_t sample_location : 1; // instr_sample_loc_t
uint32_t lod_bias : 7; uint32_t lod_bias : 7;
uint32_t unused : 5; uint32_t unused : 5;
uint32_t dimension : 2; // instr_dimension_t uint32_t dimension : 2; // instr_dimension_t
uint32_t offset_x : 5; uint32_t offset_x : 5;
uint32_t offset_y : 5; uint32_t offset_y : 5;
uint32_t offset_z : 5; uint32_t offset_z : 5;
uint32_t pred_condition : 1; uint32_t pred_condition : 1;
}); });
}); });
XEPACKEDSTRUCT(instr_fetch_vtx_t, { XEPACKEDSTRUCT(instr_fetch_vtx_t, {
/* dword0: */ /* dword0: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t opc : 5; // instr_fetch_opc_t uint32_t opc : 5; // instr_fetch_opc_t
uint32_t src_reg : 6; uint32_t src_reg : 6;
uint32_t src_reg_am : 1; uint32_t src_reg_am : 1;
uint32_t dst_reg : 6; uint32_t dst_reg : 6;
uint32_t dst_reg_am : 1; uint32_t dst_reg_am : 1;
uint32_t must_be_one : 1; uint32_t must_be_one : 1;
uint32_t const_index : 5; uint32_t const_index : 5;
uint32_t const_index_sel : 2; uint32_t const_index_sel : 2;
uint32_t reserved0 : 3; uint32_t reserved0 : 3;
uint32_t src_swiz : 2; uint32_t src_swiz : 2;
}); });
/* dword1: */ /* dword1: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t dst_swiz : 12; uint32_t dst_swiz : 12;
uint32_t format_comp_all : 1; /* '1' for signed, '0' for unsigned? */ uint32_t format_comp_all : 1; /* '1' for signed, '0' for unsigned? */
uint32_t num_format_all : 1; /* '0' for normalized, '1' for unnormalized */ uint32_t num_format_all : 1; /* '0' for normalized, '1' for unnormalized */
uint32_t signed_rf_mode_all : 1; uint32_t signed_rf_mode_all : 1;
uint32_t reserved1 : 1; uint32_t reserved1 : 1;
uint32_t format : 6; // instr_surf_fmt_t uint32_t format : 6; // instr_surf_fmt_t
uint32_t reserved2 : 1; uint32_t reserved2 : 1;
uint32_t exp_adjust_all : 7; uint32_t exp_adjust_all : 7;
uint32_t reserved3 : 1; uint32_t reserved3 : 1;
uint32_t pred_select : 1; uint32_t pred_select : 1;
}); });
/* dword2: */ /* dword2: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t stride : 8; uint32_t stride : 8;
uint32_t offset : 23; uint32_t offset : 23;
uint32_t pred_condition : 1; uint32_t pred_condition : 1;
}); });
}); });
XEPACKEDUNION(instr_fetch_t, { XEPACKEDUNION(instr_fetch_t, {
instr_fetch_tex_t tex; instr_fetch_tex_t tex;
instr_fetch_vtx_t vtx; instr_fetch_vtx_t vtx;
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
/* dword0: */ /* dword0: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t opc : 5; // instr_fetch_opc_t uint32_t opc : 5; // instr_fetch_opc_t
uint32_t : 27; uint32_t:
27;
}); });
/* dword1: */ /* dword1: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t : 32; uint32_t:
32;
}); });
/* dword2: */ /* dword2: */
XEPACKEDSTRUCTANONYMOUS({ XEPACKEDSTRUCTANONYMOUS({
uint32_t : 32; uint32_t:
32;
}); });
}); });
}); });
} // namespace xenos } // namespace xenos
} // namespace gpu } // namespace gpu
} // namespace xe } // namespace xe
#endif // XENIA_GPU_XENOS_UCODE_H_ #endif // XENIA_GPU_XENOS_UCODE_H_

View File

@ -20,22 +20,18 @@ namespace fs {
class DiscImageMemoryMapping : public MemoryMapping { class DiscImageMemoryMapping : public MemoryMapping {
public: public:
DiscImageMemoryMapping(uint8_t* address, size_t length, DiscImageMemoryMapping(uint8_t* address, size_t length)
poly::MappedMemory* mmap) : MemoryMapping(address, length) {}
: MemoryMapping(address, length), mmap_(mmap) {}
virtual ~DiscImageMemoryMapping() {} ~DiscImageMemoryMapping() override = default;
private:
poly::MappedMemory* mmap_;
}; };
DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path, DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path,
poly::MappedMemory* mmap, GDFXEntry* gdfx_entry) poly::MappedMemory* mmap, GDFXEntry* gdfx_entry)
: gdfx_entry_(gdfx_entry), : Entry(type, device, path),
gdfx_entry_iterator_(gdfx_entry->children.end()),
mmap_(mmap), mmap_(mmap),
Entry(type, device, path) {} gdfx_entry_(gdfx_entry),
gdfx_entry_iterator_(gdfx_entry->children.end()) {}
DiscImageEntry::~DiscImageEntry() {} DiscImageEntry::~DiscImageEntry() {}
@ -107,7 +103,7 @@ std::unique_ptr<MemoryMapping> DiscImageEntry::CreateMemoryMapping(
size_t real_length = size_t real_length =
length ? std::min(length, gdfx_entry_->size) : gdfx_entry_->size; length ? std::min(length, gdfx_entry_->size) : gdfx_entry_->size;
return std::make_unique<DiscImageMemoryMapping>(mmap_->data() + real_offset, return std::make_unique<DiscImageMemoryMapping>(mmap_->data() + real_offset,
real_length, mmap_); real_length);
} }
X_STATUS DiscImageEntry::Open(KernelState* kernel_state, Mode mode, bool async, X_STATUS DiscImageEntry::Open(KernelState* kernel_state, Mode mode, bool async,

View File

@ -27,21 +27,21 @@ class DiscImageEntry : public Entry {
public: public:
DiscImageEntry(Type type, Device* device, const char* path, DiscImageEntry(Type type, Device* device, const char* path,
poly::MappedMemory* mmap, GDFXEntry* gdfx_entry); poly::MappedMemory* mmap, GDFXEntry* gdfx_entry);
virtual ~DiscImageEntry(); ~DiscImageEntry() override;
poly::MappedMemory* mmap() const { return mmap_; } poly::MappedMemory* mmap() const { return mmap_; }
GDFXEntry* gdfx_entry() const { return gdfx_entry_; } GDFXEntry* gdfx_entry() const { return gdfx_entry_; }
virtual X_STATUS QueryInfo(XFileInfo* out_info); X_STATUS QueryInfo(XFileInfo* out_info) override;
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length,
const char* file_name, bool restart); const char* file_name, bool restart) override;
virtual bool can_map() { return true; } bool can_map() override { return true; }
virtual std::unique_ptr<MemoryMapping> CreateMemoryMapping( std::unique_ptr<MemoryMapping> CreateMemoryMapping(
Mode map_mode, const size_t offset, const size_t length); Mode map_mode, const size_t offset, const size_t length) override;
virtual X_STATUS Open(KernelState* kernel_state, Mode mode, bool async, X_STATUS Open(KernelState* kernel_state, Mode mode, bool async,
XFile** out_file); XFile** out_file) override;
private: private:
poly::MappedMemory* mmap_; poly::MappedMemory* mmap_;

View File

@ -22,20 +22,20 @@ class HostPathEntry : public Entry {
public: public:
HostPathEntry(Type type, Device* device, const char* path, HostPathEntry(Type type, Device* device, const char* path,
const std::wstring& local_path); const std::wstring& local_path);
virtual ~HostPathEntry(); ~HostPathEntry() override;
const std::wstring& local_path() { return local_path_; } const std::wstring& local_path() { return local_path_; }
virtual X_STATUS QueryInfo(XFileInfo* out_info); X_STATUS QueryInfo(XFileInfo* out_info) override;
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length,
const char* file_name, bool restart); const char* file_name, bool restart) override;
virtual bool can_map() { return true; } bool can_map() override { return true; }
virtual std::unique_ptr<MemoryMapping> CreateMemoryMapping( std::unique_ptr<MemoryMapping> CreateMemoryMapping(
Mode map_mode, const size_t offset, const size_t length); Mode map_mode, const size_t offset, const size_t length) override;
virtual X_STATUS Open(KernelState* kernel_state, Mode mode, bool async, X_STATUS Open(KernelState* kernel_state, Mode mode, bool async,
XFile** out_file); XFile** out_file) override;
private: private:
std::wstring local_path_; std::wstring local_path_;

View File

@ -20,12 +20,12 @@ STFSContainerEntry::STFSContainerEntry(Type type, Device* device,
const char* path, const char* path,
poly::MappedMemory* mmap, poly::MappedMemory* mmap,
STFSEntry* stfs_entry) STFSEntry* stfs_entry)
: stfs_entry_(stfs_entry), : Entry(type, device, path),
stfs_entry_iterator_(stfs_entry->children.end()),
mmap_(mmap), mmap_(mmap),
Entry(type, device, path) {} stfs_entry_(stfs_entry),
stfs_entry_iterator_(stfs_entry->children.end()) {}
STFSContainerEntry::~STFSContainerEntry() {} STFSContainerEntry::~STFSContainerEntry() = default;
X_STATUS STFSContainerEntry::QueryInfo(XFileInfo* out_info) { X_STATUS STFSContainerEntry::QueryInfo(XFileInfo* out_info) {
assert_not_null(out_info); assert_not_null(out_info);

View File

@ -27,17 +27,17 @@ class STFSContainerEntry : public Entry {
public: public:
STFSContainerEntry(Type type, Device* device, const char* path, STFSContainerEntry(Type type, Device* device, const char* path,
poly::MappedMemory* mmap, STFSEntry* stfs_entry); poly::MappedMemory* mmap, STFSEntry* stfs_entry);
virtual ~STFSContainerEntry(); ~STFSContainerEntry() override;
poly::MappedMemory* mmap() const { return mmap_; } poly::MappedMemory* mmap() const { return mmap_; }
STFSEntry* stfs_entry() const { return stfs_entry_; } STFSEntry* stfs_entry() const { return stfs_entry_; }
virtual X_STATUS QueryInfo(XFileInfo* out_info); X_STATUS QueryInfo(XFileInfo* out_info) override;
virtual X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length, X_STATUS QueryDirectory(XDirectoryInfo* out_info, size_t length,
const char* file_name, bool restart); const char* file_name, bool restart) override;
virtual X_STATUS Open(KernelState* kernel_state, Mode desired_access, X_STATUS Open(KernelState* kernel_state, Mode desired_access, bool async,
bool async, XFile** out_file); XFile** out_file) override;
private: private:
poly::MappedMemory* mmap_; poly::MappedMemory* mmap_;

View File

@ -21,7 +21,7 @@ namespace fs {
STFSContainerFile::STFSContainerFile(KernelState* kernel_state, Mode mode, STFSContainerFile::STFSContainerFile(KernelState* kernel_state, Mode mode,
STFSContainerEntry* entry) STFSContainerEntry* entry)
: entry_(entry), XFile(kernel_state, mode) {} : XFile(kernel_state, mode), entry_(entry) {}
STFSContainerFile::~STFSContainerFile() { delete entry_; } STFSContainerFile::~STFSContainerFile() { delete entry_; }

View File

@ -283,7 +283,7 @@ X_STATUS XThread::PlatformExit(int exit_code) {
static void* XThreadStartCallbackPthreads(void* param) { static void* XThreadStartCallbackPthreads(void* param) {
XThread* thread = reinterpret_cast<XThread*>(param); XThread* thread = reinterpret_cast<XThread*>(param);
xe::Profiler::ThreadEnter(thread->name()); xe::Profiler::ThreadEnter(thread->name().c_str());
current_thread_tls = thread; current_thread_tls = thread;
thread->Execute(); thread->Execute();
current_thread_tls = nullptr; current_thread_tls = nullptr;
@ -334,7 +334,7 @@ void XThread::PlatformDestroy() {
X_STATUS XThread::PlatformExit(int exit_code) { X_STATUS XThread::PlatformExit(int exit_code) {
// NOTE: does not return. // NOTE: does not return.
pthread_exit((void*)exit_code); pthread_exit(reinterpret_cast<void*>(exit_code));
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} }

View File

@ -161,7 +161,7 @@ void XUserModule::Dump() {
const xe_xex2_header_t* header = xe_xex2_get_header(xex_); const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
// XEX info. // XEX info.
printf("Module %s:\n\n", path_); printf("Module %s:\n\n", path_.c_str());
printf(" Module Flags: %.8X\n", header->module_flags); printf(" Module Flags: %.8X\n", header->module_flags);
printf(" System Flags: %.8X\n", header->system_flags); printf(" System Flags: %.8X\n", header->system_flags);
printf("\n"); printf("\n");
@ -292,7 +292,7 @@ void XUserModule::Dump() {
unimpl_count++; unimpl_count++;
} }
} }
printf(" Total: %4u\n", import_info_count); printf(" Total: %4zu\n", import_info_count);
printf(" Known: %3d%% (%d known, %d unknown)\n", printf(" Known: %3d%% (%d known, %d unknown)\n",
(int)(known_count / (float)import_info_count * 100.0f), (int)(known_count / (float)import_info_count * 100.0f),
known_count, unknown_count); known_count, unknown_count);

View File

@ -12,41 +12,37 @@
#include <xenia/core.h> #include <xenia/core.h>
namespace xe { namespace xe {
namespace ui { namespace ui {
class App; class App;
class Window; class Window;
class UIEvent { class UIEvent {
public: public:
UIEvent(Window* window = NULL) : UIEvent(Window* window = NULL) : window_(window) {}
window_(window) {} virtual ~UIEvent() = default;
virtual ~UIEvent() {}
Window* window() const { return window_; } Window* window() const { return window_; }
private: private:
Window* window_; Window* window_;
}; };
class KeyEvent : public UIEvent { class KeyEvent : public UIEvent {
public: public:
KeyEvent(Window* window, int key_code) : KeyEvent(Window* window, int key_code)
key_code_(key_code), : UIEvent(window), key_code_(key_code) {}
UIEvent(window) {} ~KeyEvent() override = default;
virtual ~KeyEvent() {}
int key_code() const { return key_code_; } int key_code() const { return key_code_; }
private: private:
int key_code_; int key_code_;
}; };
class MouseEvent : public UIEvent { class MouseEvent : public UIEvent {
public: public:
enum Button { enum Button {
MOUSE_BUTTON_NONE = 0, MOUSE_BUTTON_NONE = 0,
MOUSE_BUTTON_LEFT, MOUSE_BUTTON_LEFT,
@ -56,13 +52,11 @@ public:
MOUSE_BUTTON_X2, MOUSE_BUTTON_X2,
}; };
public: public:
MouseEvent(Window* window, MouseEvent(Window* window, Button button, int32_t x, int32_t y,
Button button, int32_t x, int32_t y, int32_t dx = 0, int32_t dy = 0)
int32_t dx = 0, int32_t dy = 0) : : UIEvent(window), button_(button), x_(x), y_(y), dx_(dx), dy_(dy) {}
button_(button), x_(x), y_(y), dx_(dx), dy_(dy), ~MouseEvent() override = default;
UIEvent(window) {}
virtual ~MouseEvent() {}
Button button() const { return button_; } Button button() const { return button_; }
int32_t x() const { return x_; } int32_t x() const { return x_; }
@ -70,17 +64,15 @@ public:
int32_t dx() const { return dx_; } int32_t dx() const { return dx_; }
int32_t dy() const { return dy_; } int32_t dy() const { return dy_; }
private: private:
Button button_; Button button_;
int32_t x_; int32_t x_;
int32_t y_; int32_t y_;
int32_t dx_; int32_t dx_;
int32_t dy_; int32_t dy_;
}; };
} // namespace ui } // namespace ui
} // namespace xe } // namespace xe
#endif // XENIA_UI_UI_EVENT_H_ #endif // XENIA_UI_UI_EVENT_H_

View File

@ -94,7 +94,7 @@ int main(std::vector<std::wstring>& args) {
runtime->Initialize(std::move(frontend), std::move(backend)); runtime->Initialize(std::move(frontend), std::move(backend));
auto module = std::make_unique<alloy::runtime::RawModule>(runtime.get()); auto module = std::make_unique<alloy::runtime::RawModule>(runtime.get());
module->LoadFile(0x00001000, "test\\codegen\\instr_add.bin"); module->LoadFile(0x00001000, L"test\\codegen\\instr_add.bin");
runtime->AddModule(std::move(module)); runtime->AddModule(std::move(module));
{ {