blob: 295941874b3f45c63b8057a3f958e3f47d5ae24c [file] [log] [blame]
Nicolas Capens68a82382018-10-02 13:16:55 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#ifndef sw_PixelProgram_hpp
16#define sw_PixelProgram_hpp
17
18#include "PixelRoutine.hpp"
19#include "SamplerCore.hpp"
20
21namespace sw
22{
23 class PixelProgram : public PixelRoutine
24 {
25 public:
Chris Forbes1845d5e2018-12-27 11:50:15 -080026 PixelProgram(const PixelProcessor::State &state, SpirvShader const *spirvShader) :
27 PixelRoutine(state, spirvShader)
Nicolas Capens68a82382018-10-02 13:16:55 -040028 {
Nicolas Capens68a82382018-10-02 13:16:55 -040029 }
30
31 virtual ~PixelProgram() {}
32
33 protected:
34 virtual void setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w);
35 virtual void applyShader(Int cMask[4]);
36 virtual Bool alphaTest(Int cMask[4]);
Chris Forbese7579262019-02-10 19:21:59 +000037 virtual void rasterOperation(Pointer<Byte> cBuffer[4], Int &x, Int sMask[4], Int zMask[4], Int cMask[4]);
Nicolas Capens68a82382018-10-02 13:16:55 -040038
39 private:
Nicolas Capens68a82382018-10-02 13:16:55 -040040 // Color outputs
41 Vector4f c[RENDERTARGETS];
Nicolas Capens68a82382018-10-02 13:16:55 -040042
Nicolas Capens68a82382018-10-02 13:16:55 -040043 // Per pixel based on conditions reached
44 Int enableIndex;
45 Array<Int4, 1 + 24> enableStack;
Nicolas Capens68a82382018-10-02 13:16:55 -040046
47 // Raster operations
48 void clampColor(Vector4f oC[RENDERTARGETS]);
49
Chris Forbes1845d5e2018-12-27 11:50:15 -080050 Int4 enableMask();
Nicolas Capens68a82382018-10-02 13:16:55 -040051
52 Float4 linearToSRGB(const Float4 &x);
Nicolas Capens68a82382018-10-02 13:16:55 -040053 };
54}
55
56#endif