Results 1 to 3 of 3

Thread: Function Question

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    18

    Function Question

    Hi,

    this is probably a really stupid question, but I'm having problems with a simple function-call in an OpenCL Kernel.

    Here's the code:
    Code :
    const float PI = 3.14159265359;
    const float TWOPI = 6.28318530718;
     
    float4 makeSphere(float4 pos, float radius) {
     
    	float u = pos.x * TWOPI;
    	float v = pos.y * PI;
     
    	float4 sphere;
    	sphere.x = radius * cos(u) * sin(v);
    	sphere.y = radius * css(u) * sin(v);
    	sphere.z = radius * cos(v);
    	sphere.w = 1.0;
     
    	return sphere;
    }
     
     
    __kernel void read_rgba8888(__rd image2d_t BaseImg, float Width, float Height, float Displacement,
    						__global float4 *Mesh, __global float4 *Colors)
    {
    	// Get values for current iteration
    	int		tid_x = get_global_id(0),
    			tid_y = get_global_id(1),
    			indx = tid_y * get_global_size(0) + tid_x;
     
    	// Init variables		
    	float4 color, vertex;
    	//int2   pos = (int2)(tid_x, tid_y);
    	// Floating-point position in 0 > 1 range
    	float4 posFloat = (float4)((float)tid_x / Width, (float)tid_y / Height, 0.0, 1.0); 
     
     
    	sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;
     
    	// Sample colour from base image
    	color = read_imagef(BaseImg, smp, (int2)(tid_x, tid_y));
     
    	// Write color at index in Colors output array
    	Colors[indx] = color;
     
    	// Displacement is determined by the displacement amount * the "length" of the color vector (ie approximate brightness)
    	/*vertex =	(float4)
    				((float)tid_x / get_global_size(0) - 0.5,
    				1.0 - (float)tid_y / get_global_size(1) - 0.5,
    				Displacement * length(color.xyzw), 1.0);*/
     
     
    	// Write mesh value at index of Mesh output array
    	Mesh[indx] = makeSphere(posFloat, 0.5);
    }

    It's obviously just supposed to bend the vertices around into a sphere, but I get an error
    kernel referenced an external function css, that can not be found
    I'm sure it's something very simple I'm doing wrong...

    Anyone any advice?

    a|x
    http://machinesdontcare.wordpress.com

  2. #2
    Junior Member
    Join Date
    Oct 2009
    Posts
    18

    Re: Function Question

    Sorry to have wasted your time guys- it was a typo....


    I was thinking 'css' meant something other than a mistyping of 'cos'

    a|x

  3. #3
    Senior Member
    Join Date
    Jul 2009
    Location
    Northern Europe
    Posts
    311

    Re: Function Question

    You should be able to get the line number of the error by requesting the build log back from clGetProgramBuildInfo.

Similar Threads

  1. Replies: 4
    Last Post: 08-22-2011, 03:51 AM
  2. external function?
    By anotherJohn in forum OpenCL
    Replies: 2
    Last Post: 04-23-2010, 03:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •