diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp index 8f75c82..16c454a 100644 --- a/src/mesa/program/ir_to_mesa.cpp +++ b/src/mesa/program/ir_to_mesa.cpp @@ -2622,8 +2622,9 @@ get_mesa_program(struct gl_context *ctx, GLenum target; const char *target_string; GLboolean progress; + gl_shader_type shaderType = _mesa_shader_type_to_index(shader->Type); struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; + &ctx->ShaderCompilerOptions[shaderType]; switch (shader->Type) { case GL_VERTEX_SHADER: @@ -2710,6 +2711,8 @@ get_mesa_program(struct gl_context *ctx, i = 0; foreach_iter(exec_list_iterator, iter, v.instructions) { const ir_to_mesa_instruction *inst = (ir_to_mesa_instruction *)iter.get(); + const unsigned numSrc = _mesa_num_inst_src_regs(inst->op); + unsigned src; mesa_inst->Opcode = inst->op; mesa_inst->CondUpdate = inst->cond_update; @@ -2720,9 +2723,22 @@ get_mesa_program(struct gl_context *ctx, mesa_inst->DstReg.CondMask = inst->dst_reg.cond_mask; mesa_inst->DstReg.WriteMask = inst->dst_reg.writemask; mesa_inst->DstReg.RelAddr = inst->dst_reg.reladdr != NULL; - mesa_inst->SrcReg[0] = mesa_src_reg_from_ir_src_reg(inst->src_reg[0]); - mesa_inst->SrcReg[1] = mesa_src_reg_from_ir_src_reg(inst->src_reg[1]); - mesa_inst->SrcReg[2] = mesa_src_reg_from_ir_src_reg(inst->src_reg[2]); + for (src = 0; src < numSrc; src++) { + if (!_mesa_valid_register_index(ctx, shaderType, + inst->src_reg[src].file, + inst->src_reg[src].index)) { + const char *regName = + _mesa_register_file_name(inst->src_reg[src].file); + + fail_link(shader_program, + "Register %s[%d] exceeds implementation limits.\n", + regName, inst->src_reg[src].index); + } + else { + mesa_inst->SrcReg[src] = + mesa_src_reg_from_ir_src_reg(inst->src_reg[src]); + } + } mesa_inst->TexSrcUnit = inst->sampler; mesa_inst->TexSrcTarget = inst->tex_target; mesa_inst->TexShadow = inst->tex_shadow; @@ -2733,7 +2749,7 @@ get_mesa_program(struct gl_context *ctx, prog->IndirectRegisterFiles |= 1 << mesa_inst->DstReg.File; /* Update program's bitmask of indirectly accessed register files */ - for (unsigned src = 0; src < 3; src++) + for (src = 0; src < numSrc; src++) if (mesa_inst->SrcReg[src].RelAddr) prog->IndirectRegisterFiles |= 1 << mesa_inst->SrcReg[src].File;