Build: changes to build with OpenColorIO 2.3 #113163

Merged
Brecht Van Lommel merged 1 commits from brecht/blender:ocio-2.3 into blender-v4.0-release 2023-10-02 19:31:26 +02:00
2 changed files with 35 additions and 1 deletions
Showing only changes of commit 458917773a - Show all commits

View File

@ -343,8 +343,15 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
unsigned int height = 0;
GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
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(
index, texture_name, sampler_name, width, height, channel, interpolation);
#endif
const float *values;
shader_desc->getTextureValues(index, values);
@ -358,6 +365,7 @@ static bool addGPULut1D2D(OCIO_GPUTextures &textures,
GPU_R16F;
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.
* It depends on more than height. So check instead by looking at the source. */
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(
texture_name, width, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
}
else {
else
#endif
{
lut.texture = GPU_texture_create_2d(
texture_name, width, height, 1, format, GPU_TEXTURE_USAGE_SHADER_READ, values);
}

View File

@ -95,6 +95,18 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
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
{
/* 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 height,
TextureType channel,
# if OCIO_VERSION_HEX >= 0x02030000
OCIO::GpuShaderDesc::TextureDimensions dimensions,
# endif
OCIO::Interpolation interpolation,
const float *values) override
{
@ -216,7 +231,11 @@ class GPUShaderCreator : public OCIO::GpuShaderCreator {
GPUTexture *texture;
eGPUTextureFormat texture_format = (channel == TEXTURE_RGB_CHANNEL) ? GPU_RGB16F : GPU_R16F;
/* 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) {
# endif
texture = GPU_texture_create_1d(
texture_name, width, 1, texture_format, GPU_TEXTURE_USAGE_SHADER_READ, values);
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,
* so that they can be properly unbound and freed in the unbind_shader_and_resources() method. */
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