diff options
author | marha <marha@users.sourceforge.net> | 2014-09-02 18:57:19 +0200 |
---|---|---|
committer | marha <marha@users.sourceforge.net> | 2014-09-02 18:57:19 +0200 |
commit | 166caebfaa2b217332a345ffb02c5b9e52f65a3d (patch) | |
tree | 2de6bdc3d44a72fda18c5d070d3902d57a0e5d4a /mesalib/src/mesa | |
parent | dea8f13d8104872dec9243abe06f3d9e4c807ccd (diff) | |
parent | 4aef26e36bc9aba4cd67c158e17f5fb93c9e018c (diff) | |
download | vcxsrv-166caebfaa2b217332a345ffb02c5b9e52f65a3d.tar.gz vcxsrv-166caebfaa2b217332a345ffb02c5b9e52f65a3d.tar.bz2 vcxsrv-166caebfaa2b217332a345ffb02c5b9e52f65a3d.zip |
Merge remote-tracking branch 'origin/released'
Diffstat (limited to 'mesalib/src/mesa')
-rw-r--r-- | mesalib/src/mesa/main/mtypes.h | 31 | ||||
-rw-r--r-- | mesalib/src/mesa/main/textureview.c | 3 | ||||
-rw-r--r-- | mesalib/src/mesa/program/ir_to_mesa.cpp | 59 | ||||
-rw-r--r-- | mesalib/src/mesa/program/prog_cache.c | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_context.h | 2 | ||||
-rw-r--r-- | mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 114 |
6 files changed, 82 insertions, 129 deletions
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h index dc25ea467..4fb30ffba 100644 --- a/mesalib/src/mesa/main/mtypes.h +++ b/mesalib/src/mesa/main/mtypes.h @@ -2348,6 +2348,20 @@ struct gl_fragment_program_state /** + * Context state for compute programs. + */ +struct gl_compute_program_state +{ + struct gl_compute_program *Current; /**< user-bound compute program */ + + /** Currently enabled and valid program (including internal programs + * and compiled shader programs). + */ + struct gl_compute_program *_Current; +}; + + +/** * ATI_fragment_shader runtime state */ #define ATI_FS_INPUT_PRIMARY 0 @@ -3908,32 +3922,32 @@ typedef enum struct gl_driver_flags { /** gl_context::Array::_DrawArrays (vertex array state) */ - GLbitfield NewArray; + uint64_t NewArray; /** gl_context::TransformFeedback::CurrentObject */ - GLbitfield NewTransformFeedback; + uint64_t NewTransformFeedback; /** gl_context::TransformFeedback::CurrentObject::shader_program */ - GLbitfield NewTransformFeedbackProg; + uint64_t NewTransformFeedbackProg; /** gl_context::RasterDiscard */ - GLbitfield NewRasterizerDiscard; + uint64_t NewRasterizerDiscard; /** * gl_context::UniformBufferBindings * gl_shader_program::UniformBlocks */ - GLbitfield NewUniformBuffer; + uint64_t NewUniformBuffer; /** * gl_context::AtomicBufferBindings */ - GLbitfield NewAtomicBuffer; + uint64_t NewAtomicBuffer; /** * gl_context::ImageUnits */ - GLbitfield NewImageUnits; + uint64_t NewImageUnits; }; struct gl_uniform_buffer_binding @@ -4153,6 +4167,7 @@ struct gl_context struct gl_vertex_program_state VertexProgram; struct gl_fragment_program_state FragmentProgram; struct gl_geometry_program_state GeometryProgram; + struct gl_compute_program_state ComputeProgram; struct gl_ati_fragment_shader_state ATIFragmentShader; struct gl_pipeline_shader_state Pipeline; /**< GLSL pipeline shader object state */ @@ -4240,7 +4255,7 @@ struct gl_context GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */ GLbitfield NewState; /**< bitwise-or of _NEW_* flags */ - GLbitfield NewDriverState;/**< bitwise-or of flags from DriverFlags */ + uint64_t NewDriverState; /**< bitwise-or of flags from DriverFlags */ struct gl_driver_flags DriverFlags; diff --git a/mesalib/src/mesa/main/textureview.c b/mesalib/src/mesa/main/textureview.c index b3521e219..6e86a9a44 100644 --- a/mesalib/src/mesa/main/textureview.c +++ b/mesalib/src/mesa/main/textureview.c @@ -536,6 +536,9 @@ _mesa_TextureView(GLuint texture, GLenum target, GLuint origtexture, /* Adjust width, height, depth to be appropriate for new target */ switch (target) { case GL_TEXTURE_1D: + height = 1; + break; + case GL_TEXTURE_3D: break; diff --git a/mesalib/src/mesa/program/ir_to_mesa.cpp b/mesalib/src/mesa/program/ir_to_mesa.cpp index e5844c3c4..49e4a7a40 100644 --- a/mesalib/src/mesa/program/ir_to_mesa.cpp +++ b/mesalib/src/mesa/program/ir_to_mesa.cpp @@ -311,7 +311,6 @@ public: int mul_operand); bool try_emit_mad_for_and_not(ir_expression *ir, int mul_operand); - bool try_emit_sat(ir_expression *ir); void emit_swz(ir_expression *ir); @@ -866,50 +865,6 @@ ir_to_mesa_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operand) return true; } -bool -ir_to_mesa_visitor::try_emit_sat(ir_expression *ir) -{ - /* Saturates were only introduced to vertex programs in - * NV_vertex_program3, so don't give them to drivers in the VP. - */ - if (this->prog->Target == GL_VERTEX_PROGRAM_ARB) - return false; - - ir_rvalue *sat_src = ir->as_rvalue_to_saturate(); - if (!sat_src) - return false; - - sat_src->accept(this); - src_reg src = this->result; - - /* If we generated an expression instruction into a temporary in - * processing the saturate's operand, apply the saturate to that - * instruction. Otherwise, generate a MOV to do the saturate. - * - * Note that we have to be careful to only do this optimization if - * the instruction in question was what generated src->result. For - * example, ir_dereference_array might generate a MUL instruction - * to create the reladdr, and return us a src reg using that - * reladdr. That MUL result is not the value we're trying to - * saturate. - */ - ir_expression *sat_src_expr = sat_src->as_expression(); - ir_to_mesa_instruction *new_inst; - new_inst = (ir_to_mesa_instruction *)this->instructions.get_tail(); - if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul || - sat_src_expr->operation == ir_binop_add || - sat_src_expr->operation == ir_binop_dot)) { - new_inst->saturate = true; - } else { - this->result = get_temp(ir->type); - ir_to_mesa_instruction *inst; - inst = emit(ir, OPCODE_MOV, dst_reg(this->result), src); - inst->saturate = true; - } - - return true; -} - void ir_to_mesa_visitor::reladdr_to_temp(ir_instruction *ir, src_reg *reg, int *num_reladdr) @@ -1072,9 +1027,6 @@ ir_to_mesa_visitor::visit(ir_expression *ir) return; } - if (try_emit_sat(ir)) - return; - if (ir->operation == ir_quadop_vector) { this->emit_swz(ir); return; @@ -1171,6 +1123,12 @@ ir_to_mesa_visitor::visit(ir_expression *ir) emit(ir, OPCODE_DDY, result_dst, op[0]); break; + case ir_unop_saturate: { + ir_to_mesa_instruction *inst = emit(ir, OPCODE_MOV, + result_dst, op[0]); + inst->saturate = true; + break; + } case ir_unop_noise: { const enum prog_opcode opcode = prog_opcode(OPCODE_NOISE1 @@ -2990,9 +2948,12 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) /* Lowering */ do_mat_op_to_vec(ir); + GLenum target = _mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage); lower_instructions(ir, (MOD_TO_FRACT | DIV_TO_MUL_RCP | EXP_TO_EXP2 | LOG_TO_LOG2 | INT_DIV_TO_MUL_RCP - | ((options->EmitNoPow) ? POW_TO_EXP2 : 0))); + | ((options->EmitNoPow) ? POW_TO_EXP2 : 0) + | ((target == GL_VERTEX_PROGRAM_ARB) ? SAT_TO_CLAMP + : 0))); progress = do_lower_jumps(ir, true, true, options->EmitNoMainReturn, options->EmitNoCont, options->EmitNoLoops) || progress; diff --git a/mesalib/src/mesa/program/prog_cache.c b/mesalib/src/mesa/program/prog_cache.c index 07192a96a..34609f056 100644 --- a/mesalib/src/mesa/program/prog_cache.c +++ b/mesalib/src/mesa/program/prog_cache.c @@ -143,7 +143,7 @@ _mesa_new_program_cache(void) if (cache) { cache->size = 17; cache->items = - calloc(1, cache->size * sizeof(struct cache_item)); + calloc(cache->size, sizeof(struct cache_item *)); if (!cache->items) { free(cache); return NULL; diff --git a/mesalib/src/mesa/state_tracker/st_context.h b/mesalib/src/mesa/state_tracker/st_context.h index 6d572bd49..58f14f954 100644 --- a/mesalib/src/mesa/state_tracker/st_context.h +++ b/mesalib/src/mesa/state_tracker/st_context.h @@ -56,7 +56,7 @@ struct u_upload_mgr; struct st_state_flags { GLuint mesa; - GLuint st; + uint64_t st; }; struct st_tracked_state { 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 84bdc4f06..dd9c84f1a 100644 --- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -75,14 +75,6 @@ extern "C" { (1 << PROGRAM_UNIFORM)) /** - * Maximum number of temporary registers. - * - * It is too big for stack allocated arrays -- it will cause stack overflow on - * Windows and likely Mac OS X. - */ -#define MAX_TEMPS 4096 - -/** * Maximum number of arrays */ #define MAX_ARRAYS 256 @@ -446,7 +438,6 @@ public: int mul_operand); bool try_emit_mad_for_and_not(ir_expression *ir, int mul_operand); - bool try_emit_sat(ir_expression *ir); void emit_swz(ir_expression *ir); @@ -1270,53 +1261,6 @@ glsl_to_tgsi_visitor::try_emit_mad_for_and_not(ir_expression *ir, int try_operan return true; } -bool -glsl_to_tgsi_visitor::try_emit_sat(ir_expression *ir) -{ - /* Emit saturates in the vertex shader only if SM 3.0 is supported. - */ - if (this->prog->Target == GL_VERTEX_PROGRAM_ARB && - !st_context(this->ctx)->has_shader_model3) { - return false; - } - - ir_rvalue *sat_src = ir->as_rvalue_to_saturate(); - if (!sat_src) - return false; - - sat_src->accept(this); - st_src_reg src = this->result; - - /* If we generated an expression instruction into a temporary in - * processing the saturate's operand, apply the saturate to that - * instruction. Otherwise, generate a MOV to do the saturate. - * - * Note that we have to be careful to only do this optimization if - * the instruction in question was what generated src->result. For - * example, ir_dereference_array might generate a MUL instruction - * to create the reladdr, and return us a src reg using that - * reladdr. That MUL result is not the value we're trying to - * saturate. - */ - ir_expression *sat_src_expr = sat_src->as_expression(); - if (sat_src_expr && (sat_src_expr->operation == ir_binop_mul || - sat_src_expr->operation == ir_binop_add || - sat_src_expr->operation == ir_binop_dot)) { - glsl_to_tgsi_instruction *new_inst; - new_inst = (glsl_to_tgsi_instruction *)this->instructions.get_tail(); - new_inst->saturate = true; - } else { - this->result = get_temp(ir->type); - st_dst_reg result_dst = st_dst_reg(this->result); - result_dst.writemask = (1 << ir->type->vector_elements) - 1; - glsl_to_tgsi_instruction *inst; - inst = emit(ir, TGSI_OPCODE_MOV, result_dst, src); - inst->saturate = true; - } - - return true; -} - void glsl_to_tgsi_visitor::reladdr_to_temp(ir_instruction *ir, st_src_reg *reg, int *num_reladdr) @@ -1363,9 +1307,6 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) return; } - if (try_emit_sat(ir)) - return; - if (ir->operation == ir_quadop_vector) assert(!"ir_quadop_vector should have been lowered"); @@ -1460,6 +1401,12 @@ glsl_to_tgsi_visitor::visit(ir_expression *ir) case ir_unop_cos_reduced: emit_scs(ir, TGSI_OPCODE_COS, result_dst, op[0]); break; + case ir_unop_saturate: { + glsl_to_tgsi_instruction *inst; + inst = emit(ir, TGSI_OPCODE_MOV, result_dst, op[0]); + inst->saturate = true; + break; + } case ir_unop_dFdx: case ir_unop_dFdx_coarse: @@ -3301,14 +3248,10 @@ get_src_arg_mask(st_dst_reg dst, st_src_reg src) void glsl_to_tgsi_visitor::simplify_cmp(void) { - unsigned *tempWrites; + int tempWritesSize = 0; + unsigned *tempWrites = NULL; unsigned outputWrites[MAX_PROGRAM_OUTPUTS]; - tempWrites = new unsigned[MAX_TEMPS]; - if (!tempWrites) { - return; - } - memset(tempWrites, 0, sizeof(unsigned) * MAX_TEMPS); memset(outputWrites, 0, sizeof(outputWrites)); foreach_in_list(glsl_to_tgsi_instruction, inst, &this->instructions) { @@ -3330,7 +3273,19 @@ glsl_to_tgsi_visitor::simplify_cmp(void) prevWriteMask = outputWrites[inst->dst.index]; outputWrites[inst->dst.index] |= inst->dst.writemask; } else if (inst->dst.file == PROGRAM_TEMPORARY) { - assert(inst->dst.index < MAX_TEMPS); + if (inst->dst.index >= tempWritesSize) { + const int inc = 4096; + + tempWrites = (unsigned*) + realloc(tempWrites, + (tempWritesSize + inc) * sizeof(unsigned)); + if (!tempWrites) + return; + + memset(tempWrites + tempWritesSize, 0, inc * sizeof(unsigned)); + tempWritesSize += inc; + } + prevWriteMask = tempWrites[inst->dst.index]; tempWrites[inst->dst.index] |= inst->dst.writemask; } else @@ -3349,7 +3304,7 @@ glsl_to_tgsi_visitor::simplify_cmp(void) } } - delete [] tempWrites; + free(tempWrites); } /* Replaces all references to a temporary register index with another index. */ @@ -4158,7 +4113,9 @@ struct label { struct st_translate { struct ureg_program *ureg; - struct ureg_dst temps[MAX_TEMPS]; + unsigned temps_size; + struct ureg_dst *temps; + struct ureg_dst arrays[MAX_ARRAYS]; struct ureg_src *constants; struct ureg_src *immediates; @@ -4299,7 +4256,19 @@ dst_register(struct st_translate *t, return ureg_dst_undef(); case PROGRAM_TEMPORARY: - assert(index < Elements(t->temps)); + /* Allocate space for temporaries on demand. */ + if (index >= t->temps_size) { + const int inc = 4096; + + t->temps = (struct ureg_dst*) + realloc(t->temps, + (t->temps_size + inc) * sizeof(struct ureg_dst)); + if (!t->temps) + return ureg_dst_undef(); + + memset(t->temps + t->temps_size, 0, inc * sizeof(struct ureg_dst)); + t->temps_size += inc; + } if (ureg_dst_is_undef(t->temps[index])) t->temps[index] = ureg_DECL_local_temporary(t->ureg); @@ -5158,6 +5127,7 @@ st_translate_program( out: if (t) { + free(t->temps); free(t->insn); free(t->labels); free(t->constants); @@ -5429,6 +5399,9 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) if (!pscreen->get_param(pscreen, PIPE_CAP_TEXTURE_GATHER_OFFSETS)) lower_offset_arrays(ir); do_mat_op_to_vec(ir); + /* Emit saturates in the vertex shader only if SM 3.0 is supported. */ + bool vs_sm3 = (_mesa_shader_stage_to_program(prog->_LinkedShaders[i]->Stage) == + GL_VERTEX_PROGRAM_ARB) && st_context(ctx)->has_shader_model3; lower_instructions(ir, MOD_TO_FRACT | DIV_TO_MUL_RCP | @@ -5438,7 +5411,8 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog) CARRY_TO_ARITH | BORROW_TO_ARITH | (options->EmitNoPow ? POW_TO_EXP2 : 0) | - (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0)); + (!ctx->Const.NativeIntegers ? INT_DIV_TO_MUL_RCP : 0) | + (vs_sm3 ? SAT_TO_CLAMP : 0)); lower_ubo_reference(prog->_LinkedShaders[i], ir); do_vec_index_to_cond_assign(ir); |