From 913146ccd401216f71f037ea304b5e61b7a138cf Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Fri, 29 Nov 2019 12:41:38 +0100 Subject: RHI: new native texture API The new version takes/returns a value that can be unpacked and passed to other functions without knowing which backend is in use. The old API will be removed in a later change when dependent modules have been updated Task-number: QTBUG-78570 Change-Id: I18d928ceef3cb617c0c509ecccb345551a7990af Reviewed-by: Laszlo Agocs --- src/gui/rhi/qrhigles2.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/gui/rhi/qrhigles2.cpp') diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index b551980bb3..563d59b318 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -3404,11 +3404,40 @@ bool QGles2Texture::buildFrom(const QRhiNativeHandles *src) return true; } +bool QGles2Texture::buildFrom(QRhiTexture::NativeTexture src) +{ + const uint *textureId = static_cast(src.object); + if (!textureId || !*textureId) + return false; + + if (!prepareBuild()) + return false; + + texture = *textureId; + specified = true; + + QRHI_RES_RHI(QRhiGles2); + QRHI_PROF; + QRHI_PROF_F(newTexture(this, false, mipLevelCount, m_flags.testFlag(CubeMap) ? 6 : 1, 1)); + + owns = false; + nativeHandlesStruct.texture = texture; + + generation += 1; + rhiD->registerResource(this); + return true; +} + const QRhiNativeHandles *QGles2Texture::nativeHandles() { return &nativeHandlesStruct; } +QRhiTexture::NativeTexture QGles2Texture::nativeTexture() +{ + return {&nativeHandlesStruct.texture, 0}; +} + QGles2Sampler::QGles2Sampler(QRhiImplementation *rhi, Filter magFilter, Filter minFilter, Filter mipmapMode, AddressMode u, AddressMode v) : QRhiSampler(rhi, magFilter, minFilter, mipmapMode, u, v) -- cgit v1.2.3