blob: 71c46df5915d5dee679e7db48d6ed637c0fd3106 [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:
Ben Clayton76e9bc02019-02-26 15:02:18 +000026 PixelProgram(
27 const PixelProcessor::State &state,
28 vk::PipelineLayout const *pipelineLayout,
29 SpirvShader const *spirvShader) :
30 PixelRoutine(state, pipelineLayout, spirvShader)
Nicolas Capens68a82382018-10-02 13:16:55 -040031 {
Nicolas Capens68a82382018-10-02 13:16:55 -040032 }
33
34 virtual ~PixelProgram() {}
35
36 protected:
37 virtual void setBuiltins(Int &x, Int &y, Float4(&z)[4], Float4 &w);
38 virtual void applyShader(Int cMask[4]);
39 virtual Bool alphaTest(Int cMask[4]);
Chris Forbese7579262019-02-10 19:21:59 +000040 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 -040041
42 private:
Nicolas Capens68a82382018-10-02 13:16:55 -040043 // Color outputs
44 Vector4f c[RENDERTARGETS];
Nicolas Capens68a82382018-10-02 13:16:55 -040045
Nicolas Capens68a82382018-10-02 13:16:55 -040046 // Per pixel based on conditions reached
47 Int enableIndex;
48 Array<Int4, 1 + 24> enableStack;
Nicolas Capens68a82382018-10-02 13:16:55 -040049
50 // Raster operations
51 void clampColor(Vector4f oC[RENDERTARGETS]);
52
Chris Forbes1845d5e2018-12-27 11:50:15 -080053 Int4 enableMask();
Nicolas Capens68a82382018-10-02 13:16:55 -040054
55 Float4 linearToSRGB(const Float4 &x);
Nicolas Capens68a82382018-10-02 13:16:55 -040056 };
57}
58
59#endif