Blender V5.3
types_image.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "util/defines.h"
8#include "util/transform.h"
9
10#ifndef __KERNEL_GPU__
11# include <climits>
12# include <functional>
13#endif
14
16
17/* Color to use when images are not found. */
18#define IMAGE_MISSING_RGBA make_float4(1, 0, 1, 1)
19#define IMAGE_MISSING_RGB make_float3(1, 0, 1)
20
21#define KERNEL_IMAGE_NONE INT_MAX
22
23/* Interpolation types for images. */
33
34/* Image data types supported by the kernel. */
53
58
59/* Alpha types
60 * How to treat alpha in images. */
70
71/* Image format types */
76
77/* Extension types for images.
78 *
79 * Defines how the image is extrapolated past its original bounds. */
81 /* Cause the image to repeat horizontally and vertically. */
83 /* Extend by repeating edge pixels of the image. */
85 /* Clip to image size and set exterior pixels as transparent. */
87 /* Repeatedly flip the image horizontally and vertically. */
89
91};
92
93/* Kernel data structure describing device image objects. */
95 /* Pointer, offset or image/texture object depending on device. */
97 /* Data Type */
99 /* Interpolation and extension type. */
102 /* Dimensions. */
103 uint width = 0;
104 uint height = 0;
105 float inv_width = 0.0f;
106 float inv_height = 0.0f;
107};
108
109/* KernelImageTexture index for UDIM tile. */
114
115/* Tile descriptor load status. Values lower than these mean the tile has been
116 * successfully loaded, and the value encodes where the tile is stored.
117 * - LOAD_NONE: Tile has never been accessed and is not in memory.
118 * - LOAD_REQUEST: Kernel requests this tile to be loaded.
119 * - LOAD_FAILED: Tile loading failed, will not try again.
120 */
121#define KERNEL_TILE_LOAD_NONE 0xFFFFFFFFU
122#define KERNEL_TILE_LOAD_REQUEST (KERNEL_TILE_LOAD_NONE - 1)
123#define KERNEL_TILE_LOAD_FAILED (KERNEL_TILE_LOAD_NONE - 2)
124
125/* Tile access state, written by the kernel and read back by the host.
126 * - NONE: Tile has not been accessed since the last clear.
127 * - REQUESTED: Kernel hit a cache miss on this tile, it needs to be loaded.
128 * - USED: Tile was accessed since the last clear.
129 *
130 * Almost all tiles will progress from REQUESTED to USED, but with dependent
131 * texture lookups it is possible a requested tile does not actually get used
132 * because the request was based on a tile that was not yet loaded and used
133 * the average color instead.
134 *
135 * This is a bitflag so we can OR these states from multiple devices.
136 */
137#define KERNEL_TILE_ACCESS_NONE 0
138#define KERNEL_TILE_ACCESS_REQUESTED (1 << 0)
139#define KERNEL_TILE_ACCESS_USED (1 << 1)
140
141/* Kernel data structure for image textures.
142 *
143 * This describes a logical image texture for the shading system, that may be stored
144 * in one or more device image objects described by KernelImageInfo. This is to
145 * support on demand loading of tiles. */
147 /* Index into image object map. */
149 /* Tile descriptor offset and count in image_texture_tile_descriptors. */
152 int tile_levels = 0;
153 int tile_num = 0;
154 /* Image dimensions */
155 int width = 0;
156 int height = 0;
157 /* Interpolation and extension type. */
160 /* Transform for 3D textures. */
161 uint use_transform_3d = false;
163 /* Fallback or fixed color. */
165};
166
167#define KERNEL_IMAGE_TEX_PADDING 2
168
170
172 const uint offset)
173{
174 return image_info_id | (offset << 24);
175}
176
181
186
191
192#ifndef __KERNEL_GPU__
193class DeviceQueue;
195 std::function<void(size_t, int, int, int, KernelTileDescriptor &tile_descriptor)>;
196using KernelImageLoadRequestedGPU = std::function<void(DeviceQueue &)>;
197#endif
198
unsigned long long int uint64_t
#define ccl_device_inline
#define CCL_NAMESPACE_END
const ccl_global KernelWorkTile * tile
CCL_NAMESPACE_BEGIN ccl_device_inline float4 zero_float4()
Definition math_float4.h:13
#define KERNEL_TILE_LOAD_FAILED
Transform transform_3d
ccl_device_inline Transform transform_zero()
Definition transform.h:280
uint KernelTileDescriptor
ImageDataType
Definition types_image.h:35
@ IMAGE_DATA_NUM_TYPES
Definition types_image.h:51
@ IMAGE_DATA_TYPE_BYTE
Definition types_image.h:40
@ IMAGE_DATA_TYPE_FLOAT
Definition types_image.h:39
@ IMAGE_DATA_TYPE_NANOVDB_FP16
Definition types_image.h:48
@ IMAGE_DATA_TYPE_FLOAT4
Definition types_image.h:36
@ IMAGE_DATA_TYPE_USHORT4
Definition types_image.h:42
@ IMAGE_DATA_TYPE_USHORT
Definition types_image.h:43
@ IMAGE_DATA_TYPE_NANOVDB_EMPTY
Definition types_image.h:49
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT
Definition types_image.h:44
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT3
Definition types_image.h:45
@ IMAGE_DATA_TYPE_HALF
Definition types_image.h:41
@ IMAGE_DATA_TYPE_BYTE4
Definition types_image.h:37
@ IMAGE_DATA_TYPE_HALF4
Definition types_image.h:38
@ IMAGE_DATA_TYPE_NANOVDB_FLOAT4
Definition types_image.h:46
@ IMAGE_DATA_TYPE_NANOVDB_FPN
Definition types_image.h:47
#define KERNEL_TILE_LOAD_NONE
ImageAlphaType
Definition types_image.h:61
@ IMAGE_ALPHA_ASSOCIATED
Definition types_image.h:63
@ IMAGE_ALPHA_CHANNEL_PACKED
Definition types_image.h:64
@ IMAGE_ALPHA_NUM_TYPES
Definition types_image.h:68
@ IMAGE_ALPHA_AUTO
Definition types_image.h:66
@ IMAGE_ALPHA_IGNORE
Definition types_image.h:65
@ IMAGE_ALPHA_UNASSOCIATED
Definition types_image.h:62
std::function< void(size_t, int, int, int, KernelTileDescriptor &tile_descriptor)> KernelImageLoadRequestedCPU
ccl_device_inline bool kernel_tile_descriptor_loaded(const KernelTileDescriptor tile)
InterpolationType
Definition types_image.h:24
@ INTERPOLATION_LINEAR
Definition types_image.h:26
@ INTERPOLATION_SMART
Definition types_image.h:29
@ INTERPOLATION_NONE
Definition types_image.h:25
@ INTERPOLATION_CLOSEST
Definition types_image.h:27
@ INTERPOLATION_CUBIC
Definition types_image.h:28
@ INTERPOLATION_NUM_TYPES
Definition types_image.h:31
std::function< void(DeviceQueue &)> KernelImageLoadRequestedGPU
#define KERNEL_IMAGE_NONE
Definition types_image.h:21
ccl_device_inline KernelTileDescriptor kernel_tile_descriptor_encode(const uint image_info_id, const uint offset)
ExtensionType
Definition types_image.h:80
@ EXTENSION_REPEAT
Definition types_image.h:82
@ EXTENSION_NUM_TYPES
Definition types_image.h:90
@ EXTENSION_CLIP
Definition types_image.h:86
@ EXTENSION_EXTEND
Definition types_image.h:84
@ EXTENSION_MIRROR
Definition types_image.h:88
ccl_device_inline uint kernel_tile_descriptor_offset(const KernelTileDescriptor tile)
ccl_device_inline uint kernel_tile_descriptor_image_info_id(const KernelTileDescriptor tile)
ImageFormatType
Definition types_image.h:72
@ IMAGE_FORMAT_PLAIN
Definition types_image.h:73
@ IMAGE_FORMAT_EQUIANGULAR
Definition types_image.h:74
ccl_device_inline bool is_nanovdb_type(int type)
Definition types_image.h:54