Support GL_EXT_draw_instanced extension.

This commit is contained in:
jimihem 2023-12-13 07:22:04 +08:00 committed by GitHub
parent 07e8220d4e
commit a7785ea1ff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 207 additions and 8 deletions

View file

@ -0,0 +1,18 @@
#version 120
#extension GL_EXT_draw_instanced : require
#define ID gl_InstanceID
uniform mat4 gtf_ModelViewProjectionMatrix;
uniform vec3 instanceOffsets[3];
uniform vec4 va[gl_MaxVertexAttribs];
vec4 color;
void main (void)
{
vec4 vertex = vec4(va[0].xy / 3.0, va[0].zw) + vec4(instanceOffsets[ID], 1.0);
color = vec4(0, 0, 0, 0);
for (int i = 1; i < gl_MaxVertexAttribs; i++)
color += va[i];
gl_Position = gtf_ModelViewProjectionMatrix * vertex;
gl_PointSize = 1.0;
}

View file

@ -1,9 +1,8 @@
130.vert
ERROR: 0:59: 'gl_InstanceID' : undeclared identifier
ERROR: 0:59: '=' : cannot convert from ' temp float' to ' temp int'
ERROR: 0:59: 'gl_InstanceID' : required extension not requested: GL_EXT_draw_instanced
ERROR: 0:61: 'texelFetch' : no matching overloaded function found
ERROR: 0:61: 'assign' : cannot convert from ' const float' to ' temp int'
ERROR: 4 compilation errors. No code generated.
ERROR: 3 compilation errors. No code generated.
Shader version: 130
@ -120,7 +119,11 @@ ERROR: node is still EOpNull!
0:46 0.300000
0:57 Function Definition: foo88( ( global void)
0:57 Function Parameters:
0:? Sequence
0:59 Sequence
0:59 Sequence
0:59 move second child to first child ( temp int)
0:59 'id' ( temp int)
0:59 'gl_InstanceID' ( gl_InstanceId int InstanceId)
0:61 'id' ( temp int)
0:63 'gl_ClipVertex' ( gl_ClipVertex 4-component vector of float ClipVertex)
0:64 'gl_Color' ( in 4-component vector of float Color)

View file

@ -0,0 +1,173 @@
GL_EXT_draw_instanced.vert
Shader version: 120
Requested GL_EXT_draw_instanced
0:? Sequence
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 Sequence
0:12 move second child to first child ( temp 4-component vector of float)
0:12 'vertex' ( temp 4-component vector of float)
0:12 add ( temp 4-component vector of float)
0:12 Construct vec4 ( temp 4-component vector of float)
0:12 divide ( temp 2-component vector of float)
0:12 vector swizzle ( temp 2-component vector of float)
0:12 direct index ( temp 4-component vector of float)
0:12 'va' ( uniform 64-element array of 4-component vector of float)
0:12 Constant:
0:12 0 (const int)
0:12 Sequence
0:12 Constant:
0:12 0 (const int)
0:12 Constant:
0:12 1 (const int)
0:12 Constant:
0:12 3.000000
0:12 vector swizzle ( temp 2-component vector of float)
0:12 direct index ( temp 4-component vector of float)
0:12 'va' ( uniform 64-element array of 4-component vector of float)
0:12 Constant:
0:12 0 (const int)
0:12 Sequence
0:12 Constant:
0:12 2 (const int)
0:12 Constant:
0:12 3 (const int)
0:12 Construct vec4 ( temp 4-component vector of float)
0:12 indirect index ( temp 3-component vector of float)
0:12 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
0:12 'gl_InstanceID' ( gl_InstanceId int InstanceId)
0:12 Constant:
0:12 1.000000
0:13 move second child to first child ( temp 4-component vector of float)
0:13 'color' ( global 4-component vector of float)
0:13 Constant:
0:13 0.000000
0:13 0.000000
0:13 0.000000
0:13 0.000000
0:14 Sequence
0:14 Sequence
0:14 move second child to first child ( temp int)
0:14 'i' ( temp int)
0:14 Constant:
0:14 1 (const int)
0:14 Loop with condition tested first
0:14 Loop Condition
0:14 Compare Less Than ( temp bool)
0:14 'i' ( temp int)
0:14 Constant:
0:14 64 (const int)
0:14 Loop Body
0:15 add second child into first child ( temp 4-component vector of float)
0:15 'color' ( global 4-component vector of float)
0:15 indirect index ( temp 4-component vector of float)
0:15 'va' ( uniform 64-element array of 4-component vector of float)
0:15 'i' ( temp int)
0:14 Loop Terminal Expression
0:14 Post-Increment ( temp int)
0:14 'i' ( temp int)
0:16 move second child to first child ( temp 4-component vector of float)
0:16 'gl_Position' ( gl_Position 4-component vector of float Position)
0:16 matrix-times-vector ( temp 4-component vector of float)
0:16 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
0:16 'vertex' ( temp 4-component vector of float)
0:17 move second child to first child ( temp float)
0:17 'gl_PointSize' ( gl_PointSize float PointSize)
0:17 Constant:
0:17 1.000000
0:? Linker Objects
0:? 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
0:? 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
0:? 'va' ( uniform 64-element array of 4-component vector of float)
0:? 'color' ( global 4-component vector of float)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)
Linked vertex stage:
Shader version: 120
Requested GL_EXT_draw_instanced
0:? Sequence
0:10 Function Definition: main( ( global void)
0:10 Function Parameters:
0:12 Sequence
0:12 Sequence
0:12 move second child to first child ( temp 4-component vector of float)
0:12 'vertex' ( temp 4-component vector of float)
0:12 add ( temp 4-component vector of float)
0:12 Construct vec4 ( temp 4-component vector of float)
0:12 divide ( temp 2-component vector of float)
0:12 vector swizzle ( temp 2-component vector of float)
0:12 direct index ( temp 4-component vector of float)
0:12 'va' ( uniform 64-element array of 4-component vector of float)
0:12 Constant:
0:12 0 (const int)
0:12 Sequence
0:12 Constant:
0:12 0 (const int)
0:12 Constant:
0:12 1 (const int)
0:12 Constant:
0:12 3.000000
0:12 vector swizzle ( temp 2-component vector of float)
0:12 direct index ( temp 4-component vector of float)
0:12 'va' ( uniform 64-element array of 4-component vector of float)
0:12 Constant:
0:12 0 (const int)
0:12 Sequence
0:12 Constant:
0:12 2 (const int)
0:12 Constant:
0:12 3 (const int)
0:12 Construct vec4 ( temp 4-component vector of float)
0:12 indirect index ( temp 3-component vector of float)
0:12 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
0:12 'gl_InstanceID' ( gl_InstanceId int InstanceId)
0:12 Constant:
0:12 1.000000
0:13 move second child to first child ( temp 4-component vector of float)
0:13 'color' ( global 4-component vector of float)
0:13 Constant:
0:13 0.000000
0:13 0.000000
0:13 0.000000
0:13 0.000000
0:14 Sequence
0:14 Sequence
0:14 move second child to first child ( temp int)
0:14 'i' ( temp int)
0:14 Constant:
0:14 1 (const int)
0:14 Loop with condition tested first
0:14 Loop Condition
0:14 Compare Less Than ( temp bool)
0:14 'i' ( temp int)
0:14 Constant:
0:14 64 (const int)
0:14 Loop Body
0:15 add second child into first child ( temp 4-component vector of float)
0:15 'color' ( global 4-component vector of float)
0:15 indirect index ( temp 4-component vector of float)
0:15 'va' ( uniform 64-element array of 4-component vector of float)
0:15 'i' ( temp int)
0:14 Loop Terminal Expression
0:14 Post-Increment ( temp int)
0:14 'i' ( temp int)
0:16 move second child to first child ( temp 4-component vector of float)
0:16 'gl_Position' ( gl_Position 4-component vector of float Position)
0:16 matrix-times-vector ( temp 4-component vector of float)
0:16 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
0:16 'vertex' ( temp 4-component vector of float)
0:17 move second child to first child ( temp float)
0:17 'gl_PointSize' ( gl_PointSize float PointSize)
0:17 Constant:
0:17 1.000000
0:? Linker Objects
0:? 'gtf_ModelViewProjectionMatrix' ( uniform 4X4 matrix of float)
0:? 'instanceOffsets' ( uniform 3-element array of 3-component vector of float)
0:? 'va' ( uniform 64-element array of 4-component vector of float)
0:? 'color' ( global 4-component vector of float)
0:? 'gl_InstanceID' ( gl_InstanceId int InstanceId)