Skip to content

Commit

Permalink
[Premake] Fixing issues during build on Linux
Browse files Browse the repository at this point in the history
- Lack of AVX2 extension (should be done differently in the future)
- Disable deprecated-volatile warning
- Added missing override in posix EventInfo, ImGui notification class and XContent class
- Removed not used XAudio2.h include in XMP
- Fixed missing switch-case in XObject
- Added fugly template in native_list.h
- Added some fixes introduced by RodoMa92 in PR198
  • Loading branch information
Gliniak committed Jan 9, 2025
1 parent 4620fa9 commit 3920739
Show file tree
Hide file tree
Showing 21 changed files with 74 additions and 36 deletions.
11 changes: 9 additions & 2 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,17 @@ filter("platforms:Linux")
"rt",
})

filter({"platforms:Linux"})
vectorextensions("AVX2")

filter({"platforms:Linux", "kind:*App"})
linkgroups("On")

filter({"platforms:Linux", "language:C++", "toolset:gcc"})
disablewarnings({
"unused-result"
"unused-result",
"deprecated-volatile",
"switch"
})

filter({"platforms:Linux", "toolset:gcc"})
Expand All @@ -135,7 +140,9 @@ filter({"platforms:Linux", "toolset:gcc"})

filter({"platforms:Linux", "language:C++", "toolset:clang"})
disablewarnings({
"deprecated-register"
"deprecated-register",
"deprecated-volatile",
"switch"
})
filter({"platforms:Linux", "language:C++", "toolset:clang", "files:*.cc or *.cpp"})
buildoptions({
Expand Down
2 changes: 0 additions & 2 deletions src/xenia/apu/audio_media_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#include "xenia/apu/xma_context.h"
#include "xenia/base/logging.h"

#include <XAudio2.h>

extern "C" {
#if XE_COMPILER_MSVC
#pragma warning(push)
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/apu/conversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ static void _generic_sequential_6_BE_to_interleaved_6_LE(
}
}
}
#if XE_COMPILER_CLANG_CL != 1
#if XE_COMPILER_CLANG_CL != 1 && !XE_PLATFORM_LINUX
// load_be_u32 unavailable on clang-cl
XE_NOINLINE
static void _movbe_sequential_6_BE_to_interleaved_6_LE(
Expand Down
9 changes: 9 additions & 0 deletions src/xenia/base/atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ inline int32_t atomic_inc(volatile int32_t* value) {
inline int32_t atomic_dec(volatile int32_t* value) {
return __sync_sub_and_fetch(value, 1);
}
inline int32_t atomic_or(volatile int32_t* value, int32_t nv) {
return __sync_or_and_fetch(value, nv);
}
inline int32_t atomic_and(volatile int32_t* value, int32_t nv) {
return __sync_and_and_fetch(value, nv);
}
inline int32_t atomic_xor(volatile int32_t* value, int32_t nv) {
return __sync_xor_and_fetch(value, nv);
}

inline int32_t atomic_exchange(int32_t new_value, volatile int32_t* value) {
return __sync_val_compare_and_swap(value, *value, new_value);
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/base/threading_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ class PosixEvent : public PosixConditionHandle<Event> {
~PosixEvent() override = default;
void Set() override { handle_.Signal(); }
void Reset() override { handle_.Reset(); }
EventInfo Query() {
EventInfo Query() override {
EventInfo result{};
assert_always();
return result;
Expand Down
8 changes: 4 additions & 4 deletions src/xenia/cpu/ppc/ppc_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ Memory* PPCFrontend::memory() const { return processor_->memory(); }
// Checks the state of the global lock and sets scratch to the current MSR
// value.
void CheckGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
auto global_mutex = reinterpret_cast<xe_global_mutex*>(arg0);
auto global_mutex = reinterpret_cast<global_mutex_type*>(arg0);
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
std::lock_guard<xe_global_mutex> lock(*global_mutex);
std::lock_guard<global_mutex_type> lock(*global_mutex);
ppc_context->scratch = *global_lock_count ? 0 : 0x8000;
}

// Enters the global lock. Safe to recursion.
void EnterGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
auto global_mutex = reinterpret_cast<xe_global_mutex*>(arg0);
auto global_mutex = reinterpret_cast<global_mutex_type*>(arg0);
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
global_mutex->lock();
xe::atomic_inc(global_lock_count);
}

// Leaves the global lock. Safe to recursion.
void LeaveGlobalLock(PPCContext* ppc_context, void* arg0, void* arg1) {
auto global_mutex = reinterpret_cast<xe_global_mutex*>(arg0);
auto global_mutex = reinterpret_cast<global_mutex_type*>(arg0);
auto global_lock_count = reinterpret_cast<int32_t*>(arg1);
auto new_lock_count = xe::atomic_dec(global_lock_count);
assert_true(new_lock_count >= 0);
Expand Down
4 changes: 4 additions & 0 deletions src/xenia/cpu/ppc/ppc_translator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,11 @@ void PPCTranslator::DumpHIR(GuestFunction* function, PPCHIRBuilder* builder) {

{
wchar_t tmpbuf[64];
#ifdef XE_PLATFORM_WIN32
_snwprintf(tmpbuf, 64, L"%X", function->address());
#else
swprintf(tmpbuf, 64, L"%X", function->address());
#endif
folder_path.append(&tmpbuf[0]);
}

Expand Down
4 changes: 2 additions & 2 deletions src/xenia/cpu/processor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ bool Processor::Restore(ByteStream* stream) {
std::vector<uint32_t> to_delete;
for (auto& it : thread_debug_infos_) {
if (it.second->state == ThreadDebugInfo::State::kZombie) {
it.second->thread_handle = NULL;
it.second->thread_handle = 0;
to_delete.push_back(it.first);
}
}
Expand Down Expand Up @@ -502,7 +502,7 @@ void Processor::OnThreadDestroyed(uint32_t thread_id) {
auto global_lock = global_critical_region_.Acquire();
auto it = thread_debug_infos_.find(thread_id);
assert_true(it != thread_debug_infos_.end());
it->second->thread_handle = NULL;
it->second->thread_handle = 0;
thread_debug_infos_.erase(it);
}

Expand Down
6 changes: 5 additions & 1 deletion src/xenia/cpu/xex_module.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1136,10 +1136,14 @@ void XexModule::Precompile() {
high_code);
final_image_sha_.finalize(image_sha_bytes_);

char fmtbuf[16];
char fmtbuf[20];

for (unsigned i = 0; i < 20; ++i) {
#ifdef XE_PLATFORM_WIN32
sprintf_s(fmtbuf, "%X", image_sha_bytes_[i]);
#else
sprintf(fmtbuf, "%X", image_sha_bytes_[i]);
#endif
image_sha_str_ += &fmtbuf[0];
}

Expand Down
7 changes: 7 additions & 0 deletions src/xenia/gpu/draw_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -580,10 +580,17 @@ static inline void GetScissorTmpl(const RegisterFile& XE_RESTRICT regs,
__m128i pa_sc_scissor = _mm_setr_epi32(
pa_sc_screen_scissor_tl_tl_x, pa_sc_screen_scissor_tl_tl_y,
pa_sc_screen_scissor_br_br_x, pa_sc_screen_scissor_br_br_y);
#if XE_PLATFORM_WIN32
__m128i xyoffsetadd = _mm_cvtsi64x_si128(
static_cast<unsigned long long>(pa_sc_window_offset_window_x_offset) |
(static_cast<unsigned long long>(pa_sc_window_offset_window_y_offset)
<< 32));
#else
__m128i xyoffsetadd = _mm_cvtsi64_si128(
static_cast<unsigned long long>(pa_sc_window_offset_window_x_offset) |
(static_cast<unsigned long long>(pa_sc_window_offset_window_y_offset)
<< 32));
#endif
xyoffsetadd = _mm_unpacklo_epi64(xyoffsetadd, xyoffsetadd);
// chrispy: put this here to make it clear that the shift by 31 is extracting
// this field
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/gpu/shared_memory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -482,7 +482,7 @@ void SharedMemory::TryFindUploadRange(const uint32_t& block_first,
}

static bool UploadRange_DoBestScanForward(uint64_t v, uint32_t* out) {
#if XE_ARCH_AMD64 == 1
#if XE_ARCH_AMD64 == 1 && XE_PLATFORM_WIN32
if (!v) {
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/gpu/trace_player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void TracePlayer::PlayTrace(const uint8_t* trace_data, size_t trace_size,
TracePlaybackMode playback_mode,
bool clear_caches) {
playing_trace_ = true;
graphics_system_->command_processor()->CallInThread([=]() {
graphics_system_->command_processor()->CallInThread([=, this]() {
PlayTraceOnThread(trace_data, trace_size, playback_mode, clear_caches);
});
}
Expand Down
12 changes: 8 additions & 4 deletions src/xenia/gpu/trace_viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -972,13 +972,17 @@ void TraceViewer::DrawVertexFetcher(Shader* shader,
case xenos::VertexFormat::k_16_16_16_16_FLOAT: {
auto e0 = LOADEL(uint32_t, 0);
auto e1 = LOADEL(uint32_t, 1);
ImGui::Text("%.2f", half_float::detail::uint16((e0 >> 16) & 0xFFFF));
ImGui::Text("%.2f", static_cast<float>(half_float::detail::uint16(
(e0 >> 16) & 0xFFFF)));
ImGui::NextColumn();
ImGui::Text("%.2f", half_float::detail::uint16((e0 >> 0) & 0xFFFF));
ImGui::Text("%.2f", static_cast<float>(half_float::detail::uint16(
(e0 >> 0) & 0xFFFF)));
ImGui::NextColumn();
ImGui::Text("%.2f", half_float::detail::uint16((e1 >> 16) & 0xFFFF));
ImGui::Text("%.2f", static_cast<float>(half_float::detail::uint16(
(e1 >> 16) & 0xFFFF)));
ImGui::NextColumn();
ImGui::Text("%.2f", half_float::detail::uint16((e1 >> 0) & 0xFFFF));
ImGui::Text("%.2f", static_cast<float>(half_float::detail::uint16(
(e1 >> 0) & 0xFFFF)));
ImGui::NextColumn();
} break;
case xenos::VertexFormat::k_32_32_32_32_FLOAT:
Expand Down
15 changes: 9 additions & 6 deletions src/xenia/kernel/util/native_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class NativeList {
};
template <typename VirtualTranslator>
static X_LIST_ENTRY* XeHostList(uint32_t ptr, VirtualTranslator context) {
return context->TranslateVirtual<X_LIST_ENTRY*>(ptr);
return context->template TranslateVirtual<X_LIST_ENTRY*>(ptr);
}
template <typename VirtualTranslator>
static uint32_t XeGuestList(X_LIST_ENTRY* ptr, VirtualTranslator context) {
Expand Down Expand Up @@ -193,7 +193,8 @@ struct X_TYPED_LIST : public X_LIST_ENTRY {

inline ForwardIterator& operator++() {
current_entry =
vt->TranslateVirtual<X_LIST_ENTRY*>(current_entry)->flink_ptr;
vt->template TranslateVirtual<X_LIST_ENTRY*>(current_entry)
->flink_ptr;
return *this;
}
inline bool operator!=(uint32_t other_ptr) const {
Expand All @@ -202,7 +203,7 @@ struct X_TYPED_LIST : public X_LIST_ENTRY {

inline TObject& operator*() {
return *ListEntryObject(
vt->TranslateVirtual<X_LIST_ENTRY*>(current_entry));
vt->template TranslateVirtual<X_LIST_ENTRY*>(current_entry));
}
};
template <typename VirtualTranslator>
Expand Down Expand Up @@ -236,15 +237,17 @@ struct X_TYPED_LIST : public X_LIST_ENTRY {
}
template <typename VirtualTranslator>
bool empty(VirtualTranslator vt) const {
return vt->TranslateVirtual<X_LIST_ENTRY*>(flink_ptr) == this;
return vt->template TranslateVirtual<X_LIST_ENTRY*>(flink_ptr) == this;
}
template <typename VirtualTranslator>
TObject* HeadObject(VirtualTranslator vt) {
return ListEntryObject(vt->TranslateVirtual<X_LIST_ENTRY*>(flink_ptr));
return ListEntryObject(
vt->template TranslateVirtual<X_LIST_ENTRY*>(flink_ptr));
}
template <typename VirtualTranslator>
TObject* TailObject(VirtualTranslator vt) {
return ListEntryObject(vt->TranslateVirtual<X_LIST_ENTRY*>(blink_ptr));
return ListEntryObject(
vt->template TranslateVirtual<X_LIST_ENTRY*>(blink_ptr));
}
};
} // namespace util
Expand Down
4 changes: 2 additions & 2 deletions src/xenia/kernel/xam/xam_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ class ProfilePasscodeDialog : public XamDialog {
if (ImGui::BeginPopupModal(title_.c_str(), nullptr,
ImGuiWindowFlags_AlwaysAutoResize)) {
if (description_.size()) {
ImGui::Text(description_.c_str());
ImGui::Text("%s", description_.c_str());
}

for (uint8_t i = 0; i < passcode_length; i++) {
Expand Down Expand Up @@ -872,7 +872,7 @@ class GamesInfoDialog final : public ui::ImGuiDialog {
ImGui::SetCursorPosX(ImGui::GetCursorPosX() + textOffsetX);
}

ImGui::Text(no_entries_message.c_str());
ImGui::Text("%s", no_entries_message.c_str());
ImGui::PopFont();
}

Expand Down
2 changes: 2 additions & 0 deletions src/xenia/kernel/xobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class XObject {
case Type::Thread:
case Type::Timer:
return true;
default:
return false;
}
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/xenia/ui/imgui_guest_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void AchievementNotificationWindow::OnDraw(ImGuiIO& io) {

ImGui::SameLine();
if (notification_draw_progress_ > 0.5f) {
ImGui::TextColored(white_color, GetNotificationText().c_str());
ImGui::TextColored(white_color, "%s", GetNotificationText().c_str());
}
}
// Restore previous style
Expand Down Expand Up @@ -248,7 +248,7 @@ void XNotifyWindow::OnDraw(ImGuiIO& io) {

ImGui::SameLine();
if (notification_draw_progress_ > 0.5f) {
ImGui::TextColored(white_color, GetDescription().c_str());
ImGui::TextColored(white_color, "%s", GetDescription().c_str());
}
}
// Restore previous style
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/ui/imgui_guest_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class ImGuiGuestNotification : public ImGuiNotification {
const ImVec2 CalculateNotificationSize(ImVec2 text_size,
float scale) override;

virtual void OnDraw(ImGuiIO& io) {}
virtual void OnDraw(ImGuiIO& io) override {}

float notification_draw_progress_;

Expand Down
4 changes: 2 additions & 2 deletions src/xenia/ui/imgui_host_notification.cc
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ void HostNotificationWindow::OnDraw(ImGuiIO& io) {
{
ImGui::SetWindowFontScale(window_scale);

ImGui::Text(GetTitle().c_str());
ImGui::Text("%s", GetTitle().c_str());
ImGui::Separator();
ImGui::Text(GetDescription().c_str());
ImGui::Text("%s", GetDescription().c_str());
}
ImGui::End();
}
Expand Down
2 changes: 1 addition & 1 deletion src/xenia/ui/imgui_host_notification.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ImGuiHostNotification : public ImGuiNotification {
const ImVec2 CalculateNotificationSize(ImVec2 text_size,
float scale) override;

virtual void OnDraw(ImGuiIO& io) {}
virtual void OnDraw(ImGuiIO& io) override {}
};

class HostNotificationWindow final : ImGuiHostNotification {
Expand Down
6 changes: 3 additions & 3 deletions src/xenia/vfs/devices/xcontent_container_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class XContentContainerDevice : public Device {

~XContentContainerDevice() override;

bool Initialize();
bool Initialize() override;

const std::string& name() const override { return name_; }
uint32_t attributes() const override { return 0; }
Expand Down Expand Up @@ -93,9 +93,9 @@ class XContentContainerDevice : public Device {
// Initialize any container specific fields.
virtual void SetupContainer() {};

Entry* ResolvePath(const std::string_view path);
Entry* ResolvePath(const std::string_view path) override;
void CloseFiles();
void Dump(StringBuffer* string_buffer);
void Dump(StringBuffer* string_buffer) override;
Result ReadHeaderAndVerify(FILE* header_file);

void SetName(std::string name) { name_ = name; }
Expand Down

0 comments on commit 3920739

Please sign in to comment.