2
1
Fork 0
mirror of https://github.com/yuzu-emu/yuzu.git synced 2024-07-04 23:31:19 +01:00

pica: Cleanup lighting register definitions and documentation.

This commit is contained in:
bunnei 2016-02-04 21:51:56 -05:00
parent c4d318f691
commit 19557aaab3
2 changed files with 51 additions and 48 deletions

View file

@ -762,7 +762,7 @@ struct Regs {
union {
BitField<0, 1, u32> directional;
BitField<1, 1, u32> two_sided_diffuse; // 1: GL_TRUE, 0: GL_FALSE; when disabled, clamp dot-product to 0
BitField<1, 1, u32> two_sided_diffuse; // When disabled, clamp dot-product to 0
};
};
@ -774,46 +774,46 @@ struct Regs {
static_assert(sizeof(LightSrc) == 0x10 * sizeof(u32), "LightSrc structure must be 0x10 words");
LightSrc light[8];
LightColor global_ambient; // emission + (material.ambient * lighting.ambient)
LightColor global_ambient; // Emission + (material.ambient * lighting.ambient)
INSERT_PADDING_WORDS(0x1);
BitField<0, 3, u32> src_num; // number of enabled lights - 1
BitField<0, 3, u32> num_lights; // Number of enabled lights - 1
union {
BitField< 2, 2, LightingFresnelSelector> fresnel_selector;
BitField< 4, 4, LightingConfig> config;
BitField<22, 2, u32> bump_selector; // 0: Texture 0, 1: Texture 1, 2: Texture 2
BitField<27, 1, u32> clamp_highlights; // 1: GL_TRUE, 0: GL_FALSE
BitField<28, 2, LightingBumpMode> bump_mode; // 1: GL_TRUE, 0: GL_FALSE
BitField<30, 1, u32> bump_renorm; // 0: GL_TRUE, 1: GL_FALSE
BitField<27, 1, u32> clamp_highlights;
BitField<28, 2, LightingBumpMode> bump_mode;
BitField<30, 1, u32> disable_bump_renorm;
};
union {
BitField<16, 1, u32> lut_enable_d0; // 0: GL_TRUE, 1: GL_FALSE
BitField<17, 1, u32> lut_enable_d1; // 0: GL_TRUE, 1: GL_FALSE
BitField<19, 1, u32> lut_enable_fr; // 0: GL_TRUE, 1: GL_FALSE
BitField<20, 1, u32> lut_enable_rr; // 0: GL_TRUE, 1: GL_FALSE
BitField<21, 1, u32> lut_enable_rg; // 0: GL_TRUE, 1: GL_FALSE
BitField<22, 1, u32> lut_enable_rb; // 0: GL_TRUE, 1: GL_FALSE
BitField<16, 1, u32> disable_lut_d0;
BitField<17, 1, u32> disable_lut_d1;
BitField<19, 1, u32> disable_lut_fr;
BitField<20, 1, u32> disable_lut_rr;
BitField<21, 1, u32> disable_lut_rg;
BitField<22, 1, u32> disable_lut_rb;
// Each bit specifies whether distance attenuation should be applied for the
// corresponding light
BitField<24, 1, u32> dist_atten_enable_light_0; // 0: GL_TRUE, 1: GL_FALSE
BitField<25, 1, u32> dist_atten_enable_light_1; // 0: GL_TRUE, 1: GL_FALSE
BitField<26, 1, u32> dist_atten_enable_light_2; // 0: GL_TRUE, 1: GL_FALSE
BitField<27, 1, u32> dist_atten_enable_light_3; // 0: GL_TRUE, 1: GL_FALSE
BitField<28, 1, u32> dist_atten_enable_light_4; // 0: GL_TRUE, 1: GL_FALSE
BitField<29, 1, u32> dist_atten_enable_light_5; // 0: GL_TRUE, 1: GL_FALSE
BitField<30, 1, u32> dist_atten_enable_light_6; // 0: GL_TRUE, 1: GL_FALSE
BitField<31, 1, u32> dist_atten_enable_light_7; // 0: GL_TRUE, 1: GL_FALSE
BitField<24, 1, u32> disable_dist_atten_light_0;
BitField<25, 1, u32> disable_dist_atten_light_1;
BitField<26, 1, u32> disable_dist_atten_light_2;
BitField<27, 1, u32> disable_dist_atten_light_3;
BitField<28, 1, u32> disable_dist_atten_light_4;
BitField<29, 1, u32> disable_dist_atten_light_5;
BitField<30, 1, u32> disable_dist_atten_light_6;
BitField<31, 1, u32> disable_dist_atten_light_7;
};
bool IsDistAttenEnabled(unsigned index) const {
const unsigned enable[] = { dist_atten_enable_light_0, dist_atten_enable_light_1,
dist_atten_enable_light_2, dist_atten_enable_light_3,
dist_atten_enable_light_4, dist_atten_enable_light_5,
dist_atten_enable_light_6, dist_atten_enable_light_7 };
return enable[index] == 0;
bool IsDistAttenDisabled(unsigned index) const {
const unsigned disable[] = { disable_dist_atten_light_0, disable_dist_atten_light_1,
disable_dist_atten_light_2, disable_dist_atten_light_3,
disable_dist_atten_light_4, disable_dist_atten_light_5,
disable_dist_atten_light_6, disable_dist_atten_light_7 };
return disable[index] != 0;
}
union {
@ -830,14 +830,17 @@ struct Regs {
// registers is written to, the behavior will be the same.
u32 lut_data[8];
// These are used to specify if absolute (abs) value should be used for each LUT index. When
// abs mode is disabled, LUT indexes are in the range of (-1.0, 1.0). Otherwise, they are in
// the range of (0.0, 1.0).
union {
BitField< 1, 1, u32> d0; // 0: GL_TRUE, 1: GL_FALSE
BitField< 5, 1, u32> d1; // 0: GL_TRUE, 1: GL_FALSE
BitField< 9, 1, u32> sp; // 0: GL_TRUE, 1: GL_FALSE
BitField<13, 1, u32> fr; // 0: GL_TRUE, 1: GL_FALSE
BitField<17, 1, u32> rb; // 0: GL_TRUE, 1: GL_FALSE
BitField<21, 1, u32> rg; // 0: GL_TRUE, 1: GL_FALSE
BitField<25, 1, u32> rr; // 0: GL_TRUE, 1: GL_FALSE
BitField< 1, 1, u32> disable_d0;
BitField< 5, 1, u32> disable_d1;
BitField< 9, 1, u32> disable_sp;
BitField<13, 1, u32> disable_fr;
BitField<17, 1, u32> disable_rb;
BitField<21, 1, u32> disable_rg;
BitField<25, 1, u32> disable_rr;
} abs_lut_input;
union {

View file

@ -75,7 +75,7 @@ struct PicaShaderConfig {
// Fragment lighting
res.lighting.enable = !regs.lighting.disable;
res.lighting.src_num = regs.lighting.src_num + 1;
res.lighting.src_num = regs.lighting.num_lights + 1;
for (unsigned light_index = 0; light_index < res.lighting.src_num; ++light_index) {
unsigned num = regs.lighting.light_enable.GetNum(light_index);
@ -83,38 +83,38 @@ struct PicaShaderConfig {
res.lighting.light[light_index].num = num;
res.lighting.light[light_index].directional = light.directional != 0;
res.lighting.light[light_index].two_sided_diffuse = light.two_sided_diffuse != 0;
res.lighting.light[light_index].dist_atten_enable = regs.lighting.IsDistAttenEnabled(num);
res.lighting.light[light_index].dist_atten_enable = !regs.lighting.IsDistAttenDisabled(num);
res.lighting.light[light_index].dist_atten_bias = Pica::float20::FromRaw(light.dist_atten_bias).ToFloat32();
res.lighting.light[light_index].dist_atten_scale = Pica::float20::FromRaw(light.dist_atten_scale).ToFloat32();
}
res.lighting.lut_d0.enable = regs.lighting.lut_enable_d0 == 0;
res.lighting.lut_d0.abs_input = regs.lighting.abs_lut_input.d0 == 0;
res.lighting.lut_d0.enable = regs.lighting.disable_lut_d0 == 0;
res.lighting.lut_d0.abs_input = regs.lighting.abs_lut_input.disable_d0 == 0;
res.lighting.lut_d0.type = regs.lighting.lut_input.d0.Value();
res.lighting.lut_d0.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d0);
res.lighting.lut_d1.enable = regs.lighting.lut_enable_d1 == 0;
res.lighting.lut_d1.abs_input = regs.lighting.abs_lut_input.d1 == 0;
res.lighting.lut_d1.enable = regs.lighting.disable_lut_d1 == 0;
res.lighting.lut_d1.abs_input = regs.lighting.abs_lut_input.disable_d1 == 0;
res.lighting.lut_d1.type = regs.lighting.lut_input.d1.Value();
res.lighting.lut_d1.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.d1);
res.lighting.lut_fr.enable = regs.lighting.lut_enable_fr == 0;
res.lighting.lut_fr.abs_input = regs.lighting.abs_lut_input.fr == 0;
res.lighting.lut_fr.enable = regs.lighting.disable_lut_fr == 0;
res.lighting.lut_fr.abs_input = regs.lighting.abs_lut_input.disable_fr == 0;
res.lighting.lut_fr.type = regs.lighting.lut_input.fr.Value();
res.lighting.lut_fr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.fr);
res.lighting.lut_rr.enable = regs.lighting.lut_enable_rr == 0;
res.lighting.lut_rr.abs_input = regs.lighting.abs_lut_input.rr == 0;
res.lighting.lut_rr.enable = regs.lighting.disable_lut_rr == 0;
res.lighting.lut_rr.abs_input = regs.lighting.abs_lut_input.disable_rr == 0;
res.lighting.lut_rr.type = regs.lighting.lut_input.rr.Value();
res.lighting.lut_rr.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rr);
res.lighting.lut_rg.enable = regs.lighting.lut_enable_rg == 0;
res.lighting.lut_rg.abs_input = regs.lighting.abs_lut_input.rg == 0;
res.lighting.lut_rg.enable = regs.lighting.disable_lut_rg == 0;
res.lighting.lut_rg.abs_input = regs.lighting.abs_lut_input.disable_rg == 0;
res.lighting.lut_rg.type = regs.lighting.lut_input.rg.Value();
res.lighting.lut_rg.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rg);
res.lighting.lut_rb.enable = regs.lighting.lut_enable_rb == 0;
res.lighting.lut_rb.abs_input = regs.lighting.abs_lut_input.rb == 0;
res.lighting.lut_rb.enable = regs.lighting.disable_lut_rb == 0;
res.lighting.lut_rb.abs_input = regs.lighting.abs_lut_input.disable_rb == 0;
res.lighting.lut_rb.type = regs.lighting.lut_input.rb.Value();
res.lighting.lut_rb.scale = regs.lighting.lut_scale.GetScale(regs.lighting.lut_scale.rb);
@ -122,7 +122,7 @@ struct PicaShaderConfig {
res.lighting.fresnel_selector = regs.lighting.fresnel_selector;
res.lighting.bump_mode = regs.lighting.bump_mode;
res.lighting.bump_selector = regs.lighting.bump_selector;
res.lighting.bump_renorm = regs.lighting.bump_renorm == 0;
res.lighting.bump_renorm = regs.lighting.disable_bump_renorm == 0;
res.lighting.clamp_highlights = regs.lighting.clamp_highlights != 0;
return res;