diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/gsp_gpu.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/y2r_u.cpp | 2 | ||||
| -rw-r--r-- | src/core/hw/gpu.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/CMakeLists.txt | 5 | ||||
| -rw-r--r-- | src/video_core/clipper.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/clipper.h | 2 | ||||
| -rw-r--r-- | src/video_core/command_processor.cpp | 27 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 6 | ||||
| -rw-r--r-- | src/video_core/rasterizer_interface.h (renamed from src/video_core/hwrasterizer_base.h) | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_base.cpp | 28 | ||||
| -rw-r--r-- | src/video_core/renderer_base.h | 8 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 19 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 15 | ||||
| -rw-r--r-- | src/video_core/swrasterizer.cpp | 16 | ||||
| -rw-r--r-- | src/video_core/swrasterizer.h | 26 |
16 files changed, 116 insertions, 78 deletions
diff --git a/src/core/hle/service/gsp_gpu.cpp b/src/core/hle/service/gsp_gpu.cpp index 3e4c70e18..98b11c798 100644 --- a/src/core/hle/service/gsp_gpu.cpp +++ b/src/core/hle/service/gsp_gpu.cpp | |||
| @@ -275,7 +275,7 @@ static void FlushDataCache(Service::Interface* self) { | |||
| 275 | u32 size = cmd_buff[2]; | 275 | u32 size = cmd_buff[2]; |
| 276 | u32 process = cmd_buff[4]; | 276 | u32 process = cmd_buff[4]; |
| 277 | 277 | ||
| 278 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion(Memory::VirtualToPhysicalAddress(address), size); | 278 | VideoCore::g_renderer->rasterizer->InvalidateRegion(Memory::VirtualToPhysicalAddress(address), size); |
| 279 | 279 | ||
| 280 | // TODO(purpasmart96): Verify return header on HW | 280 | // TODO(purpasmart96): Verify return header on HW |
| 281 | 281 | ||
| @@ -365,7 +365,7 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { | |||
| 365 | 365 | ||
| 366 | // GX request DMA - typically used for copying memory from GSP heap to VRAM | 366 | // GX request DMA - typically used for copying memory from GSP heap to VRAM |
| 367 | case CommandId::REQUEST_DMA: | 367 | case CommandId::REQUEST_DMA: |
| 368 | VideoCore::g_renderer->hw_rasterizer->FlushRegion(Memory::VirtualToPhysicalAddress(command.dma_request.source_address), | 368 | VideoCore::g_renderer->rasterizer->FlushRegion(Memory::VirtualToPhysicalAddress(command.dma_request.source_address), |
| 369 | command.dma_request.size); | 369 | command.dma_request.size); |
| 370 | 370 | ||
| 371 | memcpy(Memory::GetPointer(command.dma_request.dest_address), | 371 | memcpy(Memory::GetPointer(command.dma_request.dest_address), |
| @@ -373,7 +373,7 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { | |||
| 373 | command.dma_request.size); | 373 | command.dma_request.size); |
| 374 | SignalInterrupt(InterruptId::DMA); | 374 | SignalInterrupt(InterruptId::DMA); |
| 375 | 375 | ||
| 376 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion(Memory::VirtualToPhysicalAddress(command.dma_request.dest_address), | 376 | VideoCore::g_renderer->rasterizer->InvalidateRegion(Memory::VirtualToPhysicalAddress(command.dma_request.dest_address), |
| 377 | command.dma_request.size); | 377 | command.dma_request.size); |
| 378 | break; | 378 | break; |
| 379 | 379 | ||
| @@ -467,7 +467,7 @@ static void ExecuteCommand(const Command& command, u32 thread_id) { | |||
| 467 | if (region.size == 0) | 467 | if (region.size == 0) |
| 468 | break; | 468 | break; |
| 469 | 469 | ||
| 470 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion( | 470 | VideoCore::g_renderer->rasterizer->InvalidateRegion( |
| 471 | Memory::VirtualToPhysicalAddress(region.address), region.size); | 471 | Memory::VirtualToPhysicalAddress(region.address), region.size); |
| 472 | } | 472 | } |
| 473 | break; | 473 | break; |
diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index face1d7b0..0429927f2 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp | |||
| @@ -267,7 +267,7 @@ static void StartConversion(Service::Interface* self) { | |||
| 267 | // dst_image_size would seem to be perfect for this, but it doesn't include the gap :( | 267 | // dst_image_size would seem to be perfect for this, but it doesn't include the gap :( |
| 268 | u32 total_output_size = conversion.input_lines * | 268 | u32 total_output_size = conversion.input_lines * |
| 269 | (conversion.dst.transfer_unit + conversion.dst.gap); | 269 | (conversion.dst.transfer_unit + conversion.dst.gap); |
| 270 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion( | 270 | VideoCore::g_renderer->rasterizer->InvalidateRegion( |
| 271 | Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size); | 271 | Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size); |
| 272 | 272 | ||
| 273 | LOG_DEBUG(Service_Y2R, "called"); | 273 | LOG_DEBUG(Service_Y2R, "called"); |
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 55e215600..4bd3a632d 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp | |||
| @@ -26,7 +26,7 @@ | |||
| 26 | #include "core/tracer/recorder.h" | 26 | #include "core/tracer/recorder.h" |
| 27 | 27 | ||
| 28 | #include "video_core/command_processor.h" | 28 | #include "video_core/command_processor.h" |
| 29 | #include "video_core/hwrasterizer_base.h" | 29 | #include "video_core/rasterizer_interface.h" |
| 30 | #include "video_core/renderer_base.h" | 30 | #include "video_core/renderer_base.h" |
| 31 | #include "video_core/utils.h" | 31 | #include "video_core/utils.h" |
| 32 | #include "video_core/video_core.h" | 32 | #include "video_core/video_core.h" |
| @@ -141,7 +141,7 @@ inline void Write(u32 addr, const T data) { | |||
| 141 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PSC1); | 141 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PSC1); |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion(config.GetStartAddress(), config.GetEndAddress() - config.GetStartAddress()); | 144 | VideoCore::g_renderer->rasterizer->InvalidateRegion(config.GetStartAddress(), config.GetEndAddress() - config.GetStartAddress()); |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | // Reset "trigger" flag and set the "finish" flag | 147 | // Reset "trigger" flag and set the "finish" flag |
| @@ -172,7 +172,7 @@ inline void Write(u32 addr, const T data) { | |||
| 172 | u32 output_gap = config.texture_copy.output_gap * 16; | 172 | u32 output_gap = config.texture_copy.output_gap * 16; |
| 173 | 173 | ||
| 174 | size_t contiguous_input_size = config.texture_copy.size / input_width * (input_width + input_gap); | 174 | size_t contiguous_input_size = config.texture_copy.size / input_width * (input_width + input_gap); |
| 175 | VideoCore::g_renderer->hw_rasterizer->FlushRegion(config.GetPhysicalInputAddress(), contiguous_input_size); | 175 | VideoCore::g_renderer->rasterizer->FlushRegion(config.GetPhysicalInputAddress(), contiguous_input_size); |
| 176 | 176 | ||
| 177 | u32 remaining_size = config.texture_copy.size; | 177 | u32 remaining_size = config.texture_copy.size; |
| 178 | u32 remaining_input = input_width; | 178 | u32 remaining_input = input_width; |
| @@ -205,7 +205,7 @@ inline void Write(u32 addr, const T data) { | |||
| 205 | config.flags); | 205 | config.flags); |
| 206 | 206 | ||
| 207 | size_t contiguous_output_size = config.texture_copy.size / output_width * (output_width + output_gap); | 207 | size_t contiguous_output_size = config.texture_copy.size / output_width * (output_width + output_gap); |
| 208 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion(config.GetPhysicalOutputAddress(), contiguous_output_size); | 208 | VideoCore::g_renderer->rasterizer->InvalidateRegion(config.GetPhysicalOutputAddress(), contiguous_output_size); |
| 209 | 209 | ||
| 210 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PPF); | 210 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PPF); |
| 211 | break; | 211 | break; |
| @@ -232,7 +232,7 @@ inline void Write(u32 addr, const T data) { | |||
| 232 | u32 input_size = config.input_width * config.input_height * GPU::Regs::BytesPerPixel(config.input_format); | 232 | u32 input_size = config.input_width * config.input_height * GPU::Regs::BytesPerPixel(config.input_format); |
| 233 | u32 output_size = output_width * output_height * GPU::Regs::BytesPerPixel(config.output_format); | 233 | u32 output_size = output_width * output_height * GPU::Regs::BytesPerPixel(config.output_format); |
| 234 | 234 | ||
| 235 | VideoCore::g_renderer->hw_rasterizer->FlushRegion(config.GetPhysicalInputAddress(), input_size); | 235 | VideoCore::g_renderer->rasterizer->FlushRegion(config.GetPhysicalInputAddress(), input_size); |
| 236 | 236 | ||
| 237 | for (u32 y = 0; y < output_height; ++y) { | 237 | for (u32 y = 0; y < output_height; ++y) { |
| 238 | for (u32 x = 0; x < output_width; ++x) { | 238 | for (u32 x = 0; x < output_width; ++x) { |
| @@ -339,7 +339,7 @@ inline void Write(u32 addr, const T data) { | |||
| 339 | g_regs.display_transfer_config.trigger = 0; | 339 | g_regs.display_transfer_config.trigger = 0; |
| 340 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PPF); | 340 | GSP_GPU::SignalInterrupt(GSP_GPU::InterruptId::PPF); |
| 341 | 341 | ||
| 342 | VideoCore::g_renderer->hw_rasterizer->InvalidateRegion(config.GetPhysicalOutputAddress(), output_size); | 342 | VideoCore::g_renderer->rasterizer->InvalidateRegion(config.GetPhysicalOutputAddress(), output_size); |
| 343 | } | 343 | } |
| 344 | break; | 344 | break; |
| 345 | } | 345 | } |
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 2a924f4ad..c3d7294d5 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -11,8 +11,10 @@ set(SRCS | |||
| 11 | pica.cpp | 11 | pica.cpp |
| 12 | primitive_assembly.cpp | 12 | primitive_assembly.cpp |
| 13 | rasterizer.cpp | 13 | rasterizer.cpp |
| 14 | renderer_base.cpp | ||
| 14 | shader/shader.cpp | 15 | shader/shader.cpp |
| 15 | shader/shader_interpreter.cpp | 16 | shader/shader_interpreter.cpp |
| 17 | swrasterizer.cpp | ||
| 16 | utils.cpp | 18 | utils.cpp |
| 17 | video_core.cpp | 19 | video_core.cpp |
| 18 | ) | 20 | ) |
| @@ -30,13 +32,14 @@ set(HEADERS | |||
| 30 | clipper.h | 32 | clipper.h |
| 31 | command_processor.h | 33 | command_processor.h |
| 32 | gpu_debugger.h | 34 | gpu_debugger.h |
| 33 | hwrasterizer_base.h | ||
| 34 | pica.h | 35 | pica.h |
| 35 | primitive_assembly.h | 36 | primitive_assembly.h |
| 36 | rasterizer.h | 37 | rasterizer.h |
| 38 | rasterizer_interface.h | ||
| 37 | renderer_base.h | 39 | renderer_base.h |
| 38 | shader/shader.h | 40 | shader/shader.h |
| 39 | shader/shader_interpreter.h | 41 | shader/shader_interpreter.h |
| 42 | swrasterizer.h | ||
| 40 | utils.h | 43 | utils.h |
| 41 | video_core.h | 44 | video_core.h |
| 42 | ) | 45 | ) |
diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp index ed99c4f13..5d609da06 100644 --- a/src/video_core/clipper.cpp +++ b/src/video_core/clipper.cpp | |||
| @@ -78,7 +78,7 @@ static void InitScreenCoordinates(OutputVertex& vtx) | |||
| 78 | vtx.screenpos[2] = viewport.offset_z + vtx.pos.z * inv_w * viewport.zscale; | 78 | vtx.screenpos[2] = viewport.offset_z + vtx.pos.z * inv_w * viewport.zscale; |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | void ProcessTriangle(OutputVertex &v0, OutputVertex &v1, OutputVertex &v2) { | 81 | void ProcessTriangle(const OutputVertex &v0, const OutputVertex &v1, const OutputVertex &v2) { |
| 82 | using boost::container::static_vector; | 82 | using boost::container::static_vector; |
| 83 | 83 | ||
| 84 | // Clipping a planar n-gon against a plane will remove at least 1 vertex and introduces 2 at | 84 | // Clipping a planar n-gon against a plane will remove at least 1 vertex and introduces 2 at |
diff --git a/src/video_core/clipper.h b/src/video_core/clipper.h index 6ed01e877..f85d8d4c9 100644 --- a/src/video_core/clipper.h +++ b/src/video_core/clipper.h | |||
| @@ -14,7 +14,7 @@ namespace Clipper { | |||
| 14 | 14 | ||
| 15 | using Shader::OutputVertex; | 15 | using Shader::OutputVertex; |
| 16 | 16 | ||
| 17 | void ProcessTriangle(OutputVertex& v0, OutputVertex& v1, OutputVertex& v2); | 17 | void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const OutputVertex& v2); |
| 18 | 18 | ||
| 19 | } // namespace | 19 | } // namespace |
| 20 | 20 | ||
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index bd1b09a4b..35b976c60 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp | |||
| @@ -336,19 +336,14 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 336 | } | 336 | } |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | if (Settings::values.use_hw_renderer) { | 339 | // Send to renderer |
| 340 | // Send to hardware renderer | 340 | using Pica::Shader::OutputVertex; |
| 341 | static auto AddHWTriangle = [](const Pica::Shader::OutputVertex& v0, | 341 | auto AddTriangle = []( |
| 342 | const Pica::Shader::OutputVertex& v1, | 342 | const OutputVertex& v0, const OutputVertex& v1, const OutputVertex& v2) { |
| 343 | const Pica::Shader::OutputVertex& v2) { | 343 | VideoCore::g_renderer->rasterizer->AddTriangle(v0, v1, v2); |
| 344 | VideoCore::g_renderer->hw_rasterizer->AddTriangle(v0, v1, v2); | 344 | }; |
| 345 | }; | 345 | |
| 346 | 346 | primitive_assembler.SubmitVertex(output, AddTriangle); | |
| 347 | primitive_assembler.SubmitVertex(output, AddHWTriangle); | ||
| 348 | } else { | ||
| 349 | // Send to triangle clipper | ||
| 350 | primitive_assembler.SubmitVertex(output, Clipper::ProcessTriangle); | ||
| 351 | } | ||
| 352 | } | 347 | } |
| 353 | 348 | ||
| 354 | for (auto& range : memory_accesses.ranges) { | 349 | for (auto& range : memory_accesses.ranges) { |
| @@ -356,9 +351,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 356 | range.second, range.first); | 351 | range.second, range.first); |
| 357 | } | 352 | } |
| 358 | 353 | ||
| 359 | if (Settings::values.use_hw_renderer) { | 354 | VideoCore::g_renderer->rasterizer->DrawTriangles(); |
| 360 | VideoCore::g_renderer->hw_rasterizer->DrawTriangles(); | ||
| 361 | } | ||
| 362 | 355 | ||
| 363 | #if PICA_DUMP_GEOMETRY | 356 | #if PICA_DUMP_GEOMETRY |
| 364 | geometry_dumper.Dump(); | 357 | geometry_dumper.Dump(); |
| @@ -475,7 +468,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) { | |||
| 475 | break; | 468 | break; |
| 476 | } | 469 | } |
| 477 | 470 | ||
| 478 | VideoCore::g_renderer->hw_rasterizer->NotifyPicaRegisterChanged(id); | 471 | VideoCore::g_renderer->rasterizer->NotifyPicaRegisterChanged(id); |
| 479 | 472 | ||
| 480 | if (g_debug_context) | 473 | if (g_debug_context) |
| 481 | g_debug_context->OnEvent(DebugContext::Event::PicaCommandProcessed, reinterpret_cast<void*>(&id)); | 474 | g_debug_context->OnEvent(DebugContext::Event::PicaCommandProcessed, reinterpret_cast<void*>(&id)); |
diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 0e29661c7..4f66dbd65 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp | |||
| @@ -46,10 +46,8 @@ void DebugContext::OnEvent(Event event, void* data) { | |||
| 46 | { | 46 | { |
| 47 | std::unique_lock<std::mutex> lock(breakpoint_mutex); | 47 | std::unique_lock<std::mutex> lock(breakpoint_mutex); |
| 48 | 48 | ||
| 49 | if (Settings::values.use_hw_renderer) { | 49 | // Commit the hardware renderer's framebuffer so it will show on debug widgets |
| 50 | // Commit the hardware renderer's framebuffer so it will show on debug widgets | 50 | VideoCore::g_renderer->rasterizer->FlushFramebuffer(); |
| 51 | VideoCore::g_renderer->hw_rasterizer->FlushFramebuffer(); | ||
| 52 | } | ||
| 53 | 51 | ||
| 54 | // TODO: Should stop the CPU thread here once we multithread emulation. | 52 | // TODO: Should stop the CPU thread here once we multithread emulation. |
| 55 | 53 | ||
diff --git a/src/video_core/hwrasterizer_base.h b/src/video_core/rasterizer_interface.h index b6390950a..008c5827b 100644 --- a/src/video_core/hwrasterizer_base.h +++ b/src/video_core/rasterizer_interface.h | |||
| @@ -12,10 +12,11 @@ struct OutputVertex; | |||
| 12 | } | 12 | } |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | class HWRasterizer { | 15 | namespace VideoCore { |
| 16 | |||
| 17 | class RasterizerInterface { | ||
| 16 | public: | 18 | public: |
| 17 | virtual ~HWRasterizer() { | 19 | virtual ~RasterizerInterface() {} |
| 18 | } | ||
| 19 | 20 | ||
| 20 | /// Initialize API-specific GPU objects | 21 | /// Initialize API-specific GPU objects |
| 21 | virtual void InitObjects() = 0; | 22 | virtual void InitObjects() = 0; |
| @@ -43,3 +44,5 @@ public: | |||
| 43 | /// Notify rasterizer that any caches of the specified region should be discraded and reloaded from 3DS memory. | 44 | /// Notify rasterizer that any caches of the specified region should be discraded and reloaded from 3DS memory. |
| 44 | virtual void InvalidateRegion(PAddr addr, u32 size) = 0; | 45 | virtual void InvalidateRegion(PAddr addr, u32 size) = 0; |
| 45 | }; | 46 | }; |
| 47 | |||
| 48 | } | ||
diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp new file mode 100644 index 000000000..93e980216 --- /dev/null +++ b/src/video_core/renderer_base.cpp | |||
| @@ -0,0 +1,28 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <memory> | ||
| 6 | |||
| 7 | #include "common/make_unique.h" | ||
| 8 | |||
| 9 | #include "core/settings.h" | ||
| 10 | |||
| 11 | #include "video_core/renderer_base.h" | ||
| 12 | #include "video_core/video_core.h" | ||
| 13 | #include "video_core/swrasterizer.h" | ||
| 14 | #include "video_core/renderer_opengl/gl_rasterizer.h" | ||
| 15 | |||
| 16 | void RendererBase::RefreshRasterizerSetting() { | ||
| 17 | bool hw_renderer_enabled = VideoCore::g_hw_renderer_enabled; | ||
| 18 | if (rasterizer == nullptr || opengl_rasterizer_active != hw_renderer_enabled) { | ||
| 19 | opengl_rasterizer_active = hw_renderer_enabled; | ||
| 20 | |||
| 21 | if (hw_renderer_enabled) { | ||
| 22 | rasterizer = Common::make_unique<RasterizerOpenGL>(); | ||
| 23 | } else { | ||
| 24 | rasterizer = Common::make_unique<VideoCore::SWRasterizer>(); | ||
| 25 | } | ||
| 26 | rasterizer->InitObjects(); | ||
| 27 | } | ||
| 28 | } | ||
diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 6587bcf27..506bff815 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | 8 | ||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | 10 | ||
| 11 | #include "video_core/hwrasterizer_base.h" | 11 | #include "video_core/rasterizer_interface.h" |
| 12 | 12 | ||
| 13 | class EmuWindow; | 13 | class EmuWindow; |
| 14 | 14 | ||
| @@ -54,10 +54,14 @@ public: | |||
| 54 | return m_current_frame; | 54 | return m_current_frame; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | std::unique_ptr<HWRasterizer> hw_rasterizer; | 57 | void RefreshRasterizerSetting(); |
| 58 | |||
| 59 | std::unique_ptr<VideoCore::RasterizerInterface> rasterizer; | ||
| 58 | 60 | ||
| 59 | protected: | 61 | protected: |
| 60 | f32 m_current_fps; ///< Current framerate, should be set by the renderer | 62 | f32 m_current_fps; ///< Current framerate, should be set by the renderer |
| 61 | int m_current_frame; ///< Current frame, should be set by the renderer | 63 | int m_current_frame; ///< Current frame, should be set by the renderer |
| 62 | 64 | ||
| 65 | private: | ||
| 66 | bool opengl_rasterizer_active = false; | ||
| 63 | }; | 67 | }; |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index cc7830688..681fdca8d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp | |||
| @@ -188,9 +188,6 @@ void RasterizerOpenGL::FlushFramebuffer() { | |||
| 188 | void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { | 188 | void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { |
| 189 | const auto& regs = Pica::g_state.regs; | 189 | const auto& regs = Pica::g_state.regs; |
| 190 | 190 | ||
| 191 | if (!Settings::values.use_hw_renderer) | ||
| 192 | return; | ||
| 193 | |||
| 194 | switch(id) { | 191 | switch(id) { |
| 195 | // Culling | 192 | // Culling |
| 196 | case PICA_REG_INDEX(cull_mode): | 193 | case PICA_REG_INDEX(cull_mode): |
| @@ -287,9 +284,6 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) { | |||
| 287 | void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) { | 284 | void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) { |
| 288 | const auto& regs = Pica::g_state.regs; | 285 | const auto& regs = Pica::g_state.regs; |
| 289 | 286 | ||
| 290 | if (!Settings::values.use_hw_renderer) | ||
| 291 | return; | ||
| 292 | |||
| 293 | PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); | 287 | PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); |
| 294 | u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) | 288 | u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) |
| 295 | * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); | 289 | * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); |
| @@ -309,9 +303,6 @@ void RasterizerOpenGL::FlushRegion(PAddr addr, u32 size) { | |||
| 309 | void RasterizerOpenGL::InvalidateRegion(PAddr addr, u32 size) { | 303 | void RasterizerOpenGL::InvalidateRegion(PAddr addr, u32 size) { |
| 310 | const auto& regs = Pica::g_state.regs; | 304 | const auto& regs = Pica::g_state.regs; |
| 311 | 305 | ||
| 312 | if (!Settings::values.use_hw_renderer) | ||
| 313 | return; | ||
| 314 | |||
| 315 | PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); | 306 | PAddr cur_fb_color_addr = regs.framebuffer.GetColorBufferPhysicalAddress(); |
| 316 | u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) | 307 | u32 cur_fb_color_size = Pica::Regs::BytesPerColorPixel(regs.framebuffer.color_format) |
| 317 | * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); | 308 | * regs.framebuffer.GetWidth() * regs.framebuffer.GetHeight(); |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 378cdb65c..92b1f812e 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -14,7 +14,7 @@ | |||
| 14 | #include "common/hash.h" | 14 | #include "common/hash.h" |
| 15 | 15 | ||
| 16 | #include "video_core/pica.h" | 16 | #include "video_core/pica.h" |
| 17 | #include "video_core/hwrasterizer_base.h" | 17 | #include "video_core/rasterizer_interface.h" |
| 18 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" | 18 | #include "video_core/renderer_opengl/gl_rasterizer_cache.h" |
| 19 | #include "video_core/renderer_opengl/gl_state.h" | 19 | #include "video_core/renderer_opengl/gl_state.h" |
| 20 | #include "video_core/shader/shader_interpreter.h" | 20 | #include "video_core/shader/shader_interpreter.h" |
| @@ -102,36 +102,21 @@ struct hash<PicaShaderConfig> { | |||
| 102 | 102 | ||
| 103 | } // namespace std | 103 | } // namespace std |
| 104 | 104 | ||
| 105 | class RasterizerOpenGL : public HWRasterizer { | 105 | class RasterizerOpenGL : public VideoCore::RasterizerInterface { |
| 106 | public: | 106 | public: |
| 107 | 107 | ||
| 108 | RasterizerOpenGL(); | 108 | RasterizerOpenGL(); |
| 109 | ~RasterizerOpenGL() override; | 109 | ~RasterizerOpenGL() override; |
| 110 | 110 | ||
| 111 | /// Initialize API-specific GPU objects | ||
| 112 | void InitObjects() override; | 111 | void InitObjects() override; |
| 113 | |||
| 114 | /// Reset the rasterizer, such as flushing all caches and updating all state | ||
| 115 | void Reset() override; | 112 | void Reset() override; |
| 116 | |||
| 117 | /// Queues the primitive formed by the given vertices for rendering | ||
| 118 | void AddTriangle(const Pica::Shader::OutputVertex& v0, | 113 | void AddTriangle(const Pica::Shader::OutputVertex& v0, |
| 119 | const Pica::Shader::OutputVertex& v1, | 114 | const Pica::Shader::OutputVertex& v1, |
| 120 | const Pica::Shader::OutputVertex& v2) override; | 115 | const Pica::Shader::OutputVertex& v2) override; |
| 121 | |||
| 122 | /// Draw the current batch of triangles | ||
| 123 | void DrawTriangles() override; | 116 | void DrawTriangles() override; |
| 124 | |||
| 125 | /// Commit the rasterizer's framebuffer contents immediately to the current 3DS memory framebuffer | ||
| 126 | void FlushFramebuffer() override; | 117 | void FlushFramebuffer() override; |
| 127 | |||
| 128 | /// Notify rasterizer that the specified PICA register has been changed | ||
| 129 | void NotifyPicaRegisterChanged(u32 id) override; | 118 | void NotifyPicaRegisterChanged(u32 id) override; |
| 130 | |||
| 131 | /// Notify rasterizer that the specified 3DS memory region will be read from after this notification | ||
| 132 | void FlushRegion(PAddr addr, u32 size) override; | 119 | void FlushRegion(PAddr addr, u32 size) override; |
| 133 | |||
| 134 | /// Notify rasterizer that a 3DS memory region has been changed | ||
| 135 | void InvalidateRegion(PAddr addr, u32 size) override; | 120 | void InvalidateRegion(PAddr addr, u32 size) override; |
| 136 | 121 | ||
| 137 | /// OpenGL shader generated for a given Pica register state | 122 | /// OpenGL shader generated for a given Pica register state |
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 1420229cc..c14bdb8ab 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp | |||
| @@ -93,7 +93,6 @@ static std::array<GLfloat, 3*2> MakeOrthographicMatrix(const float width, const | |||
| 93 | 93 | ||
| 94 | /// RendererOpenGL constructor | 94 | /// RendererOpenGL constructor |
| 95 | RendererOpenGL::RendererOpenGL() { | 95 | RendererOpenGL::RendererOpenGL() { |
| 96 | hw_rasterizer.reset(new RasterizerOpenGL()); | ||
| 97 | resolution_width = std::max(VideoCore::kScreenTopWidth, VideoCore::kScreenBottomWidth); | 96 | resolution_width = std::max(VideoCore::kScreenTopWidth, VideoCore::kScreenBottomWidth); |
| 98 | resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight; | 97 | resolution_height = VideoCore::kScreenTopHeight + VideoCore::kScreenBottomHeight; |
| 99 | } | 98 | } |
| @@ -157,15 +156,7 @@ void RendererOpenGL::SwapBuffers() { | |||
| 157 | 156 | ||
| 158 | profiler.BeginFrame(); | 157 | profiler.BeginFrame(); |
| 159 | 158 | ||
| 160 | bool hw_renderer_enabled = VideoCore::g_hw_renderer_enabled; | 159 | RefreshRasterizerSetting(); |
| 161 | if (Settings::values.use_hw_renderer != hw_renderer_enabled) { | ||
| 162 | // TODO: Save new setting value to config file for next startup | ||
| 163 | Settings::values.use_hw_renderer = hw_renderer_enabled; | ||
| 164 | |||
| 165 | if (Settings::values.use_hw_renderer) { | ||
| 166 | hw_rasterizer->Reset(); | ||
| 167 | } | ||
| 168 | } | ||
| 169 | 160 | ||
| 170 | if (Pica::g_debug_context && Pica::g_debug_context->recorder) { | 161 | if (Pica::g_debug_context && Pica::g_debug_context->recorder) { |
| 171 | Pica::g_debug_context->recorder->FrameFinished(); | 162 | Pica::g_debug_context->recorder->FrameFinished(); |
| @@ -286,8 +277,6 @@ void RendererOpenGL::InitOpenGLObjects() { | |||
| 286 | 277 | ||
| 287 | state.texture_units[0].texture_2d = 0; | 278 | state.texture_units[0].texture_2d = 0; |
| 288 | state.Apply(); | 279 | state.Apply(); |
| 289 | |||
| 290 | hw_rasterizer->InitObjects(); | ||
| 291 | } | 280 | } |
| 292 | 281 | ||
| 293 | void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, | 282 | void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, |
| @@ -419,6 +408,8 @@ void RendererOpenGL::Init() { | |||
| 419 | LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); | 408 | LOG_INFO(Render_OpenGL, "GL_VENDOR: %s", glGetString(GL_VENDOR)); |
| 420 | LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); | 409 | LOG_INFO(Render_OpenGL, "GL_RENDERER: %s", glGetString(GL_RENDERER)); |
| 421 | InitOpenGLObjects(); | 410 | InitOpenGLObjects(); |
| 411 | |||
| 412 | RefreshRasterizerSetting(); | ||
| 422 | } | 413 | } |
| 423 | 414 | ||
| 424 | /// Shutdown the renderer | 415 | /// Shutdown the renderer |
diff --git a/src/video_core/swrasterizer.cpp b/src/video_core/swrasterizer.cpp new file mode 100644 index 000000000..03df15b01 --- /dev/null +++ b/src/video_core/swrasterizer.cpp | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "video_core/clipper.h" | ||
| 6 | #include "video_core/swrasterizer.h" | ||
| 7 | |||
| 8 | namespace VideoCore { | ||
| 9 | |||
| 10 | void SWRasterizer::AddTriangle(const Pica::Shader::OutputVertex& v0, | ||
| 11 | const Pica::Shader::OutputVertex& v1, | ||
| 12 | const Pica::Shader::OutputVertex& v2) { | ||
| 13 | Pica::Clipper::ProcessTriangle(v0, v1, v2); | ||
| 14 | } | ||
| 15 | |||
| 16 | } | ||
diff --git a/src/video_core/swrasterizer.h b/src/video_core/swrasterizer.h new file mode 100644 index 000000000..e9a4e39c6 --- /dev/null +++ b/src/video_core/swrasterizer.h | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | // Copyright 2015 Citra Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #pragma once | ||
| 6 | |||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 9 | #include "video_core/rasterizer_interface.h" | ||
| 10 | |||
| 11 | namespace VideoCore { | ||
| 12 | |||
| 13 | class SWRasterizer : public RasterizerInterface { | ||
| 14 | void InitObjects() override {} | ||
| 15 | void Reset() override {} | ||
| 16 | void AddTriangle(const Pica::Shader::OutputVertex& v0, | ||
| 17 | const Pica::Shader::OutputVertex& v1, | ||
| 18 | const Pica::Shader::OutputVertex& v2); | ||
| 19 | void DrawTriangles() override {} | ||
| 20 | void FlushFramebuffer() override {} | ||
| 21 | void NotifyPicaRegisterChanged(u32 id) override {} | ||
| 22 | void FlushRegion(PAddr addr, u32 size) override {} | ||
| 23 | void InvalidateRegion(PAddr addr, u32 size) override {} | ||
| 24 | }; | ||
| 25 | |||
| 26 | } | ||