Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/renderer_gl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2930,6 +2930,11 @@ namespace bgfx { namespace gl
: 0
;

// External textures are imported by wrapping an existing GL texture
// id (see createTexture/TextureGL::overrideInternal), which is valid
// on any GL/GLES context, so the capability is always advertised.
g_caps.supported |= BGFX_CAPS_TEXTURE_EXTERNAL;

g_caps.supported |= false
|| s_extension[Extension::EXT_texture_array].m_supported
|| s_extension[Extension::EXT_gpu_shader4].m_supported
Expand Down Expand Up @@ -3429,8 +3434,18 @@ namespace bgfx { namespace gl

void* createTexture(TextureHandle _handle, const Memory* _mem, uint64_t _flags, uint8_t _skip, uint64_t _external) override
{
BX_UNUSED(_external);
m_textures[_handle.idx].create(_mem, _flags, _skip);
TextureGL& texture = m_textures[_handle.idx];
texture.create(_mem, _flags, _skip);

// When an external native handle is supplied, replace the freshly
// allocated GL texture with the caller-owned texture id. overrideInternal
// sets BGFX_SAMPLER_INTERNAL_SHARED so TextureGL::destroy will not delete
// the externally owned id.
if (0 != _external)
{
texture.overrideInternal(uintptr_t(_external) );
}

return NULL;
}

Expand Down