Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 1 | // Copyright 2016 The SwiftShader Authors. All Rights Reserved. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 2 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 6 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 8 | // |
Nicolas Capens | 0bac285 | 2016-05-07 06:09:58 -0400 | [diff] [blame] | 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 14 | |
| 15 | #include "VertexShader.hpp" |
| 16 | |
Nicolas Capens | 708c24b | 2017-10-26 13:07:10 -0400 | [diff] [blame] | 17 | #include "Renderer/Vertex.hpp" |
| 18 | #include "Common/Debug.hpp" |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 19 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 20 | #include <string.h> |
| 21 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 22 | namespace sw |
| 23 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 24 | VertexShader::VertexShader(const VertexShader *vs) : Shader() |
| 25 | { |
Alexis Hetu | 53ad4af | 2017-12-06 14:49:07 -0500 | [diff] [blame] | 26 | shaderModel = 0x0300; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 27 | positionRegister = Pos; |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 28 | pointSizeRegister = Unused; |
Alexis Hetu | 6743bbf | 2015-04-21 17:06:14 -0400 | [diff] [blame] | 29 | instanceIdDeclared = false; |
Alexis Hetu | 877ddfc | 2017-07-25 17:48:00 -0400 | [diff] [blame] | 30 | vertexIdDeclared = false; |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 31 | textureSampling = false; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 32 | |
Nicolas Capens | f0aef1a | 2016-05-18 14:44:21 -0400 | [diff] [blame] | 33 | for(int i = 0; i < MAX_VERTEX_INPUTS; i++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 34 | { |
Alexis Hetu | 1d67244 | 2016-06-23 11:24:00 -0400 | [diff] [blame] | 35 | input[i] = Semantic(); |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 36 | attribType[i] = ATTRIBTYPE_FLOAT; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | if(vs) // Make a copy |
| 40 | { |
Alexis Hetu | 903e025 | 2014-11-25 14:25:32 -0500 | [diff] [blame] | 41 | for(size_t i = 0; i < vs->getLength(); i++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 42 | { |
| 43 | append(new sw::Shader::Instruction(*vs->getInstruction(i))); |
| 44 | } |
| 45 | |
| 46 | memcpy(output, vs->output, sizeof(output)); |
| 47 | memcpy(input, vs->input, sizeof(input)); |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 48 | memcpy(attribType, vs->attribType, sizeof(attribType)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 49 | positionRegister = vs->positionRegister; |
| 50 | pointSizeRegister = vs->pointSizeRegister; |
Alexis Hetu | dd8df68 | 2015-06-05 17:08:39 -0400 | [diff] [blame] | 51 | instanceIdDeclared = vs->instanceIdDeclared; |
Alexis Hetu | 877ddfc | 2017-07-25 17:48:00 -0400 | [diff] [blame] | 52 | vertexIdDeclared = vs->vertexIdDeclared; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 53 | usedSamplers = vs->usedSamplers; |
| 54 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 55 | optimize(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 56 | analyze(); |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | VertexShader::VertexShader(const unsigned long *token) : Shader() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 61 | { |
| 62 | parse(token); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 63 | |
| 64 | positionRegister = Pos; |
Nicolas Capens | ec0936c | 2016-05-18 12:32:02 -0400 | [diff] [blame] | 65 | pointSizeRegister = Unused; |
Alexis Hetu | 6743bbf | 2015-04-21 17:06:14 -0400 | [diff] [blame] | 66 | instanceIdDeclared = false; |
Alexis Hetu | 877ddfc | 2017-07-25 17:48:00 -0400 | [diff] [blame] | 67 | vertexIdDeclared = false; |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 68 | textureSampling = false; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 69 | |
Nicolas Capens | f0aef1a | 2016-05-18 14:44:21 -0400 | [diff] [blame] | 70 | for(int i = 0; i < MAX_VERTEX_INPUTS; i++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 71 | { |
Alexis Hetu | 1d67244 | 2016-06-23 11:24:00 -0400 | [diff] [blame] | 72 | input[i] = Semantic(); |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 73 | attribType[i] = ATTRIBTYPE_FLOAT; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 74 | } |
| 75 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 76 | optimize(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 77 | analyze(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 78 | } |
| 79 | |
| 80 | VertexShader::~VertexShader() |
| 81 | { |
| 82 | } |
| 83 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 84 | int VertexShader::validate(const unsigned long *const token) |
| 85 | { |
| 86 | if(!token) |
| 87 | { |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | unsigned short version = (unsigned short)(token[0] & 0x0000FFFF); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 92 | unsigned char majorVersion = (unsigned char)((token[0] & 0x0000FF00) >> 8); |
| 93 | ShaderType shaderType = (ShaderType)((token[0] & 0xFFFF0000) >> 16); |
| 94 | |
| 95 | if(shaderType != SHADER_VERTEX || majorVersion > 3) |
| 96 | { |
| 97 | return 0; |
| 98 | } |
| 99 | |
| 100 | int instructionCount = 1; |
| 101 | |
| 102 | for(int i = 0; token[i] != 0x0000FFFF; i++) |
| 103 | { |
| 104 | if((token[i] & 0x0000FFFF) == 0x0000FFFE) // Comment token |
| 105 | { |
| 106 | int length = (token[i] & 0x7FFF0000) >> 16; |
| 107 | |
| 108 | i += length; |
| 109 | } |
| 110 | else |
| 111 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 112 | Shader::Opcode opcode = (Shader::Opcode)(token[i] & 0x0000FFFF); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 113 | |
| 114 | switch(opcode) |
| 115 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 116 | case Shader::OPCODE_TEXCOORD: |
| 117 | case Shader::OPCODE_TEXKILL: |
| 118 | case Shader::OPCODE_TEX: |
| 119 | case Shader::OPCODE_TEXBEM: |
| 120 | case Shader::OPCODE_TEXBEML: |
| 121 | case Shader::OPCODE_TEXREG2AR: |
| 122 | case Shader::OPCODE_TEXREG2GB: |
| 123 | case Shader::OPCODE_TEXM3X2PAD: |
| 124 | case Shader::OPCODE_TEXM3X2TEX: |
| 125 | case Shader::OPCODE_TEXM3X3PAD: |
| 126 | case Shader::OPCODE_TEXM3X3TEX: |
| 127 | case Shader::OPCODE_RESERVED0: |
| 128 | case Shader::OPCODE_TEXM3X3SPEC: |
| 129 | case Shader::OPCODE_TEXM3X3VSPEC: |
| 130 | case Shader::OPCODE_TEXREG2RGB: |
| 131 | case Shader::OPCODE_TEXDP3TEX: |
| 132 | case Shader::OPCODE_TEXM3X2DEPTH: |
| 133 | case Shader::OPCODE_TEXDP3: |
| 134 | case Shader::OPCODE_TEXM3X3: |
| 135 | case Shader::OPCODE_TEXDEPTH: |
| 136 | case Shader::OPCODE_CMP0: |
| 137 | case Shader::OPCODE_BEM: |
| 138 | case Shader::OPCODE_DP2ADD: |
| 139 | case Shader::OPCODE_DFDX: |
| 140 | case Shader::OPCODE_DFDY: |
| 141 | case Shader::OPCODE_TEXLDD: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 142 | return 0; // Unsupported operation |
| 143 | default: |
| 144 | instructionCount++; |
| 145 | break; |
| 146 | } |
| 147 | |
| 148 | i += size(token[i], version); |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | return instructionCount; |
| 153 | } |
| 154 | |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 155 | bool VertexShader::containsTextureSampling() const |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 156 | { |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 157 | return textureSampling; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 158 | } |
| 159 | |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 160 | void VertexShader::setInput(int inputIdx, const sw::Shader::Semantic& semantic, AttribType aType) |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 161 | { |
| 162 | input[inputIdx] = semantic; |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 163 | attribType[inputIdx] = aType; |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | void VertexShader::setOutput(int outputIdx, int nbComponents, const sw::Shader::Semantic& semantic) |
| 167 | { |
| 168 | for(int i = 0; i < nbComponents; ++i) |
| 169 | { |
| 170 | output[outputIdx][i] = semantic; |
| 171 | } |
| 172 | } |
| 173 | |
| 174 | void VertexShader::setPositionRegister(int posReg) |
| 175 | { |
| 176 | setOutput(posReg, 4, sw::Shader::Semantic(sw::Shader::USAGE_POSITION, 0)); |
| 177 | positionRegister = posReg; |
| 178 | } |
| 179 | |
| 180 | void VertexShader::setPointSizeRegister(int ptSizeReg) |
| 181 | { |
| 182 | setOutput(ptSizeReg, 4, sw::Shader::Semantic(sw::Shader::USAGE_PSIZE, 0)); |
| 183 | pointSizeRegister = ptSizeReg; |
| 184 | } |
| 185 | |
| 186 | const sw::Shader::Semantic& VertexShader::getInput(int inputIdx) const |
| 187 | { |
| 188 | return input[inputIdx]; |
| 189 | } |
| 190 | |
Alexis Hetu | b7508b8 | 2016-09-22 15:36:45 -0400 | [diff] [blame] | 191 | VertexShader::AttribType VertexShader::getAttribType(int inputIdx) const |
| 192 | { |
| 193 | return attribType[inputIdx]; |
| 194 | } |
| 195 | |
Alexis Hetu | 02ad0aa | 2016-08-02 11:18:14 -0400 | [diff] [blame] | 196 | const sw::Shader::Semantic& VertexShader::getOutput(int outputIdx, int component) const |
| 197 | { |
| 198 | return output[outputIdx][component]; |
| 199 | } |
| 200 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 201 | void VertexShader::analyze() |
| 202 | { |
| 203 | analyzeInput(); |
| 204 | analyzeOutput(); |
| 205 | analyzeDirtyConstants(); |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 206 | analyzeTextureSampling(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 207 | analyzeDynamicBranching(); |
| 208 | analyzeSamplers(); |
| 209 | analyzeCallSites(); |
| 210 | analyzeDynamicIndexing(); |
| 211 | } |
| 212 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 213 | void VertexShader::analyzeInput() |
| 214 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 215 | for(unsigned int i = 0; i < instruction.size(); i++) |
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 | if(instruction[i]->opcode == Shader::OPCODE_DCL && |
| 218 | instruction[i]->dst.type == Shader::PARAMETER_INPUT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 219 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 220 | int index = instruction[i]->dst.index; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 221 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 222 | input[index] = Semantic(instruction[i]->usage, instruction[i]->usageIndex); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 223 | } |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | void VertexShader::analyzeOutput() |
| 228 | { |
Alexis Hetu | 53ad4af | 2017-12-06 14:49:07 -0500 | [diff] [blame] | 229 | if(shaderModel < 0x0300) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 230 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 231 | output[Pos][0] = Semantic(Shader::USAGE_POSITION, 0); |
| 232 | output[Pos][1] = Semantic(Shader::USAGE_POSITION, 0); |
| 233 | output[Pos][2] = Semantic(Shader::USAGE_POSITION, 0); |
| 234 | output[Pos][3] = Semantic(Shader::USAGE_POSITION, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 235 | |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 236 | for(const auto &inst : instruction) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 237 | { |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 238 | const DestinationParameter &dst = inst->dst; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 239 | |
| 240 | switch(dst.type) |
| 241 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 242 | case Shader::PARAMETER_RASTOUT: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 243 | switch(dst.index) |
| 244 | { |
| 245 | case 0: |
| 246 | // Position already assumed written |
| 247 | break; |
| 248 | case 1: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 249 | output[Fog][0] = Semantic(Shader::USAGE_FOG, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 250 | break; |
| 251 | case 2: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 252 | output[Pts][1] = Semantic(Shader::USAGE_PSIZE, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 253 | pointSizeRegister = Pts; |
| 254 | break; |
| 255 | default: ASSERT(false); |
| 256 | } |
| 257 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 258 | case Shader::PARAMETER_ATTROUT: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 259 | if(dst.index == 0) |
| 260 | { |
Nicolas Capens | 995ddea | 2016-05-17 11:48:56 -0400 | [diff] [blame] | 261 | if(dst.x) output[C0][0] = Semantic(Shader::USAGE_COLOR, 0); |
| 262 | if(dst.y) output[C0][1] = Semantic(Shader::USAGE_COLOR, 0); |
| 263 | if(dst.z) output[C0][2] = Semantic(Shader::USAGE_COLOR, 0); |
| 264 | if(dst.w) output[C0][3] = Semantic(Shader::USAGE_COLOR, 0); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 265 | } |
| 266 | else if(dst.index == 1) |
| 267 | { |
Nicolas Capens | 995ddea | 2016-05-17 11:48:56 -0400 | [diff] [blame] | 268 | if(dst.x) output[C1][0] = Semantic(Shader::USAGE_COLOR, 1); |
| 269 | if(dst.y) output[C1][1] = Semantic(Shader::USAGE_COLOR, 1); |
| 270 | if(dst.z) output[C1][2] = Semantic(Shader::USAGE_COLOR, 1); |
| 271 | if(dst.w) output[C1][3] = Semantic(Shader::USAGE_COLOR, 1); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 272 | } |
| 273 | else ASSERT(false); |
| 274 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 275 | case Shader::PARAMETER_TEXCRDOUT: |
| 276 | if(dst.x) output[T0 + dst.index][0] = Semantic(Shader::USAGE_TEXCOORD, dst.index); |
| 277 | if(dst.y) output[T0 + dst.index][1] = Semantic(Shader::USAGE_TEXCOORD, dst.index); |
| 278 | if(dst.z) output[T0 + dst.index][2] = Semantic(Shader::USAGE_TEXCOORD, dst.index); |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 279 | if(dst.w) output[T0 + dst.index][3] = Semantic(Shader::USAGE_TEXCOORD, dst.index); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 280 | break; |
| 281 | default: |
| 282 | break; |
| 283 | } |
| 284 | } |
| 285 | } |
| 286 | else // Shader Model 3.0 input declaration |
| 287 | { |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 288 | for(const auto &inst : instruction) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 289 | { |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 290 | if(inst->opcode == Shader::OPCODE_DCL && |
| 291 | inst->dst.type == Shader::PARAMETER_OUTPUT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 292 | { |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 293 | unsigned char usage = inst->usage; |
| 294 | unsigned char usageIndex = inst->usageIndex; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 295 | |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 296 | const DestinationParameter &dst = inst->dst; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 297 | |
| 298 | if(dst.x) output[dst.index][0] = Semantic(usage, usageIndex); |
| 299 | if(dst.y) output[dst.index][1] = Semantic(usage, usageIndex); |
| 300 | if(dst.z) output[dst.index][2] = Semantic(usage, usageIndex); |
| 301 | if(dst.w) output[dst.index][3] = Semantic(usage, usageIndex); |
| 302 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 303 | if(usage == Shader::USAGE_POSITION && usageIndex == 0) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 304 | { |
| 305 | positionRegister = dst.index; |
| 306 | } |
| 307 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 308 | if(usage == Shader::USAGE_PSIZE && usageIndex == 0) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 309 | { |
| 310 | pointSizeRegister = dst.index; |
| 311 | } |
| 312 | } |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 317 | void VertexShader::analyzeTextureSampling() |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 318 | { |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 319 | textureSampling = false; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 320 | |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 321 | for(const auto &inst : instruction) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 322 | { |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 323 | if(inst->src[1].type == PARAMETER_SAMPLER) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 324 | { |
Nicolas Capens | 6abe1cb | 2016-01-15 23:30:50 -0500 | [diff] [blame] | 325 | textureSampling = true; |
Alexis Hetu | bf3fc25 | 2017-12-06 14:22:10 -0500 | [diff] [blame] | 326 | break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 327 | } |
| 328 | } |
| 329 | } |
| 330 | } |