Compare commits
9 Commits
47fa5f36c5
...
9dff007cd6
Author | SHA1 | Date |
---|---|---|
![]() |
9dff007cd6 | |
![]() |
7d8c8d3bf1 | |
![]() |
b694820c90 | |
![]() |
1ff3dc4d10 | |
![]() |
3e55d0048c | |
![]() |
1a4746f261 | |
![]() |
529d453986 | |
![]() |
93b5886e22 | |
![]() |
288900ff7e |
|
@ -1,6 +1,6 @@
|
||||||
[submodule "third_party/xbyak"]
|
[submodule "third_party/xbyak"]
|
||||||
path = third_party/xbyak
|
path = third_party/xbyak
|
||||||
url = https://github.com/xenia-project/xbyak.git
|
url = https://github.com/herumi/xbyak.git
|
||||||
[submodule "third_party/imgui"]
|
[submodule "third_party/imgui"]
|
||||||
path = third_party/imgui
|
path = third_party/imgui
|
||||||
url = https://github.com/ocornut/imgui.git
|
url = https://github.com/ocornut/imgui.git
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
url = https://github.com/openluopworld/aes_128.git
|
url = https://github.com/openluopworld/aes_128.git
|
||||||
[submodule "third_party/capstone"]
|
[submodule "third_party/capstone"]
|
||||||
path = third_party/capstone
|
path = third_party/capstone
|
||||||
url = https://github.com/xenia-project/capstone.git
|
url = https://github.com/capstone-engine/capstone.git
|
||||||
[submodule "third_party/cpptoml"]
|
[submodule "third_party/cpptoml"]
|
||||||
path = third_party/cpptoml
|
path = third_party/cpptoml
|
||||||
url = https://github.com/skystrife/cpptoml.git
|
url = https://github.com/skystrife/cpptoml.git
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,7 +2,7 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Xenia : Xbox 360 Emulator Research Project *
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Copyright 2021 Ben Vanik. All rights reserved. *
|
* Copyright 2023 Ben Vanik. All rights reserved. *
|
||||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -14,8 +14,9 @@
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
//#include <vector>
|
|
||||||
|
|
||||||
|
#include "xenia/base/bit_stream.h"
|
||||||
|
#include "xenia/base/ring_buffer.h"
|
||||||
#include "xenia/memory.h"
|
#include "xenia/memory.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
|
@ -76,7 +77,7 @@ struct XMA_CONTEXT_DATA {
|
||||||
|
|
||||||
// DWORD 2
|
// DWORD 2
|
||||||
uint32_t input_buffer_read_offset : 26; // XMAGetInputBufferReadOffset
|
uint32_t input_buffer_read_offset : 26; // XMAGetInputBufferReadOffset
|
||||||
uint32_t unk_dword_2 : 6; // ErrorStatus/ErrorSet (?)
|
uint32_t error_status : 6; // ErrorStatus/ErrorSet (?)
|
||||||
|
|
||||||
// DWORD 3
|
// DWORD 3
|
||||||
uint32_t loop_start : 26; // XMASetLoopData LoopStartOffset
|
uint32_t loop_start : 26; // XMASetLoopData LoopStartOffset
|
||||||
|
@ -96,7 +97,7 @@ struct XMA_CONTEXT_DATA {
|
||||||
// DWORD 7
|
// DWORD 7
|
||||||
uint32_t output_buffer_ptr; // physical address
|
uint32_t output_buffer_ptr; // physical address
|
||||||
// DWORD 8
|
// DWORD 8
|
||||||
uint32_t work_buffer_ptr; // PtrOverlapAdd(?)
|
uint32_t work_buffer_ptr; // Stores currently processed subframe
|
||||||
|
|
||||||
// DWORD 9
|
// DWORD 9
|
||||||
// +0bit, XMAGetOutputBufferReadOffset AKA WriteBufferOffsetRead
|
// +0bit, XMAGetOutputBufferReadOffset AKA WriteBufferOffsetRead
|
||||||
|
@ -115,10 +116,40 @@ struct XMA_CONTEXT_DATA {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Store(void* ptr) {
|
void Store(void* ptr) {
|
||||||
|
// TODO: Compare current ptr state with this and see which dwords we should
|
||||||
|
// write
|
||||||
xe::copy_and_swap(reinterpret_cast<uint32_t*>(ptr),
|
xe::copy_and_swap(reinterpret_cast<uint32_t*>(ptr),
|
||||||
reinterpret_cast<const uint32_t*>(this),
|
reinterpret_cast<const uint32_t*>(this),
|
||||||
sizeof(XMA_CONTEXT_DATA) / 4);
|
sizeof(XMA_CONTEXT_DATA) / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsInputBufferValid(uint8_t buffer_index) const {
|
||||||
|
return buffer_index == 0 ? input_buffer_0_valid : input_buffer_1_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsCurrentInputBufferValid() const {
|
||||||
|
return IsInputBufferValid(current_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool IsAnyInputBufferValid() const {
|
||||||
|
return input_buffer_0_valid || input_buffer_1_valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t GetInputBufferAddress(uint8_t buffer_index) const {
|
||||||
|
return buffer_index == 0 ? input_buffer_0_ptr : input_buffer_1_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t GetCurrentInputBufferAddress() const {
|
||||||
|
return GetInputBufferAddress(current_buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint32_t GetInputBufferPacketCount(uint8_t buffer_index) const {
|
||||||
|
return buffer_index == 0 ? input_buffer_0_packet_count
|
||||||
|
: input_buffer_1_packet_count;
|
||||||
|
}
|
||||||
|
const uint32_t GetCurrentInputBufferPacketCount() const {
|
||||||
|
return GetInputBufferPacketCount(current_buffer);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
static_assert_size(XMA_CONTEXT_DATA, 64);
|
static_assert_size(XMA_CONTEXT_DATA, 64);
|
||||||
|
|
||||||
|
@ -130,11 +161,28 @@ struct Xma2ExtraData {
|
||||||
static_assert_size(Xma2ExtraData, 34);
|
static_assert_size(Xma2ExtraData, 34);
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
struct kPacketInfo {
|
||||||
|
uint8_t frame_count_;
|
||||||
|
uint8_t current_frame_;
|
||||||
|
uint32_t current_frame_size_;
|
||||||
|
|
||||||
|
const bool isLastFrameInPacket() const {
|
||||||
|
return current_frame_ == frame_count_ - 1;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr int kIdToSampleRate[4] = {24000, 32000, 44100, 48000};
|
||||||
|
|
||||||
class XmaContext {
|
class XmaContext {
|
||||||
public:
|
public:
|
||||||
static const uint32_t kBytesPerPacket = 2048;
|
static const uint32_t kBytesPerPacket = 2048;
|
||||||
|
static const uint32_t kBytesPerPacketHeader = 4;
|
||||||
|
static const uint32_t kBytesPerPacketData =
|
||||||
|
kBytesPerPacket - kBytesPerPacketHeader;
|
||||||
|
|
||||||
static const uint32_t kBitsPerPacket = kBytesPerPacket * 8;
|
static const uint32_t kBitsPerPacket = kBytesPerPacket * 8;
|
||||||
static const uint32_t kBitsPerHeader = 32;
|
static const uint32_t kBitsPerPacketHeader = 32;
|
||||||
|
static const uint32_t kBitsPerFrameHeader = 15;
|
||||||
|
|
||||||
static const uint32_t kBytesPerSample = 2;
|
static const uint32_t kBytesPerSample = 2;
|
||||||
static const uint32_t kSamplesPerFrame = 512;
|
static const uint32_t kSamplesPerFrame = 512;
|
||||||
|
@ -144,8 +192,11 @@ class XmaContext {
|
||||||
static const uint32_t kBytesPerSubframeChannel =
|
static const uint32_t kBytesPerSubframeChannel =
|
||||||
kSamplesPerSubframe * kBytesPerSample;
|
kSamplesPerSubframe * kBytesPerSample;
|
||||||
|
|
||||||
// static const uint32_t kOutputBytesPerBlock = 256;
|
static const uint32_t kOutputBytesPerBlock = 256;
|
||||||
// static const uint32_t kOutputMaxSizeBytes = 31 * kOutputBytesPerBlock;
|
static const uint32_t kOutputMaxSizeBytes = 31 * kOutputBytesPerBlock;
|
||||||
|
|
||||||
|
static const uint32_t kLastFrameMarker = 0x7FFF;
|
||||||
|
static const uint32_t kMaxFrameSizeinBits = 0x4000 - kBitsPerPacketHeader;
|
||||||
|
|
||||||
explicit XmaContext();
|
explicit XmaContext();
|
||||||
~XmaContext();
|
~XmaContext();
|
||||||
|
@ -171,30 +222,44 @@ class XmaContext {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void SwapInputBuffer(XMA_CONTEXT_DATA* data);
|
static void SwapInputBuffer(XMA_CONTEXT_DATA* data);
|
||||||
static bool TrySetupNextLoop(XMA_CONTEXT_DATA* data,
|
// Convert sampling rate from ID to frequency.
|
||||||
bool ignore_input_buffer_offset);
|
|
||||||
static void NextPacket(XMA_CONTEXT_DATA* data);
|
|
||||||
static int GetSampleRate(int id);
|
static int GetSampleRate(int id);
|
||||||
// Get the offset of the next frame. Does not traverse packets.
|
|
||||||
static size_t GetNextFrame(uint8_t* block, size_t size, size_t bit_offset);
|
|
||||||
// Get the containing packet number of the frame pointed to by the offset.
|
// Get the containing packet number of the frame pointed to by the offset.
|
||||||
static int GetFramePacketNumber(uint8_t* block, size_t size,
|
static int16_t GetPacketNumber(size_t size, size_t bit_offset);
|
||||||
size_t bit_offset);
|
|
||||||
// Get the packet number and the index of the frame inside that packet
|
const kPacketInfo GetPacketInfo(uint8_t* packet, uint32_t frame_offset);
|
||||||
static std::tuple<int, int> GetFrameNumber(uint8_t* block, size_t size,
|
|
||||||
size_t bit_offset);
|
const uint32_t GetAmountOfBitsToRead(const uint32_t remaining_stream_bits,
|
||||||
// Get the number of frames contained in the packet (including truncated) and
|
const uint32_t frame_size);
|
||||||
// if the last frame is split.
|
|
||||||
static std::tuple<int, bool> GetPacketFrameCount(uint8_t* packet);
|
const uint8_t* GetNextPacket(XMA_CONTEXT_DATA* data,
|
||||||
|
uint32_t next_packet_index,
|
||||||
|
uint32_t current_input_packet_count);
|
||||||
|
|
||||||
|
const uint32_t GetNextPacketReadOffset(uint8_t* buffer,
|
||||||
|
uint32_t next_packet_index,
|
||||||
|
uint32_t current_input_packet_count);
|
||||||
|
|
||||||
|
// Returns currently used buffer
|
||||||
|
uint8_t* GetCurrentInputBuffer(XMA_CONTEXT_DATA* data);
|
||||||
|
|
||||||
|
static uint32_t GetCurrentInputBufferSize(XMA_CONTEXT_DATA* data);
|
||||||
|
|
||||||
// Convert sample format and swap bytes
|
// Convert sample format and swap bytes
|
||||||
static void ConvertFrame(const uint8_t** samples, bool is_two_channel,
|
static void ConvertFrame(const uint8_t** samples, bool is_two_channel,
|
||||||
uint8_t* output_buffer);
|
uint8_t* output_buffer);
|
||||||
|
|
||||||
bool ValidFrameOffset(uint8_t* block, size_t size_bytes,
|
|
||||||
size_t frame_offset_bits);
|
|
||||||
void Decode(XMA_CONTEXT_DATA* data);
|
void Decode(XMA_CONTEXT_DATA* data);
|
||||||
int PrepareDecoder(uint8_t* packet, int sample_rate, bool is_two_channel);
|
void Consume(RingBuffer* output_rb, XMA_CONTEXT_DATA* data);
|
||||||
|
|
||||||
|
void UpdateLoopStatus(XMA_CONTEXT_DATA* data);
|
||||||
|
int PrepareDecoder(int sample_rate, bool is_two_channel);
|
||||||
|
void PreparePacket(const uint32_t frame_size, const uint32_t frame_padding);
|
||||||
|
|
||||||
|
RingBuffer PrepareOutputRingBuffer(XMA_CONTEXT_DATA* data);
|
||||||
|
|
||||||
|
bool DecodePacket(AVCodecContext* av_context, const AVPacket* av_packet,
|
||||||
|
AVFrame* av_frame);
|
||||||
|
|
||||||
// This method should be used ONLY when we're at the last packet of the stream
|
// This method should be used ONLY when we're at the last packet of the stream
|
||||||
// and we want to find offset in next buffer
|
// and we want to find offset in next buffer
|
||||||
|
@ -204,39 +269,24 @@ class XmaContext {
|
||||||
|
|
||||||
uint32_t id_ = 0;
|
uint32_t id_ = 0;
|
||||||
uint32_t guest_ptr_ = 0;
|
uint32_t guest_ptr_ = 0;
|
||||||
|
|
||||||
xe_mutex lock_;
|
xe_mutex lock_;
|
||||||
volatile bool is_allocated_ = false;
|
volatile bool is_allocated_ = false;
|
||||||
volatile bool is_enabled_ = false;
|
volatile bool is_enabled_ = false;
|
||||||
// bool is_dirty_ = true;
|
|
||||||
|
|
||||||
// ffmpeg structures
|
// ffmpeg structures
|
||||||
AVPacket* av_packet_ = nullptr;
|
AVPacket* av_packet_ = nullptr;
|
||||||
AVCodec* av_codec_ = nullptr;
|
AVCodec* av_codec_ = nullptr;
|
||||||
AVCodecContext* av_context_ = nullptr;
|
AVCodecContext* av_context_ = nullptr;
|
||||||
AVFrame* av_frame_ = nullptr;
|
AVFrame* av_frame_ = nullptr;
|
||||||
// uint32_t decoded_consumed_samples_ = 0; // TODO do this dynamically
|
|
||||||
// int decoded_idx_ = -1;
|
|
||||||
|
|
||||||
// bool partial_frame_saved_ = false;
|
std::array<uint8_t, kBytesPerPacketData * 2> input_buffer_;
|
||||||
// bool partial_frame_size_known_ = false;
|
|
||||||
// size_t partial_frame_total_size_bits_ = 0;
|
|
||||||
// size_t partial_frame_start_offset_bits_ = 0;
|
|
||||||
// size_t partial_frame_offset_bits_ = 0; // blah internal don't use this
|
|
||||||
// std::vector<uint8_t> partial_frame_buffer_;
|
|
||||||
uint32_t packets_skip_ = 0;
|
|
||||||
|
|
||||||
bool is_stream_done_ = false;
|
|
||||||
// bool split_frame_pending_ = false;
|
|
||||||
uint32_t split_frame_len_ = 0;
|
|
||||||
uint32_t split_frame_len_partial_ = 0;
|
|
||||||
uint8_t split_frame_padding_start_ = 0;
|
|
||||||
// first byte contains bit offset information
|
// first byte contains bit offset information
|
||||||
std::array<uint8_t, 1 + 4096> xma_frame_;
|
std::array<uint8_t, 1 + 4096> xma_frame_;
|
||||||
|
|
||||||
// uint8_t* current_frame_ = nullptr;
|
|
||||||
// conversion buffer for 2 channel frame
|
|
||||||
std::array<uint8_t, kBytesPerFrameChannel * 2> raw_frame_;
|
std::array<uint8_t, kBytesPerFrameChannel * 2> raw_frame_;
|
||||||
// std::vector<uint8_t> current_frame_ = std::vector<uint8_t>(0);
|
|
||||||
|
int32_t remaining_subframe_blocks_in_output_buffer_ = 0;
|
||||||
|
uint8_t current_frame_remaining_subframes_ = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace apu
|
} // namespace apu
|
||||||
|
|
|
@ -143,7 +143,7 @@ X_STATUS XmaDecoder::Setup(kernel::KernelState* kernel_state) {
|
||||||
assert_not_null(work_event_);
|
assert_not_null(work_event_);
|
||||||
worker_thread_ = kernel::object_ref<kernel::XHostThread>(
|
worker_thread_ = kernel::object_ref<kernel::XHostThread>(
|
||||||
new kernel::XHostThread(kernel_state, 128 * 1024, 0, [this]() {
|
new kernel::XHostThread(kernel_state, 128 * 1024, 0, [this]() {
|
||||||
WorkerThreadMain();
|
//WorkerThreadMain();
|
||||||
return 0;
|
return 0;
|
||||||
}, kernel_state->GetIdleProcess()));//this one doesnt need any process actually. never calls any guest code
|
}, kernel_state->GetIdleProcess()));//this one doesnt need any process actually. never calls any guest code
|
||||||
worker_thread_->set_name("XMA Decoder");
|
worker_thread_->set_name("XMA Decoder");
|
||||||
|
@ -307,6 +307,7 @@ void XmaDecoder::WriteRegister(uint32_t addr, uint32_t value) {
|
||||||
uint32_t context_id = base_context_id + i;
|
uint32_t context_id = base_context_id + i;
|
||||||
auto& context = contexts_[context_id];
|
auto& context = contexts_[context_id];
|
||||||
context.Enable();
|
context.Enable();
|
||||||
|
context.Work();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Signal the decoder thread to start processing.
|
// Signal the decoder thread to start processing.
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Xenia : Xbox 360 Emulator Research Project *
|
* Xenia : Xbox 360 Emulator Research Project *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
* Copyright 2021 Ben Vanik. All rights reserved. *
|
* Copyright 2023 Ben Vanik. All rights reserved. *
|
||||||
* Released under the BSD license - see LICENSE in the root for more details. *
|
* Released under the BSD license - see LICENSE in the root for more details. *
|
||||||
******************************************************************************
|
******************************************************************************
|
||||||
*/
|
*/
|
||||||
|
@ -20,29 +20,29 @@ namespace xma {
|
||||||
|
|
||||||
static const uint32_t kMaxFrameLength = 0x7FFF;
|
static const uint32_t kMaxFrameLength = 0x7FFF;
|
||||||
|
|
||||||
// Get number of frames that /begin/ in this packet.
|
// Get number of frames that /begin/ in this packet. This is valid only for XMA2
|
||||||
uint32_t GetPacketFrameCount(uint8_t* packet) {
|
// packets
|
||||||
return (uint8_t)(packet[0] >> 2);
|
const uint8_t GetPacketFrameCount(const uint8_t* packet) {
|
||||||
|
return packet[0] >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const uint8_t GetPacketMetadata(const uint8_t* packet) {
|
||||||
|
return packet[2] & 0x7;
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool IsPacketXma2Type(const uint8_t* packet) {
|
||||||
|
return GetPacketMetadata(packet) == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t GetPacketSkipCount(const uint8_t* packet) { return packet[3]; }
|
||||||
|
|
||||||
// Get the first frame offset in bits
|
// Get the first frame offset in bits
|
||||||
uint32_t GetPacketFrameOffset(uint8_t* packet) {
|
uint32_t GetPacketFrameOffset(const uint8_t* packet) {
|
||||||
uint32_t val = (uint16_t)(((packet[0] & 0x3) << 13) | (packet[1] << 5) |
|
uint32_t val = (uint16_t)(((packet[0] & 0x3) << 13) | (packet[1] << 5) |
|
||||||
(packet[2] >> 3));
|
(packet[2] >> 3));
|
||||||
// if (val > kBitsPerPacket - kBitsPerHeader) {
|
|
||||||
// // There is no data in this packet
|
|
||||||
// return -1;
|
|
||||||
// } else {
|
|
||||||
return val + 32;
|
return val + 32;
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t GetPacketMetadata(uint8_t* packet) {
|
|
||||||
return (uint8_t)(packet[2] & 0x7);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t GetPacketSkipCount(uint8_t* packet) { return (uint8_t)(packet[3]); }
|
|
||||||
|
|
||||||
} // namespace xma
|
} // namespace xma
|
||||||
} // namespace apu
|
} // namespace apu
|
||||||
} // namespace xe
|
} // namespace xe
|
||||||
|
|
|
@ -20,6 +20,9 @@ namespace xe {
|
||||||
BitStream::BitStream(uint8_t* buffer, size_t size_in_bits)
|
BitStream::BitStream(uint8_t* buffer, size_t size_in_bits)
|
||||||
: buffer_(buffer), size_bits_(size_in_bits) {}
|
: buffer_(buffer), size_bits_(size_in_bits) {}
|
||||||
|
|
||||||
|
BitStream::BitStream(const uint8_t* buffer, size_t size_in_bits)
|
||||||
|
: buffer_(const_cast<uint8_t*>(buffer)), size_bits_(size_in_bits) {}
|
||||||
|
|
||||||
BitStream::~BitStream() = default;
|
BitStream::~BitStream() = default;
|
||||||
|
|
||||||
void BitStream::SetOffset(size_t offset_bits) {
|
void BitStream::SetOffset(size_t offset_bits) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace xe {
|
||||||
class BitStream {
|
class BitStream {
|
||||||
public:
|
public:
|
||||||
BitStream(uint8_t* buffer, size_t size_in_bits);
|
BitStream(uint8_t* buffer, size_t size_in_bits);
|
||||||
|
BitStream(const uint8_t* buffer, size_t size_in_bits);
|
||||||
~BitStream();
|
~BitStream();
|
||||||
|
|
||||||
const uint8_t* buffer() const { return buffer_; }
|
const uint8_t* buffer() const { return buffer_; }
|
||||||
|
|
|
@ -56,7 +56,7 @@
|
||||||
} \
|
} \
|
||||||
template <typename TRet = void, typename... TArgs> \
|
template <typename TRet = void, typename... TArgs> \
|
||||||
inline TRet invoke(TArgs... args) { \
|
inline TRet invoke(TArgs... args) { \
|
||||||
return reinterpret_cast<NTSYSAPI TRet(NTAPI*)(TArgs...)>(fn)(args...); \
|
return reinterpret_cast<TRet(NTAPI*)(TArgs...)>(fn)(args...); \
|
||||||
} \
|
} \
|
||||||
inline operator bool() const { return fn != nullptr; } \
|
inline operator bool() const { return fn != nullptr; } \
|
||||||
} clsvar
|
} clsvar
|
||||||
|
|
|
@ -2940,7 +2940,7 @@ void DxbcShaderTranslator::CompletePixelShader() {
|
||||||
SystemConstants::Index::kAlphaTestReference,
|
SystemConstants::Index::kAlphaTestReference,
|
||||||
offsetof(SystemConstants, alpha_test_reference), dxbc::Src::kXXXX));
|
offsetof(SystemConstants, alpha_test_reference), dxbc::Src::kXXXX));
|
||||||
// Epsilon for alpha checks
|
// Epsilon for alpha checks
|
||||||
dxbc::Src fuzzy_epsilon = dxbc::Src::LF(0.01f);
|
dxbc::Src fuzzy_epsilon = dxbc::Src::LF(1e-3f);
|
||||||
// Handle "not equal" specially (specifically as "not equal" so it's true
|
// Handle "not equal" specially (specifically as "not equal" so it's true
|
||||||
// for NaN, not "less or greater" which is false for NaN).
|
// for NaN, not "less or greater" which is false for NaN).
|
||||||
a_.OpIEq(alpha_test_op_dest, alpha_test_mask_src,
|
a_.OpIEq(alpha_test_op_dest, alpha_test_mask_src,
|
||||||
|
|
|
@ -40,7 +40,6 @@ SDLInputDriver::SDLInputDriver(xe::ui::Window* window, size_t window_z_order)
|
||||||
sdl_events_unflushed_(0),
|
sdl_events_unflushed_(0),
|
||||||
sdl_pumpevents_queued_(false),
|
sdl_pumpevents_queued_(false),
|
||||||
controllers_(),
|
controllers_(),
|
||||||
controllers_mutex_(),
|
|
||||||
keystroke_states_() {}
|
keystroke_states_() {}
|
||||||
|
|
||||||
SDLInputDriver::~SDLInputDriver() {
|
SDLInputDriver::~SDLInputDriver() {
|
||||||
|
@ -151,8 +150,6 @@ X_RESULT SDLInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags,
|
||||||
|
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
@ -180,8 +177,6 @@ X_RESULT SDLInputDriver::GetState(uint32_t user_index,
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
return X_ERROR_DEVICE_NOT_CONNECTED;
|
return X_ERROR_DEVICE_NOT_CONNECTED;
|
||||||
|
@ -295,8 +290,6 @@ X_RESULT SDLInputDriver::GetKeystroke(uint32_t users, uint32_t flags,
|
||||||
QueueControllerUpdate();
|
QueueControllerUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
for (uint32_t user_index = (user_any ? 0 : users);
|
for (uint32_t user_index = (user_any ? 0 : users);
|
||||||
user_index < (user_any ? HID_SDL_USER_COUNT : users + 1); user_index++) {
|
user_index < (user_any ? HID_SDL_USER_COUNT : users + 1); user_index++) {
|
||||||
auto controller = GetControllerState(user_index);
|
auto controller = GetControllerState(user_index);
|
||||||
|
@ -420,8 +413,6 @@ void SDLInputDriver::HandleEvent(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Open the controller.
|
// Open the controller.
|
||||||
const auto controller = SDL_GameControllerOpen(event.cdevice.which);
|
const auto controller = SDL_GameControllerOpen(event.cdevice.which);
|
||||||
if (!controller) {
|
if (!controller) {
|
||||||
|
@ -485,8 +476,6 @@ void SDLInputDriver::OnControllerDeviceAdded(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Find the disconnected gamecontroller and close it.
|
// Find the disconnected gamecontroller and close it.
|
||||||
auto idx = GetControllerIndexFromInstanceID(event.cdevice.which);
|
auto idx = GetControllerIndexFromInstanceID(event.cdevice.which);
|
||||||
if (idx) {
|
if (idx) {
|
||||||
|
@ -501,8 +490,6 @@ void SDLInputDriver::OnControllerDeviceRemoved(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
auto idx = GetControllerIndexFromInstanceID(event.caxis.which);
|
auto idx = GetControllerIndexFromInstanceID(event.caxis.which);
|
||||||
assert(idx);
|
assert(idx);
|
||||||
auto& pad = controllers_.at(*idx).state.gamepad;
|
auto& pad = controllers_.at(*idx).state.gamepad;
|
||||||
|
@ -533,8 +520,6 @@ void SDLInputDriver::OnControllerDeviceAxisMotion(const SDL_Event& event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDLInputDriver::OnControllerDeviceButtonChanged(const SDL_Event& event) {
|
void SDLInputDriver::OnControllerDeviceButtonChanged(const SDL_Event& event) {
|
||||||
std::unique_lock<std::mutex> guard(controllers_mutex_);
|
|
||||||
|
|
||||||
// Define a lookup table to map between SDL and XInput button codes.
|
// Define a lookup table to map between SDL and XInput button codes.
|
||||||
// These need to be in the order of the SDL_GameControllerButton enum.
|
// These need to be in the order of the SDL_GameControllerButton enum.
|
||||||
static constexpr std::array<
|
static constexpr std::array<
|
||||||
|
|
|
@ -84,7 +84,6 @@ class SDLInputDriver final : public InputDriver {
|
||||||
int sdl_events_unflushed_;
|
int sdl_events_unflushed_;
|
||||||
std::atomic<bool> sdl_pumpevents_queued_;
|
std::atomic<bool> sdl_pumpevents_queued_;
|
||||||
std::array<ControllerState, HID_SDL_USER_COUNT> controllers_;
|
std::array<ControllerState, HID_SDL_USER_COUNT> controllers_;
|
||||||
std::mutex controllers_mutex_;
|
|
||||||
std::array<KeystrokeState, HID_SDL_USER_COUNT> keystroke_states_;
|
std::array<KeystrokeState, HID_SDL_USER_COUNT> keystroke_states_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ DEFINE_uint32(max_signed_profiles, 4,
|
||||||
"Limits how many profiles can be assigned. Possible values: 1-4",
|
"Limits how many profiles can be assigned. Possible values: 1-4",
|
||||||
"Kernel");
|
"Kernel");
|
||||||
|
|
||||||
|
DEFINE_uint32(kernel_build_version, 1888, "Define current kernel version",
|
||||||
|
"Kernel");
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
|
@ -66,6 +69,7 @@ KernelState::KernelState(Emulator* emulator)
|
||||||
user_profiles_.emplace(0, std::make_unique<xam::UserProfile>(0));
|
user_profiles_.emplace(0, std::make_unique<xam::UserProfile>(0));
|
||||||
|
|
||||||
InitializeKernelGuestGlobals();
|
InitializeKernelGuestGlobals();
|
||||||
|
kernel_version_ = KernelVersion(cvars::kernel_build_version);
|
||||||
|
|
||||||
auto content_root = emulator_->content_root();
|
auto content_root = emulator_->content_root();
|
||||||
if (!content_root.empty()) {
|
if (!content_root.empty()) {
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace kernel {
|
||||||
|
|
||||||
constexpr fourcc_t kKernelSaveSignature = make_fourcc("KRNL");
|
constexpr fourcc_t kKernelSaveSignature = make_fourcc("KRNL");
|
||||||
|
|
||||||
|
static constexpr const uint16_t kBaseKernelBuildVersion = 1888;
|
||||||
|
|
||||||
// (?), used by KeGetCurrentProcessType
|
// (?), used by KeGetCurrentProcessType
|
||||||
constexpr uint32_t X_PROCTYPE_IDLE = 0;
|
constexpr uint32_t X_PROCTYPE_IDLE = 0;
|
||||||
constexpr uint32_t X_PROCTYPE_TITLE = 1;
|
constexpr uint32_t X_PROCTYPE_TITLE = 1;
|
||||||
|
@ -145,6 +147,27 @@ struct KernelGuestGlobals {
|
||||||
struct DPCImpersonationScope {
|
struct DPCImpersonationScope {
|
||||||
uint8_t previous_irql_;
|
uint8_t previous_irql_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct KernelVersion {
|
||||||
|
union {
|
||||||
|
xe::be<uint64_t> value;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
xe::be<uint16_t> major;
|
||||||
|
xe::be<uint16_t> minor;
|
||||||
|
xe::be<uint16_t> build;
|
||||||
|
xe::be<uint16_t> qfe;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
KernelVersion(uint16_t build_ver = kBaseKernelBuildVersion) {
|
||||||
|
major = 2;
|
||||||
|
minor = 0;
|
||||||
|
build = std::max(kBaseKernelBuildVersion, build_ver);
|
||||||
|
qfe = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
class KernelState {
|
class KernelState {
|
||||||
public:
|
public:
|
||||||
explicit KernelState(Emulator* emulator);
|
explicit KernelState(Emulator* emulator);
|
||||||
|
@ -200,6 +223,8 @@ class KernelState {
|
||||||
// Access must be guarded by the global critical region.
|
// Access must be guarded by the global critical region.
|
||||||
util::ObjectTable* object_table() { return &object_table_; }
|
util::ObjectTable* object_table() { return &object_table_; }
|
||||||
|
|
||||||
|
const KernelVersion* GetKernelVersion() const { return &kernel_version_; }
|
||||||
|
|
||||||
uint32_t GetSystemProcess() const {
|
uint32_t GetSystemProcess() const {
|
||||||
return kernel_guest_globals_ + offsetof(KernelGuestGlobals, system_process);
|
return kernel_guest_globals_ + offsetof(KernelGuestGlobals, system_process);
|
||||||
}
|
}
|
||||||
|
@ -332,6 +357,8 @@ class KernelState {
|
||||||
std::map<uint8_t, std::unique_ptr<xam::UserProfile>> user_profiles_;
|
std::map<uint8_t, std::unique_ptr<xam::UserProfile>> user_profiles_;
|
||||||
std::unique_ptr<AchievementManager> achievement_manager_;
|
std::unique_ptr<AchievementManager> achievement_manager_;
|
||||||
|
|
||||||
|
KernelVersion kernel_version_;
|
||||||
|
|
||||||
xe::global_critical_region global_critical_region_;
|
xe::global_critical_region global_critical_region_;
|
||||||
|
|
||||||
// Must be guarded by the global critical region.
|
// Must be guarded by the global critical region.
|
||||||
|
|
|
@ -13,8 +13,10 @@
|
||||||
#include "xenia/kernel/xbdm/xbdm_private.h"
|
#include "xenia/kernel/xbdm/xbdm_private.h"
|
||||||
#include "xenia/kernel/xthread.h"
|
#include "xenia/kernel/xthread.h"
|
||||||
#include "xenia/xbox.h"
|
#include "xenia/xbox.h"
|
||||||
|
|
||||||
// chrispy: no idea what a real valid value is for this
|
// chrispy: no idea what a real valid value is for this
|
||||||
static constexpr const char DmXboxName[] = "Xbox360Name";
|
static constexpr const char DmXboxName[] = "Xbox360Name";
|
||||||
|
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
namespace xbdm {
|
namespace xbdm {
|
||||||
|
@ -142,8 +144,8 @@ dword_result_t DmGetSystemInfo_entry(pointer_t<XBDM_SYSTEM_INFO> info) {
|
||||||
info->base_kernel_version.minor = info->kernel_version.minor = 0;
|
info->base_kernel_version.minor = info->kernel_version.minor = 0;
|
||||||
info->base_kernel_version.qfe = info->kernel_version.qfe = 0;
|
info->base_kernel_version.qfe = info->kernel_version.qfe = 0;
|
||||||
|
|
||||||
info->base_kernel_version.build = 1888;
|
info->base_kernel_version.build = kBaseKernelBuildVersion;
|
||||||
info->kernel_version.build = 13139;
|
info->kernel_version.build = kernel_state()->GetKernelVersion()->build;
|
||||||
|
|
||||||
return XBDM_SUCCESSFUL;
|
return XBDM_SUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
|
@ -205,15 +205,12 @@ XboxkrnlModule::XboxkrnlModule(Emulator* emulator, KernelState* kernel_state)
|
||||||
// XboxKrnlVersion (8b)
|
// XboxKrnlVersion (8b)
|
||||||
// Kernel version, looks like 2b.2b.2b.2b.
|
// Kernel version, looks like 2b.2b.2b.2b.
|
||||||
// I've only seen games check >=, so we just fake something here.
|
// I've only seen games check >=, so we just fake something here.
|
||||||
uint32_t pXboxKrnlVersion = memory_->SystemHeapAlloc(8);
|
uint32_t pXboxKrnlVersion = memory_->SystemHeapAlloc(sizeof(KernelVersion));
|
||||||
auto lpXboxKrnlVersion = memory_->TranslateVirtual(pXboxKrnlVersion);
|
auto lpXboxKrnlVersion = memory_->TranslateVirtual(pXboxKrnlVersion);
|
||||||
export_resolver_->SetVariableMapping(
|
export_resolver_->SetVariableMapping(
|
||||||
"xboxkrnl.exe", ordinals::XboxKrnlVersion, pXboxKrnlVersion);
|
"xboxkrnl.exe", ordinals::XboxKrnlVersion, pXboxKrnlVersion);
|
||||||
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 0, 2);
|
std::memcpy(lpXboxKrnlVersion, kernel_state_->GetKernelVersion(),
|
||||||
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 2, 0xFFFF);
|
sizeof(KernelVersion));
|
||||||
xe::store_and_swap<uint16_t>(lpXboxKrnlVersion + 4, 0xFFFF);
|
|
||||||
xe::store_and_swap<uint8_t>(lpXboxKrnlVersion + 6, 0x80);
|
|
||||||
xe::store_and_swap<uint8_t>(lpXboxKrnlVersion + 7, 0x00);
|
|
||||||
|
|
||||||
export_resolver_->SetVariableMapping("xboxkrnl.exe",
|
export_resolver_->SetVariableMapping("xboxkrnl.exe",
|
||||||
ordinals::KeTimeStampBundle,
|
ordinals::KeTimeStampBundle,
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6b6f40200bea5ed99367513f53f6a28e52fd3d0e
|
Subproject commit 69e54e29086b7035acffb304cec57a350225f8b0
|
|
@ -1 +1 @@
|
||||||
Subproject commit dd534e877e725c9bb6f751c427442456a05384e4
|
Subproject commit 44d72a9b36702f093dd20815561a56778b2d181e
|
|
@ -1 +1 @@
|
||||||
Subproject commit b32da5329b50e3cb96229aaecba9ded032fe29cc
|
Subproject commit 46dc0f6e514f5730784bb2cac2a7c731636839e8
|
|
@ -1 +1 @@
|
||||||
Subproject commit 51c8b56011303e94840370089f816b19dbe7edf0
|
Subproject commit 19b940e864bd3a5afb3c79e3c6788869d01a19eb
|
|
@ -1 +1 @@
|
||||||
Subproject commit f9c6a90489be7b3637ff1c7298e45efafe7cf1b9
|
Subproject commit 097c04d9413c59a58b00d4d1c8d5dc0ac158ffaa
|
|
@ -39,6 +39,8 @@ project("capstone")
|
||||||
"capstone/SStream.h",
|
"capstone/SStream.h",
|
||||||
"capstone/utils.c",
|
"capstone/utils.c",
|
||||||
"capstone/utils.h",
|
"capstone/utils.h",
|
||||||
|
"capstone/Mapping.c",
|
||||||
|
"capstone/Mapping.h",
|
||||||
|
|
||||||
"capstone/arch/X86/*.c",
|
"capstone/arch/X86/*.c",
|
||||||
"capstone/arch/X86/*.h",
|
"capstone/arch/X86/*.h",
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit b2b8cf2f50a449720874f43445e23d75b77dcc43
|
Subproject commit 3bf268481da8208d171d8908e6491459de3651d7
|
|
@ -1 +1 @@
|
||||||
Subproject commit 27e3c0fe9b5dc99f339637ec2ea7efae5b945ab8
|
Subproject commit 7bdf0628b1276379886c7f6dda2cef2b3b374f0b
|
|
@ -1 +1 @@
|
||||||
Subproject commit bc70e7e11ad37f207ece73330c5b72a55fef1ceb
|
Subproject commit 63e6ee92cc906a3dbf6b333b2fd51ac1ca95f891
|
|
@ -1 +1 @@
|
||||||
Subproject commit 4c881f796d6af27ef7d9c48f87817da0d3d75dc1
|
Subproject commit bbb27a5efb85b92a0486cf361a8635715a53f6ba
|
Loading…
Reference in New Issue