Skip to content

Commit e4f8bf7

Browse files
authored
Merge pull request #178 from ZehMatt/async-shaders
Async shader loading and caching
2 parents 69451cd + f78eb76 commit e4f8bf7

79 files changed

Lines changed: 934 additions & 471 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Dependencies/OpenGL/Gl46.cs‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14444,6 +14444,14 @@ public static void glSpecializeShader(GLuint shader, string pEntryPoint, GLuint
1444414444

1444514445
#endif
1444614446

14447+
public const GLenum GL_COMPLETION_STATUS_KHR = 0x91B1;
14448+
14449+
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
14450+
private delegate void PFNGLMAXSHADERCOMPILERTHREADSKHRPROC(GLuint count);
14451+
private static PFNGLMAXSHADERCOMPILERTHREADSKHRPROC _glMaxShaderCompilerThreadsKHR;
14452+
public static bool glMaxShaderCompilerThreadsKHRLoaded => _glMaxShaderCompilerThreadsKHR != null;
14453+
public static void glMaxShaderCompilerThreadsKHR(GLuint count) => _glMaxShaderCompilerThreadsKHR(count);
14454+
1444714455
/// <summary>
1444814456
/// Loads OpenGL functions using the specified loader delegate.
1444914457
/// </summary>
@@ -15144,6 +15152,10 @@ public unsafe static void Import(GetProcAddressHandler loader)
1514415152
_glMultiDrawElementsIndirectCount = Marshal.GetDelegateForFunctionPointer<PFNGLMULTIDRAWELEMENTSINDIRECTCOUNTPROC>(loader.Invoke("glMultiDrawElementsIndirectCount"));
1514515153
_glPolygonOffsetClamp = Marshal.GetDelegateForFunctionPointer<PFNGLPOLYGONOFFSETCLAMPPROC>(loader.Invoke("glPolygonOffsetClamp"));
1514615154
#endif
15155+
IntPtr maxShaderCompilerThreads = loader.Invoke("glMaxShaderCompilerThreadsKHR");
15156+
if (maxShaderCompilerThreads == IntPtr.Zero)
15157+
maxShaderCompilerThreads = loader.Invoke("glMaxShaderCompilerThreadsARB");
15158+
_glMaxShaderCompilerThreadsKHR = maxShaderCompilerThreads != IntPtr.Zero ? Marshal.GetDelegateForFunctionPointer<PFNGLMAXSHADERCOMPILERTHREADSKHRPROC>(maxShaderCompilerThreads) : null!;
1514715159
}
1514815160
#endif
1514915161
}

‎Game.Assets/sdn/shaders/bloomadd_gl460.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#version 460
22

3-
in vec2 vs_BaseTexCoord;
3+
layout(location = 0) in vec2 vs_BaseTexCoord;
44

55
layout(std140, binding = 3) uniform source_pixel_sharedUBO {
66
bool isAlphaTesting;

‎Game.Assets/sdn/shaders/blurfilter_gl460.fs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#version 460
22

3-
in vec2 vs_CoordTap0;
4-
in vec2 vs_CoordTap1;
5-
in vec2 vs_CoordTap2;
6-
in vec2 vs_CoordTap3;
7-
in vec2 vs_CoordTap1Neg;
8-
in vec2 vs_CoordTap2Neg;
9-
in vec2 vs_CoordTap3Neg;
3+
layout(location = 0) in vec2 vs_CoordTap0;
4+
layout(location = 1) in vec2 vs_CoordTap1;
5+
layout(location = 2) in vec2 vs_CoordTap2;
6+
layout(location = 3) in vec2 vs_CoordTap3;
7+
layout(location = 4) in vec2 vs_CoordTap1Neg;
8+
layout(location = 5) in vec2 vs_CoordTap2Neg;
9+
layout(location = 6) in vec2 vs_CoordTap3Neg;
1010

1111
layout(std140, binding = 6) uniform source_ps_constants {
1212
vec4 ps_const[256];

‎Game.Assets/sdn/shaders/blurfilter_gl460.vs‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ layout(std140, binding = 5) uniform source_vs_constants {
1111
#define vsTapOffs1 vs_const[49].xy
1212
#define vsTapOffs2 vs_const[50].xy
1313

14-
out vec2 vs_CoordTap0;
15-
out vec2 vs_CoordTap1;
16-
out vec2 vs_CoordTap2;
17-
out vec2 vs_CoordTap3;
18-
out vec2 vs_CoordTap1Neg;
19-
out vec2 vs_CoordTap2Neg;
20-
out vec2 vs_CoordTap3Neg;
14+
layout(location = 0) out vec2 vs_CoordTap0;
15+
layout(location = 1) out vec2 vs_CoordTap1;
16+
layout(location = 2) out vec2 vs_CoordTap2;
17+
layout(location = 3) out vec2 vs_CoordTap3;
18+
layout(location = 4) out vec2 vs_CoordTap1Neg;
19+
layout(location = 5) out vec2 vs_CoordTap2Neg;
20+
layout(location = 6) out vec2 vs_CoordTap3Neg;
2121

2222
vec2 FlipV(vec2 uv)
2323
{

‎Game.Assets/sdn/shaders/common_clipplanes_gl460.vs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#ifndef COMMON_CLIPPLANES_GL460_VS
22
#define COMMON_CLIPPLANES_GL460_VS
33

4+
out gl_PerVertex {
5+
vec4 gl_Position;
6+
float gl_ClipDistance[2];
7+
};
8+
49
layout(std140, binding = 7) uniform source_clip_planes {
510
vec4 clipPlanes[2];
611
};

‎Game.Assets/sdn/shaders/downsample_gl460.vs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ layout(std140, binding = 5) uniform source_vs_constants {
1212
#define vsTapOffs2 vs_const[50].xy
1313
#define vsTapOffs3 vs_const[51].xy
1414

15-
out vec2 vs_CoordTap0;
16-
out vec2 vs_CoordTap1;
17-
out vec2 vs_CoordTap2;
18-
out vec2 vs_CoordTap3;
15+
layout(location = 0) out vec2 vs_CoordTap0;
16+
layout(location = 1) out vec2 vs_CoordTap1;
17+
layout(location = 2) out vec2 vs_CoordTap2;
18+
layout(location = 3) out vec2 vs_CoordTap3;
1919

2020
vec2 FlipV(vec2 uv)
2121
{

‎Game.Assets/sdn/shaders/downsample_nohdr_gl460.fs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#version 460
22
// STATIC: "CSTRIKE" "0..1"
33

4-
in vec2 vs_CoordTap0;
5-
in vec2 vs_CoordTap1;
6-
in vec2 vs_CoordTap2;
7-
in vec2 vs_CoordTap3;
4+
layout(location = 0) in vec2 vs_CoordTap0;
5+
layout(location = 1) in vec2 vs_CoordTap1;
6+
layout(location = 2) in vec2 vs_CoordTap2;
7+
layout(location = 3) in vec2 vs_CoordTap3;
88

99
layout(std140, binding = 6) uniform source_ps_constants {
1010
vec4 ps_const[256];

‎Game.Assets/sdn/shaders/eyeglint_gl460.fs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
#version 460
22

3-
in vec2 vs_TexCoord;
4-
in vec2 vs_GlintCenter;
5-
in vec3 vs_GlintColor;
3+
layout(location = 0) in vec2 vs_TexCoord;
4+
layout(location = 1) in vec2 vs_GlintCenter;
5+
layout(location = 2) in vec3 vs_GlintColor;
66

77
out vec4 fragColor;
88

‎Game.Assets/sdn/shaders/eyeglint_gl460.vs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ layout(location = 10) in vec2 v_TexCoord0;
55
layout(location = 11) in vec2 v_TexCoord1;
66
layout(location = 12) in vec3 v_TexCoord2;
77

8-
out vec2 vs_TexCoord;
9-
out vec2 vs_GlintCenter;
10-
out vec3 vs_GlintColor;
8+
layout(location = 0) out vec2 vs_TexCoord;
9+
layout(location = 1) out vec2 vs_GlintCenter;
10+
layout(location = 2) out vec3 vs_GlintColor;
1111

1212
#include "common_clipplanes_gl460.vs"
1313

‎Game.Assets/sdn/shaders/eyes_gl460.fs‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
// DYNAMIC: "WRITE_DEPTH_TO_DESTALPHA" "0..1"
33
// DYNAMIC: "PIXELFOGTYPE" "0..2"
44

5-
in vec2 vs_BaseTexCoord;
6-
in vec2 vs_IrisTexCoord;
7-
in vec2 vs_GlintTexCoord;
8-
in vec3 vs_Color;
9-
in vec4 vs_WorldPos_ProjPosZ;
5+
layout(location = 0) in vec2 vs_BaseTexCoord;
6+
layout(location = 1) in vec2 vs_IrisTexCoord;
7+
layout(location = 2) in vec2 vs_GlintTexCoord;
8+
layout(location = 3) in vec3 vs_Color;
9+
layout(location = 4) in vec4 vs_WorldPos_ProjPosZ;
1010

1111
layout(std140, binding = 6) uniform source_ps_constants {
1212
vec4 ps_const[256];

0 commit comments

Comments
 (0)