Skip to content

Commit 422845f

Browse files
committed
Fix code conformance in BDPT kernels
1 parent 8846466 commit 422845f

File tree

1 file changed

+41
-44
lines changed

1 file changed

+41
-44
lines changed

App/CL/integrator_bdpt.cl

Lines changed: 41 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ KERNEL void SampleSurface(
181181
// Ray batch
182182
GLOBAL ray const* rays,
183183
// Intersection data
184-
GLOBAL Intersection const* isects,
184+
GLOBAL Intersection const* intersections,
185185
// Hit indices
186186
GLOBAL int const* hit_indices,
187187
// Pixel indices
@@ -253,7 +253,7 @@ KERNEL void SampleSurface(
253253
// Fetch index
254254
int hit_idx = hit_indices[global_id];
255255
int pixel_idx = pixel_indices[global_id];
256-
Intersection isect = isects[hit_idx];
256+
Intersection isect = intersections[hit_idx];
257257

258258
GLOBAL Path* path = paths + pixel_idx;
259259

@@ -404,7 +404,7 @@ KERNEL void SampleSurface(
404404
}
405405
}
406406

407-
__kernel void ConnectDirect(
407+
KERNEL void ConnectDirect(
408408
int eye_vertex_index,
409409
int num_rays,
410410
GLOBAL int const* pixel_indices,
@@ -508,8 +508,8 @@ KERNEL void SampleSurface(
508508

509509
bool singular_light = Light_IsSingular(&scene.lights[light_idx]);
510510
bool singular_bxdf = Bxdf_IsSingular(&diffgeo);
511-
lightweight = 1;// singular_light ? 1.f : BalanceHeuristic(1, lightpdf, 1, lightbxdfpdf);
512-
bxdfweight = 1;// singular_bxdf ? 1.f : BalanceHeuristic(1, bxdfpdf, 1, bxdflightpdf);
511+
lightweight = singular_light ? 1.f : BalanceHeuristic(1, lightpdf, 1, lightbxdfpdf);
512+
bxdfweight = singular_bxdf ? 1.f : BalanceHeuristic(1, bxdfpdf, 1, bxdflightpdf);
513513

514514
float3 radiance = 0.f;
515515
float3 wo;
@@ -770,45 +770,42 @@ KERNEL void GenerateTileDomain(
770770
}
771771

772772
///< Restore pixel indices after compaction
773-
__kernel void FilterPathStream(
774-
// Intersections
775-
__global Intersection const* isects,
773+
KERNEL void FilterPathStream(
774+
GLOBAL Intersection const* restrict intersections,
776775
// Number of compacted indices
777-
__global int const* numitems,
778-
// Pixel indices
779-
__global int const* pixelindices,
780-
// Paths
781-
__global Path* paths,
782-
// Predicate
783-
__global int* predicate
776+
GLOBAL int const* restrict num_items,
777+
GLOBAL int const* restrict pixel_indices,
778+
GLOBAL Path* restrict paths,
779+
// 1 or 0 for each item (include or exclude)
780+
GLOBAL int* restrict predicate
784781
)
785782
{
786-
int globalid = get_global_id(0);
783+
int global_id = get_global_id(0);
787784

788785
// Handle only working subset
789-
if (globalid < *numitems)
786+
if (global_id < *num_items)
790787
{
791-
int pixelidx = pixelindices[globalid];
788+
int pixelidx = pixel_indices[global_id];
792789

793-
__global Path* path = paths + pixelidx;
790+
GLOBAL Path* path = paths + pixelidx;
794791

795792
if (Path_IsAlive(path))
796793
{
797794
bool kill = (length(Path_GetThroughput(path)) < CRAZY_LOW_THROUGHPUT);
798795

799796
if (!kill)
800797
{
801-
predicate[globalid] = isects[globalid].shapeid >= 0 ? 1 : 0;
798+
predicate[global_id] = intersections[global_id].shapeid >= 0 ? 1 : 0;
802799
}
803800
else
804801
{
805802
Path_Kill(path);
806-
predicate[globalid] = 0;
803+
predicate[global_id] = 0;
807804
}
808805
}
809806
else
810807
{
811-
predicate[globalid] = 0;
808+
predicate[global_id] = 0;
812809
}
813810
}
814811
}
@@ -838,7 +835,7 @@ KERNEL void GatherContributions(
838835
int num_rays,
839836
GLOBAL int const* restrict pixel_indices,
840837
// Shadow rays hits
841-
GLOBAL int const* restrict shadowhits,
838+
GLOBAL int const* restrict shadow_hits,
842839
// Light samples
843840
GLOBAL float3 const* restrict contributions,
844841
// Radiance sample buffer
@@ -856,7 +853,7 @@ KERNEL void GatherContributions(
856853
// Start collecting samples
857854
{
858855
// If shadow ray global_id't hit anything and reached skydome
859-
if (shadowhits[global_id] == -1)
856+
if (shadow_hits[global_id] == -1)
860857
{
861858
// Add its contribution to radiance accumulator
862859
radiance += contributions[global_id];
@@ -866,46 +863,46 @@ KERNEL void GatherContributions(
866863
}
867864
}
868865

869-
///< Restore pixel indices after compaction
870-
__kernel void RestorePixelIndices(
866+
// Restore pixel indices after compaction
867+
KERNEL void RestorePixelIndices(
871868
// Compacted indices
872-
__global int const* compacted_indices,
869+
GLOBAL int const* restrict compacted_indices,
873870
// Number of compacted indices
874-
__global int* numitems,
871+
GLOBAL int* restrict num_items,
875872
// Previous pixel indices
876-
__global int const* previndices,
873+
GLOBAL int const* restrict prev_indices,
877874
// New pixel indices
878-
__global int* newindices
875+
GLOBAL int* restrict new_indices
879876
)
880877
{
881-
int globalid = get_global_id(0);
878+
int global_id = get_global_id(0);
882879

883880
// Handle only working subset
884-
if (globalid < *numitems)
881+
if (global_id < *num_items)
885882
{
886-
newindices[globalid] = previndices[compacted_indices[globalid]];
883+
new_indices[global_id] = prev_indices[compacted_indices[global_id]];
887884
}
888885
}
889886

890887
// Copy data to interop texture if supported
891-
__kernel void ApplyGammaAndCopyData(
892-
__global float4 const* data,
893-
int imgwidth,
894-
int imgheight,
888+
KERNEL void ApplyGammaAndCopyData(
889+
//
890+
GLOBAL float4 const* data,
891+
int width,
892+
int height,
895893
float gamma,
896894
write_only image2d_t img
897895
)
898896
{
899-
int gid = get_global_id(0);
900-
901-
int gidx = gid % imgwidth;
902-
int gidy = gid / imgwidth;
897+
int global_id = get_global_id(0);
898+
int x = global_id % width;
899+
int y = global_id / width;
903900

904-
if (gidx < imgwidth && gidy < imgheight)
901+
if (x < width && y < height)
905902
{
906-
float4 v = data[gid];
903+
float4 v = data[global_id];
907904
float4 val = clamp(native_powr(v / v.w, 1.f / gamma), 0.f, 1.f);
908-
write_imagef(img, make_int2(gidx, gidy), val);
905+
write_imagef(img, make_int2(x, y), val);
909906
}
910907
}
911908

0 commit comments

Comments
 (0)