1d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Copyright 2016 The SwiftShader Authors. All Rights Reserved. 2894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 3d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Licensed under the Apache License, Version 2.0 (the "License"); 4d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// you may not use this file except in compliance with the License. 5d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// You may obtain a copy of the License at 6894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 7d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// http://www.apache.org/licenses/LICENSE-2.0 8894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman// 9d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// Unless required by applicable law or agreed to in writing, software 10d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// distributed under the License is distributed on an "AS IS" BASIS, 11d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// See the License for the specific language governing permissions and 13d999309b36cb3dceadd38217b322f0e96a06b202Nicolas Capens// limitations under the License. 14894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "PixelShader.hpp" 16894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman#include "Debug.hpp" 18894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 1966b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman#include <string.h> 2066b8ab22586debccb1f787d4d52b7f042d4ddeb8John Bauman 21894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Baumannamespace sw 22894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman{ 2319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman PixelShader::PixelShader(const PixelShader *ps) : Shader() 24894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 2519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman version = 0x0300; 2619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vPosDeclared = false; 2719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vFaceDeclared = false; 2819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman centroid = false; 29894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(ps) // Make a copy 31894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 32903e025f6cd8d978f013c741431b87b04ae01fd1Alexis Hetu for(size_t i = 0; i < ps->getLength(); i++) 33894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 3419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman append(new sw::Shader::Instruction(*ps->getInstruction(i))); 35894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 36894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 3719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman memcpy(semantic, ps->semantic, sizeof(semantic)); 3819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vPosDeclared = ps->vPosDeclared; 3919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vFaceDeclared = ps->vFaceDeclared; 4019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman usedSamplers = ps->usedSamplers; 41894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 42d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman optimize(); 4319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyze(); 44894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 4519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 46894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 4719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman PixelShader::PixelShader(const unsigned long *token) : Shader() 4819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 4919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman parse(token); 5019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 5119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vPosDeclared = false; 5219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman vFaceDeclared = false; 5319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman centroid = false; 5419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 55d4ae863d01d5f448dbbba6be4ecc161971a2324fJohn Bauman optimize(); 5619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyze(); 5719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 5819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 5919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman PixelShader::~PixelShader() 6019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 61894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 62894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 63894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int PixelShader::validate(const unsigned long *const token) 64894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 65894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(!token) 66894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 67894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return 0; 68894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 69894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 70894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned short version = (unsigned short)(token[0] & 0x0000FFFF); 71894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned char minorVersion = (unsigned char)(token[0] & 0x000000FF); 72894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman unsigned char majorVersion = (unsigned char)((token[0] & 0x0000FF00) >> 8); 73894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ShaderType shaderType = (ShaderType)((token[0] & 0xFFFF0000) >> 16); 74894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 75894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(shaderType != SHADER_PIXEL || majorVersion > 3) 76894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 77894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return 0; 78894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 79894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 80894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int instructionCount = 1; 81894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 82894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int i = 0; token[i] != 0x0000FFFF; i++) 83894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 84894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if((token[i] & 0x0000FFFF) == 0x0000FFFE) // Comment token 85894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 86894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman int length = (token[i] & 0x7FFF0000) >> 16; 87894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 88894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman i += length; 89894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 90894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 91894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 9219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Shader::Opcode opcode = (Shader::Opcode)(token[i] & 0x0000FFFF); 93894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 94894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch(opcode) 95894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 9619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_RESERVED0: 9719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MOVA: 98894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return 0; // Unsupported operation 99894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: 100894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman instructionCount++; 101894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 102894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 103894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 104894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman i += size(token[i], version); 105894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 106894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 107894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 108894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return instructionCount; 109894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 110894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 111894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool PixelShader::depthOverride() const 112894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 113894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return zOverride; 114894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 115894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 11619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman bool PixelShader::containsKill() const 117894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 11819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman return kill; 119894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 120894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 121894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool PixelShader::containsCentroid() const 122894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 123894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return centroid; 124894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 125894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 126894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool PixelShader::usesDiffuse(int component) const 127894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 128894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return semantic[0][component].active(); 129894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 130894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 131894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool PixelShader::usesSpecular(int component) const 132894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 133894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return semantic[1][component].active(); 134894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 135894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 136894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman bool PixelShader::usesTexture(int coordinate, int component) const 137894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 138894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman return semantic[2 + coordinate][component].active(); 139894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 140894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 14119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman void PixelShader::analyze() 14219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman { 14319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeZOverride(); 14419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeKill(); 14519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeInterpolants(); 14619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeDirtyConstants(); 14719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeDynamicBranching(); 14819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeSamplers(); 14919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeCallSites(); 15019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman analyzeDynamicIndexing(); 15119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman } 15219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 153894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void PixelShader::analyzeZOverride() 154894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 155894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman zOverride = false; 156894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 15719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 158894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 15919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->opcode == Shader::OPCODE_TEXM3X2DEPTH || 16019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman instruction[i]->opcode == Shader::OPCODE_TEXDEPTH || 16119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman instruction[i]->dst.type == Shader::PARAMETER_DEPTHOUT) 162894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 163894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman zOverride = true; 164894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 165894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 166894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 167894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 168894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 169894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman void PixelShader::analyzeKill() 171894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 17219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman kill = false; 173894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 17419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 175894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 17619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->opcode == Shader::OPCODE_TEXKILL || 17719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman instruction[i]->opcode == Shader::OPCODE_DISCARD) 178894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 17919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman kill = true; 180894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 181894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 182894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 183894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 184894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 185894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 186894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman void PixelShader::analyzeInterpolants() 187894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 188894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(version < 0x0300) 189894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 190894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // Set default mapping; disable unused interpolants below 19119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[0][0] = Semantic(Shader::USAGE_COLOR, 0); 19219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[0][1] = Semantic(Shader::USAGE_COLOR, 0); 19319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[0][2] = Semantic(Shader::USAGE_COLOR, 0); 19419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[0][3] = Semantic(Shader::USAGE_COLOR, 0); 195894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 19619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[1][0] = Semantic(Shader::USAGE_COLOR, 1); 19719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[1][1] = Semantic(Shader::USAGE_COLOR, 1); 19819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[1][2] = Semantic(Shader::USAGE_COLOR, 1); 19919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[1][3] = Semantic(Shader::USAGE_COLOR, 1); 200894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 201894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int i = 0; i < 8; i++) 202894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 20319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[2 + i][0] = Semantic(Shader::USAGE_TEXCOORD, i); 20419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[2 + i][1] = Semantic(Shader::USAGE_TEXCOORD, i); 20519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[2 + i][2] = Semantic(Shader::USAGE_TEXCOORD, i); 20619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman semantic[2 + i][3] = Semantic(Shader::USAGE_TEXCOORD, i); 207894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 208894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 20919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman Shader::SamplerType samplerType[16]; 210894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 211894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int i = 0; i < 16; i++) 212894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 21319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman samplerType[i] = Shader::SAMPLER_UNKNOWN; 214894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 215894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 21619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 217894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 21819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->dst.type == Shader::PARAMETER_SAMPLER) 219894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 22019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int sampler = instruction[i]->dst.index; 221894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman samplerType[sampler] = instruction[i]->samplerType; 223894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 224894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 225894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 2267f781e6a4c64f25d3d825f650fabd3b29d8f2e74Nicolas Capens bool interpolant[MAX_FRAGMENT_INPUTS][4] = {{false}}; // Interpolants in use 227894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 22819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 229894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 23019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->dst.type == Shader::PARAMETER_TEXTURE) 23106e4781c723d54d690d05c00333f77d1dc6225c2Nicolas Capens { 23219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int index = instruction[i]->dst.index + 2; 23319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int mask = instruction[i]->dst.mask; 234894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 23519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman switch(instruction[i]->opcode) 236894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 23719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEX: 23819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXBEM: 23919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXBEML: 24019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXCOORD: 24119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXDP3: 24219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXDP3TEX: 24319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2DEPTH: 24419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2PAD: 24519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2TEX: 24619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3: 24719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3PAD: 24819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3TEX: 249894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 250894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 251894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 252894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 25319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXKILL: 254894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(majorVersion < 2) 255894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 256894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 257894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 258894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 259894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 260894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 261894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 262894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 263894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 264894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 265894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 266894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 267894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 26819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3VSPEC: 269894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 270894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 271894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 272894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index - 2][3] = true; 273894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index - 1][3] = true; 274894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index - 0][3] = true; 275894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 27619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DCL: 277894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; // Ignore 278894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: // Arithmetic instruction 279894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(version >= 0x0104) 280894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 281894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ASSERT(false); 282894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 283894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 284894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 285894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 286894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int argument = 0; argument < 4; argument++) 287894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 28819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->src[argument].type == Shader::PARAMETER_INPUT || 28919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman instruction[i]->src[argument].type == Shader::PARAMETER_TEXTURE) 290894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 29119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int index = instruction[i]->src[argument].index; 29219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int swizzle = instruction[i]->src[argument].swizzle; 29319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int mask = instruction[i]->dst.mask; 29406e4781c723d54d690d05c00333f77d1dc6225c2Nicolas Capens 29519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->src[argument].type == Shader::PARAMETER_TEXTURE) 296894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 297894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman index += 2; 298894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 299894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 30019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman switch(instruction[i]->opcode) 301894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 30219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEX: 30319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXLDD: 30419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXLDL: 3050dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXOFFSET: 3060dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXLDLOFFSET: 3070dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXELFETCH: 3080dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXELFETCHOFFSET: 3090dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXGRAD: 3100dc11abbe43cec2e453b968cd8562482d4e8c6d1Alexis Hetu case Shader::OPCODE_TEXGRADOFFSET: 311894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 31219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman int sampler = instruction[i]->src[1].index; 313894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 314894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman switch(samplerType[sampler]) 315894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 31619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::SAMPLER_UNKNOWN: 317894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(version == 0x0104) 318894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 31919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if((instruction[i]->src[0].swizzle & 0x30) == 0x20) // .xyz 320894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 321894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 322894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 323894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 324894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 325894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else // .xyw 326894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 327894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 328894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 329894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 330894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 331894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 332894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else 333894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 334894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ASSERT(false); 335894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 336894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 33719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::SAMPLER_1D: 338894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 339894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 34019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::SAMPLER_2D: 341894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 342894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 343894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 34419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::SAMPLER_CUBE: 345894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 346894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 347894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 348894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 34919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::SAMPLER_VOLUME: 350894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 351894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 352894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 353894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 354894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: 355894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman ASSERT(false); 356894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 357894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 35819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->bias) 359894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 360894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 361894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 362894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 36319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->project) 364894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 365894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 366894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 367894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 36819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(version == 0x0104 && instruction[i]->opcode == Shader::OPCODE_TEX) 369894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 37019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->src[0].modifier == Shader::MODIFIER_DZ) 371894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 372894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 373894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 374894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 37519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->src[0].modifier == Shader::MODIFIER_DW) 376894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 377894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 378894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 379894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 380894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 381894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 38219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_M3X2: 383894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 384894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 385894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 386894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 387894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 388894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 389894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 390894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 391894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 1) 392894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 393894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 394894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 395894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 396894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 397894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 398894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 399894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 400894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 401894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 40219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_M3X3: 403894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 404894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 405894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 406894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 407894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 408894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 409894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 410894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 411894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 1) 412894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 413894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 414894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 415894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 416894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 417894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 418894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 419894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 420894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 421894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x4) 422894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 423894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 424894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 425894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 426894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 427894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 428894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 429894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 43019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_M3X4: 431894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 432894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 433894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 434894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 435894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 436894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 437894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 438894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 439894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 1) 440894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 441894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 442894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 443894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 444894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 445894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 446894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 447894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 448894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 449894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x4) 450894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 451894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 452894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 453894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 454894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 455894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 456894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 457894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x8) 458894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 459894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 460894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 461894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 462894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 463894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 464894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 465894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 46619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_M4X3: 467894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 468894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 469894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); 470894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); 471894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); 472894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); 473894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 474894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 475894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 1) 476894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 477894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 478894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 479894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][0] |= swizzleContainsComponent(swizzle, 0); 480894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][1] |= swizzleContainsComponent(swizzle, 1); 481894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][2] |= swizzleContainsComponent(swizzle, 2); 482894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][3] |= swizzleContainsComponent(swizzle, 3); 483894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 484894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 485894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x4) 486894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 487894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][0] |= swizzleContainsComponent(swizzle, 0); 488894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][1] |= swizzleContainsComponent(swizzle, 1); 489894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][2] |= swizzleContainsComponent(swizzle, 2); 490894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][3] |= swizzleContainsComponent(swizzle, 3); 491894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 492894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 493894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 49419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_M4X4: 495894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 496894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 497894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); 498894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); 499894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); 500894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); 501894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 502894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 503894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 1) 504894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 505894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 506894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 507894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][0] |= swizzleContainsComponent(swizzle, 0); 508894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][1] |= swizzleContainsComponent(swizzle, 1); 509894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][2] |= swizzleContainsComponent(swizzle, 2); 510894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 1][3] |= swizzleContainsComponent(swizzle, 3); 511894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 512894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 513894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x4) 514894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 515894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][0] |= swizzleContainsComponent(swizzle, 0); 516894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][1] |= swizzleContainsComponent(swizzle, 1); 517894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][2] |= swizzleContainsComponent(swizzle, 2); 518894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 2][3] |= swizzleContainsComponent(swizzle, 3); 519894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 520894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 521894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x8) 522894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 523894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][0] |= swizzleContainsComponent(swizzle, 0); 524894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][1] |= swizzleContainsComponent(swizzle, 1); 525894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][2] |= swizzleContainsComponent(swizzle, 2); 526894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index + 3][3] |= swizzleContainsComponent(swizzle, 3); 527894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 528894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 529894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 53019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_CRS: 531894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x1) 532894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 533894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x6); 534894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x6); 535894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x6); 536894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x6); 537894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 538894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 539894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x2) 540894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 541894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x5); 542894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x5); 543894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x5); 544894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x5); 545894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 546894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 547894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(mask & 0x4) 548894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 549894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x3); 550894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x3); 551894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x3); 552894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x3); 553894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 554894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 55519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DP2ADD: 556894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(argument == 0 || argument == 1) 557894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 558894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x3); 559894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x3); 560894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x3); 561894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x3); 562894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 563894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else // argument == 2 564894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 565894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); 566894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); 567894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); 568894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); 569894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 570894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 57119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DP3: 572894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7); 573894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7); 574894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7); 575894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7); 576894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 57719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DP4: 578894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); 579894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); 580894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); 581894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); 582894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 58319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_SINCOS: 58419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_EXP2X: 58519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_LOG2X: 58619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_POWX: 58719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_RCPX: 58819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_RSQX: 589894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponent(swizzle, 0); 590894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponent(swizzle, 1); 591894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponent(swizzle, 2); 592894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponent(swizzle, 3); 593894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 59419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_NRM3: 595894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, 0x7 | mask); 596894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, 0x7 | mask); 597894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, 0x7 | mask); 598894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, 0x7 | mask); 599894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 60019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MOV: 60119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_ADD: 60219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_SUB: 60319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MUL: 60419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MAD: 60519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_ABS: 60619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_CMP0: 60719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_CND: 60819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_FRC: 60919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_LRP: 61019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MAX: 61119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_MIN: 61219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_CMP: 61319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_BREAKC: 61419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DFDX: 61519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_DFDY: 616894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] |= swizzleContainsComponentMasked(swizzle, 0, mask); 617894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] |= swizzleContainsComponentMasked(swizzle, 1, mask); 618894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] |= swizzleContainsComponentMasked(swizzle, 2, mask); 619894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] |= swizzleContainsComponentMasked(swizzle, 3, mask); 620894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 62119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXCOORD: 622894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 623894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 624894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 625894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 626894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 62719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXDP3: 62819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXDP3TEX: 62919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2PAD: 63019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3PAD: 63119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2TEX: 63219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3SPEC: 63319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3VSPEC: 63419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXBEM: 63519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXBEML: 63619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X2DEPTH: 63719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3: 63819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXM3X3TEX: 639894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 640894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 641894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 642894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 64319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXREG2AR: 64419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXREG2GB: 64519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::OPCODE_TEXREG2RGB: 646894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 647894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman default: 648894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman // ASSERT(false); // Refine component usage 649894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][0] = true; 650894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][1] = true; 651894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][2] = true; 652894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman interpolant[index][3] = true; 653894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 654894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 655894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 656894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 657894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 6587f781e6a4c64f25d3d825f650fabd3b29d8f2e74Nicolas Capens for(int index = 0; index < MAX_FRAGMENT_INPUTS; index++) 659894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 660894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman for(int component = 0; component < 4; component++) 661894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 662894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(!interpolant[index][component]) 663894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 664894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman semantic[index][component] = Semantic(); 665894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 666894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 667894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 668894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 669894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else // Shader Model 3.0 input declaration; v# indexable 670894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 67119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 672894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 67319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->opcode == Shader::OPCODE_DCL) 674894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 67519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->dst.type == Shader::PARAMETER_INPUT) 676894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 67719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char usage = instruction[i]->usage; 67819bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char index = instruction[i]->usageIndex; 67919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char mask = instruction[i]->dst.mask; 68019bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char reg = instruction[i]->dst.index; 68119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman 68219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(mask & 0x01) semantic[reg][0] = Semantic(usage, index); 68319bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(mask & 0x02) semantic[reg][1] = Semantic(usage, index); 68419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(mask & 0x04) semantic[reg][2] = Semantic(usage, index); 68519bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(mask & 0x08) semantic[reg][3] = Semantic(usage, index); 686894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 68719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman else if(instruction[i]->dst.type == Shader::PARAMETER_MISCTYPE) 688894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 68919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char index = instruction[i]->dst.index; 690894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 691894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(index == 0) 692894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 693894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman vPosDeclared = true; 694894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 695894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else if(index == 1) 696894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 697894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman vFaceDeclared = true; 698894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 699894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman else ASSERT(false); 700894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 701894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 702894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 703894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 704894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 705894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman if(version >= 0x0200) 706894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 70719bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman for(unsigned int i = 0; i < instruction.size(); i++) 708894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 70919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman if(instruction[i]->opcode == Shader::OPCODE_DCL) 710894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 71119bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman bool centroid = instruction[i]->dst.centroid; 71219bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman unsigned char reg = instruction[i]->dst.index; 713894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 71419bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman switch(instruction[i]->dst.type) 715894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman { 71619bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::PARAMETER_INPUT: 717894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman semantic[reg][0].centroid = centroid; 718894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 71919bac1e08be200c31efd26f0f5fd144c9b3eefd3John Bauman case Shader::PARAMETER_TEXTURE: 720894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman semantic[2 + reg][0].centroid = centroid; 721894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman break; 722429a71c3784c3adda7682304b924ee1de9bcacb6Nicolas Capens default: 723429a71c3784c3adda7682304b924ee1de9bcacb6Nicolas Capens break; 724894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 725894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman 726894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman this->centroid = this->centroid || centroid; 727894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 728894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 729894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 730894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman } 731894018228b0e0bdbd7aa7e8f47d4a9458789ca82John Bauman} 732