Page MenuHome

doug65536_opencl_patch.diff

File Metadata

Author
Doug Gale (doug65536)
Created
Nov 13 2013, 4:29 PM

doug65536_opencl_patch.diff

Index: intern/cycles/render/light.h
===================================================================
--- intern/cycles/render/light.h (revision 46801)
+++ intern/cycles/render/light.h (working copy)
@@ -27,6 +27,7 @@
CCL_NAMESPACE_BEGIN
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Progress;
class Scene;
@@ -62,15 +63,19 @@
LightManager();
~LightManager();
- void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
void tag_update(Scene *scene);
protected:
- void device_update_points(Device *device, DeviceScene *dscene, Scene *scene);
- void device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_background(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_points(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene);
+ void device_update_distribution(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_background(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
};
CCL_NAMESPACE_END
Index: intern/cycles/render/background.h
===================================================================
--- intern/cycles/render/background.h (revision 46801)
+++ intern/cycles/render/background.h (working copy)
@@ -20,10 +20,10 @@
#define __BACKGROUND_H__
#include "util_types.h"
+#include "device.h"
CCL_NAMESPACE_BEGIN
-class Device;
class DeviceScene;
class Scene;
@@ -40,7 +40,8 @@
Background();
~Background();
- void device_update(Device *device, DeviceScene *dscene, Scene *scene);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene);
void device_free(Device *device, DeviceScene *dscene);
bool modified(const Background& background);
Index: intern/cycles/render/image.h
===================================================================
--- intern/cycles/render/image.h (revision 46801)
+++ intern/cycles/render/image.h (working copy)
@@ -32,6 +32,7 @@
#define TEX_IMAGE_FLOAT_START TEX_NUM_IMAGES
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Progress;
@@ -43,7 +44,8 @@
int add_image(const string& filename, bool& is_float);
void remove_image(const string& filename);
- void device_update(Device *device, DeviceScene *dscene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
void set_osl_texture_system(void *texture_system);
@@ -67,7 +69,12 @@
bool file_load_image(Image *img, device_vector<uchar4>& tex_img);
bool file_load_float_image(Image *img, device_vector<float4>& tex_img);
+<<<<<<< .mine
+ void device_load_image(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, int slot);
+=======
void device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progess);
+>>>>>>> .r46801
void device_free_image(Device *device, DeviceScene *dscene, int slot);
void device_pack_images(Device *device, DeviceScene *dscene, Progress& progess);
Index: intern/cycles/render/film.cpp
===================================================================
--- intern/cycles/render/film.cpp (revision 46801)
+++ intern/cycles/render/film.cpp (working copy)
@@ -183,7 +183,8 @@
{
}
-void Film::device_update(Device *device, DeviceScene *dscene)
+void Film::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene)
{
if(!need_update)
return;
Index: intern/cycles/render/camera.cpp
===================================================================
--- intern/cycles/render/camera.cpp (revision 46801)
+++ intern/cycles/render/camera.cpp (working copy)
@@ -133,7 +133,12 @@
need_device_update = true;
}
+<<<<<<< .mine
+void Camera::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene)
+=======
void Camera::device_update(Device *device, DeviceScene *dscene, Scene *scene)
+>>>>>>> .r46801
{
update();
Index: intern/cycles/render/mesh.cpp
===================================================================
--- intern/cycles/render/mesh.cpp (revision 46801)
+++ intern/cycles/render/mesh.cpp (working copy)
@@ -316,7 +316,8 @@
delete bvh;
}
-void MeshManager::update_osl_attributes(Device *device, Scene *scene, vector<AttributeRequestSet>& mesh_attributes)
+void MeshManager::update_osl_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, Scene *scene, vector<AttributeRequestSet>& mesh_attributes)
{
#ifdef WITH_OSL
/* for OSL, a hash map is used to lookup the attribute by name. */
@@ -378,7 +379,8 @@
#endif
}
-void MeshManager::update_svm_attributes(Device *device, DeviceScene *dscene, Scene *scene, vector<AttributeRequestSet>& mesh_attributes)
+void MeshManager::update_svm_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, vector<AttributeRequestSet>& mesh_attributes)
{
/* for SVM, the attributes_map table is used to lookup the offset of an
* attribute, based on a unique shader attribute id. */
@@ -440,10 +442,11 @@
/* copy to device */
dscene->data.bvh.attributes_map_stride = attr_map_stride;
- device->tex_alloc("__attributes_map", dscene->attributes_map);
+ device->tex_alloc_async(waiter, "__attributes_map", dscene->attributes_map);
}
-void MeshManager::device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void MeshManager::device_update_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
progress.set_status("Updating Mesh", "Computing attributes");
@@ -542,9 +545,9 @@
/* create attribute lookup maps */
if(scene->params.shadingsystem == SceneParams::OSL)
- update_osl_attributes(device, scene, mesh_attributes);
+ update_osl_attributes(waiter, device, scene, mesh_attributes);
else
- update_svm_attributes(device, dscene, scene, mesh_attributes);
+ update_svm_attributes(waiter, device, dscene, scene, mesh_attributes);
if(progress.get_cancel()) return;
@@ -553,15 +556,18 @@
if(attr_float.size()) {
dscene->attributes_float.copy(&attr_float[0], attr_float.size());
- device->tex_alloc("__attributes_float", dscene->attributes_float);
+ device->tex_alloc_async(waiter,
+ "__attributes_float", dscene->attributes_float);
}
if(attr_float3.size()) {
dscene->attributes_float3.copy(&attr_float3[0], attr_float3.size());
- device->tex_alloc("__attributes_float3", dscene->attributes_float3);
+ device->tex_alloc_async(waiter,
+ "__attributes_float3", dscene->attributes_float3);
}
}
-void MeshManager::device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void MeshManager::device_update_mesh(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
/* count and update offsets */
size_t vert_size = 0;
@@ -596,13 +602,14 @@
/* vertex coordinates */
progress.set_status("Updating Mesh", "Copying Mesh to device");
- device->tex_alloc("__tri_normal", dscene->tri_normal);
- device->tex_alloc("__tri_vnormal", dscene->tri_vnormal);
- device->tex_alloc("__tri_verts", dscene->tri_verts);
- device->tex_alloc("__tri_vindex", dscene->tri_vindex);
+ device->tex_alloc_async(waiter, "__tri_normal", dscene->tri_normal);
+ device->tex_alloc_async(waiter, "__tri_vnormal", dscene->tri_vnormal);
+ device->tex_alloc_async(waiter, "__tri_verts", dscene->tri_verts);
+ device->tex_alloc_async(waiter, "__tri_vindex", dscene->tri_vindex);
}
-void MeshManager::device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void MeshManager::device_update_bvh(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
/* bvh build */
progress.set_status("Updating Scene BVH", "Building");
@@ -626,33 +633,34 @@
if(pack.nodes.size()) {
dscene->bvh_nodes.reference((float4*)&pack.nodes[0], pack.nodes.size());
- device->tex_alloc("__bvh_nodes", dscene->bvh_nodes);
+ device->tex_alloc_async(waiter, "__bvh_nodes", dscene->bvh_nodes);
}
if(pack.object_node.size()) {
dscene->object_node.reference((uint*)&pack.object_node[0], pack.object_node.size());
- device->tex_alloc("__object_node", dscene->object_node);
+ device->tex_alloc_async(waiter, "__object_node", dscene->object_node);
}
if(pack.tri_woop.size()) {
dscene->tri_woop.reference(&pack.tri_woop[0], pack.tri_woop.size());
- device->tex_alloc("__tri_woop", dscene->tri_woop);
+ device->tex_alloc_async(waiter, "__tri_woop", dscene->tri_woop);
}
if(pack.prim_visibility.size()) {
dscene->prim_visibility.reference((uint*)&pack.prim_visibility[0], pack.prim_visibility.size());
- device->tex_alloc("__prim_visibility", dscene->prim_visibility);
+ device->tex_alloc_async(waiter, "__prim_visibility", dscene->prim_visibility);
}
if(pack.prim_index.size()) {
dscene->prim_index.reference((uint*)&pack.prim_index[0], pack.prim_index.size());
- device->tex_alloc("__prim_index", dscene->prim_index);
+ device->tex_alloc_async(waiter, "__prim_index", dscene->prim_index);
}
if(pack.prim_object.size()) {
dscene->prim_object.reference((uint*)&pack.prim_object[0], pack.prim_object.size());
- device->tex_alloc("__prim_object", dscene->prim_object);
+ device->tex_alloc_async(waiter, "__prim_object", dscene->prim_object);
}
dscene->data.bvh.root = pack.root_index;
}
-void MeshManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void MeshManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
if(!need_update)
return;
@@ -674,10 +682,10 @@
/* device update */
device_free(device, dscene);
- device_update_mesh(device, dscene, scene, progress);
+ device_update_mesh(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
- device_update_attributes(device, dscene, scene, progress);
+ device_update_attributes(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
/* update displacement */
@@ -694,10 +702,10 @@
if(displacement_done) {
device_free(device, dscene);
- device_update_mesh(device, dscene, scene, progress);
+ device_update_mesh(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
- device_update_attributes(device, dscene, scene, progress);
+ device_update_attributes(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
}
@@ -729,7 +737,7 @@
if(progress.get_cancel()) return;
- device_update_bvh(device, dscene, scene, progress);
+ device_update_bvh(waiter, device, dscene, scene, progress);
need_update = false;
}
Index: intern/cycles/render/scene.cpp
===================================================================
--- intern/cycles/render/scene.cpp (revision 46801)
+++ intern/cycles/render/scene.cpp (working copy)
@@ -114,58 +114,68 @@
image_manager->set_pack_images(device->info.pack_images);
+ DeviceAsyncWaiter waiter = device->create_async();
+
progress.set_status("Updating Background");
- background->device_update(device, &dscene, this);
+ background->device_update(waiter, device, &dscene, this);
if(progress.get_cancel()) return;
progress.set_status("Updating Shaders");
- shader_manager->device_update(device, &dscene, this, progress);
+ shader_manager->device_update(waiter, device, &dscene, this, progress);
if(progress.get_cancel()) return;
progress.set_status("Updating Images");
- image_manager->device_update(device, &dscene, progress);
+ image_manager->device_update(waiter, device, &dscene, progress);
if(progress.get_cancel()) return;
progress.set_status("Updating Camera");
+<<<<<<< .mine
+ camera->device_update(waiter, device, &dscene);
+=======
camera->device_update(device, &dscene, this);
+>>>>>>> .r46801
if(progress.get_cancel()) return;
progress.set_status("Updating Objects");
- object_manager->device_update(device, &dscene, this, progress);
+ object_manager->device_update(waiter, device, &dscene, this, progress);
if(progress.get_cancel()) return;
progress.set_status("Updating Meshes");
- mesh_manager->device_update(device, &dscene, this, progress);
+ mesh_manager->device_update(waiter, device, &dscene, this, progress);
if(progress.get_cancel()) return;
progress.set_status("Updating Lights");
- light_manager->device_update(device, &dscene, this, progress);
+ light_manager->device_update(waiter, device, &dscene, this, progress);
if(progress.get_cancel()) return;
progress.set_status("Updating Filter");
- filter->device_update(device, &dscene);
+ filter->device_update(waiter, device, &dscene);
if(progress.get_cancel()) return;
progress.set_status("Updating Film");
- film->device_update(device, &dscene);
+ film->device_update(waiter, device, &dscene);
if(progress.get_cancel()) return;
progress.set_status("Updating Integrator");
- integrator->device_update(device, &dscene);
+ integrator->device_update(waiter, device, &dscene);
if(progress.get_cancel()) return;
progress.set_status("Updating Device", "Writing constant memory");
- device->const_copy_to("__data", &dscene.data, sizeof(dscene.data));
+ device->const_copy_to_async(waiter,
+ "__data", &dscene.data, sizeof(dscene.data));
+
+ // Wait for all async ops to complete
+ waiter.wait();
}
Scene::MotionType Scene::need_motion()
Index: intern/cycles/render/object.cpp
===================================================================
--- intern/cycles/render/object.cpp (revision 46801)
+++ intern/cycles/render/object.cpp (working copy)
@@ -141,7 +141,8 @@
{
}
-void ObjectManager::device_update_transforms(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void ObjectManager::device_update_transforms(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
float4 *objects = dscene->objects.resize(OBJECT_SIZE*scene->objects.size());
uint *object_flag = dscene->object_flag.resize(OBJECT_SIZE*scene->objects.size());
@@ -240,11 +241,12 @@
if(progress.get_cancel()) return;
}
- device->tex_alloc("__objects", dscene->objects);
+ device->tex_alloc_async(waiter, "__objects", dscene->objects);
device->tex_alloc("__object_flag", dscene->object_flag);
}
-void ObjectManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void ObjectManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
if(!need_update)
return;
@@ -256,7 +258,7 @@
/* set object transform matrices, before applying static transforms */
progress.set_status("Updating Objects", "Copying Transformations to device");
- device_update_transforms(device, dscene, scene, progress);
+ device_update_transforms(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
Index: intern/cycles/render/light.cpp
===================================================================
--- intern/cycles/render/light.cpp (revision 46801)
+++ intern/cycles/render/light.cpp (working copy)
@@ -129,7 +129,8 @@
{
}
-void LightManager::device_update_distribution(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void LightManager::device_update_distribution(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
progress.set_status("Updating Lights", "Computing distribution");
@@ -293,13 +294,15 @@
}
/* CDF */
- device->tex_alloc("__light_distribution", dscene->light_distribution);
+ device->tex_alloc_async(waiter,
+ "__light_distribution", dscene->light_distribution);
}
else
dscene->light_distribution.clear();
}
-void LightManager::device_update_background(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void LightManager::device_update_background(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
KernelIntegrator *kintegrator = &dscene->data.integrator;
Light *background_light = NULL;
@@ -388,11 +391,14 @@
marg_cdf[res].y = 1.0f;
/* update device */
- device->tex_alloc("__light_background_marginal_cdf", dscene->light_background_marginal_cdf);
- device->tex_alloc("__light_background_conditional_cdf", dscene->light_background_conditional_cdf);
+ device->tex_alloc_async(waiter,
+ "__light_background_marginal_cdf", dscene->light_background_marginal_cdf);
+ device->tex_alloc_async(waiter,
+ "__light_background_conditional_cdf", dscene->light_background_conditional_cdf);
}
-void LightManager::device_update_points(Device *device, DeviceScene *dscene, Scene *scene)
+void LightManager::device_update_points(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene)
{
if(scene->lights.size() == 0)
return;
@@ -453,23 +459,24 @@
}
}
- device->tex_alloc("__light_data", dscene->light_data);
+ device->tex_alloc_async(waiter, "__light_data", dscene->light_data);
}
-void LightManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void LightManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
if(!need_update)
return;
device_free(device, dscene);
- device_update_points(device, dscene, scene);
+ device_update_points(waiter, device, dscene, scene);
if(progress.get_cancel()) return;
- device_update_distribution(device, dscene, scene, progress);
+ device_update_distribution(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
- device_update_background(device, dscene, scene, progress);
+ device_update_background(waiter, device, dscene, scene, progress);
if(progress.get_cancel()) return;
need_update = false;
Index: intern/cycles/render/svm.h
===================================================================
--- intern/cycles/render/svm.h (revision 46801)
+++ intern/cycles/render/svm.h (working copy)
@@ -29,6 +29,7 @@
CCL_NAMESPACE_BEGIN
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class ImageManager;
struct KernelSunSky;
@@ -45,7 +46,8 @@
SVMShaderManager();
~SVMShaderManager();
- void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
};
Index: intern/cycles/render/integrator.cpp
===================================================================
--- intern/cycles/render/integrator.cpp (revision 46801)
+++ intern/cycles/render/integrator.cpp (working copy)
@@ -54,7 +54,8 @@
{
}
-void Integrator::device_update(Device *device, DeviceScene *dscene)
+void Integrator::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene)
{
if(!need_update)
return;
@@ -99,7 +100,8 @@
sobol_generate_direction_vectors((uint(*)[SOBOL_BITS])directions, dimensions);
- device->tex_alloc("__sobol_directions", dscene->sobol_directions);
+ device->tex_alloc_async(waiter,
+ "__sobol_directions", dscene->sobol_directions);
need_update = false;
}
Index: intern/cycles/render/background.cpp
===================================================================
--- intern/cycles/render/background.cpp (revision 46801)
+++ intern/cycles/render/background.cpp (working copy)
@@ -45,7 +45,8 @@
{
}
-void Background::device_update(Device *device, DeviceScene *dscene, Scene *scene)
+void Background::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene)
{
if(!need_update)
return;
Index: intern/cycles/render/filter.h
===================================================================
--- intern/cycles/render/filter.h (revision 46801)
+++ intern/cycles/render/filter.h (working copy)
@@ -40,7 +40,8 @@
Filter();
~Filter();
- void device_update(Device *device, DeviceScene *dscene);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene);
void device_free(Device *device, DeviceScene *dscene);
bool modified(const Filter& filter);
Index: intern/cycles/render/camera.h
===================================================================
--- intern/cycles/render/camera.h (revision 46801)
+++ intern/cycles/render/camera.h (working copy)
@@ -27,6 +27,7 @@
CCL_NAMESPACE_BEGIN
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Scene;
@@ -95,7 +96,12 @@
void update();
+<<<<<<< .mine
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene);
+=======
void device_update(Device *device, DeviceScene *dscene, Scene *scene);
+>>>>>>> .r46801
void device_free(Device *device, DeviceScene *dscene);
bool modified(const Camera& cam);
Index: intern/cycles/render/mesh.h
===================================================================
--- intern/cycles/render/mesh.h (revision 46801)
+++ intern/cycles/render/mesh.h (working copy)
@@ -34,6 +34,7 @@
class BVH;
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Mesh;
class Progress;
@@ -118,14 +119,21 @@
bool displace(Device *device, Scene *scene, Mesh *mesh, Progress& progress);
/* attributes */
- void update_osl_attributes(Device *device, Scene *scene, vector<AttributeRequestSet>& mesh_attributes);
- void update_svm_attributes(Device *device, DeviceScene *dscene, Scene *scene, vector<AttributeRequestSet>& mesh_attributes);
+ void update_osl_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, Scene *scene, vector<AttributeRequestSet>& mesh_attributes);
+ void update_svm_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, vector<AttributeRequestSet>& mesh_attributes);
- void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_object(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_mesh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_attributes(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_bvh(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_object(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_mesh(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_attributes(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_bvh(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
void tag_update(Scene *scene);
Index: intern/cycles/render/osl.h
===================================================================
--- intern/cycles/render/osl.h (revision 46801)
+++ intern/cycles/render/osl.h (working copy)
@@ -48,7 +48,8 @@
OSLShaderManager();
~OSLShaderManager();
- void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
private:
Index: intern/cycles/render/svm.cpp
===================================================================
--- intern/cycles/render/svm.cpp (revision 46801)
+++ intern/cycles/render/svm.cpp (working copy)
@@ -40,7 +40,8 @@
{
}
-void SVMShaderManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void SVMShaderManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
if(!need_update)
return;
@@ -80,14 +81,14 @@
}
dscene->svm_nodes.copy((uint4*)&svm_nodes[0], svm_nodes.size());
- device->tex_alloc("__svm_nodes", dscene->svm_nodes);
+ device->tex_alloc_async(waiter, "__svm_nodes", dscene->svm_nodes);
for(i = 0; i < scene->shaders.size(); i++) {
Shader *shader = scene->shaders[i];
shader->need_update = false;
}
- device_update_common(device, dscene, scene, progress);
+ device_update_common(waiter, device, dscene, scene, progress);
need_update = false;
}
Index: intern/cycles/render/shader.cpp
===================================================================
--- intern/cycles/render/shader.cpp (revision 46801)
+++ intern/cycles/render/shader.cpp (working copy)
@@ -161,7 +161,8 @@
return id;
}
-void ShaderManager::device_update_common(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void ShaderManager::device_update_common(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
device_free_common(device, dscene);
@@ -190,7 +191,7 @@
shader_flag[i++] = shader->pass_id;
}
- device->tex_alloc("__shader_flag", dscene->shader_flag);
+ device->tex_alloc_async(waiter, "__shader_flag", dscene->shader_flag);
}
void ShaderManager::device_free_common(Device *device, DeviceScene *dscene)
Index: intern/cycles/render/object.h
===================================================================
--- intern/cycles/render/object.h (revision 46801)
+++ intern/cycles/render/object.h (working copy)
@@ -66,8 +66,10 @@
ObjectManager();
~ObjectManager();
- void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
- void device_update_transforms(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_transforms(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free(Device *device, DeviceScene *dscene);
void tag_update(Scene *scene);
Index: intern/cycles/render/integrator.h
===================================================================
--- intern/cycles/render/integrator.h (revision 46801)
+++ intern/cycles/render/integrator.h (working copy)
@@ -54,7 +54,8 @@
Integrator();
~Integrator();
- void device_update(Device *device, DeviceScene *dscene);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene);
void device_free(Device *device, DeviceScene *dscene);
bool modified(const Integrator& integrator);
Index: intern/cycles/render/filter.cpp
===================================================================
--- intern/cycles/render/filter.cpp (revision 46801)
+++ intern/cycles/render/filter.cpp (working copy)
@@ -105,7 +105,8 @@
return filter_table;
}
-void Filter::device_update(Device *device, DeviceScene *dscene)
+void Filter::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene)
{
if(!need_update)
return;
@@ -116,7 +117,8 @@
vector<float> table = filter_table(filter_type, filter_width);
dscene->filter_table.copy(&table[0], table.size());
- device->tex_alloc("__filter_table", dscene->filter_table, true);
+ device->tex_alloc_async(waiter,
+ "__filter_table", dscene->filter_table, true);
need_update = false;
}
Index: intern/cycles/render/osl.cpp
===================================================================
--- intern/cycles/render/osl.cpp (revision 46801)
+++ intern/cycles/render/osl.cpp (working copy)
@@ -69,7 +69,8 @@
delete services;
}
-void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
+void OSLShaderManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress)
{
/* test if we need to update */
bool need_update = false;
Index: intern/cycles/render/shader.h
===================================================================
--- intern/cycles/render/shader.h (revision 46801)
+++ intern/cycles/render/shader.h (working copy)
@@ -30,6 +30,7 @@
CCL_NAMESPACE_BEGIN
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Mesh;
class Progress;
@@ -95,10 +96,12 @@
virtual ~ShaderManager();
/* device update */
- virtual void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) = 0;
+ virtual void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) = 0;
virtual void device_free(Device *device, DeviceScene *dscene) = 0;
- void device_update_common(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
+ void device_update_common(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
void device_free_common(Device *device, DeviceScene *dscene);
/* get globally unique id for a type of attribute */
Index: intern/cycles/render/image.cpp
===================================================================
--- intern/cycles/render/image.cpp (revision 46801)
+++ intern/cycles/render/image.cpp (working copy)
@@ -324,7 +324,12 @@
return true;
}
+<<<<<<< .mine
+void ImageManager::device_load_image(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, int slot)
+=======
void ImageManager::device_load_image(Device *device, DeviceScene *dscene, int slot, Progress *progress)
+>>>>>>> .r46801
{
if(progress->get_cancel())
return;
@@ -367,8 +372,12 @@
if(slot >= 10) name = string_printf("__tex_image_float_0%d", slot);
else name = string_printf("__tex_image_float_00%d", slot);
+<<<<<<< .mine
+ device->tex_alloc_async(waiter, name.c_str(), tex_img, true, true);
+=======
if(!pack_images)
device->tex_alloc(name.c_str(), tex_img, true, true);
+>>>>>>> .r46801
}
else {
string filename = path_filename(images[slot]->filename);
@@ -394,8 +403,12 @@
if(slot >= 10) name = string_printf("__tex_image_0%d", slot);
else name = string_printf("__tex_image_00%d", slot);
+<<<<<<< .mine
+ device->tex_alloc_async(waiter, name.c_str(), tex_img, true, true);
+=======
if(!pack_images)
device->tex_alloc(name.c_str(), tex_img, true, true);
+>>>>>>> .r46801
}
img->need_load = false;
@@ -439,7 +452,8 @@
}
}
-void ImageManager::device_update(Device *device, DeviceScene *dscene, Progress& progress)
+void ImageManager::device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene, Progress& progress)
{
if(!need_update)
return;
@@ -447,8 +461,21 @@
TaskPool pool;
for(size_t slot = 0; slot < images.size(); slot++) {
+<<<<<<< .mine
+ if(images[slot]) {
+ if(images[slot]->users == 0) {
+ device_free_image(device, dscene, slot);
+ }
+ else if(images[slot]->need_load) {
+ string name = path_filename(images[slot]->filename);
+ progress.set_status("Updating Images", "Loading " + name);
+ device_load_image(waiter, device, dscene, slot);
+ images[slot]->need_load = false;
+ }
+=======
if(!images[slot])
continue;
+>>>>>>> .r46801
if(images[slot]->users == 0) {
device_free_image(device, dscene, slot);
@@ -460,8 +487,21 @@
}
for(size_t slot = 0; slot < float_images.size(); slot++) {
+<<<<<<< .mine
+ if(float_images[slot]) {
+ if(float_images[slot]->users == 0) {
+ device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
+ }
+ else if(float_images[slot]->need_load) {
+ string name = path_filename(float_images[slot]->filename);
+ progress.set_status("Updating Images", "Loading " + name);
+ device_load_image(waiter, device, dscene, slot + TEX_IMAGE_FLOAT_START);
+ float_images[slot]->need_load = false;
+ }
+=======
if(!float_images[slot])
continue;
+>>>>>>> .r46801
if(float_images[slot]->users == 0) {
device_free_image(device, dscene, slot + TEX_IMAGE_FLOAT_START);
Index: intern/cycles/render/film.h
===================================================================
--- intern/cycles/render/film.h (revision 46801)
+++ intern/cycles/render/film.h (working copy)
@@ -27,6 +27,7 @@
CCL_NAMESPACE_BEGIN
class Device;
+class DeviceAsyncWaiter;
class DeviceScene;
class Scene;
@@ -52,7 +53,8 @@
Film();
~Film();
- void device_update(Device *device, DeviceScene *dscene);
+ void device_update(DeviceAsyncWaiter &waiter,
+ Device *device, DeviceScene *dscene);
void device_free(Device *device, DeviceScene *dscene);
bool modified(const Film& film);
Index: intern/cycles/device/device_opencl.cpp
===================================================================
--- intern/cycles/device/device_opencl.cpp (revision 46801)
+++ intern/cycles/device/device_opencl.cpp (working copy)
@@ -36,10 +36,62 @@
CCL_NAMESPACE_BEGIN
-#define CL_MEM_PTR(p) ((cl_mem)(unsigned long)(p))
+#define CL_MEM_PTR(p) ((cl_mem)(uintptr_t)(p))
class OpenCLDevice : public Device
{
+ // Async group implementation
+ class AsyncGroupOpenCL : public AsyncGroup
+ {
+ OpenCLDevice *owner;
+ std::vector<ccl::cl_event> events;
+
+ ~AsyncGroupOpenCL()
+ {
+ clear();
+ }
+
+ void clear()
+ {
+ foreach(ccl::cl_event ev, events)
+ {
+ clReleaseEvent(ev);
+ }
+ events.clear();
+ }
+
+ /* no copying */
+ AsyncGroupOpenCL(const AsyncGroupOpenCL &rhs);
+ void operator=(const AsyncGroupOpenCL &rhs);
+
+ void wait()
+ {
+ cl_int err;
+ err = clWaitForEvents(events.size(), &events[0]);
+ owner->opencl_assert(err);
+ clear();
+ }
+
+ public:
+ AsyncGroupOpenCL(OpenCLDevice *owner)
+ : owner(owner)
+ {
+ }
+
+ static ccl::cl_event *Add(DeviceAsyncWaiter &waiter)
+ {
+ AsyncGroupOpenCL *self =
+ reinterpret_cast<AsyncGroupOpenCL*>(waiter.impl);
+ self->events.push_back(0);
+ return &self->events.back();
+ }
+ };
+
+ DeviceAsyncWaiter create_async()
+ {
+ return DeviceAsyncWaiter(new AsyncGroupOpenCL(this));
+ }
+
public:
cl_context cxContext;
cl_command_queue cqCommandQueue;
@@ -155,46 +207,78 @@
/* setup platform */
cl_uint num_platforms;
-
+
ciErr = clGetPlatformIDs(0, NULL, &num_platforms);
if(opencl_error(ciErr))
return;
-
+
if(num_platforms == 0) {
opencl_error("OpenCL: no platforms found.");
return;
}
- ciErr = clGetPlatformIDs(1, &cpPlatform, NULL);
+ /* the 'info.num' member represents the index of the device as if we concatenated
+ all of the devices from all of the platforms into one array */
+
+ vector<cl_platform_id> platform_ids;
+ platform_ids.resize(num_platforms);
+
+ ciErr = clGetPlatformIDs(num_platforms, &platform_ids[0], NULL);
if(opencl_error(ciErr))
return;
- char name[256];
- clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(name), &name, NULL);
- platform_name = name;
+ int found_anything = 0;
+ int num_base = 0;
/* get devices */
vector<cl_device_id> device_ids;
cl_uint num_devices;
- if(opencl_error(clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices)))
- return;
+ for (int platform = 0; platform < num_platforms; ++platform)
+ {
+ cpPlatform = platform_ids[platform];
- if(info.num > num_devices) {
- if(num_devices == 0)
- opencl_error("OpenCL: no devices found.");
- else
- opencl_error("OpenCL: specified device not found.");
- return;
+ char name[256];
+ clGetPlatformInfo(cpPlatform, CL_PLATFORM_NAME, sizeof(name), &name, NULL);
+ platform_name = name;
+
+ if(opencl_error(clGetDeviceIDs(cpPlatform, /*CL_DEVICE_TYPE_ALL*/CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices)))
+ return;
+
+ /* ignore this platform if it has no devices */
+ /* IMPORTANT, because a platform with no devices won't advance num_base */
+ if (num_devices == 0)
+ continue;
+
+ if(info.num - num_base >= num_devices) {
+ /* skip over the devices in this platform */
+ num_base += num_devices;
+ continue;
+ }
+
+ device_ids.resize(num_devices);
+
+ if (num_devices > 0)
+ found_anything = 1;
+
+ if(opencl_error(clGetDeviceIDs(cpPlatform, /*CL_DEVICE_TYPE_ALL*/ CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL)))
+ return;
+
+ cdDevice = device_ids[info.num - num_base];
+ break;
}
- device_ids.resize(num_devices);
-
- if(opencl_error(clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL)))
+ if(!found_anything)
+ {
+ opencl_error("OpenCL: no devices found.");
return;
+ }
+ else if (!cdDevice)
+ {
+ opencl_error("OpenCL: specified device not found.");
+ return;
+ }
- cdDevice = device_ids[info.num];
-
/* create context */
cxContext = clCreateContext(0, 1, &cdDevice, NULL, NULL, &ciErr);
if(opencl_error(ciErr))
@@ -498,6 +582,33 @@
}
}
+ void mem_copy_to_async(DeviceAsyncWaiter &waiter, device_memory& mem)
+ {
+ size_t size = mem.memory_size();
+ ciErr = clEnqueueWriteBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_FALSE, 0, size, (void*)mem.data_pointer, 0, NULL,
+ AsyncGroupOpenCL::Add(waiter));
+ opencl_assert(ciErr);
+ }
+
+ void mem_copy_from_async(DeviceAsyncWaiter &waiter, device_memory& mem,
+ int y, int w, int h, int elem)
+ {
+ size_t offset = elem*y*w;
+ size_t size = elem*w*h;
+
+ ciErr = clEnqueueReadBuffer(cqCommandQueue, CL_MEM_PTR(mem.device_pointer), CL_FALSE, offset, size, (uchar*)mem.data_pointer + offset, 0, NULL,
+ AsyncGroupOpenCL::Add(waiter));
+ opencl_assert(ciErr);
+ }
+
+ void mem_zero_async(DeviceAsyncWaiter &waiter, device_memory& mem)
+ {
+ if(mem.device_pointer) {
+ memset((void*)mem.data_pointer, 0, mem.memory_size());
+ mem_copy_to_async(waiter, mem);
+ }
+ }
+
void mem_free(device_memory& mem)
{
if(mem.device_pointer) {
@@ -507,7 +618,8 @@
}
}
- void const_copy_to(const char *name, void *host, size_t size)
+private:
+ void const_copy_to_common(const char *name, void *host, size_t size)
{
if(const_mem_map.find(name) == const_mem_map.end()) {
device_vector<uchar> *data = new device_vector<uchar>();
@@ -520,10 +632,22 @@
device_vector<uchar> *data = const_mem_map[name];
data->copy((uchar*)host, size);
}
+ }
+public:
+ void const_copy_to(const char *name, void *host, size_t size)
+ {
+ const_copy_to_common(name, host, size);
mem_copy_to(*const_mem_map[name]);
}
+ void const_copy_to_async(DeviceAsyncWaiter &waiter,
+ const char *name, void *host, size_t size)
+ {
+ const_copy_to_common(name, host, size);
+ mem_copy_to_async(waiter, *const_mem_map[name]);
+ }
+
void tex_alloc(const char *name, device_memory& mem, bool interpolation, bool periodic)
{
mem_alloc(mem, MEM_READ_ONLY);
@@ -531,6 +655,14 @@
mem_map[name] = &mem;
}
+ void tex_alloc_async(DeviceAsyncWaiter &waiter, const char *name,
+ device_memory& mem, bool interpolation, bool periodic)
+ {
+ mem_alloc(mem, MEM_READ_ONLY);
+ mem_copy_to_async(waiter, mem);
+ mem_map[name] = &mem;
+ }
+
void tex_free(device_memory& mem)
{
if(mem.data_pointer)
@@ -708,44 +840,61 @@
{
vector<cl_device_id> device_ids;
cl_uint num_devices;
- cl_platform_id platform_id;
+ vector<cl_platform_id> platform_ids;
cl_uint num_platforms;
+ /* iterate through each platform until we find one that has GPU accelerator */
+
/* get devices */
if(clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS || num_platforms == 0)
return;
- if(clGetPlatformIDs(1, &platform_id, NULL) != CL_SUCCESS)
- return;
+ platform_ids.resize(num_platforms);
- if(clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices) != CL_SUCCESS)
+ if(clGetPlatformIDs(num_platforms, &platform_ids[0], NULL) != CL_SUCCESS)
return;
-
- device_ids.resize(num_devices);
- if(clGetDeviceIDs(platform_id, CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL) != CL_SUCCESS)
- return;
-
- /* add devices */
- for(int num = 0; num < num_devices; num++) {
- cl_device_id device_id = device_ids[num];
- char name[1024];
+ int num_base = 0;
- if(clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(name), &name, NULL) != CL_SUCCESS)
+ int platform;
+ for (platform = 0; platform < num_platforms; ++platform)
+ {
+ if(clGetDeviceIDs(platform_ids[platform], /*CL_DEVICE_TYPE_ALL*/CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, 0, NULL, &num_devices) != CL_SUCCESS)
+ return;
+
+ /* ignore this platform if it has no GPU ACCELERATOR devices */
+ /* IMPORTANT, because a platform with no devices won't advance num_base */
+ if (num_devices == 0)
continue;
- DeviceInfo info;
+ device_ids.resize(num_devices);
- info.type = DEVICE_OPENCL;
- info.description = string(name);
- info.id = string_printf("OPENCL_%d", num);
- info.num = num;
- /* we don't know if it's used for display, but assume it is */
- info.display_device = true;
- info.advanced_shading = false;
+ if(clGetDeviceIDs(platform_ids[platform], /*CL_DEVICE_TYPE_ALL*/CL_DEVICE_TYPE_GPU|CL_DEVICE_TYPE_ACCELERATOR, num_devices, &device_ids[0], NULL) != CL_SUCCESS)
+ return;
info.pack_images = true;
- devices.push_back(info);
+ /* add devices */
+ for(int num = 0; num < num_devices; num++) {
+ cl_device_id device_id = device_ids[num];
+ char name[1024];
+
+ if(clGetDeviceInfo(device_id, CL_DEVICE_NAME, sizeof(name), &name, NULL) != CL_SUCCESS)
+ continue;
+
+ DeviceInfo info;
+
+ info.type = DEVICE_OPENCL;
+ info.description = string(name);
+ info.num = num + num_base;
+ info.id = string_printf("OPENCL_%d", info.num);
+ /* we don't know if it's used for display, but assume it is */
+ info.display_device = true;
+ info.advanced_shading = false;
+
+ devices.push_back(info);
+ }
+
+ num_base += num_devices;
}
}
Index: intern/cycles/device/device.cpp
===================================================================
--- intern/cycles/device/device.cpp (revision 46801)
+++ intern/cycles/device/device.cpp (working copy)
@@ -94,6 +94,38 @@
/* Device */
+/*
+ Default implementations simply do synchronous operation and return
+ no-op AsyncWaiter
+*/
+
+DeviceAsyncWaiter Device::create_async()
+{
+ return DeviceAsyncWaiter(0);
+}
+
+void Device::mem_copy_to_async(DeviceAsyncWaiter &waiter, device_memory& mem)
+{
+ mem_copy_to(mem);
+}
+
+void Device::mem_copy_from_async(DeviceAsyncWaiter &waiter, device_memory& mem,
+ int y, int w, int h, int elem)
+{
+ mem_copy_from(mem, y, w, h, elem);
+}
+
+void Device::mem_zero_async(DeviceAsyncWaiter &waiter, device_memory& mem)
+{
+ mem_zero(mem);
+}
+
+void Device::const_copy_to_async(DeviceAsyncWaiter &waiter,
+ const char *name, void *host, size_t size)
+{
+ const_copy_to(name, host, size);
+}
+
void Device::pixels_alloc(device_memory& mem)
{
mem_alloc(mem, MEM_READ_WRITE);
Index: intern/cycles/device/device.h
===================================================================
--- intern/cycles/device/device.h (revision 46801)
+++ intern/cycles/device/device.h (working copy)
@@ -93,18 +93,33 @@
void split_max_size(list<DeviceTask>& tasks, int max_size);
};
+class DeviceAsyncWaiter;
+
/* Device */
class Device {
+ friend class DeviceAsyncWaiter;
+
protected:
Device() {}
bool background;
string error_msg;
+ // Object returned by methods to support async operations
+ // Default implementation is a no-op
+ class AsyncGroup
+ {
+ public:
+ virtual ~AsyncGroup() {}
+ virtual void wait() {}
+ };
+
public:
virtual ~Device() {}
+ virtual DeviceAsyncWaiter create_async();
+
/* info */
DeviceInfo info;
virtual const string& error_message() { return error_msg; }
@@ -117,14 +132,29 @@
virtual void mem_zero(device_memory& mem) = 0;
virtual void mem_free(device_memory& mem) = 0;
+ /* regular memory (async) */
+ virtual void mem_copy_to_async(DeviceAsyncWaiter &waiter, device_memory& mem);
+ virtual void mem_copy_from_async(DeviceAsyncWaiter &waiter, device_memory& mem,
+ int y, int w, int h, int elem);
+ virtual void mem_zero_async(DeviceAsyncWaiter &waiter, device_memory& mem);
+
/* constant memory */
virtual void const_copy_to(const char *name, void *host, size_t size) = 0;
+ /* constant memory (async) */
+ virtual void const_copy_to_async(DeviceAsyncWaiter &waiter,
+ const char *name, void *host, size_t size);
+
/* texture memory */
virtual void tex_alloc(const char *name, device_memory& mem,
- bool interpolation = false, bool periodic = false) {};
+ bool interpolation = false, bool periodic = false) {}
virtual void tex_free(device_memory& mem) {};
+ /* texture memory (async) */
+ virtual void tex_alloc_async(DeviceAsyncWaiter &waiter,
+ const char *name, device_memory& mem,
+ bool interpolation = false, bool periodic = false) {}
+
/* pixel memory */
virtual void pixels_alloc(device_memory& mem);
virtual void pixels_copy_from(device_memory& mem, int y, int w, int h);
@@ -159,6 +189,39 @@
static vector<DeviceInfo>& available_devices();
};
+/* RAII object to manage lifetime of AsyncWaiter implementations */
+/* This is not nested within Device because it is forward
+ referenced with no definition in various places */
+class DeviceAsyncWaiter
+{
+public:
+ mutable Device::AsyncGroup *impl;
+
+ // Copy construct transfers ownership
+ DeviceAsyncWaiter(const DeviceAsyncWaiter &rhs)
+ : impl(rhs.impl)
+ {
+ rhs.impl = 0;
+ }
+
+ DeviceAsyncWaiter(Device::AsyncGroup *impl)
+ : impl(impl)
+ {
+ }
+
+ ~DeviceAsyncWaiter()
+ {
+ delete impl;
+ }
+
+ void wait()
+ {
+ if (impl)
+ return impl->wait();
+ }
+};
+
+
CCL_NAMESPACE_END
#endif /* __DEVICE_H__ */
Index: intern/cycles/util/util_types.h
===================================================================
--- intern/cycles/util/util_types.h (revision 46801)
+++ intern/cycles/util/util_types.h (working copy)
@@ -121,7 +121,7 @@
/* Generic Memory Pointer */
-typedef uint64_t device_ptr;
+typedef uintptr_t device_ptr;
/* Vector Types */
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt (revision 46801)
+++ CMakeLists.txt (working copy)
@@ -88,6 +88,7 @@
# Load some macros.
include(build_files/cmake/macros.cmake)
+include(InstallRequiredSystemLibraries)
#-----------------------------------------------------------------------------
# Initialize project.
@@ -806,25 +807,58 @@
add_definitions(/D_CRT_NONSTDC_NO_DEPRECATE /D_CRT_SECURE_NO_DEPRECATE /D_SCL_SECURE_NO_DEPRECATE /D_CONSOLE /D_LIB)
+<<<<<<< .mine
+ set(CMAKE_CXX_FLAGS "/nologo /J /W1 /MP /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013" CACHE STRING "MSVC MT C++ flags " FORCE)
+ set(CMAKE_C_FLAGS "/nologo /J /W1 /MP /Gd /wd4018 /wd4244 /wd4305 /wd4800 /wd4065 /wd4267 /we4013 /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
+=======
set(CMAKE_CXX_FLAGS "/nologo /J /Gd /EHsc" CACHE STRING "MSVC MT C++ flags " FORCE)
set(CMAKE_C_FLAGS "/nologo /J /Gd" CACHE STRING "MSVC MT C++ flags " FORCE)
+>>>>>>> .r46801
if(CMAKE_CL_64)
+<<<<<<< .mine
+ set(CMAKE_CXX_FLAGS_DEBUG "/Od /EHsc /RTC1 /MTd /W3 /MP /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
else()
+<<<<<<< .mine
+ set(CMAKE_CXX_FLAGS_DEBUG "/Od /EHsc /RTC1 /MTd /W3 /MP /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_CXX_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
endif()
+<<<<<<< .mine
+ set(CMAKE_CXX_FLAGS_RELEASE "/Ox /Ot /favor:INTEL64 /Oi /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_MINSIZEREL "/Ox /Os /favor:AMD64 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/Ox /Oi /favor:blend /Ob2 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_CXX_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
if(CMAKE_CL_64)
+<<<<<<< .mine
+ set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING "MSVC MT C flags " FORCE) # "/Od /EHsc /RTC1 /MTd /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /Zi" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
else()
+<<<<<<< .mine
+ set(CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG} CACHE STRING "MSVC MT C flags " FORCE) # "/Od /EHsc /RTC1 /MTd /W3 /nologo /ZI /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_C_FLAGS_DEBUG "/Od /Gm /RTC1 /MTd /ZI" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
endif()
+<<<<<<< .mine
+ set(CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE} CACHE STRING "MSVC MT flags " FORCE) # "/Ox /Ot /favor:INTEL64 /Oi /Ob2 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL} CACHE STRING "MSVC MT flags " FORCE) # "/O1 /Ob1 /EHsc /MT /W3 /nologo /J" CACHE STRING "MSVC MT flags " FORCE)
+ set(CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO} CACHE STRING "MSVC MT flags " FORCE) # "/O2 /Ob1 /EHsc /MT /W3 /nologo /Zi /J" CACHE STRING "MSVC MT flags " FORCE)
+=======
set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_MINSIZEREL "/O1 /Ob1 /MT" CACHE STRING "MSVC MT flags " FORCE)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "/O2 /Ob1 /MT /Zi" CACHE STRING "MSVC MT flags " FORCE)
+>>>>>>> .r46801
# most msvc warnings are C & C++
set(_WARNINGS "/W3 /wd4018 /wd4244 /wd4305 /wd4800 /wd4181 /wd4065 /wd4267 /we4013 /wd4200")

Event Timeline