1
\$\begingroup\$

I have a basic model to upload textures as shown in the following picture.enter image description here

I design this for several reasons:

  1. Only the primary thread owns the OpenGL context, so I choose to create buffers, map buffers and unmap buffers in the primary thread.
  2. I have many pictures to load and I don't want them to block the primary thread, so I use the subthread to load images and copy the memory.

Here are my questions:

  1. Is my model correct?
  2. Is my model the best practice?
  3. Should I create a PBO for each picture or create two PBO for all pictures and use them in turn?
  4. Should I use a shared context?

Thank you for helping me out

\$\endgroup\$
2
  • \$\begingroup\$ As with most things in programming there is no really "best practise" as it depends on what you plan to create. Does your method work? If it does, does it matter if its not "best practise" ? \$\endgroup\$ Commented Jan 11, 2019 at 10:38
  • 2
    \$\begingroup\$ I'd encourage you to profile glTexSubImage without using a PBO first, to determine whether or not this is even something you need to build a complex multi-threaded solution around. glTexSubImage - used intelligently, and with knowledge of which data formats and layouts transfer faster - can be quite fast on it's own. That's best practice: profile, determine if you need to optimize, and only then optimize if you need it. \$\endgroup\$ Commented Jan 11, 2019 at 11:58

1 Answer 1

0
\$\begingroup\$

Why would 3 need to wait on 2? As soon as you know the size of the image you can go ahead and create the buffer. So make sure you know the size early on (by putting it next to the other meta data that led you to load it in the first place or having a max size and using that always) and let the subthread load the image data directly into the PBO.

It is perfectly fine to create a few PBOs and cycle through them.

\$\endgroup\$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .