1 //          Copyright 2018 - 2021 Michael D. Parker
2 // Distributed under the Boost Software License, Version 1.0.
3 //    (See accompanying file LICENSE_1_0.txt or copy at
4 //          http://www.boost.org/LICENSE_1_0.txt)
5 
6 module bindbc.opengl.bind.nv.nv_30;
7 
8 import bindbc.loader;
9 import bindbc.opengl.config,
10        bindbc.opengl.context;
11 import bindbc.opengl.bind.types;
12 
13 // NV_shader_buffer_load
14 version (GL_NV) enum useNVShaderBufferLoad = true;
15 else version (GL_NV_shader_buffer_load) enum useNVShaderBufferLoad = true;
16 else enum useNVShaderBufferLoad = false;
17 
18 static if (useNVShaderBufferLoad) {
19     private bool _hasNVShaderBufferLoad;
20     bool hasNVShaderBufferLoad() { return _hasNVShaderBufferLoad; }
21 
22     enum uint GL_BUFFER_GPU_ADDRESS_NV = 0x8F1D;
23     enum uint GL_GPU_ADDRESS_NV = 0x8F34;
24     enum uint GL_MAX_SHADER_BUFFER_ADDRESS_NV = 0x8F35;
25 
26     extern (System) @nogc nothrow {
27         alias pglMakeBufferResidentNV = void function(GLenum,GLenum);
28         alias pglMakeBufferNonResidentNV = void function(GLenum);
29         alias pglIsBufferResidentNV = GLboolean function(GLenum);
30         alias pglMakeNamedBufferResidentNV = void function(GLuint,GLenum);
31         alias pglMakeNamedBufferNonResidentNV = void function(GLuint);
32         alias pglIsNamedBufferResidentNV = GLboolean function(GLuint);
33         alias pglGetBufferParameterui64vNV = void function(GLenum,GLenum,GLuint64*);
34         alias pglGetNamedBufferParameterui64vNV = void function(GLuint,GLenum,GLuint64*);
35         alias pglGetIntegerui64vNV = void function(GLenum,GLuint64*);
36         alias pglUniformui64NV = void function(GLint,GLuint64);
37         alias pglUniformui64vNV = void function(GLint,GLsizei,const GLuint64*);
38         alias pglGetUniformui64vNV = void function(GLuint, GLint, GLuint64*);
39         alias pglProgramUniformui64NV = void function(GLuint, GLint, GLuint64);
40         alias pglProgramUniformui64vNV = void function(GLuint, GLint, GLsizei, const GLuint64*);
41     }
42 
43     __gshared {
44         pglMakeBufferResidentNV glMakeBufferResidentNV;
45         pglMakeBufferNonResidentNV glMakeBufferNonResidentNV;
46         pglIsBufferResidentNV glIsBufferResidentNV;
47         pglMakeNamedBufferResidentNV glMakeNamedBufferResidentNV;
48         pglMakeNamedBufferNonResidentNV glMakeNamedBufferNonResidentNV;
49         pglIsNamedBufferResidentNV glIsNamedBufferResidentNV;
50         pglGetBufferParameterui64vNV glGetBufferParameterui64vNV;
51         pglGetNamedBufferParameterui64vNV glGetNamedBufferParameterui64vNV;
52         pglGetIntegerui64vNV glGetIntegerui64vNV;
53         pglUniformui64NV glUniformui64NV;
54         pglUniformui64vNV glUniformui64vNV;
55         pglGetUniformui64vNV glGetUniformui64vNV;
56         pglProgramUniformui64NV glProgramUniformui64NV;
57         pglProgramUniformui64vNV glProgramUniformui64vNV;
58     }
59 
60     private @nogc nothrow
61     bool loadNVShaderBufferLoad(SharedLib lib, GLSupport contextVersion)
62     {
63         lib.bindGLSymbol(cast(void**)&glMakeBufferResidentNV, "glMakeBufferResidentNV");
64         lib.bindGLSymbol(cast(void**)&glMakeBufferNonResidentNV, "glMakeBufferNonResidentNV");
65         lib.bindGLSymbol(cast(void**)&glIsBufferResidentNV, "glIsBufferResidentNV");
66         lib.bindGLSymbol(cast(void**)&glMakeNamedBufferResidentNV, "glMakeNamedBufferResidentNV");
67         lib.bindGLSymbol(cast(void**)&glMakeNamedBufferNonResidentNV, "glMakeNamedBufferNonResidentNV");
68         lib.bindGLSymbol(cast(void**)&glIsNamedBufferResidentNV, "glIsNamedBufferResidentNV");
69         lib.bindGLSymbol(cast(void**)&glGetBufferParameterui64vNV, "glGetBufferParameterui64vNV");
70         lib.bindGLSymbol(cast(void**)&glGetNamedBufferParameterui64vNV, "glGetNamedBufferParameterui64vNV");
71         lib.bindGLSymbol(cast(void**)&glGetIntegerui64vNV, "glGetIntegerui64vNV");
72         lib.bindGLSymbol(cast(void**)&glUniformui64NV, "glUniformui64NV");
73         lib.bindGLSymbol(cast(void**)&glUniformui64vNV, "glUniformui64vNV");
74         lib.bindGLSymbol(cast(void**)&glGetUniformui64vNV, "glGetUniformui64vNV");
75         lib.bindGLSymbol(cast(void**)&glProgramUniformui64NV, "glProgramUniformui64NV");
76         lib.bindGLSymbol(cast(void**)&glProgramUniformui64vNV, "glProgramUniformui64vNV  ");
77         return resetErrorCountGL;
78     }
79 } else enum hasNVShaderBufferLoad = false;
80 
81 package @nogc nothrow
82 void loadNV_30(SharedLib lib, GLSupport contextVersion)
83 {
84     static if(useNVShaderBufferLoad) _hasNVShaderBufferLoad =
85             hasExtension(contextVersion, "GL_NV_shader_buffer_load") &&
86             lib.loadNVShaderBufferLoad(contextVersion);
87 }