diff --git a/README.md b/README.md index 8f0963210..2521da1f8 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2062. +This is the source code for early-access 2064. ## Legal Notice diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8ec6fcdd5..a37ae37c1 100755 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -108,7 +108,6 @@ else() if (ARCHITECTURE_x86_64) add_compile_options("-mcx16") - add_compile_options("-mbranches-within-32B-boundaries") endif() if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang) diff --git a/src/core/core.cpp b/src/core/core.cpp index 76ddadb2a..b13350f6e 100755 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -84,9 +84,7 @@ FileSys::StorageId GetStorageIdForFrontendSlot( } void KProcessDeleter(Kernel::KProcess* process) { - if (process) { - process->Destroy(); - } + process->Destroy(); } using KProcessPtr = std::unique_ptr; @@ -324,6 +322,7 @@ struct System::Impl { kernel.Shutdown(); memory.Reset(); applet_manager.ClearAll(); + // TODO: The main process should be freed based on KAutoObject ref counting. main_process.reset(); LOG_DEBUG(Core, "Shutdown OK"); diff --git a/src/core/file_sys/vfs.cpp b/src/core/file_sys/vfs.cpp index 368419eca..f5ad10b15 100755 --- a/src/core/file_sys/vfs.cpp +++ b/src/core/file_sys/vfs.cpp @@ -273,6 +273,10 @@ VirtualFile VfsDirectory::GetFile(std::string_view name) const { return iter == files.end() ? nullptr : *iter; } +FileTimeStampRaw VfsDirectory::GetFileTimeStamp([[maybe_unused]] std::string_view path) const { + return {}; +} + VirtualDir VfsDirectory::GetSubdirectory(std::string_view name) const { const auto& subs = GetSubdirectories(); const auto iter = std::find_if(subs.begin(), subs.end(), diff --git a/src/core/file_sys/vfs.h b/src/core/file_sys/vfs.h index afd64e95c..ff6935da6 100755 --- a/src/core/file_sys/vfs.h +++ b/src/core/file_sys/vfs.h @@ -199,6 +199,9 @@ public: // file with name. virtual VirtualFile GetFile(std::string_view name) const; + // Returns a struct containing the file's timestamp. + virtual FileTimeStampRaw GetFileTimeStamp(std::string_view path) const; + // Returns a vector containing all of the subdirectories in this directory. virtual std::vector GetSubdirectories() const = 0; // Returns the directory with name matching name. Returns nullptr if directory dosen't have a diff --git a/src/core/file_sys/vfs_real.cpp b/src/core/file_sys/vfs_real.cpp index 3dad54f49..f4073b76a 100755 --- a/src/core/file_sys/vfs_real.cpp +++ b/src/core/file_sys/vfs_real.cpp @@ -13,6 +13,13 @@ #include "common/logging/log.h" #include "core/file_sys/vfs_real.h" +// For FileTimeStampRaw +#include + +#ifdef _MSC_VER +#define stat _stat64 +#endif + namespace FileSys { namespace FS = Common::FS; @@ -392,6 +399,28 @@ std::vector RealVfsDirectory::GetFiles() const { return IterateEntries(); } +FileTimeStampRaw RealVfsDirectory::GetFileTimeStamp(std::string_view path_) const { + const auto full_path = FS::SanitizePath(path + '/' + std::string(path_)); + const auto fs_path = std::filesystem::path{FS::ToU8String(full_path)}; + struct stat file_status; + +#ifdef _WIN32 + const auto stat_result = _wstat64(fs_path.c_str(), &file_status); +#else + const auto stat_result = stat(fs_path.c_str(), &file_status); +#endif + + if (stat_result != 0) { + return {}; + } + + return { + .created{static_cast(file_status.st_ctime)}, + .accessed{static_cast(file_status.st_atime)}, + .modified{static_cast(file_status.st_mtime)}, + }; +} + std::vector RealVfsDirectory::GetSubdirectories() const { return IterateEntries(); } diff --git a/src/core/file_sys/vfs_real.h b/src/core/file_sys/vfs_real.h index e4d1bba79..746e624cb 100755 --- a/src/core/file_sys/vfs_real.h +++ b/src/core/file_sys/vfs_real.h @@ -86,6 +86,7 @@ public: VirtualDir CreateDirectoryRelative(std::string_view relative_path) override; bool DeleteSubdirectoryRecursive(std::string_view name) override; std::vector GetFiles() const override; + FileTimeStampRaw GetFileTimeStamp(std::string_view path) const override; std::vector GetSubdirectories() const override; bool IsWritable() const override; bool IsReadable() const override; diff --git a/src/core/file_sys/vfs_types.h b/src/core/file_sys/vfs_types.h index 6215ed7af..ed0724717 100755 --- a/src/core/file_sys/vfs_types.h +++ b/src/core/file_sys/vfs_types.h @@ -6,6 +6,8 @@ #include +#include "common/common_types.h" + namespace FileSys { class VfsDirectory; @@ -18,4 +20,11 @@ using VirtualDir = std::shared_ptr; using VirtualFile = std::shared_ptr; using VirtualFilesystem = std::shared_ptr; +struct FileTimeStampRaw { + u64 created{}; + u64 accessed{}; + u64 modified{}; + u64 padding{}; +}; + } // namespace FileSys diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 3e7fd6024..570525019 100755 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp @@ -3,38 +3,65 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/hle_ipc.h" +#include "core/hle/kernel/k_event.h" #include "core/hle/service/audio/audin_u.h" namespace Service::Audio { -class IAudioIn final : public ServiceFramework { -public: - explicit IAudioIn(Core::System& system_) : ServiceFramework{system_, "IAudioIn"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "GetAudioInState"}, - {1, nullptr, "Start"}, - {2, nullptr, "Stop"}, - {3, nullptr, "AppendAudioInBuffer"}, - {4, nullptr, "RegisterBufferEvent"}, - {5, nullptr, "GetReleasedAudioInBuffer"}, - {6, nullptr, "ContainsAudioInBuffer"}, - {7, nullptr, "AppendUacInBuffer"}, - {8, nullptr, "AppendAudioInBufferAuto"}, - {9, nullptr, "GetReleasedAudioInBuffersAuto"}, - {10, nullptr, "AppendUacInBufferAuto"}, - {11, nullptr, "GetAudioInBufferCount"}, - {12, nullptr, "SetDeviceGain"}, - {13, nullptr, "GetDeviceGain"}, - {14, nullptr, "FlushAudioInBuffers"}, - }; - // clang-format on +IAudioIn::IAudioIn(Core::System& system_) + : ServiceFramework{system_, "IAudioIn"}, buffer_event{system_.Kernel()} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetAudioInState"}, + {1, &IAudioIn::Start, "Start"}, + {2, nullptr, "Stop"}, + {3, nullptr, "AppendAudioInBuffer"}, + {4, &IAudioIn::RegisterBufferEvent, "RegisterBufferEvent"}, + {5, nullptr, "GetReleasedAudioInBuffer"}, + {6, nullptr, "ContainsAudioInBuffer"}, + {7, nullptr, "AppendUacInBuffer"}, + {8, &IAudioIn::AppendAudioInBufferAuto, "AppendAudioInBufferAuto"}, + {9, nullptr, "GetReleasedAudioInBuffersAuto"}, + {10, nullptr, "AppendUacInBufferAuto"}, + {11, nullptr, "GetAudioInBufferCount"}, + {12, nullptr, "SetDeviceGain"}, + {13, nullptr, "GetDeviceGain"}, + {14, nullptr, "FlushAudioInBuffers"}, + }; + // clang-format on - RegisterHandlers(functions); - } -}; + RegisterHandlers(functions); + + Kernel::KAutoObject::Create(std::addressof(buffer_event)); + buffer_event.Initialize("IAudioIn:BufferEvent"); +} + +IAudioIn::~IAudioIn() = default; + +void IAudioIn::Start(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IAudioIn::RegisterBufferEvent(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(buffer_event.GetReadableEvent()); +} + +void IAudioIn::AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_Audio, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} AudInU::AudInU(Core::System& system_) : ServiceFramework{system_, "audin:u"} { // clang-format off diff --git a/src/core/hle/service/audio/audin_u.h b/src/core/hle/service/audio/audin_u.h index 0d75ae5ac..f2f7f9932 100755 --- a/src/core/hle/service/audio/audin_u.h +++ b/src/core/hle/service/audio/audin_u.h @@ -4,6 +4,7 @@ #pragma once +#include "core/hle/kernel/k_event.h" #include "core/hle/service/service.h" namespace Core { @@ -16,6 +17,19 @@ class HLERequestContext; namespace Service::Audio { +class IAudioIn final : public ServiceFramework { +public: + explicit IAudioIn(Core::System& system_); + ~IAudioIn() override; + +private: + void Start(Kernel::HLERequestContext& ctx); + void RegisterBufferEvent(Kernel::HLERequestContext& ctx); + void AppendAudioInBufferAuto(Kernel::HLERequestContext& ctx); + + Kernel::KEvent buffer_event; +}; + class AudInU final : public ServiceFramework { public: explicit AudInU(Core::System& system_); diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index c8d65f328..f8f9e32f7 100755 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -261,6 +261,18 @@ ResultVal VfsDirectoryServiceWrapper::GetEntryType( return FileSys::ERROR_PATH_NOT_FOUND; } +ResultVal VfsDirectoryServiceWrapper::GetFileTimeStampRaw( + const std::string& path) const { + auto dir = GetDirectoryRelativeWrapped(backing, Common::FS::GetParentPath(path)); + if (dir == nullptr) { + return FileSys::ERROR_PATH_NOT_FOUND; + } + if (GetEntryType(path).Failed()) { + return FileSys::ERROR_PATH_NOT_FOUND; + } + return MakeResult(dir->GetFileTimeStamp(Common::FS::GetFilename(path))); +} + FileSystemController::FileSystemController(Core::System& system_) : system{system_} {} FileSystemController::~FileSystemController() = default; diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index d387af3cb..b155e0811 100755 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h @@ -240,6 +240,12 @@ public: */ ResultVal GetEntryType(const std::string& path) const; + /** + * Get the timestamp of the specified path + * @return The timestamp of the specified path or error code + */ + ResultVal GetFileTimeStampRaw(const std::string& path) const; + private: FileSys::VirtualDir backing; }; diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index db4d44c12..50c788dd6 100755 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -326,7 +326,7 @@ public: {11, &IFileSystem::GetFreeSpaceSize, "GetFreeSpaceSize"}, {12, &IFileSystem::GetTotalSpaceSize, "GetTotalSpaceSize"}, {13, &IFileSystem::CleanDirectoryRecursively, "CleanDirectoryRecursively"}, - {14, nullptr, "GetFileTimeStampRaw"}, + {14, &IFileSystem::GetFileTimeStampRaw, "GetFileTimeStampRaw"}, {15, nullptr, "QueryEntry"}, }; RegisterHandlers(functions); @@ -501,6 +501,24 @@ public: rb.Push(size.get_total_size()); } + void GetFileTimeStampRaw(Kernel::HLERequestContext& ctx) { + const auto file_buffer = ctx.ReadBuffer(); + const std::string name = Common::StringFromBuffer(file_buffer); + + LOG_WARNING(Service_FS, "(Partial Implementation) called. file={}", name); + + auto result = backend.GetFileTimeStampRaw(name); + if (result.Failed()) { + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(result.Code()); + return; + } + + IPC::ResponseBuilder rb{ctx, 10}; + rb.Push(ResultSuccess); + rb.PushRaw(*result); + } + private: VfsDirectoryServiceWrapper backend; SizeGetter size; diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp index deb3abb28..8ec7d5266 100755 --- a/src/core/hle/service/ngct/ngct.cpp +++ b/src/core/hle/service/ngct/ngct.cpp @@ -15,7 +15,7 @@ public: explicit IService(Core::System& system_) : ServiceFramework{system_, "ngct:u"} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "Match"}, + {0, &IService::Match, "Match"}, {1, &IService::Filter, "Filter"}, }; // clang-format on @@ -24,6 +24,19 @@ public: } private: + void Match(Kernel::HLERequestContext& ctx) { + const auto buffer = ctx.ReadBuffer(); + const auto text = Common::StringFromFixedZeroTerminatedBuffer( + reinterpret_cast(buffer.data()), buffer.size()); + + LOG_WARNING(Service_NGCT, "(STUBBED) called, text={}", text); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + // Return false since we don't censor anything + rb.Push(false); + } + void Filter(Kernel::HLERequestContext& ctx) { const auto buffer = ctx.ReadBuffer(); const auto text = Common::StringFromFixedZeroTerminatedBuffer( diff --git a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp index 68f360b3c..6f60c6574 100755 --- a/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp +++ b/src/shader_recompiler/backend/spirv/emit_spirv_context_get_set.cpp @@ -477,7 +477,13 @@ void EmitSetSampleMask(EmitContext& ctx, Id value) { } void EmitSetFragDepth(EmitContext& ctx, Id value) { - ctx.OpStore(ctx.frag_depth, value); + if (!ctx.runtime_info.convert_depth_mode) { + ctx.OpStore(ctx.frag_depth, value); + return; + } + const Id unit{ctx.Const(0.5f)}; + const Id new_depth{ctx.OpFma(ctx.F32[1], value, unit, unit)}; + ctx.OpStore(ctx.frag_depth, new_depth); } void EmitGetZFlag(EmitContext&) { diff --git a/src/video_core/renderer_opengl/gl_shader_cache.cpp b/src/video_core/renderer_opengl/gl_shader_cache.cpp index b0e14182e..02682bd76 100755 --- a/src/video_core/renderer_opengl/gl_shader_cache.cpp +++ b/src/video_core/renderer_opengl/gl_shader_cache.cpp @@ -293,6 +293,8 @@ void ShaderCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading, }}; LoadPipelines(stop_loading, shader_cache_filename, CACHE_VERSION, load_compute, load_graphics); + LOG_INFO(Render_OpenGL, "Total Pipeline Count: {}", state.total); + std::unique_lock lock{state.mutex}; callback(VideoCore::LoadCallbackStage::Build, 0, state.total); state.has_loaded = true; diff --git a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp index 31bfbcb06..eb8b4e08b 100755 --- a/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_pipeline_cache.cpp @@ -447,6 +447,8 @@ void PipelineCache::LoadDiskResources(u64 title_id, std::stop_token stop_loading VideoCommon::LoadPipelines(stop_loading, pipeline_cache_filename, CACHE_VERSION, load_compute, load_graphics); + LOG_INFO(Render_Vulkan, "Total Pipeline Count: {}", state.total); + std::unique_lock lock{state.mutex}; callback(VideoCore::LoadCallbackStage::Build, 0, state.total); state.has_loaded = true;