Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
angle
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
angle
Commits
f95c046e
Commit
f95c046e
authored
Oct 18, 2013
by
Geoff Lang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added vertex attribute tests.
TRAC #23776 Signed-off-by: Jamie Madill Signed-off-by: Shannon Woods
parent
8a079e5e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
218 additions
and
0 deletions
+218
-0
VertexAttributeTest.cpp
tests/angle_tests/VertexAttributeTest.cpp
+218
-0
No files found.
tests/angle_tests/VertexAttributeTest.cpp
0 → 100644
View file @
f95c046e
#include "ANGLETest.h"
class
VertexAttributeTest
:
public
ANGLETest
{
protected
:
VertexAttributeTest
()
{
setWindowWidth
(
128
);
setWindowHeight
(
128
);
setRedBits
(
8
);
setGreenBits
(
8
);
setBlueBits
(
8
);
setAlphaBits
(
8
);
setDepthBits
(
24
);
mProgram
=
0
;
mTestAttrib
=
-
1
;
mExpectedAttrib
=
-
1
;
}
struct
TestData
{
GLenum
type
;
GLboolean
normalized
;
const
void
*
inputData
;
const
GLfloat
*
expectedData
;
};
void
runTest
(
const
TestData
&
test
)
{
GLint
viewportSize
[
4
];
glGetIntegerv
(
GL_VIEWPORT
,
viewportSize
);
GLint
midPixelX
=
(
viewportSize
[
0
]
+
viewportSize
[
2
])
/
2
;
GLint
midPixelY
=
(
viewportSize
[
1
]
+
viewportSize
[
3
])
/
2
;
for
(
size_t
i
=
0
;
i
<
4
;
i
++
)
{
glBindBuffer
(
GL_ARRAY_BUFFER
,
0
);
glVertexAttribPointer
(
mTestAttrib
,
i
+
1
,
test
.
type
,
test
.
normalized
,
0
,
test
.
inputData
);
glVertexAttribPointer
(
mExpectedAttrib
,
i
+
1
,
GL_FLOAT
,
GL_FALSE
,
0
,
test
.
expectedData
);
glEnableVertexAttribArray
(
mTestAttrib
);
glEnableVertexAttribArray
(
mExpectedAttrib
);
drawQuad
(
mProgram
,
"position"
,
0.5
f
);
glDisableVertexAttribArray
(
mTestAttrib
);
glDisableVertexAttribArray
(
mExpectedAttrib
);
EXPECT_PIXEL_EQ
(
midPixelX
,
midPixelY
,
255
,
255
,
255
,
255
);
}
}
virtual
void
SetUp
()
{
ANGLETest
::
SetUp
();
const
std
::
string
testVertexShaderSource
=
SHADER_SOURCE
(
attribute
highp
vec4
position
;
attribute
highp
vec4
test
;
attribute
highp
vec4
expected
;
varying
highp
vec4
color
;
void
main
(
void
)
{
gl_Position
=
position
;
color
=
vec4
(
lessThan
(
abs
(
test
-
expected
),
vec4
(
1.0
/
128.0
)));
}
);
const
std
::
string
testFragmentShaderSource
=
SHADER_SOURCE
(
varying
highp
vec4
color
;
void
main
(
void
)
{
gl_FragColor
=
color
;
}
);
mProgram
=
compileProgram
(
testVertexShaderSource
,
testFragmentShaderSource
);
if
(
mProgram
==
0
)
{
FAIL
()
<<
"shader compilation failed."
;
}
mTestAttrib
=
glGetAttribLocation
(
mProgram
,
"test"
);
mExpectedAttrib
=
glGetAttribLocation
(
mProgram
,
"expected"
);
glUseProgram
(
mProgram
);
glClearColor
(
0
,
0
,
0
,
0
);
glClearDepthf
(
0.0
);
glClear
(
GL_COLOR_BUFFER_BIT
|
GL_DEPTH_BUFFER_BIT
);
glDisable
(
GL_DEPTH_TEST
);
}
virtual
void
TearDown
()
{
glDeleteProgram
(
mProgram
);
ANGLETest
::
TearDown
();
}
static
const
size_t
mVertexCount
=
24
;
GLuint
mProgram
;
GLint
mTestAttrib
;
GLint
mExpectedAttrib
;
};
TEST_F
(
VertexAttributeTest
,
unsigned_byte_unormalized
)
{
GLubyte
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
125
,
126
,
127
,
128
,
129
,
250
,
251
,
252
,
253
,
254
,
255
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
];
}
TestData
data
=
{
GL_UNSIGNED_BYTE
,
GL_FALSE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
unsigned_byte_normalized
)
{
GLubyte
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
4
,
5
,
6
,
7
,
125
,
126
,
127
,
128
,
129
,
250
,
251
,
252
,
253
,
254
,
255
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
]
/
255.0
f
;
}
TestData
data
=
{
GL_UNSIGNED_BYTE
,
GL_TRUE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
byte_unnormalized
)
{
GLbyte
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
4
,
-
1
,
-
2
,
-
3
,
-
4
,
125
,
126
,
127
,
-
128
,
-
127
,
-
126
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
];
}
TestData
data
=
{
GL_BYTE
,
GL_FALSE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
byte_normalized
)
{
GLbyte
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
4
,
-
1
,
-
2
,
-
3
,
-
4
,
125
,
126
,
127
,
-
128
,
-
127
,
-
126
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
((
2.0
f
*
inputData
[
i
])
+
1.0
f
)
/
255.0
f
;
}
TestData
data
=
{
GL_BYTE
,
GL_TRUE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
unsigned_short_unormalized
)
{
GLushort
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
254
,
255
,
256
,
32766
,
32767
,
32768
,
65533
,
65534
,
65535
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
];
}
TestData
data
=
{
GL_UNSIGNED_SHORT
,
GL_FALSE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
unsigned_short_normalized
)
{
GLushort
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
254
,
255
,
256
,
32766
,
32767
,
32768
,
65533
,
65534
,
65535
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
]
/
65535.0
f
;
}
TestData
data
=
{
GL_UNSIGNED_SHORT
,
GL_TRUE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
short_unnormalized
)
{
GLshort
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
-
1
,
-
2
,
-
3
,
-
4
,
32766
,
32767
,
-
32768
,
-
32767
,
-
32766
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
inputData
[
i
];
}
TestData
data
=
{
GL_SHORT
,
GL_FALSE
,
inputData
,
expectedData
};
runTest
(
data
);
}
TEST_F
(
VertexAttributeTest
,
short_normalized
)
{
GLshort
inputData
[
mVertexCount
]
=
{
0
,
1
,
2
,
3
,
-
1
,
-
2
,
-
3
,
-
4
,
32766
,
32767
,
-
32768
,
-
32767
,
-
32766
};
GLfloat
expectedData
[
mVertexCount
];
for
(
size_t
i
=
0
;
i
<
mVertexCount
;
i
++
)
{
expectedData
[
i
]
=
((
2.0
f
*
inputData
[
i
])
+
1.0
f
)
/
65535.0
f
;
}
TestData
data
=
{
GL_SHORT
,
GL_TRUE
,
inputData
,
expectedData
};
runTest
(
data
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment