Fixing most clang-format errors.

This commit is contained in:
Ben Vanik 2015-05-03 10:27:50 -07:00
parent 6b22d35bfc
commit d1ee1512b9
39 changed files with 540 additions and 550 deletions

View File

@ -16,8 +16,8 @@ namespace xdb {
class Module { class Module {
public: public:
uint16_t module_id; uint16_t module_id;
// info // info
}; };
} // namespace xdb } // namespace xdb

View File

@ -96,7 +96,7 @@ class PostmortemCursor::Executor {
auto event_type = xe::load<EventType>(trace_ptr_); auto event_type = xe::load<EventType>(trace_ptr_);
switch (event_type) { switch (event_type) {
case EventType::END_OF_STREAM: { case EventType::END_OF_STREAM: {
eof_= true; eof_ = true;
cursor_->end_of_stream(); cursor_->end_of_stream();
return; return;
} }

View File

@ -12,9 +12,7 @@
namespace xdb { namespace xdb {
namespace sym { namespace sym {
Symbol* MapSymbolDatabase::Lookup(uint32_t address) { Symbol* MapSymbolDatabase::Lookup(uint32_t address) { return nullptr; }
return nullptr;
}
} // namespace sym } // namespace sym
} // namespace xdb } // namespace xdb

View File

@ -16,9 +16,9 @@ namespace xdb {
class Thread { class Thread {
public: public:
uint16_t thread_id; uint16_t thread_id;
// name // name
// etc // etc
}; };
} // namespace xdb } // namespace xdb

View File

@ -12,8 +12,6 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
DECLARE_string(apu); DECLARE_string(apu);
#endif // XENIA_APU_APU_PRIVATE_H_ #endif // XENIA_APU_APU_PRIVATE_H_

View File

@ -17,10 +17,7 @@ using namespace xe;
using namespace xe::apu; using namespace xe::apu;
using namespace xe::cpu; using namespace xe::cpu;
AudioDriver::AudioDriver(Emulator* emulator)
: emulator_(emulator), memory_(emulator->memory()) {}
AudioDriver::AudioDriver(Emulator* emulator) : AudioDriver::~AudioDriver() {}
emulator_(emulator), memory_(emulator->memory()) {
}
AudioDriver::~AudioDriver() {
}

View File

@ -11,23 +11,17 @@
#include "xenia/apu/apu-private.h" #include "xenia/apu/apu-private.h"
using namespace xe; using namespace xe;
using namespace xe::apu; using namespace xe::apu;
using namespace xe::apu::nop; using namespace xe::apu::nop;
NopAudioSystem::NopAudioSystem(Emulator* emulator) : AudioSystem(emulator) {}
NopAudioSystem::NopAudioSystem(Emulator* emulator) : NopAudioSystem::~NopAudioSystem() {}
AudioSystem(emulator) {
}
NopAudioSystem::~NopAudioSystem() { X_STATUS NopAudioSystem::CreateDriver(size_t index, HANDLE wait_handle,
} AudioDriver** out_driver) {
X_STATUS NopAudioSystem::CreateDriver(size_t index, HANDLE wait_handle, AudioDriver** out_driver) {
return X_STATUS_NOT_IMPLEMENTED; return X_STATUS_NOT_IMPLEMENTED;
} }
void NopAudioSystem::DestroyDriver(AudioDriver* driver) { void NopAudioSystem::DestroyDriver(AudioDriver* driver) { assert_always(); }
assert_always();
}

View File

@ -18,19 +18,15 @@ using namespace xe;
using namespace xe::apu; using namespace xe::apu;
using namespace xe::apu::xaudio2; using namespace xe::apu::xaudio2;
XAudio2AudioSystem::XAudio2AudioSystem(Emulator* emulator)
: AudioSystem(emulator) {}
XAudio2AudioSystem::XAudio2AudioSystem(Emulator* emulator) : XAudio2AudioSystem::~XAudio2AudioSystem() {}
AudioSystem(emulator) {
}
XAudio2AudioSystem::~XAudio2AudioSystem() { void XAudio2AudioSystem::Initialize() { AudioSystem::Initialize(); }
}
void XAudio2AudioSystem::Initialize() { X_STATUS XAudio2AudioSystem::CreateDriver(size_t index, HANDLE wait,
AudioSystem::Initialize(); AudioDriver** out_driver) {
}
X_STATUS XAudio2AudioSystem::CreateDriver(size_t index, HANDLE wait, AudioDriver** out_driver) {
assert_not_null(out_driver); assert_not_null(out_driver);
auto driver = new XAudio2AudioDriver(emulator_, wait); auto driver = new XAudio2AudioDriver(emulator_, wait);
driver->Initialize(); driver->Initialize();

View File

@ -103,7 +103,7 @@ class X64Emitter : public Xbyak::CodeGenerator {
Runtime* runtime() const { return runtime_; } Runtime* runtime() const { return runtime_; }
X64Backend* backend() const { return backend_; } X64Backend* backend() const { return backend_; }
const Xbyak::util::Cpu *cpu() const { return &cpu_; } const Xbyak::util::Cpu* cpu() const { return &cpu_; }
int Initialize(); int Initialize();
@ -193,7 +193,7 @@ class X64Emitter : public Xbyak::CodeGenerator {
X64Backend* backend_; X64Backend* backend_;
X64CodeCache* code_cache_; X64CodeCache* code_cache_;
XbyakAllocator* allocator_; XbyakAllocator* allocator_;
Xbyak::util::Cpu cpu_; // Host CPU info Xbyak::util::Cpu cpu_; // Host CPU info
hir::Instr* current_instr_; hir::Instr* current_instr_;

View File

@ -7,7 +7,6 @@
****************************************************************************** ******************************************************************************
*/ */
namespace { namespace {
enum KeyType { enum KeyType {
@ -36,16 +35,15 @@ union InstrKey {
}; };
uint32_t value; uint32_t value;
operator uint32_t() const { operator uint32_t() const { return value; }
return value;
}
InstrKey() : value(0) {} InstrKey() : value(0) {}
InstrKey(uint32_t v) : value(v) {} InstrKey(uint32_t v) : value(v) {}
InstrKey(const Instr* i) : value(0) { InstrKey(const Instr* i) : value(0) {
opcode = i->opcode->num; opcode = i->opcode->num;
uint32_t sig = i->opcode->signature; uint32_t sig = i->opcode->signature;
dest = GET_OPCODE_SIG_TYPE_DEST(sig) ? OPCODE_SIG_TYPE_V + i->dest->type : 0; dest =
GET_OPCODE_SIG_TYPE_DEST(sig) ? OPCODE_SIG_TYPE_V + i->dest->type : 0;
src1 = GET_OPCODE_SIG_TYPE_SRC1(sig); src1 = GET_OPCODE_SIG_TYPE_SRC1(sig);
if (src1 == OPCODE_SIG_TYPE_V) { if (src1 == OPCODE_SIG_TYPE_V) {
src1 += i->src1.value->type; src1 += i->src1.value->type;
@ -60,11 +58,8 @@ union InstrKey {
} }
} }
template <Opcode OPCODE, template <Opcode OPCODE, KeyType DEST = KEY_TYPE_X, KeyType SRC1 = KEY_TYPE_X,
KeyType DEST = KEY_TYPE_X, KeyType SRC2 = KEY_TYPE_X, KeyType SRC3 = KEY_TYPE_X>
KeyType SRC1 = KEY_TYPE_X,
KeyType SRC2 = KEY_TYPE_X,
KeyType SRC3 = KEY_TYPE_X>
struct Construct { struct Construct {
static const uint32_t value = static const uint32_t value =
(OPCODE) | (DEST << 8) | (SRC1 << 13) | (SRC2 << 18) | (SRC3 << 23); (OPCODE) | (DEST << 8) | (SRC1 << 13) | (SRC2 << 18) | (SRC3 << 23);
@ -88,27 +83,33 @@ struct Op : OpBase {
}; };
struct VoidOp : Op<VoidOp, KEY_TYPE_X> { struct VoidOp : Op<VoidOp, KEY_TYPE_X> {
protected: protected:
template <typename T, KeyType KEY_TYPE> friend struct Op; template <typename T, KeyType KEY_TYPE>
template <hir::Opcode OPCODE, typename... Ts> friend struct I; friend struct Op;
template <hir::Opcode OPCODE, typename... Ts>
friend struct I;
void Load(const Instr::Op& op) {} void Load(const Instr::Op& op) {}
}; };
struct OffsetOp : Op<OffsetOp, KEY_TYPE_O> { struct OffsetOp : Op<OffsetOp, KEY_TYPE_O> {
uint64_t value; uint64_t value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op; protected:
template <hir::Opcode OPCODE, typename... Ts> friend struct I; template <typename T, KeyType KEY_TYPE>
void Load(const Instr::Op& op) { friend struct Op;
this->value = op.offset; template <hir::Opcode OPCODE, typename... Ts>
} friend struct I;
void Load(const Instr::Op& op) { this->value = op.offset; }
}; };
struct SymbolOp : Op<SymbolOp, KEY_TYPE_S> { struct SymbolOp : Op<SymbolOp, KEY_TYPE_S> {
FunctionInfo* value; FunctionInfo* value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op; protected:
template <hir::Opcode OPCODE, typename... Ts> friend struct I; template <typename T, KeyType KEY_TYPE>
friend struct Op;
template <hir::Opcode OPCODE, typename... Ts>
friend struct I;
bool Load(const Instr::Op& op) { bool Load(const Instr::Op& op) {
this->value = op.symbol_info; this->value = op.symbol_info;
return true; return true;
@ -117,15 +118,17 @@ protected:
struct LabelOp : Op<LabelOp, KEY_TYPE_L> { struct LabelOp : Op<LabelOp, KEY_TYPE_L> {
hir::Label* value; hir::Label* value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op; protected:
template <hir::Opcode OPCODE, typename... Ts> friend struct I; template <typename T, KeyType KEY_TYPE>
void Load(const Instr::Op& op) { friend struct Op;
this->value = op.label; template <hir::Opcode OPCODE, typename... Ts>
} friend struct I;
void Load(const Instr::Op& op) { this->value = op.label; }
}; };
template <typename T, KeyType KEY_TYPE, typename REG_TYPE, typename CONST_TYPE, int TAG = -1> template <typename T, KeyType KEY_TYPE, typename REG_TYPE, typename CONST_TYPE,
int TAG = -1>
struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE, TAG>, KEY_TYPE> { struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE, TAG>, KEY_TYPE> {
typedef REG_TYPE reg_type; typedef REG_TYPE reg_type;
static const int tag = TAG; static const int tag = TAG;
@ -136,9 +139,7 @@ struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE, TAG>, KEY_TYPE> {
assert_true(!is_constant); assert_true(!is_constant);
return reg_; return reg_;
} }
operator const REG_TYPE&() const { operator const REG_TYPE&() const { return reg(); }
return reg();
}
bool IsEqual(const T& b) const { bool IsEqual(const T& b) const {
if (is_constant && b.is_constant) { if (is_constant && b.is_constant) {
return reinterpret_cast<const T*>(this)->constant() == b.constant(); return reinterpret_cast<const T*>(this)->constant() == b.constant();
@ -157,18 +158,10 @@ struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE, TAG>, KEY_TYPE> {
return false; return false;
} }
} }
bool operator== (const T& b) const { bool operator==(const T& b) const { return IsEqual(b); }
return IsEqual(b); bool operator!=(const T& b) const { return !IsEqual(b); }
} bool operator==(const Xbyak::Reg& b) const { return IsEqual(b); }
bool operator!= (const T& b) const { bool operator!=(const Xbyak::Reg& b) const { return !IsEqual(b); }
return !IsEqual(b);
}
bool operator== (const Xbyak::Reg& b) const {
return IsEqual(b);
}
bool operator!= (const Xbyak::Reg& b) const {
return !IsEqual(b);
}
void Load(const Instr::Op& op) { void Load(const Instr::Op& op) {
const Value* value = op.value; const Value* value = op.value;
this->value = value; this->value = value;
@ -177,7 +170,8 @@ struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE, TAG>, KEY_TYPE> {
X64Emitter::SetupReg(value, reg_); X64Emitter::SetupReg(value, reg_);
} }
} }
protected:
protected:
REG_TYPE reg_; REG_TYPE reg_;
}; };
@ -255,30 +249,34 @@ struct TagTable {
Instr::Op op; Instr::Op op;
} table[16]; } table[16];
template <typename T, typename std::enable_if<T::key_type == KEY_TYPE_X>::type* = nullptr> template <typename T,
typename std::enable_if<T::key_type == KEY_TYPE_X>::type* = nullptr>
bool CheckTag(const Instr::Op& op) { bool CheckTag(const Instr::Op& op) {
return true; return true;
} }
template <typename T, typename std::enable_if<T::key_type == KEY_TYPE_L>::type* = nullptr> template <typename T,
typename std::enable_if<T::key_type == KEY_TYPE_L>::type* = nullptr>
bool CheckTag(const Instr::Op& op) { bool CheckTag(const Instr::Op& op) {
return true; return true;
} }
template <typename T, typename std::enable_if<T::key_type == KEY_TYPE_O>::type* = nullptr> template <typename T,
typename std::enable_if<T::key_type == KEY_TYPE_O>::type* = nullptr>
bool CheckTag(const Instr::Op& op) { bool CheckTag(const Instr::Op& op) {
return true; return true;
} }
template <typename T, typename std::enable_if<T::key_type == KEY_TYPE_S>::type* = nullptr> template <typename T,
typename std::enable_if<T::key_type == KEY_TYPE_S>::type* = nullptr>
bool CheckTag(const Instr::Op& op) { bool CheckTag(const Instr::Op& op) {
return true; return true;
} }
template <typename T, typename std::enable_if<T::key_type >= KEY_TYPE_V_I8>::type* = nullptr> template <typename T, typename std::enable_if<T::key_type >=
KEY_TYPE_V_I8>::type* = nullptr>
bool CheckTag(const Instr::Op& op) { bool CheckTag(const Instr::Op& op) {
const Value* value = op.value; const Value* value = op.value;
if (T::tag == -1) { if (T::tag == -1) {
return true; return true;
} }
if (table[T::tag].valid && if (table[T::tag].valid && table[T::tag].op.value != value) {
table[T::tag].op.value != value) {
return false; return false;
} }
table[T::tag].valid = true; table[T::tag].valid = true;
@ -292,7 +290,8 @@ struct DestField;
template <typename DEST> template <typename DEST>
struct DestField<DEST> { struct DestField<DEST> {
DEST dest; DEST dest;
protected:
protected:
bool LoadDest(const Instr* i, TagTable& tag_table) { bool LoadDest(const Instr* i, TagTable& tag_table) {
Instr::Op op; Instr::Op op;
op.value = i->dest; op.value = i->dest;
@ -305,10 +304,8 @@ protected:
}; };
template <> template <>
struct DestField<VoidOp> { struct DestField<VoidOp> {
protected: protected:
bool LoadDest(const Instr* i, TagTable& tag_table) { bool LoadDest(const Instr* i, TagTable& tag_table) { return true; }
return true;
}
}; };
template <hir::Opcode OPCODE, typename... Ts> template <hir::Opcode OPCODE, typename... Ts>
@ -317,14 +314,16 @@ template <hir::Opcode OPCODE, typename DEST>
struct I<OPCODE, DEST> : DestField<DEST> { struct I<OPCODE, DEST> : DestField<DEST> {
typedef DestField<DEST> BASE; typedef DestField<DEST> BASE;
static const hir::Opcode opcode = OPCODE; static const hir::Opcode opcode = OPCODE;
static const uint32_t key = InstrKey::Construct<OPCODE, DEST::key_type>::value; static const uint32_t key =
InstrKey::Construct<OPCODE, DEST::key_type>::value;
static const KeyType dest_type = DEST::key_type; static const KeyType dest_type = DEST::key_type;
const Instr* instr; const Instr* instr;
protected:
template <typename... Ti> friend struct SequenceFields; protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) { bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key && if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table)) {
BASE::LoadDest(i, tag_table)) {
instr = i; instr = i;
return true; return true;
} }
@ -335,16 +334,18 @@ template <hir::Opcode OPCODE, typename DEST, typename SRC1>
struct I<OPCODE, DEST, SRC1> : DestField<DEST> { struct I<OPCODE, DEST, SRC1> : DestField<DEST> {
typedef DestField<DEST> BASE; typedef DestField<DEST> BASE;
static const hir::Opcode opcode = OPCODE; static const hir::Opcode opcode = OPCODE;
static const uint32_t key = InstrKey::Construct<OPCODE, DEST::key_type, SRC1::key_type>::value; static const uint32_t key =
InstrKey::Construct<OPCODE, DEST::key_type, SRC1::key_type>::value;
static const KeyType dest_type = DEST::key_type; static const KeyType dest_type = DEST::key_type;
static const KeyType src1_type = SRC1::key_type; static const KeyType src1_type = SRC1::key_type;
const Instr* instr; const Instr* instr;
SRC1 src1; SRC1 src1;
protected:
template <typename... Ti> friend struct SequenceFields; protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) { bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key && if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1)) { tag_table.CheckTag<SRC1>(i->src1)) {
instr = i; instr = i;
src1.Load(i->src1); src1.Load(i->src1);
@ -357,18 +358,20 @@ template <hir::Opcode OPCODE, typename DEST, typename SRC1, typename SRC2>
struct I<OPCODE, DEST, SRC1, SRC2> : DestField<DEST> { struct I<OPCODE, DEST, SRC1, SRC2> : DestField<DEST> {
typedef DestField<DEST> BASE; typedef DestField<DEST> BASE;
static const hir::Opcode opcode = OPCODE; static const hir::Opcode opcode = OPCODE;
static const uint32_t key = InstrKey::Construct<OPCODE, DEST::key_type, SRC1::key_type, SRC2::key_type>::value; static const uint32_t key = InstrKey::Construct<
OPCODE, DEST::key_type, SRC1::key_type, SRC2::key_type>::value;
static const KeyType dest_type = DEST::key_type; static const KeyType dest_type = DEST::key_type;
static const KeyType src1_type = SRC1::key_type; static const KeyType src1_type = SRC1::key_type;
static const KeyType src2_type = SRC2::key_type; static const KeyType src2_type = SRC2::key_type;
const Instr* instr; const Instr* instr;
SRC1 src1; SRC1 src1;
SRC2 src2; SRC2 src2;
protected:
template <typename... Ti> friend struct SequenceFields; protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) { bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key && if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1) && tag_table.CheckTag<SRC1>(i->src1) &&
tag_table.CheckTag<SRC2>(i->src2)) { tag_table.CheckTag<SRC2>(i->src2)) {
instr = i; instr = i;
@ -379,11 +382,14 @@ protected:
return false; return false;
} }
}; };
template <hir::Opcode OPCODE, typename DEST, typename SRC1, typename SRC2, typename SRC3> template <hir::Opcode OPCODE, typename DEST, typename SRC1, typename SRC2,
typename SRC3>
struct I<OPCODE, DEST, SRC1, SRC2, SRC3> : DestField<DEST> { struct I<OPCODE, DEST, SRC1, SRC2, SRC3> : DestField<DEST> {
typedef DestField<DEST> BASE; typedef DestField<DEST> BASE;
static const hir::Opcode opcode = OPCODE; static const hir::Opcode opcode = OPCODE;
static const uint32_t key = InstrKey::Construct<OPCODE, DEST::key_type, SRC1::key_type, SRC2::key_type, SRC3::key_type>::value; static const uint32_t key =
InstrKey::Construct<OPCODE, DEST::key_type, SRC1::key_type,
SRC2::key_type, SRC3::key_type>::value;
static const KeyType dest_type = DEST::key_type; static const KeyType dest_type = DEST::key_type;
static const KeyType src1_type = SRC1::key_type; static const KeyType src1_type = SRC1::key_type;
static const KeyType src2_type = SRC2::key_type; static const KeyType src2_type = SRC2::key_type;
@ -392,11 +398,12 @@ struct I<OPCODE, DEST, SRC1, SRC2, SRC3> : DestField<DEST> {
SRC1 src1; SRC1 src1;
SRC2 src2; SRC2 src2;
SRC3 src3; SRC3 src3;
protected:
template <typename... Ti> friend struct SequenceFields; protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) { bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key && if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1) && tag_table.CheckTag<SRC1>(i->src1) &&
tag_table.CheckTag<SRC2>(i->src2) && tag_table.CheckTag<SRC2>(i->src2) &&
tag_table.CheckTag<SRC3>(i->src3)) { tag_table.CheckTag<SRC3>(i->src3)) {
@ -415,8 +422,10 @@ struct SequenceFields;
template <typename I1> template <typename I1>
struct SequenceFields<I1> { struct SequenceFields<I1> {
I1 i1; I1 i1;
protected:
template <typename SEQ, typename... Ti> friend struct Sequence; protected:
template <typename SEQ, typename... Ti>
friend struct Sequence;
bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) { bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) {
if (i1.Load(i, tag_table)) { if (i1.Load(i, tag_table)) {
*new_tail = i->next; *new_tail = i->next;
@ -428,8 +437,10 @@ protected:
template <typename I1, typename I2> template <typename I1, typename I2>
struct SequenceFields<I1, I2> : SequenceFields<I1> { struct SequenceFields<I1, I2> : SequenceFields<I1> {
I2 i2; I2 i2;
protected:
template <typename SEQ, typename... Ti> friend struct Sequence; protected:
template <typename SEQ, typename... Ti>
friend struct Sequence;
bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) { bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) {
if (SequenceFields<I1>::Check(i, tag_table, new_tail)) { if (SequenceFields<I1>::Check(i, tag_table, new_tail)) {
auto ni = i->next; auto ni = i->next;
@ -444,8 +455,10 @@ protected:
template <typename I1, typename I2, typename I3> template <typename I1, typename I2, typename I3>
struct SequenceFields<I1, I2, I3> : SequenceFields<I1, I2> { struct SequenceFields<I1, I2, I3> : SequenceFields<I1, I2> {
I3 i3; I3 i3;
protected:
template <typename SEQ, typename... Ti> friend struct Sequence; protected:
template <typename SEQ, typename... Ti>
friend struct Sequence;
bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) { bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) {
if (SequenceFields<I1, I2>::Check(i, tag_table, new_tail)) { if (SequenceFields<I1, I2>::Check(i, tag_table, new_tail)) {
auto ni = i->next; auto ni = i->next;
@ -460,8 +473,10 @@ protected:
template <typename I1, typename I2, typename I3, typename I4> template <typename I1, typename I2, typename I3, typename I4>
struct SequenceFields<I1, I2, I3, I4> : SequenceFields<I1, I2, I3> { struct SequenceFields<I1, I2, I3, I4> : SequenceFields<I1, I2, I3> {
I4 i4; I4 i4;
protected:
template <typename SEQ, typename... Ti> friend struct Sequence; protected:
template <typename SEQ, typename... Ti>
friend struct Sequence;
bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) { bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) {
if (SequenceFields<I1, I2, I3>::Check(i, tag_table, new_tail)) { if (SequenceFields<I1, I2, I3>::Check(i, tag_table, new_tail)) {
auto ni = i->next; auto ni = i->next;
@ -476,8 +491,10 @@ protected:
template <typename I1, typename I2, typename I3, typename I4, typename I5> template <typename I1, typename I2, typename I3, typename I4, typename I5>
struct SequenceFields<I1, I2, I3, I4, I5> : SequenceFields<I1, I2, I3, I4> { struct SequenceFields<I1, I2, I3, I4, I5> : SequenceFields<I1, I2, I3, I4> {
I5 i5; I5 i5;
protected:
template <typename SEQ, typename... Ti> friend struct Sequence; protected:
template <typename SEQ, typename... Ti>
friend struct Sequence;
bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) { bool Check(const Instr* i, TagTable& tag_table, const Instr** new_tail) {
if (SequenceFields<I1, I2, I3, I4>::Check(i, tag_table, new_tail)) { if (SequenceFields<I1, I2, I3, I4>::Check(i, tag_table, new_tail)) {
auto ni = i->next; auto ni = i->next;
@ -528,7 +545,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;
// TODO(benvanik): find a way to do this cross-compiler. // TODO(benvanik): find a way to do this cross-compiler.
#if XE_COMPILER_MSVC #if XE_COMPILER_MSVC
static uint32_t head_key() { return T::key; } static uint32_t head_key() { return T::key; }
#else #else
@ -539,9 +556,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
template <typename REG_FN> template <typename REG_FN>
static void EmitUnaryOp( static void EmitUnaryOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const REG_FN& reg_fn) {
const REG_FN& reg_fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
e.mov(i.dest, i.src1.constant()); e.mov(i.dest, i.src1.constant());
reg_fn(e, i.dest); reg_fn(e, i.dest);
@ -554,9 +570,9 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
template <typename REG_REG_FN, typename REG_CONST_FN> template <typename REG_REG_FN, typename REG_CONST_FN>
static void EmitCommutativeBinaryOp( static void EmitCommutativeBinaryOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const REG_REG_FN& reg_reg_fn,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) { const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
if (i.dest == i.src2) { if (i.dest == i.src2) {
@ -596,9 +612,9 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
} }
template <typename REG_REG_FN, typename REG_CONST_FN> template <typename REG_REG_FN, typename REG_CONST_FN>
static void EmitAssociativeBinaryOp( static void EmitAssociativeBinaryOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const REG_REG_FN& reg_reg_fn,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) { const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
if (i.dest == i.src2) { if (i.dest == i.src2) {
@ -645,8 +661,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
template <typename FN> template <typename FN>
static void EmitCommutativeBinaryXmmOp( static void EmitCommutativeBinaryXmmOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const FN& fn) { const FN& fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
e.LoadConstantXmm(e.xmm0, i.src1.constant()); e.LoadConstantXmm(e.xmm0, i.src1.constant());
@ -660,8 +676,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
template <typename FN> template <typename FN>
static void EmitAssociativeBinaryXmmOp( static void EmitAssociativeBinaryXmmOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const FN& fn) { const FN& fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
e.LoadConstantXmm(e.xmm0, i.src1.constant()); e.LoadConstantXmm(e.xmm0, i.src1.constant());
@ -675,9 +691,9 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
template <typename REG_REG_FN, typename REG_CONST_FN> template <typename REG_REG_FN, typename REG_CONST_FN>
static void EmitCommutativeCompareOp( static void EmitCommutativeCompareOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const REG_REG_FN& reg_reg_fn,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) { const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
if (i.src1.ConstantFitsIn32Reg()) { if (i.src1.ConstantFitsIn32Reg()) {
@ -700,13 +716,14 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
} }
template <typename REG_REG_FN, typename REG_CONST_FN> template <typename REG_REG_FN, typename REG_CONST_FN>
static void EmitAssociativeCompareOp( static void EmitAssociativeCompareOp(X64Emitter& e, const EmitArgType& i,
X64Emitter& e, const EmitArgType& i, const REG_REG_FN& reg_reg_fn,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) { const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) { if (i.src1.is_constant) {
assert_true(!i.src2.is_constant); assert_true(!i.src2.is_constant);
if (i.src1.ConstantFitsIn32Reg()) { if (i.src1.ConstantFitsIn32Reg()) {
reg_const_fn(e, i.dest, i.src2, static_cast<int32_t>(i.src1.constant()), true); reg_const_fn(e, i.dest, i.src2, static_cast<int32_t>(i.src1.constant()),
true);
} else { } else {
auto temp = GetTempReg<typename decltype(i.src1)::reg_type>(e); auto temp = GetTempReg<typename decltype(i.src1)::reg_type>(e);
e.mov(temp, i.src1.constant()); e.mov(temp, i.src1.constant());
@ -714,7 +731,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
} }
} else if (i.src2.is_constant) { } else if (i.src2.is_constant) {
if (i.src2.ConstantFitsIn32Reg()) { if (i.src2.ConstantFitsIn32Reg()) {
reg_const_fn(e, i.dest, i.src1, static_cast<int32_t>(i.src2.constant()), false); reg_const_fn(e, i.dest, i.src1, static_cast<int32_t>(i.src2.constant()),
false);
} else { } else {
auto temp = GetTempReg<typename decltype(i.src2)::reg_type>(e); auto temp = GetTempReg<typename decltype(i.src2)::reg_type>(e);
e.mov(temp, i.src2.constant()); e.mov(temp, i.src2.constant());
@ -739,7 +757,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() {
@ -747,9 +765,7 @@ void Register() {
Register<Tn, Ts...>(); Register<Tn, Ts...>();
}; };
#define EMITTER_OPCODE_TABLE(name, ...) \ #define EMITTER_OPCODE_TABLE(name, ...) \
void Register_##name() { \ void Register_##name() { Register<__VA_ARGS__>(); }
Register<__VA_ARGS__>(); \
}
#define MATCH(...) __VA_ARGS__ #define MATCH(...) __VA_ARGS__
#define EMITTER(name, match) struct name : SingleSequence<name, match> #define EMITTER(name, match) struct name : SingleSequence<name, match>

View File

@ -50,8 +50,7 @@ int DebugAgent::SetupTracing(const std::string& trace_file, uint64_t capacity) {
auto file_path = xe::to_wstring(trace_file); auto file_path = xe::to_wstring(trace_file);
file_ = CreateFile(file_path.c_str(), GENERIC_READ | GENERIC_WRITE, file_ = CreateFile(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY, FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY, nullptr);
nullptr);
if (!file_) { if (!file_) {
XELOGE("Could not open trace file for writing"); XELOGE("Could not open trace file for writing");
return 1; return 1;

View File

@ -48,7 +48,8 @@ class Blitter {
GLuint dest_texture, Rect2D dest_rect); GLuint dest_texture, Rect2D dest_rect);
private: private:
void Draw(GLuint src_texture, Rect2D src_rect, Rect2D dest_rect, GLenum filter); void Draw(GLuint src_texture, Rect2D src_rect, Rect2D dest_rect,
GLenum filter);
GLuint vertex_program_; GLuint vertex_program_;
GLuint color_fragment_program_; GLuint color_fragment_program_;

View File

@ -2106,31 +2106,29 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateBlendState() {
draw_batcher_.Flush(DrawBatcher::FlushMode::kStateChange); draw_batcher_.Flush(DrawBatcher::FlushMode::kStateChange);
static const GLenum blend_map[] = { static const GLenum blend_map[] = {/* 0 */ GL_ZERO,
/* 0 */ GL_ZERO, /* 1 */ GL_ONE,
/* 1 */ GL_ONE, /* 2 */ GL_ZERO, // ?
/* 2 */ GL_ZERO, // ? /* 3 */ GL_ZERO, // ?
/* 3 */ GL_ZERO, // ? /* 4 */ GL_SRC_COLOR,
/* 4 */ GL_SRC_COLOR, /* 5 */ GL_ONE_MINUS_SRC_COLOR,
/* 5 */ GL_ONE_MINUS_SRC_COLOR, /* 6 */ GL_SRC_ALPHA,
/* 6 */ GL_SRC_ALPHA, /* 7 */ GL_ONE_MINUS_SRC_ALPHA,
/* 7 */ GL_ONE_MINUS_SRC_ALPHA, /* 8 */ GL_DST_COLOR,
/* 8 */ GL_DST_COLOR, /* 9 */ GL_ONE_MINUS_DST_COLOR,
/* 9 */ GL_ONE_MINUS_DST_COLOR, /* 10 */ GL_DST_ALPHA,
/* 10 */ GL_DST_ALPHA, /* 11 */ GL_ONE_MINUS_DST_ALPHA,
/* 11 */ GL_ONE_MINUS_DST_ALPHA, /* 12 */ GL_CONSTANT_COLOR,
/* 12 */ GL_CONSTANT_COLOR, /* 13 */ GL_ONE_MINUS_CONSTANT_COLOR,
/* 13 */ GL_ONE_MINUS_CONSTANT_COLOR, /* 14 */ GL_CONSTANT_ALPHA,
/* 14 */ GL_CONSTANT_ALPHA, /* 15 */ GL_ONE_MINUS_CONSTANT_ALPHA,
/* 15 */ GL_ONE_MINUS_CONSTANT_ALPHA, /* 16 */ GL_SRC_ALPHA_SATURATE,
/* 16 */ GL_SRC_ALPHA_SATURATE,
}; };
static const GLenum blend_op_map[] = { static const GLenum blend_op_map[] = {/* 0 */ GL_FUNC_ADD,
/* 0 */ GL_FUNC_ADD, /* 1 */ GL_FUNC_SUBTRACT,
/* 1 */ GL_FUNC_SUBTRACT, /* 2 */ GL_MIN,
/* 2 */ GL_MIN, /* 3 */ GL_MAX,
/* 3 */ GL_MAX, /* 4 */ GL_FUNC_REVERSE_SUBTRACT,
/* 4 */ GL_FUNC_REVERSE_SUBTRACT,
}; };
for (int i = 0; i < xe::countof(regs.rb_blendcontrol); ++i) { for (int i = 0; i < xe::countof(regs.rb_blendcontrol); ++i) {
uint32_t blend_control = regs.rb_blendcontrol[i]; uint32_t blend_control = regs.rb_blendcontrol[i];
@ -2183,25 +2181,23 @@ CommandProcessor::UpdateStatus CommandProcessor::UpdateDepthStencilState() {
draw_batcher_.Flush(DrawBatcher::FlushMode::kStateChange); draw_batcher_.Flush(DrawBatcher::FlushMode::kStateChange);
static const GLenum compare_func_map[] = { static const GLenum compare_func_map[] = {/* 0 */ GL_NEVER,
/* 0 */ GL_NEVER, /* 1 */ GL_LESS,
/* 1 */ GL_LESS, /* 2 */ GL_EQUAL,
/* 2 */ GL_EQUAL, /* 3 */ GL_LEQUAL,
/* 3 */ GL_LEQUAL, /* 4 */ GL_GREATER,
/* 4 */ GL_GREATER, /* 5 */ GL_NOTEQUAL,
/* 5 */ GL_NOTEQUAL, /* 6 */ GL_GEQUAL,
/* 6 */ GL_GEQUAL, /* 7 */ GL_ALWAYS,
/* 7 */ GL_ALWAYS,
}; };
static const GLenum stencil_op_map[] = { static const GLenum stencil_op_map[] = {/* 0 */ GL_KEEP,
/* 0 */ GL_KEEP, /* 1 */ GL_ZERO,
/* 1 */ GL_ZERO, /* 2 */ GL_REPLACE,
/* 2 */ GL_REPLACE, /* 3 */ GL_INCR_WRAP,
/* 3 */ GL_INCR_WRAP, /* 4 */ GL_DECR_WRAP,
/* 4 */ GL_DECR_WRAP, /* 5 */ GL_INVERT,
/* 5 */ GL_INVERT, /* 6 */ GL_INCR,
/* 6 */ GL_INCR, /* 7 */ GL_DECR,
/* 7 */ GL_DECR,
}; };
// A2XX_RB_DEPTHCONTROL_Z_ENABLE // A2XX_RB_DEPTHCONTROL_Z_ENABLE
if (regs.rb_depthcontrol & 0x00000002) { if (regs.rb_depthcontrol & 0x00000002) {

View File

@ -1497,15 +1497,22 @@ static const struct {
} cf_instructions[] = { } cf_instructions[] = {
#define INSTR(opc, fxn) \ #define INSTR(opc, fxn) \
{ #opc } { #opc }
INSTR(NOP, print_cf_nop), INSTR(EXEC, print_cf_exec), INSTR(NOP, print_cf_nop),
INSTR(EXEC_END, print_cf_exec), INSTR(COND_EXEC, print_cf_exec), INSTR(EXEC, print_cf_exec),
INSTR(COND_EXEC_END, print_cf_exec), INSTR(COND_PRED_EXEC, print_cf_exec), INSTR(EXEC_END, print_cf_exec),
INSTR(COND_PRED_EXEC_END, print_cf_exec), INSTR(LOOP_START, print_cf_loop), INSTR(COND_EXEC, print_cf_exec),
INSTR(LOOP_END, print_cf_loop), INSTR(COND_CALL, print_cf_jmp_call), INSTR(COND_EXEC_END, print_cf_exec),
INSTR(RETURN, print_cf_jmp_call), INSTR(COND_JMP, print_cf_jmp_call), INSTR(COND_PRED_EXEC, print_cf_exec),
INSTR(ALLOC, print_cf_alloc), INSTR(COND_EXEC_PRED_CLEAN, print_cf_exec), INSTR(COND_PRED_EXEC_END, print_cf_exec),
INSTR(COND_EXEC_PRED_CLEAN_END, print_cf_exec), INSTR(LOOP_START, print_cf_loop),
INSTR(MARK_VS_FETCH_DONE, print_cf_nop), // ?? INSTR(LOOP_END, print_cf_loop),
INSTR(COND_CALL, print_cf_jmp_call),
INSTR(RETURN, print_cf_jmp_call),
INSTR(COND_JMP, print_cf_jmp_call),
INSTR(ALLOC, print_cf_alloc),
INSTR(COND_EXEC_PRED_CLEAN, print_cf_exec),
INSTR(COND_EXEC_PRED_CLEAN_END, print_cf_exec),
INSTR(MARK_VS_FETCH_DONE, print_cf_nop), // ??
#undef INSTR #undef INSTR
}; };
@ -1652,66 +1659,66 @@ bool GL4ShaderTranslator::TranslateVertexFetch(const instr_fetch_vtx_t* vtx,
} fetch_types[0xff] = { } fetch_types[0xff] = {
#define TYPE(id) \ #define TYPE(id) \
{ #id } { #id }
TYPE(FMT_1_REVERSE), // 0 TYPE(FMT_1_REVERSE), // 0
{0}, {0},
TYPE(FMT_8), // 2 TYPE(FMT_8), // 2
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_8_8_8_8), // 6 TYPE(FMT_8_8_8_8), // 6
TYPE(FMT_2_10_10_10), // 7 TYPE(FMT_2_10_10_10), // 7
{0}, {0},
{0}, {0},
TYPE(FMT_8_8), // 10 TYPE(FMT_8_8), // 10
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_16), // 24 TYPE(FMT_16), // 24
TYPE(FMT_16_16), // 25 TYPE(FMT_16_16), // 25
TYPE(FMT_16_16_16_16), // 26 TYPE(FMT_16_16_16_16), // 26
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_32), // 33 TYPE(FMT_32), // 33
TYPE(FMT_32_32), // 34 TYPE(FMT_32_32), // 34
TYPE(FMT_32_32_32_32), // 35 TYPE(FMT_32_32_32_32), // 35
TYPE(FMT_32_FLOAT), // 36 TYPE(FMT_32_FLOAT), // 36
TYPE(FMT_32_32_FLOAT), // 37 TYPE(FMT_32_32_FLOAT), // 37
TYPE(FMT_32_32_32_32_FLOAT), // 38 TYPE(FMT_32_32_32_32_FLOAT), // 38
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_32_32_32_FLOAT), // 57 TYPE(FMT_32_32_32_FLOAT), // 57
#undef TYPE #undef TYPE
}; };
// Disassemble. // Disassemble.
Append(" // %sFETCH:\t", sync ? "(S)" : " "); Append(" // %sFETCH:\t", sync ? "(S)" : " ");

View File

@ -96,10 +96,10 @@ bool GLContext::Initialize(HWND hwnd) {
int context_flags = 0; int context_flags = 0;
#if DEBUG #if DEBUG
context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB; context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
#endif // DEBUG #endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, // int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, // WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, // WGL_CONTEXT_FLAGS_ARB, context_flags, //
0}; 0};
glrc_ = wglCreateContextAttribsARB(dc_, nullptr, attrib_list); glrc_ = wglCreateContextAttribsARB(dc_, nullptr, attrib_list);
@ -140,15 +140,15 @@ std::unique_ptr<GLContext> GLContext::CreateShared() {
GLContextLock context_lock(this); GLContextLock context_lock(this);
int context_flags = 0; int context_flags = 0;
//int profile = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; // int profile = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
int profile = WGL_CONTEXT_CORE_PROFILE_BIT_ARB; int profile = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
#if DEBUG #if DEBUG
context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB; context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
#endif // DEBUG #endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, // int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, // WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, // WGL_CONTEXT_FLAGS_ARB, context_flags, //
WGL_CONTEXT_PROFILE_MASK_ARB, profile, // WGL_CONTEXT_PROFILE_MASK_ARB, profile, //
0}; 0};
new_glrc = wglCreateContextAttribsARB(dc_, glrc_, attrib_list); new_glrc = wglCreateContextAttribsARB(dc_, glrc_, attrib_list);
if (!new_glrc) { if (!new_glrc) {
@ -273,9 +273,9 @@ void GLContext::DebugMessage(GLenum source, GLenum type, GLuint id,
} }
void GLAPIENTRY void GLAPIENTRY
GLContext::DebugMessageThunk(GLenum source, GLenum type, GLuint id, GLContext::DebugMessageThunk(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length, GLenum severity, GLsizei length,
const GLchar* message, GLvoid* user_param) { const GLchar* message, GLvoid* user_param) {
reinterpret_cast<GLContext*>(user_param) reinterpret_cast<GLContext*>(user_param)
->DebugMessage(source, type, id, severity, length, message); ->DebugMessage(source, type, id, severity, length, message);
} }

View File

@ -43,8 +43,9 @@ class GLContext {
void DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity, void DebugMessage(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message); GLsizei length, const GLchar* message);
static void GLAPIENTRY static void GLAPIENTRY
DebugMessageThunk(GLenum source, GLenum type, GLuint id, GLenum severity, DebugMessageThunk(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message, GLvoid* user_param); GLsizei length, const GLchar* message,
GLvoid* user_param);
HWND hwnd_; HWND hwnd_;
HDC dc_; HDC dc_;

View File

@ -212,7 +212,8 @@ void TextureInfo::CalculateTextureSizes2D(const xe_gpu_texture_fetch_t& fetch) {
output_length = size_2d.output_pitch * block_height; output_length = size_2d.output_pitch * block_height;
} }
void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch) { void TextureInfo::CalculateTextureSizesCube(
const xe_gpu_texture_fetch_t& fetch) {
assert_true(fetch.size_stack.depth + 1 == 6); assert_true(fetch.size_stack.depth + 1 == 6);
size_cube.logical_width = 1 + fetch.size_stack.width; size_cube.logical_width = 1 + fetch.size_stack.width;
size_cube.logical_height = 1 + fetch.size_stack.height; size_cube.logical_height = 1 + fetch.size_stack.height;
@ -232,8 +233,8 @@ void TextureInfo::CalculateTextureSizesCube(const xe_gpu_texture_fetch_t& fetch)
size_cube.block_height = tile_height * 32; size_cube.block_height = tile_height * 32;
uint32_t bytes_per_block = format_info->block_width * uint32_t bytes_per_block = format_info->block_width *
format_info->block_height * format_info->block_height *
format_info->bits_per_pixel / 8; format_info->bits_per_pixel / 8;
uint32_t byte_pitch = tile_width * 32 * bytes_per_block; uint32_t byte_pitch = tile_width * 32 * bytes_per_block;
if (!is_tiled) { if (!is_tiled) {
// Each row must be a multiple of 256 in linear textures. // Each row must be a multiple of 256 in linear textures.

View File

@ -1062,24 +1062,23 @@ void DrawShaderUI(xe::ui::MainWindow* window, TracePlayer& player,
// glBlendFuncSeparatei(i, src_blend, dest_blend, src_blend_alpha, // glBlendFuncSeparatei(i, src_blend, dest_blend, src_blend_alpha,
// dest_blend_alpha); // dest_blend_alpha);
void DrawBlendMode(uint32_t src_blend, uint32_t dest_blend, uint32_t blend_op) { void DrawBlendMode(uint32_t src_blend, uint32_t dest_blend, uint32_t blend_op) {
static const char* kBlendNames[] = { static const char* kBlendNames[] = {/* 0 */ "ZERO",
/* 0 */ "ZERO", /* 1 */ "ONE",
/* 1 */ "ONE", /* 2 */ "UNK2", // ?
/* 2 */ "UNK2", // ? /* 3 */ "UNK3", // ?
/* 3 */ "UNK3", // ? /* 4 */ "SRC_COLOR",
/* 4 */ "SRC_COLOR", /* 5 */ "ONE_MINUS_SRC_COLOR",
/* 5 */ "ONE_MINUS_SRC_COLOR", /* 6 */ "SRC_ALPHA",
/* 6 */ "SRC_ALPHA", /* 7 */ "ONE_MINUS_SRC_ALPHA",
/* 7 */ "ONE_MINUS_SRC_ALPHA", /* 8 */ "DST_COLOR",
/* 8 */ "DST_COLOR", /* 9 */ "ONE_MINUS_DST_COLOR",
/* 9 */ "ONE_MINUS_DST_COLOR", /* 10 */ "DST_ALPHA",
/* 10 */ "DST_ALPHA", /* 11 */ "ONE_MINUS_DST_ALPHA",
/* 11 */ "ONE_MINUS_DST_ALPHA", /* 12 */ "CONSTANT_COLOR",
/* 12 */ "CONSTANT_COLOR", /* 13 */ "ONE_MINUS_CONSTANT_COLOR",
/* 13 */ "ONE_MINUS_CONSTANT_COLOR", /* 14 */ "CONSTANT_ALPHA",
/* 14 */ "CONSTANT_ALPHA", /* 15 */ "ONE_MINUS_CONSTANT_ALPHA",
/* 15 */ "ONE_MINUS_CONSTANT_ALPHA", /* 16 */ "SRC_ALPHA_SATURATE",
/* 16 */ "SRC_ALPHA_SATURATE",
}; };
const char* src_str = kBlendNames[src_blend]; const char* src_str = kBlendNames[src_blend];
const char* dest_str = kBlendNames[dest_blend]; const char* dest_str = kBlendNames[dest_blend];
@ -2397,7 +2396,7 @@ void ImImpl_Setup() {
pixels); pixels);
// Store our identifier // Store our identifier
io.Fonts->TexID = (void*)(intptr_t)tex_id; io.Fonts->TexID = (void*)(intptr_t) tex_id;
io.DeltaTime = 1.0f / 60.0f; io.DeltaTime = 1.0f / 60.0f;
io.RenderDrawListsFn = ImImpl_RenderDrawLists; io.RenderDrawListsFn = ImImpl_RenderDrawLists;
@ -2539,7 +2538,7 @@ void ImImpl_RenderDrawLists(ImDrawList** const cmd_lists, int cmd_lists_count) {
for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end; for (const ImDrawCmd* pcmd = cmd_list->commands.begin(); pcmd != pcmd_end;
pcmd++) { pcmd++) {
if (pcmd->texture_id != prev_texture_id) { if (pcmd->texture_id != prev_texture_id) {
glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t)pcmd->texture_id); glBindTexture(GL_TEXTURE_2D, (GLuint)(intptr_t) pcmd->texture_id);
prev_texture_id = pcmd->texture_id; prev_texture_id = pcmd->texture_id;
} }
glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w), glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w),

View File

@ -63,9 +63,10 @@ struct Output {
}; };
static const char* levels[] = { static const char* levels[] = {
"", "\t", "\t\t", "\t\t\t", "\t\t\t\t", "\t\t\t\t\t", "\t\t\t\t\t\t", "", "\t", "\t\t", "\t\t\t",
"\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t\t", "x", "x", "x", "\t\t\t\t", "\t\t\t\t\t", "\t\t\t\t\t\t", "\t\t\t\t\t\t\t",
"x", "x", "x", "\t\t\t\t\t\t\t\t", "\t\t\t\t\t\t\t\t\t", "x", "x",
"x", "x", "x", "x",
}; };
/* /*
@ -155,40 +156,39 @@ void print_export_comment(Output* output, uint32_t num, ShaderType type) {
struct { struct {
uint32_t num_srcs; uint32_t num_srcs;
const char* name; const char* name;
} vector_instructions[0x20] = } vector_instructions[0x20] = {
{
#define INSTR(opc, num_srcs) \ #define INSTR(opc, num_srcs) \
{ num_srcs, #opc } { num_srcs, #opc }
INSTR(ADDv, 2), // 0 INSTR(ADDv, 2), // 0
INSTR(MULv, 2), // 1 INSTR(MULv, 2), // 1
INSTR(MAXv, 2), // 2 INSTR(MAXv, 2), // 2
INSTR(MINv, 2), // 3 INSTR(MINv, 2), // 3
INSTR(SETEv, 2), // 4 INSTR(SETEv, 2), // 4
INSTR(SETGTv, 2), // 5 INSTR(SETGTv, 2), // 5
INSTR(SETGTEv, 2), // 6 INSTR(SETGTEv, 2), // 6
INSTR(SETNEv, 2), // 7 INSTR(SETNEv, 2), // 7
INSTR(FRACv, 1), // 8 INSTR(FRACv, 1), // 8
INSTR(TRUNCv, 1), // 9 INSTR(TRUNCv, 1), // 9
INSTR(FLOORv, 1), // 10 INSTR(FLOORv, 1), // 10
INSTR(MULADDv, 3), // 111 INSTR(MULADDv, 3), // 111
INSTR(CNDEv, 3), // 12 INSTR(CNDEv, 3), // 12
INSTR(CNDGTEv, 3), // 13 INSTR(CNDGTEv, 3), // 13
INSTR(CNDGTv, 3), // 14 INSTR(CNDGTv, 3), // 14
INSTR(DOT4v, 2), // 15 INSTR(DOT4v, 2), // 15
INSTR(DOT3v, 2), // 16 INSTR(DOT3v, 2), // 16
INSTR(DOT2ADDv, 3), // 17 -- ??? INSTR(DOT2ADDv, 3), // 17 -- ???
INSTR(CUBEv, 2), // 18 INSTR(CUBEv, 2), // 18
INSTR(MAX4v, 1), // 19 INSTR(MAX4v, 1), // 19
INSTR(PRED_SETE_PUSHv, 2), // 20 INSTR(PRED_SETE_PUSHv, 2), // 20
INSTR(PRED_SETNE_PUSHv, 2), // 21 INSTR(PRED_SETNE_PUSHv, 2), // 21
INSTR(PRED_SETGT_PUSHv, 2), // 22 INSTR(PRED_SETGT_PUSHv, 2), // 22
INSTR(PRED_SETGTE_PUSHv, 2), // 23 INSTR(PRED_SETGTE_PUSHv, 2), // 23
INSTR(KILLEv, 2), // 24 INSTR(KILLEv, 2), // 24
INSTR(KILLGTv, 2), // 25 INSTR(KILLGTv, 2), // 25
INSTR(KILLGTEv, 2), // 26 INSTR(KILLGTEv, 2), // 26
INSTR(KILLNEv, 2), // 27 INSTR(KILLNEv, 2), // 27
INSTR(DSTv, 2), // 28 INSTR(DSTv, 2), // 28
INSTR(MOVAv, 1), // 29 INSTR(MOVAv, 1), // 29
}, },
scalar_instructions[0x40] = { scalar_instructions[0x40] = {
INSTR(ADDs, 1), // 0 INSTR(ADDs, 1), // 0
@ -353,64 +353,64 @@ struct {
} fetch_types[0xff] = { } fetch_types[0xff] = {
#define TYPE(id) \ #define TYPE(id) \
{ #id } { #id }
TYPE(FMT_1_REVERSE), // 0 TYPE(FMT_1_REVERSE), // 0
{0}, {0},
TYPE(FMT_8), // 2 TYPE(FMT_8), // 2
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_8_8_8_8), // 6 TYPE(FMT_8_8_8_8), // 6
TYPE(FMT_2_10_10_10), // 7 TYPE(FMT_2_10_10_10), // 7
{0}, {0},
{0}, {0},
TYPE(FMT_8_8), // 10 TYPE(FMT_8_8), // 10
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_16), // 24 TYPE(FMT_16), // 24
TYPE(FMT_16_16), // 25 TYPE(FMT_16_16), // 25
TYPE(FMT_16_16_16_16), // 26 TYPE(FMT_16_16_16_16), // 26
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_32), // 33 TYPE(FMT_32), // 33
TYPE(FMT_32_32), // 34 TYPE(FMT_32_32), // 34
TYPE(FMT_32_32_32_32), // 35 TYPE(FMT_32_32_32_32), // 35
TYPE(FMT_32_FLOAT), // 36 TYPE(FMT_32_FLOAT), // 36
TYPE(FMT_32_32_FLOAT), // 37 TYPE(FMT_32_32_FLOAT), // 37
TYPE(FMT_32_32_32_32_FLOAT), // 38 TYPE(FMT_32_32_32_32_FLOAT), // 38
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
{0}, {0},
TYPE(FMT_32_32_32_FLOAT), // 57 TYPE(FMT_32_32_32_FLOAT), // 57
#undef TYPE #undef TYPE
}; };
@ -556,34 +556,34 @@ struct {
} fetch_instructions[] = { } fetch_instructions[] = {
#define INSTR(opc, name, fxn) \ #define INSTR(opc, name, fxn) \
{ name, fxn } { name, fxn }
INSTR(VTX_FETCH, "VERTEX", print_fetch_vtx), // 0 INSTR(VTX_FETCH, "VERTEX", print_fetch_vtx), // 0
INSTR(TEX_FETCH, "SAMPLE", print_fetch_tex), // 1 INSTR(TEX_FETCH, "SAMPLE", print_fetch_tex), // 1
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
INSTR(TEX_GET_BORDER_COLOR_FRAC, "?", print_fetch_tex), // 16 INSTR(TEX_GET_BORDER_COLOR_FRAC, "?", print_fetch_tex), // 16
INSTR(TEX_GET_COMP_TEX_LOD, "?", print_fetch_tex), // 17 INSTR(TEX_GET_COMP_TEX_LOD, "?", print_fetch_tex), // 17
INSTR(TEX_GET_GRADIENTS, "?", print_fetch_tex), // 18 INSTR(TEX_GET_GRADIENTS, "?", print_fetch_tex), // 18
INSTR(TEX_GET_WEIGHTS, "?", print_fetch_tex), // 19 INSTR(TEX_GET_WEIGHTS, "?", print_fetch_tex), // 19
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
{0, 0}, {0, 0},
INSTR(TEX_SET_TEX_LOD, "SET_TEX_LOD", print_fetch_tex), // 24 INSTR(TEX_SET_TEX_LOD, "SET_TEX_LOD", print_fetch_tex), // 24
INSTR(TEX_SET_GRADIENTS_H, "?", print_fetch_tex), // 25 INSTR(TEX_SET_GRADIENTS_H, "?", print_fetch_tex), // 25
INSTR(TEX_SET_GRADIENTS_V, "?", print_fetch_tex), // 26 INSTR(TEX_SET_GRADIENTS_V, "?", print_fetch_tex), // 26
INSTR(TEX_RESERVED_4, "?", print_fetch_tex), // 27 INSTR(TEX_RESERVED_4, "?", print_fetch_tex), // 27
#undef INSTR #undef INSTR
}; };
@ -677,15 +677,22 @@ struct {
} cf_instructions[] = { } cf_instructions[] = {
#define INSTR(opc, fxn) \ #define INSTR(opc, fxn) \
{ #opc, fxn } { #opc, fxn }
INSTR(NOP, print_cf_nop), INSTR(EXEC, print_cf_exec), INSTR(NOP, print_cf_nop),
INSTR(EXEC_END, print_cf_exec), INSTR(COND_EXEC, print_cf_exec), INSTR(EXEC, print_cf_exec),
INSTR(COND_EXEC_END, print_cf_exec), INSTR(COND_PRED_EXEC, print_cf_exec), INSTR(EXEC_END, print_cf_exec),
INSTR(COND_PRED_EXEC_END, print_cf_exec), INSTR(LOOP_START, print_cf_loop), INSTR(COND_EXEC, print_cf_exec),
INSTR(LOOP_END, print_cf_loop), INSTR(COND_CALL, print_cf_jmp_call), INSTR(COND_EXEC_END, print_cf_exec),
INSTR(RETURN, print_cf_jmp_call), INSTR(COND_JMP, print_cf_jmp_call), INSTR(COND_PRED_EXEC, print_cf_exec),
INSTR(ALLOC, print_cf_alloc), INSTR(COND_EXEC_PRED_CLEAN, print_cf_exec), INSTR(COND_PRED_EXEC_END, print_cf_exec),
INSTR(COND_EXEC_PRED_CLEAN_END, print_cf_exec), INSTR(LOOP_START, print_cf_loop),
INSTR(MARK_VS_FETCH_DONE, print_cf_nop), // ?? INSTR(LOOP_END, print_cf_loop),
INSTR(COND_CALL, print_cf_jmp_call),
INSTR(RETURN, print_cf_jmp_call),
INSTR(COND_JMP, print_cf_jmp_call),
INSTR(ALLOC, print_cf_alloc),
INSTR(COND_EXEC_PRED_CLEAN, print_cf_exec),
INSTR(COND_EXEC_PRED_CLEAN_END, print_cf_exec),
INSTR(MARK_VS_FETCH_DONE, print_cf_nop), // ??
#undef INSTR #undef INSTR
}; };

View File

@ -12,8 +12,6 @@
#include <gflags/gflags.h> #include <gflags/gflags.h>
DECLARE_string(hid); DECLARE_string(hid);
#endif // XENIA_HID_HID_PRIVATE_H_ #endif // XENIA_HID_HID_PRIVATE_H_

View File

@ -64,8 +64,7 @@ X_STATUS DiscImageEntry::QueryDirectory(XDirectoryInfo* out_info, size_t length,
if (!entry) { if (!entry) {
return X_STATUS_NO_SUCH_FILE; return X_STATUS_NO_SUCH_FILE;
} }
} } else {
else {
if (restart) { if (restart) {
it_ = gdfx_entry_->children.begin(); it_ = gdfx_entry_->children.begin();
} }

View File

@ -18,9 +18,7 @@ namespace fs {
HostPathFile::HostPathFile(KernelState* kernel_state, Mode mode, HostPathFile::HostPathFile(KernelState* kernel_state, Mode mode,
HostPathEntry* entry, HANDLE file_handle) HostPathEntry* entry, HANDLE file_handle)
: entry_(entry), : entry_(entry), file_handle_(file_handle), XFile(kernel_state, mode) {}
file_handle_(file_handle),
XFile(kernel_state, mode) {}
HostPathFile::~HostPathFile() { HostPathFile::~HostPathFile() {
CloseHandle(file_handle_); CloseHandle(file_handle_);

View File

@ -39,7 +39,7 @@ int STFSContainerDevice::Init() {
return 1; return 1;
} }
//stfs_->Dump(); // stfs_->Dump();
return 0; return 0;
} }

View File

@ -45,7 +45,7 @@ X_STATUS STFSContainerEntry::QueryDirectory(XDirectoryInfo* out_info,
STFSEntry* entry(nullptr); STFSEntry* entry(nullptr);
if( file_name != nullptr ) { if (file_name != nullptr) {
// Only queries in the current directory are supported for now // Only queries in the current directory are supported for now
assert_true(std::strchr(file_name, '\\') == nullptr); assert_true(std::strchr(file_name, '\\') == nullptr);

View File

@ -30,9 +30,7 @@ Entry::Entry(Device* device, const std::string& path)
Entry::~Entry() = default; Entry::~Entry() = default;
bool Entry::is_read_only() const { bool Entry::is_read_only() const { return device_->is_read_only(); }
return device_->is_read_only();
}
} // namespace fs } // namespace fs
} // namespace kernel } // namespace kernel

View File

@ -39,8 +39,7 @@ class FileSystem {
int RegisterDevice(const std::string& path, Device* device); int RegisterDevice(const std::string& path, Device* device);
int RegisterHostPathDevice(const std::string& path, int RegisterHostPathDevice(const std::string& path,
const std::wstring& local_path, const std::wstring& local_path, bool read_only);
bool read_only);
int RegisterDiscImageDevice(const std::string& path, int RegisterDiscImageDevice(const std::string& path,
const std::wstring& local_path); const std::wstring& local_path);
int RegisterSTFSContainerDevice(const std::string& path, int RegisterSTFSContainerDevice(const std::string& path,

View File

@ -213,7 +213,7 @@ X_STATUS ObjectTable::AddNameMapping(const std::string& name, X_HANDLE handle) {
if (name_table_.count(name)) { if (name_table_.count(name)) {
return X_STATUS_OBJECT_NAME_COLLISION; return X_STATUS_OBJECT_NAME_COLLISION;
} }
name_table_.insert({ name, handle }); name_table_.insert({name, handle});
return X_STATUS_SUCCESS; return X_STATUS_SUCCESS;
} }

View File

@ -16,8 +16,7 @@ XEnumerator::XEnumerator(KernelState* kernel_state, size_t item_capacity,
size_t item_size) size_t item_size)
: XObject(kernel_state, kTypeEnumerator), : XObject(kernel_state, kTypeEnumerator),
item_capacity_(item_capacity), item_capacity_(item_capacity),
item_size_(item_size) item_size_(item_size) {}
{}
XEnumerator::~XEnumerator() = default; XEnumerator::~XEnumerator() = default;

View File

@ -424,8 +424,9 @@ void XThread::DeliverAPCs(void* data) {
// kernel_routine(apc_address, &normal_routine, &normal_context, // kernel_routine(apc_address, &normal_routine, &normal_context,
// &system_arg1, &system_arg2) // &system_arg1, &system_arg2)
uint64_t kernel_args[] = { uint64_t kernel_args[] = {
apc_address, thread->scratch_address_ + 0, thread->scratch_address_ + 4, apc_address, thread->scratch_address_ + 0,
thread->scratch_address_ + 8, thread->scratch_address_ + 12, thread->scratch_address_ + 4, thread->scratch_address_ + 8,
thread->scratch_address_ + 12,
}; };
processor->ExecuteInterrupt(0, kernel_routine, kernel_args, processor->ExecuteInterrupt(0, kernel_routine, kernel_args,
xe::countof(kernel_args)); xe::countof(kernel_args));

View File

@ -40,7 +40,7 @@ void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) {
return; return;
} }
// Build the export table used for resolution. // Build the export table used for resolution.
#include "xenia/kernel/util/export_table_pre.inc" #include "xenia/kernel/util/export_table_pre.inc"
static xe::cpu::KernelExport xam_export_table[] = { static xe::cpu::KernelExport xam_export_table[] = {
#include "xenia/kernel/xam_table.inc" #include "xenia/kernel/xam_table.inc"

View File

@ -33,7 +33,8 @@ SHIM_CALL XMsgInProcessCall_shim(PPCContext* ppc_state, KernelState* state) {
SHIM_SET_RETURN_32(result); SHIM_SET_RETURN_32(result);
} }
SHIM_CALL XMsgSystemProcessCall_shim(PPCContext* ppc_state, KernelState* state) { SHIM_CALL XMsgSystemProcessCall_shim(PPCContext* ppc_state,
KernelState* state) {
uint32_t app = SHIM_GET_ARG_32(0); uint32_t app = SHIM_GET_ARG_32(0);
uint32_t message = SHIM_GET_ARG_32(1); uint32_t message = SHIM_GET_ARG_32(1);
uint32_t buffer = SHIM_GET_ARG_32(2); uint32_t buffer = SHIM_GET_ARG_32(2);

View File

@ -283,7 +283,7 @@ SHIM_CALL NetDll_select_shim(PPCContext* ppc_state, KernelState* state) {
uint32_t timeout_ptr = SHIM_GET_ARG_32(5); uint32_t timeout_ptr = SHIM_GET_ARG_32(5);
XELOGD("NetDll_select(%d, %d, %.8X, %.8X, %.8X, %.8X)", arg0, nfds, XELOGD("NetDll_select(%d, %d, %.8X, %.8X, %.8X, %.8X)", arg0, nfds,
readfds_ptr, writefds_ptr, exceptfds_ptr, timeout_ptr); readfds_ptr, writefds_ptr, exceptfds_ptr, timeout_ptr);
fd_set readfds = { 0 }; fd_set readfds = {0};
if (readfds_ptr) { if (readfds_ptr) {
LoadFdset(SHIM_MEM_ADDR(readfds_ptr), &readfds); LoadFdset(SHIM_MEM_ADDR(readfds_ptr), &readfds);
} }

View File

@ -416,7 +416,8 @@ SHIM_CALL XamWriteGamerTile_shim(PPCContext* ppc_state, KernelState* state) {
} }
} }
SHIM_CALL XamSessionCreateHandle_shim(PPCContext* ppc_state, KernelState* state) { SHIM_CALL XamSessionCreateHandle_shim(PPCContext* ppc_state,
KernelState* state) {
uint32_t handle_ptr = SHIM_GET_ARG_32(0); uint32_t handle_ptr = SHIM_GET_ARG_32(0);
XELOGD("XamSessionCreateHandle(%.8X)", handle_ptr); XELOGD("XamSessionCreateHandle(%.8X)", handle_ptr);
@ -426,7 +427,8 @@ SHIM_CALL XamSessionCreateHandle_shim(PPCContext* ppc_state, KernelState* state)
SHIM_SET_RETURN_32(X_ERROR_SUCCESS); SHIM_SET_RETURN_32(X_ERROR_SUCCESS);
} }
SHIM_CALL XamSessionRefObjByHandle_shim(PPCContext* ppc_state, KernelState* state) { SHIM_CALL XamSessionRefObjByHandle_shim(PPCContext* ppc_state,
KernelState* state) {
uint32_t handle = SHIM_GET_ARG_32(0); uint32_t handle = SHIM_GET_ARG_32(0);
uint32_t obj_ptr = SHIM_GET_ARG_32(1); uint32_t obj_ptr = SHIM_GET_ARG_32(1);

View File

@ -319,7 +319,7 @@ SHIM_CALL KeDelayExecutionThread_shim(PPCContext* ppc_state,
} }
SHIM_CALL NtYieldExecution_shim(PPCContext* ppc_state, KernelState* state) { SHIM_CALL NtYieldExecution_shim(PPCContext* ppc_state, KernelState* state) {
//XELOGD("NtYieldExecution()"); // XELOGD("NtYieldExecution()");
XThread* thread = XThread::GetCurrentThread(); XThread* thread = XThread::GetCurrentThread();
X_STATUS result = thread->Delay(0, 0, 0); X_STATUS result = thread->Delay(0, 0, 0);
SHIM_SET_RETURN_64(0); SHIM_SET_RETURN_64(0);

View File

@ -224,15 +224,24 @@ const static struct {
uint32_t virtual_address_end; uint32_t virtual_address_end;
uint32_t target_address; uint32_t target_address;
} map_info[] = { } map_info[] = {
0x00000000, 0x3FFFFFFF, 0x00000000, // (1024mb) - virtual 4k pages 0x00000000, 0x3FFFFFFF,
0x40000000, 0x7EFFFFFF, 0x40000000, // (1024mb) - virtual 64k pages (cont) 0x00000000, // (1024mb) - virtual 4k pages
0x7F000000, 0x7F0FFFFF, 0x00000000, // (1mb) - GPU writeback 0x40000000, 0x7EFFFFFF,
0x7F100000, 0x7FFFFFFF, 0x00100000, // (15mb) - XPS? 0x40000000, // (1024mb) - virtual 64k pages (cont)
0x80000000, 0x8FFFFFFF, 0x80000000, // (256mb) - xex 64k pages 0x7F000000, 0x7F0FFFFF,
0x90000000, 0x9FFFFFFF, 0x80000000, // (256mb) - xex 4k pages 0x00000000, // (1mb) - GPU writeback
0xA0000000, 0xBFFFFFFF, 0x00000000, // (512mb) - physical 64k pages 0x7F100000, 0x7FFFFFFF,
0xC0000000, 0xDFFFFFFF, 0x00000000, // - physical 16mb pages 0x00100000, // (15mb) - XPS?
0xE0000000, 0xFFFFFFFF, 0x00000000, // - physical 4k pages 0x80000000, 0x8FFFFFFF,
0x80000000, // (256mb) - xex 64k pages
0x90000000, 0x9FFFFFFF,
0x80000000, // (256mb) - xex 4k pages
0xA0000000, 0xBFFFFFFF,
0x00000000, // (512mb) - physical 64k pages
0xC0000000, 0xDFFFFFFF,
0x00000000, // - physical 16mb pages
0xE0000000, 0xFFFFFFFF,
0x00000000, // - physical 4k pages
}; };
int Memory::MapViews(uint8_t* mapping_base) { int Memory::MapViews(uint8_t* mapping_base) {
assert_true(xe::countof(map_info) == xe::countof(views_.all_views)); assert_true(xe::countof(map_info) == xe::countof(views_.all_views));

View File

@ -16,21 +16,19 @@ namespace tools {
void apiscanner_logger::operator()(const LogType type, const char* szMessage) { void apiscanner_logger::operator()(const LogType type, const char* szMessage) {
switch (type) { switch (type) {
case LT_WARNING: case LT_WARNING:
fprintf(stderr, "[W] %s\n", szMessage); fprintf(stderr, "[W] %s\n", szMessage);
break; break;
case LT_ERROR: case LT_ERROR:
fprintf(stderr, "[!] %s\n", szMessage); fprintf(stderr, "[!] %s\n", szMessage);
break; break;
default: default:
break; break;
} }
} }
apiscanner_loader::apiscanner_loader() apiscanner_loader::apiscanner_loader()
: export_resolver(nullptr) : export_resolver(nullptr), memory_(nullptr) {
, memory_(nullptr)
{
export_resolver = std::make_unique<xe::cpu::ExportResolver>(); export_resolver = std::make_unique<xe::cpu::ExportResolver>();
kernel::XamModule::RegisterExportTable(export_resolver.get()); kernel::XamModule::RegisterExportTable(export_resolver.get());
@ -40,8 +38,7 @@ apiscanner_loader::apiscanner_loader()
memory_->Initialize(); memory_->Initialize();
} }
apiscanner_loader::~apiscanner_loader() apiscanner_loader::~apiscanner_loader() {
{
if (export_resolver != nullptr) { if (export_resolver != nullptr) {
export_resolver.reset(); export_resolver.reset();
} }
@ -62,7 +59,6 @@ bool apiscanner_loader::LoadTitleImports(const std::wstring& target) {
return ReadTarget(); return ReadTarget();
} }
bool apiscanner_loader::ReadTarget() { bool apiscanner_loader::ReadTarget() {
// XXX Do a wildcard search for all xex files? // XXX Do a wildcard search for all xex files?
const char path[] = "game:\\default.xex"; const char path[] = "game:\\default.xex";
@ -91,8 +87,7 @@ bool apiscanner_loader::ReadTarget() {
if (read_result) { if (read_result) {
loaded_titles.push_back(res); loaded_titles.push_back(res);
} }
} } else {
else {
kernel::XFileInfo file_info; kernel::XFileInfo file_info;
if (fs_entry->QueryInfo(&file_info)) { if (fs_entry->QueryInfo(&file_info)) {
if (file) { if (file) {
@ -107,7 +102,7 @@ bool apiscanner_loader::ReadTarget() {
// XXX No kernel state again // XXX No kernel state again
int result = file_system.Open(std::move(fs_entry), nullptr, int result = file_system.Open(std::move(fs_entry), nullptr,
kernel::fs::Mode::READ, false, &file); kernel::fs::Mode::READ, false, &file);
if (result) { if (result) {
if (file) { if (file) {
file->Release(); file->Release();
@ -141,10 +136,9 @@ bool apiscanner_loader::ReadTarget() {
} }
bool apiscanner_loader::ExtractImports(const void* addr, const size_t length, bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
title& info) title& info) {
{
// Load the XEX into memory and decrypt. // Load the XEX into memory and decrypt.
xe_xex2_options_t xex_options = { 0 }; xe_xex2_options_t xex_options = {0};
xe_xex2_ref xex_(xe_xex2_load(memory_.get(), addr, length, xex_options)); xe_xex2_ref xex_(xe_xex2_load(memory_.get(), addr, length, xex_options));
if (!xex_) { if (!xex_) {
log(log.LT_ERROR, "Failed to parse xex file"); log(log.LT_ERROR, "Failed to parse xex file");
@ -154,7 +148,7 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
const xe_xex2_header_t* header = xe_xex2_get_header(xex_); const xe_xex2_header_t* header = xe_xex2_get_header(xex_);
info.title_id = header->execution_info.title_id; info.title_id = header->execution_info.title_id;
// XXX Copy out library versions? // XXX Copy out library versions?
for (size_t n = 0; n < header->import_library_count; n++) { for (size_t n = 0; n < header->import_library_count; n++) {
const xe_xex2_import_library_t* library = &header->import_libraries[n]; const xe_xex2_import_library_t* library = &header->import_libraries[n];
@ -162,8 +156,7 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
xe_xex2_import_info_t* import_infos; xe_xex2_import_info_t* import_infos;
size_t import_info_count; size_t import_info_count;
if (!xe_xex2_get_import_infos(xex_, library, &import_infos, if (!xe_xex2_get_import_infos(xex_, library, &import_infos,
&import_info_count)) { &import_info_count)) {
for (size_t m = 0; m < import_info_count; m++) { for (size_t m = 0; m < import_info_count; m++) {
const xe_xex2_import_info_t* import_info = &import_infos[m]; const xe_xex2_import_info_t* import_info = &import_infos[m];
@ -186,5 +179,5 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
return true; return true;
} }
} // tools } // tools
} // xe } // xe

View File

@ -22,46 +22,39 @@
namespace xe { namespace xe {
namespace tools { namespace tools {
class apiscanner_logger class apiscanner_logger {
{ public:
public: enum LogType { LT_WARNING, LT_ERROR };
enum LogType {
LT_WARNING,
LT_ERROR
};
void operator()(const LogType type, const char* szMessage); void operator()(const LogType type, const char* szMessage);
};
class apiscanner_loader {
private:
kernel::fs::FileSystem file_system;
apiscanner_logger log;
std::unique_ptr<Memory> memory_;
std::unique_ptr<xe::cpu::ExportResolver> export_resolver;
public:
apiscanner_loader();
~apiscanner_loader();
bool LoadTitleImports(const std::wstring& target);
struct title {
uint32_t title_id;
std::vector<std::string> imports;
}; };
class apiscanner_loader const std::vector<title>& GetAllTitles() const { return loaded_titles; }
{
private:
kernel::fs::FileSystem file_system;
apiscanner_logger log;
std::unique_ptr<Memory> memory_;
std::unique_ptr<xe::cpu::ExportResolver> export_resolver;
public: private:
apiscanner_loader(); std::vector<title> loaded_titles;
~apiscanner_loader();
bool LoadTitleImports(const std::wstring& target); bool ReadTarget();
bool ExtractImports(const void* addr, const size_t length, title& info);
struct title };
{
uint32_t title_id;
std::vector<std::string> imports;
};
const std::vector<title>& GetAllTitles() const { return loaded_titles; }
private:
std::vector<title> loaded_titles;
bool ReadTarget();
bool ExtractImports(const void* addr, const size_t length, title& info);
};
} // tools
} // xe
} // tools
} // xe

View File

@ -16,7 +16,6 @@ namespace tools {
DEFINE_string(target, "", "List of file to extract imports from"); DEFINE_string(target, "", "List of file to extract imports from");
int api_scanner_main(std::vector<std::wstring>& args) { int api_scanner_main(std::vector<std::wstring>& args) {
// XXX we need gflags to split multiple flags into arrays for us // XXX we need gflags to split multiple flags into arrays for us
if (args.size() == 2 || !FLAGS_target.empty()) { if (args.size() == 2 || !FLAGS_target.empty()) {
@ -44,4 +43,4 @@ int api_scanner_main(std::vector<std::wstring>& args) {
} // namespace xe } // namespace xe
DEFINE_ENTRY_POINT(L"api-scanner", L"api-scanner --target=<target file>", DEFINE_ENTRY_POINT(L"api-scanner", L"api-scanner --target=<target file>",
xe::tools::api_scanner_main); xe::tools::api_scanner_main);

View File

@ -18,10 +18,8 @@ namespace xe {
#pragma pack(push, 4) #pragma pack(push, 4)
typedef uint32_t X_HANDLE; typedef uint32_t X_HANDLE;
#define X_INVALID_HANDLE_VALUE ((X_HANDLE)-1) #define X_INVALID_HANDLE_VALUE ((X_HANDLE)-1)
// TODO(benvanik): type all of this so we get some safety. // TODO(benvanik): type all of this so we get some safety.
@ -170,7 +168,6 @@ enum X_FILE_ATTRIBUTES {
X_FILE_ATTRIBUTE_ENCRYPTED = 0x4000, X_FILE_ATTRIBUTE_ENCRYPTED = 0x4000,
}; };
// http://code.google.com/p/vdash/source/browse/trunk/vdash/include/kernel.h // http://code.google.com/p/vdash/source/browse/trunk/vdash/include/kernel.h
enum X_FILE_INFORMATION_CLASS { enum X_FILE_INFORMATION_CLASS {
XFileDirectoryInformation = 1, XFileDirectoryInformation = 1,
@ -246,18 +243,14 @@ inline void XOverlappedSetExtendedError(void* ptr, uint32_t value) {
} }
class X_ANSI_STRING { class X_ANSI_STRING {
private: private:
uint16_t length; uint16_t length;
uint16_t maximum_length; uint16_t maximum_length;
const char* buffer; const char* buffer;
public: public:
X_ANSI_STRING() { X_ANSI_STRING() { Zero(); }
Zero(); X_ANSI_STRING(const uint8_t* base, uint32_t p) { Read(base, p); }
}
X_ANSI_STRING(const uint8_t* base, uint32_t p) {
Read(base, p);
}
void Read(const uint8_t* base, uint32_t p) { void Read(const uint8_t* base, uint32_t p) {
length = xe::load_and_swap<uint16_t>(base + p); length = xe::load_and_swap<uint16_t>(base + p);
maximum_length = xe::load_and_swap<uint16_t>(base + p + 2); maximum_length = xe::load_and_swap<uint16_t>(base + p + 2);
@ -287,13 +280,11 @@ public:
return result; return result;
} }
}; };
//static_assert_size(X_ANSI_STRING, 8); // static_assert_size(X_ANSI_STRING, 8);
// Values seem to be all over the place - GUIDs? // Values seem to be all over the place - GUIDs?
typedef uint32_t XNotificationID; typedef uint32_t XNotificationID;
// http://ffplay360.googlecode.com/svn/trunk/Common/XTLOnPC.h // http://ffplay360.googlecode.com/svn/trunk/Common/XTLOnPC.h
struct X_VIDEO_MODE { struct X_VIDEO_MODE {
be<uint32_t> display_width; be<uint32_t> display_width;