Memory: move GetPhysicalPointer and IsValidPhysicalAddress into class
This commit is contained in:
parent
cfee59c6db
commit
296c458e0e
18 changed files with 76 additions and 65 deletions
|
@ -269,7 +269,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
case PICA_REG_INDEX_WORKAROUND(pipeline.command_buffer.trigger[1], 0x23d): {
|
||||
unsigned index =
|
||||
static_cast<unsigned>(id - PICA_REG_INDEX(pipeline.command_buffer.trigger[0]));
|
||||
u32* head_ptr = (u32*)Memory::GetPhysicalPointer(
|
||||
u32* head_ptr = (u32*)VideoCore::g_memory->GetPhysicalPointer(
|
||||
regs.pipeline.command_buffer.GetPhysicalAddress(index));
|
||||
g_state.cmd_list.head_ptr = g_state.cmd_list.current_ptr = head_ptr;
|
||||
g_state.cmd_list.length = regs.pipeline.command_buffer.GetSize(index) / sizeof(u32);
|
||||
|
@ -328,7 +328,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
|
||||
// Load vertices
|
||||
const auto& index_info = regs.pipeline.index_array;
|
||||
const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset);
|
||||
const u8* index_address_8 =
|
||||
VideoCore::g_memory->GetPhysicalPointer(base_address + index_info.offset);
|
||||
const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8);
|
||||
bool index_u16 = index_info.format != 0;
|
||||
|
||||
|
@ -338,7 +339,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
if (!texture.enabled)
|
||||
continue;
|
||||
|
||||
u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress());
|
||||
u8* texture_data =
|
||||
VideoCore::g_memory->GetPhysicalPointer(texture.config.GetPhysicalAddress());
|
||||
g_debug_context->recorder->MemoryAccessed(
|
||||
texture_data,
|
||||
Pica::TexturingRegs::NibblesPerPixel(texture.format) * texture.config.width /
|
||||
|
@ -424,8 +426,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
}
|
||||
|
||||
for (auto& range : memory_accesses.ranges) {
|
||||
g_debug_context->recorder->MemoryAccessed(Memory::GetPhysicalPointer(range.first),
|
||||
range.second, range.first);
|
||||
g_debug_context->recorder->MemoryAccessed(
|
||||
VideoCore::g_memory->GetPhysicalPointer(range.first), range.second, range.first);
|
||||
}
|
||||
|
||||
VideoCore::g_renderer->Rasterizer()->DrawTriangles();
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "video_core/renderer_opengl/gl_shader_gen.h"
|
||||
#include "video_core/renderer_opengl/pica_to_gl.h"
|
||||
#include "video_core/renderer_opengl/renderer_opengl.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace OpenGL {
|
||||
|
||||
|
@ -259,7 +260,7 @@ RasterizerOpenGL::VertexArrayInfo RasterizerOpenGL::AnalyzeVertexArray(bool is_i
|
|||
if (is_indexed) {
|
||||
const auto& index_info = regs.pipeline.index_array;
|
||||
PAddr address = vertex_attributes.GetPhysicalBaseAddress() + index_info.offset;
|
||||
const u8* index_address_8 = Memory::GetPhysicalPointer(address);
|
||||
const u8* index_address_8 = VideoCore::g_memory->GetPhysicalPointer(address);
|
||||
const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8);
|
||||
bool index_u16 = index_info.format != 0;
|
||||
|
||||
|
@ -340,7 +341,7 @@ void RasterizerOpenGL::SetupVertexArray(u8* array_ptr, GLintptr buffer_offset,
|
|||
u32 data_size = loader.byte_count * vertex_num;
|
||||
|
||||
res_cache.FlushRegion(data_addr, data_size, nullptr);
|
||||
std::memcpy(array_ptr, Memory::GetPhysicalPointer(data_addr), data_size);
|
||||
std::memcpy(array_ptr, VideoCore::g_memory->GetPhysicalPointer(data_addr), data_size);
|
||||
|
||||
array_ptr += data_size;
|
||||
buffer_offset += data_size;
|
||||
|
@ -471,9 +472,9 @@ bool RasterizerOpenGL::AccelerateDrawBatchInternal(bool is_indexed, bool use_gs)
|
|||
return false;
|
||||
}
|
||||
|
||||
const u8* index_data =
|
||||
Memory::GetPhysicalPointer(regs.pipeline.vertex_attributes.GetPhysicalBaseAddress() +
|
||||
regs.pipeline.index_array.offset);
|
||||
const u8* index_data = VideoCore::g_memory->GetPhysicalPointer(
|
||||
regs.pipeline.vertex_attributes.GetPhysicalBaseAddress() +
|
||||
regs.pipeline.index_array.offset);
|
||||
std::tie(buffer_ptr, buffer_offset, std::ignore) = index_buffer.Map(index_buffer_size, 4);
|
||||
std::memcpy(buffer_ptr, index_data, index_buffer_size);
|
||||
index_buffer.Unmap(index_buffer_size);
|
||||
|
|
|
@ -134,7 +134,7 @@ static void MortonCopy(u32 stride, u32 height, u8* gl_buffer, PAddr base, PAddr
|
|||
}
|
||||
};
|
||||
|
||||
u8* tile_buffer = Memory::GetPhysicalPointer(start);
|
||||
u8* tile_buffer = VideoCore::g_memory->GetPhysicalPointer(start);
|
||||
|
||||
if (start < aligned_start && !morton_to_gl) {
|
||||
std::array<u8, tile_size> tmp_buf;
|
||||
|
@ -625,7 +625,7 @@ MICROPROFILE_DEFINE(OpenGL_SurfaceLoad, "OpenGL", "Surface Load", MP_RGB(128, 19
|
|||
void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
|
||||
ASSERT(type != SurfaceType::Fill);
|
||||
|
||||
const u8* const texture_src_data = Memory::GetPhysicalPointer(addr);
|
||||
const u8* const texture_src_data = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
if (texture_src_data == nullptr)
|
||||
return;
|
||||
|
||||
|
@ -680,7 +680,7 @@ void CachedSurface::LoadGLBuffer(PAddr load_start, PAddr load_end) {
|
|||
|
||||
MICROPROFILE_DEFINE(OpenGL_SurfaceFlush, "OpenGL", "Surface Flush", MP_RGB(128, 192, 64));
|
||||
void CachedSurface::FlushGLBuffer(PAddr flush_start, PAddr flush_end) {
|
||||
u8* const dst_buffer = Memory::GetPhysicalPointer(addr);
|
||||
u8* const dst_buffer = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
if (dst_buffer == nullptr)
|
||||
return;
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ void RendererOpenGL::LoadFBToScreenInfo(const GPU::Regs::FramebufferConfig& fram
|
|||
|
||||
Memory::RasterizerFlushRegion(framebuffer_addr, framebuffer.stride * framebuffer.height);
|
||||
|
||||
const u8* framebuffer_data = Memory::GetPhysicalPointer(framebuffer_addr);
|
||||
const u8* framebuffer_data = VideoCore::g_memory->GetPhysicalPointer(framebuffer_addr);
|
||||
|
||||
state.texture_units[0].texture_2d = screen_info.texture.resource.handle;
|
||||
state.Apply();
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "video_core/regs_framebuffer.h"
|
||||
#include "video_core/swrasterizer/framebuffer.h"
|
||||
#include "video_core/utils.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Pica {
|
||||
namespace Rasterizer {
|
||||
|
@ -31,7 +32,7 @@ void DrawPixel(int x, int y, const Math::Vec4<u8>& color) {
|
|||
GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(framebuffer.color_format.Value()));
|
||||
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) +
|
||||
coarse_y * framebuffer.width * bytes_per_pixel;
|
||||
u8* dst_pixel = Memory::GetPhysicalPointer(addr) + dst_offset;
|
||||
u8* dst_pixel = VideoCore::g_memory->GetPhysicalPointer(addr) + dst_offset;
|
||||
|
||||
switch (framebuffer.color_format) {
|
||||
case FramebufferRegs::ColorFormat::RGBA8:
|
||||
|
@ -72,7 +73,7 @@ const Math::Vec4<u8> GetPixel(int x, int y) {
|
|||
GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(framebuffer.color_format.Value()));
|
||||
u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) +
|
||||
coarse_y * framebuffer.width * bytes_per_pixel;
|
||||
u8* src_pixel = Memory::GetPhysicalPointer(addr) + src_offset;
|
||||
u8* src_pixel = VideoCore::g_memory->GetPhysicalPointer(addr) + src_offset;
|
||||
|
||||
switch (framebuffer.color_format) {
|
||||
case FramebufferRegs::ColorFormat::RGBA8:
|
||||
|
@ -102,7 +103,7 @@ const Math::Vec4<u8> GetPixel(int x, int y) {
|
|||
u32 GetDepth(int x, int y) {
|
||||
const auto& framebuffer = g_state.regs.framebuffer.framebuffer;
|
||||
const PAddr addr = framebuffer.GetDepthBufferPhysicalAddress();
|
||||
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||
u8* depth_buffer = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
|
||||
y = framebuffer.height - y;
|
||||
|
||||
|
@ -131,7 +132,7 @@ u32 GetDepth(int x, int y) {
|
|||
u8 GetStencil(int x, int y) {
|
||||
const auto& framebuffer = g_state.regs.framebuffer.framebuffer;
|
||||
const PAddr addr = framebuffer.GetDepthBufferPhysicalAddress();
|
||||
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||
u8* depth_buffer = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
|
||||
y = framebuffer.height - y;
|
||||
|
||||
|
@ -158,7 +159,7 @@ u8 GetStencil(int x, int y) {
|
|||
void SetDepth(int x, int y, u32 value) {
|
||||
const auto& framebuffer = g_state.regs.framebuffer.framebuffer;
|
||||
const PAddr addr = framebuffer.GetDepthBufferPhysicalAddress();
|
||||
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||
u8* depth_buffer = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
|
||||
y = framebuffer.height - y;
|
||||
|
||||
|
@ -193,7 +194,7 @@ void SetDepth(int x, int y, u32 value) {
|
|||
void SetStencil(int x, int y, u8 value) {
|
||||
const auto& framebuffer = g_state.regs.framebuffer.framebuffer;
|
||||
const PAddr addr = framebuffer.GetDepthBufferPhysicalAddress();
|
||||
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||
u8* depth_buffer = VideoCore::g_memory->GetPhysicalPointer(addr);
|
||||
|
||||
y = framebuffer.height - y;
|
||||
|
||||
|
@ -384,7 +385,7 @@ void DrawShadowMapPixel(int x, int y, u32 depth, u8 stencil) {
|
|||
u32 bytes_per_pixel = 4;
|
||||
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) +
|
||||
coarse_y * framebuffer.width * bytes_per_pixel;
|
||||
u8* dst_pixel = Memory::GetPhysicalPointer(addr) + dst_offset;
|
||||
u8* dst_pixel = VideoCore::g_memory->GetPhysicalPointer(addr) + dst_offset;
|
||||
|
||||
auto ref = DecodeD24S8Shadow(dst_pixel);
|
||||
u32 ref_z = ref.x;
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "video_core/swrasterizer/texturing.h"
|
||||
#include "video_core/texture/texture_decode.h"
|
||||
#include "video_core/utils.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Pica {
|
||||
namespace Rasterizer {
|
||||
|
@ -402,7 +403,8 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
|
|||
t = texture.config.height - 1 -
|
||||
GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
|
||||
|
||||
const u8* texture_data = Memory::GetPhysicalPointer(texture_address);
|
||||
const u8* texture_data =
|
||||
VideoCore::g_memory->GetPhysicalPointer(texture_address);
|
||||
auto info =
|
||||
Texture::TextureInfo::FromPicaRegister(texture.config, texture.format);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include "video_core/regs_pipeline.h"
|
||||
#include "video_core/shader/shader.h"
|
||||
#include "video_core/vertex_loader.h"
|
||||
#include "video_core/video_core.h"
|
||||
|
||||
namespace Pica {
|
||||
|
||||
|
@ -95,32 +96,32 @@ void VertexLoader::LoadVertex(u32 base_address, int index, int vertex,
|
|||
|
||||
switch (vertex_attribute_formats[i]) {
|
||||
case PipelineRegs::VertexAttributeFormat::BYTE: {
|
||||
const s8* srcdata =
|
||||
reinterpret_cast<const s8*>(Memory::GetPhysicalPointer(source_addr));
|
||||
const s8* srcdata = reinterpret_cast<const s8*>(
|
||||
VideoCore::g_memory->GetPhysicalPointer(source_addr));
|
||||
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
||||
input.attr[i][comp] = float24::FromFloat32(srcdata[comp]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PipelineRegs::VertexAttributeFormat::UBYTE: {
|
||||
const u8* srcdata =
|
||||
reinterpret_cast<const u8*>(Memory::GetPhysicalPointer(source_addr));
|
||||
const u8* srcdata = reinterpret_cast<const u8*>(
|
||||
VideoCore::g_memory->GetPhysicalPointer(source_addr));
|
||||
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
||||
input.attr[i][comp] = float24::FromFloat32(srcdata[comp]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PipelineRegs::VertexAttributeFormat::SHORT: {
|
||||
const s16* srcdata =
|
||||
reinterpret_cast<const s16*>(Memory::GetPhysicalPointer(source_addr));
|
||||
const s16* srcdata = reinterpret_cast<const s16*>(
|
||||
VideoCore::g_memory->GetPhysicalPointer(source_addr));
|
||||
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
||||
input.attr[i][comp] = float24::FromFloat32(srcdata[comp]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case PipelineRegs::VertexAttributeFormat::FLOAT: {
|
||||
const float* srcdata =
|
||||
reinterpret_cast<const float*>(Memory::GetPhysicalPointer(source_addr));
|
||||
const float* srcdata = reinterpret_cast<const float*>(
|
||||
VideoCore::g_memory->GetPhysicalPointer(source_addr));
|
||||
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
||||
input.attr[i][comp] = float24::FromFloat32(srcdata[comp]);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue