mirror of
https://git.suyu.dev/suyu/suyu
synced 2024-12-25 10:52:48 -06:00
video_core: Remove usage of PAddr and replace with VAddr.
This commit is contained in:
parent
bfe45774f1
commit
8a250de987
5 changed files with 39 additions and 39 deletions
|
@ -25,14 +25,14 @@ public:
|
||||||
virtual void FlushAll() = 0;
|
virtual void FlushAll() = 0;
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory
|
/// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory
|
||||||
virtual void FlushRegion(PAddr addr, u32 size) = 0;
|
virtual void FlushRegion(VAddr addr, u32 size) = 0;
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be invalidated
|
/// Notify rasterizer that any caches of the specified region should be invalidated
|
||||||
virtual void InvalidateRegion(PAddr addr, u32 size) = 0;
|
virtual void InvalidateRegion(VAddr addr, u32 size) = 0;
|
||||||
|
|
||||||
/// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory
|
/// Notify rasterizer that any caches of the specified region should be flushed to 3DS memory
|
||||||
/// and invalidated
|
/// and invalidated
|
||||||
virtual void FlushAndInvalidateRegion(PAddr addr, u32 size) = 0;
|
virtual void FlushAndInvalidateRegion(VAddr addr, u32 size) = 0;
|
||||||
|
|
||||||
/// Attempt to use a faster method to perform a display transfer with is_texture_copy = 0
|
/// Attempt to use a faster method to perform a display transfer with is_texture_copy = 0
|
||||||
virtual bool AccelerateDisplayTransfer(const void* config) {
|
virtual bool AccelerateDisplayTransfer(const void* config) {
|
||||||
|
@ -51,7 +51,7 @@ public:
|
||||||
|
|
||||||
/// Attempt to use a faster method to display the framebuffer to screen
|
/// Attempt to use a faster method to display the framebuffer to screen
|
||||||
virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer,
|
virtual bool AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer,
|
||||||
PAddr framebuffer_addr, u32 pixel_stride,
|
VAddr framebuffer_addr, u32 pixel_stride,
|
||||||
ScreenInfo& screen_info) {
|
ScreenInfo& screen_info) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -194,17 +194,17 @@ void RasterizerOpenGL::FlushAll() {
|
||||||
res_cache.FlushAll();
|
res_cache.FlushAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) {
|
void RasterizerOpenGL::FlushRegion(VAddr addr, u32 size) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
||||||
res_cache.FlushRegion(addr, size);
|
res_cache.FlushRegion(addr, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::InvalidateRegion(PAddr addr, u32 size) {
|
void RasterizerOpenGL::InvalidateRegion(VAddr addr, u32 size) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
||||||
res_cache.InvalidateRegion(addr, size, nullptr);
|
res_cache.InvalidateRegion(addr, size, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerOpenGL::FlushAndInvalidateRegion(PAddr addr, u32 size) {
|
void RasterizerOpenGL::FlushAndInvalidateRegion(VAddr addr, u32 size) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
MICROPROFILE_SCOPE(OpenGL_CacheManagement);
|
||||||
res_cache.FlushRegion(addr, size);
|
res_cache.FlushRegion(addr, size);
|
||||||
res_cache.InvalidateRegion(addr, size, nullptr);
|
res_cache.InvalidateRegion(addr, size, nullptr);
|
||||||
|
@ -227,7 +227,7 @@ bool RasterizerOpenGL::AccelerateFill(const void* config) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer,
|
bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer,
|
||||||
PAddr framebuffer_addr, u32 pixel_stride,
|
VAddr framebuffer_addr, u32 pixel_stride,
|
||||||
ScreenInfo& screen_info) {
|
ScreenInfo& screen_info) {
|
||||||
ASSERT_MSG(false, "Unimplemented");
|
ASSERT_MSG(false, "Unimplemented");
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -32,13 +32,13 @@ public:
|
||||||
void DrawTriangles() override;
|
void DrawTriangles() override;
|
||||||
void NotifyMaxwellRegisterChanged(u32 id) override;
|
void NotifyMaxwellRegisterChanged(u32 id) override;
|
||||||
void FlushAll() override;
|
void FlushAll() override;
|
||||||
void FlushRegion(PAddr addr, u32 size) override;
|
void FlushRegion(VAddr addr, u32 size) override;
|
||||||
void InvalidateRegion(PAddr addr, u32 size) override;
|
void InvalidateRegion(VAddr addr, u32 size) override;
|
||||||
void FlushAndInvalidateRegion(PAddr addr, u32 size) override;
|
void FlushAndInvalidateRegion(VAddr addr, u32 size) override;
|
||||||
bool AccelerateDisplayTransfer(const void* config) override;
|
bool AccelerateDisplayTransfer(const void* config) override;
|
||||||
bool AccelerateTextureCopy(const void* config) override;
|
bool AccelerateTextureCopy(const void* config) override;
|
||||||
bool AccelerateFill(const void* config) override;
|
bool AccelerateFill(const void* config) override;
|
||||||
bool AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer, PAddr framebuffer_addr,
|
bool AccelerateDisplay(const Tegra::FramebufferConfig& framebuffer, VAddr framebuffer_addr,
|
||||||
u32 pixel_stride, ScreenInfo& screen_info) override;
|
u32 pixel_stride, ScreenInfo& screen_info) override;
|
||||||
bool AccelerateDrawBatch(bool is_indexed) override;
|
bool AccelerateDrawBatch(bool is_indexed) override;
|
||||||
|
|
||||||
|
|
|
@ -107,7 +107,7 @@ static void MortonCopyTile(u32 stride, u8* tile_buffer, u8* gl_buffer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <bool morton_to_gl, PixelFormat format>
|
template <bool morton_to_gl, PixelFormat format>
|
||||||
static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, PAddr base, PAddr start, PAddr end) {
|
static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, VAddr base, VAddr start, VAddr end) {
|
||||||
constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / 8;
|
constexpr u32 bytes_per_pixel = SurfaceParams::GetFormatBpp(format) / 8;
|
||||||
constexpr u32 tile_size = bytes_per_pixel * 64;
|
constexpr u32 tile_size = bytes_per_pixel * 64;
|
||||||
|
|
||||||
|
@ -115,9 +115,9 @@ static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, PAddr base, PAddr
|
||||||
static_assert(gl_bytes_per_pixel >= bytes_per_pixel, "");
|
static_assert(gl_bytes_per_pixel >= bytes_per_pixel, "");
|
||||||
gl_buffer += gl_bytes_per_pixel - bytes_per_pixel;
|
gl_buffer += gl_bytes_per_pixel - bytes_per_pixel;
|
||||||
|
|
||||||
const PAddr aligned_down_start = base + Common::AlignDown(start - base, tile_size);
|
const VAddr aligned_down_start = base + Common::AlignDown(start - base, tile_size);
|
||||||
const PAddr aligned_start = base + Common::AlignUp(start - base, tile_size);
|
const VAddr aligned_start = base + Common::AlignUp(start - base, tile_size);
|
||||||
const PAddr aligned_end = base + Common::AlignDown(end - base, tile_size);
|
const VAddr aligned_end = base + Common::AlignDown(end - base, tile_size);
|
||||||
|
|
||||||
ASSERT(!morton_to_gl || (aligned_start == start && aligned_end == end));
|
ASSERT(!morton_to_gl || (aligned_start == start && aligned_end == end));
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, PAddr base, PAddr
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
u8* tile_buffer = Memory::GetPhysicalPointer(start);
|
u8* tile_buffer = Memory::GetPointer(start);
|
||||||
|
|
||||||
if (start < aligned_start && !morton_to_gl) {
|
if (start < aligned_start && !morton_to_gl) {
|
||||||
std::array<u8, tile_size> tmp_buf;
|
std::array<u8, tile_size> tmp_buf;
|
||||||
|
@ -162,7 +162,7 @@ static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, PAddr base, PAddr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u8*, PAddr, PAddr, PAddr), 18> morton_to_gl_fns = {
|
static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 18> morton_to_gl_fns = {
|
||||||
MortonCopy<true, PixelFormat::RGBA8>, // 0
|
MortonCopy<true, PixelFormat::RGBA8>, // 0
|
||||||
MortonCopy<true, PixelFormat::RGB8>, // 1
|
MortonCopy<true, PixelFormat::RGB8>, // 1
|
||||||
MortonCopy<true, PixelFormat::RGB5A1>, // 2
|
MortonCopy<true, PixelFormat::RGB5A1>, // 2
|
||||||
|
@ -183,7 +183,7 @@ static constexpr std::array<void (*)(u32, u32, u8*, PAddr, PAddr, PAddr), 18> mo
|
||||||
MortonCopy<true, PixelFormat::D24S8> // 17
|
MortonCopy<true, PixelFormat::D24S8> // 17
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr std::array<void (*)(u32, u32, u8*, PAddr, PAddr, PAddr), 18> gl_to_morton_fns = {
|
static constexpr std::array<void (*)(u32, u32, u8*, VAddr, VAddr, VAddr), 18> gl_to_morton_fns = {
|
||||||
MortonCopy<false, PixelFormat::RGBA8>, // 0
|
MortonCopy<false, PixelFormat::RGBA8>, // 0
|
||||||
MortonCopy<false, PixelFormat::RGB8>, // 1
|
MortonCopy<false, PixelFormat::RGB8>, // 1
|
||||||
MortonCopy<false, PixelFormat::RGB5A1>, // 2
|
MortonCopy<false, PixelFormat::RGB5A1>, // 2
|
||||||
|
@ -298,9 +298,9 @@ SurfaceParams SurfaceParams::FromInterval(SurfaceInterval interval) const {
|
||||||
SurfaceParams params = *this;
|
SurfaceParams params = *this;
|
||||||
const u32 tiled_size = is_tiled ? 8 : 1;
|
const u32 tiled_size = is_tiled ? 8 : 1;
|
||||||
const u64 stride_tiled_bytes = BytesInPixels(stride * tiled_size);
|
const u64 stride_tiled_bytes = BytesInPixels(stride * tiled_size);
|
||||||
PAddr aligned_start =
|
VAddr aligned_start =
|
||||||
addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes);
|
addr + Common::AlignDown(boost::icl::first(interval) - addr, stride_tiled_bytes);
|
||||||
PAddr aligned_end =
|
VAddr aligned_end =
|
||||||
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes);
|
addr + Common::AlignUp(boost::icl::last_next(interval) - addr, stride_tiled_bytes);
|
||||||
|
|
||||||
if (aligned_end - aligned_start > stride_tiled_bytes) {
|
if (aligned_end - aligned_start > stride_tiled_bytes) {
|
||||||
|
@ -527,10 +527,10 @@ void RasterizerCacheOpenGL::CopySurface(const Surface& src_surface, const Surfac
|
||||||
}
|
}
|
||||||
|
|
||||||
MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 64, 192));
|
MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 64, 192));
|
||||||
void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
|
void CachedSurface::LoadGLBuffer(VAddr load_start, VAddr load_end) {
|
||||||
ASSERT(type != SurfaceType::Fill);
|
ASSERT(type != SurfaceType::Fill);
|
||||||
|
|
||||||
const u8* const texture_src_data = Memory::GetPhysicalPointer(addr);
|
const u8* const texture_src_data = Memory::GetPointer(addr);
|
||||||
if (texture_src_data == nullptr)
|
if (texture_src_data == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
|
||||||
MICROPROFILE_SCOPE(OpenGL_SurfaceLoad);
|
MICROPROFILE_SCOPE(OpenGL_SurfaceLoad);
|
||||||
|
|
||||||
ASSERT(load_start >= addr && load_end <= end);
|
ASSERT(load_start >= addr && load_end <= end);
|
||||||
const u32 start_offset = load_start - addr;
|
const u64 start_offset = load_start - addr;
|
||||||
|
|
||||||
if (!is_tiled) {
|
if (!is_tiled) {
|
||||||
ASSERT(type == SurfaceType::Color);
|
ASSERT(type == SurfaceType::Color);
|
||||||
|
@ -566,8 +566,8 @@ void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64));
|
MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64));
|
||||||
void CachedSurface::FlushGLBuffer(PAddr flush_start, PAddr flush_end) {
|
void CachedSurface::FlushGLBuffer(VAddr flush_start, VAddr flush_end) {
|
||||||
u8* const dst_buffer = Memory::GetPhysicalPointer(addr);
|
u8* const dst_buffer = Memory::GetPointer(addr);
|
||||||
if (dst_buffer == nullptr)
|
if (dst_buffer == nullptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1167,7 +1167,7 @@ void RasterizerCacheOpenGL::DuplicateSurface(const Surface& src_surface,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr, u64 size) {
|
void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, VAddr addr, u64 size) {
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1227,7 +1227,7 @@ void RasterizerCacheOpenGL::ValidateSurface(const Surface& surface, PAddr addr,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCacheOpenGL::FlushRegion(PAddr addr, u64 size, Surface flush_surface) {
|
void RasterizerCacheOpenGL::FlushRegion(VAddr addr, u64 size, Surface flush_surface) {
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1263,7 +1263,7 @@ void RasterizerCacheOpenGL::FlushAll() {
|
||||||
FlushRegion(0, 0xFFFFFFFF);
|
FlushRegion(0, 0xFFFFFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCacheOpenGL::InvalidateRegion(PAddr addr, u64 size, const Surface& region_owner) {
|
void RasterizerCacheOpenGL::InvalidateRegion(VAddr addr, u64 size, const Surface& region_owner) {
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -1356,6 +1356,6 @@ void RasterizerCacheOpenGL::UnregisterSurface(const Surface& surface) {
|
||||||
surface_cache.subtract({surface->GetInterval(), SurfaceSet{surface}});
|
surface_cache.subtract({surface->GetInterval(), SurfaceSet{surface}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void RasterizerCacheOpenGL::UpdatePagesCachedCount(PAddr addr, u64 size, int delta) {
|
void RasterizerCacheOpenGL::UpdatePagesCachedCount(VAddr addr, u64 size, int delta) {
|
||||||
// ASSERT_MSG(false, "Unimplemented");
|
// ASSERT_MSG(false, "Unimplemented");
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,9 +28,9 @@ struct CachedSurface;
|
||||||
using Surface = std::shared_ptr<CachedSurface>;
|
using Surface = std::shared_ptr<CachedSurface>;
|
||||||
using SurfaceSet = std::set<Surface>;
|
using SurfaceSet = std::set<Surface>;
|
||||||
|
|
||||||
using SurfaceRegions = boost::icl::interval_set<PAddr>;
|
using SurfaceRegions = boost::icl::interval_set<VAddr>;
|
||||||
using SurfaceMap = boost::icl::interval_map<PAddr, Surface>;
|
using SurfaceMap = boost::icl::interval_map<VAddr, Surface>;
|
||||||
using SurfaceCache = boost::icl::interval_map<PAddr, SurfaceSet>;
|
using SurfaceCache = boost::icl::interval_map<VAddr, SurfaceSet>;
|
||||||
|
|
||||||
using SurfaceInterval = SurfaceCache::interval_type;
|
using SurfaceInterval = SurfaceCache::interval_type;
|
||||||
static_assert(std::is_same<SurfaceRegions::interval_type, SurfaceCache::interval_type>() &&
|
static_assert(std::is_same<SurfaceRegions::interval_type, SurfaceCache::interval_type>() &&
|
||||||
|
@ -258,8 +258,8 @@ struct CachedSurface : SurfaceParams {
|
||||||
size_t gl_buffer_size = 0;
|
size_t gl_buffer_size = 0;
|
||||||
|
|
||||||
// Read/Write data in 3DS memory to/from gl_buffer
|
// Read/Write data in 3DS memory to/from gl_buffer
|
||||||
void LoadGLBuffer(PAddr load_start, PAddr load_end);
|
void LoadGLBuffer(VAddr load_start, VAddr load_end);
|
||||||
void FlushGLBuffer(PAddr flush_start, PAddr flush_end);
|
void FlushGLBuffer(VAddr flush_start, VAddr flush_end);
|
||||||
|
|
||||||
// Upload/Download data in gl_buffer in/to this surface's texture
|
// Upload/Download data in gl_buffer in/to this surface's texture
|
||||||
void UploadGLTexture(const MathUtil::Rectangle<u32>& rect, GLuint read_fb_handle,
|
void UploadGLTexture(const MathUtil::Rectangle<u32>& rect, GLuint read_fb_handle,
|
||||||
|
@ -307,10 +307,10 @@ public:
|
||||||
SurfaceRect_Tuple GetTexCopySurface(const SurfaceParams& params);
|
SurfaceRect_Tuple GetTexCopySurface(const SurfaceParams& params);
|
||||||
|
|
||||||
/// Write any cached resources overlapping the region back to memory (if dirty)
|
/// Write any cached resources overlapping the region back to memory (if dirty)
|
||||||
void FlushRegion(PAddr addr, u64 size, Surface flush_surface = nullptr);
|
void FlushRegion(VAddr addr, u64 size, Surface flush_surface = nullptr);
|
||||||
|
|
||||||
/// Mark region as being invalidated by region_owner (nullptr if 3DS memory)
|
/// Mark region as being invalidated by region_owner (nullptr if 3DS memory)
|
||||||
void InvalidateRegion(PAddr addr, u64 size, const Surface& region_owner);
|
void InvalidateRegion(VAddr addr, u64 size, const Surface& region_owner);
|
||||||
|
|
||||||
/// Flush all cached resources tracked by this cache manager
|
/// Flush all cached resources tracked by this cache manager
|
||||||
void FlushAll();
|
void FlushAll();
|
||||||
|
@ -319,7 +319,7 @@ private:
|
||||||
void DuplicateSurface(const Surface& src_surface, const Surface& dest_surface);
|
void DuplicateSurface(const Surface& src_surface, const Surface& dest_surface);
|
||||||
|
|
||||||
/// Update surface's texture for given region when necessary
|
/// Update surface's texture for given region when necessary
|
||||||
void ValidateSurface(const Surface& surface, PAddr addr, u64 size);
|
void ValidateSurface(const Surface& surface, VAddr addr, u64 size);
|
||||||
|
|
||||||
/// Create a new surface
|
/// Create a new surface
|
||||||
Surface CreateSurface(const SurfaceParams& params);
|
Surface CreateSurface(const SurfaceParams& params);
|
||||||
|
@ -331,7 +331,7 @@ private:
|
||||||
void UnregisterSurface(const Surface& surface);
|
void UnregisterSurface(const Surface& surface);
|
||||||
|
|
||||||
/// Increase/decrease the number of surface in pages touching the specified region
|
/// Increase/decrease the number of surface in pages touching the specified region
|
||||||
void UpdatePagesCachedCount(PAddr addr, u64 size, int delta);
|
void UpdatePagesCachedCount(VAddr addr, u64 size, int delta);
|
||||||
|
|
||||||
SurfaceCache surface_cache;
|
SurfaceCache surface_cache;
|
||||||
PageMap cached_pages;
|
PageMap cached_pages;
|
||||||
|
|
Loading…
Reference in a new issue