kernel_lamp_emission.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2011-2015 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 operates on QUEUE_ACTIVE_AND_REGENERATED_RAYS.
  18. * It processes rays of state RAY_ACTIVE and RAY_HIT_BACKGROUND.
  19. * We will empty QUEUE_ACTIVE_AND_REGENERATED_RAYS queue in this kernel.
  20. */
  21. ccl_device void kernel_lamp_emission(KernelGlobals *kg)
  22. {
  23. #ifndef __VOLUME__
  24. /* We will empty this queue in this kernel. */
  25. if (ccl_global_id(0) == 0 && ccl_global_id(1) == 0) {
  26. kernel_split_params.queue_index[QUEUE_ACTIVE_AND_REGENERATED_RAYS] = 0;
  27. }
  28. #endif
  29. /* Fetch use_queues_flag. */
  30. char local_use_queues_flag = *kernel_split_params.use_queues_flag;
  31. ccl_barrier(CCL_LOCAL_MEM_FENCE);
  32. int ray_index = ccl_global_id(1) * ccl_global_size(0) + ccl_global_id(0);
  33. if (local_use_queues_flag) {
  34. ray_index = get_ray_index(kg,
  35. ray_index,
  36. QUEUE_ACTIVE_AND_REGENERATED_RAYS,
  37. kernel_split_state.queue_data,
  38. kernel_split_params.queue_size,
  39. #ifndef __VOLUME__
  40. 1
  41. #else
  42. 0
  43. #endif
  44. );
  45. if (ray_index == QUEUE_EMPTY_SLOT) {
  46. return;
  47. }
  48. }
  49. if (IS_STATE(kernel_split_state.ray_state, ray_index, RAY_ACTIVE) ||
  50. IS_STATE(kernel_split_state.ray_state, ray_index, RAY_HIT_BACKGROUND)) {
  51. PathRadiance *L = &kernel_split_state.path_radiance[ray_index];
  52. ccl_global PathState *state = &kernel_split_state.path_state[ray_index];
  53. float3 throughput = kernel_split_state.throughput[ray_index];
  54. Ray ray = kernel_split_state.ray[ray_index];
  55. ccl_global Intersection *isect = &kernel_split_state.isect[ray_index];
  56. ShaderData *sd = kernel_split_sd(sd, ray_index);
  57. kernel_path_lamp_emission(kg, state, &ray, throughput, isect, sd, L);
  58. }
  59. }
  60. CCL_NAMESPACE_END