Edit

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

Branch :

  • Show log

    Commit

  • Author : Jamie Madill
    Date : 2019-10-31 14:33:26
    Hash : e9603921
    Message : Capture/Replay: Correct a few GLenum replay issues. This change refactors the GLenum utils into a non-autogenerated and an autogenerated portion. That makes it easier to modify the non-auto- generated bits to properly output GLenums even when the gl.xml data isn't totally correct. For instance, the "GetPName" group was missing a bunch of queries. Instead of trying to fix the GL we can simply fall back to querying the "Default" group when we return invalid enum. Also corrects a missing "0x" on hex output. Also allows the capture/replay sample to specify the correct binary data directory when testing a replay. Bug: angleproject:3611 Change-Id: I8e4c690b2850bb157a8cde8b057b20603e4b177d Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1891008 Reviewed-by: Cody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>

  • src/libANGLE/gl_enum_utils.cpp
  • //
    // Copyright 2019 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.
    //
    // gl_enum_utils.cpp:
    //   Utility functions for converting GLenums to string.
    
    #include "libANGLE/gl_enum_utils.h"
    
    #include <iomanip>
    
    namespace gl
    {
    const char kUnknownGLenumString[] = "EnumUnknown";
    
    void OutputGLenumString(std::ostream &out, GLenumGroup enumGroup, unsigned int value)
    {
        const char *enumStr = GLenumToString(enumGroup, value);
        if (enumStr != kUnknownGLenumString)
        {
            out << enumStr;
            return;
        }
    
        if (enumGroup != GLenumGroup::DefaultGroup)
        {
            // Retry with the "Default" group
            enumStr = GLenumToString(GLenumGroup::DefaultGroup, value);
            if (enumStr != kUnknownGLenumString)
            {
                out << enumStr;
                return;
            }
        }
    
        out << std::hex << "0x" << std::setfill('0') << std::setw(4) << value << std::dec;
    }
    
    void OutputGLbitfieldString(std::ostream &out, GLenumGroup enumGroup, unsigned int value)
    {
        out << GLbitfieldToString(enumGroup, value);
    }
    
    const char *GLbooleanToString(unsigned int value)
    {
        switch (value)
        {
            case 0x0:
                return "GL_FALSE";
            case 0x1:
                return "GL_TRUE";
            default:
                return kUnknownGLenumString;
        }
    }
    }  // namespace gl