mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 23:07:59 +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
|
||||
if (_compressionEnabled) {
|
||||
constexpr std::array<image::BackendTarget, 2> BACKEND_TARGETS {
|
||||
image::BackendTarget::GL,
|
||||
image::BackendTarget::GLES
|
||||
image::BackendTarget::GL45,
|
||||
image::BackendTarget::GLES32
|
||||
};
|
||||
for (auto target : BACKEND_TARGETS) {
|
||||
auto processedTexture = image::processImage(buffer, _textureURL.toString().toStdString(),
|
||||
|
@ -198,7 +198,7 @@ void TextureBaker::processTexture() {
|
|||
if (_textureType == image::TextureUsage::Type::CUBE_TEXTURE) {
|
||||
buffer->reset();
|
||||
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) {
|
||||
handleError("Could not process texture " + _textureURL.toString());
|
||||
return;
|
||||
|
|
|
@ -80,7 +80,7 @@ const QStringList getSupportedFormats() {
|
|||
|
||||
// On GLES, we don't use HDR skyboxes
|
||||
QImage::Format hdrFormatForTarget(BackendTarget target) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
return QImage::Format_RGB32;
|
||||
}
|
||||
return QImage::Format_RGB30;
|
||||
|
@ -271,7 +271,7 @@ QImage processSourceImage(QImage&& srcImage, bool cubemap, BackendTarget target)
|
|||
const glm::uvec2 srcImageSize = toGlm(localCopy.size());
|
||||
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))) {
|
||||
targetSize /= 2;
|
||||
}
|
||||
|
@ -513,7 +513,7 @@ void generateLDRMips(gpu::Texture* texture, QImage&& image, BackendTarget target
|
|||
const int width = localCopy.width(), height = localCopy.height();
|
||||
auto mipFormat = texture->getStoredMipFormat();
|
||||
|
||||
if (target != BackendTarget::GLES) {
|
||||
if (target != BackendTarget::GLES32) {
|
||||
const void* data = static_cast<const void*>(localCopy.constBits());
|
||||
nvtt::TextureType textureType = nvtt::TextureType_2D;
|
||||
nvtt::InputFormat inputFormat = nvtt::InputFormat_BGRA_8UB;
|
||||
|
@ -705,7 +705,7 @@ void generateMips(gpu::Texture* texture, QImage&& image, BackendTarget target, c
|
|||
#if CPU_MIPMAPS
|
||||
PROFILE_RANGE(resource_parse, "generateMips");
|
||||
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
generateLDRMips(texture, std::move(image), target, abortProcessing, face);
|
||||
} else {
|
||||
if (image.format() == hdrFormatForTarget(target)) {
|
||||
|
@ -768,7 +768,7 @@ gpu::TexturePointer TextureUsage::process2DTextureColorFromImage(QImage&& srcIma
|
|||
gpu::Element formatMip;
|
||||
gpu::Element formatGPU;
|
||||
if (compress) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
// GLES does not support GL_BGRA
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGBA;
|
||||
formatMip = formatGPU;
|
||||
|
@ -783,8 +783,7 @@ gpu::TexturePointer TextureUsage::process2DTextureColorFromImage(QImage&& srcIma
|
|||
formatMip = formatGPU;
|
||||
}
|
||||
} else {
|
||||
if (target == BackendTarget::GLES) {
|
||||
static_assert(false);
|
||||
if (target == BackendTarget::GLES32) {
|
||||
} else {
|
||||
formatGPU = gpu::Element::COLOR_SRGBA_32;
|
||||
formatMip = gpu::Element::COLOR_SBGRA_32;
|
||||
|
@ -907,7 +906,7 @@ gpu::TexturePointer TextureUsage::process2DTextureNormalMapFromImage(QImage&& sr
|
|||
gpu::Element formatMip;
|
||||
gpu::Element formatGPU;
|
||||
if (compress) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_XY;
|
||||
} else {
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_XY;
|
||||
|
@ -947,7 +946,7 @@ gpu::TexturePointer TextureUsage::process2DTextureGrayscaleFromImage(QImage&& sr
|
|||
gpu::Element formatMip;
|
||||
gpu::Element formatGPU;
|
||||
if (compress) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_EAC_RED;
|
||||
} else {
|
||||
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);
|
||||
|
||||
if (image.format() != hdrFormatForTarget(target)) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
image = image.convertToFormat(QImage::Format_RGB32);
|
||||
} else {
|
||||
image = convertToHDRFormat(std::move(image), HDR_FORMAT, target);
|
||||
|
@ -1322,7 +1321,7 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(QImage&& srcI
|
|||
gpu::Element formatMip;
|
||||
gpu::Element formatGPU;
|
||||
if (compress) {
|
||||
if (target == BackendTarget::GLES) {
|
||||
if (target == BackendTarget::GLES32) {
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_ETC2_SRGB;
|
||||
} else {
|
||||
formatGPU = gpu::Element::COLOR_COMPRESSED_BCX_HDR_RGB;
|
||||
|
@ -1380,7 +1379,7 @@ gpu::TexturePointer TextureUsage::processCubeTextureColorFromImage(QImage&& srcI
|
|||
PROFILE_RANGE(resource_parse, "generateIrradiance");
|
||||
gpu::Element irradianceFormat;
|
||||
// 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;
|
||||
} else {
|
||||
irradianceFormat = HDR_FORMAT;
|
||||
|
|
|
@ -22,8 +22,9 @@ class QImage;
|
|||
namespace image {
|
||||
|
||||
enum class BackendTarget {
|
||||
GL,
|
||||
GLES
|
||||
GL41,
|
||||
GL45,
|
||||
GLES32
|
||||
};
|
||||
|
||||
namespace TextureUsage {
|
||||
|
|
|
@ -280,9 +280,9 @@ gpu::TexturePointer TextureCache::getImageTexture(const QString& path, image::Te
|
|||
}
|
||||
auto loader = image::TextureUsage::getTextureLoaderForType(type, options);
|
||||
#ifdef USE_GLES
|
||||
image::BackendTarget target = image::BackendTarget::GLES;
|
||||
image::BackendTarget target = image::BackendTarget::GLES32;
|
||||
#else
|
||||
image::BackendTarget target = image::BackendTarget::GL;
|
||||
image::BackendTarget target = image::BackendTarget::GL45;
|
||||
#endif
|
||||
return gpu::TexturePointer(loader(std::move(image), path.toStdString(), false, target, false));
|
||||
}
|
||||
|
@ -1171,7 +1171,12 @@ void ImageReader::read() {
|
|||
#else
|
||||
constexpr bool shouldCompress = false;
|
||||
#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) {
|
||||
qCWarning(modelnetworking) << "Could not process:" << _url;
|
||||
|
|
Loading…
Reference in a new issue