PICA: Use VS config to get immediate mode attribute count

This commit is contained in:
Jannik Vogel 2016-03-20 13:55:30 +01:00
parent 116194b147
commit 936e180787
2 changed files with 18 additions and 3 deletions

View file

@ -131,14 +131,17 @@ static void WritePicaReg(u32 id, u32 value, u32 mask) {
immediate_input.attr[immediate_attribute_id++] = attribute;
if (immediate_attribute_id >= attribute_config.GetNumTotalAttributes()) {
if (immediate_attribute_id >= g_state.regs.vs.GetNumTotalAttributes()) {
immediate_attribute_id = 0;
Shader::UnitState<false> shader_unit;
Shader::Setup(shader_unit);
if (g_debug_context)
g_debug_context->OnEvent(DebugContext::Event::VertexLoaded, (void*)&immediate_input);
// Send to vertex shader
Shader::OutputVertex output = Shader::Run(shader_unit, immediate_input, attribute_config.GetNumTotalAttributes());
Shader::OutputVertex output = Shader::Run(shader_unit, immediate_input, g_state.regs.vs.GetNumTotalAttributes());
// Send to renderer
using Pica::Shader::OutputVertex;

View file

@ -985,6 +985,7 @@ struct Regs {
return (id >= 12) || (attribute_mask & (1ULL << id)) != 0;
}
// The number of attributes loaded from the vertex buffer
inline int GetNumTotalAttributes() const {
return (int)num_extra_attributes+1;
}
@ -1123,7 +1124,17 @@ struct Regs {
BitField<24, 8, u32> w;
} int_uniforms[4];
INSERT_PADDING_WORDS(0x5);
INSERT_PADDING_WORDS(0x4);
union {
BitField<0, 4, u32> input_vertex_attributes;
//TODO: Geometry Shader fields
};
// Number of fixed attributes + loaded from vertex buffer (or immediate buffer) ?
inline int GetNumTotalAttributes() const {
return (int)input_vertex_attributes+1;
}
// Offset to shader program entry point (in words)
BitField<0, 16, u32> main_offset;
@ -1292,6 +1303,7 @@ ASSERT_REG_POSITION(triangle_topology, 0x25e);
ASSERT_REG_POSITION(restart_primitive, 0x25f);
ASSERT_REG_POSITION(gs, 0x280);
ASSERT_REG_POSITION(vs, 0x2b0);
ASSERT_REG_POSITION(vs.input_vertex_attributes, 0x2b9);
#undef ASSERT_REG_POSITION
#endif // !defined(_MSC_VER)