Cycles: Cleanup, silence strict compiler warning
There is one legit place in the code where memcpy was used as an optimization trick. Was needed for older version of GCC, but now it should be re-evaluated and checked if it still helps to have that trick. In other places it's somewhat lazy programming to zero out all object members. That is absolutely unsafe, at the moment when less trivial class is used as a member in that object things will break. Other cases were using memcpy into an object which comes from an external library. We don't control that object, and we can not guarantee it will always be safe for such memory tricks and debugging bugs caused by such low level access is far fun. Ideally we need to use more proper C++, but needs to be done with big care, including benchmarks of each change, For now do annoying but simple cast to void*.
This commit is contained in:
parent
a6e582164f
commit
b763c34e80
|
@ -90,7 +90,7 @@ struct BlenderCamera {
|
|||
static void blender_camera_init(BlenderCamera *bcam,
|
||||
BL::RenderSettings& b_render)
|
||||
{
|
||||
memset(bcam, 0, sizeof(BlenderCamera));
|
||||
memset((void *)bcam, 0, sizeof(BlenderCamera));
|
||||
|
||||
bcam->type = CAMERA_PERSPECTIVE;
|
||||
bcam->zoom = 1.0f;
|
||||
|
|
|
@ -251,7 +251,7 @@ static inline Transform get_transform(const BL::Array<float, 16>& array)
|
|||
|
||||
/* We assume both types to be just 16 floats, and transpose because blender
|
||||
* use column major matrix order while we use row major. */
|
||||
memcpy(&projection, &array, sizeof(float)*16);
|
||||
memcpy((void *)&projection, &array, sizeof(float)*16);
|
||||
projection = projection_transpose(projection);
|
||||
|
||||
/* Drop last row, matrix is assumed to be affine transform. */
|
||||
|
|
|
@ -182,7 +182,10 @@ public:
|
|||
|
||||
BVHReference& operator=(const BVHReference &arg) {
|
||||
if(&arg != this) {
|
||||
memcpy(this, &arg, sizeof(BVHReference));
|
||||
/* TODO(sergey): Check if it is still faster to memcpy() with
|
||||
* modern compilers.
|
||||
*/
|
||||
memcpy((void *)this, &arg, sizeof(BVHReference));
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ ccl_device_inline ShaderClosure *bsdf_alloc_osl(ShaderData *sd, int size, float3
|
|||
if(!sc)
|
||||
return NULL;
|
||||
|
||||
memcpy(sc, data, size);
|
||||
memcpy((void *)sc, data, size);
|
||||
|
||||
float sample_weight = fabsf(average(weight));
|
||||
sc->weight = weight;
|
||||
|
|
|
@ -65,13 +65,13 @@ CCL_NAMESPACE_BEGIN
|
|||
static void copy_matrix(OSL::Matrix44& m, const Transform& tfm)
|
||||
{
|
||||
ProjectionTransform t = projection_transpose(ProjectionTransform(tfm));
|
||||
memcpy(&m, &t, sizeof(m));
|
||||
memcpy((void *)&m, &t, sizeof(m));
|
||||
}
|
||||
|
||||
static void copy_matrix(OSL::Matrix44& m, const ProjectionTransform& tfm)
|
||||
{
|
||||
ProjectionTransform t = projection_transpose(tfm);
|
||||
memcpy(&m, &t, sizeof(m));
|
||||
memcpy((void *)&m, &t, sizeof(m));
|
||||
}
|
||||
|
||||
/* static ustrings */
|
||||
|
|
|
@ -53,7 +53,7 @@ void OSLShader::thread_init(KernelGlobals *kg, KernelGlobals *kernel_globals, OS
|
|||
OSL::ShadingSystem *ss = kg->osl->ss;
|
||||
OSLThreadData *tdata = new OSLThreadData();
|
||||
|
||||
memset(&tdata->globals, 0, sizeof(OSL::ShaderGlobals));
|
||||
memset((void *)&tdata->globals, 0, sizeof(OSL::ShaderGlobals));
|
||||
tdata->globals.tracedata = &tdata->tracedata;
|
||||
tdata->globals.flipHandedness = false;
|
||||
tdata->osl_thread_info = ss->create_thread_info();
|
||||
|
|
|
@ -176,7 +176,7 @@ Camera::Camera()
|
|||
need_flags_update = true;
|
||||
previous_need_motion = -1;
|
||||
|
||||
memset(&kernel_camera, 0, sizeof(kernel_camera));
|
||||
memset((void *)&kernel_camera, 0, sizeof(kernel_camera));
|
||||
}
|
||||
|
||||
Camera::~Camera()
|
||||
|
|
|
@ -79,13 +79,13 @@ DeviceScene::DeviceScene(Device *device)
|
|||
sobol_directions(device, "__sobol_directions", MEM_TEXTURE),
|
||||
ies_lights(device, "__ies", MEM_TEXTURE)
|
||||
{
|
||||
memset(&data, 0, sizeof(data));
|
||||
memset((void*)&data, 0, sizeof(data));
|
||||
}
|
||||
|
||||
Scene::Scene(const SceneParams& params_, Device *device)
|
||||
: device(device), dscene(device), params(params_)
|
||||
{
|
||||
memset(&dscene.data, 0, sizeof(dscene.data));
|
||||
memset((void *)&dscene.data, 0, sizeof(dscene.data));
|
||||
|
||||
camera = new Camera();
|
||||
dicing_camera = new Camera();
|
||||
|
|
|
@ -735,7 +735,7 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
|||
}
|
||||
|
||||
/* clear all compiler state */
|
||||
memset(&active_stack, 0, sizeof(active_stack));
|
||||
memset((void *)&active_stack, 0, sizeof(active_stack));
|
||||
current_svm_nodes.clear();
|
||||
|
||||
foreach(ShaderNode *node_iter, graph->nodes) {
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
{
|
||||
if(this != &from) {
|
||||
resize(from.size());
|
||||
memcpy(data_, from.data_, datasize_*sizeof(T));
|
||||
memcpy((void*)data_, from.data_, datasize_*sizeof(T));
|
||||
}
|
||||
|
||||
return *this;
|
||||
|
@ -204,7 +204,9 @@ public:
|
|||
return NULL;
|
||||
}
|
||||
else if(data_ != NULL) {
|
||||
memcpy(newdata, data_, ((datasize_ < newsize)? datasize_: newsize)*sizeof(T));
|
||||
memcpy((void *)newdata,
|
||||
data_,
|
||||
((datasize_ < newsize)? datasize_: newsize)*sizeof(T));
|
||||
mem_free(data_, capacity_);
|
||||
}
|
||||
data_ = newdata;
|
||||
|
|
Loading…
Reference in New Issue