Build: support OpenColorIO 2.3
For Linux distributions or others that upgrade before we do. Ref #113157 Pull Request: https://projects.blender.org/blender/blender/pulls/113163
This commit is contained in:
parent
a455eca7a0
commit
94e2973f0b
@ -343,8 +343,15 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
|
|||||||
unsigned int height = 0;
|
unsigned int height = 0;
|
||||||
GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
|
GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
|
||||||
Interpolation interpolation = INTERP_LINEAR;
|
Interpolation interpolation = INTERP_LINEAR;
|
||||||
|
#if OCIO_VERSION_HEX >= 0x02030000
|
||||||
|
/* Always use 2D textures in OpenColorIO 2.3, simpler and same performance. */
|
||||||
|
GpuShaderDesc::TextureDimensions dimensions = GpuShaderDesc::TEXTURE_2D;
|
||||||
|
shader_desc->getTexture(
|
||||||
|
index, texture_name, sampler_name, width, height, channel, dimensions, interpolation);
|
||||||
|
#else
|
||||||
shader_desc->getTexture(
|
shader_desc->getTexture(
|
||||||
index, texture_name, sampler_name, width, height, channel, interpolation);
|
index, texture_name, sampler_name, width, height, channel, interpolation);
|
||||||
|
#endif
|
||||||
|
|
||||||
const float *values;
|
const float *values;
|
||||||
shader_desc->getTextureValues(index, values);
|
shader_desc->getTextureValues(index, values);
|
||||||
@ -358,6 +365,7 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
|
|||||||
GPU_R16F;
|
GPU_R16F;
|
||||||
|
|
||||||
OCIO_GPULutTexture lut;
|
OCIO_GPULutTexture lut;
|
||||||
|
#if OCIO_VERSION_HEX < 0x02030000
|
||||||
/* There does not appear to be an explicit way to check if a texture is 1D or 2D.
|
/* There does not appear to be an explicit way to check if a texture is 1D or 2D.
|
||||||
* It depends on more than height. So check instead by looking at the source. */
|
* It depends on more than height. So check instead by looking at the source. */
|
||||||
std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
|
std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
|
||||||
@ -365,7 +373,9 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
|
|||||||
lut.texture = GPU_texture_create_1d(
|
lut.texture = GPU_texture_create_1d(
|
||||||
texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
lut.texture = GPU_texture_create_2d(
|
lut.texture = GPU_texture_create_2d(
|
||||||
texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
||||||
}
|
}
|
||||||
|
@ -95,6 +95,18 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
|||||||
return GPU_max_texture_size();
|
return GPU_max_texture_size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# if OCIO_VERSION_HEX >= 0x02030000
|
||||||
|
void setAllowTexture1D(bool allowed) override
|
||||||
|
{
|
||||||
|
allow_texture_1D_ = allowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool getAllowTexture1D() const override
|
||||||
|
{
|
||||||
|
return allow_texture_1D_;
|
||||||
|
}
|
||||||
|
# endif
|
||||||
|
|
||||||
bool addUniform(const char *name, const DoubleGetter &get_double) override
|
bool addUniform(const char *name, const DoubleGetter &get_double) override
|
||||||
{
|
{
|
||||||
/* Check if a resource exists with the same name and assert if it is the case, returning false
|
/* Check if a resource exists with the same name and assert if it is the case, returning false
|
||||||
@ -201,6 +213,9 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
|||||||
uint width,
|
uint width,
|
||||||
uint height,
|
uint height,
|
||||||
TextureType channel,
|
TextureType channel,
|
||||||
|
# if OCIO_VERSION_HEX >= 0x02030000
|
||||||
|
OCIO::GpuShaderDesc::TextureDimensions dimensions,
|
||||||
|
# endif
|
||||||
OCIO::Interpolation interpolation,
|
OCIO::Interpolation interpolation,
|
||||||
const float *values) override
|
const float *values) override
|
||||||
{
|
{
|
||||||
@ -216,7 +231,11 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
|||||||
GPUTexture *texture;
|
GPUTexture *texture;
|
||||||
eGPUTextureFormat texture_format = (channel == TEXTURE_RGB_CHANNEL) ? GPU_RGB16F : GPU_R16F;
|
eGPUTextureFormat texture_format = (channel == TEXTURE_RGB_CHANNEL) ? GPU_RGB16F : GPU_R16F;
|
||||||
/* A height of 1 indicates a 1D texture according to the OCIO API. */
|
/* A height of 1 indicates a 1D texture according to the OCIO API. */
|
||||||
|
# if OCIO_VERSION_HEX >= 0x02030000
|
||||||
|
if (dimensions == OCIO::GpuShaderDesc::TEXTURE_1D) {
|
||||||
|
# else
|
||||||
if (height == 1) {
|
if (height == 1) {
|
||||||
|
# endif
|
||||||
texture = GPU_texture_create_1d(
|
texture = GPU_texture_create_1d(
|
||||||
texture_name, width, 1, texture_format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
texture_name, width, 1, texture_format, GPU_TEXTURE_USAGE_SHADER_READ, values);
|
||||||
shader_create_info_.sampler(textures_.size() + 1, ImageType::FLOAT_1D, resource_name);
|
shader_create_info_.sampler(textures_.size() + 1, ImageType::FLOAT_1D, resource_name);
|
||||||
@ -398,6 +417,11 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
|
|||||||
/* A vectors that stores the created uniform buffers when bind_shader_and_resources() is called,
|
/* A vectors that stores the created uniform buffers when bind_shader_and_resources() is called,
|
||||||
* so that they can be properly unbound and freed in the unbind_shader_and_resources() method. */
|
* so that they can be properly unbound and freed in the unbind_shader_and_resources() method. */
|
||||||
Vector<GPUUniformBuf *> uniform_buffers_;
|
Vector<GPUUniformBuf *> uniform_buffers_;
|
||||||
|
|
||||||
|
# if OCIO_VERSION_HEX >= 0x02030000
|
||||||
|
/* Allow creating 1D textures, or only use 2D textures. */
|
||||||
|
bool allow_texture_1D_ = true;
|
||||||
|
# endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user