如何调试 GLSL 着色器? [英] How to debug a GLSL shader?

查看:67
本文介绍了如何调试 GLSL 着色器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要调试一个 GLSL 程序,但我不知道如何输出中间结果.是否可以使用 GLSL 进行一些调试跟踪(如使用 printf)?

I need to debug a GLSL program but I don't know how to output intermediate result. Is it possible to make some debug traces (like with printf) with GLSL ?

推荐答案

您无法轻松地从 GLSL 内部与 CPU 进行通信.使用 glslDevil 或其他工具是您最好的选择.

You can't easily communicate back to the CPU from within GLSL. Using glslDevil or other tools is your best bet.

printf 需要尝试从运行 GLSL 代码的 GPU 返回到 CPU.相反,您可以尝试推进显示.与其尝试输出文本,不如输出一些与屏幕不同的视觉效果.例如,只有当您到达要添加 printf 的代码点时,您才能将某些东西绘制为特定颜色.如果您需要 printf 一个值,您可以根据该值设置颜色.

A printf would require trying to get back to the CPU from the GPU running the GLSL code. Instead, you can try pushing ahead to the display. Instead of trying to output text, output something visually distinctive to the screen. For example you can paint something a specific color only if you reach the point of your code where you want add a printf. If you need to printf a value you can set the color according to that value.

这篇关于如何调试 GLSL 着色器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆