--- a/data/lib/sysresource/shader/include/v2_vpcommon.cgh +++ b/data/lib/sysresource/shader/include/v2_vpcommon.cgh @@ -12,7 +12,7 @@ #ifdef _USE_GPROGRAM #define END_VP_MAIN VOUT_VALUE(instanceID) = gl_InstanceID;} #else -#define END_VP_MAIN gl_Position = vfio_position;VOUT_VALUE(instanceID) = gl_InstanceID;} +#define END_VP_MAIN gl_Position = vfio_position + VIN_KEEPALIVE;VOUT_VALUE(instanceID) = gl_InstanceID;} #endif #extension GL_ARB_explicit_attrib_location : enable @@ -47,6 +47,44 @@ layout(location = 6) in vec4 vin_weights; #endif +/* Keep vin_* attributes alive so Mesa's cross-stage DCE cannot mark them + * inactive (glGetAttribLocation would return -1 -> engine "Vertex Attribute + * Problem" -> white screen). Each term is scaled by float(drawCount == -9999), + * a uniform Mesa cannot constant-fold; drawCount is always >= 0 at runtime so + * the terms are exactly 0.0 and rendering is unaffected. Guarded by the same + * #ifdefs as the declarations so only declared attributes are referenced. */ +#ifdef _USE_NORMAL +#define _VKA_N + vin_normal.x +#else +#define _VKA_N +#endif +#ifdef _USE_NORMALMAP +#define _VKA_T + vin_tangent.x +#else +#define _VKA_T +#endif +#ifdef _USE_VP_TEXCOORD0 +#define _VKA_U0 + vin_uv0.x +#else +#define _VKA_U0 +#endif +#ifdef _USE_VP_TEXCOORD1 +#define _VKA_U1 + vin_uv1.x +#else +#define _VKA_U1 +#endif +#ifdef _USE_VP_COLOR +#define _VKA_C + vin_color.x +#else +#define _VKA_C +#endif +#ifdef _USE_SKINNING +#define _VKA_W + vin_weights.x +#else +#define _VKA_W +#endif +#define VIN_KEEPALIVE vec4((vin_position.x _VKA_N _VKA_T _VKA_U0 _VKA_U1 _VKA_C _VKA_W) * float(drawCount == -9999), 0.0, 0.0, 0.0) + /*----------- Outpt --------------*/ #ifdef _USE_GPROGRAM