kernel_shader_eval.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2011-2017 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. CCL_NAMESPACE_BEGIN
  17. /* This kernel evaluates ShaderData structure from the values computed
  18. * by the previous kernels.
  19. */
  20. ccl_device void kernel_shader_eval(KernelGlobals *kg)
  21. {
  22. int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
  23. /* Sorting on cuda split is not implemented */
  24. #ifdef __KERNEL_CUDA__
  25. int queue_index = kernel_split_params.queue_index[QUEUE_ACTIVE_AND_REGENERATED_RAYS];
  26. #else
  27. int queue_index = kernel_split_params.queue_index[QUEUE_SHADER_SORTED_RAYS];
  28. #endif
  29. if (ray_index >= queue_index) {
  30. return;
  31. }
  32. ray_index = get_ray_index(kg,
  33. ray_index,
  34. #ifdef __KERNEL_CUDA__
  35. QUEUE_ACTIVE_AND_REGENERATED_RAYS,
  36. #else
  37. QUEUE_SHADER_SORTED_RAYS,
  38. #endif
  39. kernel_split_state.queue_data,
  40. kernel_split_params.queue_size,
  41. 0);
  42. if (ray_index == QUEUE_EMPTY_SLOT) {
  43. return;
  44. }
  45. ccl_global char *ray_state = kernel_split_state.ray_state;
  46. if (IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
  47. ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
  48. shader_eval_surface(kg, kernel_split_sd(sd, ray_index), state, state->flag);
  49. #ifdef __BRANCHED_PATH__
  50. if (kernel_data.integrator.branched) {
  51. shader_merge_closures(kernel_split_sd(sd, ray_index));
  52. }
  53. else
  54. #endif
  55. {
  56. shader_prepare_closures(kernel_split_sd(sd, ray_index), state);
  57. }
  58. }
  59. }
  60. CCL_NAMESPACE_END