这篇教程C++ swizzle函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中swizzle函数的典型用法代码示例。如果您正苦于以下问题:C++ swizzle函数的具体用法?C++ swizzle怎么用?C++ swizzle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了swizzle函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: i915_emit_const1fuinti915_emit_const1f(struct i915_fp_compile * p, float c0){ struct i915_fragment_shader *ifs = p->shader; unsigned reg, idx; if (c0 == 0.0) return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO); if (c0 == 1.0) return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE); for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (ifs->constant_flags[reg] == I915_CONSTFLAG_USER) continue; for (idx = 0; idx < 4; idx++) { if (!(ifs->constant_flags[reg] & (1 << idx)) || ifs->constants[reg][idx] == c0) { ifs->constants[reg][idx] = c0; ifs->constant_flags[reg] |= 1 << idx; if (reg + 1 > ifs->num_constants) ifs->num_constants = reg + 1; return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE); } } } i915_program_error(p, "i915_emit_const1f: out of constants"); return 0;}
开发者ID:ChillyWillyGuru,项目名称:RSXGL,代码行数:29,
示例2: i915_emit_const1fGLuinti915_emit_const1f(struct i915_fragment_program * p, GLfloat c0){ GLint reg, idx; if (c0 == 0.0) return swizzle(UREG(REG_TYPE_R, 0), ZERO, ZERO, ZERO, ZERO); if (c0 == 1.0) return swizzle(UREG(REG_TYPE_R, 0), ONE, ONE, ONE, ONE); for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == I915_CONSTFLAG_PARAM) continue; for (idx = 0; idx < 4; idx++) { if (!(p->constant_flags[reg] & (1 << idx)) || p->constant[reg][idx] == c0) { p->constant[reg][idx] = c0; p->constant_flags[reg] |= 1 << idx; if (reg + 1 > p->nr_constants) p->nr_constants = reg + 1; return swizzle(UREG(REG_TYPE_CONST, reg), idx, ZERO, ZERO, ONE); } } } fprintf(stderr, "%s: out of constants/n", __FUNCTION__); p->error = 1; return 0;}
开发者ID:Starlink,项目名称:mesa,代码行数:29,
示例3: updatePolyhedron void updatePolyhedron(const Vec3& current) { const Grid& grid = m_tool->grid(); const Math::Axis::Type axis = m_plane.normal.firstComponent(); const Plane3 swizzledPlane(swizzle(m_plane.anchor(), axis), swizzle(m_plane.normal, axis)); const Vec3 theMin = swizzle(grid.snapDown(min(m_initialPoint, current)), axis); const Vec3 theMax = swizzle(grid.snapUp (max(m_initialPoint, current)), axis); const Vec2 topLeft2(theMin.x(), theMin.y()); const Vec2 topRight2(theMax.x(), theMin.y()); const Vec2 bottomLeft2(theMin.x(), theMax.y()); const Vec2 bottomRight2(theMax.x(), theMax.y()); const Vec3 topLeft3 = unswizzle(Vec3(topLeft2, swizzledPlane.zAt(topLeft2)), axis); const Vec3 topRight3 = unswizzle(Vec3(topRight2, swizzledPlane.zAt(topRight2)), axis); const Vec3 bottomLeft3 = unswizzle(Vec3(bottomLeft2, swizzledPlane.zAt(bottomLeft2)), axis); const Vec3 bottomRight3 = unswizzle(Vec3(bottomRight2, swizzledPlane.zAt(bottomRight2)), axis); Polyhedron3 polyhedron = m_oldPolyhedron; polyhedron.addPoint(topLeft3); polyhedron.addPoint(bottomLeft3); polyhedron.addPoint(bottomRight3); polyhedron.addPoint(topRight3); m_tool->update(polyhedron); }
开发者ID:Gustavo6046,项目名称:TrenchBroom,代码行数:25,
示例4: transform_DST/** * [1, src0.y*src1.y, src0.z, src1.w] * So basically MUL with lotsa swizzling. */static void transform_DST(struct radeon_compiler* c, struct rc_instruction* inst){ emit2(c, inst->Prev, RC_OPCODE_MUL, inst->U.I.SaturateMode, inst->U.I.DstReg, swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_ONE, RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_ONE), swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_ONE, RC_SWIZZLE_Y, RC_SWIZZLE_ONE, RC_SWIZZLE_W)); rc_remove_instruction(inst);}
开发者ID:nikai3d,项目名称:mesa,代码行数:12,
示例5: transform_XPDstatic void transform_XPD(struct radeon_compiler* c, struct rc_instruction* inst){ struct rc_dst_register dst = try_to_reuse_dst(c, inst); emit2(c, inst->Prev, RC_OPCODE_MUL, 0, dst, swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_W), swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_W)); emit3(c, inst->Prev, RC_OPCODE_MAD, inst->U.I.SaturateMode, inst->U.I.DstReg, swizzle(inst->U.I.SrcReg[0], RC_SWIZZLE_Y, RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_W), swizzle(inst->U.I.SrcReg[1], RC_SWIZZLE_Z, RC_SWIZZLE_X, RC_SWIZZLE_Y, RC_SWIZZLE_W), negate(srcreg(RC_FILE_TEMPORARY, dst.Index))); rc_remove_instruction(inst);}
开发者ID:nikai3d,项目名称:mesa,代码行数:15,
示例6: testint test(lua_State *L) { float data[12] = {0., 1., 2., 3., 4., 5., 6., 7., 8., 9., 10., 11.}; float out_data[12]; VecN<float, 6> *v_in = (VecN<float, 6> *)data; VecN<float, 6> *v_out = (VecN<float, 6> *)out_data; for(int i=0; i < 2; i++) { int oo[] = {1, 0}; int ii[] = {0, 1}; MAT(v_out) = MAT(v_in)+MAT(v_in); swizzle(MAT(v_out), MAT(v_in), 2, oo, ii); v_in++; v_out++; } for(int j=0; j < 12; j++) { printf("j: %f/n", out_data[j]); } /* Vec3<char> v1c(64, 123, 5); v1c = v1c*0.5; printf("t: %d %d %d/n", v1c.x, v1c.y, v1c.z); */ return 0;}
开发者ID:LuaAV,项目名称:LuaAV,代码行数:26,
示例7: whilevoid *accessorThread(void *arg){ int *result = (int*)malloc(sizeof(int));; *result = 0; while(*result < MAXVAL){ swizzle(result); usleep(10 + (rand() % 100) ); } pthread_exit(result); }
开发者ID:Dongwan,项目名称:MultiCacheSim,代码行数:12,
示例8: klee_make_symbolicvoid *accessorThread(void *arg){ int *result = (int*)malloc(sizeof(int)); klee_make_symbolic(result, sizeof(int), "result"); *result = 0; while(*result < MAXVAL){ swizzle(result); usleep(10 + (rand() % 100) ); } pthread_exit(result);}
开发者ID:pansot2,项目名称:symbiosis,代码行数:12,
示例9: fixup_depth_write/* Rather than trying to intercept and jiggle depth writes during * emit, just move the value into its correct position at the end of * the program: */static voidfixup_depth_write(struct i915_fragment_program *p){ if (p->depth_written) { GLuint depth = UREG(REG_TYPE_OD, 0); i915_emit_arith(p, A0_MOV, depth, A0_DEST_CHANNEL_W, 0, swizzle(depth, X, Y, Z, Z), 0, 0); }}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:16,
示例10: emit_combine_sourcestatic GLuint emit_combine_source( struct i915_fragment_program *p, GLuint mask, GLuint unit, GLenum source, GLenum operand ){ GLuint arg, src; src = get_source(p, source, unit); switch (operand) { case GL_ONE_MINUS_SRC_COLOR: /* Get unused tmp, * Emit tmp = 1.0 + arg.-x-y-z-w */ arg = i915_get_temp( p ); return i915_emit_arith( p, A0_ADD, arg, mask, 0, swizzle(src, ONE, ONE, ONE, ONE ), negate(src, 1,1,1,1), 0); case GL_SRC_ALPHA: if (mask == A0_DEST_CHANNEL_W) return src; else return swizzle( src, W, W, W, W ); case GL_ONE_MINUS_SRC_ALPHA: /* Get unused tmp, * Emit tmp = 1.0 + arg.-w-w-w-w */ arg = i915_get_temp( p ); return i915_emit_arith( p, A0_ADD, arg, mask, 0, swizzle(src, ONE, ONE, ONE, ONE ), negate( swizzle(src,W,W,W,W), 1,1,1,1), 0); case GL_SRC_COLOR: default: return src; }}
开发者ID:Magister,项目名称:x11rdp_xorg71,代码行数:38,
示例11: i915_emit_const2fuinti915_emit_const2f(struct i915_fp_compile * p, float c0, float c1){ struct i915_fragment_shader *ifs = p->shader; unsigned reg, idx; if (c0 == 0.0) return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W); if (c0 == 1.0) return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W); if (c1 == 0.0) return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W); if (c1 == 1.0) return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W); // XXX emit swizzle here for 0, 1, -1 and any combination thereof // we can use swizzle + neg for that for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (ifs->constant_flags[reg] == 0xf || ifs->constant_flags[reg] == I915_CONSTFLAG_USER) continue; for (idx = 0; idx < 3; idx++) { if (!(ifs->constant_flags[reg] & (3 << idx))) { ifs->constants[reg][idx + 0] = c0; ifs->constants[reg][idx + 1] = c1; ifs->constant_flags[reg] |= 3 << idx; if (reg + 1 > ifs->num_constants) ifs->num_constants = reg + 1; return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO, ONE); } } } i915_program_error(p, "i915_emit_const2f: out of constants"); return 0;}
开发者ID:ChillyWillyGuru,项目名称:RSXGL,代码行数:37,
示例12: i915_emit_const2fGLuinti915_emit_const2f(struct i915_fragment_program * p, GLfloat c0, GLfloat c1){ GLint reg, idx; if (c0 == 0.0) return swizzle(i915_emit_const1f(p, c1), ZERO, X, Z, W); if (c0 == 1.0) return swizzle(i915_emit_const1f(p, c1), ONE, X, Z, W); if (c1 == 0.0) return swizzle(i915_emit_const1f(p, c0), X, ZERO, Z, W); if (c1 == 1.0) return swizzle(i915_emit_const1f(p, c0), X, ONE, Z, W); for (reg = 0; reg < I915_MAX_CONSTANT; reg++) { if (p->constant_flags[reg] == 0xf || p->constant_flags[reg] == I915_CONSTFLAG_PARAM) continue; for (idx = 0; idx < 3; idx++) { if (!(p->constant_flags[reg] & (3 << idx))) { p->constant[reg][idx] = c0; p->constant[reg][idx + 1] = c1; p->constant_flags[reg] |= 3 << idx; if (reg + 1 > p->nr_constants) p->nr_constants = reg + 1; return swizzle(UREG(REG_TYPE_CONST, reg), idx, idx + 1, ZERO, ONE); } } } fprintf(stderr, "%s: out of constants/n", __func__); p->error = 1; return 0;}
开发者ID:Unr34ler,项目名称:mesa,代码行数:36,
示例13: i915_fixup_depth_write/** * Rather than trying to intercept and jiggle depth writes during * emit, just move the value into its correct position at the end of * the program: */static voidi915_fixup_depth_write(struct i915_fp_compile *p){ /* XXX assuming pos/depth is always in output[0] */ if (p->shader->info.output_semantic_name[0] == TGSI_SEMANTIC_POSITION) { const uint depth = UREG(REG_TYPE_OD, 0); i915_emit_arith(p, A0_MOV, /* opcode */ depth, /* dest reg */ A0_DEST_CHANNEL_W, /* write mask */ 0, /* saturate? */ swizzle(depth, X, Y, Z, Z), /* src0 */ 0, 0 /* src1, src2 */); }}
开发者ID:freedesktop-unofficial-mirror,项目名称:openchrome__mesa-openchrome,代码行数:21,
示例14: emit_program_finistatic void emit_program_fini( struct i915_fragment_program *p ){ int cf = get_source( p, GL_PREVIOUS, 0 ); int out = UREG( REG_TYPE_OC, 0 ); if (p->ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) { /* Emit specular add. */ GLuint s = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_ALL); i915_emit_arith( p, A0_ADD, out, A0_DEST_CHANNEL_ALL, 0, cf, swizzle(s, X,Y,Z,ZERO), 0 ); } else if (cf != out) { /* Will wind up in here if no texture enabled or a couple of * other scenarios (GL_REPLACE for instance). */ i915_emit_arith( p, A0_MOV, out, A0_DEST_CHANNEL_ALL, 0, cf, 0, 0 ); }}
开发者ID:Magister,项目名称:x11rdp_xorg71,代码行数:19,
示例15: src_vector/** * Retrieve a ureg for the given source register. Will emit * constants, apply swizzling and negation as needed. */static GLuint src_vector( const struct fp_src_register *source ){ GLuint src; assert(source->Index < 32); /* limitiation of UREG representation */ src = UREG( src_reg_file( source->File ), source->Index ); src = swizzle(src, _X + source->Swizzle[0], _X + source->Swizzle[1], _X + source->Swizzle[2], _X + source->Swizzle[3]); if (source->NegateBase) src = negate( src, 1,1,1,1 ); return src;}
开发者ID:Ionic,项目名称:nx-libs,代码行数:23,
示例16: unlinkBlock/* Remove a block from a given list. Does no sanity checking. */staticvoid unlinkBlock ( Arena* a, UInt* b, Int listno ){ vg_assert(listno >= 0 && listno < VG_N_MALLOC_LISTS); if (get_prev_p(b) == b) { /* Only one element in the list; treat it specially. */ vg_assert(get_next_p(b) == b); a->freelist[listno] = NULL; } else { UInt* b_prev = get_prev_p(b); UInt* b_next = get_next_p(b); a->freelist[listno] = b_prev; set_next_p(b_prev, b_next); set_prev_p(b_next, b_prev); swizzle ( a, listno ); } set_prev_p(b, NULL); set_next_p(b, NULL);}
开发者ID:svn2github,项目名称:valgrind-3,代码行数:20,
示例17: build_sphere_texgenstatic void build_sphere_texgen( struct tnl_program *p, struct ureg dest, GLuint writemask ){ struct ureg normal = get_transformed_normal(p); struct ureg eye_hat = get_eye_position_normalized(p); struct ureg tmp = get_temp(p); struct ureg half = register_scalar_const(p, .5); struct ureg r = get_temp(p); struct ureg inv_m = get_temp(p); struct ureg id = get_identity_param(p); /* Could share the above calculations, but it would be * a fairly odd state for someone to set (both sphere and * reflection active for different texture coordinate * components. Of course - if two texture units enable * reflect and/or sphere, things start to tilt in favour * of seperating this out: */ /* n.u */ emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); /* 2n.u */ emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); /* (-2n.u)n + u */ emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); /* r + 0,0,1 */ emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); /* rx^2 + ry^2 + (rz+1)^2 */ emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); /* 2/m */ emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); /* 1/m */ emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); /* r/m + 1/2 */ emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); release_temp(p, tmp); release_temp(p, r); release_temp(p, inv_m);}
开发者ID:toastpp,项目名称:toastpp,代码行数:41,
示例18: swizzle_wir_swizzle *swizzle_w(operand a){ return swizzle(a, SWIZZLE_WWWW, 1);}
开发者ID:NatTuck,项目名称:mesa,代码行数:5,
示例19: src_vector/** * Retrieve a ureg for the given source register. Will emit * constants, apply swizzling and negation as needed. */static GLuintsrc_vector(struct i915_fragment_program *p, const struct prog_src_register *source, const struct gl_fragment_program *program){ GLuint src; switch (source->File) { /* Registers: */ case PROGRAM_TEMPORARY: if (source->Index >= I915_MAX_TEMPORARY) { i915_program_error(p, "Exceeded max temporary reg"); return 0; } src = UREG(REG_TYPE_R, source->Index); break; case PROGRAM_INPUT: switch (source->Index) { case FRAG_ATTRIB_WPOS: src = i915_emit_decl(p, REG_TYPE_T, p->wpos_tex, D0_CHANNEL_ALL); break; case FRAG_ATTRIB_COL0: src = i915_emit_decl(p, REG_TYPE_T, T_DIFFUSE, D0_CHANNEL_ALL); break; case FRAG_ATTRIB_COL1: src = i915_emit_decl(p, REG_TYPE_T, T_SPECULAR, D0_CHANNEL_XYZ); src = swizzle(src, X, Y, Z, ONE); break; case FRAG_ATTRIB_FOGC: src = i915_emit_decl(p, REG_TYPE_T, T_FOG_W, D0_CHANNEL_W); src = swizzle(src, W, ZERO, ZERO, ONE); break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: case FRAG_ATTRIB_TEX2: case FRAG_ATTRIB_TEX3: case FRAG_ATTRIB_TEX4: case FRAG_ATTRIB_TEX5: case FRAG_ATTRIB_TEX6: case FRAG_ATTRIB_TEX7: src = i915_emit_decl(p, REG_TYPE_T, T_TEX0 + (source->Index - FRAG_ATTRIB_TEX0), D0_CHANNEL_ALL); break; default: i915_program_error(p, "Bad source->Index"); return 0; } break; /* Various paramters and env values. All emitted to * hardware as program constants. */ case PROGRAM_LOCAL_PARAM: src = i915_emit_param4fv(p, program->Base.LocalParams[source->Index]); break; case PROGRAM_ENV_PARAM: src = i915_emit_param4fv(p, p->ctx->FragmentProgram.Parameters[source-> Index]); break; case PROGRAM_CONSTANT: case PROGRAM_STATE_VAR: case PROGRAM_NAMED_PARAM: src = i915_emit_param4fv(p, program->Base.Parameters->ParameterValues[source-> Index]); break; default: i915_program_error(p, "Bad source->File"); return 0; } src = swizzle(src, GET_SWZ(source->Swizzle, 0), GET_SWZ(source->Swizzle, 1), GET_SWZ(source->Swizzle, 2), GET_SWZ(source->Swizzle, 3)); if (source->NegateBase) src = negate(src, GET_BIT(source->NegateBase, 0), GET_BIT(source->NegateBase, 1), GET_BIT(source->NegateBase, 2), GET_BIT(source->NegateBase, 3)); return src;}
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:99,
示例20: upload_program/* Possible concerns: * * SIN, COS -- could use another taylor step? * LIT -- results seem a little different to sw mesa * LOG -- different to mesa on negative numbers, but this is conformant. * * Parse failures -- Mesa doesn't currently give a good indication * internally whether a particular program string parsed or not. This * can lead to confusion -- hopefully we cope with it ok now. * */static voidupload_program(struct i915_fragment_program *p){ const struct gl_fragment_program *program = p->ctx->FragmentProgram._Current; const struct prog_instruction *inst = program->Base.Instructions;/* _mesa_debug_fp_inst(program->Base.NumInstructions, inst); */ /* Is this a parse-failed program? Ensure a valid program is * loaded, as the flagging of an error isn't sufficient to stop * this being uploaded to hardware. */ if (inst[0].Opcode == OPCODE_END) { GLuint tmp = i915_get_utemp(p); i915_emit_arith(p, A0_MOV, UREG(REG_TYPE_OC, 0), A0_DEST_CHANNEL_ALL, 0, swizzle(tmp, ONE, ZERO, ONE, ONE), 0, 0); return; } if (program->Base.NumInstructions > I915_MAX_INSN) { i915_program_error( p, "Exceeded max instructions" ); return; } /* Not always needed: */ calc_live_regs(p); while (1) { GLuint src0, src1, src2, flags; GLuint tmp = 0, consts0 = 0, consts1 = 0; switch (inst->Opcode) { case OPCODE_ABS: src0 = src_vector(p, &inst->SrcReg[0], program); i915_emit_arith(p, A0_MAX, get_result_vector(p, inst), get_result_flags(inst), 0, src0, negate(src0, 1, 1, 1, 1), 0); break; case OPCODE_ADD: EMIT_2ARG_ARITH(A0_ADD); break; case OPCODE_CMP: src0 = src_vector(p, &inst->SrcReg[0], program); src1 = src_vector(p, &inst->SrcReg[1], program); src2 = src_vector(p, &inst->SrcReg[2], program); i915_emit_arith(p, A0_CMP, get_result_vector(p, inst), get_result_flags(inst), 0, src0, src2, src1); /* NOTE: order of src2, src1 */ break; case OPCODE_COS: src0 = src_vector(p, &inst->SrcReg[0], program); tmp = i915_get_utemp(p); consts0 = i915_emit_const4fv(p, sin_quad_constants[0]); consts1 = i915_emit_const4fv(p, sin_quad_constants[1]); /* Reduce range from repeating about [-pi,pi] to [-1,1] */ i915_emit_arith(p, A0_MAD, tmp, A0_DEST_CHANNEL_X, 0, src0, swizzle(consts1, Z, ZERO, ZERO, ZERO), /* 1/(2pi) */ swizzle(consts0, W, ZERO, ZERO, ZERO)); /* .75 */ i915_emit_arith(p, A0_FRC, tmp, A0_DEST_CHANNEL_X, 0, tmp, 0, 0); i915_emit_arith(p, A0_MAD, tmp, A0_DEST_CHANNEL_X, 0, tmp, swizzle(consts0, X, ZERO, ZERO, ZERO), /* 2 */ swizzle(consts0, Y, ZERO, ZERO, ZERO)); /* -1 */ /* Compute COS with the same calculation used for SIN, but a * different source range has been mapped to [-1,1] this time. */ /* tmp.y = abs(tmp.x); {x, abs(x), 0, 0} */ i915_emit_arith(p, A0_MAX, tmp, A0_DEST_CHANNEL_Y, 0, swizzle(tmp, ZERO, X, ZERO, ZERO),//.........这里部分代码省略.........
开发者ID:Multi2Sim,项目名称:m2s-bench-parsec-3.0-src,代码行数:101,
示例21: try_constant_propagatestatic booltry_constant_propagate(const struct gen_device_info *devinfo, vec4_instruction *inst, int arg, const copy_entry *entry){ /* For constant propagation, we only handle the same constant * across all 4 channels. Some day, we should handle the 8-bit * float vector format, which would let us constant propagate * vectors better. * We could be more aggressive here -- some channels might not get used * based on the destination writemask. */ src_reg value = get_copy_value(*entry, brw_apply_inv_swizzle_to_mask(inst->src[arg].swizzle, WRITEMASK_XYZW)); if (value.file != IMM) return false; if (value.type == BRW_REGISTER_TYPE_VF) { /* The result of bit-casting the component values of a vector float * cannot in general be represented as an immediate. */ if (inst->src[arg].type != BRW_REGISTER_TYPE_F) return false; } else { value.type = inst->src[arg].type; } if (inst->src[arg].abs) { if ((devinfo->gen >= 8 && is_logic_op(inst->opcode)) || !brw_abs_immediate(value.type, &value.as_brw_reg())) { return false; } } if (inst->src[arg].negate) { if ((devinfo->gen >= 8 && is_logic_op(inst->opcode)) || !brw_negate_immediate(value.type, &value.as_brw_reg())) { return false; } } value = swizzle(value, inst->src[arg].swizzle); switch (inst->opcode) { case BRW_OPCODE_MOV: case SHADER_OPCODE_BROADCAST: inst->src[arg] = value; return true; case SHADER_OPCODE_POW: case SHADER_OPCODE_INT_QUOTIENT: case SHADER_OPCODE_INT_REMAINDER: if (devinfo->gen < 8) break; /* fallthrough */ case BRW_OPCODE_DP2: case BRW_OPCODE_DP3: case BRW_OPCODE_DP4: case BRW_OPCODE_DPH: case BRW_OPCODE_BFI1: case BRW_OPCODE_ASR: case BRW_OPCODE_SHL: case BRW_OPCODE_SHR: case BRW_OPCODE_SUBB: if (arg == 1) { inst->src[arg] = value; return true; } break; case BRW_OPCODE_MACH: case BRW_OPCODE_MUL: case SHADER_OPCODE_MULH: case BRW_OPCODE_ADD: case BRW_OPCODE_OR: case BRW_OPCODE_AND: case BRW_OPCODE_XOR: case BRW_OPCODE_ADDC: if (arg == 1) { inst->src[arg] = value; return true; } else if (arg == 0 && inst->src[1].file != IMM) { /* Fit this constant in by commuting the operands. Exception: we * can't do this for 32-bit integer MUL/MACH because it's asymmetric. */ if ((inst->opcode == BRW_OPCODE_MUL || inst->opcode == BRW_OPCODE_MACH) && (inst->src[1].type == BRW_REGISTER_TYPE_D || inst->src[1].type == BRW_REGISTER_TYPE_UD)) break; inst->src[0] = inst->src[1]; inst->src[1] = value; return true; } break; case GS_OPCODE_SET_WRITE_OFFSET: /* This is just a multiply by a constant with special strides.//.........这里部分代码省略.........
开发者ID:etnaviv,项目名称:mesa,代码行数:101,
示例22: swizzle1static struct ureg swizzle1( struct ureg reg, int x ){ return swizzle(reg, x, x, x, x);}
开发者ID:toastpp,项目名称:toastpp,代码行数:4,
示例23: build_lighting/* Need to add some addtional parameters to allow lighting in object * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye * space lighting. */static void build_lighting( struct tnl_program *p ){ const GLboolean twoside = p->state->light_twoside; const GLboolean separate = p->state->separate_specular; GLuint nr_lights = 0, count = 0; struct ureg normal = get_transformed_normal(p); struct ureg lit = get_temp(p); struct ureg dots = get_temp(p); struct ureg _col0 = undef, _col1 = undef; struct ureg _bfc0 = undef, _bfc1 = undef; GLuint i; /* * NOTE: * dots.x = dot(normal, VPpli) * dots.y = dot(normal, halfAngle) * dots.z = back.shininess * dots.w = front.shininess */ for (i = 0; i < MAX_LIGHTS; i++) if (p->state->unit[i].light_enabled) nr_lights++; set_material_flags(p); { if (!p->state->material_shininess_is_zero) { struct ureg shininess = get_material(p, 0, STATE_SHININESS); emit_op1(p, OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X)); release_temp(p, shininess); } _col0 = make_temp(p, get_scenecolor(p, 0)); if (separate) _col1 = make_temp(p, get_identity_param(p)); else _col1 = _col0; } if (twoside) { if (!p->state->material_shininess_is_zero) { /* Note that we negate the back-face specular exponent here. * The negation will be un-done later in the back-face code below. */ struct ureg shininess = get_material(p, 1, STATE_SHININESS); emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, negate(swizzle1(shininess,X))); release_temp(p, shininess); } _bfc0 = make_temp(p, get_scenecolor(p, 1)); if (separate) _bfc1 = make_temp(p, get_identity_param(p)); else _bfc1 = _bfc0; } /* If no lights, still need to emit the scenecolor. */ { struct ureg res0 = register_output( p, VERT_RESULT_COL0 ); emit_op1(p, OPCODE_MOV, res0, 0, _col0); } if (separate) { struct ureg res1 = register_output( p, VERT_RESULT_COL1 ); emit_op1(p, OPCODE_MOV, res1, 0, _col1); } if (twoside) { struct ureg res0 = register_output( p, VERT_RESULT_BFC0 ); emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); } if (twoside && separate) { struct ureg res1 = register_output( p, VERT_RESULT_BFC1 ); emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); } if (nr_lights == 0) { release_temps(p); return; } for (i = 0; i < MAX_LIGHTS; i++) { if (p->state->unit[i].light_enabled) { struct ureg half = undef; struct ureg att = undef, VPpli = undef; count++; if (p->state->unit[i].light_eyepos3_is_zero) { /* Can used precomputed constants in this case. * Attenuation never applies to infinite lights. *///.........这里部分代码省略.........
开发者ID:toastpp,项目名称:toastpp,代码行数:101,
示例24: swizzle_yyyyir_swizzle *swizzle_yyyy(operand a){ return swizzle(a, SWIZZLE_YYYY, 4);}
开发者ID:NatTuck,项目名称:mesa,代码行数:5,
示例25: swizzle_xxxxir_swizzle *swizzle_xxxx(operand a){ return swizzle(a, SWIZZLE_XXXX, 4);}
开发者ID:NatTuck,项目名称:mesa,代码行数:5,
示例26: __aligned//.........这里部分代码省略......... ////////////////////////////////////////////////////////////////////////////////////////////////// const Triangle1* tptr = (Triangle1*) curNode.leaf(accel); prefetch<PFHINT_L1>(tptr + 3); prefetch<PFHINT_L1>(tptr + 2); prefetch<PFHINT_L1>(tptr + 1); prefetch<PFHINT_L1>(tptr + 0); const mic_i and_mask = broadcast4to16i(zlc4); const mic_f v0 = gather_4f_zlc(and_mask, (float*)&tptr[0].v0, (float*)&tptr[1].v0, (float*)&tptr[2].v0, (float*)&tptr[3].v0); const mic_f v1 = gather_4f_zlc(and_mask, (float*)&tptr[0].v1, (float*)&tptr[1].v1, (float*)&tptr[2].v1, (float*)&tptr[3].v1); const mic_f v2 = gather_4f_zlc(and_mask, (float*)&tptr[0].v2, (float*)&tptr[1].v2, (float*)&tptr[2].v2, (float*)&tptr[3].v2); const mic_f e1 = v1 - v0; const mic_f e2 = v0 - v2; const mic_f normal = lcross_zxy(e1,e2); const mic_f org = v0 - org_xyz; const mic_f odzxy = msubr231(org * swizzle(dir_xyz,_MM_SWIZ_REG_DACB), dir_xyz, swizzle(org,_MM_SWIZ_REG_DACB)); const mic_f den = ldot3_zxy(dir_xyz,normal); const mic_f rcp_den = rcp(den); const mic_f uu = ldot3_zxy(e2,odzxy); const mic_f vv = ldot3_zxy(e1,odzxy); const mic_f u = uu * rcp_den; const mic_f v = vv * rcp_den;#if defined(__BACKFACE_CULLING__) const mic_m m_init = (mic_m)0x1111 & (den > zero);#else const mic_m m_init = 0x1111;#endif const mic_m valid_u = ge(m_init,u,zero); const mic_m valid_v = ge(valid_u,v,zero); const mic_m m_aperture = le(valid_v,u+v,mic_f::one()); const mic_f nom = ldot3_zxy(org,normal); const mic_f t = rcp_den*nom; if (unlikely(none(m_aperture))) continue; mic_m m_final = lt(lt(m_aperture,min_dist_xyz,t),t,max_dist_xyz);#if defined(__USE_RAY_MASK__) const mic_i rayMask(ray.mask); const mic_i triMask = swDDDD(gather16i_4i_align(&tptr[0].v2,&tptr[1].v2,&tptr[2].v2,&tptr[3].v2)); const mic_m m_ray_mask = (rayMask & triMask) != mic_i::zero(); m_final &= m_ray_mask;#endif#if defined(__INTERSECTION_FILTER__)
开发者ID:venceslas,项目名称:embree,代码行数:66,
示例27: nv30_sampler_view_createstatic struct pipe_sampler_view *nv30_sampler_view_create(struct pipe_context *pipe, struct pipe_resource *pt, const struct pipe_sampler_view *tmpl){ const struct nv30_texfmt *fmt = nv30_texfmt(pipe->screen, tmpl->format); struct nouveau_object *eng3d = nv30_context(pipe)->screen->eng3d; struct nv30_miptree *mt = nv30_miptree(pt); struct nv30_sampler_view *so; so = MALLOC_STRUCT(nv30_sampler_view); if (!so) return NULL; so->pipe = *tmpl; so->pipe.reference.count = 1; so->pipe.texture = NULL; so->pipe.context = pipe; pipe_resource_reference(&so->pipe.texture, pt); so->fmt = NV30_3D_TEX_FORMAT_NO_BORDER; switch (pt->target) { case PIPE_TEXTURE_1D: so->fmt |= NV30_3D_TEX_FORMAT_DIMS_1D; break; case PIPE_TEXTURE_CUBE: so->fmt |= NV30_3D_TEX_FORMAT_CUBIC; case PIPE_TEXTURE_2D: case PIPE_TEXTURE_RECT: so->fmt |= NV30_3D_TEX_FORMAT_DIMS_2D; break; case PIPE_TEXTURE_3D: so->fmt |= NV30_3D_TEX_FORMAT_DIMS_3D; break; default: assert(0); so->fmt |= NV30_3D_TEX_FORMAT_DIMS_1D; break; } so->filt = fmt->filter; so->wrap = fmt->wrap; so->swz = fmt->swizzle; so->swz |= swizzle(fmt, 3, tmpl->swizzle_a); so->swz |= swizzle(fmt, 0, tmpl->swizzle_r) << 2; so->swz |= swizzle(fmt, 1, tmpl->swizzle_g) << 4; so->swz |= swizzle(fmt, 2, tmpl->swizzle_b) << 6; /* apparently, we need to ignore the t coordinate for 1D textures to * fix piglit tex1d-2dborder */ so->wrap_mask = ~0; if (pt->target == PIPE_TEXTURE_1D) { so->wrap_mask &= ~NV30_3D_TEX_WRAP_T__MASK; so->wrap |= NV30_3D_TEX_WRAP_T_REPEAT; } /* yet more hardware suckage, can't filter 32-bit float formats */ switch (tmpl->format) { case PIPE_FORMAT_R32_FLOAT: case PIPE_FORMAT_R32G32B32A32_FLOAT: so->filt_mask = ~(NV30_3D_TEX_FILTER_MIN__MASK | NV30_3D_TEX_FILTER_MAG__MASK); so->filt |= NV30_3D_TEX_FILTER_MIN_NEAREST | NV30_3D_TEX_FILTER_MAG_NEAREST; break; default: so->filt_mask = ~0; break; } so->npot_size0 = (pt->width0 << 16) | pt->height0; if (eng3d->oclass >= NV40_3D_CLASS) { so->npot_size1 = (pt->depth0 << 20) | mt->uniform_pitch; if (!mt->swizzled) so->fmt |= NV40_3D_TEX_FORMAT_LINEAR; so->fmt |= 0x00008000; so->fmt |= (pt->last_level + 1) << NV40_3D_TEX_FORMAT_MIPMAP_COUNT__SHIFT; } else { so->swz |= mt->uniform_pitch << NV30_3D_TEX_SWIZZLE_RECT_PITCH__SHIFT; if (pt->last_level) so->fmt |= NV30_3D_TEX_FORMAT_MIPMAP; so->fmt |= util_logbase2(pt->width0) << 20; so->fmt |= util_logbase2(pt->height0) << 24; so->fmt |= util_logbase2(pt->depth0) << 28; so->fmt |= 0x00010000; } so->base_lod = so->pipe.u.tex.first_level << 8; so->high_lod = MIN2(pt->last_level, so->pipe.u.tex.last_level) << 8; return &so->pipe;}
开发者ID:UIKit0,项目名称:mesa-1,代码行数:90,
示例28: swizzle_xyzwir_swizzle *swizzle_xyzw(operand a){ return swizzle(a, SWIZZLE_XYZW, 4);}
开发者ID:NatTuck,项目名称:mesa,代码行数:5,
注:本文中的swizzle函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ swoole_get_object函数代码示例 C++ switchuvm函数代码示例 |