blob: f24e80e92493f665aa72a9ec12da9c46f8ccaa8a [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_QuadRasterizer_hpp
16#define sw_QuadRasterizer_hpp
17
18#include "Rasterizer.hpp"
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050019#include "Pipeline/ShaderCore.hpp"
Chris Forbes1845d5e2018-12-27 11:50:15 -080020#include "Pipeline/SpirvShader.hpp"
Nicolas Capens1d8c8db2018-11-05 16:30:42 -050021#include "System/Types.hpp"
Nicolas Capens68a82382018-10-02 13:16:55 -040022
Nicolas Capens157ba262019-12-10 17:49:14 -050023namespace sw {
24
25class QuadRasterizer : public Rasterizer
Nicolas Capens68a82382018-10-02 13:16:55 -040026{
Nicolas Capens157ba262019-12-10 17:49:14 -050027public:
28 QuadRasterizer(const PixelProcessor::State &state, SpirvShader const *spirvShader);
29 virtual ~QuadRasterizer();
Nicolas Capens68a82382018-10-02 13:16:55 -040030
Nicolas Capens157ba262019-12-10 17:49:14 -050031 void generate();
Nicolas Capens68a82382018-10-02 13:16:55 -040032
Nicolas Capens157ba262019-12-10 17:49:14 -050033protected:
34 Pointer<Byte> constants;
Nicolas Capens68a82382018-10-02 13:16:55 -040035
Nicolas Capens157ba262019-12-10 17:49:14 -050036 Float4 Dz[4];
37 Float4 Dw;
38 Float4 Dv[MAX_INTERFACE_COMPONENTS];
39 Float4 Df;
40 Float4 DclipDistance[MAX_CLIP_DISTANCES];
41 Float4 DcullDistance[MAX_CULL_DISTANCES];
Nicolas Capens68a82382018-10-02 13:16:55 -040042
Nicolas Capens157ba262019-12-10 17:49:14 -050043 UInt occlusion;
Nicolas Capens68a82382018-10-02 13:16:55 -040044
Nicolas Capens157ba262019-12-10 17:49:14 -050045 virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0;
Nicolas Capens68a82382018-10-02 13:16:55 -040046
Nicolas Capens157ba262019-12-10 17:49:14 -050047 bool interpolateZ() const;
48 bool interpolateW() const;
49 Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective, bool clamp);
Nicolas Capens68a82382018-10-02 13:16:55 -040050
Nicolas Capens157ba262019-12-10 17:49:14 -050051 const PixelProcessor::State &state;
52 const SpirvShader *const spirvShader;
Nicolas Capens68a82382018-10-02 13:16:55 -040053
Nicolas Capens157ba262019-12-10 17:49:14 -050054private:
55 void rasterize(Int &yMin, Int &yMax);
56};
57
58} // namespace sw
Nicolas Capens68a82382018-10-02 13:16:55 -040059
Ben Claytonfccfc562019-12-17 20:37:31 +000060#endif // sw_QuadRasterizer_hpp