Skip to content

GLSL shader compilation error on Broadcom VideoCore 7 (Mesa V3D) #1491

Closed
@illwieckz

Description

@illwieckz

I was testing the current master on a Raspberry Pi 5, with Linux 6.6 and Mesa 24.3.0 and I got this:

Invalidating shader binary cache
Mesa: info: Mesa debug output: 0:10218(16): error: could not implicitly convert operands to arithmetic operator
Mesa: info: Mesa debug output: 0:10218(38): error: could not implicitly convert operands to modulus (%) operator
Mesa: info: Mesa debug output: 0:10218(32): error: operands to arithmetic operators must be numeric
Mesa: info: Mesa debug output: 0:10218(11): error: RHS of operator >> must be an integer or integer vector
Mesa: info: Mesa debug output: 0:10218(9): error: LHS of `&' must be an integer
Mesa: info: Mesa debug output: 0:10218(2): error: `return' with wrong type error, in function `nextIdx' returning uint
Mesa: info: Mesa debug output: 0:10230(7): error: initializer of type int cannot be assigned to variable of type uint
Mesa: info: Mesa debug output: 0:10230(23): error: could not implicitly convert operands to relational operator
Mesa: info: Mesa debug output: 0:10230(23): error: loop condition must be scalar boolean
Mesa: info: Mesa debug output: 0:10231(2): error: initializer of type int cannot be assigned to variable of type uint
Mesa: info: Mesa debug output: 0:10234(7): error: initializer of type int cannot be assigned to variable of type uint
Mesa: info: Mesa debug output: 0:10234(19): error: could not implicitly convert operands to relational operator
Mesa: info: Mesa debug output: 0:10234(19): error: loop condition must be scalar boolean
Mesa: info: Mesa debug output: 0:10237(6): error: operands of `==' must have the same type
Mesa: info: Mesa debug output: 0:10243(10): error: could not implicitly convert operands to arithmetic operator
Mesa: info: Mesa debug output: 0:10243(8): error: operands to arithmetic operators must be numeric
Mesa: info: Mesa debug output: 0:10243(8): error: operands to arithmetic operators must be numeric
Warn: Source for shader program lightMapping:
   0: #version 140
   1:
   2: #define HAVE_EXT_gpu_shader4 1
   3: #extension GL_ARB_texture_gather : require
   4: #define HAVE_ARB_texture_gather 1
   5: #define HAVE_EXT_texture_integer 1
   6: #define HAVE_ARB_texture_rg 1
   7: #define HAVE_ARB_uniform_buffer_object 1
   8: #extension GL_ARB_shader_storage_buffer_object : require
   9: #define HAVE_ARB_shader_storage_buffer_object 1
  10: #ifndef r_AmbientScale
  11: #define r_AmbientScale 1.00000000e+00
  12: #endif
  13: #ifndef r_SpecularScale
  14: #define r_SpecularScale 1.00000000e+00
  15: #endif
  16: #ifndef r_zNear
  17: #define r_zNear 3.00000000e+00
  18: #endif
  19: #ifndef M_PI
  20: #define M_PI 3.14159274e+00
  21: #endif
  22: #ifndef MAX_SHADOWMAPS
  23: #define MAX_SHADOWMAPS 5
  24: #endif
  25: #ifndef MAX_REF_LIGHTS
  26: #define MAX_REF_LIGHTS 1024
  27: #endif
  28: #ifndef NUM_LIGHT_LAYERS
  29: #define NUM_LIGHT_LAYERS 4
  30: #endif
  31: #ifndef TILE_SIZE
  32: #define TILE_SIZE 16
  33: #endif
  34: #ifndef r_FBufSize
  35: #define r_FBufSize vec2(1.92000000e+03, 1.08000000e+03)
  36: #endif
  37: #ifndef r_tileStep
  38: #define r_tileStep vec2(8.33333377e-03, 1.48148146e-02)
  39: #endif
  40: #ifndef r_highPrecisionRendering
  41: #define r_highPrecisionRendering 1
  42: #endif
  43: #ifndef r_realtimeLighting
  44: #define r_realtimeLighting 1
  45: #endif
  46: #ifndef r_realtimeLightingRenderer
  47: #define r_realtimeLightingRenderer 1
  48: #endif
  49: #ifndef r_precomputedLighting
  50: #define r_precomputedLighting 1
  51: #endif
  52: #ifndef r_vertexSkinning
  53: #define r_vertexSkinning 1
  54: #endif
  55: const int MAX_GLSL_BONES = 256;
  56: #ifndef r_halfLambertLighting
  57: #define r_halfLambertLighting 1
  58: #endif
  59: #ifndef r_rimLighting
  60: #define r_rimLighting 1
  61: #endif
  62: const float r_RimExponent = 3.00000000e+00;
  63: #ifndef r_normalMapping
  64: #define r_normalMapping 1
  65: #endif
  66: #ifndef r_specularMapping
  67: #define r_specularMapping 1
  68: #endif
  69: #ifndef r_physicalMapping
  70: #define r_physicalMapping 1
  71: #endif
  72: #ifndef r_glowMapping
  73: #define r_glowMapping 1
  74: #endif
  75: #ifndef r_colorGrading
  76: #define r_colorGrading 1
  77: #endif
  78: #ifndef r_zNear
  79: #define r_zNear 3.00000000e+00
  80: #endif
  81: #define IN(mode) mode in
  82: #define DECLARE_OUTPUT(type) out type outputColor;
  83: #define textureCube texture
  84: #define texture2D texture
  85: #define texture2DProj textureProj
  86: #define texture3D texture
  87: /*
  88: ===========================================================================
  89: Copyright (C) 2006-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
  90:
  91: This file is part of XreaL source code.
  92:
  93: XreaL source code is free software; you can redistribute it
  94: and/or modify it under the terms of the GNU General Public License as
  95: published by the Free Software Foundation; either version 2 of the License,
  96: or (at your option) any later version.
  97:
  98: XreaL source code is distributed in the hope that it will be
  99: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 100: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 101: GNU General Public License for more details.
 102:
 103: You should have received a copy of the GNU General Public License
 104: along with XreaL source code; if not, write to the Free Software
 105: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 106: ===========================================================================
 107: */
 108:
 109: /* lightMapping_fp.glsl */
 110:
10000: #line 10000 // computeLight_fp.glsl
10001: /*
10002: ===========================================================================
10003: Copyright (C) 2009-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
10004:
10005: This file is part of XreaL source code.
10006:
10007: XreaL source code is free software; you can redistribute it
10008: and/or modify it under the terms of the GNU General Public License as
10009: published by the Free Software Foundation; either version 2 of the License,
10010: or (at your option) any later version.
10011:
10012: XreaL source code is distributed in the hope that it will be
10013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
10014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10015: GNU General Public License for more details.
10016:
10017: You should have received a copy of the GNU General Public License
10018: along with XreaL source code; if not, write to the Free Software
10019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
10020: ===========================================================================
10021: */
10022: // computeLight_fp.glsl - Light computing helper functions
10023:
10024: #define COMPUTELIGHT_GLSL
10025:
10026: uniform float u_LightFactor;
10027:
10028: #if !defined(USE_BSP_SURFACE)
10029: 	#define USE_MODEL_SURFACE
10030: #endif
10031:
10032: #if !defined(USE_GRID_LIGHTING)
10033: 	#define USE_LIGHT_MAPPING
10034: #endif
10035:
10036: #if defined(USE_REFLECTIVE_SPECULAR)
10037: uniform samplerCube u_EnvironmentMap0;
10038: uniform samplerCube u_EnvironmentMap1;
10039: uniform float u_EnvironmentInterpolation;
10040:
10041: // Only the RGB components are meaningful
10042: // FIXME: using reflective specular will always globally decrease the scene brightness
10043: // because we're multiplying with something that can only be less than 1.
10044: vec4 EnvironmentalSpecularFactor( vec3 viewDir, vec3 normal )
10045: {
10046: 	vec4 envColor0 = textureCube(u_EnvironmentMap0, reflect( -viewDir, normal ) );
10047: 	vec4 envColor1 = textureCube(u_EnvironmentMap1, reflect( -viewDir, normal ) );
10048: 	return mix( envColor0, envColor1, u_EnvironmentInterpolation );
10049: }
10050: #endif // USE_REFLECTIVE_SPECULAR
10051:
10052: // lighting helper functions
10053:
10054: #if defined(USE_GRID_LIGHTING) || defined(USE_GRID_DELUXE_MAPPING)
10055: 	void ReadLightGrid( in vec4 texel, out vec3 ambientColor, out vec3 lightColor ) {
10056: 		float ambientScale = 2.0 * texel.a;
10057: 		float directedScale = 2.0 - ambientScale;
10058: 		ambientColor = ambientScale * texel.rgb;
10059: 		lightColor = directedScale * texel.rgb;
10060: 		ambientColor *= u_LightFactor;
10061: 		lightColor *= u_LightFactor;
10062: 	}
10063: #endif
10064:
10065: #if defined(USE_DELUXE_MAPPING) || defined(USE_GRID_DELUXE_MAPPING) || defined(r_realtimeLighting)
10066: 	#if !defined(USE_PHYSICAL_MAPPING) && defined(r_specularMapping)
10067: 		uniform vec2 u_SpecularExponent;
10068:
10069: 		vec3 computeSpecularity( vec3 lightColor, vec4 materialColor, float NdotH ) {
10070: 			return lightColor * materialColor.rgb * pow(NdotH, u_SpecularExponent.x * materialColor.a + u_SpecularExponent.y) * r_SpecularScale;
10071: 		}
10072: 	#endif
10073: #endif
10074:
10075: #if defined(USE_DELUXE_MAPPING) || defined(USE_GRID_DELUXE_MAPPING) || (defined(r_realtimeLighting) && r_realtimeLightingRenderer == 1)
10076: void computeDeluxeLight( vec3 lightDir, vec3 normal, vec3 viewDir, vec3 lightColor,
10077: 	vec4 diffuseColor, vec4 materialColor,
10078: 	inout vec4 color )
10079: {
10080: 	vec3 H = normalize( lightDir + viewDir );
10081:
10082: 	#if defined(USE_PHYSICAL_MAPPING) || defined(r_specularMapping)
10083: 		float NdotH = clamp( dot( normal, H ), 0.0, 1.0 );
10084: 	#endif // USE_PHYSICAL_MAPPING || r_specularMapping
10085:
10086: 	// clamp( NdotL, 0.0, 1.0 ) is done below
10087: 	float NdotL = dot( normal, lightDir );
10088:
10089: 	#if !defined(USE_BSP_SURFACE) && defined(r_halfLambertLighting)
10090: 		// http://developer.valvesoftware.com/wiki/Half_Lambert
10091: 		NdotL = NdotL * 0.5 + 0.5;
10092: 		NdotL *= NdotL;
10093: 	#endif
10094:
10095: 	NdotL = clamp( NdotL, 0.0, 1.0 );
10096:
10097: 	#if defined(USE_PHYSICAL_MAPPING)
10098: 		// Daemon PBR packing defaults to ORM like glTF 2.0 defines
10099: 		// https://www.khronos.org/blog/art-pipeline-for-gltf
10100: 		// > ORM texture for Occlusion, Roughness, and Metallic
10101: 		// https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/schema/material.pbrMetallicRoughness.schema.json
10102: 		// > The metalness values are sampled from the B channel. The roughness values are sampled from the G channel.
10103: 		// > These values are linear. If other channels are present (R or A), they are ignored for metallic-roughness calculations.
10104: 		// https://docs.blender.org/manual/en/2.80/addons/io_scene_gltf2.html
10105: 		// > glTF stores occlusion in the red (R) channel, allowing it to optionally share the same image
10106: 		// > with the roughness and metallic channels.
10107: 		float roughness = materialColor.g;
10108: 		float metalness = materialColor.b;
10109:
10110: 		float NdotV = clamp( dot( normal, viewDir ), 0.0, 1.0);
10111: 		float VdotH = clamp( dot( viewDir, H ), 0.0, 1.0);
10112:
10113: 		float alpha = roughness * roughness;
10114: 		float k = 0.125 * ( roughness + 1.0 ) * ( roughness + 1.0 );
10115:
10116: 		float D = alpha / ( ( NdotH * NdotH ) * (alpha * alpha - 1.0 ) + 1.0 );
10117: 		D *= D;
10118:
10119: 		float FexpNH = pow( 1.0 - NdotH, 5.0 );
10120: 		float FexpNV = pow( 1.0 - NdotV, 5.0 );
10121: 		vec3 F = mix( vec3( 0.04 ), diffuseColor.rgb, metalness );
10122: 		F += ( 1.0 - F ) * FexpNH;
10123:
10124: 		float G = NdotL / (NdotL * ( 1.0 - k ) + k );
10125: 		G *= NdotV / ( NdotV * ( 1.0 - k ) + k );
10126:
10127: 		vec3 diffuseBRDF = NdotL * diffuseColor.rgb * ( 1.0 - metalness );
10128: 		vec3 specularBRDF = vec3( ( D * F * G ) / max( 4.0 * NdotL * NdotV, 0.0001f ) );
10129: 		color.rgb += ( diffuseBRDF + specularBRDF ) * lightColor.rgb * NdotL;
10130: 		color.a = mix( diffuseColor.a, 1.0, FexpNV );
10131:
10132: 	#else // !USE_PHYSICAL_MAPPING
10133: 		color.rgb += lightColor.rgb * NdotL * diffuseColor.rgb;
10134: 		#if defined(r_specularMapping)
10135: 			color.rgb += computeSpecularity(lightColor.rgb, materialColor, NdotH);20154: 	float bestDepth = 1.0;
20155:
20156: 	// search front to back for first point inside object
20157: 	for(int i = 0; i < linearSearchSteps - 1; ++i)
20158: 	{
20159: 		currentDepth += currentSize;
20160:
20161: #if defined(USE_HEIGHTMAP_IN_NORMALMAP)
20162: 		float depth = texture2D(u_HeightMap, rayStartTexCoords + displacement * currentDepth).a;
20163: #else // !USE_HEIGHTMAP_IN_NORMALMAP
20164: 		float depth = texture2D(u_HeightMap, rayStartTexCoords + displacement * currentDepth).g;
20165: #endif // !USE_HEIGHTMAP_IN_NORMALMAP
20166:
20167: 		float heightMapDepth = topDepth - depth;
20168:
20169: 		if(bestDepth > 0.996) // if no depth found yet
20170: 		{
20171: 			if(currentDepth >= heightMapDepth)
20172: 			{
20173: 				bestDepth = currentDepth;
20174: 				break;
20175: 			}
20176: 		}
20177: 	}
20178:
20179: 	currentDepth = bestDepth;
20180:
20181: 	// recurse around first point (depth) for closest match
20182: 	for(int i = 0; i < binarySearchSteps; ++i)
20183: 	{
20184: 		currentSize *= 0.5;
20185:
20186: #if defined(USE_HEIGHTMAP_IN_NORMALMAP)
20187: 		float depth = texture2D(u_HeightMap, rayStartTexCoords + displacement * currentDepth).a;
20188: #else // !USE_HEIGHTMAP_IN_NORMALMAP
20189: 		float depth = texture2D(u_HeightMap, rayStartTexCoords + displacement * currentDepth).g;
20190: #endif // !USE_HEIGHTMAP_IN_NORMALMAP
20191:
20192: 		float heightMapDepth = topDepth - depth;
20193:
20194: 		if(currentDepth >= heightMapDepth)
20195: 		{
20196: 			bestDepth = currentDepth;
20197: 			currentDepth -= 2.0 * currentSize;
20198: 		}
20199:
20200: 		currentDepth += currentSize;
20201: 	}
20202:
20203: 	return bestDepth * displacement;
20204: }
20205: #endif // USE_RELIEF_MAPPING
 113: #line 113
 114:
 115: #define LIGHTMAPPING_GLSL
 116:
 117: uniform sampler2D	u_DiffuseMap;
 118: uniform sampler2D	u_MaterialMap;
 119: uniform sampler2D	u_GlowMap;
 120:
 121: uniform float		u_AlphaThreshold;
 122: uniform vec3		u_ViewOrigin;
 123:
 124: IN(smooth) vec3		var_Position;
 125: IN(smooth) vec2		var_TexCoords;
 126: IN(smooth) vec4		var_Color;
 127: IN(smooth) vec3		var_Tangent;
 128: IN(smooth) vec3		var_Binormal;
 129: IN(smooth) vec3		var_Normal;
 130:
 131: uniform sampler2D u_LightMap;
 132: uniform sampler3D u_LightGrid1;
 133:
 134: uniform sampler2D u_DeluxeMap;
 135: uniform sampler3D u_LightGrid2;
 136:
 137: #if defined(USE_LIGHT_MAPPING) || defined(USE_DELUXE_MAPPING)
 138: 	IN(smooth) vec2 var_TexLight;
 139: #endif
 140:
 141: #if defined(USE_GRID_LIGHTING) || defined(USE_GRID_DELUXE_MAPPING)
 142: 	uniform vec3 u_LightGridOrigin;
 143: 	uniform vec3 u_LightGridScale;
 144: #endif
 145:
 146: #if defined(USE_MATERIAL_SYSTEM)
 147: 	uniform bool u_ShowTris;
 148: 	uniform vec3 u_MaterialColour;
 149: #endif
 150:
30000: #line 30000 // shaderProfiler_fp.glsl
30001: /*
30002: ===========================================================================
30003:
30004: Daemon BSD Source Code
30005: Copyright (c) 2024 Daemon Developers
30006: All rights reserved.
30007:
30008: This file is part of the Daemon BSD Source Code (Daemon Source Code).
30009:
30010: Redistribution and use in source and binary forms, with or without
30011: modification, are permitted provided that the following conditions are met:
Warn: Compile log:
0:10218(16): error: could not implicitly convert operands to arithmetic operator
0:10218(38): error: could not implicitly convert operands to modulus (%) operator
0:10218(32): error: operands to arithmetic operators must be numeric
0:10218(11): error: RHS of operator >> must be an integer or integer vector
0:10218(9): error: LHS of `&' must be an integer
0:10218(2): error: `return' with wrong type error, in function `nextIdx' returning uint
0:10230(7): error: initializer of type int cannot be assigned to variable of type uint
0:10230(23): error: could not implicitly convert operands to relational operator
0:10230(23): error: loop condition must be scalar boolean
0:10231(2): error: initializer of type int cannot be assigned to variable of type uint
0:10234(7): error: initializer of type int cannot be assigned to variable of type uint
0:10234(19): error: could not implicitly convert operands to relational operator
0:10234(19): error: loop condition must be scalar boolean
0:10237(6): error: operands of `==' must have the same type
0:10243(10): error: could not implicitly convert operands to arithmetic operator
0:10243(8): error: operands to arithmetic operators must be numeric
0:10243(8): error: operands to arithmetic operators must be numeric

Warn: Unhandled exception (15ShaderException): Couldn't compile fragment shader: lightMapping

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions