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

Vulkan: Using main Viewport as Sprite2D texture causing artefacts and error #60475

Open
abochar opened this issue Apr 23, 2022 · 5 comments
Open

Comments

@abochar
Copy link

abochar commented Apr 23, 2022

Godot version

v4.0.alpha6.official [e4f0fc5]

System information

Windows 11, Vulkan, Nvidia 3080Ti (511.79)

Issue description

Using main Viewport as Sprite2D texture causing artefacts and error:

E 0:00:02:0993 draw_list_bind_uniform_set: Attempted to use the same texture in framebuffer attachment and a uniform (set: 3, binding: 0), this is not allowed.
<C++ Error> Condition "attachable_ptr[i].texture == bound_ptr[j]" is true.
<C++ Source> drivers/vulkan/rendering_device_vulkan.cpp:7419 @ draw_list_bind_uniform_set()

image

image

Steps to reproduce

Create sprite 2d, assign main viewport texture to it.

Minimal reproduction project

Viewport.zip

@abochar abochar changed the title Using viewport Using main Viewport as Sprite2D texture causing artefacts and arror: Apr 23, 2022
@abochar abochar changed the title Using main Viewport as Sprite2D texture causing artefacts and arror: Using main Viewport as Sprite2D texture causing artefacts and arror Apr 23, 2022
@abochar abochar changed the title Using main Viewport as Sprite2D texture causing artefacts and arror Using main Viewport as Sprite2D texture causing artefacts and error Apr 23, 2022
@Calinou Calinou added this to the 4.0 milestone Apr 23, 2022
@Calinou Calinou changed the title Using main Viewport as Sprite2D texture causing artefacts and error Vulkan: Using main Viewport as Sprite2D texture causing artefacts and error Apr 23, 2022
@gerrywastaken
Copy link

gerrywastaken commented Nov 27, 2022

This same error was mentioned in a few places so I want to create a link to them so that people eventually find this issue as it doesn't yet come up on Google:

  1. Attempted to use the same texture in framebuffer attachment error #44473 (comment)
  2. Viewport doesn't render at default size [512,512] #66483 (comment)
  3. https://godotengine.org/qa/132245/trying-shader-based-game-using-same-texture-uniform-allowed
  4. https://youtu.be/VSwVwIYEypY?t=377 (clearly shows the error spam - watched by 66K times, not sure how many encountered the same error. The presenter also encountered the 512x512 error )

Also this error still happens in v4 Beta 6

@c-schembri
Copy link

This issue is still occurring in 4.0.3.

@wilkie
Copy link

wilkie commented Sep 14, 2023

Still occurring in 4.1.1 stable. More or less any viewport texture to itself, in order to reference a prior frame. This all works in spite of the message suggesting that it is not allowed. The error spam ends up making the debugger quite useless that I will likely build Godot myself to silence it, which isn't the worst workaround.

@nan0m
Copy link

nan0m commented Nov 10, 2023

I found a workaround that eliminates the warning.

try this:

var viewport_texture = get_viewport().get_texture()
node.texture = ImageTexture.create_from_image( viewport_texture.get_image() )

the docs mention that you might want to do

await RenderingServer.frame_post_draw

before creating the image texture. Which wasn't necessary for my usecase. But I thought I would still mention it here.

@clayjohn
Copy link
Member

Just jumping in here to add some context. Using the root Viewport as a texture to draw a Sprite in the root Viewport is not supported and cannot be supported. The error is correct, but not very helpful for end-users.

What we probably need to do is detect if the user is trying to use the ViewportTexture of the root Viewport and then provide a proper error that this is not supported.

This will of course be tricky as we need to do the same for SubViewports (SubViewports cannot be used as a texture to draw an item that is a child of that SubViewport)

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

No branches or pull requests

7 participants