summaryrefslogtreecommitdiff
path: root/src/video_core/rasterizer.cpp
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-01-27 20:51:59 -0800
committerGravatar Yuri Kunde Schlesner2017-02-04 13:59:09 -0800
commit9017093f58fb08b85cfb842f305efa667d62cecb (patch)
tree98a1e77b197a562a8f13565e62f2e8bb9220ff94 /src/video_core/rasterizer.cpp
parentVideoCore: Split rasterizer regs from Regs struct (diff)
downloadyuzu-9017093f58fb08b85cfb842f305efa667d62cecb.tar.gz
yuzu-9017093f58fb08b85cfb842f305efa667d62cecb.tar.xz
yuzu-9017093f58fb08b85cfb842f305efa667d62cecb.zip
VideoCore: Split texturing regs from Regs struct
Diffstat (limited to 'src/video_core/rasterizer.cpp')
-rw-r--r--src/video_core/rasterizer.cpp52
1 files changed, 27 insertions, 25 deletions
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index f82873480..48bc26571 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -397,8 +397,8 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
397 397
398 auto w_inverse = Math::MakeVec(v0.pos.w, v1.pos.w, v2.pos.w); 398 auto w_inverse = Math::MakeVec(v0.pos.w, v1.pos.w, v2.pos.w);
399 399
400 auto textures = regs.GetTextures(); 400 auto textures = regs.texturing.GetTextures();
401 auto tev_stages = regs.GetTevStages(); 401 auto tev_stages = regs.texturing.GetTevStages();
402 402
403 bool stencil_action_enable = g_state.regs.output_merger.stencil_test.enable && 403 bool stencil_action_enable = g_state.regs.output_merger.stencil_test.enable &&
404 g_state.regs.framebuffer.depth_format == Regs::DepthFormat::D24S8; 404 g_state.regs.framebuffer.depth_format == Regs::DepthFormat::D24S8;
@@ -515,9 +515,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
515 // TODO: Refactor so cubemaps and shadowmaps can be handled 515 // TODO: Refactor so cubemaps and shadowmaps can be handled
516 if (i == 0) { 516 if (i == 0) {
517 switch (texture.config.type) { 517 switch (texture.config.type) {
518 case Regs::TextureConfig::Texture2D: 518 case TexturingRegs::TextureConfig::Texture2D:
519 break; 519 break;
520 case Regs::TextureConfig::Projection2D: { 520 case TexturingRegs::TextureConfig::Projection2D: {
521 auto tc0_w = GetInterpolatedAttribute(v0.tc0_w, v1.tc0_w, v2.tc0_w); 521 auto tc0_w = GetInterpolatedAttribute(v0.tc0_w, v1.tc0_w, v2.tc0_w);
522 u /= tc0_w; 522 u /= tc0_w;
523 v /= tc0_w; 523 v /= tc0_w;
@@ -536,21 +536,21 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
536 int t = (int)(v * float24::FromFloat32(static_cast<float>(texture.config.height))) 536 int t = (int)(v * float24::FromFloat32(static_cast<float>(texture.config.height)))
537 .ToFloat32(); 537 .ToFloat32();
538 538
539 static auto GetWrappedTexCoord = [](Regs::TextureConfig::WrapMode mode, int val, 539 static auto GetWrappedTexCoord = [](TexturingRegs::TextureConfig::WrapMode mode,
540 unsigned size) { 540 int val, unsigned size) {
541 switch (mode) { 541 switch (mode) {
542 case Regs::TextureConfig::ClampToEdge: 542 case TexturingRegs::TextureConfig::ClampToEdge:
543 val = std::max(val, 0); 543 val = std::max(val, 0);
544 val = std::min(val, (int)size - 1); 544 val = std::min(val, (int)size - 1);
545 return val; 545 return val;
546 546
547 case Regs::TextureConfig::ClampToBorder: 547 case TexturingRegs::TextureConfig::ClampToBorder:
548 return val; 548 return val;
549 549
550 case Regs::TextureConfig::Repeat: 550 case TexturingRegs::TextureConfig::Repeat:
551 return (int)((unsigned)val % size); 551 return (int)((unsigned)val % size);
552 552
553 case Regs::TextureConfig::MirroredRepeat: { 553 case TexturingRegs::TextureConfig::MirroredRepeat: {
554 unsigned int coord = ((unsigned)val % (2 * size)); 554 unsigned int coord = ((unsigned)val % (2 * size));
555 if (coord >= size) 555 if (coord >= size)
556 coord = 2 * size - 1 - coord; 556 coord = 2 * size - 1 - coord;
@@ -564,9 +564,9 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
564 } 564 }
565 }; 565 };
566 566
567 if ((texture.config.wrap_s == Regs::TextureConfig::ClampToBorder && 567 if ((texture.config.wrap_s == TexturingRegs::TextureConfig::ClampToBorder &&
568 (s < 0 || static_cast<u32>(s) >= texture.config.width)) || 568 (s < 0 || static_cast<u32>(s) >= texture.config.width)) ||
569 (texture.config.wrap_t == Regs::TextureConfig::ClampToBorder && 569 (texture.config.wrap_t == TexturingRegs::TextureConfig::ClampToBorder &&
570 (t < 0 || static_cast<u32>(t) >= texture.config.height))) { 570 (t < 0 || static_cast<u32>(t) >= texture.config.height))) {
571 auto border_color = texture.config.border_color; 571 auto border_color = texture.config.border_color;
572 texture_color[i] = {border_color.r, border_color.g, border_color.b, 572 texture_color[i] = {border_color.r, border_color.g, border_color.b,
@@ -602,17 +602,19 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
602 Math::Vec4<u8> combiner_output; 602 Math::Vec4<u8> combiner_output;
603 Math::Vec4<u8> combiner_buffer = {0, 0, 0, 0}; 603 Math::Vec4<u8> combiner_buffer = {0, 0, 0, 0};
604 Math::Vec4<u8> next_combiner_buffer = { 604 Math::Vec4<u8> next_combiner_buffer = {
605 regs.tev_combiner_buffer_color.r, regs.tev_combiner_buffer_color.g, 605 regs.texturing.tev_combiner_buffer_color.r,
606 regs.tev_combiner_buffer_color.b, regs.tev_combiner_buffer_color.a, 606 regs.texturing.tev_combiner_buffer_color.g,
607 regs.texturing.tev_combiner_buffer_color.b,
608 regs.texturing.tev_combiner_buffer_color.a,
607 }; 609 };
608 610
609 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size(); 611 for (unsigned tev_stage_index = 0; tev_stage_index < tev_stages.size();
610 ++tev_stage_index) { 612 ++tev_stage_index) {
611 const auto& tev_stage = tev_stages[tev_stage_index]; 613 const auto& tev_stage = tev_stages[tev_stage_index];
612 using Source = Regs::TevStageConfig::Source; 614 using Source = TexturingRegs::TevStageConfig::Source;
613 using ColorModifier = Regs::TevStageConfig::ColorModifier; 615 using ColorModifier = TexturingRegs::TevStageConfig::ColorModifier;
614 using AlphaModifier = Regs::TevStageConfig::AlphaModifier; 616 using AlphaModifier = TexturingRegs::TevStageConfig::AlphaModifier;
615 using Operation = Regs::TevStageConfig::Operation; 617 using Operation = TexturingRegs::TevStageConfig::Operation;
616 618
617 auto GetSource = [&](Source source) -> Math::Vec4<u8> { 619 auto GetSource = [&](Source source) -> Math::Vec4<u8> {
618 switch (source) { 620 switch (source) {
@@ -864,14 +866,14 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
864 866
865 combiner_buffer = next_combiner_buffer; 867 combiner_buffer = next_combiner_buffer;
866 868
867 if (regs.tev_combiner_buffer_input.TevStageUpdatesCombinerBufferColor( 869 if (regs.texturing.tev_combiner_buffer_input.TevStageUpdatesCombinerBufferColor(
868 tev_stage_index)) { 870 tev_stage_index)) {
869 next_combiner_buffer.r() = combiner_output.r(); 871 next_combiner_buffer.r() = combiner_output.r();
870 next_combiner_buffer.g() = combiner_output.g(); 872 next_combiner_buffer.g() = combiner_output.g();
871 next_combiner_buffer.b() = combiner_output.b(); 873 next_combiner_buffer.b() = combiner_output.b();
872 } 874 }
873 875
874 if (regs.tev_combiner_buffer_input.TevStageUpdatesCombinerBufferAlpha( 876 if (regs.texturing.tev_combiner_buffer_input.TevStageUpdatesCombinerBufferAlpha(
875 tev_stage_index)) { 877 tev_stage_index)) {
876 next_combiner_buffer.a() = combiner_output.a(); 878 next_combiner_buffer.a() = combiner_output.a();
877 } 879 }
@@ -924,16 +926,16 @@ static void ProcessTriangleInternal(const Vertex& v0, const Vertex& v1, const Ve
924 // Not fully accurate. We'd have to know what data type is used to 926 // Not fully accurate. We'd have to know what data type is used to
925 // store the depth etc. Using float for now until we know more 927 // store the depth etc. Using float for now until we know more
926 // about Pica datatypes 928 // about Pica datatypes
927 if (regs.fog_mode == Regs::FogMode::Fog) { 929 if (regs.texturing.fog_mode == TexturingRegs::FogMode::Fog) {
928 const Math::Vec3<u8> fog_color = { 930 const Math::Vec3<u8> fog_color = {
929 static_cast<u8>(regs.fog_color.r.Value()), 931 static_cast<u8>(regs.texturing.fog_color.r.Value()),
930 static_cast<u8>(regs.fog_color.g.Value()), 932 static_cast<u8>(regs.texturing.fog_color.g.Value()),
931 static_cast<u8>(regs.fog_color.b.Value()), 933 static_cast<u8>(regs.texturing.fog_color.b.Value()),
932 }; 934 };
933 935
934 // Get index into fog LUT 936 // Get index into fog LUT
935 float fog_index; 937 float fog_index;
936 if (g_state.regs.fog_flip) { 938 if (g_state.regs.texturing.fog_flip) {
937 fog_index = (1.0f - depth) * 128.0f; 939 fog_index = (1.0f - depth) * 128.0f;
938 } else { 940 } else {
939 fog_index = depth * 128.0f; 941 fog_index = depth * 128.0f;