Cleanup: fix various Cycles compilar warnings

Mainly for the build configuration of the Hydra render delegate and
standalone repo.
This commit is contained in:
Brecht Van Lommel
2023-04-04 20:00:56 +02:00
parent 920ffd3253
commit b288c4004e
12 changed files with 74 additions and 40 deletions

View File

@@ -51,6 +51,12 @@ if(WITH_CYCLES_STANDALONE AND WITH_CYCLES_STANDALONE_GUI)
endif()
if(WITH_USD)
# Silence warning from USD headers using deprecated TBB header.
add_definitions(
-D__TBB_show_deprecation_message_atomic_H
-D__TBB_show_deprecation_message_task_H
)
list(APPEND INC_SYS
${USD_INCLUDE_DIRS}
)

View File

@@ -80,6 +80,12 @@ if(EXISTS ${USD_INCLUDE_DIR}/pxr/imaging/hgiGL)
list(APPEND SRC_HD_CYCLES_HEADERS display_driver.h)
endif()
# Silence warning from USD headers using deprecated TBB header.
add_definitions(
-D__TBB_show_deprecation_message_atomic_H
-D__TBB_show_deprecation_message_task_H
)
include_directories(${INC})
include_directories(SYSTEM ${INC_SYS})

View File

@@ -4,6 +4,12 @@
#ifdef _WIN32
// Include first to avoid "NOGDI" definition set in Cycles headers
# ifndef NOMINMAX
# define NOMINMAX
# endif
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN
# endif
# include <Windows.h>
#endif

View File

@@ -370,6 +370,16 @@ VtValue convertFromCyclesArray(const array<SrcType> &value)
return VtValue(convertedValue);
}
template<> VtValue convertFromCyclesArray<float2, GfVec2f>(const array<float2> &value)
{
VtVec2fArray convertedValue;
convertedValue.reserve(value.size());
for (const auto &element : value) {
convertedValue.push_back(GfVec2f(element.x, element.y));
}
return VtValue(convertedValue);
}
template<> VtValue convertFromCyclesArray<float3, GfVec3f>(const array<float3> &value)
{
VtVec3fArray convertedValue;

View File

@@ -18,7 +18,7 @@ ccl_device_noinline int svm_node_tex_coord(KernelGlobals kg,
uint4 node,
int offset)
{
float3 data;
float3 data = zero_float3();
uint type = node.y;
uint out_offset = node.z;
@@ -100,7 +100,7 @@ ccl_device_noinline int svm_node_tex_coord_bump_dx(KernelGlobals kg,
int offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
float3 data = zero_float3();
uint type = node.y;
uint out_offset = node.z;
@@ -185,7 +185,7 @@ ccl_device_noinline int svm_node_tex_coord_bump_dy(KernelGlobals kg,
int offset)
{
#ifdef __RAY_DIFFERENTIALS__
float3 data;
float3 data = zero_float3();
uint type = node.y;
uint out_offset = node.z;

View File

@@ -247,13 +247,16 @@ size_t CachedData::memory_used() const
static M44d convert_yup_zup(const M44d &mtx, float scale_mult)
{
V3d scale, shear, rotation, translation;
extractSHRT(mtx,
scale,
shear,
rotation,
translation,
true,
IMATH_INTERNAL_NAMESPACE::Euler<double>::XZY);
if (!extractSHRT(mtx,
scale,
shear,
rotation,
translation,
true,
IMATH_INTERNAL_NAMESPACE::Euler<double>::XZY)) {
return mtx;
}
M44d rot_mat, scale_mat, trans_mat;
rot_mat.setEulerAngles(V3d(rotation.x, -rotation.z, rotation.y));

View File

@@ -531,7 +531,7 @@ PrimitiveType Hair::primitive_type() const
/* Fill in coordinates for curve transparency shader evaluation on device. */
static int fill_shader_input(const Hair *hair,
const int object_index,
const size_t object_index,
device_vector<KernelShaderEvalInput> &d_input)
{
int d_input_size = 0;

View File

@@ -86,7 +86,7 @@ ImageHandle::ImageHandle(const ImageHandle &other)
: tile_slots(other.tile_slots), manager(other.manager)
{
/* Increase image user count. */
foreach (const int slot, tile_slots) {
foreach (const size_t slot, tile_slots) {
manager->add_image_user(slot);
}
}
@@ -97,7 +97,7 @@ ImageHandle &ImageHandle::operator=(const ImageHandle &other)
manager = other.manager;
tile_slots = other.tile_slots;
foreach (const int slot, tile_slots) {
foreach (const size_t slot, tile_slots) {
manager->add_image_user(slot);
}
@@ -111,7 +111,7 @@ ImageHandle::~ImageHandle()
void ImageHandle::clear()
{
foreach (const int slot, tile_slots) {
foreach (const size_t slot, tile_slots) {
manager->remove_image_user(slot);
}
@@ -165,7 +165,7 @@ vector<int4> ImageHandle::get_svm_slots() const
for (size_t i = 0; i < num_nodes; i++) {
int4 node;
int slot = tile_slots[2 * i];
size_t slot = tile_slots[2 * i];
node.x = manager->images[slot]->loader->get_tile_number();
node.y = slot;
@@ -387,7 +387,7 @@ void ImageManager::load_image_metadata(Image *img)
ImageHandle ImageManager::add_image(const string &filename, const ImageParams &params)
{
const int slot = add_image_slot(new OIIOImageLoader(filename), params, false);
const size_t slot = add_image_slot(new OIIOImageLoader(filename), params, false);
ImageHandle handle;
handle.tile_slots.push_back(slot);
@@ -408,13 +408,13 @@ ImageHandle ImageManager::add_image(const string &filename,
/* Since we don't have information about the exact tile format used in this code location,
* just attempt all replacement patterns that Blender supports. */
if (tile != 0) {
string_replace(tile_filename, "<UDIM>", string_printf("%04d", tile));
string_replace(tile_filename, "<UDIM>", string_printf("%04d", (int)tile));
int u = ((tile - 1001) % 10);
int v = ((tile - 1001) / 10);
string_replace(tile_filename, "<UVTILE>", string_printf("u%d_v%d", u + 1, v + 1));
}
const int slot = add_image_slot(new OIIOImageLoader(tile_filename), params, false);
const size_t slot = add_image_slot(new OIIOImageLoader(tile_filename), params, false);
handle.tile_slots.push_back(slot);
}
@@ -425,7 +425,7 @@ ImageHandle ImageManager::add_image(ImageLoader *loader,
const ImageParams &params,
const bool builtin)
{
const int slot = add_image_slot(loader, params, builtin);
const size_t slot = add_image_slot(loader, params, builtin);
ImageHandle handle;
handle.tile_slots.push_back(slot);
@@ -438,7 +438,7 @@ ImageHandle ImageManager::add_image(const vector<ImageLoader *> &loaders,
{
ImageHandle handle;
for (ImageLoader *loader : loaders) {
const int slot = add_image_slot(loader, params, true);
const size_t slot = add_image_slot(loader, params, true);
handle.tile_slots.push_back(slot);
}
@@ -446,9 +446,9 @@ ImageHandle ImageManager::add_image(const vector<ImageLoader *> &loaders,
return handle;
}
int ImageManager::add_image_slot(ImageLoader *loader,
const ImageParams &params,
const bool builtin)
size_t ImageManager::add_image_slot(ImageLoader *loader,
const ImageParams &params,
const bool builtin)
{
Image *img;
size_t slot;
@@ -492,7 +492,7 @@ int ImageManager::add_image_slot(ImageLoader *loader,
return slot;
}
void ImageManager::add_image_user(int slot)
void ImageManager::add_image_user(size_t slot)
{
thread_scoped_lock device_lock(images_mutex);
Image *image = images[slot];
@@ -501,7 +501,7 @@ void ImageManager::add_image_user(int slot)
image->users++;
}
void ImageManager::remove_image_user(int slot)
void ImageManager::remove_image_user(size_t slot)
{
thread_scoped_lock device_lock(images_mutex);
Image *image = images[slot];
@@ -682,7 +682,7 @@ bool ImageManager::file_load_image(Image *img, int texture_limit)
return true;
}
void ImageManager::device_load_image(Device *device, Scene *scene, int slot, Progress *progress)
void ImageManager::device_load_image(Device *device, Scene *scene, size_t slot, Progress *progress)
{
if (progress->get_cancel()) {
return;
@@ -698,7 +698,7 @@ void ImageManager::device_load_image(Device *device, Scene *scene, int slot, Pro
ImageDataType type = img->metadata.type;
/* Name for debugging. */
img->mem_name = string_printf("tex_image_%s_%03d", name_from_type(type), slot);
img->mem_name = string_printf("tex_image_%s_%03d", name_from_type(type), (int)slot);
/* Free previous texture in slot. */
if (img->mem) {
@@ -819,7 +819,7 @@ void ImageManager::device_load_image(Device *device, Scene *scene, int slot, Pro
img->need_load = false;
}
void ImageManager::device_free_image(Device *, int slot)
void ImageManager::device_free_image(Device *, size_t slot)
{
Image *img = images[slot];
if (img == NULL) {
@@ -874,7 +874,10 @@ void ImageManager::device_update(Device *device, Scene *scene, Progress &progres
need_update_ = false;
}
void ImageManager::device_update_slot(Device *device, Scene *scene, int slot, Progress *progress)
void ImageManager::device_update_slot(Device *device,
Scene *scene,
size_t slot,
Progress *progress)
{
Image *img = images[slot];
assert(img != NULL);

View File

@@ -156,7 +156,7 @@ class ImageHandle {
ImageManager *get_manager() const;
protected:
vector<int> tile_slots;
vector<size_t> tile_slots;
ImageManager *manager;
friend class ImageManager;
@@ -179,7 +179,7 @@ class ImageManager {
ImageHandle add_image(const vector<ImageLoader *> &loaders, const ImageParams &params);
void device_update(Device *device, Scene *scene, Progress &progress);
void device_update_slot(Device *device, Scene *scene, int slot, Progress *progress);
void device_update_slot(Device *device, Scene *scene, size_t slot, Progress *progress);
void device_free(Device *device);
void device_load_builtin(Device *device, Scene *scene, Progress &progress);
@@ -223,17 +223,17 @@ class ImageManager {
vector<Image *> images;
void *osl_texture_system;
int add_image_slot(ImageLoader *loader, const ImageParams &params, const bool builtin);
void add_image_user(int slot);
void remove_image_user(int slot);
size_t add_image_slot(ImageLoader *loader, const ImageParams &params, const bool builtin);
void add_image_user(size_t slot);
void remove_image_user(size_t slot);
void load_image_metadata(Image *img);
template<TypeDesc::BASETYPE FileFormat, typename StorageType>
bool file_load_image(Image *img, int texture_limit);
void device_load_image(Device *device, Scene *scene, int slot, Progress *progress);
void device_free_image(Device *device, int slot);
void device_load_image(Device *device, Scene *scene, size_t slot, Progress *progress);
void device_free_image(Device *device, size_t slot);
friend class ImageHandle;
};

View File

@@ -264,9 +264,9 @@ void LightManager::device_update_distribution(Device *,
/* Count emissive triangles. */
Mesh *mesh = static_cast<Mesh *>(object->get_geometry());
size_t mesh_num_triangles = mesh->num_triangles();
int mesh_num_triangles = static_cast<int>(mesh->num_triangles());
for (size_t i = 0; i < mesh_num_triangles; i++) {
for (int i = 0; i < mesh_num_triangles; i++) {
int shader_index = mesh->get_shader()[i];
Shader *shader = (shader_index < mesh->get_used_shaders().size()) ?
static_cast<Shader *>(mesh->get_used_shaders()[shader_index]) :

View File

@@ -35,7 +35,7 @@ static float3 compute_face_normal(const Mesh::Triangle &t, float3 *verts)
/* Fill in coordinates for mesh displacement shader evaluation on device. */
static int fill_shader_input(const Scene *scene,
const Mesh *mesh,
const int object_index,
const size_t object_index,
device_vector<KernelShaderEvalInput> &d_input)
{
int d_input_size = 0;

View File

@@ -40,7 +40,7 @@ ccl_device_inline float half_to_float(half h_in)
* unsigned shorts. */
class half {
public:
half() : v(0) {}
half() = default;
half(const unsigned short &i) : v(i) {}
operator unsigned short()
{