diff options
| author | 2015-05-09 15:57:29 +0200 | |
|---|---|---|
| committer | 2015-05-09 15:57:29 +0200 | |
| commit | e35e72d0a5c90c37d22328115fa0f29dd17aeaee (patch) | |
| tree | 4053db2c53a1ac77294c03782de75c91c0cf4b27 /src/video_core | |
| parent | Loader: Add missing include (diff) | |
| parent | Memory: Add GetPhysicalPointer helper function (diff) | |
| download | yuzu-e35e72d0a5c90c37d22328115fa0f29dd17aeaee.tar.gz yuzu-e35e72d0a5c90c37d22328115fa0f29dd17aeaee.tar.xz yuzu-e35e72d0a5c90c37d22328115fa0f29dd17aeaee.zip | |
Merge pull request #734 from yuriks/memmap
Small memory map definitions cleanup
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/command_processor.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/pica.h | 11 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 10 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 8 |
4 files changed, 11 insertions, 22 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index c4cdf672b..1ea7cad07 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -102,7 +102,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 102 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); | 102 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); |
| 103 | 103 | ||
| 104 | const auto& index_info = registers.index_array; | 104 | const auto& index_info = registers.index_array; |
| 105 | const u8* index_address_8 = Memory::GetPointer(PAddrToVAddr(base_address + index_info.offset)); | 105 | const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset); |
| 106 | const u16* index_address_16 = (u16*)index_address_8; | 106 | const u16* index_address_16 = (u16*)index_address_8; |
| 107 | bool index_u16 = index_info.format != 0; | 107 | bool index_u16 = index_info.format != 0; |
| 108 | 108 | ||
| @@ -135,7 +135,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 135 | input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); | 135 | input.attr[i][2].ToFloat32(), input.attr[i][3].ToFloat32()); |
| 136 | } else { | 136 | } else { |
| 137 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { | 137 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { |
| 138 | const u8* srcdata = Memory::GetPointer(PAddrToVAddr(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i])); | 138 | const u8* srcdata = Memory::GetPhysicalPointer(vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]); |
| 139 | 139 | ||
| 140 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : | 140 | const float srcval = (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::BYTE) ? *(s8*)srcdata : |
| 141 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : | 141 | (vertex_attribute_formats[i] == Regs::VertexAttributeFormat::UBYTE) ? *(u8*)srcdata : |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index a0ba715f3..e4a91058c 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -998,15 +998,4 @@ union CommandHeader { | |||
| 998 | BitField<31, 1, u32> group_commands; | 998 | BitField<31, 1, u32> group_commands; |
| 999 | }; | 999 | }; |
| 1000 | 1000 | ||
| 1001 | // TODO: Ugly, should fix PhysicalToVirtualAddress instead | ||
| 1002 | inline static u32 PAddrToVAddr(u32 addr) { | ||
| 1003 | if (addr >= Memory::VRAM_PADDR && addr < Memory::VRAM_PADDR + Memory::VRAM_SIZE) { | ||
| 1004 | return addr - Memory::VRAM_PADDR + Memory::VRAM_VADDR; | ||
| 1005 | } else if (addr >= Memory::FCRAM_PADDR && addr < Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) { | ||
| 1006 | return addr - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; | ||
| 1007 | } else { | ||
| 1008 | return 0; | ||
| 1009 | } | ||
| 1010 | } | ||
| 1011 | |||
| 1012 | } // namespace | 1001 | } // namespace |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 6ec253601..3b3fef484 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -30,7 +30,7 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | |||
| 30 | const u32 coarse_y = y & ~7; | 30 | const u32 coarse_y = y & ~7; |
| 31 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value())); | 31 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value())); |
| 32 | u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel; | 32 | u32 dst_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel; |
| 33 | u8* dst_pixel = Memory::GetPointer(PAddrToVAddr(addr)) + dst_offset; | 33 | u8* dst_pixel = Memory::GetPhysicalPointer(addr) + dst_offset; |
| 34 | 34 | ||
| 35 | switch (registers.framebuffer.color_format) { | 35 | switch (registers.framebuffer.color_format) { |
| 36 | case registers.framebuffer.RGBA8: | 36 | case registers.framebuffer.RGBA8: |
| @@ -67,7 +67,7 @@ static const Math::Vec4<u8> GetPixel(int x, int y) { | |||
| 67 | const u32 coarse_y = y & ~7; | 67 | const u32 coarse_y = y & ~7; |
| 68 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value())); | 68 | u32 bytes_per_pixel = GPU::Regs::BytesPerPixel(GPU::Regs::PixelFormat(registers.framebuffer.color_format.Value())); |
| 69 | u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel; | 69 | u32 src_offset = VideoCore::GetMortonOffset(x, y, bytes_per_pixel) + coarse_y * registers.framebuffer.width * bytes_per_pixel; |
| 70 | u8* src_pixel = Memory::GetPointer(PAddrToVAddr(addr)) + src_offset; | 70 | u8* src_pixel = Memory::GetPhysicalPointer(addr) + src_offset; |
| 71 | 71 | ||
| 72 | switch (registers.framebuffer.color_format) { | 72 | switch (registers.framebuffer.color_format) { |
| 73 | case registers.framebuffer.RGBA8: | 73 | case registers.framebuffer.RGBA8: |
| @@ -95,7 +95,7 @@ static const Math::Vec4<u8> GetPixel(int x, int y) { | |||
| 95 | 95 | ||
| 96 | static u32 GetDepth(int x, int y) { | 96 | static u32 GetDepth(int x, int y) { |
| 97 | const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress(); | 97 | const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress(); |
| 98 | u8* depth_buffer = Memory::GetPointer(PAddrToVAddr(addr)); | 98 | u8* depth_buffer = Memory::GetPhysicalPointer(addr); |
| 99 | 99 | ||
| 100 | y = (registers.framebuffer.height - y); | 100 | y = (registers.framebuffer.height - y); |
| 101 | 101 | ||
| @@ -122,7 +122,7 @@ static u32 GetDepth(int x, int y) { | |||
| 122 | 122 | ||
| 123 | static void SetDepth(int x, int y, u32 value) { | 123 | static void SetDepth(int x, int y, u32 value) { |
| 124 | const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress(); | 124 | const PAddr addr = registers.framebuffer.GetDepthBufferPhysicalAddress(); |
| 125 | u8* depth_buffer = Memory::GetPointer(PAddrToVAddr(addr)); | 125 | u8* depth_buffer = Memory::GetPhysicalPointer(addr); |
| 126 | 126 | ||
| 127 | y = (registers.framebuffer.height - y); | 127 | y = (registers.framebuffer.height - y); |
| 128 | 128 | ||
| @@ -361,7 +361,7 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, | |||
| 361 | s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width); | 361 | s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width); |
| 362 | t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height); | 362 | t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height); |
| 363 | 363 | ||
| 364 | u8* texture_data = Memory::GetPointer(PAddrToVAddr(texture.config.GetPhysicalAddress())); | 364 | u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress()); |
| 365 | auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); | 365 | auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); |
| 366 | 366 | ||
| 367 | texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); | 367 | texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 6b242a6ed..0c072120d 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -119,15 +119,15 @@ void RendererOpenGL::SwapBuffers() { | |||
| 119 | void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer, | 119 | void RendererOpenGL::LoadFBToActiveGLTexture(const GPU::Regs::FramebufferConfig& framebuffer, |
| 120 | const TextureInfo& texture) { | 120 | const TextureInfo& texture) { |
| 121 | 121 | ||
| 122 | const VAddr framebuffer_vaddr = Memory::PhysicalToVirtualAddress( | 122 | const PAddr framebuffer_addr = framebuffer.active_fb == 0 ? |
| 123 | framebuffer.active_fb == 0 ? framebuffer.address_left1 : framebuffer.address_left2); | 123 | framebuffer.address_left1 : framebuffer.address_left2; |
| 124 | 124 | ||
| 125 | LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x", | 125 | LOG_TRACE(Render_OpenGL, "0x%08x bytes from 0x%08x(%dx%d), fmt %x", |
| 126 | framebuffer.stride * framebuffer.height, | 126 | framebuffer.stride * framebuffer.height, |
| 127 | framebuffer_vaddr, (int)framebuffer.width, | 127 | framebuffer_addr, (int)framebuffer.width, |
| 128 | (int)framebuffer.height, (int)framebuffer.format); | 128 | (int)framebuffer.height, (int)framebuffer.format); |
| 129 | 129 | ||
| 130 | const u8* framebuffer_data = Memory::GetPointer(framebuffer_vaddr); | 130 | const u8* framebuffer_data = Memory::GetPhysicalPointer(framebuffer_addr); |
| 131 | 131 | ||
| 132 | int bpp = GPU::Regs::BytesPerPixel(framebuffer.color_format); | 132 | int bpp = GPU::Regs::BytesPerPixel(framebuffer.color_format); |
| 133 | size_t pixel_stride = framebuffer.stride / bpp; | 133 | size_t pixel_stride = framebuffer.stride / bpp; |