Answer the question
In order to leave comments, you need to log in
How to optimize CUDA?
There is a piece of code, as for me it is quite simple, but it takes as long as 5 milliseconds, somehow this is a lot, as for parallel computing.
__global__ void kernel_compute_global_lighting(float* device_lenght_buff, CudaRenderWindow render_window, CudaRenderCamera camera, CudaRenderMap map, CudaRenderTextures textures, CudaRenderLight lights) {
int pixel_coordinate_y = blockIdx.x * blockDim.x + threadIdx.x;
int pixel_coordinate_x = blockIdx.y * blockDim.y + threadIdx.y;
if (pixel_coordinate_y >= render_window.render_height || pixel_coordinate_x >= render_window.render_width)
return;
render_window.device_rendered_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].r = render_window.device_render_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].r * lights.device_light_pointers[0]->r;
render_window.device_rendered_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].g = render_window.device_render_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].g * lights.device_light_pointers[0]->g;
render_window.device_rendered_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].b = render_window.device_render_window[pixel_coordinate_y*render_window.render_width + pixel_coordinate_x].b * lights.device_light_pointers[0]->b;
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question