Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

in Postprocess mode, the GPU crashes steadily #33

Open
SnowWindSaveYou opened this issue May 25, 2024 · 3 comments
Open

in Postprocess mode, the GPU crashes steadily #33

SnowWindSaveYou opened this issue May 25, 2024 · 3 comments

Comments

@SnowWindSaveYou
Copy link
Collaborator

SnowWindSaveYou commented May 25, 2024

cq0rJKRSkO

After examining the issue, it turns out that the main cause is the failure to bind the new buffer to the clearStartOffsetBufferKernel after reallocating the buffer due to a change in screen size.

This issue can be simply resolved by binding the buffer before dispatching the kernel:

            //reset StartOffsetBuffer to zeros
            oitComputeUtils.SetInt("screenWidth", screenWidth);
            oitComputeUtils.SetBuffer(clearStartOffsetBufferKernel, startOffsetBufferId, startOffsetBuffer);
            oitComputeUtils.Dispatch(clearStartOffsetBufferKernel, dispatchGroupSizeX, dispatchGroupSizeY, 1);

And, when I investigated this issue, I also discovered that the Screen.width value retrieved here changes frequently, because this variable refers to the current window , which could be the preview window, the editor window, and the game window.
It might be a better approach to bind an independent buffer for each camera?

Additionally, switching windows can causes the OIT effect to disappear, and I have not yet found the reason for this.

@happy-turtle
Copy link
Owner

happy-turtle commented May 30, 2024

Thank you for investigating! Those are some really good points. I agree, setting the buffer size based on the screen size is not ideal. We should instead set it based on the current camera buffer size.
I already have an idea on how to implement this for all three pipelines, but it will require some refactoring and the extension of IOrderIndependentTransparency to include the width and height of the texture. Maybe similar to this:

interface IOrderIndependentTransparency
{
  void PreRender(CommandBuffer command, int width, int height);
}

Though I wonder if we need more flexibility here and pass a RTHandle or something similar. Anyways, I will try and set up a pull request. 😊 But feel free to start one as well if you are up for it.

@happy-turtle
Copy link
Owner

I tried to work on it at #34, but it didn't quite fix the issue for me. Using the camera parameters is fine for URP and HDRP. But I can't get it to work with the Built-in pipeline. It works if only the scene view or only the game view is visible. But it breaks once multiple views are active at the same time.

@happy-turtle
Copy link
Owner

happy-turtle commented Jul 4, 2024

Alright, I can now offer a solution for the first issue, the frequent crashes you mentioned, with #40.
Regarding the effect often disappearing, I am still a bit clueless as well. I guess something with the effect initalization and cleanup order is not correct...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants