diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 11 | ||||
| -rw-r--r-- | src/core/core.h | 5 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.h | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 26 |
5 files changed, 48 insertions, 17 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index bf39ad689..713ee17c1 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -136,7 +136,7 @@ struct System::Impl { | |||
| 136 | if (virtual_filesystem == nullptr) | 136 | if (virtual_filesystem == nullptr) |
| 137 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | 137 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); |
| 138 | 138 | ||
| 139 | current_process = Kernel::Process::Create(kernel, "main"); | 139 | kernel.MakeCurrentProcess(Kernel::Process::Create(kernel, "main")); |
| 140 | 140 | ||
| 141 | cpu_barrier = std::make_shared<CpuBarrier>(); | 141 | cpu_barrier = std::make_shared<CpuBarrier>(); |
| 142 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); | 142 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); |
| @@ -202,7 +202,7 @@ struct System::Impl { | |||
| 202 | return init_result; | 202 | return init_result; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | const Loader::ResultStatus load_result{app_loader->Load(current_process)}; | 205 | const Loader::ResultStatus load_result{app_loader->Load(kernel.CurrentProcess())}; |
| 206 | if (load_result != Loader::ResultStatus::Success) { | 206 | if (load_result != Loader::ResultStatus::Success) { |
| 207 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); | 207 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); |
| 208 | Shutdown(); | 208 | Shutdown(); |
| @@ -281,7 +281,6 @@ struct System::Impl { | |||
| 281 | std::unique_ptr<VideoCore::RendererBase> renderer; | 281 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| 282 | std::unique_ptr<Tegra::GPU> gpu_core; | 282 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 283 | std::shared_ptr<Tegra::DebugContext> debug_context; | 283 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 284 | Kernel::SharedPtr<Kernel::Process> current_process; | ||
| 285 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; | 284 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; |
| 286 | std::shared_ptr<CpuBarrier> cpu_barrier; | 285 | std::shared_ptr<CpuBarrier> cpu_barrier; |
| 287 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; | 286 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; |
| @@ -363,7 +362,11 @@ const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(size_t core_index) { | |||
| 363 | } | 362 | } |
| 364 | 363 | ||
| 365 | Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() { | 364 | Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() { |
| 366 | return impl->current_process; | 365 | return impl->kernel.CurrentProcess(); |
| 366 | } | ||
| 367 | |||
| 368 | const Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() const { | ||
| 369 | return impl->kernel.CurrentProcess(); | ||
| 367 | } | 370 | } |
| 368 | 371 | ||
| 369 | ARM_Interface& System::ArmInterface(size_t core_index) { | 372 | ARM_Interface& System::ArmInterface(size_t core_index) { |
diff --git a/src/core/core.h b/src/core/core.h index 5c3c0e2a1..ab3663427 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -174,9 +174,12 @@ public: | |||
| 174 | /// Gets the scheduler for the CPU core with the specified index | 174 | /// Gets the scheduler for the CPU core with the specified index |
| 175 | const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index); | 175 | const std::shared_ptr<Kernel::Scheduler>& Scheduler(size_t core_index); |
| 176 | 176 | ||
| 177 | /// Gets the current process | 177 | /// Provides a reference to the current process |
| 178 | Kernel::SharedPtr<Kernel::Process>& CurrentProcess(); | 178 | Kernel::SharedPtr<Kernel::Process>& CurrentProcess(); |
| 179 | 179 | ||
| 180 | /// Provides a constant reference to the current process. | ||
| 181 | const Kernel::SharedPtr<Kernel::Process>& CurrentProcess() const; | ||
| 182 | |||
| 180 | /// Provides a reference to the kernel instance. | 183 | /// Provides a reference to the kernel instance. |
| 181 | Kernel::KernelCore& Kernel(); | 184 | Kernel::KernelCore& Kernel(); |
| 182 | 185 | ||
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 7902c2882..3e0800a71 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -116,6 +116,7 @@ struct KernelCore::Impl { | |||
| 116 | next_thread_id = 1; | 116 | next_thread_id = 1; |
| 117 | 117 | ||
| 118 | process_list.clear(); | 118 | process_list.clear(); |
| 119 | current_process.reset(); | ||
| 119 | 120 | ||
| 120 | handle_table.Clear(); | 121 | handle_table.Clear(); |
| 121 | resource_limits.fill(nullptr); | 122 | resource_limits.fill(nullptr); |
| @@ -206,6 +207,7 @@ struct KernelCore::Impl { | |||
| 206 | 207 | ||
| 207 | // Lists all processes that exist in the current session. | 208 | // Lists all processes that exist in the current session. |
| 208 | std::vector<SharedPtr<Process>> process_list; | 209 | std::vector<SharedPtr<Process>> process_list; |
| 210 | SharedPtr<Process> current_process; | ||
| 209 | 211 | ||
| 210 | Kernel::HandleTable handle_table; | 212 | Kernel::HandleTable handle_table; |
| 211 | std::array<SharedPtr<ResourceLimit>, 4> resource_limits; | 213 | std::array<SharedPtr<ResourceLimit>, 4> resource_limits; |
| @@ -264,6 +266,18 @@ void KernelCore::AppendNewProcess(SharedPtr<Process> process) { | |||
| 264 | impl->process_list.push_back(std::move(process)); | 266 | impl->process_list.push_back(std::move(process)); |
| 265 | } | 267 | } |
| 266 | 268 | ||
| 269 | void KernelCore::MakeCurrentProcess(SharedPtr<Process> process) { | ||
| 270 | impl->current_process = std::move(process); | ||
| 271 | } | ||
| 272 | |||
| 273 | SharedPtr<Process>& KernelCore::CurrentProcess() { | ||
| 274 | return impl->current_process; | ||
| 275 | } | ||
| 276 | |||
| 277 | const SharedPtr<Process>& KernelCore::CurrentProcess() const { | ||
| 278 | return impl->current_process; | ||
| 279 | } | ||
| 280 | |||
| 267 | void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) { | 281 | void KernelCore::AddNamedPort(std::string name, SharedPtr<ClientPort> port) { |
| 268 | impl->named_ports.emplace(std::move(name), std::move(port)); | 282 | impl->named_ports.emplace(std::move(name), std::move(port)); |
| 269 | } | 283 | } |
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index ab2e9bffa..c0771ecf0 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h | |||
| @@ -65,6 +65,15 @@ public: | |||
| 65 | /// Adds the given shared pointer to an internal list of active processes. | 65 | /// Adds the given shared pointer to an internal list of active processes. |
| 66 | void AppendNewProcess(SharedPtr<Process> process); | 66 | void AppendNewProcess(SharedPtr<Process> process); |
| 67 | 67 | ||
| 68 | /// Makes the given process the new current process. | ||
| 69 | void MakeCurrentProcess(SharedPtr<Process> process); | ||
| 70 | |||
| 71 | /// Retrieves a reference to the current process. | ||
| 72 | SharedPtr<Process>& CurrentProcess(); | ||
| 73 | |||
| 74 | /// Retrieves a const reference to the current process. | ||
| 75 | const SharedPtr<Process>& CurrentProcess() const; | ||
| 76 | |||
| 68 | /// Adds a port to the named port table | 77 | /// Adds a port to the named port table |
| 69 | void AddNamedPort(std::string name, SharedPtr<ClientPort> port); | 78 | void AddNamedPort(std::string name, SharedPtr<ClientPort> port); |
| 70 | 79 | ||
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 6e89fa6e3..19399fab8 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -152,13 +152,13 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 152 | const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); | 152 | const Tegra::GPUVAddr end = regs.vertex_array_limit[index].LimitAddress(); |
| 153 | 153 | ||
| 154 | if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) { | 154 | if (regs.instanced_arrays.IsInstancingEnabled(index) && vertex_array.divisor != 0) { |
| 155 | start += vertex_array.stride * (gpu.state.current_instance / vertex_array.divisor); | 155 | start += static_cast<Tegra::GPUVAddr>(vertex_array.stride) * |
| 156 | (gpu.state.current_instance / vertex_array.divisor); | ||
| 156 | } | 157 | } |
| 157 | 158 | ||
| 158 | ASSERT(end > start); | 159 | ASSERT(end > start); |
| 159 | u64 size = end - start + 1; | 160 | const u64 size = end - start + 1; |
| 160 | 161 | const GLintptr vertex_buffer_offset = buffer_cache.UploadMemory(start, size); | |
| 161 | GLintptr vertex_buffer_offset = buffer_cache.UploadMemory(start, size); | ||
| 162 | 162 | ||
| 163 | // Bind the vertex array to the buffer at the current offset. | 163 | // Bind the vertex array to the buffer at the current offset. |
| 164 | glBindVertexBuffer(index, buffer_cache.GetHandle(), vertex_buffer_offset, | 164 | glBindVertexBuffer(index, buffer_cache.GetHandle(), vertex_buffer_offset, |
| @@ -178,7 +178,7 @@ void RasterizerOpenGL::SetupVertexArrays() { | |||
| 178 | 178 | ||
| 179 | void RasterizerOpenGL::SetupShaders() { | 179 | void RasterizerOpenGL::SetupShaders() { |
| 180 | MICROPROFILE_SCOPE(OpenGL_Shader); | 180 | MICROPROFILE_SCOPE(OpenGL_Shader); |
| 181 | auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); | 181 | const auto& gpu = Core::System::GetInstance().GPU().Maxwell3D(); |
| 182 | 182 | ||
| 183 | // Next available bindpoints to use when uploading the const buffers and textures to the GLSL | 183 | // Next available bindpoints to use when uploading the const buffers and textures to the GLSL |
| 184 | // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points. | 184 | // shaders. The constbuffer bindpoint starts after the shader stage configuration bind points. |
| @@ -186,7 +186,7 @@ void RasterizerOpenGL::SetupShaders() { | |||
| 186 | u32 current_texture_bindpoint = 0; | 186 | u32 current_texture_bindpoint = 0; |
| 187 | 187 | ||
| 188 | for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { | 188 | for (size_t index = 0; index < Maxwell::MaxShaderProgram; ++index) { |
| 189 | auto& shader_config = gpu.regs.shader_config[index]; | 189 | const auto& shader_config = gpu.regs.shader_config[index]; |
| 190 | const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; | 190 | const Maxwell::ShaderProgram program{static_cast<Maxwell::ShaderProgram>(index)}; |
| 191 | 191 | ||
| 192 | // Skip stages that are not enabled | 192 | // Skip stages that are not enabled |
| @@ -198,7 +198,7 @@ void RasterizerOpenGL::SetupShaders() { | |||
| 198 | 198 | ||
| 199 | GLShader::MaxwellUniformData ubo{}; | 199 | GLShader::MaxwellUniformData ubo{}; |
| 200 | ubo.SetFromRegs(gpu.state.shader_stages[stage]); | 200 | ubo.SetFromRegs(gpu.state.shader_stages[stage]); |
| 201 | GLintptr offset = buffer_cache.UploadHostMemory( | 201 | const GLintptr offset = buffer_cache.UploadHostMemory( |
| 202 | &ubo, sizeof(ubo), static_cast<size_t>(uniform_buffer_alignment)); | 202 | &ubo, sizeof(ubo), static_cast<size_t>(uniform_buffer_alignment)); |
| 203 | 203 | ||
| 204 | // Bind the buffer | 204 | // Bind the buffer |
| @@ -436,7 +436,7 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 436 | 436 | ||
| 437 | ScopeAcquireGLContext acquire_context{emu_window}; | 437 | ScopeAcquireGLContext acquire_context{emu_window}; |
| 438 | 438 | ||
| 439 | auto [dirty_color_surface, dirty_depth_surface] = | 439 | const auto [dirty_color_surface, dirty_depth_surface] = |
| 440 | ConfigureFramebuffers(true, regs.zeta.Address() != 0 && regs.zeta_enable != 0, true); | 440 | ConfigureFramebuffers(true, regs.zeta.Address() != 0 && regs.zeta_enable != 0, true); |
| 441 | 441 | ||
| 442 | SyncDepthTestState(); | 442 | SyncDepthTestState(); |
| @@ -450,7 +450,8 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 450 | 450 | ||
| 451 | // Draw the vertex batch | 451 | // Draw the vertex batch |
| 452 | const bool is_indexed = accelerate_draw == AccelDraw::Indexed; | 452 | const bool is_indexed = accelerate_draw == AccelDraw::Indexed; |
| 453 | const u64 index_buffer_size{regs.index_array.count * regs.index_array.FormatSizeInBytes()}; | 453 | const u64 index_buffer_size{static_cast<u64>(regs.index_array.count) * |
| 454 | static_cast<u64>(regs.index_array.FormatSizeInBytes())}; | ||
| 454 | 455 | ||
| 455 | state.draw.vertex_buffer = buffer_cache.GetHandle(); | 456 | state.draw.vertex_buffer = buffer_cache.GetHandle(); |
| 456 | state.Apply(); | 457 | state.Apply(); |
| @@ -493,7 +494,8 @@ void RasterizerOpenGL::DrawArrays() { | |||
| 493 | const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)}; | 494 | const GLint base_vertex{static_cast<GLint>(regs.vb_element_base)}; |
| 494 | 495 | ||
| 495 | // Adjust the index buffer offset so it points to the first desired index. | 496 | // Adjust the index buffer offset so it points to the first desired index. |
| 496 | index_buffer_offset += regs.index_array.first * regs.index_array.FormatSizeInBytes(); | 497 | index_buffer_offset += static_cast<GLintptr>(regs.index_array.first) * |
| 498 | static_cast<GLintptr>(regs.index_array.FormatSizeInBytes()); | ||
| 497 | 499 | ||
| 498 | glDrawElementsBaseVertex(primitive_mode, regs.index_array.count, | 500 | glDrawElementsBaseVertex(primitive_mode, regs.index_array.count, |
| 499 | MaxwellToGL::IndexFormat(regs.index_array.format), | 501 | MaxwellToGL::IndexFormat(regs.index_array.format), |
| @@ -588,7 +590,7 @@ void RasterizerOpenGL::SamplerInfo::Create() { | |||
| 588 | } | 590 | } |
| 589 | 591 | ||
| 590 | void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) { | 592 | void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) { |
| 591 | GLuint s = sampler.handle; | 593 | const GLuint s = sampler.handle; |
| 592 | 594 | ||
| 593 | if (mag_filter != config.mag_filter) { | 595 | if (mag_filter != config.mag_filter) { |
| 594 | mag_filter = config.mag_filter; | 596 | mag_filter = config.mag_filter; |
| @@ -682,7 +684,7 @@ u32 RasterizerOpenGL::SetupTextures(Maxwell::ShaderStage stage, Shader& shader, | |||
| 682 | 684 | ||
| 683 | for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { | 685 | for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { |
| 684 | const auto& entry = entries[bindpoint]; | 686 | const auto& entry = entries[bindpoint]; |
| 685 | u32 current_bindpoint = current_unit + bindpoint; | 687 | const u32 current_bindpoint = current_unit + bindpoint; |
| 686 | 688 | ||
| 687 | // Bind the uniform to the sampler. | 689 | // Bind the uniform to the sampler. |
| 688 | 690 | ||