[Mesa-dev] [Bug 102204] GL_ARB_buffer_storage crippled extension on r600, radeonsi and amdgpu Mesa drivers

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Nov 3 16:51:03 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=102204

--- Comment #9 from Matias N. Goldberg <dark_sylinc at yahoo.com.ar> ---
Disclaimer: I'm not a Mesa dev.

I saw this ticket by accident and since I'm a heavy user of
GL_ARB_buffer_storage on AMD+Mesa, I took a look in case there's something that
could affect me.

After glancing through the problems, it appears that the problem is "user
error" and the real bug here are the lack of performance warnings to report via
KHR_debug.

GL_ARB_buffer_storage can backfire if you do not use it well.
It would appear that you're performing several operations that are not
supported in HW (such as the use of GL_UNSIGNED_BYTE which requires converting
all indices to GL_UNSIGNED_SHORT in SW) and must be processed to work
correctly.

Or do stuff that is a minefield, like issuing a loop of
glMemoryBarrier+glDrawElementsBaseVertex PER TRIANGLE while reading from a
persistent mapped buffer. That is just not gonna work fast.

The reason GL_CLIENT_STORAGE_BIT improves things is because the buffer is
stored on a CPU buffer (i.e. a good ol' malloc), and when it's time to render,
Mesa does the SW conversions for you, then uploads the data to GPU.
When that flag is not present, Mesa must be constantly downloading & uploading
data from GPU back & forth to accommodate whatever you're doing that is not
natively supported.

The rule of thumb is that persistent mapped memory should be treated as write
only, read once memory.
If I'm writing view matrices and then render that once, I write directly to the
the persistent mapped buffer and use it directly on the shader.
If I'm writing material/pass data that is reused multiple times on multiple
draws, I write it once to the persistent mapped buffer and then perform a
glCopyBufferSubData to another buffer that is not CPU visible at all.

Btw avoid using GL_MAP_COHERENT_BIT. Your calls to glReadPixels to directly
store into the PBO backed by coherent memory could be hurting you a lot.
glReadPixels must do deswizzling; it's not a raw memcpy on the GPU side.
Keeping both the CPU & GPU caches in sync is foolishness here.
If you insist on using GL_MAP_COHERENT_BIT for your glReadPixels; perform the
glReadPixels onto a PBO buffer that is not CPU visible (to perform
deswizzling), then perform a glCopyBufferSubData from that PBO into another PBO
(that is now CPU visible).

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20181103/c3f00326/attachment.html>


More information about the mesa-dev mailing list