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 b50e32a commit 534ace0
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 64 deletions.
13 changes: 11 additions & 2 deletions premake5.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,18 @@ 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",
"deprecated-enum-enum-conversion",
})

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

filter({"platforms:Linux", "language:C++", "toolset:clang"})
disablewarnings({
"deprecated-register"
"deprecated-register",
"deprecated-volatile",
"switch",
"deprecated-enum-enum-conversion",
})
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
4 changes: 2 additions & 2 deletions src/xenia/base/console_app_main_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ extern "C" int main(int argc, char** argv) {
}

// Initialize logging. Needs parsed cvars.
xe::InitializeLogging(entry_info.name);
//xe::InitializeLogging(entry_info.name);

std::vector<std::string> args;
for (int n = 0; n < argc; n++) {
Expand All @@ -32,7 +32,7 @@ extern "C" int main(int argc, char** argv) {

int result = entry_info.entry_point(args);

xe::ShutdownLogging();
//xe::ShutdownLogging();

return result;
}
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
2 changes: 1 addition & 1 deletion src/xenia/debug/ui/debug_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ void DebugWindow::DrawToolbar() {
case cpu::ThreadDebugInfo::State::kAlive:
case cpu::ThreadDebugInfo::State::kExited:
case cpu::ThreadDebugInfo::State::kWaiting:
if (thread_info->thread_handle == NULL || thread_info->thread == NULL) {
if (!thread_info->thread_handle || thread_info->thread == nullptr) {
thread_combo.Append("(invalid)");
} else {
thread_combo.Append(thread_info->thread->thread_name());
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/draw_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ constexpr bool IsPrimitivePolygonal(bool vgt_output_path_is_tessellation_enable,
return (primitive_polygonal_table & (1U << static_cast<uint32_t>(type))) != 0;
}
XE_FORCEINLINE
bool IsPrimitivePolygonal(const RegisterFile& regs) {
static bool IsPrimitivePolygonal(const RegisterFile& regs) {
return IsPrimitivePolygonal(
regs.Get<reg::VGT_OUTPUT_PATH_CNTL>().path_select ==
xenos::VGTOutputPath::kTessellationEnable,
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
18 changes: 12 additions & 6 deletions src/xenia/gpu/trace_viewer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -899,9 +899,11 @@ void TraceViewer::DrawVertexFetcher(Shader* shader,
} break;
case xenos::VertexFormat::k_16_16_FLOAT: {
auto e0 = LOADEL(uint32_t, 0);
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();
} break;
case xenos::VertexFormat::k_32_32:
Expand Down Expand Up @@ -972,13 +974,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
2 changes: 1 addition & 1 deletion src/xenia/kernel/util/presence_string_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ class AttributeStringFormatter {
} // namespace kernel
} // namespace xe

#endif XENIA_KERNEL_UTIL_PRESENCE_STRING_BUILDER_H_
#endif // XENIA_KERNEL_UTIL_PRESENCE_STRING_BUILDER_H_
2 changes: 1 addition & 1 deletion src/xenia/kernel/xam/xam_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ dword_result_t XamContentLaunchImageInternal_entry(lpvoid_t content_data_ptr,

auto& loader_data = xam->loader_data();
loader_data.host_path = xe::path_to_utf8(host_path);
loader_data.launch_path = xex_path;
loader_data.launch_path = xex_path.value();

xam->SaveLoaderData();

Expand Down
Loading

0 comments on commit 534ace0

Please sign in to comment.