blob: 77bbce15d0af287f58f602aa12534db01031f8ca [file] [log] [blame]
Nicolas Capens0bac2852016-05-07 06:09:58 -04001// Copyright 2016 The SwiftShader Authors. All Rights Reserved.
John Bauman66b8ab22014-05-06 15:57:45 -04002//
Nicolas Capens0bac2852016-05-07 06:09:58 -04003// 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
John Bauman66b8ab22014-05-06 15:57:45 -04006//
Nicolas Capens0bac2852016-05-07 06:09:58 -04007// http://www.apache.org/licenses/LICENSE-2.0
John Bauman66b8ab22014-05-06 15:57:45 -04008//
Nicolas Capens0bac2852016-05-07 06:09:58 -04009// 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.
John Bauman66b8ab22014-05-06 15:57:45 -040014
15#ifndef sw_QuadRasterizer_hpp
16#define sw_QuadRasterizer_hpp
17
18#include "Rasterizer.hpp"
Nicolas Capens708c24b2017-10-26 13:07:10 -040019#include "Shader/ShaderCore.hpp"
20#include "Shader/PixelShader.hpp"
21#include "Common/Types.hpp"
John Bauman66b8ab22014-05-06 15:57:45 -040022
23namespace sw
24{
Alexis Hetuf2a8c372015-07-13 11:08:41 -040025 class QuadRasterizer : public Rasterizer
John Bauman66b8ab22014-05-06 15:57:45 -040026 {
Nicolas Capensba53fbf2016-01-14 13:43:42 -050027 public:
Alexis Hetuf2a8c372015-07-13 11:08:41 -040028 QuadRasterizer(const PixelProcessor::State &state, const PixelShader *shader);
John Bauman66b8ab22014-05-06 15:57:45 -040029 virtual ~QuadRasterizer();
30
Nicolas Capensba53fbf2016-01-14 13:43:42 -050031 void generate();
32
33 protected:
Nicolas Capens4f172c72016-01-13 08:34:30 -050034 Pointer<Byte> constants;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040035
Nicolas Capens4f172c72016-01-13 08:34:30 -050036 Float4 Dz[4];
37 Float4 Dw;
Nicolas Capens3b4c93f2016-05-18 12:51:37 -040038 Float4 Dv[MAX_FRAGMENT_INPUTS][4];
Nicolas Capens4f172c72016-01-13 08:34:30 -050039 Float4 Df;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040040
Nicolas Capens4f172c72016-01-13 08:34:30 -050041 UInt occlusion;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040042
Sean Risser29364a02019-05-28 12:50:28 -040043 Int y;
44 Int yMin;
45 Int yMax;
46
Alexis Hetuf2a8c372015-07-13 11:08:41 -040047#if PERF_PROFILE
Nicolas Capens4f172c72016-01-13 08:34:30 -050048 Long cycles[PERF_TIMERS];
Alexis Hetuf2a8c372015-07-13 11:08:41 -040049#endif
Alexis Hetuf2a8c372015-07-13 11:08:41 -040050
Sean Risser29364a02019-05-28 12:50:28 -040051 virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x) = 0;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040052
53 bool interpolateZ() const;
54 bool interpolateW() const;
Nicolas Capens5ba372f2017-10-05 16:05:47 -040055 Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective, bool clamp);
Alexis Hetuf2a8c372015-07-13 11:08:41 -040056
Nicolas Capensba53fbf2016-01-14 13:43:42 -050057 const PixelProcessor::State &state;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040058 const PixelShader *const shader;
59
John Bauman66b8ab22014-05-06 15:57:45 -040060 private:
Sean Risser29364a02019-05-28 12:50:28 -040061 void rasterize();
John Bauman66b8ab22014-05-06 15:57:45 -040062 };
63}
64
65#endif // sw_QuadRasterizer_hpp