mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-20 09:19:58 +00:00
Memory: Add GetPhysicalPointer helper function
This commit is contained in:
parent
28a9e4c1d5
commit
17a8cae003
7 changed files with 28 additions and 19 deletions
|
@ -159,7 +159,7 @@ void TextureInfoDockWidget::OnStrideChanged(int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QPixmap TextureInfoDockWidget::ReloadPixmap() const {
|
QPixmap TextureInfoDockWidget::ReloadPixmap() const {
|
||||||
u8* src = Memory::GetPointer(Memory::PhysicalToVirtualAddress(info.physical_address));
|
u8* src = Memory::GetPhysicalPointer(info.physical_address);
|
||||||
return QPixmap::fromImage(LoadTexture(src, info));
|
return QPixmap::fromImage(LoadTexture(src, info));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ void GPUCommandListWidget::SetCommandInfo(const QModelIndex& index) {
|
||||||
auto format = Pica::registers.GetTextures()[index].format;
|
auto format = Pica::registers.GetTextures()[index].format;
|
||||||
|
|
||||||
auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format);
|
auto info = Pica::DebugUtils::TextureInfo::FromPicaRegister(config, format);
|
||||||
u8* src = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalAddress()));
|
u8* src = Memory::GetPhysicalPointer(config.GetPhysicalAddress());
|
||||||
new_info_widget = new TextureInfoWidget(src, info);
|
new_info_widget = new TextureInfoWidget(src, info);
|
||||||
} else {
|
} else {
|
||||||
new_info_widget = new QWidget;
|
new_info_widget = new QWidget;
|
||||||
|
|
|
@ -215,7 +215,7 @@ void GraphicsFramebufferWidget::OnUpdate()
|
||||||
u32 bytes_per_pixel = GraphicsFramebufferWidget::BytesPerPixel(framebuffer_format);
|
u32 bytes_per_pixel = GraphicsFramebufferWidget::BytesPerPixel(framebuffer_format);
|
||||||
|
|
||||||
QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32);
|
QImage decoded_image(framebuffer_width, framebuffer_height, QImage::Format_ARGB32);
|
||||||
u8* buffer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(framebuffer_address));
|
u8* buffer = Memory::GetPhysicalPointer(framebuffer_address);
|
||||||
|
|
||||||
for (unsigned int y = 0; y < framebuffer_height; ++y) {
|
for (unsigned int y = 0; y < framebuffer_height; ++y) {
|
||||||
for (unsigned int x = 0; x < framebuffer_width; ++x) {
|
for (unsigned int x = 0; x < framebuffer_width; ++x) {
|
||||||
|
|
|
@ -76,8 +76,8 @@ inline void Write(u32 addr, const T data) {
|
||||||
auto& config = g_regs.memory_fill_config[is_second_filler];
|
auto& config = g_regs.memory_fill_config[is_second_filler];
|
||||||
|
|
||||||
if (config.address_start && config.trigger) {
|
if (config.address_start && config.trigger) {
|
||||||
u8* start = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetStartAddress()));
|
u8* start = Memory::GetPhysicalPointer(config.GetStartAddress());
|
||||||
u8* end = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetEndAddress()));
|
u8* end = Memory::GetPhysicalPointer(config.GetEndAddress());
|
||||||
|
|
||||||
if (config.fill_24bit) {
|
if (config.fill_24bit) {
|
||||||
// fill with 24-bit values
|
// fill with 24-bit values
|
||||||
|
@ -114,8 +114,8 @@ inline void Write(u32 addr, const T data) {
|
||||||
{
|
{
|
||||||
const auto& config = g_regs.display_transfer_config;
|
const auto& config = g_regs.display_transfer_config;
|
||||||
if (config.trigger & 1) {
|
if (config.trigger & 1) {
|
||||||
u8* src_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalInputAddress()));
|
u8* src_pointer = Memory::GetPhysicalPointer(config.GetPhysicalInputAddress());
|
||||||
u8* dst_pointer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalOutputAddress()));
|
u8* dst_pointer = Memory::GetPhysicalPointer(config.GetPhysicalOutputAddress());
|
||||||
|
|
||||||
if (config.scaling > config.ScaleXY) {
|
if (config.scaling > config.ScaleXY) {
|
||||||
LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u", config.scaling.Value());
|
LOG_CRITICAL(HW_GPU, "Unimplemented display transfer scaling mode %u", config.scaling.Value());
|
||||||
|
@ -257,7 +257,7 @@ inline void Write(u32 addr, const T data) {
|
||||||
const auto& config = g_regs.command_processor_config;
|
const auto& config = g_regs.command_processor_config;
|
||||||
if (config.trigger & 1)
|
if (config.trigger & 1)
|
||||||
{
|
{
|
||||||
u32* buffer = (u32*)Memory::GetPointer(Memory::PhysicalToVirtualAddress(config.GetPhysicalAddress()));
|
u32* buffer = (u32*)Memory::GetPhysicalPointer(config.GetPhysicalAddress());
|
||||||
Pica::CommandProcessor::ProcessCommandList(buffer, config.size);
|
Pica::CommandProcessor::ProcessCommandList(buffer, config.size);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -192,4 +192,13 @@ PAddr VirtualToPhysicalAddress(VAddr addr);
|
||||||
*/
|
*/
|
||||||
VAddr PhysicalToVirtualAddress(PAddr addr);
|
VAddr PhysicalToVirtualAddress(PAddr addr);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a pointer to the memory region beginning at the specified physical address.
|
||||||
|
*
|
||||||
|
* @note This is currently implemented using PhysicalToVirtualAddress().
|
||||||
|
*/
|
||||||
|
inline u8* GetPhysicalPointer(PAddr address) {
|
||||||
|
return GetPointer(PhysicalToVirtualAddress(address));
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -102,7 +102,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
|
||||||
bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed));
|
bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed));
|
||||||
|
|
||||||
const auto& index_info = registers.index_array;
|
const auto& index_info = registers.index_array;
|
||||||
const u8* index_address_8 = Memory::GetPointer(Memory::PhysicalToVirtualAddress(base_address + index_info.offset));
|
const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset);
|
||||||
const u16* index_address_16 = (u16*)index_address_8;
|
const u16* index_address_16 = (u16*)index_address_8;
|
||||||
bool index_u16 = index_info.format != 0;
|
bool index_u16 = index_info.format != 0;
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) {
|
||||||
input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32());
|
input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32());
|
||||||
} else {
|
} else {
|
||||||
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) {
|
||||||
const u8* srcdata = Memory::GetPointer(Memory::PhysicalToVirtualAddress(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]));
|
const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]);
|
||||||
|
|
||||||
const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata :
|
const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata :
|
||||||
(vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata :
|
(vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata :
|
||||||
|
|
|
@ -30,7 +30,7 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) {
|
||||||
const u32 coarse_y = y & ~7;
|
const u32 coarse_y = y & ~7;
|
||||||
u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value()));
|
u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value()));
|
||||||
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel;
|
u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel;
|
||||||
u8* dst_pixel = Memory::GetPointer(Memory::PhysicalToVirtualAddress(addr)) + dst_offset;
|
u8* dst_pixel = Memory::GetPhysicalPointer(addr) + dst_offset;
|
||||||
|
|
||||||
switch (registers.framebuffer.color_format) {
|
switch (registers.framebuffer.color_format) {
|
||||||
case registers.framebuffer.RGBA8:
|
case registers.framebuffer.RGBA8:
|
||||||
|
@ -67,7 +67,7 @@ static const Math::Vec4<u8> GetPixel(int x, int y) {
|
||||||
const u32 coarse_y = y & ~7;
|
const u32 coarse_y = y & ~7;
|
||||||
u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value()));
|
u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value()));
|
||||||
u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel;
|
u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel;
|
||||||
u8* src_pixel = Memory::GetPointer(Memory::PhysicalToVirtualAddress(addr)) + src_offset;
|
u8* src_pixel = Memory::GetPhysicalPointer(addr) + src_offset;
|
||||||
|
|
||||||
switch (registers.framebuffer.color_format) {
|
switch (registers.framebuffer.color_format) {
|
||||||
case registers.framebuffer.RGBA8:
|
case registers.framebuffer.RGBA8:
|
||||||
|
@ -95,7 +95,7 @@ static const Math::Vec4<u8> GetPixel(int x, int y) {
|
||||||
|
|
||||||
static u32 GetDepth(int x, int y) {
|
static u32 GetDepth(int x, int y) {
|
||||||
const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress();
|
const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress();
|
||||||
u8* depth_buffer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(addr));
|
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||||
|
|
||||||
y = (registers.framebuffer.height - y);
|
y = (registers.framebuffer.height - y);
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ static u32 GetDepth(int x, int y) {
|
||||||
|
|
||||||
static void SetDepth(int x, int y, u32 value) {
|
static void SetDepth(int x, int y, u32 value) {
|
||||||
const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress();
|
const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress();
|
||||||
u8* depth_buffer = Memory::GetPointer(Memory::PhysicalToVirtualAddress(addr));
|
u8* depth_buffer = Memory::GetPhysicalPointer(addr);
|
||||||
|
|
||||||
y = (registers.framebuffer.height - y);
|
y = (registers.framebuffer.height - y);
|
||||||
|
|
||||||
|
@ -361,7 +361,7 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
|
||||||
s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width);
|
s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width);
|
||||||
t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
|
t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height);
|
||||||
|
|
||||||
u8* texture_data = Memory::GetPointer(Memory::PhysicalToVirtualAddress(texture.config.GetPhysicalAddress()));
|
u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress());
|
||||||
auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format);
|
auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format);
|
||||||
|
|
||||||
texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info);
|
texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info);
|
||||||
|
|
|
@ -119,15 +119,15 @@ void RendererOpenGL::SwapBuffers() {
|
||||||
void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
|
void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer,
|
||||||
const TextureInfo& texture) {
|
const TextureInfo& texture) {
|
||||||
|
|
||||||
const VAddr framebuffer_vaddr = Memory::PhysicalToVirtualAddress(
|
const PAddr framebuffer_addr = framebuffer.active_fb == 0 ?
|
||||||
framebuffer.active_fb == 0 ? framebuffer.address_left1 : framebuffer.address_left2);
|
framebuffer.address_left1 : framebuffer.address_left2;
|
||||||
|
|
||||||
LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x",
|
LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x",
|
||||||
framebuffer.stride * framebuffer.height,
|
framebuffer.stride * framebuffer.height,
|
||||||
framebuffer_vaddr, (int)framebuffer.width,
|
framebuffer_addr, (int)framebuffer.width,
|
||||||
(int)framebuffer.height, (int)framebuffer.format);
|
(int)framebuffer.height, (int)framebuffer.format);
|
||||||
|
|
||||||
const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr);
|
const u8* framebuffer_data = Memory::GetPhysicalPointer(framebuffer_addr);
|
||||||
|
|
||||||
int bpp = GPU::Regs::BytesPerPixel(framebuffer.color_format);
|
int bpp = GPU::Regs::BytesPerPixel(framebuffer.color_format);
|
||||||
size_t pixel_stride = framebuffer.stride / bpp;
|
size_t pixel_stride = framebuffer.stride / bpp;
|
||||||
|
|
Loading…
Reference in a new issue