📄 atifragshader.c
字号:
#if MESA_DEBUG_ATI_FS for (j = 0; j < MAX_NUM_PASSES_ATI; j++) { for (i = 0; i < MAX_NUM_FRAGMENT_REGISTERS_ATI; i++) { GLuint op = curProg->SetupInst[j][i].Opcode; const char *op_enum = op > 5 ? _mesa_lookup_enum_by_nr(op) : "0"; GLuint src = curProg->SetupInst[j][i].src; GLuint swizzle = curProg->SetupInst[j][i].swizzle; fprintf(stderr, "%2d %04X %s %d %04X\n", i, op, op_enum, src, swizzle); } for (i = 0; i < curProg->numArithInstr[j]; i++) { GLuint op0 = curProg->Instructions[j][i].Opcode[0]; GLuint op1 = curProg->Instructions[j][i].Opcode[1]; const char *op0_enum = op0 > 5 ? _mesa_lookup_enum_by_nr(op0) : "0"; const char *op1_enum = op1 > 5 ? _mesa_lookup_enum_by_nr(op1) : "0"; GLuint count0 = curProg->Instructions[j][i].ArgCount[0]; GLuint count1 = curProg->Instructions[j][i].ArgCount[1]; fprintf(stderr, "%2d %04X %s %d %04X %s %d\n", i, op0, op0_enum, count0, op1, op1_enum, count1); } }#endif if (ctx->Driver.ProgramStringNotify) ctx->Driver.ProgramStringNotify( ctx, GL_FRAGMENT_SHADER_ATI, NULL );}void GLAPIENTRY_mesa_PassTexCoordATI(GLuint dst, GLuint coord, GLenum swizzle){ GET_CURRENT_CONTEXT(ctx); struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; struct atifs_setupinst *curI; if (!ctx->ATIFragmentShader.Compiling) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(outsideShader)"); return; } if (curProg->cur_pass == 1) { match_pair_inst(curProg, 0); curProg->cur_pass = 2; } if ((curProg->cur_pass > 2) || ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoord(pass)"); return; } if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(dst)"); return; } if (((coord < GL_REG_0_ATI) || (coord > GL_REG_5_ATI)) && ((coord < GL_TEXTURE0_ARB) || (coord > GL_TEXTURE7_ARB) || ((coord - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(coord)"); return; } if ((curProg->cur_pass == 0) && (coord >= GL_REG_0_ATI)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(coord)"); return; } if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "glPassTexCoordATI(swizzle)"); return; } if ((swizzle & 1) && (coord >= GL_REG_0_ATI)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); return; } if (coord <= GL_TEXTURE7_ARB) { GLuint tmp = coord - GL_TEXTURE0_ARB; if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glPassTexCoordATI(swizzle)"); return; } else { curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); } } curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); new_tex_inst(curProg); /* add the instructions */ curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; curI->Opcode = ATI_FRAGMENT_SHADER_PASS_OP; curI->src = coord; curI->swizzle = swizzle;#if MESA_DEBUG_ATI_FS _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(coord), _mesa_lookup_enum_by_nr(swizzle));#endif}void GLAPIENTRY_mesa_SampleMapATI(GLuint dst, GLuint interp, GLenum swizzle){ GET_CURRENT_CONTEXT(ctx); struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; struct atifs_setupinst *curI; if (!ctx->ATIFragmentShader.Compiling) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(outsideShader)"); return; } if (curProg->cur_pass == 1) { match_pair_inst(curProg, 0); curProg->cur_pass = 2; } if ((curProg->cur_pass > 2) || ((1 << (dst - GL_REG_0_ATI)) & curProg->regsAssigned[curProg->cur_pass >> 1])) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(pass)"); return; } if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI) || ((dst - GL_REG_0_ATI) >= ctx->Const.MaxTextureUnits)) { _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(dst)"); return; } if (((interp < GL_REG_0_ATI) || (interp > GL_REG_5_ATI)) && ((interp < GL_TEXTURE0_ARB) || (interp > GL_TEXTURE7_ARB) || ((interp - GL_TEXTURE0_ARB) >= ctx->Const.MaxTextureUnits))) { /* is this texture5 or texture7? spec is a bit unclear there */ _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(interp)"); return; } if ((curProg->cur_pass == 0) && (interp >= GL_REG_0_ATI)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(interp)"); return; } if (!(swizzle >= GL_SWIZZLE_STR_ATI) && (swizzle <= GL_SWIZZLE_STQ_DQ_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "glSampleMapATI(swizzle)"); return; } if ((swizzle & 1) && (interp >= GL_REG_0_ATI)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); return; } if (interp <= GL_TEXTURE7_ARB) { GLuint tmp = interp - GL_TEXTURE0_ARB; if ((((curProg->swizzlerq >> (tmp * 2)) & 3) != 0) && (((swizzle & 1) + 1) != ((curProg->swizzlerq >> (tmp * 2)) & 3))) { _mesa_error(ctx, GL_INVALID_OPERATION, "glSampleMapATI(swizzle)"); return; } else { curProg->swizzlerq |= (((swizzle & 1) + 1) << (tmp * 2)); } } curProg->regsAssigned[curProg->cur_pass >> 1] |= 1 << (dst - GL_REG_0_ATI); new_tex_inst(curProg); /* add the instructions */ curI = &curProg->SetupInst[curProg->cur_pass >> 1][dst - GL_REG_0_ATI]; curI->Opcode = ATI_FRAGMENT_SHADER_SAMPLE_OP; curI->src = interp; curI->swizzle = swizzle;#if MESA_DEBUG_ATI_FS _mesa_debug(ctx, "%s(%s, %s, %s)\n", __FUNCTION__, _mesa_lookup_enum_by_nr(dst), _mesa_lookup_enum_by_nr(interp), _mesa_lookup_enum_by_nr(swizzle));#endif}static void_mesa_FragmentOpXATI(GLint optype, GLuint arg_count, GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod){ GET_CURRENT_CONTEXT(ctx); struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; GLint ci; struct atifs_instruction *curI; GLuint modtemp = dstMod & ~GL_SATURATE_BIT_ATI; if (!ctx->ATIFragmentShader.Compiling) { _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(outsideShader)"); return; } if (curProg->cur_pass==0) curProg->cur_pass=1; else if (curProg->cur_pass==2) curProg->cur_pass=3; /* decide whether this is a new instruction or not ... all color instructions are new, and alpha instructions might also be new if there was no preceding color inst */ if ((optype == 0) || (curProg->last_optype == optype)) { if (curProg->numArithInstr[curProg->cur_pass >> 1] > 7) { _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(instrCount)"); return; } /* easier to do that here slight side effect invalid instr will still be inserted as nops */ match_pair_inst(curProg, optype); new_arith_inst(curProg); } curProg->last_optype = optype; ci = curProg->numArithInstr[curProg->cur_pass >> 1] - 1; /* add the instructions */ curI = &curProg->Instructions[curProg->cur_pass >> 1][ci]; /* error checking */ if ((dst < GL_REG_0_ATI) || (dst > GL_REG_5_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dst)"); return; } if ((modtemp != GL_NONE) && (modtemp != GL_2X_BIT_ATI) && (modtemp != GL_4X_BIT_ATI) && (modtemp != GL_8X_BIT_ATI) && (modtemp != GL_HALF_BIT_ATI) && !(modtemp != GL_QUARTER_BIT_ATI) && (modtemp != GL_EIGHTH_BIT_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(dstMod)%x", modtemp); return; } /* op checking? Actually looks like that's missing in the spec but we'll do it anyway */ if (((op < GL_ADD_ATI) || (op > GL_DOT2_ADD_ATI)) && !(op == GL_MOV_ATI)) { _mesa_error(ctx, GL_INVALID_ENUM, "C/AFragmentOpATI(op)"); return; } if (optype == 1) { if (((op == GL_DOT2_ADD_ATI) && (curI->Opcode[0] != GL_DOT2_ADD_ATI)) || ((op == GL_DOT3_ATI) && (curI->Opcode[0] != GL_DOT3_ATI)) || ((op == GL_DOT4_ATI) && (curI->Opcode[0] != GL_DOT4_ATI)) || ((op != GL_DOT4_ATI) && (curI->Opcode[0] == GL_DOT4_ATI))) { _mesa_error(ctx, GL_INVALID_OPERATION, "AFragmentOpATI(op)"); return; } } if ((op == GL_DOT4_ATI) && (((arg1 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg1Rep == GL_ALPHA) || (arg1Rep == GL_NONE))) || (((arg2 == GL_SECONDARY_INTERPOLATOR_ATI) && ((arg2Rep == GL_ALPHA) || (arg2Rep == GL_NONE)))))) { _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(sec_interp)"); } if (!check_arith_arg(curProg, optype, arg1, arg1Rep)) { return; } if (arg2) { if (!check_arith_arg(curProg, optype, arg2, arg2Rep)) { return; } } if (arg3) { if (!check_arith_arg(curProg, optype, arg3, arg3Rep)) { return; } if ((arg1 >= GL_CON_0_ATI) && (arg1 <= GL_CON_7_ATI) && (arg2 >= GL_CON_0_ATI) && (arg2 <= GL_CON_7_ATI) && (arg3 >= GL_CON_0_ATI) && (arg3 <= GL_CON_7_ATI) && (arg1 != arg2) && (arg1 != arg3) && (arg2 != arg3)) { _mesa_error(ctx, GL_INVALID_OPERATION, "C/AFragmentOpATI(3Consts)"); return; } } /* all ok - not all fully validated though (e.g. argNMod - spec doesn't say anything) */ curI->Opcode[optype] = op; curI->SrcReg[optype][0].Index = arg1; curI->SrcReg[optype][0].argRep = arg1Rep; curI->SrcReg[optype][0].argMod = arg1Mod; curI->ArgCount[optype] = arg_count; if (arg2) { curI->SrcReg[optype][1].Index = arg2; curI->SrcReg[optype][1].argRep = arg2Rep; curI->SrcReg[optype][1].argMod = arg2Mod; } if (arg3) { curI->SrcReg[optype][2].Index = arg3; curI->SrcReg[optype][2].argRep = arg3Rep; curI->SrcReg[optype][2].argMod = arg3Mod; } curI->DstReg[optype].Index = dst; curI->DstReg[optype].dstMod = dstMod; curI->DstReg[optype].dstMask = dstMask;#if MESA_DEBUG_ATI_FS debug_op(optype, arg_count, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod);#endif}void GLAPIENTRY_mesa_ColorFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 1, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0);}void GLAPIENTRY_mesa_ColorFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 2, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0, 0);}void GLAPIENTRY_mesa_ColorFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_COLOR_OP, 3, op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod);}void GLAPIENTRY_mesa_AlphaFragmentOp1ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 1, op, dst, 0, dstMod, arg1, arg1Rep, arg1Mod, 0, 0, 0, 0, 0, 0);}void GLAPIENTRY_mesa_AlphaFragmentOp2ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 2, op, dst, 0, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, 0, 0, 0);}void GLAPIENTRY_mesa_AlphaFragmentOp3ATI(GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod){ _mesa_FragmentOpXATI(ATI_FRAGMENT_SHADER_ALPHA_OP, 3, op, dst, 0, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod, arg3, arg3Rep, arg3Mod);}void GLAPIENTRY_mesa_SetFragmentShaderConstantATI(GLuint dst, const GLfloat * value){ GLuint dstindex; GET_CURRENT_CONTEXT(ctx); if ((dst < GL_CON_0_ATI) || (dst > GL_CON_7_ATI)) { /* spec says nothing about what should happen here but we can't just segfault...*/ _mesa_error(ctx, GL_INVALID_ENUM, "glSetFragmentShaderConstantATI(dst)"); return; } dstindex = dst - GL_CON_0_ATI; if (ctx->ATIFragmentShader.Compiling) { struct ati_fragment_shader *curProg = ctx->ATIFragmentShader.Current; COPY_4V(curProg->Constants[dstindex], value); curProg->LocalConstDef |= 1 << dstindex; } else { FLUSH_VERTICES(ctx, _NEW_PROGRAM); COPY_4V(ctx->ATIFragmentShader.GlobalConstants[dstindex], value); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -