Path: blob/main_old/src/tests/compiler_tests/GlFragDataNotModified_test.cpp
1693 views
//1// Copyright 2018 The ANGLE Project Authors. All rights reserved.2// Use of this source code is governed by a BSD-style license that can be3// found in the LICENSE file.4//5// GlFragDataNotModified_test.cpp:6// Test that the properties of built-in gl_FragData are not modified when a shader is compiled7// multiple times.8//910#include "tests/test_utils/ShaderCompileTreeTest.h"1112namespace13{1415class GlFragDataNotModifiedTest : public sh::ShaderCompileTreeTest16{17public:18GlFragDataNotModifiedTest() {}1920protected:21void initResources(ShBuiltInResources *resources) override22{23resources->MaxDrawBuffers = 4;24resources->EXT_draw_buffers = 1;25}2627::GLenum getShaderType() const override { return GL_FRAGMENT_SHADER; }28ShShaderSpec getShaderSpec() const override { return SH_GLES2_SPEC; }29};3031// Test a bug where we could modify the value of a builtin variable.32TEST_F(GlFragDataNotModifiedTest, BuiltinRewritingBug)33{34const std::string &shaderString =35"#extension GL_EXT_draw_buffers : require\n"36"precision mediump float;\n"37"void main() {\n"38" gl_FragData[gl_MaxDrawBuffers] = vec4(0.0);\n"39"}";4041if (compile(shaderString))42{43FAIL() << "Shader compilation succeeded, expecting failure\n";44}45if (compile(shaderString))46{47FAIL() << "Shader compilation succeeded, expecting failure\n";48}49}5051} // anonymous namespace525354