diff options
author | marha <marha@users.sourceforge.net> | 2014-01-15 21:37:10 +0100 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-01-15 21:37:10 +0100 |
commit | b7f01cb1f6cfd1ec301f650a073436c91ec614aa (patch) | |
tree | 1dbf32344313ad7e5884e6686251cad398a231fa /mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | |
parent | 7b4b94b4449aec056c4c92f5cacc2f89a292a80e (diff) | |
parent | 1b0fcca503ae9cf2d462b60770f96c794dfbb27a (diff) | |
download | vcxsrv-b7f01cb1f6cfd1ec301f650a073436c91ec614aa.tar.gz vcxsrv-b7f01cb1f6cfd1ec301f650a073436c91ec614aa.tar.bz2 vcxsrv-b7f01cb1f6cfd1ec301f650a073436c91ec614aa.zip |
Merge remote-tracking branch 'origin/released'
* origin/released:
mesa xkeyboard-config xserver git update 15 jan 2014
randrproto libfontenc mesa xserver git update 10 Jan 2014
randsrproto fontconfig libX11 git update 6 Jan 2014
Conflicts:
mesalib/src/glsl/builtin_functions.cpp
mesalib/src/glsl/ir_builder.h
xorg-server/Xext/xres.c
xorg-server/dix/dispatch.c
xorg-server/dix/dixfonts.c
xorg-server/hw/xwin/wingc.c
xorg-server/hw/xwin/winwindowswm.c
xorg-server/include/gc.h
xorg-server/os/access.c
Diffstat (limited to 'mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp')
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 172 |
1 files changed, 83 insertions, 89 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index eb12426a5..f1b354429 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -897,8 +897,8 @@ glsl_to_tgsi_visitor::add_constant(gl_register_file file, /* Search immediate storage to see if we already have an identical * immediate that we can use instead of adding a duplicate entry. */ - foreach_iter(exec_list_iterator, iter, this->immediates) { - entry = (immediate_storage *)iter.get(); + foreach_list(node, &this->immediates) { + entry = (immediate_storage *) node; if (entry->size == size && entry->type == datatype && @@ -1040,8 +1040,8 @@ glsl_to_tgsi_visitor::find_variable_storage(ir_variable *var) variable_storage *entry; - foreach_iter(exec_list_iterator, iter, this->variables) { - entry = (variable_storage *)iter.get(); + foreach_list(node, &this->variables) { + entry = (variable_storage *) node; if (entry->var == var) return entry; @@ -1179,8 +1179,8 @@ glsl_to_tgsi_visitor::visit(ir_function *ir) assert(sig); - foreach_iter(exec_list_iterator, iter, sig->body) { - ir_instruction *ir = (ir_instruction *)iter.get(); + foreach_list(node, &sig->body) { + ir_instruction *ir = (ir_instruction *) node; ir->accept(this); } @@ -2455,8 +2455,8 @@ glsl_to_tgsi_visitor::visit(ir_constant *ir) st_src_reg temp_base = get_temp(ir->type); st_dst_reg temp = st_dst_reg(temp_base); - foreach_iter(exec_list_iterator, iter, ir->components) { - ir_constant *field_value = (ir_constant *)iter.get(); + foreach_list(node, &ir->components) { + ir_constant *field_value = (ir_constant *) node; int size = type_size(field_value->type); assert(size > 0); @@ -2572,8 +2572,8 @@ glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig) { function_entry *entry; - foreach_iter(exec_list_iterator, iter, this->function_signatures) { - entry = (function_entry *)iter.get(); + foreach_list(node, &this->function_signatures) { + entry = (function_entry *) node; if (entry->sig == sig) return entry; @@ -2585,8 +2585,8 @@ glsl_to_tgsi_visitor::get_function_signature(ir_function_signature *sig) entry->bgn_inst = NULL; /* Allocate storage for all the parameters. */ - foreach_iter(exec_list_iterator, iter, sig->parameters) { - ir_variable *param = (ir_variable *)iter.get(); + foreach_list(node, &sig->parameters) { + ir_variable *param = (ir_variable *) node; variable_storage *storage; storage = find_variable_storage(param); @@ -2617,10 +2617,10 @@ glsl_to_tgsi_visitor::visit(ir_call *ir) int i; /* Process in parameters. */ - exec_list_iterator sig_iter = sig->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *param = (ir_variable *)sig_iter.get(); + foreach_two_lists(formal_node, &sig->parameters, + actual_node, &ir->actual_parameters) { + ir_rvalue *param_rval = (ir_rvalue *) actual_node; + ir_variable *param = (ir_variable *) formal_node; if (param->data.mode == ir_var_function_in || param->data.mode == ir_var_function_inout) { @@ -2643,20 +2643,17 @@ glsl_to_tgsi_visitor::visit(ir_call *ir) r.index++; } } - - sig_iter.next(); } - assert(!sig_iter.has_next()); /* Emit call instruction */ call_inst = emit(ir, TGSI_OPCODE_CAL); call_inst->function = entry; /* Process out parameters. */ - sig_iter = sig->parameters.iterator(); - foreach_iter(exec_list_iterator, iter, *ir) { - ir_rvalue *param_rval = (ir_rvalue *)iter.get(); - ir_variable *param = (ir_variable *)sig_iter.get(); + foreach_two_lists(formal_node, &sig->parameters, + actual_node, &ir->actual_parameters) { + ir_rvalue *param_rval = (ir_rvalue *) actual_node; + ir_variable *param = (ir_variable *) formal_node; if (param->data.mode == ir_var_function_out || param->data.mode == ir_var_function_inout) { @@ -2679,10 +2676,7 @@ glsl_to_tgsi_visitor::visit(ir_call *ir) r.index++; } } - - sig_iter.next(); } - assert(!sig_iter.has_next()); /* Process return value. */ this->result = entry->return_reg; @@ -3070,8 +3064,8 @@ count_resources(glsl_to_tgsi_visitor *v, gl_program *prog) { v->samplers_used = 0; - foreach_iter(exec_list_iterator, iter, v->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &v->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; if (is_tex_instruction(inst->op)) { v->samplers_used |= 1 << inst->sampler; @@ -3216,8 +3210,8 @@ glsl_to_tgsi_visitor::simplify_cmp(void) memset(tempWrites, 0, sizeof(unsigned) * MAX_TEMPS); memset(outputWrites, 0, sizeof(outputWrites)); - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; unsigned prevWriteMask = 0; /* Give up if we encounter relative addressing or flow control. */ @@ -3262,8 +3256,8 @@ glsl_to_tgsi_visitor::simplify_cmp(void) void glsl_to_tgsi_visitor::rename_temp_register(int index, int new_index) { - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; unsigned j; for (j=0; j < num_inst_src_regs(inst->op); j++) { @@ -3286,8 +3280,8 @@ glsl_to_tgsi_visitor::get_first_temp_read(int index) int loop_start = -1; /* index of the first active BGNLOOP (if any) */ unsigned i = 0, j; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; for (j=0; j < num_inst_src_regs(inst->op); j++) { if (inst->src[j].file == PROGRAM_TEMPORARY && @@ -3318,8 +3312,8 @@ glsl_to_tgsi_visitor::get_first_temp_write(int index) int loop_start = -1; /* index of the first active BGNLOOP (if any) */ int i = 0; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) { return (depth == 0) ? i : loop_start; @@ -3347,8 +3341,8 @@ glsl_to_tgsi_visitor::get_last_temp_read(int index) int last = -1; /* index of last instruction that reads the temporary */ unsigned i = 0, j; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; for (j=0; j < num_inst_src_regs(inst->op); j++) { if (inst->src[j].file == PROGRAM_TEMPORARY && @@ -3378,8 +3372,8 @@ glsl_to_tgsi_visitor::get_last_temp_write(int index) int last = -1; /* index of last instruction that writes to the temporary */ int i = 0; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == index) last = (depth == 0) ? i : -2; @@ -3427,8 +3421,8 @@ glsl_to_tgsi_visitor::copy_propagate(void) int *acp_level = rzalloc_array(mem_ctx, int, this->next_temp * 4); int level = 0; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; assert(inst->dst.file != PROGRAM_TEMPORARY || inst->dst.index < this->next_temp); @@ -3624,13 +3618,13 @@ glsl_to_tgsi_visitor::eliminate_dead_code(void) int last_read = get_last_temp_read(i); int j = 0; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list_safe(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; if (inst->dst.file == PROGRAM_TEMPORARY && inst->dst.index == i && j > last_read) { - iter.remove(); + inst->remove(); delete inst; } @@ -3661,8 +3655,8 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void) int level = 0; int removed = 0; - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; assert(inst->dst.file != PROGRAM_TEMPORARY || inst->dst.index < this->next_temp); @@ -3769,13 +3763,13 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void) /* Now actually remove the instructions that are completely dead and update * the writemask of other instructions with dead channels. */ - foreach_iter(exec_list_iterator, iter, this->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list_safe(node, &this->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; if (!inst->dead_mask || !inst->dst.writemask) continue; else if ((inst->dst.writemask & ~inst->dead_mask) == 0) { - iter.remove(); + inst->remove(); delete inst; removed++; } else @@ -3956,8 +3950,8 @@ get_pixel_transfer_visitor(struct st_fragment_program *fp, /* Now copy the instructions from the original glsl_to_tgsi_visitor into the * new visitor. */ - foreach_iter(exec_list_iterator, iter, original->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &original->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; glsl_to_tgsi_instruction *newinst; st_src_reg src_regs[3]; @@ -4040,8 +4034,8 @@ get_bitmap_visitor(struct st_fragment_program *fp, /* Now copy the instructions from the original glsl_to_tgsi_visitor into the * new visitor. */ - foreach_iter(exec_list_iterator, iter, original->instructions) { - glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *)iter.get(); + foreach_list(node, &original->instructions) { + glsl_to_tgsi_instruction *inst = (glsl_to_tgsi_instruction *) node; glsl_to_tgsi_instruction *newinst; st_src_reg src_regs[3]; @@ -4962,15 +4956,15 @@ st_translate_program( goto out; } i = 0; - foreach_iter(exec_list_iterator, iter, program->immediates) { - immediate_storage *imm = (immediate_storage *)iter.get(); + foreach_list(node, &program->immediates) { + immediate_storage *imm = (immediate_storage *) node; assert(i < program->num_immediates); t->immediates[i++] = emit_immediate(t, imm->values, imm->type, imm->size); } assert(i == program->num_immediates); /* texture samplers */ - for (i = 0; i < ctx->Const.FragmentProgram.MaxTextureImageUnits; i++) { + for (i = 0; i < ctx->Const.Program[MESA_SHADER_FRAGMENT].MaxTextureImageUnits; i++) { if (program->samplers_used & (1 << i)) { t->samplers[i] = ureg_DECL_sampler(ureg, i); } @@ -4978,10 +4972,9 @@ st_translate_program( /* Emit each instruction in turn: */ - foreach_iter(exec_list_iterator, iter, program->instructions) { + foreach_list(n, &program->instructions) { set_insn_start(t, ureg_get_instruction_number(ureg)); - compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *)iter.get(), - clamp_color); + compile_tgsi_instruction(t, (glsl_to_tgsi_instruction *) n, clamp_color); } /* Fix up all emitted labels: @@ -4996,7 +4989,7 @@ st_translate_program( * prog->ParameterValues to get reallocated (e.g., anything that adds a * program constant) has to happen before creating this linkage. */ - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (program->shader_program->_LinkedShaders[i] == NULL) continue; @@ -5023,6 +5016,24 @@ out: } /* ----------------------------- End TGSI code ------------------------------ */ + +static unsigned +shader_stage_to_ptarget(gl_shader_stage stage) +{ + switch (stage) { + case MESA_SHADER_VERTEX: + return PIPE_SHADER_VERTEX; + case MESA_SHADER_FRAGMENT: + return PIPE_SHADER_FRAGMENT; + case MESA_SHADER_GEOMETRY: + return PIPE_SHADER_GEOMETRY; + } + + assert(!"should not be reached"); + return PIPE_SHADER_VERTEX; +} + + /** * Convert a shader's GLSL IR into a Mesa gl_program, although without * generating Mesa IR. @@ -5034,30 +5045,12 @@ get_mesa_program(struct gl_context *ctx, { glsl_to_tgsi_visitor* v; struct gl_program *prog; - GLenum target; + GLenum target = _mesa_shader_stage_to_program(shader->Stage); bool progress; struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(shader->Type)]; + &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(shader->Type)]; struct pipe_screen *pscreen = ctx->st->pipe->screen; - unsigned ptarget; - - switch (shader->Type) { - case GL_VERTEX_SHADER: - target = GL_VERTEX_PROGRAM_ARB; - ptarget = PIPE_SHADER_VERTEX; - break; - case GL_FRAGMENT_SHADER: - target = GL_FRAGMENT_PROGRAM_ARB; - ptarget = PIPE_SHADER_FRAGMENT; - break; - case GL_GEOMETRY_SHADER: - target = GL_GEOMETRY_PROGRAM_NV; - ptarget = PIPE_SHADER_GEOMETRY; - break; - default: - assert(!"should not be reached"); - return NULL; - } + unsigned ptarget = shader_stage_to_ptarget(shader->Stage); validate_ir_tree(shader->ir); @@ -5089,8 +5082,8 @@ get_mesa_program(struct gl_context *ctx, do { progress = GL_FALSE; - foreach_iter(exec_list_iterator, iter, v->function_signatures) { - function_entry *entry = (function_entry *)iter.get(); + foreach_list(node, &v->function_signatures) { + function_entry *entry = (function_entry *) node; if (!entry->bgn_inst) { v->current_function = entry; @@ -5143,7 +5136,7 @@ get_mesa_program(struct gl_context *ctx, if (ctx->Shader.Flags & GLSL_DUMP) { printf("\n"); printf("GLSL IR for linked %s program %d:\n", - _mesa_shader_enum_to_string(shader->Type), + _mesa_shader_stage_to_string(shader->Stage), shader_program->Name); _mesa_print_ir(shader->ir, NULL); printf("\n"); @@ -5154,7 +5147,7 @@ get_mesa_program(struct gl_context *ctx, prog->Instructions = NULL; prog->NumInstructions = 0; - do_set_program_inouts(shader->ir, prog, shader->Type); + do_set_program_inouts(shader->ir, prog, shader->Stage); count_resources(v, prog); _mesa_reference_program(ctx, &shader->Program, prog); @@ -5207,6 +5200,7 @@ st_new_shader(struct gl_context *ctx, GLuint name, GLuint type) shader = rzalloc(NULL, struct gl_shader); if (shader) { shader->Type = type; + shader->Stage = _mesa_shader_enum_to_shader_stage(type); shader->Name = name; _mesa_init_shader(ctx, shader); } @@ -5236,14 +5230,14 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) { assert(prog->LinkStatus); - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { if (prog->_LinkedShaders[i] == NULL) continue; bool progress; exec_list *ir = prog->_LinkedShaders[i]->ir; const struct gl_shader_compiler_options *options = - &ctx->ShaderCompilerOptions[_mesa_shader_type_to_index(prog->_LinkedShaders[i]->Type)]; + &ctx->ShaderCompilerOptions[_mesa_shader_enum_to_shader_stage(prog->_LinkedShaders[i]->Type)]; /* If there are forms of indirect addressing that the driver * cannot handle, perform the lowering pass. @@ -5306,7 +5300,7 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) validate_ir_tree(ir); } - for (unsigned i = 0; i < MESA_SHADER_TYPES; i++) { + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) { struct gl_program *linked_prog; if (prog->_LinkedShaders[i] == NULL) |