Skip to content

Commit

Permalink
Merge remote-tracking branch 'b/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
youle31 committed Jun 20, 2023
2 parents 6257fdb + e381951 commit 63e503a
Show file tree
Hide file tree
Showing 87 changed files with 4,707 additions and 3,501 deletions.
2 changes: 2 additions & 0 deletions extern/hipew/include/hiprtew.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ typedef hiprtError(thiprtSetFuncTable)(hiprtContext context,
hiprtFuncDataSet set);
typedef hiprtError(thiprtDestroyFuncTable)(hiprtContext context,
hiprtFuncTable funcTable);
typedef void(thiprtSetLogLevel)( hiprtLogLevel level );

/* Function declarations. */
extern thiprtCreateContext *hiprtCreateContext;
Expand All @@ -94,6 +95,7 @@ extern thiprtGetSceneBuildTemporaryBufferSize *hiprtGetSceneBuildTemporaryBuffer
extern thiprtCreateFuncTable *hiprtCreateFuncTable;
extern thiprtSetFuncTable *hiprtSetFuncTable;
extern thiprtDestroyFuncTable *hiprtDestroyFuncTable;
extern thiprtSetLogLevel *hiprtSetLogLevel;

/* HIPEW API. */

Expand Down
2 changes: 2 additions & 0 deletions extern/hipew/src/hiprtew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ thiprtGetSceneBuildTemporaryBufferSize *hiprtGetSceneBuildTemporaryBufferSize;
thiprtCreateFuncTable *hiprtCreateFuncTable;
thiprtSetFuncTable *hiprtSetFuncTable;
thiprtDestroyFuncTable *hiprtDestroyFuncTable;
thiprtSetLogLevel *hiprtSetLogLevel;

static void hipewHipRtExit(void)
{
Expand Down Expand Up @@ -89,6 +90,7 @@ bool hiprtewInit()
HIPRT_LIBRARY_FIND(hiprtCreateFuncTable)
HIPRT_LIBRARY_FIND(hiprtSetFuncTable)
HIPRT_LIBRARY_FIND(hiprtDestroyFuncTable)
HIPRT_LIBRARY_FIND(hiprtSetLogLevel)

result = true;
#endif
Expand Down
5 changes: 3 additions & 2 deletions extern/xdnd/xdnd.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,9 @@ static char *concat_string_list (char **t, int *bytes)
break;
if (!(t[n][0]))
break;
strcpy (s + l, t[n]);
l += strlen (t[n]) + 1;
int t_size = strlen (t[n]) + 1;
memcpy (s + l, t[n], t_size);
l += t_size;
}
*bytes = l;
s[l] = '\0';
Expand Down
5 changes: 3 additions & 2 deletions intern/cycles/device/hiprt/device_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ HIPRTDevice::HIPRTDevice(const DeviceInfo &info, Stats &stats, Profiler &profile
set_error(string_printf("Failed to create HIPRT Function Table"));
return;
}

hiprtSetLogLevel(hiprtLogLevelNone);
}

HIPRTDevice::~HIPRTDevice()
Expand Down Expand Up @@ -261,8 +263,7 @@ string HIPRTDevice::compile_kernel(const uint kernel_features, const char *name,
linker_options.append(" --offload-arch=").append(arch);
linker_options.append(" -fgpu-rdc --hip-link --cuda-device-only ");
string hiprt_ver(HIPRT_VERSION_STR);
string hiprt_bc;
hiprt_bc = hiprt_path + "\\hiprt" + hiprt_ver + "_amd_lib_win.bc";
string hiprt_bc = hiprt_path + "\\dist\\bin\\Release\\hiprt" + hiprt_ver + "_amd_lib_win.bc";

string linker_command = string_printf("clang++ %s \"%s\" %s -o \"%s\"",
linker_options.c_str(),
Expand Down
2 changes: 2 additions & 0 deletions intern/cycles/device/hiprt/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ bool HIPRTDeviceQueue::enqueue(DeviceKernel kernel,
0),
"enqueue");

debug_enqueue_end();

return !(hiprt_device_->have_error());
}

Expand Down
10 changes: 5 additions & 5 deletions intern/cycles/kernel/device/hiprt/bvh.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
GET_TRAVERSAL_STACK()

if (visibility & PATH_RAY_SHADOW_OPAQUE) {
GET_TRAVERSAL_ANY_HIT(table_closest_intersect, 0)
GET_TRAVERSAL_ANY_HIT(table_closest_intersect, 0, ray->time)
hit = traversal.getNextHit();
}
else {
GET_TRAVERSAL_CLOSEST_HIT(table_closest_intersect, 0)
GET_TRAVERSAL_CLOSEST_HIT(table_closest_intersect, 0, ray->time)
hit = traversal.getNextHit();
}
if (hit.hasHit()) {
Expand Down Expand Up @@ -157,13 +157,13 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
payload.in_state = state;
payload.max_hits = max_hits;
payload.visibility = visibility;
payload.prim_type = PRIMITIVE_TRIANGLE;
payload.prim_type = PRIMITIVE_NONE;
payload.ray_time = ray->time;
payload.num_hits = 0;
payload.r_num_recorded_hits = num_recorded_hits;
payload.r_throughput = throughput;
GET_TRAVERSAL_STACK()
GET_TRAVERSAL_ANY_HIT(table_shadow_intersect, 1)
GET_TRAVERSAL_ANY_HIT(table_shadow_intersect, 1, ray->time)
hiprtHit hit = traversal.getNextHit();
num_recorded_hits = payload.r_num_recorded_hits;
throughput = payload.r_throughput;
Expand Down Expand Up @@ -201,7 +201,7 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg,

GET_TRAVERSAL_STACK()

GET_TRAVERSAL_CLOSEST_HIT(table_volume_intersect, 3)
GET_TRAVERSAL_CLOSEST_HIT(table_volume_intersect, 3, ray->time)
hiprtHit hit = traversal.getNextHit();
// return hit.hasHit();
if (hit.hasHit()) {
Expand Down
21 changes: 9 additions & 12 deletions intern/cycles/kernel/device/hiprt/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,45 +53,42 @@ struct LocalPayload {
# endif

# ifdef HIPRT_SHARED_STACK
# define GET_TRAVERSAL_ANY_HIT(FUNCTION_TABLE, RAY_TYPE) \
# define GET_TRAVERSAL_ANY_HIT(FUNCTION_TABLE, RAY_TYPE, RAY_TIME) \
hiprtSceneTraversalAnyHitCustomStack<Stack> traversal(kernel_data.device_bvh, \
ray_hip, \
stack, \
visibility, \
hiprtTraversalHintDefault, \
&payload, \
kernel_params.FUNCTION_TABLE, \
RAY_TYPE); \
hiprtSceneTraversalAnyHitCustomStack<Stack> traversal_simple( \
kernel_data.device_bvh, ray_hip, stack, visibility);
# define GET_TRAVERSAL_CLOSEST_HIT(FUNCTION_TABLE, RAY_TYPE) \
RAY_TYPE, \
RAY_TIME);

# define GET_TRAVERSAL_CLOSEST_HIT(FUNCTION_TABLE, RAY_TYPE, RAY_TIME) \
hiprtSceneTraversalClosestCustomStack<Stack> traversal(kernel_data.device_bvh, \
ray_hip, \
stack, \
visibility, \
hiprtTraversalHintDefault, \
&payload, \
kernel_params.FUNCTION_TABLE, \
RAY_TYPE); \
hiprtSceneTraversalClosestCustomStack<Stack> traversal_simple( \
kernel_data.device_bvh, ray_hip, stack, visibility);
RAY_TYPE, \
RAY_TIME);
# else
# define GET_TRAVERSAL_ANY_HIT(FUNCTION_TABLE) \
hiprtSceneTraversalAnyHit traversal(kernel_data.device_bvh, \
ray_hip, \
visibility, \
FUNCTION_TABLE, \
hiprtTraversalHintDefault, \
&payload); \
hiprtSceneTraversalAnyHit traversal_simple(kernel_data.device_bvh, ray_hip, visibility);
&payload);
# define GET_TRAVERSAL_CLOSEST_HIT(FUNCTION_TABLE) \
hiprtSceneTraversalClosest traversal(kernel_data.device_bvh, \
ray_hip, \
visibility, \
FUNCTION_TABLE, \
hiprtTraversalHintDefault, \
&payload); \
hiprtSceneTraversalClosest traversal_simple(kernel_data.device_bvh, ray_hip, visibility);
&payload);
# endif

ccl_device_inline void set_intersect_point(KernelGlobals kg,
Expand Down
4 changes: 3 additions & 1 deletion intern/cycles/kernel/integrator/mnee.h
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,9 @@ ccl_device_forceinline bool mnee_path_contribution(KernelGlobals kg,
surface_shader_bsdf_eval(kg, state, sd, wo, throughput, ls->shader);

/* Update light sample with new position / direction and keep pdf in vertex area measure. */
light_sample_update(kg, ls, vertices[vertex_count - 1].p);
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
light_sample_update(
kg, ls, vertices[vertex_count - 1].p, vertices[vertex_count - 1].n, path_flag);

/* Save state path bounce info in case a light path node is used in the refractive interface or
* light shader graph. */
Expand Down
10 changes: 7 additions & 3 deletions intern/cycles/kernel/integrator/shade_dedicated_light.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ccl_device_inline bool shadow_linking_light_sample_from_intersection(
KernelGlobals kg,
ccl_private const Intersection &ccl_restrict isect,
ccl_private const Ray &ccl_restrict ray,
const float3 N,
const uint32_t path_flag,
ccl_private LightSample *ccl_restrict ls)
{
const int lamp = isect.prim;
Expand All @@ -31,7 +33,7 @@ ccl_device_inline bool shadow_linking_light_sample_from_intersection(
return distant_light_sample_from_intersection(kg, ray.D, lamp, ls);
}

return light_sample_from_intersection(kg, &isect, ray.P, ray.D, ls);
return light_sample_from_intersection(kg, &isect, ray.P, ray.D, N, path_flag, ls);
}

ccl_device_inline float shadow_linking_light_sample_mis_weight(KernelGlobals kg,
Expand Down Expand Up @@ -88,8 +90,11 @@ ccl_device bool shadow_linking_shade_light(KernelGlobals kg,
ccl_private float &mis_weight,
ccl_private int &ccl_restrict light_group)
{
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
LightSample ls ccl_optional_struct_init;
const bool use_light_sample = shadow_linking_light_sample_from_intersection(kg, isect, ray, &ls);
const bool use_light_sample = shadow_linking_light_sample_from_intersection(
kg, isect, ray, N, path_flag, &ls);
if (!use_light_sample) {
/* No light to be sampled, so no direct light contribution either. */
return false;
Expand All @@ -100,7 +105,6 @@ ccl_device bool shadow_linking_shade_light(KernelGlobals kg,
return false;
}

const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
if (!is_light_shader_visible_to_path(ls.shader, path_flag)) {
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions intern/cycles/kernel/integrator/shade_light.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ ccl_device_inline void integrate_light(KernelGlobals kg,
float3 ray_P = INTEGRATOR_STATE(state, ray, P);
const float3 ray_D = INTEGRATOR_STATE(state, ray, D);
const float ray_time = INTEGRATOR_STATE(state, ray, time);
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);

/* Advance ray to new start distance. */
INTEGRATOR_STATE_WRITE(state, ray, tmin) = intersection_t_offset(isect.t);

LightSample ls ccl_optional_struct_init;
const bool use_light_sample = light_sample_from_intersection(kg, &isect, ray_P, ray_D, &ls);
const bool use_light_sample = light_sample_from_intersection(
kg, &isect, ray_P, ray_D, N, path_flag, &ls);

if (!use_light_sample) {
return;
}

/* Use visibility flag to skip lights. */
#ifdef __PASSES__
const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
if (!is_light_shader_visible_to_path(ls.shader, path_flag)) {
return;
}
Expand Down
17 changes: 15 additions & 2 deletions intern/cycles/kernel/light/distribution.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ ccl_device_noinline bool light_distribution_sample(KernelGlobals kg,
const float3 rand,
const float time,
const float3 P,
const float3 N,
const int object_receiver,
const int shader_flags,
const int bounce,
const uint32_t path_flag,
ccl_private LightSample *ls)
Expand All @@ -56,8 +58,19 @@ ccl_device_noinline bool light_distribution_sample(KernelGlobals kg,
const int index = light_distribution_sample(kg, rand.z);
const float pdf_selection = kernel_data.integrator.distribution_pdf_lights;
const float2 rand_uv = float3_to_float2(rand);
return light_sample<in_volume_segment>(
kg, rand_uv, time, P, object_receiver, bounce, path_flag, index, 0, pdf_selection, ls);
return light_sample<in_volume_segment>(kg,
rand_uv,
time,
P,
N,
object_receiver,
shader_flags,
bounce,
path_flag,
index,
0,
pdf_selection,
ls);
}

ccl_device_inline float light_distribution_pdf_lamp(KernelGlobals kg)
Expand Down
12 changes: 9 additions & 3 deletions intern/cycles/kernel/light/light.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ ccl_device_inline bool light_sample(KernelGlobals kg,
const int lamp,
const float2 rand,
const float3 P,
const float3 N,
const int shader_flags,
const uint32_t path_flag,
ccl_private LightSample *ls)
{
Expand Down Expand Up @@ -150,7 +152,7 @@ ccl_device_inline bool light_sample(KernelGlobals kg,
}
}
else if (type == LIGHT_POINT) {
if (!point_light_sample<in_volume_segment>(klight, rand, P, ls)) {
if (!point_light_sample(klight, rand, P, N, shader_flags, ls)) {
return false;
}
}
Expand All @@ -171,7 +173,9 @@ ccl_device_noinline bool light_sample(KernelGlobals kg,
const float2 rand,
const float time,
const float3 P,
const float3 N,
const int object_receiver,
const int shader_flags,
const int bounce,
const uint32_t path_flag,
const int emitter_index,
Expand Down Expand Up @@ -233,7 +237,7 @@ ccl_device_noinline bool light_sample(KernelGlobals kg,
return false;
}

if (!light_sample<in_volume_segment>(kg, light, rand, P, path_flag, ls)) {
if (!light_sample<in_volume_segment>(kg, light, rand, P, N, shader_flags, path_flag, ls)) {
return false;
}
}
Expand Down Expand Up @@ -446,6 +450,8 @@ ccl_device bool light_sample_from_intersection(KernelGlobals kg,
ccl_private const Intersection *ccl_restrict isect,
const float3 ray_P,
const float3 ray_D,
const float3 N,
const uint32_t path_flag,
ccl_private LightSample *ccl_restrict ls)
{
const int lamp = isect->prim;
Expand All @@ -468,7 +474,7 @@ ccl_device bool light_sample_from_intersection(KernelGlobals kg,
}
}
else if (type == LIGHT_POINT) {
if (!point_light_sample_from_intersection(klight, isect, ray_P, ray_D, ls)) {
if (!point_light_sample_from_intersection(klight, isect, ray_P, ray_D, N, path_flag, ls)) {
return false;
}
}
Expand Down
Loading

0 comments on commit 63e503a

Please sign in to comment.