summaryrefslogtreecommitdiff
path: root/src/video_core
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2015-05-09 03:08:11 -0300
committerGravatar Yuri Kunde Schlesner2015-05-09 03:08:11 -0300
commit28a9e4c1d55c66e99b5cf16fda00dcb75ab27fde (patch)
tree9c40b519bff8a84c948b9343367763781cb64454 /src/video_core
parentMemory: Sort memory region variables by VAddr (diff)
downloadyuzu-28a9e4c1d55c66e99b5cf16fda00dcb75ab27fde.tar.gz
yuzu-28a9e4c1d55c66e99b5cf16fda00dcb75ab27fde.tar.xz
yuzu-28a9e4c1d55c66e99b5cf16fda00dcb75ab27fde.zip
Memory: Support more regions in the VAddr-PAddr translation functions
Also adds better documentation and removes the one-off reimplementation of the function in pica.h.
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/command_processor.cpp4
-rw-r--r--src/video_core/pica.h11
-rw-r--r--src/video_core/rasterizer.cpp10
3 files changed, 7 insertions, 18 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp
index c4cdf672b..7c4047e33 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::GetPointer(Memory::PhysicalToVirtualAddress(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::GetPointer(Memory::PhysicalToVirtualAddress(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 4c48b6bf7..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
1002inline 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::LINEAR_HEAP_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..ab7776929 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::GetPointer(Memory::PhysicalToVirtualAddress(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::GetPointer(Memory::PhysicalToVirtualAddress(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
96static u32 GetDepth(int x, int y) { 96static 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::GetPointer(Memory::PhysicalToVirtualAddress(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
123static void SetDepth(int x, int y, u32 value) { 123static 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::GetPointer(Memory::PhysicalToVirtualAddress(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::GetPointer(Memory::PhysicalToVirtualAddress(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);