copy_constant_to_storage(union gl_constant_value *storage,
const ir_constant *val,
const enum glsl_base_type base_type,
- const unsigned int elements)
+ const unsigned int elements,
+ unsigned int boolean_true)
{
for (unsigned int i = 0; i < elements; i++) {
switch (base_type) {
storage[i].f = val->value.f[i];
break;
case GLSL_TYPE_BOOL:
- storage[i].b = int(val->value.b[i]);
+ storage[i].b = val->value.b[i] ? boolean_true : 0;
break;
case GLSL_TYPE_ARRAY:
case GLSL_TYPE_STRUCT:
void
set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
const char *name, const glsl_type *type,
- ir_constant *val)
+ ir_constant *val, unsigned int boolean_true)
{
if (type->is_record()) {
ir_constant *field_constant;
const char *field_name = ralloc_asprintf(mem_ctx, "%s.%s", name,
type->fields.structure[i].name);
set_uniform_initializer(mem_ctx, prog, field_name,
- field_type, field_constant);
+ field_type, field_constant, boolean_true);
field_constant = (ir_constant *)field_constant->next;
}
return;
const char *element_name = ralloc_asprintf(mem_ctx, "%s[%d]", name, i);
set_uniform_initializer(mem_ctx, prog, element_name,
- element_type, val->array_elements[i]);
+ element_type, val->array_elements[i],
+ boolean_true);
}
return;
}
copy_constant_to_storage(& storage->storage[idx],
val->array_elements[i],
base_type,
- elements);
+ elements,
+ boolean_true);
idx += elements;
}
copy_constant_to_storage(storage->storage,
val,
val->type->base_type,
- val->type->components());
+ val->type->components(),
+ boolean_true);
if (storage->type->is_sampler()) {
for (int sh = 0; sh < MESA_SHADER_STAGES; sh++) {
}
void
-link_set_uniform_initializers(struct gl_shader_program *prog)
+link_set_uniform_initializers(struct gl_shader_program *prog,
+ unsigned int boolean_true)
{
void *mem_ctx = NULL;
}
} else if (var->constant_value) {
linker::set_uniform_initializer(mem_ctx, prog, var->name,
- var->type, var->constant_value);
+ var->type, var->constant_value,
+ boolean_true);
}
}
}
}
void
-link_assign_uniform_locations(struct gl_shader_program *prog)
+link_assign_uniform_locations(struct gl_shader_program *prog,
+ unsigned int boolean_true)
{
ralloc_free(prog->UniformStorage);
prog->UniformStorage = NULL;
prog->UniformStorage = uniforms;
link_set_image_access_qualifiers(prog);
- link_set_uniform_initializers(prog);
+ link_set_uniform_initializers(prog, boolean_true);
return;
}
goto done;
update_array_sizes(prog);
- link_assign_uniform_locations(prog);
+ link_assign_uniform_locations(prog, ctx->Const.UniformBooleanTrue);
link_assign_atomic_counter_resources(ctx, prog);
store_fragdepth_layout(prog);
link_invalidate_variable_locations(exec_list *ir);
extern void
-link_assign_uniform_locations(struct gl_shader_program *prog);
+link_assign_uniform_locations(struct gl_shader_program *prog,
+ unsigned int boolean_true);
extern void
-link_set_uniform_initializers(struct gl_shader_program *prog);
+link_set_uniform_initializers(struct gl_shader_program *prog,
+ unsigned int boolean_true);
extern int
link_cross_validate_uniform_block(void *mem_ctx,
copy_constant_to_storage(union gl_constant_value *storage,
const ir_constant *val,
const enum glsl_base_type base_type,
- const unsigned int elements);
+ const unsigned int elements,
+ unsigned int boolean_true);
}
class copy_constant_to_storage : public ::testing::Test {
linker::copy_constant_to_storage(storage,
val,
val->type->base_type,
- val->type->components());
+ val->type->components(),
+ 0xF00F);
- verify_data(storage, 0, val, red_zone_size);
+ verify_data(storage, 0, val, red_zone_size, 0xF00F);
}
void
linker::copy_constant_to_storage(storage,
val,
val->type->base_type,
- val->type->components());
+ val->type->components(),
+ 0xF00F);
- verify_data(storage, 0, val, red_zone_size);
+ verify_data(storage, 0, val, red_zone_size, 0xF00F);
}
void
linker::copy_constant_to_storage(storage,
val,
val->type->base_type,
- val->type->components());
+ val->type->components(),
+ 0xF00F);
- verify_data(storage, 0, val, red_zone_size);
+ verify_data(storage, 0, val, red_zone_size, 0xF00F);
}
void
linker::copy_constant_to_storage(storage,
val,
val->type->base_type,
- val->type->components());
+ val->type->components(),
+ 0xF00F);
- verify_data(storage, 0, val, red_zone_size);
+ verify_data(storage, 0, val, red_zone_size, 0xF00F);
}
/**
linker::copy_constant_to_storage(storage,
val,
GLSL_TYPE_SAMPLER,
- val->type->components());
+ val->type->components(),
+ 0xF00F);
- verify_data(storage, 0, val, red_zone_size);
+ verify_data(storage, 0, val, red_zone_size, 0xF00F);
}
TEST_F(copy_constant_to_storage, bool_uniform)
extern void
set_uniform_initializer(void *mem_ctx, gl_shader_program *prog,
const char *name, const glsl_type *type,
- ir_constant *val);
+ ir_constant *val, unsigned int boolean_true);
}
class set_uniform_initializer : public ::testing::Test {
ir_constant *val;
generate_data(mem_ctx, base_type, columns, rows, val);
- linker::set_uniform_initializer(mem_ctx, prog, name, type, val);
+ linker::set_uniform_initializer(mem_ctx, prog, name, type, val, 0xF00F);
verify_initialization(prog, actual_index);
verify_data(prog->UniformStorage[actual_index].storage, 0, val,
- red_zone_components);
+ red_zone_components, 0xF00F);
}
TEST_F(set_uniform_initializer, int_uniform)
generate_array_data(mem_ctx, base_type, columns, rows,
array_size + excess_data_size, val);
- linker::set_uniform_initializer(mem_ctx, prog, name, element_type, val);
+ linker::set_uniform_initializer(mem_ctx, prog, name, element_type, val,
+ 0xF00F);
verify_initialization(prog, actual_index);
verify_data(prog->UniformStorage[actual_index].storage, array_size,
- val, red_zone_components);
+ val, red_zone_components, 0xF00F);
}
TEST_F(set_uniform_initializer, int_array_uniform)
*/
void
verify_data(gl_constant_value *storage, unsigned storage_array_size,
- ir_constant *val, unsigned red_zone_size)
+ ir_constant *val, unsigned red_zone_size,
+ unsigned int boolean_true)
{
if (val->type->base_type == GLSL_TYPE_ARRAY) {
const glsl_type *const element_type = val->array_elements[0]->type;
for (unsigned i = 0; i < storage_array_size; i++) {
verify_data(storage + (i * element_type->components()), 0,
- val->array_elements[i], 0);
+ val->array_elements[i], 0, boolean_true);
}
const unsigned components = element_type->components();
EXPECT_EQ(val->value.f[i], storage[i].f);
break;
case GLSL_TYPE_BOOL:
- EXPECT_EQ(int(val->value.b[i]), storage[i].i);
+ EXPECT_EQ(val->value.b[i] ? boolean_true : 0, storage[i].i);
break;
case GLSL_TYPE_ATOMIC_UINT:
case GLSL_TYPE_STRUCT:
extern void
verify_data(gl_constant_value *storage, unsigned storage_array_size,
- ir_constant *val, unsigned red_zone_size);
+ ir_constant *val, unsigned red_zone_size,
+ unsigned int boolean_true);