在 OS X 10.4+ 上向 VRAM 读取/写入任意字节
大家好,Cocoa 开发人员,
我想咨询一下这里的一些专家,看看他们是否能够帮助澄清文档缺乏的领域。现在我们有一种方法,旨在通过获取显示器的基地址并写入/读取从该地址开始的字节模式来测试 VRAM。这提供了这样的效果:显示器上的每个像素都被连续设置为特定颜色,然后读回该颜色以确保它与预期的颜色相同。
最初的实现使用 Quickdraw 函数来获取此地址,我的任务是使其更新到 10.4+。我正在使用 CGDisplayCaptureWithOptions(kCGDirectMainDisplay, kCGCaptureNoFill) ,然后通过调用 CGDisplayBaseAddress(kCGDirectMainDisplay) 获取基地址。这似乎达到了我的预期,并且实现效果与之前的版本一样好。
我唯一要问的问题是,这是否真的写入VRAM,或者只是RAM中的显示器缓冲区?或者我应该使用像 OpenGL 这样的东西来做到这一点?感谢大家的任何指点和/或建议。如果您认为有必要,我可以提供代码示例。
Hello fellow Cocoa developers,
I would like to check with some of the experts here to see if they might be able to help clarify an area where the docs are lacking. Right now we have a method that is meant to be testing the VRAM by getting the base address of the display and writing / reading a pattern of bytes starting at that address. This provides the effect that each pixel on the display is successively set to a specific color which is then read back to make sure it is the same as what is expected.
The original implementation used quickdraw functions to obtain this address, and I have been tasked with bringing it up to date for 10.4+. I am using CGDisplayCaptureWithOptions(kCGDirectMainDisplay, kCGCaptureNoFill)
and then getting the base address by calling CGDisplayBaseAddress(kCGDirectMainDisplay)
. This seems to do what I expect and the implementation is working just as well as the previous version.
The only question left for me to ask is if this is really writing to VRAM or is it just the display's buffer in RAM? Or should I use something like OpenGL to do this? Thank you all for any pointers and/or suggestions. I can provide a code sample if you think it is necessary.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自 Apple 的文档:
CGDisplayBaseAddress(),在 Mac OS X 10.6 中已弃用
“返回在线显示的帧缓冲区内存中的基地址。您应该使用而不是使用原始帧缓冲区绘制到屏幕支持的绘图引擎,例如 Quartz 或 OpenGL。”
听起来是一个不错的推荐。您应该使用 OpenGL 进行绘图和测试(我想,使用
glReadPixels()
)。From Apple's docs:
CGDisplayBaseAddress(), deprecated in Mac OS X 10.6
"Returns the base address in framebuffer memory of an online display. Instead of using the raw framebuffer to draw to the screen, you should instead use a supported drawing engine such as Quartz or OpenGL."
It sounds like a good recommendation. You should use OpenGL for both drawing and testing (I suppose, with
glReadPixels()
).