diff options
50 files changed, 255 insertions, 227 deletions
diff --git a/src/citra_qt/debugger/graphics_tracing.cpp b/src/citra_qt/debugger/graphics_tracing.cpp index e06498744..1402f8e79 100644 --- a/src/citra_qt/debugger/graphics_tracing.cpp +++ b/src/citra_qt/debugger/graphics_tracing.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <array> +#include <iterator> #include <memory> #include <boost/range/algorithm/copy.hpp> @@ -18,6 +21,7 @@ #include "core/hw/gpu.h" #include "core/hw/lcd.h" +#include "core/tracer/recorder.h" #include "nihstro/float24.h" diff --git a/src/common/bit_field.h b/src/common/bit_field.h index 371eb17a1..4748999ed 100644 --- a/src/common/bit_field.h +++ b/src/common/bit_field.h @@ -186,5 +186,5 @@ private: #pragma pack() #if (__GNUC__ >= 5) || defined(__clang__) || defined(_MSC_VER) -static_assert(std::is_trivially_copyable<BitField<0, 1, u32>>::value, "BitField must be trivially copyable"); +static_assert(std::is_trivially_copyable<BitField<0, 1, unsigned>>::value, "BitField must be trivially copyable"); #endif diff --git a/src/common/bit_set.h b/src/common/bit_set.h index 85f91e786..7f5de8df2 100644 --- a/src/common/bit_set.h +++ b/src/common/bit_set.h @@ -7,6 +7,7 @@ #include <intrin.h> #endif #include <initializer_list> +#include <new> #include <type_traits> #include "common/common_types.h" @@ -186,4 +187,4 @@ public: typedef Common::BitSet<u8> BitSet8; typedef Common::BitSet<u16> BitSet16; typedef Common::BitSet<u32> BitSet32; -typedef Common::BitSet<u64> BitSet64;
\ No newline at end of file +typedef Common::BitSet<u64> BitSet64; diff --git a/src/common/code_block.h b/src/common/code_block.h index 9ef7296d3..2fa4a0090 100644 --- a/src/common/code_block.h +++ b/src/common/code_block.h @@ -4,8 +4,10 @@ #pragma once -#include "common_types.h" -#include "memory_util.h" +#include <cstddef> + +#include "common/common_types.h" +#include "common/memory_util.h" // Everything that needs to generate code should inherit from this. // You get memory management for free, plus, you can use all emitter functions without diff --git a/src/common/common_funcs.h b/src/common/common_funcs.h index aa6aff7b9..ab3515683 100644 --- a/src/common/common_funcs.h +++ b/src/common/common_funcs.h @@ -4,6 +4,10 @@ #pragma once +#if !defined(ARCHITECTURE_x86_64) && !defined(_M_ARM) +#include <cstdlib> // for exit +#endif + #include "common_types.h" #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) diff --git a/src/common/file_util.h b/src/common/file_util.h index 3aac4fa46..c6a8694ce 100644 --- a/src/common/file_util.h +++ b/src/common/file_util.h @@ -7,9 +7,9 @@ #include <array> #include <fstream> #include <functional> -#include <cstddef> #include <cstdio> #include <string> +#include <type_traits> #include <vector> #include "common/common_types.h" diff --git a/src/common/x64/emitter.h b/src/common/x64/emitter.h index a33724146..60a77dfe1 100644 --- a/src/common/x64/emitter.h +++ b/src/common/x64/emitter.h @@ -17,6 +17,8 @@ #pragma once +#include <cstddef> + #include "common/assert.h" #include "common/bit_set.h" #include "common/common_types.h" diff --git a/src/core/hle/result.h b/src/core/hle/result.h index 53931a106..3fc1ab4ee 100644 --- a/src/core/hle/result.h +++ b/src/core/hle/result.h @@ -5,7 +5,6 @@ #pragma once #include <new> -#include <type_traits> #include <utility> #include "common/assert.h" diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index 525432957..b9322c55d 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -389,6 +389,10 @@ ResultCode FormatConfig() { res = CreateConfigInfoBlk(0x000F0004, sizeof(CONSOLE_MODEL), 0xC, &CONSOLE_MODEL); if (!res.IsSuccess()) return res; + // 0x00170000 - Unknown + res = CreateConfigInfoBlk(0x00170000, 0x4, 0xE, zero_buffer); + if (!res.IsSuccess()) return res; + // Save the buffer to the file res = UpdateConfigNANDSavegame(); if (!res.IsSuccess()) diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h index 606ab99cf..c01806836 100644 --- a/src/core/hle/service/cfg/cfg.h +++ b/src/core/hle/service/cfg/cfg.h @@ -98,19 +98,6 @@ void GetCountryCodeString(Service::Interface* self); void GetCountryCodeID(Service::Interface* self); /** - * CFG::GetConfigInfoBlk2 service function - * Inputs: - * 0 : 0x00010082 - * 1 : Size - * 2 : Block ID - * 3 : Descriptor for the output buffer - * 4 : Output buffer pointer - * Outputs: - * 1 : Result of function, 0 on success, otherwise error code - */ -void GetConfigInfoBlk2(Service::Interface* self); - -/** * CFG::SecureInfoGetRegion service function * Inputs: * 1 : None diff --git a/src/core/hle/service/gsp_gpu.h b/src/core/hle/service/gsp_gpu.h index 55a993bb8..3b4b678a3 100644 --- a/src/core/hle/service/gsp_gpu.h +++ b/src/core/hle/service/gsp_gpu.h @@ -10,6 +10,7 @@ #include "common/bit_field.h" #include "common/common_types.h" +#include "core/hle/result.h" #include "core/hle/service/service.h" //////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/src/core/hw/lcd.h b/src/core/hw/lcd.h index 3dd877fbf..57029c5e8 100644 --- a/src/core/hw/lcd.h +++ b/src/core/hw/lcd.h @@ -52,8 +52,6 @@ struct Regs { return content[index]; } -#undef ASSERT_MEMBER_SIZE - }; static_assert(std::is_standard_layout<Regs>::value, "Structure does not use standard layout"); diff --git a/src/core/settings.h b/src/core/settings.h index 04c0a47f9..ce2a31164 100644 --- a/src/core/settings.h +++ b/src/core/settings.h @@ -6,7 +6,8 @@ #include <string> #include <array> -#include <common/file_util.h> + +#include "common/common_types.h" namespace Settings { diff --git a/src/core/tracer/recorder.h b/src/core/tracer/recorder.h index a42ccc45f..febf883c8 100644 --- a/src/core/tracer/recorder.h +++ b/src/core/tracer/recorder.h @@ -4,6 +4,7 @@ #pragma once +#include <string> #include <unordered_map> #include <vector> diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index de4082b1f..581a37897 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -15,7 +15,6 @@ set(SRCS shader/shader.cpp shader/shader_interpreter.cpp swrasterizer.cpp - utils.cpp vertex_loader.cpp video_core.cpp ) diff --git a/src/video_core/clipper.cpp b/src/video_core/clipper.cpp index 3d503486e..2bc747102 100644 --- a/src/video_core/clipper.cpp +++ b/src/video_core/clipper.cpp @@ -2,13 +2,24 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <array> +#include <cstddef> + #include <boost/container/static_vector.hpp> +#include <boost/container/vector.hpp> + +#include "common/bit_field.h" +#include "common/common_types.h" +#include "common/logging/log.h" +#include "common/vector_math.h" #include "video_core/clipper.h" #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" #include "video_core/rasterizer.h" -#include "video_core/shader/shader_interpreter.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index 58883e374..be1a936b2 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -2,26 +2,32 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <cmath> -#include <boost/range/algorithm/fill.hpp> +#include <array> +#include <cstddef> +#include <memory> +#include <utility> -#include "common/alignment.h" +#include "common/assert.h" +#include "common/logging/log.h" #include "common/microprofile.h" +#include "common/vector_math.h" -#include "core/settings.h" #include "core/hle/service/gsp_gpu.h" #include "core/hw/gpu.h" +#include "core/memory.h" +#include "core/tracer/recorder.h" -#include "video_core/clipper.h" #include "video_core/command_processor.h" +#include "video_core/debug_utils/debug_utils.h" #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" #include "video_core/primitive_assembly.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_base.h" -#include "video_core/video_core.h" -#include "video_core/debug_utils/debug_utils.h" -#include "video_core/shader/shader_interpreter.h" +#include "video_core/shader/shader.h" #include "video_core/vertex_loader.h" +#include "video_core/video_core.h" namespace Pica { diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 178a566f7..fb20f81dd 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -4,35 +4,41 @@ #include <algorithm> #include <condition_variable> +#include <cstdint> #include <cstring> #include <fstream> -#include <list> #include <map> #include <mutex> +#include <stdexcept> #include <string> #ifdef HAVE_PNG #include <png.h> +#include <setjmp.h> #endif +#include <nihstro/bit_field.h> #include <nihstro/float24.h> #include <nihstro/shader_binary.h> #include "common/assert.h" +#include "common/bit_field.h" #include "common/color.h" #include "common/common_types.h" #include "common/file_util.h" +#include "common/logging/log.h" #include "common/math_util.h" #include "common/vector_math.h" -#include "core/settings.h" - +#include "video_core/debug_utils/debug_utils.h" #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_base.h" +#include "video_core/shader/shader.h" #include "video_core/utils.h" #include "video_core/video_core.h" -#include "video_core/debug_utils/debug_utils.h" using nihstro::DVLBHeader; using nihstro::DVLEHeader; diff --git a/src/video_core/debug_utils/debug_utils.h b/src/video_core/debug_utils/debug_utils.h index dd0828cee..be2d0301a 100644 --- a/src/video_core/debug_utils/debug_utils.h +++ b/src/video_core/debug_utils/debug_utils.h @@ -4,23 +4,33 @@ #pragma once +#include <algorithm> #include <array> #include <condition_variable> +#include <iterator> #include <list> #include <map> #include <memory> #include <mutex> +#include <string> +#include <utility> #include <vector> +#include "common/common_types.h" #include "common/vector_math.h" -#include "core/tracer/recorder.h" - #include "video_core/pica.h" -#include "video_core/shader/shader.h" + +namespace CiTrace { +class Recorder; +} namespace Pica { +namespace Shader { +struct ShaderSetup; +} + class DebugContext { public: enum class Event { diff --git a/src/video_core/pica.cpp b/src/video_core/pica.cpp index ccbaf071b..be82cf4b5 100644 --- a/src/video_core/pica.cpp +++ b/src/video_core/pica.cpp @@ -3,10 +3,13 @@ // Refer to the license.txt file included. #include <cstring> +#include <iterator> #include <unordered_map> +#include <utility> #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/primitive_assembly.h" #include "video_core/shader/shader.h" namespace Pica { @@ -480,7 +483,7 @@ std::string Regs::GetCommandName(int index) { static std::unordered_map<u32, const char*> map; if (map.empty()) { - map.insert(begin(register_names), end(register_names)); + map.insert(std::begin(register_names), std::end(register_names)); } // Return empty string if no match is found diff --git a/src/video_core/pica.h b/src/video_core/pica.h index cf130d7f8..5891fb72a 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -5,10 +5,13 @@ #pragma once #include <array> -#include <cmath> #include <cstddef> #include <string> +#ifndef _MSC_VER +#include <type_traits> // for std::enable_if +#endif + #include "common/assert.h" #include "common/bit_field.h" #include "common/common_funcs.h" @@ -16,8 +19,6 @@ #include "common/vector_math.h" #include "common/logging/log.h" -#include "pica_types.h" - namespace Pica { // Returns index corresponding to the Regs member labeled by field_name diff --git a/src/video_core/pica_state.h b/src/video_core/pica_state.h index 323290054..bbecad850 100644 --- a/src/video_core/pica_state.h +++ b/src/video_core/pica_state.h @@ -4,6 +4,11 @@ #pragma once +#include <array> + +#include "common/bit_field.h" +#include "common/common_types.h" + #include "video_core/pica.h" #include "video_core/primitive_assembly.h" #include "video_core/shader/shader.h" diff --git a/src/video_core/pica_types.h b/src/video_core/pica_types.h index ecf45654b..3b7bfbdca 100644 --- a/src/video_core/pica_types.h +++ b/src/video_core/pica_types.h @@ -4,6 +4,7 @@ #pragma once +#include <cmath> #include <cstring> #include "common/common_types.h" diff --git a/src/video_core/primitive_assembly.cpp b/src/video_core/primitive_assembly.cpp index ff3e2b862..68ea3c08a 100644 --- a/src/video_core/primitive_assembly.cpp +++ b/src/video_core/primitive_assembly.cpp @@ -6,8 +6,7 @@ #include "video_core/pica.h" #include "video_core/primitive_assembly.h" -#include "video_core/debug_utils/debug_utils.h" -#include "video_core/shader/shader_interpreter.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 9cf77b1f2..df67b9081 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -3,22 +3,28 @@ // Refer to the license.txt file included. #include <algorithm> +#include <array> #include <cmath> +#include "common/assert.h" +#include "common/bit_field.h" #include "common/color.h" #include "common/common_types.h" +#include "common/logging/log.h" #include "common/math_util.h" #include "common/microprofile.h" +#include "common/vector_math.h" #include "core/memory.h" #include "core/hw/gpu.h" +#include "video_core/debug_utils/debug_utils.h" #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" #include "video_core/rasterizer.h" #include "video_core/utils.h" -#include "video_core/debug_utils/debug_utils.h" -#include "video_core/shader/shader_interpreter.h" +#include "video_core/shader/shader.h" namespace Pica { diff --git a/src/video_core/renderer_base.cpp b/src/video_core/renderer_base.cpp index ccd497de0..3f451e062 100644 --- a/src/video_core/renderer_base.cpp +++ b/src/video_core/renderer_base.cpp @@ -2,10 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <atomic> #include <memory> -#include "core/settings.h" - #include "video_core/renderer_base.h" #include "video_core/video_core.h" #include "video_core/swrasterizer.h" diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index a8c775c80..519d81aeb 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -2,27 +2,28 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <cstring> #include <memory> +#include <string> +#include <tuple> +#include <utility> #include <glad/glad.h> +#include "common/assert.h" #include "common/color.h" -#include "common/file_util.h" +#include "common/logging/log.h" #include "common/math_util.h" -#include "common/microprofile.h" +#include "common/vector_math.h" -#include "core/memory.h" -#include "core/settings.h" #include "core/hw/gpu.h" #include "video_core/pica.h" #include "video_core/pica_state.h" -#include "video_core/utils.h" #include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_shader_gen.h" #include "video_core/renderer_opengl/gl_shader_util.h" #include "video_core/renderer_opengl/pica_to_gl.h" +#include "video_core/renderer_opengl/renderer_opengl.h" static bool IsPassThroughTevStage(const Pica::Regs::TevStageConfig& stage) { return (stage.color_op == Pica::Regs::TevStageConfig::Operation::Replace && @@ -812,6 +813,7 @@ void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Pica::Regs::TextureConf if (wrap_s == TextureConfig::ClampToBorder || wrap_t == TextureConfig::ClampToBorder) { if (border_color != config.border_color.raw) { + border_color = config.border_color.raw; auto gl_color = PicaToGL::ColorRGBA8(border_color); glSamplerParameterfv(s, GL_TEXTURE_BORDER_COLOR, gl_color.data()); } diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 8d6177e88..82fa61742 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -4,23 +4,33 @@ #pragma once +#include <array> #include <cstddef> #include <cstring> #include <memory> #include <vector> #include <unordered_map> +#include <glad/glad.h> + +#include "common/bit_field.h" #include "common/common_types.h" #include "common/hash.h" +#include "common/vector_math.h" + +#include "core/hw/gpu.h" #include "video_core/pica.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" #include "video_core/rasterizer_interface.h" #include "video_core/renderer_opengl/gl_rasterizer_cache.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" #include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/pica_to_gl.h" -#include "video_core/renderer_opengl/renderer_opengl.h" -#include "video_core/shader/shader_interpreter.h" +#include "video_core/shader/shader.h" + +struct ScreenInfo; /** * This struct contains all state used to generate the GLSL shader program that emulates the current @@ -39,36 +49,18 @@ struct PicaShaderConfig { res.alpha_test_func = regs.output_merger.alpha_test.enable ? regs.output_merger.alpha_test.func.Value() : Pica::Regs::CompareFunc::Always; - // Copy relevant TevStageConfig fields only. We're doing this manually (instead of calling - // the GetTevStages() function) because BitField explicitly disables copies. - - res.tev_stages[0].sources_raw = regs.tev_stage0.sources_raw; - res.tev_stages[1].sources_raw = regs.tev_stage1.sources_raw; - res.tev_stages[2].sources_raw = regs.tev_stage2.sources_raw; - res.tev_stages[3].sources_raw = regs.tev_stage3.sources_raw; - res.tev_stages[4].sources_raw = regs.tev_stage4.sources_raw; - res.tev_stages[5].sources_raw = regs.tev_stage5.sources_raw; - - res.tev_stages[0].modifiers_raw = regs.tev_stage0.modifiers_raw; - res.tev_stages[1].modifiers_raw = regs.tev_stage1.modifiers_raw; - res.tev_stages[2].modifiers_raw = regs.tev_stage2.modifiers_raw; - res.tev_stages[3].modifiers_raw = regs.tev_stage3.modifiers_raw; - res.tev_stages[4].modifiers_raw = regs.tev_stage4.modifiers_raw; - res.tev_stages[5].modifiers_raw = regs.tev_stage5.modifiers_raw; - - res.tev_stages[0].ops_raw = regs.tev_stage0.ops_raw; - res.tev_stages[1].ops_raw = regs.tev_stage1.ops_raw; - res.tev_stages[2].ops_raw = regs.tev_stage2.ops_raw; - res.tev_stages[3].ops_raw = regs.tev_stage3.ops_raw; - res.tev_stages[4].ops_raw = regs.tev_stage4.ops_raw; - res.tev_stages[5].ops_raw = regs.tev_stage5.ops_raw; - - res.tev_stages[0].scales_raw = regs.tev_stage0.scales_raw; - res.tev_stages[1].scales_raw = regs.tev_stage1.scales_raw; - res.tev_stages[2].scales_raw = regs.tev_stage2.scales_raw; - res.tev_stages[3].scales_raw = regs.tev_stage3.scales_raw; - res.tev_stages[4].scales_raw = regs.tev_stage4.scales_raw; - res.tev_stages[5].scales_raw = regs.tev_stage5.scales_raw; + // Copy relevant tev stages fields. + // We don't sync const_color here because of the high variance, it is a + // shader uniform instead. + const auto& tev_stages = regs.GetTevStages(); + DEBUG_ASSERT(res.tev_stages.size() == tev_stages.size()); + for (size_t i = 0; i < tev_stages.size(); i++) { + const auto& tev_stage = tev_stages[i]; + res.tev_stages[i].sources_raw = tev_stage.sources_raw; + res.tev_stages[i].modifiers_raw = tev_stage.modifiers_raw; + res.tev_stages[i].ops_raw = tev_stage.ops_raw; + res.tev_stages[i].scales_raw = tev_stage.scales_raw; + } res.combiner_buffer_input = regs.tev_combiner_buffer_input.update_mask_rgb.Value() | diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp index 55c2fb283..7efd0038a 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.cpp @@ -2,10 +2,19 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <atomic> +#include <cstring> +#include <iterator> #include <unordered_set> +#include <utility> +#include <vector> +#include <glad/glad.h> + +#include "common/bit_field.h" #include "common/emu_window.h" -#include "common/hash.h" +#include "common/logging/log.h" #include "common/math_util.h" #include "common/microprofile.h" #include "common/vector_math.h" @@ -15,7 +24,7 @@ #include "video_core/debug_utils/debug_utils.h" #include "video_core/pica_state.h" #include "video_core/renderer_opengl/gl_rasterizer_cache.h" -#include "video_core/renderer_opengl/pica_to_gl.h" +#include "video_core/renderer_opengl/gl_state.h" #include "video_core/utils.h" #include "video_core/video_core.h" diff --git a/src/video_core/renderer_opengl/gl_rasterizer_cache.h b/src/video_core/renderer_opengl/gl_rasterizer_cache.h index 893d51138..225596415 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer_cache.h +++ b/src/video_core/renderer_opengl/gl_rasterizer_cache.h @@ -4,20 +4,26 @@ #pragma once -#include <map> +#include <array> #include <memory> #include <set> +#include <tuple> #include <boost/icl/interval_map.hpp> +#include <glad/glad.h> -#include "common/math_util.h" +#include "common/assert.h" +#include "common/common_funcs.h" +#include "common/common_types.h" #include "core/hw/gpu.h" #include "video_core/pica.h" -#include "video_core/debug_utils/debug_utils.h" #include "video_core/renderer_opengl/gl_resource_manager.h" -#include "video_core/renderer_opengl/gl_state.h" + +namespace MathUtil { +template <class T> struct Rectangle; +} struct CachedSurface; diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 646b4eaaf..9011caa39 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -2,9 +2,17 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <array> +#include <cstddef> + +#include "common/assert.h" +#include "common/bit_field.h" +#include "common/logging/log.h" + #include "video_core/pica.h" #include "video_core/renderer_opengl/gl_rasterizer.h" #include "video_core/renderer_opengl/gl_shader_gen.h" +#include "video_core/renderer_opengl/gl_shader_util.h" using Pica::Regs; using TevStageConfig = Regs::TevStageConfig; diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h index 0ca9d2879..3eb07d57a 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.h +++ b/src/video_core/renderer_opengl/gl_shader_gen.h @@ -6,7 +6,7 @@ #include <string> -#include "video_core/renderer_opengl/gl_rasterizer.h" +struct PicaShaderConfig; namespace GLShader { diff --git a/src/video_core/renderer_opengl/gl_shader_util.cpp b/src/video_core/renderer_opengl/gl_shader_util.cpp index e3f7a5868..dded3db46 100644 --- a/src/video_core/renderer_opengl/gl_shader_util.cpp +++ b/src/video_core/renderer_opengl/gl_shader_util.cpp @@ -2,9 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <algorithm> #include <vector> +#include <glad/glad.h> + #include "common/logging/log.h" #include "video_core/renderer_opengl/gl_shader_util.h" diff --git a/src/video_core/renderer_opengl/gl_state.cpp b/src/video_core/renderer_opengl/gl_state.cpp index f04bdd8c5..02cd9f417 100644 --- a/src/video_core/renderer_opengl/gl_state.cpp +++ b/src/video_core/renderer_opengl/gl_state.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include "video_core/pica.h" -#include "video_core/renderer_opengl/gl_resource_manager.h" +#include <glad/glad.h> + +#include "common/common_funcs.h" +#include "common/logging/log.h" + #include "video_core/renderer_opengl/gl_state.h" OpenGLState OpenGLState::cur_state; diff --git a/src/video_core/renderer_opengl/gl_state.h b/src/video_core/renderer_opengl/gl_state.h index 0f72e9004..24f20e47c 100644 --- a/src/video_core/renderer_opengl/gl_state.h +++ b/src/video_core/renderer_opengl/gl_state.h @@ -5,7 +5,6 @@ #pragma once #include <glad/glad.h> -#include <memory> class OpenGLState { public: diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index fd3617d77..976d1f364 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -4,9 +4,16 @@ #pragma once +#include <array> +#include <cstddef> + #include <glad/glad.h> +#include "common/assert.h" +#include "common/bit_field.h" +#include "common/common_funcs.h" #include "common/common_types.h" +#include "common/logging/log.h" #include "video_core/pica.h" diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 8f907593f..0e9a0be8b 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -5,23 +5,28 @@ #include <algorithm> #include <cstddef> #include <cstdlib> +#include <memory> + +#include <glad/glad.h> #include "common/assert.h" +#include "common/bit_field.h" #include "common/emu_window.h" #include "common/logging/log.h" #include "common/profiler_reporting.h" +#include "common/synchronized_wrapper.h" -#include "core/memory.h" -#include "core/settings.h" #include "core/hw/gpu.h" #include "core/hw/hw.h" #include "core/hw/lcd.h" +#include "core/memory.h" +#include "core/settings.h" +#include "core/tracer/recorder.h" -#include "video_core/video_core.h" #include "video_core/debug_utils/debug_utils.h" -#include "video_core/renderer_opengl/gl_rasterizer.h" -#include "video_core/renderer_opengl/gl_shader_util.h" +#include "video_core/rasterizer_interface.h" #include "video_core/renderer_opengl/renderer_opengl.h" +#include "video_core/video_core.h" static const char vertex_shader[] = R"( #version 150 core diff --git a/src/video_core/renderer_opengl/renderer_opengl.h b/src/video_core/renderer_opengl/renderer_opengl.h index 5ca5255ac..00e1044ab 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.h +++ b/src/video_core/renderer_opengl/renderer_opengl.h @@ -8,6 +8,9 @@ #include <glad/glad.h> +#include "common/common_types.h" +#include "common/math_util.h" + #include "core/hw/gpu.h" #include "video_core/renderer_base.h" diff --git a/src/video_core/shader/shader.cpp b/src/video_core/shader/shader.cpp index 043e99190..65dcc9156 100644 --- a/src/video_core/shader/shader.cpp +++ b/src/video_core/shader/shader.cpp @@ -2,26 +2,30 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. -#include <memory> +#include <atomic> +#include <cmath> +#include <cstring> #include <unordered_map> +#include <utility> #include <boost/range/algorithm/fill.hpp> +#include "common/bit_field.h" #include "common/hash.h" +#include "common/logging/log.h" #include "common/microprofile.h" -#include "video_core/debug_utils/debug_utils.h" #include "video_core/pica.h" #include "video_core/pica_state.h" -#include "video_core/video_core.h" - -#include "shader.h" -#include "shader_interpreter.h" +#include "video_core/shader/shader.h" +#include "video_core/shader/shader_interpreter.h" #ifdef ARCHITECTURE_x86_64 -#include "shader_jit_x64.h" +#include "video_core/shader/shader_jit_x64.h" #endif // ARCHITECTURE_x86_64 +#include "video_core/video_core.h" + namespace Pica { namespace Shader { @@ -70,24 +74,8 @@ OutputVertex Run(UnitState<false>& state, const InputVertex& input, int num_attr // Setup input register table const auto& attribute_register_map = config.input_register_map; - // TODO: Instead of this cumbersome logic, just load the input data directly like - // for (int attr = 0; attr < num_attributes; ++attr) { input_attr[0] = state.registers.input[attribute_register_map.attribute0_register]; } - if (num_attributes > 0) state.registers.input[attribute_register_map.attribute0_register] = input.attr[0]; - if (num_attributes > 1) state.registers.input[attribute_register_map.attribute1_register] = input.attr[1]; - if (num_attributes > 2) state.registers.input[attribute_register_map.attribute2_register] = input.attr[2]; - if (num_attributes > 3) state.registers.input[attribute_register_map.attribute3_register] = input.attr[3]; - if (num_attributes > 4) state.registers.input[attribute_register_map.attribute4_register] = input.attr[4]; - if (num_attributes > 5) state.registers.input[attribute_register_map.attribute5_register] = input.attr[5]; - if (num_attributes > 6) state.registers.input[attribute_register_map.attribute6_register] = input.attr[6]; - if (num_attributes > 7) state.registers.input[attribute_register_map.attribute7_register] = input.attr[7]; - if (num_attributes > 8) state.registers.input[attribute_register_map.attribute8_register] = input.attr[8]; - if (num_attributes > 9) state.registers.input[attribute_register_map.attribute9_register] = input.attr[9]; - if (num_attributes > 10) state.registers.input[attribute_register_map.attribute10_register] = input.attr[10]; - if (num_attributes > 11) state.registers.input[attribute_register_map.attribute11_register] = input.attr[11]; - if (num_attributes > 12) state.registers.input[attribute_register_map.attribute12_register] = input.attr[12]; - if (num_attributes > 13) state.registers.input[attribute_register_map.attribute13_register] = input.attr[13]; - if (num_attributes > 14) state.registers.input[attribute_register_map.attribute14_register] = input.attr[14]; - if (num_attributes > 15) state.registers.input[attribute_register_map.attribute15_register] = input.attr[15]; + for (unsigned i = 0; i < num_attributes; i++) + state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; state.conditional_code[0] = false; state.conditional_code[1] = false; @@ -164,22 +152,8 @@ DebugData<true> ProduceDebugInfo(const InputVertex& input, int num_attributes, c float24 dummy_register; boost::fill(state.registers.input, &dummy_register); - if (num_attributes > 0) state.registers.input[attribute_register_map.attribute0_register] = &input.attr[0].x; - if (num_attributes > 1) state.registers.input[attribute_register_map.attribute1_register] = &input.attr[1].x; - if (num_attributes > 2) state.registers.input[attribute_register_map.attribute2_register] = &input.attr[2].x; - if (num_attributes > 3) state.registers.input[attribute_register_map.attribute3_register] = &input.attr[3].x; - if (num_attributes > 4) state.registers.input[attribute_register_map.attribute4_register] = &input.attr[4].x; - if (num_attributes > 5) state.registers.input[attribute_register_map.attribute5_register] = &input.attr[5].x; - if (num_attributes > 6) state.registers.input[attribute_register_map.attribute6_register] = &input.attr[6].x; - if (num_attributes > 7) state.registers.input[attribute_register_map.attribute7_register] = &input.attr[7].x; - if (num_attributes > 8) state.registers.input[attribute_register_map.attribute8_register] = &input.attr[8].x; - if (num_attributes > 9) state.registers.input[attribute_register_map.attribute9_register] = &input.attr[9].x; - if (num_attributes > 10) state.registers.input[attribute_register_map.attribute10_register] = &input.attr[10].x; - if (num_attributes > 11) state.registers.input[attribute_register_map.attribute11_register] = &input.attr[11].x; - if (num_attributes > 12) state.registers.input[attribute_register_map.attribute12_register] = &input.attr[12].x; - if (num_attributes > 13) state.registers.input[attribute_register_map.attribute13_register] = &input.attr[13].x; - if (num_attributes > 14) state.registers.input[attribute_register_map.attribute14_register] = &input.attr[14].x; - if (num_attributes > 15) state.registers.input[attribute_register_map.attribute15_register] = &input.attr[15].x; + for (unsigned i = 0; i < num_attributes; i++) + state.registers.input[attribute_register_map.GetRegisterForAttribute(i)] = input.attr[i]; state.conditional_code[0] = false; state.conditional_code[1] = false; diff --git a/src/video_core/shader/shader.h b/src/video_core/shader/shader.h index 9ce9344d2..56b83bfeb 100644 --- a/src/video_core/shader/shader.h +++ b/src/video_core/shader/shader.h @@ -4,17 +4,23 @@ #pragma once +#include <array> +#include <cstddef> +#include <memory> +#include <type_traits> #include <vector> #include <boost/container/static_vector.hpp> -#include <nihstro/shader_binary.h> +#include <nihstro/shader_bytecode.h> +#include "common/assert.h" #include "common/common_funcs.h" #include "common/common_types.h" #include "common/vector_math.h" #include "video_core/pica.h" +#include "video_core/pica_types.h" using nihstro::RegisterType; using nihstro::SourceRegister; diff --git a/src/video_core/shader/shader_interpreter.cpp b/src/video_core/shader/shader_interpreter.cpp index 9b978583e..7710f7fbc 100644 --- a/src/video_core/shader/shader_interpreter.cpp +++ b/src/video_core/shader/shader_interpreter.cpp @@ -2,12 +2,20 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <array> +#include <cmath> #include <numeric> + #include <nihstro/shader_bytecode.h> -#include "common/file_util.h" -#include "video_core/pica.h" +#include "common/assert.h" +#include "common/common_types.h" +#include "common/logging/log.h" +#include "common/vector_math.h" + #include "video_core/pica_state.h" +#include "video_core/pica_types.h" #include "video_core/shader/shader.h" #include "video_core/shader/shader_interpreter.h" diff --git a/src/video_core/shader/shader_interpreter.h b/src/video_core/shader/shader_interpreter.h index 294bca50e..6048cdf3a 100644 --- a/src/video_core/shader/shader_interpreter.h +++ b/src/video_core/shader/shader_interpreter.h @@ -4,12 +4,12 @@ #pragma once -#include "video_core/shader/shader.h" - namespace Pica { namespace Shader { +template <bool Debug> struct UnitState; + template<bool Debug> void RunInterpreter(UnitState<Debug>& state); diff --git a/src/video_core/shader/shader_jit_x64.cpp b/src/video_core/shader/shader_jit_x64.cpp index b7747fa42..99f6c51eb 100644 --- a/src/video_core/shader/shader_jit_x64.cpp +++ b/src/video_core/shader/shader_jit_x64.cpp @@ -3,8 +3,15 @@ // Refer to the license.txt file included. #include <algorithm> -#include <smmintrin.h> +#include <cmath> +#include <cstdint> +#include <xmmintrin.h> +#include <nihstro/shader_bytecode.h> + +#include "common/assert.h" +#include "common/logging/log.h" +#include "common/vector_math.h" #include "common/x64/abi.h" #include "common/x64/cpu_detect.h" #include "common/x64/emitter.h" @@ -13,6 +20,7 @@ #include "shader_jit_x64.h" #include "video_core/pica_state.h" +#include "video_core/pica_types.h" namespace Pica { diff --git a/src/video_core/shader/shader_jit_x64.h b/src/video_core/shader/shader_jit_x64.h index cd6280ade..30aa7ff30 100644 --- a/src/video_core/shader/shader_jit_x64.h +++ b/src/video_core/shader/shader_jit_x64.h @@ -4,14 +4,17 @@ #pragma once +#include <array> +#include <cstddef> #include <utility> #include <vector> #include <nihstro/shader_bytecode.h> +#include "common/bit_set.h" +#include "common/common_types.h" #include "common/x64/emitter.h" -#include "video_core/pica.h" #include "video_core/shader/shader.h" using nihstro::Instruction; diff --git a/src/video_core/swrasterizer.h b/src/video_core/swrasterizer.h index 090f899bc..0a028b774 100644 --- a/src/video_core/swrasterizer.h +++ b/src/video_core/swrasterizer.h @@ -8,6 +8,12 @@ #include "video_core/rasterizer_interface.h" +namespace Pica { +namespace Shader { +struct OutputVertex; +} +} + namespace VideoCore { class SWRasterizer : public RasterizerInterface { diff --git a/src/video_core/utils.cpp b/src/video_core/utils.cpp deleted file mode 100644 index 6e1ff5cf4..000000000 --- a/src/video_core/utils.cpp +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright 2014 Citra Emulator Project -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#include <cstdio> -#include <cstring> - -#include "video_core/utils.h" - -namespace VideoCore { - -/** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ -void DumpTGA(std::string filename, short width, short height, u8* raw_data) { - TGAHeader hdr = {0, 0, 2, 0, 0, 0, 0, width, height, 24, 0}; - FILE* fout = fopen(filename.c_str(), "wb"); - - fwrite(&hdr, sizeof(TGAHeader), 1, fout); - - for (int y = 0; y < height; y++) { - for (int x = 0; x < width; x++) { - putc(raw_data[(3 * (y * width)) + (3 * x) + 0], fout); // b - putc(raw_data[(3 * (y * width)) + (3 * x) + 1], fout); // g - putc(raw_data[(3 * (y * width)) + (3 * x) + 2], fout); // r - } - } - - fclose(fout); -} -} // namespace diff --git a/src/video_core/utils.h b/src/video_core/utils.h index 4fa60a10e..7ce83a055 100644 --- a/src/video_core/utils.h +++ b/src/video_core/utils.h @@ -4,37 +4,10 @@ #pragma once -#include <string> - #include "common/common_types.h" namespace VideoCore { -/// Structure for the TGA texture format (for dumping) -struct TGAHeader { - char idlength; - char colormaptype; - char datatypecode; - short int colormaporigin; - short int colormaplength; - short int x_origin; - short int y_origin; - short width; - short height; - char bitsperpixel; - char imagedescriptor; -}; - -/** - * Dumps a texture to TGA - * @param filename String filename to dump texture to - * @param width Width of texture in pixels - * @param height Height of texture in pixels - * @param raw_data Raw RGBA8 texture data to dump - * @todo This should be moved to some general purpose/common code - */ -void DumpTGA(std::string filename, short width, short height, u8* raw_data); - /** * Interleave the lower 3 bits of each coordinate to get the intra-block offsets, which are * arranged in a Z-order curve. More details on the bit manipulation at: diff --git a/src/video_core/vertex_loader.cpp b/src/video_core/vertex_loader.cpp index 8a3d91896..21ae52949 100644 --- a/src/video_core/vertex_loader.cpp +++ b/src/video_core/vertex_loader.cpp @@ -1,14 +1,13 @@ -#include <cmath> -#include <string> +#include <memory> -#include "boost/range/algorithm/fill.hpp" +#include <boost/range/algorithm/fill.hpp> #include "common/assert.h" #include "common/alignment.h" #include "common/bit_field.h" -#include "common/common_funcs.h" #include "common/common_types.h" #include "common/logging/log.h" +#include "common/vector_math.h" #include "core/memory.h" @@ -16,6 +15,7 @@ #include "video_core/pica.h" #include "video_core/pica_state.h" #include "video_core/pica_types.h" +#include "video_core/shader/shader.h" #include "video_core/vertex_loader.h" namespace Pica { @@ -137,4 +137,4 @@ void VertexLoader::LoadVertex(u32 base_address, int index, int vertex, Shader::I } } -} // namespace Pica
\ No newline at end of file +} // namespace Pica diff --git a/src/video_core/vertex_loader.h b/src/video_core/vertex_loader.h index ff42d1596..becf5a403 100644 --- a/src/video_core/vertex_loader.h +++ b/src/video_core/vertex_loader.h @@ -1,14 +1,19 @@ #pragma once -#include <iterator> -#include <algorithm> +#include "common/common_types.h" #include "video_core/pica.h" -#include "video_core/shader/shader.h" -#include "video_core/debug_utils/debug_utils.h" namespace Pica { +namespace DebugUtils { +class MemoryAccessTracker; +} + +namespace Shader { +class InputVertex; +} + class VertexLoader { public: void Setup(const Pica::Regs& regs); diff --git a/src/video_core/video_core.cpp b/src/video_core/video_core.cpp index 855286173..c9975876d 100644 --- a/src/video_core/video_core.cpp +++ b/src/video_core/video_core.cpp @@ -4,12 +4,8 @@ #include <memory> -#include "common/emu_window.h" #include "common/logging/log.h" -#include "core/core.h" -#include "core/settings.h" - #include "video_core/pica.h" #include "video_core/renderer_base.h" #include "video_core/video_core.h" |