static void handle_sample_op(GLcontext * ctx, struct atifs_machine *machine, struct atifs_instruction *inst, const struct sw_span *span, GLuint column) { GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI; GLuint swizzle = inst->DstReg[0].Swizzle; GLuint sample_tex = inst->SrcReg[0][0].Index; /* if we get here after passing pass one then we are starting pass two - backup the registers */ if (machine->pass == 1) { finish_pass(machine); machine->pass = 2; } if (sample_tex >= GL_TEXTURE0_ARB && sample_tex <= GL_TEXTURE7_ARB) { sample_tex -= GL_TEXTURE0_ARB; fetch_texel(ctx, span->array->texcoords[sample_tex][column], 0.0F, sample_tex, machine->Registers[idx]); } else if (sample_tex >= GL_REG_0_ATI && sample_tex <= GL_REG_5_ATI) { /* this is wrong... */ sample_tex -= GL_REG_0_ATI; fetch_texel(ctx, machine->Registers[sample_tex], 0, sample_tex, machine->Registers[idx]); } apply_swizzle(machine, idx, swizzle); }
static void handle_pass_op(struct atifs_machine *machine, struct atifs_instruction *inst, const struct sw_span *span, GLuint column) { GLuint idx = inst->DstReg[0].Index - GL_REG_0_ATI; GLuint swizzle = inst->DstReg[0].Swizzle; GLuint pass_tex = inst->SrcReg[0][0].Index; /* if we get here after passing pass one then we are starting pass two - backup the registers */ if (machine->pass == 1) { finish_pass(machine); machine->pass = 2; } if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { pass_tex -= GL_TEXTURE0_ARB; COPY_4V(machine->Registers[idx], span->array->texcoords[pass_tex][column]); } else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI && machine->pass == 2) { pass_tex -= GL_REG_0_ATI; COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]); } apply_swizzle(machine, idx, swizzle); }
static void handle_pass_op(struct atifs_machine *machine, struct atifs_setupinst *texinst, const SWspan *span, GLuint column, GLuint idx) { GLuint swizzle = texinst->swizzle; GLuint pass_tex = texinst->src; if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { pass_tex -= GL_TEXTURE0_ARB; COPY_4V(machine->Registers[idx], span->array->attribs[FRAG_ATTRIB_TEX0 + pass_tex][column]); } else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) { pass_tex -= GL_REG_0_ATI; COPY_4V(machine->Registers[idx], machine->PrevPassRegisters[pass_tex]); } apply_swizzle(machine->Registers[idx], swizzle); }
/** * Compile one setup instruction to TGSI instructions. */ static void compile_setupinst(struct st_translate *t, const unsigned r, const struct atifs_setupinst *texinst) { struct ureg_dst dst[1]; struct ureg_src src[2]; if (!texinst->Opcode) return; dst[0] = get_temp(t, r); GLuint pass_tex = texinst->src; if (pass_tex >= GL_TEXTURE0_ARB && pass_tex <= GL_TEXTURE7_ARB) { unsigned attr = pass_tex - GL_TEXTURE0_ARB + VARYING_SLOT_TEX0; src[0] = t->inputs[t->inputMapping[attr]]; } else if (pass_tex >= GL_REG_0_ATI && pass_tex <= GL_REG_5_ATI) { unsigned reg = pass_tex - GL_REG_0_ATI; /* the frontend already validated that REG is only allowed in second pass */ if (t->regs_written[0][reg]) { src[0] = ureg_src(t->temps[reg]); } else { src[0] = ureg_imm1f(t->ureg, 0.0f); } } src[0] = apply_swizzle(t, src[0], texinst->swizzle); if (texinst->Opcode == ATI_FRAGMENT_SHADER_SAMPLE_OP) { /* by default texture and sampler indexes are the same */ src[1] = t->samplers[r]; /* the texture target is still unknown, it will be fixed in the draw call */ ureg_tex_insn(t->ureg, TGSI_OPCODE_TEX, dst, 1, TGSI_TEXTURE_2D, NULL, 0, src, 2); } else if (texinst->Opcode == ATI_FRAGMENT_SHADER_PASS_OP) { ureg_insn(t->ureg, TGSI_OPCODE_MOV, dst, 1, src, 1); } t->regs_written[t->current_pass][r] = true; }
static bool load_texture_sampler(gs_texture_t tex, gs_samplerstate_t ss) { bool success = true; GLint min_filter; if (tex->cur_sampler == ss) return true; if (tex->cur_sampler) samplerstate_release(tex->cur_sampler); tex->cur_sampler = ss; if (!ss) return true; samplerstate_addref(ss); min_filter = ss->min_filter; if (gs_texture_is_rect(tex)) strip_mipmap_filter(&min_filter); if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MIN_FILTER, min_filter)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAG_FILTER, ss->mag_filter)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_WRAP_S, ss->address_u)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_WRAP_T, ss->address_v)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_WRAP_R, ss->address_w)) success = false; if (!gl_tex_param_i(tex->gl_target, GL_TEXTURE_MAX_ANISOTROPY_EXT, ss->max_anisotropy)) success = false; apply_swizzle(tex); return success; }
static void handle_sample_op(struct gl_context * ctx, struct atifs_machine *machine, struct atifs_setupinst *texinst, const SWspan *span, GLuint column, GLuint idx) { /* sample from unit idx using texinst->src as coords */ GLuint swizzle = texinst->swizzle; GLuint coord_source = texinst->src; GLfloat tex_coords[4] = { 0 }; if (coord_source >= GL_TEXTURE0_ARB && coord_source <= GL_TEXTURE7_ARB) { coord_source -= GL_TEXTURE0_ARB; COPY_4V(tex_coords, span->array->attribs[FRAG_ATTRIB_TEX0 + coord_source][column]); } else if (coord_source >= GL_REG_0_ATI && coord_source <= GL_REG_5_ATI) { coord_source -= GL_REG_0_ATI; COPY_4V(tex_coords, machine->PrevPassRegisters[coord_source]); } apply_swizzle(tex_coords, swizzle); fetch_texel(ctx, tex_coords, 0.0F, idx, machine->Registers[idx]); }