Skip to content

Commit

Permalink
Trying to find where the shader fails
Browse files Browse the repository at this point in the history
  • Loading branch information
ViktorWalter committed Feb 28, 2024
1 parent 0de96d4 commit 67595d7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/compute_lib/compute_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ static const EGLint egl_config_attribs_gbm[] = {
EGL_NONE };
static const EGLint egl_config_attribs_surfaceless[] = {
EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,
EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT_KHR,
EGL_BLUE_SIZE, 8,
EGL_GREEN_SIZE, 8,
EGL_RED_SIZE, 8,
Expand Down
33 changes: 27 additions & 6 deletions include/detect/uv_led_detect_fast_gpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void uvdar::UVDARLedDetectFASTGPU::init() {
//compute_lib_program_print_resources(&compute_prog);

// init image2d objects
texture_in = COMPUTE_LIB_IMAGE2D_NEW("image_in", GL_TEXTURE0, image_size.width, image_size.height, GL_R8UI, GL_READ_ONLY, GL_CLAMP_TO_EDGE, GL_LINEAR, GL_RED_INTEGER, GL_UNSIGNED_BYTE);
texture_in = COMPUTE_LIB_IMAGE2D_NEW("image_in", GL_TEXTURE0, image_size.width, image_size.height, GL_R8UI, GL_READ_ONLY, GL_CLAMP_TO_EDGE, GL_LINEAR, GL_RED_INTEGER, GL_UNSIGNED_BYTE);
if (compute_lib_image2d_init(&compute_prog, &texture_in, 0)) {
fprintf(stderr, "Failed to create image2d '%s'!\r\n", texture_in.uniform_name);
compute_lib_error_queue_flush(&compute_inst, stderr);
Expand Down Expand Up @@ -166,17 +166,38 @@ bool uvdar::UVDARLedDetectFASTGPU::processImage(const cv::Mat i_image, std::vect
compute_lib_image2d_write(&compute_prog, &mask, (mask_id>=0)?masks_[mask_id].data:nullptr);

// dispatch compute shader
compute_lib_program_dispatch(&compute_prog, image_size.width / local_size_x, image_size.height / local_size_y, 1);
if ( compute_lib_program_dispatch(&compute_prog, image_size.width / local_size_x, image_size.height / local_size_y, 1)){
std::cerr << "[UVDARDetectorFASTGPU]: Failed to dispatch the shader!" << std::endl;
return false;
}

// retrieve detected markers
compute_lib_acbo_read_uint_val(&compute_prog, &markers_count_acbo, &markers_cnt_val);
if ( compute_lib_acbo_read_uint_val(&compute_prog, &markers_count_acbo, &markers_cnt_val)){
std::cerr << "[UVDARDetectorFASTGPU]: Failed to extract the marker count!" << std::endl;
return false;
}
if (markers_cnt_val > max_markers_count) markers_cnt_val = max_markers_count;
if (markers_cnt_val > 0) compute_lib_ssbo_read(&compute_prog, &markers_ssbo, (void*) markers, markers_cnt_val);
if (markers_cnt_val > 0)
{
if ( compute_lib_ssbo_read(&compute_prog, &markers_ssbo, (void*) markers, markers_cnt_val)){
std::cerr << "[UVDARDetectorFASTGPU]: Failed to extract the marker SSBO!" << std::endl;
return false;
}
}

// retrieve detected sun points
compute_lib_acbo_read_uint_val(&compute_prog, &sun_pts_count_acbo, &sun_points_cnt_val);
if (compute_lib_acbo_read_uint_val(&compute_prog, &sun_pts_count_acbo, &sun_points_cnt_val)){
std::cerr << "[UVDARDetectorFASTGPU]: Failed to extract the marker count!" << std::endl;
return false;
}
if (sun_points_cnt_val > max_sun_pts_count) sun_points_cnt_val = max_sun_pts_count;
if (sun_points_cnt_val > 0) compute_lib_ssbo_read(&compute_prog, &sun_pts_ssbo, (void*) sun_pts, sun_points_cnt_val);
if (sun_points_cnt_val > 0)
{
if (compute_lib_ssbo_read(&compute_prog, &sun_pts_ssbo, (void*) sun_pts, sun_points_cnt_val)){
std::cerr << "[UVDARDetectorFASTGPU]: Failed to extract the marker SSBO!" << std::endl;
return false;
}
}

// find centroids of concentrated detected markers
cpuFindMarkerCentroids(markers, markers_cnt_val, 5, detected_points);
Expand Down

0 comments on commit 67595d7

Please sign in to comment.