Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 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. |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 14 | |
| 15 | #ifndef sw_QuadRasterizer_hpp |
| 16 | #define sw_QuadRasterizer_hpp |
| 17 | |
| 18 | #include "Rasterizer.hpp" |
Nicolas Capens | 708c24b | 2017-10-26 13:07:10 -0400 | [diff] [blame^] | 19 | #include "Shader/ShaderCore.hpp" |
| 20 | #include "Shader/PixelShader.hpp" |
| 21 | #include "Common/Types.hpp" |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 22 | |
| 23 | namespace sw |
| 24 | { |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 25 | class QuadRasterizer : public Rasterizer |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 26 | { |
Nicolas Capens | ba53fbf | 2016-01-14 13:43:42 -0500 | [diff] [blame] | 27 | public: |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 28 | QuadRasterizer(const PixelProcessor::State &state, const PixelShader *shader); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 29 | virtual ~QuadRasterizer(); |
| 30 | |
Nicolas Capens | ba53fbf | 2016-01-14 13:43:42 -0500 | [diff] [blame] | 31 | void generate(); |
| 32 | |
| 33 | protected: |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 34 | Pointer<Byte> constants; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 35 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 36 | Float4 Dz[4]; |
| 37 | Float4 Dw; |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 38 | Float4 Dv[MAX_FRAGMENT_INPUTS][4]; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 39 | Float4 Df; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 40 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 41 | UInt occlusion; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 42 | |
| 43 | #if PERF_PROFILE |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 44 | Long cycles[PERF_TIMERS]; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 45 | #endif |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 46 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 47 | virtual void quad(Pointer<Byte> cBuffer[4], Pointer<Byte> &zBuffer, Pointer<Byte> &sBuffer, Int cMask[4], Int &x, Int &y) = 0; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 48 | |
| 49 | bool interpolateZ() const; |
| 50 | bool interpolateW() const; |
Nicolas Capens | 5ba372f | 2017-10-05 16:05:47 -0400 | [diff] [blame] | 51 | Float4 interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective, bool clamp); |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 52 | |
Nicolas Capens | ba53fbf | 2016-01-14 13:43:42 -0500 | [diff] [blame] | 53 | const PixelProcessor::State &state; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 54 | const PixelShader *const shader; |
| 55 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 56 | private: |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 57 | void rasterize(Int &yMin, Int &yMax); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 58 | }; |
| 59 | } |
| 60 | |
| 61 | #endif // sw_QuadRasterizer_hpp |