Hash :
720f6bbe
Author :
Date :
2025-05-15T00:00:00
Fix attribute and uniform name validation
* Fixed null name error messages
to refer to correct parameters.
* BindUniformLocation
* Added name checks for null
and all reserved prefixes.
* Fixed error code for reserved prefixes.
* GetAttribLocation & GetUniformLocation
* Moved reserved prefixes check to the Context.
* Fixed and expanded tests.
Fixed: angleproject:418986804
Change-Id: I62760b3010fd38ee2e31e4ff88d9910647b329dd
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/6568552
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
//
// Copyright 2015 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.
//
// ErrorMessages.cpp : Tests functionality of internal error error messages
#include "test_utils/ANGLETest.h"
#include "../src/libANGLE/ErrorStrings.h"
#include "test_utils/gl_raii.h"
namespace
{
struct Message
{
GLenum source;
GLenum type;
GLenum id;
GLenum severity;
std::string message;
const void *userParam;
inline bool operator==(Message a)
{
if (a.source == source && a.type == type && a.id == id && a.message == message)
{
return true;
}
else
{
return false;
}
}
};
static void GL_APIENTRY Callback(GLenum source,
GLenum type,
GLuint id,
GLenum severity,
GLsizei length,
const GLchar *message,
const void *userParam)
{
Message m{source, type, id, severity, std::string(message, length), userParam};
std::vector<Message> *messages =
static_cast<std::vector<Message> *>(const_cast<void *>(userParam));
messages->push_back(m);
}
} // namespace
namespace angle
{
class ErrorMessagesTest : public ANGLETest<>
{
protected:
ErrorMessagesTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
setWebGLCompatibilityEnabled(true);
}
};
// Verify functionality of WebGL specific errors using KHR_debug
TEST_P(ErrorMessagesTest, ErrorMessages)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_KHR_debug"));
glEnable(GL_DEBUG_OUTPUT);
std::vector<Message> messages;
glDebugMessageCallbackKHR(Callback, &messages);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
constexpr GLenum source = GL_DEBUG_SOURCE_API;
constexpr GLenum type = GL_DEBUG_TYPE_ERROR;
constexpr GLenum severity = GL_DEBUG_SEVERITY_HIGH;
constexpr GLuint id1 = 1282;
const std::string message1 =
std::string("glBindAttribLocation: ") + gl::err::kNameStartsWithReservedPrefix;
Message expectedMessage;
GLint numMessages = 0;
glGetIntegerv(GL_DEBUG_LOGGED_MESSAGES, &numMessages);
EXPECT_EQ(0, numMessages);
glBindAttribLocation(0, 0, "_webgl_var");
ASSERT_EQ(1u, messages.size());
expectedMessage.source = source;
expectedMessage.id = id1;
expectedMessage.type = type;
expectedMessage.severity = severity;
expectedMessage.message = message1;
Message &m = messages.front();
ASSERT_TRUE(m == expectedMessage);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these
// tests should be run against.
ANGLE_INSTANTIATE_TEST(ErrorMessagesTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_METAL(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES(),
ES2_VULKAN());
} // namespace angle