mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Merge remote-tracking branch 'upstream/master' into materialMapping
This commit is contained in:
commit
d2ecc21f0b
2 changed files with 17 additions and 14 deletions
|
@ -333,14 +333,14 @@ QSharedPointer<Resource> TextureCache::createResourceCopy(const QSharedPointer<R
|
||||||
|
|
||||||
int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkTexture>>();
|
int networkTexturePointerMetaTypeId = qRegisterMetaType<QWeakPointer<NetworkTexture>>();
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const QUrl& url) :
|
NetworkTexture::NetworkTexture(const QUrl& url, bool resourceTexture) :
|
||||||
Resource(url),
|
Resource(url),
|
||||||
_type(),
|
|
||||||
_maxNumPixels(100)
|
_maxNumPixels(100)
|
||||||
{
|
{
|
||||||
_textureSource = std::make_shared<gpu::TextureSource>(url);
|
if (resourceTexture) {
|
||||||
_lowestRequestedMipLevel = 0;
|
_textureSource = std::make_shared<gpu::TextureSource>(url);
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
NetworkTexture::NetworkTexture(const NetworkTexture& other) :
|
||||||
|
@ -425,7 +425,7 @@ gpu::TexturePointer NetworkTexture::getFallbackTexture() const {
|
||||||
class ImageReader : public QRunnable {
|
class ImageReader : public QRunnable {
|
||||||
public:
|
public:
|
||||||
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url,
|
||||||
const QByteArray& data, int maxNumPixels);
|
const QByteArray& data, size_t extraHash, int maxNumPixels);
|
||||||
void run() override final;
|
void run() override final;
|
||||||
void read();
|
void read();
|
||||||
|
|
||||||
|
@ -435,6 +435,7 @@ private:
|
||||||
QWeakPointer<Resource> _resource;
|
QWeakPointer<Resource> _resource;
|
||||||
QUrl _url;
|
QUrl _url;
|
||||||
QByteArray _content;
|
QByteArray _content;
|
||||||
|
size_t _extraHash;
|
||||||
int _maxNumPixels;
|
int _maxNumPixels;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1068,7 +1069,7 @@ void NetworkTexture::loadTextureContent(const QByteArray& content) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _maxNumPixels));
|
QThreadPool::globalInstance()->start(new ImageReader(_self, _url, content, _extraHash, _maxNumPixels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetworkTexture::refresh() {
|
void NetworkTexture::refresh() {
|
||||||
|
@ -1093,10 +1094,11 @@ void NetworkTexture::refresh() {
|
||||||
Resource::refresh();
|
Resource::refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, int maxNumPixels) :
|
ImageReader::ImageReader(const QWeakPointer<Resource>& resource, const QUrl& url, const QByteArray& data, size_t extraHash, int maxNumPixels) :
|
||||||
_resource(resource),
|
_resource(resource),
|
||||||
_url(url),
|
_url(url),
|
||||||
_content(data),
|
_content(data),
|
||||||
|
_extraHash(extraHash),
|
||||||
_maxNumPixels(maxNumPixels)
|
_maxNumPixels(maxNumPixels)
|
||||||
{
|
{
|
||||||
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
DependencyManager::get<StatTracker>()->incrementStat("PendingProcessing");
|
||||||
|
@ -1152,11 +1154,12 @@ void ImageReader::read() {
|
||||||
}
|
}
|
||||||
auto networkTexture = resource.staticCast<NetworkTexture>();
|
auto networkTexture = resource.staticCast<NetworkTexture>();
|
||||||
|
|
||||||
// Hash the source image to for KTX caching
|
// Hash the source image and extraHash for KTX caching
|
||||||
std::string hash;
|
std::string hash;
|
||||||
{
|
{
|
||||||
QCryptographicHash hasher(QCryptographicHash::Md5);
|
QCryptographicHash hasher(QCryptographicHash::Md5);
|
||||||
hasher.addData(_content);
|
hasher.addData(_content);
|
||||||
|
hasher.addData(std::to_string(_extraHash).c_str());
|
||||||
hash = hasher.result().toHex().toStdString();
|
hash = hasher.result().toHex().toStdString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1245,11 +1248,11 @@ void ImageReader::read() {
|
||||||
Q_ARG(int, texture->getHeight()));
|
Q_ARG(int, texture->getHeight()));
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl) {
|
NetworkTexturePointer TextureCache::getResourceTexture(const QUrl& resourceTextureUrl) {
|
||||||
gpu::TexturePointer texture;
|
gpu::TexturePointer texture;
|
||||||
if (resourceTextureUrl == SPECTATOR_CAMERA_FRAME_URL) {
|
if (resourceTextureUrl == SPECTATOR_CAMERA_FRAME_URL) {
|
||||||
if (!_spectatorCameraNetworkTexture) {
|
if (!_spectatorCameraNetworkTexture) {
|
||||||
_spectatorCameraNetworkTexture.reset(new NetworkTexture(resourceTextureUrl));
|
_spectatorCameraNetworkTexture.reset(new NetworkTexture(resourceTextureUrl, true));
|
||||||
}
|
}
|
||||||
if (!_spectatorCameraFramebuffer) {
|
if (!_spectatorCameraFramebuffer) {
|
||||||
getSpectatorCameraFramebuffer(); // initialize frame buffer
|
getSpectatorCameraFramebuffer(); // initialize frame buffer
|
||||||
|
@ -1260,7 +1263,7 @@ NetworkTexturePointer TextureCache::getResourceTexture(QUrl resourceTextureUrl)
|
||||||
// FIXME: Generalize this, DRY up this code
|
// FIXME: Generalize this, DRY up this code
|
||||||
if (resourceTextureUrl == HMD_PREVIEW_FRAME_URL) {
|
if (resourceTextureUrl == HMD_PREVIEW_FRAME_URL) {
|
||||||
if (!_hmdPreviewNetworkTexture) {
|
if (!_hmdPreviewNetworkTexture) {
|
||||||
_hmdPreviewNetworkTexture.reset(new NetworkTexture(resourceTextureUrl));
|
_hmdPreviewNetworkTexture.reset(new NetworkTexture(resourceTextureUrl, true));
|
||||||
}
|
}
|
||||||
if (_hmdPreviewFramebuffer) {
|
if (_hmdPreviewFramebuffer) {
|
||||||
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
texture = _hmdPreviewFramebuffer->getRenderBuffer(0);
|
||||||
|
|
|
@ -45,7 +45,7 @@ class NetworkTexture : public Resource, public Texture {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
NetworkTexture(const QUrl& url);
|
NetworkTexture(const QUrl& url, bool resourceTexture = false);
|
||||||
NetworkTexture(const NetworkTexture& other);
|
NetworkTexture(const NetworkTexture& other);
|
||||||
~NetworkTexture() override;
|
~NetworkTexture() override;
|
||||||
|
|
||||||
|
@ -183,7 +183,7 @@ public:
|
||||||
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
gpu::TexturePointer getTextureByHash(const std::string& hash);
|
||||||
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
gpu::TexturePointer cacheTextureByHash(const std::string& hash, const gpu::TexturePointer& texture);
|
||||||
|
|
||||||
NetworkTexturePointer getResourceTexture(QUrl resourceTextureUrl);
|
NetworkTexturePointer getResourceTexture(const QUrl& resourceTextureUrl);
|
||||||
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
|
const gpu::FramebufferPointer& getHmdPreviewFramebuffer(int width, int height);
|
||||||
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer();
|
||||||
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer(int width, int height);
|
const gpu::FramebufferPointer& getSpectatorCameraFramebuffer(int width, int height);
|
||||||
|
|
Loading…
Reference in a new issue