IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to debug the shader code?, No debug ,no developer!
Wang Wei
post Nov 7 2009, 11:39 PM
Post #1


Newbie
*

Group: Members
Posts: 1
Joined: 7-November 09
Member No.: 9,783



Hi,the optix is great work, the API is ingenious!
I read the guide and try some work,it seem can do many different job.
but it is annoying to write really work code without debuging tools.
for example
I try add mirror shade to the path_tracer demo program.
first , i replace two box with two sphere and use diffuse material, it work fine.
then i write a simple mirror shade,just like this

RT_PROGRAM void mirror()
{
float3 world_shading_normal = normalize( rtTransformNormal( RT_OBJECT_TO_WORLD, shading_normal ) );
float3 world_geometric_normal = normalize( rtTransformNormal( RT_OBJECT_TO_WORLD, geometric_normal ) );
float3 ffnormal = faceforward( world_shading_normal, -ray.direction, world_geometric_normal );
float3 hitpoint = ray.origin + t_hit * ray.direction;
current_prd.direction = reflect(ray.direction,ffnormal);
current_prd.origin = hitpoint + current_prd.direction * 1e-2 ;
current_prd.attenuation = current_prd.attenuation * make_float3(0.99f);
current_prd.countEmitted = true;
current_prd.radiance = make_float3(0.0f);
}
it is very simple,is it?
but.. the program is crash and give a error "lanugh time out",
oh, maybe a forever loop exist?
i guess and guess ,
try and try,
finally i find when i set
current_prd.attenuation = current_prd.attenuation * make_float3(0.8f);
it Work.
but i still don't know Why!
are there any debug tools that could make me step into code,trace line ,watch vars?
I know cuda have a emu mode, does Optix have it ?
or what debugging method you guys use?
Thanks.
Go to the top of the page
 
+Quote Post
Austin Robison
post Nov 9 2009, 06:24 PM
Post #2


Advanced Member
***

Group: Moderators
Posts: 11
Joined: 25-August 09
Member No.: 9,146



Hi,

We're working hard on creating debugging tools that will make writing OptiX programs easier. One such tool that exists in the API already is the rtPrintf() call that you can make from inside of your OptiX programs (be sure to enable it with the corresponding C API call, rtContextSetPrintEnabled()). You can use rtPrintf() to output text to the console from one or more of your launch indicies.

Launch timeouts occur when your OptiX device is also being used as a display device and runs for too long (just like CUDA). By having your mirror shaders attentuation be set to .99 you end up with more rays bouncing around your scene. The russian roulette algorithm in the path tracer is more likely to stop tracing a path when the path's attenuation is small. Setting your mirror rays to .99 will keep the paths around for longer, on average, and will increase the runtime of your kernel. When you set the attenuation to .8 you decreased the length of those paths and decreased the runtime of the kernel to be below the limit. Hope that helps!

~Austin
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Copyright © 2008 NVIDIA® Corporation.  Terms of Use | Legal Info | Privacy Policy Time is now: 23rd November 2009 - 05:37 PM