summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp6
-rw-r--r--src/core/hle/service/nvdrv/devices/nvdisp_disp0.h4
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.cpp4
-rw-r--r--src/core/hle/service/nvflinger/buffer_queue.h5
-rw-r--r--src/core/hle/service/nvflinger/nvflinger.cpp3
-rw-r--r--src/core/hle/service/vi/vi.cpp20
-rw-r--r--src/video_core/gpu.h1
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp22
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.h1
-rw-r--r--src/yuzu/configuration/config.cpp2
-rw-r--r--src/yuzu_cmd/config.cpp2
-rw-r--r--src/yuzu_cmd/default_ini.h2
12 files changed, 52 insertions, 20 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
index c39d5a164..ed69a4325 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp
@@ -18,7 +18,8 @@ u32 nvdisp_disp0::ioctl(Ioctl command, const std::vector<u8>& input, std::vector
18} 18}
19 19
20void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, 20void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height,
21 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform) { 21 u32 stride, NVFlinger::BufferQueue::BufferTransformFlags transform,
22 const MathUtil::Rectangle<int>& crop_rect) {
22 VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle); 23 VAddr addr = nvmap_dev->GetObjectAddress(buffer_handle);
23 LOG_WARNING(Service, 24 LOG_WARNING(Service,
24 "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}", 25 "Drawing from address {:X} offset {:08X} Width {} Height {} Stride {} Format {}",
@@ -26,7 +27,8 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3
26 27
27 using PixelFormat = Tegra::FramebufferConfig::PixelFormat; 28 using PixelFormat = Tegra::FramebufferConfig::PixelFormat;
28 const Tegra::FramebufferConfig framebuffer{ 29 const Tegra::FramebufferConfig framebuffer{
29 addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform}; 30 addr, offset, width, height, stride, static_cast<PixelFormat>(format),
31 transform, crop_rect};
30 32
31 Core::System::GetInstance().perf_stats.EndGameFrame(); 33 Core::System::GetInstance().perf_stats.EndGameFrame();
32 34
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
index 3d3979723..d4631a32b 100644
--- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
+++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.h
@@ -7,6 +7,7 @@
7#include <memory> 7#include <memory>
8#include <vector> 8#include <vector>
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "common/math_util.h"
10#include "core/hle/service/nvdrv/devices/nvdevice.h" 11#include "core/hle/service/nvdrv/devices/nvdevice.h"
11#include "core/hle/service/nvflinger/buffer_queue.h" 12#include "core/hle/service/nvflinger/buffer_queue.h"
12 13
@@ -23,7 +24,8 @@ public:
23 24
24 /// Performs a screen flip, drawing the buffer pointed to by the handle. 25 /// Performs a screen flip, drawing the buffer pointed to by the handle.
25 void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride, 26 void flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u32 height, u32 stride,
26 NVFlinger::BufferQueue::BufferTransformFlags transform); 27 NVFlinger::BufferQueue::BufferTransformFlags transform,
28 const MathUtil::Rectangle<int>& crop_rect);
27 29
28private: 30private:
29 std::shared_ptr<nvmap> nvmap_dev; 31 std::shared_ptr<nvmap> nvmap_dev;
diff --git a/src/core/hle/service/nvflinger/buffer_queue.cpp b/src/core/hle/service/nvflinger/buffer_queue.cpp
index a181cd2dc..7132b18ad 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.cpp
+++ b/src/core/hle/service/nvflinger/buffer_queue.cpp
@@ -57,13 +57,15 @@ const IGBPBuffer& BufferQueue::RequestBuffer(u32 slot) const {
57 return itr->igbp_buffer; 57 return itr->igbp_buffer;
58} 58}
59 59
60void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform) { 60void BufferQueue::QueueBuffer(u32 slot, BufferTransformFlags transform,
61 const MathUtil::Rectangle<int>& crop_rect) {
61 auto itr = std::find_if(queue.begin(), queue.end(), 62 auto itr = std::find_if(queue.begin(), queue.end(),
62 [&](const Buffer& buffer) { return buffer.slot == slot; }); 63 [&](const Buffer& buffer) { return buffer.slot == slot; });
63 ASSERT(itr != queue.end()); 64 ASSERT(itr != queue.end());
64 ASSERT(itr->status == Buffer::Status::Dequeued); 65 ASSERT(itr->status == Buffer::Status::Dequeued);
65 itr->status = Buffer::Status::Queued; 66 itr->status = Buffer::Status::Queued;
66 itr->transform = transform; 67 itr->transform = transform;
68 itr->crop_rect = crop_rect;
67} 69}
68 70
69boost::optional<const BufferQueue::Buffer&> BufferQueue::AcquireBuffer() { 71boost::optional<const BufferQueue::Buffer&> BufferQueue::AcquireBuffer() {
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h
index 1e55b487e..004170538 100644
--- a/src/core/hle/service/nvflinger/buffer_queue.h
+++ b/src/core/hle/service/nvflinger/buffer_queue.h
@@ -6,6 +6,7 @@
6 6
7#include <vector> 7#include <vector>
8#include <boost/optional.hpp> 8#include <boost/optional.hpp>
9#include "common/math_util.h"
9#include "common/swap.h" 10#include "common/swap.h"
10#include "core/hle/kernel/event.h" 11#include "core/hle/kernel/event.h"
11 12
@@ -68,12 +69,14 @@ public:
68 Status status = Status::Free; 69 Status status = Status::Free;
69 IGBPBuffer igbp_buffer; 70 IGBPBuffer igbp_buffer;
70 BufferTransformFlags transform; 71 BufferTransformFlags transform;
72 MathUtil::Rectangle<int> crop_rect;
71 }; 73 };
72 74
73 void SetPreallocatedBuffer(u32 slot, IGBPBuffer& buffer); 75 void SetPreallocatedBuffer(u32 slot, IGBPBuffer& buffer);
74 boost::optional<u32> DequeueBuffer(u32 width, u32 height); 76 boost::optional<u32> DequeueBuffer(u32 width, u32 height);
75 const IGBPBuffer& RequestBuffer(u32 slot) const; 77 const IGBPBuffer& RequestBuffer(u32 slot) const;
76 void QueueBuffer(u32 slot, BufferTransformFlags transform); 78 void QueueBuffer(u32 slot, BufferTransformFlags transform,
79 const MathUtil::Rectangle<int>& crop_rect);
77 boost::optional<const Buffer&> AcquireBuffer(); 80 boost::optional<const Buffer&> AcquireBuffer();
78 void ReleaseBuffer(u32 slot); 81 void ReleaseBuffer(u32 slot);
79 u32 Query(QueryType type); 82 u32 Query(QueryType type);
diff --git a/src/core/hle/service/nvflinger/nvflinger.cpp b/src/core/hle/service/nvflinger/nvflinger.cpp
index 826646b7d..d580f779e 100644
--- a/src/core/hle/service/nvflinger/nvflinger.cpp
+++ b/src/core/hle/service/nvflinger/nvflinger.cpp
@@ -149,7 +149,8 @@ void NVFlinger::Compose() {
149 ASSERT(nvdisp); 149 ASSERT(nvdisp);
150 150
151 nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format, 151 nvdisp->flip(igbp_buffer.gpu_buffer_id, igbp_buffer.offset, igbp_buffer.format,
152 igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->transform); 152 igbp_buffer.width, igbp_buffer.height, igbp_buffer.stride, buffer->transform,
153 buffer->crop_rect);
153 154
154 buffer_queue->ReleaseBuffer(buffer->slot); 155 buffer_queue->ReleaseBuffer(buffer->slot);
155 } 156 }
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp
index e094510bf..eccee6e33 100644
--- a/src/core/hle/service/vi/vi.cpp
+++ b/src/core/hle/service/vi/vi.cpp
@@ -7,6 +7,7 @@
7#include <memory> 7#include <memory>
8#include <boost/optional.hpp> 8#include <boost/optional.hpp>
9#include "common/alignment.h" 9#include "common/alignment.h"
10#include "common/math_util.h"
10#include "common/scope_exit.h" 11#include "common/scope_exit.h"
11#include "core/core_timing.h" 12#include "core/core_timing.h"
12#include "core/hle/ipc_helpers.h" 13#include "core/hle/ipc_helpers.h"
@@ -27,8 +28,8 @@ struct DisplayInfo {
27 char display_name[0x40]{"Default"}; 28 char display_name[0x40]{"Default"};
28 u64 unknown_1{1}; 29 u64 unknown_1{1};
29 u64 unknown_2{1}; 30 u64 unknown_2{1};
30 u64 width{1920}; 31 u64 width{1280};
31 u64 height{1080}; 32 u64 height{720};
32}; 33};
33static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size"); 34static_assert(sizeof(DisplayInfo) == 0x60, "DisplayInfo has wrong size");
34 35
@@ -327,8 +328,8 @@ public:
327 328
328protected: 329protected:
329 void SerializeData() override { 330 void SerializeData() override {
330 // TODO(Subv): Figure out what this value means, writing non-zero here will make libnx try 331 // TODO(Subv): Figure out what this value means, writing non-zero here will make libnx
331 // to read an IGBPBuffer object from the parcel. 332 // try to read an IGBPBuffer object from the parcel.
332 Write<u32_le>(1); 333 Write<u32_le>(1);
333 WriteObject(buffer); 334 WriteObject(buffer);
334 Write<u32_le>(0); 335 Write<u32_le>(0);
@@ -360,8 +361,8 @@ public:
360 INSERT_PADDING_WORDS(3); 361 INSERT_PADDING_WORDS(3);
361 u32_le timestamp; 362 u32_le timestamp;
362 s32_le is_auto_timestamp; 363 s32_le is_auto_timestamp;
363 s32_le crop_left;
364 s32_le crop_top; 364 s32_le crop_top;
365 s32_le crop_left;
365 s32_le crop_right; 366 s32_le crop_right;
366 s32_le crop_bottom; 367 s32_le crop_bottom;
367 s32_le scaling_mode; 368 s32_le scaling_mode;
@@ -370,6 +371,10 @@ public:
370 INSERT_PADDING_WORDS(2); 371 INSERT_PADDING_WORDS(2);
371 u32_le fence_is_valid; 372 u32_le fence_is_valid;
372 std::array<Fence, 2> fences; 373 std::array<Fence, 2> fences;
374
375 MathUtil::Rectangle<int> GetCropRect() const {
376 return {crop_left, crop_top, crop_right, crop_bottom};
377 }
373 }; 378 };
374 static_assert(sizeof(Data) == 80, "ParcelData has wrong size"); 379 static_assert(sizeof(Data) == 80, "ParcelData has wrong size");
375 380
@@ -519,7 +524,8 @@ private:
519 } else if (transaction == TransactionId::QueueBuffer) { 524 } else if (transaction == TransactionId::QueueBuffer) {
520 IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()}; 525 IGBPQueueBufferRequestParcel request{ctx.ReadBuffer()};
521 526
522 buffer_queue->QueueBuffer(request.data.slot, request.data.transform); 527 buffer_queue->QueueBuffer(request.data.slot, request.data.transform,
528 request.data.GetCropRect());
523 529
524 IGBPQueueBufferResponseParcel response{1280, 720}; 530 IGBPQueueBufferResponseParcel response{1280, 720};
525 ctx.WriteBuffer(response.Serialize()); 531 ctx.WriteBuffer(response.Serialize());
@@ -532,7 +538,7 @@ private:
532 IGBPQueryResponseParcel response{value}; 538 IGBPQueryResponseParcel response{value};
533 ctx.WriteBuffer(response.Serialize()); 539 ctx.WriteBuffer(response.Serialize());
534 } else if (transaction == TransactionId::CancelBuffer) { 540 } else if (transaction == TransactionId::CancelBuffer) {
535 LOG_WARNING(Service_VI, "(STUBBED) called, transaction=CancelBuffer"); 541 LOG_CRITICAL(Service_VI, "(STUBBED) called, transaction=CancelBuffer");
536 } else { 542 } else {
537 ASSERT_MSG(false, "Unimplemented"); 543 ASSERT_MSG(false, "Unimplemented");
538 } 544 }
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h
index cc5ca656e..60930e997 100644
--- a/src/video_core/gpu.h
+++ b/src/video_core/gpu.h
@@ -67,6 +67,7 @@ struct FramebufferConfig {
67 67
68 using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags; 68 using TransformFlags = Service::NVFlinger::BufferQueue::BufferTransformFlags;
69 TransformFlags transform_flags; 69 TransformFlags transform_flags;
70 MathUtil::Rectangle<int> crop_rect;
70}; 71};
71 72
72namespace Engines { 73namespace Engines {
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index 1930fa6ef..7810b9147 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -154,6 +154,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const Tegra::FramebufferConfig& framebuf
154 154
155 // Framebuffer orientation handling 155 // Framebuffer orientation handling
156 framebuffer_transform_flags = framebuffer.transform_flags; 156 framebuffer_transform_flags = framebuffer.transform_flags;
157 framebuffer_crop_rect = framebuffer.crop_rect;
157 158
158 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default 159 // Ensure no bad interactions with GL_UNPACK_ALIGNMENT, which by default
159 // only allows rows to have a memory alignement of 4. 160 // only allows rows to have a memory alignement of 4.
@@ -320,11 +321,24 @@ void RendererOpenGL::DrawScreenTriangles(const ScreenInfo& screen_info, float x,
320 } 321 }
321 } 322 }
322 323
324 ASSERT_MSG(framebuffer_crop_rect.top == 0, "Unimplemented");
325 ASSERT_MSG(framebuffer_crop_rect.left == 0, "Unimplemented");
326
327 // Scale the output by the crop width/height. This is commonly used with 1280x720 rendering
328 // (e.g. handheld mode) on a 1920x1080 framebuffer.
329 f32 scale_u = 1.f, scale_v = 1.f;
330 if (framebuffer_crop_rect.GetWidth() > 0) {
331 scale_u = static_cast<f32>(framebuffer_crop_rect.GetWidth()) / screen_info.texture.width;
332 }
333 if (framebuffer_crop_rect.GetHeight() > 0) {
334 scale_v = static_cast<f32>(framebuffer_crop_rect.GetHeight()) / screen_info.texture.height;
335 }
336
323 std::array<ScreenRectVertex, 4> vertices = {{ 337 std::array<ScreenRectVertex, 4> vertices = {{
324 ScreenRectVertex(x, y, texcoords.top, left), 338 ScreenRectVertex(x, y, texcoords.top * scale_u, left * scale_v),
325 ScreenRectVertex(x + w, y, texcoords.bottom, left), 339 ScreenRectVertex(x + w, y, texcoords.bottom * scale_u, left * scale_v),
326 ScreenRectVertex(x, y + h, texcoords.top, right), 340 ScreenRectVertex(x, y + h, texcoords.top * scale_u, right * scale_v),
327 ScreenRectVertex(x + w, y + h, texcoords.bottom, right), 341 ScreenRectVertex(x + w, y + h, texcoords.bottom * scale_u, right * scale_v),
328 }}; 342 }};
329 343
330 state.texture_units[0].texture_2d = screen_info.display_texture; 344 state.texture_units[0].texture_2d = screen_info.display_texture;
diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h
index fd0267cf5..59d92a3dc 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.h
+++ b/src/video_core/renderer_opengl/renderer_opengl.h
@@ -97,4 +97,5 @@ private:
97 97
98 /// Used for transforming the framebuffer orientation 98 /// Used for transforming the framebuffer orientation
99 Tegra::FramebufferConfig::TransformFlags framebuffer_transform_flags; 99 Tegra::FramebufferConfig::TransformFlags framebuffer_transform_flags;
100 MathUtil::Rectangle<int> framebuffer_crop_rect;
100}; 101};
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp
index a32134fbe..62754a1a9 100644
--- a/src/yuzu/configuration/config.cpp
+++ b/src/yuzu/configuration/config.cpp
@@ -97,7 +97,7 @@ void Config::ReadValues() {
97 qt_config->endGroup(); 97 qt_config->endGroup();
98 98
99 qt_config->beginGroup("System"); 99 qt_config->beginGroup("System");
100 Settings::values.use_docked_mode = qt_config->value("use_docked_mode", true).toBool(); 100 Settings::values.use_docked_mode = qt_config->value("use_docked_mode", false).toBool();
101 qt_config->endGroup(); 101 qt_config->endGroup();
102 102
103 qt_config->beginGroup("Miscellaneous"); 103 qt_config->beginGroup("Miscellaneous");
diff --git a/src/yuzu_cmd/config.cpp b/src/yuzu_cmd/config.cpp
index 3a311b69f..723e8b4cc 100644
--- a/src/yuzu_cmd/config.cpp
+++ b/src/yuzu_cmd/config.cpp
@@ -110,7 +110,7 @@ void Config::ReadValues() {
110 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true); 110 sdl2_config->GetBoolean("Data Storage", "use_virtual_sd", true);
111 111
112 // System 112 // System
113 Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", true); 113 Settings::values.use_docked_mode = sdl2_config->GetBoolean("System", "use_docked_mode", false);
114 114
115 // Miscellaneous 115 // Miscellaneous
116 Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace"); 116 Settings::values.log_filter = sdl2_config->Get("Miscellaneous", "log_filter", "*:Trace");
diff --git a/src/yuzu_cmd/default_ini.h b/src/yuzu_cmd/default_ini.h
index 71d2e040f..5eca38b48 100644
--- a/src/yuzu_cmd/default_ini.h
+++ b/src/yuzu_cmd/default_ini.h
@@ -163,7 +163,7 @@ use_virtual_sd =
163 163
164[System] 164[System]
165# Whether the system is docked 165# Whether the system is docked
166# 1 (default): Yes, 0: No 166# 1: Yes, 0 (default): No
167use_docked_mode = 167use_docked_mode =
168 168
169# The system region that yuzu will use during emulation 169# The system region that yuzu will use during emulation