Structure problem

Hi everybody,

I’m currently facing a strange problem :

I define a perRayData structure and declare a variable :

struct PerRayData_test
{
float3 a;
float3 b;
};

rtDeclareVariable(PerRayData_test, prd_test, rtPayload, );

The following initialization in a any_hit_program makes my program crash:

prd_test.a = make_float3(0);
prd_test.b = make_float3(0);

with error :

OptiX Error: Unknown error (Details: Function “_rtContextLaunch2D” caught except
ion: Encountered a CUDA error: Kernel launch returned (999): Unknown, [6619200]).

After debugging instruction by instruction it seems that the second initialization causes the crash.
So I modify my structure in the following way :

struct PerRayData_test
{
float a1;
float a2;
float a3;
float b1;
float b2;
float b3;
};

and modify the lines :

prd_test.a1 = 0;
prd_test.a2 = 0;
prd_test.a3 = 0;
prd_test.b1 = 0;
prd_test.b2 = 0;
prd_test.b3 = 0;

The program crashes on the initialization of b3 with the same error…
But when I separate a and b in two different structures (each containing a float3), the program works oO !!

Please can you explain me this strange behaviour ?? Thanks.

Please always provide at least the following information on problem reports to reduce turnaround times:
Operating system, bitness, OptiX version, CUDA Toolkit version, graphics board(s), display driver version.

Please read the OptiX release notes to verify if you used a supported combination of tools (e.g. OptiX 3.0.1 with CUDA 5.5 or 6.0 is not supported.)
Do not use debug flags (-G -g) on the nvcc command line.

Thanks for your answer,

I’m working under windows 7 64bits, my code is compiled in 64 bits too. I use optix v3.0.1 with cuda 5.5. My graphics card is a GTX670MX and my display driver is v320.57.

I’m now confronted to a new problem :
I want to use the optix textureSampler3D. So I declare it in this way :

RT_CHECK_ERROR(rtTextureSamplerCreate(context, &textureSampler));
RT_CHECK_ERROR(rtTextureSamplerSetIndexingMode(textureSampler, RT_TEXTURE_INDEX_NORMALIZED_COORDINATES));
RT_CHECK_ERROR(rtTextureSamplerSetReadMode(textureSampler, RT_TEXTURE_READ_NORMALIZED_FLOAT));
RT_CHECK_ERROR(rtTextureSamplerSetMipLevelCount(textureSampler, 1u));
RT_CHECK_ERROR(rtTextureSamplerSetMaxAnisotropy(textureSampler, 1.0f));
RT_CHECK_ERROR(rtTextureSamplerSetArraySize(textureSampler, (unsigned int)tex_depth));

for(i=0;i<tex_depth;i++){

RT_CHECK_ERROR(rtTextureSamplerSetBuffer(textureSampler, (unsigned int)i, 0, texture3D[i]));

}

RT_CHECK_ERROR(rtTextureSamplerSetFilteringModes(textureSampler, RT_FILTER_LINEAR, RT_FILTER_LINEAR, RT_FILTER_NONE));

RT_CHECK_ERROR(rtContextDeclareVariable(context, “textureSampler”, &textureSampler_variable));
RT_CHECK_ERROR(rtVariableSetObject(textureSampler_variable, textureSampler));

RT_CHECK_ERROR(rtTextureSamplerValidate(textureSampler));

where texture3D is a RTbuffer containing ‘tex_depth’ slices (247) of size (416x416).

But I faced the following error when the program starts :

OptiX Error: Invalid value (Details: Function “_rtContextLaunch2D” caught except
ion: Encountered a CUDA error: driver().cuArray3DCreate(&m_array, &ad) returned
(1): Invalid value, [7667808])
(…\sampleBox\sample5.c:113)

any idea ?

That would have been the problem. This is NOT a supported CUDA Toolkit version for OptiX 3.0.1.
Please use CUDA Toolkit 5.0 instead.

On the new problem, filling the 3D texture should only have one single call to setBuffer().
Something like this with contiguous source data and a CUDA-supported data format:

rtTextureSamplerSetBuffer(textureSampler, 0, 0, texture3D);

Note that CUDA only supports 1-, 2-, and 4-component textures! That is, RGB needs to be expanded to RGBA.
There is no support for texture arrays or mipmaps in OptiX. You tried to upload a 3D texture array from slices.

This is still true with Optix 3.5.1?

Can I call this function “rtTextureSamplerSetBuffer” with “texture_array_idx” > 0 ?

RTresult RTAPI rtTextureSamplerSetBuffer(	
  RTtexturesampler 	texturesampler,
  unsigned int 	texture_array_idx,
  unsigned int 	mip_level,
  RTbuffer 	buffer 
)

Thx
AD

Still unsupported.
The more flexible way to handle an arbitrary number of textures are bindless textures which run in hardware on Kepler GPUs (and newer once supported). See OptiX example rayDifferentials.

Thank you for the reply.

One more question: What happen if i try to use bindless textures wit a GPU older than Kepler? I get an error or there is only a performance issue (slower execution)?

AD

Straight from the OptiX Programming Guide:
While OptiX supports bindless texture access on all architectures, hardware supported bindless textures are only available on Kepler (sm_30) devices and above with 304 driver.
On pre-Kepler devices, bindless texture references are handled in software and may be slower compared to regularly bound textures.