仅为窗口的一部分创建 Vulkan 表面 [英] Create Vulkan surface for only a portion of a window

查看:44
本文介绍了仅为窗口的一部分创建 Vulkan 表面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个应用程序,它有一个窗口,顶部有一个水平工具栏.我们传递给 Vulkan 以创建表面的窗口级句柄最终包括工具栏后面的区域,即 Vulkan 完全不知道工具栏并且表面包括工具栏后面"的空间.

We have an application which has a window with a horizontal toolbar at the top. The windows-level handle we pass to Vulkan to create the surface ends up including the area behind the toolbar i.e. Vulkan is completely unaware of the toolbar and the surface includes the space "behind" it.

我的问题是,一个表面可以只代表这个窗口的一部分吗?我们显然不需要处理位于工具栏后面的像素的数据,因此要避免创建比必要更大的帧缓冲区、深度缓冲区等.

My question is, can a surface represent only a portion of this window? We obviously need not process data for the pixels that lie behind the toolbar, and so want to avoid creating a frame buffer, depth buffer etc. bigger than necessary.

我完全理解我可以使用视口在视觉上完成这一点,例如具有原点偏移和高度补偿,但是据我了解,即使我只渲染到该窗口的一部分,帧缓冲区实际上仍然包含表面完整大小的像素信息(例如,800x600 客户区窗口的 800x600).帧缓冲器然后被映射"为映射".因此被挤压到视口区域.

I fully understand that I can accomplish this visually using a viewport which e.g. has an origin offset and height compensation, however to my understanding the frame buffer actually still contains information for pixels the full size of the surface (e.g. 800x600 for an 800x600 client-area window) even if I am only rendering to a portion of that window. The frame buffer then gets "mapped" and therefore squished to the viewport area.

所有这些让我想知道视口的目的是什么.如果它只是定义了从图像缓冲区到表面区域的映射,那么如果您的帧缓冲区包含的像素比它被映射到的区域多得多,这不是非常低效吗?在您的应用程序中使用例如部分部分没有意义吗?首先是不同的窗口 HWND,然后从那时起创建不同的表面?

All of this has sort of left me wondering what the purpose of a viewport is. If it simply defines a mapping from your image buffer to an area in the surface, is that not highly inefficient if your framebuffer contains considerably more pixels than the area it is being mapped to? Would it not make sense to rather section of portions in your application using e.g. different windows HWNDs FIRST, and then create different surfaces from then onwards?

如何避免渲染到超出需要的区域?

How can I avoid rendering to an area bigger than necessary?

推荐答案

几乎每个应用程序的处理方式是窗口的客户区(即:不是工具栏等的东西)是主框架窗口的子窗口.调整框架大小后,您可以调整客户端窗口的大小以匹配新的客户区域(考虑工具栏/等的新大小).

The way this gets handled for pretty much every application is that the client area of a window (ie: the stuff that isn't toolbars and the like) is a child window of the main frame window. When the frame is resized, you resize the client window to match the new client area (taking into account the new sizes of the toolbars/etc).

正是这个客户端窗口应该为它创建一个 Vulkan 表面.

It is this client window which should have a Vulkan surface created for it.

这篇关于仅为窗口的一部分创建 Vulkan 表面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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