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

查看:321
本文介绍了如何调试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的代码点时,才能绘制特定颜色的颜色。如果您需要打印一个值,您可以根据该值设置颜色。

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天全站免登陆