virtual void visit(ir_call *);
virtual void visit(ir_return *);
virtual void visit(ir_discard *);
+ virtual void visit(ir_demote *);
virtual void visit(ir_texture *);
virtual void visit(ir_if *);
virtual void visit(ir_emit_vertex *);
return src;
}
-static int
-storage_type_size(const struct glsl_type *type, bool bindless)
-{
- unsigned int i;
- int size;
-
- switch (type->base_type) {
- case GLSL_TYPE_UINT:
- case GLSL_TYPE_INT:
- case GLSL_TYPE_UINT8:
- case GLSL_TYPE_INT8:
- case GLSL_TYPE_UINT16:
- case GLSL_TYPE_INT16:
- case GLSL_TYPE_FLOAT:
- case GLSL_TYPE_FLOAT16:
- case GLSL_TYPE_BOOL:
- if (type->is_matrix()) {
- return type->matrix_columns;
- } else {
- /* Regardless of size of vector, it gets a vec4. This is bad
- * packing for things like floats, but otherwise arrays become a
- * mess. Hopefully a later pass over the code can pack scalars
- * down if appropriate.
- */
- return 1;
- }
- break;
- case GLSL_TYPE_DOUBLE:
- if (type->is_matrix()) {
- if (type->vector_elements > 2)
- return type->matrix_columns * 2;
- else
- return type->matrix_columns;
- } else {
- if (type->vector_elements > 2)
- return 2;
- else
- return 1;
- }
- break;
- case GLSL_TYPE_UINT64:
- case GLSL_TYPE_INT64:
- if (type->vector_elements > 2)
- return 2;
- else
- return 1;
- case GLSL_TYPE_ARRAY:
- assert(type->length > 0);
- return storage_type_size(type->fields.array, bindless) * type->length;
- case GLSL_TYPE_STRUCT:
- size = 0;
- for (i = 0; i < type->length; i++) {
- size += storage_type_size(type->fields.structure[i].type, bindless);
- }
- return size;
- case GLSL_TYPE_SAMPLER:
- case GLSL_TYPE_IMAGE:
- if (!bindless)
- return 0;
- /* fall through */
- case GLSL_TYPE_SUBROUTINE:
- return 1;
- case GLSL_TYPE_ATOMIC_UINT:
- case GLSL_TYPE_VOID:
- case GLSL_TYPE_ERROR:
- case GLSL_TYPE_INTERFACE:
- case GLSL_TYPE_FUNCTION:
- assert(!"Invalid type in type_size");
- break;
- }
-
- return 0;
-}
-
static int
type_size(const struct glsl_type *type)
{
- return storage_type_size(type, false);
+ return type->count_vec4_slots(false, false);
}
/**
break;
case ir_binop_mod:
/* Floating point should be lowered by MOD_TO_FLOOR in the compiler. */
- assert(ir->type->is_integer());
+ assert(ir->type->is_integer_32());
emit(ir, OPCODE_MUL, result_dst, op[0], op[1]);
break;
case ir_unop_unpack_sampler_2x32:
case ir_unop_pack_image_2x32:
case ir_unop_unpack_image_2x32:
+ case ir_unop_atan:
+ case ir_binop_atan2:
assert(!"not supported");
break;
emit(ir, OPCODE_KIL, undef_dst, this->result);
}
+void
+ir_to_mesa_visitor::visit(ir_demote *ir)
+{
+ assert(!"demote statement unsupported");
+}
+
void
ir_to_mesa_visitor::visit(ir_if *ir)
{
add_uniform_to_shader(struct gl_context *ctx,
struct gl_shader_program *shader_program,
struct gl_program_parameter_list *params)
- : ctx(ctx), params(params), idx(-1)
+ : ctx(ctx), shader_program(shader_program), params(params), idx(-1)
{
/* empty */
}
bool last_field);
struct gl_context *ctx;
+ struct gl_shader_program *shader_program;
struct gl_program_parameter_list *params;
int idx;
ir_variable *var;
*/
if (this->idx < 0)
this->idx = index;
+
+ /* Each Parameter will hold the index to the backing uniform storage.
+ * This avoids relying on names to match parameters and uniform
+ * storages later when associating uniform storage.
+ */
+ unsigned location;
+ const bool found =
+ shader_program->UniformHash->get(location, params->Parameters[index].Name);
+ assert(found);
+
+ for (unsigned i = 0; i < num_params; i++) {
+ struct gl_program_parameter *param = ¶ms->Parameters[index + i];
+ param->UniformStorageIndex = location;
+ param->MainUniformStorageIndex = params->Parameters[this->idx].UniformStorageIndex;
+ }
}
/**
void
_mesa_associate_uniform_storage(struct gl_context *ctx,
struct gl_shader_program *shader_program,
- struct gl_program *prog,
- bool propagate_to_storage)
+ struct gl_program *prog)
{
struct gl_program_parameter_list *params = prog->Parameters;
gl_shader_stage shader_type = prog->info.stage;
if (params->Parameters[i].Type != PROGRAM_UNIFORM)
continue;
- unsigned location;
- const bool found =
- shader_program->UniformHash->get(location, params->Parameters[i].Name);
- assert(found);
-
- if (!found)
- continue;
+ unsigned location = params->Parameters[i].UniformStorageIndex;
struct gl_uniform_storage *storage =
&shader_program->data->UniformStorage[location];
* data from the linker's backing store. This will cause values from
* initializers in the source code to be copied over.
*/
- if (propagate_to_storage) {
- unsigned array_elements = MAX2(1, storage->array_elements);
- if (ctx->Const.PackedDriverUniformStorage && !prog->is_arb_asm &&
- (storage->is_bindless || !storage->type->contains_opaque())) {
- const int dmul = storage->type->is_64bit() ? 2 : 1;
- const unsigned components =
- storage->type->vector_elements *
- storage->type->matrix_columns;
-
- for (unsigned s = 0; s < storage->num_driver_storage; s++) {
- gl_constant_value *uni_storage = (gl_constant_value *)
- storage->driver_storage[s].data;
- memcpy(uni_storage, storage->storage,
- sizeof(storage->storage[0]) * components *
- array_elements * dmul);
- }
- } else {
- _mesa_propagate_uniforms_to_driver_storage(storage, 0,
- array_elements);
+ unsigned array_elements = MAX2(1, storage->array_elements);
+ if (ctx->Const.PackedDriverUniformStorage && !prog->is_arb_asm &&
+ (storage->is_bindless || !storage->type->contains_opaque())) {
+ const int dmul = storage->type->is_64bit() ? 2 : 1;
+ const unsigned components =
+ storage->type->vector_elements *
+ storage->type->matrix_columns;
+
+ for (unsigned s = 0; s < storage->num_driver_storage; s++) {
+ gl_constant_value *uni_storage = (gl_constant_value *)
+ storage->driver_storage[s].data;
+ memcpy(uni_storage, storage->storage,
+ sizeof(storage->storage[0]) * components *
+ array_elements * dmul);
}
+ } else {
+ _mesa_propagate_uniforms_to_driver_storage(storage, 0,
+ array_elements);
}
last_location = location;
* prog->ParameterValues to get reallocated (e.g., anything that adds a
* program constant) has to happen before creating this linkage.
*/
- _mesa_associate_uniform_storage(ctx, shader_program, prog, true);
+ _mesa_associate_uniform_storage(ctx, shader_program, prog);
if (!shader_program->data->LinkStatus) {
goto fail_exit;
}
}
}
- build_program_resource_list(ctx, prog);
+ build_program_resource_list(ctx, prog, false);
return prog->data->LinkStatus;
}
prog->data->LinkStatus = LINKING_FAILURE;
}
+ if (prog->data->LinkStatus != LINKING_FAILURE)
+ _mesa_create_program_resource_hash(prog);
+
/* Return early if we are loading the shader from on-disk cache */
if (prog->data->LinkStatus == LINKING_SKIPPED)
return;