godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.11k stars 21.16k forks source link

Regression: textureSize() of screen/depth texture causes internal errors and editor hang #72986

Closed minoaut closed 1 year ago

minoaut commented 1 year ago

Godot version

v4.0.rc.custom_build [b12bf7ff0]

System information

Ubuntu 23.04 (Lunar Lobster)

Issue description

In a spatial shader: calling textureSize with a texture with hint_screen_texture or hint_depth_texture causes a long list of errors in the terminal, hangs the editor for a minute and fails to run the shader. Shaders using textureSize built fine two weeks ago.

Steps to reproduce

Open sample project. Errors should be printed to console right away.

terminal_output.txt

Minimal reproduction project

textureSize.zip

Shader for MeshInstance3D with a plane mesh:

shader_type spatial;

uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;

void fragment() {
    textureSize(SCREEN_TEXTURE, 0);  // <- culprit
    ALBEDO = vec3(1, 0, 0);
}
clayjohn commented 1 year ago

Looks like our multiview handling code is a little over-eager and is producing this:

textureSize(multiviewSampler(color_buffer, material_samplers[9]), multiview_uv(0.xy)

CC @BastiaanOlij