2
// Copyright 2019 The ANGLE Project Authors. All rights reserved.
3
// Use of this source code is governed by a BSD-style license that can be
4
// found in the LICENSE file.
6
// samplerVideoWEBGL_test.cpp:
7
// Tests compiling shaders that use samplerVideoWEBGL types
10
#include "GLSLANG/ShaderLang.h"
12
#include "gtest/gtest.h"
13
#include "tests/test_utils/ShaderCompileTreeTest.h"
17
class SamplerVideoWEBGLTest : public ShaderCompileTreeTest
20
SamplerVideoWEBGLTest() {}
22
void initResources(ShBuiltInResources *resources) override
24
resources->WEBGL_video_texture = 1;
28
::GLenum getShaderType() const override { return GL_FRAGMENT_SHADER; }
29
ShShaderSpec getShaderSpec() const override { return SH_GLES3_1_SPEC; }
32
// Checks whether compiler returns error when extension isn't enabled but samplerVideoWEBGL is
34
TEST_F(SamplerVideoWEBGLTest, UsingSamplerVideoWEBGLWithoutWEBGLVideoTextureExtensionRequired)
36
const std::string &shaderString =
37
"precision mediump float;\n"
38
"uniform mediump samplerVideoWEBGL s;\n"
41
" gl_FragColor = textureVideoWEBGL(s, vec2(0.0, 0.0));\n"
44
if (compile(shaderString))
46
FAIL() << "Shader compilation passed, expecting fail:\n" << mInfoLog;
50
// Checks whether compiler returns error when extension isn't enabled but use samplerVideoWEBGL is
51
// used in ES300 shader.
52
TEST_F(SamplerVideoWEBGLTest,
53
UsingSamplerVideoWEBGLWithoutWEBGLVideoTextureExtensionRequiredInES300)
55
const std::string &shaderString =
57
"precision mediump float;\n"
58
"uniform mediump samplerVideoWEBGL s;\n"
59
"out vec4 my_FragColor;\n"
62
" my_FragColor = texture(s, vec2(0.0, 0.0));\n"
65
if (compile(shaderString))
67
FAIL() << "Shader compilation passed, expecting fail:\n" << mInfoLog;
71
// Checks whether compiler can support samplerVideoWEBGL as texture2D parameter.
72
TEST_F(SamplerVideoWEBGLTest, SamplerVideoWEBGLCanBeSupportedInTexture2D)
74
const std::string &shaderString =
75
"#extension GL_WEBGL_video_texture : require\n"
76
"precision mediump float;\n"
77
"uniform mediump samplerVideoWEBGL s;\n"
80
" gl_FragColor = textureVideoWEBGL(s, vec2(0.0, 0.0));\n"
83
if (!compile(shaderString))
85
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
89
// Checks whether compiler can support samplerVideoWEBGL as texture parameter in ES300.
90
TEST_F(SamplerVideoWEBGLTest, SamplerVideoWEBGLCanBeSupportedInTextureInES300)
92
const std::string &shaderString =
94
"#extension GL_WEBGL_video_texture : require\n"
95
"precision mediump float;\n"
96
"uniform mediump samplerVideoWEBGL s;\n"
97
"out vec4 my_FragColor;\n"
100
" my_FragColor = texture(s, vec2(0.0, 0.0));\n"
103
if (!compile(shaderString))
105
FAIL() << "Shader compilation failed, expecting success:\n" << mInfoLog;
b'\\ No newline at end of file'