Edit

kc3-lang/angle/src/libANGLE/es3_copy_conversion_table_autogen.cpp

Branch :

  • Show log

    Commit

  • Author : Corentin Wallez
    Date : 2017-11-08 14:00:32
    Hash : f0e89be6
    Message : Use packed enums for the texture types and targets, part 1 In OpenGL there are two enum "sets" used by the API that are very similar: texture types (or bind point) and texture targets. They only differ in that texture types have GL_TEXTURE_CUBEMAP and target have GL_TEXTURE_CUBEMAP_[POSITIVE|NEGATIVE]_[X|Y|Z]. This is a problem because in ANGLE we use GLenum to pass around both types of data, making it difficult to know which of type and target a variable is. In addition these enums are placed somewhat randomly in the space of OpenGL enums, making it slow to have a mapping from texture types to some data. Such a mapping is in hot-code with gl::State::mTextures. This commit stack makes the texture types and target enums be translated to internal packed enums right at the OpenGL entry point and used throughout ANGLE to have type safety and performance gains. This is the first of two commit which does the refactor for all of the validation and stops inside gl::Context. This was the best place to split patches without having many conversions from packed enums to GL enums. BUG=angleproject:2169 Change-Id: Ib43da7e71c253bd9fe210fb0ec0de61bc286e6d3 Reviewed-on: https://chromium-review.googlesource.com/758835 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org>

  • src/libANGLE/es3_copy_conversion_table_autogen.cpp
  • // GENERATED FILE - DO NOT EDIT.
    // Generated by gen_copy_conversion_table.py using data from es3_copy_conversion_formats.json.
    //
    // Copyright 2018 The ANGLE Project Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style license that can be
    // found in the LICENSE file.
    //
    // format_map:
    //   Determining the sized internal format from a (format,type) pair.
    //   Also check es3 format combinations for validity.
    
    #include "angle_gl.h"
    #include "common/debug.h"
    
    namespace gl
    {
    
    bool ValidES3CopyConversion(GLenum textureFormat, GLenum framebufferFormat)
    {
        switch (textureFormat)
        {
            case GL_ALPHA:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_BGRA_EXT:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_LUMINANCE:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RED:
                    case GL_RG:
                    case GL_RGB:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_LUMINANCE_ALPHA:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RED:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RED:
                    case GL_RG:
                    case GL_RGB:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RED_INTEGER:
                switch (framebufferFormat)
                {
                    case GL_RED_INTEGER:
                    case GL_RGBA_INTEGER:
                    case GL_RGB_INTEGER:
                    case GL_RG_INTEGER:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RG:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RG:
                    case GL_RGB:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RGB:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RGB:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RGBA:
                switch (framebufferFormat)
                {
                    case GL_BGRA_EXT:
                    case GL_RGBA:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RGBA_INTEGER:
                switch (framebufferFormat)
                {
                    case GL_RGBA_INTEGER:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RGB_INTEGER:
                switch (framebufferFormat)
                {
                    case GL_RGBA_INTEGER:
                    case GL_RGB_INTEGER:
                        return true;
                    default:
                        break;
                }
                break;
    
            case GL_RG_INTEGER:
                switch (framebufferFormat)
                {
                    case GL_RGBA_INTEGER:
                    case GL_RGB_INTEGER:
                    case GL_RG_INTEGER:
                        return true;
                    default:
                        break;
                }
                break;
    
            default:
                break;
        }
    
        return false;
    }
    
    }  // namespace gl