diff options
| author | 2014-12-15 21:28:45 +0100 | |
|---|---|---|
| committer | 2014-12-20 18:06:53 +0100 | |
| commit | 40f123b7c0eaf1507d51f6b87192ec2f956e5d5e (patch) | |
| tree | 7f87847435d510ed0e70a10cd67129a3b2511335 /src/video_core | |
| parent | Pica: Further improve Tev emulation. (diff) | |
| download | yuzu-40f123b7c0eaf1507d51f6b87192ec2f956e5d5e.tar.gz yuzu-40f123b7c0eaf1507d51f6b87192ec2f956e5d5e.tar.xz yuzu-40f123b7c0eaf1507d51f6b87192ec2f956e5d5e.zip | |
Pica: Unify ugly address translation hacks.
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/command_processor.cpp | 4 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.h | 2 | ||||
| -rw-r--r-- | src/video_core/pica.h | 25 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 8 |
5 files changed, 25 insertions, 16 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index b74cd3261..3d06ac7e6 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -56,7 +56,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 56 | g_debug_context->OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr); | 56 | g_debug_context->OnEvent(DebugContext::Event::IncomingPrimitiveBatch, nullptr); |
| 57 | 57 | ||
| 58 | const auto& attribute_config = registers.vertex_attributes; | 58 | const auto& attribute_config = registers.vertex_attributes; |
| 59 | const u8* const base_address = Memory::GetPointer(attribute_config.GetBaseAddress()); | 59 | const u8* const base_address = Memory::GetPointer(PAddrToVAddr(attribute_config.GetPhysicalBaseAddress())); |
| 60 | 60 | ||
| 61 | // Information about internal vertex attributes | 61 | // Information about internal vertex attributes |
| 62 | const u8* vertex_attribute_sources[16]; | 62 | const u8* vertex_attribute_sources[16]; |
| @@ -116,7 +116,7 @@ static inline void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 116 | input.attr[i][comp] = float24::FromFloat32(srcval); | 116 | input.attr[i][comp] = float24::FromFloat32(srcval); |
| 117 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", | 117 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08lx + 0x%04lx: %f", |
| 118 | comp, i, vertex, index, | 118 | comp, i, vertex, index, |
| 119 | attribute_config.GetBaseAddress(), | 119 | PAddrToVAddr(attribute_config.GetPhysicalBaseAddress()), |
| 120 | vertex_attribute_sources[i] - base_address, | 120 | vertex_attribute_sources[i] - base_address, |
| 121 | srcdata - vertex_attribute_sources[i], | 121 | srcdata - vertex_attribute_sources[i], |
| 122 | input.attr[i][comp].ToFloat32()); | 122 | input.attr[i][comp].ToFloat32()); |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 3cc22f436..08ecd4ccb 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -455,7 +455,7 @@ TextureInfo TextureInfo::FromPicaRegister(const Regs::TextureConfig& config, | |||
| 455 | const Regs::TextureFormat& format) | 455 | const Regs::TextureFormat& format) |
| 456 | { | 456 | { |
| 457 | TextureInfo info; | 457 | TextureInfo info; |
| 458 | info.address = config.GetPhysicalAddress(); | 458 | info.physical_address = config.GetPhysicalAddress(); |
| 459 | info.width = config.width; | 459 | info.width = config.width; |
| 460 | info.height = config.height; | 460 | info.height = config.height; |
| 461 | info.format = format; | 461 | info.format = format; |
diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index f950356f3..2a764e121 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h | |||
| @@ -192,7 +192,7 @@ void OnPicaRegWrite(u32 id, u32 value); | |||
| 192 | std::unique_ptr<PicaTrace> FinishPicaTracing(); | 192 | std::unique_ptr<PicaTrace> FinishPicaTracing(); |
| 193 | 193 | ||
| 194 | struct TextureInfo { | 194 | struct TextureInfo { |
| 195 | unsigned int address; | 195 | PAddr physical_address; |
| 196 | int width; | 196 | int width; |
| 197 | int height; | 197 | int height; |
| 198 | int stride; | 198 | int stride; |
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 5712439e1..7d82d733d 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -127,7 +127,7 @@ struct Regs { | |||
| 127 | u32 address; | 127 | u32 address; |
| 128 | 128 | ||
| 129 | u32 GetPhysicalAddress() const { | 129 | u32 GetPhysicalAddress() const { |
| 130 | return DecodeAddressRegister(address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; | 130 | return DecodeAddressRegister(address); |
| 131 | } | 131 | } |
| 132 | 132 | ||
| 133 | // texture1 and texture2 store the texture format directly after the address | 133 | // texture1 and texture2 store the texture format directly after the address |
| @@ -317,11 +317,11 @@ struct Regs { | |||
| 317 | 317 | ||
| 318 | INSERT_PADDING_WORDS(0x1); | 318 | INSERT_PADDING_WORDS(0x1); |
| 319 | 319 | ||
| 320 | inline u32 GetColorBufferAddress() const { | 320 | inline u32 GetColorBufferPhysicalAddress() const { |
| 321 | return Memory::PhysicalToVirtualAddress(DecodeAddressRegister(color_buffer_address)); | 321 | return DecodeAddressRegister(color_buffer_address); |
| 322 | } | 322 | } |
| 323 | inline u32 GetDepthBufferAddress() const { | 323 | inline u32 GetDepthBufferPhysicalAddress() const { |
| 324 | return Memory::PhysicalToVirtualAddress(DecodeAddressRegister(depth_buffer_address)); | 324 | return DecodeAddressRegister(depth_buffer_address); |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | inline u32 GetWidth() const { | 327 | inline u32 GetWidth() const { |
| @@ -345,9 +345,8 @@ struct Regs { | |||
| 345 | 345 | ||
| 346 | BitField<0, 29, u32> base_address; | 346 | BitField<0, 29, u32> base_address; |
| 347 | 347 | ||
| 348 | inline u32 GetBaseAddress() const { | 348 | u32 GetPhysicalBaseAddress() const { |
| 349 | // TODO: Ugly, should fix PhysicalToVirtualAddress instead | 349 | return DecodeAddressRegister(base_address); |
| 350 | return DecodeAddressRegister(base_address) - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; | ||
| 351 | } | 350 | } |
| 352 | 351 | ||
| 353 | // Descriptor for internal vertex attributes | 352 | // Descriptor for internal vertex attributes |
| @@ -779,5 +778,15 @@ union CommandHeader { | |||
| 779 | BitField<31, 1, u32> group_commands; | 778 | BitField<31, 1, u32> group_commands; |
| 780 | }; | 779 | }; |
| 781 | 780 | ||
| 781 | // TODO: Ugly, should fix PhysicalToVirtualAddress instead | ||
| 782 | inline static u32 PAddrToVAddr(u32 addr) { | ||
| 783 | if (addr >= Memory::VRAM_PADDR && addr < Memory::VRAM_PADDR + Memory::VRAM_SIZE) { | ||
| 784 | return addr - Memory::VRAM_PADDR + Memory::VRAM_VADDR; | ||
| 785 | } else if (addr >= Memory::FCRAM_PADDR && addr < Memory::FCRAM_PADDR + Memory::FCRAM_SIZE) { | ||
| 786 | return addr - Memory::FCRAM_PADDR + Memory::HEAP_LINEAR_VADDR; | ||
| 787 | } else { | ||
| 788 | return 0; | ||
| 789 | } | ||
| 790 | } | ||
| 782 | 791 | ||
| 783 | } // namespace | 792 | } // namespace |
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 25efd49c8..bd79e4413 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp | |||
| @@ -18,7 +18,7 @@ namespace Pica { | |||
| 18 | namespace Rasterizer { | 18 | namespace Rasterizer { |
| 19 | 19 | ||
| 20 | static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | 20 | static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { |
| 21 | u32* color_buffer = (u32*)Memory::GetPointer(registers.framebuffer.GetColorBufferAddress()); | 21 | u32* color_buffer = (u32*)Memory::GetPointer(PAddrToVAddr(registers.framebuffer.GetColorBufferPhysicalAddress())); |
| 22 | u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b(); | 22 | u32 value = (color.a() << 24) | (color.r() << 16) | (color.g() << 8) | color.b(); |
| 23 | 23 | ||
| 24 | // Assuming RGBA8 format until actual framebuffer format handling is implemented | 24 | // Assuming RGBA8 format until actual framebuffer format handling is implemented |
| @@ -26,14 +26,14 @@ static void DrawPixel(int x, int y, const Math::Vec4<u8>& color) { | |||
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | static u32 GetDepth(int x, int y) { | 28 | static u32 GetDepth(int x, int y) { |
| 29 | u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); | 29 | u16* depth_buffer = (u16*)Memory::GetPointer(PAddrToVAddr(registers.framebuffer.GetDepthBufferPhysicalAddress())); |
| 30 | 30 | ||
| 31 | // Assuming 16-bit depth buffer format until actual format handling is implemented | 31 | // Assuming 16-bit depth buffer format until actual format handling is implemented |
| 32 | return *(depth_buffer + x + y * registers.framebuffer.GetWidth()); | 32 | return *(depth_buffer + x + y * registers.framebuffer.GetWidth()); |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | static void SetDepth(int x, int y, u16 value) { | 35 | static void SetDepth(int x, int y, u16 value) { |
| 36 | u16* depth_buffer = (u16*)Memory::GetPointer(registers.framebuffer.GetDepthBufferAddress()); | 36 | u16* depth_buffer = (u16*)Memory::GetPointer(PAddrToVAddr(registers.framebuffer.GetDepthBufferPhysicalAddress())); |
| 37 | 37 | ||
| 38 | // Assuming 16-bit depth buffer format until actual format handling is implemented | 38 | // Assuming 16-bit depth buffer format until actual format handling is implemented |
| 39 | *(depth_buffer + x + y * registers.framebuffer.GetWidth()) = value; | 39 | *(depth_buffer + x + y * registers.framebuffer.GetWidth()) = value; |
| @@ -204,7 +204,7 @@ void ProcessTriangle(const VertexShader::OutputVertex& v0, | |||
| 204 | s = GetWrappedTexCoord(registers.texture0.wrap_s, s, registers.texture0.width); | 204 | s = GetWrappedTexCoord(registers.texture0.wrap_s, s, registers.texture0.width); |
| 205 | t = GetWrappedTexCoord(registers.texture0.wrap_t, t, registers.texture0.height); | 205 | t = GetWrappedTexCoord(registers.texture0.wrap_t, t, registers.texture0.height); |
| 206 | 206 | ||
| 207 | u8* texture_data = Memory::GetPointer(texture.config.GetPhysicalAddress()); | 207 | u8* texture_data = Memory::GetPointer(PAddrToVAddr(texture.config.GetPhysicalAddress())); |
| 208 | auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); | 208 | auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); |
| 209 | 209 | ||
| 210 | texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); | 210 | texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); |