From 84054b7cd878feb4100a153837b74f816a9d4841 Mon Sep 17 00:00:00 2001 From: Dragios Date: Mon, 23 Oct 2017 23:58:40 +0800 Subject: [PATCH 1/3] Get rid of narrowing conversion warning --- src/video_core/swrasterizer/rasterizer.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index 862135614..06162bd1f 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -376,8 +376,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve if (use_border_s || use_border_t) { auto border_color = texture.config.border_color; - texture_color[i] = {border_color.r, border_color.g, border_color.b, - border_color.a}; + texture_color[i] = { + static_cast(border_color.r), static_cast(border_color.g), + static_cast(border_color.b), static_cast(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. @@ -415,10 +416,10 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve Math::Vec4 combiner_output; Math::Vec4 combiner_buffer = {0, 0, 0, 0}; Math::Vec4 next_combiner_buffer = { - regs.texturing.tev_combiner_buffer_color.r, - regs.texturing.tev_combiner_buffer_color.g, - regs.texturing.tev_combiner_buffer_color.b, - regs.texturing.tev_combiner_buffer_color.a, + static_cast(regs.texturing.tev_combiner_buffer_color.r), + static_cast(regs.texturing.tev_combiner_buffer_color.g), + static_cast(regs.texturing.tev_combiner_buffer_color.b), + static_cast(regs.texturing.tev_combiner_buffer_color.a), }; Math::Vec4 primary_fragment_color = {0, 0, 0, 0}; @@ -473,8 +474,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve return combiner_buffer; case Source::Constant: - return {tev_stage.const_r, tev_stage.const_g, tev_stage.const_b, - tev_stage.const_a}; + return { + static_cast(tev_stage.const_r), static_cast(tev_stage.const_g), + static_cast(tev_stage.const_b), static_cast(tev_stage.const_a)}; case Source::Previous: return combiner_output; From 9b3eb69973c368cc6e73bf8802f412085f1880a3 Mon Sep 17 00:00:00 2001 From: Dragios Date: Wed, 25 Oct 2017 22:03:21 +0800 Subject: [PATCH 2/3] Utilize vector function instead --- src/video_core/swrasterizer/rasterizer.cpp | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/video_core/swrasterizer/rasterizer.cpp b/src/video_core/swrasterizer/rasterizer.cpp index 06162bd1f..586587eb8 100644 --- a/src/video_core/swrasterizer/rasterizer.cpp +++ b/src/video_core/swrasterizer/rasterizer.cpp @@ -376,9 +376,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve if (use_border_s || use_border_t) { auto border_color = texture.config.border_color; - texture_color[i] = { - static_cast(border_color.r), static_cast(border_color.g), - static_cast(border_color.b), static_cast(border_color.a)}; + texture_color[i] = Math::MakeVec(border_color.r.Value(), border_color.g.Value(), + border_color.b.Value(), border_color.a.Value()) + .Cast(); } 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. @@ -415,12 +415,12 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve // analogously. Math::Vec4 combiner_output; Math::Vec4 combiner_buffer = {0, 0, 0, 0}; - Math::Vec4 next_combiner_buffer = { - static_cast(regs.texturing.tev_combiner_buffer_color.r), - static_cast(regs.texturing.tev_combiner_buffer_color.g), - static_cast(regs.texturing.tev_combiner_buffer_color.b), - static_cast(regs.texturing.tev_combiner_buffer_color.a), - }; + Math::Vec4 next_combiner_buffer = + Math::MakeVec(regs.texturing.tev_combiner_buffer_color.r.Value(), + regs.texturing.tev_combiner_buffer_color.g.Value(), + regs.texturing.tev_combiner_buffer_color.b.Value(), + regs.texturing.tev_combiner_buffer_color.a.Value()) + .Cast(); Math::Vec4 primary_fragment_color = {0, 0, 0, 0}; Math::Vec4 secondary_fragment_color = {0, 0, 0, 0}; @@ -474,9 +474,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve return combiner_buffer; case Source::Constant: - return { - static_cast(tev_stage.const_r), static_cast(tev_stage.const_g), - static_cast(tev_stage.const_b), static_cast(tev_stage.const_a)}; + return Math::MakeVec(tev_stage.const_r.Value(), tev_stage.const_g.Value(), + tev_stage.const_b.Value(), tev_stage.const_a.Value()) + .Cast(); case Source::Previous: return combiner_output; @@ -589,11 +589,10 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve // store the depth etc. Using float for now until we know more // about Pica datatypes if (regs.texturing.fog_mode == TexturingRegs::FogMode::Fog) { - const Math::Vec3 fog_color = { - static_cast(regs.texturing.fog_color.r.Value()), - static_cast(regs.texturing.fog_color.g.Value()), - static_cast(regs.texturing.fog_color.b.Value()), - }; + const Math::Vec3 fog_color = Math::MakeVec(regs.texturing.fog_color.r.Value(), + regs.texturing.fog_color.g.Value(), + regs.texturing.fog_color.b.Value()) + .Cast(); // Get index into fog LUT float fog_index; @@ -745,12 +744,12 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve FramebufferRegs::BlendFactor factor) -> u8 { DEBUG_ASSERT(channel < 4); - const Math::Vec4 blend_const = { - static_cast(output_merger.blend_const.r), - static_cast(output_merger.blend_const.g), - static_cast(output_merger.blend_const.b), - static_cast(output_merger.blend_const.a), - }; + const Math::Vec4 blend_const = + Math::MakeVec(output_merger.blend_const.r.Value(), + output_merger.blend_const.g.Value(), + output_merger.blend_const.b.Value(), + output_merger.blend_const.a.Value()) + .Cast(); switch (factor) { case FramebufferRegs::BlendFactor::Zero: @@ -851,5 +850,4 @@ void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2) { } } // namespace Rasterizer - } // namespace Pica From 3e26b0dee5208d6d0efd0702259ded44571fcc4d Mon Sep 17 00:00:00 2001 From: Dragios Date: Fri, 27 Oct 2017 09:44:45 +0800 Subject: [PATCH 3/3] swrasterizer folder minor edit --- src/video_core/swrasterizer/clipper.cpp | 6 ++---- src/video_core/swrasterizer/clipper.h | 6 ++---- src/video_core/swrasterizer/rasterizer.h | 2 -- src/video_core/swrasterizer/swrasterizer.cpp | 3 ++- src/video_core/swrasterizer/swrasterizer.h | 3 ++- 5 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/video_core/swrasterizer/clipper.cpp b/src/video_core/swrasterizer/clipper.cpp index c1ed48398..4ede218e3 100644 --- a/src/video_core/swrasterizer/clipper.cpp +++ b/src/video_core/swrasterizer/clipper.cpp @@ -20,7 +20,6 @@ using Pica::Rasterizer::Vertex; namespace Pica { - namespace Clipper { struct ClippingEdge { @@ -192,6 +191,5 @@ void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const Outpu } } -} // namespace - -} // namespace +} // namespace Clipper +} // namespace Pica diff --git a/src/video_core/swrasterizer/clipper.h b/src/video_core/swrasterizer/clipper.h index b51af0af9..c9e14e3d7 100644 --- a/src/video_core/swrasterizer/clipper.h +++ b/src/video_core/swrasterizer/clipper.h @@ -5,7 +5,6 @@ #pragma once namespace Pica { - namespace Shader { struct OutputVertex; } @@ -16,6 +15,5 @@ using Shader::OutputVertex; void ProcessTriangle(const OutputVertex& v0, const OutputVertex& v1, const OutputVertex& v2); -} // namespace - -} // namespace +} // namespace Clipper +} // namespace Pica diff --git a/src/video_core/swrasterizer/rasterizer.h b/src/video_core/swrasterizer/rasterizer.h index 66cd6cfd4..0670776a9 100644 --- a/src/video_core/swrasterizer/rasterizer.h +++ b/src/video_core/swrasterizer/rasterizer.h @@ -7,7 +7,6 @@ #include "video_core/shader/shader.h" namespace Pica { - namespace Rasterizer { struct Vertex : Shader::OutputVertex { @@ -44,5 +43,4 @@ struct Vertex : Shader::OutputVertex { void ProcessTriangle(const Vertex& v0, const Vertex& v1, const Vertex& v2); } // namespace Rasterizer - } // namespace Pica diff --git a/src/video_core/swrasterizer/swrasterizer.cpp b/src/video_core/swrasterizer/swrasterizer.cpp index 402b705dd..cda5d52da 100644 --- a/src/video_core/swrasterizer/swrasterizer.cpp +++ b/src/video_core/swrasterizer/swrasterizer.cpp @@ -12,4 +12,5 @@ void SWRasterizer::AddTriangle(const Pica::Shader::OutputVertex& v0, const Pica::Shader::OutputVertex& v2) { Pica::Clipper::ProcessTriangle(v0, v1, v2); } -} + +} // namespace VideoCore diff --git a/src/video_core/swrasterizer/swrasterizer.h b/src/video_core/swrasterizer/swrasterizer.h index 6d42d7409..87e64f8f6 100644 --- a/src/video_core/swrasterizer/swrasterizer.h +++ b/src/video_core/swrasterizer/swrasterizer.h @@ -24,4 +24,5 @@ class SWRasterizer : public RasterizerInterface { void FlushRegion(PAddr addr, u32 size) override {} void FlushAndInvalidateRegion(PAddr addr, u32 size) override {} }; -} + +} // namespace VideoCore