You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-14 13:41:12 +00:00
Fix 2D instance params crashing using outside of main()
(cherry picked from commit 93bc18f2b0)
This commit is contained in:
@@ -1837,7 +1837,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
|
|||||||
actions.base_varying_index = 5;
|
actions.base_varying_index = 5;
|
||||||
|
|
||||||
actions.global_buffer_array_variable = "global_shader_uniforms.data";
|
actions.global_buffer_array_variable = "global_shader_uniforms.data";
|
||||||
actions.instance_uniform_index_variable = "draw_data.instance_uniforms_ofs";
|
actions.instance_uniform_index_variable = "instances.data[instance_index].instance_uniforms_ofs";
|
||||||
|
|
||||||
shader.compiler.initialize(actions);
|
shader.compiler.initialize(actions);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ layout(set = 1, binding = 0, std140) uniform MaterialUniforms {
|
|||||||
/* clang-format on */
|
/* clang-format on */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint instance_index;
|
||||||
|
|
||||||
#GLOBALS
|
#GLOBALS
|
||||||
|
|
||||||
#ifdef USE_ATTRIBUTES
|
#ifdef USE_ATTRIBUTES
|
||||||
@@ -66,9 +68,9 @@ void main() {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef USE_ATTRIBUTES
|
#ifdef USE_ATTRIBUTES
|
||||||
uint instance_index = params.base_instance_index;
|
instance_index = params.base_instance_index;
|
||||||
#else
|
#else
|
||||||
uint instance_index = gl_InstanceIndex + params.base_instance_index;
|
instance_index = gl_InstanceIndex + params.base_instance_index;
|
||||||
instance_index_interp = instance_index;
|
instance_index_interp = instance_index;
|
||||||
#endif // USE_ATTRIBUTES
|
#endif // USE_ATTRIBUTES
|
||||||
const InstanceData draw_data = instances.data[instance_index];
|
const InstanceData draw_data = instances.data[instance_index];
|
||||||
@@ -240,7 +242,7 @@ void main() {
|
|||||||
#include "canvas_uniforms_inc.glsl"
|
#include "canvas_uniforms_inc.glsl"
|
||||||
|
|
||||||
#ifndef USE_ATTRIBUTES
|
#ifndef USE_ATTRIBUTES
|
||||||
layout(location = 4) in flat uint instance_index;
|
layout(location = 4) in flat uint instance_index_interp;
|
||||||
#endif // USE_ATTRIBUTES
|
#endif // USE_ATTRIBUTES
|
||||||
|
|
||||||
layout(location = 0) in vec2 uv_interp;
|
layout(location = 0) in vec2 uv_interp;
|
||||||
@@ -287,6 +289,8 @@ vec2 sdf_to_screen_uv(vec2 p_sdf) {
|
|||||||
return p_sdf * canvas_data.sdf_to_screen;
|
return p_sdf * canvas_data.sdf_to_screen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint instance_index;
|
||||||
|
|
||||||
#GLOBALS
|
#GLOBALS
|
||||||
|
|
||||||
#ifdef LIGHT_CODE_USED
|
#ifdef LIGHT_CODE_USED
|
||||||
@@ -461,10 +465,11 @@ void main() {
|
|||||||
vec2 vertex = vertex_interp;
|
vec2 vertex = vertex_interp;
|
||||||
|
|
||||||
#ifdef USE_ATTRIBUTES
|
#ifdef USE_ATTRIBUTES
|
||||||
const InstanceData draw_data = instances.data[params.base_instance_index];
|
instance_index = params.base_instance_index;
|
||||||
#else
|
#else
|
||||||
const InstanceData draw_data = instances.data[instance_index];
|
instance_index = instance_index_interp;
|
||||||
#endif // USE_ATTRIBUTES
|
#endif // USE_ATTRIBUTES
|
||||||
|
const InstanceData draw_data = instances.data[instance_index];
|
||||||
|
|
||||||
#if !defined(USE_ATTRIBUTES) && !defined(USE_PRIMITIVE)
|
#if !defined(USE_ATTRIBUTES) && !defined(USE_PRIMITIVE)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user