On Fri, May 13, 2016 at 7:26 AM, Param Hanji <param.catchch...@gmail.com>
wrote:

> Yup, thanks a lot! one more thing.
>
> I tried to figure where the weave function is called. This brought me to 2
> files - bundle.c and shoot.c. The documentation states that rt_shootray()
> is the primary shot coordinator. I guessed that rt_shootray_bundle() (in
> bundle.c) does the same, but for several rays (the per ray parallelization
> you mentioned). Is this correct?
>

Correct. That is the ANSI C code path of librt.

You should focus on the rt_shootray() code path.
rt_shootray_bundle() was designed mainly for a SIMD vector architecture.
The OpenCL model is SIMT so that code style is not necessarily the most
elegant or optimal.

The pseudo-code below is a simplification of the important parts of librt
ANSI C rt_shootray():

--- shoot.c

    BU_LIST_INIT(&new_segs.l);
    BU_LIST_INIT(&waiting_segs.l);
    BU_LIST_INIT(&finished_segs.l);

    struct soltab *stp;

    for (stp : solids) {
        stp->st_meth->ft_shot(stp, &ss.newray, ap, &new_segs);
    }


    struct seg *s2;

    while (BU_LIST_WHILE(s2, seg, &(new_segs.l))) {
        BU_LIST_DEQUEUE(&(s2->l));
        ...
        BU_LIST_INSERT(&(waiting_segs.l), &(s2->l));
    }

    if (BU_LIST_NON_EMPTY(&(waiting_segs.l))) {
        rt_boolweave(&finished_segs, &waiting_segs, &InitialPart, ap);
    }

    if (!BU_LIST_IS_EMPTY(&(finished_segs.l))) {
        rt_boolfinal(&InitialPart, &FinalPart, BACKING_DIST,
                     INFINITY,
    }                regionbits, ap, solidbits);

---

The ray shooting in the OpenCL librt is done in primitives/primitive_util.c
in function clt_frame(). The clt_frame() function invokes a kernel with a
thread per pixel, shooting a ray per pixel, to generate a whole image
frame.

there are two image generation modes:
- immediate:
  do_pixel() (in rt.cl) calls the shootray() function to determine the
closest intersection along the ray path and returns the output color.
- stored:
  count_hits() (in rt.cl) counts the number of intersections along the ray
path. a buffer is allocated to store all the intersection results.
store_segs()  stores the intersection results (segment lists) for all rays.
Then the output color is determined via the shading kernel shade_segs().

You are going to be interested in working in the 'stored' mode because you
will need the segment list data. The stored mode can be activated by
passing '-l 5' as a command line argument to the 'rt' program while it's in
OpenCL mode i.e. '-z 1'.

Regards,

-- 
Vasco Alexandre da Silva Costa
PhD in Computer Engineering (Computer Graphics)
Instituto Superior Técnico/University of Lisbon, Portugal
------------------------------------------------------------------------------
Mobile security can be enabling, not merely restricting. Employees who
bring their own devices (BYOD) to work are irked by the imposition of MDM
restrictions. Mobile Device Manager Plus allows you to control only the
apps on BYO-devices by containerizing them, leaving personal data untouched!
https://ad.doubleclick.net/ddm/clk/304595813;131938128;j
_______________________________________________
BRL-CAD Developer mailing list
brlcad-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-devel

Reply via email to