Refactor: Cycles: Stop using entire OIIO namespace
Pull Request: https://projects.blender.org/blender/blender/pulls/132361
This commit is contained in:
@@ -51,11 +51,11 @@ void OIIOOutputDriver::write_render_tile(const Tile &tile)
|
||||
}
|
||||
|
||||
/* Manipulate offset and stride to convert from bottom-up to top-down convention. */
|
||||
ImageBuf image_buffer(spec,
|
||||
pixels.data() + (height - 1) * width * 4,
|
||||
AutoStride,
|
||||
-width * 4 * sizeof(float),
|
||||
AutoStride);
|
||||
OIIO::ImageBuf image_buffer(spec,
|
||||
pixels.data() + (height - 1) * width * 4,
|
||||
AutoStride,
|
||||
-width * 4 * sizeof(float),
|
||||
AutoStride);
|
||||
|
||||
/* Apply gamma correction for (some) non-linear file formats.
|
||||
* TODO: use OpenColorIO view transform if available. */
|
||||
@@ -63,7 +63,7 @@ void OIIOOutputDriver::write_render_tile(const Tile &tile)
|
||||
u_colorspace_auto, "", image_output->format_name(), true) == u_colorspace_srgb)
|
||||
{
|
||||
const float g = 1.0f / 2.2f;
|
||||
ImageBufAlgo::pow(image_buffer, image_buffer, {g, g, g, 1.0f});
|
||||
OIIO::ImageBufAlgo::pow(image_buffer, image_buffer, {g, g, g, 1.0f});
|
||||
}
|
||||
|
||||
/* Write to disk and close */
|
||||
|
||||
@@ -1156,22 +1156,20 @@ bool OSLRenderServices::get_userdata(
|
||||
}
|
||||
|
||||
#if OSL_LIBRARY_VERSION_CODE >= 11304
|
||||
TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *context,
|
||||
const TextureOpt *opt)
|
||||
OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(
|
||||
OSLUStringHash filename, OSL::ShadingContext *context, const OSL::TextureOpt *opt)
|
||||
{
|
||||
return get_texture_handle(to_ustring(filename), context, opt);
|
||||
}
|
||||
|
||||
TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSL::ustring filename,
|
||||
OSL::ShadingContext *,
|
||||
const TextureOpt *)
|
||||
OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(
|
||||
OSL::ustring filename, OSL::ShadingContext * /*context*/, const OSL::TextureOpt * /*options*/)
|
||||
#elif OSL_LIBRARY_VERSION_CODE >= 11100
|
||||
TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *)
|
||||
OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *)
|
||||
#else
|
||||
|
||||
TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHash filename)
|
||||
OSL::TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHash filename)
|
||||
#endif
|
||||
{
|
||||
OSLTextureHandleMap::iterator it = textures.find(filename);
|
||||
@@ -1180,13 +1178,13 @@ TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHa
|
||||
/* For non-OIIO textures, just return a pointer to our own OSLTextureHandle. */
|
||||
if (it != textures.end()) {
|
||||
if (it->second->type != OSLTextureHandle::OIIO) {
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(it->second.get());
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(it->second.get());
|
||||
}
|
||||
}
|
||||
|
||||
/* Get handle from OpenImageIO. */
|
||||
OSL::TextureSystem *ts = m_texturesys;
|
||||
TextureSystem::TextureHandle *handle = ts->get_texture_handle(to_ustring(filename));
|
||||
OSL::TextureSystem::TextureHandle *handle = ts->get_texture_handle(to_ustring(filename));
|
||||
if (handle == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -1199,57 +1197,56 @@ TextureSystem::TextureHandle *OSLRenderServices::get_texture_handle(OSLUStringHa
|
||||
|
||||
/* Assign OIIO texture handle and return. */
|
||||
it->second->oiio_handle = handle;
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(it->second.get());
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(it->second.get());
|
||||
}
|
||||
else {
|
||||
/* Construct GPU texture handle for existing textures. */
|
||||
if (it != textures.end()) {
|
||||
switch (it->second->type) {
|
||||
case OSLTextureHandle::OIIO:
|
||||
return nullptr;
|
||||
case OSLTextureHandle::SVM:
|
||||
if (!it->second->handle.empty() && it->second->handle.get_manager() != image_manager) {
|
||||
it.clear();
|
||||
break;
|
||||
}
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_SVM |
|
||||
it->second->svm_slots[0].y);
|
||||
case OSLTextureHandle::IES:
|
||||
if (!it->second->handle.empty() && it->second->handle.get_manager() != image_manager) {
|
||||
it.clear();
|
||||
break;
|
||||
}
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_IES |
|
||||
it->second->svm_slots[0].y);
|
||||
case OSLTextureHandle::AO:
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(
|
||||
OSL_TEXTURE_HANDLE_TYPE_AO_OR_BEVEL | 1);
|
||||
case OSLTextureHandle::BEVEL:
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(
|
||||
OSL_TEXTURE_HANDLE_TYPE_AO_OR_BEVEL | 2);
|
||||
}
|
||||
}
|
||||
|
||||
if (!image_manager) {
|
||||
return nullptr;
|
||||
/* Construct GPU texture handle for existing textures. */
|
||||
if (it != textures.end()) {
|
||||
switch (it->second->type) {
|
||||
case OSLTextureHandle::OIIO:
|
||||
return nullptr;
|
||||
case OSLTextureHandle::SVM:
|
||||
if (!it->second->handle.empty() && it->second->handle.get_manager() != image_manager) {
|
||||
it.clear();
|
||||
break;
|
||||
}
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_SVM |
|
||||
it->second->svm_slots[0].y);
|
||||
case OSLTextureHandle::IES:
|
||||
if (!it->second->handle.empty() && it->second->handle.get_manager() != image_manager) {
|
||||
it.clear();
|
||||
break;
|
||||
}
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_IES |
|
||||
it->second->svm_slots[0].y);
|
||||
case OSLTextureHandle::AO:
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(
|
||||
OSL_TEXTURE_HANDLE_TYPE_AO_OR_BEVEL | 1);
|
||||
case OSLTextureHandle::BEVEL:
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(
|
||||
OSL_TEXTURE_HANDLE_TYPE_AO_OR_BEVEL | 2);
|
||||
}
|
||||
|
||||
/* Load new textures using SVM image manager. */
|
||||
ImageHandle handle = image_manager->add_image(filename.string(), ImageParams());
|
||||
if (handle.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!textures.insert(filename, new OSLTextureHandle(handle))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reinterpret_cast<TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_SVM |
|
||||
handle.svm_slot());
|
||||
}
|
||||
|
||||
if (!image_manager) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* Load new textures using SVM image manager. */
|
||||
ImageHandle handle = image_manager->add_image(filename.string(), ImageParams());
|
||||
if (handle.empty()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!textures.insert(filename, new OSLTextureHandle(handle))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return reinterpret_cast<OSL::TextureSystem::TextureHandle *>(OSL_TEXTURE_HANDLE_TYPE_SVM |
|
||||
handle.svm_slot());
|
||||
}
|
||||
|
||||
bool OSLRenderServices::good(TextureSystem::TextureHandle *texture_handle)
|
||||
bool OSLRenderServices::good(OSL::TextureSystem::TextureHandle *texture_handle)
|
||||
{
|
||||
OSLTextureHandle *handle = (OSLTextureHandle *)texture_handle;
|
||||
|
||||
@@ -1265,7 +1262,7 @@ bool OSLRenderServices::good(TextureSystem::TextureHandle *texture_handle)
|
||||
bool OSLRenderServices::texture(OSLUStringHash filename,
|
||||
TextureHandle *texture_handle,
|
||||
TexturePerthread *texture_thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
float s,
|
||||
float t,
|
||||
@@ -1450,7 +1447,7 @@ bool OSLRenderServices::texture(OSLUStringHash filename,
|
||||
bool OSLRenderServices::texture3d(OSLUStringHash filename,
|
||||
TextureHandle *texture_handle,
|
||||
TexturePerthread *texture_thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
const OSL::Vec3 &P,
|
||||
const OSL::Vec3 &dPdx,
|
||||
@@ -1564,7 +1561,7 @@ bool OSLRenderServices::texture3d(OSLUStringHash filename,
|
||||
bool OSLRenderServices::environment(OSLUStringHash filename,
|
||||
TextureHandle *texture_handle,
|
||||
TexturePerthread *thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
const OSL::Vec3 &R,
|
||||
const OSL::Vec3 &dRdx,
|
||||
|
||||
@@ -191,25 +191,25 @@ class OSLRenderServices : public OSL::RendererServices {
|
||||
bool derivatives) override;
|
||||
|
||||
#if OSL_LIBRARY_VERSION_CODE >= 11304
|
||||
TextureSystem::TextureHandle *get_texture_handle(OSL::ustring filename,
|
||||
OSL::ShadingContext *context,
|
||||
const TextureOpt *options) override;
|
||||
TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *context,
|
||||
const TextureOpt *options) override;
|
||||
OSL::TextureSystem::TextureHandle *get_texture_handle(OSL::ustring filename,
|
||||
OSL::ShadingContext *context,
|
||||
const OSL::TextureOpt *options) override;
|
||||
OSL::TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *context,
|
||||
const OSL::TextureOpt *options) override;
|
||||
#elif OSL_LIBRARY_VERSION_CODE >= 11100
|
||||
TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *context) override;
|
||||
OSL::TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename,
|
||||
OSL::ShadingContext *context) override;
|
||||
#else
|
||||
TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename) override;
|
||||
OSL::TextureSystem::TextureHandle *get_texture_handle(OSLUStringHash filename) override;
|
||||
#endif
|
||||
|
||||
bool good(TextureSystem::TextureHandle *texture_handle) override;
|
||||
bool good(OSL::TextureSystem::TextureHandle *texture_handle) override;
|
||||
|
||||
bool texture(OSLUStringHash filename,
|
||||
TextureSystem::TextureHandle *texture_handle,
|
||||
OSL::TextureSystem::TextureHandle *texture_handle,
|
||||
TexturePerthread *texture_thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
float s,
|
||||
float t,
|
||||
@@ -226,7 +226,7 @@ class OSLRenderServices : public OSL::RendererServices {
|
||||
bool texture3d(OSLUStringHash filename,
|
||||
TextureHandle *texture_handle,
|
||||
TexturePerthread *texture_thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
const OSL::Vec3 &P,
|
||||
const OSL::Vec3 &dPdx,
|
||||
@@ -242,7 +242,7 @@ class OSLRenderServices : public OSL::RendererServices {
|
||||
bool environment(OSLUStringHash filename,
|
||||
TextureHandle *texture_handle,
|
||||
TexturePerthread *texture_thread_info,
|
||||
TextureOpt &options,
|
||||
OSL::TextureOpt &options,
|
||||
OSL::ShaderGlobals *sg,
|
||||
const OSL::Vec3 &R,
|
||||
const OSL::Vec3 &dRdx,
|
||||
|
||||
@@ -262,7 +262,7 @@ void OSLShaderManager::texture_system_init()
|
||||
thread_scoped_lock lock(ts_shared_mutex);
|
||||
|
||||
if (ts_shared_users++ == 0) {
|
||||
ts_shared = TextureSystem::create(true);
|
||||
ts_shared = OSL::TextureSystem::create(true);
|
||||
|
||||
ts_shared->attribute("automip", 1);
|
||||
ts_shared->attribute("autotile", 64);
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
OIIO_NAMESPACE_USING
|
||||
using OIIO::ArgParse;
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
@@ -13,7 +13,10 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
OIIO_NAMESPACE_USING
|
||||
using OIIO::AutoStride;
|
||||
using OIIO::ImageInput;
|
||||
using OIIO::ImageOutput;
|
||||
using OIIO::ImageSpec;
|
||||
|
||||
template<typename T>
|
||||
void util_image_resize_pixels(const vector<T> &input_pixels,
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "util/algorithm.h"
|
||||
#include "util/half.h"
|
||||
#include "util/image.h"
|
||||
#include "util/math_base.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
|
||||
@@ -13,7 +13,19 @@
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
OIIO_NAMESPACE_USING
|
||||
using OIIO::ParamValue;
|
||||
|
||||
using OIIO::TypeColor;
|
||||
using OIIO::TypeDesc;
|
||||
using OIIO::TypeFloat;
|
||||
using OIIO::TypeFloat4;
|
||||
using OIIO::TypeInt;
|
||||
using OIIO::TypeMatrix;
|
||||
using OIIO::TypeNormal;
|
||||
using OIIO::TypePoint;
|
||||
using OIIO::TypeString;
|
||||
using OIIO::TypeUnknown;
|
||||
using OIIO::TypeVector;
|
||||
|
||||
static constexpr TypeDesc TypeFloat2(TypeDesc::FLOAT, TypeDesc::VEC2);
|
||||
static constexpr TypeDesc TypeRGBA(TypeDesc::FLOAT, TypeDesc::VEC4, TypeDesc::COLOR);
|
||||
@@ -22,4 +34,7 @@ static constexpr TypeDesc TypeFloatArray4(TypeDesc::FLOAT,
|
||||
TypeDesc::NOSEMANTICS,
|
||||
4);
|
||||
|
||||
using OIIO::ustring;
|
||||
using OIIO::ustringhash;
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
@@ -14,9 +14,7 @@
|
||||
#include <OpenImageIO/strutil.h>
|
||||
#include <OpenImageIO/sysutil.h>
|
||||
|
||||
OIIO_NAMESPACE_USING
|
||||
|
||||
#include <stdio.h>
|
||||
#include <cstdio>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -38,7 +36,6 @@ OIIO_NAMESPACE_USING
|
||||
# include <shlwapi.h>
|
||||
#endif
|
||||
|
||||
#include "util/map.h"
|
||||
#include "util/windows.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
@@ -344,8 +341,8 @@ string path_get(const string &sub)
|
||||
return special;
|
||||
}
|
||||
|
||||
if (cached_path == "") {
|
||||
cached_path = path_dirname(Sysutil::this_program_path());
|
||||
if (cached_path.empty()) {
|
||||
cached_path = path_dirname(OIIO::Sysutil::this_program_path());
|
||||
}
|
||||
|
||||
return path_join(cached_path, sub);
|
||||
@@ -353,8 +350,8 @@ string path_get(const string &sub)
|
||||
|
||||
string path_user_get(const string &sub)
|
||||
{
|
||||
if (cached_user_path == "") {
|
||||
cached_user_path = path_dirname(Sysutil::this_program_path());
|
||||
if (cached_user_path.empty()) {
|
||||
cached_user_path = path_dirname(OIIO::Sysutil::this_program_path());
|
||||
}
|
||||
|
||||
return path_join(cached_user_path, sub);
|
||||
|
||||
@@ -3,14 +3,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0 */
|
||||
|
||||
#include "util/system.h"
|
||||
|
||||
#include "util/log.h"
|
||||
#include "util/string.h"
|
||||
#include "util/types.h"
|
||||
|
||||
#include <OpenImageIO/sysutil.h>
|
||||
|
||||
OIIO_NAMESPACE_USING
|
||||
|
||||
#ifdef _WIN32
|
||||
# if (!defined(FREE_WINDOWS))
|
||||
|
||||
Reference in New Issue
Block a user