2016-04-15 21:01:20 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2011-2016 Blender Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __UTIL_TEXTURE_H__
|
|
|
|
#define __UTIL_TEXTURE_H__
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2016-05-27 20:58:33 +00:00
|
|
|
/* Texture limits on devices. */
|
2016-04-15 21:01:20 +00:00
|
|
|
|
2016-05-27 20:58:33 +00:00
|
|
|
/* CUDA (Geforce 4xx and 5xx) */
|
2017-04-27 09:11:08 +00:00
|
|
|
#define TEX_NUM_FLOAT4_CUDA 5
|
|
|
|
#define TEX_NUM_BYTE4_CUDA 84
|
|
|
|
#define TEX_NUM_HALF4_CUDA 0
|
|
|
|
#define TEX_NUM_FLOAT_CUDA 0
|
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
2017-04-27 07:34:51 +00:00
|
|
|
#define TEX_NUM_BYTE_CUDA 0
|
|
|
|
#define TEX_NUM_HALF_CUDA 0
|
|
|
|
#define TEX_START_FLOAT4_CUDA 0
|
2017-04-27 09:11:08 +00:00
|
|
|
#define TEX_START_BYTE4_CUDA TEX_NUM_FLOAT4_CUDA
|
|
|
|
#define TEX_START_HALF4_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA)
|
|
|
|
#define TEX_START_FLOAT_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA)
|
|
|
|
#define TEX_START_BYTE_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA + TEX_NUM_FLOAT_CUDA)
|
|
|
|
#define TEX_START_HALF_CUDA (TEX_NUM_FLOAT4_CUDA + TEX_NUM_BYTE4_CUDA + TEX_NUM_HALF4_CUDA + TEX_NUM_FLOAT_CUDA + TEX_NUM_BYTE_CUDA)
|
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
2017-04-27 07:34:51 +00:00
|
|
|
|
|
|
|
/* Any architecture other than old CUDA cards */
|
|
|
|
#define TEX_NUM_MAX (INT_MAX >> 4)
|
2016-04-15 21:01:20 +00:00
|
|
|
|
|
|
|
/* Color to use when textures are not found. */
|
|
|
|
#define TEX_IMAGE_MISSING_R 1
|
|
|
|
#define TEX_IMAGE_MISSING_G 0
|
|
|
|
#define TEX_IMAGE_MISSING_B 1
|
|
|
|
#define TEX_IMAGE_MISSING_A 1
|
|
|
|
|
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
2017-04-27 07:34:51 +00:00
|
|
|
#if defined (__KERNEL_CUDA__) && (__CUDA_ARCH__ < 300)
|
|
|
|
# define kernel_tex_type(tex) (tex < TEX_START_BYTE4_CUDA ? IMAGE_DATA_TYPE_FLOAT4 : IMAGE_DATA_TYPE_BYTE4)
|
|
|
|
# define kernel_tex_index(tex) (tex)
|
|
|
|
#else
|
|
|
|
# define kernel_tex_type(tex) (tex & IMAGE_DATA_TYPE_MASK)
|
|
|
|
# define kernel_tex_index(tex) (tex >> IMAGE_DATA_TYPE_SHIFT)
|
|
|
|
#endif
|
|
|
|
|
2016-04-15 21:01:20 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|
|
|
|
#endif /* __UTIL_TEXTURE_H__ */
|