prog->data->NumUniformStorage);
data = rzalloc_array(prog->data->UniformStorage,
union gl_constant_value, num_data_slots);
+ prog->data->UniformDataDefaults =
+ rzalloc_array(prog->data->UniformStorage,
+ union gl_constant_value, num_data_slots);
} else {
data = prog->data->UniformDataSlots;
}
unsigned vec_size =
prog->data->UniformStorage[i].type->component_slots() *
MAX2(prog->data->UniformStorage[i].array_elements, 1);
- blob_write_bytes(metadata, prog->data->UniformStorage[i].storage,
+ unsigned slot =
+ prog->data->UniformStorage[i].storage -
+ prog->data->UniformDataSlots;
+ blob_write_bytes(metadata, &prog->data->UniformDataDefaults[slot],
sizeof(union gl_constant_value) * vec_size);
}
}
data = rzalloc_array(uniforms, union gl_constant_value,
prog->data->NumUniformDataSlots);
prog->data->UniformDataSlots = data;
+ prog->data->UniformDataDefaults =
+ rzalloc_array(uniforms, union gl_constant_value,
+ prog->data->NumUniformDataSlots);
prog->UniformHash = new string_to_uint_map;
unsigned vec_size =
prog->data->UniformStorage[i].type->component_slots() *
MAX2(prog->data->UniformStorage[i].array_elements, 1);
+ unsigned slot =
+ prog->data->UniformStorage[i].storage -
+ prog->data->UniformDataSlots;
blob_copy_bytes(metadata,
- (uint8_t *) prog->data->UniformStorage[i].storage,
+ (uint8_t *) &prog->data->UniformDataSlots[slot],
sizeof(union gl_constant_value) * vec_size);
assert(vec_size + prog->data->UniformStorage[i].storage <=
data + prog->data->NumUniformDataSlots);
}
}
+
+ memcpy(prog->data->UniformDataDefaults, prog->data->UniformDataSlots,
+ sizeof(union gl_constant_value) * prog->data->NumUniformDataSlots);
}
enum uniform_remap_type
unsigned NumUniformDataSlots;
union gl_constant_value *UniformDataSlots;
+ /* Used to hold initial uniform values for program binary restores.
+ *
+ * From the ARB_get_program_binary spec:
+ *
+ * "A successful call to ProgramBinary will reset all uniform
+ * variables to their initial values. The initial value is either
+ * the value of the variable's initializer as specified in the
+ * original shader source, or 0 if no initializer was present.
+ */
+ union gl_constant_value *UniformDataDefaults;
+
GLboolean Validated;
/** List of all active resources after linking. */