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 {
public:
uint16_t module_id;
// info
uint16_t module_id;
// info
};
} // namespace xdb

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -11,23 +11,17 @@
#include "xenia/apu/apu-private.h"
using namespace xe;
using namespace xe::apu;
using namespace xe::apu::nop;
NopAudioSystem::NopAudioSystem(Emulator* emulator) : AudioSystem(emulator) {}
NopAudioSystem::NopAudioSystem(Emulator* emulator) :
AudioSystem(emulator) {
}
NopAudioSystem::~NopAudioSystem() {}
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;
}
void NopAudioSystem::DestroyDriver(AudioDriver* driver) {
assert_always();
}
void NopAudioSystem::DestroyDriver(AudioDriver* driver) { assert_always(); }

View File

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

View File

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

View File

@ -7,7 +7,6 @@
******************************************************************************
*/
namespace {
enum KeyType {
@ -36,16 +35,15 @@ union InstrKey {
};
uint32_t value;
operator uint32_t() const {
return value;
}
operator uint32_t() const { return value; }
InstrKey() : value(0) {}
InstrKey(uint32_t v) : value(v) {}
InstrKey(const Instr* i) : value(0) {
opcode = i->opcode->num;
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);
if (src1 == OPCODE_SIG_TYPE_V) {
src1 += i->src1.value->type;
@ -60,11 +58,8 @@ union InstrKey {
}
}
template <Opcode OPCODE,
KeyType DEST = KEY_TYPE_X,
KeyType SRC1 = KEY_TYPE_X,
KeyType SRC2 = KEY_TYPE_X,
KeyType SRC3 = KEY_TYPE_X>
template <Opcode OPCODE, KeyType DEST = KEY_TYPE_X, KeyType SRC1 = KEY_TYPE_X,
KeyType SRC2 = KEY_TYPE_X, KeyType SRC3 = KEY_TYPE_X>
struct Construct {
static const uint32_t value =
(OPCODE) | (DEST << 8) | (SRC1 << 13) | (SRC2 << 18) | (SRC3 << 23);
@ -88,27 +83,33 @@ struct Op : OpBase {
};
struct VoidOp : Op<VoidOp, KEY_TYPE_X> {
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op;
template <hir::Opcode OPCODE, typename... Ts> friend struct I;
protected:
template <typename T, KeyType KEY_TYPE>
friend struct Op;
template <hir::Opcode OPCODE, typename... Ts>
friend struct I;
void Load(const Instr::Op& op) {}
};
struct OffsetOp : Op<OffsetOp, KEY_TYPE_O> {
uint64_t value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op;
template <hir::Opcode OPCODE, typename... Ts> friend struct I;
void Load(const Instr::Op& op) {
this->value = op.offset;
}
protected:
template <typename T, KeyType KEY_TYPE>
friend struct Op;
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> {
FunctionInfo* value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op;
template <hir::Opcode OPCODE, typename... Ts> friend struct I;
protected:
template <typename T, KeyType KEY_TYPE>
friend struct Op;
template <hir::Opcode OPCODE, typename... Ts>
friend struct I;
bool Load(const Instr::Op& op) {
this->value = op.symbol_info;
return true;
@ -117,15 +118,17 @@ protected:
struct LabelOp : Op<LabelOp, KEY_TYPE_L> {
hir::Label* value;
protected:
template <typename T, KeyType KEY_TYPE> friend struct Op;
template <hir::Opcode OPCODE, typename... Ts> friend struct I;
void Load(const Instr::Op& op) {
this->value = op.label;
}
protected:
template <typename T, KeyType KEY_TYPE>
friend struct Op;
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> {
typedef REG_TYPE reg_type;
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);
return reg_;
}
operator const REG_TYPE&() const {
return reg();
}
operator const REG_TYPE&() const { return reg(); }
bool IsEqual(const T& b) const {
if (is_constant && b.is_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;
}
}
bool operator== (const T& b) const {
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 Xbyak::Reg& b) const {
return !IsEqual(b);
}
bool operator==(const T& b) const { 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 Xbyak::Reg& b) const { return !IsEqual(b); }
void Load(const Instr::Op& op) {
const Value* value = op.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_);
}
}
protected:
protected:
REG_TYPE reg_;
};
@ -255,30 +249,34 @@ struct TagTable {
Instr::Op op;
} 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) {
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) {
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) {
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) {
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) {
const Value* value = op.value;
if (T::tag == -1) {
return true;
}
if (table[T::tag].valid &&
table[T::tag].op.value != value) {
if (table[T::tag].valid && table[T::tag].op.value != value) {
return false;
}
table[T::tag].valid = true;
@ -292,7 +290,8 @@ struct DestField;
template <typename DEST>
struct DestField<DEST> {
DEST dest;
protected:
protected:
bool LoadDest(const Instr* i, TagTable& tag_table) {
Instr::Op op;
op.value = i->dest;
@ -305,10 +304,8 @@ protected:
};
template <>
struct DestField<VoidOp> {
protected:
bool LoadDest(const Instr* i, TagTable& tag_table) {
return true;
}
protected:
bool LoadDest(const Instr* i, TagTable& tag_table) { return true; }
};
template <hir::Opcode OPCODE, typename... Ts>
@ -317,14 +314,16 @@ template <hir::Opcode OPCODE, typename DEST>
struct I<OPCODE, DEST> : DestField<DEST> {
typedef DestField<DEST> BASE;
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;
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) {
if (InstrKey(i).value == key &&
BASE::LoadDest(i, tag_table)) {
if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table)) {
instr = i;
return true;
}
@ -335,16 +334,18 @@ template <hir::Opcode OPCODE, typename DEST, typename SRC1>
struct I<OPCODE, DEST, SRC1> : DestField<DEST> {
typedef DestField<DEST> BASE;
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 src1_type = SRC1::key_type;
const Instr* instr;
SRC1 src1;
protected:
template <typename... Ti> friend struct SequenceFields;
protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key &&
BASE::LoadDest(i, tag_table) &&
if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1)) {
instr = i;
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> {
typedef DestField<DEST> BASE;
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 src1_type = SRC1::key_type;
static const KeyType src2_type = SRC2::key_type;
const Instr* instr;
SRC1 src1;
SRC2 src2;
protected:
template <typename... Ti> friend struct SequenceFields;
protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key &&
BASE::LoadDest(i, tag_table) &&
if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1) &&
tag_table.CheckTag<SRC2>(i->src2)) {
instr = i;
@ -379,11 +382,14 @@ protected:
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> {
typedef DestField<DEST> BASE;
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 src1_type = SRC1::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;
SRC2 src2;
SRC3 src3;
protected:
template <typename... Ti> friend struct SequenceFields;
protected:
template <typename... Ti>
friend struct SequenceFields;
bool Load(const Instr* i, TagTable& tag_table) {
if (InstrKey(i).value == key &&
BASE::LoadDest(i, tag_table) &&
if (InstrKey(i).value == key && BASE::LoadDest(i, tag_table) &&
tag_table.CheckTag<SRC1>(i->src1) &&
tag_table.CheckTag<SRC2>(i->src2) &&
tag_table.CheckTag<SRC3>(i->src3)) {
@ -415,8 +422,10 @@ struct SequenceFields;
template <typename I1>
struct SequenceFields<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) {
if (i1.Load(i, tag_table)) {
*new_tail = i->next;
@ -428,8 +437,10 @@ protected:
template <typename I1, typename I2>
struct SequenceFields<I1, I2> : SequenceFields<I1> {
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) {
if (SequenceFields<I1>::Check(i, tag_table, new_tail)) {
auto ni = i->next;
@ -444,8 +455,10 @@ protected:
template <typename I1, typename I2, typename I3>
struct SequenceFields<I1, I2, I3> : SequenceFields<I1, I2> {
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) {
if (SequenceFields<I1, I2>::Check(i, tag_table, new_tail)) {
auto ni = i->next;
@ -460,8 +473,10 @@ protected:
template <typename I1, typename I2, typename I3, typename I4>
struct SequenceFields<I1, I2, I3, I4> : SequenceFields<I1, I2, I3> {
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) {
if (SequenceFields<I1, I2, I3>::Check(i, tag_table, new_tail)) {
auto ni = i->next;
@ -476,8 +491,10 @@ protected:
template <typename I1, typename I2, typename I3, typename I4, typename I5>
struct SequenceFields<I1, I2, I3, I4, I5> : SequenceFields<I1, I2, I3, I4> {
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) {
if (SequenceFields<I1, I2, I3, I4>::Check(i, tag_table, new_tail)) {
auto ni = i->next;
@ -528,7 +545,7 @@ template <typename SEQ, typename T>
struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
typedef Sequence<SingleSequence<SEQ, T>, T> BASE;
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
static uint32_t head_key() { return T::key; }
#else
@ -539,9 +556,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
}
template <typename REG_FN>
static void EmitUnaryOp(
X64Emitter& e, const EmitArgType& i,
const REG_FN& reg_fn) {
static void EmitUnaryOp(X64Emitter& e, const EmitArgType& i,
const REG_FN& reg_fn) {
if (i.src1.is_constant) {
e.mov(i.dest, i.src1.constant());
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>
static void EmitCommutativeBinaryOp(
X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) {
static void EmitCommutativeBinaryOp(X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn,
const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_constant);
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>
static void EmitAssociativeBinaryOp(
X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) {
static void EmitAssociativeBinaryOp(X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn,
const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_constant);
if (i.dest == i.src2) {
@ -645,8 +661,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
}
template <typename FN>
static void EmitCommutativeBinaryXmmOp(
X64Emitter& e, const EmitArgType& i, const FN& fn) {
static void EmitCommutativeBinaryXmmOp(X64Emitter& e, const EmitArgType& i,
const FN& fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_constant);
e.LoadConstantXmm(e.xmm0, i.src1.constant());
@ -660,8 +676,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
}
template <typename FN>
static void EmitAssociativeBinaryXmmOp(
X64Emitter& e, const EmitArgType& i, const FN& fn) {
static void EmitAssociativeBinaryXmmOp(X64Emitter& e, const EmitArgType& i,
const FN& fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_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>
static void EmitCommutativeCompareOp(
X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) {
static void EmitCommutativeCompareOp(X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn,
const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_constant);
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>
static void EmitAssociativeCompareOp(
X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn, const REG_CONST_FN& reg_const_fn) {
static void EmitAssociativeCompareOp(X64Emitter& e, const EmitArgType& i,
const REG_REG_FN& reg_reg_fn,
const REG_CONST_FN& reg_const_fn) {
if (i.src1.is_constant) {
assert_true(!i.src2.is_constant);
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 {
auto temp = GetTempReg<typename decltype(i.src1)::reg_type>(e);
e.mov(temp, i.src1.constant());
@ -714,7 +731,8 @@ struct SingleSequence : public Sequence<SingleSequence<SEQ, T>, T> {
}
} else if (i.src2.is_constant) {
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 {
auto temp = GetTempReg<typename decltype(i.src2)::reg_type>(e);
e.mov(temp, i.src2.constant());
@ -739,7 +757,7 @@ static const tag_t TAG7 = 7;
template <typename T>
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>
void Register() {
@ -747,9 +765,7 @@ void Register() {
Register<Tn, Ts...>();
};
#define EMITTER_OPCODE_TABLE(name, ...) \
void Register_##name() { \
Register<__VA_ARGS__>(); \
}
void Register_##name() { Register<__VA_ARGS__>(); }
#define MATCH(...) __VA_ARGS__
#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);
file_ = CreateFile(file_path.c_str(), GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY,
nullptr);
FILE_ATTRIBUTE_NORMAL | FILE_ATTRIBUTE_TEMPORARY, nullptr);
if (!file_) {
XELOGE("Could not open trace file for writing");
return 1;

View File

@ -48,7 +48,8 @@ class Blitter {
GLuint dest_texture, Rect2D dest_rect);
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 color_fragment_program_;

View File

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

View File

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

View File

@ -96,10 +96,10 @@ bool GLContext::Initialize(HWND hwnd) {
int context_flags = 0;
#if DEBUG
context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
#endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, //
#endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, //
0};
glrc_ = wglCreateContextAttribsARB(dc_, nullptr, attrib_list);
@ -140,15 +140,15 @@ std::unique_ptr<GLContext> GLContext::CreateShared() {
GLContextLock context_lock(this);
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;
#if DEBUG
context_flags |= WGL_CONTEXT_DEBUG_BIT_ARB;
#endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, //
WGL_CONTEXT_PROFILE_MASK_ARB, profile, //
#endif // DEBUG
int attrib_list[] = {WGL_CONTEXT_MAJOR_VERSION_ARB, 4, //
WGL_CONTEXT_MINOR_VERSION_ARB, 5, //
WGL_CONTEXT_FLAGS_ARB, context_flags, //
WGL_CONTEXT_PROFILE_MASK_ARB, profile, //
0};
new_glrc = wglCreateContextAttribsARB(dc_, glrc_, attrib_list);
if (!new_glrc) {
@ -273,9 +273,9 @@ void GLContext::DebugMessage(GLenum source, GLenum type, GLuint id,
}
void GLAPIENTRY
GLContext::DebugMessageThunk(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length,
const GLchar* message, GLvoid* user_param) {
GLContext::DebugMessageThunk(GLenum source, GLenum type, GLuint id,
GLenum severity, GLsizei length,
const GLchar* message, GLvoid* user_param) {
reinterpret_cast<GLContext*>(user_param)
->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,
GLsizei length, const GLchar* message);
static void GLAPIENTRY
DebugMessageThunk(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message, GLvoid* user_param);
DebugMessageThunk(GLenum source, GLenum type, GLuint id, GLenum severity,
GLsizei length, const GLchar* message,
GLvoid* user_param);
HWND hwnd_;
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;
}
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);
size_cube.logical_width = 1 + fetch.size_stack.width;
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;
uint32_t bytes_per_block = format_info->block_width *
format_info->block_height *
format_info->bits_per_pixel / 8;
format_info->block_height *
format_info->bits_per_pixel / 8;
uint32_t byte_pitch = tile_width * 32 * bytes_per_block;
if (!is_tiled) {
// 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,
// dest_blend_alpha);
void DrawBlendMode(uint32_t src_blend, uint32_t dest_blend, uint32_t blend_op) {
static const char* kBlendNames[] = {
/* 0 */ "ZERO",
/* 1 */ "ONE",
/* 2 */ "UNK2", // ?
/* 3 */ "UNK3", // ?
/* 4 */ "SRC_COLOR",
/* 5 */ "ONE_MINUS_SRC_COLOR",
/* 6 */ "SRC_ALPHA",
/* 7 */ "ONE_MINUS_SRC_ALPHA",
/* 8 */ "DST_COLOR",
/* 9 */ "ONE_MINUS_DST_COLOR",
/* 10 */ "DST_ALPHA",
/* 11 */ "ONE_MINUS_DST_ALPHA",
/* 12 */ "CONSTANT_COLOR",
/* 13 */ "ONE_MINUS_CONSTANT_COLOR",
/* 14 */ "CONSTANT_ALPHA",
/* 15 */ "ONE_MINUS_CONSTANT_ALPHA",
/* 16 */ "SRC_ALPHA_SATURATE",
static const char* kBlendNames[] = {/* 0 */ "ZERO",
/* 1 */ "ONE",
/* 2 */ "UNK2", // ?
/* 3 */ "UNK3", // ?
/* 4 */ "SRC_COLOR",
/* 5 */ "ONE_MINUS_SRC_COLOR",
/* 6 */ "SRC_ALPHA",
/* 7 */ "ONE_MINUS_SRC_ALPHA",
/* 8 */ "DST_COLOR",
/* 9 */ "ONE_MINUS_DST_COLOR",
/* 10 */ "DST_ALPHA",
/* 11 */ "ONE_MINUS_DST_ALPHA",
/* 12 */ "CONSTANT_COLOR",
/* 13 */ "ONE_MINUS_CONSTANT_COLOR",
/* 14 */ "CONSTANT_ALPHA",
/* 15 */ "ONE_MINUS_CONSTANT_ALPHA",
/* 16 */ "SRC_ALPHA_SATURATE",
};
const char* src_str = kBlendNames[src_blend];
const char* dest_str = kBlendNames[dest_blend];
@ -2397,7 +2396,7 @@ void ImImpl_Setup() {
pixels);
// 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.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;
pcmd++) {
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;
}
glScissor((int)pcmd->clip_rect.x, (int)(height - pcmd->clip_rect.w),

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -39,8 +39,7 @@ class FileSystem {
int RegisterDevice(const std::string& path, Device* device);
int RegisterHostPathDevice(const std::string& path,
const std::wstring& local_path,
bool read_only);
const std::wstring& local_path, bool read_only);
int RegisterDiscImageDevice(const std::string& path,
const std::wstring& local_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)) {
return X_STATUS_OBJECT_NAME_COLLISION;
}
name_table_.insert({ name, handle });
name_table_.insert({name, handle});
return X_STATUS_SUCCESS;
}

View File

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

View File

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

View File

@ -40,7 +40,7 @@ void XamModule::RegisterExportTable(xe::cpu::ExportResolver* export_resolver) {
return;
}
// Build the export table used for resolution.
// Build the export table used for resolution.
#include "xenia/kernel/util/export_table_pre.inc"
static xe::cpu::KernelExport xam_export_table[] = {
#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_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 message = SHIM_GET_ARG_32(1);
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);
XELOGD("NetDll_select(%d, %d, %.8X, %.8X, %.8X, %.8X)", arg0, nfds,
readfds_ptr, writefds_ptr, exceptfds_ptr, timeout_ptr);
fd_set readfds = { 0 };
fd_set readfds = {0};
if (readfds_ptr) {
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);
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_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 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) {
//XELOGD("NtYieldExecution()");
// XELOGD("NtYieldExecution()");
XThread* thread = XThread::GetCurrentThread();
X_STATUS result = thread->Delay(0, 0, 0);
SHIM_SET_RETURN_64(0);

View File

@ -224,15 +224,24 @@ const static struct {
uint32_t virtual_address_end;
uint32_t target_address;
} map_info[] = {
0x00000000, 0x3FFFFFFF, 0x00000000, // (1024mb) - virtual 4k pages
0x40000000, 0x7EFFFFFF, 0x40000000, // (1024mb) - virtual 64k pages (cont)
0x7F000000, 0x7F0FFFFF, 0x00000000, // (1mb) - GPU writeback
0x7F100000, 0x7FFFFFFF, 0x00100000, // (15mb) - XPS?
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
0x00000000, 0x3FFFFFFF,
0x00000000, // (1024mb) - virtual 4k pages
0x40000000, 0x7EFFFFFF,
0x40000000, // (1024mb) - virtual 64k pages (cont)
0x7F000000, 0x7F0FFFFF,
0x00000000, // (1mb) - GPU writeback
0x7F100000, 0x7FFFFFFF,
0x00100000, // (15mb) - XPS?
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) {
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) {
switch (type) {
case LT_WARNING:
fprintf(stderr, "[W] %s\n", szMessage);
break;
case LT_ERROR:
fprintf(stderr, "[!] %s\n", szMessage);
break;
default:
break;
case LT_WARNING:
fprintf(stderr, "[W] %s\n", szMessage);
break;
case LT_ERROR:
fprintf(stderr, "[!] %s\n", szMessage);
break;
default:
break;
}
}
apiscanner_loader::apiscanner_loader()
: export_resolver(nullptr)
, memory_(nullptr)
{
: export_resolver(nullptr), memory_(nullptr) {
export_resolver = std::make_unique<xe::cpu::ExportResolver>();
kernel::XamModule::RegisterExportTable(export_resolver.get());
@ -40,8 +38,7 @@ apiscanner_loader::apiscanner_loader()
memory_->Initialize();
}
apiscanner_loader::~apiscanner_loader()
{
apiscanner_loader::~apiscanner_loader() {
if (export_resolver != nullptr) {
export_resolver.reset();
}
@ -62,7 +59,6 @@ bool apiscanner_loader::LoadTitleImports(const std::wstring& target) {
return ReadTarget();
}
bool apiscanner_loader::ReadTarget() {
// XXX Do a wildcard search for all xex files?
const char path[] = "game:\\default.xex";
@ -91,8 +87,7 @@ bool apiscanner_loader::ReadTarget() {
if (read_result) {
loaded_titles.push_back(res);
}
}
else {
} else {
kernel::XFileInfo file_info;
if (fs_entry->QueryInfo(&file_info)) {
if (file) {
@ -107,7 +102,7 @@ bool apiscanner_loader::ReadTarget() {
// XXX No kernel state again
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 (file) {
file->Release();
@ -141,10 +136,9 @@ bool apiscanner_loader::ReadTarget() {
}
bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
title& info)
{
title& info) {
// 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));
if (!xex_) {
log(log.LT_ERROR, "Failed to parse xex file");
@ -162,8 +156,7 @@ bool apiscanner_loader::ExtractImports(const void* addr, const size_t length,
xe_xex2_import_info_t* import_infos;
size_t import_info_count;
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++) {
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;
}
} // tools
} // xe
} // tools
} // xe

View File

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

View File

@ -16,7 +16,6 @@ namespace tools {
DEFINE_string(target, "", "List of file to extract imports from");
int api_scanner_main(std::vector<std::wstring>& args) {
// XXX we need gflags to split multiple flags into arrays for us
if (args.size() == 2 || !FLAGS_target.empty()) {
@ -44,4 +43,4 @@ int api_scanner_main(std::vector<std::wstring>& args) {
} // namespace xe
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)
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.
@ -170,7 +168,6 @@ enum X_FILE_ATTRIBUTES {
X_FILE_ATTRIBUTE_ENCRYPTED = 0x4000,
};
// http://code.google.com/p/vdash/source/browse/trunk/vdash/include/kernel.h
enum X_FILE_INFORMATION_CLASS {
XFileDirectoryInformation = 1,
@ -246,18 +243,14 @@ inline void XOverlappedSetExtendedError(void* ptr, uint32_t value) {
}
class X_ANSI_STRING {
private:
uint16_t length;
uint16_t maximum_length;
private:
uint16_t length;
uint16_t maximum_length;
const char* buffer;
public:
X_ANSI_STRING() {
Zero();
}
X_ANSI_STRING(const uint8_t* base, uint32_t p) {
Read(base, p);
}
public:
X_ANSI_STRING() { Zero(); }
X_ANSI_STRING(const uint8_t* base, uint32_t p) { Read(base, p); }
void Read(const uint8_t* base, uint32_t p) {
length = xe::load_and_swap<uint16_t>(base + p);
maximum_length = xe::load_and_swap<uint16_t>(base + p + 2);
@ -287,13 +280,11 @@ public:
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?
typedef uint32_t XNotificationID;
// http://ffplay360.googlecode.com/svn/trunk/Common/XTLOnPC.h
struct X_VIDEO_MODE {
be<uint32_t> display_width;