├── .gitignore
├── .gitmodules
├── COPYING.txt
├── README.md
├── SConscript
├── SConstruct
├── TODO
├── cl.options
├── copyright-header.cpp
├── external
├── CL
│ ├── cl.h
│ ├── cl_egl.h
│ ├── cl_ext.h
│ ├── cl_gl.h
│ ├── cl_gl_ext.h
│ ├── cl_platform.h
│ └── opencl.h
└── glm
│ ├── CMakeLists.txt
│ ├── copying.txt
│ ├── core
│ ├── _detail.hpp
│ ├── _fixes.hpp
│ ├── _swizzle.hpp
│ ├── _swizzle_func.hpp
│ ├── _vectorize.hpp
│ ├── dummy.cpp
│ ├── func_common.hpp
│ ├── func_common.inl
│ ├── func_exponential.hpp
│ ├── func_exponential.inl
│ ├── func_geometric.hpp
│ ├── func_geometric.inl
│ ├── func_integer.hpp
│ ├── func_integer.inl
│ ├── func_matrix.hpp
│ ├── func_matrix.inl
│ ├── func_noise.hpp
│ ├── func_noise.inl
│ ├── func_packing.hpp
│ ├── func_packing.inl
│ ├── func_trigonometric.hpp
│ ├── func_trigonometric.inl
│ ├── func_vector_relational.hpp
│ ├── func_vector_relational.inl
│ ├── hint.hpp
│ ├── intrinsic_common.hpp
│ ├── intrinsic_common.inl
│ ├── intrinsic_exponential.hpp
│ ├── intrinsic_exponential.inl
│ ├── intrinsic_geometric.hpp
│ ├── intrinsic_geometric.inl
│ ├── intrinsic_matrix.hpp
│ ├── intrinsic_matrix.inl
│ ├── intrinsic_trigonometric.hpp
│ ├── intrinsic_trigonometric.inl
│ ├── intrinsic_vector_relational.hpp
│ ├── intrinsic_vector_relational.inl
│ ├── setup.hpp
│ ├── type.hpp
│ ├── type_float.hpp
│ ├── type_gentype.hpp
│ ├── type_gentype.inl
│ ├── type_half.hpp
│ ├── type_half.inl
│ ├── type_int.hpp
│ ├── type_mat.hpp
│ ├── type_mat.inl
│ ├── type_mat2x2.hpp
│ ├── type_mat2x2.inl
│ ├── type_mat2x3.hpp
│ ├── type_mat2x3.inl
│ ├── type_mat2x4.hpp
│ ├── type_mat2x4.inl
│ ├── type_mat3x2.hpp
│ ├── type_mat3x2.inl
│ ├── type_mat3x3.hpp
│ ├── type_mat3x3.inl
│ ├── type_mat3x4.hpp
│ ├── type_mat3x4.inl
│ ├── type_mat4x2.hpp
│ ├── type_mat4x2.inl
│ ├── type_mat4x3.hpp
│ ├── type_mat4x3.inl
│ ├── type_mat4x4.hpp
│ ├── type_mat4x4.inl
│ ├── type_size.hpp
│ ├── type_vec.hpp
│ ├── type_vec.inl
│ ├── type_vec1.hpp
│ ├── type_vec1.inl
│ ├── type_vec2.hpp
│ ├── type_vec2.inl
│ ├── type_vec3.hpp
│ ├── type_vec3.inl
│ ├── type_vec4.hpp
│ └── type_vec4.inl
│ ├── ext.hpp
│ ├── glm.hpp
│ ├── gtc
│ ├── half_float.hpp
│ ├── half_float.inl
│ ├── matrix_access.hpp
│ ├── matrix_access.inl
│ ├── matrix_integer.hpp
│ ├── matrix_inverse.hpp
│ ├── matrix_inverse.inl
│ ├── matrix_transform.hpp
│ ├── matrix_transform.inl
│ ├── noise.hpp
│ ├── noise.inl
│ ├── quaternion.hpp
│ ├── quaternion.inl
│ ├── random.hpp
│ ├── random.inl
│ ├── swizzle.hpp
│ ├── swizzle.inl
│ ├── type_precision.hpp
│ ├── type_precision.inl
│ ├── type_ptr.hpp
│ └── type_ptr.inl
│ ├── gtx
│ ├── associated_min_max.hpp
│ ├── associated_min_max.inl
│ ├── bit.hpp
│ ├── bit.inl
│ ├── closest_point.hpp
│ ├── closest_point.inl
│ ├── color_cast.hpp
│ ├── color_cast.inl
│ ├── color_space.hpp
│ ├── color_space.inl
│ ├── color_space_YCoCg.hpp
│ ├── color_space_YCoCg.inl
│ ├── compatibility.hpp
│ ├── compatibility.inl
│ ├── component_wise.hpp
│ ├── component_wise.inl
│ ├── constants.hpp
│ ├── constants.inl
│ ├── epsilon.hpp
│ ├── epsilon.inl
│ ├── euler_angles.hpp
│ ├── euler_angles.inl
│ ├── extend.hpp
│ ├── extend.inl
│ ├── extented_min_max.hpp
│ ├── extented_min_max.inl
│ ├── fast_exponential.hpp
│ ├── fast_exponential.inl
│ ├── fast_square_root.hpp
│ ├── fast_square_root.inl
│ ├── fast_trigonometry.hpp
│ ├── fast_trigonometry.inl
│ ├── gradient_paint.hpp
│ ├── gradient_paint.inl
│ ├── handed_coordinate_space.hpp
│ ├── handed_coordinate_space.inl
│ ├── inertia.hpp
│ ├── inertia.inl
│ ├── int_10_10_10_2.hpp
│ ├── int_10_10_10_2.inl
│ ├── integer.hpp
│ ├── integer.inl
│ ├── intersect.hpp
│ ├── intersect.inl
│ ├── log_base.hpp
│ ├── log_base.inl
│ ├── matrix_cross_product.hpp
│ ├── matrix_cross_product.inl
│ ├── matrix_interpolation.hpp
│ ├── matrix_interpolation.inl
│ ├── matrix_major_storage.hpp
│ ├── matrix_major_storage.inl
│ ├── matrix_operation.hpp
│ ├── matrix_operation.inl
│ ├── matrix_query.hpp
│ ├── matrix_query.inl
│ ├── mixed_product.hpp
│ ├── mixed_product.inl
│ ├── multiple.hpp
│ ├── multiple.inl
│ ├── noise.hpp
│ ├── noise.inl
│ ├── norm.hpp
│ ├── norm.inl
│ ├── normal.hpp
│ ├── normal.inl
│ ├── normalize_dot.hpp
│ ├── normalize_dot.inl
│ ├── number_precision.hpp
│ ├── number_precision.inl
│ ├── ocl_type.hpp
│ ├── ocl_type.inl
│ ├── optimum_pow.hpp
│ ├── optimum_pow.inl
│ ├── orthonormalize.hpp
│ ├── orthonormalize.inl
│ ├── perpendicular.hpp
│ ├── perpendicular.inl
│ ├── polar_coordinates.hpp
│ ├── polar_coordinates.inl
│ ├── projection.hpp
│ ├── projection.inl
│ ├── quaternion.hpp
│ ├── quaternion.inl
│ ├── random.hpp
│ ├── random.inl
│ ├── raw_data.hpp
│ ├── raw_data.inl
│ ├── reciprocal.hpp
│ ├── reciprocal.inl
│ ├── rotate_vector.hpp
│ ├── rotate_vector.inl
│ ├── simd_mat4.hpp
│ ├── simd_mat4.inl
│ ├── simd_vec4.hpp
│ ├── simd_vec4.inl
│ ├── spline.hpp
│ ├── spline.inl
│ ├── std_based_type.hpp
│ ├── std_based_type.inl
│ ├── string_cast.hpp
│ ├── string_cast.inl
│ ├── transform.hpp
│ ├── transform.inl
│ ├── transform2.hpp
│ ├── transform2.inl
│ ├── ulp.hpp
│ ├── ulp.inl
│ ├── unsigned_int.hpp
│ ├── unsigned_int.inl
│ ├── vec1.hpp
│ ├── vec1.inl
│ ├── vector_access.hpp
│ ├── vector_access.inl
│ ├── vector_angle.hpp
│ ├── vector_angle.inl
│ ├── vector_query.hpp
│ ├── vector_query.inl
│ ├── verbose_operator.hpp
│ ├── verbose_operator.inl
│ ├── wrap.hpp
│ └── wrap.inl
│ └── virtrev
│ └── xstream.hpp
├── gl.options
├── kernels
├── bound_n_split.h
├── bound_n_split_balanced.cl
├── bound_n_split_breadthfirst.cl
├── bound_n_split_local.cl
├── bound_n_split_multipass.cl
├── dice.cl
├── framebuffer.cl
├── histogram_pyramid.cl
├── prefix_sum.cl
├── reyes.cl
├── test.cl
└── utility.h
├── micropolis
├── micropolis.options
├── reyes.options
├── shaders
├── bound_n_split.h
├── hwtess.frag
├── hwtess.tess_ctrl
├── hwtess.tess_eval
├── hwtess.vert
├── local_bound_n_split.compute
├── local_clear_out_range_cnt.compute
├── local_init_count_buffers.compute
├── local_init_range_buffers.compute
├── local_prefixsum.h
├── local_setup_indirection.compute
├── multipass_bound.compute
├── multipass_copy_ranges.compute
├── multipass_create_geometry_for_ranges.compute
├── multipass_init_ranges.compute
├── multipass_setup_indirection.compute
├── noise
│ ├── classicnoise2D.glsl
│ ├── classicnoise3D.glsl
│ ├── classicnoise4D.glsl
│ ├── noise2D.glsl
│ ├── noise3D.glsl
│ └── noise4D.glsl
├── prefixsum_accumulate.compute
├── prefixsum_reduce.compute
├── tex_draw.frag
├── tex_draw.vert
├── utility.h
├── wire.frag
├── wire.tess_ctrl
├── wire.tess_eval
└── wire.vert
├── src
├── CL
│ ├── Buffer.cpp
│ ├── Buffer.h
│ ├── CommandQueue.cpp
│ ├── CommandQueue.h
│ ├── Device.cpp
│ ├── Device.h
│ ├── Event.cpp
│ ├── Event.h
│ ├── Exception.cpp
│ ├── Exception.h
│ ├── HistogramPyramid.cpp
│ ├── HistogramPyramid.h
│ ├── Kernel.cpp
│ ├── Kernel.h
│ ├── OpenCL.h
│ ├── PrefixSum.cpp
│ ├── PrefixSum.h
│ ├── Program.cpp
│ ├── Program.h
│ └── config.xml
├── GL
│ ├── Buffer.cpp
│ ├── Buffer.h
│ ├── ComputeShader.cpp
│ ├── ComputeShader.h
│ ├── Image.cpp
│ ├── Image.h
│ ├── PrefixSum.cpp
│ ├── PrefixSum.h
│ ├── Shader.cpp
│ ├── Shader.h
│ ├── ShaderObject.cpp
│ ├── ShaderObject.h
│ ├── Texture.cpp
│ ├── Texture.h
│ ├── VBO.cpp
│ ├── VBO.h
│ ├── config.xml
│ ├── extensions.glprofile
│ ├── glutils.cpp
│ ├── glutils.h
│ └── type_info.h
├── Reyes
│ ├── BoundNSplitCL.h
│ ├── BoundNSplitCLBounded.cpp
│ ├── BoundNSplitCLBounded.h
│ ├── BoundNSplitCLBreadth.cpp
│ ├── BoundNSplitCLBreadth.h
│ ├── BoundNSplitCLCPU.cpp
│ ├── BoundNSplitCLCPU.h
│ ├── BoundNSplitCLLocal.cpp
│ ├── BoundNSplitCLLocal.h
│ ├── Framebuffer.cpp
│ ├── Framebuffer.h
│ ├── PatchIndex.cpp
│ ├── PatchIndex.h
│ ├── PatchRange.h
│ ├── PatchType.h
│ ├── Renderer.cpp
│ ├── Renderer.h
│ ├── RendererCL.cpp
│ ├── RendererCL.h
│ ├── Reyes.h
│ ├── config.xml
│ └── old
│ │ ├── BoundNSplitCLBalanced.cpp
│ │ ├── BoundNSplitCLBalanced.h
│ │ ├── BoundNSplitCLBreadthFirst.cpp
│ │ ├── BoundNSplitCLBreadthFirst.h
│ │ ├── BoundNSplitGL.h
│ │ ├── BoundNSplitGLCPU.cpp
│ │ ├── BoundNSplitGLCPU.h
│ │ ├── BoundNSplitGLLocal.cpp
│ │ ├── BoundNSplitGLLocal.h
│ │ ├── BoundNSplitGLMultipass.cpp
│ │ ├── BoundNSplitGLMultipass.h
│ │ ├── RendererGLHWTess.cpp
│ │ ├── RendererGLHWTess.h
│ │ ├── RendererGLWire.cpp
│ │ └── RendererGLWire.h
├── base
│ ├── Patch.cpp
│ ├── Patch.h
│ ├── Projection.cpp
│ ├── Projection.h
│ ├── Statistics.cpp
│ ├── Statistics.h
│ ├── common.h
│ ├── utility.cpp
│ └── utility.h
└── micropolis
│ ├── Scene.cpp
│ ├── Scene.h
│ ├── config.xml
│ ├── main.cpp
│ └── mscene.capnp
├── testscene
├── bigguy.mscene
├── blender
│ ├── columns.blend
│ ├── depth_complexity.blend
│ ├── depth_complexity512.blend
│ ├── eyesplit.blend
│ ├── pillars.blend
│ ├── test.blend
│ └── tree.blend
├── columns.mscene
├── depth_complexity.mscene
├── eye_split.mscene
├── hair.mscene
├── hair2.mscene
├── hair3.mscene
├── killeroo.mscene
├── killeroos.mscene
├── pillars.mscene
├── spheres.mscene
├── teapot.mscene
├── teapot_greg.mscene
├── teapots.mscene
├── test.mscene
└── tree.mscene
├── tools
├── benchmark.py
├── benchmark_plot.py
├── bez2mscene.py
├── bez2mscene_greg.py
├── blender_graph.py
├── changecolor.py
├── create_load_plot.py
├── formatMapGen.py
├── format_map_template.cc
├── generate_traces.sh
├── local_bns_plot.py
├── measure_bound_rates.py
├── measure_camera_path.py
├── measure_local_speedup.py
├── measure_local_vs_multipass.py
├── measure_new_times.py
├── measure_speedup.py
├── measure_times.py
├── measure_times_for_comparison.py
├── measure_traces.sh
├── measure_trade_off.py
├── mscene_export.py
├── parse_trace.py
├── plot_bound_rate.py
├── plot_bound_rate_loc_v_multipass.py
├── plot_bound_rate_old.py
├── plot_camera_path.py
├── plot_tradeoff.py
├── show_balance.py
├── show_trace.sh
├── trace_summary.py
└── visualize_trace.py
└── traces
├── HD7970-host-bns.trace
└── R9-290X-host-bns.trace
/.gitignore:
--------------------------------------------------------------------------------
1 | testscene/zinkia*
2 | mscene/zinkia*
3 | screenshot*
4 | traces/*.pdf
5 | *.o
6 | micropolis_*
7 | generated/*
8 | .sconsign.dblite
9 | reyes.trace
10 | reyes.statistics
11 | statistics.dump
12 | AMDOpenCLDebugAPIUsage.log
13 | __pycache__
14 | debug/
15 | release/
16 | benchmarks/
17 | *.blend1
18 | *.blend2
19 | *.blend3
20 | measurements/
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "tools/flextGL"]
2 | path = tools/flextGL
3 | url = https://github.com/ginkgo/flextGL.git
4 | [submodule "tools/configGen"]
5 | path = tools/configGen
6 | url = https://github.com/ginkgo/configGen.git
7 |
--------------------------------------------------------------------------------
/SConscript:
--------------------------------------------------------------------------------
1 | Import('env')
2 | Import('python3')
3 | Import('config')
4 |
5 | env.Command(['#/%s/generated/flextGL.c' % config, '#/%s/generated/flextGL.h' % config],
6 | ['#/src/GL/extensions.glprofile', '#/tools/flextGL/flextGLgen.py', '#/tools/flextGL/flext.py',
7 | Glob('#/tools/flextGL/templates/glfw3/*template')],
8 | python3+' tools/flextGL/flextGLgen.py src/GL/extensions.glprofile -D%s/generated -Tglfw3' % config)
9 |
10 | env.Command(['#/%s/generated/Config.cpp' % config, '#/%s/generated/Config.h' % config],
11 | ['#/src/micropolis/config.xml', Glob('#/tools/configGen/*')],
12 | python3+' tools/configGen/configGen.py src/micropolis/config.xml -D%s/generated -Hh -Ccpp' % config)
13 |
14 | env.Command(['#/%s/generated/CLConfig.cpp' % config, '#/%s/generated/CLConfig.h' % config],
15 | ['#/src/CL/config.xml', Glob('#/tools/configGen/*')],
16 | python3+' tools/configGen/configGen.py src/CL/config.xml -D%s/generated -Hh -Ccpp' % config)
17 |
18 | env.Command(['#/%s/generated/GLConfig.cpp' % config, '#/%s/generated/GLConfig.h' % config],
19 | ['#/src/GL/config.xml', Glob('#/tools/configGen/*')],
20 | python3+' tools/configGen/configGen.py src/GL/config.xml -D%s/generated -Hh -Ccpp' % config)
21 |
22 | env.Command(['#/%s/generated/ReyesConfig.cpp' % config, '#/%s/generated/ReyesConfig.h' % config],
23 | ['#/src/Reyes/config.xml', Glob('#/tools/configGen/*')],
24 | python3+' tools/configGen/configGen.py src/Reyes/config.xml -D%s/generated -Hh -Ccpp' % config)
25 |
26 | env.Command(['#/%s/generated/format_map.cpp' % config, '#/%s/generated/format_map.h' % config],
27 | Glob('tools/format*'),
28 | python3+' tools/formatMapGen.py -D%s/generated -Hh -Ccpp' % config)
29 |
30 | env.Command(['#/%s/generated/mscene.capnp.c++' % config, '#/%s/generated/mscene.capnp.h' % config],
31 | ['#/src/micropolis/mscene.capnp'],
32 | 'capnpc src/micropolis/mscene.capnp --src-prefix=src/micropolis -oc++:%s/generated' % config)
33 |
34 |
35 | base = env.Object(Glob('src/base/*.cpp') + ['#/%s/generated/Config.cpp' % config])
36 | GL = env.Object(Glob('src/GL/*.cpp') + ['#/%s/generated/flextGL.c' % config, '#/%s/generated/format_map.cpp' % config, '#/%s/generated/GLConfig.cpp' % config])
37 | CL = env.Object(Glob('src/CL/*.cpp') + ['#/%s/generated/CLConfig.cpp' % config])
38 | Reyes = env.Object(Glob('src/Reyes/*.cpp') + ['#/%s/generated/ReyesConfig.cpp' % config])
39 |
40 | env.Program('#/micropolis_%s' % config,
41 | Glob('src/micropolis/*.cpp') + ['#/%s/generated/mscene.capnp.c++' % config] + base + GL + CL + Reyes)
42 |
--------------------------------------------------------------------------------
/SConstruct:
--------------------------------------------------------------------------------
1 |
2 | used_toolchain = 'GCC'
3 | python3 = 'python3'
4 |
5 |
6 | def setup_env(toolchain, optimization_flags, defines, config):
7 |
8 | env = Environment()
9 |
10 | warning_flags = ['-Wall', '-Wextra',
11 | '-Wno-ignored-qualifiers',
12 | '-Wno-unused-but-set-variable',
13 | '-Wno-unused-parameter',
14 | '-Wno-unused-variable',
15 | '-Wno-unknown-pragmas']
16 |
17 | env['CPPPATH'] = ['#/external', '#/%s/generated' % config, '#src', '#src/base']
18 |
19 | if toolchain=='GCC':
20 | env['LINK'] = 'g++'
21 | env['CC'] = 'gcc'
22 | env['CXX'] = 'g++'
23 | elif used_toolchain=='Clang':
24 | env['LINK'] = 'clang++'
25 | env['CC'] = 'clang'
26 | env['CXX'] = 'clang++'
27 | else:
28 | print('The toolchain \'%s\' is not supported.' % toolchain)
29 | Exit(1)
30 |
31 | env['LIBS'] = ['GL', 'glfw', 'boost_regex', 'IL', 'OpenCL', 'Xrandr', 'rt', 'capnp', 'kj']
32 | env['CCFLAGS'] = optimization_flags + warning_flags
33 | env['CXXFLAGS'] = ['-std=c++11']
34 | env['CFLAGS'] = ['-std=c99']
35 | env['LINKFLAGS'] = []
36 |
37 | env['CPPDEFINES'] = defines
38 |
39 | return env
40 |
41 | release_env = setup_env(used_toolchain, optimization_flags=['-O2', '-msse4'], defines=['linux', 'NDEBUG'], config='release')
42 | debug_env = setup_env(used_toolchain, optimization_flags=['-O0', '-ggdb'], defines=['linux', 'DEBUG_OPENCL'], config='debug')
43 |
44 |
45 | SConscript('SConscript', variant_dir='release', duplicate=0, exports={'env':release_env, 'python3':python3, 'config':'release'})
46 | SConscript('SConscript', variant_dir='debug', duplicate=0, exports={'env':debug_env, 'python3':python3, 'config':'debug'})
47 |
48 |
49 |
--------------------------------------------------------------------------------
/cl.options:
--------------------------------------------------------------------------------
1 | // Search directory for OpenCL kernels.
2 | kernel_dir = kernels
3 |
4 | // Pair of integers defining the platform and device id of the OpenCL device that shall be used.
5 | opencl_device_id = 0 0
6 |
7 | // Force slow path for OpenCL/OpenGL buffer sharing.
8 | disable_buffer_sharing = false
9 |
10 | // Controls how we wait for OpenCL events. Polling is slightly faster but uses more CPU cycles.
11 | do_event_polling = true
12 |
13 | // Allocation method of host/device transfer buffers. Either PINNED or UNPINNED.
14 | // PINNED should be a lot faster.
15 | transfer_buffer_mode = PINNED
16 |
17 | // Will dump the concatenated OpenCL kernel files into /tmp/ for debugging purposes.
18 | dump_kernel_files = false
19 |
20 | // Target file for writing OpenCL trace to.
21 | trace_file = reyes.trace
22 |
23 |
24 |
25 | #hash:-6551815436000442985
26 |
--------------------------------------------------------------------------------
/copyright-header.cpp:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 | This file is part of Micropolis.
20 |
21 | Micropolis is free software: you can redistribute it and/or modify
22 | it under the terms of the GNU General Public License as published by
23 | the Free Software Foundation, either version 3 of the License, or
24 | (at your option) any later version.
25 |
26 | Micropolis is distributed in the hope that it will be useful,
27 | but WITHOUT ANY WARRANTY; without even the implied warranty of
28 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 | GNU General Public License for more details.
30 |
31 | You should have received a copy of the GNU General Public License
32 | along with Micropolis. If not, see .
33 |
--------------------------------------------------------------------------------
/external/CL/opencl.h:
--------------------------------------------------------------------------------
1 | /*******************************************************************************
2 | * Copyright (c) 2008-2012 The Khronos Group Inc.
3 | *
4 | * Permission is hereby granted, free of charge, to any person obtaining a
5 | * copy of this software and/or associated documentation files (the
6 | * "Materials"), to deal in the Materials without restriction, including
7 | * without limitation the rights to use, copy, modify, merge, publish,
8 | * distribute, sublicense, and/or sell copies of the Materials, and to
9 | * permit persons to whom the Materials are furnished to do so, subject to
10 | * the following conditions:
11 | *
12 | * The above copyright notice and this permission notice shall be included
13 | * in all copies or substantial portions of the Materials.
14 | *
15 | * THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 | * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 | * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 | * MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
22 | ******************************************************************************/
23 |
24 | /* $Revision: 11708 $ on $Date: 2010-06-13 23:36:24 -0700 (Sun, 13 Jun 2010) $ */
25 |
26 | #ifndef __OPENCL_H
27 | #define __OPENCL_H
28 |
29 | #ifdef __cplusplus
30 | extern "C" {
31 | #endif
32 |
33 | #ifdef __APPLE__
34 |
35 | #include
36 | #include
37 | #include
38 | #include
39 |
40 | #else
41 |
42 | #include
43 | #include
44 | #include
45 | #include
46 |
47 | #endif
48 |
49 | #ifdef __cplusplus
50 | }
51 | #endif
52 |
53 | #endif /* __OPENCL_H */
54 |
55 |
--------------------------------------------------------------------------------
/external/glm/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(NAME glm)
2 |
3 | file(GLOB ROOT_SOURCE *.cpp)
4 | file(GLOB ROOT_INLINE *.inl)
5 | file(GLOB ROOT_HEADER *.hpp)
6 |
7 | file(GLOB_RECURSE CORE_SOURCE ./core/*.cpp)
8 | file(GLOB_RECURSE CORE_INLINE ./core/*.inl)
9 | file(GLOB_RECURSE CORE_HEADER ./core/*.hpp)
10 |
11 | file(GLOB_RECURSE GTC_SOURCE ./gtc/*.cpp)
12 | file(GLOB_RECURSE GTC_INLINE ./gtc/*.inl)
13 | file(GLOB_RECURSE GTC_HEADER ./gtc/*.hpp)
14 |
15 | file(GLOB_RECURSE GTX_SOURCE ./gtx/*.cpp)
16 | file(GLOB_RECURSE GTX_INLINE ./gtx/*.inl)
17 | file(GLOB_RECURSE GTX_HEADER ./gtx/*.hpp)
18 |
19 | file(GLOB_RECURSE VIRTREV_SOURCE ./virtrev/*.cpp)
20 | file(GLOB_RECURSE VIRTREV_INLINE ./virtrev/*.inl)
21 | file(GLOB_RECURSE VIRTREV_HEADER ./virtrev/*.hpp)
22 |
23 | source_group("Core Files" FILES ${CORE_SOURCE})
24 | source_group("Core Files" FILES ${CORE_INLINE})
25 | source_group("Core Files" FILES ${CORE_HEADER})
26 | source_group("GTC Files" FILES ${GTC_SOURCE})
27 | source_group("GTC Files" FILES ${GTC_INLINE})
28 | source_group("GTC Files" FILES ${GTC_HEADER})
29 | source_group("GTX Files" FILES ${GTX_SOURCE})
30 | source_group("GTX Files" FILES ${GTX_INLINE})
31 | source_group("GTX Files" FILES ${GTX_HEADER})
32 | source_group("VIRTREV Files" FILES ${VIRTREV_SOURCE})
33 | source_group("VIRTREV Files" FILES ${VIRTREV_INLINE})
34 | source_group("VIRTREV Files" FILES ${VIRTREV_HEADER})
35 |
36 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
37 |
38 | add_executable(${NAME}
39 | ${ROOT_SOURCE} ${ROOT_INLINE} ${ROOT_HEADER}
40 | ${CORE_SOURCE} ${CORE_INLINE} ${CORE_HEADER}
41 | ${GTC_SOURCE} ${GTC_INLINE} ${GTC_HEADER}
42 | ${GTX_SOURCE} ${GTX_INLINE} ${GTX_HEADER}
43 | ${VIRTREV_SOURCE} ${VIRTREV_INLINE} ${VIRTREV_HEADER})
44 |
--------------------------------------------------------------------------------
/external/glm/copying.txt:
--------------------------------------------------------------------------------
1 | The MIT License
2 |
3 | Copyright (c) 2005 - 2012 G-Truc Creation
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/external/glm/core/_fixes.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/_fixes.hpp
25 | /// @date 2011-02-21 / 2011-11-22
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #include
30 |
31 | //! Workaround for compatibility with other libraries
32 | #ifdef max
33 | #undef max
34 | #endif
35 |
36 | //! Workaround for compatibility with other libraries
37 | #ifdef min
38 | #undef min
39 | #endif
40 |
41 | //! Workaround for Android
42 | #ifdef isnan
43 | #undef isnan
44 | #endif
45 |
46 | //! Workaround for Android
47 | #ifdef isinf
48 | #undef isinf
49 | #endif
50 |
51 | //! Workaround for Chrone Native Client
52 | #ifdef log2
53 | #undef log2
54 | #endif
55 |
56 |
--------------------------------------------------------------------------------
/external/glm/core/dummy.cpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/dummy.cpp
25 | /// @date 2011-01-19 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///
28 | /// GLM is a header only library. There is nothing to compile.
29 | /// dummy.cpp exist only a wordaround for CMake file.
30 | ///////////////////////////////////////////////////////////////////////////////////
31 |
32 | #define GLM_MESSAGES
33 | #include "../glm.hpp"
34 | #include "../ext.hpp"
35 |
36 | //#error "GLM is a header only library"
37 |
38 | int main()
39 | {
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/external/glm/core/func_common.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/core/func_common.hpp
--------------------------------------------------------------------------------
/external/glm/core/func_common.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/core/func_common.inl
--------------------------------------------------------------------------------
/external/glm/core/func_integer.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/core/func_integer.hpp
--------------------------------------------------------------------------------
/external/glm/core/hint.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/hint.hpp
25 | /// @date 2008-08-14 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #ifndef glm_core_type
30 | #define glm_core_type
31 |
32 | namespace glm
33 | {
34 | // Use dont_care, nicest and fastest to optimize implementations.
35 | class dont_care {};
36 | class nicest {};
37 | class fastest {};
38 | }//namespace glm
39 |
40 | #endif//glm_core_type
41 |
--------------------------------------------------------------------------------
/external/glm/core/intrinsic_exponential.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/intrinsic_exponential.inl
25 | /// @date 2011-06-15 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
--------------------------------------------------------------------------------
/external/glm/core/intrinsic_trigonometric.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/intrinsic_trigonometric.hpp
25 | /// @date 2009-06-09 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #ifndef glm_detail_intrinsic_trigonometric
30 | #define glm_detail_intrinsic_trigonometric
31 |
32 | #include "setup.hpp"
33 |
34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2)
35 | # error "SSE2 instructions not supported or enabled"
36 | #else
37 |
38 | namespace glm{
39 | namespace detail
40 | {
41 |
42 | }//namespace detail
43 | }//namespace glm
44 |
45 | #include "intrinsic_trigonometric.inl"
46 |
47 | #endif//GLM_ARCH
48 | #endif//glm_detail_intrinsic_trigonometric
49 |
--------------------------------------------------------------------------------
/external/glm/core/intrinsic_trigonometric.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/intrinsic_trigonometric.inl
25 | /// @date 2011-06-15 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
--------------------------------------------------------------------------------
/external/glm/core/intrinsic_vector_relational.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/intrinsic_vector_relational.hpp
25 | /// @date 2009-06-09 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #ifndef glm_detail_intrinsic_vector_relational
30 | #define glm_detail_intrinsic_vector_relational
31 |
32 | #include "setup.hpp"
33 |
34 | #if((GLM_ARCH & GLM_ARCH_SSE2) != GLM_ARCH_SSE2)
35 | # error "SSE2 instructions not supported or enabled"
36 | #else
37 |
38 | namespace glm{
39 | namespace detail
40 | {
41 |
42 | }//namespace detail
43 | }//namespace glm
44 |
45 | #include "intrinsic_vector_relational.inl"
46 |
47 | #endif//GLM_ARCH
48 | #endif//glm_detail_intrinsic_vector_relational
49 |
--------------------------------------------------------------------------------
/external/glm/core/type_half.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/core/type_half.inl
--------------------------------------------------------------------------------
/external/glm/core/type_mat.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/type_mat.inl
25 | /// @date 2011-06-15 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
--------------------------------------------------------------------------------
/external/glm/core/type_size.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/type_size.hpp
25 | /// @date 2008-10-05 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #ifndef glm_core_type_size
30 | #define glm_core_type_size
31 |
32 | #include
33 |
34 | namespace glm{
35 | namespace detail
36 | {
37 | //typedef std::size_t size_t;
38 | typedef int sizeType;
39 |
40 | }//namespace detail
41 | }//namespace glm
42 |
43 | #endif//glm_core_type_size
44 |
--------------------------------------------------------------------------------
/external/glm/core/type_vec.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/type_vec.hpp
25 | /// @date 2010-01-26 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | #ifndef glm_core_type_vec
30 | #define glm_core_type_vec
31 |
32 | #include "type_gentype.hpp"
33 |
34 | namespace glm{
35 | namespace detail
36 | {
37 |
38 | }//namespace detail
39 | }//namespace glm
40 |
41 | #endif//glm_core_type_vec
42 |
--------------------------------------------------------------------------------
/external/glm/core/type_vec.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref core
24 | /// @file glm/core/type_vec.inl
25 | /// @date 2011-06-15 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
--------------------------------------------------------------------------------
/external/glm/gtc/type_precision.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtc_swizzle
24 | /// @file glm/gtc/swizzle.inl
25 | /// @date 2009-06-14 / 2011-06-15
26 | /// @author Christophe Riccio
27 | ///////////////////////////////////////////////////////////////////////////////////
28 |
29 | namespace glm
30 | {
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/external/glm/gtx/closest_point.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_bit
24 | /// @file glm/gtx/bit.hpp
25 | /// @date 2005-12-30 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | ///
30 | /// @defgroup gtx_closest_point GLM_GTX_closest_point: Find closest point
31 | /// @ingroup gtx
32 | ///
33 | /// @brief Find the point on a straight line which is the closet of a point.
34 | ///
35 | /// need to be included to use these functionalities.
36 | ///////////////////////////////////////////////////////////////////////////////////
37 |
38 | #ifndef GLM_GTX_closest_point
39 | #define GLM_GTX_closest_point GLM_VERSION
40 |
41 | // Dependency:
42 | #include "../glm.hpp"
43 |
44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
45 | # pragma message("GLM: GLM_GTX_closest_point extension included")
46 | #endif
47 |
48 | namespace glm
49 | {
50 | /// @addtogroup gtx_closest_point
51 | /// @{
52 |
53 | /// Find the point on a straight line which is the closet of a point.
54 | /// @see gtx_closest_point
55 | template
56 | detail::tvec3 closestPointOnLine(
57 | detail::tvec3 const & point,
58 | detail::tvec3 const & a,
59 | detail::tvec3 const & b);
60 |
61 | /// @}
62 | }// namespace glm
63 |
64 | #include "closest_point.inl"
65 |
66 | #endif//GLM_GTX_closest_point
67 |
--------------------------------------------------------------------------------
/external/glm/gtx/closest_point.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-30
5 | // Updated : 2008-10-05
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/closest_point.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | #ifndef glm_gtx_closest_point
11 | #define glm_gtx_closest_point
12 |
13 | namespace glm
14 | {
15 | template
16 | GLM_FUNC_QUALIFIER detail::tvec3 closestPointOnLine
17 | (
18 | detail::tvec3 const & point,
19 | detail::tvec3 const & a,
20 | detail::tvec3 const & b
21 | )
22 | {
23 | valType LineLength = distance(a, b);
24 | detail::tvec3 Vector = point - a;
25 | detail::tvec3 LineDirection = (b - a) / LineLength;
26 |
27 | // Project Vector to LineDirection to get the distance of point from a
28 | valType Distance = dot(Vector, LineDirection);
29 |
30 | if(Distance <= valType(0)) return a;
31 | if(Distance >= LineLength) return b;
32 | return a + LineDirection * Distance;
33 | }
34 | }//namespace glm
35 |
36 | #endif//glm_gtx_closest_point
37 |
--------------------------------------------------------------------------------
/external/glm/gtx/color_space_YCoCg.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2008-10-28
5 | // Updated : 2008-10-28
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/color_space_YCoCg.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCg
14 | (
15 | detail::tvec3 const & rgbColor
16 | )
17 | {
18 | detail::tvec3 result;
19 | result.x/*Y */ = rgbColor.r / valType(4) + rgbColor.g / valType(2) + rgbColor.b / valType(4);
20 | result.y/*Co*/ = rgbColor.r / valType(2) + rgbColor.g * valType(0) - rgbColor.b / valType(2);
21 | result.z/*Cg*/ = - rgbColor.r / valType(4) + rgbColor.g / valType(2) - rgbColor.b / valType(4);
22 | return result;
23 | }
24 |
25 | template
26 | GLM_FUNC_QUALIFIER detail::tvec3 rgb2YCoCgR
27 | (
28 | detail::tvec3 const & rgbColor
29 | )
30 | {
31 | detail::tvec3 result;
32 | result.x/*Y */ = rgbColor.g / valType(2) + (rgbColor.r + rgbColor.b) / valType(4);
33 | result.y/*Co*/ = rgbColor.r - rgbColor.b;
34 | result.z/*Cg*/ = rgbColor.g - (rgbColor.r + rgbColor.b) / valType(2);
35 | return result;
36 | }
37 |
38 | template
39 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCg2rgb
40 | (
41 | detail::tvec3 const & YCoCgColor
42 | )
43 | {
44 | detail::tvec3 result;
45 | result.r = YCoCgColor.x + YCoCgColor.y - YCoCgColor.z;
46 | result.g = YCoCgColor.x + YCoCgColor.z;
47 | result.b = YCoCgColor.x - YCoCgColor.y - YCoCgColor.z;
48 | return result;
49 | }
50 |
51 | template
52 | GLM_FUNC_QUALIFIER detail::tvec3 YCoCgR2rgb
53 | (
54 | detail::tvec3 const & YCoCgRColor
55 | )
56 | {
57 | detail::tvec3 result;
58 | valType tmp = YCoCgRColor.x - (YCoCgRColor.z / valType(2));
59 | result.g = YCoCgRColor.z + tmp;
60 | result.b = tmp - (YCoCgRColor.y / valType(2));
61 | result.r = result.b + YCoCgRColor.y;
62 | return result;
63 | }
64 | }//namespace glm
65 |
--------------------------------------------------------------------------------
/external/glm/gtx/component_wise.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2007-05-21
5 | // Updated : 2010-02-12
6 | // Licence : This source is under MIT License
7 | // File : gtx_component_wise.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER typename genType::value_type compAdd(genType const & v)
14 | {
15 | typename genType::size_type result = typename genType::value_type(0);
16 | for(typename genType::size_type i = 0; i < v.length(); ++i)
17 | result += v[i];
18 | return result;
19 | }
20 |
21 | template
22 | GLM_FUNC_QUALIFIER typename genType::value_type compMul(genType const & v)
23 | {
24 | typename genType::value_type result = typename genType::value_type(1);
25 | for(typename genType::size_type i = 0; i < v.length(); ++i)
26 | result *= v[i];
27 | return result;
28 | }
29 |
30 | template
31 | GLM_FUNC_QUALIFIER typename genType::value_type compMin(genType const & v)
32 | {
33 | typename genType::value_type result = typename genType::value_type(v[0]);
34 | for(typename genType::size_type i = 1; i < v.length(); ++i)
35 | result = min(result, v[i]);
36 | return result;
37 | }
38 |
39 | template
40 | GLM_FUNC_QUALIFIER typename genType::value_type compMax(genType const & v)
41 | {
42 | typename genType::value_type result = typename genType::value_type(v[0]);
43 | for(typename genType::size_type i = 1; i < v.length(); ++i)
44 | result = max(result, v[i]);
45 | return result;
46 | }
47 | }//namespace glm
48 |
--------------------------------------------------------------------------------
/external/glm/gtx/extend.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_extend
24 | /// @file glm/gtx/extend.hpp
25 | /// @date 2006-01-07 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | ///
30 | /// @defgroup gtx_extend GLM_GTX_extend: Position extending
31 | /// @ingroup gtx
32 | ///
33 | /// @brief Extend a position from a source to a position at a defined length.
34 | ///
35 | /// need to be included to use these functionalities.
36 | ///////////////////////////////////////////////////////////////////////////////////
37 |
38 | #ifndef GLM_GTX_extend
39 | #define GLM_GTX_extend GLM_VERSION
40 |
41 | // Dependency:
42 | #include "../glm.hpp"
43 |
44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
45 | # pragma message("GLM: GLM_GTX_extend extension included")
46 | #endif
47 |
48 | namespace glm
49 | {
50 | /// @addtogroup gtx_extend
51 | /// @{
52 |
53 | /// Extends of Length the Origin position using the (Source - Origin) direction.
54 | /// @see gtx_extend
55 | template
56 | genType extend(
57 | genType const & Origin,
58 | genType const & Source,
59 | typename genType::value_type const Length);
60 |
61 | /// @}
62 | }//namespace glm
63 |
64 | #include "extend.inl"
65 |
66 | #endif//GLM_GTX_extend
67 |
--------------------------------------------------------------------------------
/external/glm/gtx/extend.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2006-01-07
5 | // Updated : 2008-10-05
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/extend.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | genType extend
14 | (
15 | genType const & Origin,
16 | genType const & Source,
17 | genType const & Distance
18 | )
19 | {
20 | return Origin + (Source - Origin) * Distance;
21 | }
22 |
23 | template
24 | detail::tvec2 extend
25 | (
26 | detail::tvec2 const & Origin,
27 | detail::tvec2 const & Source,
28 | valType const & Distance
29 | )
30 | {
31 | return Origin + (Source - Origin) * Distance;
32 | }
33 |
34 | template
35 | detail::tvec3 extend
36 | (
37 | detail::tvec3 const & Origin,
38 | detail::tvec3 const & Source,
39 | valType const & Distance
40 | )
41 | {
42 | return Origin + (Source - Origin) * Distance;
43 | }
44 |
45 | template
46 | detail::tvec4 extend
47 | (
48 | detail::tvec4 const & Origin,
49 | detail::tvec4 const & Source,
50 | valType const & Distance
51 | )
52 | {
53 | return Origin + (Source - Origin) * Distance;
54 | }
55 | }//namespace glm
56 |
--------------------------------------------------------------------------------
/external/glm/gtx/gradient_paint.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2009-03-06
5 | // Updated : 2009-03-09
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/gradient_paint.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | valType radialGradient
14 | (
15 | detail::tvec2 const & Center,
16 | valType const & Radius,
17 | detail::tvec2 const & Focal,
18 | detail::tvec2 const & Position
19 | )
20 | {
21 | detail::tvec2 F = Focal - Center;
22 | detail::tvec2 D = Position - Focal;
23 | valType Radius2 = pow2(Radius);
24 | valType Fx2 = pow2(F.x);
25 | valType Fy2 = pow2(F.y);
26 |
27 | valType Numerator = (D.x * F.x + D.y * F.y) + sqrt(Radius2 * (pow2(D.x) + pow2(D.y)) - pow2(D.x * F.y - D.y * F.x));
28 | valType Denominator = Radius2 - (Fx2 + Fy2);
29 | return Numerator / Denominator;
30 | }
31 |
32 | template
33 | valType linearGradient
34 | (
35 | detail::tvec2 const & Point0,
36 | detail::tvec2 const & Point1,
37 | detail::tvec2 const & Position
38 | )
39 | {
40 | detail::tvec2 Dist = Point1 - Point0;
41 | return (Dist.x * (Position.x - Point0.x) + Dist.y * (Position.y - Point0.y)) / glm::dot(Dist, Dist);
42 | }
43 | }//namespace glm
44 |
--------------------------------------------------------------------------------
/external/glm/gtx/handed_coordinate_space.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2009-02-19
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/handed_coordinate_space.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER bool rightHanded
14 | (
15 | detail::tvec3 const & tangent,
16 | detail::tvec3 const & binormal,
17 | detail::tvec3 const & normal
18 | )
19 | {
20 | return dot(cross(normal, tangent), binormal) > T(0);
21 | }
22 |
23 | template
24 | GLM_FUNC_QUALIFIER bool leftHanded
25 | (
26 | detail::tvec3 const & tangent,
27 | detail::tvec3 const & binormal,
28 | detail::tvec3 const & normal
29 | )
30 | {
31 | return dot(cross(normal, tangent), binormal) < T(0);
32 | }
33 | }//namespace glm
34 |
--------------------------------------------------------------------------------
/external/glm/gtx/int_10_10_10_2.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_int_10_10_10_2
24 | /// @file glm/gtx/int_10_10_10_2.hpp
25 | /// @date 2010-07-07 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | /// @see gtx_raw_data (dependence)
30 | ///
31 | /// @defgroup gtx_int_10_10_10_2 GLM_GTX_int_10_10_10_2: Packed integer
32 | /// @ingroup gtx
33 | ///
34 | /// @brief Pack vector to 1010102 integers. Storage only.
35 | ///
36 | /// need to be included to use these functionalities.
37 | ///////////////////////////////////////////////////////////////////////////////////
38 |
39 | #ifndef GLM_GTX_int_10_10_10_2
40 | #define GLM_GTX_int_10_10_10_2 GLM_VERSION
41 |
42 | // Dependency:
43 | #include "../glm.hpp"
44 | #include "../gtx/raw_data.hpp"
45 |
46 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
47 | # pragma message("GLM: GLM_GTX_int_10_10_10_2 extension included")
48 | #endif
49 |
50 | namespace glm
51 | {
52 | /// @addtogroup gtx_int_10_10_10_2
53 | /// @{
54 |
55 | //! From GLM_GTX_int_10_10_10_2 extension.
56 | //! Cast a vec4 to an u_10_10_10_2.
57 | dword uint10_10_10_2_cast(glm::vec4 const & v);
58 |
59 | /// @}
60 | }//namespace glm
61 |
62 | #include "int_10_10_10_2.inl"
63 |
64 | #endif//GLM_GTX_int_10_10_10_2
65 |
--------------------------------------------------------------------------------
/external/glm/gtx/int_10_10_10_2.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2010-07-07
5 | // Updated : 2010-07-07
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/int_10_10_10_2.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | GLM_FUNC_QUALIFIER dword uint10_10_10_2_cast
13 | (
14 | glm::vec4 const & v
15 | )
16 | {
17 | return dword(uint(v.x * 2047.f) << 0 | uint(v.y * 2047.f) << 10 | uint(v.z * 2047.f) << 20 | uint(v.w * 3.f) << 30);
18 | }
19 | }//namespace glm
20 |
--------------------------------------------------------------------------------
/external/glm/gtx/log_base.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_log_base
24 | /// @file glm/gtx/log_base.hpp
25 | /// @date 2008-10-24 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | ///
30 | /// @defgroup gtx_log_base GLM_GTX_log_base: Log with base
31 | /// @ingroup gtx
32 | ///
33 | /// @brief Logarithm for any base. base can be a vector or a scalar.
34 | ///
35 | /// need to be included to use these functionalities.
36 | ///////////////////////////////////////////////////////////////////////////////////
37 |
38 | #ifndef GLM_GTX_log_base
39 | #define GLM_GTX_log_base GLM_VERSION
40 |
41 | // Dependency:
42 | #include "../glm.hpp"
43 |
44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
45 | # pragma message("GLM: GLM_GTX_log_base extension included")
46 | #endif
47 |
48 | namespace glm
49 | {
50 | /// @addtogroup gtx_log_base
51 | /// @{
52 |
53 | //! Logarithm for any base.
54 | //! From GLM_GTX_log_base.
55 | template
56 | genType log(
57 | genType const & x,
58 | genType const & base);
59 |
60 | /// @}
61 | }//namespace glm
62 |
63 | #include "log_base.inl"
64 |
65 | #endif//GLM_GTX_log_base
66 |
--------------------------------------------------------------------------------
/external/glm/gtx/log_base.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2008-10-24
5 | // Updated : 2008-10-24
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/log_base.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | #include "../core/_vectorize.hpp"
11 |
12 | namespace glm
13 | {
14 | template
15 | GLM_FUNC_QUALIFIER genType log(
16 | genType const & x,
17 | genType const & base)
18 | {
19 | assert(x != genType(0));
20 |
21 | return glm::log(x) / glm::log(base);
22 | }
23 |
24 | VECTORIZE_VEC_SCA(log)
25 | VECTORIZE_VEC_VEC(log)
26 | }//namespace glm
27 |
--------------------------------------------------------------------------------
/external/glm/gtx/matrix_cross_product.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2005-12-21
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/matrix_cross_product.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tmat3x3 matrixCross3
14 | (
15 | detail::tvec3 const & x
16 | )
17 | {
18 | detail::tmat3x3 Result(T(0));
19 | Result[0][1] = x.z;
20 | Result[1][0] = -x.z;
21 | Result[0][2] = -x.y;
22 | Result[2][0] = x.y;
23 | Result[1][2] = x.x;
24 | Result[2][1] = -x.x;
25 | return Result;
26 | }
27 |
28 | template
29 | GLM_FUNC_QUALIFIER detail::tmat4x4 matrixCross4
30 | (
31 | detail::tvec3 const & x
32 | )
33 | {
34 | detail::tmat4x4 Result(T(0));
35 | Result[0][1] = x.z;
36 | Result[1][0] = -x.z;
37 | Result[0][2] = -x.y;
38 | Result[2][0] = x.y;
39 | Result[1][2] = x.x;
40 | Result[2][1] = -x.x;
41 | return Result;
42 | }
43 |
44 | }//namespace glm
45 |
--------------------------------------------------------------------------------
/external/glm/gtx/mixed_product.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_mixed_product
24 | /// @file glm/gtx/mixed_product.hpp
25 | /// @date 2007-04-03 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | ///
30 | /// @defgroup gtx_mixed_product GLM_GTX_mixed_producte: Mixed product
31 | /// @ingroup gtx
32 | ///
33 | /// @brief Mixed product of 3 vectors.
34 | ///
35 | /// need to be included to use these functionalities.
36 | ///////////////////////////////////////////////////////////////////////////////////
37 |
38 | #ifndef GLM_GTX_mixed_product
39 | #define GLM_GTX_mixed_product GLM_VERSION
40 |
41 | // Dependency:
42 | #include "../glm.hpp"
43 |
44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
45 | # pragma message("GLM: GLM_GTX_mixed_product extension included")
46 | #endif
47 |
48 | namespace glm
49 | {
50 | /// @addtogroup gtx_mixed_product
51 | /// @{
52 |
53 | /// @brief Mixed product of 3 vectors (from GLM_GTX_mixed_product extension)
54 | template
55 | valType mixedProduct(
56 | detail::tvec3 const & v1,
57 | detail::tvec3 const & v2,
58 | detail::tvec3 const & v3);
59 |
60 | /// @}
61 | }// namespace glm
62 |
63 | #include "mixed_product.inl"
64 |
65 | #endif//GLM_GTX_mixed_product
66 |
--------------------------------------------------------------------------------
/external/glm/gtx/mixed_product.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2007-04-03
5 | // Updated : 2008-09-17
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/mixed_product.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER valType mixedProduct
14 | (
15 | detail::tvec3 const & v1,
16 | detail::tvec3 const & v2,
17 | detail::tvec3 const & v3
18 | )
19 | {
20 | return dot(cross(v1, v2), v3);
21 | }
22 | }//namespace glm
23 |
--------------------------------------------------------------------------------
/external/glm/gtx/noise.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Based on the work of Stefan Gustavson and Ashima Arts on "webgl-noise":
5 | // https://github.com/ashima/webgl-noise
6 | // Following Stefan Gustavson's paper "Simplex noise demystified":
7 | // http://www.itn.liu.se/~stegu/simplexnoise/simplexnoise.pdf
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 | // Created : 2011-04-21
10 | // Updated : 2011-04-21
11 | // Licence : This source is under MIT License
12 | // File : glm/gtx/noise.inl
13 | ///////////////////////////////////////////////////////////////////////////////////////////////////
14 | // Dependency:
15 | // - GLM core
16 | ///////////////////////////////////////////////////////////////////////////////////////////////////
17 |
18 | namespace glm{
19 |
20 | }//namespace glm
21 |
--------------------------------------------------------------------------------
/external/glm/gtx/normal.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_normal
24 | /// @file glm/gtx/normal.hpp
25 | /// @date 2005-12-21 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | /// @see gtx_extented_min_max (dependence)
30 | ///
31 | /// @defgroup gtx_normal GLM_GTX_normal: Compute normals
32 | /// @ingroup gtx
33 | ///
34 | /// @brief Compute the normal of a triangle.
35 | ///
36 | /// need to be included to use these functionalities.
37 | ///////////////////////////////////////////////////////////////////////////////////
38 |
39 | #ifndef GLM_GTX_normal
40 | #define GLM_GTX_normal GLM_VERSION
41 |
42 | // Dependency:
43 | #include "../glm.hpp"
44 |
45 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
46 | # pragma message("GLM: GLM_GTX_normal extension included")
47 | #endif
48 |
49 | namespace glm
50 | {
51 | /// @addtogroup gtx_normal
52 | /// @{
53 |
54 | //! Computes triangle normal from triangle points.
55 | //! From GLM_GTX_normal extension.
56 | template
57 | detail::tvec3 triangleNormal(
58 | detail::tvec3 const & p1,
59 | detail::tvec3 const & p2,
60 | detail::tvec3 const & p3);
61 |
62 | /// @}
63 | }//namespace glm
64 |
65 | #include "normal.inl"
66 |
67 | #endif//GLM_GTX_normal
68 |
--------------------------------------------------------------------------------
/external/glm/gtx/normal.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2011-06-07
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/normal.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tvec3 triangleNormal
14 | (
15 | detail::tvec3 const & p1,
16 | detail::tvec3 const & p2,
17 | detail::tvec3 const & p3
18 | )
19 | {
20 | return normalize(cross(p1 - p2, p1 - p3));
21 | }
22 | }//namespace glm
23 |
--------------------------------------------------------------------------------
/external/glm/gtx/number_precision.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2007-05-10
5 | // Updated : 2007-05-10
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/number_precision.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/external/glm/gtx/ocl_type.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/gtx/ocl_type.inl
--------------------------------------------------------------------------------
/external/glm/gtx/optimum_pow.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2005-12-27
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/optimum_pow.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER genType pow2(const genType& x)
14 | {
15 | return x * x;
16 | }
17 |
18 | template
19 | GLM_FUNC_QUALIFIER genType pow3(const genType& x)
20 | {
21 | return x * x * x;
22 | }
23 |
24 | template
25 | GLM_FUNC_QUALIFIER genType pow4(const genType& x)
26 | {
27 | return x * x * x * x;
28 | }
29 |
30 | GLM_FUNC_QUALIFIER bool powOfTwo(int x)
31 | {
32 | return !(x & (x - 1));
33 | }
34 |
35 | GLM_FUNC_QUALIFIER detail::tvec2 powOfTwo(const detail::tvec2& x)
36 | {
37 | return detail::tvec2(
38 | powOfTwo(x.x),
39 | powOfTwo(x.y));
40 | }
41 |
42 | GLM_FUNC_QUALIFIER detail::tvec3 powOfTwo(const detail::tvec3& x)
43 | {
44 | return detail::tvec3(
45 | powOfTwo(x.x),
46 | powOfTwo(x.y),
47 | powOfTwo(x.z));
48 | }
49 |
50 | GLM_FUNC_QUALIFIER detail::tvec4 powOfTwo(const detail::tvec4& x)
51 | {
52 | return detail::tvec4(
53 | powOfTwo(x.x),
54 | powOfTwo(x.y),
55 | powOfTwo(x.z),
56 | powOfTwo(x.w));
57 | }
58 | }//namespace glm
59 |
--------------------------------------------------------------------------------
/external/glm/gtx/orthonormalize.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2005-12-21
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/orthonormalize.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tmat3x3 orthonormalize
14 | (
15 | const detail::tmat3x3& m
16 | )
17 | {
18 | detail::tmat3x3 r = m;
19 |
20 | r[0] = normalize(r[0]);
21 |
22 | float d0 = dot(r[0], r[1]);
23 | r[1] -= r[0] * d0;
24 | r[1] = normalize(r[1]);
25 |
26 | float d1 = dot(r[1], r[2]);
27 | d0 = dot(r[0], r[2]);
28 | r[2] -= r[0] * d0 + r[1] * d1;
29 | r[2] = normalize(r[2]);
30 |
31 | return r;
32 | }
33 |
34 | template
35 | GLM_FUNC_QUALIFIER detail::tvec3 orthonormalize
36 | (
37 | const detail::tvec3& x,
38 | const detail::tvec3& y
39 | )
40 | {
41 | return normalize(x - y * dot(y, x));
42 | }
43 | }//namespace glm
44 |
--------------------------------------------------------------------------------
/external/glm/gtx/perpendicular.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_perpendicular
24 | /// @file glm/gtx/perpendicular.hpp
25 | /// @date 2005-12-21 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | /// @see gtx_projection (dependence)
30 | ///
31 | /// @defgroup gtx_perpendicular GLM_GTX_perpendicular: Perpendicular
32 | /// @ingroup gtx
33 | ///
34 | /// @brief Perpendicular of a vector from other one
35 | ///
36 | /// need to be included to use these functionalities.
37 | ///////////////////////////////////////////////////////////////////////////////////
38 |
39 | #ifndef GLM_GTX_perpendicular
40 | #define GLM_GTX_perpendicular GLM_VERSION
41 |
42 | // Dependency:
43 | #include "../glm.hpp"
44 | #include "../gtx/projection.hpp"
45 |
46 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
47 | # pragma message("GLM: GLM_GTX_perpendicular extension included")
48 | #endif
49 |
50 | namespace glm
51 | {
52 | /// @addtogroup gtx_perpendicular
53 | /// @{
54 |
55 | //! Projects x a perpendicular axis of Normal.
56 | //! From GLM_GTX_perpendicular extension.
57 | template
58 | vecType perp(
59 | vecType const & x,
60 | vecType const & Normal);
61 |
62 | /// @}
63 | }//namespace glm
64 |
65 | #include "perpendicular.inl"
66 |
67 | #endif//GLM_GTX_perpendicular
68 |
--------------------------------------------------------------------------------
/external/glm/gtx/perpendicular.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2009-03-06
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/perpendicular.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER vecType perp
14 | (
15 | vecType const & x,
16 | vecType const & Normal
17 | )
18 | {
19 | return x - proj(x, Normal);
20 | }
21 | }//namespace glm
22 |
--------------------------------------------------------------------------------
/external/glm/gtx/polar_coordinates.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2007-03-06
5 | // Updated : 2009-05-01
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/polar_coordinates.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tvec3 polar
14 | (
15 | detail::tvec3 const & euclidean
16 | )
17 | {
18 | T length = length(euclidean);
19 | detail::tvec3 tmp = euclidean / length;
20 | T xz_dist = sqrt(tmp.x * tmp.x + tmp.z * tmp.z);
21 |
22 | return detail::tvec3(
23 | degrees(atan(xz_dist, tmp.y)), // latitude
24 | degrees(atan(tmp.x, tmp.z)), // longitude
25 | xz_dist); // xz distance
26 | }
27 |
28 | template
29 | GLM_FUNC_QUALIFIER detail::tvec3 euclidean
30 | (
31 | detail::tvec3 const & polar
32 | )
33 | {
34 | T latitude = radians(polar.x);
35 | T longitude = radians(polar.y);
36 | return detail::tvec3(
37 | cos(latitude) * sin(longitude),
38 | sin(latitude),
39 | cos(latitude) * cos(longitude));
40 | }
41 |
42 | }//namespace glm
43 |
--------------------------------------------------------------------------------
/external/glm/gtx/projection.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///
23 | /// @ref gtx_projection
24 | /// @file glm/gtx/projection.hpp
25 | /// @date 2005-12-21 / 2011-06-07
26 | /// @author Christophe Riccio
27 | ///
28 | /// @see core (dependence)
29 | ///
30 | /// @defgroup gtx_projection GLM_GTX_projection: Projection
31 | /// @ingroup gtx
32 | ///
33 | /// @brief Projection of a vector to other one
34 | ///
35 | /// need to be included to use these functionalities.
36 | ///////////////////////////////////////////////////////////////////////////////////
37 |
38 | #ifndef GLM_GTX_projection
39 | #define GLM_GTX_projection GLM_VERSION
40 |
41 | // Dependency:
42 | #include "../glm.hpp"
43 |
44 | #if(defined(GLM_MESSAGES) && !defined(glm_ext))
45 | # pragma message("GLM: GLM_GTX_projection extension included")
46 | #endif
47 |
48 | namespace glm
49 | {
50 | /// @addtogroup gtx_projection
51 | /// @{
52 |
53 | //! Projects x on Normal.
54 | //! From GLM_GTX_projection extension.
55 | template
56 | vecType proj(
57 | vecType const & x,
58 | vecType const & Normal);
59 |
60 | /// @}
61 | }//namespace glm
62 |
63 | #include "projection.inl"
64 |
65 | #endif//GLM_GTX_projection
66 |
--------------------------------------------------------------------------------
/external/glm/gtx/projection.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2009-03-06
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/projection.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER vecType proj
14 | (
15 | vecType const & x,
16 | vecType const & Normal
17 | )
18 | {
19 | return glm::dot(x, Normal) / glm::dot(Normal, Normal) * Normal;
20 | }
21 | }//namespace glm
22 |
--------------------------------------------------------------------------------
/external/glm/gtx/raw_data.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2008-11-19
5 | // Updated : 2008-11-19
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/raw_data.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 | // Dependency:
10 | // - GLM core
11 | ///////////////////////////////////////////////////////////////////////////////////////////////////
12 |
--------------------------------------------------------------------------------
/external/glm/gtx/simd_vec4.hpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/gtx/simd_vec4.hpp
--------------------------------------------------------------------------------
/external/glm/gtx/spline.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2007-01-25
5 | // Updated : 2009-02-19
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/spline.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm{
11 |
12 | template
13 | GLM_FUNC_QUALIFIER genType catmullRom
14 | (
15 | genType const & v1,
16 | genType const & v2,
17 | genType const & v3,
18 | genType const & v4,
19 | typename genType::value_type const & s
20 | )
21 | {
22 | typename genType::value_type s1 = s;
23 | typename genType::value_type s2 = pow2(s);
24 | typename genType::value_type s3 = pow3(s);
25 |
26 | typename genType::value_type f1 = -s3 + typename genType::value_type(2) * s2 - s;
27 | typename genType::value_type f2 = typename genType::value_type(3) * s3 - typename genType::value_type(5) * s2 + typename genType::value_type(2);
28 | typename genType::value_type f3 = typename genType::value_type(-3) * s3 + typename genType::value_type(4) * s2 + s;
29 | typename genType::value_type f4 = s3 - s2;
30 |
31 | return (f1 * v1 + f2 * v2 + f3 * v3 + f4 * v4) / typename genType::value_type(2);
32 |
33 | }
34 |
35 | template
36 | GLM_FUNC_QUALIFIER genType hermite
37 | (
38 | genType const & v1,
39 | genType const & t1,
40 | genType const & v2,
41 | genType const & t2,
42 | typename genType::value_type const & s
43 | )
44 | {
45 | typename genType::value_type s1 = s;
46 | typename genType::value_type s2 = pow2(s);
47 | typename genType::value_type s3 = pow3(s);
48 |
49 | typename genType::value_type f1 = typename genType::value_type(2) * s3 - typename genType::value_type(3) * s2 + typename genType::value_type(1);
50 | typename genType::value_type f2 = typename genType::value_type(-2) * s3 + typename genType::value_type(3) * s2;
51 | typename genType::value_type f3 = s3 - typename genType::value_type(2) * s2 + s;
52 | typename genType::value_type f4 = s3 - s2;
53 |
54 | return f1 * v1 + f2 * v2 + f3 * t1 + f4 * t2;
55 | }
56 |
57 | template
58 | GLM_FUNC_QUALIFIER genType cubic
59 | (
60 | genType const & v1,
61 | genType const & v2,
62 | genType const & v3,
63 | genType const & v4,
64 | typename genType::value_type const & s
65 | )
66 | {
67 | return ((v1 * s + v2) * s + v3) * s + v4;
68 | }
69 |
70 | }//namespace glm
71 |
--------------------------------------------------------------------------------
/external/glm/gtx/std_based_type.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2008-06-08
5 | // Updated : 2008-06-08
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/std_based_type.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/external/glm/gtx/transform.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-21
5 | // Updated : 2009-04-29
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/transform.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate(
14 | T x, T y, T z)
15 | {
16 | return translate(
17 | detail::tmat4x4(1.0f),
18 | detail::tvec3(x, y , z));
19 | }
20 |
21 | template
22 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate(
23 | detail::tmat4x4 const & m,
24 | T x, T y, T z)
25 | {
26 | return translate(
27 | m, detail::tvec3(x, y , z));
28 | }
29 |
30 | template
31 | GLM_FUNC_QUALIFIER detail::tmat4x4 translate(
32 | detail::tvec3 const & v)
33 | {
34 | return translate(
35 | detail::tmat4x4(1.0f), v);
36 | }
37 |
38 | template
39 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate(
40 | T angle,
41 | T x, T y, T z)
42 | {
43 | return rotate(
44 | detail::tmat4x4(1), angle, detail::tvec3(x, y, z));
45 | }
46 |
47 | template
48 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate(
49 | T angle,
50 | detail::tvec3 const & v)
51 | {
52 | return rotate(
53 | detail::tmat4x4(1), angle, v);
54 | }
55 |
56 | template
57 | GLM_FUNC_QUALIFIER detail::tmat4x4 rotate(
58 | detail::tmat4x4 const & m,
59 | T angle,
60 | T x, T y, T z)
61 | {
62 | return rotate(
63 | m, angle, detail::tvec3(x, y, z));
64 | }
65 |
66 | template
67 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale(T x, T y, T z)
68 | {
69 | return scale(
70 | detail::tmat4x4(1), detail::tvec3(x, y, z));
71 | }
72 |
73 | template
74 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale(
75 | detail::tmat4x4 const & m,
76 | T x, T y, T z)
77 | {
78 | return scale(
79 | m, detail::tvec3(x, y, z));
80 | }
81 |
82 | template
83 | GLM_FUNC_QUALIFIER detail::tmat4x4 scale(
84 | detail::tvec3 const & v)
85 | {
86 | return scale(
87 | detail::tmat4x4(1.0f), v);
88 | }
89 |
90 | }//namespace glm
91 |
--------------------------------------------------------------------------------
/external/glm/gtx/unsigned_int.hpp:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////
2 | /// OpenGL Mathematics (glm.g-truc.net)
3 | ///
4 | /// Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
5 | /// Permission is hereby granted, free of charge, to any person obtaining a copy
6 | /// of this software and associated documentation files (the "Software"), to deal
7 | /// in the Software without restriction, including without limitation the rights
8 | /// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | /// copies of the Software, and to permit persons to whom the Software is
10 | /// furnished to do so, subject to the following conditions:
11 | ///
12 | /// The above copyright notice and this permission notice shall be included in
13 | /// all copies or substantial portions of the Software.
14 | ///
15 | /// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | /// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | /// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | /// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | /// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | /// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | /// THE SOFTWARE.
22 | ///////////////////////////////////////////////////////////////////////////////////
23 |
24 | #if(defined(GLM_MESSAGES))
25 | # pragma message("GLM: GLM_GTX_unsigned_int extension is deprecated, include GLM_GTX_integer instead")
26 | #endif
27 |
--------------------------------------------------------------------------------
/external/glm/gtx/unsigned_int.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-24
5 | // Updated : 2008-10-07
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/unsigned_int.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 |
13 | }//namespace glm
14 |
--------------------------------------------------------------------------------
/external/glm/gtx/vec1.inl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ginkgo/micropolis/dcfa88b77d9c96533e94ae598a826082a3c5ee0a/external/glm/gtx/vec1.inl
--------------------------------------------------------------------------------
/external/glm/gtx/vector_access.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2006-01-16
5 | // Updated : 2008-10-07
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/vector_access.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER void set
14 | (
15 | detail::tvec2& v,
16 | valType const & x,
17 | valType const & y
18 | )
19 | {
20 | v.x = x;
21 | v.y = y;
22 | }
23 |
24 | template
25 | GLM_FUNC_QUALIFIER void set
26 | (
27 | detail::tvec3& v,
28 | valType const & x,
29 | valType const & y,
30 | valType const & z
31 | )
32 | {
33 | v.x = x;
34 | v.y = y;
35 | v.z = z;
36 | }
37 |
38 | template
39 | GLM_FUNC_QUALIFIER void set
40 | (
41 | detail::tvec4& v,
42 | valType const & x,
43 | valType const & y,
44 | valType const & z,
45 | valType const & w
46 | )
47 | {
48 | v.x = x;
49 | v.y = y;
50 | v.z = z;
51 | v.w = w;
52 | }
53 | }//namespace glm
54 |
--------------------------------------------------------------------------------
/external/glm/gtx/vector_angle.inl:
--------------------------------------------------------------------------------
1 | ///////////////////////////////////////////////////////////////////////////////////////////////////
2 | // OpenGL Mathematics Copyright (c) 2005 - 2012 G-Truc Creation (www.g-truc.net)
3 | ///////////////////////////////////////////////////////////////////////////////////////////////////
4 | // Created : 2005-12-30
5 | // Updated : 2008-09-29
6 | // Licence : This source is under MIT License
7 | // File : glm/gtx/vector_angle.inl
8 | ///////////////////////////////////////////////////////////////////////////////////////////////////
9 |
10 | namespace glm
11 | {
12 | template
13 | GLM_FUNC_QUALIFIER typename genType::value_type angle
14 | (
15 | genType const & x,
16 | genType const & y
17 | )
18 | {
19 | return degrees(acos(dot(x, y)));
20 | }
21 |
22 | //! \todo epsilon is hard coded to 0.01
23 | template
24 | GLM_FUNC_QUALIFIER valType orientedAngle
25 | (
26 | detail::tvec2 const & x,
27 | detail::tvec2 const & y
28 | )
29 | {
30 | valType Angle = glm::degrees(acos(dot(x, y)));
31 | detail::tvec2 TransformedVector = glm::rotate(x, Angle);
32 | if(all(equalEpsilon(y, TransformedVector, valType(0.01))))
33 | return Angle;
34 | else
35 | return -Angle;
36 | }
37 |
38 | template
39 | GLM_FUNC_QUALIFIER valType orientedAngle
40 | (
41 | detail::tvec3 const & x,
42 | detail::tvec3 const & y,
43 | detail::tvec3 const & ref
44 | )
45 | {
46 | valType Angle = glm::degrees(glm::acos(glm::dot(x, y)));
47 |
48 | if(glm::dot(ref, glm::cross(x, y)) < valType(0))
49 | return -Angle;
50 | else
51 | return Angle;
52 | }
53 | }//namespace glm
54 |
--------------------------------------------------------------------------------
/gl.options:
--------------------------------------------------------------------------------
1 | // Number of anti-aliasing samples. (0 means no AA)
2 | fsaa_samples = 0
3 |
4 | // Search directory for GLSL shader files.
5 | shader_dir = shaders
6 |
7 | // Maximum anisotropy for texture filtering.
8 | max_anisotropy = 1
9 |
10 |
11 |
12 | #hash:8399595359367650450
13 |
--------------------------------------------------------------------------------
/kernels/framebuffer.cl:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | __kernel void clear (__global float4* framebuffer, float4 color)
21 | {
22 | int pos = get_global_id(0);
23 | framebuffer[pos] = color;
24 | }
25 |
--------------------------------------------------------------------------------
/kernels/histogram_pyramid.cl:
--------------------------------------------------------------------------------
1 |
2 | kernel void reduce (int count, int offset1, int offset2, global int* buffer)
3 | {
4 | int gid = get_global_id(0);
5 |
6 | if (gid*2+0 < count) {
7 | buffer[gid + offset2] = buffer[gid*2 + 0 + offset1];
8 | }
9 |
10 | if (gid*2+1 < count) {
11 | buffer[gid + offset2] += buffer[gid*2 + 1 + offset1];
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/kernels/prefix_sum.cl:
--------------------------------------------------------------------------------
1 | #include "utility.h"
2 |
3 | // Compile time constants
4 | // N - size_t
5 |
6 | kernel void reduce(int batch_size,
7 | global int* ibuf,
8 | global int* obuf,
9 | global int* rbuf)
10 | {
11 | local int tbuf[N];
12 |
13 | int lid = get_local_id(0);
14 | int wid = get_group_id(0);
15 | int gid1 = wid*N + lid;
16 | int gid2 = wid*N + (N/2) + lid;
17 |
18 | tbuf[lid] = 0;
19 | tbuf[lid+(N/2)] = 0;
20 |
21 | // read input data into shared buffer
22 | if (gid1 < batch_size) tbuf[lid] = ibuf[gid1];
23 | if (gid2 < batch_size) tbuf[lid+(N/2)] = ibuf[gid2];
24 |
25 | // up-sweep
26 | for (int i = 1; i <= (N/2); i <<= 1) {
27 | barrier(CLK_LOCAL_MEM_FENCE);
28 |
29 | if (lid < (N/2)/i) {
30 | int ai = (2*lid+1)*i-1;
31 | int bi = (2*lid+2)*i-1;
32 | tbuf[bi] += tbuf[ai];
33 | }
34 | }
35 |
36 | // down-sweep
37 | for (int i = (N/2); i >= 2; i >>= 1) {
38 | barrier(CLK_LOCAL_MEM_FENCE);
39 | \
40 | if (lid < N/i-1) {
41 | int ai = i*(lid+1)-1;
42 | int bi = ai + i/2;
43 |
44 | tbuf[bi] += tbuf[ai];
45 | }
46 | }
47 |
48 | // write results back
49 | barrier(CLK_LOCAL_MEM_FENCE);
50 | if (gid1 < batch_size) obuf[gid1] = tbuf[lid];
51 | if (gid2 < batch_size) obuf[gid2] = tbuf[lid+(N/2)];
52 |
53 | rbuf[wid] = tbuf[N-1];
54 | }
55 |
56 |
57 | kernel void accumulate(int batch_size,
58 | global const int* reduced,
59 | global int* accumulated)
60 | {
61 | int gid = get_global_id(0) + N;
62 | int rid = get_global_id(0) / N;
63 |
64 | if (gid < batch_size) {
65 | accumulated[gid] += reduced[rid];
66 | }
67 | }
68 |
69 |
70 |
--------------------------------------------------------------------------------
/kernels/test.cl:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | __kernel void test (write_only image2d_t framebuffer, float t)
21 | {
22 | int2 coord = (int2) (get_global_id(0), get_global_id(1));
23 | float2 offset = (float2)(get_global_size(0), get_global_size(1)) * 0.5;
24 |
25 | float d = length((float2)(coord.x,coord.y} - offset);
26 | float r = sin(t * -0.7 + d * 0.13) * 0.5 + 0.5;
27 | float g = sin(t * -1.3 + d * 0.11) * 0.5 + 0.5;
28 | float b = sin(t * -1.9 + d * 0.10) * 0.5 + 0.5;
29 |
30 | write_imagef(framebuffer, coord, (float4)(r,g,b,1));
31 | }
32 |
--------------------------------------------------------------------------------
/micropolis:
--------------------------------------------------------------------------------
1 | micropolis_release
--------------------------------------------------------------------------------
/micropolis.options:
--------------------------------------------------------------------------------
1 | // Local offset of the camera along the X axis.
2 | camera_x_offset = 0
3 |
4 | // Local offset of the camera along the Y axis.
5 | camera_y_offset = 0
6 |
7 | // Local offset of the camera along the Z axis.
8 | camera_z_offset = 0
9 |
10 | // Enables dump mode.
11 | // The renderer will dump a trace, statistics and the currenct config after a certain number of frames and exit.
12 | dump_mode = false
13 |
14 | // Disable window.
15 | // Useful for benchmark scripts.
16 | windowless = false
17 |
18 | // Controls after which frame the application dumps a trace and exits in trace dump mode.
19 | dump_after = 10
20 |
21 | // Number of frame dumps to perform per invocation.
22 | dump_count = 1
23 |
24 | // 0...(Almost) no output
25 | // 1...Regular performance information and warnings posted
26 | // 2...Lots of information posted, can be detrimental to render performance
27 | verbosity_level = 1
28 |
29 | // Target file for writing program stats to.
30 | statistics_file = statistics.dump
31 |
32 |
33 |
34 | #hash:3905350090599934784
35 |
--------------------------------------------------------------------------------
/reyes.options:
--------------------------------------------------------------------------------
1 | // Size of the window in pixels.
2 | window_size = 1600 1200
3 |
4 | // Application window title.
5 | window_title = MICROPOLIS
6 |
7 | // Patch data input file.
8 | input_file = testscene/columns.mscene
9 |
10 | // Clear color for framebuffer.
11 | clear_color = 0.1 0.1 0.7 0
12 |
13 | // Size used for bounding and dicing.
14 | reyes_patch_size = 8
15 |
16 | // Maximum size for patches before they can be sent to the dicing stage.
17 | bound_n_split_limit = 8
18 |
19 | // The number of pixels a surface can be outside of the viewport without being culled.
20 | cull_ribbon = 32
21 |
22 | // Defines which renderer implementation to use.
23 | // Either OPENCL or GLTESS.
24 | renderer_type = OPENCL
25 |
26 | // Defines how micropolygons are shaded.
27 | // Either SMOOTH or FLAT. Only affects GLTESS renderer atm.
28 | shading_mode = FLAT
29 |
30 | // Controls backface-culling.
31 | backface_culling = true
32 |
33 | // Method used to implement Bound&Split. Either CPU, BOUNDED, LOCAL, or BREADTH
34 | bound_n_split_method = BOUNDED
35 |
36 | // Number of samples per side for doing calculating patch range bound.
37 | bound_sample_rate = 3
38 |
39 | // Maximum number of times a surface patch can be split.
40 | max_split_depth = 23
41 |
42 | // Number of patches that get cached and are submitted as a
43 | // single rendering pass together.
44 | reyes_patches_per_pass = 100000
45 |
46 | // Framebuffer tile size.
47 | framebuffer_tile_size = 8
48 |
49 | // Number of sub-one bits for fixed precision pixel coordinates.
50 | subpixel_bits = 6
51 |
52 | // Width of the work-group for the dicing kernel.
53 | dice_group_width = 8
54 |
55 | // Number of patch buffers used for transferring patch data to device.
56 | bns_pipeline_length = 8
57 |
58 | // Number of work groups for local bound n split operation.
59 | local_bns_work_groups = 128
60 |
61 | // If set to true, the patches are split but not diced and rasterized.
62 | dummy_render = false
63 |
64 | debug_work_group_balance = false
65 |
66 | // Small hack to showcase displacement.
67 | displacement = false
68 |
69 | // Assign different color to different passes.
70 | pass_color_mode = false
71 |
72 |
73 |
74 | #hash:359867968645853476
75 |
--------------------------------------------------------------------------------
/shaders/hwtess.frag:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | #version 150
21 |
22 | uniform vec4 color;
23 |
24 | in vec3 p_eye;
25 | in vec3 n_eye;
26 | in vec3 tex_coord;
27 |
28 | out vec4 frag_color;
29 |
30 | void main()
31 | {
32 | // vec3 n = normalize(cross(dFdx(p_eye), dFdy(p_eye)));
33 | // frag_color = color * max(0, 0.15 + 0.85 * dot(n, vec3(0,0,1)));
34 |
35 | frag_color = color * max(0, dot(n_eye, vec3(0,0,1)));
36 | }
37 |
--------------------------------------------------------------------------------
/shaders/hwtess.tess_ctrl:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout(vertices=4) out;
4 |
5 | uniform int dicing_rate;
6 |
7 | void main(void)
8 | {
9 | gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
10 |
11 | gl_TessLevelInner[0] = dicing_rate;
12 | gl_TessLevelInner[1] = dicing_rate;
13 | gl_TessLevelOuter[0] = dicing_rate;
14 | gl_TessLevelOuter[1] = dicing_rate;
15 | gl_TessLevelOuter[2] = dicing_rate;
16 | gl_TessLevelOuter[3] = dicing_rate;
17 | }
18 |
--------------------------------------------------------------------------------
/shaders/hwtess.tess_eval:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | @include
4 |
5 | layout(quads, equal_spacing, ccw) in;
6 |
7 | uniform mat4 mv;
8 | uniform mat4 mvp;
9 | uniform samplerBuffer patches;
10 |
11 | out vec3 p_eye;
12 | out vec3 n_eye;
13 | out vec3 tex_coord;
14 |
15 | vec3 eval_patch(vec2 t, int patch_id)
16 | {
17 | vec2 s = 1 - t;
18 |
19 | mat4 B = outerProduct(vec4(s.x*s.x*s.x, 3*s.x*s.x*t.x, 3*s.x*t.x*t.x, t.x*t.x*t.x),
20 | vec4(s.y*s.y*s.y, 3*s.y*s.y*t.y, 3*s.y*t.y*t.y, t.y*t.y*t.y));
21 |
22 | vec3 sum = vec3(0,0,0);
23 | for (int u = 0; u < 4; ++u) {
24 | for (int v = 0; v < 4; ++v) {
25 | sum += B[v][u] * texelFetch(patches, u + v * 4 + patch_id * 16).xyz;
26 | }
27 | }
28 |
29 | return sum;
30 | }
31 |
32 | void main()
33 | {
34 | vec2 t = mix(mix(gl_in[0].gl_Position.xy, gl_in[1].gl_Position.xy, gl_TessCoord.x),
35 | mix(gl_in[3].gl_Position.xy, gl_in[2].gl_Position.xy, gl_TessCoord.x), gl_TessCoord.y);
36 |
37 | int patch_id = int(gl_in[0].gl_Position.z);
38 |
39 | vec3 p = eval_patch(t, patch_id);
40 | vec3 px = eval_patch(t+vec2(0.001,0), patch_id);
41 | vec3 py = eval_patch(t+vec2(0,0.001), patch_id);
42 | vec3 n = normalize(cross(px-p,py-p));
43 |
44 | // float disp = snoise(p*0.5) + snoise(p*1.0) * 0.5 + snoise(p*2.0) * 0.25;
45 | // disp = snoise(vec3(disp * 8,0,0) * 0.25);
46 | // p += 0.04 * n * disp;
47 |
48 | tex_coord = vec3(t, patch_id);
49 | p_eye = vec3(mv * vec4(p,1));
50 | n_eye = vec3(mv * vec4(n,0));
51 |
52 | gl_Position = mvp * vec4(p,1);
53 | }
54 |
--------------------------------------------------------------------------------
/shaders/hwtess.vert:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | #version 430
21 |
22 | in vec4 vertex;
23 |
24 | void main()
25 | {
26 | gl_Position = vertex;
27 | }
28 |
--------------------------------------------------------------------------------
/shaders/local_clear_out_range_cnt.compute:
--------------------------------------------------------------------------------
1 |
2 | #version 430
3 |
4 | layout (local_size_x = 1) in;
5 |
6 | layout (std430) buffer out_range_cnt
7 | {
8 | uint out_range_count;
9 | };
10 |
11 |
12 | void main (void)
13 | {
14 | out_range_count = 0;
15 | }
16 |
--------------------------------------------------------------------------------
/shaders/local_init_count_buffers.compute:
--------------------------------------------------------------------------------
1 |
2 |
3 | #define WORK_GROUP_CNT 32
4 | #define WORK_GROUP_SIZE 64
5 |
6 | layout (local_size_x = WORK_GROUP_CNT) in;
7 |
8 | layout (std430) buffer in_range_cnt
9 | {
10 | int in_range_count[];
11 | };
12 |
13 | uniform uint patch_count;
14 |
15 | void main ()
16 | {
17 | uint lid = gl_GlobalInvocationID.x;
18 | uint ilid = WORK_GROUP_CNT - lid - 1;
19 |
20 | in_range_count[lid] = int((patch_count+ilid)/WORK_GROUP_CNT);
21 | }
22 |
--------------------------------------------------------------------------------
/shaders/local_init_range_buffers.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | @include
4 |
5 | #define WORK_GROUP_CNT 32
6 | #define WORK_GROUP_SIZE 64
7 |
8 | layout (local_size_x = WORK_GROUP_SIZE) in;
9 |
10 | layout (std430) buffer in_pids
11 | {
12 | uint pids[];
13 | };
14 |
15 | layout (std430) buffer in_mins
16 | {
17 | vec2 mins[];
18 | };
19 |
20 | layout (std430) buffer in_maxs
21 | {
22 | vec2 maxs[];
23 | };
24 |
25 | uniform uint patch_count;
26 | uniform uint buffer_stride;
27 |
28 | void main ()
29 | {
30 | uint items_per_work_group = round_up_div(patch_count, WORK_GROUP_CNT);
31 |
32 | uint gid = gl_GlobalInvocationID.x;
33 | uint wid = gid / items_per_work_group;
34 | uint lid = gid % items_per_work_group;
35 |
36 | if (gid < patch_count) {
37 | uint pos = lid + wid * buffer_stride;
38 | pids[pos] = gid;
39 | mins[pos] = vec2(0,0);
40 | maxs[pos] = vec2(1,1);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/shaders/local_prefixsum.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef LOCAL_PREFIXSUM_H
3 | #define LOCAL_PREFIXSUM_H
4 |
5 | shared uint prefix_pad[WORK_GROUP_SIZE];
6 |
7 | uint prefix_sum(uint v)
8 | {
9 | uint lid = gl_LocalInvocationID.x;
10 |
11 | prefix_pad[lid] = v;
12 |
13 | // up-sweep
14 | for (uint i = 1; i <= WORK_GROUP_SIZE/2; i <<= 1) {
15 | memoryBarrierShared();
16 |
17 | if (lid < (WORK_GROUP_SIZE/2)/i) {
18 | uint ai = (2*lid+1)*i-1;
19 | uint bi = (2*lid+2)*i-1;
20 | prefix_pad[bi] += prefix_pad[ai];
21 | }
22 | }
23 |
24 | // down-sweep
25 | for (uint i = WORK_GROUP_SIZE/2; i >= 2; i >>= 1) {
26 | memoryBarrierShared();
27 |
28 | if (lid < WORK_GROUP_SIZE/i-1) {
29 | uint ai = i*(lid+1)-1;
30 | uint bi = ai + i/2;
31 |
32 | prefix_pad[bi] += prefix_pad[ai];
33 | }
34 | }
35 |
36 | memoryBarrierShared();
37 | return prefix_pad[lid];
38 | }
39 |
40 |
41 | #endif
42 |
--------------------------------------------------------------------------------
/shaders/local_setup_indirection.compute:
--------------------------------------------------------------------------------
1 |
2 | #version 430
3 |
4 | layout (local_size_x = 1) in;
5 |
6 | layout (std430) buffer out_range_cnt
7 | {
8 | uint out_range_count;
9 | };
10 |
11 | layout (std430) buffer indirection_buffer
12 | {
13 | uint count;
14 | uint instanceCount;
15 | uint first;
16 | uint baseInstance;
17 | };
18 |
19 | uniform uint batch_size;
20 |
21 | void main (void)
22 | {
23 | count = min(batch_size, out_range_count) * 4;
24 | instanceCount = 1;
25 | first = 0;
26 | baseInstance = 0;
27 | }
28 |
--------------------------------------------------------------------------------
/shaders/multipass_bound.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 64) in;
4 |
5 | uniform uint batch_size;
6 | uniform uint batch_offset;
7 | uniform uint max_split_depth;
8 |
9 | @include
10 | @include
11 |
12 |
13 | // Patch range stack arrays
14 | layout (std430) buffer stack_min
15 | {
16 | vec2 smin[];
17 | };
18 |
19 | layout (std430) buffer stack_max
20 | {
21 | vec2 smax[];
22 | };
23 |
24 | // 8 MSB: stack depth
25 | // 24 LSB: patch id
26 | layout (std430) buffer stack_pid
27 | {
28 | uint spid[];
29 | };
30 |
31 | // Array of packed flags
32 | // first component is set to 1 if patch is split
33 | // second component is set to 1 if patch is drawn
34 | layout (std430) buffer flag_pad
35 | {
36 | uvec2 fpad[];
37 | };
38 |
39 | // Pads for placing split patches
40 | layout (std430) buffer split_pad_pid
41 | {
42 | uint sp_pid[];
43 | };
44 |
45 | layout (std430) buffer split_pad1_min
46 | {
47 | vec2 sp1_min[];
48 | };
49 |
50 | layout (std430) buffer split_pad1_max
51 | {
52 | vec2 sp1_max[];
53 | };
54 |
55 | layout (std430) buffer split_pad2_min
56 | {
57 | vec2 sp2_min[];
58 | };
59 |
60 | layout (std430) buffer split_pad2_max
61 | {
62 | vec2 sp2_max[];
63 | };
64 |
65 |
66 | void do_vsplit(uint bid, vec2 pmin, vec2 pmax, uint pid, uint depth)
67 | {
68 | float c = mix(pmin.y, pmax.y, 0.5);
69 |
70 | sp_pid[bid] = pid | (depth << 24);
71 |
72 | sp1_min[bid] = pmin;
73 | sp1_max[bid] = vec2(pmax.x, c);
74 |
75 | sp2_min[bid] = vec2(pmin.x, c);
76 | sp2_max[bid] = pmax;
77 | }
78 |
79 | void do_hsplit(uint bid, vec2 pmin, vec2 pmax, uint pid, uint depth)
80 | {
81 | float c = mix(pmin.x, pmax.x, 0.5);
82 |
83 | sp_pid[bid] = pid | (depth << 24);
84 |
85 | sp1_min[bid] = pmin;
86 | sp1_max[bid] = vec2(c, pmax.y);
87 |
88 | sp2_min[bid] = vec2(c, pmin.y);
89 | sp2_max[bid] = pmax;
90 | }
91 |
92 |
93 | void main (void)
94 | {
95 | uint bid = gl_GlobalInvocationID.x;
96 | uint sid = bid + batch_offset;
97 |
98 | if (bid >= batch_size) return;
99 |
100 | uint rpid = spid[sid] & 0xffffff;
101 | uint rdepth = spid[sid] >> 24;
102 | vec2 rmin = smin[sid];
103 | vec2 rmax = smax[sid];
104 |
105 | uint bound_flag = bound(rpid, rmin, rmax, rdepth);
106 |
107 | fpad[bid] = uvec2((bound_flag>>1)&1, (bound_flag>>0)&1);
108 |
109 | if ((bound_flag & 2) != 0) {
110 | if ((bound_flag & 4) != 0) {
111 | do_vsplit(bid, rmin, rmax, rpid, rdepth+1);
112 | } else {
113 | do_hsplit(bid, rmin, rmax, rpid, rdepth+1);
114 | }
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/shaders/multipass_copy_ranges.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 64) in;
4 |
5 | uniform int batch_size;
6 | uniform int batch_offset;
7 |
8 | layout (std430) buffer stack_min
9 | {
10 | vec2 smin[];
11 | };
12 |
13 | layout (std430) buffer stack_max
14 | {
15 | vec2 smax[];
16 | };
17 |
18 | layout (std430) buffer stack_pid
19 | {
20 | uint spid[];
21 | };
22 |
23 |
24 | layout (std430) buffer flag_pad
25 | {
26 | ivec2 fpad[];
27 | };
28 |
29 | layout (std430) buffer summed_flags
30 | {
31 | ivec2 fsum[];
32 | };
33 |
34 |
35 | // Pads for placing split patches
36 | layout (std430) buffer split_pad_pid
37 | {
38 | uint sp_pid[];
39 | };
40 |
41 | layout (std430) buffer split_pad1_min
42 | {
43 | vec2 sp1_min[];
44 | };
45 |
46 | layout (std430) buffer split_pad1_max
47 | {
48 | vec2 sp1_max[];
49 | };
50 |
51 | layout (std430) buffer split_pad2_min
52 | {
53 | vec2 sp2_min[];
54 | };
55 |
56 | layout (std430) buffer split_pad2_max
57 | {
58 | vec2 sp2_max[];
59 | };
60 |
61 |
62 | void main (void)
63 | {
64 | uint bid = gl_GlobalInvocationID.x;
65 | uint xid = batch_offset + (fsum[bid].x - 1) * 2;
66 |
67 | if (bid < batch_size && fpad[bid].x == 1) {
68 |
69 | spid[xid+0] = sp_pid[bid];
70 | smin[xid+0] = sp1_min[bid];
71 | smax[xid+0] = sp1_max[bid];
72 |
73 | spid[xid+1] = sp_pid[bid];
74 | smin[xid+1] = sp2_min[bid];
75 | smax[xid+1] = sp2_max[bid];
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/shaders/multipass_create_geometry_for_ranges.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 4, local_size_y = 16) in;
4 |
5 | uniform int batch_size;
6 | uniform int batch_offset;
7 |
8 | layout (std430) buffer stack_min
9 | {
10 | vec2 smin[];
11 | };
12 |
13 | layout (std430) buffer stack_max
14 | {
15 | vec2 smax[];
16 | };
17 |
18 | layout (std430) buffer stack_pid
19 | {
20 | uint spid[];
21 | };
22 |
23 | layout (std430) buffer flag_pad
24 | {
25 | ivec2 fpad[];
26 | };
27 |
28 | layout (std430) buffer summed_flags
29 | {
30 | ivec2 fsum[];
31 | };
32 |
33 | layout (std430) buffer vertex_buffer
34 | {
35 | vec4 vbuffer[];
36 | };
37 |
38 | void main (void)
39 | {
40 | const vec2 intp[4] = {vec2(0,0), vec2(1,0), vec2(1,1), vec2(0,1)};
41 |
42 | uint vid = gl_GlobalInvocationID.x;
43 | uint bid = gl_GlobalInvocationID.y;
44 | uint sid = bid + uint(batch_offset);
45 |
46 | if (bid < batch_size && fpad[bid].y == 1) {
47 | uint rpid = spid[sid] & 0xffffff;
48 | vec2 rmin = smin[sid];
49 | vec2 rmax = smax[sid];
50 |
51 | vec2 i = intp[vid];
52 | vec2 p = mix(rmin, rmax, i);
53 |
54 | uint xid = fsum[bid].y - 1;
55 |
56 | vbuffer[xid*4+vid] = vec4(p, float(rpid),1);
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/shaders/multipass_init_ranges.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 64) in;
4 |
5 | uniform int patch_count;
6 |
7 | layout (std430) buffer stack_min
8 | {
9 | vec2 smin[];
10 | };
11 |
12 | layout (std430) buffer stack_max
13 | {
14 | vec2 smax[];
15 | };
16 |
17 | layout (std430) buffer stack_pid
18 | {
19 | uint spid[];
20 | };
21 |
22 |
23 | void main (void)
24 | {
25 | uint pid = gl_GlobalInvocationID.x;
26 | if (pid < patch_count) {
27 | smin[pid] = vec2(0.0,0.0);
28 | smax[pid] = vec2(1.0,1.0);
29 | spid[pid] = pid;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/shaders/multipass_setup_indirection.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 1) in;
4 |
5 | layout (std430) buffer flag_total
6 | {
7 | ivec2 ftotal;
8 | };
9 |
10 | layout (std430) buffer indirection_buffer
11 | {
12 | uint count;
13 | uint instanceCount;
14 | uint first;
15 | uint baseInstance;
16 | };
17 |
18 | void main (void)
19 | {
20 | count = 4 * ftotal.y;
21 | instanceCount = 1;
22 | first = 0;
23 | baseInstance = 0;
24 | }
25 |
--------------------------------------------------------------------------------
/shaders/noise/noise2D.glsl:
--------------------------------------------------------------------------------
1 | //
2 | // Description : Array and textureless GLSL 2D simplex noise function.
3 | // Author : Ian McEwan, Ashima Arts.
4 | // Maintainer : ijm
5 | // Lastmod : 20110822 (ijm)
6 | // License : Copyright (C) 2011 Ashima Arts. All rights reserved.
7 | // Distributed under the MIT License. See LICENSE file.
8 | // https://github.com/ashima/webgl-noise
9 | //
10 |
11 | vec3 mod289(vec3 x) {
12 | return x - floor(x * (1.0 / 289.0)) * 289.0;
13 | }
14 |
15 | vec2 mod289(vec2 x) {
16 | return x - floor(x * (1.0 / 289.0)) * 289.0;
17 | }
18 |
19 | vec3 permute(vec3 x) {
20 | return mod289(((x*34.0)+1.0)*x);
21 | }
22 |
23 | float snoise(vec2 v)
24 | {
25 | const vec4 C = vec4(0.211324865405187, // (3.0-sqrt(3.0))/6.0
26 | 0.366025403784439, // 0.5*(sqrt(3.0)-1.0)
27 | -0.577350269189626, // -1.0 + 2.0 * C.x
28 | 0.024390243902439); // 1.0 / 41.0
29 | // First corner
30 | vec2 i = floor(v + dot(v, C.yy) );
31 | vec2 x0 = v - i + dot(i, C.xx);
32 |
33 | // Other corners
34 | vec2 i1;
35 | //i1.x = step( x0.y, x0.x ); // x0.x > x0.y ? 1.0 : 0.0
36 | //i1.y = 1.0 - i1.x;
37 | i1 = (x0.x > x0.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0);
38 | // x0 = x0 - 0.0 + 0.0 * C.xx ;
39 | // x1 = x0 - i1 + 1.0 * C.xx ;
40 | // x2 = x0 - 1.0 + 2.0 * C.xx ;
41 | vec4 x12 = x0.xyxy + C.xxzz;
42 | x12.xy -= i1;
43 |
44 | // Permutations
45 | i = mod289(i); // Avoid truncation effects in permutation
46 | vec3 p = permute( permute( i.y + vec3(0.0, i1.y, 1.0 ))
47 | + i.x + vec3(0.0, i1.x, 1.0 ));
48 |
49 | vec3 m = max(0.5 - vec3(dot(x0,x0), dot(x12.xy,x12.xy), dot(x12.zw,x12.zw)), 0.0);
50 | m = m*m ;
51 | m = m*m ;
52 |
53 | // Gradients: 41 points uniformly over a line, mapped onto a diamond.
54 | // The ring size 17*17 = 289 is close to a multiple of 41 (41*7 = 287)
55 |
56 | vec3 x = 2.0 * fract(p * C.www) - 1.0;
57 | vec3 h = abs(x) - 0.5;
58 | vec3 ox = floor(x + 0.5);
59 | vec3 a0 = x - ox;
60 |
61 | // Normalise gradients implicitly by scaling m
62 | // Approximation of: m *= inversesqrt( a0*a0 + h*h );
63 | m *= 1.79284291400159 - 0.85373472095314 * ( a0*a0 + h*h );
64 |
65 | // Compute final noise value at P
66 | vec3 g;
67 | g.x = a0.x * x0.x + h.x * x0.y;
68 | g.yz = a0.yz * x12.xz + h.yz * x12.yw;
69 | return 130.0 * dot(m, g);
70 | }
71 |
--------------------------------------------------------------------------------
/shaders/prefixsum_accumulate.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 128) in;
4 |
5 | uniform uint batch_size;
6 |
7 | layout (std430) buffer accumulated
8 | {
9 | ivec2 abuf[];
10 | };
11 |
12 | layout (std430) buffer reduced
13 | {
14 | ivec2 rbuf[];
15 | };
16 |
17 |
18 | void main (void)
19 | {
20 | if (gl_GlobalInvocationID.x + 128 < batch_size) {
21 | abuf[gl_GlobalInvocationID.x + 128] += rbuf[gl_WorkGroupID.x];
22 | }
23 | }
24 |
25 |
--------------------------------------------------------------------------------
/shaders/prefixsum_reduce.compute:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout (local_size_x = 64) in;
4 |
5 | uniform uint batch_size;
6 |
7 | layout (std430) buffer input_buffer
8 | {
9 | ivec2 ibuf[];
10 | };
11 |
12 | layout (std430) buffer output_buffer
13 | {
14 | ivec2 obuf[];
15 | };
16 |
17 | layout (std430) buffer reduced_buffer
18 | {
19 | ivec2 rbuf[];
20 | };
21 |
22 | shared ivec2 tbuf[128];
23 |
24 | void main (void)
25 | {
26 |
27 | uint lid = gl_LocalInvocationID.x;
28 | uint wid = gl_WorkGroupID.x;
29 | uint gid1 = wid*128 + lid;
30 | uint gid2 = wid*128 + 64 + lid;
31 |
32 | tbuf[lid] = ivec2(0);
33 | tbuf[lid+64] = ivec2(0);
34 |
35 | // read input data into shared buffer
36 | if (gid1 < batch_size) tbuf[lid] = ibuf[gid1];
37 | if (gid2 < batch_size) tbuf[lid+64] = ibuf[gid2];
38 |
39 | // up-sweep
40 | for (uint i = 1; i <= 64; i <<= 1) {
41 | memoryBarrierShared();
42 |
43 | if (lid < 64/i) {
44 | uint ai = (2*lid+1)*i-1;
45 | uint bi = (2*lid+2)*i-1;
46 | tbuf[bi] += tbuf[ai];
47 | }
48 | }
49 |
50 | // down-sweep
51 | for (uint i = 64; i >= 2; i >>= 1) {
52 | memoryBarrierShared();
53 | \
54 | if (lid < 128/i-1) {
55 | uint ai = i*(lid+1)-1;
56 | uint bi = ai + i/2;
57 |
58 | tbuf[bi] += tbuf[ai];
59 | }
60 | }
61 |
62 | // write results back
63 | memoryBarrierShared();
64 | if (gid1 < batch_size) obuf[gid1] = tbuf[lid];
65 | if (gid2 < batch_size) obuf[gid2] = tbuf[lid+64];
66 |
67 | rbuf[wid] = tbuf[127];
68 | }
69 |
--------------------------------------------------------------------------------
/shaders/tex_draw.frag:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | #version 330
21 |
22 | uniform samplerBuffer framebuffer;
23 | uniform int bsize;
24 | uniform ivec2 gridsize;
25 |
26 | void main (void)
27 | {
28 | ivec2 pxlpos = ivec2(gl_FragCoord.xy);
29 |
30 | ivec2 gridpos = pxlpos / bsize;
31 | int grid_id = gridpos.x + gridsize.x * gridpos.y;
32 | ivec2 loclpos = pxlpos - gridpos * bsize;
33 | int locl_id = loclpos.x + bsize * loclpos.y;
34 |
35 | int pos = grid_id * bsize * bsize + locl_id;
36 |
37 | vec4 c = vec4(texelFetch(framebuffer, pos).xyz, 1);
38 |
39 | // Do gamma correction
40 | c = vec4(pow(c.r, 0.454545), pow(c.g, 0.454545), pow(c.b, 0.454545), c.a);
41 |
42 | gl_FragColor = c;
43 | }
44 |
--------------------------------------------------------------------------------
/shaders/tex_draw.vert:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 | #version 330
20 |
21 | in vec3 vertex;
22 |
23 | void main (void)
24 | {
25 | gl_Position = vec4(vertex,1);
26 | }
27 |
--------------------------------------------------------------------------------
/shaders/utility.h:
--------------------------------------------------------------------------------
1 |
2 | #ifndef UTILITY_H
3 | #define UTILITY_H
4 |
5 | const float infinity = 999999999999999999.0;
6 |
7 | uint round_up_div(uint n, uint d)
8 | {
9 | return n/d + ((n%d == 0) ? 0 : 1);
10 | }
11 |
12 |
13 | bool intersects (vec3 min1, vec3 max1, vec3 min2, vec3 max2)
14 | {
15 | return all(lessThan(min1, max2)) && all(lessThan(min2, max1));
16 | }
17 |
18 | #endif // UTILITY_H
19 |
--------------------------------------------------------------------------------
/shaders/wire.frag:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | #version 150
21 |
22 | uniform vec4 color;
23 |
24 | out vec4 frag_color;
25 |
26 | void main()
27 | {
28 | frag_color = color;
29 | }
30 |
--------------------------------------------------------------------------------
/shaders/wire.tess_ctrl:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout(vertices=4) out;
4 |
5 | void main(void)
6 | {
7 | gl_out[gl_InvocationID].gl_Position = gl_in[gl_InvocationID].gl_Position;
8 |
9 | gl_TessLevelOuter[0] = 2;
10 | gl_TessLevelOuter[1] = 8;
11 | }
12 |
--------------------------------------------------------------------------------
/shaders/wire.tess_eval:
--------------------------------------------------------------------------------
1 | #version 430
2 |
3 | layout(isolines, equal_spacing, ccw) in;
4 |
5 | uniform bool flip;
6 | uniform mat4 mvp;
7 | uniform samplerBuffer patches;
8 |
9 | vec3 eval_patch(vec2 t, int patch_id)
10 | {
11 | vec2 s = 1 - t;
12 |
13 | mat4 B = outerProduct(vec4(s.x*s.x*s.x, 3*s.x*s.x*t.x, 3*s.x*t.x*t.x, t.x*t.x*t.x),
14 | vec4(s.y*s.y*s.y, 3*s.y*s.y*t.y, 3*s.y*t.y*t.y, t.y*t.y*t.y));
15 |
16 | vec3 sum = vec3(0,0,0);
17 | for (int u = 0; u < 4; ++u) {
18 | for (int v = 0; v < 4; ++v) {
19 | sum += B[v][u] * texelFetch(patches, u + v * 4 + patch_id * 16).xyz;
20 | }
21 | }
22 |
23 | return sum;
24 | }
25 |
26 | void main()
27 | {
28 | vec2 tc = gl_TessCoord.xy * vec2(1,2);
29 | tc = flip ? tc.xy : tc.yx;
30 |
31 | vec2 t = mix(mix(gl_in[0].gl_Position.xy, gl_in[1].gl_Position.xy, tc.x),
32 | mix(gl_in[3].gl_Position.xy, gl_in[2].gl_Position.xy, tc.x), tc.y);
33 |
34 | gl_Position = mvp * vec4(eval_patch(t, int(gl_in[0].gl_Position.z)),1);
35 | }
36 |
--------------------------------------------------------------------------------
/shaders/wire.vert:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 |
20 | #version 430
21 |
22 | in vec4 vertex;
23 |
24 | void main()
25 | {
26 | gl_Position = vertex;
27 | }
28 |
--------------------------------------------------------------------------------
/src/CL/Buffer.h:
--------------------------------------------------------------------------------
1 |
2 | #pragma once
3 |
4 | #include "common.h"
5 |
6 | #include
7 |
8 | #include "GL/Texture.h"
9 |
10 | namespace CL
11 | {
12 | class CommandQueue;
13 | class Device;
14 |
15 | class Buffer : public noncopyable
16 | {
17 | protected:
18 |
19 | Device* _device;
20 | cl_mem_flags _flags;
21 | size_t _size;
22 |
23 | cl_mem _buffer;
24 |
25 | string _use;
26 | bool _shared;
27 |
28 | Buffer(Device& device, cl_mem_flags flags, const string& use="unkown") : _device(&device), _flags(flags), _size(0), _buffer(0), _use(use), _shared(false) {};
29 |
30 | public:
31 |
32 |
33 | Buffer(Device& device, size_t size, cl_mem_flags flags, const string& use="unknown");
34 | Buffer(Device& device, GLuint GL_buffer, const string& use="unknown");
35 | virtual ~Buffer();
36 |
37 | Buffer(Buffer&& other);
38 | Buffer& operator=(Buffer&& other);
39 |
40 | cl_mem get() const { return _buffer; }
41 |
42 | size_t get_size() const;
43 |
44 | virtual void resize(size_t new_size);
45 | };
46 |
47 |
48 | class ImageBuffer : public noncopyable
49 | {
50 | cl_mem _buffer;
51 |
52 | public:
53 |
54 | ImageBuffer(Device& device, GL::Texture& texture, cl_mem_flags flags);
55 | ~ImageBuffer();
56 |
57 | cl_mem get() const { return _buffer; }
58 | };
59 |
60 |
61 | class TransferBuffer : public Buffer
62 | {
63 | void* _host_ptr;
64 |
65 | public:
66 |
67 | TransferBuffer(Device& device, size_t size, cl_mem_flags flags, const string& use="unknown");
68 | virtual ~TransferBuffer();
69 |
70 | TransferBuffer(TransferBuffer&&);
71 | TransferBuffer& operator=(TransferBuffer&&);
72 |
73 | virtual void resize(size_t new_size);
74 |
75 | void set_host_ptr(void* ptr) { _host_ptr = ptr; }
76 |
77 | void* void_ptr();
78 | template T* host_ptr() { return (T*)void_ptr(); };
79 | template T& host_ref() { return *((T*)void_ptr()); };
80 | };
81 |
82 |
83 | }
84 |
--------------------------------------------------------------------------------
/src/CL/Device.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 | #include
6 |
7 | #include "Event.h"
8 |
9 |
10 | namespace CL
11 | {
12 | class Device : public noncopyable
13 | {
14 |
15 |
16 | cl_context _context;
17 | cl_device_id _device;
18 |
19 | bool _share_gl;
20 |
21 | std::set _supported_extensions;
22 |
23 | public:
24 |
25 |
26 | Device(int platform_index, int device_index);
27 | ~Device();
28 |
29 | cl_device_id get_device() { return _device; }
30 | cl_context get_context() { return _context; }
31 |
32 | bool share_gl() const { return _share_gl; }
33 |
34 | void print_info();
35 |
36 |
37 | private:
38 |
39 |
40 | struct EventIndex
41 | {
42 | int id;
43 | string name;
44 | string queue_name;
45 | cl_event event;
46 |
47 | bool is_user;
48 | cl_ulong user_begin;
49 | cl_ulong user_end;
50 |
51 | int dependency_count;
52 | int dependency_ids[Event::MAX_ID_COUNT];
53 | };
54 |
55 | std::unordered_map _events;
56 | int _id_count;
57 | bool _dump_trace;
58 |
59 |
60 | public:
61 |
62 |
63 | Event insert_event(const string& name, const string& queue_name, cl_event event, const Event& dependencies);
64 | size_t setup_event_pad(const Event& event, vector& event_pad, cl_event*& event_pad_ptr);
65 |
66 | int insert_user_event(const string& name, cl_event event, const Event& dependencies);
67 | void end_user_event(int id);
68 |
69 | void dump_trace();
70 | void release_events();
71 |
72 | size_t max_compute_units() const;
73 | size_t preferred_work_group_size_multiple() const;
74 |
75 | bool check_extension(const string& extension_name) const;
76 |
77 |
78 | private:
79 |
80 |
81 | void query_extensions();
82 |
83 |
84 | };
85 | }
86 |
--------------------------------------------------------------------------------
/src/CL/Event.cpp:
--------------------------------------------------------------------------------
1 | #include "Event.h"
2 |
3 | #include "Device.h"
4 | #include "Exception.h"
5 |
6 | CL::Event::Event() :
7 | _count(0)
8 | {
9 |
10 | }
11 |
12 | CL::Event::Event(int id) :
13 | _count(1)
14 | {
15 | _ids[0] = id;
16 | }
17 |
18 | CL::Event::Event(const Event& event) :
19 | _count(event._count)
20 | {
21 | assert(event._count < MAX_ID_COUNT);
22 |
23 | for (size_t i = 0; i < _count; ++i) {
24 | _ids[i] = event._ids[i];
25 | }
26 | }
27 |
28 | const size_t CL::Event::get_id_count() const
29 | {
30 | return _count;
31 | }
32 |
33 | const int* CL::Event::get_ids() const
34 | {
35 | return _ids;
36 | }
37 |
38 | CL::Event CL::Event::operator | (const CL::Event& other) const
39 | {
40 | Event e(other);
41 |
42 | e._count += _count;
43 |
44 | assert(e._count < MAX_ID_COUNT);
45 |
46 | for (size_t i = 0; i < _count; ++i) {
47 | e._ids[i + other._count] = _ids[i];
48 | }
49 |
50 | return e;
51 | }
52 |
53 | CL::Event& CL::Event::operator = (const CL::Event& other)
54 | {
55 | _count = other._count;
56 |
57 | for (size_t i = 0; i < _count; ++i) {
58 | _ids[i] = other._ids[i];
59 | }
60 |
61 | return *this;
62 | }
63 |
64 |
65 |
66 |
67 | CL::UserEvent::UserEvent(CL::Device& device, const string& name)
68 | : _device(device)
69 | , _name(name)
70 | , _event(0)
71 | , _id(-1)
72 | , _active(false)
73 | {
74 | }
75 |
76 |
77 | CL::UserEvent::~UserEvent()
78 | {
79 | if (_active) {
80 | end();
81 | }
82 | }
83 |
84 |
85 | void CL::UserEvent::begin(const CL::Event& dependencies)
86 | {
87 | cl_int status;
88 |
89 | _event = clCreateUserEvent(_device.get_context(), &status);
90 | OPENCL_ASSERT(status);
91 |
92 | _id = _device.insert_user_event(_name, _event, dependencies);
93 | _active = true;
94 | }
95 |
96 |
97 | void CL::UserEvent::end()
98 | {
99 | cl_int status;
100 |
101 | if (!_active) return;
102 |
103 | status = clSetUserEventStatus(_event, CL_COMPLETE);
104 | OPENCL_ASSERT(status);
105 |
106 | _device.end_user_event(_id);
107 |
108 | _event = 0;
109 | _id = -1;
110 | _active = false;
111 | }
112 |
--------------------------------------------------------------------------------
/src/CL/Event.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 |
6 |
7 | namespace CL
8 | {
9 | class Device;
10 |
11 | class Event
12 | {
13 | public:
14 |
15 | static const int MAX_ID_COUNT = 16;
16 |
17 | private:
18 | int _ids[MAX_ID_COUNT];
19 | size_t _count;
20 |
21 | public:
22 |
23 | Event();
24 | Event(int id);
25 | Event(const Event& event);
26 |
27 | Event operator | (const Event& other) const;
28 | Event& operator = (const Event& other);
29 | const size_t get_id_count() const;
30 | const int* get_ids() const;
31 | };
32 |
33 |
34 | class UserEvent : noncopyable
35 | {
36 |
37 | Device& _device;
38 | string _name;
39 | cl_event _event;
40 | int _id;
41 | bool _active;
42 |
43 | public:
44 |
45 |
46 | UserEvent(Device& device, const string& name);
47 | ~UserEvent();
48 |
49 | void begin(const CL::Event& dependencies);
50 | void end();
51 |
52 | Event event() const { return Event(_id); }
53 |
54 | };
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/CL/Exception.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 |
6 |
7 | namespace CL
8 | {
9 |
10 | class Exception
11 | {
12 | string _msg;
13 | string _file;
14 | int _line_no;
15 |
16 | public:
17 |
18 | Exception(cl_int err_code, const string& file, int line_no);
19 | Exception(const string& msg, const string& file, int line_no);
20 |
21 | const string& msg();
22 | const string& file() { return _file; }
23 | const int line_no() { return _line_no; }
24 | };
25 |
26 | }
27 |
28 | #define OPENCL_EXCEPTION(error) throw CL::Exception((error), __FILE__, __LINE__)
29 | #define OPENCL_ASSERT(error) if ((error)!= CL_SUCCESS) throw CL::Exception((error), __FILE__, __LINE__)
30 |
--------------------------------------------------------------------------------
/src/CL/HistogramPyramid.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | #include "Buffer.h"
6 | #include "Event.h"
7 | #include "Program.h"
8 | #include "CommandQueue.h"
9 |
10 |
11 | namespace CL
12 | {
13 | class Kernel;
14 |
15 | class HistogramPyramid : public noncopyable
16 | {
17 | Program _program;
18 |
19 | shared_ptr _reduce_kernel;
20 |
21 | Device& _device;
22 | string _use;
23 |
24 | public:
25 |
26 | HistogramPyramid(Device& device, const string& use="unknown");
27 | ~HistogramPyramid();
28 |
29 | Event apply(size_t base_item_count, size_t base_size, CommandQueue& queue, Buffer& pyramid, Event& event) const;
30 |
31 | size_t pyramid_size(size_t base_size) const;
32 | size_t get_top_level(size_t base_item_count) const;
33 |
34 | void get_offsets(size_t base_size, std::vector& offsets) const;
35 | void get_sizes(size_t base_item_count, std::vector& sizes) const;
36 |
37 | };
38 |
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/CL/Kernel.cpp:
--------------------------------------------------------------------------------
1 | #include "Kernel.h"
2 |
3 | #include "Exception.h"
4 | #include "Device.h"
5 |
6 | #include "Config.h"
7 |
8 | CL::Kernel::Kernel(cl_program program, cl_device_id device, const string& kernelname) :
9 | _program(0)
10 | {
11 | cl_int status;
12 |
13 | _kernel = clCreateKernel(program, kernelname.c_str(), &status);
14 | OPENCL_ASSERT(status);
15 |
16 | if (config.verbosity_level() > 0) {
17 | // Get kernel info
18 |
19 | size_t work_group_size;
20 | size_t preferred_work_group_size_multiple;
21 | cl_ulong local_mem_size;
22 | cl_ulong private_mem_size;
23 | size_t compile_work_group_size[3];
24 |
25 | status = clGetKernelWorkGroupInfo(_kernel, device, CL_KERNEL_WORK_GROUP_SIZE,
26 | sizeof(work_group_size), &work_group_size,
27 | NULL);
28 | OPENCL_ASSERT(status);
29 |
30 | status = clGetKernelWorkGroupInfo(_kernel, device, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
31 | sizeof(preferred_work_group_size_multiple), &preferred_work_group_size_multiple,
32 | NULL);
33 | OPENCL_ASSERT(status);
34 |
35 | status = clGetKernelWorkGroupInfo(_kernel, device, CL_KERNEL_LOCAL_MEM_SIZE,
36 | sizeof(local_mem_size), &local_mem_size,
37 | NULL);
38 | OPENCL_ASSERT(status);
39 |
40 | status = clGetKernelWorkGroupInfo(_kernel, device, CL_KERNEL_PRIVATE_MEM_SIZE,
41 | sizeof(private_mem_size), &private_mem_size,
42 | NULL);
43 | OPENCL_ASSERT(status);
44 |
45 | status = clGetKernelWorkGroupInfo(_kernel, device, CL_KERNEL_COMPILE_WORK_GROUP_SIZE,
46 | sizeof(compile_work_group_size), &compile_work_group_size,
47 | NULL);
48 | OPENCL_ASSERT(status);
49 |
50 | cout << "kernel " << kernelname << ": "
51 | << local_mem_size << "bytes local, "
52 | << private_mem_size << "bytes private" << endl;
53 | }
54 | }
55 |
56 | CL::Kernel::~Kernel()
57 | {
58 | clReleaseKernel(_kernel);
59 |
60 | if (_program != 0) {
61 | clReleaseProgram(_program);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/CL/Kernel.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 |
6 | #include "Exception.h"
7 | #include "Buffer.h"
8 |
9 | namespace CL
10 | {
11 | class Device;
12 |
13 | class Kernel : public noncopyable
14 | {
15 | cl_kernel _kernel;
16 | cl_program _program;
17 |
18 | public:
19 |
20 | Kernel(cl_program program, cl_device_id device, const string& kernelname);
21 | ~Kernel();
22 |
23 | template void set_arg (cl_uint arg_index, const T& buffer);
24 |
25 | cl_kernel get() { return _kernel; }
26 |
27 |
28 | template void set_args(Types && ... values)
29 | {
30 | set_args_from(0, values...);
31 | }
32 |
33 | template void set_args_from(cl_uint i, const T& value, Types && ... rest)
34 | {
35 | set_arg(i, value);
36 | set_args_from(i+1, rest...);
37 | }
38 |
39 |
40 | void set_args_from(cl_uint i) {}
41 |
42 | };
43 |
44 | template
45 | inline void Kernel::set_arg(cl_uint arg_index, const T& value)
46 | {
47 | cl_int status;
48 |
49 | status = clSetKernelArg(_kernel, arg_index, sizeof(T), &value);
50 |
51 | OPENCL_ASSERT(status);
52 | }
53 |
54 | template<>
55 | inline void Kernel::set_arg(cl_uint arg_index, const ImageBuffer& value)
56 | {
57 | cl_mem mem = value.get();
58 | set_arg(arg_index, mem);
59 | }
60 |
61 | template<>
62 | inline void Kernel::set_arg(cl_uint arg_index, const Buffer& value)
63 | {
64 | cl_mem mem = value.get();
65 | set_arg(arg_index, mem);
66 | }
67 |
68 | template<>
69 | inline void Kernel::set_arg(cl_uint arg_index, const TransferBuffer& value)
70 | {
71 | cl_mem mem = value.get();
72 | set_arg(arg_index, mem);
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/CL/OpenCL.h:
--------------------------------------------------------------------------------
1 | /******************************************************************************\
2 | * This file is part of Micropolis. *
3 | * *
4 | * Micropolis is free software: you can redistribute it and/or modify *
5 | * it under the terms of the GNU General Public License as published by *
6 | * the Free Software Foundation, either version 3 of the License, or *
7 | * (at your option) any later version. *
8 | * *
9 | * Micropolis is distributed in the hope that it will be useful, *
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 | * GNU General Public License for more details. *
13 | * *
14 | * You should have received a copy of the GNU General Public License *
15 | * along with Micropolis. If not, see . *
16 | \******************************************************************************/
17 |
18 |
19 | #pragma once
20 |
21 | #include "Buffer.h"
22 | #include "CommandQueue.h"
23 | #include "Device.h"
24 | #include "Event.h"
25 | #include "Exception.h"
26 | #include "Kernel.h"
27 | #include "Program.h"
28 |
--------------------------------------------------------------------------------
/src/CL/PrefixSum.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | #include "Buffer.h"
6 | #include "Event.h"
7 | #include "Program.h"
8 | #include "CommandQueue.h"
9 |
10 |
11 | namespace CL
12 | {
13 | class Kernel;
14 |
15 | class PrefixSum : public noncopyable
16 | {
17 | vector _buffer_pyramid;
18 |
19 | Program _program;
20 |
21 | shared_ptr _reduce_kernel;
22 | shared_ptr _accumulate_kernel;
23 |
24 | Device& _device;
25 | string _use;
26 |
27 | size_t _max_input_items;
28 |
29 | public:
30 |
31 | PrefixSum(Device& device, size_t max_input_items, const string& use="unknown");
32 | ~PrefixSum();
33 |
34 | Event apply(size_t batch_size, CommandQueue& queue, Buffer& input, Buffer& output, Buffer& total, Event& event);
35 |
36 | void resize(size_t new_max_size);
37 |
38 | private:
39 |
40 | Event do_reduce (size_t batch_size, CommandQueue& queue, Buffer& input, Buffer& output, Buffer& reduced, Event& event);
41 | Event do_accumulate (size_t batch_size, CommandQueue& queue, Buffer& reduced, Buffer& accumulated, Event& event);
42 | };
43 |
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/CL/Program.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 |
6 | #include
7 |
8 | namespace CL
9 | {
10 | class Kernel;
11 | class Device;
12 |
13 | class Program : public noncopyable
14 | {
15 | cl_device_id _device;
16 | cl_program _program;
17 | std::stringstream* _source_buffer;
18 |
19 | public:
20 |
21 | Program();
22 | ~Program();
23 |
24 | void define(const string& macro, const string& statement);
25 |
26 | void set_constant(const string& name, int value);
27 | void set_constant(const string& name, size_t value);
28 | void set_constant(const string& name, float value);
29 | void set_constant(const string& name, ivec2 value);
30 | void set_constant(const string& name, vec4 value);
31 |
32 | void compile(Device& device, const string& filename);
33 |
34 | Kernel* get_kernel(const string& name);
35 | };
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/CL/config.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | #include "common.h"
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Search directory for OpenCL kernels.
34 |
35 |
36 |
37 | Pair of integers defining the platform and device id of the OpenCL device that shall be used.
38 |
39 |
40 |
41 | Force slow path for OpenCL/OpenGL buffer sharing.
42 |
43 |
44 |
45 | Controls how we wait for OpenCL events. Polling is slightly faster but uses more CPU cycles.
46 |
47 |
48 |
49 | Allocation method of host/device transfer buffers. Either PINNED or UNPINNED.
50 | PINNED should be a lot faster.
51 |
52 |
53 |
54 | Will dump the concatenated OpenCL kernel files into /tmp/ for debugging purposes.
55 |
56 |
57 |
58 | Target file for writing OpenCL trace to.
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/src/GL/Buffer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 | #include
5 |
6 | namespace GL
7 | {
8 |
9 | class Buffer : public noncopyable
10 | {
11 | GLuint _buffer;
12 | size_t _size;
13 |
14 | mutable GLenum _target;
15 | mutable int _index;
16 |
17 | public:
18 |
19 | Buffer(size_t size);
20 | ~Buffer();
21 |
22 | Buffer(Buffer&& other);
23 | Buffer& operator=(Buffer&& other);
24 |
25 | GLuint get_id() const;
26 | size_t get_size() const;
27 |
28 | void resize(size_t new_size);
29 |
30 | GLuint get_target_index() const;
31 |
32 | void bind(GLenum target) const;
33 | void bind(GLenum target, GLuint index) const;
34 |
35 | void unbind() const;
36 |
37 | void send_data(void* data, size_t size);
38 | void send_subdata(void* data, size_t offset, size_t size);
39 |
40 | void read_data(void* data, size_t size);
41 |
42 |
43 | template
44 | static void bind_all(GLenum target, GLuint start, Buffer& buffer, Types&& ... rest)
45 | {
46 | buffer.bind(target, start);
47 | bind_all(target, start+1, rest...);
48 | }
49 |
50 | template
51 | static void unbind_all(Buffer& buffer, Types&& ... rest)
52 | {
53 | buffer.unbind();
54 | unbind_all(rest...);
55 | }
56 |
57 | static void bind_all(GLenum target, GLuint start) {};
58 | static void unbind_all() {};
59 | };
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/GL/ComputeShader.cpp:
--------------------------------------------------------------------------------
1 | #include "ComputeShader.h"
2 |
3 | #include "ShaderObject.h"
4 |
5 |
6 | #include "Config.h"
7 |
8 | #include
9 |
10 | GL::ComputeShader::ComputeShader(const string& shader_name)
11 | : Shader()
12 | {
13 | _name = shader_name;
14 |
15 |
16 | if (config.verbosity_level() >= 2) {
17 | cout << boost::format("Compiling compute-shader \"%1%\"...") % _name << endl;
18 | }
19 |
20 | ShaderObject compute_shader(shader_name, "", GL_COMPUTE_SHADER);
21 |
22 | if (compute_shader.invalid()) {
23 | cout << boost::format("Compiling compute-shader \"%1%\" FAILED") % _name << endl;
24 | exit(1);
25 | return;
26 | }
27 |
28 | _program = glCreateProgram();
29 | compute_shader.attach_to(_program);
30 |
31 | link();
32 | }
33 |
34 |
35 |
36 | GL::ComputeShader::~ComputeShader()
37 | {
38 |
39 | }
40 |
41 |
42 | void GL::ComputeShader::dispatch(ivec3 group_count)
43 | {
44 | glDispatchCompute((GLuint)group_count.x,
45 | (GLuint)group_count.y,
46 | (GLuint)group_count.z);
47 | // Force sync
48 | GLsync sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
49 | //glWaitSync(sync, 0, GL_TIMEOUT_IGNORED);
50 | glDeleteSync(sync);
51 | }
52 |
--------------------------------------------------------------------------------
/src/GL/ComputeShader.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "Shader.h"
4 |
5 |
6 | namespace GL
7 | {
8 |
9 | class ComputeShader : public Shader
10 | {
11 |
12 | public:
13 |
14 | ComputeShader(const string& shader_name);
15 | ~ComputeShader();
16 |
17 | void dispatch(ivec3 group_count);
18 |
19 | void dispatch(int group_count) { dispatch(ivec3(group_count, 1,1)); }
20 | void dispatch(int w, int h) { dispatch(ivec3(w,h,1)); }
21 | void dispatch(ivec2 group_count) { dispatch(ivec3(group_count, 1)); }
22 | void dispatch(int w, int h, int d) { dispatch(ivec3(w,h,d)); }
23 |
24 | };
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/GL/PrefixSum.cpp:
--------------------------------------------------------------------------------
1 | #include "PrefixSum.h"
2 |
3 |
4 | GL::PrefixSum::PrefixSum(size_t max_input_items)
5 | : reduce("prefixsum_reduce")
6 | , accumulate("prefixsum_accumulate")
7 | , max_input_items(max_input_items)
8 | {
9 | for (int i = (max_input_items-1)/128+1; i > 1; i = (i-1)/128+1) {
10 | buffer_pyramid.emplace_back(i * sizeof(ivec2));
11 | }
12 | }
13 |
14 |
15 | GL::PrefixSum::~PrefixSum()
16 | {
17 |
18 | }
19 |
20 |
21 | void GL::PrefixSum::apply(size_t batch_size, GL::Buffer& input, GL::Buffer& output, Buffer& total)
22 | {
23 | if (batch_size == 0) return;
24 |
25 | if (batch_size <= 128) {
26 | do_reduce(batch_size, input, output, total);
27 | return;
28 | }
29 |
30 | size_t reduced_size = (batch_size-1)/128+1;
31 | int level = buffer_pyramid.size()-1;
32 | while (level >= 0 && buffer_pyramid[level].get_size() < reduced_size) {
33 | level--;
34 | }
35 | assert(level >= 0);
36 |
37 | do_reduce (batch_size, input, output, buffer_pyramid.at(level));
38 |
39 | apply((batch_size-1)/128+1, buffer_pyramid.at(level), buffer_pyramid.at(level), total);
40 |
41 | do_accumulate(batch_size, buffer_pyramid[level], output);
42 | }
43 |
44 |
45 | void GL::PrefixSum::do_reduce(size_t batch_size, GL::Buffer& input, GL::Buffer& output, GL::Buffer& reduced)
46 | {
47 | reduce.bind();
48 |
49 | if (input.get_id() == output.get_id())
50 | GL::Buffer::bind_all(GL_SHADER_STORAGE_BUFFER, 0, input, reduced);
51 | else
52 | GL::Buffer::bind_all(GL_SHADER_STORAGE_BUFFER, 0, input, output, reduced);
53 |
54 | reduce.set_uniform("batch_size", (GLuint)batch_size);
55 | reduce.set_buffer("input_buffer", input);
56 | reduce.set_buffer("output_buffer", output);
57 | reduce.set_buffer("reduced_buffer", reduced);
58 |
59 | reduce.dispatch((batch_size-1)/128+1);
60 |
61 | if (input.get_id() == output.get_id())
62 | GL::Buffer::unbind_all(input, reduced);
63 | else
64 | GL::Buffer::unbind_all(input, output, reduced);
65 |
66 | reduce.unbind();
67 | }
68 |
69 |
70 | void GL::PrefixSum::do_accumulate(size_t batch_size, GL::Buffer& reduced, GL::Buffer& accumulated)
71 | {
72 | if ((batch_size-1)/128 == 0) return;
73 |
74 | accumulate.bind();
75 |
76 | GL::Buffer::bind_all(GL_SHADER_STORAGE_BUFFER, 0, reduced, accumulated);
77 |
78 | accumulate.set_uniform("batch_size", (GLuint)batch_size);
79 | accumulate.set_buffer("reduced", reduced);
80 | accumulate.set_buffer("accumulated", accumulated);
81 |
82 | accumulate.dispatch((batch_size-1)/128);
83 |
84 | GL::Buffer::unbind_all(reduced, accumulated);
85 |
86 | accumulate.unbind();
87 | }
88 |
--------------------------------------------------------------------------------
/src/GL/PrefixSum.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | #include "Buffer.h"
6 | #include "ComputeShader.h"
7 |
8 | namespace GL
9 | {
10 |
11 | class PrefixSum : public noncopyable
12 | {
13 | vector buffer_pyramid;
14 |
15 | ComputeShader reduce;
16 | ComputeShader accumulate;
17 |
18 | size_t max_input_items;
19 |
20 | public:
21 |
22 | PrefixSum(size_t max_input_items);
23 | ~PrefixSum();
24 |
25 | void apply(size_t batch_size, Buffer& input, Buffer& output, Buffer& total);
26 |
27 |
28 | private:
29 |
30 | void do_reduce (size_t batch_size, Buffer& input, Buffer& output, Buffer& reduced);
31 | void do_accumulate (size_t batch_size, Buffer& reduced, Buffer& accumulated);
32 | };
33 | }
34 |
--------------------------------------------------------------------------------
/src/GL/ShaderObject.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | namespace GL
6 | {
7 |
8 | class ShaderObject
9 | {
10 | GLuint shader_handle;
11 | string shadername;
12 |
13 | std::stringstream ss;
14 | map file_to_index_map;
15 | map index_to_file_map;
16 |
17 | public:
18 |
19 | ShaderObject(const string& shader, const string& material, GLenum shader_type);
20 | ~ShaderObject();
21 |
22 | bool valid() const;
23 | bool invalid() const;
24 | void attach_to(GLuint program_handle) const;
25 |
26 | private:
27 |
28 | GLuint compile_shader_object(const string& shader,
29 | const string& material,
30 | GLenum type);
31 | bool load_shader_source(const string& shader,
32 | const string& material,
33 | const string& file_extension);
34 |
35 | bool read_file(const string& filename);
36 |
37 | void print_shader_log();
38 |
39 |
40 | };
41 |
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/src/GL/config.xml:
--------------------------------------------------------------------------------
1 |
17 |
18 |
19 |
20 | #include "common.h"
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | Number of anti-aliasing samples. (0 means no AA)
30 |
31 |
32 |
33 | Search directory for GLSL shader files.
34 |
35 |
36 |
37 | Maximum anisotropy for texture filtering.
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/src/GL/extensions.glprofile:
--------------------------------------------------------------------------------
1 | # This file is part of Micropolis.
2 | #
3 | # Micropolis is free software: you can redistribute it and/or modify
4 | # it under the terms of the GNU General Public License as published by
5 | # the Free Software Foundation, either version 3 of the License, or
6 | # (at your option) any later version.
7 | #
8 | # Micropolis is distributed in the hope that it will be useful,
9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | # GNU General Public License for more details.
12 | #
13 | # You should have received a copy of the GNU General Public License
14 | # along with Micropolis. If not, see .
15 |
16 | version 4.3 core
17 |
18 | extension ARB_texture_rg required
19 | extension EXT_texture_filter_anisotropic optional
20 | extension ARB_cl_event optional
21 | extension ARB_debug_output optional
--------------------------------------------------------------------------------
/src/GL/glutils.cpp:
--------------------------------------------------------------------------------
1 |
2 | #include "glutils.h"
3 |
4 |
5 | #include
6 |
7 | #define LOG_BUFFER_SIZE 1024*64
8 |
9 | void GL::insert_filename_and_print(char* clog, const string& filename)
10 | {
11 | string line;
12 |
13 | const boost::regex pattern("(.+)([0-9]+):([0-9]+)(.+)");
14 | const boost::regex pattern2("([0-9]+)\\(([0-9]+)\\) :(.+)");
15 | boost::match_results match;
16 |
17 | std::stringstream ss(clog);
18 |
19 | while(std::getline(ss, line)) {
20 | if (boost::regex_match(line, match, pattern)) {
21 | cout << filename << ":" << match.str(3) << ":" << match.str(2) << "" << match.str(4) << endl;
22 | } else if (boost::regex_match(line, match, pattern2)) {
23 | cout << filename << ":" << match.str(2) << ":" << match.str(1) << ":" << match.str(3) << endl;
24 | } else {
25 | cout << line << endl;
26 | }
27 | }
28 | }
29 |
30 |
31 | /**
32 | * Print a shader program error log to the shell.
33 | * @param program OpenGL Shader Program handle.
34 | * @param filename Filename of the linked file(s) to give feedback.
35 | */
36 | void GL::print_program_log(GLuint program, const string& filename)
37 | {
38 | char logBuffer[LOG_BUFFER_SIZE];
39 | GLsizei length;
40 |
41 | logBuffer[0] = '\0';
42 | glGetProgramInfoLog(program, LOG_BUFFER_SIZE, &length,logBuffer);
43 |
44 | if (length > 0) {
45 | cout << "--------------------------------------------------------------------------------" << endl;
46 | cout << filename << " program link log:" << endl;
47 | insert_filename_and_print(logBuffer, filename);
48 | }
49 | };
50 |
51 |
52 | /**
53 | * Print a shader error log to shell.
54 | * @param program OpenGL Shader handle.
55 | * @param filename Filename of the compiled file to give feedback.
56 | */
57 | void GL::print_shader_log(GLuint shader, const string& filename)
58 | {
59 | char logBuffer[LOG_BUFFER_SIZE];
60 | GLsizei length;
61 |
62 | logBuffer[0] = '\0';
63 | glGetShaderInfoLog(shader, LOG_BUFFER_SIZE, &length,logBuffer);
64 |
65 | if (length > 0) {
66 | cout << "--------------------------------------------------------------------------------" << endl;
67 | cout << filename << " shader build log:" << endl;
68 | insert_filename_and_print(logBuffer, filename);
69 | }
70 | };
71 |
--------------------------------------------------------------------------------
/src/GL/glutils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 |
6 | namespace GL
7 | {
8 |
9 | void insert_filename_and_print(char* clog, const string& filename);
10 | void print_shader_log(GLuint shader, const string& filename);
11 | void print_program_log(GLuint program, const string& filename);
12 |
13 | }
14 |
--------------------------------------------------------------------------------
/src/Reyes/BoundNSplitCL.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | #include "CL/OpenCL.h"
6 | #include "CL/PrefixSum.h"
7 | #include "GL/Texture.h"
8 | #include "GL/VBO.h"
9 | #include "Patch.h"
10 | #include "PatchRange.h"
11 | #include "PatchType.h"
12 | #include "Projection.h"
13 |
14 | namespace Reyes
15 | {
16 |
17 |
18 | struct Batch
19 | {
20 | size_t patch_count;
21 | PatchType patch_type;
22 | CL::Buffer& patch_buffer;
23 | CL::Buffer& patch_ids;
24 | CL::Buffer& patch_min;
25 | CL::Buffer& patch_max;
26 | CL::Event transfer_done;
27 | };
28 |
29 | class BoundNSplitCL
30 | {
31 |
32 | public:
33 |
34 | virtual ~BoundNSplitCL() {};
35 |
36 | public:
37 |
38 | virtual void init(void* patches_handle, const mat4& matrix, const Projection* projection) = 0;
39 | virtual bool done() = 0;
40 | virtual void finish() = 0;
41 |
42 | virtual Batch do_bound_n_split(CL::Event& ready) = 0;
43 | };
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/Reyes/BoundNSplitCLBounded.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 |
4 | #include "common.h"
5 |
6 |
7 | #include "BoundNSplitCL.h"
8 |
9 |
10 | namespace Reyes
11 | {
12 |
13 |
14 | class PatchIndex;
15 |
16 |
17 | class BoundNSplitCLBounded : public BoundNSplitCL
18 | {
19 |
20 | CL::CommandQueue& _queue;
21 | shared_ptr _patch_index;
22 |
23 | CL::Program _bound_n_split_program_bezier;
24 | CL::Program _bound_n_split_program_gregory;
25 |
26 | shared_ptr _bound_kernel_bezier;
27 | shared_ptr _bound_kernel_gregory;
28 | shared_ptr _move_kernel;
29 | shared_ptr _init_ranges_kernel;
30 | shared_ptr _init_projection_buffer_kernel;
31 |
32 | void* _active_handle;
33 | CL::Buffer* _active_patch_buffer;
34 | mat4 _active_matrix;
35 | PatchType _active_patch_type;
36 | int _stack_height;
37 |
38 | CL::Buffer _pid_stack;
39 | CL::Buffer _depth_stack;
40 | CL::Buffer _min_stack;
41 | CL::Buffer _max_stack;
42 |
43 | CL::TransferBuffer _split_ranges_cnt_buffer;
44 |
45 | CL::Buffer _out_pids_buffer;
46 | CL::Buffer _out_mins_buffer;
47 | CL::Buffer _out_maxs_buffer;
48 | CL::TransferBuffer _out_range_cnt_buffer;
49 |
50 | CL::Buffer _bound_flags;
51 | CL::Buffer _draw_flags;
52 | CL::Buffer _split_flags;
53 |
54 | CL::Buffer _pid_pad;
55 | CL::Buffer _depth_pad;
56 | CL::Buffer _min_pad;
57 | CL::Buffer _max_pad;
58 |
59 | CL::Buffer _projection_buffer;
60 |
61 | CL::Event _ready;
62 |
63 | CL::PrefixSum _prefix_sum;
64 |
65 | CL::UserEvent _user_event;
66 |
67 | public:
68 |
69 |
70 | BoundNSplitCLBounded(CL::Device& device, CL::CommandQueue& queue,
71 | shared_ptr& patch_index);
72 |
73 |
74 | virtual void init(void* patches_handle,
75 | const mat4& matrix, const Projection* projection);
76 | virtual bool done();
77 | virtual void finish();
78 |
79 | virtual Batch do_bound_n_split(CL::Event& ready);
80 |
81 | };
82 |
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/Reyes/BoundNSplitCLLocal.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "common.h"
4 |
5 | #include "BoundNSplitCL.h"
6 |
7 |
8 | namespace Reyes
9 | {
10 |
11 |
12 | class PatchIndex;
13 |
14 |
15 | class BoundNSplitCLLocal : public BoundNSplitCL
16 | {
17 |
18 | CL::CommandQueue& _queue;
19 | shared_ptr _patch_index;
20 |
21 | CL::Program _bound_n_split_program_bezier;
22 | CL::Program _bound_n_split_program_gregory;
23 |
24 | shared_ptr _bound_n_split_kernel_bezier;
25 | shared_ptr _bound_n_split_kernel_gregory;
26 | shared_ptr _init_range_buffers_kernel;
27 | shared_ptr _init_projection_buffer_kernel;
28 | shared_ptr _init_count_buffers_kernel;
29 |
30 | void* _active_handle;
31 | CL::Buffer* _active_patch_buffer;
32 | mat4 _active_matrix;
33 | Reyes::PatchType _active_patch_type;
34 |
35 | size_t _in_buffers_size;
36 | size_t _in_buffer_stride;
37 | CL::Buffer _in_pids_buffer;
38 | CL::Buffer _in_mins_buffer;
39 | CL::Buffer _in_maxs_buffer;
40 | CL::Buffer _in_range_cnt_buffer;
41 |
42 | CL::Buffer _out_pids_buffer;
43 | CL::Buffer _out_mins_buffer;
44 | CL::Buffer _out_maxs_buffer;
45 | CL::TransferBuffer _out_range_cnt_buffer;
46 |
47 | CL::TransferBuffer _processed_count_buffer;
48 |
49 | CL::Buffer _projection_buffer;
50 |
51 | CL::Event _ready;
52 |
53 | bool _done;
54 | int _iteration_count;
55 |
56 | public:
57 |
58 |
59 | BoundNSplitCLLocal(CL::Device& device, CL::CommandQueue& queue,
60 | shared_ptr& patch_index);
61 |
62 |
63 | virtual void init(void* patches_handle,
64 | const mat4& matrix, const Projection* projection);
65 | virtual bool done();
66 | virtual void finish();
67 |
68 | virtual Batch do_bound_n_split(CL::Event& ready);
69 | };
70 |
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/src/Reyes/PatchIndex.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "PatchType.h"
4 | #include "GL/Texture.h"
5 | #include "CL/OpenCL.h"
6 |
7 | namespace Reyes
8 | {
9 |
10 | class PatchIndex
11 | {
12 |
13 |
14 | struct PatchData
15 | {
16 | size_t patch_count;
17 | vector patch_data;
18 | PatchType type;
19 |
20 | shared_ptr patch_texture;
21 | shared_ptr opencl_buffer;
22 | };
23 |
24 | map