简体   繁体   English

在实现OIT的同时,不同windows的buffer和texture能否在OpenGL中共享同一个绑定点?

[英]Could the buffers and textures of different windows share the same binding point in OpenGL while realizing OIT?

Firstly I want to say that I have already realized the PPLL(Per-Pixel Linked Lists) to draw transparently, and everything seems to be rather normal.首先我想说我已经实现了PPLL(Per-Pixel Linked Lists) 可以透明地绘制,一切看起来都很正常。 The problem occurred in the time when I try to use PPLL in multiple windows.问题发生在我尝试在多个 windows 中使用 PPLL 的时候。

I'm using OpenGL 4.5 + QT in my program.我在我的程序中使用 OpenGL 4.5 + QT。 The user interface sketch is shown as follows:用户界面草图如下所示: 在此处输入图像描述

The interface divides into two parts, window 0 and 1, and they are rendering same things from different angles.界面分为window 0和1两部分,它们从不同的角度渲染相同的东西。 A window 2 will be opened and closed occasionally to show other things. window 2 偶尔会打开和关闭以显示其他内容。

All the three windows can be rendered in transparent mode normally. windows这三个都可以正常在透明模式下渲染。 However, when a window 2 is closed, window 0 will turn to be flickering and colorless (while window 2 is still normal), as the following picture shows.但是,当一个 window 2 关闭时,window 0 会变成闪烁无色(而 window 2 仍然正常),如下图所示。

在此处输入图像描述

The following are some realization details of the PPLL in each window.以下是每个 window 中 PPLL 的一些实现细节。

The three windows use the same shader.三个 windows 使用相同的着色器。 It's worth noting that the images in fragment shaders for PPLL share the same binding points for each window.值得注意的是,PPLL 的片段着色器中的图像对于每个 window 共享相同的绑定点。

layout (binding = 0, r32ui)         uniform uimage2D head_pointer_image;        // save the head pointers for all pixels
layout (binding = 1, rgba32ui)      uniform writeonly uimageBuffer list_buffer; // save every fragment data
layout (binding = 0, offset = 0)    uniform atomic_uint list_counter;           // used to assign a unique index for each fragment

Each window has its own resources (buffers and textures) for PPLL, and the resources will be applyed when the window is initialized and deleted when the window is closed.每个 window 都有自己的 PPLL 资源(缓冲区和纹理),这些资源将在 window 初始化时应用,在 window 关闭时删除。

GLuint m_headPointerTexture;
GLuint m_headPointerClearBuffer;
GLuint m_atomicCounterBuffer;
GLuint m_linkedListBuffer;
GLuint m_linkedListTexture;
....
glDeleteTextures(1, &m_headPointerTexture);
glDeleteBuffers(1, &m_headPointerClearBuffer);
glDeleteBuffers(1, &m_atomicCounterBuffer);
glDeleteBuffers(1, &m_linkedListBuffer);
glDeleteTextures(1, &m_linkedListTexture);

I have two conjectures for the error render of window 0:对于 window 0 的错误渲染,我有两个猜想:

  1. Different windows should use different binding points for the images defined in glsl.不同的 windows 应该对 glsl 中定义的图像使用不同的绑定点。

  2. Different windows should share the resources (buffers and textures).不同的 windows 应该共享资源(缓冲区和纹理)。

I have run kinds of tests for each conjecture, but the results are all unsatisfactory.我对每个猜想都进行了各种测试,但结果都不尽如人意。

UPDATE:更新:

It's a complex project.这是一个复杂的项目。 I'm not entirely sure the error is related to the PPLL.我不完全确定该错误与 PPLL 有关。 When object A and B are both drawn on window 0 and 1, the error will occur.当object A和B都画在window 0和1上时,会出现错误。 However, when I only draw object A (or B) on window 0 and 1, the error will not occur.但是,当我只在window 0和1上绘制object A(或B)时,不会出现错误。 It's rather strange.这很奇怪。 I'm completely out of my mind.我完全疯了。

The error occurs in the time when a window 2 is closed, so it's related to the release of the resources applied by window 2.该错误发生在window 2 关闭时,与window 2 申请的资源释放有关。

Adjusting the order of the deconstruction of window 2 properly will solve the problem.适当调整 window 2 的解构顺序即可解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM