Files
fn_registry/cpp/functions/gfx/gpu_check.md
T
egutierrez 47fac22230 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

3.5 KiB

name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, tested, tests, test_file_path, file_path, framework, params, output
name kind lang domain version purity signature description tags uses_functions uses_types returns returns_optional error_type imports tested tests test_file_path file_path framework params output
gpu_check function cpp gfx 1.0.0 impure bool fn_gfx::gpu_check_caps(GpuCaps& out) Rellena GpuCaps con las capacidades del contexto OpenGL activo: vendor, renderer, version, limites de compute workgroup, flags has_compute_shader/has_storage_buffer, y version CUDA runtime (deteccion en compile-time via CUDART_VERSION). Requiere contexto GL activo. Retorna false si el contexto no esta disponible.
gpu
opengl
cuda
caps
hardware
probe
gfx
compute
infra
pendiente-usar
gl_loader_cpp_gfx
false error_go_core
gfx/gpu_check.h
gfx/gl_loader.h
cuda_runtime.h
cstring
string
false
cpp/functions/gfx/gpu_check.cpp opengl
name desc
out Referencia a GpuCaps que se rellena con las capacidades detectadas. Se resetea al inicio de la llamada.
true si el contexto GL esta activo y gl_vendor no esta vacio; false si no hay contexto GL activo o el driver devuelve nullptr para GL_VENDOR.

gpu_check

Probing de capacidades GPU en runtime: OpenGL strings, compute shader support y CUDA.

Uso tipico

#include "gfx/gpu_check.h"
#include "gfx/gl_loader.h"

// Dentro de render(), despues del primer frame (contexto GL activo):
fn::gfx::GpuCaps caps;
if (fn::gfx::gpu_check_caps(caps)) {
    printf("GPU: %s\n", caps.gl_renderer.c_str());
    printf("Compute shaders: %s\n", caps.has_compute_shader ? "yes" : "no");
    if (!caps.cuda_runtime_version.empty())
        printf("CUDA runtime: %s\n", caps.cuda_runtime_version.c_str());
} else {
    printf("No GL context active\n");
}

Estructura GpuCaps

struct GpuCaps {
    std::string gl_vendor;                  // "NVIDIA Corporation"
    std::string gl_renderer;                // "NVIDIA GeForce RTX 3080/PCIe/SSE2"
    std::string gl_version;                 // "4.6.0 NVIDIA 550.54.15"
    int max_compute_workgroup_count[3];     // [65535, 65535, 65535] tipico NVIDIA
    int max_compute_workgroup_size[3];      // [1024, 1024, 64] tipico
    bool has_compute_shader;                // GL 4.3+ o ARB_compute_shader
    bool has_storage_buffer;                // GL 4.3+ o ARB_shader_storage_buffer_object
    std::string cuda_runtime_version;       // "12.4" o "" si no compilado con CUDA
};

CUDA detection

La version CUDA se detecta en compile time via el macro CUDART_VERSION de <cuda_runtime.h>. Si la app no esta compilada con el CUDA toolkit, cuda_runtime_version sera "". Para detection en runtime del toolkit del sistema, usar cuda_toolkit_check_bash_infra.

Requisito de contexto GL

Llamar siempre despues de crear el contexto GL. En apps que usan fn::run_app, el contexto esta activo desde el primer frame del render() callback. En Windows, fn::gfx::gl_loader_init() debe haberse llamado antes para que los punteros de funcion esten resueltos.

Uso previsto (fn doctor cpp-apps)

Esta funcion sera invocada por el audit de fn doctor cpp-apps para verificar que las apps C++ del registry tienen acceso a compute shaders cuando declaran dependencias de gpu_compute_program, gpu_dispatch, etc.

CMakeLists.txt

add_imgui_app(mi_app
    main.cpp
    ${CMAKE_SOURCE_DIR}/cpp/functions/gfx/gpu_check.cpp
)
# CUDA opcional: si la app compila con CUDA toolkit el header cuda_runtime.h
# estara disponible y FN_HAS_CUDA_RUNTIME se activara automaticamente.