Updated glsl-optimizer.

This commit is contained in:
bkaradzic 2013-03-18 22:51:48 -07:00
parent 8d5f9f3355
commit 511bde63fa
15 changed files with 51 additions and 43 deletions

View File

@ -1600,11 +1600,11 @@ ast_expression::hir(exec_list *instructions,
* negative constant expression."
*/
if (array->type->is_matrix()) {
if (array->type->row_type()->vector_elements <= idx) {
if ((int)array->type->row_type()->vector_elements <= idx) {
bound = array->type->row_type()->vector_elements;
}
} else if (array->type->is_vector()) {
if (array->type->vector_elements <= idx) {
if ((int)array->type->vector_elements <= idx) {
bound = array->type->vector_elements;
}
} else {
@ -1738,7 +1738,7 @@ ast_expression::hir(exec_list *instructions,
break;
case ast_bool_constant:
result = new(ctx) ir_constant(bool(this->primary_expression.bool_constant));
result = new(ctx) ir_constant(bool(!!this->primary_expression.bool_constant));
break;
case ast_sequence: {
@ -2477,7 +2477,7 @@ process_initializer(ir_variable *var, ast_declaration *decl,
}
static void
apply_precision_to_variable(const struct ast_type_specifier *spec,
apply_precision_to_variable(const class ast_type_specifier *spec,
ir_variable *var,
struct _mesa_glsl_parse_state *state)
{
@ -4110,7 +4110,7 @@ ast_uniform_block::hir(exec_list *instructions,
decl_list->hir(&declared_variables, state);
foreach_list_const(node, &declared_variables) {
struct ir_variable *var = (ir_variable *)node;
class ir_variable *var = (ir_variable *)node;
struct gl_uniform_buffer_variable *ubo_var =
&ubo->Uniforms[ubo->NumUniforms++];

View File

@ -334,7 +334,7 @@ glslopt_shader* glslopt_optimize (glslopt_ctx* ctx, glslopt_shader_type type, co
if (!(options & kGlslOptionSkipPreprocessor))
{
state->error = glcpp_preprocess (state, &shaderSource, &state->info_log, state->extensions, ctx->mesa_ctx.API);
state->error = !!glcpp_preprocess (state, &shaderSource, &state->info_log, state->extensions, ctx->mesa_ctx.API);
if (state->error)
{
shader->status = !state->error;

View File

@ -108,7 +108,7 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
if (ctx->Const.ForceGLSLExtensionsWarn)
_mesa_glsl_process_extension("all", NULL, "warn", NULL, this);
this->default_uniform_qualifier = new(this) ast_type_qualifier();
this->default_uniform_qualifier = new(this) ast_type_qualifier;
this->default_uniform_qualifier->flags.q.shared = 1;
this->default_uniform_qualifier->flags.q.column_major = 1;
}
@ -335,7 +335,7 @@ bool _mesa_glsl_extension::compatible_with_state(const _mesa_glsl_parse_state *
* offset this->supported_flag. See
* _mesa_glsl_extension::supported_flag for more info.
*/
return state->extensions->*(this->supported_flag);
return !!(state->extensions->*(this->supported_flag));
}
/**
@ -697,7 +697,7 @@ ast_parameter_declarator::print(void) const
type->print();
if (identifier)
printf("%s ", identifier);
ast_opt_array_size_print(is_array, array_size);
ast_opt_array_size_print(!!is_array, array_size);
}
@ -713,7 +713,7 @@ void
ast_declaration::print(void) const
{
printf("%s ", identifier);
ast_opt_array_size_print(is_array, array_size);
ast_opt_array_size_print(!!is_array, array_size);
if (initializer) {
printf("= ");
@ -1063,7 +1063,7 @@ do_common_optimization(exec_list *ir, bool linked,
}
delete ls;
return progress;
return !!progress;
}
extern "C" {

View File

@ -831,7 +831,7 @@ ir_constant::get_float_component(unsigned i) const
case GLSL_TYPE_UINT: return (float) this->value.u[i];
case GLSL_TYPE_INT: return (float) this->value.i[i];
case GLSL_TYPE_FLOAT: return this->value.f[i];
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0 : 0.0;
case GLSL_TYPE_BOOL: return this->value.b[i] ? 1.0f : 0.0f;
default: assert(!"Should not get here."); break;
}

View File

@ -81,7 +81,7 @@ swizzle_for_size(operand a, int components)
{
void *mem_ctx = ralloc_parent(a.val);
if (a.val->type->vector_elements < components)
if ((int)a.val->type->vector_elements < components)
components = a.val->type->vector_elements;
unsigned s[4] = { 0, 1, 2, 3 };

View File

@ -279,7 +279,7 @@ ir_expression::constant_expression_value(struct hash_table *variable_context)
case ir_unop_round_even:
assert(op[0]->type->base_type == GLSL_TYPE_FLOAT);
for (unsigned c = 0; c < op[0]->type->components(); c++) {
data.f[c] = round_to_even(op[0]->value.f[c]);
data.f[c] = (float)round_to_even(op[0]->value.f[c]);
}
break;

View File

@ -852,7 +852,7 @@ ir_reader::read_constant(s_expression *expr)
break;
}
case GLSL_TYPE_BOOL: {
data.b[k] = value->value();
data.b[k] = !!value->value();
break;
}
default:

View File

@ -333,14 +333,14 @@ private:
if (this->ubo_var) {
this->uniforms[id].block_index = this->ubo_block_index;
unsigned alignment = type->std140_base_alignment(ubo_var->RowMajor);
unsigned alignment = type->std140_base_alignment(!!ubo_var->RowMajor);
this->ubo_byte_offset = align(this->ubo_byte_offset, alignment);
this->uniforms[id].offset = this->ubo_byte_offset;
this->ubo_byte_offset += type->std140_size(ubo_var->RowMajor);
this->ubo_byte_offset += type->std140_size(!!ubo_var->RowMajor);
if (type->is_array()) {
this->uniforms[id].array_stride =
align(type->fields.array->std140_size(ubo_var->RowMajor), 16);
align(type->fields.array->std140_size(!!ubo_var->RowMajor), 16);
} else {
this->uniforms[id].array_stride = 0;
}
@ -348,7 +348,7 @@ private:
if (type->is_matrix() ||
(type->is_array() && type->fields.array->is_matrix())) {
this->uniforms[id].matrix_stride = 16;
this->uniforms[id].row_major = ubo_var->RowMajor;
this->uniforms[id].row_major = !!ubo_var->RowMajor;
} else {
this->uniforms[id].matrix_stride = 0;
this->uniforms[id].row_major = false;
@ -493,8 +493,8 @@ link_assign_uniform_block_offsets(struct gl_shader *shader)
struct gl_uniform_buffer_variable *ubo_var = &block->Uniforms[i];
const struct glsl_type *type = ubo_var->Type;
unsigned alignment = type->std140_base_alignment(ubo_var->RowMajor);
unsigned size = type->std140_size(ubo_var->RowMajor);
unsigned alignment = type->std140_base_alignment(!!ubo_var->RowMajor);
unsigned size = type->std140_size(!!ubo_var->RowMajor);
offset = align(offset, alignment);
ubo_var->Offset = offset;

View File

@ -2385,7 +2385,7 @@ check_resources(struct gl_context *ctx, struct gl_shader_program *prog)
}
}
return prog->LinkStatus;
return !!prog->LinkStatus;
}
void

View File

@ -126,14 +126,14 @@ ir_mat_op_to_vec_visitor::do_mul_mat_mat(ir_dereference *result,
ir_assignment *assign;
ir_expression *expr;
for (b_col = 0; b_col < b->type->matrix_columns; b_col++) {
for (b_col = 0; b_col < (int)b->type->matrix_columns; b_col++) {
/* first column */
expr = new(mem_ctx) ir_expression(ir_binop_mul,
get_column(a, 0),
get_element(b, b_col, 0));
/* following columns */
for (i = 1; i < a->type->matrix_columns; i++) {
for (i = 1; i < (int)a->type->matrix_columns; i++) {
ir_expression *mul_expr;
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
@ -164,7 +164,7 @@ ir_mat_op_to_vec_visitor::do_mul_mat_vec(ir_dereference *result,
get_element(b, 0, 0));
/* following columns */
for (i = 1; i < a->type->matrix_columns; i++) {
for (i = 1; i < (int)a->type->matrix_columns; i++) {
ir_expression *mul_expr;
mul_expr = new(mem_ctx) ir_expression(ir_binop_mul,
@ -185,7 +185,7 @@ ir_mat_op_to_vec_visitor::do_mul_vec_mat(ir_dereference *result,
{
int i;
for (i = 0; i < b->type->matrix_columns; i++) {
for (i = 0; i < (int)b->type->matrix_columns; i++) {
ir_rvalue *column_result;
ir_expression *column_expr;
ir_assignment *column_assign;
@ -210,7 +210,7 @@ ir_mat_op_to_vec_visitor::do_mul_mat_scalar(ir_dereference *result,
{
int i;
for (i = 0; i < a->type->matrix_columns; i++) {
for (i = 0; i < (int)a->type->matrix_columns; i++) {
ir_expression *column_expr;
ir_assignment *column_assign;

View File

@ -87,7 +87,7 @@ lower_ubo_reference_visitor::handle_rvalue(ir_rvalue **rvalue)
this->ubo_var = &block->Uniforms[var->location];
ir_rvalue *offset = new(mem_ctx) ir_constant(0u);
unsigned const_offset = 0;
bool row_major = ubo_var->RowMajor;
bool row_major = !!ubo_var->RowMajor;
/* Calculate the offset to the start of the region of the UBO
* dereferenced by *rvalue. This may be a variable offset if an
@ -218,18 +218,18 @@ lower_ubo_reference_visitor::emit_ubo_loads(ir_dereference *deref,
field_offset =
align(field_offset,
field->type->std140_base_alignment(ubo_var->RowMajor));
field->type->std140_base_alignment(!!ubo_var->RowMajor));
emit_ubo_loads(field_deref, base_offset, deref_offset + field_offset);
field_offset += field->type->std140_size(ubo_var->RowMajor);
field_offset += field->type->std140_size(!!ubo_var->RowMajor);
}
return;
}
if (deref->type->is_array()) {
unsigned array_stride =
align(deref->type->fields.array->std140_size(ubo_var->RowMajor), 16);
align(deref->type->fields.array->std140_size(!!ubo_var->RowMajor), 16);
for (unsigned i = 0; i < deref->type->length; i++) {
ir_constant *element = new(mem_ctx) ir_constant(i);

View File

@ -109,7 +109,7 @@ ir_vec_index_to_cond_assign_visitor::convert_vec_index_to_cond_assign(ir_rvalue
mem_ctx);
/* Generate a conditional move of each vector element to the temp. */
for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
for (i = 0; i < (int)orig_deref->array->type->vector_elements; i++) {
ir_rvalue *condition_swizzle =
new(base_ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1);
@ -209,7 +209,7 @@ ir_vec_index_to_cond_assign_visitor::visit_leave(ir_assignment *ir)
mem_ctx);
/* Generate a conditional move of each vector element to the temp. */
for (i = 0; i < orig_deref->array->type->vector_elements; i++) {
for (i = 0; i < (int)orig_deref->array->type->vector_elements; i++) {
ir_rvalue *condition_swizzle =
new(ir) ir_swizzle(cond_deref->clone(ir, NULL), i, 0, 0, 0, 1);

View File

@ -93,7 +93,7 @@ ir_vec_index_to_swizzle_visitor::convert_vec_index_to_swizzle(ir_rvalue *ir)
* large. For simplicity sake, just clamp the index to [0, size-1].
*/
const int i = MIN2(MAX2(ir_constant->value.i[0], 0),
(deref->array->type->vector_elements - 1));
((int)deref->array->type->vector_elements - 1));
return new(ctx) ir_swizzle(deref->array, i, 0, 0, 0, 1);
}

View File

@ -45,14 +45,16 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../talloc;../../../include;../../mesa;../../mapi;../../../include/c99"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;snprintf=_snprintf"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="false"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
DisableSpecificWarnings="4291;4996;4800;4099;4244;4018"
DisableSpecificWarnings="4996"
ForcedIncludeFiles=""
/>
<Tool
@ -111,14 +113,16 @@
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="../../talloc;../../../include;../../mesa;../../mapi;../../../include/c99"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;snprintf=_snprintf"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
MinimalRebuild="false"
ExceptionHandling="0"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
DisableSpecificWarnings="4291;4996;4800;4099;4244;4018"
DisableSpecificWarnings="4996"
ForcedIncludeFiles=""
/>
<Tool
@ -178,13 +182,15 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../../talloc;../../../include;../../mesa;../../mapi;../../../include/c99"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;snprintf=_snprintf"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
ExceptionHandling="0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
DisableSpecificWarnings="4291;4996;4800;4099;4244;4018"
DisableSpecificWarnings="4996"
ForcedIncludeFiles=""
/>
<Tool
@ -245,13 +251,15 @@
Optimization="2"
EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="../../talloc;../../../include;../../mesa;../../mapi;../../../include/c99"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;snprintf=_snprintf"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;NOMINMAX;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE"
ExceptionHandling="0"
RuntimeLibrary="0"
EnableFunctionLevelLinking="true"
RuntimeTypeInfo="false"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="1"
DisableSpecificWarnings="4291;4996;4800;4099;4244;4018"
DisableSpecificWarnings="4996"
ForcedIncludeFiles=""
/>
<Tool

View File

@ -79,7 +79,7 @@ read_atom(void *ctx, const char *&src, char *&symbol_buffer)
int i = strtol(src, &int_end, 10);
// If strtod matched more characters, it must have a decimal part
if (float_end > int_end)
expr = new(ctx) s_float(f);
expr = new(ctx) s_float((float)f);
else
expr = new(ctx) s_int(i);
} else {