Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes 0 stride handling #688

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As written, this continue is unnecessary. However, we could also move this last entry update block up and eliminate some GL calls in the process (i.e. we don't need to set attrib pointer and enable it just to then disable it)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, updated.

}

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