mirror of
https://github.com/JulianGro/overte.git
synced 2025-05-28 00:11:43 +02:00
Merge pull request #16054 from jherico/fix/bugz-919
BUGZ-919: Skybox broken on older AMD drivers
This commit is contained in:
commit
54671da230
4 changed files with 29 additions and 71 deletions
|
@ -33,8 +33,8 @@ using namespace gpu::gl;
|
||||||
#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
|
#define GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT 0x8E8F
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool GLTexelFormat::isCompressed() const {
|
bool GLTexelFormat::isCompressed(GLenum format) {
|
||||||
switch (internalFormat) {
|
switch (format) {
|
||||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
||||||
|
@ -92,6 +92,11 @@ bool GLTexelFormat::isCompressed() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GLTexelFormat::isCompressed() const {
|
||||||
|
return isCompressed(internalFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) {
|
GLenum GLTexelFormat::evalGLTexelFormatInternal(const gpu::Element& dstFormat) {
|
||||||
GLenum result = GL_RGBA8;
|
GLenum result = GL_RGBA8;
|
||||||
switch (dstFormat.getDimension()) {
|
switch (dstFormat.getDimension()) {
|
||||||
|
|
|
@ -14,13 +14,15 @@ namespace gpu { namespace gl {
|
||||||
|
|
||||||
class GLTexelFormat {
|
class GLTexelFormat {
|
||||||
public:
|
public:
|
||||||
GLenum internalFormat;
|
GLenum internalFormat{ GL_RGBA8 };
|
||||||
GLenum format;
|
GLenum format{ GL_RGBA };
|
||||||
GLenum type;
|
GLenum type{ GL_UNSIGNED_BYTE };
|
||||||
|
|
||||||
GLTexelFormat(GLenum glinternalFormat, GLenum glformat, GLenum gltype) : internalFormat(glinternalFormat), format(glformat), type(gltype) {}
|
GLTexelFormat(GLenum glinternalFormat, GLenum glformat, GLenum gltype) : internalFormat(glinternalFormat), format(glformat), type(gltype) {}
|
||||||
GLTexelFormat(GLenum glinternalFormat) : internalFormat(glinternalFormat) {}
|
GLTexelFormat(GLenum glinternalFormat) : internalFormat(glinternalFormat) {}
|
||||||
|
|
||||||
|
static bool isCompressed(GLenum glinternalFormat);
|
||||||
|
|
||||||
bool isCompressed() const;
|
bool isCompressed() const;
|
||||||
|
|
||||||
static GLTexelFormat evalGLTexelFormat(const Element& dstFormat) {
|
static GLTexelFormat evalGLTexelFormat(const Element& dstFormat) {
|
||||||
|
|
|
@ -33,6 +33,7 @@ class GL45Backend : public GLBackend {
|
||||||
friend class Context;
|
friend class Context;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static const GLint RESOURCE_TRANSFER_TEX_UNIT { 32 };
|
||||||
static GLint MAX_COMBINED_SHADER_STORAGE_BLOCKS;
|
static GLint MAX_COMBINED_SHADER_STORAGE_BLOCKS;
|
||||||
static GLint MAX_UNIFORM_LOCATIONS;
|
static GLint MAX_UNIFORM_LOCATIONS;
|
||||||
#if GPU_BINDLESS_TEXTURES
|
#if GPU_BINDLESS_TEXTURES
|
||||||
|
|
|
@ -226,81 +226,31 @@ void GL45Texture::generateMips() const {
|
||||||
|
|
||||||
Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
Size GL45Texture::copyMipFaceLinesFromTexture(uint16_t mip, uint8_t face, const uvec3& size, uint32_t yOffset, GLenum internalFormat, GLenum format, GLenum type, Size sourceSize, const void* sourcePointer) const {
|
||||||
Size amountCopied = sourceSize;
|
Size amountCopied = sourceSize;
|
||||||
|
bool compressed = GLTexelFormat::isCompressed(internalFormat);
|
||||||
if (GL_TEXTURE_2D == _target) {
|
if (GL_TEXTURE_2D == _target) {
|
||||||
switch (internalFormat) {
|
if (compressed) {
|
||||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
glCompressedTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, internalFormat,
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
static_cast<GLsizei>(sourceSize), sourcePointer);
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
} else {
|
||||||
case GL_COMPRESSED_RED_RGTC1:
|
glTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer);
|
||||||
case GL_COMPRESSED_RG_RGTC2:
|
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
|
|
||||||
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
|
|
||||||
case GL_COMPRESSED_RGB8_ETC2:
|
|
||||||
case GL_COMPRESSED_SRGB8_ETC2:
|
|
||||||
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
||||||
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
||||||
case GL_COMPRESSED_RGBA8_ETC2_EAC:
|
|
||||||
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
|
||||||
case GL_COMPRESSED_R11_EAC:
|
|
||||||
case GL_COMPRESSED_SIGNED_R11_EAC:
|
|
||||||
case GL_COMPRESSED_RG11_EAC:
|
|
||||||
case GL_COMPRESSED_SIGNED_RG11_EAC:
|
|
||||||
glCompressedTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, internalFormat,
|
|
||||||
static_cast<GLsizei>(sourceSize), sourcePointer);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
glTextureSubImage2D(_id, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
} else if (GL_TEXTURE_CUBE_MAP == _target) {
|
} else if (GL_TEXTURE_CUBE_MAP == _target) {
|
||||||
switch (internalFormat) {
|
// DSA and cubemap functions are notoriously buggy. use the 4.1 compatible pathway
|
||||||
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
|
glActiveTexture(GL_TEXTURE0 + GL45Backend::RESOURCE_TRANSFER_TEX_UNIT);
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
|
glBindTexture(_target, _texture);
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
|
auto target = GLTexture::CUBE_FACE_LAYOUT[face];
|
||||||
case GL_COMPRESSED_RED_RGTC1:
|
if (compressed) {
|
||||||
case GL_COMPRESSED_RG_RGTC2:
|
glCompressedTexSubImage2D(target, mip, 0, yOffset, size.x, size.y, internalFormat,
|
||||||
case GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM:
|
static_cast<GLsizei>(sourceSize), sourcePointer);
|
||||||
case GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:
|
} else {
|
||||||
case GL_COMPRESSED_RGB8_ETC2:
|
glTexSubImage2D(target, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer);
|
||||||
case GL_COMPRESSED_SRGB8_ETC2:
|
|
||||||
case GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
||||||
case GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2:
|
|
||||||
case GL_COMPRESSED_RGBA8_ETC2_EAC:
|
|
||||||
case GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC:
|
|
||||||
case GL_COMPRESSED_R11_EAC:
|
|
||||||
case GL_COMPRESSED_SIGNED_R11_EAC:
|
|
||||||
case GL_COMPRESSED_RG11_EAC:
|
|
||||||
case GL_COMPRESSED_SIGNED_RG11_EAC:
|
|
||||||
#if AMD_CUBE_MAP_EXT_WORKAROUND
|
|
||||||
if (glCompressedTextureSubImage2DEXT) {
|
|
||||||
auto target = GLTexture::CUBE_FACE_LAYOUT[face];
|
|
||||||
glCompressedTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, internalFormat,
|
|
||||||
static_cast<GLsizei>(sourceSize), sourcePointer);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
glCompressedTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, internalFormat,
|
|
||||||
static_cast<GLsizei>(sourceSize), sourcePointer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
#if AMD_CUBE_MAP_EXT_WORKAROUND
|
|
||||||
if (glTextureSubImage2DEXT) {
|
|
||||||
auto target = GLTexture::CUBE_FACE_LAYOUT[face];
|
|
||||||
glTextureSubImage2DEXT(_id, target, mip, 0, yOffset, size.x, size.y, format, type, sourcePointer);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
glTextureSubImage3D(_id, mip, 0, yOffset, face, size.x, size.y, 1, format, type, sourcePointer);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
glBindTexture(_target, 0);
|
||||||
} else {
|
} else {
|
||||||
assert(false);
|
assert(false);
|
||||||
amountCopied = 0;
|
amountCopied = 0;
|
||||||
}
|
}
|
||||||
(void)CHECK_GL_ERROR();
|
(void)CHECK_GL_ERROR();
|
||||||
|
|
||||||
return amountCopied;
|
return amountCopied;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue