diff options
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/command_processor.cpp | 12 | ||||
| -rw-r--r-- | src/video_core/command_processor.h | 4 | ||||
| -rw-r--r-- | src/video_core/debug_utils/debug_utils.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/hwrasterizer_base.h | 9 | ||||
| -rw-r--r-- | src/video_core/pica.h | 14 | ||||
| -rw-r--r-- | src/video_core/rasterizer.cpp | 31 | ||||
| -rw-r--r-- | src/video_core/renderer_base.h | 4 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 9 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 5 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/pica_to_gl.h | 2 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/renderer_opengl.cpp | 15 | ||||
| -rw-r--r-- | src/video_core/vertex_shader.h | 5 | ||||
| -rw-r--r-- | src/video_core/video_core.h | 7 |
13 files changed, 77 insertions, 41 deletions
diff --git a/src/video_core/command_processor.cpp b/src/video_core/command_processor.cpp index b46fadd9f..110caec76 100644 --- a/src/video_core/command_processor.cpp +++ b/src/video_core/command_processor.cpp @@ -6,18 +6,20 @@ #include "common/profiler.h" +#include "core/hle/service/gsp_gpu.h" +#include "core/hw/gpu.h" +#include "core/settings.h" + +#include "debug_utils/debug_utils.h" + #include "clipper.h" #include "command_processor.h" #include "math.h" #include "pica.h" #include "primitive_assembly.h" +#include "renderer_base.h" #include "vertex_shader.h" #include "video_core.h" -#include "core/hle/service/gsp_gpu.h" -#include "core/hw/gpu.h" -#include "core/settings.h" - -#include "debug_utils/debug_utils.h" namespace Pica { diff --git a/src/video_core/command_processor.h b/src/video_core/command_processor.h index bb3d4150f..022a71f5e 100644 --- a/src/video_core/command_processor.h +++ b/src/video_core/command_processor.h @@ -4,11 +4,11 @@ #pragma once +#include <type_traits> + #include "common/bit_field.h" #include "common/common_types.h" -#include "pica.h" - namespace Pica { namespace CommandProcessor { diff --git a/src/video_core/debug_utils/debug_utils.cpp b/src/video_core/debug_utils/debug_utils.cpp index 7b8ab72b6..d24c0f11e 100644 --- a/src/video_core/debug_utils/debug_utils.cpp +++ b/src/video_core/debug_utils/debug_utils.cpp @@ -23,6 +23,7 @@ #include "common/vector_math.h" #include "video_core/pica.h" +#include "video_core/renderer_base.h" #include "video_core/utils.h" #include "video_core/video_core.h" diff --git a/src/video_core/hwrasterizer_base.h b/src/video_core/hwrasterizer_base.h index dec193f8b..c8746c608 100644 --- a/src/video_core/hwrasterizer_base.h +++ b/src/video_core/hwrasterizer_base.h @@ -4,8 +4,13 @@ #pragma once -#include "common/emu_window.h" -#include "video_core/vertex_shader.h" +#include "common/common_types.h" + +namespace Pica { +namespace VertexShader { +struct OutputVertex; +} +} class HWRasterizer { public: diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 9628a7589..feb20214a 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h @@ -5,10 +5,10 @@ #pragma once #include <array> +#include <cmath> #include <cstddef> -#include <initializer_list> #include <map> -#include <vector> +#include <string> #include "common/assert.h" #include "common/bit_field.h" @@ -114,11 +114,17 @@ struct Regs { struct TextureConfig { enum WrapMode : u32 { ClampToEdge = 0, + ClampToBorder = 1, Repeat = 2, MirroredRepeat = 3, }; - INSERT_PADDING_WORDS(0x1); + union { + BitField< 0, 8, u32> r; + BitField< 8, 8, u32> g; + BitField<16, 8, u32> b; + BitField<24, 8, u32> a; + } border_color; union { BitField< 0, 16, u32> height; @@ -1014,7 +1020,7 @@ struct float24 { u32 mantissa = hex & 0xFFFF; u32 exponent = (hex >> 16) & 0x7F; u32 sign = hex >> 23; - ret.value = powf(2.0f, (float)exponent-63.0f) * (1.0f + mantissa * powf(2.0f, -16.f)); + ret.value = std::pow(2.0f, (float)exponent-63.0f) * (1.0f + mantissa * std::pow(2.0f, -16.f)); if (sign) ret.value = -ret.value; } diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp index 59d156ee7..70b115744 100644 --- a/src/video_core/rasterizer.cpp +++ b/src/video_core/rasterizer.cpp @@ -349,6 +349,9 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, val = std::min(val, (int)size - 1); return val; + case Regs::TextureConfig::ClampToBorder: + return val; + case Regs::TextureConfig::Repeat: return (int)((unsigned)val % size); @@ -367,17 +370,23 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0, } }; - // Textures are laid out from bottom to top, hence we invert the t coordinate. - // NOTE: This may not be the right place for the inversion. - // TODO: Check if this applies to ETC textures, too. - s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width); - t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height); - - u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress()); - auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); - - texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); - DebugUtils::DumpTexture(texture.config, texture_data); + if ((texture.config.wrap_s == Regs::TextureConfig::ClampToBorder && (s < 0 || s >= texture.config.width)) + || (texture.config.wrap_t == Regs::TextureConfig::ClampToBorder && (t < 0 || t >= texture.config.height))) { + auto border_color = texture.config.border_color; + texture_color[i] = { border_color.r, border_color.g, border_color.b, border_color.a }; + } else { + // Textures are laid out from bottom to top, hence we invert the t coordinate. + // NOTE: This may not be the right place for the inversion. + // TODO: Check if this applies to ETC textures, too. + s = GetWrappedTexCoord(texture.config.wrap_s, s, texture.config.width); + t = texture.config.height - 1 - GetWrappedTexCoord(texture.config.wrap_t, t, texture.config.height); + + u8* texture_data = Memory::GetPhysicalPointer(texture.config.GetPhysicalAddress()); + auto info = DebugUtils::TextureInfo::FromPicaRegister(texture.config, texture.format); + + texture_color[i] = DebugUtils::LookupTexture(texture_data, s, t, info); + DebugUtils::DumpTexture(texture.config, texture_data); + } } // Texture environment - consists of 6 stages of color and alpha combining. diff --git a/src/video_core/renderer_base.h b/src/video_core/renderer_base.h index 5757ac75d..6587bcf27 100644 --- a/src/video_core/renderer_base.h +++ b/src/video_core/renderer_base.h @@ -4,10 +4,14 @@ #pragma once +#include <memory> + #include "common/common_types.h" #include "video_core/hwrasterizer_base.h" +class EmuWindow; + class RendererBase : NonCopyable { public: diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 518f79331..935a9f281 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -2,10 +2,15 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <cstring> +#include <memory> + #include "common/color.h" +#include "common/math_util.h" -#include "core/settings.h" #include "core/hw/gpu.h" +#include "core/memory.h" +#include "core/settings.h" #include "video_core/pica.h" #include "video_core/utils.h" @@ -16,8 +21,6 @@ #include "generated/gl_3_2_core.h" -#include <memory> - static bool IsPassThroughTevStage(const Pica::Regs::TevStageConfig& stage) { return (stage.color_op == Pica::Regs::TevStageConfig::Operation::Replace && stage.alpha_op == Pica::Regs::TevStageConfig::Operation::Replace && diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index d7d422b1f..ae7b26fc6 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -4,7 +4,12 @@ #pragma once +#include <vector> + +#include "common/common_types.h" + #include "video_core/hwrasterizer_base.h" +#include "video_core/vertex_shader.h" #include "gl_state.h" #include "gl_rasterizer_cache.h" diff --git a/src/video_core/renderer_opengl/pica_to_gl.h b/src/video_core/renderer_opengl/pica_to_gl.h index e566f9f7a..73f63c55d 100644 --- a/src/video_core/renderer_opengl/pica_to_gl.h +++ b/src/video_core/renderer_opengl/pica_to_gl.h @@ -15,7 +15,7 @@ namespace PicaToGL { inline GLenum WrapMode(Pica::Regs::TextureConfig::WrapMode mode) { static const GLenum wrap_mode_table[] = { GL_CLAMP_TO_EDGE, // WrapMode::ClampToEdge - 0, // Unknown + GL_CLAMP_TO_BORDER,// WrapMode::ClampToBorder GL_REPEAT, // WrapMode::Repeat GL_MIRRORED_REPEAT // WrapMode::MirroredRepeat }; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 3399ca123..9799f74fa 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -2,23 +2,26 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include <algorithm> +#include <cstddef> +#include <cstdlib> + +#include "common/assert.h" +#include "common/emu_window.h" +#include "common/logging/log.h" +#include "common/profiler_reporting.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 "common/emu_window.h" -#include "common/logging/log.h" -#include "common/profiler_reporting.h" - #include "video_core/video_core.h" #include "video_core/renderer_opengl/renderer_opengl.h" #include "video_core/renderer_opengl/gl_shader_util.h" #include "video_core/renderer_opengl/gl_shaders.h" -#include <algorithm> - /** * Vertex structure that the drawn screen rectangles are composed of. */ diff --git a/src/video_core/vertex_shader.h b/src/video_core/vertex_shader.h index 7471a6de8..c997e6a77 100644 --- a/src/video_core/vertex_shader.h +++ b/src/video_core/vertex_shader.h @@ -4,11 +4,10 @@ #pragma once -#include <initializer_list> +#include <type_traits> -#include <common/common_types.h> +#include "common/vector_math.h" -#include "math.h" #include "pica.h" namespace Pica { diff --git a/src/video_core/video_core.h b/src/video_core/video_core.h index 3f24df7bd..14b33c9dd 100644 --- a/src/video_core/video_core.h +++ b/src/video_core/video_core.h @@ -4,12 +4,11 @@ #pragma once -#include "common/emu_window.h" - -#include "renderer_base.h" - #include <atomic> +class EmuWindow; +class RendererBase; + //////////////////////////////////////////////////////////////////////////////////////////////////// // Video Core namespace |
