Skip to content

Conversation

@mcourteaux
Copy link
Contributor

Fixes #3418 properly, and replaces the patch in 72f9b8b.

CC @synaptor.

{
BGFX_PROFILER_SCOPE("scratchBuffer::flush", kColorResource);
scratchBuffer.flush();
scratchBuffer.reset();
Copy link
Owner

Choose a reason for hiding this comment

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

Is there reason to not have flush inside reset?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

They are two separate things IMO. Currently they are used one after the other, indeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that in the master branch, flush() was being called at the right time, but after the reset(). This effectively made flush() a no-op, because we only try to flush the memory region that we touched. However, I guess we were lucky, and it did always update?

Copy link
Owner

Choose a reason for hiding this comment

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

They are two separate things IMO. Currently they are used one after the other, indeed.

I understand this, but I see case where flush is called independently from reset but it looks like calling reset without flush first would be a bug always? Is there case where calling reset without flush would be desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Merged them into one function.



void ScratchBufferVK::flush()
void ScratchBufferVK::flush_and_reset()
Copy link
Owner

@bkaradzic bkaradzic Apr 1, 2025

Choose a reason for hiding this comment

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

Following bgfx code style would be flushAndReset, but it's better to implement as reset(bool _flush = true)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Went with flush(_reset = true), because that makes a lot more sense to me.

@bkaradzic bkaradzic merged commit 6e76442 into bkaradzic:master Apr 1, 2025
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BGFX_DEBUG_TEXT buffer memory corruption

2 participants