Commit c2c5fc48 by Qiankun Miao Committed by Commit Bot

Remove CSS Shader related code

CSS shader has been removed from spec and chrome code base. Remove the code in ANGLE. BUG=chromium:233383 Change-Id: I93a35437f540e51ce7af9d49f21ca60d7c0b156a Reviewed-on: https://chromium-review.googlesource.com/378739Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
parent 7ef9aa7b
...@@ -49,7 +49,7 @@ typedef unsigned int GLenum; ...@@ -49,7 +49,7 @@ typedef unsigned int GLenum;
// Version number for shader translation API. // Version number for shader translation API.
// It is incremented every time the API changes. // It is incremented every time the API changes.
#define ANGLE_SH_VERSION 155 #define ANGLE_SH_VERSION 156
typedef enum { typedef enum {
SH_GLES2_SPEC, SH_GLES2_SPEC,
...@@ -61,27 +61,6 @@ typedef enum { ...@@ -61,27 +61,6 @@ typedef enum {
SH_GLES3_1_SPEC, SH_GLES3_1_SPEC,
SH_WEBGL3_SPEC, SH_WEBGL3_SPEC,
// The CSS Shaders spec is a subset of the WebGL spec.
//
// In both CSS vertex and fragment shaders, ANGLE:
// (1) Reserves the "css_" prefix.
// (2) Renames the main function to css_main.
// (3) Disables the gl_MaxDrawBuffers built-in.
//
// In CSS fragment shaders, ANGLE:
// (1) Disables the gl_FragColor built-in.
// (2) Disables the gl_FragData built-in.
// (3) Enables the css_MixColor built-in.
// (4) Enables the css_ColorMatrix built-in.
//
// After passing a CSS shader through ANGLE, the browser is expected to append
// a new main function to it.
// This new main function will call the css_main function.
// It may also perform additional operations like varying assignment, texture
// access, and gl_FragColor assignment in order to implement the CSS Shaders
// blend modes.
//
SH_CSS_SHADERS_SPEC
} ShShaderSpec; } ShShaderSpec;
typedef enum typedef enum
......
...@@ -134,9 +134,6 @@ int main(int argc, char *argv[]) ...@@ -134,9 +134,6 @@ int main(int argc, char *argv[])
spec = SH_WEBGL_SPEC; spec = SH_WEBGL_SPEC;
} }
break; break;
case 'c':
spec = SH_CSS_SHADERS_SPEC;
break;
default: default:
failCode = EFailUsage; failCode = EFailUsage;
} }
...@@ -331,7 +328,6 @@ void usage() ...@@ -331,7 +328,6 @@ void usage()
" -s=e31 : use GLES31 spec (in development)\n" " -s=e31 : use GLES31 spec (in development)\n"
" -s=w : use WebGL spec\n" " -s=w : use WebGL spec\n"
" -s=w2 : use WebGL 2 spec (in development)\n" " -s=w2 : use WebGL 2 spec (in development)\n"
" -s=c : use CSS Shaders spec\n"
" -b=e : output GLSL ES code (this is by default)\n" " -b=e : output GLSL ES code (this is by default)\n"
" -b=g : output GLSL code (compatibility profile)\n" " -b=g : output GLSL code (compatibility profile)\n"
" -b=g[NUM]: output GLSL code (NUM can be 130, 140, 150, 330, 400, 410, 420, 430, " " -b=g[NUM]: output GLSL code (NUM can be 130, 140, 150, 330, 400, 410, 420, 430, "
......
...@@ -91,7 +91,6 @@ ...@@ -91,7 +91,6 @@
'compiler/translator/RewriteDoWhile.h', 'compiler/translator/RewriteDoWhile.h',
'compiler/translator/RewriteTexelFetchOffset.cpp', 'compiler/translator/RewriteTexelFetchOffset.cpp',
'compiler/translator/RewriteTexelFetchOffset.h', 'compiler/translator/RewriteTexelFetchOffset.h',
'compiler/translator/RenameFunction.h',
'compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp', 'compiler/translator/ScalarizeVecAndMatConstructorArgs.cpp',
'compiler/translator/ScalarizeVecAndMatConstructorArgs.h', 'compiler/translator/ScalarizeVecAndMatConstructorArgs.h',
'compiler/translator/SearchSymbol.cpp', 'compiler/translator/SearchSymbol.cpp',
......
...@@ -17,7 +17,6 @@ ...@@ -17,7 +17,6 @@
#include "compiler/translator/PruneEmptyDeclarations.h" #include "compiler/translator/PruneEmptyDeclarations.h"
#include "compiler/translator/RegenerateStructNames.h" #include "compiler/translator/RegenerateStructNames.h"
#include "compiler/translator/RemovePow.h" #include "compiler/translator/RemovePow.h"
#include "compiler/translator/RenameFunction.h"
#include "compiler/translator/RewriteDoWhile.h" #include "compiler/translator/RewriteDoWhile.h"
#include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h" #include "compiler/translator/ScalarizeVecAndMatConstructorArgs.h"
#include "compiler/translator/UnfoldShortCircuitAST.h" #include "compiler/translator/UnfoldShortCircuitAST.h"
...@@ -35,8 +34,7 @@ ...@@ -35,8 +34,7 @@
bool IsWebGLBasedSpec(ShShaderSpec spec) bool IsWebGLBasedSpec(ShShaderSpec spec)
{ {
return (spec == SH_WEBGL_SPEC || spec == SH_CSS_SHADERS_SPEC || spec == SH_WEBGL2_SPEC || return (spec == SH_WEBGL_SPEC || spec == SH_WEBGL2_SPEC || spec == SH_WEBGL3_SPEC);
spec == SH_WEBGL3_SPEC);
} }
bool IsGLSL130OrNewer(ShShaderOutput output) bool IsGLSL130OrNewer(ShShaderOutput output)
...@@ -60,7 +58,6 @@ size_t GetGlobalMaxTokenSize(ShShaderSpec spec) ...@@ -60,7 +58,6 @@ size_t GetGlobalMaxTokenSize(ShShaderSpec spec)
switch (spec) switch (spec)
{ {
case SH_WEBGL_SPEC: case SH_WEBGL_SPEC:
case SH_CSS_SHADERS_SPEC:
return 256; return 256;
default: default:
return 1024; return 1024;
...@@ -111,7 +108,6 @@ int MapSpecToShaderVersion(ShShaderSpec spec) ...@@ -111,7 +108,6 @@ int MapSpecToShaderVersion(ShShaderSpec spec)
{ {
case SH_GLES2_SPEC: case SH_GLES2_SPEC:
case SH_WEBGL_SPEC: case SH_WEBGL_SPEC:
case SH_CSS_SHADERS_SPEC:
return 100; return 100;
case SH_GLES3_SPEC: case SH_GLES3_SPEC:
case SH_WEBGL2_SPEC: case SH_WEBGL2_SPEC:
...@@ -298,9 +294,6 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[], ...@@ -298,9 +294,6 @@ TIntermNode *TCompiler::compileTreeImpl(const char *const shaderStrings[],
if (success && (compileOptions & SH_TIMING_RESTRICTIONS)) if (success && (compileOptions & SH_TIMING_RESTRICTIONS))
success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0); success = enforceTimingRestrictions(root, (compileOptions & SH_DEPENDENCY_GRAPH) != 0);
if (success && shaderSpec == SH_CSS_SHADERS_SPEC)
rewriteCSSShader(root);
// Unroll for-loop markup needs to happen after validateLimitations pass. // Unroll for-loop markup needs to happen after validateLimitations pass.
if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX)) if (success && (compileOptions & SH_UNROLL_FOR_LOOP_WITH_INTEGER_INDEX))
{ {
...@@ -763,12 +756,6 @@ bool TCompiler::validateOutputs(TIntermNode* root) ...@@ -763,12 +756,6 @@ bool TCompiler::validateOutputs(TIntermNode* root)
return (validateOutputs.validateAndCountErrors(infoSink.info) == 0); return (validateOutputs.validateAndCountErrors(infoSink.info) == 0);
} }
void TCompiler::rewriteCSSShader(TIntermNode* root)
{
RenameFunction renamer("main(", "css_main(");
root->traverse(&renamer);
}
bool TCompiler::validateLimitations(TIntermNode* root) bool TCompiler::validateLimitations(TIntermNode* root)
{ {
ValidateLimitations validate(shaderType, &infoSink.info); ValidateLimitations validate(shaderType, &infoSink.info);
......
...@@ -31,8 +31,7 @@ class TranslatorHLSL; ...@@ -31,8 +31,7 @@ class TranslatorHLSL;
#endif // ANGLE_ENABLE_HLSL #endif // ANGLE_ENABLE_HLSL
// //
// Helper function to identify specs that are based on the WebGL spec, // Helper function to identify specs that are based on the WebGL spec.
// like the CSS Shaders spec.
// //
bool IsWebGLBasedSpec(ShShaderSpec spec); bool IsWebGLBasedSpec(ShShaderSpec spec);
...@@ -119,8 +118,6 @@ class TCompiler : public TShHandleBase ...@@ -119,8 +118,6 @@ class TCompiler : public TShHandleBase
bool checkCallDepth(); bool checkCallDepth();
// Returns true if a program has no conflicting or missing fragment outputs // Returns true if a program has no conflicting or missing fragment outputs
bool validateOutputs(TIntermNode* root); bool validateOutputs(TIntermNode* root);
// Rewrites a shader's intermediate tree according to the CSS Shaders spec.
void rewriteCSSShader(TIntermNode* root);
// Returns true if the given shader does not exceed the minimum // Returns true if the given shader does not exceed the minimum
// functionality mandated in GLSL 1.0 spec Appendix A. // functionality mandated in GLSL 1.0 spec Appendix A.
bool validateLimitations(TIntermNode* root); bool validateLimitations(TIntermNode* root);
......
...@@ -511,16 +511,13 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR ...@@ -511,16 +511,13 @@ void InsertBuiltInFunctions(sh::GLenum type, ShShaderSpec spec, const ShBuiltInR
symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors, symbolTable.insertConstInt(ESSL1_BUILTINS, "gl_MaxVaryingVectors", resources.MaxVaryingVectors,
EbpMedium); EbpMedium);
if (spec != SH_CSS_SHADERS_SPEC) symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers,
EbpMedium);
if (resources.EXT_blend_func_extended)
{ {
symbolTable.insertConstInt(COMMON_BUILTINS, "gl_MaxDrawBuffers", resources.MaxDrawBuffers, symbolTable.insertConstIntExt(COMMON_BUILTINS, "GL_EXT_blend_func_extended",
EbpMedium); "gl_MaxDualSourceDrawBuffersEXT",
if (resources.EXT_blend_func_extended) resources.MaxDualSourceDrawBuffers);
{
symbolTable.insertConstIntExt(COMMON_BUILTINS, "GL_EXT_blend_func_extended",
"gl_MaxDualSourceDrawBuffersEXT",
resources.MaxDualSourceDrawBuffers);
}
} }
symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors", symbolTable.insertConstInt(ESSL3_BUILTINS, "gl_MaxVertexOutputVectors",
...@@ -590,85 +587,73 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec, ...@@ -590,85 +587,73 @@ void IdentifyBuiltIns(sh::GLenum type, ShShaderSpec spec,
switch (type) switch (type)
{ {
case GL_FRAGMENT_SHADER: case GL_FRAGMENT_SHADER:
symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"), {
TType(EbtFloat, EbpMedium, EvqFragCoord, 4))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FragCoord"),
symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"), TType(EbtFloat, EbpMedium, EvqFragCoord, 4)));
TType(EbtBool, EbpUndefined, EvqFrontFacing, 1))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_FrontFacing"),
symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"), TType(EbtBool, EbpUndefined, EvqFrontFacing, 1)));
TType(EbtFloat, EbpMedium, EvqPointCoord, 2))); symbolTable.insert(COMMON_BUILTINS, new TVariable(NewPoolTString("gl_PointCoord"),
TType(EbtFloat, EbpMedium, EvqPointCoord, 2)));
//
// In CSS Shaders, gl_FragColor, gl_FragData, and gl_MaxDrawBuffers are not available. symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"),
// Instead, css_MixColor and css_ColorMatrix are available. TType(EbtFloat, EbpMedium, EvqFragColor, 4)));
// TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true);
if (spec != SH_CSS_SHADERS_SPEC) fragData.setArraySize(resources.MaxDrawBuffers);
{ symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData));
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragColor"),
TType(EbtFloat, EbpMedium, EvqFragColor, 4))); if (resources.EXT_blend_func_extended)
TType fragData(EbtFloat, EbpMedium, EvqFragData, 4, 1, true); {
fragData.setArraySize(resources.MaxDrawBuffers); symbolTable.insert(
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("gl_FragData"), fragData)); ESSL1_BUILTINS, "GL_EXT_blend_func_extended",
new TVariable(NewPoolTString("gl_SecondaryFragColorEXT"),
if (resources.EXT_blend_func_extended) TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4)));
{ TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1, true);
symbolTable.insert( secondaryFragData.setArraySize(resources.MaxDualSourceDrawBuffers);
ESSL1_BUILTINS, "GL_EXT_blend_func_extended", symbolTable.insert(
new TVariable(NewPoolTString("gl_SecondaryFragColorEXT"), ESSL1_BUILTINS, "GL_EXT_blend_func_extended",
TType(EbtFloat, EbpMedium, EvqSecondaryFragColorEXT, 4))); new TVariable(NewPoolTString("gl_SecondaryFragDataEXT"), secondaryFragData));
TType secondaryFragData(EbtFloat, EbpMedium, EvqSecondaryFragDataEXT, 4, 1, true); }
secondaryFragData.setArraySize(resources.MaxDualSourceDrawBuffers);
symbolTable.insert( if (resources.EXT_frag_depth)
ESSL1_BUILTINS, "GL_EXT_blend_func_extended", {
new TVariable(NewPoolTString("gl_SecondaryFragDataEXT"), secondaryFragData)); symbolTable.insert(
} ESSL1_BUILTINS, "GL_EXT_frag_depth",
new TVariable(
if (resources.EXT_frag_depth) NewPoolTString("gl_FragDepthEXT"),
{ TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium,
symbolTable.insert( EvqFragDepthEXT, 1)));
ESSL1_BUILTINS, "GL_EXT_frag_depth", }
new TVariable(
NewPoolTString("gl_FragDepthEXT"), symbolTable.insert(ESSL3_BUILTINS,
TType(EbtFloat, resources.FragmentPrecisionHigh ? EbpHigh : EbpMedium, new TVariable(NewPoolTString("gl_FragDepth"),
EvqFragDepthEXT, 1))); TType(EbtFloat, EbpHigh, EvqFragDepth, 1)));
}
if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch)
symbolTable.insert(ESSL3_BUILTINS, {
new TVariable(NewPoolTString("gl_FragDepth"), TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true);
TType(EbtFloat, EbpHigh, EvqFragDepth, 1))); lastFragData.setArraySize(resources.MaxDrawBuffers);
if (resources.EXT_shader_framebuffer_fetch || resources.NV_shader_framebuffer_fetch) if (resources.EXT_shader_framebuffer_fetch)
{ {
TType lastFragData(EbtFloat, EbpMedium, EvqLastFragData, 4, 1, true); symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch",
lastFragData.setArraySize(resources.MaxDrawBuffers); new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
}
if (resources.EXT_shader_framebuffer_fetch) else if (resources.NV_shader_framebuffer_fetch)
{ {
symbolTable.insert(ESSL1_BUILTINS, "GL_EXT_shader_framebuffer_fetch", symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); new TVariable(NewPoolTString("gl_LastFragColor"),
} TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
else if (resources.NV_shader_framebuffer_fetch) symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch",
{ new TVariable(NewPoolTString("gl_LastFragData"), lastFragData));
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", }
new TVariable(NewPoolTString("gl_LastFragColor"), }
TType(EbtFloat, EbpMedium, EvqLastFragColor, 4))); else if (resources.ARM_shader_framebuffer_fetch)
symbolTable.insert(ESSL1_BUILTINS, "GL_NV_shader_framebuffer_fetch", {
new TVariable(NewPoolTString("gl_LastFragData"), lastFragData)); symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch",
} new TVariable(NewPoolTString("gl_LastFragColorARM"),
} TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
else if (resources.ARM_shader_framebuffer_fetch) }
{ }
symbolTable.insert(ESSL1_BUILTINS, "GL_ARM_shader_framebuffer_fetch",
new TVariable(NewPoolTString("gl_LastFragColorARM"),
TType(EbtFloat, EbpMedium, EvqLastFragColor, 4)));
}
}
else
{
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_MixColor"),
TType(EbtFloat, EbpMedium, EvqGlobal, 4)));
symbolTable.insert(ESSL1_BUILTINS, new TVariable(NewPoolTString("css_ColorMatrix"),
TType(EbtFloat, EbpMedium, EvqGlobal, 4, 4)));
}
break; break;
......
...@@ -447,11 +447,6 @@ bool TParseContext::checkIsNotReserved(const TSourceLoc &line, const TString &id ...@@ -447,11 +447,6 @@ bool TParseContext::checkIsNotReserved(const TSourceLoc &line, const TString &id
error(line, reservedErrMsg, "_webgl_"); error(line, reservedErrMsg, "_webgl_");
return false; return false;
} }
if (mShaderSpec == SH_CSS_SHADERS_SPEC && identifier.compare(0, 4, "css_") == 0)
{
error(line, reservedErrMsg, "css_");
return false;
}
} }
if (identifier.find("__") != TString::npos) if (identifier.find("__") != TString::npos)
{ {
......
//
// 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 COMPILER_TRANSLATOR_RENAMEFUNCTION_H_
#define COMPILER_TRANSLATOR_RENAMEFUNCTION_H_
#include "compiler/translator/IntermNode.h"
//
// Renames a function, including its declaration and any calls to it.
//
class RenameFunction : public TIntermTraverser
{
public:
RenameFunction(const TString& oldFunctionName, const TString& newFunctionName)
: TIntermTraverser(true, false, false)
, mOldFunctionName(oldFunctionName)
, mNewFunctionName(newFunctionName) {}
bool visitAggregate(Visit visit, TIntermAggregate *node) override
{
TOperator op = node->getOp();
if ((op == EOpFunction || op == EOpFunctionCall) && node->getName() == mOldFunctionName)
node->setName(mNewFunctionName);
return true;
}
private:
const TString mOldFunctionName;
const TString mNewFunctionName;
};
#endif // COMPILER_TRANSLATOR_RENAMEFUNCTION_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment