forked from eden-emu/eden
Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
60dfad7e4a | ||
![]() |
fa80001513 |
5 changed files with 37 additions and 160 deletions
|
@ -7,43 +7,8 @@
|
||||||
#include "core/hle/service/server_manager.h"
|
#include "core/hle/service/server_manager.h"
|
||||||
#include "core/hle/service/sm/sm.h"
|
#include "core/hle/service/sm/sm.h"
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace Service::MM {
|
namespace Service::MM {
|
||||||
enum class Module : u32 {
|
|
||||||
CPU = 0,
|
|
||||||
GPU = 1,
|
|
||||||
EMC = 2,
|
|
||||||
SYS_BUS = 3,
|
|
||||||
M_SELECT = 4,
|
|
||||||
NVDEC = 5,
|
|
||||||
NVENC = 6,
|
|
||||||
NVJPG = 7,
|
|
||||||
TEST = 8
|
|
||||||
};
|
|
||||||
|
|
||||||
class Session {
|
|
||||||
public:
|
|
||||||
Session(Module module_, u32 request_id_, bool is_auto_clear_event_) {
|
|
||||||
this->module = module_;
|
|
||||||
this->request_id = request_id_;
|
|
||||||
this->is_auto_clear_event = is_auto_clear_event_;
|
|
||||||
this->min = 0;
|
|
||||||
this->max = -1;
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
|
||||||
Module module;
|
|
||||||
u32 request_id, min;
|
|
||||||
s32 max;
|
|
||||||
bool is_auto_clear_event;
|
|
||||||
|
|
||||||
void SetAndWait(u32 min_, s32 max_) {
|
|
||||||
this->min = min_;
|
|
||||||
this->max = max_;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
class MM_U final : public ServiceFramework<MM_U> {
|
class MM_U final : public ServiceFramework<MM_U> {
|
||||||
public:
|
public:
|
||||||
explicit MM_U(Core::System& system_) : ServiceFramework{system_, "mm:u"} {
|
explicit MM_U(Core::System& system_) : ServiceFramework{system_, "mm:u"} {
|
||||||
|
@ -65,53 +30,26 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void InitializeOld(HLERequestContext& ctx) {
|
void InitializeOld(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_WARNING(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto module = rp.PopEnum<Module>();
|
|
||||||
rp.Pop<u32>();
|
|
||||||
const auto event_clear_mode = rp.Pop<u32>();
|
|
||||||
|
|
||||||
const bool is_auto_clear_event = event_clear_mode == 1;
|
|
||||||
|
|
||||||
sessions.push_back({module, request_id++, is_auto_clear_event});
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FinalizeOld(HLERequestContext& ctx) {
|
void FinalizeOld(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_WARNING(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto module = rp.PopEnum<Module>();
|
|
||||||
|
|
||||||
for (auto it = sessions.begin(); it != sessions.end(); ++it) {
|
|
||||||
if (it->module == module) {
|
|
||||||
sessions.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAndWaitOld(HLERequestContext& ctx) {
|
void SetAndWaitOld(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto module = rp.PopEnum<Module>();
|
min = rp.Pop<u32>();
|
||||||
const auto min = rp.Pop<u32>();
|
max = rp.Pop<u32>();
|
||||||
const auto max = rp.Pop<s32>();
|
LOG_DEBUG(Service_MM, "(STUBBED) called, min=0x{:X}, max=0x{:X}", min, max);
|
||||||
|
|
||||||
for (auto& session : sessions) {
|
current = min;
|
||||||
if (session.module == module) {
|
|
||||||
session.SetAndWait(min, max);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
@ -119,72 +57,35 @@ private:
|
||||||
void GetOld(HLERequestContext& ctx) {
|
void GetOld(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto module = rp.PopEnum<Module>();
|
|
||||||
|
|
||||||
for (const auto& session : sessions) {
|
|
||||||
if (session.module == module) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(session.min);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push<u32>(0);
|
rb.Push(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Initialize(HLERequestContext& ctx) {
|
void Initialize(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_WARNING(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto module = rp.PopEnum<Module>();
|
|
||||||
rp.Pop<u32>();
|
|
||||||
const auto event_clear_mode = rp.Pop<u32>();
|
|
||||||
|
|
||||||
const bool is_auto_clear_event = event_clear_mode == 1;
|
|
||||||
|
|
||||||
sessions.push_back({module, request_id++, is_auto_clear_event});
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push(request_id - 1);
|
rb.Push<u32>(id); // Any non zero value
|
||||||
}
|
}
|
||||||
|
|
||||||
void Finalize(HLERequestContext& ctx) {
|
void Finalize(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_WARNING(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto id = rp.Pop<u32>();
|
|
||||||
|
|
||||||
for (auto it = sessions.begin(); it != sessions.end(); ++it) {
|
|
||||||
if (it->request_id == id) {
|
|
||||||
sessions.erase(it);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetAndWait(HLERequestContext& ctx) {
|
void SetAndWait(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
IPC::RequestParser rp{ctx};
|
||||||
const auto id = rp.Pop<u32>();
|
u32 input_id = rp.Pop<u32>();
|
||||||
const auto min = rp.Pop<u32>();
|
min = rp.Pop<u32>();
|
||||||
const auto max = rp.Pop<s32>();
|
max = rp.Pop<u32>();
|
||||||
|
LOG_DEBUG(Service_MM, "(STUBBED) called, input_id=0x{:X}, min=0x{:X}, max=0x{:X}", input_id,
|
||||||
|
min, max);
|
||||||
|
|
||||||
for (auto& session : sessions) {
|
current = min;
|
||||||
if (session.request_id == id) {
|
|
||||||
session.SetAndWait(min, max);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
}
|
}
|
||||||
|
@ -192,25 +93,15 @@ private:
|
||||||
void Get(HLERequestContext& ctx) {
|
void Get(HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
LOG_DEBUG(Service_MM, "(STUBBED) called");
|
||||||
|
|
||||||
IPC::RequestParser rp{ctx};
|
|
||||||
const auto id = rp.Pop<u32>();
|
|
||||||
|
|
||||||
for (const auto& session : sessions) {
|
|
||||||
if (session.request_id == id) {
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
|
||||||
rb.Push(ResultSuccess);
|
|
||||||
rb.Push(session.min);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
IPC::ResponseBuilder rb{ctx, 3};
|
IPC::ResponseBuilder rb{ctx, 3};
|
||||||
rb.Push(ResultSuccess);
|
rb.Push(ResultSuccess);
|
||||||
rb.Push<u32>(0);
|
rb.Push(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Session> sessions;
|
u32 min{0};
|
||||||
u32 request_id{1};
|
u32 max{0};
|
||||||
|
u32 current{0};
|
||||||
|
u32 id{1};
|
||||||
};
|
};
|
||||||
|
|
||||||
void LoopProcess(Core::System& system) {
|
void LoopProcess(Core::System& system) {
|
||||||
|
|
|
@ -1505,7 +1505,7 @@ Image::Image(TextureCacheRuntime& runtime_, const ImageInfo& info_, GPUVAddr gpu
|
||||||
if (runtime->device.HasDebuggingToolAttached()) {
|
if (runtime->device.HasDebuggingToolAttached()) {
|
||||||
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
original_image.SetObjectNameEXT(VideoCommon::Name(*this).c_str());
|
||||||
}
|
}
|
||||||
current_image = &Image::original_image;
|
current_image = *original_image;
|
||||||
storage_image_views.resize(info.resources.levels);
|
storage_image_views.resize(info.resources.levels);
|
||||||
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() &&
|
if (IsPixelFormatASTC(info.format) && !runtime->device.IsOptimalAstcSupported() &&
|
||||||
Settings::values.astc_recompression.GetValue() ==
|
Settings::values.astc_recompression.GetValue() ==
|
||||||
|
@ -1806,8 +1806,8 @@ VkImageView Image::StorageImageView(s32 level) noexcept {
|
||||||
if (!view) {
|
if (!view) {
|
||||||
const auto format_info =
|
const auto format_info =
|
||||||
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
MaxwellToVK::SurfaceFormat(runtime->device, FormatType::Optimal, true, info.format);
|
||||||
view = MakeStorageView(runtime->device.GetLogical(), level, *(this->*current_image),
|
view =
|
||||||
format_info.format);
|
MakeStorageView(runtime->device.GetLogical(), level, current_image, format_info.format);
|
||||||
}
|
}
|
||||||
return *view;
|
return *view;
|
||||||
}
|
}
|
||||||
|
@ -1838,7 +1838,7 @@ bool Image::ScaleUp(bool ignore) {
|
||||||
runtime->ViewFormats(info.format));
|
runtime->ViewFormats(info.format));
|
||||||
ignore = false;
|
ignore = false;
|
||||||
}
|
}
|
||||||
current_image = &Image::scaled_image;
|
current_image = *scaled_image;
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1863,7 +1863,7 @@ bool Image::ScaleDown(bool ignore) {
|
||||||
}
|
}
|
||||||
ASSERT(info.type != ImageType::Linear);
|
ASSERT(info.type != ImageType::Linear);
|
||||||
flags &= ~ImageFlagBits::Rescaled;
|
flags &= ~ImageFlagBits::Rescaled;
|
||||||
current_image = &Image::original_image;
|
current_image = *original_image;
|
||||||
if (ignore) {
|
if (ignore) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1982,7 +1982,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
|
||||||
const VkImageViewUsageCreateInfo image_view_usage{
|
const VkImageViewUsageCreateInfo image_view_usage{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO,
|
||||||
.pNext = nullptr,
|
.pNext = nullptr,
|
||||||
.usage = image.UsageFlags(),
|
.usage = ImageUsageFlags(format_info, format),
|
||||||
};
|
};
|
||||||
const VkImageViewCreateInfo create_info{
|
const VkImageViewCreateInfo create_info{
|
||||||
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
|
||||||
|
|
|
@ -24,6 +24,7 @@ using Common::SlotVector;
|
||||||
using VideoCommon::ImageId;
|
using VideoCommon::ImageId;
|
||||||
using VideoCommon::NUM_RT;
|
using VideoCommon::NUM_RT;
|
||||||
using VideoCommon::Region2D;
|
using VideoCommon::Region2D;
|
||||||
|
using VideoCommon::RenderTargets;
|
||||||
using VideoCore::Surface::PixelFormat;
|
using VideoCore::Surface::PixelFormat;
|
||||||
|
|
||||||
class BlitImageHelper;
|
class BlitImageHelper;
|
||||||
|
@ -160,17 +161,13 @@ public:
|
||||||
std::span<const VideoCommon::BufferImageCopy> copies);
|
std::span<const VideoCommon::BufferImageCopy> copies);
|
||||||
|
|
||||||
[[nodiscard]] VkImage Handle() const noexcept {
|
[[nodiscard]] VkImage Handle() const noexcept {
|
||||||
return *(this->*current_image);
|
return current_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageAspectFlags AspectMask() const noexcept {
|
[[nodiscard]] VkImageAspectFlags AspectMask() const noexcept {
|
||||||
return aspect_mask;
|
return aspect_mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept {
|
|
||||||
return (this->*current_image).UsageFlags();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns true when the image is already initialized and mark it as initialized
|
/// Returns true when the image is already initialized and mark it as initialized
|
||||||
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
[[nodiscard]] bool ExchangeInitialization() noexcept {
|
||||||
return std::exchange(initialized, true);
|
return std::exchange(initialized, true);
|
||||||
|
@ -193,15 +190,11 @@ private:
|
||||||
TextureCacheRuntime* runtime{};
|
TextureCacheRuntime* runtime{};
|
||||||
|
|
||||||
vk::Image original_image;
|
vk::Image original_image;
|
||||||
vk::Image scaled_image;
|
|
||||||
|
|
||||||
// Use a pointer to field because it is relative, so that the object can be
|
|
||||||
// moved without breaking the reference.
|
|
||||||
vk::Image Image::*current_image{};
|
|
||||||
|
|
||||||
std::vector<vk::ImageView> storage_image_views;
|
std::vector<vk::ImageView> storage_image_views;
|
||||||
VkImageAspectFlags aspect_mask = 0;
|
VkImageAspectFlags aspect_mask = 0;
|
||||||
bool initialized = false;
|
bool initialized = false;
|
||||||
|
vk::Image scaled_image{};
|
||||||
|
VkImage current_image{};
|
||||||
|
|
||||||
std::unique_ptr<Framebuffer> scale_framebuffer;
|
std::unique_ptr<Framebuffer> scale_framebuffer;
|
||||||
std::unique_ptr<ImageView> scale_view;
|
std::unique_ptr<ImageView> scale_view;
|
||||||
|
|
|
@ -247,7 +247,7 @@ vk::Image MemoryAllocator::CreateImage(const VkImageCreateInfo& ci) const {
|
||||||
|
|
||||||
vk::Check(vmaCreateImage(allocator, &ci, &alloc_ci, &handle, &allocation, nullptr));
|
vk::Check(vmaCreateImage(allocator, &ci, &alloc_ci, &handle, &allocation, nullptr));
|
||||||
|
|
||||||
return vk::Image(handle, ci.usage, *device.GetLogical(), allocator, allocation,
|
return vk::Image(handle, *device.GetLogical(), allocator, allocation,
|
||||||
device.GetDispatchLoader());
|
device.GetDispatchLoader());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -651,10 +651,9 @@ public:
|
||||||
|
|
||||||
class Image {
|
class Image {
|
||||||
public:
|
public:
|
||||||
explicit Image(VkImage handle_, VkImageUsageFlags usage_, VkDevice owner_,
|
explicit Image(VkImage handle_, VkDevice owner_, VmaAllocator allocator_,
|
||||||
VmaAllocator allocator_, VmaAllocation allocation_,
|
VmaAllocation allocation_, const DeviceDispatch& dld_) noexcept
|
||||||
const DeviceDispatch& dld_) noexcept
|
: handle{handle_}, owner{owner_}, allocator{allocator_},
|
||||||
: handle{handle_}, usage{usage_}, owner{owner_}, allocator{allocator_},
|
|
||||||
allocation{allocation_}, dld{&dld_} {}
|
allocation{allocation_}, dld{&dld_} {}
|
||||||
Image() = default;
|
Image() = default;
|
||||||
|
|
||||||
|
@ -662,13 +661,12 @@ public:
|
||||||
Image& operator=(const Image&) = delete;
|
Image& operator=(const Image&) = delete;
|
||||||
|
|
||||||
Image(Image&& rhs) noexcept
|
Image(Image&& rhs) noexcept
|
||||||
: handle{std::exchange(rhs.handle, nullptr)}, usage{rhs.usage}, owner{rhs.owner},
|
: handle{std::exchange(rhs.handle, nullptr)}, owner{rhs.owner}, allocator{rhs.allocator},
|
||||||
allocator{rhs.allocator}, allocation{rhs.allocation}, dld{rhs.dld} {}
|
allocation{rhs.allocation}, dld{rhs.dld} {}
|
||||||
|
|
||||||
Image& operator=(Image&& rhs) noexcept {
|
Image& operator=(Image&& rhs) noexcept {
|
||||||
Release();
|
Release();
|
||||||
handle = std::exchange(rhs.handle, nullptr);
|
handle = std::exchange(rhs.handle, nullptr);
|
||||||
usage = rhs.usage;
|
|
||||||
owner = rhs.owner;
|
owner = rhs.owner;
|
||||||
allocator = rhs.allocator;
|
allocator = rhs.allocator;
|
||||||
allocation = rhs.allocation;
|
allocation = rhs.allocation;
|
||||||
|
@ -695,15 +693,10 @@ public:
|
||||||
|
|
||||||
void SetObjectNameEXT(const char* name) const;
|
void SetObjectNameEXT(const char* name) const;
|
||||||
|
|
||||||
[[nodiscard]] VkImageUsageFlags UsageFlags() const noexcept {
|
|
||||||
return usage;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Release() const noexcept;
|
void Release() const noexcept;
|
||||||
|
|
||||||
VkImage handle = nullptr;
|
VkImage handle = nullptr;
|
||||||
VkImageUsageFlags usage{};
|
|
||||||
VkDevice owner = nullptr;
|
VkDevice owner = nullptr;
|
||||||
VmaAllocator allocator = nullptr;
|
VmaAllocator allocator = nullptr;
|
||||||
VmaAllocation allocation = nullptr;
|
VmaAllocation allocation = nullptr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue