DaemonEngine / Daemon

The Dæmon game engine. With some bits of ioq3 and XreaL.
https://unvanquished.net
BSD 3-Clause "New" or "Revised" License
298 stars 61 forks source link

Material system GLSL compile error on Intel #1260

Open slipher opened 3 weeks ago

slipher commented 3 weeks ago

Tested with a clean homepath, only setting the 2 cvars to enable material system.

Calling GetRefAPI…
GL_VENDOR: Intel
GL_RENDERER: Intel(R) UHD Graphics 630
GL_VERSION: 3.2.0 - Build 31.0.101.2115
GL_MAX_TEXTURE_SIZE: 16384
GL_SHADING_LANGUAGE_VERSION: 1.50 - Build 31.0.101.2115
GL_MAX_VERTEX_UNIFORM_COMPONENTS 4096
GL_MAX_VERTEX_ATTRIBS 16
Occlusion query bits: 64
GL_MAX_DRAW_BUFFERS: 8
GL_TEXTURE_MAX_ANISOTROPY_EXT: 16.000000
GL_MAX_RENDERBUFFER_SIZE: 16384
GL_MAX_COLOR_ATTACHMENTS: 8
PIXELFORMAT: color(16-bits)
MODE: -2, 1920 x 1080 fullscreen hz: N/A
Using OpenGL version 3.2, requested: 3.2
^x0f0Using OpenGL 3.x context.
^x0f0Using an OpenGL core profile.
OpenGL 3.x context is not forward compatible.
^x0f0Using OpenGL extensions: GL_ARB_half_float_pixel GL_ARB_texture_float GL_EXT_gpu_shader4 GL_ARB_gpu_shader5 GL_EXT_texture_integer GL_ARB_texture_rg GL_ARB_texture_gather GL_ARB_provoking_vertex GL_EXT_texture_compression_s3tc GL_ARB_texture_compression_rgtc GL_EXT_texture_filter_anisotropic GL_ARB_half_float_vertex GL_ARB_framebuffer_object GL_ARB_get_program_binary GL_ARB_buffer_storage GL_ARB_uniform_buffer_object GL_ARB_map_buffer_range GL_ARB_sync GL_ARB_depth_clamp GL_ARB_compute_shader GL_ARB_bindless_texture GL_ARB_shader_draw_parameters GL_ARB_shader_storage_buffer_object GL_ARB_multi_draw_indirect GL_ARB_shading_language_420pack GL_ARB_explicit_uniform_location GL_ARB_shader_image_load_store GL_ARB_shader_atomic_counters GL_ARB_indirect_parameters
^x0f0Using S3TC (DXTC) texture compression.
^x0f0Using GPU vertex skinning with max 233 bones in a single pass, models are hardware accelerated.
Extracting VM module cgame-amd64.nexe from c:\users\meh\Documents\My Games\Unvanquished\pkg/unvanquished_0.54.0.dpk...
Loading VM module cgame-amd64.nexe...
Using loader args:  c:\unv\Unvanquished\build\vs-deps10\Release/nacl_loader.exe -v -B c:\unv\Unvanquished\build\vs-deps10\Release/irt_core-amd64.nexe -e -i 100:1868 -- c:\unv\tmp\hom323/cgame-amd64.nexe 100
Loaded VM module in 583 msec
Loading Lua plugin using a new Lua state.
Loaded font face 'unifont' [regular] from 'fonts/unifont.ttf'.
Loaded font face 'Roboto' [bold] from 'fonts/Roboto-Bold.ttf'.
Loaded font face 'Roboto' [italic, bold] from 'fonts/Roboto-BoldItalic.ttf'.
Loaded font face 'Roboto' [italic] from 'fonts/Roboto-Italic.ttf'.
Loaded font face 'Roboto' [regular] from 'fonts/Roboto-Regular.ttf'.
Loaded font face 'FontAwesome' [regular] from 'fonts/fontawesome-webfont.ttf'.
Loaded font face 'DejaVu Sans' [regular] from 'fonts/DejaVuSansCondensed.ttf'.
Loaded font face 'Material Icons' [regular] from 'fonts/MaterialIcons-Regular.ttf'.
Invalidating shader binary cache
^3Warn: Source for shader program genericMaterial:
   0: #version 150 core
   1: #define HAVE_EXT_gpu_shader4 1
   2: #extension GL_ARB_gpu_shader5 : require
   3: #define HAVE_ARB_gpu_shader5 1
   4: #extension GL_ARB_texture_gather : require
   5: #define HAVE_ARB_texture_gather 1
   6: #define HAVE_EXT_texture_integer 1
   7: #define HAVE_ARB_texture_rg 1
   8: #define HAVE_ARB_uniform_buffer_object 1
   9: #extension GL_ARB_bindless_texture : require
  10: #define HAVE_ARB_bindless_texture 1
  11: #extension GL_ARB_shader_draw_parameters : require
  12: #define HAVE_ARB_shader_draw_parameters 1
  13: #extension GL_ARB_shader_storage_buffer_object : require
  14: #define HAVE_ARB_shader_storage_buffer_object 1
  15: #define IN in
  16: #define OUT(mode) mode out
  17: #define textureCube texture
  18: #define texture2D texture
  19: #define texture2DProj textureProj
  20: #define texture3D texture
  21: OUT(flat) int in_drawID;
  22: OUT(flat) int in_baseInstance;
  23: #define drawID gl_DrawIDARB
  24: #define baseInstance gl_BaseInstanceARB
  25: 
  26: #ifndef r_highPrecisionRendering
  27: #define r_highPrecisionRendering 1
  28: #endif
  29: #ifndef r_dynamicLight
  30: #define r_dynamicLight 1
  31: #endif
  32: #ifndef r_dynamicLightRenderer
  33: #define r_dynamicLightRenderer 1
  34: #endif
  35: #ifndef r_precomputedLighting
  36: #define r_precomputedLighting 1
  37: #endif
  38: #ifndef r_vertexSkinning
  39: #define r_vertexSkinning 1
  40: #endif
  41: const int MAX_GLSL_BONES = 233;
  42: #ifndef r_halfLambertLighting
  43: #define r_halfLambertLighting 1
  44: #endif
  45: #ifndef r_normalMapping
  46: #define r_normalMapping 1
  47: #endif
  48: #ifndef r_specularMapping
  49: #define r_specularMapping 1
  50: #endif
  51: #ifndef r_physicalMapping
  52: #define r_physicalMapping 1
  53: #endif
  54: #ifndef r_glowMapping
  55: #define r_glowMapping 1
  56: #endif
  57: #ifndef r_zNear
  58: #define r_zNear 3.00000000e+00
  59: #endif
  60: #define USE_MATERIAL_SYSTEM
  61: 
  62: struct Material {
  63:   mat4 u_TextureMatrix;
  64:   vec4 u_ColorModulate;
  65:   vec4 u_Color;
  66:   uvec2 u_ColorMap;
  67:   uvec2 u_DepthMap;
  68:   float u_AlphaThreshold;
  69:   float u_InverseLightFactor;
  70:   float u_VertexInterpolation;
  71:   float u_DepthScale;
  72:   float u_Time;
  73:   int material_padding0;
  74:   int material_padding1;
  75:   int material_padding2;
  76: };
  77: 
  78: layout(std430, binding = 0) readonly buffer materialsSSBO {
  79:   Material materials[];
  80: };
  81: 
  82: #define u_TextureMatrix materials[baseInstance].u_TextureMatrix
  83: #define u_ColorModulate materials[baseInstance].u_ColorModulate
  84: #define u_Color materials[baseInstance].u_Color
  85: #define u_ColorMap_initial uvec2( materials[baseInstance].u_ColorMap )
  86: #define u_DepthMap_initial uvec2( materials[baseInstance].u_DepthMap )
  87: #define u_AlphaThreshold materials[baseInstance].u_AlphaThreshold
  88: #define u_InverseLightFactor materials[baseInstance].u_InverseLightFactor
  89: #define u_VertexInterpolation materials[baseInstance].u_VertexInterpolation
  90: #define u_DepthScale materials[baseInstance].u_DepthScale
  91: #define u_Time materials[baseInstance].u_Time
  92: 
  93: uniform vec3 u_ViewOrigin;
  94: uniform vec3 u_ViewUp;
  95: uniform mat4 u_ModelMatrix;
  96: uniform mat4 u_ModelViewProjectionMatrix;
  97: 
  98: #ifndef r_AmbientScale
  99: #define r_AmbientScale 1.00000000e+00
 100: #endif
 101: #ifndef r_SpecularScale
 102: #define r_SpecularScale 1.00000000e+00
 103: #endif
 104: #ifndef r_zNear
 105: #define r_zNear 3.00000000e+00
 106: #endif
 107: #ifndef M_PI
 108: #define M_PI 3.14159274e+00
 109: #endif
 110: #ifndef MAX_SHADOWMAPS
 111: #define MAX_SHADOWMAPS 5
 112: #endif
 113: #ifndef MAX_REF_LIGHTS
 114: #define MAX_REF_LIGHTS 1024
 115: #endif
 116: #ifndef TILE_SIZE
 117: #define TILE_SIZE 16
 118: #endif
 119: #ifndef r_FBufSize
 120: #define r_FBufSize vec2(1.92000000e+03, 1.08000000e+03)
 121: #endif
 122: #ifndef r_tileStep
 123: #define r_tileStep vec2(8.33333377e-03, 1.48148146e-02)
 124: #endif
 125: /*
 126: ===========================================================================
 127: Copyright (C) 2006-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
 128: 
 129: This file is part of XreaL source code.
 130: 
 131: XreaL source code is free software; you can redistribute it
 132: and/or modify it under the terms of the GNU General Public License as
 133: published by the Free Software Foundation; either version 2 of the License,
 134: or (at your option) any later version.
 135: 
 136: XreaL source code is distributed in the hope that it will be
 137: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
 138: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 139: GNU General Public License for more details.
 140: 
 141: You should have received a copy of the GNU General Public License
 142: along with XreaL source code; if not, write to the Free Software
 143: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 144: ===========================================================================
 145: */
 146: 
 147: /* generic_vp.glsl */
 148: 
10000: #line 10000 // vertexSimple_vp.glsl
10001: /*
10002: ===========================================================================
10003: Copyright (C) 2010 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: // vertexSimple_vp.glsl - simple vertex fetch
10023: 
10024: struct localBasis {
10025:  vec3 normal;
10026:  vec3 tangent, binormal;
10027: };
10028: 
10029: vec3 QuatTransVec(in vec4 quat, in vec3 vec) {
10030:  vec3 tmp = 2.0 * cross( quat.xyz, vec );
10031:  return vec + quat.w * tmp + cross( quat.xyz, tmp );
10032: }
10033: 
10034: void QTangentToLocalBasis( in vec4 qtangent, out localBasis LB ) {
10035:  LB.normal = QuatTransVec( qtangent, vec3( 0.0, 0.0, 1.0 ) );
10036:  LB.tangent = QuatTransVec( qtangent, vec3( 1.0, 0.0, 0.0 ) );
10037:  LB.tangent *= sign( qtangent.w );
10038:  LB.binormal = QuatTransVec( qtangent, vec3( 0.0, 1.0, 0.0 ) );
10039: }
10040: 
10041: #if !defined(USE_VERTEX_ANIMATION) && !defined(USE_VERTEX_SKINNING) && !defined(USE_VERTEX_SPRITE)
10042: 
10043: IN vec3 attr_Position;
10044: IN vec4 attr_Color;
10045: IN vec4 attr_QTangent;
10046: IN vec4 attr_TexCoord0;
10047: 
10048: void VertexFetch(out vec4 position,
10049:       out localBasis normalBasis,
10050:       out vec4 color,
10051:       out vec2 texCoord,
10052:       out vec2 lmCoord)
10053: {
10054:  position = vec4( attr_Position, 1.0 );
10055:  QTangentToLocalBasis( attr_QTangent, normalBasis );
10056:  color    = attr_Color;
10057:  texCoord = attr_TexCoord0.xy;
10058:  lmCoord  = attr_TexCoord0.zw;
10059: }
10060: #endif
  25: #line 25
20000: #line 20000 // vertexSkinning_vp.glsl
20001: /*
20002: ===========================================================================
20003: Copyright (C) 2009-2011 Robert Beckebans <trebor_7@users.sourceforge.net>
20004: 
20005: This file is part of XreaL source code.
20006: 
20007: XreaL source code is free software; you can redistribute it
20008: and/or modify it under the terms of the GNU General Public License as
20009: published by the Free Software Foundation; either version 2 of the License,
20010: or (at your option) any later version.
20011: 
20012: XreaL source code is distributed in the hope that it will be
20013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
20014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20015: GNU General Public License for more details.
20016: 
20017: You should have received a copy of the GNU General Public License
20018: along with XreaL source code; if not, write to the Free Software
20019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20020: ===========================================================================
20021: */
20022: // vertexSkinning_vp.glsl - GPU vertex skinning for skeletal meshes
20023: 
20024: #if defined(USE_VERTEX_SKINNING)
20025: 
20026: IN vec3 attr_Position;
20027: IN vec2 attr_TexCoord0;
20028: IN vec4 attr_Color;
20029: IN vec4 attr_QTangent;
20030: IN vec4 attr_BoneFactors;
20031: 
20032: // even elements are rotation quat, odd elements are translation + scale (in .w)
20033: 
20034: void VertexFetch(out vec4 position,
20035:       out localBasis LB,
20036:       out vec4 color,
20037:       out vec2 texCoord,
20038:       out vec2 lmCoord)
20039: {
20040:  const float scale = 1.0 / 256.0;
20041:  const float weightScale = 1.0 / 255.0;
20042:  localBasis inLB;
20043: 
20044:  // Unpack data from "bone factors". This used to have the index in the high byte and the weight
20045:  // in the low byte, which may seem a bit more logical, but it triggered issues with some
20046:  // Nvidia shader compilers (https://github.com/DaemonEngine/Daemon/issues/472).
20047:  vec4 ipart = floor( attr_BoneFactors * scale );
20048:  vec4 fpart = attr_BoneFactors * scale - ipart;
20049:  // idx = 2 times the original bone index (the index input to boneFactor)
20050:  ivec4 idx = ivec4( fpart * 512.0 );
20051:  vec4 weights = ipart * weightScale;
20052: 
20053:  vec4 quat = u_Bones[ idx.x ];
20054:  vec4 trans = u_Bones[ idx.x + 1 ];
20055: 
20056:  QTangentToLocalBasis( attr_QTangent, inLB );
20057: 
20058:  position.xyz = weights.x * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
20059:  LB.normal = weights.x * (QuatTransVec( quat, inLB.normal ));
20060:  LB.tangent = weights.x * (QuatTransVec( quat, inLB.tangent ));
20061:  LB.binormal = weights.x * (QuatTransVec( quat, inLB.binormal ));
20062:  
20063:  quat = u_Bones[ idx.y ];
20064:  trans = u_Bones[ idx.y + 1 ];
20065: 
20066:  position.xyz += weights.y * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
20067:  LB.normal += weights.y * (QuatTransVec( quat, inLB.normal ));
20068:  LB.tangent += weights.y * (QuatTransVec( quat, inLB.tangent ));
20069:  LB.binormal += weights.y * (QuatTransVec( quat, inLB.binormal ));
20070: 
20071:  quat = u_Bones[ idx.z ];
20072:  trans = u_Bones[ idx.z + 1 ];
20073: 
20074:  position.xyz += weights.z * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
20075:  LB.normal += weights.z * (QuatTransVec( quat, inLB.normal ));
20076:  LB.tangent += weights.z * (QuatTransVec( quat, inLB.tangent ));
20077:  LB.binormal += weights.z * (QuatTransVec( quat, inLB.binormal ));
20078: 
20079:  quat = u_Bones[ idx.w ];
20080:  trans = u_Bones[ idx.w + 1 ];
20081: 
20082:  position.xyz += weights.w * (QuatTransVec( quat, attr_Position ) * trans.w + trans.xyz);
20083:  LB.normal += weights.w * (QuatTransVec( quat, inLB.normal ));
20084:  LB.tangent += weights.w * (QuatTransVec( quat, inLB.tangent ));
20085:  LB.binormal += weights.w * (QuatTransVec( quat, inLB.binormal ));
20086: 
20087:  position.w = 1.0;
20088:  LB.normal   = normalize(LB.normal);
20089:  LB.tangent  = normalize(LB.tangent);
20090:  LB.binormal = normalize(LB.binormal);
20091: 
20092:  color    = attr_Color;
20093:  texCoord = attr_TexCoord0;
20094:  lmCoord  = attr_TexCoord0;
20095: }
20096: #endif
  26: #line 26
30000: #line 30000 // vertexAnimation_vp.glsl
30001: /*
30002: ===========================================================================
30003: Copyright (C) 2010 Robert Beckebans <trebor_7@users.sourceforge.net>
30004: 
30005: This file is part of XreaL source code.
30006: 
30007: XreaL source code is free software; you can redistribute it
30008: and/or modify it under the terms of the GNU General Public License as
30009: published by the Free Software Foundation; either version 2 of the License,
30010: or (at your option) any later version.
30011: 
30012: XreaL source code is distributed in the hope that it will be
30013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
30014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
30015: GNU General Public License for more details.
30016: 
30017: You should have received a copy of the GNU General Public License
30018: along with XreaL source code; if not, write to the Free Software
30019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
30020: ===========================================================================
30021: */
30022: // vertexAnimation_vp.glsl - interpolates .md3/.mdc vertex animations
30023: 
30024: #if defined(USE_VERTEX_ANIMATION)
30025: 
30026: IN vec3 attr_Position;
30027: IN vec4 attr_Color;
30028: IN vec4 attr_QTangent;
30029: IN vec2 attr_TexCoord0;
30030: IN vec3 attr_Position2;
30031: IN vec4 attr_QTangent2;
30032: 
30033: 
30034: void VertexAnimation_P_N(    vec3 fromPosition, vec3 toPosition,
30035:              vec4 fromQTangent, vec4 toQTangent,
30036:              float frac,
30037:              inout vec4 position, inout vec3 normal)
30038: {
30039:  vec3 fromNormal = QuatTransVec( fromQTangent, vec3( 0.0, 0.0, 1.0 ) );
30040:  vec3 toNormal = QuatTransVec( toQTangent, vec3( 0.0, 0.0, 1.0 ) );
30041: 
30042:  position.xyz = 512.0 * mix(fromPosition, toPosition, frac);
30043:  position.w = 1;
30044: 
30045:  normal = normalize(mix(fromNormal, toNormal, frac));
30046: }
30047: 
30048: void VertexFetch(out vec4 position,
30049:       out localBasis LB,
30050:       out vec4 color,
30051:       out vec2 texCoord,
30052:       out vec2 lmCoord)
30053: {
30054:  localBasis fromLB, toLB;
30055: 
30056:  QTangentToLocalBasis( attr_QTangent, fromLB );
30057:  QTangentToLocalBasis( attr_QTangent2, toLB );
30058: 
30059:  position.xyz = 512.0 * mix(attr_Position, attr_Position2, u_VertexInterpolation);
30060:  position.w = 1;
30061:  
30062:  LB.normal = normalize(mix(fromLB.normal, toLB.normal, u_VertexInterpolation));
30063:  LB.tangent = normalize(mix(fromLB.tangent, toLB.tangent, u_VertexInterpolation));
30064:  LB.binormal = normalize(mix(fromLB.binormal, toLB.binormal, u_VertexInterpolation));
30065: 
30066:  color    = attr_Color;
30067:  texCoord = attr_TexCoord0;
30068:  lmCoord  = attr_TexCoord0;
30069: }
30070: #endif
  27: #line 27
40000: #line 40000 // vertexSprite_vp.glsl
40001: /*
40002: ===========================================================================
40003: Copyright (C) 2010 Robert Beckebans <trebor_7@users.sourceforge.net>
40004: 
40005: This file is part of XreaL source code.
40006: 
40007: XreaL source code is free software; you can redistribute it
40008: and/or modify it under the terms of the GNU General Public License as
40009: published by the Free Software Foundation; either version 2 of the License,
40010: or (at your option) any later version.
40011: 
40012: XreaL source code is distributed in the hope that it will be
40013: useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
40014: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
40015: GNU General Public License for more details.
40016: 
40017: You should have received a copy of the GNU General Public License
40018: along with XreaL source code; if not, write to the Free Software
40019: Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
40020: ===========================================================================
40021: */
40022: // vertexSprite_vp.glsl - sprite vertex fetch
40023: 
40024: #if defined(USE_VERTEX_SPRITE)
40025: 
40026: IN vec3 attr_Position;
40027: IN vec4 attr_Color;
40028: IN vec4 attr_TexCoord0;
40029: IN vec4 attr_Orientation;
40030: 
40031: 
40032: float           depthScale;
40033: 
40034: void VertexFetch(out vec4 position,
40035:       out localBasis normalBasis,
40036:       out vec4 color,
40037:       out vec2 texCoord,
40038:       out vec2 lmCoord)
40039: {
40040:  vec2 corner;
40041:  float radius = attr_Orientation.w;
40042:  vec3 normal = normalize( u_ViewOrigin - attr_Position ), up, left;
40043:  float s, c; // sin & cos of rotation factor
40044: 
40045:  corner = sign( attr_TexCoord0.zw );
40046: 
40047:  if( radius <= 0.0 ) {
40048:      // autosprite2 mode, attr_Orientation.xyz contains the up-vector
40049:      up = attr_Orientation.xyz;
40050:      left = radius * normalize( cross( up, normal ) );
40051:      position = vec4( attr_Position + corner.y * left, 1.0 );
40052:  } else {
40053:      // autosprite mode, attr_Orientation.x contains the rotation angle
40054:      left = normalize( cross( u_ViewUp, normal ) );
40055:      up = cross( left, normal );
40056: 
40057:      s = radius * sin( radians( attr_Orientation.x ) );
40058:      c = radius * cos( radians( attr_Orientation.x ) );
40059: 
40060:      // rotate left and up vectors
40061:      vec3 leftOrig = left;
40062:      left = c * left + s * up;
40063:      up = c * up - s * leftOrig;
40064: 
40065:      left *= corner.x;
40066:      up *= corner.y;
40067: 
40068:      position = vec4( attr_Position + left + up, 1.0 );
40069:  }
40070:  normalBasis.normal = normal;
40071:  normalBasis.tangent = normalize( up );
40072:  normalBasis.binormal = normalize( left );
40073: 
40074:  texCoord = 0.5 * corner + 0.5; //attr_TexCoord0.xy;
40075:  lmCoord  = abs( attr_TexCoord0.zw );
40076:  color    = attr_Color;
40077: 
40078:  depthScale = 2.0 * radius;
40079: }
40080: #endif
  28: #line 28
  29: 
  30: #if !defined(USE_VERTEX_SPRITE)
  31: #endif
  32: 
  33: 
  34: #if defined(USE_TCGEN_ENVIRONMENT)
  35: #endif
  36: 
  37: #if defined(USE_VERTEX_SPRITE)
  38: OUT(smooth) vec2  var_FadeDepth;
  39: #elif defined(USE_DEPTH_FADE)
  40: OUT(smooth) vec2  var_FadeDepth;
  41: #endif
  42: 
  43: OUT(smooth) vec2  var_TexCoords;
  44: OUT(smooth) vec4  var_Color;
  45: 
  46: void DeformVertex( inout vec4 pos,
  47:          inout vec3 normal,
  48:          inout vec2 st,
  49:          inout vec4 color,
  50:          in    float time);
  51: 
  52: void  main()
  53: {
50000: #line 50000 // material_vp.glsl
50001: /*
50002: ===========================================================================
50003: 
50004: Daemon BSD Source Code
50005: Copyright (c) 2024 Daemon Developers
50006: All rights reserved.
50007: 
50008: This file is part of the Daemon BSD Source Code (Daemon Source Code).
50009: 
50010: Redistribution and use in source and binary forms, with or without
50011: modification, are permitted provided that the following conditions are met:
50012:     * Redistributions of source code must retain the above copyright
50013:       notice, this list of conditions and the following disclaimer.
50014:     * Redistributions in binary form must reproduce the above copyright
50015:       notice, this list of conditions and the following disclaimer in the
50016:       documentation and/or other materials provided with the distribution.
50017:     * Neither the name of the Daemon developers nor the
50018:       names of its contributors may be used to endorse or promote products
50019:       derived from this software without specific prior written permission.
50020: 
50021: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
50022: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50023: WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
50024: DISCLAIMED. IN NO EVENT SHALL DAEMON DEVELOPERS BE LIABLE FOR ANY
50025: DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
50026: (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50027: LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
50028: ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50029: (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
50030: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
50031: 
50032: ===========================================================================
50033: */
50034: 
50035: /* material_vp.glsl */
50036: 
50037: #if defined(USE_MATERIAL_SYSTEM)
50038: 
50039: #ifdef HAVE_ARB_shader_draw_parameters
50040:   in_drawID = drawID;
50041:   in_baseInstance = baseInstance;
50042: #endif // !HAVE_ARB_shader_draw_parameters
50043: 
50044: #endif // !USE_MATERIAL_SYSTEM
  62: #line 62
  63: 
  64:   vec4 position;
  65:   localBasis LB;
  66:   vec4 color;
  67:   vec2 texCoord, lmCoord;
  68: 
  69:   VertexFetch( position, LB, color, texCoord, lmCoord );
  70:   color = color * u_ColorModulate + u_Color;
  71: 
  72:   DeformVertex( position,
  73:             LB.normal,
  74:             texCoord,
  75:             color,
  76:             u_Time);
  77: 
  78:   // transform vertex position into homogenous clip-space
  79:   gl_Position = u_ModelViewProjectionMatrix * position;
  80: 
  81:   // transform texcoords
  82: #if defined(USE_TCGEN_ENVIRONMENT)
  83:   {
  84:       // TODO: Explain why only the rotational part of u_ModelMatrix is relevant
  85:       position.xyz = mat3(u_ModelMatrix) * position.xyz;
  86: 
  87:       vec3 viewer = normalize(u_ViewOrigin - position.xyz);
  88: 
  89:       float d = dot(LB.normal, viewer);
  90: 
  91:       vec3 reflected = LB.normal * 2.0 * d - viewer;
  92: 
  93:       var_TexCoords = 0.5 + vec2(0.5, -0.5) * reflected.yz;
  94:   }
  95: #elif defined(USE_TCGEN_LIGHTMAP)
  96:   var_TexCoords = (u_TextureMatrix * vec4(lmCoord, 0.0, 1.0)).xy;
  97: #else
  98:   var_TexCoords = (u_TextureMatrix * vec4(texCoord, 0.0, 1.0)).xy;
  99: #endif
 100: 
 101: #if defined(USE_DEPTH_FADE)
 102:   // compute z of end of fading effect
 103:   vec4 fadeDepth = u_ModelViewProjectionMatrix * (position - u_DepthScale * vec4(LB.normal, 0.0));
 104:   var_FadeDepth = fadeDepth.zw;
 105: #elif defined(USE_VERTEX_SPRITE)
 106:   vec4 fadeDepth = u_ModelViewProjectionMatrix * (position - depthScale * vec4(LB.normal, 0.0));
 107:   var_FadeDepth = fadeDepth.zw;
 108: #endif
 109: 
 110:   var_Color = color;
 111: }

^3Warn: Compile log:
ERROR: 4:19: 'readonly' : reserved word 
ERROR: 4:19: 'readonly' : syntax error syntax error
VReaperV commented 3 weeks ago

This seems to be a driver bug. Also, it's reporting an entirely incorrect line number.

slipher commented 2 weeks ago

I tried requesting OpenGL 4.6 (using r_glMajorVersion and r_glMinorVersion) and it compiled! (And worked OK if I turned off GPU occlusion culling.)

So either we're lacking some extension, or Intel's extension loading is buggy. Might we consider requesting a higher core profile than 3.2 when material system is enabled, instead of loading extensions a la carte?

VReaperV commented 2 weeks ago

Intel's extension loading is buggy

This is the case, since the extension spec states:

(insert after third paragraph, p. 73) The memory qualifiers "coherent", "volatile", "restrict", "readonly", and "writeonly" may be used in the declaration of buffer variables (i.e., members of shader storage blocks). ... Additionally, memory qualifiers may also be used in the declaration of shader storage blocks.

Might we consider requesting a higher core profile than 3.2 when material system is enabled, instead of loading extensions a la carte?

I think that's reasonable, yeah. Another thing that might work is changing the shader version.

illwieckz commented 2 weeks ago

This should work:

diff --git a/src/engine/sys/sdl_glimp.cpp b/src/engine/sys/sdl_glimp.cpp
index e9a28ab38..ad317b247 100644
--- a/src/engine/sys/sdl_glimp.cpp
+++ b/src/engine/sys/sdl_glimp.cpp
@@ -1021,13 +1021,15 @@ static rserr_t GLimp_ValidateBestContext(
    For information about core, compatibility and forward profiles,
    see https://www.khronos.org/opengl/wiki/OpenGL_Context */

+   bool testGL46 = r_materialSystem.Get();
+
    struct {
        int major;
        int minor;
        glProfile profile;
        bool testByDefault;
    } glSupportArray[] {
-       { 4, 6, glProfile::CORE, false },
+       { 4, 6, glProfile::CORE, testGL46 },
        { 4, 5, glProfile::CORE, false },
        { 4, 4, glProfile::CORE, false },
        { 4, 3, glProfile::CORE, false },

I recommend to use a dedicated bool variable and not read the cvar directly because the line setting this bool may be extended later with an option to disable the workaround.

VReaperV commented 2 weeks ago

Lower profiles than 4.6 (4.3 and up can be worth checking) might work too.

illwieckz commented 2 weeks ago

Yes, I would be curious to know the lowest version that works, and if an extension is missing, that may help to identify it.

slipher commented 2 weeks ago

4.2 is the lowest that works.