Hash :
d55d283c
Author :
Date :
2015-10-27T13:59:19
Add a test for flat shader 'provoking vertex'. The provoking vertex, or leading vertex, is the vertex in a triangle which produces the value that gets used for a flat-shaded triangle. Flat shading means the same value gets used for the entire triangle. It seems as though D3D and OpenGL have different definitions of which vertex is the leading/provoking one; GL says it is the *last* vertex of a primitive, while while D3D says it is the first. Additional complexity comes about from triangle strips, which switch winding order, and primitive restart, which defines new primitives in the middle of prior primitives. BUG=angleproject:754 Change-Id: If1217cba33dabf3b1e4ad13fd639d049cb16fe44 Reviewed-on: https://chromium-review.googlesource.com/309152 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Geoff Lang <geofflang@chromium.org> Tested-by: Jamie Madill <jmadill@chromium.org>
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 123
//
// Copyright (c) 2012 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.
//
#ifndef ANGLE_TESTS_ANGLE_TEST_H_
#define ANGLE_TESTS_ANGLE_TEST_H_
#include <gtest/gtest.h>
#include <algorithm>
#include "angle_gl.h"
#include "angle_test_configs.h"
#include "common/angleutils.h"
#include "shader_utils.h"
#define EXPECT_GL_ERROR(err) EXPECT_EQ(static_cast<GLenum>(err), glGetError())
#define EXPECT_GL_NO_ERROR() EXPECT_GL_ERROR(GL_NO_ERROR)
#define ASSERT_GL_ERROR(err) ASSERT_EQ(static_cast<GLenum>(err), glGetError())
#define ASSERT_GL_NO_ERROR() ASSERT_GL_ERROR(GL_NO_ERROR)
#define EXPECT_EGL_ERROR(err) EXPECT_EQ((err), eglGetError())
#define EXPECT_EGL_SUCCESS() EXPECT_EGL_ERROR(EGL_SUCCESS)
#define ASSERT_EGL_ERROR(err) ASSERT_EQ((err), eglGetError())
#define ASSERT_EGL_SUCCESS() ASSERT_EGL_ERROR(EGL_SUCCESS)
#define ASSERT_GLENUM_EQ(expected, actual) ASSERT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#define EXPECT_GLENUM_EQ(expected, actual) EXPECT_EQ(static_cast<GLenum>(expected), static_cast<GLenum>(actual))
#define EXPECT_PIXEL_EQ(x, y, r, g, b, a) \
{ \
GLubyte pixel[4]; \
glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); \
EXPECT_GL_NO_ERROR(); \
EXPECT_EQ((r), pixel[0]); \
EXPECT_EQ((g), pixel[1]); \
EXPECT_EQ((b), pixel[2]); \
EXPECT_EQ((a), pixel[3]); \
}
#define EXPECT_PIXEL_NEAR(x, y, r, g, b, a, abs_error) \
{ \
GLubyte pixel[4]; \
glReadPixels((x), (y), 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel); \
EXPECT_GL_NO_ERROR(); \
EXPECT_NEAR((r), pixel[0], abs_error); \
EXPECT_NEAR((g), pixel[1], abs_error); \
EXPECT_NEAR((b), pixel[2], abs_error); \
EXPECT_NEAR((a), pixel[3], abs_error); \
}
class EGLWindow;
class OSWindow;
class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
{
protected:
ANGLETest();
~ANGLETest();
public:
static bool InitTestWindow();
static bool DestroyTestWindow();
static void SetWindowVisible(bool isVisible);
static bool eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName);
protected:
virtual void SetUp();
virtual void TearDown();
virtual void swapBuffers();
static void drawQuad(GLuint program, const std::string& positionAttribName, GLfloat quadDepth, GLfloat quadScale = 1.0f);
static GLuint compileShader(GLenum type, const std::string &source);
static bool extensionEnabled(const std::string &extName);
static bool eglClientExtensionEnabled(const std::string &extName);
void setWindowWidth(int width);
void setWindowHeight(int height);
void setConfigRedBits(int bits);
void setConfigGreenBits(int bits);
void setConfigBlueBits(int bits);
void setConfigAlphaBits(int bits);
void setConfigDepthBits(int bits);
void setConfigStencilBits(int bits);
void setMultisampleEnabled(bool enabled);
int getClientVersion() const;
EGLWindow *getEGLWindow() const;
int getWindowWidth() const;
int getWindowHeight() const;
bool isMultisampleEnabled() const;
bool isIntel() const;
bool isAMD() const;
bool isNVidia() const;
// Note: FL9_3 is explicitly *not* considered D3D11.
bool isD3D11() const;
EGLint getPlatformRenderer() const;
private:
bool createEGLContext();
bool destroyEGLContext();
EGLWindow *mEGLWindow;
int mWidth;
int mHeight;
static OSWindow *mOSWindow;
};
class ANGLETestEnvironment : public testing::Environment
{
public:
virtual void SetUp();
virtual void TearDown();
};
#endif // ANGLE_TESTS_ANGLE_TEST_H_