├── .gitignore ├── .gitattributes ├── premake5.exe ├── .editorconfig ├── include ├── parallel │ ├── gl │ │ ├── primitives │ │ │ └── radix-sort.hh │ │ └── opengl.hh │ └── amp │ │ └── primitives │ │ └── radix-sort.hh └── GL │ └── wglext.h ├── premake5.lua ├── sources ├── gl │ ├── opengl.cc │ └── primitives │ │ └── radix-sort.cc └── amp │ └── primitives │ └── radix-sort.cc └── tests ├── test-amp.cc └── test-gl.cc /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.exe binary 3 | -------------------------------------------------------------------------------- /premake5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cNoNim/radix-sort/HEAD/premake5.exe -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | [*] 3 | charset = utf-8 4 | end_of_line = lf 5 | indent_size = 2 6 | indent_style = space 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | -------------------------------------------------------------------------------- /include/parallel/gl/primitives/radix-sort.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace parallel { 6 | namespace gl { 7 | 8 | void radix_sort(GL const & gl, buffer key, GLsizeiptr size = 0, buffer index = buffer::empty(), 9 | bool descending = false, bool is_signed = false, bool is_float = false); 10 | 11 | } 12 | } 13 | 14 | -------------------------------------------------------------------------------- /include/parallel/amp/primitives/radix-sort.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace parallel { 6 | namespace amp { 7 | 8 | void radix_sort(concurrency::accelerator_view & av, 9 | concurrency::array_view key, concurrency::array_view index, 10 | bool descending = false, bool is_signed = false, bool is_float = false); 11 | 12 | } 13 | } 14 | 15 | #undef EACH 16 | -------------------------------------------------------------------------------- /premake5.lua: -------------------------------------------------------------------------------- 1 | workspace "parallel" 2 | configurations { "debug", "release" } 3 | platforms { "x86", "x64" } 4 | location "build" 5 | 6 | includedirs "include" 7 | flags "staticruntime" 8 | 9 | filter "configurations:debug" 10 | flags "symbols" 11 | 12 | filter "configurations:release" 13 | defines "NDEBUG" 14 | optimize "full" 15 | 16 | filter "platforms:x86" 17 | architecture "x32" 18 | targetsuffix "-x86" 19 | 20 | filter "platforms:x64" 21 | architecture "x64" 22 | targetsuffix "-x64" 23 | 24 | project "parallel-gl" 25 | kind "staticlib" 26 | language "c++" 27 | 28 | files { "sources/gl/**.cc" 29 | , "include/parallel/gl/**.hh" 30 | , "include/GL/**.h" 31 | } 32 | 33 | project "parallel-amp" 34 | kind "staticlib" 35 | language "c++" 36 | 37 | files { "sources/amp/**.cc" 38 | , "include/parallel/amp/**.hh" 39 | } 40 | 41 | project "parallel-tests-gl" 42 | kind "consoleapp" 43 | language "c++" 44 | links { "parallel-gl" } 45 | 46 | files { "tests/test-gl.cc" } 47 | 48 | project "parallel-tests-amp" 49 | kind "consoleapp" 50 | language "c++" 51 | links { "parallel-amp" } 52 | 53 | files { "tests/test-amp.cc" } 54 | -------------------------------------------------------------------------------- /sources/gl/opengl.cc: -------------------------------------------------------------------------------- 1 | #include "parallel/gl/opengl.hh" 2 | 3 | #include 4 | 5 | namespace parallel { 6 | namespace gl { 7 | 8 | static GL gl; 9 | 10 | GL & GL::instance() { return gl; } 11 | 12 | static PIXELFORMATDESCRIPTOR pfd = { 0 }; 13 | GL & GL::initialize(HDC device, GLDEBUGPROC debug_message_callback, bool debug /*= false*/) { 14 | static char const * names[] = { 15 | #define FUNCTION(name, NAME) "gl" # name, 16 | GL_FUNCTIONS(FUNCTION) 17 | #undef FUNCTION 18 | nullptr 19 | }; 20 | 21 | pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; 22 | SetPixelFormat(device, ChoosePixelFormat(device, &pfd), &pfd); 23 | wglMakeCurrent(device, wglCreateContext(device)); 24 | 25 | auto major = 0, minor = 0; 26 | glGetIntegerv(GL_MAJOR_VERSION, &major); 27 | glGetIntegerv(GL_MINOR_VERSION, &minor); 28 | if (major < 4 || minor < 3) 29 | debug_message_callback(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 30 | GL_VERSION, GL_DEBUG_SEVERITY_HIGH, -1, "OpenGL 4.3 Required", nullptr); 31 | 32 | if (debug) { 33 | auto wglCreateContextAttribsARB 34 | = reinterpret_cast(wglGetProcAddress("wglCreateContextAttribsARB")); 35 | GLint attribs[] = { WGL_CONTEXT_FLAGS_ARB, WGL_CONTEXT_DEBUG_BIT_ARB, 0 }; 36 | auto context = wglGetCurrentContext(); 37 | wglMakeCurrent(device, wglCreateContextAttribsARB(device, nullptr, attribs)); 38 | wglDeleteContext(context); 39 | glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS); 40 | } 41 | 42 | auto gl_name = names; 43 | auto gl_function = reinterpret_cast(this); 44 | while (*gl_name) *gl_function++ = wglGetProcAddress(*gl_name++); 45 | 46 | if(debug_message_callback != nullptr) 47 | this->DebugMessageCallback(debug_message_callback, nullptr); 48 | 49 | glGetIntegerv(GL_UNIFORM_BUFFER_OFFSET_ALIGNMENT, &this->alignment); 50 | 51 | return *this; 52 | } 53 | 54 | void GL::deinitialize() { 55 | auto context = wglGetCurrentContext(); 56 | auto device = wglGetCurrentDC(); 57 | wglMakeCurrent(nullptr, nullptr); 58 | wglDeleteContext(context); 59 | DeleteDC(device); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /tests/test-amp.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #define EACH(i, size) for (auto i = decltype(size)(0); i < size; i++) 11 | 12 | uint64_t ticks(void) { 13 | const uint64_t ticks_per_second = UINT64_C(10000000); 14 | static LARGE_INTEGER freq; 15 | static uint64_t start_time; 16 | LARGE_INTEGER value; 17 | QueryPerformanceCounter(&value); 18 | if (!freq.QuadPart) { 19 | QueryPerformanceFrequency(&freq); 20 | start_time = value.QuadPart; 21 | } 22 | return ((value.QuadPart - start_time) * ticks_per_second) / freq.QuadPart; 23 | } 24 | 25 | template 26 | uint64_t timed(F && f) { 27 | auto start = ticks(); 28 | f(); 29 | return ticks() - start; 30 | }; 31 | 32 | void test_amp(size_t min_count, size_t max_count, bool debug) { 33 | using namespace parallel::amp; 34 | using namespace concurrency; 35 | auto acc = accelerator(); 36 | auto cpu_acc = accelerator(accelerator::cpu_accelerator); 37 | std::wcout << L"C++ AMP" << std::endl 38 | << L"\t" << acc.description << std::endl; 39 | array keys(max_count, cpu_acc.default_view, acc.default_view); 40 | array indexes(max_count, cpu_acc.default_view, acc.default_view); 41 | if (!debug) { 42 | std::cout << "Warming..."; 43 | radix_sort(acc.default_view, keys.view_as(extent<1>(min_count)), indexes.view_as(extent<1>(min_count)), true); 44 | acc.default_view.wait(); 45 | std::cout << "done." << std::endl; 46 | } 47 | for (size_t count = min_count; count <= max_count; count <<= 1) { 48 | EACH(i, count) { 49 | uint32_t j = i == 0 ? 0 : rand() % i; 50 | keys[i] = keys[j]; 51 | keys[j] = int32_t(i - count / 2); 52 | indexes[i] = indexes[j]; 53 | indexes[j] = uint32_t(i); 54 | } 55 | auto elapsed = timed([&acc, &keys, &indexes, &count] { 56 | radix_sort(acc.default_view, keys.view_as(extent<1>(count)), indexes.view_as(extent<1>(count)), true, true); 57 | acc.default_view.wait(); 58 | }); 59 | auto passed = true; 60 | for (size_t i = 0; i < count && passed; i++) 61 | passed &= indexes[i] == count - i - 1; 62 | std::cout << std::setprecision(8) << std::setfill(' ') 63 | << "count " << std::setw(10) << count << " " 64 | << "elapsed " << std::setw(10) << elapsed << " ticks " << std::setw(10) << elapsed / 10000000. << " sec " 65 | << "speed " << std::setw(12) << (count * 10000000ll) / elapsed << " per sec " 66 | << "- " << (passed ? "PASSED" : "FAILED") << std::endl; 67 | } 68 | std::cout << "COMPLETE C++ AMP" << std::endl; 69 | } 70 | 71 | int main(int argc, char const * argv[]) { 72 | #ifndef NDEBUG 73 | bool debug = true; 74 | #else 75 | bool debug = argc > 2; 76 | #endif 77 | size_t min_count = 1024; 78 | size_t max_count = 64 * 1024 * 1024; 79 | if (argc > 1) { 80 | uint64_t count; 81 | std::istringstream(argv[1]) >> count; 82 | if (count < min_count) max_count = min_count; 83 | if (count > UINT_MAX) max_count = UINT_MAX; 84 | min_count = max_count = static_cast(count); 85 | } 86 | srand(max_count); 87 | test_amp(min_count, max_count, debug); 88 | std::cout << "Press [ENTER] for exit..."; 89 | std::cin.ignore(); 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /tests/test-gl.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | #define EACH(i, size) for (auto i = decltype(size)(0); i < size; i++) 12 | 13 | uint64_t ticks(void) { 14 | const uint64_t ticks_per_second = UINT64_C(10000000); 15 | static LARGE_INTEGER freq; 16 | static uint64_t start_time; 17 | LARGE_INTEGER value; 18 | QueryPerformanceCounter(&value); 19 | if (!freq.QuadPart) { 20 | QueryPerformanceFrequency(&freq); 21 | start_time = value.QuadPart; 22 | } 23 | return ((value.QuadPart - start_time) * ticks_per_second) / freq.QuadPart; 24 | } 25 | 26 | template 27 | uint64_t timed(F && f) { 28 | auto start = ticks(); 29 | f(); 30 | return ticks() - start; 31 | }; 32 | 33 | void APIENTRY debug_message( 34 | GLenum source, GLenum type, GLuint id, GLenum severity, 35 | GLsizei, GLchar const * message, void const *) { 36 | std::cout << std::resetiosflags << std::hex << std::setfill('0') 37 | << "0x" << std::setw(8) << source << ":" 38 | << "0x" << std::setw(8) << type << ":" 39 | << "0x" << std::setw(8) << id << ":" 40 | << "0x" << std::setw(8) << severity << std::endl 41 | << message << std::endl; 42 | if (type == GL_DEBUG_TYPE_ERROR) { 43 | std::cout << "Press [ENTER] to exit..."; 44 | std::cin.ignore(); 45 | exit(1); 46 | } 47 | } 48 | 49 | void test_gl(size_t min_count, size_t max_count, bool debug) { 50 | using namespace parallel::gl; 51 | auto window = CreateWindowExA(WS_EX_APPWINDOW, "static", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); 52 | auto device = GetDC(window); 53 | auto & gl = GL::instance().initialize(device, &debug_message, debug); 54 | 55 | std::cout 56 | << "OpenGL " << glGetString(GL_VERSION) << std::endl 57 | << "\t" << glGetString(GL_VENDOR) << std::endl 58 | << "\t" << glGetString(GL_RENDERER) << std::endl; 59 | 60 | struct { buffer objects[2]; } buffers = { 0 }; 61 | buffer::factory(gl, sizeof(buffers) / sizeof(GLuint), buffers.objects); 62 | buffers.objects[0].allocate(gl, sizeof(GLint) * max_count); 63 | buffers.objects[1].allocate(gl, sizeof(GLuint) * max_count); 64 | if (!debug) { 65 | std::cout << "Warming..."; 66 | radix_sort(gl, buffers.objects[0], min_count, buffers.objects[1], true, true); 67 | glFinish(); 68 | std::cout << "done." << std::endl; 69 | } 70 | for (size_t count = min_count; count <= max_count; count <<= 1) { 71 | buffers.objects[0].map(gl, 0, count, 72 | [&buffers](GL const & gl, GLint * keys, GLsizeiptr count) { 73 | buffers.objects[1].map(gl, 0, count, 74 | [&keys](GL const &, GLuint * indexes, GLsizeiptr count) { 75 | EACH(i, count) { 76 | size_t j = i == 0 ? 0 : rand() % i; 77 | keys[i] = keys[j]; 78 | keys[j] = GLint(i - count / 2); 79 | indexes[i] = indexes[j]; 80 | indexes[j] = GLuint(i); 81 | } 82 | }); 83 | }); 84 | auto elapsed = timed([&gl, &buffers, &count] { 85 | radix_sort(gl, buffers.objects[0], count, buffers.objects[1], true, true); 86 | glFinish(); 87 | }); 88 | auto passed = true; 89 | buffers.objects[1].map(gl, 0, count, 90 | [&passed](GL const &, GLuint * ptr, GLsizeiptr count) { 91 | EACH(i, count) 92 | if (!(passed &= ptr[i] == count - i - 1)) break; 93 | }); 94 | std::cout << std::setprecision(8) << std::setfill(' ') 95 | << "count " << std::setw(10) << count << " " 96 | << "elapsed " << std::setw(10) << elapsed << " ticks " << std::setw(10) << elapsed / 10000000. << " sec " 97 | << "speed " << std::setw(12) << (count * 10000000ll) / elapsed << " per sec " 98 | << "- " << (passed ? "PASSED" : "FAILED") << std::endl; 99 | } 100 | std::cout << "COMPLETE OpenGL" << std::endl; 101 | gl.deinitialize(); 102 | } 103 | 104 | int main(int argc, char const * argv[]) { 105 | #ifndef NDEBUG 106 | bool debug = true; 107 | #else 108 | bool debug = argc > 2; 109 | #endif 110 | size_t min_count = 1024; 111 | size_t max_count = 64 * 1024 * 1024; 112 | if (argc > 1) { 113 | uint64_t count; 114 | std::istringstream(argv[1]) >> count; 115 | if (count < min_count) max_count = min_count; 116 | if (count > UINT_MAX) max_count = UINT_MAX; 117 | min_count = max_count = static_cast(count); 118 | } 119 | srand(max_count); 120 | test_gl(min_count, max_count, debug); 121 | std::cout << "Press [ENTER] for exit..."; 122 | std::cin.ignore(); 123 | return 0; 124 | } 125 | -------------------------------------------------------------------------------- /include/parallel/gl/opengl.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define WIN32_LEAN_AND_MEAN 1 4 | #define WIN32_EXTRA_LEAN 5 | #include 6 | #include 7 | #include 8 | 9 | #pragma comment(lib, "opengl32.lib") 10 | 11 | #define EACH(i, size) for (GLsizeiptr i = 0; i < size; i++) 12 | 13 | #define BUFFER_OFFSET(i) ((char *)NULL + (i)) 14 | 15 | #define _STR(x) #x 16 | #define STR(x) _STR(x) 17 | 18 | #define GLSL(...) STR(__VA_ARGS__) "\n" 19 | #define GLSL_DEFINE(name, ...) "#define " STR(name) " " GLSL(__VA_ARGS__) 20 | 21 | #define GL_FUNCTIONS(FUNCTION) \ 22 | FUNCTION(BindBuffer, BINDBUFFER) \ 23 | FUNCTION(BindBufferBase, BINDBUFFERBASE) \ 24 | FUNCTION(BindBufferRange, BINDBUFFERRANGE) \ 25 | FUNCTION(BindProgramPipeline, BINDPROGRAMPIPELINE) \ 26 | FUNCTION(GetBufferParameteriv, GETBUFFERPARAMETERIV) \ 27 | FUNCTION(GetBufferParameteri64v, GETBUFFERPARAMETERI64V) \ 28 | FUNCTION(BufferData, BUFFERDATA) \ 29 | FUNCTION(BufferSubData, BUFFERSUBDATA) \ 30 | FUNCTION(CopyBufferSubData, COPYBUFFERSUBDATA) \ 31 | FUNCTION(CreateShaderProgramv, CREATESHADERPROGRAMV) \ 32 | FUNCTION(DebugMessageCallback, DEBUGMESSAGECALLBACK) \ 33 | FUNCTION(DebugMessageInsert, DEBUGMESSAGEINSERT) \ 34 | FUNCTION(DispatchCompute, DISPATCHCOMPUTE) \ 35 | FUNCTION(GenBuffers, GENBUFFERS) \ 36 | FUNCTION(GenProgramPipelines, GENPROGRAMPIPELINES) \ 37 | FUNCTION(GetProgramInfoLog, GETPROGRAMINFOLOG) \ 38 | FUNCTION(GetProgramiv, GETPROGRAMIV) \ 39 | FUNCTION(MapBuffer, MAPBUFFER) \ 40 | FUNCTION(MapBufferRange, MAPBUFFERRANGE) \ 41 | FUNCTION(MemoryBarrier, MEMORYBARRIER) \ 42 | FUNCTION(UnmapBuffer, UNMAPBUFFER) \ 43 | FUNCTION(UseProgram, USEPROGRAM) \ 44 | FUNCTION(UseProgramStages, USEPROGRAMSTAGES) 45 | 46 | namespace parallel { 47 | namespace gl { 48 | 49 | struct GL { 50 | #define FUNCTION(name, NAME) \ 51 | PFNGL ## NAME ## PROC name; 52 | GL_FUNCTIONS(FUNCTION) 53 | #undef FUNCTION 54 | GLint alignment; 55 | GL & initialize(HDC device, GLDEBUGPROC debug_message_callback, bool debug = false); 56 | void deinitialize(); 57 | 58 | static GL & instance(); 59 | }; 60 | 61 | struct buffer 62 | { 63 | GLuint id; 64 | template 65 | void allocate(GL const & gl, GLsizeiptr size) { 66 | gl.BindBuffer(GL_COPY_WRITE_BUFFER, id); 67 | gl.BufferData(GL_COPY_WRITE_BUFFER, size, nullptr, USAGE); 68 | } 69 | template 70 | GLsizeiptr allocate(GL const & gl, GLsizeiptr size, GLsizei count, bool aligned = false) { 71 | auto aligned_size = aligned 72 | ? ((size + gl.alignment - 1) / gl.alignment) * gl.alignment 73 | : size * count; 74 | gl.BindBuffer(GL_COPY_WRITE_BUFFER, id); 75 | gl.BufferData(GL_COPY_WRITE_BUFFER, aligned_size * count, nullptr, USAGE); 76 | return aligned_size; 77 | } 78 | void free(GL const & gl) { 79 | gl.BindBuffer(GL_COPY_WRITE_BUFFER, id); 80 | gl.BufferData(GL_COPY_WRITE_BUFFER, 0, nullptr, GL_DYNAMIC_COPY); 81 | } 82 | template 83 | void sub_data(GL const & gl, T && data, GLsizeiptr offset) { 84 | gl.BindBuffer(GL_COPY_WRITE_BUFFER, id); 85 | gl.BufferSubData(GL_COPY_WRITE_BUFFER, offset, sizeof(T), &data); 86 | } 87 | template 88 | void sub_data(GL const & gl, T (&array)[N], GLsizeiptr alignment) { 89 | gl.BindBuffer(GL_COPY_WRITE_BUFFER, id); 90 | EACH (i, N) 91 | gl.BufferSubData(GL_COPY_WRITE_BUFFER, i * alignment, sizeof(T), &array[i]); 92 | } 93 | template 94 | void map(GL const & gl, F && f) { 95 | auto buffer_size = size(gl); 96 | gl.BindBuffer(TARGET, id); 97 | auto ptr = reinterpret_cast(gl.MapBuffer(TARGET, ACCESS)); 98 | f(gl, ptr, buffer_size / sizeof(T)); 99 | gl.UnmapBuffer(TARGET); 100 | } 101 | template 102 | void map(GL const & gl, GLsizeiptr offset, GLsizeiptr count, F && f) { 103 | gl.BindBuffer(TARGET, id); 104 | auto ptr = reinterpret_cast(gl.MapBufferRange(TARGET, offset * sizeof(T), count * sizeof(T), ACCESS)); 105 | f(gl, ptr, count); 106 | gl.UnmapBuffer(TARGET); 107 | } 108 | template 109 | void bind(GL const & gl, GLuint index) { gl.BindBufferBase(TARGET, index, id); } 110 | template 111 | void bind(GL const & gl, GLuint index, GLsizeiptr offset, GLsizeiptr size) { 112 | gl.BindBufferRange(TARGET, index, id, offset, size); 113 | } 114 | GLsizeiptr size(GL const & gl) { 115 | if (sizeof(GLsizeiptr) == sizeof(GLint)) { 116 | GLint size = 0; 117 | gl.BindBuffer(GL_COPY_READ_BUFFER, id); 118 | gl.GetBufferParameteriv(GL_COPY_READ_BUFFER, GL_BUFFER_SIZE, &size); 119 | return (GLsizeiptr)size; 120 | } else { 121 | GLint64 size = 0; 122 | gl.BindBuffer(GL_COPY_READ_BUFFER, id); 123 | gl.GetBufferParameteri64v(GL_COPY_READ_BUFFER, GL_BUFFER_SIZE, &size); 124 | return (GLsizeiptr)size; 125 | } 126 | } 127 | bool is_empty() { return id == 0; } 128 | static buffer empty() { 129 | return buffer{ 0 }; 130 | } 131 | static void factory(GL const & gl, GLsizei count, buffer * buffers) { 132 | gl.GenBuffers(count, reinterpret_cast(buffers)); 133 | } 134 | }; 135 | 136 | template 137 | struct program { 138 | GLuint id; 139 | }; 140 | 141 | template<> 142 | struct program { 143 | GLuint id; 144 | void dispatch(GL const & gl, GLuint x = 1, GLuint y = 1, GLuint z = 1) { 145 | gl.UseProgram(id); 146 | gl.DispatchCompute(x, y, z); 147 | } 148 | }; 149 | 150 | template 151 | program 152 | make_program(GL const & gl, Sources... sources) { 153 | GLchar const * array_sources[] = { 154 | "#version 430 core\n" 155 | GLSL( 156 | precision highp float; 157 | precision highp int; 158 | layout(std140, column_major) uniform; 159 | layout(std430, column_major) buffer; 160 | ), sources... 161 | }; 162 | auto id = gl.CreateShaderProgramv(TYPE, ARRAYSIZE(array_sources), array_sources); 163 | auto status = GL_TRUE; 164 | gl.GetProgramiv(id, GL_LINK_STATUS, &status); 165 | if (GL_TRUE != status) { 166 | char info[1024]; 167 | gl.GetProgramInfoLog(id, sizeof(info), nullptr, info); 168 | gl.DebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_ERROR, 169 | GL_LINK_STATUS, GL_DEBUG_SEVERITY_HIGH, -1, info); 170 | } 171 | return program { id }; 172 | } 173 | 174 | using vertex_program = program; 175 | using fragment_program = program; 176 | using compute_program = program; 177 | 178 | struct pipeline { 179 | GLuint id; 180 | pipeline(GL const & gl) : id(make(gl)) {} 181 | pipeline & use(GL const & gl, program const & program) { gl.UseProgramStages(id, GL_VERTEX_SHADER_BIT, program.id); return *this; } 182 | pipeline & use(GL const & gl, program const & program) { gl.UseProgramStages(id, GL_FRAGMENT_SHADER_BIT, program.id); return *this; } 183 | void rect(GL const & gl) { 184 | gl.UseProgram(0); 185 | gl.BindProgramPipeline(id); 186 | glRects(-1, -1, 1, 1); 187 | } 188 | private: 189 | static GLuint 190 | make(GL const & gl) { 191 | auto id = 0u; 192 | gl.GenProgramPipelines(1, &id); 193 | return id; 194 | } 195 | }; 196 | 197 | } 198 | } 199 | 200 | #undef EACH 201 | -------------------------------------------------------------------------------- /sources/amp/primitives/radix-sort.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, Oleg Ageev 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | #include "parallel/amp/primitives/radix-sort.hh" 28 | 29 | #include 30 | #include 31 | #include 32 | 33 | #define WG_COUNT 64 34 | #define WG_SIZE 256 35 | #define BLOCK_SIZE 1024 // (4 * WG_SIZE) 36 | #define BITS_PER_PASS 4 37 | #define RADICES 16 // (1 << BITS_PER_PASS) 38 | #define RADICES_MASK 0xf // (RADICES - 1) 39 | 40 | #define BARRIER t_idx.barrier.wait() 41 | 42 | #define EACH(i, count) for (auto i = decltype(count)(0); i < count; i++) 43 | 44 | using namespace concurrency; 45 | using namespace concurrency::graphics; 46 | 47 | template T to_mask(T n) restrict(cpu, amp) { return (1 << n) - 1; } 48 | template T bfe(T src, uint shift, uint n) restrict(cpu, amp) 49 | { return (src >> shift) & to_mask(n); } 50 | template T bfe_sign(T src, uint shift, uint n) restrict(cpu, amp) 51 | { return ((((src >> shift) & to_mask(n - 1)) 52 | ^ to_mask(n - 1)) 53 | & to_mask(n - 1)) 54 | | ((src >> shift) & (1 << (n - 1))); } 55 | 56 | template 57 | T clamp(T x, T minVal, T maxVal) restrict(cpu, amp) { return min(max(x, minVal), maxVal); } 58 | template 59 | auto mix(T x, S y, uint_4 a) restrict(cpu, amp) { return x * a + y * (1 - a); } 60 | template 61 | uint_4 lessThan(T x, T y) restrict(cpu, amp) { 62 | return uint_4(x.x < y.x, x.y < y.y, x.z < y.z, x.w < y.w); 63 | } 64 | template 65 | uint_4 equal(T x, T y) restrict(cpu, amp) { 66 | return uint_4(x.x == y.x, x.y == y.y, x.z == y.z, x.w == y.w); 67 | } 68 | template 69 | typename short_vector::type 70 | get_by(T src, uint_4 idx) restrict(cpu, amp) { 71 | return typename short_vector::type(src[idx.x], src[idx.y], src[idx.z], src[idx.w]); 72 | } 73 | template 74 | typename short_vector::type 75 | get_by(T * src, uint_4 idx) restrict(cpu, amp) { 76 | return typename short_vector::type(src[idx.x], src[idx.y], src[idx.z], src[idx.w]); 77 | } 78 | template 79 | void inc_by(T src, uint_4 idx, uint_4 flag) restrict(cpu, amp) { 80 | atomic_fetch_add(&src[idx.x], flag.x); 81 | atomic_fetch_add(&src[idx.y], flag.y); 82 | atomic_fetch_add(&src[idx.z], flag.z); 83 | atomic_fetch_add(&src[idx.w], flag.w); 84 | } 85 | template 86 | void set_by(T dest, uint_4 idx, S val) restrict(cpu, amp) { 87 | dest[idx.x] = val.x; 88 | dest[idx.y] = val.y; 89 | dest[idx.z] = val.z; 90 | dest[idx.w] = val.w; 91 | } 92 | template 93 | void set_by(T dest, uint_4 idx, S val, uint_4 flag) restrict(cpu, amp) { 94 | if (flag.x) dest[idx.x] = val.x; 95 | if (flag.y) dest[idx.y] = val.y; 96 | if (flag.z) dest[idx.z] = val.z; 97 | if (flag.w) dest[idx.w] = val.w; 98 | } 99 | struct blocks_info { uint count; uint offset; }; 100 | blocks_info get_blocks_info(const uint n, const uint wg_idx) restrict(cpu, amp) { 101 | const uint aligned = n + BLOCK_SIZE - (n % BLOCK_SIZE); 102 | const uint blocks = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; 103 | const uint blocks_per_wg = (blocks + WG_COUNT - 1) / WG_COUNT; 104 | const int n_blocks = int(aligned / BLOCK_SIZE) - int(blocks_per_wg * wg_idx); 105 | return blocks_info { 106 | uint(clamp(n_blocks, 0, int(blocks_per_wg))), 107 | blocks_per_wg * BLOCK_SIZE * wg_idx 108 | }; 109 | } 110 | uint prefix_sum(uint data, uint & total_sum, tiled_index t_idx) restrict(amp) { 111 | tile_static uint local_sort[WG_SIZE * 2]; 112 | const auto LC_IDX = t_idx.local[0]; 113 | local_sort[LC_IDX] = 0; 114 | const auto lc_idx = LC_IDX + WG_SIZE; 115 | local_sort[lc_idx] = data; 116 | BARRIER; 117 | 118 | for (uint i = 1; i < WG_SIZE; i <<= 1) { 119 | uint tmp = local_sort[lc_idx - i]; 120 | BARRIER; 121 | local_sort[lc_idx] += tmp; 122 | BARRIER; 123 | } 124 | total_sum = local_sort[WG_SIZE * 2 - 1]; 125 | return local_sort[lc_idx - 1]; 126 | } 127 | uint prefix_scan(uint_4 & v) restrict(cpu, amp) { 128 | uint sum = 0; 129 | uint tmp; 130 | tmp = v.x; v.x = sum; sum += tmp; 131 | tmp = v.y; v.y = sum; sum += tmp; 132 | tmp = v.z; v.z = sum; sum += tmp; 133 | tmp = v.w; v.w = sum; sum += tmp; 134 | return sum; 135 | } 136 | void sort_bits(uint_4 & sort, uint_4 & sort_val, 137 | tiled_index t_idx, uint * local_sort, uint * local_sort_val, 138 | uint shift, bool descending, bool is_signed) restrict(amp) { 139 | auto signs = bfe_sign(sort, shift, BITS_PER_PASS); 140 | const auto LC_IDX = t_idx.local[0]; 141 | const auto addr = 4 * LC_IDX + uint_4(0, 1, 2, 3); 142 | EACH(i_bit, BITS_PER_PASS) { 143 | const auto mask = (1 << i_bit); 144 | const auto cmp = equal((is_signed ? signs : (sort >> shift)) & mask, uint_4(descending != is_signed) * mask); 145 | auto key = cmp; 146 | uint total; 147 | key += prefix_sum(prefix_scan(key), total, t_idx); 148 | BARRIER; 149 | 150 | const uint_4 dest_addr = mix(key, addr - key + total, cmp); 151 | set_by(local_sort, dest_addr, sort); 152 | set_by(local_sort_val, dest_addr, sort_val); 153 | BARRIER; 154 | 155 | sort = get_by(local_sort, addr); 156 | sort_val = get_by(local_sort_val, addr); 157 | BARRIER; 158 | 159 | if (is_signed) { 160 | set_by(local_sort, dest_addr, signs); 161 | BARRIER; 162 | 163 | signs = get_by(local_sort, addr); 164 | BARRIER; 165 | } 166 | } 167 | } 168 | 169 | void histogram_count( 170 | tiled_index t_idx, 171 | array_view data_key_in, 172 | array_view histogram, 173 | uint shift, 174 | bool descending, 175 | bool is_signed) restrict(amp) { 176 | tile_static uint local_histogram[WG_SIZE * RADICES]; 177 | const auto LC_IDX = t_idx.local[0]; 178 | const auto WG_IDX = t_idx.tile[0]; 179 | EACH(i, RADICES) local_histogram[i * WG_SIZE + LC_IDX] = 0; 180 | BARRIER; 181 | const auto n = data_key_in.extent.size(); 182 | const auto blocks = get_blocks_info(n, WG_IDX); 183 | auto addr = blocks.offset + 4 * LC_IDX + uint_4(0, 1, 2, 3); 184 | EACH(i_block, blocks.count) { 185 | const auto less_than = lessThan(addr, uint_4(n)); 186 | const auto data_vec = get_by(data_key_in, addr); 187 | const auto k = is_signed 188 | ? bfe_sign(data_vec, shift, BITS_PER_PASS) 189 | : bfe(data_vec, shift, BITS_PER_PASS); 190 | const auto key = descending != is_signed ? (RADICES_MASK - k) : k; 191 | const auto local_key = key * WG_SIZE + LC_IDX; 192 | inc_by(local_histogram, local_key, less_than); 193 | addr += BLOCK_SIZE; 194 | } 195 | BARRIER; 196 | if (LC_IDX < RADICES) { 197 | uint sum = 0; EACH(i, WG_SIZE) sum += local_histogram[LC_IDX * WG_SIZE + i]; 198 | histogram[LC_IDX * WG_COUNT + WG_IDX] = sum; 199 | } 200 | } 201 | 202 | void prefix_sum(tiled_index t_idx, array_view histogram) restrict(amp) { 203 | tile_static uint seed; 204 | const auto LC_IDX = t_idx.local[0]; 205 | const auto WG_IDX = t_idx.tile[0]; 206 | seed = 0; 207 | BARRIER; 208 | 209 | EACH(d, RADICES) { 210 | auto val = 0u; 211 | auto idx = d * WG_COUNT + LC_IDX; 212 | if (LC_IDX < WG_COUNT) val = histogram[idx]; 213 | uint total; 214 | auto res = prefix_sum(val, total, t_idx); 215 | if (LC_IDX < WG_COUNT) histogram[idx] = res + seed; 216 | if (LC_IDX == WG_COUNT - 1) seed += res + val; 217 | BARRIER; 218 | } 219 | } 220 | 221 | void permute( 222 | tiled_index t_idx, 223 | array_view data_key_in, 224 | array_view data_index_in, 225 | array_view data_key_out, 226 | array_view data_index_out, 227 | array_view histogram, 228 | uint shift, 229 | bool descending, 230 | bool is_signed, 231 | bool key_index) restrict(amp) { 232 | tile_static uint local_histogram_to_carry[RADICES]; 233 | tile_static uint local_histogram[RADICES * 2]; 234 | tile_static uint local_sort[BLOCK_SIZE]; 235 | tile_static uint local_sort_val[BLOCK_SIZE]; 236 | const auto LC_IDX = t_idx.local[0]; 237 | const auto WG_IDX = t_idx.tile[0]; 238 | const uint carry_idx = (descending && !is_signed ? (RADICES_MASK - LC_IDX) : LC_IDX); 239 | if (LC_IDX < RADICES) local_histogram_to_carry[LC_IDX] = histogram[carry_idx * WG_COUNT + WG_IDX]; 240 | BARRIER; 241 | 242 | const uint def = (uint(!descending) * 0xffffffff) ^ (uint(is_signed) * 0x80000000); 243 | const uint n = data_key_in.extent.size(); 244 | const auto blocks = get_blocks_info(n, WG_IDX); 245 | uint_4 addr = blocks.offset + 4 * LC_IDX + uint_4(0, 1, 2, 3); 246 | EACH(i_block, blocks.count) { 247 | const auto less_than = lessThan(addr, uint_4(n)); 248 | const auto less_than_val = lessThan(addr, uint_4(key_index ? n : 0)); 249 | const auto data_vec = get_by(data_key_in, addr); 250 | const auto data_val_vec = get_by(data_index_in, addr); 251 | auto sort = mix(data_vec, def, less_than); 252 | auto sort_val = mix(data_val_vec, 0, less_than_val); 253 | sort_bits(sort, sort_val, t_idx, local_sort, local_sort_val, shift, descending, is_signed); 254 | auto k = is_signed 255 | ? bfe_sign(sort, shift, BITS_PER_PASS) 256 | : bfe(sort, shift, BITS_PER_PASS); 257 | const auto key = (descending != is_signed) ? (RADICES_MASK - k) : k; 258 | const auto hist_key = key + RADICES; 259 | const auto local_key = key + (LC_IDX / RADICES) * RADICES; 260 | k = is_signed ? key : k; 261 | const auto offset = get_by(local_histogram_to_carry, k) + 4 * LC_IDX + uint_4(0, 1, 2, 3); 262 | local_sort[LC_IDX] = 0; 263 | BARRIER; 264 | 265 | inc_by(local_sort, local_key, less_than); 266 | BARRIER; 267 | 268 | const auto lc_idx = LC_IDX + RADICES; 269 | if (LC_IDX < RADICES) { 270 | local_histogram[LC_IDX] = 0; 271 | uint sum = 0; EACH(i, WG_SIZE / RADICES) sum += local_sort[i * RADICES + LC_IDX]; 272 | local_histogram_to_carry[carry_idx] += local_histogram[lc_idx] = sum; 273 | } 274 | BARRIER; 275 | 276 | uint tmp = 0; 277 | if (LC_IDX < RADICES) local_histogram[lc_idx] = local_histogram[lc_idx - 1]; 278 | BARRIER; 279 | if (LC_IDX < RADICES) tmp = local_histogram[lc_idx - 3] 280 | + local_histogram[lc_idx - 2] 281 | + local_histogram[lc_idx - 1]; 282 | BARRIER; 283 | if (LC_IDX < RADICES) local_histogram[lc_idx] += tmp; 284 | BARRIER; 285 | if (LC_IDX < RADICES) tmp = local_histogram[lc_idx - 12] 286 | + local_histogram[lc_idx - 8] 287 | + local_histogram[lc_idx - 4]; 288 | BARRIER; 289 | if (LC_IDX < RADICES) local_histogram[lc_idx] += tmp; 290 | BARRIER; 291 | 292 | const auto out_key = offset - get_by(local_histogram, hist_key); 293 | set_by(data_key_out, out_key, sort, less_than); 294 | set_by(data_index_out, out_key, sort_val, less_than_val); 295 | BARRIER; 296 | addr += BLOCK_SIZE; 297 | } 298 | } 299 | 300 | void flip_float( 301 | tiled_index t_idx, 302 | array_view data, 303 | bool invert) restrict(amp) { 304 | const auto LC_IDX = t_idx.local[0]; 305 | const auto WG_IDX = t_idx.tile[0]; 306 | const uint n = data.extent.size(); 307 | const auto blocks = get_blocks_info(n, WG_IDX); 308 | uint_4 addr = blocks.offset + 4 * LC_IDX + uint_4(0, 1, 2, 3); 309 | EACH(i_block, blocks.count) { 310 | const auto less_than = lessThan(addr, uint_4(n)); 311 | const auto data_vec = get_by(data, addr); 312 | auto value = mix(data_vec, 0, less_than); 313 | auto mask = invert 314 | ? (((value >> 31) - 1) | 0x80000000) 315 | : uint_4(-int_4(value >> 31) | 0x80000000); 316 | value ^= mask; 317 | set_by(data, addr, value, less_than); 318 | addr += BLOCK_SIZE; 319 | } 320 | } 321 | 322 | 323 | namespace parallel { 324 | namespace amp { 325 | 326 | void radix_sort(concurrency::accelerator_view & av, 327 | concurrency::array_view key, concurrency::array_view index, 328 | bool descending /*= false*/, bool is_signed /*= false*/, bool is_float /*= false*/) { 329 | array histogram(WG_COUNT * RADICES, av); 330 | array key_out(key.extent, av); 331 | array index_out(index.extent, av); 332 | auto tile = extent<1>(WG_COUNT * WG_SIZE).tile(); 333 | auto prefix_tile = extent<1>(WG_SIZE).tile(); 334 | array_view data_key_in = key; 335 | array_view data_key_out = key_out; 336 | array_view data_index_in = index; 337 | array_view data_index_out = index_out; 338 | auto key_index = index.extent.size() != 0; 339 | for (uint shift = 0; shift < 32; shift += 4) { 340 | if (is_float && shift == 0) { 341 | concurrency::parallel_for_each(av, tile, 342 | [=](tiled_index t_idx) restrict(amp) { 343 | flip_float(t_idx, data_key_in, false); 344 | }); 345 | } 346 | 347 | concurrency::parallel_for_each(av, tile, 348 | [=, &histogram](tiled_index t_idx) restrict(amp) { 349 | histogram_count(t_idx, data_key_in, histogram, 350 | shift, descending, is_signed && shift == 28); 351 | }); 352 | concurrency::parallel_for_each(av, prefix_tile, 353 | [=, &histogram](tiled_index t_idx) restrict(amp) { 354 | prefix_sum(t_idx, histogram); 355 | }); 356 | concurrency::parallel_for_each(av, tile, 357 | [=, &histogram](tiled_index t_idx) restrict(amp) { 358 | permute(t_idx, data_key_in, data_index_in, 359 | data_key_out, data_index_out, histogram, 360 | shift, descending, is_signed && shift == 28, key_index); 361 | }); 362 | std::swap(data_key_in, data_key_out); 363 | std::swap(data_index_in, data_index_out); 364 | } 365 | 366 | if (is_float) { 367 | concurrency::parallel_for_each(av, tile, 368 | [=](tiled_index t_idx) restrict(amp) { 369 | flip_float(t_idx, data_key_in, true); 370 | }); 371 | } 372 | } 373 | 374 | } 375 | } 376 | 377 | -------------------------------------------------------------------------------- /sources/gl/primitives/radix-sort.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2016, Oleg Ageev 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright notice, this 9 | list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 19 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 21 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 22 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 23 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 24 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | */ 26 | 27 | /* 28 | Based on work of Takahiro HARADA 29 | https://github.com/takahiroharada/OCLRadixSort 30 | and changes in AMD Bolt C++ Template Library 31 | https://github.com/HSA-Libraries/Bolt 32 | */ 33 | 34 | #include "parallel/gl/primitives/radix-sort.hh" 35 | 36 | #include "parallel/gl/opengl.hh" 37 | 38 | #undef min 39 | #undef max 40 | 41 | #define CONSTS 0 42 | 43 | #define HISTOGRAM 0 44 | #define DATA 1 45 | #define KEY_IN 0 46 | #define KEY_OUT 1 47 | #define VALUE_IN 2 48 | #define VALUE_OUT 3 49 | 50 | #define WG_COUNT 64 51 | #define WG_SIZE 256 52 | #define BLOCK_SIZE 1024 // (4 * WG_SIZE) 53 | #define BITS_PER_PASS 4 54 | #define RADICES 16 // (1 << BITS_PER_PASS) 55 | #define RADICES_MASK 0xf // (RADICES - 1) 56 | 57 | static GLchar const * prolog = GLSL( 58 | layout(local_size_x = WG_SIZE) in; 59 | layout(binding = CONSTS) uniform Consts { 60 | uint shift; 61 | bool descending; 62 | bool is_signed; 63 | bool key_index; 64 | }; 65 | layout(binding = HISTOGRAM) buffer Histogram { uint histogram[]; }; 66 | layout(binding = DATA) buffer Data { uint buf[]; } data[4]; 67 | ) 68 | GLSL_DEFINE(EACH(i, count), for (int i = 0; i < count; i++)) 69 | GLSL_DEFINE(TO_MASK(n), ((1 << (n)) - 1)) 70 | GLSL_DEFINE(BFE(src, s, n), ((src >> s) & TO_MASK(n))) 71 | GLSL_DEFINE(BFE_SIGN(src, s, n), 72 | (((((src >> s) & TO_MASK(n - 1)) 73 | ^ TO_MASK(n - 1)) 74 | & TO_MASK(n - 1)) 75 | | ((src >> s) & (1 << (n - 1))))) 76 | GLSL_DEFINE(BARRIER, groupMemoryBarrier(); barrier()) 77 | GLSL_DEFINE(LC_IDX, gl_LocalInvocationIndex) 78 | GLSL_DEFINE(WG_IDX, gl_WorkGroupID.x) 79 | GLSL_DEFINE(MIX(T, x, y, a), (x) * T(a) + (y) * (1 - T(a))) 80 | GLSL_DEFINE(GET_BY4(T, src, idx), T(src[idx.x], src[idx.y], src[idx.z], src[idx.w])) 81 | GLSL_DEFINE(SET_BY4(dest, idx, val), do { 82 | dest[idx.x] = val.x; 83 | dest[idx.y] = val.y; 84 | dest[idx.z] = val.z; 85 | dest[idx.w] = val.w; 86 | } while(false)) 87 | GLSL_DEFINE(SET_BY4_CHECKED(dest, idx, val, flag), do { 88 | if (flag.x) dest[idx.x] = val.x; 89 | if (flag.y) dest[idx.y] = val.y; 90 | if (flag.z) dest[idx.z] = val.z; 91 | if (flag.w) dest[idx.w] = val.w; 92 | } while(false)) 93 | GLSL_DEFINE(INC_BY4_CHECKED(dest, idx, flag), do { 94 | atomicAdd(dest[idx.x], uint(flag.x)); 95 | atomicAdd(dest[idx.y], uint(flag.y)); 96 | atomicAdd(dest[idx.z], uint(flag.z)); 97 | atomicAdd(dest[idx.w], uint(flag.w)); 98 | } while(false)) 99 | GLSL( 100 | struct blocks_info { uint count; uint offset; }; 101 | blocks_info get_blocks_info(const uint n, const uint wg_idx) { 102 | const uint aligned = n + BLOCK_SIZE - (n % BLOCK_SIZE); 103 | const uint blocks = (n + BLOCK_SIZE - 1) / BLOCK_SIZE; 104 | const uint blocks_per_wg = (blocks + WG_COUNT - 1) / WG_COUNT; 105 | const int n_blocks = int(aligned / BLOCK_SIZE) - int(blocks_per_wg * wg_idx); 106 | return blocks_info(uint(clamp(n_blocks, 0, int(blocks_per_wg))), blocks_per_wg * BLOCK_SIZE * wg_idx); 107 | } 108 | shared uint local_sort[BLOCK_SIZE]; 109 | uint prefix_sum(uint data, inout uint total_sum) { 110 | const uint lc_idx = LC_IDX + WG_SIZE; 111 | local_sort[LC_IDX] = 0; 112 | local_sort[lc_idx] = data; 113 | BARRIER; 114 | for (uint i = 1; i < WG_SIZE; i <<= 1) { 115 | uint tmp = local_sort[lc_idx - i]; 116 | BARRIER; 117 | local_sort[lc_idx] += tmp; 118 | BARRIER; 119 | } 120 | total_sum = local_sort[WG_SIZE * 2 - 1]; 121 | return local_sort[lc_idx - 1]; 122 | } 123 | uint prefix_scan(inout uvec4 v) { 124 | uint sum = 0; 125 | uint tmp; 126 | tmp = v.x; v.x = sum; sum += tmp; 127 | tmp = v.y; v.y = sum; sum += tmp; 128 | tmp = v.z; v.z = sum; sum += tmp; 129 | tmp = v.w; v.w = sum; sum += tmp; 130 | return sum; 131 | }); 132 | 133 | static GLchar const * histogram_count = GLSL( 134 | shared uint local_histogram[WG_SIZE * RADICES]; 135 | void main() { 136 | EACH(i, RADICES) local_histogram[i * WG_SIZE + LC_IDX] = 0; 137 | BARRIER; 138 | 139 | const uint n = data[KEY_IN].buf.length(); 140 | const blocks_info blocks = get_blocks_info(n, WG_IDX); 141 | uvec4 addr = blocks.offset + 4 * LC_IDX + uvec4(0, 1, 2, 3); 142 | EACH(i_block, blocks.count) { 143 | const bvec4 less_than = lessThan(addr, uvec4(n)); 144 | const uvec4 data_vec = GET_BY4(uvec4, data[KEY_IN].buf, addr); 145 | const uvec4 k = is_signed 146 | ? BFE_SIGN(data_vec, shift, BITS_PER_PASS) 147 | : BFE(data_vec, shift, BITS_PER_PASS); 148 | const uvec4 key = descending != is_signed ? (RADICES_MASK - k) : k; 149 | const uvec4 local_key = key * WG_SIZE + LC_IDX; 150 | INC_BY4_CHECKED(local_histogram, local_key, less_than); 151 | addr += BLOCK_SIZE; 152 | } 153 | BARRIER; 154 | 155 | if (LC_IDX < RADICES) { 156 | uint sum = 0; EACH(i, WG_SIZE) sum += local_histogram[LC_IDX * WG_SIZE + i]; 157 | histogram[LC_IDX * WG_COUNT + WG_IDX] = sum; 158 | } 159 | BARRIER; 160 | }); 161 | 162 | static GLchar const * prefix_scan = GLSL( 163 | shared uint seed; 164 | void main() { 165 | seed = 0; 166 | BARRIER; 167 | 168 | EACH(d, RADICES) { 169 | uint val = 0; 170 | uint idx = d * WG_COUNT + LC_IDX; 171 | if (LC_IDX < WG_COUNT) val = histogram[idx]; 172 | uint total; 173 | uint res = prefix_sum(val, total); 174 | if (LC_IDX < WG_COUNT) histogram[idx] = res + seed; 175 | if (LC_IDX == WG_COUNT - 1) seed += res + val; 176 | BARRIER; 177 | } 178 | }); 179 | 180 | static GLchar const * permute = GLSL( 181 | shared uint local_sort_val[BLOCK_SIZE]; 182 | void sort_bits(inout uvec4 sort, inout uvec4 sort_val) { 183 | uvec4 signs = BFE_SIGN(sort, shift, BITS_PER_PASS); 184 | const uvec4 addr = 4 * LC_IDX + uvec4(0, 1, 2, 3); 185 | EACH(i_bit, BITS_PER_PASS) { 186 | const uint mask = (1 << i_bit); 187 | const bvec4 cmp = equal((is_signed ? signs : (sort >> shift)) & mask, uvec4(descending != is_signed) * mask); 188 | uvec4 key = uvec4(cmp); 189 | uint total; 190 | key += prefix_sum(prefix_scan(key), total); 191 | BARRIER; 192 | 193 | const uvec4 dest_addr = MIX(uvec4, key, addr - key + total, cmp); 194 | SET_BY4(local_sort, dest_addr, sort); 195 | SET_BY4(local_sort_val, dest_addr, sort_val); 196 | BARRIER; 197 | 198 | sort = GET_BY4(uvec4, local_sort, addr); 199 | sort_val = GET_BY4(uvec4, local_sort_val, addr); 200 | BARRIER; 201 | 202 | if (is_signed) { 203 | SET_BY4(local_sort, dest_addr, signs); 204 | BARRIER; 205 | 206 | signs = GET_BY4(uvec4, local_sort, addr); 207 | BARRIER; 208 | } 209 | } 210 | } 211 | shared uint local_histogram_to_carry[RADICES]; 212 | shared uint local_histogram[RADICES * 2]; 213 | void main() { 214 | const uint carry_idx = (descending && !is_signed ? (RADICES_MASK - LC_IDX) : LC_IDX); 215 | if (LC_IDX < RADICES) local_histogram_to_carry[LC_IDX] = histogram[carry_idx * WG_COUNT + WG_IDX]; 216 | BARRIER; 217 | 218 | const uint def = (uint(!descending) * 0xffffffff) ^ (uint(is_signed) * 0x80000000); 219 | const uint n = data[KEY_IN].buf.length(); 220 | const blocks_info blocks = get_blocks_info(n, WG_IDX); 221 | uvec4 addr = blocks.offset + 4 * LC_IDX + uvec4(0, 1, 2, 3); 222 | EACH(i_block, blocks.count) { 223 | const bvec4 less_than = lessThan(addr, uvec4(n)); 224 | const bvec4 less_than_val = lessThan(addr, uvec4(key_index ? n : 0)); 225 | const uvec4 data_vec = GET_BY4(uvec4, data[KEY_IN].buf, addr); 226 | const uvec4 data_val_vec = GET_BY4(uvec4, data[VALUE_IN].buf, addr); 227 | uvec4 sort = MIX(uvec4, data_vec, def, less_than); 228 | uvec4 sort_val = MIX(uvec4, data_val_vec, 0, less_than_val); 229 | sort_bits(sort, sort_val); 230 | uvec4 k = is_signed 231 | ? BFE_SIGN(sort, shift, BITS_PER_PASS) 232 | : BFE(sort, shift, BITS_PER_PASS); 233 | const uvec4 key = (descending != is_signed) ? (RADICES_MASK - k) : k; 234 | const uvec4 hist_key = key + RADICES; 235 | const uvec4 local_key = key + (LC_IDX / RADICES) * RADICES; 236 | k = is_signed ? key : k; 237 | const uvec4 offset = GET_BY4(uvec4, local_histogram_to_carry, k) + 4 * LC_IDX + uvec4(0, 1, 2, 3); 238 | local_sort[LC_IDX] = 0; 239 | BARRIER; 240 | 241 | INC_BY4_CHECKED(local_sort, local_key, less_than); 242 | BARRIER; 243 | 244 | const uint lc_idx = LC_IDX + RADICES; 245 | if (LC_IDX < RADICES) { 246 | local_histogram[LC_IDX] = 0; 247 | uint sum = 0; EACH(i, WG_SIZE / RADICES) sum += local_sort[i * RADICES + LC_IDX]; 248 | local_histogram_to_carry[carry_idx] += local_histogram[lc_idx] = sum; 249 | } 250 | BARRIER; 251 | 252 | uint tmp = 0; 253 | if (LC_IDX < RADICES) local_histogram[lc_idx] = local_histogram[lc_idx - 1]; 254 | BARRIER; 255 | if (LC_IDX < RADICES) tmp = local_histogram[lc_idx - 3] 256 | + local_histogram[lc_idx - 2] 257 | + local_histogram[lc_idx - 1]; 258 | BARRIER; 259 | if (LC_IDX < RADICES) local_histogram[lc_idx] += tmp; 260 | BARRIER; 261 | if (LC_IDX < RADICES) tmp = local_histogram[lc_idx - 12] 262 | + local_histogram[lc_idx - 8] 263 | + local_histogram[lc_idx - 4]; 264 | BARRIER; 265 | if (LC_IDX < RADICES) local_histogram[lc_idx] += tmp; 266 | BARRIER; 267 | 268 | const uvec4 out_key = offset - GET_BY4(uvec4, local_histogram, hist_key); 269 | SET_BY4_CHECKED(data[KEY_OUT].buf, out_key, sort, less_than); 270 | SET_BY4_CHECKED(data[VALUE_OUT].buf, out_key, sort_val, less_than_val); 271 | BARRIER; 272 | addr += BLOCK_SIZE; 273 | } 274 | }); 275 | 276 | static GLchar const * flip_float = GLSL( 277 | void main() { 278 | const uint n = data[KEY_IN].buf.length(); 279 | const blocks_info blocks = get_blocks_info(n, WG_IDX); 280 | uvec4 addr = blocks.offset + 4 * LC_IDX + uvec4(0, 1, 2, 3); 281 | EACH(i_block, blocks.count) { 282 | const bvec4 less_than = lessThan(addr, uvec4(n)); 283 | const uvec4 data_vec = GET_BY4(uvec4, data[KEY_IN].buf, addr); 284 | uvec4 value = MIX(uvec4, data_vec, 0, less_than); 285 | uvec4 mask = is_signed ? ((value >> 31) - 1) | 0x80000000 : -ivec4(value >> 31) | 0x80000000; 286 | value ^= mask; 287 | SET_BY4_CHECKED(data[KEY_IN].buf, addr, value, less_than); 288 | addr += BLOCK_SIZE; 289 | } 290 | }); 291 | 292 | template 293 | void swap(T& a, T& b) { auto tmp = a; a = b; b = tmp; } 294 | 295 | #define EACH(i, count) for (auto i = decltype(count)(0); i < count; i++) 296 | 297 | namespace parallel { 298 | namespace gl { 299 | 300 | struct { compute_program histogram_count, prefix_scan, permute, flip_float; } static kernels; 301 | struct { buffer consts, histogram, output[2]; } static buffers; 302 | struct Consts { GLuint shift, descending, is_signed, key_index; }; 303 | 304 | void radix_sort(GL const & gl, buffer key, GLsizeiptr size /*= 0*/, buffer index /*= buffer::empty()*/, 305 | bool descending /*= false*/, bool is_signed /*= false*/, bool is_float /*= false*/) { 306 | static bool initialized = false; 307 | static GLsizeiptr aligned_const_size = 0; 308 | if (!initialized) { 309 | buffer::factory(gl, sizeof(buffers) / sizeof(buffer), &buffers.consts); 310 | aligned_const_size = buffers.consts.allocate(gl, sizeof(Consts), 9, true); 311 | buffers.histogram.allocate(gl, sizeof(GLuint) * WG_COUNT * RADICES); 312 | 313 | kernels.histogram_count = make_program(gl, prolog, histogram_count); 314 | kernels.prefix_scan = make_program(gl, prolog, prefix_scan); 315 | kernels.permute = make_program(gl, prolog, permute); 316 | kernels.flip_float = make_program(gl, prolog, flip_float); 317 | initialized = true; 318 | } 319 | 320 | size = size == 0 ? key.size(gl) : size * sizeof(GLuint); 321 | 322 | Consts consts[] = { 323 | 0, descending, 0, !index.is_empty(), 324 | 4, descending, 0, !index.is_empty(), 325 | 8, descending, 0, !index.is_empty(), 326 | 12, descending, 0, !index.is_empty(), 327 | 16, descending, 0, !index.is_empty(), 328 | 20, descending, 0, !index.is_empty(), 329 | 24, descending, 0, !index.is_empty(), 330 | 28, descending, is_signed && !is_float, !index.is_empty(), 331 | 28, descending, 1, !index.is_empty() // inverse flip float 332 | }; 333 | buffers.consts.sub_data(gl, consts, aligned_const_size); 334 | buffers.output[0].allocate(gl, size); 335 | if (!index.is_empty()) { buffers.output[1].allocate(gl, size); } 336 | 337 | buffer data[] = { key, buffers.output[0], index, index.is_empty() ? buffer::empty() : buffers.output[1] }; 338 | buffers.histogram.bind(gl, HISTOGRAM); 339 | EACH(i, 8) { 340 | buffers.consts.bind(gl, CONSTS, i * aligned_const_size, sizeof(Consts)); 341 | data[KEY_IN].bind(gl, DATA + KEY_IN, 0, size); 342 | data[KEY_OUT].bind(gl, DATA + KEY_OUT, 0, size); 343 | data[VALUE_IN].bind(gl, DATA + VALUE_IN, 0, size); 344 | data[VALUE_OUT].bind(gl, DATA + VALUE_OUT, 0, size); 345 | 346 | if (is_float && i == 0) { 347 | kernels.flip_float.dispatch(gl, WG_COUNT); 348 | gl.MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 349 | } 350 | 351 | kernels.histogram_count.dispatch(gl, WG_COUNT); 352 | gl.MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 353 | kernels.prefix_scan.dispatch(gl); 354 | gl.MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 355 | kernels.permute.dispatch(gl, WG_COUNT); 356 | gl.MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 357 | 358 | swap(data[KEY_IN], data[KEY_OUT]); 359 | swap(data[VALUE_IN], data[VALUE_OUT]); 360 | } 361 | 362 | if (is_float) { 363 | buffers.consts.bind(gl, CONSTS, 8 * aligned_const_size, sizeof(Consts)); 364 | data[KEY_IN].bind(gl, DATA + KEY_IN); 365 | kernels.flip_float.dispatch(gl, WG_COUNT); 366 | gl.MemoryBarrier(GL_SHADER_STORAGE_BARRIER_BIT); 367 | } 368 | 369 | buffers.output[0].free(gl); 370 | if (!index.is_empty()) { buffers.output[1].free(gl); } 371 | } 372 | 373 | } 374 | } 375 | -------------------------------------------------------------------------------- /include/GL/wglext.h: -------------------------------------------------------------------------------- 1 | #ifndef __wglext_h_ 2 | #define __wglext_h_ 1 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | /* 9 | ** Copyright (c) 2013-2015 The Khronos Group Inc. 10 | ** 11 | ** Permission is hereby granted, free of charge, to any person obtaining a 12 | ** copy of this software and/or associated documentation files (the 13 | ** "Materials"), to deal in the Materials without restriction, including 14 | ** without limitation the rights to use, copy, modify, merge, publish, 15 | ** distribute, sublicense, and/or sell copies of the Materials, and to 16 | ** permit persons to whom the Materials are furnished to do so, subject to 17 | ** the following conditions: 18 | ** 19 | ** The above copyright notice and this permission notice shall be included 20 | ** in all copies or substantial portions of the Materials. 21 | ** 22 | ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | ** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 26 | ** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 27 | ** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 28 | ** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. 29 | */ 30 | /* 31 | ** This header is generated from the Khronos OpenGL / OpenGL ES XML 32 | ** API Registry. The current version of the Registry, generator scripts 33 | ** used to make the header, and the header can be found at 34 | ** http://www.opengl.org/registry/ 35 | ** 36 | ** Khronos $Revision: 31597 $ on $Date: 2015-06-25 16:32:35 -0400 (Thu, 25 Jun 2015) $ 37 | */ 38 | 39 | #if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) 40 | #define WIN32_LEAN_AND_MEAN 1 41 | #include 42 | #endif 43 | 44 | #define WGL_WGLEXT_VERSION 20150623 45 | 46 | /* Generated C header for: 47 | * API: wgl 48 | * Versions considered: .* 49 | * Versions emitted: _nomatch_^ 50 | * Default extensions included: wgl 51 | * Additional extensions included: _nomatch_^ 52 | * Extensions removed: _nomatch_^ 53 | */ 54 | 55 | #ifndef WGL_ARB_buffer_region 56 | #define WGL_ARB_buffer_region 1 57 | #define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 58 | #define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 59 | #define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 60 | #define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 61 | typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); 62 | typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); 63 | typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); 64 | typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 65 | #ifdef WGL_WGLEXT_PROTOTYPES 66 | HANDLE WINAPI wglCreateBufferRegionARB (HDC hDC, int iLayerPlane, UINT uType); 67 | VOID WINAPI wglDeleteBufferRegionARB (HANDLE hRegion); 68 | BOOL WINAPI wglSaveBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height); 69 | BOOL WINAPI wglRestoreBufferRegionARB (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); 70 | #endif 71 | #endif /* WGL_ARB_buffer_region */ 72 | 73 | #ifndef WGL_ARB_context_flush_control 74 | #define WGL_ARB_context_flush_control 1 75 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097 76 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0 77 | #define WGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098 78 | #endif /* WGL_ARB_context_flush_control */ 79 | 80 | #ifndef WGL_ARB_create_context 81 | #define WGL_ARB_create_context 1 82 | #define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001 83 | #define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002 84 | #define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 85 | #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 86 | #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 87 | #define WGL_CONTEXT_FLAGS_ARB 0x2094 88 | #define ERROR_INVALID_VERSION_ARB 0x2095 89 | typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList); 90 | #ifdef WGL_WGLEXT_PROTOTYPES 91 | HGLRC WINAPI wglCreateContextAttribsARB (HDC hDC, HGLRC hShareContext, const int *attribList); 92 | #endif 93 | #endif /* WGL_ARB_create_context */ 94 | 95 | #ifndef WGL_ARB_create_context_profile 96 | #define WGL_ARB_create_context_profile 1 97 | #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 98 | #define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 99 | #define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 100 | #define ERROR_INVALID_PROFILE_ARB 0x2096 101 | #endif /* WGL_ARB_create_context_profile */ 102 | 103 | #ifndef WGL_ARB_create_context_robustness 104 | #define WGL_ARB_create_context_robustness 1 105 | #define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 106 | #define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 107 | #define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 108 | #define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 109 | #endif /* WGL_ARB_create_context_robustness */ 110 | 111 | #ifndef WGL_ARB_extensions_string 112 | #define WGL_ARB_extensions_string 1 113 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); 114 | #ifdef WGL_WGLEXT_PROTOTYPES 115 | const char *WINAPI wglGetExtensionsStringARB (HDC hdc); 116 | #endif 117 | #endif /* WGL_ARB_extensions_string */ 118 | 119 | #ifndef WGL_ARB_framebuffer_sRGB 120 | #define WGL_ARB_framebuffer_sRGB 1 121 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 122 | #endif /* WGL_ARB_framebuffer_sRGB */ 123 | 124 | #ifndef WGL_ARB_make_current_read 125 | #define WGL_ARB_make_current_read 1 126 | #define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 127 | #define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 128 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 129 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (void); 130 | #ifdef WGL_WGLEXT_PROTOTYPES 131 | BOOL WINAPI wglMakeContextCurrentARB (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 132 | HDC WINAPI wglGetCurrentReadDCARB (void); 133 | #endif 134 | #endif /* WGL_ARB_make_current_read */ 135 | 136 | #ifndef WGL_ARB_multisample 137 | #define WGL_ARB_multisample 1 138 | #define WGL_SAMPLE_BUFFERS_ARB 0x2041 139 | #define WGL_SAMPLES_ARB 0x2042 140 | #endif /* WGL_ARB_multisample */ 141 | 142 | #ifndef WGL_ARB_pbuffer 143 | #define WGL_ARB_pbuffer 1 144 | DECLARE_HANDLE(HPBUFFERARB); 145 | #define WGL_DRAW_TO_PBUFFER_ARB 0x202D 146 | #define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E 147 | #define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F 148 | #define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 149 | #define WGL_PBUFFER_LARGEST_ARB 0x2033 150 | #define WGL_PBUFFER_WIDTH_ARB 0x2034 151 | #define WGL_PBUFFER_HEIGHT_ARB 0x2035 152 | #define WGL_PBUFFER_LOST_ARB 0x2036 153 | typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 154 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); 155 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); 156 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); 157 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 158 | #ifdef WGL_WGLEXT_PROTOTYPES 159 | HPBUFFERARB WINAPI wglCreatePbufferARB (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 160 | HDC WINAPI wglGetPbufferDCARB (HPBUFFERARB hPbuffer); 161 | int WINAPI wglReleasePbufferDCARB (HPBUFFERARB hPbuffer, HDC hDC); 162 | BOOL WINAPI wglDestroyPbufferARB (HPBUFFERARB hPbuffer); 163 | BOOL WINAPI wglQueryPbufferARB (HPBUFFERARB hPbuffer, int iAttribute, int *piValue); 164 | #endif 165 | #endif /* WGL_ARB_pbuffer */ 166 | 167 | #ifndef WGL_ARB_pixel_format 168 | #define WGL_ARB_pixel_format 1 169 | #define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 170 | #define WGL_DRAW_TO_WINDOW_ARB 0x2001 171 | #define WGL_DRAW_TO_BITMAP_ARB 0x2002 172 | #define WGL_ACCELERATION_ARB 0x2003 173 | #define WGL_NEED_PALETTE_ARB 0x2004 174 | #define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 175 | #define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 176 | #define WGL_SWAP_METHOD_ARB 0x2007 177 | #define WGL_NUMBER_OVERLAYS_ARB 0x2008 178 | #define WGL_NUMBER_UNDERLAYS_ARB 0x2009 179 | #define WGL_TRANSPARENT_ARB 0x200A 180 | #define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 181 | #define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 182 | #define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 183 | #define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A 184 | #define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B 185 | #define WGL_SHARE_DEPTH_ARB 0x200C 186 | #define WGL_SHARE_STENCIL_ARB 0x200D 187 | #define WGL_SHARE_ACCUM_ARB 0x200E 188 | #define WGL_SUPPORT_GDI_ARB 0x200F 189 | #define WGL_SUPPORT_OPENGL_ARB 0x2010 190 | #define WGL_DOUBLE_BUFFER_ARB 0x2011 191 | #define WGL_STEREO_ARB 0x2012 192 | #define WGL_PIXEL_TYPE_ARB 0x2013 193 | #define WGL_COLOR_BITS_ARB 0x2014 194 | #define WGL_RED_BITS_ARB 0x2015 195 | #define WGL_RED_SHIFT_ARB 0x2016 196 | #define WGL_GREEN_BITS_ARB 0x2017 197 | #define WGL_GREEN_SHIFT_ARB 0x2018 198 | #define WGL_BLUE_BITS_ARB 0x2019 199 | #define WGL_BLUE_SHIFT_ARB 0x201A 200 | #define WGL_ALPHA_BITS_ARB 0x201B 201 | #define WGL_ALPHA_SHIFT_ARB 0x201C 202 | #define WGL_ACCUM_BITS_ARB 0x201D 203 | #define WGL_ACCUM_RED_BITS_ARB 0x201E 204 | #define WGL_ACCUM_GREEN_BITS_ARB 0x201F 205 | #define WGL_ACCUM_BLUE_BITS_ARB 0x2020 206 | #define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 207 | #define WGL_DEPTH_BITS_ARB 0x2022 208 | #define WGL_STENCIL_BITS_ARB 0x2023 209 | #define WGL_AUX_BUFFERS_ARB 0x2024 210 | #define WGL_NO_ACCELERATION_ARB 0x2025 211 | #define WGL_GENERIC_ACCELERATION_ARB 0x2026 212 | #define WGL_FULL_ACCELERATION_ARB 0x2027 213 | #define WGL_SWAP_EXCHANGE_ARB 0x2028 214 | #define WGL_SWAP_COPY_ARB 0x2029 215 | #define WGL_SWAP_UNDEFINED_ARB 0x202A 216 | #define WGL_TYPE_RGBA_ARB 0x202B 217 | #define WGL_TYPE_COLORINDEX_ARB 0x202C 218 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 219 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 220 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 221 | #ifdef WGL_WGLEXT_PROTOTYPES 222 | BOOL WINAPI wglGetPixelFormatAttribivARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues); 223 | BOOL WINAPI wglGetPixelFormatAttribfvARB (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, FLOAT *pfValues); 224 | BOOL WINAPI wglChoosePixelFormatARB (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 225 | #endif 226 | #endif /* WGL_ARB_pixel_format */ 227 | 228 | #ifndef WGL_ARB_pixel_format_float 229 | #define WGL_ARB_pixel_format_float 1 230 | #define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 231 | #endif /* WGL_ARB_pixel_format_float */ 232 | 233 | #ifndef WGL_ARB_render_texture 234 | #define WGL_ARB_render_texture 1 235 | #define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 236 | #define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 237 | #define WGL_TEXTURE_FORMAT_ARB 0x2072 238 | #define WGL_TEXTURE_TARGET_ARB 0x2073 239 | #define WGL_MIPMAP_TEXTURE_ARB 0x2074 240 | #define WGL_TEXTURE_RGB_ARB 0x2075 241 | #define WGL_TEXTURE_RGBA_ARB 0x2076 242 | #define WGL_NO_TEXTURE_ARB 0x2077 243 | #define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 244 | #define WGL_TEXTURE_1D_ARB 0x2079 245 | #define WGL_TEXTURE_2D_ARB 0x207A 246 | #define WGL_MIPMAP_LEVEL_ARB 0x207B 247 | #define WGL_CUBE_MAP_FACE_ARB 0x207C 248 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D 249 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E 250 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F 251 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 252 | #define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 253 | #define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 254 | #define WGL_FRONT_LEFT_ARB 0x2083 255 | #define WGL_FRONT_RIGHT_ARB 0x2084 256 | #define WGL_BACK_LEFT_ARB 0x2085 257 | #define WGL_BACK_RIGHT_ARB 0x2086 258 | #define WGL_AUX0_ARB 0x2087 259 | #define WGL_AUX1_ARB 0x2088 260 | #define WGL_AUX2_ARB 0x2089 261 | #define WGL_AUX3_ARB 0x208A 262 | #define WGL_AUX4_ARB 0x208B 263 | #define WGL_AUX5_ARB 0x208C 264 | #define WGL_AUX6_ARB 0x208D 265 | #define WGL_AUX7_ARB 0x208E 266 | #define WGL_AUX8_ARB 0x208F 267 | #define WGL_AUX9_ARB 0x2090 268 | typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 269 | typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); 270 | typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int *piAttribList); 271 | #ifdef WGL_WGLEXT_PROTOTYPES 272 | BOOL WINAPI wglBindTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 273 | BOOL WINAPI wglReleaseTexImageARB (HPBUFFERARB hPbuffer, int iBuffer); 274 | BOOL WINAPI wglSetPbufferAttribARB (HPBUFFERARB hPbuffer, const int *piAttribList); 275 | #endif 276 | #endif /* WGL_ARB_render_texture */ 277 | 278 | #ifndef WGL_ARB_robustness_application_isolation 279 | #define WGL_ARB_robustness_application_isolation 1 280 | #define WGL_CONTEXT_RESET_ISOLATION_BIT_ARB 0x00000008 281 | #endif /* WGL_ARB_robustness_application_isolation */ 282 | 283 | #ifndef WGL_ARB_robustness_share_group_isolation 284 | #define WGL_ARB_robustness_share_group_isolation 1 285 | #endif /* WGL_ARB_robustness_share_group_isolation */ 286 | 287 | #ifndef WGL_3DFX_multisample 288 | #define WGL_3DFX_multisample 1 289 | #define WGL_SAMPLE_BUFFERS_3DFX 0x2060 290 | #define WGL_SAMPLES_3DFX 0x2061 291 | #endif /* WGL_3DFX_multisample */ 292 | 293 | #ifndef WGL_3DL_stereo_control 294 | #define WGL_3DL_stereo_control 1 295 | #define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 296 | #define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 297 | #define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 298 | #define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 299 | typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); 300 | #ifdef WGL_WGLEXT_PROTOTYPES 301 | BOOL WINAPI wglSetStereoEmitterState3DL (HDC hDC, UINT uState); 302 | #endif 303 | #endif /* WGL_3DL_stereo_control */ 304 | 305 | #ifndef WGL_AMD_gpu_association 306 | #define WGL_AMD_gpu_association 1 307 | #define WGL_GPU_VENDOR_AMD 0x1F00 308 | #define WGL_GPU_RENDERER_STRING_AMD 0x1F01 309 | #define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 310 | #define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 311 | #define WGL_GPU_RAM_AMD 0x21A3 312 | #define WGL_GPU_CLOCK_AMD 0x21A4 313 | #define WGL_GPU_NUM_PIPES_AMD 0x21A5 314 | #define WGL_GPU_NUM_SIMD_AMD 0x21A6 315 | #define WGL_GPU_NUM_RB_AMD 0x21A7 316 | #define WGL_GPU_NUM_SPI_AMD 0x21A8 317 | typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT *ids); 318 | typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, int property, GLenum dataType, UINT size, void *data); 319 | typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); 320 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); 321 | typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int *attribList); 322 | typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); 323 | typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); 324 | typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); 325 | typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 326 | #ifdef WGL_WGLEXT_PROTOTYPES 327 | UINT WINAPI wglGetGPUIDsAMD (UINT maxCount, UINT *ids); 328 | INT WINAPI wglGetGPUInfoAMD (UINT id, int property, GLenum dataType, UINT size, void *data); 329 | UINT WINAPI wglGetContextGPUIDAMD (HGLRC hglrc); 330 | HGLRC WINAPI wglCreateAssociatedContextAMD (UINT id); 331 | HGLRC WINAPI wglCreateAssociatedContextAttribsAMD (UINT id, HGLRC hShareContext, const int *attribList); 332 | BOOL WINAPI wglDeleteAssociatedContextAMD (HGLRC hglrc); 333 | BOOL WINAPI wglMakeAssociatedContextCurrentAMD (HGLRC hglrc); 334 | HGLRC WINAPI wglGetCurrentAssociatedContextAMD (void); 335 | VOID WINAPI wglBlitContextFramebufferAMD (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); 336 | #endif 337 | #endif /* WGL_AMD_gpu_association */ 338 | 339 | #ifndef WGL_ATI_pixel_format_float 340 | #define WGL_ATI_pixel_format_float 1 341 | #define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 342 | #endif /* WGL_ATI_pixel_format_float */ 343 | 344 | #ifndef WGL_EXT_create_context_es2_profile 345 | #define WGL_EXT_create_context_es2_profile 1 346 | #define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 347 | #endif /* WGL_EXT_create_context_es2_profile */ 348 | 349 | #ifndef WGL_EXT_create_context_es_profile 350 | #define WGL_EXT_create_context_es_profile 1 351 | #define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004 352 | #endif /* WGL_EXT_create_context_es_profile */ 353 | 354 | #ifndef WGL_EXT_depth_float 355 | #define WGL_EXT_depth_float 1 356 | #define WGL_DEPTH_FLOAT_EXT 0x2040 357 | #endif /* WGL_EXT_depth_float */ 358 | 359 | #ifndef WGL_EXT_display_color_table 360 | #define WGL_EXT_display_color_table 1 361 | typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); 362 | typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (const GLushort *table, GLuint length); 363 | typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); 364 | typedef VOID (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); 365 | #ifdef WGL_WGLEXT_PROTOTYPES 366 | GLboolean WINAPI wglCreateDisplayColorTableEXT (GLushort id); 367 | GLboolean WINAPI wglLoadDisplayColorTableEXT (const GLushort *table, GLuint length); 368 | GLboolean WINAPI wglBindDisplayColorTableEXT (GLushort id); 369 | VOID WINAPI wglDestroyDisplayColorTableEXT (GLushort id); 370 | #endif 371 | #endif /* WGL_EXT_display_color_table */ 372 | 373 | #ifndef WGL_EXT_extensions_string 374 | #define WGL_EXT_extensions_string 1 375 | typedef const char *(WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); 376 | #ifdef WGL_WGLEXT_PROTOTYPES 377 | const char *WINAPI wglGetExtensionsStringEXT (void); 378 | #endif 379 | #endif /* WGL_EXT_extensions_string */ 380 | 381 | #ifndef WGL_EXT_framebuffer_sRGB 382 | #define WGL_EXT_framebuffer_sRGB 1 383 | #define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 384 | #endif /* WGL_EXT_framebuffer_sRGB */ 385 | 386 | #ifndef WGL_EXT_make_current_read 387 | #define WGL_EXT_make_current_read 1 388 | #define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 389 | typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 390 | typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (void); 391 | #ifdef WGL_WGLEXT_PROTOTYPES 392 | BOOL WINAPI wglMakeContextCurrentEXT (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); 393 | HDC WINAPI wglGetCurrentReadDCEXT (void); 394 | #endif 395 | #endif /* WGL_EXT_make_current_read */ 396 | 397 | #ifndef WGL_EXT_multisample 398 | #define WGL_EXT_multisample 1 399 | #define WGL_SAMPLE_BUFFERS_EXT 0x2041 400 | #define WGL_SAMPLES_EXT 0x2042 401 | #endif /* WGL_EXT_multisample */ 402 | 403 | #ifndef WGL_EXT_pbuffer 404 | #define WGL_EXT_pbuffer 1 405 | DECLARE_HANDLE(HPBUFFEREXT); 406 | #define WGL_DRAW_TO_PBUFFER_EXT 0x202D 407 | #define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E 408 | #define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F 409 | #define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 410 | #define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 411 | #define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 412 | #define WGL_PBUFFER_LARGEST_EXT 0x2033 413 | #define WGL_PBUFFER_WIDTH_EXT 0x2034 414 | #define WGL_PBUFFER_HEIGHT_EXT 0x2035 415 | typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 416 | typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); 417 | typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); 418 | typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); 419 | typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 420 | #ifdef WGL_WGLEXT_PROTOTYPES 421 | HPBUFFEREXT WINAPI wglCreatePbufferEXT (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList); 422 | HDC WINAPI wglGetPbufferDCEXT (HPBUFFEREXT hPbuffer); 423 | int WINAPI wglReleasePbufferDCEXT (HPBUFFEREXT hPbuffer, HDC hDC); 424 | BOOL WINAPI wglDestroyPbufferEXT (HPBUFFEREXT hPbuffer); 425 | BOOL WINAPI wglQueryPbufferEXT (HPBUFFEREXT hPbuffer, int iAttribute, int *piValue); 426 | #endif 427 | #endif /* WGL_EXT_pbuffer */ 428 | 429 | #ifndef WGL_EXT_pixel_format 430 | #define WGL_EXT_pixel_format 1 431 | #define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 432 | #define WGL_DRAW_TO_WINDOW_EXT 0x2001 433 | #define WGL_DRAW_TO_BITMAP_EXT 0x2002 434 | #define WGL_ACCELERATION_EXT 0x2003 435 | #define WGL_NEED_PALETTE_EXT 0x2004 436 | #define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 437 | #define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 438 | #define WGL_SWAP_METHOD_EXT 0x2007 439 | #define WGL_NUMBER_OVERLAYS_EXT 0x2008 440 | #define WGL_NUMBER_UNDERLAYS_EXT 0x2009 441 | #define WGL_TRANSPARENT_EXT 0x200A 442 | #define WGL_TRANSPARENT_VALUE_EXT 0x200B 443 | #define WGL_SHARE_DEPTH_EXT 0x200C 444 | #define WGL_SHARE_STENCIL_EXT 0x200D 445 | #define WGL_SHARE_ACCUM_EXT 0x200E 446 | #define WGL_SUPPORT_GDI_EXT 0x200F 447 | #define WGL_SUPPORT_OPENGL_EXT 0x2010 448 | #define WGL_DOUBLE_BUFFER_EXT 0x2011 449 | #define WGL_STEREO_EXT 0x2012 450 | #define WGL_PIXEL_TYPE_EXT 0x2013 451 | #define WGL_COLOR_BITS_EXT 0x2014 452 | #define WGL_RED_BITS_EXT 0x2015 453 | #define WGL_RED_SHIFT_EXT 0x2016 454 | #define WGL_GREEN_BITS_EXT 0x2017 455 | #define WGL_GREEN_SHIFT_EXT 0x2018 456 | #define WGL_BLUE_BITS_EXT 0x2019 457 | #define WGL_BLUE_SHIFT_EXT 0x201A 458 | #define WGL_ALPHA_BITS_EXT 0x201B 459 | #define WGL_ALPHA_SHIFT_EXT 0x201C 460 | #define WGL_ACCUM_BITS_EXT 0x201D 461 | #define WGL_ACCUM_RED_BITS_EXT 0x201E 462 | #define WGL_ACCUM_GREEN_BITS_EXT 0x201F 463 | #define WGL_ACCUM_BLUE_BITS_EXT 0x2020 464 | #define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 465 | #define WGL_DEPTH_BITS_EXT 0x2022 466 | #define WGL_STENCIL_BITS_EXT 0x2023 467 | #define WGL_AUX_BUFFERS_EXT 0x2024 468 | #define WGL_NO_ACCELERATION_EXT 0x2025 469 | #define WGL_GENERIC_ACCELERATION_EXT 0x2026 470 | #define WGL_FULL_ACCELERATION_EXT 0x2027 471 | #define WGL_SWAP_EXCHANGE_EXT 0x2028 472 | #define WGL_SWAP_COPY_EXT 0x2029 473 | #define WGL_SWAP_UNDEFINED_EXT 0x202A 474 | #define WGL_TYPE_RGBA_EXT 0x202B 475 | #define WGL_TYPE_COLORINDEX_EXT 0x202C 476 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 477 | typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 478 | typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 479 | #ifdef WGL_WGLEXT_PROTOTYPES 480 | BOOL WINAPI wglGetPixelFormatAttribivEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, int *piValues); 481 | BOOL WINAPI wglGetPixelFormatAttribfvEXT (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int *piAttributes, FLOAT *pfValues); 482 | BOOL WINAPI wglChoosePixelFormatEXT (HDC hdc, const int *piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); 483 | #endif 484 | #endif /* WGL_EXT_pixel_format */ 485 | 486 | #ifndef WGL_EXT_pixel_format_packed_float 487 | #define WGL_EXT_pixel_format_packed_float 1 488 | #define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 489 | #endif /* WGL_EXT_pixel_format_packed_float */ 490 | 491 | #ifndef WGL_EXT_swap_control 492 | #define WGL_EXT_swap_control 1 493 | typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); 494 | typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); 495 | #ifdef WGL_WGLEXT_PROTOTYPES 496 | BOOL WINAPI wglSwapIntervalEXT (int interval); 497 | int WINAPI wglGetSwapIntervalEXT (void); 498 | #endif 499 | #endif /* WGL_EXT_swap_control */ 500 | 501 | #ifndef WGL_EXT_swap_control_tear 502 | #define WGL_EXT_swap_control_tear 1 503 | #endif /* WGL_EXT_swap_control_tear */ 504 | 505 | #ifndef WGL_I3D_digital_video_control 506 | #define WGL_I3D_digital_video_control 1 507 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 508 | #define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 509 | #define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 510 | #define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 511 | typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 512 | typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 513 | #ifdef WGL_WGLEXT_PROTOTYPES 514 | BOOL WINAPI wglGetDigitalVideoParametersI3D (HDC hDC, int iAttribute, int *piValue); 515 | BOOL WINAPI wglSetDigitalVideoParametersI3D (HDC hDC, int iAttribute, const int *piValue); 516 | #endif 517 | #endif /* WGL_I3D_digital_video_control */ 518 | 519 | #ifndef WGL_I3D_gamma 520 | #define WGL_I3D_gamma 1 521 | #define WGL_GAMMA_TABLE_SIZE_I3D 0x204E 522 | #define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F 523 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int *piValue); 524 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int *piValue); 525 | typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 526 | typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 527 | #ifdef WGL_WGLEXT_PROTOTYPES 528 | BOOL WINAPI wglGetGammaTableParametersI3D (HDC hDC, int iAttribute, int *piValue); 529 | BOOL WINAPI wglSetGammaTableParametersI3D (HDC hDC, int iAttribute, const int *piValue); 530 | BOOL WINAPI wglGetGammaTableI3D (HDC hDC, int iEntries, USHORT *puRed, USHORT *puGreen, USHORT *puBlue); 531 | BOOL WINAPI wglSetGammaTableI3D (HDC hDC, int iEntries, const USHORT *puRed, const USHORT *puGreen, const USHORT *puBlue); 532 | #endif 533 | #endif /* WGL_I3D_gamma */ 534 | 535 | #ifndef WGL_I3D_genlock 536 | #define WGL_I3D_genlock 1 537 | #define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 538 | #define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 539 | #define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 540 | #define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 541 | #define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 542 | #define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 543 | #define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A 544 | #define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B 545 | #define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C 546 | typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); 547 | typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); 548 | typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL *pFlag); 549 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); 550 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT *uSource); 551 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); 552 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT *uEdge); 553 | typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); 554 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT *uRate); 555 | typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); 556 | typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT *uDelay); 557 | typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 558 | #ifdef WGL_WGLEXT_PROTOTYPES 559 | BOOL WINAPI wglEnableGenlockI3D (HDC hDC); 560 | BOOL WINAPI wglDisableGenlockI3D (HDC hDC); 561 | BOOL WINAPI wglIsEnabledGenlockI3D (HDC hDC, BOOL *pFlag); 562 | BOOL WINAPI wglGenlockSourceI3D (HDC hDC, UINT uSource); 563 | BOOL WINAPI wglGetGenlockSourceI3D (HDC hDC, UINT *uSource); 564 | BOOL WINAPI wglGenlockSourceEdgeI3D (HDC hDC, UINT uEdge); 565 | BOOL WINAPI wglGetGenlockSourceEdgeI3D (HDC hDC, UINT *uEdge); 566 | BOOL WINAPI wglGenlockSampleRateI3D (HDC hDC, UINT uRate); 567 | BOOL WINAPI wglGetGenlockSampleRateI3D (HDC hDC, UINT *uRate); 568 | BOOL WINAPI wglGenlockSourceDelayI3D (HDC hDC, UINT uDelay); 569 | BOOL WINAPI wglGetGenlockSourceDelayI3D (HDC hDC, UINT *uDelay); 570 | BOOL WINAPI wglQueryGenlockMaxSourceDelayI3D (HDC hDC, UINT *uMaxLineDelay, UINT *uMaxPixelDelay); 571 | #endif 572 | #endif /* WGL_I3D_genlock */ 573 | 574 | #ifndef WGL_I3D_image_buffer 575 | #define WGL_I3D_image_buffer 1 576 | #define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 577 | #define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 578 | typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); 579 | typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); 580 | typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 581 | typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hDC, const LPVOID *pAddress, UINT count); 582 | #ifdef WGL_WGLEXT_PROTOTYPES 583 | LPVOID WINAPI wglCreateImageBufferI3D (HDC hDC, DWORD dwSize, UINT uFlags); 584 | BOOL WINAPI wglDestroyImageBufferI3D (HDC hDC, LPVOID pAddress); 585 | BOOL WINAPI wglAssociateImageBufferEventsI3D (HDC hDC, const HANDLE *pEvent, const LPVOID *pAddress, const DWORD *pSize, UINT count); 586 | BOOL WINAPI wglReleaseImageBufferEventsI3D (HDC hDC, const LPVOID *pAddress, UINT count); 587 | #endif 588 | #endif /* WGL_I3D_image_buffer */ 589 | 590 | #ifndef WGL_I3D_swap_frame_lock 591 | #define WGL_I3D_swap_frame_lock 1 592 | typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (void); 593 | typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (void); 594 | typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL *pFlag); 595 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL *pFlag); 596 | #ifdef WGL_WGLEXT_PROTOTYPES 597 | BOOL WINAPI wglEnableFrameLockI3D (void); 598 | BOOL WINAPI wglDisableFrameLockI3D (void); 599 | BOOL WINAPI wglIsEnabledFrameLockI3D (BOOL *pFlag); 600 | BOOL WINAPI wglQueryFrameLockMasterI3D (BOOL *pFlag); 601 | #endif 602 | #endif /* WGL_I3D_swap_frame_lock */ 603 | 604 | #ifndef WGL_I3D_swap_frame_usage 605 | #define WGL_I3D_swap_frame_usage 1 606 | typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float *pUsage); 607 | typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); 608 | typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); 609 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 610 | #ifdef WGL_WGLEXT_PROTOTYPES 611 | BOOL WINAPI wglGetFrameUsageI3D (float *pUsage); 612 | BOOL WINAPI wglBeginFrameTrackingI3D (void); 613 | BOOL WINAPI wglEndFrameTrackingI3D (void); 614 | BOOL WINAPI wglQueryFrameTrackingI3D (DWORD *pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); 615 | #endif 616 | #endif /* WGL_I3D_swap_frame_usage */ 617 | 618 | #ifndef WGL_NV_DX_interop 619 | #define WGL_NV_DX_interop 1 620 | #define WGL_ACCESS_READ_ONLY_NV 0x00000000 621 | #define WGL_ACCESS_READ_WRITE_NV 0x00000001 622 | #define WGL_ACCESS_WRITE_DISCARD_NV 0x00000002 623 | typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void *dxObject, HANDLE shareHandle); 624 | typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void *dxDevice); 625 | typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); 626 | typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 627 | typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); 628 | typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); 629 | typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 630 | typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE *hObjects); 631 | #ifdef WGL_WGLEXT_PROTOTYPES 632 | BOOL WINAPI wglDXSetResourceShareHandleNV (void *dxObject, HANDLE shareHandle); 633 | HANDLE WINAPI wglDXOpenDeviceNV (void *dxDevice); 634 | BOOL WINAPI wglDXCloseDeviceNV (HANDLE hDevice); 635 | HANDLE WINAPI wglDXRegisterObjectNV (HANDLE hDevice, void *dxObject, GLuint name, GLenum type, GLenum access); 636 | BOOL WINAPI wglDXUnregisterObjectNV (HANDLE hDevice, HANDLE hObject); 637 | BOOL WINAPI wglDXObjectAccessNV (HANDLE hObject, GLenum access); 638 | BOOL WINAPI wglDXLockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 639 | BOOL WINAPI wglDXUnlockObjectsNV (HANDLE hDevice, GLint count, HANDLE *hObjects); 640 | #endif 641 | #endif /* WGL_NV_DX_interop */ 642 | 643 | #ifndef WGL_NV_DX_interop2 644 | #define WGL_NV_DX_interop2 1 645 | #endif /* WGL_NV_DX_interop2 */ 646 | 647 | #ifndef WGL_NV_copy_image 648 | #define WGL_NV_copy_image 1 649 | typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 650 | #ifdef WGL_WGLEXT_PROTOTYPES 651 | BOOL WINAPI wglCopyImageSubDataNV (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); 652 | #endif 653 | #endif /* WGL_NV_copy_image */ 654 | 655 | #ifndef WGL_NV_delay_before_swap 656 | #define WGL_NV_delay_before_swap 1 657 | typedef BOOL (WINAPI * PFNWGLDELAYBEFORESWAPNVPROC) (HDC hDC, GLfloat seconds); 658 | #ifdef WGL_WGLEXT_PROTOTYPES 659 | BOOL WINAPI wglDelayBeforeSwapNV (HDC hDC, GLfloat seconds); 660 | #endif 661 | #endif /* WGL_NV_delay_before_swap */ 662 | 663 | #ifndef WGL_NV_float_buffer 664 | #define WGL_NV_float_buffer 1 665 | #define WGL_FLOAT_COMPONENTS_NV 0x20B0 666 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 667 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 668 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 669 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 670 | #define WGL_TEXTURE_FLOAT_R_NV 0x20B5 671 | #define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 672 | #define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 673 | #define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 674 | #endif /* WGL_NV_float_buffer */ 675 | 676 | #ifndef WGL_NV_gpu_affinity 677 | #define WGL_NV_gpu_affinity 1 678 | DECLARE_HANDLE(HGPUNV); 679 | struct _GPU_DEVICE { 680 | DWORD cb; 681 | CHAR DeviceName[32]; 682 | CHAR DeviceString[128]; 683 | DWORD Flags; 684 | RECT rcVirtualScreen; 685 | }; 686 | typedef struct _GPU_DEVICE *PGPU_DEVICE; 687 | #define ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 688 | #define ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 689 | typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); 690 | typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 691 | typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); 692 | typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 693 | typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); 694 | #ifdef WGL_WGLEXT_PROTOTYPES 695 | BOOL WINAPI wglEnumGpusNV (UINT iGpuIndex, HGPUNV *phGpu); 696 | BOOL WINAPI wglEnumGpuDevicesNV (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); 697 | HDC WINAPI wglCreateAffinityDCNV (const HGPUNV *phGpuList); 698 | BOOL WINAPI wglEnumGpusFromAffinityDCNV (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); 699 | BOOL WINAPI wglDeleteDCNV (HDC hdc); 700 | #endif 701 | #endif /* WGL_NV_gpu_affinity */ 702 | 703 | #ifndef WGL_NV_multisample_coverage 704 | #define WGL_NV_multisample_coverage 1 705 | #define WGL_COVERAGE_SAMPLES_NV 0x2042 706 | #define WGL_COLOR_SAMPLES_NV 0x20B9 707 | #endif /* WGL_NV_multisample_coverage */ 708 | 709 | #ifndef WGL_NV_present_video 710 | #define WGL_NV_present_video 1 711 | DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); 712 | #define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 713 | typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); 714 | typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 715 | typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int *piValue); 716 | #ifdef WGL_WGLEXT_PROTOTYPES 717 | int WINAPI wglEnumerateVideoDevicesNV (HDC hDC, HVIDEOOUTPUTDEVICENV *phDeviceList); 718 | BOOL WINAPI wglBindVideoDeviceNV (HDC hDC, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int *piAttribList); 719 | BOOL WINAPI wglQueryCurrentContextNV (int iAttribute, int *piValue); 720 | #endif 721 | #endif /* WGL_NV_present_video */ 722 | 723 | #ifndef WGL_NV_render_depth_texture 724 | #define WGL_NV_render_depth_texture 1 725 | #define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 726 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 727 | #define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 728 | #define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 729 | #define WGL_DEPTH_COMPONENT_NV 0x20A7 730 | #endif /* WGL_NV_render_depth_texture */ 731 | 732 | #ifndef WGL_NV_render_texture_rectangle 733 | #define WGL_NV_render_texture_rectangle 1 734 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 735 | #define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 736 | #define WGL_TEXTURE_RECTANGLE_NV 0x20A2 737 | #endif /* WGL_NV_render_texture_rectangle */ 738 | 739 | #ifndef WGL_NV_swap_group 740 | #define WGL_NV_swap_group 1 741 | typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); 742 | typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); 743 | typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint *group, GLuint *barrier); 744 | typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 745 | typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint *count); 746 | typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); 747 | #ifdef WGL_WGLEXT_PROTOTYPES 748 | BOOL WINAPI wglJoinSwapGroupNV (HDC hDC, GLuint group); 749 | BOOL WINAPI wglBindSwapBarrierNV (GLuint group, GLuint barrier); 750 | BOOL WINAPI wglQuerySwapGroupNV (HDC hDC, GLuint *group, GLuint *barrier); 751 | BOOL WINAPI wglQueryMaxSwapGroupsNV (HDC hDC, GLuint *maxGroups, GLuint *maxBarriers); 752 | BOOL WINAPI wglQueryFrameCountNV (HDC hDC, GLuint *count); 753 | BOOL WINAPI wglResetFrameCountNV (HDC hDC); 754 | #endif 755 | #endif /* WGL_NV_swap_group */ 756 | 757 | #ifndef WGL_NV_vertex_array_range 758 | #define WGL_NV_vertex_array_range 1 759 | typedef void *(WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 760 | typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); 761 | #ifdef WGL_WGLEXT_PROTOTYPES 762 | void *WINAPI wglAllocateMemoryNV (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority); 763 | void WINAPI wglFreeMemoryNV (void *pointer); 764 | #endif 765 | #endif /* WGL_NV_vertex_array_range */ 766 | 767 | #ifndef WGL_NV_video_capture 768 | #define WGL_NV_video_capture 1 769 | DECLARE_HANDLE(HVIDEOINPUTDEVICENV); 770 | #define WGL_UNIQUE_ID_NV 0x20CE 771 | #define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF 772 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 773 | typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 774 | typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 775 | typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 776 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 777 | #ifdef WGL_WGLEXT_PROTOTYPES 778 | BOOL WINAPI wglBindVideoCaptureDeviceNV (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); 779 | UINT WINAPI wglEnumerateVideoCaptureDevicesNV (HDC hDc, HVIDEOINPUTDEVICENV *phDeviceList); 780 | BOOL WINAPI wglLockVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 781 | BOOL WINAPI wglQueryVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int *piValue); 782 | BOOL WINAPI wglReleaseVideoCaptureDeviceNV (HDC hDc, HVIDEOINPUTDEVICENV hDevice); 783 | #endif 784 | #endif /* WGL_NV_video_capture */ 785 | 786 | #ifndef WGL_NV_video_output 787 | #define WGL_NV_video_output 1 788 | DECLARE_HANDLE(HPVIDEODEV); 789 | #define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 790 | #define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 791 | #define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 792 | #define WGL_VIDEO_OUT_COLOR_NV 0x20C3 793 | #define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 794 | #define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 795 | #define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 796 | #define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 797 | #define WGL_VIDEO_OUT_FRAME 0x20C8 798 | #define WGL_VIDEO_OUT_FIELD_1 0x20C9 799 | #define WGL_VIDEO_OUT_FIELD_2 0x20CA 800 | #define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB 801 | #define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC 802 | typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 803 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); 804 | typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 805 | typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); 806 | typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 807 | typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 808 | #ifdef WGL_WGLEXT_PROTOTYPES 809 | BOOL WINAPI wglGetVideoDeviceNV (HDC hDC, int numDevices, HPVIDEODEV *hVideoDevice); 810 | BOOL WINAPI wglReleaseVideoDeviceNV (HPVIDEODEV hVideoDevice); 811 | BOOL WINAPI wglBindVideoImageNV (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); 812 | BOOL WINAPI wglReleaseVideoImageNV (HPBUFFERARB hPbuffer, int iVideoBuffer); 813 | BOOL WINAPI wglSendPbufferToVideoNV (HPBUFFERARB hPbuffer, int iBufferType, unsigned long *pulCounterPbuffer, BOOL bBlock); 814 | BOOL WINAPI wglGetVideoInfoNV (HPVIDEODEV hpVideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); 815 | #endif 816 | #endif /* WGL_NV_video_output */ 817 | 818 | #ifndef WGL_OML_sync_control 819 | #define WGL_OML_sync_control 1 820 | typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 821 | typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32 *numerator, INT32 *denominator); 822 | typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 823 | typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 824 | typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 825 | typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 826 | #ifdef WGL_WGLEXT_PROTOTYPES 827 | BOOL WINAPI wglGetSyncValuesOML (HDC hdc, INT64 *ust, INT64 *msc, INT64 *sbc); 828 | BOOL WINAPI wglGetMscRateOML (HDC hdc, INT32 *numerator, INT32 *denominator); 829 | INT64 WINAPI wglSwapBuffersMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); 830 | INT64 WINAPI wglSwapLayerBuffersMscOML (HDC hdc, int fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); 831 | BOOL WINAPI wglWaitForMscOML (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64 *ust, INT64 *msc, INT64 *sbc); 832 | BOOL WINAPI wglWaitForSbcOML (HDC hdc, INT64 target_sbc, INT64 *ust, INT64 *msc, INT64 *sbc); 833 | #endif 834 | #endif /* WGL_OML_sync_control */ 835 | 836 | #ifdef __cplusplus 837 | } 838 | #endif 839 | 840 | #endif 841 | --------------------------------------------------------------------------------