mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-08 17:29:10 +02:00
Merge pull request #8818 from jherico/amd_crash
Fix AMD crash caused by missing glFlush
This commit is contained in:
commit
3874f173b6
3 changed files with 47 additions and 22 deletions
|
@ -37,8 +37,7 @@ void TextureRecycler::clear() {
|
|||
_allTextures.clear();
|
||||
}
|
||||
|
||||
uint32_t TextureRecycler::getNextTexture() {
|
||||
if (_readyTextures.empty()) {
|
||||
void TextureRecycler::addTexture() {
|
||||
uint32_t newTexture;
|
||||
glGenTextures(1, &newTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, newTexture);
|
||||
|
@ -60,6 +59,15 @@ uint32_t TextureRecycler::getNextTexture() {
|
|||
_readyTextures.push(newTexture);
|
||||
}
|
||||
|
||||
uint32_t TextureRecycler::getNextTexture() {
|
||||
while (_allTextures.size() < _textureCount) {
|
||||
addTexture();
|
||||
}
|
||||
|
||||
if (_readyTextures.empty()) {
|
||||
addTexture();
|
||||
}
|
||||
|
||||
uint32_t result = _readyTextures.front();
|
||||
_readyTextures.pop();
|
||||
auto& item = _allTextures[result];
|
||||
|
|
|
@ -15,15 +15,21 @@
|
|||
|
||||
#include <GLMHelpers.h>
|
||||
|
||||
// GPU resources are typically buffered for one copy being used by the renderer,
|
||||
// one copy in flight, and one copy being used by the receiver
|
||||
#define GPU_RESOURCE_BUFFER_SIZE 3
|
||||
|
||||
class TextureRecycler {
|
||||
public:
|
||||
TextureRecycler(bool useMipmaps) : _useMipmaps(useMipmaps) {}
|
||||
void setSize(const uvec2& size);
|
||||
void setTextureCount(uint8_t textureCount);
|
||||
void clear();
|
||||
uint32_t getNextTexture();
|
||||
void recycleTexture(uint32_t texture);
|
||||
|
||||
private:
|
||||
void addTexture();
|
||||
|
||||
struct TexInfo {
|
||||
const uint32_t _tex{ 0 };
|
||||
|
@ -42,6 +48,7 @@ private:
|
|||
Queue _readyTextures;
|
||||
uvec2 _size{ 1920, 1080 };
|
||||
bool _useMipmaps;
|
||||
uint8_t _textureCount { GPU_RESOURCE_BUFFER_SIZE };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -663,11 +663,21 @@ void GLBackend::recycle() const {
|
|||
Lock lock(_trashMutex);
|
||||
std::swap(_externalTexturesTrash, externalTexturesTrash);
|
||||
}
|
||||
if (!externalTexturesTrash.empty()) {
|
||||
std::vector<GLsync> fences;
|
||||
fences.resize(externalTexturesTrash.size());
|
||||
for (size_t i = 0; i < externalTexturesTrash.size(); ++i) {
|
||||
fences[i] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
}
|
||||
// External texture fences will be read in another thread/context, so we need a flush
|
||||
glFlush();
|
||||
size_t index = 0;
|
||||
for (auto pair : externalTexturesTrash) {
|
||||
auto fence = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
auto fence = fences[index++];
|
||||
pair.second(pair.first, fence);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
std::list<GLuint> programsTrash;
|
||||
|
|
Loading…
Reference in a new issue