Skip to content

Commit

Permalink
nv2a: Fix handling of 0-stride vertex attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
abaire committed Mar 21, 2022
1 parent 6e19690 commit 4ce20dd
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions hw/xbox/nv2a/pgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -6662,17 +6662,6 @@ static void pgraph_bind_vertex_attributes(NV2AState *d,
updated_memory_buffer = true;
}

if (attr->needs_conversion) {
glVertexAttribIPointer(i, attr->gl_count, attr->gl_type, stride,
(void *)attrib_data_addr);
} else {
glVertexAttribPointer(i, attr->gl_count, attr->gl_type,
attr->gl_normalize, stride,
(void *)attrib_data_addr);
}

glEnableVertexAttribArray(i);

uint32_t provoking_element_index = provoking_element - min_element;
size_t element_size = attr->size * attr->count;
assert(element_size <= sizeof(attr->inline_value));
Expand All @@ -6683,12 +6672,26 @@ static void pgraph_bind_vertex_attributes(NV2AState *d,
} else {
last_entry = d->vram_ptr + start;
}
if (stride) {
last_entry += stride * provoking_element_index;
if (!stride) {
// Stride of 0 indicates that only the first element should be
// used.
pgraph_update_inline_value(attr, last_entry);
glDisableVertexAttribArray(i);
glVertexAttrib4fv(i, attr->inline_value);
continue;
}

if (attr->needs_conversion) {
glVertexAttribIPointer(i, attr->gl_count, attr->gl_type, stride,
(void *)attrib_data_addr);
} else {
last_entry += element_size * provoking_element_index;
glVertexAttribPointer(i, attr->gl_count, attr->gl_type,
attr->gl_normalize, stride,
(void *)attrib_data_addr);
}

glEnableVertexAttribArray(i);
last_entry += stride * provoking_element_index;
pgraph_update_inline_value(attr, last_entry);
}

Expand Down

0 comments on commit 4ce20dd

Please sign in to comment.