Lines Matching refs:builder
29 static void StencilOp(IRBuilder<> &builder, const unsigned char op, in StencilOp() argument
32 CondBranch condBranch(builder); in StencilOp()
33 Value * s = builder.CreateLoad(sPtr, "stenciOpS"); in StencilOp()
36 builder.CreateStore(builder.getInt8(0), sPtr); in StencilOp()
39 builder.CreateStore(s, sPtr); in StencilOp()
42 builder.CreateStore(sRef, sPtr); in StencilOp()
45 condBranch.ifCond(builder.CreateICmpEQ(s, builder.getInt8(255))); in StencilOp()
46 builder.CreateStore(s, sPtr); in StencilOp()
48 builder.CreateStore(builder.CreateAdd(s, builder.getInt8(1)), sPtr); in StencilOp()
52 condBranch.ifCond(builder.CreateICmpEQ(s, builder.getInt8(0))); in StencilOp()
53 builder.CreateStore(s, sPtr); in StencilOp()
55 builder.CreateStore(builder.CreateSub(s, builder.getInt8(1)), sPtr); in StencilOp()
59 builder.CreateStore(builder.CreateNot(s), sPtr); in StencilOp()
62 builder.CreateStore(builder.CreateAdd(s, builder.getInt8(1)), sPtr); in StencilOp()
65 builder.CreateStore(builder.CreateSub(s, builder.getInt8(1)), sPtr); in StencilOp()
73 static Value * StencilOp(IRBuilder<> & builder, Value * face, in StencilOp() argument
77 CondBranch condBranch(builder); in StencilOp()
79 condBranch.ifCond(builder.CreateICmpEQ(face, builder.getInt8(0))); in StencilOp()
81 StencilOp(builder, frontOp, sPtr, sRef); in StencilOp()
85 StencilOp(builder, backOp, sPtr, sRef); in StencilOp()
88 return builder.CreateLoad(sPtr); in StencilOp()
91 static void StencilFunc(IRBuilder<> & builder, const unsigned char func, in StencilFunc() argument
96 builder.CreateStore(builder.getFalse(), sCmpPtr); in StencilFunc()
99 builder.CreateStore(builder.CreateICmpULT(sRef, s), sCmpPtr); in StencilFunc()
102 builder.CreateStore(builder.CreateICmpEQ(sRef, s), sCmpPtr); in StencilFunc()
105 builder.CreateStore(builder.CreateICmpULE(sRef, s), sCmpPtr); in StencilFunc()
108 builder.CreateStore(builder.CreateICmpUGT(sRef, s), sCmpPtr); in StencilFunc()
111 builder.CreateStore(builder.CreateICmpNE(sRef, s), sCmpPtr); in StencilFunc()
114 builder.CreateStore(builder.CreateICmpUGE(sRef, s), sCmpPtr); in StencilFunc()
117 builder.CreateStore(builder.getTrue(), sCmpPtr); in StencilFunc()
128 Value * sOne, const bool isVector, IRBuilder<> & builder) in BlendFactor() argument
142 factor = builder.CreateSub(one, src); in BlendFactor()
148 factor = builder.CreateSub(one, dst); in BlendFactor()
153 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
156 factor = builder.CreateSub(sOne, srcA); in BlendFactor()
158 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
163 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
166 factor = builder.CreateSub(sOne, dstA); in BlendFactor()
168 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
172 factor = minIntScalar(builder, srcA, builder.CreateSub(sOne, dstA)); in BlendFactor()
174 factor = intVec(builder, factor, factor, factor, sOne); in BlendFactor()
182 factor = builder.CreateSub(one, constant); in BlendFactor()
187 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
190 factor = builder.CreateSub(sOne, constantA); in BlendFactor()
192 factor = intVec(builder, factor, factor, factor, factor); in BlendFactor()
201 static Value * Saturate(IRBuilder<> & builder, Value * intVector) in Saturate() argument
203 intVector = intVecMax(builder, intVector, constIntVec(builder, 0,0,0,0)); in Saturate()
204 return intVecMin(builder, intVector, constIntVec(builder, 255,255,255,255)); in Saturate()
209 static Value * IntVectorToScreenColor(IRBuilder<> & builder, const GGLPixelFormat format, Value * s… in IntVectorToScreenColor() argument
212 src = builder.CreateShl(src, constIntVec(builder, 0, 8, 16, 24)); in IntVectorToScreenColor()
213 std::vector<Value *> comps = extractVector(builder, src); in IntVectorToScreenColor()
214 comps[0] = builder.CreateOr(comps[0], comps[1]); in IntVectorToScreenColor()
215 comps[0] = builder.CreateOr(comps[0], comps[2]); in IntVectorToScreenColor()
216 comps[0] = builder.CreateOr(comps[0], comps[3]); in IntVectorToScreenColor()
219 src = builder.CreateAnd(src, constIntVec(builder, 0xf8, 0xfc, 0xf8, 0)); in IntVectorToScreenColor()
220 std::vector<Value *> comps = extractVector(builder, src); in IntVectorToScreenColor()
223 comps[i] = builder.CreateTrunc(comps[i], builder.getInt16Ty()); in IntVectorToScreenColor()
224 comps[2] = builder.CreateLShr(comps[2], 3); in IntVectorToScreenColor()
225 comps[1] = builder.CreateShl(comps[1], 3); in IntVectorToScreenColor()
226 comps[0] = builder.CreateShl(comps[0], 8); in IntVectorToScreenColor()
228 comps[0] = builder.CreateOr(comps[0], comps[1]); in IntVectorToScreenColor()
229 comps[0] = builder.CreateOr(comps[0], comps[2]); in IntVectorToScreenColor()
232 return builder.getInt32(0); in IntVectorToScreenColor()
240 static Value * ScreenColorToIntVector(IRBuilder<> & builder, const GGLPixelFormat format, Value * s… in ScreenColorToIntVector() argument
242 src = builder.CreateZExt(src, builder.getInt32Ty()); in ScreenColorToIntVector()
243 Value * dst = intVec(builder, src, src, src, src); in ScreenColorToIntVector()
245 dst = builder.CreateLShr(dst, constIntVec(builder, 0, 8, 16, 24)); in ScreenColorToIntVector()
246 dst = builder.CreateAnd(dst, constIntVec(builder, 0xff, 0xff, 0xff, 0xff)); in ScreenColorToIntVector()
249 dst = builder.CreateAnd(dst, constIntVec(builder, 0xf800, 0x7e0, 0x1f, 0)); in ScreenColorToIntVector()
250 dst = builder.CreateLShr(dst, constIntVec(builder, 8, 3, 0, 0)); in ScreenColorToIntVector()
251 dst = builder.CreateShl(dst, constIntVec(builder, 0, 0, 3, 0)); in ScreenColorToIntVector()
252 dst = builder.CreateOr(dst, constIntVec(builder, 0, 0, 0, 0xff)); in ScreenColorToIntVector()
262 IRBuilder<> & builder, Value * src, Value * dst) in GenerateFSBlend() argument
264 Type * const intType = builder.getInt32Ty(); in GenerateFSBlend()
276 src = builder.CreateFMul(src, constFloatVec(builder,255,255,255,255)); in GenerateFSBlend()
277 src = builder.CreateFPToSI(src, intVecType(builder)); in GenerateFSBlend()
278 src = Saturate(builder, src); in GenerateFSBlend()
279 src = IntVectorToScreenColor(builder, format, src); in GenerateFSBlend()
323 src = builder.CreateFMul(src, constFloatVec(builder,255,255,255,255)); in GenerateFSBlend()
324 src = builder.CreateFPToSI(src, intVecType(builder)); in GenerateFSBlend()
329 Value * const one = constIntVec(builder,255,255,255,255); in GenerateFSBlend()
330 Value * const zero = constIntVec(builder,0,0,0,0); in GenerateFSBlend()
331 Value * const sOne = builder.getInt32(255); in GenerateFSBlend()
332 Value * const sZero = builder.getInt32(0); in GenerateFSBlend()
335 Value * constant = constIntVec(builder,gglCtx->blendState.color[0], in GenerateFSBlend()
344 Value * srcA = extractVector(builder,src)[3]; in GenerateFSBlend()
345 Value * dstA = extractVector(builder,dst)[3]; in GenerateFSBlend()
346 Value * constantA = extractVector(builder,constant)[3]; in GenerateFSBlend()
350 constantA, sOne, true, builder); in GenerateFSBlend()
354 constantA, sOne, false, builder); in GenerateFSBlend()
355 sf = builder.CreateInsertElement(sf, sfA, builder.getInt32(3), in GenerateFSBlend()
361 constantA, sOne, true, builder); in GenerateFSBlend()
365 constantA, sOne, false, builder); in GenerateFSBlend()
366 df = builder.CreateInsertElement(df, dfA, builder.getInt32(3), in GenerateFSBlend()
371 sf = builder.CreateAdd(sf, builder.CreateLShr(sf, constIntVec(builder,7,7,7,7))); in GenerateFSBlend()
372 df = builder.CreateAdd(df, builder.CreateLShr(df, constIntVec(builder,7,7,7,7))); in GenerateFSBlend()
374 src = builder.CreateMul(src, sf); in GenerateFSBlend()
375 dst = builder.CreateMul(dst, df); in GenerateFSBlend()
380 res = builder.CreateAdd(src, dst); in GenerateFSBlend()
383 res = builder.CreateSub(src, dst); in GenerateFSBlend()
386 res = builder.CreateSub(dst, src); in GenerateFSBlend()
393 srcA = extractVector(builder,src)[3]; in GenerateFSBlend()
394 dstA = extractVector(builder,dst)[3]; in GenerateFSBlend()
398 resA = builder.CreateAdd(srcA, dstA); in GenerateFSBlend()
401 resA = builder.CreateSub(srcA, dstA); in GenerateFSBlend()
404 resA = builder.CreateSub(dstA, srcA); in GenerateFSBlend()
410 res = builder.CreateInsertElement(res, resA, builder.getInt32(3), in GenerateFSBlend()
414 res = builder.CreateAShr(res, constIntVec(builder,8,8,8,8)); in GenerateFSBlend()
415 res = Saturate(builder, res); in GenerateFSBlend()
416 res = IntVectorToScreenColor(builder, format, res); in GenerateFSBlend()
420 static FunctionType * ScanLineFunctionType(IRBuilder<> & builder) in ScanLineFunctionType() argument
423 VectorType * vectorType = floatVecType(builder); in ScanLineFunctionType()
425 Type * intType = builder.getInt32Ty(); in ScanLineFunctionType()
427 PointerType * bytePointerType = PointerType::get(builder.getInt8Ty(), 0); in ScanLineFunctionType()
438 FunctionType *functionType = FunctionType::get(/*Result=*/builder.getVoidTy(), in ScanLineFunctionType()
451 IRBuilder<> builder(mod->getContext()); in GenerateScanLine() local
454 Type * intType = builder.getInt32Ty(); in GenerateScanLine()
456 Type * byteType = builder.getInt8Ty(); in GenerateScanLine()
464 ScanLineFunctionType(builder))); in GenerateScanLine()
466 BasicBlock *label_entry = BasicBlock::Create(builder.getContext(), "entry", func, 0); in GenerateScanLine()
467 builder.SetInsertPoint(label_entry); in GenerateScanLine()
468 CondBranch condBranch(builder); in GenerateScanLine()
479 Value * framePtr = builder.CreateAlloca(intPointerType); in GenerateScanLine()
480 builder.CreateStore(args++, framePtr); in GenerateScanLine()
481 Value * depthPtr = builder.CreateAlloca(intPointerType); in GenerateScanLine()
482 builder.CreateStore(args++, depthPtr); in GenerateScanLine()
483 Value * stencilPtr = builder.CreateAlloca(bytePointerType); in GenerateScanLine()
484 builder.CreateStore(args++, stencilPtr); in GenerateScanLine()
487 Value * countPtr = builder.CreateAlloca(intType); in GenerateScanLine()
488 builder.CreateStore(args++, countPtr); in GenerateScanLine()
492 sFace = builder.CreateLoad(builder.CreateConstInBoundsGEP1_32(stencilState, 0), "sFace"); in GenerateScanLine()
494 sRef = builder.getInt8(gglCtx->frontStencil.ref); in GenerateScanLine()
496 sRef = builder.CreateLoad(builder.CreateConstInBoundsGEP1_32(stencilState, 1), "sRef"); in GenerateScanLine()
498 sMask = builder.getInt8(gglCtx->frontStencil.mask); in GenerateScanLine()
500 sMask = builder.CreateLoad(builder.CreateConstInBoundsGEP1_32(stencilState, 2), "sMask"); in GenerateScanLine()
502 sFunc = builder.getInt8(gglCtx->frontStencil.func); in GenerateScanLine()
504 sFunc = builder.CreateLoad(builder.CreateConstInBoundsGEP1_32(stencilState, 3), "sFunc"); in GenerateScanLine()
513 frame = builder.CreateLoad(framePtr); in GenerateScanLine()
515 frame = builder.CreateLoad(framePtr); in GenerateScanLine()
516 frame = builder.CreateBitCast(frame, PointerType::get(builder.getInt16Ty(), 0)); in GenerateScanLine()
518 frame = builder.CreateLoad(framePtr); // color buffer not set yet in GenerateScanLine()
526 depth = builder.CreateLoad(depthPtr); in GenerateScanLine()
530 Value * count = builder.CreateLoad(countPtr); in GenerateScanLine()
533 Value * cmp = builder.CreateICmpEQ(count, builder.getInt32(0)); in GenerateScanLine()
540 stencil = builder.CreateLoad(stencilPtr); in GenerateScanLine()
544 sCmpPtr = builder.CreateAlloca(builder.getInt1Ty()); in GenerateScanLine()
546 sPtr = builder.CreateAlloca(byteType); in GenerateScanLine()
549 s = builder.CreateLoad(stencil); in GenerateScanLine()
550 s = builder.CreateAnd(s, sMask); in GenerateScanLine()
551 builder.CreateStore(s, sPtr); in GenerateScanLine()
554 condBranch.ifCond(builder.CreateICmpEQ(sFace, builder.getInt8(0))); in GenerateScanLine()
556 StencilFunc(builder, gglCtx->frontStencil.func, s, sRef, sCmpPtr); in GenerateScanLine()
560 StencilFunc(builder, gglCtx->backStencil.func, s, sRef, sCmpPtr); in GenerateScanLine()
564 sCmp = builder.CreateLoad(sCmpPtr); in GenerateScanLine()
571 depthZ = builder.CreateLoad(depth, "depthZ"); // z stored in buffer in GenerateScanLine()
572 zPtr = builder.CreateAlloca(intType); // temp store for modifying incoming z in GenerateScanLine()
576 z = builder.CreateBitCast(start, intPointerType); in GenerateScanLine()
577 z = builder.CreateConstInBoundsGEP1_32(z, (GGL_FS_INPUT_OFFSET + in GenerateScanLine()
579 z = builder.CreateLoad(z, "z"); in GenerateScanLine()
581 builder.CreateStore(z, zPtr); in GenerateScanLine()
583 Value * zNegative = builder.CreateICmpSLT(z, builder.getInt32(0)); in GenerateScanLine()
586 z = builder.CreateXor(z, builder.getInt32(0x7fffffff)); in GenerateScanLine()
587 builder.CreateStore(z, zPtr); in GenerateScanLine()
591 z = builder.CreateLoad(zPtr, "z"); in GenerateScanLine()
598 zCmp = builder.CreateICmpSLT(z, depthZ); in GenerateScanLine()
601 zCmp = builder.CreateICmpEQ(z, depthZ); in GenerateScanLine()
604 zCmp = builder.CreateICmpSLE(z, depthZ); in GenerateScanLine()
607 zCmp = builder.CreateICmpSGT(z, depthZ); in GenerateScanLine()
610 zCmp = builder.CreateICmpNE(z, depthZ); in GenerateScanLine()
613 zCmp = builder.CreateICmpSGE(z, depthZ); in GenerateScanLine()
632 Value * fsOutputs = builder.CreateConstInBoundsGEP1_32(start, in GenerateScanLine()
637 CallInst *call = builder.CreateCall3(fsFunction,inputs, outputs, constants); in GenerateScanLine()
641 Value * dst = Constant::getNullValue(intVecType(builder)); in GenerateScanLine()
643 Value * frameColor = builder.CreateLoad(frame, "frameColor"); in GenerateScanLine()
644 dst = ScreenColorToIntVector(builder, gglCtx->bufferState.colorFormat, frameColor); in GenerateScanLine()
647 Value * src = builder.CreateConstInBoundsGEP1_32(fsOutputs, 0); in GenerateScanLine()
648 src = builder.CreateLoad(src); in GenerateScanLine()
650 …nerateFSBlend(gglCtx, gglCtx->bufferState.colorFormat,/*&prog->outputRegDesc,*/ builder, src, dst); in GenerateScanLine()
651 builder.CreateStore(color, frame); in GenerateScanLine()
654 z = builder.CreateBitCast(z, intType); in GenerateScanLine()
655 builder.CreateStore(z, depth); // store z in GenerateScanLine()
659 builder.CreateStore(StencilOp(builder, sFace, gglCtx->frontStencil.dPass, in GenerateScanLine()
665 builder.CreateStore(StencilOp(builder, sFace, gglCtx->frontStencil.dFail, in GenerateScanLine()
671 builder.CreateStore(StencilOp(builder, sFace, gglCtx->frontStencil.sFail, in GenerateScanLine()
676 frame = builder.CreateConstInBoundsGEP1_32(frame, 1); // frame++ in GenerateScanLine()
678 frame = builder.CreateBitCast(frame, PointerType::get(builder.getInt32Ty(), 0)); in GenerateScanLine()
679 builder.CreateStore(frame, framePtr); in GenerateScanLine()
681 depth = builder.CreateConstInBoundsGEP1_32(depth, 1); // depth++ in GenerateScanLine()
682 builder.CreateStore(depth, depthPtr); in GenerateScanLine()
685 stencil = builder.CreateConstInBoundsGEP1_32(stencil, 1); // stencil++ in GenerateScanLine()
686 builder.CreateStore(stencil, stencilPtr); in GenerateScanLine()
690 vPtr = builder.CreateConstInBoundsGEP1_32(start, GGL_FS_INPUT_OFFSET + in GenerateScanLine()
692 v = builder.CreateLoad(vPtr); in GenerateScanLine()
693 dx = builder.CreateConstInBoundsGEP1_32(step, GGL_FS_INPUT_OFFSET + in GenerateScanLine()
695 dx = builder.CreateLoad(dx); in GenerateScanLine()
696 v = builder.CreateFAdd(v, dx); in GenerateScanLine()
697 builder.CreateStore(v, vPtr); in GenerateScanLine()
699 Type * floatType = builder.getFloatTy(); in GenerateScanLine()
701 vPtr = builder.CreateBitCast(start, floatPointerType); in GenerateScanLine()
702 vPtr = builder.CreateConstInBoundsGEP1_32(vPtr, in GenerateScanLine()
704 v = builder.CreateLoad(vPtr); in GenerateScanLine()
705 dx = builder.CreateBitCast(step, floatPointerType); in GenerateScanLine()
706 dx = builder.CreateConstInBoundsGEP1_32(dx, in GenerateScanLine()
708 dx = builder.CreateLoad(dx); in GenerateScanLine()
709 v = builder.CreateFAdd(v, dx); in GenerateScanLine()
710 builder.CreateStore(v, vPtr); in GenerateScanLine()
714 vPtr = builder.CreateConstInBoundsGEP1_32(start, GGL_FS_INPUT_OFFSET + in GenerateScanLine()
716 v = builder.CreateLoad(vPtr); in GenerateScanLine()
717 dx = builder.CreateConstInBoundsGEP1_32(step, GGL_FS_INPUT_OFFSET + in GenerateScanLine()
719 dx = builder.CreateLoad(dx); in GenerateScanLine()
720 v = builder.CreateFAdd(v, dx); in GenerateScanLine()
721 builder.CreateStore(v, vPtr); in GenerateScanLine()
725 …vPtr = builder.CreateConstInBoundsGEP1_32(start, offsetof(VertexOutput,varyings)/sizeof(Vector4) +… in GenerateScanLine()
726 v = builder.CreateLoad(vPtr); in GenerateScanLine()
727 dx = builder.CreateConstInBoundsGEP1_32(step, GGL_FS_INPUT_OFFSET + in GenerateScanLine()
729 dx = builder.CreateLoad(dx); in GenerateScanLine()
730 v = builder.CreateFAdd(v, dx); in GenerateScanLine()
731 builder.CreateStore(v, vPtr); in GenerateScanLine()
734 count = builder.CreateSub(count, builder.getInt32(1)); in GenerateScanLine()
735 builder.CreateStore(count, countPtr); // count--; in GenerateScanLine()
739 builder.CreateRetVoid(); in GenerateScanLine()