本文整理汇总了C++中emit_op2函数的典型用法代码示例。如果您正苦于以下问题:C++ emit_op2函数的具体用法?C++ emit_op2怎么用?C++ emit_op2使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了emit_op2函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build_atten_pointsize
/**
* Point size attenuation computation.
*/
static void build_atten_pointsize( struct tnl_program *p )
{
struct ureg eye = get_eye_position_z(p);
struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
struct ureg out = register_output(p, VERT_RESULT_PSIZ);
struct ureg ut = get_temp(p);
/* dist = |eyez| */
emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z));
/* p1 + dist * (p2 + dist * p3); */
emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y));
emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
ut, swizzle1(state_attenuation, X));
/* 1 / sqrt(factor) */
emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );
#if 0
/* out = pointSize / sqrt(factor) */
emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
#else
/* this is a good place to clamp the point size since there's likely
* no hardware registers to clamp point size at rasterization time.
*/
emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z));
#endif
release_temp(p, ut);
}
示例2: build_pointsize
/* Seems like it could be tighter:
*/
static void build_pointsize( struct tnl_program *p )
{
struct ureg eye = get_eye_position(p);
struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
struct ureg out = register_output(p, VERT_RESULT_PSIZ);
struct ureg ut = get_temp(p);
/* 1, Z, Z * Z, 1 */
emit_op1(p, OPCODE_MOV, ut, WRITEMASK_XW, swizzle1(get_identity_param(p), W));
emit_op1(p, OPCODE_ABS, ut, WRITEMASK_YZ, swizzle1(eye, Z));
emit_op2(p, OPCODE_MUL, ut, WRITEMASK_Z, ut, ut);
/* p1 + p2 * dist + p3 * dist * dist, 0 */
emit_op2(p, OPCODE_DP3, ut, WRITEMASK_X, ut, state_attenuation);
/* 1 / sqrt(factor) */
emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );
/* ut = pointSize / factor */
emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
/* Clamp to min/max - state_size.[yz]
*/
emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
emit_op2(p, OPCODE_MIN, out, 0, swizzle1(ut, X), swizzle1(state_size, Z));
release_temp(p, ut);
}
示例3: build_pointsize
static void build_pointsize( struct tnl_program *p )
{
struct ureg eye = get_eye_position(p);
struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
struct ureg out = register_output(p, VERT_RESULT_PSIZ);
struct ureg ut = get_temp(p);
/* dist = |eyez| */
emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z));
/* p1 + dist * (p2 + dist * p3); */
emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y));
emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
ut, swizzle1(state_attenuation, X));
/* 1 / sqrt(factor) */
emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );
#if 1
/* out = pointSize / sqrt(factor) */
emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
#else
/* not sure, might make sense to do clamping here,
but it's not done in t_vb_points neither */
emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z));
#endif
release_temp(p, ut);
}
示例4: emit_normalize_vec3
static void emit_normalize_vec3( struct tnl_program *p,
struct ureg dest,
struct ureg src )
{
emit_op2(p, OPCODE_DP3, dest, WRITEMASK_W, src, src);
emit_op1(p, OPCODE_RSQ, dest, WRITEMASK_W, swizzle1(dest,W));
emit_op2(p, OPCODE_MUL, dest, WRITEMASK_XYZ, src, swizzle1(dest,W));
}
示例5: emit_matrix_transform_vec3
static void emit_matrix_transform_vec3( struct tnl_program *p,
struct ureg dest,
const struct ureg *mat,
struct ureg src)
{
emit_op2(p, OPCODE_DP3, dest, WRITEMASK_X, src, mat[0]);
emit_op2(p, OPCODE_DP3, dest, WRITEMASK_Y, src, mat[1]);
emit_op2(p, OPCODE_DP3, dest, WRITEMASK_Z, src, mat[2]);
}
示例6: build_fog
static void build_fog( struct tnl_program *p )
{
struct ureg fog = register_output(p, VERT_RESULT_FOGC);
struct ureg input;
GLuint useabs = p->state->fog_source_is_depth && p->state->fog_option &&
(p->state->fog_option != FOG_EXP2);
if (p->state->fog_source_is_depth) {
input = swizzle1(get_eye_position(p), Z);
}
else {
input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
}
if (p->state->fog_option &&
p->state->tnl_do_vertex_fog) {
struct ureg params = register_param2(p, STATE_INTERNAL,
STATE_FOG_PARAMS_OPTIMIZED);
struct ureg tmp = get_temp(p);
struct ureg id = get_identity_param(p);
emit_op1(p, OPCODE_MOV, fog, 0, id);
if (useabs) {
emit_op1(p, OPCODE_ABS, tmp, 0, input);
}
switch (p->state->fog_option) {
case FOG_LINEAR: {
emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
swizzle1(params,X), swizzle1(params,Y));
emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
break;
}
case FOG_EXP:
emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
swizzle1(params,Z));
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
case FOG_EXP2:
emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, ureg_negate(tmp));
break;
}
release_temp(p, tmp);
}
else {
/* results = incoming fog coords (compute fog per-fragment later)
*
* KW: Is it really necessary to do anything in this case?
*/
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, 0, input);
}
}
示例7: build_fog
static void build_fog( struct tnl_program *p )
{
struct ureg fog = register_output(p, VERT_RESULT_FOGC);
struct ureg input;
if (p->state->fog_source_is_depth) {
input = swizzle1(get_eye_position(p), Z);
}
else {
input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
}
if (p->state->fog_mode && p->state->tnl_do_vertex_fog) {
struct ureg params = register_param2(p, STATE_INTERNAL,
STATE_FOG_PARAMS_OPTIMIZED);
struct ureg tmp = get_temp(p);
GLboolean useabs = (p->state->fog_mode != FOG_EXP2);
if (useabs) {
emit_op1(p, OPCODE_ABS, tmp, 0, input);
}
switch (p->state->fog_mode) {
case FOG_LINEAR: {
struct ureg id = get_identity_param(p);
emit_op3(p, OPCODE_MAD, tmp, 0, useabs ? tmp : input,
swizzle1(params,X), swizzle1(params,Y));
emit_op2(p, OPCODE_MAX, tmp, 0, tmp, swizzle1(id,X)); /* saturate */
emit_op2(p, OPCODE_MIN, fog, WRITEMASK_X, tmp, swizzle1(id,W));
break;
}
case FOG_EXP:
emit_op2(p, OPCODE_MUL, tmp, 0, useabs ? tmp : input,
swizzle1(params,Z));
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
break;
case FOG_EXP2:
emit_op2(p, OPCODE_MUL, tmp, 0, input, swizzle1(params,W));
emit_op2(p, OPCODE_MUL, tmp, 0, tmp, tmp);
emit_op1(p, OPCODE_EX2, fog, WRITEMASK_X, negate(tmp));
break;
}
release_temp(p, tmp);
}
else {
/* results = incoming fog coords (compute fog per-fragment later)
*
* KW: Is it really necessary to do anything in this case?
* BP: Yes, we always need to compute the absolute value, unless
* we want to push that down into the fragment program...
*/
GLboolean useabs = GL_TRUE;
emit_op1(p, useabs ? OPCODE_ABS : OPCODE_MOV, fog, WRITEMASK_X, input);
}
}
示例8: emit_normalize_vec3
static void emit_normalize_vec3( struct tnl_program *p,
struct ureg dest,
struct ureg src )
{
struct ureg tmp = get_temp(p);
emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src);
emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp);
emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X));
release_temp(p, tmp);
}
示例9: emit_normalize_vec3
static void emit_normalize_vec3( struct tnl_program *p,
struct ureg dest,
struct ureg src )
{
#if 0
/* XXX use this when drivers are ready for NRM3 */
emit_op1(p, OPCODE_NRM3, dest, WRITEMASK_XYZ, src);
#else
struct ureg tmp = get_temp(p);
emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src);
emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp);
emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X));
release_temp(p, tmp);
#endif
}
示例10: get_eye_normal
static struct ureg get_eye_normal( struct tnl_program *p )
{
if (is_undef(p->eye_normal)) {
struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL );
struct ureg mvinv[3];
register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2,
STATE_MATRIX_INVTRANS, mvinv );
p->eye_normal = reserve_temp(p);
/* Transform to eye space:
*/
emit_matrix_transform_vec3( p, p->eye_normal, mvinv, normal );
/* Normalize/Rescale:
*/
if (p->state->normalize) {
emit_normalize_vec3( p, p->eye_normal, p->eye_normal );
}
else if (p->state->rescale_normals) {
struct ureg rescale = register_param2(p, STATE_INTERNAL,
STATE_NORMAL_SCALE);
emit_op2( p, OPCODE_MUL, p->eye_normal, 0, p->eye_normal,
swizzle1(rescale, X));
}
}
return p->eye_normal;
}
示例11: build_fog
static void build_fog( struct tnl_program *p )
{
struct ureg fog = register_output(p, VARYING_SLOT_FOGC);
struct ureg input;
if (p->state->fog_source_is_depth) {
switch (p->state->fog_distance_mode) {
case FDM_EYE_RADIAL: /* Z = sqrt(Xe*Xe + Ye*Ye + Ze*Ze) */
input = get_eye_position(p);
emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input);
emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog);
emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog);
break;
case FDM_EYE_PLANE: /* Z = Ze */
input = get_eye_position_z(p);
emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input);
break;
case FDM_EYE_PLANE_ABS: /* Z = abs(Ze) */
input = get_eye_position_z(p);
emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
break;
default: assert(0); break; /* can't happen */
}
}
else {
input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
}
emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p));
}
示例12: build_reflect_texgen
static void build_reflect_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);
/* 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, dest, writemask, negate(tmp), normal, eye_hat);
release_temp(p, tmp);
}
示例13: emit_degenerate_lit
/**
* Compute:
* lit.y = MAX(0, dots.x)
* lit.z = SLT(0, dots.x)
*/
static void emit_degenerate_lit( struct tnl_program *p,
struct ureg lit,
struct ureg dots )
{
struct ureg id = get_identity_param(p); /* id = {0,0,0,1} */
/* Note that lit.x & lit.w will not be examined. Note also that
* dots.xyzw == dots.xxxx.
*/
/* MAX lit, id, dots;
*/
emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots);
/* result[2] = (in > 0 ? 1 : 0)
* SLT lit.z, id.z, dots; # lit.z = (0 < dots.z) ? 1 : 0
*/
emit_op2(p, OPCODE_SLT, lit, WRITEMASK_Z, swizzle1(id,Z), dots);
}
示例14: calculate_light_attenuation
static struct ureg calculate_light_attenuation( struct tnl_program *p,
GLuint i,
struct ureg VPpli,
struct ureg dist )
{
struct ureg attenuation = register_param3(p, STATE_LIGHT, i,
STATE_ATTENUATION);
struct ureg att = undef;
/* Calculate spot attenuation:
*/
if (!p->state->unit[i].light_spotcutoff_is_180) {
struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL,
STATE_LIGHT_SPOT_DIR_NORMALIZED, i);
struct ureg spot = get_temp(p);
struct ureg slt = get_temp(p);
att = get_temp(p);
emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm);
emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot);
emit_op1(p, OPCODE_ABS, spot, 0, spot);
emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W));
emit_op2(p, OPCODE_MUL, att, 0, slt, spot);
release_temp(p, spot);
release_temp(p, slt);
}
/* Calculate distance attenuation(See formula (2.4) at glspec 2.1 page 62):
*
* Skip the calucation when _dist_ is undefined(light_eyepos3_is_zero)
*/
if (p->state->unit[i].light_attenuated && !is_undef(dist)) {
if (is_undef(att))
att = get_temp(p);
/* 1/d,d,d,1/d */
emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist);
/* 1,d,d*d,1/d */
emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y));
/* 1/dist-atten */
emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist);
if (!p->state->unit[i].light_spotcutoff_is_180) {
/* dist-atten */
emit_op1(p, OPCODE_RCP, dist, 0, dist);
/* spot-atten * dist-atten */
emit_op2(p, OPCODE_MUL, att, 0, dist, att);
}
else {
/* dist-atten */
emit_op1(p, OPCODE_RCP, att, 0, dist);
}
}
return att;
}
示例15: build_sphere_texgen
static 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);
}