diff options
| author | 2016-04-28 20:17:35 +0200 | |
|---|---|---|
| committer | 2016-04-28 20:17:35 +0200 | |
| commit | 2403e86cbb5c49afeceb98f7c6e843da78dff415 (patch) | |
| tree | e50eecedf62fd47638bf603eb334161d72871021 | |
| parent | Move "&" to their proper place, add missing includes and make some properly r... (diff) | |
| download | yuzu-2403e86cbb5c49afeceb98f7c6e843da78dff415.tar.gz yuzu-2403e86cbb5c49afeceb98f7c6e843da78dff415.tar.xz yuzu-2403e86cbb5c49afeceb98f7c6e843da78dff415.zip | |
Don't keep base_address in the loader, it doesn't belong there (with it, the loader can't be cached).
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/command_processor.cpp | 7 | ||||
| -rw-r--r-- | src/video_core/vertex_loader.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/vertex_loader.h | 5 |
3 files changed, 10 insertions, 11 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 8c3e982a3..373fb51ad 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -199,13 +199,14 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 199 | // Processes information about internal vertex attributes to figure out how a vertex is loaded. | 199 | // Processes information about internal vertex attributes to figure out how a vertex is loaded. |
| 200 | // Later, these can be compiled and cached. | 200 | // Later, these can be compiled and cached. |
| 201 | VertexLoader loader; | 201 | VertexLoader loader; |
| 202 | const u32 base_address = regs.vertex_attributes.GetPhysicalBaseAddress(); | ||
| 202 | loader.Setup(regs); | 203 | loader.Setup(regs); |
| 203 | 204 | ||
| 204 | // Load vertices | 205 | // Load vertices |
| 205 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); | 206 | bool is_indexed = (id == PICA_REG_INDEX(trigger_draw_indexed)); |
| 206 | 207 | ||
| 207 | const auto& index_info = regs.index_array; | 208 | const auto& index_info = regs.index_array; |
| 208 | const u8* index_address_8 = Memory::GetPhysicalPointer(loader.GetPhysicalBaseAddress() + index_info.offset); | 209 | const u8* index_address_8 = Memory::GetPhysicalPointer(base_address + index_info.offset); |
| 209 | const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8); | 210 | const u16* index_address_16 = reinterpret_cast<const u16*>(index_address_8); |
| 210 | bool index_u16 = index_info.format != 0; | 211 | bool index_u16 = index_info.format != 0; |
| 211 | 212 | ||
| @@ -252,7 +253,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 252 | if (is_indexed) { | 253 | if (is_indexed) { |
| 253 | if (g_debug_context && Pica::g_debug_context->recorder) { | 254 | if (g_debug_context && Pica::g_debug_context->recorder) { |
| 254 | int size = index_u16 ? 2 : 1; | 255 | int size = index_u16 ? 2 : 1; |
| 255 | memory_accesses.AddAccess(loader.GetPhysicalBaseAddress() + index_info.offset + size * index, size); | 256 | memory_accesses.AddAccess(base_address + index_info.offset + size * index, size); |
| 256 | } | 257 | } |
| 257 | 258 | ||
| 258 | for (unsigned int i = 0; i < VERTEX_CACHE_SIZE; ++i) { | 259 | for (unsigned int i = 0; i < VERTEX_CACHE_SIZE; ++i) { |
| @@ -267,7 +268,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 267 | if (!vertex_cache_hit) { | 268 | if (!vertex_cache_hit) { |
| 268 | // Initialize data for the current vertex | 269 | // Initialize data for the current vertex |
| 269 | Shader::InputVertex input; | 270 | Shader::InputVertex input; |
| 270 | loader.LoadVertex(index, vertex, input, memory_accesses); | 271 | loader.LoadVertex(base_address, index, vertex, input, memory_accesses); |
| 271 | 272 | ||
| 272 | if (g_debug_context) | 273 | if (g_debug_context) |
| 273 | g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); | 274 | g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&input); |
diff --git a/src/video_core/vertex_loader.cpp b/src/video_core/vertex_loader.cpp index 958201e5e..c2630d9eb 100644 --- a/src/video_core/vertex_loader.cpp +++ b/src/video_core/vertex_loader.cpp | |||
| @@ -23,7 +23,6 @@ namespace Pica { | |||
| 23 | 23 | ||
| 24 | void VertexLoader::Setup(const Pica::Regs& regs) { | 24 | void VertexLoader::Setup(const Pica::Regs& regs) { |
| 25 | const auto& attribute_config = regs.vertex_attributes; | 25 | const auto& attribute_config = regs.vertex_attributes; |
| 26 | base_address = attribute_config.GetPhysicalBaseAddress(); | ||
| 27 | num_total_attributes = attribute_config.GetNumTotalAttributes(); | 26 | num_total_attributes = attribute_config.GetNumTotalAttributes(); |
| 28 | 27 | ||
| 29 | boost::fill(vertex_attribute_sources, 0xdeadbeef); | 28 | boost::fill(vertex_attribute_sources, 0xdeadbeef); |
| @@ -49,7 +48,7 @@ void VertexLoader::Setup(const Pica::Regs& regs) { | |||
| 49 | if (attribute_index < 12) { | 48 | if (attribute_index < 12) { |
| 50 | int element_size = attribute_config.GetElementSizeInBytes(attribute_index); | 49 | int element_size = attribute_config.GetElementSizeInBytes(attribute_index); |
| 51 | offset = Common::AlignUp(offset, element_size); | 50 | offset = Common::AlignUp(offset, element_size); |
| 52 | vertex_attribute_sources[attribute_index] = base_address + loader_config.data_offset + offset; | 51 | vertex_attribute_sources[attribute_index] = loader_config.data_offset + offset; |
| 53 | vertex_attribute_strides[attribute_index] = static_cast<u32>(loader_config.byte_count); | 52 | vertex_attribute_strides[attribute_index] = static_cast<u32>(loader_config.byte_count); |
| 54 | vertex_attribute_formats[attribute_index] = attribute_config.GetFormat(attribute_index); | 53 | vertex_attribute_formats[attribute_index] = attribute_config.GetFormat(attribute_index); |
| 55 | vertex_attribute_elements[attribute_index] = attribute_config.GetNumElements(attribute_index); | 54 | vertex_attribute_elements[attribute_index] = attribute_config.GetNumElements(attribute_index); |
| @@ -66,7 +65,7 @@ void VertexLoader::Setup(const Pica::Regs& regs) { | |||
| 66 | } | 65 | } |
| 67 | } | 66 | } |
| 68 | 67 | ||
| 69 | void VertexLoader::LoadVertex(int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses) { | 68 | void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses) { |
| 70 | for (int i = 0; i < num_total_attributes; ++i) { | 69 | for (int i = 0; i < num_total_attributes; ++i) { |
| 71 | if (vertex_attribute_elements[i] != 0) { | 70 | if (vertex_attribute_elements[i] != 0) { |
| 72 | // Default attribute values set if array elements have < 4 components. This | 71 | // Default attribute values set if array elements have < 4 components. This |
| @@ -78,7 +77,7 @@ void VertexLoader::LoadVertex(int index, int vertex, Shader::InputVertex& input, | |||
| 78 | 77 | ||
| 79 | // Load per-vertex data from the loader arrays | 78 | // Load per-vertex data from the loader arrays |
| 80 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { | 79 | for (unsigned int comp = 0; comp < vertex_attribute_elements[i]; ++comp) { |
| 81 | u32 source_addr = vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]; | 80 | u32 source_addr = base_address + vertex_attribute_sources[i] + vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i]; |
| 82 | const u8* srcdata = Memory::GetPhysicalPointer(source_addr); | 81 | const u8* srcdata = Memory::GetPhysicalPointer(source_addr); |
| 83 | 82 | ||
| 84 | if (g_debug_context && Pica::g_debug_context->recorder) { | 83 | if (g_debug_context && Pica::g_debug_context->recorder) { |
| @@ -97,7 +96,7 @@ void VertexLoader::LoadVertex(int index, int vertex, Shader::InputVertex& input, | |||
| 97 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f", | 96 | LOG_TRACE(HW_GPU, "Loaded component %x of attribute %x for vertex %x (index %x) from 0x%08x + 0x%08x + 0x%04x: %f", |
| 98 | comp, i, vertex, index, | 97 | comp, i, vertex, index, |
| 99 | base_address, | 98 | base_address, |
| 100 | vertex_attribute_sources[i] - base_address, | 99 | vertex_attribute_sources[i], |
| 101 | vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], | 100 | vertex_attribute_strides[i] * vertex + comp * vertex_attribute_element_size[i], |
| 102 | input.attr[i][comp].ToFloat32()); | 101 | input.attr[i][comp].ToFloat32()); |
| 103 | } | 102 | } |
diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index 560d36edc..40c5e83c9 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h | |||
| @@ -38,10 +38,10 @@ public: | |||
| 38 | class VertexLoader { | 38 | class VertexLoader { |
| 39 | public: | 39 | public: |
| 40 | void Setup(const Pica::Regs& regs); | 40 | void Setup(const Pica::Regs& regs); |
| 41 | void LoadVertex(int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses); | 41 | void LoadVertex(u32 base_address, int index, int vertex, Shader::InputVertex& input, MemoryAccesses& memory_accesses); |
| 42 | 42 | ||
| 43 | u32 GetPhysicalBaseAddress() const { return base_address; } | ||
| 44 | int GetNumTotalAttributes() const { return num_total_attributes; } | 43 | int GetNumTotalAttributes() const { return num_total_attributes; } |
| 44 | |||
| 45 | private: | 45 | private: |
| 46 | u32 vertex_attribute_sources[16]; | 46 | u32 vertex_attribute_sources[16]; |
| 47 | u32 vertex_attribute_strides[16] = {}; | 47 | u32 vertex_attribute_strides[16] = {}; |
| @@ -49,7 +49,6 @@ private: | |||
| 49 | u32 vertex_attribute_elements[16] = {}; | 49 | u32 vertex_attribute_elements[16] = {}; |
| 50 | u32 vertex_attribute_element_size[16] = {}; | 50 | u32 vertex_attribute_element_size[16] = {}; |
| 51 | bool vertex_attribute_is_default[16]; | 51 | bool vertex_attribute_is_default[16]; |
| 52 | u32 base_address; | ||
| 53 | int num_total_attributes; | 52 | int num_total_attributes; |
| 54 | }; | 53 | }; |
| 55 | 54 | ||