diff options
Diffstat (limited to '')
| -rw-r--r-- | src/video_core/pica.h | 69 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 30 |
2 files changed, 51 insertions, 48 deletions
diff --git a/src/video_core/pica.h b/src/video_core/pica.h index 809b16d2b..9077b1725 100644 --- a/src/video_core/pica.h +++ b/src/video_core/pica.h | |||
| @@ -762,7 +762,7 @@ struct Regs { | |||
| 762 | 762 | ||
| 763 | union { | 763 | union { |
| 764 | BitField<0, 1, u32> directional; | 764 | BitField<0, 1, u32> directional; |
| 765 | BitField<1, 1, u32> two_sided_diffuse; // 1: GL_TRUE, 0: GL_FALSE; when disabled, clamp dot-product to 0 | 765 | BitField<1, 1, u32> two_sided_diffuse; // When disabled, clamp dot-product to 0 |
| 766 | }; | 766 | }; |
| 767 | }; | 767 | }; |
| 768 | 768 | ||
| @@ -774,46 +774,46 @@ struct Regs { | |||
| 774 | static_assert(sizeof(LightSrc) == 0x10 * sizeof(u32), "LightSrc structure must be 0x10 words"); | 774 | static_assert(sizeof(LightSrc) == 0x10 * sizeof(u32), "LightSrc structure must be 0x10 words"); |
| 775 | 775 | ||
| 776 | LightSrc light[8]; | 776 | LightSrc light[8]; |
| 777 | LightColor global_ambient; // emission + (material.ambient * lighting.ambient) | 777 | LightColor global_ambient; // Emission + (material.ambient * lighting.ambient) |
| 778 | INSERT_PADDING_WORDS(0x1); | 778 | INSERT_PADDING_WORDS(0x1); |
| 779 | BitField<0, 3, u32> src_num; // number of enabled lights - 1 | 779 | BitField<0, 3, u32> num_lights; // Number of enabled lights - 1 |
| 780 | 780 | ||
| 781 | union { | 781 | union { |
| 782 | BitField< 2, 2, LightingFresnelSelector> fresnel_selector; | 782 | BitField< 2, 2, LightingFresnelSelector> fresnel_selector; |
| 783 | BitField< 4, 4, LightingConfig> config; | 783 | BitField< 4, 4, LightingConfig> config; |
| 784 | BitField<22, 2, u32> bump_selector; // 0: Texture 0, 1: Texture 1, 2: Texture 2 | 784 | BitField<22, 2, u32> bump_selector; // 0: Texture 0, 1: Texture 1, 2: Texture 2 |
| 785 | BitField<27, 1, u32> clamp_highlights; // 1: GL_TRUE, 0: GL_FALSE | 785 | BitField<27, 1, u32> clamp_highlights; |
| 786 | BitField<28, 2, LightingBumpMode> bump_mode; // 1: GL_TRUE, 0: GL_FALSE | 786 | BitField<28, 2, LightingBumpMode> bump_mode; |
| 787 | BitField<30, 1, u32> bump_renorm; // 0: GL_TRUE, 1: GL_FALSE | 787 | BitField<30, 1, u32> disable_bump_renorm; |
| 788 | }; | 788 | }; |
| 789 | 789 | ||
| 790 | union { | 790 | union { |
| 791 | BitField<16, 1, u32> lut_enable_d0; // 0: GL_TRUE, 1: GL_FALSE | 791 | BitField<16, 1, u32> disable_lut_d0; |
| 792 | BitField<17, 1, u32> lut_enable_d1; // 0: GL_TRUE, 1: GL_FALSE | 792 | BitField<17, 1, u32> disable_lut_d1; |
| 793 | BitField<19, 1, u32> lut_enable_fr; // 0: GL_TRUE, 1: GL_FALSE | 793 | BitField<19, 1, u32> disable_lut_fr; |
| 794 | BitField<20, 1, u32> lut_enable_rr; // 0: GL_TRUE, 1: GL_FALSE | 794 | BitField<20, 1, u32> disable_lut_rr; |
| 795 | BitField<21, 1, u32> lut_enable_rg; // 0: GL_TRUE, 1: GL_FALSE | 795 | BitField<21, 1, u32> disable_lut_rg; |
| 796 | BitField<22, 1, u32> lut_enable_rb; // 0: GL_TRUE, 1: GL_FALSE | 796 | BitField<22, 1, u32> disable_lut_rb; |
| 797 | 797 | ||
| 798 | // Each bit specifies whether distance attenuation should be applied for the | 798 | // Each bit specifies whether distance attenuation should be applied for the |
| 799 | // corresponding light | 799 | // corresponding light |
| 800 | 800 | ||
| 801 | BitField<24, 1, u32> dist_atten_enable_light_0; // 0: GL_TRUE, 1: GL_FALSE | 801 | BitField<24, 1, u32> disable_dist_atten_light_0; |
| 802 | BitField<25, 1, u32> dist_atten_enable_light_1; // 0: GL_TRUE, 1: GL_FALSE | 802 | BitField<25, 1, u32> disable_dist_atten_light_1; |
| 803 | BitField<26, 1, u32> dist_atten_enable_light_2; // 0: GL_TRUE, 1: GL_FALSE | 803 | BitField<26, 1, u32> disable_dist_atten_light_2; |
| 804 | BitField<27, 1, u32> dist_atten_enable_light_3; // 0: GL_TRUE, 1: GL_FALSE | 804 | BitField<27, 1, u32> disable_dist_atten_light_3; |
| 805 | BitField<28, 1, u32> dist_atten_enable_light_4; // 0: GL_TRUE, 1: GL_FALSE | 805 | BitField<28, 1, u32> disable_dist_atten_light_4; |
| 806 | BitField<29, 1, u32> dist_atten_enable_light_5; // 0: GL_TRUE, 1: GL_FALSE | 806 | BitField<29, 1, u32> disable_dist_atten_light_5; |
| 807 | BitField<30, 1, u32> dist_atten_enable_light_6; // 0: GL_TRUE, 1: GL_FALSE | 807 | BitField<30, 1, u32> disable_dist_atten_light_6; |
| 808 | BitField<31, 1, u32> dist_atten_enable_light_7; // 0: GL_TRUE, 1: GL_FALSE | 808 | BitField<31, 1, u32> disable_dist_atten_light_7; |
| 809 | }; | 809 | }; |
| 810 | 810 | ||
| 811 | bool IsDistAttenEnabled(unsigned index) const { | 811 | bool IsDistAttenDisabled(unsigned index) const { |
| 812 | const unsigned enable[] = { dist_atten_enable_light_0, dist_atten_enable_light_1, | 812 | const unsigned disable[] = { disable_dist_atten_light_0, disable_dist_atten_light_1, |
| 813 | dist_atten_enable_light_2, dist_atten_enable_light_3, | 813 | disable_dist_atten_light_2, disable_dist_atten_light_3, |
| 814 | dist_atten_enable_light_4, dist_atten_enable_light_5, | 814 | disable_dist_atten_light_4, disable_dist_atten_light_5, |
| 815 | dist_atten_enable_light_6, dist_atten_enable_light_7 }; | 815 | disable_dist_atten_light_6, disable_dist_atten_light_7 }; |
| 816 | return enable[index] == 0; | 816 | return disable[index] != 0; |
| 817 | } | 817 | } |
| 818 | 818 | ||
| 819 | union { | 819 | union { |
| @@ -830,14 +830,17 @@ struct Regs { | |||
| 830 | // registers is written to, the behavior will be the same. | 830 | // registers is written to, the behavior will be the same. |
| 831 | u32 lut_data[8]; | 831 | u32 lut_data[8]; |
| 832 | 832 | ||
| 833 | // These are used to specify if absolute (abs) value should be used for each LUT index. When | ||
| 834 | // abs mode is disabled, LUT indexes are in the range of (-1.0, 1.0). Otherwise, they are in | ||
| 835 | // the range of (0.0, 1.0). | ||
| 833 | union { | 836 | union { |
| 834 | BitField< 1, 1, u32> d0; // 0: GL_TRUE, 1: GL_FALSE | 837 | BitField< 1, 1, u32> disable_d0; |
| 835 | BitField< 5, 1, u32> d1; // 0: GL_TRUE, 1: GL_FALSE | 838 | BitField< 5, 1, u32> disable_d1; |
| 836 | BitField< 9, 1, u32> sp; // 0: GL_TRUE, 1: GL_FALSE | 839 | BitField< 9, 1, u32> disable_sp; |
| 837 | BitField<13, 1, u32> fr; // 0: GL_TRUE, 1: GL_FALSE | 840 | BitField<13, 1, u32> disable_fr; |
| 838 | BitField<17, 1, u32> rb; // 0: GL_TRUE, 1: GL_FALSE | 841 | BitField<17, 1, u32> disable_rb; |
| 839 | BitField<21, 1, u32> rg; // 0: GL_TRUE, 1: GL_FALSE | 842 | BitField<21, 1, u32> disable_rg; |
| 840 | BitField<25, 1, u32> rr; // 0: GL_TRUE, 1: GL_FALSE | 843 | BitField<25, 1, u32> disable_rr; |
| 841 | } abs_lut_input; | 844 | } abs_lut_input; |
| 842 | 845 | ||
| 843 | union { | 846 | union { |
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index 208a7bcb6..fef5f5331 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h | |||
| @@ -75,7 +75,7 @@ struct PicaShaderConfig { | |||
| 75 | // Fragment lighting | 75 | // Fragment lighting |
| 76 | 76 | ||
| 77 | res.lighting.enable = !regs.lighting.disable; | 77 | res.lighting.enable = !regs.lighting.disable; |
| 78 | res.lighting.src_num = regs.lighting.src_num + 1; | 78 | res.lighting.src_num = regs.lighting.num_lights + 1; |
| 79 | 79 | ||
| 80 | for (unsigned light_index = 0; light_index < res.lighting.src_num; ++light_index) { | 80 | for (unsigned light_index = 0; light_index < res.lighting.src_num; ++light_index) { |
| 81 | unsigned num = regs.lighting.light_enable.GetNum(light_index); | 81 | unsigned num = regs.lighting.light_enable.GetNum(light_index); |
| @@ -83,38 +83,38 @@ struct PicaShaderConfig { | |||
| 83 | res.lighting.light[light_index].num = num; | 83 | res.lighting.light[light_index].num = num; |
| 84 | res.lighting.light[light_index].directional = light.directional != 0; | 84 | res.lighting.light[light_index].directional = light.directional != 0; |
| 85 | res.lighting.light[light_index].two_sided_diffuse = light.two_sided_diffuse != 0; | 85 | res.lighting.light[light_index].two_sided_diffuse = light.two_sided_diffuse != 0; |
| 86 | res.lighting.light[light_index].dist_atten_enable = regs.lighting.IsDistAttenEnabled(num); | 86 | res.lighting.light[light_index].dist_atten_enable = !regs.lighting.IsDistAttenDisabled(num); |
| 87 | res.lighting.light[light_index].dist_atten_bias = Pica::float20::FromRaw(light.dist_atten_bias).ToFloat32(); | 87 | res.lighting.light[light_index].dist_atten_bias = Pica::float20::FromRaw(light.dist_atten_bias).ToFloat32(); |
| 88 | res.lighting.light[light_index].dist_atten_scale = Pica::float20::FromRaw(light.dist_atten_scale).ToFloat32(); | 88 | res.lighting.light[light_index].dist_atten_scale = Pica::float20::FromRaw(light.dist_atten_scale).ToFloat32(); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | res.lighting.lut_d0.enable = regs.lighting.lut_enable_d0 == 0; | 91 | res.lighting.lut_d0.enable = regs.lighting.disable_lut_d0 == 0; |
| 92 | res.lighting.lut_d0.abs_input = regs.lighting.abs_lut_input.d0 == 0; | 92 | res.lighting.lut_d0.abs_input = regs.lighting.abs_lut_input.disable_d0 == 0; |
| 93 | res.lighting.lut_d0.type = regs.lighting.lut_input.d0.Value(); | 93 | res.lighting.lut_d0.type = regs.lighting.lut_input.d0.Value(); |
| 94 | res.lighting.lut_d0.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d0); | 94 | res.lighting.lut_d0.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d0); |
| 95 | 95 | ||
| 96 | res.lighting.lut_d1.enable = regs.lighting.lut_enable_d1 == 0; | 96 | res.lighting.lut_d1.enable = regs.lighting.disable_lut_d1 == 0; |
| 97 | res.lighting.lut_d1.abs_input = regs.lighting.abs_lut_input.d1 == 0; | 97 | res.lighting.lut_d1.abs_input = regs.lighting.abs_lut_input.disable_d1 == 0; |
| 98 | res.lighting.lut_d1.type = regs.lighting.lut_input.d1.Value(); | 98 | res.lighting.lut_d1.type = regs.lighting.lut_input.d1.Value(); |
| 99 | res.lighting.lut_d1.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d1); | 99 | res.lighting.lut_d1.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d1); |
| 100 | 100 | ||
| 101 | res.lighting.lut_fr.enable = regs.lighting.lut_enable_fr == 0; | 101 | res.lighting.lut_fr.enable = regs.lighting.disable_lut_fr == 0; |
| 102 | res.lighting.lut_fr.abs_input = regs.lighting.abs_lut_input.fr == 0; | 102 | res.lighting.lut_fr.abs_input = regs.lighting.abs_lut_input.disable_fr == 0; |
| 103 | res.lighting.lut_fr.type = regs.lighting.lut_input.fr.Value(); | 103 | res.lighting.lut_fr.type = regs.lighting.lut_input.fr.Value(); |
| 104 | res.lighting.lut_fr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.fr); | 104 | res.lighting.lut_fr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.fr); |
| 105 | 105 | ||
| 106 | res.lighting.lut_rr.enable = regs.lighting.lut_enable_rr == 0; | 106 | res.lighting.lut_rr.enable = regs.lighting.disable_lut_rr == 0; |
| 107 | res.lighting.lut_rr.abs_input = regs.lighting.abs_lut_input.rr == 0; | 107 | res.lighting.lut_rr.abs_input = regs.lighting.abs_lut_input.disable_rr == 0; |
| 108 | res.lighting.lut_rr.type = regs.lighting.lut_input.rr.Value(); | 108 | res.lighting.lut_rr.type = regs.lighting.lut_input.rr.Value(); |
| 109 | res.lighting.lut_rr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rr); | 109 | res.lighting.lut_rr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rr); |
| 110 | 110 | ||
| 111 | res.lighting.lut_rg.enable = regs.lighting.lut_enable_rg == 0; | 111 | res.lighting.lut_rg.enable = regs.lighting.disable_lut_rg == 0; |
| 112 | res.lighting.lut_rg.abs_input = regs.lighting.abs_lut_input.rg == 0; | 112 | res.lighting.lut_rg.abs_input = regs.lighting.abs_lut_input.disable_rg == 0; |
| 113 | res.lighting.lut_rg.type = regs.lighting.lut_input.rg.Value(); | 113 | res.lighting.lut_rg.type = regs.lighting.lut_input.rg.Value(); |
| 114 | res.lighting.lut_rg.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rg); | 114 | res.lighting.lut_rg.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rg); |
| 115 | 115 | ||
| 116 | res.lighting.lut_rb.enable = regs.lighting.lut_enable_rb == 0; | 116 | res.lighting.lut_rb.enable = regs.lighting.disable_lut_rb == 0; |
| 117 | res.lighting.lut_rb.abs_input = regs.lighting.abs_lut_input.rb == 0; | 117 | res.lighting.lut_rb.abs_input = regs.lighting.abs_lut_input.disable_rb == 0; |
| 118 | res.lighting.lut_rb.type = regs.lighting.lut_input.rb.Value(); | 118 | res.lighting.lut_rb.type = regs.lighting.lut_input.rb.Value(); |
| 119 | res.lighting.lut_rb.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rb); | 119 | res.lighting.lut_rb.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rb); |
| 120 | 120 | ||
| @@ -122,7 +122,7 @@ struct PicaShaderConfig { | |||
| 122 | res.lighting.fresnel_selector = regs.lighting.fresnel_selector; | 122 | res.lighting.fresnel_selector = regs.lighting.fresnel_selector; |
| 123 | res.lighting.bump_mode = regs.lighting.bump_mode; | 123 | res.lighting.bump_mode = regs.lighting.bump_mode; |
| 124 | res.lighting.bump_selector = regs.lighting.bump_selector; | 124 | res.lighting.bump_selector = regs.lighting.bump_selector; |
| 125 | res.lighting.bump_renorm = regs.lighting.bump_renorm == 0; | 125 | res.lighting.bump_renorm = regs.lighting.disable_bump_renorm == 0; |
| 126 | res.lighting.clamp_highlights = regs.lighting.clamp_highlights != 0; | 126 | res.lighting.clamp_highlights = regs.lighting.clamp_highlights != 0; |
| 127 | 127 | ||
| 128 | return res; | 128 | return res; |