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_32;
7 
8 import bindbc.loader;
9 import bindbc.opengl.config,
10        bindbc.opengl.context;
11 import bindbc.opengl.bind.types;
12 
13 // NV_vertex_buffer_unified_memory
14 version (GL_NV) enum useNVVertexBufferUnifiedMemory = true;
15 else version (GL_NV_vertex_buffer_unified_memory) enum useNVVertexBufferUnifiedMemory = true;
16 else enum useNVVertexBufferUnifiedMemory  = false;
17 
18 static if (useNVVertexBufferUnifiedMemory  ) {
19     private bool _hasNVVertexBufferUnifiedMemory;
20     bool hasNVVertexBufferUnifiedMemory() { return _hasNVVertexBufferUnifiedMemory; }
21 
22     enum uint GL_VERTEX_ATTRIB_ARRAY_UNIFIED_NV = 0x8F1E;
23     enum uint GL_ELEMENT_ARRAY_UNIFIED_NV = 0x8F1F;
24     enum uint GL_VERTEX_ATTRIB_ARRAY_ADDRESS_NV = 0x8F20;
25     enum uint GL_TEXTURE_COORD_ARRAY_ADDRESS_NV = 0x8F25;
26     enum uint GL_VERTEX_ARRAY_ADDRESS_NV = 0x8F21;
27     enum uint GL_NORMAL_ARRAY_ADDRESS_NV = 0x8F22;
28     enum uint GL_COLOR_ARRAY_ADDRESS_NV = 0x8F23;
29     enum uint GL_INDEX_ARRAY_ADDRESS_NV = 0x8F24;
30     enum uint GL_EDGE_FLAG_ARRAY_ADDRESS_NV = 0x8F26;
31     enum uint GL_SECONDARY_COLOR_ARRAY_ADDRESS_NV = 0x8F27;
32     enum uint GL_FOG_COORD_ARRAY_ADDRESS_NV = 0x8F28;
33     enum uint GL_ELEMENT_ARRAY_ADDRESS_NV = 0x8F29;
34     enum uint GL_VERTEX_ATTRIB_ARRAY_LENGTH_NV = 0x8F2A;
35     enum uint GL_TEXTURE_COORD_ARRAY_LENGTH_NV = 0x8F2F;
36     enum uint GL_VERTEX_ARRAY_LENGTH_NV = 0x8F2B;
37     enum uint GL_NORMAL_ARRAY_LENGTH_NV = 0x8F2C;
38     enum uint GL_COLOR_ARRAY_LENGTH_NV = 0x8F2D;
39     enum uint GL_INDEX_ARRAY_LENGTH_NV = 0x8F2E;
40     enum uint GL_EDGE_FLAG_ARRAY_LENGTH_NV = 0x8F30;
41     enum uint GL_SECONDARY_COLOR_ARRAY_LENGTH_NV = 0x8F31;
42     enum uint GL_FOG_COORD_ARRAY_LENGTH_NV = 0x8F32;
43     enum uint GL_ELEMENT_ARRAY_LENGTH_NV = 0x8F33;
44 
45     extern (System) @nogc nothrow {
46       alias pglBufferAddressRangeNV = void function(GLenum,GLuint,GLuint64,GLsizeiptr);
47       alias pglVertexFormatNV = void function(GLint,GLenum,GLsizei);
48       alias pglNormalFormatNV = void function(GLenum,GLsizei);
49       alias pglColorFormatNV = void function(GLint,GLenum,GLsizei);
50       alias pglIndexFormatNV = void function(GLenum,GLsizei);
51       alias pglTexCoordFormatNV = void function(GLint,GLenum,GLsizei);
52       alias pglEdgeFlagFormatNV = void function(GLsizei);
53       alias pglSecondaryColorFormatNV = void function(GLint,GLenum,GLsizei);
54       alias pglFogCoordFormatNV = void function(GLenum,GLsizei);
55       alias pglVertexAttribFormatNV = void function(GLuint,GLint,GLenum,GLboolean,GLsizei);
56       alias pglVertexAttribIFormatNV = void function(GLuint,GLint,GLenum,GLsizei);
57       alias pglGetIntegerui64i_vNV = void function(GLenum,GLuint,GLuint64[]);
58     }
59 
60     __gshared {
61       pglBufferAddressRangeNV glBufferAddressRangeNV;
62       pglVertexFormatNV glVertexFormatNV;
63       pglNormalFormatNV glNormalFormatNV;
64       pglColorFormatNV glColorFormatNV;
65       pglIndexFormatNV glIndexFormatNV;
66       pglTexCoordFormatNV glTexCoordFormatNV;
67       pglEdgeFlagFormatNV glEdgeFlagFormatNV;
68       pglSecondaryColorFormatNV glSecondaryColorFormatNV;
69       pglFogCoordFormatNV glFogCoordFormatNV;
70       pglVertexAttribFormatNV glVertexAttribFormatNV;
71       pglVertexAttribIFormatNV glVertexAttribIFormatNV;
72       pglGetIntegerui64i_vNV glGetIntegerui64i_vNV;
73     }
74 
75     private @nogc nothrow
76     bool loadNVShaderBufferLoad(SharedLib lib, GLSupport contextVersion)
77     {
78         lib.bindGLSymbol(cast(void**)&glBufferAddressRangeNV, "glBufferAddressRangeNV");
79         lib.bindGLSymbol(cast(void**)&glVertexFormatNV, "glVertexFormatNV");
80         lib.bindGLSymbol(cast(void**)&glNormalFormatNV, "glNormalFormatNV");
81         lib.bindGLSymbol(cast(void**)&glColorFormatNV, "glColorFormatNV");
82         lib.bindGLSymbol(cast(void**)&glIndexFormatNV, "glIndexFormatNV");
83         lib.bindGLSymbol(cast(void**)&glTexCoordFormatNV, "glTexCoordFormatNV");
84         lib.bindGLSymbol(cast(void**)&glEdgeFlagFormatNV, "glEdgeFlagFormatNV");
85         lib.bindGLSymbol(cast(void**)&glSecondaryColorFormatNV, "glSecondaryColorFormatNV");
86         lib.bindGLSymbol(cast(void**)&glFogCoordFormatNV, "glFogCoordFormatNV");
87         lib.bindGLSymbol(cast(void**)&glVertexAttribFormatNV, "glVertexAttribFormatNV");
88         lib.bindGLSymbol(cast(void**)&glVertexAttribIFormatNV, "glVertexAttribIFormatNV");
89         lib.bindGLSymbol(cast(void**)&glGetIntegerui64i_vNV, "glGetIntegerui64i_vNV");
90 
91         return resetErrorCountGL;
92     }
93 } else enum hasNVVertexBufferUnifiedMemory = false;
94 
95 package @nogc nothrow
96 void loadNV_32(SharedLib lib, GLSupport contextVersion)
97 {
98     static if(useNVVertexBufferUnifiedMemory ) _hasNVVertexBufferUnifiedMemory =
99             hasExtension(contextVersion, "GL_NV_vertex_buffer_unified_memory") &&
100             lib.loadNVShaderBufferLoad(contextVersion);
101 }