[Bf-blender-cvs] [c65b2fb91ae] tmp-ocio-v2: OCIOv2: Fix compilations issues in Cycles.
Jeroen Bakker
noreply at git.blender.org
Wed Nov 25 15:52:21 CET 2020
Commit: c65b2fb91aedc69a145e543635a894a0b3e071c3
Author: Jeroen Bakker
Date: Wed Nov 25 15:46:57 2020 +0100
Branches: tmp-ocio-v2
https://developer.blender.org/rBc65b2fb91aedc69a145e543635a894a0b3e071c3
OCIOv2: Fix compilations issues in Cycles.
This is a rough version. The result should be slower than we have. We
should find a solution where we could cache the device_processor or find
a better way how to increase the performance by evaluating an area or
using GPU processors. OCIO also has a function called
`getOptimizedCPUProcessor`.
===================================================================
M intern/cycles/render/colorspace.cpp
M intern/cycles/render/shader.cpp
===================================================================
diff --git a/intern/cycles/render/colorspace.cpp b/intern/cycles/render/colorspace.cpp
index 57979d5f225..cf7cbaa9137 100644
--- a/intern/cycles/render/colorspace.cpp
+++ b/intern/cycles/render/colorspace.cpp
@@ -192,6 +192,7 @@ void ColorSpaceManager::is_builtin_colorspace(ustring colorspace,
return;
}
+ OCIO::ConstCPUProcessorRcPtr device_processor = processor->getDefaultCPUProcessor();
is_scene_linear = true;
is_srgb = true;
for (int i = 0; i < 256; i++) {
@@ -201,10 +202,10 @@ void ColorSpaceManager::is_builtin_colorspace(ustring colorspace,
float cG[3] = {0, v, 0};
float cB[3] = {0, 0, v};
float cW[3] = {v, v, v};
- processor->applyRGB(cR);
- processor->applyRGB(cG);
- processor->applyRGB(cB);
- processor->applyRGB(cW);
+ device_processor->applyRGB(cR);
+ device_processor->applyRGB(cG);
+ device_processor->applyRGB(cB);
+ device_processor->applyRGB(cW);
/* Make sure that there is no channel crosstalk. */
if (fabsf(cR[1]) > 1e-5f || fabsf(cR[2]) > 1e-5f || fabsf(cG[0]) > 1e-5f ||
@@ -267,6 +268,7 @@ inline void processor_apply_pixels(const OCIO::Processor *processor, T *pixels,
/* TODO: implement faster version for when we know the conversion
* is a simple matrix transform between linear spaces. In that case
* un-premultiply is not needed. */
+ OCIO::ConstCPUProcessorRcPtr device_processor = processor->getDefaultCPUProcessor();
/* Process large images in chunks to keep temporary memory requirement down. */
const size_t chunk_size = std::min((size_t)(16 * 1024 * 1024), num_pixels);
@@ -289,7 +291,7 @@ inline void processor_apply_pixels(const OCIO::Processor *processor, T *pixels,
}
OCIO::PackedImageDesc desc((float *)float_pixels.data(), width, 1, 4);
- processor->apply(desc);
+ device_processor->apply(desc);
for (size_t i = 0; i < width; i++) {
float4 value = float_pixels[i];
@@ -345,13 +347,14 @@ void ColorSpaceManager::to_scene_linear(ColorSpaceProcessor *processor_,
const OCIO::Processor *processor = (const OCIO::Processor *)processor_;
if (processor) {
+ OCIO::ConstCPUProcessorRcPtr device_processor = processor->getDefaultCPUProcessor();
if (channels == 3) {
- processor->applyRGB(pixel);
+ device_processor->applyRGB(pixel);
}
else if (channels == 4) {
if (pixel[3] == 1.0f || pixel[3] == 0.0f) {
/* Fast path for RGBA. */
- processor->applyRGB(pixel);
+ device_processor->applyRGB(pixel);
}
else {
/* Un-associate and associate alpha since color management should not
@@ -363,7 +366,7 @@ void ColorSpaceManager::to_scene_linear(ColorSpaceProcessor *processor_,
pixel[1] *= inv_alpha;
pixel[2] *= inv_alpha;
- processor->applyRGB(pixel);
+ device_processor->applyRGB(pixel);
pixel[0] *= alpha;
pixel[1] *= alpha;
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index cf49dedc426..4ac3222a556 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -394,20 +394,24 @@ ShaderManager::ShaderManager()
OCIO::ConstProcessorRcPtr to_rgb_processor = config->getProcessor("XYZ", "scene_linear");
OCIO::ConstProcessorRcPtr to_xyz_processor = config->getProcessor("scene_linear", "XYZ");
if (to_rgb_processor && to_xyz_processor) {
+ OCIO::ConstCPUProcessorRcPtr to_xyz_device_processor =
+ to_xyz_processor->getDefaultCPUProcessor();
+ OCIO::ConstCPUProcessorRcPtr to_rgb_device_processor =
+ to_rgb_processor->getDefaultCPUProcessor();
float r[] = {1.0f, 0.0f, 0.0f};
float g[] = {0.0f, 1.0f, 0.0f};
float b[] = {0.0f, 0.0f, 1.0f};
- to_xyz_processor->applyRGB(r);
- to_xyz_processor->applyRGB(g);
- to_xyz_processor->applyRGB(b);
+ to_xyz_device_processor->applyRGB(r);
+ to_xyz_device_processor->applyRGB(g);
+ to_xyz_device_processor->applyRGB(b);
rgb_to_y = make_float3(r[1], g[1], b[1]);
float x[] = {1.0f, 0.0f, 0.0f};
float y[] = {0.0f, 1.0f, 0.0f};
float z[] = {0.0f, 0.0f, 1.0f};
- to_rgb_processor->applyRGB(x);
- to_rgb_processor->applyRGB(y);
- to_rgb_processor->applyRGB(z);
+ to_rgb_device_processor->applyRGB(x);
+ to_rgb_device_processor->applyRGB(y);
+ to_rgb_device_processor->applyRGB(z);
xyz_to_r = make_float3(x[0], y[0], z[0]);
xyz_to_g = make_float3(x[1], y[1], z[1]);
xyz_to_b = make_float3(x[2], y[2], z[2]);
More information about the Bf-blender-cvs
mailing list