-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add bounds checking when writing to the temp index buffer when expanding primitives #17387
Conversation
…offset instead of the pointer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, I think it might be a bit cleaner to use a field on SoftwareTransformResult
for the index buffer it wrote to, though.
-[Unknown]
u16 *newInds = inds + vertexCount; | ||
u16 *indsOut = newInds; | ||
const u16 *indsIn = (const u16 *)(inds + indsOffset); | ||
int newIndsOffset = indsOffset + vertexCount; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it'd be cleaner for result.indsBuffer
or something to exist, and be the resulting index pointer. We already use result.drawBuffer
, so it'd make the code more symmetrical and probably easier to understand.
-[Unknown]
bool SoftwareTransform::ExpandPoints(int vertexCount, int &maxIndex, u16 *inds, int &indsOffset, int indexBufferSize, const TransformedVertex *transformed, TransformedVertex *transformedExpanded, int &numTrans, bool throughmode) { | ||
// Before we start, do a sanity check - does the output fit? | ||
if (vertexCount * 6 > indexBufferSize - indsOffset) { | ||
// Won't fit, kill the draw. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably log, if not report this situation. It could mean it's running garbage (most likely?) but might actually be some kind of effect.
-[Unknown]
I feel like we found in FF4 or some game that surprisingly high resulting vertex counts from spline/bezier are valid, so I worry about trying to cap it incorrectly... -[Unknown] |
Closing this, seems increasing the buffer size did the trick as I haven't seen any repeat of this yet. Though I do want to make things clearer and more "intentional" around these buffers at some point. |
Not sure whether it make the most sense to:
Opinions? At least this one feels the safest...