Fixing many clang warnings.

This commit is contained in:
Ben Vanik 2014-08-21 23:10:08 -07:00
parent 7ae303dfa2
commit 6f802c2432
14 changed files with 260 additions and 427 deletions

View File

@ -89,142 +89,6 @@ static const uint64_t k0 = 0xc3a5c85c97cb3127ULL;
static const uint64_t k1 = 0xb492b66fbe98f273ULL;
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
// instruction, especially if the shift is a manifest constant.
static uint64_t Rotate(uint64_t val, int shift) {
@ -374,4 +238,4 @@ uint64_t hash64(const void *data, size_t length, uint64_t seed) {
return HashLen16(CityHash64((const char *)data, length) - k2, seed);
}
} // namespace xe
} // namespace xe

View File

@ -9,11 +9,15 @@
#include <xenia/core/socket.h>
#include <fcntl.h>
#include <poll.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <netinet/tcp.h>
#include <poll.h>
#include <sys/socket.h>
#include <unistd.h>
#include <poly/math.h>
void xe_socket_init() {
// 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_port = htons(0);
int r = bind(socket, (struct sockaddr*)&socket_addr, sizeof(socket_addr));
if (r == SOCKET_ERROR) {
if (r == -1) {
return 1;
}
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;
inet_ntop(AF_INET, &client_ip, out_client_info->addr,
XECOUNT(out_client_info->addr));
poly::countof(out_client_info->addr));
return 0;
}
@ -177,7 +181,7 @@ int xe_socket_loop_poll(xe_socket_loop_t* loop, bool check_read,
// Poll.
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)
;
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;
if (loop->pending_queued_write) {
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].events = POLLIN;

View File

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

View File

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

View File

@ -20,22 +20,18 @@ namespace fs {
class DiscImageMemoryMapping : public MemoryMapping {
public:
DiscImageMemoryMapping(uint8_t* address, size_t length,
poly::MappedMemory* mmap)
: MemoryMapping(address, length), mmap_(mmap) {}
DiscImageMemoryMapping(uint8_t* address, size_t length)
: MemoryMapping(address, length) {}
virtual ~DiscImageMemoryMapping() {}
private:
poly::MappedMemory* mmap_;
~DiscImageMemoryMapping() override = default;
};
DiscImageEntry::DiscImageEntry(Type type, Device* device, const char* path,
poly::MappedMemory* mmap, GDFXEntry* gdfx_entry)
: gdfx_entry_(gdfx_entry),
gdfx_entry_iterator_(gdfx_entry->children.end()),
: Entry(type, device, path),
mmap_(mmap),
Entry(type, device, path) {}
gdfx_entry_(gdfx_entry),
gdfx_entry_iterator_(gdfx_entry->children.end()) {}
DiscImageEntry::~DiscImageEntry() {}
@ -107,7 +103,7 @@ std::unique_ptr<MemoryMapping> DiscImageEntry::CreateMemoryMapping(
size_t real_length =
length ? std::min(length, gdfx_entry_->size) : gdfx_entry_->size;
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,

View File

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

View File

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

View File

@ -20,12 +20,12 @@ STFSContainerEntry::STFSContainerEntry(Type type, Device* device,
const char* path,
poly::MappedMemory* mmap,
STFSEntry* stfs_entry)
: stfs_entry_(stfs_entry),
stfs_entry_iterator_(stfs_entry->children.end()),
: Entry(type, device, path),
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) {
assert_not_null(out_info);

View File

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

View File

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

View File

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

View File

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

View File

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