blob: 1d7681d5479903933bf1937ffbc455ba80683087 [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
43#if PERF_PROFILE
Nicolas Capens4f172c72016-01-13 08:34:30 -050044 Long cycles[PERF_TIMERS];
Alexis Hetuf2a8c372015-07-13 11:08:41 -040045#endif
Alexis Hetuf2a8c372015-07-13 11:08:41 -040046
Nicolas Capens4f172c72016-01-13 08:34:30 -050047 virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040048
49 bool interpolateZ() const;
50 bool interpolateW() const;
Nicolas Capens5ba372f2017-10-05 16:05:47 -040051 Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective, bool clamp);
Alexis Hetuf2a8c372015-07-13 11:08:41 -040052
Nicolas Capensba53fbf2016-01-14 13:43:42 -050053 const PixelProcessor::State &state;
Alexis Hetuf2a8c372015-07-13 11:08:41 -040054 const PixelShader *const shader;
55
John Bauman66b8ab22014-05-06 15:57:45 -040056 private:
Nicolas Capens4f172c72016-01-13 08:34:30 -050057 void rasterize(Int &yMin, Int &yMax);
John Bauman66b8ab22014-05-06 15:57:45 -040058 };
59}
60
61#endif // sw_QuadRasterizer_hpp