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 "PixelProcessor.hpp" |
| 16 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 17 | #include "Surface.hpp" |
| 18 | #include "Primitive.hpp" |
Nicolas Capens | 708c24b | 2017-10-26 13:07:10 -0400 | [diff] [blame] | 19 | #include "Shader/PixelPipeline.hpp" |
| 20 | #include "Shader/PixelProgram.hpp" |
| 21 | #include "Shader/PixelShader.hpp" |
| 22 | #include "Shader/Constants.hpp" |
| 23 | #include "Common/Debug.hpp" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 24 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 25 | #include <string.h> |
| 26 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 27 | namespace sw |
| 28 | { |
| 29 | extern bool complementaryDepthBuffer; |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 30 | extern TransparencyAntialiasing transparencyAntialiasing; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 31 | extern bool perspectiveCorrection; |
| 32 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 33 | bool precachePixel = false; |
| 34 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 35 | unsigned int PixelProcessor::States::computeHash() |
| 36 | { |
| 37 | unsigned int *state = (unsigned int*)this; |
| 38 | unsigned int hash = 0; |
| 39 | |
Nicolas Capens | 5d96188 | 2016-01-01 23:18:14 -0500 | [diff] [blame] | 40 | for(unsigned int i = 0; i < sizeof(States) / 4; i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 41 | { |
| 42 | hash ^= state[i]; |
| 43 | } |
| 44 | |
| 45 | return hash; |
| 46 | } |
| 47 | |
| 48 | PixelProcessor::State::State() |
| 49 | { |
| 50 | memset(this, 0, sizeof(State)); |
| 51 | } |
| 52 | |
| 53 | bool PixelProcessor::State::operator==(const State &state) const |
| 54 | { |
| 55 | if(hash != state.hash) |
| 56 | { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | return memcmp(static_cast<const States*>(this), static_cast<const States*>(&state), sizeof(States)) == 0; |
| 61 | } |
| 62 | |
Alexis Hetu | c6a57cb | 2016-04-07 10:48:31 -0400 | [diff] [blame] | 63 | PixelProcessor::UniformBufferInfo::UniformBufferInfo() |
| 64 | { |
| 65 | buffer = nullptr; |
| 66 | offset = 0; |
| 67 | } |
| 68 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 69 | PixelProcessor::PixelProcessor(Context *context) : context(context) |
| 70 | { |
| 71 | setGlobalMipmapBias(0.0f); // Round to highest LOD [0.5, 1.0]: -0.5 |
| 72 | // Round to nearest LOD [0.7, 1.4]: 0.0 |
| 73 | // Round to lowest LOD [1.0, 2.0]: 0.5 |
| 74 | |
| 75 | routineCache = 0; |
| 76 | setRoutineCacheSize(1024); |
| 77 | } |
| 78 | |
| 79 | PixelProcessor::~PixelProcessor() |
| 80 | { |
| 81 | delete routineCache; |
| 82 | routineCache = 0; |
| 83 | } |
| 84 | |
| 85 | void PixelProcessor::setFloatConstant(unsigned int index, const float value[4]) |
| 86 | { |
Alexis Hetu | 04c967a | 2015-07-08 15:56:17 -0400 | [diff] [blame] | 87 | if(index < FRAGMENT_UNIFORM_VECTORS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 88 | { |
| 89 | c[index][0] = value[0]; |
| 90 | c[index][1] = value[1]; |
| 91 | c[index][2] = value[2]; |
| 92 | c[index][3] = value[3]; |
| 93 | } |
| 94 | else ASSERT(false); |
| 95 | |
| 96 | if(index < 8) // ps_1_x constants |
| 97 | { |
Nicolas Capens | d55d997 | 2018-10-18 13:47:29 -0400 | [diff] [blame] | 98 | // TODO: Compact into generic function |
| 99 | short x = iround(4095 * clamp_s(value[0], -1.0f, 1.0f)); |
| 100 | short y = iround(4095 * clamp_s(value[1], -1.0f, 1.0f)); |
| 101 | short z = iround(4095 * clamp_s(value[2], -1.0f, 1.0f)); |
| 102 | short w = iround(4095 * clamp_s(value[3], -1.0f, 1.0f)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 103 | |
| 104 | cW[index][0][0] = x; |
| 105 | cW[index][0][1] = x; |
| 106 | cW[index][0][2] = x; |
| 107 | cW[index][0][3] = x; |
| 108 | |
| 109 | cW[index][1][0] = y; |
| 110 | cW[index][1][1] = y; |
| 111 | cW[index][1][2] = y; |
| 112 | cW[index][1][3] = y; |
| 113 | |
| 114 | cW[index][2][0] = z; |
| 115 | cW[index][2][1] = z; |
| 116 | cW[index][2][2] = z; |
| 117 | cW[index][2][3] = z; |
| 118 | |
| 119 | cW[index][3][0] = w; |
| 120 | cW[index][3][1] = w; |
| 121 | cW[index][3][2] = w; |
| 122 | cW[index][3][3] = w; |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | void PixelProcessor::setIntegerConstant(unsigned int index, const int value[4]) |
| 127 | { |
| 128 | if(index < 16) |
| 129 | { |
| 130 | i[index][0] = value[0]; |
| 131 | i[index][1] = value[1]; |
| 132 | i[index][2] = value[2]; |
| 133 | i[index][3] = value[3]; |
| 134 | } |
| 135 | else ASSERT(false); |
| 136 | } |
| 137 | |
| 138 | void PixelProcessor::setBooleanConstant(unsigned int index, int boolean) |
| 139 | { |
| 140 | if(index < 16) |
| 141 | { |
| 142 | b[index] = boolean != 0; |
| 143 | } |
| 144 | else ASSERT(false); |
| 145 | } |
| 146 | |
Alexis Hetu | 2c2a7b2 | 2015-10-27 16:12:11 -0400 | [diff] [blame] | 147 | void PixelProcessor::setUniformBuffer(int index, sw::Resource* buffer, int offset) |
| 148 | { |
Alexis Hetu | c6a57cb | 2016-04-07 10:48:31 -0400 | [diff] [blame] | 149 | uniformBufferInfo[index].buffer = buffer; |
| 150 | uniformBufferInfo[index].offset = offset; |
Alexis Hetu | 2c2a7b2 | 2015-10-27 16:12:11 -0400 | [diff] [blame] | 151 | } |
| 152 | |
Alexis Hetu | c6a57cb | 2016-04-07 10:48:31 -0400 | [diff] [blame] | 153 | void PixelProcessor::lockUniformBuffers(byte** u, sw::Resource* uniformBuffers[]) |
Alexis Hetu | 2c2a7b2 | 2015-10-27 16:12:11 -0400 | [diff] [blame] | 154 | { |
| 155 | for(int i = 0; i < MAX_UNIFORM_BUFFER_BINDINGS; ++i) |
| 156 | { |
Alexis Hetu | c6a57cb | 2016-04-07 10:48:31 -0400 | [diff] [blame] | 157 | u[i] = uniformBufferInfo[i].buffer ? static_cast<byte*>(uniformBufferInfo[i].buffer->lock(PUBLIC, PRIVATE)) + uniformBufferInfo[i].offset : nullptr; |
| 158 | uniformBuffers[i] = uniformBufferInfo[i].buffer; |
Alexis Hetu | 2c2a7b2 | 2015-10-27 16:12:11 -0400 | [diff] [blame] | 159 | } |
| 160 | } |
| 161 | |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 162 | void PixelProcessor::setRenderTarget(int index, Surface *renderTarget, unsigned int layer) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 163 | { |
| 164 | context->renderTarget[index] = renderTarget; |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 165 | context->renderTargetLayer[index] = layer; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 166 | } |
| 167 | |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 168 | void PixelProcessor::setDepthBuffer(Surface *depthBuffer, unsigned int layer) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 169 | { |
Nicolas Capens | 3751c1e | 2016-03-21 14:14:14 -0400 | [diff] [blame] | 170 | context->depthBuffer = depthBuffer; |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 171 | context->depthBufferLayer = layer; |
Nicolas Capens | 3751c1e | 2016-03-21 14:14:14 -0400 | [diff] [blame] | 172 | } |
| 173 | |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 174 | void PixelProcessor::setStencilBuffer(Surface *stencilBuffer, unsigned int layer) |
Nicolas Capens | 3751c1e | 2016-03-21 14:14:14 -0400 | [diff] [blame] | 175 | { |
| 176 | context->stencilBuffer = stencilBuffer; |
Nicolas Capens | 8af24c5 | 2017-12-11 14:45:01 -0500 | [diff] [blame] | 177 | context->stencilBufferLayer = layer; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 178 | } |
| 179 | |
| 180 | void PixelProcessor::setTexCoordIndex(unsigned int stage, int texCoordIndex) |
| 181 | { |
| 182 | if(stage < 8) |
| 183 | { |
| 184 | context->textureStage[stage].setTexCoordIndex(texCoordIndex); |
| 185 | } |
| 186 | else ASSERT(false); |
| 187 | } |
| 188 | |
| 189 | void PixelProcessor::setStageOperation(unsigned int stage, TextureStage::StageOperation stageOperation) |
| 190 | { |
| 191 | if(stage < 8) |
| 192 | { |
| 193 | context->textureStage[stage].setStageOperation(stageOperation); |
| 194 | } |
| 195 | else ASSERT(false); |
| 196 | } |
| 197 | |
| 198 | void PixelProcessor::setFirstArgument(unsigned int stage, TextureStage::SourceArgument firstArgument) |
| 199 | { |
| 200 | if(stage < 8) |
| 201 | { |
| 202 | context->textureStage[stage].setFirstArgument(firstArgument); |
| 203 | } |
| 204 | else ASSERT(false); |
| 205 | } |
| 206 | |
| 207 | void PixelProcessor::setSecondArgument(unsigned int stage, TextureStage::SourceArgument secondArgument) |
| 208 | { |
| 209 | if(stage < 8) |
| 210 | { |
| 211 | context->textureStage[stage].setSecondArgument(secondArgument); |
| 212 | } |
| 213 | else ASSERT(false); |
| 214 | } |
| 215 | |
| 216 | void PixelProcessor::setThirdArgument(unsigned int stage, TextureStage::SourceArgument thirdArgument) |
| 217 | { |
| 218 | if(stage < 8) |
| 219 | { |
| 220 | context->textureStage[stage].setThirdArgument(thirdArgument); |
| 221 | } |
| 222 | else ASSERT(false); |
| 223 | } |
| 224 | |
| 225 | void PixelProcessor::setStageOperationAlpha(unsigned int stage, TextureStage::StageOperation stageOperationAlpha) |
| 226 | { |
| 227 | if(stage < 8) |
| 228 | { |
| 229 | context->textureStage[stage].setStageOperationAlpha(stageOperationAlpha); |
| 230 | } |
| 231 | else ASSERT(false); |
| 232 | } |
| 233 | |
| 234 | void PixelProcessor::setFirstArgumentAlpha(unsigned int stage, TextureStage::SourceArgument firstArgumentAlpha) |
| 235 | { |
| 236 | if(stage < 8) |
| 237 | { |
| 238 | context->textureStage[stage].setFirstArgumentAlpha(firstArgumentAlpha); |
| 239 | } |
| 240 | else ASSERT(false); |
| 241 | } |
| 242 | |
| 243 | void PixelProcessor::setSecondArgumentAlpha(unsigned int stage, TextureStage::SourceArgument secondArgumentAlpha) |
| 244 | { |
| 245 | if(stage < 8) |
| 246 | { |
| 247 | context->textureStage[stage].setSecondArgumentAlpha(secondArgumentAlpha); |
| 248 | } |
| 249 | else ASSERT(false); |
| 250 | } |
| 251 | |
| 252 | void PixelProcessor::setThirdArgumentAlpha(unsigned int stage, TextureStage::SourceArgument thirdArgumentAlpha) |
| 253 | { |
| 254 | if(stage < 8) |
| 255 | { |
| 256 | context->textureStage[stage].setThirdArgumentAlpha(thirdArgumentAlpha); |
| 257 | } |
| 258 | else ASSERT(false); |
| 259 | } |
| 260 | |
| 261 | void PixelProcessor::setFirstModifier(unsigned int stage, TextureStage::ArgumentModifier firstModifier) |
| 262 | { |
| 263 | if(stage < 8) |
| 264 | { |
| 265 | context->textureStage[stage].setFirstModifier(firstModifier); |
| 266 | } |
| 267 | else ASSERT(false); |
| 268 | } |
| 269 | |
| 270 | void PixelProcessor::setSecondModifier(unsigned int stage, TextureStage::ArgumentModifier secondModifier) |
| 271 | { |
| 272 | if(stage < 8) |
| 273 | { |
| 274 | context->textureStage[stage].setSecondModifier(secondModifier); |
| 275 | } |
| 276 | else ASSERT(false); |
| 277 | } |
| 278 | |
| 279 | void PixelProcessor::setThirdModifier(unsigned int stage, TextureStage::ArgumentModifier thirdModifier) |
| 280 | { |
| 281 | if(stage < 8) |
| 282 | { |
| 283 | context->textureStage[stage].setThirdModifier(thirdModifier); |
| 284 | } |
| 285 | else ASSERT(false); |
| 286 | } |
| 287 | |
| 288 | void PixelProcessor::setFirstModifierAlpha(unsigned int stage, TextureStage::ArgumentModifier firstModifierAlpha) |
| 289 | { |
| 290 | if(stage < 8) |
| 291 | { |
| 292 | context->textureStage[stage].setFirstModifierAlpha(firstModifierAlpha); |
| 293 | } |
| 294 | else ASSERT(false); |
| 295 | } |
| 296 | |
| 297 | void PixelProcessor::setSecondModifierAlpha(unsigned int stage, TextureStage::ArgumentModifier secondModifierAlpha) |
| 298 | { |
| 299 | if(stage < 8) |
| 300 | { |
| 301 | context->textureStage[stage].setSecondModifierAlpha(secondModifierAlpha); |
| 302 | } |
| 303 | else ASSERT(false); |
| 304 | } |
| 305 | |
| 306 | void PixelProcessor::setThirdModifierAlpha(unsigned int stage, TextureStage::ArgumentModifier thirdModifierAlpha) |
| 307 | { |
| 308 | if(stage < 8) |
| 309 | { |
| 310 | context->textureStage[stage].setThirdModifierAlpha(thirdModifierAlpha); |
| 311 | } |
| 312 | else ASSERT(false); |
| 313 | } |
| 314 | |
| 315 | void PixelProcessor::setDestinationArgument(unsigned int stage, TextureStage::DestinationArgument destinationArgument) |
| 316 | { |
| 317 | if(stage < 8) |
| 318 | { |
| 319 | context->textureStage[stage].setDestinationArgument(destinationArgument); |
| 320 | } |
| 321 | else ASSERT(false); |
| 322 | } |
| 323 | |
| 324 | void PixelProcessor::setConstantColor(unsigned int stage, const Color<float> &constantColor) |
| 325 | { |
| 326 | if(stage < 8) |
| 327 | { |
| 328 | context->textureStage[stage].setConstantColor(constantColor); |
| 329 | } |
| 330 | else ASSERT(false); |
| 331 | } |
| 332 | |
| 333 | void PixelProcessor::setBumpmapMatrix(unsigned int stage, int element, float value) |
| 334 | { |
| 335 | if(stage < 8) |
| 336 | { |
| 337 | context->textureStage[stage].setBumpmapMatrix(element, value); |
| 338 | } |
| 339 | else ASSERT(false); |
| 340 | } |
| 341 | |
| 342 | void PixelProcessor::setLuminanceScale(unsigned int stage, float value) |
| 343 | { |
| 344 | if(stage < 8) |
| 345 | { |
| 346 | context->textureStage[stage].setLuminanceScale(value); |
| 347 | } |
| 348 | else ASSERT(false); |
| 349 | } |
| 350 | |
| 351 | void PixelProcessor::setLuminanceOffset(unsigned int stage, float value) |
| 352 | { |
| 353 | if(stage < 8) |
| 354 | { |
| 355 | context->textureStage[stage].setLuminanceOffset(value); |
| 356 | } |
| 357 | else ASSERT(false); |
| 358 | } |
| 359 | |
| 360 | void PixelProcessor::setTextureFilter(unsigned int sampler, FilterType textureFilter) |
| 361 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 362 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 363 | { |
| 364 | context->sampler[sampler].setTextureFilter(textureFilter); |
| 365 | } |
| 366 | else ASSERT(false); |
| 367 | } |
| 368 | |
| 369 | void PixelProcessor::setMipmapFilter(unsigned int sampler, MipmapType mipmapFilter) |
| 370 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 371 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 372 | { |
| 373 | context->sampler[sampler].setMipmapFilter(mipmapFilter); |
| 374 | } |
| 375 | else ASSERT(false); |
| 376 | } |
| 377 | |
| 378 | void PixelProcessor::setGatherEnable(unsigned int sampler, bool enable) |
| 379 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 380 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 381 | { |
| 382 | context->sampler[sampler].setGatherEnable(enable); |
| 383 | } |
| 384 | else ASSERT(false); |
| 385 | } |
| 386 | |
| 387 | void PixelProcessor::setAddressingModeU(unsigned int sampler, AddressingMode addressMode) |
| 388 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 389 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 390 | { |
| 391 | context->sampler[sampler].setAddressingModeU(addressMode); |
| 392 | } |
| 393 | else ASSERT(false); |
| 394 | } |
| 395 | |
| 396 | void PixelProcessor::setAddressingModeV(unsigned int sampler, AddressingMode addressMode) |
| 397 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 398 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 399 | { |
| 400 | context->sampler[sampler].setAddressingModeV(addressMode); |
| 401 | } |
| 402 | else ASSERT(false); |
| 403 | } |
| 404 | |
| 405 | void PixelProcessor::setAddressingModeW(unsigned int sampler, AddressingMode addressMode) |
| 406 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 407 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 408 | { |
| 409 | context->sampler[sampler].setAddressingModeW(addressMode); |
| 410 | } |
| 411 | else ASSERT(false); |
| 412 | } |
| 413 | |
| 414 | void PixelProcessor::setReadSRGB(unsigned int sampler, bool sRGB) |
| 415 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 416 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 417 | { |
| 418 | context->sampler[sampler].setReadSRGB(sRGB); |
| 419 | } |
| 420 | else ASSERT(false); |
| 421 | } |
| 422 | |
| 423 | void PixelProcessor::setMipmapLOD(unsigned int sampler, float bias) |
| 424 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 425 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 426 | { |
| 427 | context->sampler[sampler].setMipmapLOD(bias); |
| 428 | } |
| 429 | else ASSERT(false); |
| 430 | } |
| 431 | |
| 432 | void PixelProcessor::setBorderColor(unsigned int sampler, const Color<float> &borderColor) |
| 433 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 434 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 435 | { |
| 436 | context->sampler[sampler].setBorderColor(borderColor); |
| 437 | } |
| 438 | else ASSERT(false); |
| 439 | } |
| 440 | |
Alexis Hetu | 617a5d5 | 2014-11-13 10:56:20 -0500 | [diff] [blame] | 441 | void PixelProcessor::setMaxAnisotropy(unsigned int sampler, float maxAnisotropy) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 442 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 443 | if(sampler < TEXTURE_IMAGE_UNITS) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 444 | { |
| 445 | context->sampler[sampler].setMaxAnisotropy(maxAnisotropy); |
| 446 | } |
| 447 | else ASSERT(false); |
| 448 | } |
| 449 | |
Alexis Hetu | 010a464 | 2017-07-18 14:33:04 -0400 | [diff] [blame] | 450 | void PixelProcessor::setHighPrecisionFiltering(unsigned int sampler, bool highPrecisionFiltering) |
| 451 | { |
| 452 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 453 | { |
| 454 | context->sampler[sampler].setHighPrecisionFiltering(highPrecisionFiltering); |
| 455 | } |
| 456 | else ASSERT(false); |
| 457 | } |
| 458 | |
Alexis Hetu | 1d01aa3 | 2015-09-29 11:50:05 -0400 | [diff] [blame] | 459 | void PixelProcessor::setSwizzleR(unsigned int sampler, SwizzleType swizzleR) |
| 460 | { |
| 461 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 462 | { |
| 463 | context->sampler[sampler].setSwizzleR(swizzleR); |
| 464 | } |
| 465 | else ASSERT(false); |
| 466 | } |
| 467 | |
| 468 | void PixelProcessor::setSwizzleG(unsigned int sampler, SwizzleType swizzleG) |
| 469 | { |
| 470 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 471 | { |
| 472 | context->sampler[sampler].setSwizzleG(swizzleG); |
| 473 | } |
| 474 | else ASSERT(false); |
| 475 | } |
| 476 | |
| 477 | void PixelProcessor::setSwizzleB(unsigned int sampler, SwizzleType swizzleB) |
| 478 | { |
| 479 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 480 | { |
| 481 | context->sampler[sampler].setSwizzleB(swizzleB); |
| 482 | } |
| 483 | else ASSERT(false); |
| 484 | } |
| 485 | |
| 486 | void PixelProcessor::setSwizzleA(unsigned int sampler, SwizzleType swizzleA) |
| 487 | { |
| 488 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 489 | { |
| 490 | context->sampler[sampler].setSwizzleA(swizzleA); |
| 491 | } |
| 492 | else ASSERT(false); |
| 493 | } |
| 494 | |
Nicolas Capens | f878d50 | 2017-11-06 15:29:46 -0500 | [diff] [blame] | 495 | void PixelProcessor::setCompareFunc(unsigned int sampler, CompareFunc compFunc) |
| 496 | { |
| 497 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 498 | { |
| 499 | context->sampler[sampler].setCompareFunc(compFunc); |
| 500 | } |
| 501 | else ASSERT(false); |
| 502 | } |
| 503 | |
Alexis Hetu | 95ac187 | 2016-06-06 13:26:52 -0400 | [diff] [blame] | 504 | void PixelProcessor::setBaseLevel(unsigned int sampler, int baseLevel) |
| 505 | { |
| 506 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 507 | { |
| 508 | context->sampler[sampler].setBaseLevel(baseLevel); |
| 509 | } |
| 510 | else ASSERT(false); |
| 511 | } |
| 512 | |
| 513 | void PixelProcessor::setMaxLevel(unsigned int sampler, int maxLevel) |
| 514 | { |
| 515 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 516 | { |
| 517 | context->sampler[sampler].setMaxLevel(maxLevel); |
| 518 | } |
| 519 | else ASSERT(false); |
| 520 | } |
| 521 | |
Alexis Hetu | 112d81f | 2016-06-07 12:36:35 -0400 | [diff] [blame] | 522 | void PixelProcessor::setMinLod(unsigned int sampler, float minLod) |
| 523 | { |
| 524 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 525 | { |
| 526 | context->sampler[sampler].setMinLod(minLod); |
| 527 | } |
| 528 | else ASSERT(false); |
| 529 | } |
| 530 | |
| 531 | void PixelProcessor::setMaxLod(unsigned int sampler, float maxLod) |
| 532 | { |
| 533 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 534 | { |
| 535 | context->sampler[sampler].setMaxLod(maxLod); |
| 536 | } |
| 537 | else ASSERT(false); |
| 538 | } |
| 539 | |
Alexis Hetu | 88482c3 | 2018-06-05 17:05:17 -0400 | [diff] [blame] | 540 | void PixelProcessor::setSyncRequired(unsigned int sampler, bool isSincRequired) |
| 541 | { |
| 542 | if(sampler < TEXTURE_IMAGE_UNITS) |
| 543 | { |
| 544 | context->sampler[sampler].setSyncRequired(isSincRequired); |
| 545 | } |
| 546 | else ASSERT(false); |
| 547 | } |
| 548 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 549 | void PixelProcessor::setWriteSRGB(bool sRGB) |
| 550 | { |
| 551 | context->setWriteSRGB(sRGB); |
| 552 | } |
| 553 | |
Maxime Grégoire | d976274 | 2015-07-08 16:43:48 -0400 | [diff] [blame] | 554 | void PixelProcessor::setColorLogicOpEnabled(bool colorLogicOpEnabled) |
| 555 | { |
| 556 | context->setColorLogicOpEnabled(colorLogicOpEnabled); |
| 557 | } |
| 558 | |
| 559 | void PixelProcessor::setLogicalOperation(LogicalOperation logicalOperation) |
| 560 | { |
| 561 | context->setLogicalOperation(logicalOperation); |
| 562 | } |
| 563 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 564 | void PixelProcessor::setDepthBufferEnable(bool depthBufferEnable) |
| 565 | { |
| 566 | context->setDepthBufferEnable(depthBufferEnable); |
| 567 | } |
| 568 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 569 | void PixelProcessor::setDepthCompare(DepthCompareMode depthCompareMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 570 | { |
| 571 | context->depthCompareMode = depthCompareMode; |
| 572 | } |
| 573 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 574 | void PixelProcessor::setAlphaCompare(AlphaCompareMode alphaCompareMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 575 | { |
| 576 | context->alphaCompareMode = alphaCompareMode; |
| 577 | } |
| 578 | |
| 579 | void PixelProcessor::setDepthWriteEnable(bool depthWriteEnable) |
| 580 | { |
| 581 | context->depthWriteEnable = depthWriteEnable; |
| 582 | } |
| 583 | |
| 584 | void PixelProcessor::setAlphaTestEnable(bool alphaTestEnable) |
| 585 | { |
| 586 | context->alphaTestEnable = alphaTestEnable; |
| 587 | } |
| 588 | |
Nicolas Capens | dd4c863 | 2018-07-31 15:33:28 -0400 | [diff] [blame] | 589 | void PixelProcessor::setCullMode(CullMode cullMode, bool frontFacingCCW) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 590 | { |
| 591 | context->cullMode = cullMode; |
Nicolas Capens | dd4c863 | 2018-07-31 15:33:28 -0400 | [diff] [blame] | 592 | context->frontFacingCCW = frontFacingCCW; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | void PixelProcessor::setColorWriteMask(int index, int rgbaMask) |
| 596 | { |
| 597 | context->setColorWriteMask(index, rgbaMask); |
| 598 | } |
| 599 | |
| 600 | void PixelProcessor::setStencilEnable(bool stencilEnable) |
| 601 | { |
| 602 | context->stencilEnable = stencilEnable; |
| 603 | } |
| 604 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 605 | void PixelProcessor::setStencilCompare(StencilCompareMode stencilCompareMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 606 | { |
| 607 | context->stencilCompareMode = stencilCompareMode; |
| 608 | } |
| 609 | |
| 610 | void PixelProcessor::setStencilReference(int stencilReference) |
| 611 | { |
| 612 | context->stencilReference = stencilReference; |
| 613 | stencil.set(stencilReference, context->stencilMask, context->stencilWriteMask); |
| 614 | } |
| 615 | |
| 616 | void PixelProcessor::setStencilReferenceCCW(int stencilReferenceCCW) |
| 617 | { |
| 618 | context->stencilReferenceCCW = stencilReferenceCCW; |
| 619 | stencilCCW.set(stencilReferenceCCW, context->stencilMaskCCW, context->stencilWriteMaskCCW); |
| 620 | } |
| 621 | |
| 622 | void PixelProcessor::setStencilMask(int stencilMask) |
| 623 | { |
| 624 | context->stencilMask = stencilMask; |
| 625 | stencil.set(context->stencilReference, stencilMask, context->stencilWriteMask); |
| 626 | } |
| 627 | |
| 628 | void PixelProcessor::setStencilMaskCCW(int stencilMaskCCW) |
| 629 | { |
| 630 | context->stencilMaskCCW = stencilMaskCCW; |
| 631 | stencilCCW.set(context->stencilReferenceCCW, stencilMaskCCW, context->stencilWriteMaskCCW); |
| 632 | } |
| 633 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 634 | void PixelProcessor::setStencilFailOperation(StencilOperation stencilFailOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 635 | { |
| 636 | context->stencilFailOperation = stencilFailOperation; |
| 637 | } |
| 638 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 639 | void PixelProcessor::setStencilPassOperation(StencilOperation stencilPassOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 640 | { |
| 641 | context->stencilPassOperation = stencilPassOperation; |
| 642 | } |
| 643 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 644 | void PixelProcessor::setStencilZFailOperation(StencilOperation stencilZFailOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 645 | { |
| 646 | context->stencilZFailOperation = stencilZFailOperation; |
| 647 | } |
| 648 | |
| 649 | void PixelProcessor::setStencilWriteMask(int stencilWriteMask) |
| 650 | { |
| 651 | context->stencilWriteMask = stencilWriteMask; |
| 652 | stencil.set(context->stencilReference, context->stencilMask, stencilWriteMask); |
| 653 | } |
| 654 | |
| 655 | void PixelProcessor::setStencilWriteMaskCCW(int stencilWriteMaskCCW) |
| 656 | { |
| 657 | context->stencilWriteMaskCCW = stencilWriteMaskCCW; |
| 658 | stencilCCW.set(context->stencilReferenceCCW, context->stencilMaskCCW, stencilWriteMaskCCW); |
| 659 | } |
| 660 | |
| 661 | void PixelProcessor::setTwoSidedStencil(bool enable) |
| 662 | { |
| 663 | context->twoSidedStencil = enable; |
| 664 | } |
| 665 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 666 | void PixelProcessor::setStencilCompareCCW(StencilCompareMode stencilCompareMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 667 | { |
| 668 | context->stencilCompareModeCCW = stencilCompareMode; |
| 669 | } |
| 670 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 671 | void PixelProcessor::setStencilFailOperationCCW(StencilOperation stencilFailOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 672 | { |
| 673 | context->stencilFailOperationCCW = stencilFailOperation; |
| 674 | } |
| 675 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 676 | void PixelProcessor::setStencilPassOperationCCW(StencilOperation stencilPassOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 677 | { |
| 678 | context->stencilPassOperationCCW = stencilPassOperation; |
| 679 | } |
| 680 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 681 | void PixelProcessor::setStencilZFailOperationCCW(StencilOperation stencilZFailOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 682 | { |
| 683 | context->stencilZFailOperationCCW = stencilZFailOperation; |
| 684 | } |
| 685 | |
| 686 | void PixelProcessor::setTextureFactor(const Color<float> &textureFactor) |
| 687 | { |
| 688 | // FIXME: Compact into generic function // FIXME: Clamp |
| 689 | short textureFactorR = iround(4095 * textureFactor.r); |
| 690 | short textureFactorG = iround(4095 * textureFactor.g); |
| 691 | short textureFactorB = iround(4095 * textureFactor.b); |
| 692 | short textureFactorA = iround(4095 * textureFactor.a); |
| 693 | |
| 694 | factor.textureFactor4[0][0] = textureFactorR; |
| 695 | factor.textureFactor4[0][1] = textureFactorR; |
| 696 | factor.textureFactor4[0][2] = textureFactorR; |
| 697 | factor.textureFactor4[0][3] = textureFactorR; |
| 698 | |
| 699 | factor.textureFactor4[1][0] = textureFactorG; |
| 700 | factor.textureFactor4[1][1] = textureFactorG; |
| 701 | factor.textureFactor4[1][2] = textureFactorG; |
| 702 | factor.textureFactor4[1][3] = textureFactorG; |
| 703 | |
| 704 | factor.textureFactor4[2][0] = textureFactorB; |
| 705 | factor.textureFactor4[2][1] = textureFactorB; |
| 706 | factor.textureFactor4[2][2] = textureFactorB; |
| 707 | factor.textureFactor4[2][3] = textureFactorB; |
| 708 | |
| 709 | factor.textureFactor4[3][0] = textureFactorA; |
| 710 | factor.textureFactor4[3][1] = textureFactorA; |
| 711 | factor.textureFactor4[3][2] = textureFactorA; |
| 712 | factor.textureFactor4[3][3] = textureFactorA; |
| 713 | } |
| 714 | |
| 715 | void PixelProcessor::setBlendConstant(const Color<float> &blendConstant) |
| 716 | { |
| 717 | // FIXME: Compact into generic function // FIXME: Clamp |
| 718 | short blendConstantR = iround(65535 * blendConstant.r); |
| 719 | short blendConstantG = iround(65535 * blendConstant.g); |
| 720 | short blendConstantB = iround(65535 * blendConstant.b); |
| 721 | short blendConstantA = iround(65535 * blendConstant.a); |
| 722 | |
| 723 | factor.blendConstant4W[0][0] = blendConstantR; |
| 724 | factor.blendConstant4W[0][1] = blendConstantR; |
| 725 | factor.blendConstant4W[0][2] = blendConstantR; |
| 726 | factor.blendConstant4W[0][3] = blendConstantR; |
| 727 | |
| 728 | factor.blendConstant4W[1][0] = blendConstantG; |
| 729 | factor.blendConstant4W[1][1] = blendConstantG; |
| 730 | factor.blendConstant4W[1][2] = blendConstantG; |
| 731 | factor.blendConstant4W[1][3] = blendConstantG; |
| 732 | |
| 733 | factor.blendConstant4W[2][0] = blendConstantB; |
| 734 | factor.blendConstant4W[2][1] = blendConstantB; |
| 735 | factor.blendConstant4W[2][2] = blendConstantB; |
| 736 | factor.blendConstant4W[2][3] = blendConstantB; |
| 737 | |
| 738 | factor.blendConstant4W[3][0] = blendConstantA; |
| 739 | factor.blendConstant4W[3][1] = blendConstantA; |
| 740 | factor.blendConstant4W[3][2] = blendConstantA; |
| 741 | factor.blendConstant4W[3][3] = blendConstantA; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 742 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 743 | // FIXME: Compact into generic function // FIXME: Clamp |
| 744 | short invBlendConstantR = iround(65535 * (1 - blendConstant.r)); |
| 745 | short invBlendConstantG = iround(65535 * (1 - blendConstant.g)); |
| 746 | short invBlendConstantB = iround(65535 * (1 - blendConstant.b)); |
| 747 | short invBlendConstantA = iround(65535 * (1 - blendConstant.a)); |
| 748 | |
| 749 | factor.invBlendConstant4W[0][0] = invBlendConstantR; |
| 750 | factor.invBlendConstant4W[0][1] = invBlendConstantR; |
| 751 | factor.invBlendConstant4W[0][2] = invBlendConstantR; |
| 752 | factor.invBlendConstant4W[0][3] = invBlendConstantR; |
| 753 | |
| 754 | factor.invBlendConstant4W[1][0] = invBlendConstantG; |
| 755 | factor.invBlendConstant4W[1][1] = invBlendConstantG; |
| 756 | factor.invBlendConstant4W[1][2] = invBlendConstantG; |
| 757 | factor.invBlendConstant4W[1][3] = invBlendConstantG; |
| 758 | |
| 759 | factor.invBlendConstant4W[2][0] = invBlendConstantB; |
| 760 | factor.invBlendConstant4W[2][1] = invBlendConstantB; |
| 761 | factor.invBlendConstant4W[2][2] = invBlendConstantB; |
| 762 | factor.invBlendConstant4W[2][3] = invBlendConstantB; |
| 763 | |
| 764 | factor.invBlendConstant4W[3][0] = invBlendConstantA; |
| 765 | factor.invBlendConstant4W[3][1] = invBlendConstantA; |
| 766 | factor.invBlendConstant4W[3][2] = invBlendConstantA; |
| 767 | factor.invBlendConstant4W[3][3] = invBlendConstantA; |
| 768 | |
| 769 | factor.blendConstant4F[0][0] = blendConstant.r; |
| 770 | factor.blendConstant4F[0][1] = blendConstant.r; |
| 771 | factor.blendConstant4F[0][2] = blendConstant.r; |
| 772 | factor.blendConstant4F[0][3] = blendConstant.r; |
| 773 | |
| 774 | factor.blendConstant4F[1][0] = blendConstant.g; |
| 775 | factor.blendConstant4F[1][1] = blendConstant.g; |
| 776 | factor.blendConstant4F[1][2] = blendConstant.g; |
| 777 | factor.blendConstant4F[1][3] = blendConstant.g; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 778 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 779 | factor.blendConstant4F[2][0] = blendConstant.b; |
| 780 | factor.blendConstant4F[2][1] = blendConstant.b; |
| 781 | factor.blendConstant4F[2][2] = blendConstant.b; |
| 782 | factor.blendConstant4F[2][3] = blendConstant.b; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 783 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 784 | factor.blendConstant4F[3][0] = blendConstant.a; |
| 785 | factor.blendConstant4F[3][1] = blendConstant.a; |
| 786 | factor.blendConstant4F[3][2] = blendConstant.a; |
| 787 | factor.blendConstant4F[3][3] = blendConstant.a; |
| 788 | |
| 789 | factor.invBlendConstant4F[0][0] = 1 - blendConstant.r; |
| 790 | factor.invBlendConstant4F[0][1] = 1 - blendConstant.r; |
| 791 | factor.invBlendConstant4F[0][2] = 1 - blendConstant.r; |
| 792 | factor.invBlendConstant4F[0][3] = 1 - blendConstant.r; |
| 793 | |
| 794 | factor.invBlendConstant4F[1][0] = 1 - blendConstant.g; |
| 795 | factor.invBlendConstant4F[1][1] = 1 - blendConstant.g; |
| 796 | factor.invBlendConstant4F[1][2] = 1 - blendConstant.g; |
| 797 | factor.invBlendConstant4F[1][3] = 1 - blendConstant.g; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 798 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 799 | factor.invBlendConstant4F[2][0] = 1 - blendConstant.b; |
| 800 | factor.invBlendConstant4F[2][1] = 1 - blendConstant.b; |
| 801 | factor.invBlendConstant4F[2][2] = 1 - blendConstant.b; |
| 802 | factor.invBlendConstant4F[2][3] = 1 - blendConstant.b; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 803 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 804 | factor.invBlendConstant4F[3][0] = 1 - blendConstant.a; |
| 805 | factor.invBlendConstant4F[3][1] = 1 - blendConstant.a; |
| 806 | factor.invBlendConstant4F[3][2] = 1 - blendConstant.a; |
| 807 | factor.invBlendConstant4F[3][3] = 1 - blendConstant.a; |
| 808 | } |
| 809 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 810 | void PixelProcessor::setFillMode(FillMode fillMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 811 | { |
| 812 | context->fillMode = fillMode; |
| 813 | } |
| 814 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 815 | void PixelProcessor::setShadingMode(ShadingMode shadingMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 816 | { |
| 817 | context->shadingMode = shadingMode; |
| 818 | } |
| 819 | |
| 820 | void PixelProcessor::setAlphaBlendEnable(bool alphaBlendEnable) |
| 821 | { |
| 822 | context->setAlphaBlendEnable(alphaBlendEnable); |
| 823 | } |
| 824 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 825 | void PixelProcessor::setSourceBlendFactor(BlendFactor sourceBlendFactor) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 826 | { |
| 827 | context->setSourceBlendFactor(sourceBlendFactor); |
| 828 | } |
| 829 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 830 | void PixelProcessor::setDestBlendFactor(BlendFactor destBlendFactor) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 831 | { |
| 832 | context->setDestBlendFactor(destBlendFactor); |
| 833 | } |
| 834 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 835 | void PixelProcessor::setBlendOperation(BlendOperation blendOperation) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 836 | { |
| 837 | context->setBlendOperation(blendOperation); |
| 838 | } |
| 839 | |
| 840 | void PixelProcessor::setSeparateAlphaBlendEnable(bool separateAlphaBlendEnable) |
| 841 | { |
| 842 | context->setSeparateAlphaBlendEnable(separateAlphaBlendEnable); |
| 843 | } |
| 844 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 845 | void PixelProcessor::setSourceBlendFactorAlpha(BlendFactor sourceBlendFactorAlpha) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 846 | { |
| 847 | context->setSourceBlendFactorAlpha(sourceBlendFactorAlpha); |
| 848 | } |
| 849 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 850 | void PixelProcessor::setDestBlendFactorAlpha(BlendFactor destBlendFactorAlpha) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 851 | { |
| 852 | context->setDestBlendFactorAlpha(destBlendFactorAlpha); |
| 853 | } |
| 854 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 855 | void PixelProcessor::setBlendOperationAlpha(BlendOperation blendOperationAlpha) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 856 | { |
| 857 | context->setBlendOperationAlpha(blendOperationAlpha); |
| 858 | } |
| 859 | |
Alexis Hetu | a818c45 | 2015-06-11 13:06:58 -0400 | [diff] [blame] | 860 | void PixelProcessor::setAlphaReference(float alphaReference) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 861 | { |
| 862 | context->alphaReference = alphaReference; |
| 863 | |
Alexis Hetu | a818c45 | 2015-06-11 13:06:58 -0400 | [diff] [blame] | 864 | factor.alphaReference4[0] = (word)iround(alphaReference * 0x1000 / 0xFF); |
| 865 | factor.alphaReference4[1] = (word)iround(alphaReference * 0x1000 / 0xFF); |
| 866 | factor.alphaReference4[2] = (word)iround(alphaReference * 0x1000 / 0xFF); |
| 867 | factor.alphaReference4[3] = (word)iround(alphaReference * 0x1000 / 0xFF); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 868 | } |
| 869 | |
| 870 | void PixelProcessor::setGlobalMipmapBias(float bias) |
| 871 | { |
| 872 | context->setGlobalMipmapBias(bias); |
| 873 | } |
| 874 | |
| 875 | void PixelProcessor::setFogStart(float start) |
| 876 | { |
| 877 | setFogRanges(start, context->fogEnd); |
| 878 | } |
| 879 | |
| 880 | void PixelProcessor::setFogEnd(float end) |
| 881 | { |
| 882 | setFogRanges(context->fogStart, end); |
| 883 | } |
| 884 | |
| 885 | void PixelProcessor::setFogColor(Color<float> fogColor) |
| 886 | { |
| 887 | // TODO: Compact into generic function |
| 888 | word fogR = (unsigned short)(65535 * fogColor.r); |
| 889 | word fogG = (unsigned short)(65535 * fogColor.g); |
| 890 | word fogB = (unsigned short)(65535 * fogColor.b); |
| 891 | |
| 892 | fog.color4[0][0] = fogR; |
| 893 | fog.color4[0][1] = fogR; |
| 894 | fog.color4[0][2] = fogR; |
| 895 | fog.color4[0][3] = fogR; |
| 896 | |
| 897 | fog.color4[1][0] = fogG; |
| 898 | fog.color4[1][1] = fogG; |
| 899 | fog.color4[1][2] = fogG; |
| 900 | fog.color4[1][3] = fogG; |
| 901 | |
| 902 | fog.color4[2][0] = fogB; |
| 903 | fog.color4[2][1] = fogB; |
| 904 | fog.color4[2][2] = fogB; |
| 905 | fog.color4[2][3] = fogB; |
| 906 | |
| 907 | fog.colorF[0] = replicate(fogColor.r); |
| 908 | fog.colorF[1] = replicate(fogColor.g); |
| 909 | fog.colorF[2] = replicate(fogColor.b); |
| 910 | } |
| 911 | |
| 912 | void PixelProcessor::setFogDensity(float fogDensity) |
| 913 | { |
| 914 | fog.densityE = replicate(-fogDensity * 1.442695f); // 1/e^x = 2^(-x*1.44) |
Nicolas Capens | a36f3f9 | 2015-08-04 15:34:26 -0400 | [diff] [blame] | 915 | fog.density2E = replicate(-fogDensity * fogDensity * 1.442695f); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 916 | } |
| 917 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 918 | void PixelProcessor::setPixelFogMode(FogMode fogMode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 919 | { |
| 920 | context->pixelFogMode = fogMode; |
| 921 | } |
| 922 | |
| 923 | void PixelProcessor::setPerspectiveCorrection(bool perspectiveEnable) |
| 924 | { |
| 925 | perspectiveCorrection = perspectiveEnable; |
| 926 | } |
| 927 | |
| 928 | void PixelProcessor::setOcclusionEnabled(bool enable) |
| 929 | { |
| 930 | context->occlusionEnabled = enable; |
| 931 | } |
| 932 | |
| 933 | void PixelProcessor::setRoutineCacheSize(int cacheSize) |
| 934 | { |
| 935 | delete routineCache; |
Alexis Hetu | f287834 | 2019-03-12 16:32:04 -0400 | [diff] [blame] | 936 | routineCache = new RoutineCache<State>(clamp(cacheSize, 1, 65536)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 937 | } |
| 938 | |
| 939 | void PixelProcessor::setFogRanges(float start, float end) |
| 940 | { |
| 941 | context->fogStart = start; |
| 942 | context->fogEnd = end; |
| 943 | |
| 944 | if(start == end) |
| 945 | { |
| 946 | end += 0.001f; // Hack: ensure there is a small range |
| 947 | } |
| 948 | |
| 949 | float fogScale = -1.0f / (end - start); |
| 950 | float fogOffset = end * -fogScale; |
| 951 | |
| 952 | fog.scale = replicate(fogScale); |
| 953 | fog.offset = replicate(fogOffset); |
| 954 | } |
| 955 | |
| 956 | const PixelProcessor::State PixelProcessor::update() const |
| 957 | { |
| 958 | State state; |
| 959 | |
| 960 | if(context->pixelShader) |
| 961 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 962 | state.shaderID = context->pixelShader->getSerialID(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 963 | } |
| 964 | else |
| 965 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 966 | state.shaderID = 0; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 967 | } |
| 968 | |
| 969 | state.depthOverride = context->pixelShader && context->pixelShader->depthOverride(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 970 | state.shaderContainsKill = context->pixelShader ? context->pixelShader->containsKill() : false; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 971 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 972 | if(context->alphaTestActive()) |
| 973 | { |
| 974 | state.alphaCompareMode = context->alphaCompareMode; |
| 975 | |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 976 | state.transparencyAntialiasing = context->getMultiSampleCount() > 1 ? transparencyAntialiasing : TRANSPARENCY_NONE; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 977 | } |
| 978 | |
| 979 | state.depthWriteEnable = context->depthWriteActive(); |
| 980 | |
| 981 | if(context->stencilActive()) |
| 982 | { |
| 983 | state.stencilActive = true; |
| 984 | state.stencilCompareMode = context->stencilCompareMode; |
| 985 | state.stencilFailOperation = context->stencilFailOperation; |
| 986 | state.stencilPassOperation = context->stencilPassOperation; |
| 987 | state.stencilZFailOperation = context->stencilZFailOperation; |
| 988 | state.noStencilMask = (context->stencilMask == 0xFF); |
| 989 | state.noStencilWriteMask = (context->stencilWriteMask == 0xFF); |
| 990 | state.stencilWriteMasked = (context->stencilWriteMask == 0x00); |
| 991 | |
| 992 | state.twoSidedStencil = context->twoSidedStencil; |
| 993 | state.stencilCompareModeCCW = context->twoSidedStencil ? context->stencilCompareModeCCW : state.stencilCompareMode; |
| 994 | state.stencilFailOperationCCW = context->twoSidedStencil ? context->stencilFailOperationCCW : state.stencilFailOperation; |
| 995 | state.stencilPassOperationCCW = context->twoSidedStencil ? context->stencilPassOperationCCW : state.stencilPassOperation; |
| 996 | state.stencilZFailOperationCCW = context->twoSidedStencil ? context->stencilZFailOperationCCW : state.stencilZFailOperation; |
| 997 | state.noStencilMaskCCW = context->twoSidedStencil ? (context->stencilMaskCCW == 0xFF) : state.noStencilMask; |
| 998 | state.noStencilWriteMaskCCW = context->twoSidedStencil ? (context->stencilWriteMaskCCW == 0xFF) : state.noStencilWriteMask; |
| 999 | state.stencilWriteMaskedCCW = context->twoSidedStencil ? (context->stencilWriteMaskCCW == 0x00) : state.stencilWriteMasked; |
| 1000 | } |
| 1001 | |
| 1002 | if(context->depthBufferActive()) |
| 1003 | { |
| 1004 | state.depthTestActive = true; |
| 1005 | state.depthCompareMode = context->depthCompareMode; |
Alexis Hetu | b9dda64 | 2016-10-06 11:25:32 -0400 | [diff] [blame] | 1006 | state.quadLayoutDepthBuffer = Surface::hasQuadLayout(context->depthBuffer->getInternalFormat()); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1007 | } |
| 1008 | |
| 1009 | state.occlusionEnabled = context->occlusionEnabled; |
| 1010 | |
| 1011 | state.fogActive = context->fogActive(); |
| 1012 | state.pixelFogMode = context->pixelFogActive(); |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 1013 | state.wBasedFog = context->wBasedFog && context->pixelFogActive() != FOG_NONE; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1014 | state.perspective = context->perspectiveActive(); |
Nicolas Capens | 3cbeac5 | 2017-09-15 11:49:31 -0400 | [diff] [blame] | 1015 | state.depthClamp = (context->depthBias != 0.0f) || (context->slopeDepthBias != 0.0f); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1016 | |
| 1017 | if(context->alphaBlendActive()) |
| 1018 | { |
| 1019 | state.alphaBlendActive = true; |
| 1020 | state.sourceBlendFactor = context->sourceBlendFactor(); |
| 1021 | state.destBlendFactor = context->destBlendFactor(); |
| 1022 | state.blendOperation = context->blendOperation(); |
| 1023 | state.sourceBlendFactorAlpha = context->sourceBlendFactorAlpha(); |
| 1024 | state.destBlendFactorAlpha = context->destBlendFactorAlpha(); |
| 1025 | state.blendOperationAlpha = context->blendOperationAlpha(); |
| 1026 | } |
Maxime Grégoire | d976274 | 2015-07-08 16:43:48 -0400 | [diff] [blame] | 1027 | |
| 1028 | state.logicalOperation = context->colorLogicOp(); |
| 1029 | |
Alexis Hetu | 1edcd8b | 2015-11-05 11:12:41 -0500 | [diff] [blame] | 1030 | for(int i = 0; i < RENDERTARGETS; i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1031 | { |
Nicolas Capens | c98186a | 2016-04-18 12:07:22 -0400 | [diff] [blame] | 1032 | state.colorWriteMask |= context->colorWriteActive(i) << (4 * i); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1033 | state.targetFormat[i] = context->renderTargetInternalFormat(i); |
| 1034 | } |
| 1035 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1036 | state.writeSRGB = context->writeSRGB && context->renderTarget[0] && Surface::isSRGBwritable(context->renderTarget[0]->getExternalFormat()); |
| 1037 | state.multiSample = context->getMultiSampleCount(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1038 | state.multiSampleMask = context->multiSampleMask; |
| 1039 | |
| 1040 | if(state.multiSample > 1 && context->pixelShader) |
| 1041 | { |
| 1042 | state.centroid = context->pixelShader->containsCentroid(); |
| 1043 | } |
| 1044 | |
Nicolas Capens | dd4c863 | 2018-07-31 15:33:28 -0400 | [diff] [blame] | 1045 | state.frontFaceCCW = context->frontFacingCCW; |
| 1046 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1047 | if(!context->pixelShader) |
| 1048 | { |
| 1049 | for(unsigned int i = 0; i < 8; i++) |
| 1050 | { |
| 1051 | state.textureStage[i] = context->textureStage[i].textureStageState(); |
| 1052 | } |
| 1053 | |
| 1054 | state.specularAdd = context->specularActive() && context->specularEnable; |
| 1055 | } |
| 1056 | |
| 1057 | for(unsigned int i = 0; i < 16; i++) |
| 1058 | { |
| 1059 | if(context->pixelShader) |
| 1060 | { |
| 1061 | if(context->pixelShader->usesSampler(i)) |
| 1062 | { |
| 1063 | state.sampler[i] = context->sampler[i].samplerState(); |
| 1064 | } |
| 1065 | } |
| 1066 | else |
| 1067 | { |
| 1068 | if(i < 8 && state.textureStage[i].stageOperation != TextureStage::STAGE_DISABLE) |
| 1069 | { |
| 1070 | state.sampler[i] = context->sampler[i].samplerState(); |
| 1071 | } |
| 1072 | else break; |
| 1073 | } |
| 1074 | } |
| 1075 | |
| 1076 | const bool point = context->isDrawPoint(true); |
| 1077 | const bool sprite = context->pointSpriteActive(); |
Nicolas Capens | a0f4be8 | 2014-10-22 14:35:30 -0400 | [diff] [blame] | 1078 | const bool flatShading = (context->shadingMode == SHADING_FLAT) || point; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1079 | |
Alexis Hetu | 53ad4af | 2017-12-06 14:49:07 -0500 | [diff] [blame] | 1080 | if(context->pixelShaderModel() < 0x0300) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1081 | { |
| 1082 | for(int coordinate = 0; coordinate < 8; coordinate++) |
| 1083 | { |
| 1084 | for(int component = 0; component < 4; component++) |
| 1085 | { |
| 1086 | if(context->textureActive(coordinate, component)) |
| 1087 | { |
| 1088 | state.texture[coordinate].component |= 1 << component; |
| 1089 | |
| 1090 | if(point && !sprite) |
| 1091 | { |
| 1092 | state.texture[coordinate].flat |= 1 << component; |
| 1093 | } |
| 1094 | } |
| 1095 | } |
| 1096 | |
Alexis Hetu | 53ad4af | 2017-12-06 14:49:07 -0500 | [diff] [blame] | 1097 | if(context->textureTransformProject[coordinate] && context->pixelShaderModel() <= 0x0103) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1098 | { |
| 1099 | if(context->textureTransformCount[coordinate] == 2) |
| 1100 | { |
| 1101 | state.texture[coordinate].project = 1; |
| 1102 | } |
| 1103 | else if(context->textureTransformCount[coordinate] == 3) |
| 1104 | { |
| 1105 | state.texture[coordinate].project = 2; |
| 1106 | } |
| 1107 | else if(context->textureTransformCount[coordinate] == 4 || context->textureTransformCount[coordinate] == 0) |
| 1108 | { |
| 1109 | state.texture[coordinate].project = 3; |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | for(int color = 0; color < 2; color++) |
| 1115 | { |
| 1116 | for(int component = 0; component < 4; component++) |
| 1117 | { |
| 1118 | if(context->colorActive(color, component)) |
| 1119 | { |
| 1120 | state.color[color].component |= 1 << component; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 1121 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1122 | if(point || flatShading) |
| 1123 | { |
| 1124 | state.color[color].flat |= 1 << component; |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if(context->fogActive()) |
| 1131 | { |
| 1132 | state.fog.component = true; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 1133 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1134 | if(point) |
| 1135 | { |
| 1136 | state.fog.flat = true; |
| 1137 | } |
| 1138 | } |
| 1139 | } |
| 1140 | else |
| 1141 | { |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 1142 | for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1143 | { |
| 1144 | for(int component = 0; component < 4; component++) |
| 1145 | { |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 1146 | const Shader::Semantic &semantic = context->pixelShader->getInput(interpolant, component); |
Alexis Hetu | 12b0050 | 2016-05-20 13:01:11 -0400 | [diff] [blame] | 1147 | |
| 1148 | if(semantic.active()) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1149 | { |
| 1150 | bool flat = point; |
| 1151 | |
Alexis Hetu | 12b0050 | 2016-05-20 13:01:11 -0400 | [diff] [blame] | 1152 | switch(semantic.usage) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1153 | { |
Alexis Hetu | 12b0050 | 2016-05-20 13:01:11 -0400 | [diff] [blame] | 1154 | case Shader::USAGE_TEXCOORD: flat = point && !sprite; break; |
| 1155 | case Shader::USAGE_COLOR: flat = semantic.flat || flatShading; break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1156 | } |
| 1157 | |
| 1158 | state.interpolant[interpolant].component |= 1 << component; |
| 1159 | |
| 1160 | if(flat) |
| 1161 | { |
| 1162 | state.interpolant[interpolant].flat |= 1 << component; |
| 1163 | } |
| 1164 | } |
| 1165 | } |
| 1166 | } |
| 1167 | } |
| 1168 | |
| 1169 | if(state.centroid) |
| 1170 | { |
Nicolas Capens | 3b4c93f | 2016-05-18 12:51:37 -0400 | [diff] [blame] | 1171 | for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1172 | { |
| 1173 | for(int component = 0; component < 4; component++) |
| 1174 | { |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 1175 | state.interpolant[interpolant].centroid = context->pixelShader->getInput(interpolant, 0).centroid; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1176 | } |
| 1177 | } |
| 1178 | } |
| 1179 | |
| 1180 | state.hash = state.computeHash(); |
| 1181 | |
| 1182 | return state; |
| 1183 | } |
| 1184 | |
| 1185 | Routine *PixelProcessor::routine(const State &state) |
| 1186 | { |
| 1187 | Routine *routine = routineCache->query(state); |
| 1188 | |
| 1189 | if(!routine) |
| 1190 | { |
Alexis Hetu | 53ad4af | 2017-12-06 14:49:07 -0500 | [diff] [blame] | 1191 | const bool integerPipeline = (context->pixelShaderModel() <= 0x0104); |
Nicolas Capens | ba53fbf | 2016-01-14 13:43:42 -0500 | [diff] [blame] | 1192 | QuadRasterizer *generator = nullptr; |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 1193 | |
Alexis Hetu | f2a8c37 | 2015-07-13 11:08:41 -0400 | [diff] [blame] | 1194 | if(integerPipeline) |
| 1195 | { |
| 1196 | generator = new PixelPipeline(state, context->pixelShader); |
| 1197 | } |
| 1198 | else |
| 1199 | { |
| 1200 | generator = new PixelProgram(state, context->pixelShader); |
| 1201 | } |
Nicolas Capens | 4f172c7 | 2016-01-13 08:34:30 -0500 | [diff] [blame] | 1202 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1203 | generator->generate(); |
Chris Forbes | 878d4b0 | 2019-01-21 10:48:35 -0800 | [diff] [blame] | 1204 | routine = (*generator)("PixelRoutine_%0.8X", state.shaderID); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1205 | delete generator; |
| 1206 | |
| 1207 | routineCache->add(state, routine); |
| 1208 | } |
| 1209 | |
| 1210 | return routine; |
| 1211 | } |
| 1212 | } |