Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/image.cpp
| Show First 20 Lines • Show All 812 Lines • ▼ Show 20 Lines | if (!file_load_image<TypeDesc::FLOAT, float>(img, type, texture_limit, *tex_img)) { | ||||
| pixels[1] = TEX_IMAGE_MISSING_G; | pixels[1] = TEX_IMAGE_MISSING_G; | ||||
| pixels[2] = TEX_IMAGE_MISSING_B; | pixels[2] = TEX_IMAGE_MISSING_B; | ||||
| pixels[3] = TEX_IMAGE_MISSING_A; | pixels[3] = TEX_IMAGE_MISSING_A; | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_FLOAT) { | else if (type == IMAGE_DATA_TYPE_FLOAT) { | ||||
| device_vector<float> *tex_img = new device_vector<float>( | device_vector<float> *tex_img = new device_vector<float>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::FLOAT, float>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::FLOAT, float>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| float *pixels = (float *)tex_img->alloc(1, 1); | float *pixels = (float *)tex_img->alloc(1, 1); | ||||
| pixels[0] = TEX_IMAGE_MISSING_R; | pixels[0] = TEX_IMAGE_MISSING_R; | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_BYTE4) { | else if (type == IMAGE_DATA_TYPE_BYTE4) { | ||||
| device_vector<uchar4> *tex_img = new device_vector<uchar4>( | device_vector<uchar4> *tex_img = new device_vector<uchar4>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| uchar *pixels = (uchar *)tex_img->alloc(1, 1); | uchar *pixels = (uchar *)tex_img->alloc(1, 1); | ||||
| pixels[0] = (TEX_IMAGE_MISSING_R * 255); | pixels[0] = (TEX_IMAGE_MISSING_R * 255); | ||||
| pixels[1] = (TEX_IMAGE_MISSING_G * 255); | pixels[1] = (TEX_IMAGE_MISSING_G * 255); | ||||
| pixels[2] = (TEX_IMAGE_MISSING_B * 255); | pixels[2] = (TEX_IMAGE_MISSING_B * 255); | ||||
| pixels[3] = (TEX_IMAGE_MISSING_A * 255); | pixels[3] = (TEX_IMAGE_MISSING_A * 255); | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = img->metadata.compress_as_srgb; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_BYTE) { | else if (type == IMAGE_DATA_TYPE_BYTE) { | ||||
| device_vector<uchar> *tex_img = new device_vector<uchar>( | device_vector<uchar> *tex_img = new device_vector<uchar>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::UINT8, uchar>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| uchar *pixels = (uchar *)tex_img->alloc(1, 1); | uchar *pixels = (uchar *)tex_img->alloc(1, 1); | ||||
| pixels[0] = (TEX_IMAGE_MISSING_R * 255); | pixels[0] = (TEX_IMAGE_MISSING_R * 255); | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = img->metadata.compress_as_srgb; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_HALF4) { | else if (type == IMAGE_DATA_TYPE_HALF4) { | ||||
| device_vector<half4> *tex_img = new device_vector<half4>( | device_vector<half4> *tex_img = new device_vector<half4>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| half *pixels = (half *)tex_img->alloc(1, 1); | half *pixels = (half *)tex_img->alloc(1, 1); | ||||
| pixels[0] = TEX_IMAGE_MISSING_R; | pixels[0] = TEX_IMAGE_MISSING_R; | ||||
| pixels[1] = TEX_IMAGE_MISSING_G; | pixels[1] = TEX_IMAGE_MISSING_G; | ||||
| pixels[2] = TEX_IMAGE_MISSING_B; | pixels[2] = TEX_IMAGE_MISSING_B; | ||||
| pixels[3] = TEX_IMAGE_MISSING_A; | pixels[3] = TEX_IMAGE_MISSING_A; | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_USHORT) { | else if (type == IMAGE_DATA_TYPE_USHORT) { | ||||
| device_vector<uint16_t> *tex_img = new device_vector<uint16_t>( | device_vector<uint16_t> *tex_img = new device_vector<uint16_t>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::USHORT, uint16_t>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::USHORT, uint16_t>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| uint16_t *pixels = (uint16_t *)tex_img->alloc(1, 1); | uint16_t *pixels = (uint16_t *)tex_img->alloc(1, 1); | ||||
| pixels[0] = (TEX_IMAGE_MISSING_R * 65535); | pixels[0] = (TEX_IMAGE_MISSING_R * 65535); | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_USHORT4) { | else if (type == IMAGE_DATA_TYPE_USHORT4) { | ||||
| device_vector<ushort4> *tex_img = new device_vector<ushort4>( | device_vector<ushort4> *tex_img = new device_vector<ushort4>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::USHORT, uint16_t>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::USHORT, uint16_t>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| uint16_t *pixels = (uint16_t *)tex_img->alloc(1, 1); | uint16_t *pixels = (uint16_t *)tex_img->alloc(1, 1); | ||||
| pixels[0] = (TEX_IMAGE_MISSING_R * 65535); | pixels[0] = (TEX_IMAGE_MISSING_R * 65535); | ||||
| pixels[1] = (TEX_IMAGE_MISSING_G * 65535); | pixels[1] = (TEX_IMAGE_MISSING_G * 65535); | ||||
| pixels[2] = (TEX_IMAGE_MISSING_B * 65535); | pixels[2] = (TEX_IMAGE_MISSING_B * 65535); | ||||
| pixels[3] = (TEX_IMAGE_MISSING_A * 65535); | pixels[3] = (TEX_IMAGE_MISSING_A * 65535); | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| else if (type == IMAGE_DATA_TYPE_HALF) { | else if (type == IMAGE_DATA_TYPE_HALF) { | ||||
| device_vector<half> *tex_img = new device_vector<half>( | device_vector<half> *tex_img = new device_vector<half>( | ||||
| device, img->mem_name.c_str(), MEM_TEXTURE); | device, img->mem_name.c_str(), MEM_TEXTURE); | ||||
| if (!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, *tex_img)) { | if (!file_load_image<TypeDesc::HALF, half>(img, type, texture_limit, *tex_img)) { | ||||
| /* on failure to load, we set a 1x1 pixels pink image */ | /* on failure to load, we set a 1x1 pixels pink image */ | ||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| half *pixels = (half *)tex_img->alloc(1, 1); | half *pixels = (half *)tex_img->alloc(1, 1); | ||||
| pixels[0] = TEX_IMAGE_MISSING_R; | pixels[0] = TEX_IMAGE_MISSING_R; | ||||
| } | } | ||||
| img->mem = tex_img; | img->mem = tex_img; | ||||
| img->mem->interpolation = img->interpolation; | img->mem->interpolation = img->interpolation; | ||||
| img->mem->extension = img->extension; | img->mem->extension = img->extension; | ||||
| img->mem->compress_as_srgb = false; | |||||
| thread_scoped_lock device_lock(device_mutex); | thread_scoped_lock device_lock(device_mutex); | ||||
| tex_img->copy_to_device(); | tex_img->copy_to_device(); | ||||
| } | } | ||||
| img->need_load = false; | img->need_load = false; | ||||
| } | } | ||||
| void ImageManager::device_free_image(Device *, ImageDataType type, int slot) | void ImageManager::device_free_image(Device *, ImageDataType type, int slot) | ||||
| ▲ Show 20 Lines • Show All 137 Lines • Show Last 20 Lines | |||||