Skip to content
Closed
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
3 changes: 1 addition & 2 deletions hw/xbox/nv2a/pgraph/vk/vertex.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ void pgraph_vk_update_vertex_ram_buffer(PGRAPHState *pg, hwaddr offset,
size_t end_bit = TARGET_PAGE_ALIGN(offset + size) / TARGET_PAGE_SIZE;
size_t nbits = end_bit - start_bit;

if (find_next_bit(r->uploaded_bitmap, start_bit + nbits, start_bit) <
end_bit) {
if (find_next_bit(r->uploaded_bitmap, start_bit + nbits, start_bit) < end_bit && r->in_draw) {
Copy link
Member

Choose a reason for hiding this comment

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

When this function is called, r->in_draw should be false, which means this path will never be triggered

Copy link
Author

Choose a reason for hiding this comment

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

Is there a case then where we even would need this if check and its proceeding functionality? I ask since I haven't found a situation where this path never being triggered has caused greater issues than when it has been triggered. But I also haven't tested the entire xbox library with this change yet. I admit it's possible that my change here could just be exposing a symptom to a deeper problem.

Copy link
Member

Choose a reason for hiding this comment

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

where we even would need this if check and its proceeding functionality

Yes, as the comment below indicates, if vertex data are changed while the draw command buffer is being built (but before it is executed), then we need to finish any pending drawing. There are ways to make this faster, but this simple logic here prioritizes correctness. There's also a chance there's some pathological case, or we are being too conservative--since you've found an instance where this path is triggered often you can find what data are changing (via the bitmap).

// Vertex data changed while building the draw list. Finish drawing
// before updating RAM buffer.
pgraph_vk_finish(pg, VK_FINISH_REASON_VERTEX_BUFFER_DIRTY);
Expand Down