1d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 3d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Licensed under the Apache License, Version 2.0 (the "License"); 4d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// you may not use this file except in compliance with the License. 5d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// You may obtain a copy of the License at 666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 7d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// http://www.apache.org/licenses/LICENSE-2.0 866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman// 9d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Unless required by applicable law or agreed to in writing, software 10d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// distributed under the License is distributed on an "AS IS" BASIS, 11d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// See the License for the specific language governing permissions and 13d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// limitations under the License. 1466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#ifndef sw_PixelShader_hpp 1666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#define sw_PixelShader_hpp 1766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 1866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include "Shader.hpp" 197f781e6a4c64f25d3d825f650fabd3b29d8f2e74Nicolas Capens#include "Main/Config.hpp" 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumannamespace sw 2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman{ 2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman class PixelShader : public Shader 2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman { 2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman public: 2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman explicit PixelShader(const PixelShader *ps = 0); 2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman explicit PixelShader(const unsigned long *token); 2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman virtual ~PixelShader(); 3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman static int validate(const unsigned long *const token); // Returns number of instructions if valid 3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool depthOverride() const; 3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool containsKill() const; 3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool containsCentroid() const; 3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool usesDiffuse(int component) const; 3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool usesSpecular(int component) const; 3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool usesTexture(int coordinate, int component) const; 3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 39655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu void setInput(int inputIdx, int nbComponents, const Semantic& semantic); 40655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu const Semantic& getInput(int inputIdx, int component) const; 4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 42655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu void declareVPos() { vPosDeclared = true; } 43655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu void declareVFace() { vFaceDeclared = true; } 44655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu bool isVPosDeclared() const { return vPosDeclared; } 45655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu bool isVFaceDeclared() const { return vFaceDeclared; } 4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman private: 48655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu void analyze(); 4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman void analyzeZOverride(); 5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman void analyzeKill(); 5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman void analyzeInterpolants(); 5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 53655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu Semantic input[MAX_FRAGMENT_INPUTS][4]; 54655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu 55655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu bool vPosDeclared; 56655844b4800443aafe38ffad44526b14f8ddb119Alexis Hetu bool vFaceDeclared; 5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool zOverride; 5866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool kill; 5966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman bool centroid; 6066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman }; 6166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman} 6266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 6366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#endif // sw_PixelShader_hpp 64