PixelShader.hpp revision d999309b36cb3dceadd38217b322f0e96a06b202
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"
1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Baumannamespace sw
2166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman{
2266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	class PixelShader : public Shader
2366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	{
2466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	public:
2566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		explicit PixelShader(const PixelShader *ps = 0);
2666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		explicit PixelShader(const unsigned long *token);
2766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
2866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		virtual ~PixelShader();
2966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
3066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		static int validate(const unsigned long *const token);   // Returns number of instructions if valid
3166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool depthOverride() const;
3266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool containsKill() const;
3366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool containsCentroid() const;
3466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool usesDiffuse(int component) const;
3566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool usesSpecular(int component) const;
3666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool usesTexture(int coordinate, int component) const;
3766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
3866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		virtual void analyze();
3966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
408a0e897ffaa5fd090d3005e9db596cb948b6b874Alexis Hetu		enum {MAX_INPUT_VARYINGS = 10};
4166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		Semantic semantic[MAX_INPUT_VARYINGS][4];   // FIXME: Private
4266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
4366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool vPosDeclared;
4466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool vFaceDeclared;
4566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
4666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	private:
4766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		void analyzeZOverride();
4866b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		void analyzeKill();
4966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		void analyzeInterpolants();
5066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
5166b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool zOverride;
5266b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool kill;
5366b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman		bool centroid;
5466b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman	};
5566b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman}
5666b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman
5766b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#endif   // sw_PixelShader_hpp
58