diff options
author | Brian Paul <[email protected]> | 2003-09-04 15:18:22 +0000 |
---|---|---|
committer | Brian Paul <[email protected]> | 2003-09-04 15:18:22 +0000 |
commit | 9c9c2cd7255a50559c97c512416c2be17b869a03 (patch) | |
tree | e46bb9ca99491ef867577cc972504ba0c7928837 /src | |
parent | e082348a4b59af0221b88a11c87acdb46f67eaa1 (diff) |
Added new opcodes for ARB_fragment_program, like ABS, CMP, TXB, etc.
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/main/nvfragprog.h | 48 | ||||
-rw-r--r-- | src/mesa/swrast/s_nvfragprog.c | 62 |
2 files changed, 89 insertions, 21 deletions
diff --git a/src/mesa/main/nvfragprog.h b/src/mesa/main/nvfragprog.h index cf5253b2457..772edd6be44 100644 --- a/src/mesa/main/nvfragprog.h +++ b/src/mesa/main/nvfragprog.h @@ -75,12 +75,15 @@ /* Fragment program instruction opcodes */ enum fp_opcode { - FP_OPCODE_ADD = 1000, + FP_OPCODE_ABS = 1000, /* ARB_f_p only */ + FP_OPCODE_ADD, + FP_OPCODE_CMP, /* ARB_f_p only */ FP_OPCODE_COS, - FP_OPCODE_DDX, - FP_OPCODE_DDY, + FP_OPCODE_DDX, /* NV_f_p only */ + FP_OPCODE_DDY, /* NV_f_p only */ FP_OPCODE_DP3, FP_OPCODE_DP4, + FP_OPCODE_DPH, /* ARB_f_p only */ FP_OPCODE_DST, FP_OPCODE_EX2, FP_OPCODE_FLR, @@ -94,32 +97,35 @@ enum fp_opcode { FP_OPCODE_MIN, FP_OPCODE_MOV, FP_OPCODE_MUL, - FP_OPCODE_PK2H, - FP_OPCODE_PK2US, - FP_OPCODE_PK4B, - FP_OPCODE_PK4UB, + FP_OPCODE_PK2H, /* NV_f_p only */ + FP_OPCODE_PK2US, /* NV_f_p only */ + FP_OPCODE_PK4B, /* NV_f_p only */ + FP_OPCODE_PK4UB, /* NV_f_p only */ FP_OPCODE_POW, FP_OPCODE_RCP, - FP_OPCODE_RFL, + FP_OPCODE_RFL, /* NV_f_p only */ FP_OPCODE_RSQ, - FP_OPCODE_SEQ, - FP_OPCODE_SFL, - FP_OPCODE_SGE, - FP_OPCODE_SGT, + FP_OPCODE_SCS, /* ARB_f_p only */ + FP_OPCODE_SEQ, /* NV_f_p only */ + FP_OPCODE_SFL, /* NV_f_p only */ + FP_OPCODE_SGE, /* NV_f_p only */ + FP_OPCODE_SGT, /* NV_f_p only */ FP_OPCODE_SIN, - FP_OPCODE_SLE, + FP_OPCODE_SLE, /* NV_f_p only */ FP_OPCODE_SLT, - FP_OPCODE_SNE, - FP_OPCODE_STR, + FP_OPCODE_SNE, /* NV_f_p only */ + FP_OPCODE_STR, /* NV_f_p only */ FP_OPCODE_SUB, + FP_OPCODE_SWZ, /* ARB_f_p only */ FP_OPCODE_TEX, - FP_OPCODE_TXD, + FP_OPCODE_TXB, /* ARB_f_p only */ + FP_OPCODE_TXD, /* NV_f_p only */ FP_OPCODE_TXP, - FP_OPCODE_UP2H, - FP_OPCODE_UP2US, - FP_OPCODE_UP4B, - FP_OPCODE_UP4UB, - FP_OPCODE_X2D, + FP_OPCODE_UP2H, /* NV_f_p only */ + FP_OPCODE_UP2US, /* NV_f_p only */ + FP_OPCODE_UP4B, /* NV_f_p only */ + FP_OPCODE_UP4UB, /* NV_f_p only */ + FP_OPCODE_X2D, /* XPD in ARB_f_p */ FP_OPCODE_END /* private opcode */ }; diff --git a/src/mesa/swrast/s_nvfragprog.c b/src/mesa/swrast/s_nvfragprog.c index 92fc6ed4528..c230ff38de8 100644 --- a/src/mesa/swrast/s_nvfragprog.c +++ b/src/mesa/swrast/s_nvfragprog.c @@ -595,6 +595,17 @@ execute_program( GLcontext *ctx, } switch (inst->Opcode) { + case FP_OPCODE_ABS: + { + GLfloat a[4], result[4]; + fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a ); + result[0] = FABSF(a[0]); + result[1] = FABSF(a[1]); + result[2] = FABSF(a[2]); + result[3] = FABSF(a[3]); + store_vector4( inst, machine, result ); + } + break; case FP_OPCODE_ADD: { GLfloat a[4], b[4], result[4]; @@ -607,6 +618,19 @@ execute_program( GLcontext *ctx, store_vector4( inst, machine, result ); } break; + case FP_OPCODE_CMP: + { + GLfloat a[4], b[4], c[4], result[4]; + fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a ); + fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b ); + fetch_vector4( ctx, &inst->SrcReg[2], machine, program, c ); + result[0] = a[0] < 0.0F ? b[0] : c[0]; + result[1] = a[1] < 0.0F ? b[1] : c[1]; + result[2] = a[2] < 0.0F ? b[2] : c[2]; + result[3] = a[3] < 0.0F ? b[3] : c[3]; + store_vector4( inst, machine, result ); + } + break; case FP_OPCODE_COS: { GLfloat a[4], result[4]; @@ -682,6 +706,16 @@ execute_program( GLcontext *ctx, store_vector4( inst, machine, result ); } break; + case FP_OPCODE_DPH: + { + GLfloat a[4], b[4], result[4]; + fetch_vector4( ctx, &inst->SrcReg[0], machine, program, a ); + fetch_vector4( ctx, &inst->SrcReg[1], machine, program, b ); + result[0] = result[1] = result[2] = result[3] = + a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + b[3]; + store_vector4( inst, machine, result ); + } + break; case FP_OPCODE_DST: /* Distance vector */ { GLfloat a[4], b[4], result[4]; @@ -952,6 +986,17 @@ execute_program( GLcontext *ctx, #endif } break; + case FP_OPCODE_SCS: /* sine and cos */ + { + GLfloat a[4], result[4]; + fetch_vector1( ctx, &inst->SrcReg[0], machine, program, a ); + result[0] = cos(a[0]); + result[1] = sin(a[0]); + result[2] = 0.0; /* undefined! */ + result[3] = 0.0; /* undefined! */ + store_vector4( inst, machine, result ); + } + break; case FP_OPCODE_SEQ: /* set on equal */ { GLfloat a[4], b[4], result[4]; @@ -1057,6 +1102,11 @@ execute_program( GLcontext *ctx, store_vector4( inst, machine, result ); } break; + case FP_OPCODE_SWZ: + { + /* XXX to do: extended swizzle */ + } + break; case FP_OPCODE_TEX: /* Texel lookup */ { @@ -1069,6 +1119,18 @@ execute_program( GLcontext *ctx, store_vector4( inst, machine, color ); } break; + case FP_OPCODE_TXB: + /* Texel lookup with LOD bias */ + { + GLfloat texcoord[4], color[4]; + fetch_vector4( ctx, &inst->SrcReg[0], machine, program, texcoord ); + /* XXX: apply bias from texcoord[3]!!! */ + fetch_texel( ctx, texcoord, + span->array->lambda[inst->TexSrcUnit][column], + inst->TexSrcUnit, color ); + store_vector4( inst, machine, color ); + } + break; case FP_OPCODE_TXD: /* Texture lookup w/ partial derivatives for LOD */ { |