Unlimited number of textures for Cycles
This patch allows for an unlimited number of textures in Cycles where the hardware allows. It replaces a number static arrays with dynamic arrays and changes the way the flat_slot indices are calculated. Eventually, I'd like to get to a point where there are only flat slots left and textures off all kinds are stored in a single array. Note that the arrays in DeviceScene are changed from containing device_vector<T> objects to device_vector<T>* pointers. Ideally, I'd like to store objects, but dynamic resizing of a std:vector in pre-C++11 calls the copy constructor, which for a good reason is not implemented for device_vector. Once we require C++11 for Cycles builds, we can implement a move constructor for device_vector and store objects again. The limits for CUDA Fermi hardware still apply. Reviewers: tod_baudais, InsigMathK, dingto, #cycles Reviewed By: dingto, #cycles Subscribers: dingto, smellslikedonkey Differential Revision: https://developer.blender.org/D2650
This commit is contained in:
@@ -20,18 +20,19 @@
|
||||
|
||||
ccl_device_inline float4 svm_image_texture_read(KernelGlobals *kg, int id, int offset)
|
||||
{
|
||||
const texture_type = kernel_tex_type(id);
|
||||
/* Float4 */
|
||||
if(id < TEX_START_BYTE4_OPENCL) {
|
||||
if(texture_type == IMAGE_DATA_TYPE_FLOAT4) {
|
||||
return kernel_tex_fetch(__tex_image_float4_packed, offset);
|
||||
}
|
||||
/* Byte4 */
|
||||
else if(id < TEX_START_FLOAT_OPENCL) {
|
||||
else if(texture_type == IMAGE_DATA_TYPE_BYTE4) {
|
||||
uchar4 r = kernel_tex_fetch(__tex_image_byte4_packed, offset);
|
||||
float f = 1.0f/255.0f;
|
||||
return make_float4(r.x*f, r.y*f, r.z*f, r.w*f);
|
||||
}
|
||||
/* Float */
|
||||
else if(id < TEX_START_BYTE_OPENCL) {
|
||||
else if(texture_type == IMAGE_DATA_TYPE_FLOAT) {
|
||||
float f = kernel_tex_fetch(__tex_image_float_packed, offset);
|
||||
return make_float4(f, f, f, 1.0f);
|
||||
}
|
||||
|
Reference in New Issue
Block a user