-
Notifications
You must be signed in to change notification settings - Fork 127
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
VDR: Fix vertex offset in indirect draw calls #1984
base: dev
Are you sure you want to change the base?
VDR: Fix vertex offset in indirect draw calls #1984
Conversation
CI gfxreconstruct build queued with queue ID 354749. |
CI gfxreconstruct build # 5917 running. |
CI gfxreconstruct build # 5917 passed. |
So if I understood what the code is doing correctly, in FindMinMaxVertexIndices function, you are processing the index buffer to find the minimum and maximum indices used in the range of the index data. Then, you are adding the vertex offset to the min and max values for the index range. When you add different offsets to the min and max, you essentially expand the range incorrectly, as you are applying two different offsets. You should be applying a single vertex offset to both the min and max values. The offsets you add should be uniform for both min and max, based on the range of indices you are processing. I think it should calculate the min and max indices first then apply the vertex offset for that specific draw call to the indices. Then track the overall min and max indices across all draw calls comparing the adjusted values. |
Correct.
I think I understand what you mean and I think you are right. I updated the patch accordingly |
00c42d9
to
bcc5726
Compare
CI gfxreconstruct build queued with queue ID 359227. |
CI gfxreconstruct build # 5961 running. |
CI gfxreconstruct build # 5961 passed. |
Could you also pass the original binary file offset? (bufferOffset) The vertexOffset is relative to the buffer segment for that draw, but the actual data in binary file may be in different location. |
What do you mean with |
No, I'm looking for the absolute offset within the original binary file where the vertex buffer data starts. (I just referred as "bufferOffset") Maybe within the "parameters" or inside "vertexBuffers in api json? (fileOffset is what I meant. We need to have for both index buffer and vertex buffer file offset to handle indirect draw calls since it contains multiple draws I need to parse.)
Here are the steps of my parsing, (FYI) |
This looks correct
I think this is not correct.
Also in order to correctly detect the memory layout you will also need the information in |
The buffer is dumped starting from that offset. I don't think it makes sense to add it again in your calculations |
(Accidently deleted this comment so adding it back..)
Yes, this is the offset for the start of the buffer right? This is the value I would like to have passed into part of the parameters like this example. (as fileOffset)
Since I don't have direct access to the min indices and binding_offset values, could you provide the pre-calculated "offset" value? This would allow me to directly access the buffer data in the binary file instead of doing the calculation again. |
The buffer is dumped starting from that offset. I don't think it makes sense to add it again in your calculations |
I understand what you mean by 'The buffer is dumped starting from that offset', but I still think I need the that offset value to correctly parse the vertex data (for like indirect calls). The vertexOffset value in the indirectParams is relative to the start of the buffer, but I don't know where the buffer starts in the binary file. Without the fileOffset value, I won't be able to correctly calculate the absolute offset within the binary file and parse the data accurately. Since I would need to search each draw's data from the vertexOffset given from indirectParams, I would need the absolute offset of the file to correctly locate. Unless the vertexOffset is already accounting with the file offset, I would have to calculate the offset of the draw call based on the given file, which is already applied with another offset. Does this make sense or am I misunderstanding something? |
The issue is that for indirect draws, there can be multiple VkDrawIndexedIndirectCommand/VkDrawIndirectCommand setups. While the offset used is correct for the one setup with the lowest vertex, it may be incorrect for others, each has its own vertexOffset, only index, etc. So we cannot just relay on gfxr to start at the proper offset, we have to adapt it to each one individually, hence for this we do need the offset. Also from a data point of view, I think the json file should contain all the data, and the offset used for the file should be conceptually be part of that data. Right now we just have a file with content (hence the file size), but the json does not state the offset it was started for, I think it really should. |
I think it wasn't a very good idea that in #1915 we added the vertexOffset in buffer's offset calculation because of indirect draw calls and it would be more sane to dump the buffers starting at the offset it was bound with Indirect parameters are read from the buffers and are dumped in the output json (an example of a vkCmdDrawIndexedIndirect: https://pastebin.com/raw/5G5t6TKW) so that information is available. I think the are two missing pieces of information from the json that is needed to parse the dumped buffers: One is the current pipeline's In any case I can try to add the offset in the buffer's json entries although that won't be very straightforward as the buffers are dumped in a different place than where the json is generated and the calculated offset contributed from the vertexOffset (which requires parsing the index buffer) is lost by that time. |
The index type of the index buffer is also included in the output json file
CI gfxreconstruct build queued with queue ID 375110. |
Pushed more commits in this PR. |
CI gfxreconstruct build # 6096 running. |
CI gfxreconstruct build # 6096 failed. |
I understand the perspective, but I'm not sure which would be the "correct" way to handle this. While it's true that including it might provide more context about the original buffer layout, it would also result in larger files with potentially unnecessary data. On the other hand, having the vertexOffset would allow us to trim the amount of unused data sent back, regardless of the type of draw call. It's a trade-off between preserving buffer context and minimizing data overhead. I think both options could make sense, but in context of my use cases, the additional data is not needed. As for indirect call, I would need to caculate min index again
I see. I thought this would be straight forward since other parameters were also being outputted to json and the file offset is basically starting point of the binary buffer dumped. |
No description provided.