Lines Matching refs:builder
31 static Value * pointSample(IRBuilder<> & builder, Value * textureData, Value * index, const GGLPixe… in pointSample() argument
36 textureData = builder.CreateGEP(textureData, index); in pointSample()
37 texel = builder.CreateLoad(textureData, "texel"); in pointSample()
40 textureData = builder.CreateGEP(textureData, index); in pointSample()
41 texel = builder.CreateLoad(textureData, "texel"); in pointSample()
42 texel = builder.CreateOr(texel, builder.getInt32(0xff000000)); in pointSample()
45 textureData = builder.CreateBitCast(textureData, PointerType::get(builder.getInt16Ty(), 0)); in pointSample()
46 textureData = builder.CreateGEP(textureData, index); in pointSample()
47 texel = builder.CreateLoad(textureData, "texel565"); in pointSample()
48 texel = builder.CreateZExt(texel, Type::getInt32Ty(builder.getContext())); in pointSample()
50 Value * b = builder.CreateAnd(texel, builder.getInt32(0x1f)); in pointSample()
51 b = builder.CreateShl(b, builder.getInt32(3)); in pointSample()
52 b = builder.CreateOr(b, builder.CreateLShr(b, builder.getInt32(5))); in pointSample()
54 Value * g = builder.CreateAnd(texel, builder.getInt32(0x7e0)); in pointSample()
55 g = builder.CreateShl(g, builder.getInt32(5)); in pointSample()
56 g = builder.CreateOr(g, builder.CreateLShr(g, builder.getInt32(6))); in pointSample()
57 g = builder.CreateAnd(g, builder.getInt32(0xff00)); in pointSample()
59 Value * r = builder.CreateAnd(texel, builder.getInt32(0xF800)); in pointSample()
60 r = builder.CreateShl(r, builder.getInt32(8)); in pointSample()
61 r = builder.CreateOr(r, builder.CreateLShr(r, builder.getInt32(5))); in pointSample()
62 r = builder.CreateAnd(r, builder.getInt32(0xff0000)); in pointSample()
64 texel = builder.CreateOr(r, builder.CreateOr(g, b)); in pointSample()
65 texel = builder.CreateOr(texel, builder.getInt32(0xff000000), name("texel")); in pointSample()
69 textureData = builder.CreateBitCast(textureData, PointerType::get(builder.getInt8Ty(),0)); in pointSample()
70 textureData = builder.CreateGEP(textureData, index); in pointSample()
71 texel = builder.CreateLoad(textureData, "texel_a8"); in pointSample()
72 texel = builder.CreateZExt(texel, builder.getInt32Ty()); in pointSample()
73 texel = builder.CreateShl(texel, builder.getInt32(24)); in pointSample()
77 textureData = builder.CreateBitCast(textureData, PointerType::get(builder.getInt8Ty(),0)); in pointSample()
78 textureData = builder.CreateGEP(textureData, index); in pointSample()
79 texel = builder.CreateLoad(textureData, "texel_l8"); in pointSample()
80 texel = builder.CreateZExt(texel, builder.getInt32Ty()); in pointSample()
81 texel = builder.CreateOr(texel, builder.CreateShl(texel, 8)); in pointSample()
82 texel = builder.CreateOr(texel, builder.CreateShl(texel, 8)); in pointSample()
83 texel = builder.CreateOr(texel, builder.getInt32(0xff000000)); in pointSample()
87 textureData = builder.CreateBitCast(textureData, PointerType::get(builder.getInt16Ty(),0)); in pointSample()
88 textureData = builder.CreateGEP(textureData, index); in pointSample()
89 texel = builder.CreateLoad(textureData, "texel_la8"); in pointSample()
90 texel = builder.CreateZExt(texel, builder.getInt32Ty()); in pointSample()
91 Value * alpha = builder.CreateAnd(texel, builder.getInt32(0xff00)); in pointSample()
92 texel = builder.CreateAnd(texel, builder.getInt32(0xff)); in pointSample()
93 texel = builder.CreateOr(texel, builder.CreateShl(texel, 8)); in pointSample()
94 texel = builder.CreateOr(texel, builder.CreateShl(texel, 8)); in pointSample()
95 texel = builder.CreateOr(texel, builder.CreateShl(alpha, 16)); in pointSample()
100 texel = builder.getInt32(0xffff00ff); in pointSample()
106 Value * channels = Constant::getNullValue(intVecType(builder)); in pointSample()
113 channels = builder.CreateInsertElement(channels, texel, builder.getInt32(0)); in pointSample()
114 channels = builder.CreateInsertElement(channels, texel, builder.getInt32(1)); in pointSample()
115 channels = builder.CreateInsertElement(channels, texel, builder.getInt32(2)); in pointSample()
116 channels = builder.CreateInsertElement(channels, texel, builder.getInt32(3)); in pointSample()
127 channels = builder.CreateLShr(channels, constIntVec(builder, 0, 8, 16, 24)); in pointSample()
128 channels = builder.CreateAnd(channels, constIntVec(builder, 0xff, 0xff, 0xff, 0xff)); in pointSample()
143 static Value * linearSample(IRBuilder<> & builder, Value * textureData, Value * indexOffset, in linearSample() argument
149 Value * x1 = builder.CreateAdd(x0, builder.getInt32(1)); in linearSample()
150 x1 = minIntScalar(builder, x1, w); in linearSample()
151 Value * y1 = builder.CreateAdd(y0, builder.getInt32(1)); in linearSample()
152 y1 = minIntScalar(builder, y1, h); in linearSample()
157 Value * index = builder.CreateMul(y0, width); in linearSample()
158 index = builder.CreateAdd(index, x0); in linearSample()
159 index = builder.CreateAdd(index, indexOffset); in linearSample()
160 Value * s0 = pointSample(builder, textureData, index, format/*, ®Desc*/); in linearSample()
163 index = builder.CreateMul(y0, width); in linearSample()
164 index = builder.CreateAdd(index, x1); in linearSample()
165 index = builder.CreateAdd(index, indexOffset); in linearSample()
166 Value * s1 = pointSample(builder, textureData, index, format/*, ®Desc*/); in linearSample()
169 index = builder.CreateMul(y1, width); in linearSample()
170 index = builder.CreateAdd(index, x1); in linearSample()
171 index = builder.CreateAdd(index, indexOffset); in linearSample()
172 Value * s2 = pointSample(builder, textureData, index, format/*, ®Desc*/); in linearSample()
175 index = builder.CreateMul(y1, width); in linearSample()
176 index = builder.CreateAdd(index, x0); in linearSample()
177 index = builder.CreateAdd(index, indexOffset); in linearSample()
178 Value * s3 = pointSample(builder, textureData, index, format/*, ®Desc*/); in linearSample()
181 Value * xLerpVec = intVec(builder, xLerp, xLerp, xLerp, xLerp); in linearSample()
183 Value * h0 = builder.CreateMul(builder.CreateSub(s1, s0), xLerpVec); in linearSample()
185 h0 = builder.CreateAShr(h0, constIntVec(builder, SHIFT, SHIFT, SHIFT, SHIFT)); in linearSample()
186 h0 = builder.CreateAdd(h0, s0); in linearSample()
188 Value * h1 = builder.CreateMul(builder.CreateSub(s2, s3), xLerpVec); in linearSample()
189 h1 = builder.CreateAShr(h1, constIntVec(builder, SHIFT, SHIFT, SHIFT, SHIFT)); in linearSample()
190 h1 = builder.CreateAdd(h1, s3); in linearSample()
192 Value * sample = builder.CreateMul(builder.CreateSub(h1, h0), in linearSample()
193 intVec(builder, yLerp, yLerp, yLerp, yLerp)); in linearSample()
194 sample = builder.CreateAShr(sample, constIntVec(builder, SHIFT, SHIFT, SHIFT, SHIFT)); in linearSample()
195 sample = builder.CreateAdd(sample, h0); in linearSample()
220 static Value * texcoordWrap(IRBuilder<> & builder, const unsigned wrap, in texcoordWrap() argument
224 Type * intType = Type::getInt32Ty(builder.getContext()); in texcoordWrap()
230 tc = ConstantFP::get(builder.getContext(), APFloat(float(1 << SHIFT))); in texcoordWrap()
231 tc = builder.CreateFMul(tc, r); in texcoordWrap()
232 tc = builder.CreateFPToSI(tc, intType); in texcoordWrap()
239 odd = builder.CreateAnd(tc, builder.getInt32(1 << SHIFT), name("tc_odd")); in texcoordWrap()
242 tc = builder.CreateAnd(tc, builder.getInt32((1 << SHIFT) - 1)); in texcoordWrap()
244 tc = builder.CreateMul(tc, dim); in texcoordWrap()
246 *texelLerp = builder.CreateAnd(tc, builder.getInt32((1 << SHIFT) - 1)); in texcoordWrap()
248 tc = builder.CreateLShr(tc, builder.getInt32(SHIFT)); in texcoordWrap()
252 tc = maxIntScalar(builder, tc, builder.getInt32(0)); in texcoordWrap()
253 tc = minIntScalar(builder, tc, dim); in texcoordWrap()
255 Value * tcPtr = builder.CreateAlloca(intType); in texcoordWrap()
256 builder.CreateStore(tc, tcPtr); in texcoordWrap()
257 odd = builder.CreateICmpNE(odd, builder.getInt32(0)); in texcoordWrap()
259 CondBranch condBranch(builder); in texcoordWrap()
262 tc = builder.CreateSub(dim, tc, name("tc_mirrored")); in texcoordWrap()
263 builder.CreateStore(tc, tcPtr); in texcoordWrap()
267 tc = builder.CreateLoad(tcPtr); in texcoordWrap()
274 Value * tex2D(IRBuilder<> & builder, Value * in1, const unsigned sampler, in tex2D() argument
278 Type * intType = builder.getInt32Ty(); in tex2D()
281 llvm::Module * module = builder.GetInsertBlock()->getParent()->getParent(); in tex2D()
282 std::vector<Value * > texcoords = extractVector(builder, in1); in tex2D()
289 Value * textureWidth = builder.CreateConstInBoundsGEP1_32(textureDimensions, in tex2D()
291 textureWidth = builder.CreateLoad(textureWidth, name("textureWidth")); in tex2D()
292 Value * textureHeight = builder.CreateConstInBoundsGEP1_32(textureDimensions, in tex2D()
294 textureHeight = builder.CreateLoad(textureHeight, name("textureHeight")); in tex2D()
295 Value * textureW = builder.CreateSub(textureWidth, builder.getInt32(1)); in tex2D()
296 Value * textureH = builder.CreateSub(textureHeight, builder.getInt32(1)); in tex2D()
304 Value * x = texcoordWrap(builder, gglCtx->textureState.textures[sampler].wrapS, in tex2D()
306 Value * y = texcoordWrap(builder, gglCtx->textureState.textures[sampler].wrapT, in tex2D()
309 Value * index = builder.CreateMul(y, textureWidth); in tex2D()
310 index = builder.CreateAdd(index, x); in tex2D()
318 textureData = builder.CreateConstInBoundsGEP1_32(textureData, sampler); in tex2D()
319 textureData = builder.CreateLoad(textureData); in tex2D()
323 Value * ret = pointSample(builder, textureData, index, in tex2D()
325 return intColorVecToFloatColorVec(builder, ret); in tex2D()
328 Value * ret = linearSample(builder, textureData, builder.getInt32(0), x, y, xLerp, yLerp, in tex2D()
331 return intColorVecToFloatColorVec(builder, ret); in tex2D()
338 static Value * FCmpGT(IRBuilder<> & builder, Value * lhs, Value * rhs) in FCmpGT() argument
340 Type * const intType = Type::getInt32Ty(builder.getContext()); in FCmpGT()
341 lhs = builder.CreateBitCast(lhs, intType); in FCmpGT()
342 rhs = builder.CreateBitCast(rhs, intType); in FCmpGT()
343 return builder.CreateICmpUGT(lhs, rhs); in FCmpGT()
346 static Value * FPositive(IRBuilder<> & builder, Value * val) in FPositive() argument
349 return builder.CreateFCmpOGE(val, Constant::getNullValue(builder.getFloatTy())); in FPositive()
356 static Value * Fabs(IRBuilder<> & builder, Value * val) in Fabs() argument
358 val = builder.CreateBitCast(val, builder.getInt32Ty()); in Fabs()
359 val = builder.CreateAnd(val, builder.getInt32(~0x80000000)); in Fabs()
360 return builder.CreateBitCast(val, builder.getFloatTy()); in Fabs()
364 Value * texCube(IRBuilder<> & builder, Value * in1, const unsigned sampler, in texCube() argument
371 Type * const intType = builder.getInt32Ty(); in texCube()
373 Type * const floatType = builder.getFloatTy(); in texCube()
375 Constant * const float1 = constFloat(builder, 1.0f); in texCube()
376 Constant * const float0_5 = constFloat(builder, 0.5f); in texCube()
378 Module * module = builder.GetInsertBlock()->getParent()->getParent(); in texCube()
379 std::vector<Value * > texcoords = extractVector(builder, in1); in texCube()
386 Value * textureWidth = builder.CreateConstInBoundsGEP1_32(textureDimensions, in texCube()
388 textureWidth = builder.CreateLoad(textureWidth, name("textureWidth")); in texCube()
389 Value * textureHeight = builder.CreateConstInBoundsGEP1_32(textureDimensions, in texCube()
391 textureHeight = builder.CreateLoad(textureHeight, name("textureHeight")); in texCube()
392 Value * textureW = builder.CreateSub(textureWidth, builder.getInt32(1)); in texCube()
393 Value * textureH = builder.CreateSub(textureHeight, builder.getInt32(1)); in texCube()
395 Value * mx = Fabs(builder, texcoords[0]), * my = Fabs(builder, texcoords[1]); in texCube()
396 Value * mz = Fabs(builder, texcoords[2]); in texCube()
397 Value * sPtr = builder.CreateAlloca(floatType); in texCube()
398 Value * tPtr = builder.CreateAlloca(floatType); in texCube()
399 Value * maPtr = builder.CreateAlloca(floatType); in texCube()
400 Value * facePtr = builder.CreateAlloca(intType); in texCube()
402 Value * mxGmyCmp = FCmpGT(builder, mx, my); in texCube()
403 Value * mxGmzCmp = FCmpGT(builder, mx, mz); in texCube()
405 CondBranch condBranch(builder); in texCube()
406 condBranch.ifCond(builder.CreateAnd(mxGmyCmp, mxGmzCmp)); // if (mx > my && mx > mz) in texCube()
409 condBranch.ifCond(FPositive(builder, texcoords[0])); in texCube()
412 builder.CreateStore(builder.CreateFNeg(texcoords[2]), sPtr); in texCube()
413 builder.CreateStore(builder.CreateFNeg(texcoords[1]), tPtr); in texCube()
414 builder.CreateStore(builder.getInt32(0), facePtr); in texCube()
419 builder.CreateStore((texcoords[2]), sPtr); in texCube()
420 builder.CreateStore(builder.CreateFNeg(texcoords[1]), tPtr); in texCube()
421 builder.CreateStore(builder.getInt32(1), facePtr); in texCube()
426 builder.CreateStore(mx, maPtr); in texCube()
431 Value * myGmxCmp = FCmpGT(builder, my, mx); in texCube()
432 Value * myGmzCmp = FCmpGT(builder, my, mz); in texCube()
433 condBranch.ifCond(builder.CreateAnd(myGmxCmp, myGmzCmp)); // my > mx && my > mz in texCube()
436 condBranch.ifCond(FPositive(builder, texcoords[1])); in texCube()
439 builder.CreateStore((texcoords[0]), sPtr); in texCube()
440 builder.CreateStore((texcoords[2]), tPtr); in texCube()
441 builder.CreateStore(builder.getInt32(2), facePtr); in texCube()
446 builder.CreateStore(texcoords[0], sPtr); in texCube()
447 builder.CreateStore(builder.CreateFNeg(texcoords[2]), tPtr); in texCube()
448 builder.CreateStore(builder.getInt32(3), facePtr); in texCube()
453 builder.CreateStore(my, maPtr); in texCube()
459 condBranch.ifCond(FPositive(builder, texcoords[2])); in texCube()
462 builder.CreateStore((texcoords[0]), sPtr); in texCube()
463 builder.CreateStore(builder.CreateFNeg(texcoords[1]), tPtr); in texCube()
464 builder.CreateStore(builder.getInt32(4), facePtr); in texCube()
469 builder.CreateStore(builder.CreateFNeg(texcoords[0]), sPtr); in texCube()
470 builder.CreateStore(builder.CreateFNeg(texcoords[1]), tPtr); in texCube()
471 builder.CreateStore(builder.getInt32(5), facePtr); in texCube()
476 builder.CreateStore(mz, maPtr); in texCube()
485 Value * s = builder.CreateLoad(sPtr); in texCube()
486 Value * t = builder.CreateLoad(tPtr); in texCube()
487 Value * ma = builder.CreateLoad(maPtr); in texCube()
488 Value * face = builder.CreateLoad(facePtr); in texCube()
490 s = builder.CreateFDiv(s, ma); in texCube()
491 s = builder.CreateFAdd(s, float1); in texCube()
492 s = builder.CreateFMul(s, float0_5); in texCube()
494 t = builder.CreateFDiv(t, ma); in texCube()
495 t = builder.CreateFAdd(t, float1); in texCube()
496 t = builder.CreateFMul(t, float0_5); in texCube()
500 Value * x = texcoordWrap(builder, gglCtx->textureState.textures[sampler].wrapS, in texCube()
502 Value * y = texcoordWrap(builder, gglCtx->textureState.textures[sampler].wrapT, in texCube()
504 Value * indexOffset = builder.CreateMul(builder.CreateMul(textureHeight, textureWidth), face); in texCube()
505 Value * index = builder.CreateAdd(builder.CreateMul(y, textureWidth), x); in texCube()
513 textureData = builder.CreateConstInBoundsGEP1_32(textureData, sampler); in texCube()
514 textureData = builder.CreateLoad(textureData); in texCube()
518 textureData = pointSample(builder, textureData, builder.CreateAdd(indexOffset, index), in texCube()
520 return intColorVecToFloatColorVec(builder, textureData); in texCube()
524 textureData = linearSample(builder, textureData, indexOffset, x, y, xLerp, yLerp, in texCube()
527 return intColorVecToFloatColorVec(builder, textureData); in texCube()