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:
authorStefan Werner <stefan.werner@tangent-animation.com>2018-07-05 13:37:52 +0300
committerStefan Werner <stefan.werner@tangent-animation.com>2018-07-05 14:53:34 +0300
commit4d00e95ee3ed91f86262bb218f1c5df901da724c (patch)
tree5d9af704609b38cca76a5786189c126ac7072332 /intern/cycles/device
parentcd17b3258327522b8c6f56a3ee7239a91f2be149 (diff)
Cycles: Adding native support for UINT16 textures.
Textures in 16 bit integer format are sometimes used for displacement, bump and normal maps and can be exported by tools like Substance Painter. Without this patch, Cycles would promote those textures to single precision floating point, causing them to take up twice as much memory as needed. Reviewers: #cycles, brecht, sergey Reviewed By: #cycles, brecht, sergey Subscribers: sergey, dingto, #cycles Tags: #cycles Differential Revision: https://developer.blender.org/D3523
Diffstat (limited to 'intern/cycles/device')
-rw-r--r--intern/cycles/device/device_cuda.cpp1
-rw-r--r--intern/cycles/device/device_memory.h12
2 files changed, 13 insertions, 0 deletions
diff --git a/intern/cycles/device/device_cuda.cpp b/intern/cycles/device/device_cuda.cpp
index 8294af340e8..73c9697223d 100644
--- a/intern/cycles/device/device_cuda.cpp
+++ b/intern/cycles/device/device_cuda.cpp
@@ -1072,6 +1072,7 @@ public:
CUarray_format_enum format;
switch(mem.data_type) {
case TYPE_UCHAR: format = CU_AD_FORMAT_UNSIGNED_INT8; break;
+ case TYPE_UINT16: format = CU_AD_FORMAT_UNSIGNED_INT16; break;
case TYPE_UINT: format = CU_AD_FORMAT_UNSIGNED_INT32; break;
case TYPE_INT: format = CU_AD_FORMAT_SIGNED_INT32; break;
case TYPE_FLOAT: format = CU_AD_FORMAT_FLOAT; break;
diff --git a/intern/cycles/device/device_memory.h b/intern/cycles/device/device_memory.h
index 1138964f18c..b6f3c2913a5 100644
--- a/intern/cycles/device/device_memory.h
+++ b/intern/cycles/device/device_memory.h
@@ -43,6 +43,7 @@ enum MemoryType {
enum DataType {
TYPE_UNKNOWN,
TYPE_UCHAR,
+ TYPE_UINT16,
TYPE_UINT,
TYPE_INT,
TYPE_FLOAT,
@@ -57,6 +58,7 @@ static inline size_t datatype_size(DataType datatype)
case TYPE_UCHAR: return sizeof(uchar);
case TYPE_FLOAT: return sizeof(float);
case TYPE_UINT: return sizeof(uint);
+ case TYPE_UINT16: return sizeof(uint16_t);
case TYPE_INT: return sizeof(int);
case TYPE_HALF: return sizeof(half);
case TYPE_UINT64: return sizeof(uint64_t);
@@ -156,6 +158,16 @@ template<> struct device_type_traits<half> {
static const int num_elements = 1;
};
+template<> struct device_type_traits<ushort4> {
+ static const DataType data_type = TYPE_UINT16;
+ static const int num_elements = 4;
+};
+
+template<> struct device_type_traits<uint16_t> {
+ static const DataType data_type = TYPE_UINT16;
+ static const int num_elements = 1;
+};
+
template<> struct device_type_traits<half4> {
static const DataType data_type = TYPE_HALF;
static const int num_elements = 4;