KhronosGroup / KhronosGroup/glslang

Doesn't support GL_EXT_draw_instanced

Open
#3,110 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement GLSL/ESSL
Dominant language
C++
Stars
3.6k
Forks
990
Avg merge
1d 2h
Merged PRs (30d)
31

Description

The following shader will report error.

ERROR: 0:61: 'gl_InstanceID' : undeclared identifier

#version 120
#extension GL_EXT_gpu_shader4: enable
#extension GL_EXT_draw_instanced: enable
uniform mat4 viewMat4x4;
#define NUM_INSTANCES 400
uniform vec4 position[NUM_INSTANCES];
uniform vec4 rotation[NUM_INSTANCES];
#define MAX_LIGHTS 2
uniform vec4 light_position[MAX_LIGHTS];
uniform mat4 ViewMat4x4;
varying vec3 lightDir[MAX_LIGHTS];
varying vec3 normal, eyeVec;
mat4 quaternionToMatrix( vec4 q )
{
mat4 result;
float xx,yy,zz,xy,xz,yz,wx,wy,wz;
xx = q.x * q.x;
yy = q.y * q.y;
zz = q.z * q.z;
xy = q.x * q.y;
xz = q.x * q.z;
yz = q.y * q.z;
wx = q.w * q.x;
wy = q.w * q.y;
wz = q.w * q.z;
result[0][0] = 1.0 - 2.0*(yy + zz);
result[0][1] = 2.0*(xy + wz);
result[0][2] = 2.0*(xz - wy);
result[0][3] = 0.0;
result[1][0] = 2.0*(xy - wz);
result[1][1] = 1.0 - 2.0*(xx + zz);
result[1][2] = 2.0*(yz + wx);
result[1][3] = 0.0;
result[2][0] = 2.0*(xz + wy);
result[2][1] = 2.0*(yz - wx);
result[2][2] = 1.0 - 2.0*(xx + yy);
result[2][3] = 0.0;
result[3][0] = 0.0;
result[3][1] = 0.0;
result[3][2] = 0.0;
result[3][3] = 1.0;
return result;
}
mat3 Extract3x3Part( mat4 m )
{
mat3 result;
result[0][0] = m[0][0];
result[0][1] = m[0][1];
result[0][2] = m[0][2];
result[1][0] = m[1][0];
result[1][1] = m[1][1];
result[1][2] = m[1][2];
result[2][0] = m[2][0];
result[2][1] = m[2][1];
result[2][2] = m[2][2];
return result;
}
void main()
{
mat4 transMat4x4;
transMat4x4 = quaternionToMatrix( rotation[gl_InstanceID] );
transMat4x4[3][0] = position[gl_InstanceID].x;
transMat4x4[3][1] = position[gl_InstanceID].y;
transMat4x4[3][2] = position[gl_InstanceID].z;
mat4 modelViewMat = ViewMat4x4 * transMat4x4;
vec4 P = modelViewMat * gl_Vertex;
gl_Position = gl_ProjectionMatrix * P;
eyeVec = -P.xyz;
gl_TexCoord[0] = gl_MultiTexCoord0;
for( int i=0; i

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided shader and its gl_InstanceID error with glslangvalidator, then trace handling for GL_EXT_draw_instanced and GL_EXT_gpu_shader4. Done means the reported shader is accepted with the extension enabled and the relevant validation behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.