John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1 | // SwiftShader Software Renderer |
| 2 | // |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -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 "VertexProgram.hpp" |
| 13 | |
| 14 | #include "Renderer.hpp" |
| 15 | #include "VertexShader.hpp" |
| 16 | #include "Vertex.hpp" |
| 17 | #include "Half.hpp" |
| 18 | #include "SamplerCore.hpp" |
| 19 | #include "Debug.hpp" |
| 20 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 21 | namespace sw |
| 22 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 23 | VertexProgram::VertexProgram(const VertexProcessor::State &state, const VertexShader *shader) : VertexRoutine(state, shader) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 24 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 25 | ifDepth = 0; |
| 26 | loopRepDepth = 0; |
| 27 | breakDepth = 0; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 28 | currentLabel = -1; |
| 29 | whileTest = false; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 30 | |
| 31 | for(int i = 0; i < 2048; i++) |
| 32 | { |
| 33 | labelBlock[i] = 0; |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | VertexProgram::~VertexProgram() |
| 38 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 39 | for(int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 40 | { |
| 41 | delete sampler[i]; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | void VertexProgram::pipeline(Registers &r) |
| 46 | { |
Alexis Hetu | 0b65c5e | 2015-03-31 11:48:57 -0400 | [diff] [blame] | 47 | for(int i = 0; i < VERTEX_TEXTURE_IMAGE_UNITS; i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 48 | { |
| 49 | sampler[i] = new SamplerCore(r.constants, state.samplerState[i]); |
| 50 | } |
| 51 | |
| 52 | if(!state.preTransformed) |
| 53 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 54 | program(r); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 55 | } |
| 56 | else |
| 57 | { |
| 58 | passThrough(r); |
| 59 | } |
| 60 | } |
| 61 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 62 | void VertexProgram::program(Registers &r) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 63 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 64 | // shader->print("VertexShader-%0.8X.txt", state.shaderID); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 65 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 66 | unsigned short version = shader->getVersion(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 67 | |
| 68 | r.enableIndex = 0; |
| 69 | r.stackIndex = 0; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 70 | |
Nicolas Capens | 4677a5f | 2014-05-06 16:42:26 -0400 | [diff] [blame] | 71 | if(shader->containsLeaveInstruction()) |
| 72 | { |
| 73 | r.enableLeave = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); |
| 74 | } |
| 75 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 76 | // Create all call site return blocks up front |
Alexis Hetu | 903e025 | 2014-11-25 14:25:32 -0500 | [diff] [blame] | 77 | for(size_t i = 0; i < shader->getLength(); i++) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 78 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 79 | const Shader::Instruction *instruction = shader->getInstruction(i); |
| 80 | Shader::Opcode opcode = instruction->opcode; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 81 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 82 | if(opcode == Shader::OPCODE_CALL || opcode == Shader::OPCODE_CALLNZ) |
| 83 | { |
| 84 | const Dst &dst = instruction->dst; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 85 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 86 | ASSERT(callRetBlock[dst.label].size() == dst.callSite); |
| 87 | callRetBlock[dst.label].push_back(Nucleus::createBasicBlock()); |
| 88 | } |
| 89 | } |
| 90 | |
Alexis Hetu | 903e025 | 2014-11-25 14:25:32 -0500 | [diff] [blame] | 91 | for(size_t i = 0; i < shader->getLength(); i++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 92 | { |
| 93 | const Shader::Instruction *instruction = shader->getInstruction(i); |
| 94 | Shader::Opcode opcode = instruction->opcode; |
| 95 | |
| 96 | if(opcode == Shader::OPCODE_DCL || opcode == Shader::OPCODE_DEF || opcode == Shader::OPCODE_DEFI || opcode == Shader::OPCODE_DEFB) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 97 | { |
| 98 | continue; |
| 99 | } |
| 100 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 101 | Dst dst = instruction->dst; |
| 102 | Src src0 = instruction->src[0]; |
| 103 | Src src1 = instruction->src[1]; |
| 104 | Src src2 = instruction->src[2]; |
Alexis Hetu | c3d95f3 | 2015-09-23 12:27:32 -0400 | [diff] [blame] | 105 | Src src3 = instruction->src[3]; |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 106 | Src src4 = instruction->src[4]; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 107 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 108 | bool predicate = instruction->predicate; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 109 | Control control = instruction->control; |
| 110 | bool integer = dst.type == Shader::PARAMETER_ADDR; |
| 111 | bool pp = dst.partialPrecision; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 112 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 113 | Vector4f d; |
| 114 | Vector4f s0; |
| 115 | Vector4f s1; |
| 116 | Vector4f s2; |
Alexis Hetu | c3d95f3 | 2015-09-23 12:27:32 -0400 | [diff] [blame] | 117 | Vector4f s3; |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 118 | Vector4f s4; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 119 | |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 120 | if(src0.type != Shader::PARAMETER_VOID) s0 = fetchRegisterF(r, src0); |
| 121 | if(src1.type != Shader::PARAMETER_VOID) s1 = fetchRegisterF(r, src1); |
| 122 | if(src2.type != Shader::PARAMETER_VOID) s2 = fetchRegisterF(r, src2); |
Alexis Hetu | c3d95f3 | 2015-09-23 12:27:32 -0400 | [diff] [blame] | 123 | if(src3.type != Shader::PARAMETER_VOID) s3 = fetchRegisterF(r, src3); |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 124 | if(src4.type != Shader::PARAMETER_VOID) s4 = fetchRegisterF(r, src4); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 125 | |
| 126 | switch(opcode) |
| 127 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 128 | case Shader::OPCODE_VS_1_0: break; |
| 129 | case Shader::OPCODE_VS_1_1: break; |
| 130 | case Shader::OPCODE_VS_2_0: break; |
| 131 | case Shader::OPCODE_VS_2_x: break; |
| 132 | case Shader::OPCODE_VS_2_sw: break; |
| 133 | case Shader::OPCODE_VS_3_0: break; |
| 134 | case Shader::OPCODE_VS_3_sw: break; |
| 135 | case Shader::OPCODE_DCL: break; |
| 136 | case Shader::OPCODE_DEF: break; |
| 137 | case Shader::OPCODE_DEFI: break; |
| 138 | case Shader::OPCODE_DEFB: break; |
| 139 | case Shader::OPCODE_NOP: break; |
| 140 | case Shader::OPCODE_ABS: abs(d, s0); break; |
| 141 | case Shader::OPCODE_ADD: add(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 142 | case Shader::OPCODE_IADD: iadd(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 143 | case Shader::OPCODE_CRS: crs(d, s0, s1); break; |
| 144 | case Shader::OPCODE_FORWARD1: forward1(d, s0, s1, s2); break; |
| 145 | case Shader::OPCODE_FORWARD2: forward2(d, s0, s1, s2); break; |
| 146 | case Shader::OPCODE_FORWARD3: forward3(d, s0, s1, s2); break; |
| 147 | case Shader::OPCODE_FORWARD4: forward4(d, s0, s1, s2); break; |
| 148 | case Shader::OPCODE_REFLECT1: reflect1(d, s0, s1); break; |
| 149 | case Shader::OPCODE_REFLECT2: reflect2(d, s0, s1); break; |
| 150 | case Shader::OPCODE_REFLECT3: reflect3(d, s0, s1); break; |
| 151 | case Shader::OPCODE_REFLECT4: reflect4(d, s0, s1); break; |
| 152 | case Shader::OPCODE_REFRACT1: refract1(d, s0, s1, s2.x); break; |
| 153 | case Shader::OPCODE_REFRACT2: refract2(d, s0, s1, s2.x); break; |
| 154 | case Shader::OPCODE_REFRACT3: refract3(d, s0, s1, s2.x); break; |
| 155 | case Shader::OPCODE_REFRACT4: refract4(d, s0, s1, s2.x); break; |
| 156 | case Shader::OPCODE_DP1: dp1(d, s0, s1); break; |
| 157 | case Shader::OPCODE_DP2: dp2(d, s0, s1); break; |
| 158 | case Shader::OPCODE_DP3: dp3(d, s0, s1); break; |
| 159 | case Shader::OPCODE_DP4: dp4(d, s0, s1); break; |
Alexis Hetu | c3d95f3 | 2015-09-23 12:27:32 -0400 | [diff] [blame] | 160 | case Shader::OPCODE_DET2: det2(d, s0, s1); break; |
| 161 | case Shader::OPCODE_DET3: det3(d, s0, s1, s2); break; |
| 162 | case Shader::OPCODE_DET4: det4(d, s0, s1, s2, s3); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 163 | case Shader::OPCODE_ATT: att(d, s0, s1); break; |
| 164 | case Shader::OPCODE_EXP2X: exp2x(d, s0, pp); break; |
| 165 | case Shader::OPCODE_EXP2: exp2(d, s0, pp); break; |
| 166 | case Shader::OPCODE_EXPP: expp(d, s0, version); break; |
| 167 | case Shader::OPCODE_EXP: exp(d, s0, pp); break; |
| 168 | case Shader::OPCODE_FRC: frc(d, s0); break; |
| 169 | case Shader::OPCODE_TRUNC: trunc(d, s0); break; |
| 170 | case Shader::OPCODE_FLOOR: floor(d, s0); break; |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 171 | case Shader::OPCODE_ROUND: round(d, s0); break; |
Alexis Hetu | 8e851c1 | 2015-06-04 11:30:54 -0400 | [diff] [blame] | 172 | case Shader::OPCODE_ROUNDEVEN: roundEven(d, s0); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 173 | case Shader::OPCODE_CEIL: ceil(d, s0); break; |
| 174 | case Shader::OPCODE_LIT: lit(d, s0); break; |
| 175 | case Shader::OPCODE_LOG2X: log2x(d, s0, pp); break; |
| 176 | case Shader::OPCODE_LOG2: log2(d, s0, pp); break; |
| 177 | case Shader::OPCODE_LOGP: logp(d, s0, version); break; |
| 178 | case Shader::OPCODE_LOG: log(d, s0, pp); break; |
| 179 | case Shader::OPCODE_LRP: lrp(d, s0, s1, s2); break; |
| 180 | case Shader::OPCODE_STEP: step(d, s0, s1); break; |
| 181 | case Shader::OPCODE_SMOOTH: smooth(d, s0, s1, s2); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 182 | case Shader::OPCODE_FLOATBITSTOINT: |
| 183 | case Shader::OPCODE_FLOATBITSTOUINT: |
| 184 | case Shader::OPCODE_INTBITSTOFLOAT: |
| 185 | case Shader::OPCODE_UINTBITSTOFLOAT: d = s0; break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 186 | case Shader::OPCODE_M3X2: M3X2(r, d, s0, src1); break; |
| 187 | case Shader::OPCODE_M3X3: M3X3(r, d, s0, src1); break; |
| 188 | case Shader::OPCODE_M3X4: M3X4(r, d, s0, src1); break; |
| 189 | case Shader::OPCODE_M4X3: M4X3(r, d, s0, src1); break; |
| 190 | case Shader::OPCODE_M4X4: M4X4(r, d, s0, src1); break; |
| 191 | case Shader::OPCODE_MAD: mad(d, s0, s1, s2); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 192 | case Shader::OPCODE_IMAD: imad(d, s0, s1, s2); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 193 | case Shader::OPCODE_MAX: max(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 194 | case Shader::OPCODE_IMAX: imax(d, s0, s1); break; |
| 195 | case Shader::OPCODE_UMAX: umax(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 196 | case Shader::OPCODE_MIN: min(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 197 | case Shader::OPCODE_IMIN: imin(d, s0, s1); break; |
| 198 | case Shader::OPCODE_UMIN: umin(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 199 | case Shader::OPCODE_MOV: mov(d, s0, integer); break; |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 200 | case Shader::OPCODE_MOVA: mov(d, s0, true); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 201 | case Shader::OPCODE_NEG: neg(d, s0); break; |
| 202 | case Shader::OPCODE_INEG: ineg(d, s0); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 203 | case Shader::OPCODE_F2B: f2b(d, s0); break; |
| 204 | case Shader::OPCODE_B2F: b2f(d, s0); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 205 | case Shader::OPCODE_F2I: f2i(d, s0); break; |
| 206 | case Shader::OPCODE_I2F: i2f(d, s0); break; |
| 207 | case Shader::OPCODE_F2U: f2u(d, s0); break; |
| 208 | case Shader::OPCODE_U2F: u2f(d, s0); break; |
| 209 | case Shader::OPCODE_I2B: i2b(d, s0); break; |
| 210 | case Shader::OPCODE_B2I: b2i(d, s0); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 211 | case Shader::OPCODE_MUL: mul(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 212 | case Shader::OPCODE_IMUL: imul(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 213 | case Shader::OPCODE_NRM2: nrm2(d, s0, pp); break; |
| 214 | case Shader::OPCODE_NRM3: nrm3(d, s0, pp); break; |
| 215 | case Shader::OPCODE_NRM4: nrm4(d, s0, pp); break; |
| 216 | case Shader::OPCODE_POWX: powx(d, s0, s1, pp); break; |
| 217 | case Shader::OPCODE_POW: pow(d, s0, s1, pp); break; |
| 218 | case Shader::OPCODE_RCPX: rcpx(d, s0, pp); break; |
| 219 | case Shader::OPCODE_DIV: div(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 220 | case Shader::OPCODE_IDIV: idiv(d, s0, s1); break; |
| 221 | case Shader::OPCODE_UDIV: udiv(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 222 | case Shader::OPCODE_MOD: mod(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 223 | case Shader::OPCODE_IMOD: imod(d, s0, s1); break; |
| 224 | case Shader::OPCODE_UMOD: umod(d, s0, s1); break; |
| 225 | case Shader::OPCODE_SHL: shl(d, s0, s1); break; |
| 226 | case Shader::OPCODE_ISHR: ishr(d, s0, s1); break; |
| 227 | case Shader::OPCODE_USHR: ushr(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 228 | case Shader::OPCODE_RSQX: rsqx(d, s0, pp); break; |
| 229 | case Shader::OPCODE_SQRT: sqrt(d, s0, pp); break; |
| 230 | case Shader::OPCODE_RSQ: rsq(d, s0, pp); break; |
| 231 | case Shader::OPCODE_LEN2: len2(d.x, s0, pp); break; |
| 232 | case Shader::OPCODE_LEN3: len3(d.x, s0, pp); break; |
| 233 | case Shader::OPCODE_LEN4: len4(d.x, s0, pp); break; |
| 234 | case Shader::OPCODE_DIST1: dist1(d.x, s0, s1, pp); break; |
| 235 | case Shader::OPCODE_DIST2: dist2(d.x, s0, s1, pp); break; |
| 236 | case Shader::OPCODE_DIST3: dist3(d.x, s0, s1, pp); break; |
| 237 | case Shader::OPCODE_DIST4: dist4(d.x, s0, s1, pp); break; |
| 238 | case Shader::OPCODE_SGE: step(d, s1, s0); break; |
| 239 | case Shader::OPCODE_SGN: sgn(d, s0); break; |
| 240 | case Shader::OPCODE_SINCOS: sincos(d, s0, pp); break; |
| 241 | case Shader::OPCODE_COS: cos(d, s0, pp); break; |
| 242 | case Shader::OPCODE_SIN: sin(d, s0, pp); break; |
| 243 | case Shader::OPCODE_TAN: tan(d, s0); break; |
| 244 | case Shader::OPCODE_ACOS: acos(d, s0); break; |
| 245 | case Shader::OPCODE_ASIN: asin(d, s0); break; |
| 246 | case Shader::OPCODE_ATAN: atan(d, s0); break; |
| 247 | case Shader::OPCODE_ATAN2: atan2(d, s0, s1); break; |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 248 | case Shader::OPCODE_COSH: cosh(d, s0, pp); break; |
| 249 | case Shader::OPCODE_SINH: sinh(d, s0, pp); break; |
| 250 | case Shader::OPCODE_TANH: tanh(d, s0, pp); break; |
| 251 | case Shader::OPCODE_ACOSH: acosh(d, s0, pp); break; |
| 252 | case Shader::OPCODE_ASINH: asinh(d, s0, pp); break; |
| 253 | case Shader::OPCODE_ATANH: atanh(d, s0, pp); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 254 | case Shader::OPCODE_SLT: slt(d, s0, s1); break; |
| 255 | case Shader::OPCODE_SUB: sub(d, s0, s1); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 256 | case Shader::OPCODE_ISUB: isub(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 257 | case Shader::OPCODE_BREAK: BREAK(r); break; |
| 258 | case Shader::OPCODE_BREAKC: BREAKC(r, s0, s1, control); break; |
| 259 | case Shader::OPCODE_BREAKP: BREAKP(r, src0); break; |
| 260 | case Shader::OPCODE_CONTINUE: CONTINUE(r); break; |
| 261 | case Shader::OPCODE_TEST: TEST(); break; |
| 262 | case Shader::OPCODE_CALL: CALL(r, dst.label, dst.callSite); break; |
| 263 | case Shader::OPCODE_CALLNZ: CALLNZ(r, dst.label, dst.callSite, src0); break; |
| 264 | case Shader::OPCODE_ELSE: ELSE(r); break; |
| 265 | case Shader::OPCODE_ENDIF: ENDIF(r); break; |
| 266 | case Shader::OPCODE_ENDLOOP: ENDLOOP(r); break; |
| 267 | case Shader::OPCODE_ENDREP: ENDREP(r); break; |
| 268 | case Shader::OPCODE_ENDWHILE: ENDWHILE(r); break; |
| 269 | case Shader::OPCODE_IF: IF(r, src0); break; |
| 270 | case Shader::OPCODE_IFC: IFC(r, s0, s1, control); break; |
| 271 | case Shader::OPCODE_LABEL: LABEL(dst.index); break; |
| 272 | case Shader::OPCODE_LOOP: LOOP(r, src1); break; |
| 273 | case Shader::OPCODE_REP: REP(r, src0); break; |
| 274 | case Shader::OPCODE_WHILE: WHILE(r, src0); break; |
| 275 | case Shader::OPCODE_RET: RET(r); break; |
| 276 | case Shader::OPCODE_LEAVE: LEAVE(r); break; |
| 277 | case Shader::OPCODE_CMP: cmp(d, s0, s1, control); break; |
| 278 | case Shader::OPCODE_ICMP: icmp(d, s0, s1, control); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 279 | case Shader::OPCODE_UCMP: ucmp(d, s0, s1, control); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 280 | case Shader::OPCODE_SELECT: select(d, s0, s1, s2); break; |
| 281 | case Shader::OPCODE_EXTRACT: extract(d.x, s0, s1.x); break; |
| 282 | case Shader::OPCODE_INSERT: insert(d, s0, s1.x, s2.x); break; |
| 283 | case Shader::OPCODE_ALL: all(d.x, s0); break; |
| 284 | case Shader::OPCODE_ANY: any(d.x, s0); break; |
| 285 | case Shader::OPCODE_NOT: not(d, s0); break; |
Alexis Hetu | 8d78cf7 | 2015-08-28 14:24:45 -0400 | [diff] [blame] | 286 | case Shader::OPCODE_OR: or(d, s0, s1); break; |
| 287 | case Shader::OPCODE_XOR: xor(d, s0, s1); break; |
| 288 | case Shader::OPCODE_AND: and(d, s0, s1); break; |
| 289 | case Shader::OPCODE_EQ: equal(d, s0, s1); break; |
| 290 | case Shader::OPCODE_NE: notEqual(d, s0, s1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 291 | case Shader::OPCODE_TEXLDL: TEXLDL(r, d, s0, src1); break; |
| 292 | case Shader::OPCODE_TEX: TEX(r, d, s0, src1); break; |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 293 | case Shader::OPCODE_TEXOFFSET: TEXOFFSET(r, d, s0, src1, s2, s3); break; |
| 294 | case Shader::OPCODE_TEXLDLOFFSET: TEXLDL(r, d, s0, src1, s2); break; |
| 295 | case Shader::OPCODE_TEXELFETCH: TEXELFETCH(r, d, s0, src1, s2); break; |
| 296 | case Shader::OPCODE_TEXELFETCHOFFSET: TEXELFETCH(r, d, s0, src1, s2, s3); break; |
| 297 | case Shader::OPCODE_TEXGRAD: TEXGRAD(r, d, s0, src1, s2, s3); break; |
| 298 | case Shader::OPCODE_TEXGRADOFFSET: TEXGRAD(r, d, s0, src1, s2, s3, s4); break; |
Alexis Hetu | 9bcb31d | 2015-07-22 17:03:26 -0400 | [diff] [blame] | 299 | case Shader::OPCODE_TEXSIZE: TEXSIZE(r, d, s0.x, src1); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 300 | case Shader::OPCODE_END: break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 301 | default: |
| 302 | ASSERT(false); |
| 303 | } |
| 304 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 305 | if(dst.type != Shader::PARAMETER_VOID && dst.type != Shader::PARAMETER_LABEL && opcode != Shader::OPCODE_NOP) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 306 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 307 | if(dst.integer) |
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 | switch(opcode) |
| 310 | { |
| 311 | case Shader::OPCODE_DIV: |
| 312 | if(dst.x) d.x = Trunc(d.x); |
| 313 | if(dst.y) d.y = Trunc(d.y); |
| 314 | if(dst.z) d.z = Trunc(d.z); |
| 315 | if(dst.w) d.w = Trunc(d.w); |
| 316 | break; |
| 317 | default: |
| 318 | break; // No truncation to integer required when arguments are integer |
| 319 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 320 | } |
| 321 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 322 | if(dst.saturate) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 323 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 324 | if(dst.x) d.x = Max(d.x, Float4(0.0f)); |
| 325 | if(dst.y) d.y = Max(d.y, Float4(0.0f)); |
| 326 | if(dst.z) d.z = Max(d.z, Float4(0.0f)); |
| 327 | if(dst.w) d.w = Max(d.w, Float4(0.0f)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 328 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 329 | if(dst.x) d.x = Min(d.x, Float4(1.0f)); |
| 330 | if(dst.y) d.y = Min(d.y, Float4(1.0f)); |
| 331 | if(dst.z) d.z = Min(d.z, Float4(1.0f)); |
| 332 | if(dst.w) d.w = Min(d.w, Float4(1.0f)); |
| 333 | } |
| 334 | |
Nicolas Capens | c6e8ab1 | 2014-05-06 23:31:07 -0400 | [diff] [blame] | 335 | if(instruction->isPredicated()) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 336 | { |
| 337 | Vector4f pDst; // FIXME: Rename |
| 338 | |
| 339 | switch(dst.type) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 340 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 341 | case Shader::PARAMETER_VOID: break; |
| 342 | case Shader::PARAMETER_TEMP: |
| 343 | if(dst.rel.type == Shader::PARAMETER_VOID) |
| 344 | { |
| 345 | if(dst.x) pDst.x = r.r[dst.index].x; |
| 346 | if(dst.y) pDst.y = r.r[dst.index].y; |
| 347 | if(dst.z) pDst.z = r.r[dst.index].z; |
| 348 | if(dst.w) pDst.w = r.r[dst.index].w; |
| 349 | } |
| 350 | else |
| 351 | { |
| 352 | Int a = relativeAddress(r, dst); |
| 353 | |
| 354 | if(dst.x) pDst.x = r.r[dst.index + a].x; |
| 355 | if(dst.y) pDst.y = r.r[dst.index + a].y; |
| 356 | if(dst.z) pDst.z = r.r[dst.index + a].z; |
| 357 | if(dst.w) pDst.w = r.r[dst.index + a].w; |
| 358 | } |
| 359 | break; |
| 360 | case Shader::PARAMETER_ADDR: pDst = r.a0; break; |
| 361 | case Shader::PARAMETER_RASTOUT: |
| 362 | switch(dst.index) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 363 | { |
| 364 | case 0: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 365 | if(dst.x) pDst.x = r.o[Pos].x; |
| 366 | if(dst.y) pDst.y = r.o[Pos].y; |
| 367 | if(dst.z) pDst.z = r.o[Pos].z; |
| 368 | if(dst.w) pDst.w = r.o[Pos].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 369 | break; |
| 370 | case 1: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 371 | pDst.x = r.o[Fog].x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 372 | break; |
| 373 | case 2: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 374 | pDst.x = r.o[Pts].y; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 375 | break; |
| 376 | default: |
| 377 | ASSERT(false); |
| 378 | } |
| 379 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 380 | case Shader::PARAMETER_ATTROUT: |
| 381 | if(dst.x) pDst.x = r.o[D0 + dst.index].x; |
| 382 | if(dst.y) pDst.y = r.o[D0 + dst.index].y; |
| 383 | if(dst.z) pDst.z = r.o[D0 + dst.index].z; |
| 384 | if(dst.w) pDst.w = r.o[D0 + dst.index].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 385 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 386 | case Shader::PARAMETER_TEXCRDOUT: |
| 387 | // case Shader::PARAMETER_OUTPUT: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 388 | if(version < 0x0300) |
| 389 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 390 | if(dst.x) pDst.x = r.o[T0 + dst.index].x; |
| 391 | if(dst.y) pDst.y = r.o[T0 + dst.index].y; |
| 392 | if(dst.z) pDst.z = r.o[T0 + dst.index].z; |
| 393 | if(dst.w) pDst.w = r.o[T0 + dst.index].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 394 | } |
| 395 | else |
| 396 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 397 | if(dst.rel.type == Shader::PARAMETER_VOID) // Not relative |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 398 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 399 | if(dst.x) pDst.x = r.o[dst.index].x; |
| 400 | if(dst.y) pDst.y = r.o[dst.index].y; |
| 401 | if(dst.z) pDst.z = r.o[dst.index].z; |
| 402 | if(dst.w) pDst.w = r.o[dst.index].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 403 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 404 | else if(dst.rel.type == Shader::PARAMETER_LOOP) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 405 | { |
| 406 | Int aL = r.aL[r.loopDepth]; |
| 407 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 408 | if(dst.x) pDst.x = r.o[dst.index + aL].x; |
| 409 | if(dst.y) pDst.y = r.o[dst.index + aL].y; |
| 410 | if(dst.z) pDst.z = r.o[dst.index + aL].z; |
| 411 | if(dst.w) pDst.w = r.o[dst.index + aL].w; |
| 412 | } |
| 413 | else |
| 414 | { |
| 415 | Int a = relativeAddress(r, dst); |
| 416 | |
| 417 | if(dst.x) pDst.x = r.o[dst.index + a].x; |
| 418 | if(dst.y) pDst.y = r.o[dst.index + a].y; |
| 419 | if(dst.z) pDst.z = r.o[dst.index + a].z; |
| 420 | if(dst.w) pDst.w = r.o[dst.index + a].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 421 | } |
| 422 | } |
| 423 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 424 | case Shader::PARAMETER_LABEL: break; |
| 425 | case Shader::PARAMETER_PREDICATE: pDst = r.p0; break; |
| 426 | case Shader::PARAMETER_INPUT: break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 427 | default: |
| 428 | ASSERT(false); |
| 429 | } |
| 430 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 431 | Int4 enable = enableMask(r, instruction); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 432 | |
| 433 | Int4 xEnable = enable; |
| 434 | Int4 yEnable = enable; |
| 435 | Int4 zEnable = enable; |
| 436 | Int4 wEnable = enable; |
| 437 | |
| 438 | if(predicate) |
| 439 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 440 | unsigned char pSwizzle = instruction->predicateSwizzle; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 441 | |
| 442 | Float4 xPredicate = r.p0[(pSwizzle >> 0) & 0x03]; |
| 443 | Float4 yPredicate = r.p0[(pSwizzle >> 2) & 0x03]; |
| 444 | Float4 zPredicate = r.p0[(pSwizzle >> 4) & 0x03]; |
| 445 | Float4 wPredicate = r.p0[(pSwizzle >> 6) & 0x03]; |
| 446 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 447 | if(!instruction->predicateNot) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 448 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 449 | if(dst.x) xEnable = xEnable & As<Int4>(xPredicate); |
| 450 | if(dst.y) yEnable = yEnable & As<Int4>(yPredicate); |
| 451 | if(dst.z) zEnable = zEnable & As<Int4>(zPredicate); |
| 452 | if(dst.w) wEnable = wEnable & As<Int4>(wPredicate); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 453 | } |
| 454 | else |
| 455 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 456 | if(dst.x) xEnable = xEnable & ~As<Int4>(xPredicate); |
| 457 | if(dst.y) yEnable = yEnable & ~As<Int4>(yPredicate); |
| 458 | if(dst.z) zEnable = zEnable & ~As<Int4>(zPredicate); |
| 459 | if(dst.w) wEnable = wEnable & ~As<Int4>(wPredicate); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 460 | } |
| 461 | } |
| 462 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 463 | if(dst.x) d.x = As<Float4>(As<Int4>(d.x) & xEnable); |
| 464 | if(dst.y) d.y = As<Float4>(As<Int4>(d.y) & yEnable); |
| 465 | if(dst.z) d.z = As<Float4>(As<Int4>(d.z) & zEnable); |
| 466 | if(dst.w) d.w = As<Float4>(As<Int4>(d.w) & wEnable); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 467 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 468 | if(dst.x) d.x = As<Float4>(As<Int4>(d.x) | (As<Int4>(pDst.x) & ~xEnable)); |
| 469 | if(dst.y) d.y = As<Float4>(As<Int4>(d.y) | (As<Int4>(pDst.y) & ~yEnable)); |
| 470 | if(dst.z) d.z = As<Float4>(As<Int4>(d.z) | (As<Int4>(pDst.z) & ~zEnable)); |
| 471 | if(dst.w) d.w = As<Float4>(As<Int4>(d.w) | (As<Int4>(pDst.w) & ~wEnable)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 472 | } |
| 473 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 474 | switch(dst.type) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 475 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 476 | case Shader::PARAMETER_VOID: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 477 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 478 | case Shader::PARAMETER_TEMP: |
| 479 | if(dst.rel.type == Shader::PARAMETER_VOID) |
| 480 | { |
| 481 | if(dst.x) r.r[dst.index].x = d.x; |
| 482 | if(dst.y) r.r[dst.index].y = d.y; |
| 483 | if(dst.z) r.r[dst.index].z = d.z; |
| 484 | if(dst.w) r.r[dst.index].w = d.w; |
| 485 | } |
| 486 | else |
| 487 | { |
| 488 | Int a = relativeAddress(r, dst); |
| 489 | |
| 490 | if(dst.x) r.r[dst.index + a].x = d.x; |
| 491 | if(dst.y) r.r[dst.index + a].y = d.y; |
| 492 | if(dst.z) r.r[dst.index + a].z = d.z; |
| 493 | if(dst.w) r.r[dst.index + a].w = d.w; |
| 494 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 495 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 496 | case Shader::PARAMETER_ADDR: |
| 497 | if(dst.x) r.a0.x = d.x; |
| 498 | if(dst.y) r.a0.y = d.y; |
| 499 | if(dst.z) r.a0.z = d.z; |
| 500 | if(dst.w) r.a0.w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 501 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 502 | case Shader::PARAMETER_RASTOUT: |
| 503 | switch(dst.index) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 504 | { |
| 505 | case 0: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 506 | if(dst.x) r.o[Pos].x = d.x; |
| 507 | if(dst.y) r.o[Pos].y = d.y; |
| 508 | if(dst.z) r.o[Pos].z = d.z; |
| 509 | if(dst.w) r.o[Pos].w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 510 | break; |
| 511 | case 1: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 512 | r.o[Fog].x = d.x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 513 | break; |
| 514 | case 2: |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 515 | r.o[Pts].y = d.x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 516 | break; |
| 517 | default: ASSERT(false); |
| 518 | } |
| 519 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 520 | case Shader::PARAMETER_ATTROUT: |
| 521 | if(dst.x) r.o[D0 + dst.index].x = d.x; |
| 522 | if(dst.y) r.o[D0 + dst.index].y = d.y; |
| 523 | if(dst.z) r.o[D0 + dst.index].z = d.z; |
| 524 | if(dst.w) r.o[D0 + dst.index].w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 525 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 526 | case Shader::PARAMETER_TEXCRDOUT: |
| 527 | // case Shader::PARAMETER_OUTPUT: |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 528 | if(version < 0x0300) |
| 529 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 530 | if(dst.x) r.o[T0 + dst.index].x = d.x; |
| 531 | if(dst.y) r.o[T0 + dst.index].y = d.y; |
| 532 | if(dst.z) r.o[T0 + dst.index].z = d.z; |
| 533 | if(dst.w) r.o[T0 + dst.index].w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 534 | } |
| 535 | else |
| 536 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 537 | if(dst.rel.type == Shader::PARAMETER_VOID) // Not relative |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 538 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 539 | if(dst.x) r.o[dst.index].x = d.x; |
| 540 | if(dst.y) r.o[dst.index].y = d.y; |
| 541 | if(dst.z) r.o[dst.index].z = d.z; |
| 542 | if(dst.w) r.o[dst.index].w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 543 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 544 | else if(dst.rel.type == Shader::PARAMETER_LOOP) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 545 | { |
| 546 | Int aL = r.aL[r.loopDepth]; |
| 547 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 548 | if(dst.x) r.o[dst.index + aL].x = d.x; |
| 549 | if(dst.y) r.o[dst.index + aL].y = d.y; |
| 550 | if(dst.z) r.o[dst.index + aL].z = d.z; |
| 551 | if(dst.w) r.o[dst.index + aL].w = d.w; |
| 552 | } |
| 553 | else |
| 554 | { |
| 555 | Int a = relativeAddress(r, dst); |
| 556 | |
| 557 | if(dst.x) r.o[dst.index + a].x = d.x; |
| 558 | if(dst.y) r.o[dst.index + a].y = d.y; |
| 559 | if(dst.z) r.o[dst.index + a].z = d.z; |
| 560 | if(dst.w) r.o[dst.index + a].w = d.w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 561 | } |
| 562 | } |
| 563 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 564 | case Shader::PARAMETER_LABEL: break; |
| 565 | case Shader::PARAMETER_PREDICATE: r.p0 = d; break; |
| 566 | case Shader::PARAMETER_INPUT: break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 567 | default: |
| 568 | ASSERT(false); |
| 569 | } |
| 570 | } |
| 571 | } |
| 572 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 573 | if(currentLabel != -1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 574 | { |
| 575 | Nucleus::setInsertBlock(returnBlock); |
| 576 | } |
| 577 | } |
| 578 | |
| 579 | void VertexProgram::passThrough(Registers &r) |
| 580 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 581 | if(shader) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 582 | { |
| 583 | for(int i = 0; i < 12; i++) |
| 584 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 585 | unsigned char usage = shader->output[i][0].usage; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 586 | |
| 587 | switch(usage) |
| 588 | { |
| 589 | case 0xFF: |
| 590 | continue; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 591 | case Shader::USAGE_PSIZE: |
| 592 | r.o[i].y = r.v[i].x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 593 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 594 | case Shader::USAGE_TEXCOORD: |
| 595 | r.o[i].x = r.v[i].x; |
| 596 | r.o[i].y = r.v[i].y; |
| 597 | r.o[i].z = r.v[i].z; |
| 598 | r.o[i].w = r.v[i].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 599 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 600 | case Shader::USAGE_POSITION: |
| 601 | r.o[i].x = r.v[i].x; |
| 602 | r.o[i].y = r.v[i].y; |
| 603 | r.o[i].z = r.v[i].z; |
| 604 | r.o[i].w = r.v[i].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 605 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 606 | case Shader::USAGE_COLOR: |
| 607 | r.o[i].x = r.v[i].x; |
| 608 | r.o[i].y = r.v[i].y; |
| 609 | r.o[i].z = r.v[i].z; |
| 610 | r.o[i].w = r.v[i].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 611 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 612 | case Shader::USAGE_FOG: |
| 613 | r.o[i].x = r.v[i].x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 614 | break; |
| 615 | default: |
| 616 | ASSERT(false); |
| 617 | } |
| 618 | } |
| 619 | } |
| 620 | else |
| 621 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 622 | r.o[Pos].x = r.v[PositionT].x; |
| 623 | r.o[Pos].y = r.v[PositionT].y; |
| 624 | r.o[Pos].z = r.v[PositionT].z; |
| 625 | r.o[Pos].w = r.v[PositionT].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 626 | |
| 627 | for(int i = 0; i < 2; i++) |
| 628 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 629 | r.o[D0 + i].x = r.v[Color0 + i].x; |
| 630 | r.o[D0 + i].y = r.v[Color0 + i].y; |
| 631 | r.o[D0 + i].z = r.v[Color0 + i].z; |
| 632 | r.o[D0 + i].w = r.v[Color0 + i].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | for(int i = 0; i < 8; i++) |
| 636 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 637 | r.o[T0 + i].x = r.v[TexCoord0 + i].x; |
| 638 | r.o[T0 + i].y = r.v[TexCoord0 + i].y; |
| 639 | r.o[T0 + i].z = r.v[TexCoord0 + i].z; |
| 640 | r.o[T0 + i].w = r.v[TexCoord0 + i].w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 641 | } |
| 642 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 643 | r.o[Pts].y = r.v[PointSize].x; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 644 | } |
| 645 | } |
| 646 | |
Nicolas Capens | 5d96188 | 2016-01-01 23:18:14 -0500 | [diff] [blame] | 647 | Vector4f VertexProgram::fetchRegisterF(Registers &r, const Src &src, unsigned int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 648 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 649 | Vector4f reg; |
Nicolas Capens | 5d96188 | 2016-01-01 23:18:14 -0500 | [diff] [blame] | 650 | unsigned int i = src.index + offset; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 651 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 652 | switch(src.type) |
| 653 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 654 | case Shader::PARAMETER_TEMP: |
| 655 | if(src.rel.type == Shader::PARAMETER_VOID) |
| 656 | { |
| 657 | reg = r.r[i]; |
| 658 | } |
| 659 | else |
| 660 | { |
| 661 | reg = r.r[i + relativeAddress(r, src)]; |
| 662 | } |
| 663 | break; |
| 664 | case Shader::PARAMETER_CONST: |
| 665 | reg = readConstant(r, src, offset); |
| 666 | break; |
| 667 | case Shader::PARAMETER_INPUT: |
| 668 | if(src.rel.type == Shader::PARAMETER_VOID) |
| 669 | { |
| 670 | reg = r.v[i]; |
| 671 | } |
| 672 | else |
| 673 | { |
| 674 | reg = r.v[i + relativeAddress(r, src)]; |
| 675 | } |
| 676 | break; |
| 677 | case Shader::PARAMETER_VOID: return r.r[0]; // Dummy |
| 678 | case Shader::PARAMETER_FLOAT4LITERAL: |
| 679 | reg.x = Float4(src.value[0]); |
| 680 | reg.y = Float4(src.value[1]); |
| 681 | reg.z = Float4(src.value[2]); |
| 682 | reg.w = Float4(src.value[3]); |
| 683 | break; |
| 684 | case Shader::PARAMETER_ADDR: reg = r.a0; break; |
| 685 | case Shader::PARAMETER_CONSTBOOL: return r.r[0]; // Dummy |
| 686 | case Shader::PARAMETER_CONSTINT: return r.r[0]; // Dummy |
| 687 | case Shader::PARAMETER_LOOP: return r.r[0]; // Dummy |
| 688 | case Shader::PARAMETER_PREDICATE: return r.r[0]; // Dummy |
| 689 | case Shader::PARAMETER_SAMPLER: |
| 690 | if(src.rel.type == Shader::PARAMETER_VOID) |
| 691 | { |
| 692 | reg.x = As<Float4>(Int4(i)); |
| 693 | } |
| 694 | else if(src.rel.type == Shader::PARAMETER_TEMP) |
| 695 | { |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 696 | reg.x = As<Float4>(Int4(i) + As<Int4>(r.r[src.rel.index].x)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 697 | } |
| 698 | return reg; |
| 699 | case Shader::PARAMETER_OUTPUT: |
| 700 | if(src.rel.type == Shader::PARAMETER_VOID) |
| 701 | { |
| 702 | reg = r.o[i]; |
| 703 | } |
| 704 | else |
| 705 | { |
| 706 | reg = r.o[i + relativeAddress(r, src)]; |
| 707 | } |
| 708 | break; |
Alexis Hetu | dd8df68 | 2015-06-05 17:08:39 -0400 | [diff] [blame] | 709 | case Shader::PARAMETER_MISCTYPE: |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 710 | reg.x = As<Float>(Int(r.instanceID)); |
Alexis Hetu | dd8df68 | 2015-06-05 17:08:39 -0400 | [diff] [blame] | 711 | return reg; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 712 | default: |
| 713 | ASSERT(false); |
| 714 | } |
| 715 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 716 | const Float4 &x = reg[(src.swizzle >> 0) & 0x3]; |
| 717 | const Float4 &y = reg[(src.swizzle >> 2) & 0x3]; |
| 718 | const Float4 &z = reg[(src.swizzle >> 4) & 0x3]; |
| 719 | const Float4 &w = reg[(src.swizzle >> 6) & 0x3]; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 720 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 721 | Vector4f mod; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 722 | |
| 723 | switch(src.modifier) |
| 724 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 725 | case Shader::MODIFIER_NONE: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 726 | mod.x = x; |
| 727 | mod.y = y; |
| 728 | mod.z = z; |
| 729 | mod.w = w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 730 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 731 | case Shader::MODIFIER_NEGATE: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 732 | mod.x = -x; |
| 733 | mod.y = -y; |
| 734 | mod.z = -z; |
| 735 | mod.w = -w; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 736 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 737 | case Shader::MODIFIER_ABS: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 738 | mod.x = Abs(x); |
| 739 | mod.y = Abs(y); |
| 740 | mod.z = Abs(z); |
| 741 | mod.w = Abs(w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 742 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 743 | case Shader::MODIFIER_ABS_NEGATE: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 744 | mod.x = -Abs(x); |
| 745 | mod.y = -Abs(y); |
| 746 | mod.z = -Abs(z); |
| 747 | mod.w = -Abs(w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 748 | break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 749 | case Shader::MODIFIER_NOT: |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 750 | mod.x = As<Float4>(As<Int4>(x) ^ Int4(0xFFFFFFFF)); |
| 751 | mod.y = As<Float4>(As<Int4>(y) ^ Int4(0xFFFFFFFF)); |
| 752 | mod.z = As<Float4>(As<Int4>(z) ^ Int4(0xFFFFFFFF)); |
| 753 | mod.w = As<Float4>(As<Int4>(w) ^ Int4(0xFFFFFFFF)); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 754 | break; |
| 755 | default: |
| 756 | ASSERT(false); |
| 757 | } |
| 758 | |
| 759 | return mod; |
| 760 | } |
| 761 | |
Nicolas Capens | 5d96188 | 2016-01-01 23:18:14 -0500 | [diff] [blame] | 762 | Vector4f VertexProgram::readConstant(Registers &r, const Src &src, unsigned int offset) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 763 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 764 | Vector4f c; |
Nicolas Capens | 5d96188 | 2016-01-01 23:18:14 -0500 | [diff] [blame] | 765 | unsigned int i = src.index + offset; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 766 | |
| 767 | if(src.rel.type == Shader::PARAMETER_VOID) // Not relative |
| 768 | { |
| 769 | c.x = c.y = c.z = c.w = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c[i])); |
| 770 | |
| 771 | c.x = c.x.xxxx; |
| 772 | c.y = c.y.yyyy; |
| 773 | c.z = c.z.zzzz; |
| 774 | c.w = c.w.wwww; |
| 775 | |
Nicolas Capens | eafdb22 | 2015-05-15 15:24:08 -0400 | [diff] [blame] | 776 | if(shader->containsDefineInstruction()) // Constant may be known at compile time |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 777 | { |
Alexis Hetu | 903e025 | 2014-11-25 14:25:32 -0500 | [diff] [blame] | 778 | for(size_t j = 0; j < shader->getLength(); j++) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 779 | { |
| 780 | const Shader::Instruction &instruction = *shader->getInstruction(j); |
| 781 | |
| 782 | if(instruction.opcode == Shader::OPCODE_DEF) |
| 783 | { |
| 784 | if(instruction.dst.index == i) |
| 785 | { |
| 786 | c.x = Float4(instruction.src[0].value[0]); |
| 787 | c.y = Float4(instruction.src[0].value[1]); |
| 788 | c.z = Float4(instruction.src[0].value[2]); |
| 789 | c.w = Float4(instruction.src[0].value[3]); |
| 790 | |
| 791 | break; |
| 792 | } |
| 793 | } |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | else if(src.rel.type == Shader::PARAMETER_LOOP) |
| 798 | { |
| 799 | Int loopCounter = r.aL[r.loopDepth]; |
| 800 | |
| 801 | c.x = c.y = c.z = c.w = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c[i]) + loopCounter * 16); |
| 802 | |
| 803 | c.x = c.x.xxxx; |
| 804 | c.y = c.y.yyyy; |
| 805 | c.z = c.z.zzzz; |
| 806 | c.w = c.w.wwww; |
| 807 | } |
| 808 | else |
| 809 | { |
| 810 | if(src.rel.deterministic) |
| 811 | { |
| 812 | Int a = relativeAddress(r, src); |
| 813 | |
| 814 | c.x = c.y = c.z = c.w = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c[i]) + a * 16); |
| 815 | |
| 816 | c.x = c.x.xxxx; |
| 817 | c.y = c.y.yyyy; |
| 818 | c.z = c.z.zzzz; |
| 819 | c.w = c.w.wwww; |
| 820 | } |
| 821 | else |
| 822 | { |
| 823 | int component = src.rel.swizzle & 0x03; |
| 824 | Float4 a; |
| 825 | |
| 826 | switch(src.rel.type) |
| 827 | { |
| 828 | case Shader::PARAMETER_ADDR: a = r.a0[component]; break; |
| 829 | case Shader::PARAMETER_TEMP: a = r.r[src.rel.index][component]; break; |
| 830 | case Shader::PARAMETER_INPUT: a = r.v[src.rel.index][component]; break; |
| 831 | case Shader::PARAMETER_OUTPUT: a = r.o[src.rel.index][component]; break; |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 832 | case Shader::PARAMETER_CONST: a = *Pointer<Float>(r.data + OFFSET(DrawData,vs.c[src.rel.index][component])); break; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 833 | default: ASSERT(false); |
| 834 | } |
| 835 | |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 836 | Int4 index = Int4(i) + As<Int4>(a) * Int4(src.rel.scale); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 837 | |
Alexis Hetu | 028f41b | 2016-01-13 14:40:47 -0500 | [diff] [blame] | 838 | index = Min(As<UInt4>(index), UInt4(VERTEX_UNIFORM_VECTORS)); // Clamp to constant register range, c[VERTEX_UNIFORM_VECTORS] = {0, 0, 0, 0} |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 839 | |
| 840 | Int index0 = Extract(index, 0); |
| 841 | Int index1 = Extract(index, 1); |
| 842 | Int index2 = Extract(index, 2); |
| 843 | Int index3 = Extract(index, 3); |
| 844 | |
| 845 | c.x = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c) + index0 * 16, 16); |
| 846 | c.y = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c) + index1 * 16, 16); |
| 847 | c.z = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c) + index2 * 16, 16); |
| 848 | c.w = *Pointer<Float4>(r.data + OFFSET(DrawData,vs.c) + index3 * 16, 16); |
| 849 | |
| 850 | transpose4x4(c.x, c.y, c.z, c.w); |
| 851 | } |
| 852 | } |
| 853 | |
| 854 | return c; |
| 855 | } |
| 856 | |
| 857 | Int VertexProgram::relativeAddress(Registers &r, const Shader::Parameter &var) |
| 858 | { |
| 859 | ASSERT(var.rel.deterministic); |
| 860 | |
| 861 | if(var.rel.type == Shader::PARAMETER_TEMP) |
| 862 | { |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 863 | return As<Int>(Extract(r.r[var.rel.index].x, 0)) * var.rel.scale; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 864 | } |
| 865 | else if(var.rel.type == Shader::PARAMETER_INPUT) |
| 866 | { |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 867 | return As<Int>(Extract(r.v[var.rel.index].x, 0)) * var.rel.scale; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 868 | } |
| 869 | else if(var.rel.type == Shader::PARAMETER_OUTPUT) |
| 870 | { |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 871 | return As<Int>(Extract(r.o[var.rel.index].x, 0)) * var.rel.scale; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 872 | } |
| 873 | else if(var.rel.type == Shader::PARAMETER_CONST) |
| 874 | { |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 875 | RValue<Int4> c = *Pointer<Int4>(r.data + OFFSET(DrawData, vs.c[var.rel.index])); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 876 | |
Alexis Hetu | 02a2bb8 | 2015-08-20 14:10:33 -0400 | [diff] [blame] | 877 | return Extract(c, 0) * var.rel.scale; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 878 | } |
| 879 | else ASSERT(false); |
| 880 | |
| 881 | return 0; |
| 882 | } |
| 883 | |
| 884 | Int4 VertexProgram::enableMask(Registers &r, const Shader::Instruction *instruction) |
| 885 | { |
| 886 | Int4 enable = instruction->analysisBranch ? Int4(r.enableStack[r.enableIndex]) : Int4(0xFFFFFFFF); |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 887 | |
| 888 | if(!whileTest) |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 889 | { |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 890 | if(shader->containsBreakInstruction() && instruction->analysisBreak) |
| 891 | { |
| 892 | enable &= r.enableBreak; |
| 893 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 894 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 895 | if(shader->containsContinueInstruction() && instruction->analysisContinue) |
| 896 | { |
| 897 | enable &= r.enableContinue; |
| 898 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 899 | |
John Bauman | d4ae863 | 2014-05-06 16:18:33 -0400 | [diff] [blame] | 900 | if(shader->containsLeaveInstruction() && instruction->analysisLeave) |
| 901 | { |
| 902 | enable &= r.enableLeave; |
| 903 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | return enable; |
| 907 | } |
| 908 | |
| 909 | void VertexProgram::M3X2(Registers &r, Vector4f &dst, Vector4f &src0, Src &src1) |
| 910 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 911 | Vector4f row0 = fetchRegisterF(r, src1, 0); |
| 912 | Vector4f row1 = fetchRegisterF(r, src1, 1); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 913 | |
| 914 | dst.x = dot3(src0, row0); |
| 915 | dst.y = dot3(src0, row1); |
| 916 | } |
| 917 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 918 | void VertexProgram::M3X3(Registers &r, Vector4f &dst, Vector4f &src0, Src &src1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 919 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 920 | Vector4f row0 = fetchRegisterF(r, src1, 0); |
| 921 | Vector4f row1 = fetchRegisterF(r, src1, 1); |
| 922 | Vector4f row2 = fetchRegisterF(r, src1, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 923 | |
| 924 | dst.x = dot3(src0, row0); |
| 925 | dst.y = dot3(src0, row1); |
| 926 | dst.z = dot3(src0, row2); |
| 927 | } |
| 928 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 929 | void VertexProgram::M3X4(Registers &r, Vector4f &dst, Vector4f &src0, Src &src1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 930 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 931 | Vector4f row0 = fetchRegisterF(r, src1, 0); |
| 932 | Vector4f row1 = fetchRegisterF(r, src1, 1); |
| 933 | Vector4f row2 = fetchRegisterF(r, src1, 2); |
| 934 | Vector4f row3 = fetchRegisterF(r, src1, 3); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 935 | |
| 936 | dst.x = dot3(src0, row0); |
| 937 | dst.y = dot3(src0, row1); |
| 938 | dst.z = dot3(src0, row2); |
| 939 | dst.w = dot3(src0, row3); |
| 940 | } |
| 941 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 942 | void VertexProgram::M4X3(Registers &r, Vector4f &dst, Vector4f &src0, Src &src1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 943 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 944 | Vector4f row0 = fetchRegisterF(r, src1, 0); |
| 945 | Vector4f row1 = fetchRegisterF(r, src1, 1); |
| 946 | Vector4f row2 = fetchRegisterF(r, src1, 2); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 947 | |
| 948 | dst.x = dot4(src0, row0); |
| 949 | dst.y = dot4(src0, row1); |
| 950 | dst.z = dot4(src0, row2); |
| 951 | } |
| 952 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 953 | void VertexProgram::M4X4(Registers &r, Vector4f &dst, Vector4f &src0, Src &src1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 954 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 955 | Vector4f row0 = fetchRegisterF(r, src1, 0); |
| 956 | Vector4f row1 = fetchRegisterF(r, src1, 1); |
| 957 | Vector4f row2 = fetchRegisterF(r, src1, 2); |
| 958 | Vector4f row3 = fetchRegisterF(r, src1, 3); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 959 | |
| 960 | dst.x = dot4(src0, row0); |
| 961 | dst.y = dot4(src0, row1); |
| 962 | dst.z = dot4(src0, row2); |
| 963 | dst.w = dot4(src0, row3); |
| 964 | } |
| 965 | |
| 966 | void VertexProgram::BREAK(Registers &r) |
| 967 | { |
| 968 | llvm::BasicBlock *deadBlock = Nucleus::createBasicBlock(); |
| 969 | llvm::BasicBlock *endBlock = loopRepEndBlock[loopRepDepth - 1]; |
| 970 | |
| 971 | if(breakDepth == 0) |
| 972 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 973 | r.enableIndex = r.enableIndex - breakDepth; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 974 | Nucleus::createBr(endBlock); |
| 975 | } |
| 976 | else |
| 977 | { |
| 978 | r.enableBreak = r.enableBreak & ~r.enableStack[r.enableIndex]; |
| 979 | Bool allBreak = SignMask(r.enableBreak) == 0x0; |
| 980 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 981 | r.enableIndex = r.enableIndex - breakDepth; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 982 | branch(allBreak, endBlock, deadBlock); |
| 983 | } |
| 984 | |
| 985 | Nucleus::setInsertBlock(deadBlock); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 986 | r.enableIndex = r.enableIndex + breakDepth; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 987 | } |
| 988 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 989 | void VertexProgram::BREAKC(Registers &r, Vector4f &src0, Vector4f &src1, Control control) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 990 | { |
| 991 | Int4 condition; |
| 992 | |
| 993 | switch(control) |
| 994 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 995 | case Shader::CONTROL_GT: condition = CmpNLE(src0.x, src1.x); break; |
| 996 | case Shader::CONTROL_EQ: condition = CmpEQ(src0.x, src1.x); break; |
| 997 | case Shader::CONTROL_GE: condition = CmpNLT(src0.x, src1.x); break; |
| 998 | case Shader::CONTROL_LT: condition = CmpLT(src0.x, src1.x); break; |
| 999 | case Shader::CONTROL_NE: condition = CmpNEQ(src0.x, src1.x); break; |
| 1000 | case Shader::CONTROL_LE: condition = CmpLE(src0.x, src1.x); break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1001 | default: |
| 1002 | ASSERT(false); |
| 1003 | } |
| 1004 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1005 | BREAK(r, condition); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | void VertexProgram::BREAKP(Registers &r, const Src &predicateRegister) // FIXME: Factor out parts common with BREAKC |
| 1009 | { |
| 1010 | Int4 condition = As<Int4>(r.p0[predicateRegister.swizzle & 0x3]); |
| 1011 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1012 | if(predicateRegister.modifier == Shader::MODIFIER_NOT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1013 | { |
| 1014 | condition = ~condition; |
| 1015 | } |
| 1016 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1017 | BREAK(r, condition); |
| 1018 | } |
| 1019 | |
| 1020 | void VertexProgram::BREAK(Registers &r, Int4 &condition) |
| 1021 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1022 | condition &= r.enableStack[r.enableIndex]; |
| 1023 | |
| 1024 | llvm::BasicBlock *continueBlock = Nucleus::createBasicBlock(); |
| 1025 | llvm::BasicBlock *endBlock = loopRepEndBlock[loopRepDepth - 1]; |
| 1026 | |
| 1027 | r.enableBreak = r.enableBreak & ~condition; |
| 1028 | Bool allBreak = SignMask(r.enableBreak) == 0x0; |
| 1029 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1030 | r.enableIndex = r.enableIndex - breakDepth; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1031 | branch(allBreak, endBlock, continueBlock); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1032 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1033 | Nucleus::setInsertBlock(continueBlock); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1034 | r.enableIndex = r.enableIndex + breakDepth; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1035 | } |
| 1036 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1037 | void VertexProgram::CONTINUE(Registers &r) |
| 1038 | { |
| 1039 | r.enableContinue = r.enableContinue & ~r.enableStack[r.enableIndex]; |
| 1040 | } |
| 1041 | |
| 1042 | void VertexProgram::TEST() |
| 1043 | { |
| 1044 | whileTest = true; |
| 1045 | } |
| 1046 | |
| 1047 | void VertexProgram::CALL(Registers &r, int labelIndex, int callSiteIndex) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1048 | { |
| 1049 | if(!labelBlock[labelIndex]) |
| 1050 | { |
| 1051 | labelBlock[labelIndex] = Nucleus::createBasicBlock(); |
| 1052 | } |
| 1053 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1054 | if(callRetBlock[labelIndex].size() > 1) |
| 1055 | { |
| 1056 | r.callStack[r.stackIndex++] = UInt(callSiteIndex); |
| 1057 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1058 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1059 | Int4 restoreLeave = r.enableLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1060 | |
| 1061 | Nucleus::createBr(labelBlock[labelIndex]); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1062 | Nucleus::setInsertBlock(callRetBlock[labelIndex][callSiteIndex]); |
| 1063 | |
| 1064 | r.enableLeave = restoreLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1065 | } |
| 1066 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1067 | void VertexProgram::CALLNZ(Registers &r, int labelIndex, int callSiteIndex, const Src &src) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1068 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1069 | if(src.type == Shader::PARAMETER_CONSTBOOL) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1070 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1071 | CALLNZb(r, labelIndex, callSiteIndex, src); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1072 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1073 | else if(src.type == Shader::PARAMETER_PREDICATE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1074 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1075 | CALLNZp(r, labelIndex, callSiteIndex, src); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1076 | } |
| 1077 | else ASSERT(false); |
| 1078 | } |
| 1079 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1080 | void VertexProgram::CALLNZb(Registers &r, int labelIndex, int callSiteIndex, const Src &boolRegister) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1081 | { |
| 1082 | Bool condition = (*Pointer<Byte>(r.data + OFFSET(DrawData,vs.b[boolRegister.index])) != Byte(0)); // FIXME |
| 1083 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1084 | if(boolRegister.modifier == Shader::MODIFIER_NOT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1085 | { |
| 1086 | condition = !condition; |
| 1087 | } |
| 1088 | |
| 1089 | if(!labelBlock[labelIndex]) |
| 1090 | { |
| 1091 | labelBlock[labelIndex] = Nucleus::createBasicBlock(); |
| 1092 | } |
| 1093 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1094 | if(callRetBlock[labelIndex].size() > 1) |
| 1095 | { |
| 1096 | r.callStack[r.stackIndex++] = UInt(callSiteIndex); |
| 1097 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1098 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1099 | Int4 restoreLeave = r.enableLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1100 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1101 | branch(condition, labelBlock[labelIndex], callRetBlock[labelIndex][callSiteIndex]); |
| 1102 | Nucleus::setInsertBlock(callRetBlock[labelIndex][callSiteIndex]); |
| 1103 | |
| 1104 | r.enableLeave = restoreLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1105 | } |
| 1106 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1107 | void VertexProgram::CALLNZp(Registers &r, int labelIndex, int callSiteIndex, const Src &predicateRegister) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1108 | { |
| 1109 | Int4 condition = As<Int4>(r.p0[predicateRegister.swizzle & 0x3]); |
| 1110 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1111 | if(predicateRegister.modifier == Shader::MODIFIER_NOT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1112 | { |
| 1113 | condition = ~condition; |
| 1114 | } |
| 1115 | |
| 1116 | condition &= r.enableStack[r.enableIndex]; |
| 1117 | |
| 1118 | if(!labelBlock[labelIndex]) |
| 1119 | { |
| 1120 | labelBlock[labelIndex] = Nucleus::createBasicBlock(); |
| 1121 | } |
| 1122 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1123 | if(callRetBlock[labelIndex].size() > 1) |
| 1124 | { |
| 1125 | r.callStack[r.stackIndex++] = UInt(callSiteIndex); |
| 1126 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1127 | |
| 1128 | r.enableIndex++; |
| 1129 | r.enableStack[r.enableIndex] = condition; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1130 | Int4 restoreLeave = r.enableLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1131 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1132 | Bool notAllFalse = SignMask(condition) != 0; |
| 1133 | branch(notAllFalse, labelBlock[labelIndex], callRetBlock[labelIndex][callSiteIndex]); |
| 1134 | Nucleus::setInsertBlock(callRetBlock[labelIndex][callSiteIndex]); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1135 | |
| 1136 | r.enableIndex--; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1137 | r.enableLeave = restoreLeave; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1138 | } |
| 1139 | |
| 1140 | void VertexProgram::ELSE(Registers &r) |
| 1141 | { |
| 1142 | ifDepth--; |
| 1143 | |
| 1144 | llvm::BasicBlock *falseBlock = ifFalseBlock[ifDepth]; |
| 1145 | llvm::BasicBlock *endBlock = Nucleus::createBasicBlock(); |
| 1146 | |
| 1147 | if(isConditionalIf[ifDepth]) |
| 1148 | { |
| 1149 | Int4 condition = ~r.enableStack[r.enableIndex] & r.enableStack[r.enableIndex - 1]; |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1150 | Bool notAllFalse = SignMask(condition) != 0; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1151 | |
| 1152 | branch(notAllFalse, falseBlock, endBlock); |
| 1153 | |
| 1154 | r.enableStack[r.enableIndex] = ~r.enableStack[r.enableIndex] & r.enableStack[r.enableIndex - 1]; |
| 1155 | } |
| 1156 | else |
| 1157 | { |
| 1158 | Nucleus::createBr(endBlock); |
| 1159 | Nucleus::setInsertBlock(falseBlock); |
| 1160 | } |
| 1161 | |
| 1162 | ifFalseBlock[ifDepth] = endBlock; |
| 1163 | |
| 1164 | ifDepth++; |
| 1165 | } |
| 1166 | |
| 1167 | void VertexProgram::ENDIF(Registers &r) |
| 1168 | { |
| 1169 | ifDepth--; |
| 1170 | |
| 1171 | llvm::BasicBlock *endBlock = ifFalseBlock[ifDepth]; |
| 1172 | |
| 1173 | Nucleus::createBr(endBlock); |
| 1174 | Nucleus::setInsertBlock(endBlock); |
| 1175 | |
| 1176 | if(isConditionalIf[ifDepth]) |
| 1177 | { |
| 1178 | breakDepth--; |
| 1179 | r.enableIndex--; |
| 1180 | } |
| 1181 | } |
| 1182 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1183 | void VertexProgram::ENDLOOP(Registers &r) |
| 1184 | { |
| 1185 | loopRepDepth--; |
| 1186 | |
| 1187 | r.aL[r.loopDepth] = r.aL[r.loopDepth] + r.increment[r.loopDepth]; // FIXME: += |
| 1188 | |
| 1189 | llvm::BasicBlock *testBlock = loopRepTestBlock[loopRepDepth]; |
| 1190 | llvm::BasicBlock *endBlock = loopRepEndBlock[loopRepDepth]; |
| 1191 | |
| 1192 | Nucleus::createBr(testBlock); |
| 1193 | Nucleus::setInsertBlock(endBlock); |
| 1194 | |
| 1195 | r.loopDepth--; |
| 1196 | r.enableBreak = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); |
| 1197 | } |
| 1198 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1199 | void VertexProgram::ENDREP(Registers &r) |
| 1200 | { |
| 1201 | loopRepDepth--; |
| 1202 | |
| 1203 | llvm::BasicBlock *testBlock = loopRepTestBlock[loopRepDepth]; |
| 1204 | llvm::BasicBlock *endBlock = loopRepEndBlock[loopRepDepth]; |
| 1205 | |
| 1206 | Nucleus::createBr(testBlock); |
| 1207 | Nucleus::setInsertBlock(endBlock); |
| 1208 | |
| 1209 | r.loopDepth--; |
| 1210 | r.enableBreak = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); |
| 1211 | } |
| 1212 | |
| 1213 | void VertexProgram::ENDWHILE(Registers &r) |
| 1214 | { |
| 1215 | loopRepDepth--; |
| 1216 | |
| 1217 | llvm::BasicBlock *testBlock = loopRepTestBlock[loopRepDepth]; |
| 1218 | llvm::BasicBlock *endBlock = loopRepEndBlock[loopRepDepth]; |
| 1219 | |
| 1220 | Nucleus::createBr(testBlock); |
| 1221 | Nucleus::setInsertBlock(endBlock); |
| 1222 | |
| 1223 | r.enableIndex--; |
| 1224 | r.enableBreak = Int4(0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF); |
| 1225 | whileTest = false; |
| 1226 | } |
| 1227 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1228 | void VertexProgram::IF(Registers &r, const Src &src) |
| 1229 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1230 | if(src.type == Shader::PARAMETER_CONSTBOOL) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1231 | { |
| 1232 | IFb(r, src); |
| 1233 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1234 | else if(src.type == Shader::PARAMETER_PREDICATE) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1235 | { |
| 1236 | IFp(r, src); |
| 1237 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1238 | else |
| 1239 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 1240 | Int4 condition = As<Int4>(fetchRegisterF(r, src).x); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1241 | IF(r, condition); |
| 1242 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1243 | } |
| 1244 | |
| 1245 | void VertexProgram::IFb(Registers &r, const Src &boolRegister) |
| 1246 | { |
| 1247 | ASSERT(ifDepth < 24 + 4); |
| 1248 | |
| 1249 | Bool condition = (*Pointer<Byte>(r.data + OFFSET(DrawData,vs.b[boolRegister.index])) != Byte(0)); // FIXME |
| 1250 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1251 | if(boolRegister.modifier == Shader::MODIFIER_NOT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1252 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1253 | condition = !condition; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | llvm::BasicBlock *trueBlock = Nucleus::createBasicBlock(); |
| 1257 | llvm::BasicBlock *falseBlock = Nucleus::createBasicBlock(); |
| 1258 | |
| 1259 | branch(condition, trueBlock, falseBlock); |
| 1260 | |
| 1261 | isConditionalIf[ifDepth] = false; |
| 1262 | ifFalseBlock[ifDepth] = falseBlock; |
| 1263 | |
| 1264 | ifDepth++; |
| 1265 | } |
| 1266 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1267 | void VertexProgram::IFp(Registers &r, const Src &predicateRegister) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1268 | { |
| 1269 | Int4 condition = As<Int4>(r.p0[predicateRegister.swizzle & 0x3]); |
| 1270 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1271 | if(predicateRegister.modifier == Shader::MODIFIER_NOT) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1272 | { |
| 1273 | condition = ~condition; |
| 1274 | } |
| 1275 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1276 | IF(r, condition); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1277 | } |
| 1278 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1279 | void VertexProgram::IFC(Registers &r, Vector4f &src0, Vector4f &src1, Control control) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1280 | { |
| 1281 | Int4 condition; |
| 1282 | |
| 1283 | switch(control) |
| 1284 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1285 | case Shader::CONTROL_GT: condition = CmpNLE(src0.x, src1.x); break; |
| 1286 | case Shader::CONTROL_EQ: condition = CmpEQ(src0.x, src1.x); break; |
| 1287 | case Shader::CONTROL_GE: condition = CmpNLT(src0.x, src1.x); break; |
| 1288 | case Shader::CONTROL_LT: condition = CmpLT(src0.x, src1.x); break; |
| 1289 | case Shader::CONTROL_NE: condition = CmpNEQ(src0.x, src1.x); break; |
| 1290 | case Shader::CONTROL_LE: condition = CmpLE(src0.x, src1.x); break; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1291 | default: |
| 1292 | ASSERT(false); |
| 1293 | } |
| 1294 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1295 | IF(r, condition); |
| 1296 | } |
| 1297 | |
| 1298 | void VertexProgram::IF(Registers &r, Int4 &condition) |
| 1299 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1300 | condition &= r.enableStack[r.enableIndex]; |
| 1301 | |
| 1302 | r.enableIndex++; |
| 1303 | r.enableStack[r.enableIndex] = condition; |
| 1304 | |
| 1305 | llvm::BasicBlock *trueBlock = Nucleus::createBasicBlock(); |
| 1306 | llvm::BasicBlock *falseBlock = Nucleus::createBasicBlock(); |
| 1307 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1308 | Bool notAllFalse = SignMask(condition) != 0; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1309 | |
| 1310 | branch(notAllFalse, trueBlock, falseBlock); |
| 1311 | |
| 1312 | isConditionalIf[ifDepth] = true; |
| 1313 | ifFalseBlock[ifDepth] = falseBlock; |
| 1314 | |
| 1315 | ifDepth++; |
| 1316 | breakDepth++; |
| 1317 | } |
| 1318 | |
| 1319 | void VertexProgram::LABEL(int labelIndex) |
| 1320 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1321 | if(!labelBlock[labelIndex]) |
| 1322 | { |
| 1323 | labelBlock[labelIndex] = Nucleus::createBasicBlock(); |
| 1324 | } |
| 1325 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1326 | Nucleus::setInsertBlock(labelBlock[labelIndex]); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1327 | currentLabel = labelIndex; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1328 | } |
| 1329 | |
| 1330 | void VertexProgram::LOOP(Registers &r, const Src &integerRegister) |
| 1331 | { |
| 1332 | r.loopDepth++; |
| 1333 | |
| 1334 | r.iteration[r.loopDepth] = *Pointer<Int>(r.data + OFFSET(DrawData,vs.i[integerRegister.index][0])); |
| 1335 | r.aL[r.loopDepth] = *Pointer<Int>(r.data + OFFSET(DrawData,vs.i[integerRegister.index][1])); |
| 1336 | r.increment[r.loopDepth] = *Pointer<Int>(r.data + OFFSET(DrawData,vs.i[integerRegister.index][2])); |
| 1337 | |
| 1338 | // FIXME: Compiles to two instructions? |
| 1339 | If(r.increment[r.loopDepth] == 0) |
| 1340 | { |
| 1341 | r.increment[r.loopDepth] = 1; |
| 1342 | } |
| 1343 | |
| 1344 | llvm::BasicBlock *loopBlock = Nucleus::createBasicBlock(); |
| 1345 | llvm::BasicBlock *testBlock = Nucleus::createBasicBlock(); |
| 1346 | llvm::BasicBlock *endBlock = Nucleus::createBasicBlock(); |
| 1347 | |
| 1348 | loopRepTestBlock[loopRepDepth] = testBlock; |
| 1349 | loopRepEndBlock[loopRepDepth] = endBlock; |
| 1350 | |
| 1351 | // FIXME: jump(testBlock) |
| 1352 | Nucleus::createBr(testBlock); |
| 1353 | Nucleus::setInsertBlock(testBlock); |
| 1354 | |
| 1355 | branch(r.iteration[r.loopDepth] > 0, loopBlock, endBlock); |
| 1356 | Nucleus::setInsertBlock(loopBlock); |
| 1357 | |
| 1358 | r.iteration[r.loopDepth] = r.iteration[r.loopDepth] - 1; // FIXME: -- |
| 1359 | |
| 1360 | loopRepDepth++; |
| 1361 | breakDepth = 0; |
| 1362 | } |
| 1363 | |
| 1364 | void VertexProgram::REP(Registers &r, const Src &integerRegister) |
| 1365 | { |
| 1366 | r.loopDepth++; |
| 1367 | |
| 1368 | r.iteration[r.loopDepth] = *Pointer<Int>(r.data + OFFSET(DrawData,vs.i[integerRegister.index][0])); |
| 1369 | r.aL[r.loopDepth] = r.aL[r.loopDepth - 1]; |
| 1370 | |
| 1371 | llvm::BasicBlock *loopBlock = Nucleus::createBasicBlock(); |
| 1372 | llvm::BasicBlock *testBlock = Nucleus::createBasicBlock(); |
| 1373 | llvm::BasicBlock *endBlock = Nucleus::createBasicBlock(); |
| 1374 | |
| 1375 | loopRepTestBlock[loopRepDepth] = testBlock; |
| 1376 | loopRepEndBlock[loopRepDepth] = endBlock; |
| 1377 | |
| 1378 | // FIXME: jump(testBlock) |
| 1379 | Nucleus::createBr(testBlock); |
| 1380 | Nucleus::setInsertBlock(testBlock); |
| 1381 | |
| 1382 | branch(r.iteration[r.loopDepth] > 0, loopBlock, endBlock); |
| 1383 | Nucleus::setInsertBlock(loopBlock); |
| 1384 | |
| 1385 | r.iteration[r.loopDepth] = r.iteration[r.loopDepth] - 1; // FIXME: -- |
| 1386 | |
| 1387 | loopRepDepth++; |
| 1388 | breakDepth = 0; |
| 1389 | } |
| 1390 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1391 | void VertexProgram::WHILE(Registers &r, const Src &temporaryRegister) |
| 1392 | { |
| 1393 | r.enableIndex++; |
| 1394 | |
| 1395 | llvm::BasicBlock *loopBlock = Nucleus::createBasicBlock(); |
| 1396 | llvm::BasicBlock *testBlock = Nucleus::createBasicBlock(); |
| 1397 | llvm::BasicBlock *endBlock = Nucleus::createBasicBlock(); |
| 1398 | |
| 1399 | loopRepTestBlock[loopRepDepth] = testBlock; |
| 1400 | loopRepEndBlock[loopRepDepth] = endBlock; |
| 1401 | |
| 1402 | Int4 restoreBreak = r.enableBreak; |
| 1403 | Int4 restoreContinue = r.enableContinue; |
| 1404 | |
| 1405 | // FIXME: jump(testBlock) |
| 1406 | Nucleus::createBr(testBlock); |
| 1407 | Nucleus::setInsertBlock(testBlock); |
| 1408 | r.enableContinue = restoreContinue; |
| 1409 | |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 1410 | const Vector4f &src = fetchRegisterF(r, temporaryRegister); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1411 | Int4 condition = As<Int4>(src.x); |
| 1412 | condition &= r.enableStack[r.enableIndex - 1]; |
| 1413 | r.enableStack[r.enableIndex] = condition; |
| 1414 | |
| 1415 | Bool notAllFalse = SignMask(condition) != 0; |
| 1416 | branch(notAllFalse, loopBlock, endBlock); |
| 1417 | |
| 1418 | Nucleus::setInsertBlock(endBlock); |
| 1419 | r.enableBreak = restoreBreak; |
| 1420 | |
| 1421 | Nucleus::setInsertBlock(loopBlock); |
| 1422 | |
| 1423 | loopRepDepth++; |
| 1424 | breakDepth = 0; |
| 1425 | } |
| 1426 | |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1427 | void VertexProgram::RET(Registers &r) |
| 1428 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1429 | if(currentLabel == -1) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1430 | { |
| 1431 | returnBlock = Nucleus::createBasicBlock(); |
| 1432 | Nucleus::createBr(returnBlock); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1433 | } |
| 1434 | else |
| 1435 | { |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1436 | llvm::BasicBlock *unreachableBlock = Nucleus::createBasicBlock(); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1437 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1438 | if(callRetBlock[currentLabel].size() > 1) // Pop the return destination from the call stack |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1439 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1440 | // FIXME: Encapsulate |
| 1441 | UInt index = r.callStack[--r.stackIndex]; |
| 1442 | |
John Bauman | 66b8ab2 | 2014-05-06 15:57:45 -0400 | [diff] [blame] | 1443 | llvm::Value *value = index.loadValue(); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1444 | llvm::Value *switchInst = Nucleus::createSwitch(value, unreachableBlock, (int)callRetBlock[currentLabel].size()); |
| 1445 | |
| 1446 | for(unsigned int i = 0; i < callRetBlock[currentLabel].size(); i++) |
| 1447 | { |
| 1448 | Nucleus::addSwitchCase(switchInst, i, callRetBlock[currentLabel][i]); |
| 1449 | } |
| 1450 | } |
| 1451 | else if(callRetBlock[currentLabel].size() == 1) // Jump directly to the unique return destination |
| 1452 | { |
| 1453 | Nucleus::createBr(callRetBlock[currentLabel][0]); |
| 1454 | } |
| 1455 | else // Function isn't called |
| 1456 | { |
| 1457 | Nucleus::createBr(unreachableBlock); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1458 | } |
| 1459 | |
| 1460 | Nucleus::setInsertBlock(unreachableBlock); |
| 1461 | Nucleus::createUnreachable(); |
| 1462 | } |
| 1463 | } |
| 1464 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1465 | void VertexProgram::LEAVE(Registers &r) |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1466 | { |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1467 | r.enableLeave = r.enableLeave & ~r.enableStack[r.enableIndex]; |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1468 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1469 | // FIXME: Return from function if all instances left |
| 1470 | // FIXME: Use enableLeave in other control-flow constructs |
| 1471 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1472 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1473 | void VertexProgram::TEXLDL(Registers &r, Vector4f &dst, Vector4f &src0, const Src &src1) |
| 1474 | { |
| 1475 | Vector4f tmp; |
| 1476 | sampleTexture(r, tmp, src1, src0.x, src0.y, src0.z, src0.w); |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1477 | |
| 1478 | dst.x = tmp[(src1.swizzle >> 0) & 0x3]; |
| 1479 | dst.y = tmp[(src1.swizzle >> 2) & 0x3]; |
| 1480 | dst.z = tmp[(src1.swizzle >> 4) & 0x3]; |
| 1481 | dst.w = tmp[(src1.swizzle >> 6) & 0x3]; |
| 1482 | } |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1483 | |
| 1484 | void VertexProgram::TEX(Registers &r, Vector4f &dst, Vector4f &src0, const Src &src1) |
| 1485 | { |
| 1486 | Float4 lod = Float4(0.0f); |
| 1487 | Vector4f tmp; |
| 1488 | sampleTexture(r, tmp, src1, src0.x, src0.y, src0.z, lod); |
| 1489 | |
| 1490 | dst.x = tmp[(src1.swizzle >> 0) & 0x3]; |
| 1491 | dst.y = tmp[(src1.swizzle >> 2) & 0x3]; |
| 1492 | dst.z = tmp[(src1.swizzle >> 4) & 0x3]; |
| 1493 | dst.w = tmp[(src1.swizzle >> 6) & 0x3]; |
| 1494 | } |
| 1495 | |
Alexis Hetu | 25d47fc | 2015-10-22 13:58:32 -0400 | [diff] [blame] | 1496 | void VertexProgram::TEXOFFSET(Registers &r, Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3) |
| 1497 | { |
| 1498 | UNIMPLEMENTED(); |
| 1499 | } |
| 1500 | |
| 1501 | void VertexProgram::TEXLDL(Registers &r, Vector4f &dst, Vector4f &src, const Src&, Vector4f &offset) |
| 1502 | { |
| 1503 | UNIMPLEMENTED(); |
| 1504 | } |
| 1505 | |
| 1506 | void VertexProgram::TEXELFETCH(Registers &r, Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2) |
| 1507 | { |
| 1508 | UNIMPLEMENTED(); |
| 1509 | } |
| 1510 | |
| 1511 | void VertexProgram::TEXELFETCH(Registers &r, Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &offset) |
| 1512 | { |
| 1513 | UNIMPLEMENTED(); |
| 1514 | } |
| 1515 | |
| 1516 | void VertexProgram::TEXGRAD(Registers &r, Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3) |
| 1517 | { |
| 1518 | UNIMPLEMENTED(); |
| 1519 | } |
| 1520 | |
| 1521 | void VertexProgram::TEXGRAD(Registers &r, Vector4f &dst, Vector4f &src0, const Src& src1, Vector4f &src2, Vector4f &src3, Vector4f &offset) |
| 1522 | { |
| 1523 | UNIMPLEMENTED(); |
| 1524 | } |
| 1525 | |
Alexis Hetu | 9bcb31d | 2015-07-22 17:03:26 -0400 | [diff] [blame] | 1526 | void VertexProgram::TEXSIZE(Registers &r, Vector4f &dst, Float4 &lod, const Src &src1) |
| 1527 | { |
| 1528 | Pointer<Byte> textureMipmap = r.data + OFFSET(DrawData, mipmap[16]) + src1.index * sizeof(Texture) + OFFSET(Texture, mipmap); |
| 1529 | for(int i = 0; i < 4; ++i) |
| 1530 | { |
| 1531 | Pointer<Byte> mipmap = textureMipmap + (As<Int>(Extract(lod, i)) + Int(1)) * sizeof(Mipmap); |
| 1532 | dst.x = Insert(dst.x, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, width)))), i); |
| 1533 | dst.y = Insert(dst.y, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, height)))), i); |
| 1534 | dst.z = Insert(dst.z, As<Float>(Int(*Pointer<Short>(mipmap + OFFSET(Mipmap, depth)))), i); |
| 1535 | } |
| 1536 | } |
| 1537 | |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1538 | void VertexProgram::sampleTexture(Registers &r, Vector4f &c, const Src &s, Float4 &u, Float4 &v, Float4 &w, Float4 &q) |
| 1539 | { |
| 1540 | if(s.type == Shader::PARAMETER_SAMPLER && s.rel.type == Shader::PARAMETER_VOID) |
| 1541 | { |
| 1542 | Pointer<Byte> texture = r.data + OFFSET(DrawData,mipmap[16]) + s.index * sizeof(Texture); |
| 1543 | sampler[s.index]->sampleTexture(texture, c, u, v, w, q, r.a0, r.a0, false, false, true); |
| 1544 | } |
| 1545 | else |
| 1546 | { |
Alexis Hetu | af1970c | 2015-04-17 14:26:07 -0400 | [diff] [blame] | 1547 | Int index = As<Int>(Float(fetchRegisterF(r, s).x.x)); |
John Bauman | 19bac1e | 2014-05-06 15:23:49 -0400 | [diff] [blame] | 1548 | |
| 1549 | for(int i = 0; i < 16; i++) |
| 1550 | { |
| 1551 | if(shader->usesSampler(i)) |
| 1552 | { |
| 1553 | If(index == i) |
| 1554 | { |
| 1555 | Pointer<Byte> texture = r.data + OFFSET(DrawData,mipmap[16]) + i * sizeof(Texture); |
| 1556 | sampler[i]->sampleTexture(texture, c, u, v, w, q, r.a0, r.a0, false, false, true); |
| 1557 | // FIXME: When the sampler states are the same, we could use one sampler and just index the texture |
| 1558 | } |
| 1559 | } |
| 1560 | } |
| 1561 | } |
| 1562 | } |
John Bauman | 8940182 | 2014-05-06 15:04:28 -0400 | [diff] [blame] | 1563 | } |