VideoCore: Change misleading register names
A few registers had names such as "count" or "number" when they actually contained the maximum (that is, count - 1). This can easily lead to hard to notice off by one errors.
This commit is contained in:
parent
5bb6753f2e
commit
bbc7844021
|
@ -138,7 +138,7 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
|
||||
immediate_input.attr[immediate_attribute_id++] = attribute;
|
||||
|
||||
if (immediate_attribute_id >= regs.vs.num_input_attributes + 1) {
|
||||
if (immediate_attribute_id >= regs.vs.max_input_attribute_index + 1) {
|
||||
MICROPROFILE_SCOPE(GPU_Drawing);
|
||||
immediate_attribute_id = 0;
|
||||
|
||||
|
@ -150,7 +150,8 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
|
|||
g_debug_context->OnEvent(DebugContext::Event::VertexShaderInvocation,
|
||||
static_cast<void*>(&immediate_input));
|
||||
Shader::UnitState shader_unit;
|
||||
shader_unit.LoadInputVertex(immediate_input, regs.vs.num_input_attributes + 1);
|
||||
shader_unit.LoadInputVertex(immediate_input,
|
||||
regs.vs.max_input_attribute_index + 1);
|
||||
shader_engine->Run(g_state.vs, shader_unit);
|
||||
auto output_vertex = Shader::OutputVertex::FromRegisters(
|
||||
shader_unit.registers.output, regs, regs.vs.output_mask);
|
||||
|
|
|
@ -868,7 +868,7 @@ struct Regs {
|
|||
LightSrc light[8];
|
||||
LightColor global_ambient; // Emission + (material.ambient * lighting.ambient)
|
||||
INSERT_PADDING_WORDS(0x1);
|
||||
BitField<0, 3, u32> num_lights; // Number of enabled lights - 1
|
||||
BitField<0, 3, u32> max_light_index; // Number of enabled lights - 1
|
||||
|
||||
union {
|
||||
BitField<2, 2, LightingFresnelSelector> fresnel_selector;
|
||||
|
@ -1045,7 +1045,7 @@ struct Regs {
|
|||
BitField<48, 12, u64> attribute_mask;
|
||||
|
||||
// number of total attributes minus 1
|
||||
BitField<60, 4, u64> num_extra_attributes;
|
||||
BitField<60, 4, u64> max_attribute_index;
|
||||
};
|
||||
|
||||
inline VertexAttributeFormat GetFormat(int n) const {
|
||||
|
@ -1076,7 +1076,7 @@ struct Regs {
|
|||
}
|
||||
|
||||
inline int GetNumTotalAttributes() const {
|
||||
return (int)num_extra_attributes + 1;
|
||||
return (int)max_attribute_index + 1;
|
||||
}
|
||||
|
||||
// Attribute loaders map the source vertex data to input attributes
|
||||
|
@ -1214,7 +1214,7 @@ struct Regs {
|
|||
|
||||
union {
|
||||
// Number of input attributes to shader unit - 1
|
||||
BitField<0, 4, u32> num_input_attributes;
|
||||
BitField<0, 4, u32> max_input_attribute_index;
|
||||
};
|
||||
|
||||
// Offset to shader program entry point (in words)
|
||||
|
|
|
@ -467,7 +467,7 @@ void RasterizerOpenGL::NotifyPicaRegisterChanged(u32 id) {
|
|||
|
||||
// Fragment lighting switches
|
||||
case PICA_REG_INDEX(lighting.disable):
|
||||
case PICA_REG_INDEX(lighting.num_lights):
|
||||
case PICA_REG_INDEX(lighting.max_light_index):
|
||||
case PICA_REG_INDEX(lighting.config0):
|
||||
case PICA_REG_INDEX(lighting.config1):
|
||||
case PICA_REG_INDEX(lighting.abs_lut_input):
|
||||
|
|
|
@ -84,7 +84,7 @@ union PicaShaderConfig {
|
|||
// Fragment lighting
|
||||
|
||||
state.lighting.enable = !regs.lighting.disable;
|
||||
state.lighting.src_num = regs.lighting.num_lights + 1;
|
||||
state.lighting.src_num = regs.lighting.max_light_index + 1;
|
||||
|
||||
for (unsigned light_index = 0; light_index < state.lighting.src_num; ++light_index) {
|
||||
unsigned num = regs.lighting.light_enable.GetNum(light_index);
|
||||
|
|
Reference in New Issue