Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/render/image.cpp')
-rw-r--r--intern/cycles/render/image.cpp70
1 files changed, 49 insertions, 21 deletions
diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp
index 7bceb8a8bfa..c0cbf0af968 100644
--- a/intern/cycles/render/image.cpp
+++ b/intern/cycles/render/image.cpp
@@ -22,6 +22,7 @@
#include "util_image.h"
#include "util_path.h"
#include "util_progress.h"
+#include "util_texture.h"
#ifdef WITH_OSL
#include <OSL/oslexec.h>
@@ -29,16 +30,46 @@
CCL_NAMESPACE_BEGIN
-ImageManager::ImageManager()
+ImageManager::ImageManager(const DeviceInfo& info)
{
need_update = true;
pack_images = false;
osl_texture_system = NULL;
animation_frame = 0;
- tex_num_images = TEX_NUM_IMAGES;
- tex_num_float_images = TEX_NUM_FLOAT_IMAGES;
- tex_image_byte_start = TEX_IMAGE_BYTE_START;
+ /* Set image limits */
+
+ /* CPU */
+ if(info.type == DEVICE_CPU) {
+ tex_num_byte_images = TEX_NUM_BYTE_IMAGES_CPU;
+ tex_num_float_images = TEX_NUM_FLOAT_IMAGES_CPU;
+ tex_image_byte_start = TEX_IMAGE_BYTE_START_CPU;
+ }
+ /* CUDA (Fermi) */
+ else if((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && !info.extended_images) {
+ tex_num_byte_images = TEX_NUM_BYTE_IMAGES_CUDA;
+ tex_num_float_images = TEX_NUM_FLOAT_IMAGES_CUDA;
+ tex_image_byte_start = TEX_IMAGE_BYTE_START_CUDA;
+ }
+ /* CUDA (Kepler and above) */
+ else if((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && info.extended_images) {
+ tex_num_byte_images = TEX_NUM_BYTE_IMAGES_CUDA_KEPLER;
+ tex_num_float_images = TEX_NUM_FLOAT_IMAGES_CUDA_KEPLER;
+ tex_image_byte_start = TEX_IMAGE_BYTE_START_CUDA_KELPER;
+ }
+ /* OpenCL */
+ else if(info.pack_images) {
+ tex_num_byte_images = TEX_NUM_BYTE_IMAGES_OPENCL;
+ tex_num_float_images = TEX_NUM_FLOAT_IMAGES_OPENCL;
+ tex_image_byte_start = TEX_IMAGE_BYTE_START_OPENCL;
+ }
+ /* Should never happen */
+ else {
+ tex_num_byte_images = 0;
+ tex_num_float_images = 0;
+ tex_image_byte_start = 0;
+ assert(0);
+ }
}
ImageManager::~ImageManager()
@@ -59,18 +90,6 @@ void ImageManager::set_osl_texture_system(void *texture_system)
osl_texture_system = texture_system;
}
-void ImageManager::set_extended_image_limits(const DeviceInfo& info)
-{
- if(info.type == DEVICE_CPU) {
- tex_num_images = TEX_EXTENDED_NUM_IMAGES_CPU;
- tex_num_float_images = TEX_EXTENDED_NUM_FLOAT_IMAGES;
- tex_image_byte_start = TEX_EXTENDED_IMAGE_BYTE_START;
- }
- else if((info.type == DEVICE_CUDA || info.type == DEVICE_MULTI) && info.extended_images) {
- tex_num_images = TEX_EXTENDED_NUM_IMAGES_GPU;
- }
-}
-
bool ImageManager::set_animation_frame_update(int frame)
{
if(frame != animation_frame) {
@@ -263,9 +282,9 @@ int ImageManager::add_image(const string& filename,
if(slot == images.size()) {
/* max images limit reached */
- if(images.size() == tex_num_images) {
+ if(images.size() == tex_num_byte_images) {
printf("ImageManager::add_image: byte image limit reached %d, skipping '%s'\n",
- tex_num_images, filename.c_str());
+ tex_num_byte_images, filename.c_str());
return -1;
}
@@ -350,7 +369,8 @@ void ImageManager::remove_image(const string& filename,
filename,
builtin_data,
interpolation,
- extension)) {
+ extension))
+ {
remove_image(slot);
break;
}
@@ -374,7 +394,8 @@ void ImageManager::tag_reload_image(const string& filename,
filename,
builtin_data,
interpolation,
- extension)) {
+ extension))
+ {
images[slot]->need_load = true;
break;
}
@@ -387,7 +408,8 @@ void ImageManager::tag_reload_image(const string& filename,
filename,
builtin_data,
interpolation,
- extension)) {
+ extension))
+ {
float_images[slot]->need_load = true;
break;
}
@@ -447,6 +469,9 @@ bool ImageManager::file_load_image(Image *img, device_vector<uchar4>& tex_img)
/* read RGBA pixels */
uchar *pixels = (uchar*)tex_img.resize(width, height, depth);
+ if(pixels == NULL) {
+ return false;
+ }
bool cmyk = false;
if(in) {
@@ -570,6 +595,9 @@ bool ImageManager::file_load_float_image(Image *img, device_vector<float4>& tex_
/* read RGBA pixels */
float *pixels = (float*)tex_img.resize(width, height, depth);
+ if(pixels == NULL) {
+ return false;
+ }
bool cmyk = false;
if(in) {