osl_shader.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright 2011-2013 Blender Foundation
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef __OSL_SHADER_H__
  17. #define __OSL_SHADER_H__
  18. #ifdef WITH_OSL
  19. /* OSL Shader Engine
  20. *
  21. * Holds all variables to execute and use OSL shaders from the kernel. These
  22. * are initialized externally by OSLShaderManager before rendering starts.
  23. *
  24. * Before/after a thread starts rendering, thread_init/thread_free must be
  25. * called, which will store any per thread OSL state in thread local storage.
  26. * This means no thread state must be passed along in the kernel itself.
  27. */
  28. # include "kernel/kernel_types.h"
  29. CCL_NAMESPACE_BEGIN
  30. class Scene;
  31. struct ShaderClosure;
  32. struct ShaderData;
  33. struct differential3;
  34. struct KernelGlobals;
  35. struct OSLGlobals;
  36. struct OSLShadingSystem;
  37. class OSLShader {
  38. public:
  39. /* init */
  40. static void register_closures(OSLShadingSystem *ss);
  41. /* per thread data */
  42. static void thread_init(KernelGlobals *kg,
  43. KernelGlobals *kernel_globals,
  44. OSLGlobals *osl_globals);
  45. static void thread_free(KernelGlobals *kg);
  46. /* eval */
  47. static void eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
  48. static void eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
  49. static void eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
  50. static void eval_displacement(KernelGlobals *kg, ShaderData *sd, PathState *state);
  51. /* attributes */
  52. static int find_attribute(KernelGlobals *kg,
  53. const ShaderData *sd,
  54. uint id,
  55. AttributeDescriptor *desc);
  56. };
  57. CCL_NAMESPACE_END
  58. #endif
  59. #endif /* __OSL_SHADER_H__ */