diff options
| author | 2018-03-23 23:30:48 -0400 | |
|---|---|---|
| committer | 2018-03-23 23:30:48 -0400 | |
| commit | a10baacf9e5ab48af7fb0ccbdc75371c9287d3ba (patch) | |
| tree | 9ed56f99b9d2564f9250d3754e429eb0c8b43323 /src/core | |
| parent | Merge pull request #255 from Subv/sd_card (diff) | |
| parent | gl_rasterizer: Fake render in green, because it's cooler. (diff) | |
| download | yuzu-a10baacf9e5ab48af7fb0ccbdc75371c9287d3ba.tar.gz yuzu-a10baacf9e5ab48af7fb0ccbdc75371c9287d3ba.tar.xz yuzu-a10baacf9e5ab48af7fb0ccbdc75371c9287d3ba.zip | |
Merge pull request #265 from bunnei/tegra-progress-2
Tegra progress 2
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | 11 | ||||
| -rw-r--r-- | src/core/hle/service/nvflinger/buffer_queue.h | 2 | ||||
| -rw-r--r-- | src/core/memory.cpp | 40 | ||||
| -rw-r--r-- | src/core/memory.h | 20 |
4 files changed, 66 insertions, 7 deletions
diff --git a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp index 94530724e..87b3a2d74 100644 --- a/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp +++ b/src/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp | |||
| @@ -26,14 +26,13 @@ void nvdisp_disp0::flip(u32 buffer_handle, u32 offset, u32 format, u32 width, u3 | |||
| 26 | "Drawing from address %lx offset %08X Width %u Height %u Stride %u Format %u", addr, | 26 | "Drawing from address %lx offset %08X Width %u Height %u Stride %u Format %u", addr, |
| 27 | offset, width, height, stride, format); | 27 | offset, width, height, stride, format); |
| 28 | 28 | ||
| 29 | using PixelFormat = RendererBase::FramebufferInfo::PixelFormat; | 29 | using PixelFormat = Tegra::FramebufferConfig::PixelFormat; |
| 30 | using Flags = NVFlinger::BufferQueue::BufferTransformFlags; | 30 | const Tegra::FramebufferConfig framebuffer{ |
| 31 | const bool flip_vertical = static_cast<u32>(transform) & static_cast<u32>(Flags::FlipV); | 31 | addr, offset, width, height, stride, static_cast<PixelFormat>(format), transform}; |
| 32 | const RendererBase::FramebufferInfo framebuffer_info{ | ||
| 33 | addr, offset, width, height, stride, static_cast<PixelFormat>(format), flip_vertical}; | ||
| 34 | 32 | ||
| 35 | Core::System::GetInstance().perf_stats.EndGameFrame(); | 33 | Core::System::GetInstance().perf_stats.EndGameFrame(); |
| 36 | VideoCore::g_renderer->SwapBuffers(framebuffer_info); | 34 | |
| 35 | VideoCore::g_renderer->SwapBuffers(framebuffer); | ||
| 37 | } | 36 | } |
| 38 | 37 | ||
| 39 | } // namespace Devices | 38 | } // namespace Devices |
diff --git a/src/core/hle/service/nvflinger/buffer_queue.h b/src/core/hle/service/nvflinger/buffer_queue.h index 686eadca7..1de5767cb 100644 --- a/src/core/hle/service/nvflinger/buffer_queue.h +++ b/src/core/hle/service/nvflinger/buffer_queue.h | |||
| @@ -47,6 +47,8 @@ public: | |||
| 47 | ~BufferQueue() = default; | 47 | ~BufferQueue() = default; |
| 48 | 48 | ||
| 49 | enum class BufferTransformFlags : u32 { | 49 | enum class BufferTransformFlags : u32 { |
| 50 | /// No transform flags are set | ||
| 51 | Unset = 0x00, | ||
| 50 | /// Flip source image horizontally (around the vertical axis) | 52 | /// Flip source image horizontally (around the vertical axis) |
| 51 | FlipH = 0x01, | 53 | FlipH = 0x01, |
| 52 | /// Flip source image vertically (around the horizontal axis) | 54 | /// Flip source image vertically (around the horizontal axis) |
diff --git a/src/core/memory.cpp b/src/core/memory.cpp index a9beccb95..d6469dd3d 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp | |||
| @@ -41,6 +41,9 @@ static void MapPages(PageTable& page_table, VAddr base, u64 size, u8* memory, Pa | |||
| 41 | LOG_DEBUG(HW_Memory, "Mapping %p onto %016" PRIX64 "-%016" PRIX64, memory, base * PAGE_SIZE, | 41 | LOG_DEBUG(HW_Memory, "Mapping %p onto %016" PRIX64 "-%016" PRIX64, memory, base * PAGE_SIZE, |
| 42 | (base + size) * PAGE_SIZE); | 42 | (base + size) * PAGE_SIZE); |
| 43 | 43 | ||
| 44 | RasterizerFlushVirtualRegion(base << PAGE_BITS, size * PAGE_SIZE, | ||
| 45 | FlushMode::FlushAndInvalidate); | ||
| 46 | |||
| 44 | VAddr end = base + size; | 47 | VAddr end = base + size; |
| 45 | while (base != end) { | 48 | while (base != end) { |
| 46 | ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %016" PRIX64, base); | 49 | ASSERT_MSG(base < PAGE_TABLE_NUM_ENTRIES, "out of range mapping at %016" PRIX64, base); |
| @@ -288,6 +291,43 @@ u8* GetPhysicalPointer(PAddr address) { | |||
| 288 | return target_pointer; | 291 | return target_pointer; |
| 289 | } | 292 | } |
| 290 | 293 | ||
| 294 | void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode) { | ||
| 295 | // Since pages are unmapped on shutdown after video core is shutdown, the renderer may be | ||
| 296 | // null here | ||
| 297 | if (VideoCore::g_renderer == nullptr) { | ||
| 298 | return; | ||
| 299 | } | ||
| 300 | |||
| 301 | VAddr end = start + size; | ||
| 302 | |||
| 303 | auto CheckRegion = [&](VAddr region_start, VAddr region_end) { | ||
| 304 | if (start >= region_end || end <= region_start) { | ||
| 305 | // No overlap with region | ||
| 306 | return; | ||
| 307 | } | ||
| 308 | |||
| 309 | VAddr overlap_start = std::max(start, region_start); | ||
| 310 | VAddr overlap_end = std::min(end, region_end); | ||
| 311 | u64 overlap_size = overlap_end - overlap_start; | ||
| 312 | |||
| 313 | auto* rasterizer = VideoCore::g_renderer->Rasterizer(); | ||
| 314 | switch (mode) { | ||
| 315 | case FlushMode::Flush: | ||
| 316 | rasterizer->FlushRegion(overlap_start, overlap_size); | ||
| 317 | break; | ||
| 318 | case FlushMode::Invalidate: | ||
| 319 | rasterizer->InvalidateRegion(overlap_start, overlap_size); | ||
| 320 | break; | ||
| 321 | case FlushMode::FlushAndInvalidate: | ||
| 322 | rasterizer->FlushAndInvalidateRegion(overlap_start, overlap_size); | ||
| 323 | break; | ||
| 324 | } | ||
| 325 | }; | ||
| 326 | |||
| 327 | CheckRegion(PROCESS_IMAGE_VADDR, PROCESS_IMAGE_VADDR_END); | ||
| 328 | CheckRegion(HEAP_VADDR, HEAP_VADDR_END); | ||
| 329 | } | ||
| 330 | |||
| 291 | u8 Read8(const VAddr addr) { | 331 | u8 Read8(const VAddr addr) { |
| 292 | return Read<u8>(addr); | 332 | return Read<u8>(addr); |
| 293 | } | 333 | } |
diff --git a/src/core/memory.h b/src/core/memory.h index f5bf0141f..4b9c482fe 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -36,7 +36,10 @@ enum class PageType : u8 { | |||
| 36 | Unmapped, | 36 | Unmapped, |
| 37 | /// Page is mapped to regular memory. This is the only type you can get pointers to. | 37 | /// Page is mapped to regular memory. This is the only type you can get pointers to. |
| 38 | Memory, | 38 | Memory, |
| 39 | /// Page is mapped to a memory hook, which intercepts read and write requests. | 39 | /// Page is mapped to regular memory, but also needs to check for rasterizer cache flushing and |
| 40 | /// invalidation | ||
| 41 | RasterizerCachedMemory, | ||
| 42 | /// Page is mapped to a I/O region. Writing and reading to this page is handled by functions. | ||
| 40 | Special, | 43 | Special, |
| 41 | }; | 44 | }; |
| 42 | 45 | ||
| @@ -242,4 +245,19 @@ boost::optional<VAddr> PhysicalToVirtualAddress(PAddr addr); | |||
| 242 | */ | 245 | */ |
| 243 | u8* GetPhysicalPointer(PAddr address); | 246 | u8* GetPhysicalPointer(PAddr address); |
| 244 | 247 | ||
| 248 | enum class FlushMode { | ||
| 249 | /// Write back modified surfaces to RAM | ||
| 250 | Flush, | ||
| 251 | /// Remove region from the cache | ||
| 252 | Invalidate, | ||
| 253 | /// Write back modified surfaces to RAM, and also remove them from the cache | ||
| 254 | FlushAndInvalidate, | ||
| 255 | }; | ||
| 256 | |||
| 257 | /** | ||
| 258 | * Flushes and invalidates any externally cached rasterizer resources touching the given virtual | ||
| 259 | * address region. | ||
| 260 | */ | ||
| 261 | void RasterizerFlushVirtualRegion(VAddr start, u64 size, FlushMode mode); | ||
| 262 | |||
| 245 | } // namespace Memory | 263 | } // namespace Memory |