⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 i915_program.c

📁 Mesa is an open-source implementation of the OpenGL specification - a system for rendering interacti
💻 C
📖 第 1 页 / 共 2 页
字号:
      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;}GLuinti915_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", __FUNCTION__);   p->error = 1;   return 0;}GLuinti915_emit_const4f(struct i915_fragment_program * p,                  GLfloat c0, GLfloat c1, GLfloat c2, GLfloat c3){   GLint reg;   for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {      if (p->constant_flags[reg] == 0xf &&          p->constant[reg][0] == c0 &&          p->constant[reg][1] == c1 &&          p->constant[reg][2] == c2 && p->constant[reg][3] == c3) {         return UREG(REG_TYPE_CONST, reg);      }      else if (p->constant_flags[reg] == 0) {         p->constant[reg][0] = c0;         p->constant[reg][1] = c1;         p->constant[reg][2] = c2;         p->constant[reg][3] = c3;         p->constant_flags[reg] = 0xf;         if (reg + 1 > p->nr_constants)            p->nr_constants = reg + 1;         return UREG(REG_TYPE_CONST, reg);      }   }   fprintf(stderr, "%s: out of constants\n", __FUNCTION__);   p->error = 1;   return 0;}GLuinti915_emit_const4fv(struct i915_fragment_program * p, const GLfloat * c){   return i915_emit_const4f(p, c[0], c[1], c[2], c[3]);}GLuinti915_emit_param4fv(struct i915_fragment_program * p, const GLfloat * values){   GLint reg, i;   for (i = 0; i < p->nr_params; i++) {      if (p->param[i].values == values)         return UREG(REG_TYPE_CONST, p->param[i].reg);   }   for (reg = 0; reg < I915_MAX_CONSTANT; reg++) {      if (p->constant_flags[reg] == 0) {         p->constant_flags[reg] = I915_CONSTFLAG_PARAM;         i = p->nr_params++;         p->param[i].values = values;         p->param[i].reg = reg;         p->params_uptodate = 0;         if (reg + 1 > p->nr_constants)            p->nr_constants = reg + 1;         return UREG(REG_TYPE_CONST, reg);      }   }   fprintf(stderr, "%s: out of constants\n", __FUNCTION__);   p->error = 1;   return 0;}voidi915_program_error(struct i915_fragment_program *p, const char *msg){   _mesa_problem(NULL, "i915_program_error: %s", msg);   p->error = 1;}voidi915_init_program(struct i915_context *i915, struct i915_fragment_program *p){   GLcontext *ctx = &i915->intel.ctx;   p->translated = 0;   p->params_uptodate = 0;   p->on_hardware = 0;   p->error = 0;   p->nr_tex_indirect = 1;      /* correct? */   p->nr_tex_insn = 0;   p->nr_alu_insn = 0;   p->nr_decl_insn = 0;   p->ctx = ctx;   memset(p->constant_flags, 0, sizeof(p->constant_flags));   p->nr_constants = 0;   p->csr = p->program;   p->decl = p->declarations;   p->decl_s = 0;   p->decl_t = 0;   p->temp_flag = 0xffff000;   p->utemp_flag = ~0x7;   p->wpos_tex = -1;   p->depth_written = 0;   p->nr_params = 0;   *(p->decl++) = _3DSTATE_PIXEL_SHADER_PROGRAM;}voidi915_fini_program(struct i915_fragment_program *p){   GLuint program_size = p->csr - p->program;   GLuint decl_size = p->decl - p->declarations;   if (p->nr_tex_indirect > I915_MAX_TEX_INDIRECT)      i915_program_error(p, "Exceeded max nr indirect texture lookups");   if (p->nr_tex_insn > I915_MAX_TEX_INSN)      i915_program_error(p, "Exceeded max TEX instructions");   if (p->nr_alu_insn > I915_MAX_ALU_INSN)      i915_program_error(p, "Exceeded max ALU instructions");   if (p->nr_decl_insn > I915_MAX_DECL_INSN)      i915_program_error(p, "Exceeded max DECL instructions");   if (p->error) {      p->FragProg.Base.NumNativeInstructions = 0;      p->FragProg.Base.NumNativeAluInstructions = 0;      p->FragProg.Base.NumNativeTexInstructions = 0;      p->FragProg.Base.NumNativeTexIndirections = 0;   }   else {      p->FragProg.Base.NumNativeInstructions = (p->nr_alu_insn +                                                p->nr_tex_insn +                                                p->nr_decl_insn);      p->FragProg.Base.NumNativeAluInstructions = p->nr_alu_insn;      p->FragProg.Base.NumNativeTexInstructions = p->nr_tex_insn;      p->FragProg.Base.NumNativeTexIndirections = p->nr_tex_indirect;   }   p->declarations[0] |= program_size + decl_size - 2;}voidi915_upload_program(struct i915_context *i915,                    struct i915_fragment_program *p){   GLuint program_size = p->csr - p->program;   GLuint decl_size = p->decl - p->declarations;   FALLBACK(&i915->intel, I915_FALLBACK_PROGRAM, p->error);   /* Could just go straight to the batchbuffer from here:    */   if (i915->state.ProgramSize != (program_size + decl_size) ||       memcmp(i915->state.Program + decl_size, p->program,              program_size * sizeof(int)) != 0) {      I915_STATECHANGE(i915, I915_UPLOAD_PROGRAM);      memcpy(i915->state.Program, p->declarations, decl_size * sizeof(int));      memcpy(i915->state.Program + decl_size, p->program,             program_size * sizeof(int));      i915->state.ProgramSize = decl_size + program_size;   }   /* Always seemed to get a failure if I used memcmp() to    * shortcircuit this state upload.  Needs further investigation?    */   if (p->nr_constants) {      GLuint nr = p->nr_constants;      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 1);      I915_STATECHANGE(i915, I915_UPLOAD_CONSTANTS);      i915->state.Constant[0] = _3DSTATE_PIXEL_SHADER_CONSTANTS | ((nr) * 4);      i915->state.Constant[1] = (1 << (nr - 1)) | ((1 << (nr - 1)) - 1);      memcpy(&i915->state.Constant[2], p->constant, 4 * sizeof(int) * (nr));      i915->state.ConstantSize = 2 + (nr) * 4;      if (0) {         GLuint i;         for (i = 0; i < nr; i++) {            fprintf(stderr, "const[%d]: %f %f %f %f\n", i,                    p->constant[i][0],                    p->constant[i][1], p->constant[i][2], p->constant[i][3]);         }      }   }   else {      I915_ACTIVESTATE(i915, I915_UPLOAD_CONSTANTS, 0);   }   p->on_hardware = 1;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -