Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Compressed Texture Compat #2318

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion gapis/api/gles/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func getFeatures(ctx context.Context, version string, ext extensions) (features,
vertexHalfFloatOES: ext.get("GL_OES_vertex_half_float"),
eglImageExternal: ext.get("GL_OES_EGL_image_external"),
textureMultisample: ext.get("ARB_texture_multisample"),
compressedTextureFormats: getSupportedCompressedTextureFormats(ext),
compressedTextureFormats: getSupportedCompressedTextureFormats(v, ext),
supportGenerateMipmapHint: v.IsES,
}

Expand Down
31 changes: 22 additions & 9 deletions gapis/api/gles/texture_compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ func (tc *textureCompat) convertFormat(
id api.CmdID,
cmd api.Cmd) {

// Compressed formats are replaced by RGBA8
// TODO: What about SRGB?
if internalformat != nil && isCompressedFormat(internalformat.get()) {
if _, supported := tc.f.compressedTextureFormats[internalformat.get()]; !supported {
internalformat.set(GLenum_GL_RGBA8)
}
}

if tc.v.IsES {
return
}
Expand Down Expand Up @@ -166,14 +174,6 @@ func (tc *textureCompat) convertFormat(
internalformat.set(GLenum_GL_RGBA16UI)
case GLenum_GL_STENCIL_INDEX8: // TODO: not supported on desktop.
}

// Compressed formats are replaced by RGBA8
// TODO: What about SRGB?
if isCompressedFormat(internalformat.get()) {
if _, supported := tc.f.compressedTextureFormats[internalformat.get()]; !supported {
internalformat.set(GLenum_GL_RGBA8)
}
}
}

if format != nil {
Expand Down Expand Up @@ -323,14 +323,27 @@ func decompressTexSubImage2D(ctx context.Context, i api.CmdID, a *GlCompressedTe

// getSupportedCompressedTextureFormats returns the set of supported compressed
// texture formats for a given extension list.
func getSupportedCompressedTextureFormats(extensions extensions) map[GLenum]struct{} {
func getSupportedCompressedTextureFormats(v *Version, extensions extensions) map[GLenum]struct{} {
supported := map[GLenum]struct{}{}
for extension := range extensions {
for _, format := range getExtensionTextureFormats(extension) {
supported[format] = struct{}{}
}
}
if v.AtLeastES(3, 0) || v.AtLeastGL(4, 3) {
supported[GLenum_GL_COMPRESSED_R11_EAC] = struct{}{}
supported[GLenum_GL_COMPRESSED_SIGNED_R11_EAC] = struct{}{}
supported[GLenum_GL_COMPRESSED_RG11_EAC] = struct{}{}
supported[GLenum_GL_COMPRESSED_SIGNED_RG11_EAC] = struct{}{}
supported[GLenum_GL_COMPRESSED_RGB8_ETC2] = struct{}{}
supported[GLenum_GL_COMPRESSED_SRGB8_ETC2] = struct{}{}
supported[GLenum_GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2] = struct{}{}
supported[GLenum_GL_COMPRESSED_SRGB8_PUNCHTHROUGH_ALPHA1_ETC2] = struct{}{}
supported[GLenum_GL_COMPRESSED_RGBA8_ETC2_EAC] = struct{}{}
supported[GLenum_GL_COMPRESSED_SRGB8_ALPHA8_ETC2_EAC] = struct{}{}
}
return supported

}

// getExtensionTextureFormats returns the list of compressed texture formats
Expand Down