对GLSL着色器进行基准测试以比较替代实现的速度 [英] Benchmarking GLSL shaders to compare speed of alternative implementations

查看:111
本文介绍了对GLSL着色器进行基准测试以比较替代实现的速度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用OpenGL和GLSL着色器绘制二维函数z = f(x,y).我想使用色图将函数的值映射到颜色,但是某些色图是使用HSL或HSV色空间表示的(例如色相图).

I want to plot two-dimensional function z = f(x,y) using OpenGL and GLSL shaders. I'd like to map the value of function to color using a colormap, but some colormaps are expressed using HSL or HSV colorspace (for example hue maps).

您可以在GLSL中(在这里和其他地方)找到hsv2rgb()的不同替代实现.

You can find (here and in other places) different alternative implementtions of hsv2rgb() in GLSL.

我如何基准这些着色器(那些功能)以找出最快的着色器?

How can I benchmark those shaders (those functions) to find out which one is fastest?

推荐答案

实施所有您想尝试的替代方法,并应用通常的基准测试建议:

Implement all alternatives you want to try and apply the usual benchmark suggestions:

  • 重复单个基准测试足够的时间,以使时间只有几秒钟(更少的时间会受到太多噪音的干扰)
  • 在要运行它的环境中重复执行基准测试.
  • 尝试使设置尽可能接近实际情况(相同的后台进程等).
  • 重复执行几次基准测试,并忽略异常值.
  • 随机化运行之间的算法/测试顺序.
  • 确保对要测试的部分禁用缓存(如果适用).

由于包含了OpenGL解决方案,因此您还应该考虑是否还要计算数据传输量.确保刷新管道(opengl会延迟一些调用,但是刷新将等待直到它们实际完成为止).

Since you include OpenGL solutions you should consider if you want to count data transfers as well. Make sure you flush the pipelines (opengl deffers some calls, but flush will wait until they are actually finished).

如果运行时间太近,您可以说它们差不多相同,或者增加数据大小/重复次数以使差异更加明显.

If the run-times are too close you can either say they are about the same or increase data size/repetitions to make the difference more prominent.

这篇关于对GLSL着色器进行基准测试以比较替代实现的速度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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