John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1 | // SwiftShader Software Renderer |
| 2 | // |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 3 | // Copyright(c) 2005-2013 TransGaming Inc. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 4 | // |
| 5 | // All rights reserved. No part of this software may be copied, distributed, transmitted, |
| 6 | // transcribed, stored in a retrieval system, translated into any human or computer |
| 7 | // language by any means, or disclosed to third parties without the explicit written |
| 8 | // agreement of TransGaming Inc. Without such an agreement, no rights or licenses, express |
| 9 | // or implied, including but not limited to any patent rights, are granted to you. |
| 10 | // |
| 11 | |
| 12 | #include "PixelShader.hpp" |
| 13 | |
| 14 | #include "Debug.hpp" |
| 15 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 16 | #include <string.h> |
| 17 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 18 | namespace sw |
| 19 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 20 | PixelShader::PixelShader(const PixelShader *ps) : Shader() |
| 21 | { |
| 22 | version = 0x0300; |
| 23 | vPosDeclared = false; |
| 24 | vFaceDeclared = false; |
| 25 | centroid = false; |
| 26 | |
| 27 | if(ps) // Make a copy |
| 28 | { |
Alexis Hetu | 903e025 | 2014-11-25 14:25:32 -0500 | [diff] [blame] | 29 | for(size_t i = 0; i < ps->getLength(); i++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 30 | { |
| 31 | append(new sw::Shader::Instruction(*ps->getInstruction(i))); |
| 32 | } |
| 33 | |
| 34 | memcpy(semantic, ps->semantic, sizeof(semantic)); |
| 35 | vPosDeclared = ps->vPosDeclared; |
| 36 | vFaceDeclared = ps->vFaceDeclared; |
| 37 | usedSamplers = ps->usedSamplers; |
| 38 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 39 | optimize(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 40 | analyze(); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | PixelShader::PixelShader(const unsigned long *token) : Shader() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 45 | { |
| 46 | parse(token); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 47 | |
| 48 | vPosDeclared = false; |
| 49 | vFaceDeclared = false; |
| 50 | centroid = false; |
| 51 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 52 | optimize(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 53 | analyze(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | PixelShader::~PixelShader() |
| 57 | { |
| 58 | } |
| 59 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 60 | int PixelShader::validate(const unsigned long *const token) |
| 61 | { |
| 62 | if(!token) |
| 63 | { |
| 64 | return 0; |
| 65 | } |
| 66 | |
| 67 | unsigned short version = (unsigned short)(token[0] & 0x0000FFFF); |
| 68 | unsigned char minorVersion = (unsigned char)(token[0] & 0x000000FF); |
| 69 | unsigned char majorVersion = (unsigned char)((token[0] & 0x0000FF00) >> 8); |
| 70 | ShaderType shaderType = (ShaderType)((token[0] & 0xFFFF0000) >> 16); |
| 71 | |
| 72 | if(shaderType != SHADER_PIXEL || majorVersion > 3) |
| 73 | { |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | int instructionCount = 1; |
| 78 | |
| 79 | for(int i = 0; token[i] != 0x0000FFFF; i++) |
| 80 | { |
| 81 | if((token[i] & 0x0000FFFF) == 0x0000FFFE) // Comment token |
| 82 | { |
| 83 | int length = (token[i] & 0x7FFF0000) >> 16; |
| 84 | |
| 85 | i += length; |
| 86 | } |
| 87 | else |
| 88 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 89 | Shader::Opcode opcode = (Shader::Opcode)(token[i] & 0x0000FFFF); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 90 | |
| 91 | switch(opcode) |
| 92 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 93 | case Shader::OPCODE_RESERVED0: |
| 94 | case Shader::OPCODE_MOVA: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 95 | return 0; // Unsupported operation |
| 96 | default: |
| 97 | instructionCount++; |
| 98 | break; |
| 99 | } |
| 100 | |
| 101 | i += size(token[i], version); |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | return instructionCount; |
| 106 | } |
| 107 | |
| 108 | bool PixelShader::depthOverride() const |
| 109 | { |
| 110 | return zOverride; |
| 111 | } |
| 112 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 113 | bool PixelShader::containsKill() const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 114 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 115 | return kill; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | bool PixelShader::containsCentroid() const |
| 119 | { |
| 120 | return centroid; |
| 121 | } |
| 122 | |
| 123 | bool PixelShader::usesDiffuse(int component) const |
| 124 | { |
| 125 | return semantic[0][component].active(); |
| 126 | } |
| 127 | |
| 128 | bool PixelShader::usesSpecular(int component) const |
| 129 | { |
| 130 | return semantic[1][component].active(); |
| 131 | } |
| 132 | |
| 133 | bool PixelShader::usesTexture(int coordinate, int component) const |
| 134 | { |
| 135 | return semantic[2 + coordinate][component].active(); |
| 136 | } |
| 137 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 138 | void PixelShader::analyze() |
| 139 | { |
| 140 | analyzeZOverride(); |
| 141 | analyzeKill(); |
| 142 | analyzeInterpolants(); |
| 143 | analyzeDirtyConstants(); |
| 144 | analyzeDynamicBranching(); |
| 145 | analyzeSamplers(); |
| 146 | analyzeCallSites(); |
| 147 | analyzeDynamicIndexing(); |
| 148 | } |
| 149 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 150 | void PixelShader::analyzeZOverride() |
| 151 | { |
| 152 | zOverride = false; |
| 153 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 154 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 155 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 156 | if(instruction[i]->opcode == Shader::OPCODE_TEXM3X2DEPTH || |
| 157 | instruction[i]->opcode == Shader::OPCODE_TEXDEPTH || |
| 158 | instruction[i]->dst.type == Shader::PARAMETER_DEPTHOUT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 159 | { |
| 160 | zOverride = true; |
| 161 | |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 167 | void PixelShader::analyzeKill() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 168 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 169 | kill = false; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 170 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 171 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 172 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 173 | if(instruction[i]->opcode == Shader::OPCODE_TEXKILL || |
| 174 | instruction[i]->opcode == Shader::OPCODE_DISCARD) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 175 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 176 | kill = true; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 177 | |
| 178 | break; |
| 179 | } |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | void PixelShader::analyzeInterpolants() |
| 184 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 185 | if(version < 0x0300) |
| 186 | { |
| 187 | // Set default mapping; disable unused interpolants below |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 188 | semantic[0][0] = Semantic(Shader::USAGE_COLOR, 0); |
| 189 | semantic[0][1] = Semantic(Shader::USAGE_COLOR, 0); |
| 190 | semantic[0][2] = Semantic(Shader::USAGE_COLOR, 0); |
| 191 | semantic[0][3] = Semantic(Shader::USAGE_COLOR, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 192 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 193 | semantic[1][0] = Semantic(Shader::USAGE_COLOR, 1); |
| 194 | semantic[1][1] = Semantic(Shader::USAGE_COLOR, 1); |
| 195 | semantic[1][2] = Semantic(Shader::USAGE_COLOR, 1); |
| 196 | semantic[1][3] = Semantic(Shader::USAGE_COLOR, 1); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 197 | |
| 198 | for(int i = 0; i < 8; i++) |
| 199 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 200 | semantic[2 + i][0] = Semantic(Shader::USAGE_TEXCOORD, i); |
| 201 | semantic[2 + i][1] = Semantic(Shader::USAGE_TEXCOORD, i); |
| 202 | semantic[2 + i][2] = Semantic(Shader::USAGE_TEXCOORD, i); |
| 203 | semantic[2 + i][3] = Semantic(Shader::USAGE_TEXCOORD, i); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 204 | } |
| 205 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 206 | Shader::SamplerType samplerType[16]; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 207 | |
| 208 | for(int i = 0; i < 16; i++) |
| 209 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 210 | samplerType[i] = Shader::SAMPLER_UNKNOWN; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 211 | } |
| 212 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 213 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 214 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 215 | if(instruction[i]->dst.type == Shader::PARAMETER_SAMPLER) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 216 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 217 | int sampler = instruction[i]->dst.index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 218 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 219 | samplerType[sampler] = instruction[i]->samplerType; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 220 | } |
| 221 | } |
| 222 | |
Nicolas Capens | 9185981 | 2016-01-02 00:00:35 -0500 | [diff] [blame^] | 223 | bool interpolant[MAX_INPUT_VARYINGS][4] = {{false}}; // Interpolants in use |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 224 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 225 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 226 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 227 | if(instruction[i]->dst.type == Shader::PARAMETER_TEXTURE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 228 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 229 | int index = instruction[i]->dst.index + 2; |
| 230 | int mask = instruction[i]->dst.mask; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 231 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 232 | switch(instruction[i]->opcode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 233 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 234 | case Shader::OPCODE_TEX: |
| 235 | case Shader::OPCODE_TEXBEM: |
| 236 | case Shader::OPCODE_TEXBEML: |
| 237 | case Shader::OPCODE_TEXCOORD: |
| 238 | case Shader::OPCODE_TEXDP3: |
| 239 | case Shader::OPCODE_TEXDP3TEX: |
| 240 | case Shader::OPCODE_TEXM3X2DEPTH: |
| 241 | case Shader::OPCODE_TEXM3X2PAD: |
| 242 | case Shader::OPCODE_TEXM3X2TEX: |
| 243 | case Shader::OPCODE_TEXM3X3: |
| 244 | case Shader::OPCODE_TEXM3X3PAD: |
| 245 | case Shader::OPCODE_TEXM3X3TEX: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 246 | interpolant[index][0] = true; |
| 247 | interpolant[index][1] = true; |
| 248 | interpolant[index][2] = true; |
| 249 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 250 | case Shader::OPCODE_TEXKILL: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 251 | if(majorVersion < 2) |
| 252 | { |
| 253 | interpolant[index][0] = true; |
| 254 | interpolant[index][1] = true; |
| 255 | interpolant[index][2] = true; |
| 256 | } |
| 257 | else |
| 258 | { |
| 259 | interpolant[index][0] = true; |
| 260 | interpolant[index][1] = true; |
| 261 | interpolant[index][2] = true; |
| 262 | interpolant[index][3] = true; |
| 263 | } |
| 264 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 265 | case Shader::OPCODE_TEXM3X3VSPEC: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 266 | interpolant[index][0] = true; |
| 267 | interpolant[index][1] = true; |
| 268 | interpolant[index][2] = true; |
| 269 | interpolant[index - 2][3] = true; |
| 270 | interpolant[index - 1][3] = true; |
| 271 | interpolant[index - 0][3] = true; |
| 272 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 273 | case Shader::OPCODE_DCL: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 274 | break; // Ignore |
| 275 | default: // Arithmetic instruction |
| 276 | if(version >= 0x0104) |
| 277 | { |
| 278 | ASSERT(false); |
| 279 | } |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | for(int argument = 0; argument < 4; argument++) |
| 284 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 285 | if(instruction[i]->src[argument].type == Shader::PARAMETER_INPUT || |
| 286 | instruction[i]->src[argument].type == Shader::PARAMETER_TEXTURE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 287 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 288 | int index = instruction[i]->src[argument].index; |
| 289 | int swizzle = instruction[i]->src[argument].swizzle; |
| 290 | int mask = instruction[i]->dst.mask; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 291 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 292 | if(instruction[i]->src[argument].type == Shader::PARAMETER_TEXTURE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 293 | { |
| 294 | index += 2; |
| 295 | } |
| 296 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 297 | switch(instruction[i]->opcode) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 298 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 299 | case Shader::OPCODE_TEX: |
| 300 | case Shader::OPCODE_TEXLDD: |
| 301 | case Shader::OPCODE_TEXLDL: |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 302 | case Shader::OPCODE_TEXOFFSET: |
| 303 | case Shader::OPCODE_TEXLDLOFFSET: |
| 304 | case Shader::OPCODE_TEXELFETCH: |
| 305 | case Shader::OPCODE_TEXELFETCHOFFSET: |
| 306 | case Shader::OPCODE_TEXGRAD: |
| 307 | case Shader::OPCODE_TEXGRADOFFSET: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 308 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 309 | int sampler = instruction[i]->src[1].index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 310 | |
| 311 | switch(samplerType[sampler]) |
| 312 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 313 | case Shader::SAMPLER_UNKNOWN: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 314 | if(version == 0x0104) |
| 315 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 316 | if((instruction[i]->src[0].swizzle & 0x30) == 0x20) // .xyz |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 317 | { |
| 318 | interpolant[index][0] = true; |
| 319 | interpolant[index][1] = true; |
| 320 | interpolant[index][2] = true; |
| 321 | } |
| 322 | else // .xyw |
| 323 | { |
| 324 | interpolant[index][0] = true; |
| 325 | interpolant[index][1] = true; |
| 326 | interpolant[index][3] = true; |
| 327 | } |
| 328 | } |
| 329 | else |
| 330 | { |
| 331 | ASSERT(false); |
| 332 | } |
| 333 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 334 | case Shader::SAMPLER_1D: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 335 | interpolant[index][0] = true; |
| 336 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 337 | case Shader::SAMPLER_2D: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 338 | interpolant[index][0] = true; |
| 339 | interpolant[index][1] = true; |
| 340 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 341 | case Shader::SAMPLER_CUBE: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 342 | interpolant[index][0] = true; |
| 343 | interpolant[index][1] = true; |
| 344 | interpolant[index][2] = true; |
| 345 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 346 | case Shader::SAMPLER_VOLUME: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 347 | interpolant[index][0] = true; |
| 348 | interpolant[index][1] = true; |
| 349 | interpolant[index][2] = true; |
| 350 | break; |
| 351 | default: |
| 352 | ASSERT(false); |
| 353 | } |
| 354 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 355 | if(instruction[i]->bias) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 356 | { |
| 357 | interpolant[index][3] = true; |
| 358 | } |
| 359 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 360 | if(instruction[i]->project) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 361 | { |
| 362 | interpolant[index][3] = true; |
| 363 | } |
| 364 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 365 | if(version == 0x0104 && instruction[i]->opcode == Shader::OPCODE_TEX) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 366 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 367 | if(instruction[i]->src[0].modifier == Shader::MODIFIER_DZ) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 368 | { |
| 369 | interpolant[index][2] = true; |
| 370 | } |
| 371 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 372 | if(instruction[i]->src[0].modifier == Shader::MODIFIER_DW) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 373 | { |
| 374 | interpolant[index][3] = true; |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 379 | case Shader::OPCODE_M3X2: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 380 | if(mask & 0x1) |
| 381 | { |
| 382 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 383 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 384 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 385 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 386 | } |
| 387 | |
| 388 | if(argument == 1) |
| 389 | { |
| 390 | if(mask & 0x2) |
| 391 | { |
| 392 | interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 393 | interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 394 | interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 395 | interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 396 | } |
| 397 | } |
| 398 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 399 | case Shader::OPCODE_M3X3: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 400 | if(mask & 0x1) |
| 401 | { |
| 402 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 403 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 404 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 405 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 406 | } |
| 407 | |
| 408 | if(argument == 1) |
| 409 | { |
| 410 | if(mask & 0x2) |
| 411 | { |
| 412 | interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 413 | interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 414 | interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 415 | interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 416 | } |
| 417 | |
| 418 | if(mask & 0x4) |
| 419 | { |
| 420 | interpolant[index + 2][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 421 | interpolant[index + 2][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 422 | interpolant[index + 2][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 423 | interpolant[index + 2][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 424 | } |
| 425 | } |
| 426 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 427 | case Shader::OPCODE_M3X4: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 428 | if(mask & 0x1) |
| 429 | { |
| 430 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 431 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 432 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 433 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 434 | } |
| 435 | |
| 436 | if(argument == 1) |
| 437 | { |
| 438 | if(mask & 0x2) |
| 439 | { |
| 440 | interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 441 | interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 442 | interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 443 | interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 444 | } |
| 445 | |
| 446 | if(mask & 0x4) |
| 447 | { |
| 448 | interpolant[index + 2][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 449 | interpolant[index + 2][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 450 | interpolant[index + 2][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 451 | interpolant[index + 2][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 452 | } |
| 453 | |
| 454 | if(mask & 0x8) |
| 455 | { |
| 456 | interpolant[index + 3][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 457 | interpolant[index + 3][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 458 | interpolant[index + 3][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 459 | interpolant[index + 3][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 460 | } |
| 461 | } |
| 462 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 463 | case Shader::OPCODE_M4X3: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 464 | if(mask & 0x1) |
| 465 | { |
| 466 | interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); |
| 467 | interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); |
| 468 | interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); |
| 469 | interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); |
| 470 | } |
| 471 | |
| 472 | if(argument == 1) |
| 473 | { |
| 474 | if(mask & 0x2) |
| 475 | { |
| 476 | interpolant[index + 1][0] |= swizzleContainsComponent(swizzle, 0); |
| 477 | interpolant[index + 1][1] |= swizzleContainsComponent(swizzle, 1); |
| 478 | interpolant[index + 1][2] |= swizzleContainsComponent(swizzle, 2); |
| 479 | interpolant[index + 1][3] |= swizzleContainsComponent(swizzle, 3); |
| 480 | } |
| 481 | |
| 482 | if(mask & 0x4) |
| 483 | { |
| 484 | interpolant[index + 2][0] |= swizzleContainsComponent(swizzle, 0); |
| 485 | interpolant[index + 2][1] |= swizzleContainsComponent(swizzle, 1); |
| 486 | interpolant[index + 2][2] |= swizzleContainsComponent(swizzle, 2); |
| 487 | interpolant[index + 2][3] |= swizzleContainsComponent(swizzle, 3); |
| 488 | } |
| 489 | } |
| 490 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 491 | case Shader::OPCODE_M4X4: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 492 | if(mask & 0x1) |
| 493 | { |
| 494 | interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); |
| 495 | interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); |
| 496 | interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); |
| 497 | interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); |
| 498 | } |
| 499 | |
| 500 | if(argument == 1) |
| 501 | { |
| 502 | if(mask & 0x2) |
| 503 | { |
| 504 | interpolant[index + 1][0] |= swizzleContainsComponent(swizzle, 0); |
| 505 | interpolant[index + 1][1] |= swizzleContainsComponent(swizzle, 1); |
| 506 | interpolant[index + 1][2] |= swizzleContainsComponent(swizzle, 2); |
| 507 | interpolant[index + 1][3] |= swizzleContainsComponent(swizzle, 3); |
| 508 | } |
| 509 | |
| 510 | if(mask & 0x4) |
| 511 | { |
| 512 | interpolant[index + 2][0] |= swizzleContainsComponent(swizzle, 0); |
| 513 | interpolant[index + 2][1] |= swizzleContainsComponent(swizzle, 1); |
| 514 | interpolant[index + 2][2] |= swizzleContainsComponent(swizzle, 2); |
| 515 | interpolant[index + 2][3] |= swizzleContainsComponent(swizzle, 3); |
| 516 | } |
| 517 | |
| 518 | if(mask & 0x8) |
| 519 | { |
| 520 | interpolant[index + 3][0] |= swizzleContainsComponent(swizzle, 0); |
| 521 | interpolant[index + 3][1] |= swizzleContainsComponent(swizzle, 1); |
| 522 | interpolant[index + 3][2] |= swizzleContainsComponent(swizzle, 2); |
| 523 | interpolant[index + 3][3] |= swizzleContainsComponent(swizzle, 3); |
| 524 | } |
| 525 | } |
| 526 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 527 | case Shader::OPCODE_CRS: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 528 | if(mask & 0x1) |
| 529 | { |
| 530 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x6); |
| 531 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x6); |
| 532 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x6); |
| 533 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x6); |
| 534 | } |
| 535 | |
| 536 | if(mask & 0x2) |
| 537 | { |
| 538 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x5); |
| 539 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x5); |
| 540 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x5); |
| 541 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x5); |
| 542 | } |
| 543 | |
| 544 | if(mask & 0x4) |
| 545 | { |
| 546 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x3); |
| 547 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x3); |
| 548 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x3); |
| 549 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x3); |
| 550 | } |
| 551 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 552 | case Shader::OPCODE_DP2ADD: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 553 | if(argument == 0 || argument == 1) |
| 554 | { |
| 555 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x3); |
| 556 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x3); |
| 557 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x3); |
| 558 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x3); |
| 559 | } |
| 560 | else // argument == 2 |
| 561 | { |
| 562 | interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); |
| 563 | interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); |
| 564 | interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); |
| 565 | interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); |
| 566 | } |
| 567 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 568 | case Shader::OPCODE_DP3: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 569 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); |
| 570 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); |
| 571 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); |
| 572 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); |
| 573 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 574 | case Shader::OPCODE_DP4: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 575 | interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); |
| 576 | interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); |
| 577 | interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); |
| 578 | interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); |
| 579 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 580 | case Shader::OPCODE_SINCOS: |
| 581 | case Shader::OPCODE_EXP2X: |
| 582 | case Shader::OPCODE_LOG2X: |
| 583 | case Shader::OPCODE_POWX: |
| 584 | case Shader::OPCODE_RCPX: |
| 585 | case Shader::OPCODE_RSQX: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 586 | interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); |
| 587 | interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); |
| 588 | interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); |
| 589 | interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); |
| 590 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 591 | case Shader::OPCODE_NRM3: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 592 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7 | mask); |
| 593 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7 | mask); |
| 594 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7 | mask); |
| 595 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7 | mask); |
| 596 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 597 | case Shader::OPCODE_MOV: |
| 598 | case Shader::OPCODE_ADD: |
| 599 | case Shader::OPCODE_SUB: |
| 600 | case Shader::OPCODE_MUL: |
| 601 | case Shader::OPCODE_MAD: |
| 602 | case Shader::OPCODE_ABS: |
| 603 | case Shader::OPCODE_CMP0: |
| 604 | case Shader::OPCODE_CND: |
| 605 | case Shader::OPCODE_FRC: |
| 606 | case Shader::OPCODE_LRP: |
| 607 | case Shader::OPCODE_MAX: |
| 608 | case Shader::OPCODE_MIN: |
| 609 | case Shader::OPCODE_CMP: |
| 610 | case Shader::OPCODE_BREAKC: |
| 611 | case Shader::OPCODE_DFDX: |
| 612 | case Shader::OPCODE_DFDY: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 613 | interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, mask); |
| 614 | interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, mask); |
| 615 | interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, mask); |
| 616 | interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, mask); |
| 617 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 618 | case Shader::OPCODE_TEXCOORD: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 619 | interpolant[index][0] = true; |
| 620 | interpolant[index][1] = true; |
| 621 | interpolant[index][2] = true; |
| 622 | interpolant[index][3] = true; |
| 623 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 624 | case Shader::OPCODE_TEXDP3: |
| 625 | case Shader::OPCODE_TEXDP3TEX: |
| 626 | case Shader::OPCODE_TEXM3X2PAD: |
| 627 | case Shader::OPCODE_TEXM3X3PAD: |
| 628 | case Shader::OPCODE_TEXM3X2TEX: |
| 629 | case Shader::OPCODE_TEXM3X3SPEC: |
| 630 | case Shader::OPCODE_TEXM3X3VSPEC: |
| 631 | case Shader::OPCODE_TEXBEM: |
| 632 | case Shader::OPCODE_TEXBEML: |
| 633 | case Shader::OPCODE_TEXM3X2DEPTH: |
| 634 | case Shader::OPCODE_TEXM3X3: |
| 635 | case Shader::OPCODE_TEXM3X3TEX: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 636 | interpolant[index][0] = true; |
| 637 | interpolant[index][1] = true; |
| 638 | interpolant[index][2] = true; |
| 639 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 640 | case Shader::OPCODE_TEXREG2AR: |
| 641 | case Shader::OPCODE_TEXREG2GB: |
| 642 | case Shader::OPCODE_TEXREG2RGB: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 643 | break; |
| 644 | default: |
| 645 | // ASSERT(false); // Refine component usage |
| 646 | interpolant[index][0] = true; |
| 647 | interpolant[index][1] = true; |
| 648 | interpolant[index][2] = true; |
| 649 | interpolant[index][3] = true; |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 655 | for(int index = 0; index < MAX_INPUT_VARYINGS; index++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 656 | { |
| 657 | for(int component = 0; component < 4; component++) |
| 658 | { |
| 659 | if(!interpolant[index][component]) |
| 660 | { |
| 661 | semantic[index][component] = Semantic(); |
| 662 | } |
| 663 | } |
| 664 | } |
| 665 | } |
| 666 | else // Shader Model 3.0 input declaration; v# indexable |
| 667 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 668 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 669 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 670 | if(instruction[i]->opcode == Shader::OPCODE_DCL) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 671 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 672 | if(instruction[i]->dst.type == Shader::PARAMETER_INPUT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 673 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 674 | unsigned char usage = instruction[i]->usage; |
| 675 | unsigned char index = instruction[i]->usageIndex; |
| 676 | unsigned char mask = instruction[i]->dst.mask; |
| 677 | unsigned char reg = instruction[i]->dst.index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 678 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 679 | if(mask & 0x01) semantic[reg][0] = Semantic(usage, index); |
| 680 | if(mask & 0x02) semantic[reg][1] = Semantic(usage, index); |
| 681 | if(mask & 0x04) semantic[reg][2] = Semantic(usage, index); |
| 682 | if(mask & 0x08) semantic[reg][3] = Semantic(usage, index); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 683 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 684 | else if(instruction[i]->dst.type == Shader::PARAMETER_MISCTYPE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 685 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 686 | unsigned char index = instruction[i]->dst.index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 687 | |
| 688 | if(index == 0) |
| 689 | { |
| 690 | vPosDeclared = true; |
| 691 | } |
| 692 | else if(index == 1) |
| 693 | { |
| 694 | vFaceDeclared = true; |
| 695 | } |
| 696 | else ASSERT(false); |
| 697 | } |
| 698 | } |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | if(version >= 0x0200) |
| 703 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 704 | for(unsigned int i = 0; i < instruction.size(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 705 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 706 | if(instruction[i]->opcode == Shader::OPCODE_DCL) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 707 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 708 | bool centroid = instruction[i]->dst.centroid; |
| 709 | unsigned char reg = instruction[i]->dst.index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 710 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 711 | switch(instruction[i]->dst.type) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 712 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 713 | case Shader::PARAMETER_INPUT: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 714 | semantic[reg][0].centroid = centroid; |
| 715 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 716 | case Shader::PARAMETER_TEXTURE: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 717 | semantic[2 + reg][0].centroid = centroid; |
| 718 | break; |
Nicolas Capens | b69aa27 | 2016-01-02 00:06:41 -0500 | [diff] [blame] | 719 | default: |
| 720 | break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 721 | } |
| 722 | |
| 723 | this->centroid = this->centroid || centroid; |
| 724 | } |
| 725 | } |
| 726 | } |
| 727 | } |
| 728 | } |