mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Update BackendTarget to include version
This commit is contained in:
parent
f1e63f489b
commit
140b9be1c4
4 changed files with 25 additions and 20 deletions
|
@ -150,8 +150,8 @@ void TextureBaker::processTexture() {
|
||||||
// Compressed KTX
|
// Compressed KTX
|
||||||
if (_compressionEnabled) {
|
if (_compressionEnabled) {
|
||||||
constexpr std::array<image::BackendTarget, 2> BACKEND_TARGETS {
|
constexpr std::array<image::BackendTarget, 2> BACKEND_TARGETS {
|
||||||
image::BackendTarget::GL,
|
image::BackendTarget::GL45,
|
||||||
image::BackendTarget::GLES
|
image::BackendTarget::GLES32
|
||||||
};
|
};
|
||||||
for (auto target : BACKEND_TARGETS) {
|
for (auto target : BACKEND_TARGETS) {
|
||||||
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(),
|
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(),
|
||||||
|
@ -198,7 +198,7 @@ void TextureBaker::processTexture() {
|
||||||
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
||||||
buffer->reset();
|
buffer->reset();
|
||||||
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(),
|
auto processedTexture = image::processImage(std::move(buffer), _textureURL.toString().toStdString(),
|
||||||
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, image::BackendTarget::GL, _abortProcessing);
|
ABSOLUTE_MAX_TEXTURE_NUM_PIXELS, _textureType, false, image::BackendTarget::GL45, _abortProcessing);
|
||||||
if (!processedTexture) {
|
if (!processedTexture) {
|
||||||
handleError("Could not process texture " + _textureURL.toString());
|
handleError("Could not process texture " + _textureURL.toString());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -80,7 +80,7 @@ const QStringList getSupportedFormats() {
|
||||||
|
|
||||||
// On GLES, we don't use HDR skyboxes
|
// On GLES, we don't use HDR skyboxes
|
||||||
QImage::Format hdrFormatForTarget(BackendTarget target) {
|
QImage::Format hdrFormatForTarget(BackendTarget target) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
return QImage::Format_RGB32;
|
return QImage::Format_RGB32;
|
||||||
}
|
}
|
||||||
return QImage::Format_RGB30;
|
return QImage::Format_RGB30;
|
||||||
|
@ -271,7 +271,7 @@ QImage processSourceImage(QImage&& srcImage, bool cubemap, BackendTarget target)
|
||||||
const glm::uvec2 srcImageSize = toGlm(localCopy.size());
|
const glm::uvec2 srcImageSize = toGlm(localCopy.size());
|
||||||
glm::uvec2 targetSize = srcImageSize;
|
glm::uvec2 targetSize = srcImageSize;
|
||||||
|
|
||||||
const auto maxTextureSize = target == BackendTarget::GL ? MAX_TEXTURE_SIZE_GL : MAX_TEXTURE_SIZE_GLES;
|
const auto maxTextureSize = target == BackendTarget::GLES32 ? MAX_TEXTURE_SIZE_GLES : MAX_TEXTURE_SIZE_GL;
|
||||||
while (glm::any(glm::greaterThan(targetSize, maxTextureSize))) {
|
while (glm::any(glm::greaterThan(targetSize, maxTextureSize))) {
|
||||||
targetSize /= 2;
|
targetSize /= 2;
|
||||||
}
|
}
|
||||||
|
@ -513,7 +513,7 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, BackendTarget target
|
||||||
const int width = localCopy.width(), height = localCopy.height();
|
const int width = localCopy.width(), height = localCopy.height();
|
||||||
auto mipFormat = texture->getStoredMipFormat();
|
auto mipFormat = texture->getStoredMipFormat();
|
||||||
|
|
||||||
if (target != BackendTarget::GLES) {
|
if (target != BackendTarget::GLES32) {
|
||||||
const void* data = static_cast<const void*>(localCopy.constBits());
|
const void* data = static_cast<const void*>(localCopy.constBits());
|
||||||
nvtt::TextureType textureType = nvtt::TextureType_2D;
|
nvtt::TextureType textureType = nvtt::TextureType_2D;
|
||||||
nvtt::InputFormat inputFormat = nvtt::InputFormat_BGRA_8UB;
|
nvtt::InputFormat inputFormat = nvtt::InputFormat_BGRA_8UB;
|
||||||
|
@ -705,7 +705,7 @@ void generateMips(gpu::Texture* texture, QImage&& image, BackendTarget target, c
|
||||||
#if CPU_MIPMAPS
|
#if CPU_MIPMAPS
|
||||||
PROFILE_RANGE(resource_parse, "generateMips");
|
PROFILE_RANGE(resource_parse, "generateMips");
|
||||||
|
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
generateLDRMips(texture, std::move(image), target, abortProcessing, face);
|
generateLDRMips(texture, std::move(image), target, abortProcessing, face);
|
||||||
} else {
|
} else {
|
||||||
if (image.format() == hdrFormatForTarget(target)) {
|
if (image.format() == hdrFormatForTarget(target)) {
|
||||||
|
@ -768,7 +768,7 @@ gpu::TexturePointer TextureUsage::process2DTextureColorFromImage(QImage&& srcIma
|
||||||
gpu::Element formatMip;
|
gpu::Element formatMip;
|
||||||
gpu::Element formatGPU;
|
gpu::Element formatGPU;
|
||||||
if (compress) {
|
if (compress) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
// GLES does not support GL_BGRA
|
// GLES does not support GL_BGRA
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGBA;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGBA;
|
||||||
formatMip = formatGPU;
|
formatMip = formatGPU;
|
||||||
|
@ -783,8 +783,7 @@ gpu::TexturePointer TextureUsage::process2DTextureColorFromImage(QImage&& srcIma
|
||||||
formatMip = formatGPU;
|
formatMip = formatGPU;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
static_assert(false);
|
|
||||||
} else {
|
} else {
|
||||||
formatGPU = gpu::Element::COLOR_SRGBA_32;
|
formatGPU = gpu::Element::COLOR_SRGBA_32;
|
||||||
formatMip = gpu::Element::COLOR_SBGRA_32;
|
formatMip = gpu::Element::COLOR_SBGRA_32;
|
||||||
|
@ -907,7 +906,7 @@ gpu::TexturePointer TextureUsage::process2DTextureNormalMapFromImage(QImage&& sr
|
||||||
gpu::Element formatMip;
|
gpu::Element formatMip;
|
||||||
gpu::Element formatGPU;
|
gpu::Element formatGPU;
|
||||||
if (compress) {
|
if (compress) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_XY;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_XY;
|
||||||
} else {
|
} else {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_XY;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_XY;
|
||||||
|
@ -947,7 +946,7 @@ gpu::TexturePointer TextureUsage::process2DTextureGrayscaleFromImage(QImage&& sr
|
||||||
gpu::Element formatMip;
|
gpu::Element formatMip;
|
||||||
gpu::Element formatGPU;
|
gpu::Element formatGPU;
|
||||||
if (compress) {
|
if (compress) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_RED;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_RED;
|
||||||
} else {
|
} else {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_RED;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_RED;
|
||||||
|
@ -1312,7 +1311,7 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(QImage&& srcI
|
||||||
QImage image = processSourceImage(std::move(localCopy), true, target);
|
QImage image = processSourceImage(std::move(localCopy), true, target);
|
||||||
|
|
||||||
if (image.format() != hdrFormatForTarget(target)) {
|
if (image.format() != hdrFormatForTarget(target)) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
image = image.convertToFormat(QImage::Format_RGB32);
|
image = image.convertToFormat(QImage::Format_RGB32);
|
||||||
} else {
|
} else {
|
||||||
image = convertToHDRFormat(std::move(image), HDR_FORMAT, target);
|
image = convertToHDRFormat(std::move(image), HDR_FORMAT, target);
|
||||||
|
@ -1322,7 +1321,7 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(QImage&& srcI
|
||||||
gpu::Element formatMip;
|
gpu::Element formatMip;
|
||||||
gpu::Element formatGPU;
|
gpu::Element formatGPU;
|
||||||
if (compress) {
|
if (compress) {
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGB;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGB;
|
||||||
} else {
|
} else {
|
||||||
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_HDR_RGB;
|
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_HDR_RGB;
|
||||||
|
@ -1380,7 +1379,7 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(QImage&& srcI
|
||||||
PROFILE_RANGE(resource_parse, "generateIrradiance");
|
PROFILE_RANGE(resource_parse, "generateIrradiance");
|
||||||
gpu::Element irradianceFormat;
|
gpu::Element irradianceFormat;
|
||||||
// TODO: we could locally compress the irradiance texture on Android, but we don't need to
|
// TODO: we could locally compress the irradiance texture on Android, but we don't need to
|
||||||
if (target == BackendTarget::GLES) {
|
if (target == BackendTarget::GLES32) {
|
||||||
irradianceFormat = gpu::Element::COLOR_SRGBA_32;
|
irradianceFormat = gpu::Element::COLOR_SRGBA_32;
|
||||||
} else {
|
} else {
|
||||||
irradianceFormat = HDR_FORMAT;
|
irradianceFormat = HDR_FORMAT;
|
||||||
|
|
|
@ -22,8 +22,9 @@ class QImage;
|
||||||
namespace image {
|
namespace image {
|
||||||
|
|
||||||
enum class BackendTarget {
|
enum class BackendTarget {
|
||||||
GL,
|
GL41,
|
||||||
GLES
|
GL45,
|
||||||
|
GLES32
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace TextureUsage {
|
namespace TextureUsage {
|
||||||
|
|
|
@ -280,9 +280,9 @@ gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::Te
|
||||||
}
|
}
|
||||||
auto loader = image::TextureUsage::getTextureLoaderForType(type, options);
|
auto loader = image::TextureUsage::getTextureLoaderForType(type, options);
|
||||||
#ifdef USE_GLES
|
#ifdef USE_GLES
|
||||||
image::BackendTarget target = image::BackendTarget::GLES;
|
image::BackendTarget target = image::BackendTarget::GLES32;
|
||||||
#else
|
#else
|
||||||
image::BackendTarget target = image::BackendTarget::GL;
|
image::BackendTarget target = image::BackendTarget::GL45;
|
||||||
#endif
|
#endif
|
||||||
return gpu::TexturePointer(loader(std::move(image), path.toStdString(), false, target, false));
|
return gpu::TexturePointer(loader(std::move(image), path.toStdString(), false, target, false));
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1171,12 @@ void ImageReader::read() {
|
||||||
#else
|
#else
|
||||||
constexpr bool shouldCompress = false;
|
constexpr bool shouldCompress = false;
|
||||||
#endif
|
#endif
|
||||||
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _maxNumPixels, networkTexture->getTextureType(), shouldCompress);
|
#ifdef USE_GLES
|
||||||
|
image::BackendTarget target = image::BackendTarget::GLES32;
|
||||||
|
#else
|
||||||
|
image::BackendTarget target = image::BackendTarget::GL45;
|
||||||
|
#endif
|
||||||
|
texture = image::processImage(std::move(buffer), _url.toString().toStdString(), _maxNumPixels, networkTexture->getTextureType(), shouldCompress, target);
|
||||||
|
|
||||||
if (!texture) {
|
if (!texture) {
|
||||||
qCWarning(modelnetworking) << "Could not process:" << _url;
|
qCWarning(modelnetworking) << "Could not process:" << _url;
|
||||||
|
|
Loading…
Reference in a new issue