diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.cpp | 47 | ||||
| -rw-r--r-- | src/video_core/renderer_vulkan/blit_image.h | 3 | ||||
| -rw-r--r-- | src/yuzu/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | src/yuzu/main.cpp | 52 | ||||
| -rw-r--r-- | src/yuzu/main.h | 9 |
7 files changed, 70 insertions, 54 deletions
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 752592e2e..b8c993748 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "core/hle/kernel/k_resource_limit.h" | 26 | #include "core/hle/kernel/k_resource_limit.h" |
| 27 | #include "core/hle/kernel/k_scheduler.h" | 27 | #include "core/hle/kernel/k_scheduler.h" |
| 28 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" | 28 | #include "core/hle/kernel/k_scoped_scheduler_lock_and_sleep.h" |
| 29 | #include "core/hle/kernel/k_system_control.h" | ||
| 29 | #include "core/hle/kernel/k_thread.h" | 30 | #include "core/hle/kernel/k_thread.h" |
| 30 | #include "core/hle/kernel/k_thread_queue.h" | 31 | #include "core/hle/kernel/k_thread_queue.h" |
| 31 | #include "core/hle/kernel/kernel.h" | 32 | #include "core/hle/kernel/kernel.h" |
| @@ -50,6 +51,7 @@ static void ResetThreadContext64(Core::ARM_Interface::ThreadContext64& context, | |||
| 50 | VAddr entry_point, u64 arg) { | 51 | VAddr entry_point, u64 arg) { |
| 51 | context = {}; | 52 | context = {}; |
| 52 | context.cpu_registers[0] = arg; | 53 | context.cpu_registers[0] = arg; |
| 54 | context.cpu_registers[18] = Kernel::KSystemControl::GenerateRandomU64() | 1; | ||
| 53 | context.pc = entry_point; | 55 | context.pc = entry_point; |
| 54 | context.sp = stack_top; | 56 | context.sp = stack_top; |
| 55 | // TODO(merry): Perform a hardware test to determine the below value. | 57 | // TODO(merry): Perform a hardware test to determine the below value. |
diff --git a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp index 081b2c8e0..6f98d0998 100644 --- a/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp +++ b/src/shader_recompiler/backend/glasm/emit_glasm_context_get_set.cpp | |||
| @@ -86,7 +86,7 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 86 | } | 86 | } |
| 87 | switch (attr) { | 87 | switch (attr) { |
| 88 | case IR::Attribute::PrimitiveId: | 88 | case IR::Attribute::PrimitiveId: |
| 89 | ctx.Add("MOV.S {}.x,primitive.id;", inst); | 89 | ctx.Add("MOV.F {}.x,primitive.id;", inst); |
| 90 | break; | 90 | break; |
| 91 | case IR::Attribute::PositionX: | 91 | case IR::Attribute::PositionX: |
| 92 | case IR::Attribute::PositionY: | 92 | case IR::Attribute::PositionY: |
| @@ -113,13 +113,13 @@ void EmitGetAttribute(EmitContext& ctx, IR::Inst& inst, IR::Attribute attr, Scal | |||
| 113 | ctx.Add("MOV.F {}.x,vertex.tesscoord.{};", inst, swizzle); | 113 | ctx.Add("MOV.F {}.x,vertex.tesscoord.{};", inst, swizzle); |
| 114 | break; | 114 | break; |
| 115 | case IR::Attribute::InstanceId: | 115 | case IR::Attribute::InstanceId: |
| 116 | ctx.Add("MOV.S {}.x,{}.instance;", inst, ctx.attrib_name); | 116 | ctx.Add("MOV.F {}.x,{}.instance;", inst, ctx.attrib_name); |
| 117 | break; | 117 | break; |
| 118 | case IR::Attribute::VertexId: | 118 | case IR::Attribute::VertexId: |
| 119 | ctx.Add("MOV.S {}.x,{}.id;", inst, ctx.attrib_name); | 119 | ctx.Add("MOV.F {}.x,{}.id;", inst, ctx.attrib_name); |
| 120 | break; | 120 | break; |
| 121 | case IR::Attribute::FrontFace: | 121 | case IR::Attribute::FrontFace: |
| 122 | ctx.Add("CMP.S {}.x,{}.facing.x,0,-1;", inst, ctx.attrib_name); | 122 | ctx.Add("CMP.F {}.x,{}.facing.x,0,-1;", inst, ctx.attrib_name); |
| 123 | break; | 123 | break; |
| 124 | default: | 124 | default: |
| 125 | throw NotImplementedException("Get attribute {}", attr); | 125 | throw NotImplementedException("Get attribute {}", attr); |
diff --git a/src/video_core/renderer_vulkan/blit_image.cpp b/src/video_core/renderer_vulkan/blit_image.cpp index cd5995897..2c3914459 100644 --- a/src/video_core/renderer_vulkan/blit_image.cpp +++ b/src/video_core/renderer_vulkan/blit_image.cpp | |||
| @@ -518,53 +518,6 @@ void BlitImageHelper::Convert(VkPipeline pipeline, const Framebuffer* dst_frameb | |||
| 518 | scheduler.InvalidateState(); | 518 | scheduler.InvalidateState(); |
| 519 | } | 519 | } |
| 520 | 520 | ||
| 521 | void BlitImageHelper::ConvertColor(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | ||
| 522 | ImageView& src_image_view, u32 up_scale, u32 down_shift) { | ||
| 523 | const VkPipelineLayout layout = *one_texture_pipeline_layout; | ||
| 524 | const VkImageView src_view = src_image_view.ColorView(); | ||
| 525 | const VkSampler sampler = *nearest_sampler; | ||
| 526 | const VkExtent2D extent{ | ||
| 527 | .width = std::max((src_image_view.size.width * up_scale) >> down_shift, 1U), | ||
| 528 | .height = std::max((src_image_view.size.height * up_scale) >> down_shift, 1U), | ||
| 529 | }; | ||
| 530 | scheduler.RequestRenderpass(dst_framebuffer); | ||
| 531 | scheduler.Record([pipeline, layout, sampler, src_view, extent, up_scale, down_shift, | ||
| 532 | this](vk::CommandBuffer cmdbuf) { | ||
| 533 | const VkOffset2D offset{ | ||
| 534 | .x = 0, | ||
| 535 | .y = 0, | ||
| 536 | }; | ||
| 537 | const VkViewport viewport{ | ||
| 538 | .x = 0.0f, | ||
| 539 | .y = 0.0f, | ||
| 540 | .width = static_cast<float>(extent.width), | ||
| 541 | .height = static_cast<float>(extent.height), | ||
| 542 | .minDepth = 0.0f, | ||
| 543 | .maxDepth = 0.0f, | ||
| 544 | }; | ||
| 545 | const VkRect2D scissor{ | ||
| 546 | .offset = offset, | ||
| 547 | .extent = extent, | ||
| 548 | }; | ||
| 549 | const PushConstants push_constants{ | ||
| 550 | .tex_scale = {viewport.width, viewport.height}, | ||
| 551 | .tex_offset = {0.0f, 0.0f}, | ||
| 552 | }; | ||
| 553 | const VkDescriptorSet descriptor_set = one_texture_descriptor_allocator.Commit(); | ||
| 554 | UpdateOneTextureDescriptorSet(device, descriptor_set, sampler, src_view); | ||
| 555 | |||
| 556 | // TODO: Barriers | ||
| 557 | cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline); | ||
| 558 | cmdbuf.BindDescriptorSets(VK_PIPELINE_BIND_POINT_GRAPHICS, layout, 0, descriptor_set, | ||
| 559 | nullptr); | ||
| 560 | cmdbuf.SetViewport(0, viewport); | ||
| 561 | cmdbuf.SetScissor(0, scissor); | ||
| 562 | cmdbuf.PushConstants(layout, VK_SHADER_STAGE_VERTEX_BIT, push_constants); | ||
| 563 | cmdbuf.Draw(3, 1, 0, 0); | ||
| 564 | }); | ||
| 565 | scheduler.InvalidateState(); | ||
| 566 | } | ||
| 567 | |||
| 568 | void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | 521 | void BlitImageHelper::ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, |
| 569 | ImageView& src_image_view) { | 522 | ImageView& src_image_view) { |
| 570 | const VkPipelineLayout layout = *two_textures_pipeline_layout; | 523 | const VkPipelineLayout layout = *two_textures_pipeline_layout; |
diff --git a/src/video_core/renderer_vulkan/blit_image.h b/src/video_core/renderer_vulkan/blit_image.h index 1d9f61a52..85e7dca5b 100644 --- a/src/video_core/renderer_vulkan/blit_image.h +++ b/src/video_core/renderer_vulkan/blit_image.h | |||
| @@ -60,9 +60,6 @@ private: | |||
| 60 | void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | 60 | void Convert(VkPipeline pipeline, const Framebuffer* dst_framebuffer, |
| 61 | const ImageView& src_image_view); | 61 | const ImageView& src_image_view); |
| 62 | 62 | ||
| 63 | void ConvertColor(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | ||
| 64 | ImageView& src_image_view, u32 up_scale, u32 down_shift); | ||
| 65 | |||
| 66 | void ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, | 63 | void ConvertDepthStencil(VkPipeline pipeline, const Framebuffer* dst_framebuffer, |
| 67 | ImageView& src_image_view); | 64 | ImageView& src_image_view); |
| 68 | 65 | ||
diff --git a/src/yuzu/CMakeLists.txt b/src/yuzu/CMakeLists.txt index 732e8c276..30902101d 100644 --- a/src/yuzu/CMakeLists.txt +++ b/src/yuzu/CMakeLists.txt | |||
| @@ -251,6 +251,9 @@ target_include_directories(yuzu PRIVATE ../../externals/Vulkan-Headers/include) | |||
| 251 | if (NOT WIN32) | 251 | if (NOT WIN32) |
| 252 | target_include_directories(yuzu PRIVATE ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) | 252 | target_include_directories(yuzu PRIVATE ${Qt5Gui_PRIVATE_INCLUDE_DIRS}) |
| 253 | endif() | 253 | endif() |
| 254 | if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") | ||
| 255 | target_link_libraries(yuzu PRIVATE Qt5::DBus) | ||
| 256 | endif() | ||
| 254 | 257 | ||
| 255 | target_compile_definitions(yuzu PRIVATE | 258 | target_compile_definitions(yuzu PRIVATE |
| 256 | # Use QStringBuilder for string concatenation to reduce | 259 | # Use QStringBuilder for string concatenation to reduce |
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index a7271e075..1e02d715b 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp | |||
| @@ -1236,11 +1236,58 @@ void GMainWindow::OnDisplayTitleBars(bool show) { | |||
| 1236 | } | 1236 | } |
| 1237 | } | 1237 | } |
| 1238 | 1238 | ||
| 1239 | #ifdef __linux__ | ||
| 1240 | static std::optional<QDBusObjectPath> HoldWakeLockLinux(u32 window_id = 0) { | ||
| 1241 | if (!QDBusConnection::sessionBus().isConnected()) { | ||
| 1242 | return {}; | ||
| 1243 | } | ||
| 1244 | // reference: https://flatpak.github.io/xdg-desktop-portal/#gdbus-org.freedesktop.portal.Inhibit | ||
| 1245 | QDBusInterface xdp(QString::fromLatin1("org.freedesktop.portal.Desktop"), | ||
| 1246 | QString::fromLatin1("/org/freedesktop/portal/desktop"), | ||
| 1247 | QString::fromLatin1("org.freedesktop.portal.Inhibit")); | ||
| 1248 | if (!xdp.isValid()) { | ||
| 1249 | LOG_WARNING(Frontend, "Couldn't connect to XDP D-Bus endpoint"); | ||
| 1250 | return {}; | ||
| 1251 | } | ||
| 1252 | QVariantMap options = {}; | ||
| 1253 | //: TRANSLATORS: This string is shown to the user to explain why yuzu needs to prevent the | ||
| 1254 | //: computer from sleeping | ||
| 1255 | options.insert(QString::fromLatin1("reason"), | ||
| 1256 | QCoreApplication::translate("GMainWindow", "yuzu is running a game")); | ||
| 1257 | // 0x4: Suspend lock; 0x8: Idle lock | ||
| 1258 | QDBusReply<QDBusObjectPath> reply = | ||
| 1259 | xdp.call(QString::fromLatin1("Inhibit"), | ||
| 1260 | QString::fromLatin1("x11:") + QString::number(window_id, 16), 12U, options); | ||
| 1261 | |||
| 1262 | if (reply.isValid()) { | ||
| 1263 | return reply.value(); | ||
| 1264 | } | ||
| 1265 | LOG_WARNING(Frontend, "Couldn't read Inhibit reply from XDP: {}", | ||
| 1266 | reply.error().message().toStdString()); | ||
| 1267 | return {}; | ||
| 1268 | } | ||
| 1269 | |||
| 1270 | static void ReleaseWakeLockLinux(QDBusObjectPath lock) { | ||
| 1271 | if (!QDBusConnection::sessionBus().isConnected()) { | ||
| 1272 | return; | ||
| 1273 | } | ||
| 1274 | QDBusInterface unlocker(QString::fromLatin1("org.freedesktop.portal.Desktop"), lock.path(), | ||
| 1275 | QString::fromLatin1("org.freedesktop.portal.Request")); | ||
| 1276 | unlocker.call(QString::fromLatin1("Close")); | ||
| 1277 | } | ||
| 1278 | #endif // __linux__ | ||
| 1279 | |||
| 1239 | void GMainWindow::PreventOSSleep() { | 1280 | void GMainWindow::PreventOSSleep() { |
| 1240 | #ifdef _WIN32 | 1281 | #ifdef _WIN32 |
| 1241 | SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); | 1282 | SetThreadExecutionState(ES_CONTINUOUS | ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED); |
| 1242 | #elif defined(HAVE_SDL2) | 1283 | #elif defined(HAVE_SDL2) |
| 1243 | SDL_DisableScreenSaver(); | 1284 | SDL_DisableScreenSaver(); |
| 1285 | #ifdef __linux__ | ||
| 1286 | auto reply = HoldWakeLockLinux(winId()); | ||
| 1287 | if (reply) { | ||
| 1288 | wake_lock = std::move(reply.value()); | ||
| 1289 | } | ||
| 1290 | #endif | ||
| 1244 | #endif | 1291 | #endif |
| 1245 | } | 1292 | } |
| 1246 | 1293 | ||
| @@ -1249,6 +1296,11 @@ void GMainWindow::AllowOSSleep() { | |||
| 1249 | SetThreadExecutionState(ES_CONTINUOUS); | 1296 | SetThreadExecutionState(ES_CONTINUOUS); |
| 1250 | #elif defined(HAVE_SDL2) | 1297 | #elif defined(HAVE_SDL2) |
| 1251 | SDL_EnableScreenSaver(); | 1298 | SDL_EnableScreenSaver(); |
| 1299 | #ifdef __linux__ | ||
| 1300 | if (!wake_lock.path().isEmpty()) { | ||
| 1301 | ReleaseWakeLockLinux(wake_lock); | ||
| 1302 | } | ||
| 1303 | #endif | ||
| 1252 | #endif | 1304 | #endif |
| 1253 | } | 1305 | } |
| 1254 | 1306 | ||
diff --git a/src/yuzu/main.h b/src/yuzu/main.h index 0fd41ed4f..7870bb963 100644 --- a/src/yuzu/main.h +++ b/src/yuzu/main.h | |||
| @@ -17,6 +17,12 @@ | |||
| 17 | #include "yuzu/compatibility_list.h" | 17 | #include "yuzu/compatibility_list.h" |
| 18 | #include "yuzu/hotkeys.h" | 18 | #include "yuzu/hotkeys.h" |
| 19 | 19 | ||
| 20 | #ifdef __linux__ | ||
| 21 | #include <QVariant> | ||
| 22 | #include <QtDBus/QDBusInterface> | ||
| 23 | #include <QtDBus/QtDBus> | ||
| 24 | #endif | ||
| 25 | |||
| 20 | class Config; | 26 | class Config; |
| 21 | class EmuThread; | 27 | class EmuThread; |
| 22 | class GameList; | 28 | class GameList; |
| @@ -394,6 +400,9 @@ private: | |||
| 394 | 400 | ||
| 395 | // Applets | 401 | // Applets |
| 396 | QtSoftwareKeyboardDialog* software_keyboard = nullptr; | 402 | QtSoftwareKeyboardDialog* software_keyboard = nullptr; |
| 403 | #ifdef __linux__ | ||
| 404 | QDBusObjectPath wake_lock{}; | ||
| 405 | #endif | ||
| 397 | 406 | ||
| 398 | protected: | 407 | protected: |
| 399 | void dropEvent(QDropEvent* event) override; | 408 | void dropEvent(QDropEvent* event) override; |