Hash :
6423b7fc
Author :
Date :
2019-12-04T18:45:24
Return the correct location count for Matrices GetLocationCount() is currently returning the number of rows in the matrix, rather than the columns, which leads to shader validation errors (and test failures). This fix returns the number of columns in a matrix. Bug: angleproject:4200 Test: dEQP-GLES31.functional.separate_shader.random.63 Change-Id: I8d25eb3733c2ddbe53ff54794f480c1d43e22a88 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1952173 Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org> Reviewed-by: Courtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Tim Van Patten <timvp@google.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 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232
//
// 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.
//
// MatrixTest:
// Test various shader matrix variable declarations.
#include <vector>
#include "test_utils/ANGLETest.h"
#include "test_utils/gl_raii.h"
using namespace angle;
namespace
{
class MatrixTest31 : public ANGLETest
{
protected:
MatrixTest31()
{
setWindowWidth(64);
setWindowHeight(64);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
TEST_P(MatrixTest31, Mat3Varying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3 matrix;
layout(location=3) out vec3 vector;
void main()
{
matrix = mat3(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3 matrix;
layout(location=3) in vec3 vector;
out vec4 oColor;
void main()
{
oColor = vec4(matrix[0], 1.0);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3VaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3 matrix;
layout(location=2) out vec3 vector;
void main()
{
matrix = mat3(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
TEST_P(MatrixTest31, Mat3x4Varying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4 matrix;
layout(location=3) out vec3 vector;
void main()
{
matrix = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3x4 matrix;
layout(location=3) in vec3 vector;
out vec4 oColor;
void main()
{
oColor = vec4(matrix[0]);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3x4VaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4 matrix;
layout(location=2) out vec3 vector;
void main()
{
matrix = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
TEST_P(MatrixTest31, Mat3x4ArrayVarying)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4[2] matrix;
layout(location=6) out vec3 vector;
void main()
{
matrix[0] = mat3x4(1.0);
matrix[1] = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
constexpr char kFS[] = R"(#version 310 es
precision mediump float;
layout(location=0) in mat3x4[2] matrix;
layout(location=6) in vec3 vector;
out vec4 oColor;
bool isZero(vec4 value) {
return value == vec4(0,0,0,0);
}
void main()
{
oColor = vec4(matrix[0][0]);
})";
ANGLE_GL_PROGRAM(program, kVS, kFS);
glUseProgram(program);
drawQuad(program, "a_position", 0.5f);
EXPECT_GL_NO_ERROR();
}
TEST_P(MatrixTest31, Mat3x4ArrayVaryingBadLocation)
{
constexpr char kVS[] = R"(#version 310 es
precision mediump float;
in vec4 a_position;
layout(location=0) out mat3x4[2] matrix;
layout(location=5) out vec3 vector;
void main()
{
matrix[0] = mat3x4(1.0);
matrix[1] = mat3x4(1.0);
vector = vec3(1.0);
gl_Position = a_position;
})";
GLProgram program;
GLuint vs = glCreateShader(GL_VERTEX_SHADER);
const char *sourceVsArray[1] = {kVS};
glShaderSource(vs, 1, sourceVsArray, nullptr);
glCompileShader(vs);
GLint compileResult;
glGetShaderiv(vs, GL_COMPILE_STATUS, &compileResult);
EXPECT_GL_FALSE(compileResult);
}
ANGLE_INSTANTIATE_TEST_ES31(MatrixTest31);
} // namespace