Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -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 | 8940182 | 2014-05-06 15:04:28 -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 | 8940182 | 2014-05-06 15:04:28 -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 | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 14 | |
| 15 | #include "QuadRasterizer.hpp" |
| 16 | |
| 17 | #include "Math.hpp" |
| 18 | #include "Primitive.hpp" |
| 19 | #include "Renderer.hpp" |
| 20 | #include "Constants.hpp" |
| 21 | #include "Debug.hpp" |
| 22 | |
| 23 | namespace sw |
| 24 | { |
| 25 | extern bool veryEarlyDepthTest; |
| 26 | extern bool complementaryDepthBuffer; |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 27 | extern bool fullPixelPositionRegister; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 28 | |
| 29 | extern int clusterCount; |
| 30 | |
Nicolas Capens | ba53fbf | 2016-01-14 13:43:42 -0500 | [diff] [blame] | 31 | QuadRasterizer::QuadRasterizer(const PixelProcessor::State &state, const PixelShader *pixelShader) : state(state), shader(pixelShader) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 32 | { |
| 33 | } |
| 34 | |
| 35 | QuadRasterizer::~QuadRasterizer() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void QuadRasterizer::generate() |
| 40 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 41 | #if PERF_PROFILE |
| 42 | for(int i = 0; i < PERF_TIMERS; i++) |
| 43 | { |
| 44 | cycles[i] = 0; |
| 45 | } |
| 46 | |
| 47 | Long pixelTime = Ticks(); |
| 48 | #endif |
| 49 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 50 | constants = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,constants)); |
| 51 | occlusion = 0; |
| 52 | |
| 53 | Do |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 54 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 55 | Int yMin = *Pointer<Int>(primitive + OFFSET(Primitive,yMin)); |
| 56 | Int yMax = *Pointer<Int>(primitive + OFFSET(Primitive,yMax)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 57 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 58 | Int cluster2 = cluster + cluster; |
| 59 | yMin += clusterCount * 2 - 2 - cluster2; |
| 60 | yMin &= -clusterCount * 2; |
| 61 | yMin += cluster2; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 62 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 63 | If(yMin < yMax) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 64 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 65 | rasterize(yMin, yMax); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 66 | } |
| 67 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 68 | primitive += sizeof(Primitive) * state.multiSample; |
| 69 | count--; |
| 70 | } |
| 71 | Until(count == 0) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 72 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 73 | if(state.occlusionEnabled) |
| 74 | { |
| 75 | UInt clusterOcclusion = *Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster); |
| 76 | clusterOcclusion += occlusion; |
| 77 | *Pointer<UInt>(data + OFFSET(DrawData,occlusion) + 4 * cluster) = clusterOcclusion; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 78 | } |
| 79 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 80 | #if PERF_PROFILE |
| 81 | cycles[PERF_PIXEL] = Ticks() - pixelTime; |
| 82 | |
| 83 | for(int i = 0; i < PERF_TIMERS; i++) |
| 84 | { |
| 85 | *Pointer<Long>(data + OFFSET(DrawData,cycles[i]) + 8 * cluster) += cycles[i]; |
| 86 | } |
| 87 | #endif |
| 88 | |
| 89 | Return(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 90 | } |
| 91 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 92 | void QuadRasterizer::rasterize(Int &yMin, Int &yMax) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 93 | { |
Alexis Hetu | 1edcd8b | 2015-11-05 11:12:41 -0500 | [diff] [blame] | 94 | Pointer<Byte> cBuffer[RENDERTARGETS]; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 95 | Pointer<Byte> zBuffer; |
| 96 | Pointer<Byte> sBuffer; |
| 97 | |
Alexis Hetu | 1edcd8b | 2015-11-05 11:12:41 -0500 | [diff] [blame] | 98 | for(int index = 0; index < RENDERTARGETS; index++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 99 | { |
| 100 | if(state.colorWriteActive(index)) |
| 101 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 102 | cBuffer[index] = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,colorBuffer[index])) + yMin * *Pointer<Int>(data + OFFSET(DrawData,colorPitchB[index])); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 103 | } |
| 104 | } |
| 105 | |
| 106 | if(state.depthTestActive) |
| 107 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 108 | zBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,depthBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData,depthPitchB)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 109 | } |
| 110 | |
| 111 | if(state.stencilActive) |
| 112 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 113 | sBuffer = *Pointer<Pointer<Byte>>(data + OFFSET(DrawData,stencilBuffer)) + yMin * *Pointer<Int>(data + OFFSET(DrawData,stencilPitchB)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | Int y = yMin; |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 117 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 118 | Do |
| 119 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 120 | Int x0a = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span))); |
| 121 | Int x0b = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span))); |
Nicolas Capens | c50d35d | 2015-01-27 01:52:41 -0500 | [diff] [blame] | 122 | Int x0 = Min(x0a, x0b); |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 123 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 124 | for(unsigned int q = 1; q < state.multiSample; q++) |
| 125 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 126 | x0a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 0) * sizeof(Primitive::Span))); |
| 127 | x0b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->left) + (y + 1) * sizeof(Primitive::Span))); |
Nicolas Capens | c50d35d | 2015-01-27 01:52:41 -0500 | [diff] [blame] | 128 | x0 = Min(x0, Min(x0a, x0b)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 129 | } |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 130 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 131 | x0 &= 0xFFFFFFFE; |
| 132 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 133 | Int x1a = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span))); |
| 134 | Int x1b = Int(*Pointer<Short>(primitive + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span))); |
Nicolas Capens | c50d35d | 2015-01-27 01:52:41 -0500 | [diff] [blame] | 135 | Int x1 = Max(x1a, x1b); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 136 | |
| 137 | for(unsigned int q = 1; q < state.multiSample; q++) |
| 138 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 139 | x1a = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 0) * sizeof(Primitive::Span))); |
| 140 | x1b = Int(*Pointer<Short>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline->right) + (y + 1) * sizeof(Primitive::Span))); |
Nicolas Capens | c50d35d | 2015-01-27 01:52:41 -0500 | [diff] [blame] | 141 | x1 = Max(x1, Max(x1a, x1b)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 142 | } |
| 143 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 144 | Float4 yyyy = Float4(Float(y)) + *Pointer<Float4>(primitive + OFFSET(Primitive,yQuad), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 145 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 146 | if(interpolateZ()) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 147 | { |
| 148 | for(unsigned int q = 0; q < state.multiSample; q++) |
| 149 | { |
| 150 | Float4 y = yyyy; |
| 151 | |
| 152 | if(state.multiSample > 1) |
| 153 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 154 | y -= *Pointer<Float4>(constants + OFFSET(Constants,Y) + q * sizeof(float4)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 155 | } |
| 156 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 157 | Dz[q] = *Pointer<Float4>(primitive + OFFSET(Primitive,z.C), 16) + y * *Pointer<Float4>(primitive + OFFSET(Primitive,z.B), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 158 | } |
| 159 | } |
| 160 | |
| 161 | if(veryEarlyDepthTest && state.multiSample == 1) |
| 162 | { |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 163 | if(!state.stencilActive && state.depthTestActive && (state.depthCompareMode == DEPTH_LESSEQUAL || state.depthCompareMode == DEPTH_LESS)) // FIXME: Both modes ok? |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 164 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 165 | Float4 xxxx = Float4(Float(x0)) + *Pointer<Float4>(primitive + OFFSET(Primitive,xQuad), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 166 | |
| 167 | Pointer<Byte> buffer; |
| 168 | Int pitch; |
| 169 | |
| 170 | if(!state.quadLayoutDepthBuffer) |
| 171 | { |
| 172 | buffer = zBuffer + 4 * x0; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 173 | pitch = *Pointer<Int>(data + OFFSET(DrawData,depthPitchB)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 174 | } |
| 175 | else |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 176 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 177 | buffer = zBuffer + 8 * x0; |
| 178 | } |
| 179 | |
| 180 | For(Int x = x0, x < x1, x += 2) |
| 181 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 182 | Float4 z = interpolate(xxxx, Dz[0], z, primitive + OFFSET(Primitive,z), false, false); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 183 | |
| 184 | Float4 zValue; |
Nicolas Capens | 81f1830 | 2016-01-14 09:32:35 -0500 | [diff] [blame] | 185 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 186 | if(!state.quadLayoutDepthBuffer) |
| 187 | { |
| 188 | // FIXME: Properly optimizes? |
| 189 | zValue.xy = *Pointer<Float4>(buffer); |
| 190 | zValue.zw = *Pointer<Float4>(buffer + pitch - 8); |
| 191 | } |
| 192 | else |
| 193 | { |
| 194 | zValue = *Pointer<Float4>(buffer, 16); |
| 195 | } |
| 196 | |
| 197 | Int4 zTest; |
| 198 | |
| 199 | if(complementaryDepthBuffer) |
| 200 | { |
| 201 | zTest = CmpLE(zValue, z); |
| 202 | } |
| 203 | else |
| 204 | { |
| 205 | zTest = CmpNLT(zValue, z); |
| 206 | } |
| 207 | |
| 208 | Int zMask = SignMask(zTest); |
| 209 | |
| 210 | If(zMask == 0) |
| 211 | { |
| 212 | x0 += 2; |
| 213 | } |
| 214 | Else |
| 215 | { |
| 216 | x = x1; |
| 217 | } |
| 218 | |
| 219 | xxxx += Float4(2); |
| 220 | |
| 221 | if(!state.quadLayoutDepthBuffer) |
| 222 | { |
| 223 | buffer += 8; |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | buffer += 16; |
| 228 | } |
| 229 | } |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | If(x0 < x1) |
| 234 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 235 | if(interpolateW()) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 236 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 237 | Dw = *Pointer<Float4>(primitive + OFFSET(Primitive,w.C), 16) + yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,w.B), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 238 | } |
| 239 | |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 240 | for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 241 | { |
Nicolas Capens | 66be245 | 2015-01-27 14:58:57 -0500 | [diff] [blame] | 242 | for(int component = 0; component < 4; component++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 243 | { |
| 244 | if(state.interpolant[interpolant].component & (1 << component)) |
| 245 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 246 | Dv[interpolant][component] = *Pointer<Float4>(primitive + OFFSET(Primitive,V[interpolant][component].C), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 247 | |
| 248 | if(!(state.interpolant[interpolant].flat & (1 << component))) |
| 249 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 250 | Dv[interpolant][component] += yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,V[interpolant][component].B), 16); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 251 | } |
| 252 | } |
| 253 | } |
| 254 | } |
| 255 | |
Nicolas Capens | 66be245 | 2015-01-27 14:58:57 -0500 | [diff] [blame] | 256 | if(state.fog.component) |
| 257 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 258 | Df = *Pointer<Float4>(primitive + OFFSET(Primitive,f.C), 16); |
Nicolas Capens | 66be245 | 2015-01-27 14:58:57 -0500 | [diff] [blame] | 259 | |
| 260 | if(!state.fog.flat) |
| 261 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 262 | Df += yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,f.B), 16); |
Nicolas Capens | 66be245 | 2015-01-27 14:58:57 -0500 | [diff] [blame] | 263 | } |
| 264 | } |
| 265 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 266 | Short4 xLeft[4]; |
| 267 | Short4 xRight[4]; |
| 268 | |
| 269 | for(unsigned int q = 0; q < state.multiSample; q++) |
| 270 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 271 | xLeft[q] = *Pointer<Short4>(primitive + q * sizeof(Primitive) + OFFSET(Primitive,outline) + y * sizeof(Primitive::Span)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 272 | xRight[q] = xLeft[q]; |
| 273 | |
| 274 | xLeft[q] = Swizzle(xLeft[q], 0xA0) - Short4(1, 2, 1, 2); |
| 275 | xRight[q] = Swizzle(xRight[q], 0xF5) - Short4(0, 1, 0, 1); |
| 276 | } |
| 277 | |
| 278 | For(Int x = x0, x < x1, x += 2) |
| 279 | { |
| 280 | Short4 xxxx = Short4(x); |
| 281 | Int cMask[4]; |
| 282 | |
| 283 | for(unsigned int q = 0; q < state.multiSample; q++) |
| 284 | { |
| 285 | Short4 mask = CmpGT(xxxx, xLeft[q]) & CmpGT(xRight[q], xxxx); |
| 286 | cMask[q] = SignMask(Pack(mask, mask)) & 0x0000000F; |
| 287 | } |
| 288 | |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 289 | quad(cBuffer, zBuffer, sBuffer, cMask, x, y); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 290 | } |
| 291 | } |
| 292 | |
Alexis Hetu | 1edcd8b | 2015-11-05 11:12:41 -0500 | [diff] [blame] | 293 | for(int index = 0; index < RENDERTARGETS; index++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 294 | { |
| 295 | if(state.colorWriteActive(index)) |
| 296 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 297 | cBuffer[index] += *Pointer<Int>(data + OFFSET(DrawData,colorPitchB[index])) << (1 + sw::log2(clusterCount)); // FIXME: Precompute |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 298 | } |
| 299 | } |
| 300 | |
| 301 | if(state.depthTestActive) |
| 302 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 303 | zBuffer += *Pointer<Int>(data + OFFSET(DrawData,depthPitchB)) << (1 + sw::log2(clusterCount)); // FIXME: Precompute |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | if(state.stencilActive) |
| 307 | { |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 308 | sBuffer += *Pointer<Int>(data + OFFSET(DrawData,stencilPitchB)) << (1 + sw::log2(clusterCount)); // FIXME: Precompute |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | y += 2 * clusterCount; |
| 312 | } |
| 313 | Until(y >= yMax) |
| 314 | } |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 315 | |
| 316 | Float4 QuadRasterizer::interpolate(Float4 &x, Float4 &D, Float4 &rhw, Pointer<Byte> planeEquation, bool flat, bool perspective) |
| 317 | { |
| 318 | Float4 interpolant = D; |
| 319 | |
| 320 | if(!flat) |
| 321 | { |
| 322 | interpolant += x * *Pointer<Float4>(planeEquation + OFFSET(PlaneEquation, A), 16); |
| 323 | |
| 324 | if(perspective) |
| 325 | { |
| 326 | interpolant *= rhw; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | return interpolant; |
| 331 | } |
| 332 | |
| 333 | bool QuadRasterizer::interpolateZ() const |
| 334 | { |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 335 | return state.depthTestActive || state.pixelFogActive() || (shader && shader->isVPosDeclared() && fullPixelPositionRegister); |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 336 | } |
| 337 | |
| 338 | bool QuadRasterizer::interpolateW() const |
| 339 | { |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 340 | return state.perspective || (shader && shader->isVPosDeclared() && fullPixelPositionRegister); |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 341 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 342 | } |