On Mon Dec 5 21:52:51 2022 +0000, Zebediah Figura wrote:
Is it legal to declare a static texture and initialize it?
Yes, it is legal to declare and initialize a static texture (or more generally, a static variable that contains objects), like in the following shader: ```hlsl Texture2D real_tex; static Texture2D tex = real_tex;
float4 main() : sv_target { return tex.Load(int3(0, 0, 0)); } ```
However, that particular piece of code is only active when the variable is **not** initialized, which is legal, as long it is not used before being assigned a proper object (that can be determined statically), such as in this shader: ```hlsl Texture2D real_tex; static Texture2D tex;
float4 main() : sv_target { tex = real_tex; return tex.Load(int3(0, 0, 0)); } ```