Blender  V3.3
ocio_impl_glsl.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later AND BSD-3-Clause
2  * Copyright 2003-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved (BSD-3-Clause).
3  * 2013 Blender Foundation (GPL-2.0-or-later). */
4 
5 #include <limits>
6 #include <list>
7 #include <sstream>
8 #include <string.h>
9 #include <vector>
10 
11 #ifdef _MSC_VER
12 # pragma warning(push)
13 # pragma warning(disable : 4251 4275)
14 #endif
15 #include <OpenColorIO/OpenColorIO.h>
16 #ifdef _MSC_VER
17 # pragma warning(pop)
18 #endif
19 
20 #include "GPU_immediate.h"
21 #include "GPU_shader.h"
22 #include "GPU_uniform_buffer.h"
23 
25 
26 using namespace OCIO_NAMESPACE;
27 
28 #include "MEM_guardedalloc.h"
29 
30 #include "ocio_impl.h"
31 #include "ocio_shader_shared.hh"
32 
33 /* **** OpenGL drawing routines using GLSL for color space transform ***** */
34 
40 };
41 
46 };
47 
49  /* GPU shader. */
50  struct GPUShader *shader = nullptr;
51 
54  GPUUniformBuf *parameters_buffer = nullptr;
55 
56  /* Destructor. */
58  {
59  if (shader) {
60  GPU_shader_free(shader);
61  }
62  if (parameters_buffer) {
63  GPU_uniformbuf_free(parameters_buffer);
64  }
65  }
66 };
67 
69  GPUTexture *texture = nullptr;
70  std::string sampler_name;
71 };
72 
74  GpuShaderDesc::UniformData data;
75  std::string name;
76 };
77 
80  std::vector<OCIO_GPULutTexture> luts;
81 
82  /* Dummy in case of no overlay. */
83  GPUTexture *dummy = nullptr;
84 
85  /* Uniforms */
86  std::vector<OCIO_GPUUniform> uniforms;
87  GPUUniformBuf *uniforms_buffer = nullptr;
88 
89  /* Destructor. */
91  {
92  for (OCIO_GPULutTexture &lut : luts) {
93  GPU_texture_free(lut.texture);
94  }
95  if (dummy) {
96  GPU_texture_free(dummy);
97  }
98  if (uniforms_buffer) {
99  GPU_uniformbuf_free(uniforms_buffer);
100  }
101  }
102 };
103 
106  GPUUniformBuf *buffer = nullptr;
108  GPUTexture *texture = nullptr;
109  /* To detect when to update the uniforms and textures. */
110  size_t cache_id = 0;
111 
112  /* Destructor. */
114  {
115  if (texture) {
116  GPU_texture_free(texture);
117  }
118  if (buffer) {
120  }
121  }
122 };
123 
128 
129  /* Cache variables. */
130  std::string input;
131  std::string view;
132  std::string display;
133  std::string look;
134  bool use_curve_mapping = false;
135 
137  bool valid = false;
138 };
139 
140 static const int SHADER_CACHE_MAX_SIZE = 4;
141 std::list<OCIO_GPUDisplayShader> SHADER_CACHE;
142 
143 /* -------------------------------------------------------------------- */
147 static bool createGPUShader(OCIO_GPUShader &shader,
149  const GpuShaderDescRcPtr &shaderdesc_to_scene_linear,
150  const GpuShaderDescRcPtr &shaderdesc_to_display,
151  const bool use_curve_mapping)
152 {
153  using namespace blender::gpu::shader;
154 
155  std::string source;
156  source += shaderdesc_to_scene_linear->getShaderText();
157  source += "\n";
158  source += shaderdesc_to_display->getShaderText();
159  source += "\n";
160 
161  {
162  /* Replace all uniform declarations by a comment.
163  * This avoids double declarations from the backend. */
164  size_t index = 0;
165  while (true) {
166  index = source.find("uniform ", index);
167  if (index == -1) {
168  break;
169  }
170  source.replace(index, 2, "//");
171  index += 2;
172  }
173  }
174 
175  StageInterfaceInfo iface("OCIO_Interface", "");
176  iface.smooth(Type::VEC2, "texCoord_interp");
177 
178  ShaderCreateInfo info("OCIO_Display");
179  /* Work around OpenColorIO not supporting latest GLSL yet. */
180  info.define("texture1D", "texture");
181  info.define("texture2D", "texture");
182  info.define("texture3D", "texture");
183  info.typedef_source("ocio_shader_shared.hh");
184  info.sampler(TEXTURE_SLOT_IMAGE, ImageType::FLOAT_2D, "image_texture");
185  info.sampler(TEXTURE_SLOT_OVERLAY, ImageType::FLOAT_2D, "overlay_texture");
186  info.uniform_buf(UNIFORMBUF_SLOT_DISPLAY, "OCIO_GPUParameters", "parameters");
187  info.push_constant(Type::MAT4, "ModelViewProjectionMatrix");
188  info.vertex_in(0, Type::VEC2, "pos");
189  info.vertex_in(1, Type::VEC2, "texCoord");
190  info.vertex_out(iface);
191  info.fragment_out(0, Type::VEC4, "fragColor");
192  info.vertex_source("gpu_shader_display_transform_vert.glsl");
193  info.fragment_source("gpu_shader_display_transform_frag.glsl");
194  info.fragment_source_generated = source;
195 
196  /* T96502: Work around for incorrect OCIO GLSL code generation when using
197  * GradingPrimaryTransform. Should be reevaluated when changing to a next version of OCIO.
198  * (currently v2.1.1). */
199  info.define("inf 1e32");
200 
201  if (use_curve_mapping) {
202  info.define("USE_CURVE_MAPPING");
203  info.uniform_buf(UNIFORMBUF_SLOT_CURVEMAP, "OCIO_GPUCurveMappingParameters", "curve_mapping");
204  info.sampler(TEXTURE_SLOT_CURVE_MAPPING, ImageType::FLOAT_1D, "curve_mapping_texture");
205  }
206 
207  /* Set LUT textures. */
208  int slot = TEXTURE_SLOT_LUTS_OFFSET;
209  for (OCIO_GPULutTexture &texture : textures.luts) {
210  const int dimensions = GPU_texture_dimensions(texture.texture);
211  ImageType type = (dimensions == 1) ? ImageType::FLOAT_1D :
212  (dimensions == 2) ? ImageType::FLOAT_2D :
213  ImageType::FLOAT_3D;
214 
215  info.sampler(slot++, type, texture.sampler_name.c_str());
216  }
217 
218  /* Set LUT uniforms. */
219  if (!textures.uniforms.empty()) {
220  /* NOTE: For simplicity, we pad everything to size of vec4 avoiding sorting and alignment
221  * issues. It is unlikely that this becomes a real issue. */
222  size_t ubo_size = textures.uniforms.size() * sizeof(float) * 4;
223  void *ubo_data_buf = malloc(ubo_size);
224 
225  uint32_t *ubo_data = reinterpret_cast<uint32_t *>(ubo_data_buf);
226 
227  std::stringstream ss;
228  ss << "struct OCIO_GPULutParameters {\n";
229 
230  int index = 0;
231  for (OCIO_GPUUniform &uniform : textures.uniforms) {
232  index += 1;
233  const GpuShaderDesc::UniformData &data = uniform.data;
234  const char *name = uniform.name.c_str();
235  char prefix = ' ';
236  int vec_len;
237  switch (data.m_type) {
238  case UNIFORM_DOUBLE: {
239  vec_len = 1;
240  float value = float(data.m_getDouble());
241  memcpy(ubo_data, &value, sizeof(float));
242  break;
243  }
244  case UNIFORM_BOOL: {
245  prefix = 'b';
246  vec_len = 1;
247  int value = int(data.m_getBool());
248  memcpy(ubo_data, &value, sizeof(int));
249  break;
250  }
251  case UNIFORM_FLOAT3:
252  vec_len = 3;
253  memcpy(ubo_data, data.m_getFloat3().data(), sizeof(float) * 3);
254  break;
255  case UNIFORM_VECTOR_FLOAT:
256  vec_len = data.m_vectorFloat.m_getSize();
257  memcpy(ubo_data, data.m_vectorFloat.m_getVector(), sizeof(float) * vec_len);
258  break;
259  case UNIFORM_VECTOR_INT:
260  prefix = 'i';
261  vec_len = data.m_vectorInt.m_getSize();
262  memcpy(ubo_data, data.m_vectorInt.m_getVector(), sizeof(int) * vec_len);
263  break;
264  default:
265  continue;
266  }
267  /* Align every member to 16bytes. */
268  ubo_data += 4;
269  /* Use a generic variable name because some GLSL compilers can interpret the preprocessor
270  * define as recursive. */
271  ss << " " << prefix << "vec4 var" << index << ";\n";
272  /* Use a define to keep the generated code working. */
273  blender::StringRef suffix = blender::StringRefNull("xyzw").substr(0, vec_len);
274  ss << "#define " << name << " lut_parameters.var" << index << "." << suffix << "\n";
275  }
276  ss << "};\n";
277  info.typedef_source_generated = ss.str();
278 
279  info.uniform_buf(UNIFORMBUF_SLOT_LUTS, "OCIO_GPULutParameters", "lut_parameters");
280 
281  textures.uniforms_buffer = GPU_uniformbuf_create_ex(
282  ubo_size, ubo_data_buf, "OCIO_LutParameters");
283 
284  free(ubo_data_buf);
285  }
286 
287  shader.shader = GPU_shader_create_from_info(reinterpret_cast<GPUShaderCreateInfo *>(&info));
288 
289  return (shader.shader != nullptr);
290 }
291 
294 /* -------------------------------------------------------------------- */
299  const GpuShaderDescRcPtr &shader_desc,
300  int index)
301 {
302  OCIO_GPUUniform uniform;
303  uniform.name = shader_desc->getUniform(index, uniform.data);
304  if (uniform.data.m_type == UNIFORM_UNKNOWN) {
305  return false;
306  }
307 
308  textures.uniforms.push_back(uniform);
309  return true;
310 }
311 
313  const GpuShaderDescRcPtr &shader_desc,
314  int index)
315 {
316  const char *texture_name = nullptr;
317  const char *sampler_name = nullptr;
318  unsigned int width = 0;
319  unsigned int height = 0;
320  GpuShaderCreator::TextureType channel = GpuShaderCreator::TEXTURE_RGB_CHANNEL;
321  Interpolation interpolation = INTERP_LINEAR;
322  shader_desc->getTexture(
323  index, texture_name, sampler_name, width, height, channel, interpolation);
324 
325  const float *values;
326  shader_desc->getTextureValues(index, values);
327  if (texture_name == nullptr || sampler_name == nullptr || width == 0 || height == 0 ||
328  values == nullptr) {
329  return false;
330  }
331 
332  eGPUTextureFormat format = (channel == GpuShaderCreator::TEXTURE_RGB_CHANNEL) ? GPU_RGB16F :
333  GPU_R16F;
334 
335  OCIO_GPULutTexture lut;
336  /* There does not appear to be an explicit way to check if a texture is 1D or 2D.
337  * It depends on more than height. So check instead by looking at the source. */
338  std::string sampler1D_name = std::string("sampler1D ") + sampler_name;
339  if (strstr(shader_desc->getShaderText(), sampler1D_name.c_str()) != nullptr) {
340  lut.texture = GPU_texture_create_1d(texture_name, width, 1, format, values);
341  }
342  else {
343  lut.texture = GPU_texture_create_2d(texture_name, width, height, 1, format, values);
344  }
345  if (lut.texture == nullptr) {
346  return false;
347  }
348 
349  GPU_texture_filter_mode(lut.texture, interpolation != INTERP_NEAREST);
350  GPU_texture_wrap_mode(lut.texture, false, true);
351 
352  lut.sampler_name = sampler_name;
353 
354  textures.luts.push_back(lut);
355  return true;
356 }
357 
359  const GpuShaderDescRcPtr &shader_desc,
360  int index)
361 {
362  const char *texture_name = nullptr;
363  const char *sampler_name = nullptr;
364  unsigned int edgelen = 0;
365  Interpolation interpolation = INTERP_LINEAR;
366  shader_desc->get3DTexture(index, texture_name, sampler_name, edgelen, interpolation);
367 
368  const float *values;
369  shader_desc->get3DTextureValues(index, values);
370  if (texture_name == nullptr || sampler_name == nullptr || edgelen == 0 || values == nullptr) {
371  return false;
372  }
373 
374  OCIO_GPULutTexture lut;
376  texture_name, edgelen, edgelen, edgelen, 1, GPU_RGB16F, GPU_DATA_FLOAT, values);
377  if (lut.texture == nullptr) {
378  return false;
379  }
380 
381  GPU_texture_filter_mode(lut.texture, interpolation != INTERP_NEAREST);
382  GPU_texture_wrap_mode(lut.texture, false, true);
383 
384  lut.sampler_name = sampler_name;
385 
386  textures.luts.push_back(lut);
387  return true;
388 }
389 
391  const GpuShaderDescRcPtr &shaderdesc_to_scene_linear,
392  const GpuShaderDescRcPtr &shaderdesc_to_display)
393 {
394  textures.dummy = GPU_texture_create_error(2, false);
395 
396  textures.luts.clear();
397  textures.uniforms.clear();
398 
399  for (int index = 0; index < shaderdesc_to_scene_linear->getNumUniforms(); index++) {
400  if (!addGPUUniform(textures, shaderdesc_to_scene_linear, index)) {
401  return false;
402  }
403  }
404  for (int index = 0; index < shaderdesc_to_scene_linear->getNumTextures(); index++) {
405  if (!addGPULut1D2D(textures, shaderdesc_to_scene_linear, index)) {
406  return false;
407  }
408  }
409  for (int index = 0; index < shaderdesc_to_scene_linear->getNum3DTextures(); index++) {
410  if (!addGPULut3D(textures, shaderdesc_to_scene_linear, index)) {
411  return false;
412  }
413  }
414  for (int index = 0; index < shaderdesc_to_display->getNumUniforms(); index++) {
415  if (!addGPUUniform(textures, shaderdesc_to_display, index)) {
416  return false;
417  }
418  }
419  for (int index = 0; index < shaderdesc_to_display->getNumTextures(); index++) {
420  if (!addGPULut1D2D(textures, shaderdesc_to_display, index)) {
421  return false;
422  }
423  }
424  for (int index = 0; index < shaderdesc_to_display->getNum3DTextures(); index++) {
425  if (!addGPULut3D(textures, shaderdesc_to_display, index)) {
426  return false;
427  }
428  }
429 
430  return true;
431 }
432 
435 /* -------------------------------------------------------------------- */
440  OCIO_CurveMappingSettings *curve_mapping_settings)
441 {
442  if (curve_mapping_settings) {
443  int lut_size = curve_mapping_settings->lut_size;
444 
445  curvemap.texture = GPU_texture_create_1d("OCIOCurveMap", lut_size, 1, GPU_RGBA16F, nullptr);
446  GPU_texture_filter_mode(curvemap.texture, false);
447  GPU_texture_wrap_mode(curvemap.texture, false, true);
448 
450 
451  if (curvemap.texture == nullptr || curvemap.buffer == nullptr) {
452  return false;
453  }
454  }
455 
456  return true;
457 }
458 
460  OCIO_CurveMappingSettings *curve_mapping_settings)
461 {
462  /* Test if we need to update. The caller ensures the curve_mapping_settings
463  * changes when its contents changes. */
464  if (curve_mapping_settings == nullptr || curvemap.cache_id == curve_mapping_settings->cache_id) {
465  return;
466  }
467 
468  curvemap.cache_id = curve_mapping_settings->cache_id;
469 
470  /* Update texture. */
471  int offset[3] = {0, 0, 0};
472  int extent[3] = {curve_mapping_settings->lut_size, 0, 0};
473  const float *pixels = curve_mapping_settings->lut;
475  curvemap.texture, GPU_DATA_FLOAT, pixels, UNPACK3(offset), UNPACK3(extent));
476 
477  /* Update uniforms. */
479  for (int i = 0; i < 4; i++) {
480  data.range[i] = curve_mapping_settings->range[i];
481  data.mintable[i] = curve_mapping_settings->mintable[i];
482  data.ext_in_x[i] = curve_mapping_settings->ext_in_x[i];
483  data.ext_in_y[i] = curve_mapping_settings->ext_in_y[i];
484  data.ext_out_x[i] = curve_mapping_settings->ext_out_x[i];
485  data.ext_out_y[i] = curve_mapping_settings->ext_out_y[i];
486  data.first_x[i] = curve_mapping_settings->first_x[i];
487  data.first_y[i] = curve_mapping_settings->first_y[i];
488  data.last_x[i] = curve_mapping_settings->last_x[i];
489  data.last_y[i] = curve_mapping_settings->last_y[i];
490  }
491  for (int i = 0; i < 3; i++) {
492  data.black[i] = curve_mapping_settings->black[i];
493  data.bwmul[i] = curve_mapping_settings->bwmul[i];
494  }
495  data.lut_size = curve_mapping_settings->lut_size;
496  data.use_extend_extrapolate = curve_mapping_settings->use_extend_extrapolate;
497 
498  GPU_uniformbuf_update(curvemap.buffer, &data);
499 }
500 
502  float scale,
503  float exponent,
504  float dither,
505  bool use_predivide,
506  bool use_overlay)
507 {
508  bool do_update = false;
509  if (shader.parameters_buffer == nullptr) {
511  do_update = true;
512  }
514  if (data.scale != scale) {
515  data.scale = scale;
516  do_update = true;
517  }
518  if (data.exponent != exponent) {
519  data.exponent = exponent;
520  do_update = true;
521  }
522  if (data.dither != dither) {
523  data.dither = dither;
524  do_update = true;
525  }
526  if (bool(data.use_predivide) != use_predivide) {
527  data.use_predivide = use_predivide;
528  do_update = true;
529  }
530  if (bool(data.use_overlay) != use_overlay) {
531  data.use_overlay = use_overlay;
532  do_update = true;
533  }
534  if (do_update) {
536  }
537 }
538 
541 /* -------------------------------------------------------------------- */
545 bool OCIOImpl::supportGPUShader()
546 {
547  /* Minimum supported version 3.3 does meet all requirements. */
548  return true;
549 }
550 
552  OCIO_ConstConfigRcPtr *config,
553  const char *input,
554  const char *view,
555  const char *display,
556  const char *look,
557  OCIO_CurveMappingSettings *curve_mapping_settings)
558 {
559  /* Find existing shader in cache. */
560  const bool use_curve_mapping = (curve_mapping_settings != nullptr);
561  for (std::list<OCIO_GPUDisplayShader>::iterator it = SHADER_CACHE.begin();
562  it != SHADER_CACHE.end();
563  it++) {
564  if (it->input == input && it->view == view && it->display == display && it->look == look &&
565  it->use_curve_mapping == use_curve_mapping) {
566  /* Move to front of the cache to mark as most recently used. */
567  if (it != SHADER_CACHE.begin()) {
568  SHADER_CACHE.splice(SHADER_CACHE.begin(), SHADER_CACHE, it);
569  }
570 
571  return *it;
572  }
573  }
574 
575  /* Remove least recently used element from cache. */
576  if (SHADER_CACHE.size() >= SHADER_CACHE_MAX_SIZE) {
577  SHADER_CACHE.pop_back();
578  }
579 
580  /* Create GPU shader. */
581  SHADER_CACHE.emplace_front();
582  OCIO_GPUDisplayShader &display_shader = SHADER_CACHE.front();
583 
584  display_shader.input = input;
585  display_shader.view = view;
586  display_shader.display = display;
587  display_shader.look = look;
588  display_shader.use_curve_mapping = use_curve_mapping;
589  display_shader.valid = false;
590 
591  /* Create Processors.
592  *
593  * Scale and exponent are handled outside of OCIO shader so we can handle them
594  * as uniforms at the binding stage. OCIO would otherwise bake them into the
595  * shader code, requiring slow recompiles when interactively adjusting them.
596  *
597  * Note that OCIO does have the concept of dynamic properties, however there
598  * is no dynamic gamma and exposure is part of more expensive operations only.
599  *
600  * Since exposure must happen in scene linear, we use two processors. The input
601  * is usually scene linear already and so that conversion is often a no-op.
602  */
603  OCIO_ConstProcessorRcPtr *processor_to_scene_linear = OCIO_configGetProcessorWithNames(
604  config, input, ROLE_SCENE_LINEAR);
605  OCIO_ConstProcessorRcPtr *processor_to_display = OCIO_createDisplayProcessor(
606  config, ROLE_SCENE_LINEAR, view, display, look, 1.0f, 1.0f, false);
607 
608  /* Create shader descriptions. */
609  if (processor_to_scene_linear && processor_to_display) {
610  GpuShaderDescRcPtr shaderdesc_to_scene_linear = GpuShaderDesc::CreateShaderDesc();
611  shaderdesc_to_scene_linear->setLanguage(GPU_LANGUAGE_GLSL_1_3);
612  shaderdesc_to_scene_linear->setFunctionName("OCIO_to_scene_linear");
613  shaderdesc_to_scene_linear->setResourcePrefix("to_scene");
614  (*(ConstProcessorRcPtr *)processor_to_scene_linear)
615  ->getDefaultGPUProcessor()
616  ->extractGpuShaderInfo(shaderdesc_to_scene_linear);
617  shaderdesc_to_scene_linear->finalize();
618 
619  GpuShaderDescRcPtr shaderdesc_to_display = GpuShaderDesc::CreateShaderDesc();
620  shaderdesc_to_display->setLanguage(GPU_LANGUAGE_GLSL_1_3);
621  shaderdesc_to_display->setFunctionName("OCIO_to_display");
622  shaderdesc_to_display->setResourcePrefix("to_display");
623  (*(ConstProcessorRcPtr *)processor_to_display)
624  ->getDefaultGPUProcessor()
625  ->extractGpuShaderInfo(shaderdesc_to_display);
626  shaderdesc_to_display->finalize();
627 
628  /* Create GPU shader and textures. */
629  if (createGPUTextures(
630  display_shader.textures, shaderdesc_to_scene_linear, shaderdesc_to_display) &&
631  createGPUCurveMapping(display_shader.curvemap, curve_mapping_settings) &&
632  createGPUShader(display_shader.shader,
633  display_shader.textures,
634  shaderdesc_to_scene_linear,
635  shaderdesc_to_display,
636  use_curve_mapping)) {
637  display_shader.valid = true;
638  }
639  }
640 
641  /* Free processors. */
642  if (processor_to_scene_linear) {
643  OCIO_processorRelease(processor_to_scene_linear);
644  }
645  if (processor_to_display) {
646  OCIO_processorRelease(processor_to_display);
647  }
648 
649  return display_shader;
650 }
651 
662 bool OCIOImpl::gpuDisplayShaderBind(OCIO_ConstConfigRcPtr *config,
663  const char *input,
664  const char *view,
665  const char *display,
666  const char *look,
667  OCIO_CurveMappingSettings *curve_mapping_settings,
668  const float scale,
669  const float exponent,
670  const float dither,
671  const bool use_predivide,
672  const bool use_overlay)
673 {
674  /* Get GPU shader from cache or create new one. */
675  OCIO_GPUDisplayShader &display_shader = getGPUDisplayShader(
676  config, input, view, display, look, curve_mapping_settings);
677  if (!display_shader.valid) {
678  return false;
679  }
680 
681  /* Verify the shader is valid. */
682  OCIO_GPUTextures &textures = display_shader.textures;
683  OCIO_GPUShader &shader = display_shader.shader;
684  OCIO_GPUCurveMappping &curvemap = display_shader.curvemap;
685 
686  /* Update and bind curve mapping data. */
687  if (curve_mapping_settings) {
688  updateGPUCurveMapping(curvemap, curve_mapping_settings);
691  }
692 
693  /* Bind textures to sampler units. Texture 0 is set by caller.
694  * Uniforms have already been set for texture bind points. */
695  if (!use_overlay) {
696  /* Avoid missing binds. */
698  }
699  for (int i = 0; i < textures.luts.size(); i++) {
700  GPU_texture_bind(textures.luts[i].texture, TEXTURE_SLOT_LUTS_OFFSET + i);
701  }
702 
703  if (textures.uniforms_buffer) {
705  }
706 
707  updateGPUDisplayParameters(shader, scale, exponent, dither, use_predivide, use_overlay);
709 
710  /* TODO(fclem): remove remains of IMM. */
711  immBindShader(shader.shader);
712 
713  return true;
714 }
715 
716 void OCIOImpl::gpuDisplayShaderUnbind()
717 {
719 }
720 
721 void OCIOImpl::gpuCacheFree()
722 {
723  SHADER_CACHE.clear();
724 }
725 
typedef float(TangentPoint)[2]
void BLI_kdtree_nd_() free(KDTree *tree)
Definition: kdtree_impl.h:102
#define UNPACK3(a)
static AppView * view
void immUnbindProgram(void)
void immBindShader(GPUShader *shader)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint * textures
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
struct GPUShader GPUShader
Definition: GPU_shader.h:20
struct GPUShaderCreateInfo GPUShaderCreateInfo
Definition: GPU_shader.h:18
void GPU_shader_free(GPUShader *shader)
Definition: gpu_shader.cc:200
GPUShader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
Definition: gpu_shader.cc:277
void GPU_texture_update_sub(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
Definition: gpu_texture.cc:417
void GPU_texture_wrap_mode(GPUTexture *tex, bool use_repeat, bool use_clamp)
Definition: gpu_texture.cc:546
GPUTexture * GPU_texture_create_1d(const char *name, int w, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:278
struct GPUTexture GPUTexture
Definition: GPU_texture.h:17
@ GPU_DATA_FLOAT
Definition: GPU_texture.h:171
void GPU_texture_free(GPUTexture *tex)
Definition: gpu_texture.cc:564
void GPU_texture_filter_mode(GPUTexture *tex, bool use_filter)
Definition: gpu_texture.cc:518
GPUTexture * GPU_texture_create_2d(const char *name, int w, int h, int mip_len, eGPUTextureFormat format, const float *data)
Definition: gpu_texture.cc:291
eGPUTextureFormat
Definition: GPU_texture.h:83
@ GPU_R16F
Definition: GPU_texture.h:113
@ GPU_RGB16F
Definition: GPU_texture.h:127
GPUTexture * GPU_texture_create_3d(const char *name, int w, int h, int d, int mip_len, eGPUTextureFormat texture_format, eGPUDataFormat data_format, const void *data)
Definition: gpu_texture.cc:309
int GPU_texture_dimensions(const GPUTexture *tex)
Definition: gpu_texture.cc:583
void GPU_texture_bind(GPUTexture *tex, int unit)
Definition: gpu_texture.cc:466
GPUTexture * GPU_texture_create_error(int dimension, bool array)
Definition: gpu_texture.cc:374
struct GPUUniformBuf GPUUniformBuf
#define GPU_uniformbuf_create(size)
GPUUniformBuf * GPU_uniformbuf_create_ex(size_t size, const void *data, const char *name)
void GPU_uniformbuf_update(GPUUniformBuf *ubo, const void *data)
void GPU_uniformbuf_free(GPUUniformBuf *ubo)
void GPU_uniformbuf_bind(GPUUniformBuf *ubo, int slot)
Read Guarded memory(de)allocation.
constexpr StringRef substr(int64_t start, int64_t size) const
depth_tx normal_tx diffuse_light_tx specular_light_tx volume_light_tx environment_tx ambient_occlusion_tx aov_value_tx in_weight_img GPU_RGBA16F
ccl_global float * buffer
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
ccl_global KernelShaderEvalInput * input
double parameters[NUM_PARAMETERS]
format
Definition: logImageCore.h:38
OCIO_ConstProcessorRcPtr * OCIO_configGetProcessorWithNames(OCIO_ConstConfigRcPtr *config, const char *srcName, const char *dstName)
Definition: ocio_capi.cc:174
OCIO_ConstProcessorRcPtr * OCIO_createDisplayProcessor(OCIO_ConstConfigRcPtr *config, const char *input, const char *view, const char *display, const char *look, const float scale, const float exponent, const bool inverse)
Definition: ocio_capi.cc:247
void OCIO_processorRelease(OCIO_ConstProcessorRcPtr *processor)
Definition: ocio_capi.cc:181
static bool addGPULut3D(OCIO_GPUTextures &textures, const GpuShaderDescRcPtr &shader_desc, int index)
static OCIO_GPUDisplayShader & getGPUDisplayShader(OCIO_ConstConfigRcPtr *config, const char *input, const char *view, const char *display, const char *look, OCIO_CurveMappingSettings *curve_mapping_settings)
static void updateGPUDisplayParameters(OCIO_GPUShader &shader, float scale, float exponent, float dither, bool use_predivide, bool use_overlay)
static bool createGPUCurveMapping(OCIO_GPUCurveMappping &curvemap, OCIO_CurveMappingSettings *curve_mapping_settings)
static bool addGPUUniform(OCIO_GPUTextures &textures, const GpuShaderDescRcPtr &shader_desc, int index)
OCIO_GPUUniformBufSlots
@ UNIFORMBUF_SLOT_CURVEMAP
@ UNIFORMBUF_SLOT_DISPLAY
@ UNIFORMBUF_SLOT_LUTS
static bool createGPUShader(OCIO_GPUShader &shader, OCIO_GPUTextures &textures, const GpuShaderDescRcPtr &shaderdesc_to_scene_linear, const GpuShaderDescRcPtr &shaderdesc_to_display, const bool use_curve_mapping)
OCIO_GPUTextureSlots
@ TEXTURE_SLOT_CURVE_MAPPING
@ TEXTURE_SLOT_OVERLAY
@ TEXTURE_SLOT_LUTS_OFFSET
@ TEXTURE_SLOT_IMAGE
static const int SHADER_CACHE_MAX_SIZE
static bool createGPUTextures(OCIO_GPUTextures &textures, const GpuShaderDescRcPtr &shaderdesc_to_scene_linear, const GpuShaderDescRcPtr &shaderdesc_to_display)
static void updateGPUCurveMapping(OCIO_GPUCurveMappping &curvemap, OCIO_CurveMappingSettings *curve_mapping_settings)
static bool addGPULut1D2D(OCIO_GPUTextures &textures, const GpuShaderDescRcPtr &shader_desc, int index)
std::list< OCIO_GPUDisplayShader > SHADER_CACHE
unsigned int uint32_t
Definition: stdint.h:80
GPUUniformBuf * buffer
OCIO_GPUCurveMappping curvemap
OCIO_GPUTextures textures
GPUTexture * texture
std::string sampler_name
struct GPUShader * shader
GPUUniformBuf * parameters_buffer
OCIO_GPUParameters parameters
std::vector< OCIO_GPUUniform > uniforms
std::vector< OCIO_GPULutTexture > luts
GpuShaderDesc::UniformData data
std::string name
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Self & typedef_source(StringRefNull filename)
Self & uniform_buf(int slot, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Self & sampler(int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, eGPUSamplerState sampler=(eGPUSamplerState) -1)
Self & fragment_source(StringRefNull filename)
Self & vertex_in(int slot, Type type, StringRefNull name)
Self & vertex_out(StageInterfaceInfo &interface)
Self & push_constant(Type type, StringRefNull name, int array_size=0)
Self & define(StringRefNull name, StringRefNull value="")
Self & vertex_source(StringRefNull filename)
Self & fragment_out(int slot, Type type, StringRefNull name, DualBlend blend=DualBlend::NONE)
Self & smooth(Type type, StringRefNull _name)