mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-07 00:38:48 +02:00
Merge branch 'master' into asm-shader-rework-1
Conflicts: src/mesa/shader/arbprogparse.c
This commit is contained in:
commit
a512985fd8
616 changed files with 31358 additions and 20804 deletions
13
Makefile
13
Makefile
|
|
@ -345,7 +345,9 @@ DRI_FILES = \
|
|||
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch] \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/*/*.[chS] \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/Makefile \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/*/Makefile \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile \
|
||||
$(DIRECTORY)/src/mesa/drivers/dri/*/server/*.[ch]
|
||||
|
||||
|
|
@ -388,7 +390,17 @@ GLW_FILES = \
|
|||
$(DIRECTORY)/src/glw/glw.pc.in \
|
||||
$(DIRECTORY)/src/glw/depend
|
||||
|
||||
GLEW_FILES = \
|
||||
$(DIRECTORY)/include/GL/glew.h \
|
||||
$(DIRECTORY)/include/GL/glxew.h \
|
||||
$(DIRECTORY)/include/GL/wglew.h \
|
||||
$(DIRECTORY)/src/glew/*.c \
|
||||
$(DIRECTORY)/src/glew/Makefile \
|
||||
$(DIRECTORY)/src/glew/SConscript \
|
||||
$(DIRECTORY)/src/glew/LICENSE.txt
|
||||
|
||||
DEMO_FILES = \
|
||||
$(GLEW_FILES) \
|
||||
$(DIRECTORY)/progs/beos/*.cpp \
|
||||
$(DIRECTORY)/progs/beos/Makefile \
|
||||
$(DIRECTORY)/progs/images/*.rgb \
|
||||
|
|
@ -415,6 +427,7 @@ DEMO_FILES = \
|
|||
$(DIRECTORY)/progs/glsl/*.c \
|
||||
$(DIRECTORY)/progs/glsl/*.frag \
|
||||
$(DIRECTORY)/progs/glsl/*.vert \
|
||||
$(DIRECTORY)/progs/glsl/*.shtest \
|
||||
$(DIRECTORY)/progs/windml/Makefile.ugl \
|
||||
$(DIRECTORY)/progs/windml/*.c \
|
||||
$(DIRECTORY)/progs/windml/*.bmp \
|
||||
|
|
|
|||
|
|
@ -971,5 +971,6 @@ esac
|
|||
#
|
||||
if [ ${INSTALLDIR} != "." ] ; then
|
||||
echo "mklib: Installing" ${FINAL_LIBS} "in" ${INSTALLDIR}
|
||||
test -d ${INSTALLDIR} || mkdir -p ${INSTALLDIR}
|
||||
mv ${FINAL_LIBS} ${INSTALLDIR}/
|
||||
fi
|
||||
|
|
|
|||
15
configure.ac
15
configure.ac
|
|
@ -1159,6 +1159,21 @@ AC_ARG_WITH([xorg-driver-dir],
|
|||
[XORG_DRIVER_INSTALL_DIR="${libdir}/xorg/modules/drivers"])
|
||||
AC_SUBST([XORG_DRIVER_INSTALL_DIR])
|
||||
|
||||
AC_ARG_WITH([max-width],
|
||||
[AS_HELP_STRING([--with-max-width=N],
|
||||
[Maximum framebuffer width (4096)])],
|
||||
[DEFINES="${DEFINES} -DMAX_WIDTH=${withval}";
|
||||
AS_IF([test "${withval}" -gt "4096"],
|
||||
[AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
|
||||
)
|
||||
AC_ARG_WITH([max-height],
|
||||
[AS_HELP_STRING([--with-max-height=N],
|
||||
[Maximum framebuffer height (4096)])],
|
||||
[DEFINES="${DEFINES} -DMAX_HEIGHT=${withval}";
|
||||
AS_IF([test "${withval}" -gt "4096"],
|
||||
[AC_MSG_WARN([Large framebuffer: see s_tritemp.h comments.])])]
|
||||
)
|
||||
|
||||
dnl
|
||||
dnl Gallium Intel configuration
|
||||
dnl
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ few preprocessor defines.</p>
|
|||
<ul>
|
||||
<li>If <tt>GLX_USE_TLS</tt> is defined, method #4 is used.</li>
|
||||
<li>If <tt>PTHREADS</tt> is defined, method #3 is used.</li>
|
||||
<li>If any of <tt>PTHREADS</tt>, <tt>USE_XTHREADS</tt>,
|
||||
<li>If any of <tt>PTHREADS</tt>,
|
||||
<tt>SOLARIS_THREADS</tt>, <tt>WIN32_THREADS</tt>, or <tt>BEOS_THREADS</tt>
|
||||
is defined, method #2 is used.</li>
|
||||
<li>If none of the preceeding are defined, method #1 is used.</li>
|
||||
|
|
|
|||
|
|
@ -316,6 +316,19 @@ Basically, applying a translation of (0.375, 0.375, 0.0) to your coordinates
|
|||
will fix the problem.
|
||||
</p>
|
||||
|
||||
<h2>3.6 How can I change the maximum framebuffer size in Mesa's
|
||||
<tt>swrast</tt> backend?</h2>
|
||||
<p>
|
||||
These can be overridden by using the <tt>--with-max-width</tt> and
|
||||
<tt>--with-max-height</tt> options. The two need not be equal.
|
||||
</p><p>
|
||||
Do note that Mesa uses these values to size some internal buffers,
|
||||
so increasing these sizes will cause Mesa to require additional
|
||||
memory. Furthermore, increasing these limits beyond <tt>4096</tt>
|
||||
may introduce rasterization artifacts; see the leading comments in
|
||||
<tt>src/mesa/swrast/s_tritemp.h</tt>.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
|
|
|
|||
61
docs/relnotes-7.5.1.html
Normal file
61
docs/relnotes-7.5.1.html
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<HTML>
|
||||
|
||||
<TITLE>Mesa Release Notes</TITLE>
|
||||
|
||||
<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
|
||||
|
||||
<BODY>
|
||||
|
||||
<body bgcolor="#eeeeee">
|
||||
|
||||
<H1>Mesa 7.5.1 Release Notes / (date TBD)</H1>
|
||||
|
||||
<p>
|
||||
Mesa 7.5.1 is a bug-fix release fixing issues found since the 7.5 release.
|
||||
</p>
|
||||
<p>
|
||||
The main new feature of Mesa 7.5.x is the
|
||||
<a href="http://wiki.freedesktop.org/wiki/Software/gallium"
|
||||
target="_parent">Gallium3D</a> infrastructure.
|
||||
</p>
|
||||
<p>
|
||||
Mesa 7.5.1 implements the OpenGL 2.1 API, but the version reported by
|
||||
glGetString(GL_VERSION) depends on the particular driver being used.
|
||||
Some drivers don't support all the features required in OpenGL 2.1.
|
||||
</p>
|
||||
<p>
|
||||
See the <a href="install.html">Compiling/Installing page</a> for prerequisites
|
||||
for DRI hardware acceleration.
|
||||
</p>
|
||||
|
||||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
tbd
|
||||
</pre>
|
||||
|
||||
|
||||
<h2>New features</h2>
|
||||
<ul>
|
||||
<li>Added configure --with-max-width=W, --with-max-height=H options to specify
|
||||
max framebuffer, viewport size.
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Bug fixes</h2>
|
||||
<ul>
|
||||
<li>Added missing GLEW library to MesaDemos tarballs.
|
||||
<li>Fixed swapbuffers jerkiness in Doom3/etc in Intel drivers.
|
||||
<li>Fixed front buffer rendering bug in Intel drivers.
|
||||
<li>Fixed minor GLX memory leaks.
|
||||
<li>Fixed some texture env / fragment program state bugs.
|
||||
<li>Fixed some Gallium glBlitFramebuffer() bugs
|
||||
</ul>
|
||||
|
||||
|
||||
<h2>Changes</h2>
|
||||
<ul>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -40,7 +40,15 @@ If you're especially concerned with stability you should probably look for
|
|||
|
||||
<h2>MD5 checksums</h2>
|
||||
<pre>
|
||||
tbd
|
||||
553fd956e544727f30fbe249619b6286 MesaLib-7.5.tar.gz
|
||||
459f332551f6ebb86f384d21dd15e1f0 MesaLib-7.5.tar.bz2
|
||||
8c02c0e17a9025250d20424ae32f5163 MesaLib-7.5.zip
|
||||
a188da2886fa5496ea0c2cda602b2eeb MesaDemos-7.5.tar.gz
|
||||
398ee8801814a00e47f6c2314e3dfddc MesaDemos-7.5.tar.bz2
|
||||
15a0c8ae013c54335a26335e1a98d609 MesaDemos-7.5.zip
|
||||
81010147def5a644ba14f9bbb7a49a2a MesaGLUT-7.5.tar.gz
|
||||
baa7a1e850b6e39bae58868fd0684004 MesaGLUT-7.5.tar.bz2
|
||||
265228418e4423fa328f2f5b7970cf08 MesaGLUT-7.5.zip
|
||||
</pre>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -46,6 +46,10 @@ This was written by Zack Rusin at Tungsten Graphics.
|
|||
<li>radeon/r200/r300 GL_EXT_framebuffer_object support when used with
|
||||
kernel memory manager
|
||||
<li>r300 driver support for GL_EXT_vertex_array_bgra, GL_EXT_texture_sRGB
|
||||
<li>i915/945 driver support for GL_ARB_point_sprite, GL_EXT_stencil_two_side
|
||||
and GL_ATI_separate_stencil extensions
|
||||
<li>Added configure --with-max-width=W, --with-max-height=H options to specify
|
||||
max framebuffer, viewport size.
|
||||
</ul>
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ The release notes summarize what's new or changed in each Mesa release.
|
|||
|
||||
<UL>
|
||||
<LI><A HREF="relnotes-7.6.html">7.6 release notes</A>
|
||||
<LI><A HREF="relnotes-7.5.1.html">7.5.1 release notes</A>
|
||||
<LI><A HREF="relnotes-7.5.html">7.5 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.4.html">7.4.4 release notes</A>
|
||||
<LI><A HREF="relnotes-7.4.3.html">7.4.3 release notes</A>
|
||||
|
|
|
|||
|
|
@ -29,9 +29,9 @@ extern "C" {
|
|||
*/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glext.h last updated $Date: 2009-05-05 15:27:42 -0700 (Tue, 05 May 2009) $ */
|
||||
/* glext.h last updated $Date: 2009-08-03 02:13:51 -0700 (Mon, 03 Aug 2009) $ */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GL_GLEXT_VERSION 52
|
||||
#define GL_GLEXT_VERSION 54
|
||||
|
||||
/* Function declaration macros - to move into glplatform.h */
|
||||
|
||||
|
|
@ -510,6 +510,8 @@ extern "C" {
|
|||
#define GL_CLIP_DISTANCE3 0x3003
|
||||
#define GL_CLIP_DISTANCE4 0x3004
|
||||
#define GL_CLIP_DISTANCE5 0x3005
|
||||
#define GL_CLIP_DISTANCE6 0x3006
|
||||
#define GL_CLIP_DISTANCE7 0x3007
|
||||
#define GL_MAX_CLIP_DISTANCES 0x0D32
|
||||
#define GL_MAJOR_VERSION 0x821B
|
||||
#define GL_MINOR_VERSION 0x821C
|
||||
|
|
@ -600,6 +602,9 @@ extern "C" {
|
|||
#define GL_QUERY_NO_WAIT 0x8E14
|
||||
#define GL_QUERY_BY_REGION_WAIT 0x8E15
|
||||
#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
|
||||
#define GL_BUFFER_ACCESS_FLAGS 0x911F
|
||||
#define GL_BUFFER_MAP_LENGTH 0x9120
|
||||
#define GL_BUFFER_MAP_OFFSET 0x9121
|
||||
/* Reuse tokens from ARB_depth_buffer_float */
|
||||
/* reuse GL_DEPTH_COMPONENT32F */
|
||||
/* reuse GL_DEPTH32F_STENCIL8 */
|
||||
|
|
@ -804,6 +809,84 @@ extern "C" {
|
|||
/* reuse GL_INVALID_INDEX */
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_3_2
|
||||
#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001
|
||||
#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||
#define GL_LINES_ADJACENCY 0x000A
|
||||
#define GL_LINE_STRIP_ADJACENCY 0x000B
|
||||
#define GL_TRIANGLES_ADJACENCY 0x000C
|
||||
#define GL_TRIANGLE_STRIP_ADJACENCY 0x000D
|
||||
#define GL_PROGRAM_POINT_SIZE 0x8642
|
||||
#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS 0x8C29
|
||||
#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED 0x8DA7
|
||||
#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS 0x8DA8
|
||||
#define GL_GEOMETRY_SHADER 0x8DD9
|
||||
#define GL_GEOMETRY_VERTICES_OUT 0x8916
|
||||
#define GL_GEOMETRY_INPUT_TYPE 0x8917
|
||||
#define GL_GEOMETRY_OUTPUT_TYPE 0x8918
|
||||
#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS 0x8DDF
|
||||
#define GL_MAX_GEOMETRY_OUTPUT_VERTICES 0x8DE0
|
||||
#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS 0x8DE1
|
||||
#define GL_MAX_VERTEX_OUTPUT_COMPONENTS 0x9122
|
||||
#define GL_MAX_GEOMETRY_INPUT_COMPONENTS 0x9123
|
||||
#define GL_MAX_GEOMETRY_OUTPUT_COMPONENTS 0x9124
|
||||
#define GL_MAX_FRAGMENT_INPUT_COMPONENTS 0x9125
|
||||
#define GL_CONTEXT_PROFILE_MASK 0x9126
|
||||
/* reuse GL_MAX_VARYING_COMPONENTS */
|
||||
/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
|
||||
/* Reuse tokens from ARB_depth_clamp */
|
||||
/* reuse GL_DEPTH_CLAMP */
|
||||
/* Would reuse tokens from ARB_draw_elements_base_vertex, but it has none */
|
||||
/* Would reuse tokens from ARB_fragment_coord_conventions, but it has none */
|
||||
/* Reuse tokens from ARB_provoking_vertex */
|
||||
/* reuse GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION */
|
||||
/* reuse GL_FIRST_VERTEX_CONVENTION */
|
||||
/* reuse GL_LAST_VERTEX_CONVENTION */
|
||||
/* reuse GL_PROVOKING_VERTEX */
|
||||
/* Reuse tokens from ARB_seamless_cube_map */
|
||||
/* reuse GL_TEXTURE_CUBE_MAP_SEAMLESS */
|
||||
/* Reuse tokens from ARB_sync */
|
||||
/* reuse GL_MAX_SERVER_WAIT_TIMEOUT */
|
||||
/* reuse GL_OBJECT_TYPE */
|
||||
/* reuse GL_SYNC_CONDITION */
|
||||
/* reuse GL_SYNC_STATUS */
|
||||
/* reuse GL_SYNC_FLAGS */
|
||||
/* reuse GL_SYNC_FENCE */
|
||||
/* reuse GL_SYNC_GPU_COMMANDS_COMPLETE */
|
||||
/* reuse GL_UNSIGNALED */
|
||||
/* reuse GL_SIGNALED */
|
||||
/* reuse GL_ALREADY_SIGNALED */
|
||||
/* reuse GL_TIMEOUT_EXPIRED */
|
||||
/* reuse GL_CONDITION_SATISFIED */
|
||||
/* reuse GL_WAIT_FAILED */
|
||||
/* reuse GL_TIMEOUT_IGNORED */
|
||||
/* reuse GL_SYNC_FLUSH_COMMANDS_BIT */
|
||||
/* reuse GL_TIMEOUT_IGNORED */
|
||||
/* Reuse tokens from ARB_texture_multisample */
|
||||
/* reuse GL_SAMPLE_POSITION */
|
||||
/* reuse GL_SAMPLE_MASK */
|
||||
/* reuse GL_SAMPLE_MASK_VALUE */
|
||||
/* reuse GL_MAX_SAMPLE_MASK_WORDS */
|
||||
/* reuse GL_TEXTURE_2D_MULTISAMPLE */
|
||||
/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE */
|
||||
/* reuse GL_TEXTURE_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE */
|
||||
/* reuse GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_TEXTURE_SAMPLES */
|
||||
/* reuse GL_TEXTURE_FIXED_SAMPLE_LOCATIONS */
|
||||
/* reuse GL_SAMPLER_2D_MULTISAMPLE */
|
||||
/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE */
|
||||
/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE */
|
||||
/* reuse GL_SAMPLER_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY */
|
||||
/* reuse GL_MAX_COLOR_TEXTURE_SAMPLES */
|
||||
/* reuse GL_MAX_DEPTH_TEXTURE_SAMPLES */
|
||||
/* reuse GL_MAX_INTEGER_SAMPLES */
|
||||
/* Don't need to reuse tokens from ARB_vertex_array_bgra since they're already in 1.2 core */
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_multitexture
|
||||
#define GL_TEXTURE0_ARB 0x84C0
|
||||
#define GL_TEXTURE1_ARB 0x84C1
|
||||
|
|
@ -1530,6 +1613,100 @@ extern "C" {
|
|||
#ifndef GL_ARB_shader_texture_lod
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_depth_clamp
|
||||
#define GL_DEPTH_CLAMP 0x864F
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_draw_elements_base_vertex
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_fragment_coord_conventions
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_provoking_vertex
|
||||
#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION 0x8E4C
|
||||
#define GL_FIRST_VERTEX_CONVENTION 0x8E4D
|
||||
#define GL_LAST_VERTEX_CONVENTION 0x8E4E
|
||||
#define GL_PROVOKING_VERTEX 0x8E4F
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_seamless_cube_map
|
||||
#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_sync
|
||||
#define GL_MAX_SERVER_WAIT_TIMEOUT 0x9111
|
||||
#define GL_OBJECT_TYPE 0x9112
|
||||
#define GL_SYNC_CONDITION 0x9113
|
||||
#define GL_SYNC_STATUS 0x9114
|
||||
#define GL_SYNC_FLAGS 0x9115
|
||||
#define GL_SYNC_FENCE 0x9116
|
||||
#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117
|
||||
#define GL_UNSIGNALED 0x9118
|
||||
#define GL_SIGNALED 0x9119
|
||||
#define GL_ALREADY_SIGNALED 0x911A
|
||||
#define GL_TIMEOUT_EXPIRED 0x911B
|
||||
#define GL_CONDITION_SATISFIED 0x911C
|
||||
#define GL_WAIT_FAILED 0x911D
|
||||
#define GL_SYNC_FLUSH_COMMANDS_BIT 0x00000001
|
||||
#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_multisample
|
||||
#define GL_SAMPLE_POSITION 0x8E50
|
||||
#define GL_SAMPLE_MASK 0x8E51
|
||||
#define GL_SAMPLE_MASK_VALUE 0x8E52
|
||||
#define GL_MAX_SAMPLE_MASK_WORDS 0x8E59
|
||||
#define GL_TEXTURE_2D_MULTISAMPLE 0x9100
|
||||
#define GL_PROXY_TEXTURE_2D_MULTISAMPLE 0x9101
|
||||
#define GL_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9102
|
||||
#define GL_PROXY_TEXTURE_2D_MULTISAMPLE_ARRAY 0x9103
|
||||
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE 0x9104
|
||||
#define GL_TEXTURE_BINDING_2D_MULTISAMPLE_ARRAY 0x9105
|
||||
#define GL_TEXTURE_SAMPLES 0x9106
|
||||
#define GL_TEXTURE_FIXED_SAMPLE_LOCATIONS 0x9107
|
||||
#define GL_SAMPLER_2D_MULTISAMPLE 0x9108
|
||||
#define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
|
||||
#define GL_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910B
|
||||
#define GL_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910C
|
||||
#define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE_ARRAY 0x910D
|
||||
#define GL_MAX_COLOR_TEXTURE_SAMPLES 0x910E
|
||||
#define GL_MAX_DEPTH_TEXTURE_SAMPLES 0x910F
|
||||
#define GL_MAX_INTEGER_SAMPLES 0x9110
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_vertex_array_bgra
|
||||
/* reuse GL_BGRA */
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_draw_buffers_blend
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_sample_shading
|
||||
#define GL_SAMPLE_SHADING 0x8C36
|
||||
#define GL_MIN_SAMPLE_SHADING_VALUE 0x8C37
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_cube_map_array
|
||||
#define GL_TEXTURE_CUBE_MAP_ARRAY 0x9009
|
||||
#define GL_TEXTURE_BINDING_CUBE_MAP_ARRAY 0x900A
|
||||
#define GL_PROXY_TEXTURE_CUBE_MAP_ARRAY 0x900B
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY 0x900C
|
||||
#define GL_SAMPLER_CUBE_MAP_ARRAY_SHADOW 0x900D
|
||||
#define GL_INT_SAMPLER_CUBE_MAP_ARRAY 0x900E
|
||||
#define GL_UNSIGNED_INT_SAMPLER_CUBE_MAP_ARRAY 0x900F
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_gather
|
||||
#define GL_MIN_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5E
|
||||
#define GL_MAX_PROGRAM_TEXTURE_GATHER_OFFSET 0x8E5F
|
||||
#define GL_MAX_PROGRAM_TEXTURE_GATHER_COMPONENTS 0x8F9F
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_query_lod
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_abgr
|
||||
#define GL_ABGR_EXT 0x8000
|
||||
#endif
|
||||
|
|
@ -3996,11 +4173,11 @@ extern "C" {
|
|||
#define GL_SAMPLE_MASK_VALUE_NV 0x8E52
|
||||
#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53
|
||||
#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54
|
||||
#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59
|
||||
#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55
|
||||
#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56
|
||||
#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57
|
||||
#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58
|
||||
#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59
|
||||
#endif
|
||||
|
||||
#ifndef GL_NV_transform_feedback2
|
||||
|
|
@ -4046,6 +4223,94 @@ extern "C" {
|
|||
#define GL_PROVOKING_VERTEX_EXT 0x8E4F
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_texture_snorm
|
||||
#define GL_ALPHA_SNORM 0x9010
|
||||
#define GL_LUMINANCE_SNORM 0x9011
|
||||
#define GL_LUMINANCE_ALPHA_SNORM 0x9012
|
||||
#define GL_INTENSITY_SNORM 0x9013
|
||||
#define GL_ALPHA8_SNORM 0x9014
|
||||
#define GL_LUMINANCE8_SNORM 0x9015
|
||||
#define GL_LUMINANCE8_ALPHA8_SNORM 0x9016
|
||||
#define GL_INTENSITY8_SNORM 0x9017
|
||||
#define GL_ALPHA16_SNORM 0x9018
|
||||
#define GL_LUMINANCE16_SNORM 0x9019
|
||||
#define GL_LUMINANCE16_ALPHA16_SNORM 0x901A
|
||||
#define GL_INTENSITY16_SNORM 0x901B
|
||||
/* reuse GL_R_SNORM */
|
||||
/* reuse GL_RG_SNORM */
|
||||
/* reuse GL_RGB_SNORM */
|
||||
/* reuse GL_RGBA_SNORM */
|
||||
/* reuse GL_R8_SNORM */
|
||||
/* reuse GL_RG8_SNORM */
|
||||
/* reuse GL_RGB8_SNORM */
|
||||
/* reuse GL_RGBA8_SNORM */
|
||||
/* reuse GL_R16_SNORM */
|
||||
/* reuse GL_RG16_SNORM */
|
||||
/* reuse GL_RGB16_SNORM */
|
||||
/* reuse GL_RGBA16_SNORM */
|
||||
/* reuse GL_SIGNED_NORMALIZED */
|
||||
#endif
|
||||
|
||||
#ifndef GL_AMD_draw_buffers_blend
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_texture_range
|
||||
#define GL_TEXTURE_RANGE_LENGTH_APPLE 0x85B7
|
||||
#define GL_TEXTURE_RANGE_POINTER_APPLE 0x85B8
|
||||
#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC
|
||||
#define GL_STORAGE_PRIVATE_APPLE 0x85BD
|
||||
/* reuse GL_STORAGE_CACHED_APPLE */
|
||||
/* reuse GL_STORAGE_SHARED_APPLE */
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_float_pixels
|
||||
#define GL_HALF_APPLE 0x140B
|
||||
#define GL_RGBA_FLOAT32_APPLE 0x8814
|
||||
#define GL_RGB_FLOAT32_APPLE 0x8815
|
||||
#define GL_ALPHA_FLOAT32_APPLE 0x8816
|
||||
#define GL_INTENSITY_FLOAT32_APPLE 0x8817
|
||||
#define GL_LUMINANCE_FLOAT32_APPLE 0x8818
|
||||
#define GL_LUMINANCE_ALPHA_FLOAT32_APPLE 0x8819
|
||||
#define GL_RGBA_FLOAT16_APPLE 0x881A
|
||||
#define GL_RGB_FLOAT16_APPLE 0x881B
|
||||
#define GL_ALPHA_FLOAT16_APPLE 0x881C
|
||||
#define GL_INTENSITY_FLOAT16_APPLE 0x881D
|
||||
#define GL_LUMINANCE_FLOAT16_APPLE 0x881E
|
||||
#define GL_LUMINANCE_ALPHA_FLOAT16_APPLE 0x881F
|
||||
#define GL_COLOR_FLOAT_APPLE 0x8A0F
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_vertex_program_evaluators
|
||||
#define GL_VERTEX_ATTRIB_MAP1_APPLE 0x8A00
|
||||
#define GL_VERTEX_ATTRIB_MAP2_APPLE 0x8A01
|
||||
#define GL_VERTEX_ATTRIB_MAP1_SIZE_APPLE 0x8A02
|
||||
#define GL_VERTEX_ATTRIB_MAP1_COEFF_APPLE 0x8A03
|
||||
#define GL_VERTEX_ATTRIB_MAP1_ORDER_APPLE 0x8A04
|
||||
#define GL_VERTEX_ATTRIB_MAP1_DOMAIN_APPLE 0x8A05
|
||||
#define GL_VERTEX_ATTRIB_MAP2_SIZE_APPLE 0x8A06
|
||||
#define GL_VERTEX_ATTRIB_MAP2_COEFF_APPLE 0x8A07
|
||||
#define GL_VERTEX_ATTRIB_MAP2_ORDER_APPLE 0x8A08
|
||||
#define GL_VERTEX_ATTRIB_MAP2_DOMAIN_APPLE 0x8A09
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_aux_depth_stencil
|
||||
#define GL_AUX_DEPTH_STENCIL_APPLE 0x8A14
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_object_purgeable
|
||||
#define GL_BUFFER_OBJECT_APPLE 0x85B3
|
||||
#define GL_RELEASED_APPLE 0x8A19
|
||||
#define GL_VOLATILE_APPLE 0x8A1A
|
||||
#define GL_RETAINED_APPLE 0x8A1B
|
||||
#define GL_UNDEFINED_APPLE 0x8A1C
|
||||
#define GL_PURGEABLE_APPLE 0x8A1D
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_row_bytes
|
||||
#define GL_PACK_ROW_BYTES_APPLE 0x8A15
|
||||
#define GL_UNPACK_ROW_BYTES_APPLE 0x8A16
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************/
|
||||
|
||||
|
|
@ -4125,6 +4390,12 @@ typedef int64_t GLint64EXT;
|
|||
typedef uint64_t GLuint64EXT;
|
||||
#endif
|
||||
|
||||
#ifndef ARB_sync
|
||||
typedef int64_t GLint64;
|
||||
typedef uint64_t GLuint64;
|
||||
typedef struct __GLsync *GLsync;
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_1_2
|
||||
#define GL_VERSION_1_2 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
|
|
@ -4698,6 +4969,26 @@ GLAPI void APIENTRY glEndConditionalRender (void);
|
|||
GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
|
||||
GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *);
|
||||
GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *);
|
||||
GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *);
|
||||
GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *);
|
||||
GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *);
|
||||
GLAPI void APIENTRY glGetUniformuiv (GLuint, GLint, GLuint *);
|
||||
GLAPI void APIENTRY glBindFragDataLocation (GLuint, GLuint, const GLchar *);
|
||||
GLAPI GLint APIENTRY glGetFragDataLocation (GLuint, const GLchar *);
|
||||
|
|
@ -4737,6 +5028,26 @@ typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
|
|||
typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
|
||||
typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
|
||||
typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);
|
||||
typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);
|
||||
typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);
|
||||
|
|
@ -4759,52 +5070,6 @@ typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer
|
|||
typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_3_0_DEPRECATED
|
||||
#define GL_VERSION_3_0_DEPRECATED 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint);
|
||||
GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *);
|
||||
GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *);
|
||||
GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *);
|
||||
GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *);
|
||||
GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *);
|
||||
GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
|
||||
typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_3_1
|
||||
#define GL_VERSION_3_1 1
|
||||
/* OpenGL 3.1 also reuses entry points from these extensions: */
|
||||
|
|
@ -4822,6 +5087,27 @@ typedef void (APIENTRYP PFNGLTEXBUFFERPROC) (GLenum target, GLenum internalforma
|
|||
typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXPROC) (GLuint index);
|
||||
#endif
|
||||
|
||||
#ifndef GL_VERSION_3_2
|
||||
#define GL_VERSION_3_2 1
|
||||
/* OpenGL 3.2 also reuses entry points from these extensions: */
|
||||
/* ARB_draw_elements_base_vertex */
|
||||
/* ARB_provoking_vertex */
|
||||
/* ARB_sync */
|
||||
/* ARB_texture_multisample */
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glGetInteger64i_v (GLenum, GLuint, GLint64 *);
|
||||
GLAPI void APIENTRY glGetBufferParameteri64v (GLenum, GLenum, GLint64 *);
|
||||
GLAPI void APIENTRY glProgramParameteri (GLuint, GLenum, GLint);
|
||||
GLAPI void APIENTRY glFramebufferTexture (GLenum, GLenum, GLuint, GLint);
|
||||
GLAPI void APIENTRY glFramebufferTextureFace (GLenum, GLenum, GLuint, GLint, GLenum);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLGETINTEGER64I_VPROC) (GLenum target, GLuint index, GLint64 *data);
|
||||
typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERI64VPROC) (GLenum target, GLenum pname, GLint64 *params);
|
||||
typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIPROC) (GLuint program, GLenum pname, GLint value);
|
||||
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
|
||||
typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_multitexture
|
||||
#define GL_ARB_multitexture 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
|
|
@ -5567,6 +5853,112 @@ typedef void (APIENTRYP PFNGLCOPYBUFFERSUBDATAPROC) (GLenum readTarget, GLenum w
|
|||
#define GL_ARB_shader_texture_lod 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_depth_clamp
|
||||
#define GL_ARB_depth_clamp 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_draw_elements_base_vertex
|
||||
#define GL_ARB_draw_elements_base_vertex 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glDrawElementsBaseVertex (GLenum, GLsizei, GLenum, const GLvoid *, GLint);
|
||||
GLAPI void APIENTRY glDrawRangeElementsBaseVertex (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *, GLint);
|
||||
GLAPI void APIENTRY glDrawElementsInstancedBaseVertex (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei, GLint);
|
||||
GLAPI void APIENTRY glMultiDrawElementsBaseVertex (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei, const GLint *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
|
||||
typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSBASEVERTEXPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex);
|
||||
typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDBASEVERTEXPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount, GLint basevertex);
|
||||
typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSBASEVERTEXPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount, const GLint *basevertex);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_fragment_coord_conventions
|
||||
#define GL_ARB_fragment_coord_conventions 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_provoking_vertex
|
||||
#define GL_ARB_provoking_vertex 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glProvokingVertex (GLenum);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLPROVOKINGVERTEXPROC) (GLenum mode);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_seamless_cube_map
|
||||
#define GL_ARB_seamless_cube_map 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_sync
|
||||
#define GL_ARB_sync 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI GLsync APIENTRY glFenceSync (GLenum, GLbitfield);
|
||||
GLAPI GLboolean APIENTRY glIsSync (GLsync);
|
||||
GLAPI void APIENTRY glDeleteSync (GLsync);
|
||||
GLAPI GLenum APIENTRY glClientWaitSync (GLsync, GLbitfield, GLuint64);
|
||||
GLAPI void APIENTRY glWaitSync (GLsync, GLbitfield, GLuint64);
|
||||
GLAPI void APIENTRY glGetInteger64v (GLenum, GLint64 *);
|
||||
GLAPI void APIENTRY glGetSynciv (GLsync, GLenum, GLsizei, GLsizei *, GLint *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef GLsync (APIENTRYP PFNGLFENCESYNCPROC) (GLenum condition, GLbitfield flags);
|
||||
typedef GLboolean (APIENTRYP PFNGLISSYNCPROC) (GLsync sync);
|
||||
typedef void (APIENTRYP PFNGLDELETESYNCPROC) (GLsync sync);
|
||||
typedef GLenum (APIENTRYP PFNGLCLIENTWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (APIENTRYP PFNGLWAITSYNCPROC) (GLsync sync, GLbitfield flags, GLuint64 timeout);
|
||||
typedef void (APIENTRYP PFNGLGETINTEGER64VPROC) (GLenum pname, GLint64 *params);
|
||||
typedef void (APIENTRYP PFNGLGETSYNCIVPROC) (GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *values);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_multisample
|
||||
#define GL_ARB_texture_multisample 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glTexImage2DMultisample (GLenum, GLsizei, GLint, GLsizei, GLsizei, GLboolean);
|
||||
GLAPI void APIENTRY glTexImage3DMultisample (GLenum, GLsizei, GLint, GLsizei, GLsizei, GLsizei, GLboolean);
|
||||
GLAPI void APIENTRY glGetMultisamplefv (GLenum, GLuint, GLfloat *);
|
||||
GLAPI void APIENTRY glSampleMaski (GLuint, GLbitfield);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLTEXIMAGE2DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations);
|
||||
typedef void (APIENTRYP PFNGLTEXIMAGE3DMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations);
|
||||
typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVPROC) (GLenum pname, GLuint index, GLfloat *val);
|
||||
typedef void (APIENTRYP PFNGLSAMPLEMASKIPROC) (GLuint index, GLbitfield mask);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_vertex_array_bgra
|
||||
#define GL_ARB_vertex_array_bgra 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_draw_buffers_blend
|
||||
#define GL_ARB_draw_buffers_blend 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBlendEquationi (GLuint, GLenum);
|
||||
GLAPI void APIENTRY glBlendEquationSeparatei (GLuint, GLenum, GLenum);
|
||||
GLAPI void APIENTRY glBlendFunci (GLuint, GLenum, GLenum);
|
||||
GLAPI void APIENTRY glBlendFuncSeparatei (GLuint, GLenum, GLenum, GLenum, GLenum);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONIPROC) (GLuint buf, GLenum mode);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEIPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
|
||||
typedef void (APIENTRYP PFNGLBLENDFUNCIPROC) (GLuint buf, GLenum src, GLenum dst);
|
||||
typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEIPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_sample_shading
|
||||
#define GL_ARB_sample_shading 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glMinSampleShading (GLclampf);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLMINSAMPLESHADINGPROC) (GLclampf value);
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_cube_map_array
|
||||
#define GL_ARB_texture_cube_map_array 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_gather
|
||||
#define GL_ARB_texture_gather 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_ARB_texture_query_lod
|
||||
#define GL_ARB_texture_query_lod 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_abgr
|
||||
#define GL_EXT_abgr 1
|
||||
#endif
|
||||
|
|
@ -8204,7 +8596,7 @@ GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum)
|
|||
GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
|
||||
GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr);
|
||||
GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint);
|
||||
GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLint *, GLenum);
|
||||
GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLchar* *, GLenum);
|
||||
GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *);
|
||||
GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *);
|
||||
GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);
|
||||
|
|
@ -8216,7 +8608,7 @@ typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, cons
|
|||
typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
|
||||
typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
|
||||
typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);
|
||||
typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
|
||||
typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
|
||||
typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);
|
||||
typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);
|
||||
typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
|
||||
|
|
@ -8781,6 +9173,78 @@ GLAPI void APIENTRY glProvokingVertexEXT (GLenum);
|
|||
typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
|
||||
#endif
|
||||
|
||||
#ifndef GL_EXT_texture_snorm
|
||||
#define GL_EXT_texture_snorm 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_AMD_draw_buffers_blend
|
||||
#define GL_AMD_draw_buffers_blend 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glBlendFuncIndexedAMD (GLuint, GLenum, GLenum);
|
||||
GLAPI void APIENTRY glBlendFuncSeparateIndexedAMD (GLuint, GLenum, GLenum, GLenum, GLenum);
|
||||
GLAPI void APIENTRY glBlendEquationIndexedAMD (GLuint, GLenum);
|
||||
GLAPI void APIENTRY glBlendEquationSeparateIndexedAMD (GLuint, GLenum, GLenum);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLBLENDFUNCINDEXEDAMDPROC) (GLuint buf, GLenum src, GLenum dst);
|
||||
typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONINDEXEDAMDPROC) (GLuint buf, GLenum mode);
|
||||
typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEINDEXEDAMDPROC) (GLuint buf, GLenum modeRGB, GLenum modeAlpha);
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_texture_range
|
||||
#define GL_APPLE_texture_range 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glTextureRangeAPPLE (GLenum, GLsizei, const GLvoid *);
|
||||
GLAPI void APIENTRY glGetTexParameterPointervAPPLE (GLenum, GLenum, GLvoid* *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLTEXTURERANGEAPPLEPROC) (GLenum target, GLsizei length, const GLvoid *pointer);
|
||||
typedef void (APIENTRYP PFNGLGETTEXPARAMETERPOINTERVAPPLEPROC) (GLenum target, GLenum pname, GLvoid* *params);
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_float_pixels
|
||||
#define GL_APPLE_float_pixels 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_vertex_program_evaluators
|
||||
#define GL_APPLE_vertex_program_evaluators 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI void APIENTRY glEnableVertexAttribAPPLE (GLuint, GLenum);
|
||||
GLAPI void APIENTRY glDisableVertexAttribAPPLE (GLuint, GLenum);
|
||||
GLAPI GLboolean APIENTRY glIsVertexAttribEnabledAPPLE (GLuint, GLenum);
|
||||
GLAPI void APIENTRY glMapVertexAttrib1dAPPLE (GLuint, GLuint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
|
||||
GLAPI void APIENTRY glMapVertexAttrib1fAPPLE (GLuint, GLuint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
|
||||
GLAPI void APIENTRY glMapVertexAttrib2dAPPLE (GLuint, GLuint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
|
||||
GLAPI void APIENTRY glMapVertexAttrib2fAPPLE (GLuint, GLuint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
|
||||
typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBAPPLEPROC) (GLuint index, GLenum pname);
|
||||
typedef GLboolean (APIENTRYP PFNGLISVERTEXATTRIBENABLEDAPPLEPROC) (GLuint index, GLenum pname);
|
||||
typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint stride, GLint order, const GLdouble *points);
|
||||
typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB1FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint stride, GLint order, const GLfloat *points);
|
||||
typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2DAPPLEPROC) (GLuint index, GLuint size, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, const GLdouble *points);
|
||||
typedef void (APIENTRYP PFNGLMAPVERTEXATTRIB2FAPPLEPROC) (GLuint index, GLuint size, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, const GLfloat *points);
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_aux_depth_stencil
|
||||
#define GL_APPLE_aux_depth_stencil 1
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_object_purgeable
|
||||
#define GL_APPLE_object_purgeable 1
|
||||
#ifdef GL_GLEXT_PROTOTYPES
|
||||
GLAPI GLenum APIENTRY glObjectPurgeableAPPLE (GLenum, GLuint, GLenum);
|
||||
GLAPI GLenum APIENTRY glObjectUnpurgeableAPPLE (GLenum, GLuint, GLenum);
|
||||
GLAPI void APIENTRY glGetObjectParameterivAPPLE (GLenum, GLuint, GLenum, GLint *);
|
||||
#endif /* GL_GLEXT_PROTOTYPES */
|
||||
typedef GLenum (APIENTRYP PFNGLOBJECTPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
|
||||
typedef GLenum (APIENTRYP PFNGLOBJECTUNPURGEABLEAPPLEPROC) (GLenum objectType, GLuint name, GLenum option);
|
||||
typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVAPPLEPROC) (GLenum objectType, GLuint name, GLenum pname, GLint *params);
|
||||
#endif
|
||||
|
||||
#ifndef GL_APPLE_row_bytes
|
||||
#define GL_APPLE_row_bytes 1
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
/*
|
||||
** Copyright (c) 2007 The Khronos Group Inc.
|
||||
** Copyright (c) 2007-2009 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
|
|
@ -28,6 +28,8 @@ extern "C" {
|
|||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Function declaration macros - to move into glplatform.h */
|
||||
|
||||
#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#include <windows.h>
|
||||
|
|
@ -46,9 +48,9 @@ extern "C" {
|
|||
/*************************************************************/
|
||||
|
||||
/* Header file version number, required by OpenGL ABI for Linux */
|
||||
/* glxext.h last updated 2008/10/22 */
|
||||
/* glxext.h last updated 2009/08/03 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define GLX_GLXEXT_VERSION 21
|
||||
#define GLX_GLXEXT_VERSION 23
|
||||
|
||||
#ifndef GLX_VERSION_1_3
|
||||
#define GLX_WINDOW_BIT 0x00000001
|
||||
|
|
@ -135,6 +137,12 @@ extern "C" {
|
|||
#define GLX_CONTEXT_FLAGS_ARB 0x2094
|
||||
#endif
|
||||
|
||||
#ifndef GLX_ARB_create_context_profile
|
||||
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#endif
|
||||
|
||||
#ifndef GLX_SGIS_multisample
|
||||
#define GLX_SAMPLE_BUFFERS_SGIS 100000
|
||||
#define GLX_SAMPLES_SGIS 100001
|
||||
|
|
@ -518,6 +526,10 @@ extern GLXContext glXCreateContextAttribsARB (Display *, GLXFBConfig, GLXContext
|
|||
typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display *dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
|
||||
#endif
|
||||
|
||||
#ifndef GLX_ARB_create_context_profile
|
||||
#define GLX_ARB_create_context_profile 1
|
||||
#endif
|
||||
|
||||
#ifndef GLX_SGIS_multisample
|
||||
#define GLX_SGIS_multisample 1
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ extern "C" {
|
|||
/*************************************************************/
|
||||
|
||||
/* Header file version number */
|
||||
/* wglext.h last updated 2009/03/03 */
|
||||
/* wglext.h last updated 2009/08/03 */
|
||||
/* Current version at http://www.opengl.org/registry/ */
|
||||
#define WGL_WGLEXT_VERSION 12
|
||||
#define WGL_WGLEXT_VERSION 15
|
||||
|
||||
#ifndef WGL_ARB_buffer_region
|
||||
#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001
|
||||
|
|
@ -176,8 +176,8 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
|
||||
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
|
||||
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
|
||||
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
|
||||
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
|
||||
|
|
@ -185,6 +185,13 @@ extern "C" {
|
|||
#define ERROR_INVALID_VERSION_ARB 0x2095
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
|
||||
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
|
||||
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
|
||||
#define ERROR_INVALID_PROFILE_ARB 0x2096
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_make_current_read
|
||||
#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043
|
||||
#endif
|
||||
|
|
@ -497,6 +504,10 @@ extern HGLRC WINAPI wglCreateContextAttribsARB (HDC, HGLRC, const int *);
|
|||
typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int *attribList);
|
||||
#endif
|
||||
|
||||
#ifndef WGL_ARB_create_context_profile
|
||||
#define WGL_ARB_create_context_profile 1
|
||||
#endif
|
||||
|
||||
#ifndef WGL_EXT_display_color_table
|
||||
#define WGL_EXT_display_color_table 1
|
||||
#ifdef WGL_WGLEXT_PROTOTYPES
|
||||
|
|
|
|||
|
|
@ -43,6 +43,9 @@
|
|||
#include "GL/glut.h"
|
||||
#include "readtex.h"
|
||||
|
||||
#ifndef GL_TEXTURE_CUBE_MAP_SEAMLESS
|
||||
#define GL_TEXTURE_CUBE_MAP_SEAMLESS 0x884F
|
||||
#endif
|
||||
|
||||
static GLfloat Xrot = 0, Yrot = 0;
|
||||
static GLfloat EyeDist = 10;
|
||||
|
|
@ -53,6 +56,8 @@ static GLint FrameParity = 0;
|
|||
static GLenum FilterIndex = 0;
|
||||
static GLint ClampIndex = 0;
|
||||
static GLboolean supportFBO = GL_FALSE;
|
||||
static GLboolean supportSeamless = GL_FALSE;
|
||||
static GLboolean seamless = GL_FALSE;
|
||||
|
||||
|
||||
static struct {
|
||||
|
|
@ -91,7 +96,9 @@ static struct {
|
|||
|
||||
|
||||
|
||||
#define eps1 0.99
|
||||
/* The effects of GL_ARB_seamless_cube_map don't show up unless eps1 is 1.0.
|
||||
*/
|
||||
#define eps1 1.0 /*0.99*/
|
||||
#define br 20.0 /* box radius */
|
||||
|
||||
static const GLfloat tex_coords[] = {
|
||||
|
|
@ -231,6 +238,13 @@ static void draw( void )
|
|||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER,
|
||||
FilterModes[FilterIndex].mag_mode);
|
||||
|
||||
if (supportSeamless) {
|
||||
if (seamless) {
|
||||
glEnable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||
} else {
|
||||
glDisable(GL_TEXTURE_CUBE_MAP_SEAMLESS);
|
||||
}
|
||||
}
|
||||
wrap = ClampModes[ClampIndex].mode;
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, wrap);
|
||||
glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, wrap);
|
||||
|
|
@ -321,6 +335,11 @@ static void key(unsigned char k, int x, int y)
|
|||
mode = !mode;
|
||||
set_mode(mode);
|
||||
break;
|
||||
case 's':
|
||||
seamless = ! seamless;
|
||||
printf("Seamless cube map filtering is %sabled\n",
|
||||
(seamless) ? "en" : "dis" );
|
||||
break;
|
||||
case 'v':
|
||||
use_vertex_arrays = ! use_vertex_arrays;
|
||||
printf( "Vertex arrays are %sabled\n",
|
||||
|
|
@ -502,23 +521,26 @@ static void load_envmaps(void)
|
|||
static void init( GLboolean useImageFiles )
|
||||
{
|
||||
/* check for extensions */
|
||||
{
|
||||
char *exten = (char *) glGetString(GL_EXTENSIONS);
|
||||
if (!strstr(exten, "GL_ARB_texture_cube_map")) {
|
||||
printf("Sorry, this demo requires GL_ARB_texture_cube_map\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Needed for glGenerateMipmapEXT / auto mipmapping
|
||||
*/
|
||||
if (strstr(exten, "GL_EXT_framebuffer_object")) {
|
||||
supportFBO = GL_TRUE;
|
||||
}
|
||||
else if (!strstr(exten, "GL_SGIS_generate_mipmap")) {
|
||||
printf("Sorry, this demo requires GL_EXT_framebuffer_object or GL_SGIS_generate_mipmap\n");
|
||||
exit(0);
|
||||
}
|
||||
if (!GLEW_ARB_texture_cube_map) {
|
||||
printf("Sorry, this demo requires GL_ARB_texture_cube_map\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* Needed for glGenerateMipmapEXT / auto mipmapping
|
||||
*/
|
||||
supportFBO = GLEW_EXT_framebuffer_object;
|
||||
|
||||
if (!supportFBO && !GLEW_SGIS_generate_mipmap) {
|
||||
printf("Sorry, this demo requires GL_EXT_framebuffer_object or "
|
||||
"GL_SGIS_generate_mipmap\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
/* GLEW doesn't know about this extension yet, so use the old GLUT function
|
||||
* to check for availability.
|
||||
*/
|
||||
supportSeamless = glutExtensionSupported("GL_ARB_seamless_cube_map");
|
||||
|
||||
printf("GL_RENDERER: %s\n", (char *) glGetString(GL_RENDERER));
|
||||
|
||||
if (useImageFiles) {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ PROGRAMS = \
|
|||
eglgears \
|
||||
eglscreen \
|
||||
peglgears \
|
||||
xeglbindtex \
|
||||
xeglgears \
|
||||
xeglthreads \
|
||||
xegl_tri
|
||||
|
|
@ -84,6 +85,12 @@ peglgears.o: peglgears.c $(HEADERS)
|
|||
$(CC) -c $(CFLAGS) -I$(TOP)/include peglgears.c
|
||||
|
||||
|
||||
xeglbindtex: xeglbindtex.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) xeglbindtex.o -L$(TOP)/$(LIB_DIR) -lEGL -lGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
xeglbindtex.o: xeglbindtex.c $(HEADERS)
|
||||
$(CC) -c $(CFLAGS) -I$(TOP)/include xeglbindtex.c
|
||||
|
||||
xeglgears: xeglgears.o $(TOP)/$(LIB_DIR)/libEGL.so
|
||||
$(CC) $(CFLAGS) xeglgears.o -L$(TOP)/$(LIB_DIR) -lEGL -lGL $(LIBDRM_LIB) $(APP_LIB_DEPS) -o $@
|
||||
|
||||
|
|
|
|||
474
progs/egl/xeglbindtex.c
Normal file
474
progs/egl/xeglbindtex.c
Normal file
|
|
@ -0,0 +1,474 @@
|
|||
/*
|
||||
* Simple demo for eglBindTexImage. Based on xegl_tri.c by
|
||||
*
|
||||
* Copyright (C) 2008 Brian Paul All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* The spec says that eglBindTexImage supports only OpenGL ES context, but this
|
||||
* demo uses OpenGL context. Keep in mind that this is non-standard.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GL/gl.h>
|
||||
#include <EGL/egl.h>
|
||||
|
||||
static EGLDisplay dpy;
|
||||
static EGLContext ctx_win, ctx_pbuf;
|
||||
static EGLSurface surf_win, surf_pbuf;
|
||||
static GLuint tex_pbuf;
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 0.0, view_rotz = 0.0;
|
||||
static GLboolean blend = GL_TRUE;
|
||||
static GLuint color_flow;
|
||||
|
||||
static void
|
||||
make_pbuffer(int width, int height)
|
||||
{
|
||||
static const EGLint config_attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_BIND_TO_TEXTURE_RGB, EGL_TRUE,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLint pbuf_attribs[] = {
|
||||
EGL_WIDTH, width,
|
||||
EGL_HEIGHT, height,
|
||||
EGL_TEXTURE_FORMAT, EGL_TEXTURE_RGB,
|
||||
EGL_TEXTURE_TARGET, EGL_TEXTURE_2D,
|
||||
EGL_NONE
|
||||
};
|
||||
EGLConfig config;
|
||||
EGLint num_configs;
|
||||
|
||||
if (!eglChooseConfig(dpy, config_attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config for pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx_pbuf = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
surf_pbuf = eglCreatePbufferSurface(dpy, config, pbuf_attribs);
|
||||
if (surf_pbuf == EGL_NO_SURFACE) {
|
||||
printf("failed to allocate pbuffer\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
glGenTextures(1, &tex_pbuf);
|
||||
}
|
||||
|
||||
static void
|
||||
use_pbuffer(void)
|
||||
{
|
||||
static int initialized;
|
||||
|
||||
eglMakeCurrent(dpy, surf_pbuf, surf_pbuf, ctx_pbuf);
|
||||
if (!initialized) {
|
||||
EGLint width, height;
|
||||
GLfloat ar;
|
||||
|
||||
initialized = 1;
|
||||
|
||||
eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &width);
|
||||
eglQuerySurface(dpy, surf_pbuf, EGL_WIDTH, &height);
|
||||
ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1, 1, 1.0, 10.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
/* y-inverted */
|
||||
glScalef(1.0, -1.0, 1.0);
|
||||
|
||||
glTranslatef(0.0, 0.0, -5.0);
|
||||
|
||||
glClearColor(0.2, 0.2, 0.2, 0.0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
make_window(Display *x_dpy, const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet)
|
||||
{
|
||||
static const EGLint attribs[] = {
|
||||
EGL_RED_SIZE, 8,
|
||||
EGL_GREEN_SIZE, 8,
|
||||
EGL_BLUE_SIZE, 8,
|
||||
EGL_ALPHA_SIZE, 8,
|
||||
EGL_DEPTH_SIZE, 8,
|
||||
EGL_NONE
|
||||
};
|
||||
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visInfo, visTemplate;
|
||||
int num_visuals;
|
||||
EGLConfig config;
|
||||
EGLint num_configs, vid;
|
||||
|
||||
scrnum = DefaultScreen( x_dpy );
|
||||
root = RootWindow( x_dpy, scrnum );
|
||||
|
||||
if (!eglChooseConfig(dpy, attribs, &config, 1, &num_configs)) {
|
||||
printf("Error: couldn't get an EGL visual config\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!eglGetConfigAttrib(dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
|
||||
printf("Error: eglGetConfigAttrib() failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* The X window visual must match the EGL config */
|
||||
visTemplate.visualid = vid;
|
||||
visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
|
||||
if (!visInfo) {
|
||||
printf("Error: couldn't get X visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( x_dpy, root, visInfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
attr.override_redirect = 0;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
|
||||
|
||||
win = XCreateWindow( x_dpy, root, 0, 0, width, height,
|
||||
0, visInfo->depth, InputOutput,
|
||||
visInfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(x_dpy, win, &sizehints);
|
||||
XSetStandardProperties(x_dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
ctx_win = eglCreateContext(dpy, config, EGL_NO_CONTEXT, NULL );
|
||||
if (!ctx_win) {
|
||||
printf("Error: glXCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
surf_win = eglCreateWindowSurface(dpy, config, win, NULL);
|
||||
|
||||
XFree(visInfo);
|
||||
|
||||
*winRet = win;
|
||||
}
|
||||
|
||||
static void
|
||||
use_window(void)
|
||||
{
|
||||
static int initialized;
|
||||
|
||||
eglMakeCurrent(dpy, surf_win, surf_win, ctx_win);
|
||||
if (!initialized) {
|
||||
initialized = 1;
|
||||
glEnable(GL_TEXTURE_2D);
|
||||
glBindTexture(GL_TEXTURE_2D, tex_pbuf);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
draw_triangle(void)
|
||||
{
|
||||
static const GLfloat verts[3][2] = {
|
||||
{ -3, -3 },
|
||||
{ 3, -3 },
|
||||
{ 0, 3 }
|
||||
};
|
||||
GLfloat colors[3][3] = {
|
||||
{ 1, 0, 0 },
|
||||
{ 0, 1, 0 },
|
||||
{ 0, 0, 1 }
|
||||
};
|
||||
GLint i;
|
||||
|
||||
/* flow the color */
|
||||
for (i = 0; i < 3; i++) {
|
||||
GLint first = (i + color_flow / 256) % 3;
|
||||
GLint second = (first + 1) % 3;
|
||||
GLint third = (second + 1) % 3;
|
||||
GLfloat c = (color_flow % 256) / 256.0f;
|
||||
|
||||
c = c * c * c;
|
||||
colors[i][first] = 1.0f - c;
|
||||
colors[i][second] = c;
|
||||
colors[i][third] = 0.0f;
|
||||
}
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(3, GL_FLOAT, 0, colors);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
}
|
||||
|
||||
static void
|
||||
draw_textured_cube(void)
|
||||
{
|
||||
static const GLfloat verts[][2] = {
|
||||
{ -4, -4 },
|
||||
{ 4, -4 },
|
||||
{ 4, 4 },
|
||||
{ -4, 4 }
|
||||
};
|
||||
static const GLfloat colors[][4] = {
|
||||
{ 1, 1, 1, 0.5 },
|
||||
{ 1, 1, 1, 0.5 },
|
||||
{ 1, 1, 1, 0.5 },
|
||||
{ 1, 1, 1, 0.5 }
|
||||
};
|
||||
static const GLfloat texs[][2] = {
|
||||
{ 0, 0 },
|
||||
{ 1, 0 },
|
||||
{ 1, 1 },
|
||||
{ 0, 1 }
|
||||
};
|
||||
static const GLfloat xforms[6][4] = {
|
||||
{ 0, 0, 1, 0 },
|
||||
{ 90, 0, 1, 0 },
|
||||
{ 180, 0, 1, 0 },
|
||||
{ 270, 0, 1, 0 },
|
||||
{ 90, 1, 0, 0 },
|
||||
{ -90, 1, 0, 0 }
|
||||
};
|
||||
GLint i;
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
if (blend) {
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
} else {
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
glVertexPointer(2, GL_FLOAT, 0, verts);
|
||||
glColorPointer(4, GL_FLOAT, 0, colors);
|
||||
glTexCoordPointer(2, GL_FLOAT, 0, texs);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_COLOR_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
for (i = 0; i < 6; i++) {
|
||||
glPushMatrix();
|
||||
glRotatef(xforms[i][0], xforms[i][1], xforms[i][2], xforms[i][3]);
|
||||
glTranslatef(0, 0, 4.1);
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glDisableClientState(GL_COLOR_ARRAY);
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
}
|
||||
|
||||
static void
|
||||
draw(void)
|
||||
{
|
||||
use_pbuffer();
|
||||
draw_triangle();
|
||||
|
||||
use_window();
|
||||
|
||||
eglBindTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1, 0, 0);
|
||||
glRotatef(view_roty, 0, 1, 0);
|
||||
glRotatef(view_rotz, 0, 0, 1);
|
||||
|
||||
draw_textured_cube();
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
eglReleaseTexImage(dpy, surf_pbuf, EGL_BACK_BUFFER);
|
||||
}
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(int width, int height)
|
||||
{
|
||||
GLfloat ar = (GLfloat) width / (GLfloat) height;
|
||||
|
||||
use_window();
|
||||
|
||||
glViewport(0, 0, (GLint) width, (GLint) height);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-ar, ar, -1, 1, 5.0, 60.0);
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -40.0);
|
||||
}
|
||||
|
||||
static void
|
||||
event_loop(Display *x_dpy, Window win)
|
||||
{
|
||||
while (1) {
|
||||
int redraw = 1;
|
||||
|
||||
if (XPending(x_dpy) > 0) {
|
||||
XEvent event;
|
||||
XNextEvent(x_dpy, &event);
|
||||
|
||||
switch (event.type) {
|
||||
case Expose:
|
||||
redraw = 1;
|
||||
break;
|
||||
case ConfigureNotify:
|
||||
reshape(event.xconfigure.width, event.xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event.xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else if (code == XK_b) {
|
||||
blend = !blend;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event.xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
redraw = 1;
|
||||
break;
|
||||
default:
|
||||
; /*no-op*/
|
||||
}
|
||||
}
|
||||
|
||||
if (redraw) {
|
||||
view_rotx += 1.0;
|
||||
view_roty += 2.0;
|
||||
view_rotz += 1.5;
|
||||
color_flow += 20;
|
||||
draw();
|
||||
eglSwapBuffers(dpy, surf_win);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
const int winWidth = 300, winHeight = 300;
|
||||
Display *x_dpy;
|
||||
Window win;
|
||||
char *dpyName = NULL;
|
||||
EGLint egl_major, egl_minor;
|
||||
const char *s;
|
||||
|
||||
x_dpy = XOpenDisplay(dpyName);
|
||||
if (!x_dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
dpy = eglGetDisplay(x_dpy);
|
||||
if (!dpy) {
|
||||
printf("Error: eglGetDisplay() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!eglInitialize(dpy, &egl_major, &egl_minor)) {
|
||||
printf("Error: eglInitialize() failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
s = eglQueryString(dpy, EGL_VERSION);
|
||||
printf("EGL_VERSION = %s\n", s);
|
||||
|
||||
make_window(x_dpy, "color flow", 0, 0, winWidth, winHeight, &win);
|
||||
make_pbuffer(winWidth, winHeight);
|
||||
|
||||
XMapWindow(x_dpy, win);
|
||||
|
||||
reshape(winWidth, winHeight);
|
||||
event_loop(x_dpy, win);
|
||||
|
||||
glDeleteTextures(1, &tex_pbuf);
|
||||
|
||||
eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
|
||||
eglTerminate(dpy);
|
||||
|
||||
XDestroyWindow(x_dpy, win);
|
||||
XCloseDisplay(x_dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
1
progs/glsl/.gitignore
vendored
1
progs/glsl/.gitignore
vendored
|
|
@ -22,6 +22,7 @@ samplers_array
|
|||
shaderutil.c
|
||||
shaderutil.h
|
||||
shadow_sampler
|
||||
shtest
|
||||
skinning
|
||||
texaaline
|
||||
texdemo1
|
||||
|
|
|
|||
|
|
@ -14,6 +14,11 @@ LIBS = -L$(TOP)/$(LIB_DIR) -l$(GLUT_LIB) -l$(GLEW_LIB) -l$(GLU_LIB) -l$(GL_LIB)
|
|||
|
||||
INCLUDE_DIRS = -I$(TOP)/progs/util
|
||||
|
||||
# using : to avoid APP_CC pointing to CC loop
|
||||
CC:=$(APP_CC)
|
||||
CFLAGS += -I$(INCDIR)
|
||||
LDLIBS=$(LIBS)
|
||||
|
||||
DEMO_SOURCES = \
|
||||
array.c \
|
||||
bitmap.c \
|
||||
|
|
@ -33,6 +38,7 @@ DEMO_SOURCES = \
|
|||
points.c \
|
||||
samplers.c \
|
||||
shadow_sampler.c \
|
||||
shtest.c \
|
||||
skinning.c \
|
||||
texaaline.c \
|
||||
texdemo1.c \
|
||||
|
|
@ -52,28 +58,16 @@ UTIL_SOURCES = \
|
|||
readtex.c
|
||||
|
||||
UTIL_OBJS = $(UTIL_SOURCES:.c=.o)
|
||||
|
||||
|
||||
PROG_OBJS = $(DEMO_SOURCES:.c=.o)
|
||||
PROGS = $(DEMO_SOURCES:%.c=%)
|
||||
|
||||
|
||||
|
||||
##### RULES #####
|
||||
|
||||
# make .o file from .c file:
|
||||
.c.o:
|
||||
$(APP_CC) -c -I$(INCDIR) $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# make executable from .o files
|
||||
.o:
|
||||
$(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $< $(UTIL_OBJS) $(LIBS) -o $@
|
||||
|
||||
|
||||
##### TARGETS #####
|
||||
|
||||
default: $(PROGS)
|
||||
|
||||
$(PROG_OBJS): $(UTIL_HEADERS)
|
||||
|
||||
$(PROGS): $(UTIL_OBJS)
|
||||
|
||||
clean:
|
||||
-rm -f $(PROGS)
|
||||
|
|
@ -83,7 +77,6 @@ clean:
|
|||
-rm -f readtex.*
|
||||
|
||||
|
||||
|
||||
##### Extra dependencies
|
||||
|
||||
extfuncs.h: $(TOP)/progs/util/extfuncs.h
|
||||
|
|
@ -101,138 +94,3 @@ shaderutil.c: $(TOP)/progs/util/shaderutil.c
|
|||
shaderutil.h: $(TOP)/progs/util/shaderutil.h
|
||||
cp $< .
|
||||
|
||||
|
||||
|
||||
array.o: $(UTIL_HEADERS)
|
||||
|
||||
array: array.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
bitmap.o: $(UTIL_HEADERS)
|
||||
|
||||
bitmap: bitmap.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
brick.o: $(UTIL_HEADERS)
|
||||
|
||||
brick: brick.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
bump.o: $(UTIL_HEADERS)
|
||||
|
||||
bump: bump.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
convolutions.o: $(UTIL_HEADERS)
|
||||
|
||||
convolutions: convolutions.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
deriv.o: deriv.c $(UTIL_HEADERS)
|
||||
|
||||
deriv: deriv.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
identity.o: $(UTIL_HEADERS)
|
||||
|
||||
identity: identity.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
fragcoord.o: $(UTIL_HEADERS)
|
||||
|
||||
fragcoord: fragcoord.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
linktest.o: $(UTIL_HEADERS)
|
||||
|
||||
linktest: linktest.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
mandelbrot.o: $(UTIL_HEADERS)
|
||||
|
||||
mandelbrot: mandelbrot.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
multinoise.o: $(UTIL_HEADERS)
|
||||
|
||||
multinoise: multinoise.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
multitex.o: $(UTIL_HEADERS)
|
||||
|
||||
multitex: multitex.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
noise.o: $(UTIL_HEADERS)
|
||||
|
||||
noise: noise.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
noise2.o: $(UTIL_HEADERS)
|
||||
|
||||
noise2: noise2.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
points.o: $(UTIL_HEADERS)
|
||||
|
||||
points: points.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
pointcoord.o: $(UTIL_HEADERS)
|
||||
|
||||
pointcoord: pointcoord.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
samplers.o: $(UTIL_HEADERS)
|
||||
|
||||
samplers: samplers.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
samplers_array.o: $(UTIL_HEADERS)
|
||||
|
||||
samplers_array: samplers_array.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
shadow_sampler.o: $(UTIL_HEADERS)
|
||||
|
||||
shadow_sampler: shadow_sampler.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
skinning.o: $(UTIL_HEADERS)
|
||||
|
||||
skinning: skinning.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
texaaline.o: $(UTIL_HEADERS)
|
||||
|
||||
texaaline: texaaline.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
texdemo1.o: $(UTIL_HEADERS)
|
||||
|
||||
texdemo1: texdemo1.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
toyball.o: $(UTIL_HEADERS)
|
||||
|
||||
toyball: toyball.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
twoside.o: $(UTIL_HEADERS)
|
||||
|
||||
twoside: twoside.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
trirast.o: $(UTIL_HEADERS)
|
||||
|
||||
trirast: trirast.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
vert-or-frag-only.o: $(UTIL_HEADERS)
|
||||
|
||||
vert-or-frag-only: vert-or-frag-only.o $(UTIL_OBJS)
|
||||
|
||||
|
||||
vert-tex.o: $(UTIL_HEADERS)
|
||||
|
||||
vert-tex: vert-tex.o $(UTIL_OBJS)
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ static GLuint program;
|
|||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
{ "LightPosition", 1, GL_FLOAT_VEC3, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
/* frag */
|
||||
{ "BrickColor", 3, GL_FLOAT, { 0.8, 0.2, 0.2, 0 }, -1 },
|
||||
{ "MortarColor", 3, GL_FLOAT, { 0.6, 0.6, 0.6, 0 }, -1 },
|
||||
{ "BrickSize", 2, GL_FLOAT, { 1.0, 0.3, 0, 0 }, -1 },
|
||||
{ "BrickPct", 2, GL_FLOAT, { 0.9, 0.8, 0, 0 }, -1 },
|
||||
{ "BrickColor", 1, GL_FLOAT_VEC3, { 0.8, 0.2, 0.2, 0 }, -1 },
|
||||
{ "MortarColor", 1, GL_FLOAT_VEC3, { 0.6, 0.6, 0.6, 0 }, -1 },
|
||||
{ "BrickSize", 1, GL_FLOAT_VEC2, { 1.0, 0.3, 0, 0 }, -1 },
|
||||
{ "BrickPct", 1, GL_FLOAT_VEC2, { 0.9, 0.8, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -148,7 +148,8 @@ Init(void)
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
|
@ -183,7 +184,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
8
progs/glsl/brick.shtest
Normal file
8
progs/glsl/brick.shtest
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
vs CH06-brick.vert
|
||||
fs CH06-brick.frag
|
||||
uniform LightPosition GL_FLOAT_VEC3 0.1 0.1 9.0
|
||||
uniform BrickColor GL_FLOAT_VEC3 0.8 0.2 0.2
|
||||
uniform MortarColor GL_FLOAT_VEC3 0.6 0.6 0.6
|
||||
uniform BrickSize GL_FLOAT_VEC2 1.0 0.3
|
||||
uniform BrickPct GL_FLOAT_VEC2 0.9 0.8
|
||||
|
||||
|
|
@ -24,11 +24,11 @@ static GLuint program;
|
|||
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "SurfaceColor", 3, GL_FLOAT, { 0.8, 0.8, 0.2, 0 }, -1 },
|
||||
{ "BumpDensity", 1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
|
||||
{ "BumpSize", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
|
||||
{ "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
{ "LightPosition", 1, GL_FLOAT_VEC3, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "SurfaceColor", 1, GL_FLOAT_VEC3, { 0.8, 0.8, 0.2, 0 }, -1 },
|
||||
{ "BumpDensity", 1, GL_FLOAT, { 10.0, 0, 0, 0 }, -1 },
|
||||
{ "BumpSize", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
|
||||
{ "SpecularFactor", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -242,7 +242,8 @@ Init(void)
|
|||
|
||||
CheckError(__LINE__);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
CheckError(__LINE__);
|
||||
|
||||
|
|
@ -280,7 +281,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -448,7 +448,6 @@ int main(int argc, char **argv)
|
|||
{
|
||||
glutInit(&argc, argv);
|
||||
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE);
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(200, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ static GLuint program;
|
|||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
/* vert */
|
||||
{ "LightPosition", 3, GL_FLOAT, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
{ "LightPosition", 1, GL_FLOAT_VEC3, { 0.1, 0.1, 9.0, 0}, -1 },
|
||||
{ "SpecularContribution", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
{ "DiffuseContribution", 1, GL_FLOAT, { 0.5, 0, 0, 0 }, -1 },
|
||||
{ "Shininess", 1, GL_FLOAT, { 20.0, 0, 0, 0 }, -1 },
|
||||
|
|
@ -34,9 +34,9 @@ static struct uniform_info Uniforms[] = {
|
|||
{ "Zoom", 1, GL_FLOAT, { 0.125, 0, 0, 0 }, -1 },
|
||||
{ "Xcenter", 1, GL_FLOAT, { -1.5, 0, 0, 0 }, -1 },
|
||||
{ "Ycenter", 1, GL_FLOAT, { .005, 0, 0, 0 }, -1 },
|
||||
{ "InnerColor", 3, GL_FLOAT, { 1, 0, 0, 0 }, -1 },
|
||||
{ "OuterColor1", 3, GL_FLOAT, { 0, 1, 0, 0 }, -1 },
|
||||
{ "OuterColor2", 3, GL_FLOAT, { 0, 0, 1, 0 }, -1 },
|
||||
{ "InnerColor", 1, GL_FLOAT_VEC3, { 1, 0, 0, 0 }, -1 },
|
||||
{ "OuterColor1", 1, GL_FLOAT_VEC3, { 0, 1, 0, 0 }, -1 },
|
||||
{ "OuterColor2", 1, GL_FLOAT_VEC3, { 0, 0, 1, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -159,7 +159,8 @@ Init(void)
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
uZoom = glGetUniformLocation(program, "Zoom");
|
||||
uXcenter = glGetUniformLocation(program, "Xcenter");
|
||||
|
|
@ -198,7 +199,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
13
progs/glsl/mandelbrot.shtest
Normal file
13
progs/glsl/mandelbrot.shtest
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
vs CH18-mandel.vert
|
||||
fs CH18-mandel.frag
|
||||
uniform LightPosition GL_FLOAT_VEC3 0.1 0.1 9.0
|
||||
uniform SpecularContribution GL_FLOAT 0.5
|
||||
uniform DiffuseContribution GL_FLOAT 0.5
|
||||
uniform Shininess GL_FLOAT 20.0
|
||||
uniform Iterations GL_FLOAT 12
|
||||
uniform Zoom GL_FLOAT 0.125
|
||||
uniform Xcenter GL_FLOAT -1.5
|
||||
uniform Ycenter GL_FLOAT .005
|
||||
uniform InnerColor GL_FLOAT_VEC3 1 0 0
|
||||
uniform OuterColor1 GL_FLOAT_VEC3 0 1 0
|
||||
uniform OuterColor2 GL_FLOAT_VEC3 0 0 1
|
||||
|
|
@ -262,7 +262,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -59,8 +59,8 @@ static GLint VertCoord_attr = -1, TexCoord0_attr = -1, TexCoord1_attr = -1;
|
|||
|
||||
/* value[0] = tex unit */
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "tex1", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
|
||||
{ "tex2", 1, GL_INT, { 1, 0, 0, 0 }, -1 },
|
||||
{ "tex1", 1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
|
||||
{ "tex2", 1, GL_SAMPLER_2D, { 1, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ DrawPolygonArray(void)
|
|||
|
||||
if (VertCoord_attr >= 0) {
|
||||
glVertexAttribPointer(VertCoord_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, VertCoords);
|
||||
0, vertPtr);
|
||||
glEnableVertexAttribArray(VertCoord_attr);
|
||||
}
|
||||
else {
|
||||
|
|
@ -143,11 +143,11 @@ DrawPolygonArray(void)
|
|||
}
|
||||
|
||||
glVertexAttribPointer(TexCoord0_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, Tex0Coords);
|
||||
0, tex0Ptr);
|
||||
glEnableVertexAttribArray(TexCoord0_attr);
|
||||
|
||||
glVertexAttribPointer(TexCoord1_attr, 2, GL_FLOAT, GL_FALSE,
|
||||
0, Tex1Coords);
|
||||
0, tex1Ptr);
|
||||
glEnableVertexAttribArray(TexCoord1_attr);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
|
@ -328,7 +328,8 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, uniforms);
|
||||
SetUniformValues(program, uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
VertCoord_attr = glGetAttribLocation(program, "VertCoord");
|
||||
if (VertCoord_attr > 0) {
|
||||
|
|
|
|||
6
progs/glsl/multitex.shtest
Normal file
6
progs/glsl/multitex.shtest
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
vs multitex.vert
|
||||
fs multitex.frag
|
||||
texture 0 ../images/tile.rgb
|
||||
texture 1 ../images/tree2.rgba
|
||||
uniform tex1 GL_SAMPLER_2D 0
|
||||
uniform tex2 GL_SAMPLER_2D 1
|
||||
|
|
@ -35,8 +35,8 @@ static const char *FragShaderText =
|
|||
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "Scale", 4, GL_FLOAT, { 0.5, 0.4, 0.0, 0}, -1 },
|
||||
{ "Bias", 4, GL_FLOAT, { 0.5, 0.3, 0.0, 0}, -1 },
|
||||
{ "Scale", 1, GL_FLOAT_VEC4, { 0.5, 0.4, 0.0, 0}, -1 },
|
||||
{ "Bias", 1, GL_FLOAT_VEC4, { 0.5, 0.3, 0.0, 0}, -1 },
|
||||
{ "Slice", 1, GL_FLOAT, { 0.5, 0, 0, 0}, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
|
@ -179,7 +179,8 @@ Init(void)
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
|
@ -199,7 +200,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -186,7 +186,6 @@ static void Init (void)
|
|||
int main (int argc, char *argv[])
|
||||
{
|
||||
glutInit (&argc, argv);
|
||||
glutInitWindowPosition ( 0, 0);
|
||||
glutInitWindowSize (200, 200);
|
||||
glutInitDisplayMode (GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
glutCreateWindow (argv[0]);
|
||||
|
|
|
|||
|
|
@ -187,7 +187,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -321,7 +321,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 300);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
629
progs/glsl/shtest.c
Normal file
629
progs/glsl/shtest.c
Normal file
|
|
@ -0,0 +1,629 @@
|
|||
/*
|
||||
* Simple shader test harness.
|
||||
* Brian Paul
|
||||
* 13 Aug 2009
|
||||
*
|
||||
* Usage:
|
||||
* shtest --vs vertShaderFile --fs fragShaderFile
|
||||
*
|
||||
* In this case the given vertex/frag shaders are read and compiled.
|
||||
* Random values are assigned to the uniforms.
|
||||
*
|
||||
* or:
|
||||
* shtest configFile
|
||||
*
|
||||
* In this case a config file is read that specifies the file names
|
||||
* of the shaders plus initial values for uniforms.
|
||||
*
|
||||
* Example config file:
|
||||
*
|
||||
* vs shader.vert
|
||||
* fs shader.frag
|
||||
* uniform pi 3.14159
|
||||
* uniform v1 1.0 0.5 0.2 0.3
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glu.h>
|
||||
#include <GL/glut.h>
|
||||
#include "shaderutil.h"
|
||||
#include "readtex.h"
|
||||
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPHERE,
|
||||
CUBE,
|
||||
NUM_SHAPES
|
||||
} shape;
|
||||
|
||||
|
||||
static char *FragShaderFile = NULL;
|
||||
static char *VertShaderFile = NULL;
|
||||
static char *ConfigFile = NULL;
|
||||
|
||||
/* program/shader objects */
|
||||
static GLuint fragShader;
|
||||
static GLuint vertShader;
|
||||
static GLuint Program;
|
||||
|
||||
|
||||
#define MAX_UNIFORMS 100
|
||||
static struct uniform_info Uniforms[MAX_UNIFORMS];
|
||||
static GLuint NumUniforms = 0;
|
||||
|
||||
|
||||
#define MAX_ATTRIBS 100
|
||||
static struct attrib_info Attribs[MAX_ATTRIBS];
|
||||
static GLuint NumAttribs = 0;
|
||||
|
||||
|
||||
/**
|
||||
* Config file info.
|
||||
*/
|
||||
struct config_file
|
||||
{
|
||||
struct name_value
|
||||
{
|
||||
char name[100];
|
||||
float value[4];
|
||||
int type;
|
||||
} uniforms[100];
|
||||
|
||||
int num_uniforms;
|
||||
};
|
||||
|
||||
|
||||
static GLint win = 0;
|
||||
static GLboolean Anim = GL_FALSE;
|
||||
static GLfloat TexRot = 0.0;
|
||||
static GLfloat xRot = 0.0f, yRot = 0.0f, zRot = 0.0f;
|
||||
static shape Object = SPHERE;
|
||||
|
||||
|
||||
static float
|
||||
RandomFloat(float min, float max)
|
||||
{
|
||||
int k = rand() % 10000;
|
||||
float x = min + (max - min) * k / 10000.0;
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/** Set new random values for uniforms */
|
||||
static void
|
||||
RandomUniformValues(void)
|
||||
{
|
||||
GLuint i;
|
||||
for (i = 0; i < NumUniforms; i++) {
|
||||
if (Uniforms[i].type == GL_FLOAT) {
|
||||
Uniforms[i].value[0] = RandomFloat(0.0, 1.0);
|
||||
}
|
||||
else {
|
||||
Uniforms[i].value[0] = RandomFloat(-1.0, 2.0);
|
||||
Uniforms[i].value[1] = RandomFloat(-1.0, 2.0);
|
||||
Uniforms[i].value[2] = RandomFloat(-1.0, 2.0);
|
||||
Uniforms[i].value[3] = RandomFloat(-1.0, 2.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Idle(void)
|
||||
{
|
||||
yRot += 2.0;
|
||||
if (yRot > 360.0)
|
||||
yRot -= 360.0;
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
SquareVertex(GLfloat s, GLfloat t, GLfloat size)
|
||||
{
|
||||
GLfloat x = -size + s * 2.0 * size;
|
||||
GLfloat y = -size + t * 2.0 * size;
|
||||
GLuint i;
|
||||
|
||||
glMultiTexCoord2f(GL_TEXTURE0, s, t);
|
||||
glMultiTexCoord2f(GL_TEXTURE1, s, t);
|
||||
glMultiTexCoord2f(GL_TEXTURE2, s, t);
|
||||
glMultiTexCoord2f(GL_TEXTURE3, s, t);
|
||||
|
||||
/* assign (s,t) to the generic attributes */
|
||||
for (i = 0; i < NumAttribs; i++) {
|
||||
if (Attribs[i].location >= 0) {
|
||||
glVertexAttrib2f(Attribs[i].location, s, t);
|
||||
}
|
||||
}
|
||||
|
||||
glVertex2f(x, y);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Draw a square, specifying normal and tangent vectors.
|
||||
*/
|
||||
static void
|
||||
Square(GLfloat size)
|
||||
{
|
||||
GLint tangentAttrib = 1;
|
||||
glNormal3f(0, 0, 1);
|
||||
glVertexAttrib3f(tangentAttrib, 1, 0, 0);
|
||||
glBegin(GL_POLYGON);
|
||||
#if 1
|
||||
SquareVertex(0, 0, size);
|
||||
SquareVertex(1, 0, size);
|
||||
SquareVertex(1, 1, size);
|
||||
SquareVertex(0, 1, size);
|
||||
#else
|
||||
glTexCoord2f(0, 0); glVertex2f(-size, -size);
|
||||
glTexCoord2f(1, 0); glVertex2f( size, -size);
|
||||
glTexCoord2f(1, 1); glVertex2f( size, size);
|
||||
glTexCoord2f(0, 1); glVertex2f(-size, size);
|
||||
#endif
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Cube(GLfloat size)
|
||||
{
|
||||
/* +X */
|
||||
glPushMatrix();
|
||||
glRotatef(90, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -X */
|
||||
glPushMatrix();
|
||||
glRotatef(-90, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* +Y */
|
||||
glPushMatrix();
|
||||
glRotatef(90, 1, 0, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -Y */
|
||||
glPushMatrix();
|
||||
glRotatef(-90, 1, 0, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
|
||||
/* +Z */
|
||||
glPushMatrix();
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
|
||||
/* -Z */
|
||||
glPushMatrix();
|
||||
glRotatef(180, 0, 1, 0);
|
||||
glTranslatef(0, 0, size);
|
||||
Square(size);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Sphere(GLfloat radius, GLint slices, GLint stacks)
|
||||
{
|
||||
static GLUquadricObj *q = NULL;
|
||||
|
||||
if (!q) {
|
||||
q = gluNewQuadric();
|
||||
gluQuadricDrawStyle(q, GLU_FILL);
|
||||
gluQuadricNormals(q, GLU_SMOOTH);
|
||||
gluQuadricTexture(q, GL_TRUE);
|
||||
}
|
||||
|
||||
gluSphere(q, radius, slices, stacks);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Redisplay(void)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(xRot, 1.0f, 0.0f, 0.0f);
|
||||
glRotatef(yRot, 0.0f, 1.0f, 0.0f);
|
||||
glRotatef(zRot, 0.0f, 0.0f, 1.0f);
|
||||
|
||||
glMatrixMode(GL_TEXTURE);
|
||||
glLoadIdentity();
|
||||
glRotatef(TexRot, 0.0f, 1.0f, 0.0f);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
|
||||
if (Object == SPHERE) {
|
||||
Sphere(2.0, 20, 10);
|
||||
}
|
||||
else if (Object == CUBE) {
|
||||
Cube(2.0);
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Reshape(int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0f, 0.0f, -15.0f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
CleanUp(void)
|
||||
{
|
||||
glDeleteShader(fragShader);
|
||||
glDeleteShader(vertShader);
|
||||
glDeleteProgram(Program);
|
||||
glutDestroyWindow(win);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Key(unsigned char key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case 'a':
|
||||
Anim = !Anim;
|
||||
if (Anim)
|
||||
glutIdleFunc(Idle);
|
||||
else
|
||||
glutIdleFunc(NULL);
|
||||
break;
|
||||
case 'z':
|
||||
zRot += step;
|
||||
break;
|
||||
case 'Z':
|
||||
zRot -= step;
|
||||
break;
|
||||
case 'o':
|
||||
Object = (Object + 1) % NUM_SHAPES;
|
||||
break;
|
||||
case 'r':
|
||||
RandomUniformValues();
|
||||
SetUniformValues(Program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
break;
|
||||
case 27:
|
||||
CleanUp();
|
||||
exit(0);
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
SpecialKey(int key, int x, int y)
|
||||
{
|
||||
const GLfloat step = 2.0;
|
||||
|
||||
(void) x;
|
||||
(void) y;
|
||||
|
||||
switch(key) {
|
||||
case GLUT_KEY_UP:
|
||||
xRot += step;
|
||||
break;
|
||||
case GLUT_KEY_DOWN:
|
||||
xRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_LEFT:
|
||||
yRot -= step;
|
||||
break;
|
||||
case GLUT_KEY_RIGHT:
|
||||
yRot += step;
|
||||
break;
|
||||
}
|
||||
glutPostRedisplay();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
InitUniforms(const struct config_file *conf,
|
||||
struct uniform_info uniforms[])
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < conf->num_uniforms; i++) {
|
||||
int j;
|
||||
for (j = 0; uniforms[j].name; j++) {
|
||||
if (strcmp(uniforms[j].name, conf->uniforms[i].name) == 0) {
|
||||
uniforms[j].type = conf->uniforms[i].type;
|
||||
uniforms[j].value[0] = conf->uniforms[i].value[0];
|
||||
uniforms[j].value[1] = conf->uniforms[i].value[1];
|
||||
uniforms[j].value[2] = conf->uniforms[i].value[2];
|
||||
uniforms[j].value[3] = conf->uniforms[i].value[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
LoadTexture(GLint unit, const char *texFileName)
|
||||
{
|
||||
GLint imgWidth, imgHeight;
|
||||
GLenum imgFormat;
|
||||
GLubyte *image = NULL;
|
||||
GLuint tex;
|
||||
GLenum filter = GL_LINEAR;
|
||||
|
||||
image = LoadRGBImage(texFileName, &imgWidth, &imgHeight, &imgFormat);
|
||||
if (!image) {
|
||||
printf("Couldn't read %s\n", texFileName);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Load Texture: unit %d: %s %d x %d\n",
|
||||
unit, texFileName, imgWidth, imgHeight);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0 + unit);
|
||||
glGenTextures(1, &tex);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
|
||||
gluBuild2DMipmaps(GL_TEXTURE_2D, 4, imgWidth, imgHeight,
|
||||
imgFormat, GL_UNSIGNED_BYTE, image);
|
||||
free(image);
|
||||
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filter);
|
||||
}
|
||||
|
||||
|
||||
static GLenum
|
||||
TypeFromName(const char *n)
|
||||
{
|
||||
static const struct {
|
||||
const char *name;
|
||||
GLenum type;
|
||||
} types[] = {
|
||||
{ "GL_FLOAT", GL_FLOAT },
|
||||
{ "GL_FLOAT_VEC2", GL_FLOAT_VEC2 },
|
||||
{ "GL_FLOAT_VEC3", GL_FLOAT_VEC3 },
|
||||
{ "GL_FLOAT_VEC4", GL_FLOAT_VEC4 },
|
||||
{ "GL_INT", GL_INT },
|
||||
{ "GL_INT_VEC2", GL_INT_VEC2 },
|
||||
{ "GL_INT_VEC3", GL_INT_VEC3 },
|
||||
{ "GL_INT_VEC4", GL_INT_VEC4 },
|
||||
{ "GL_SAMPLER_2D", GL_SAMPLER_2D },
|
||||
{ NULL, 0 }
|
||||
};
|
||||
GLuint i;
|
||||
|
||||
for (i = 0; types[i].name; i++) {
|
||||
if (strcmp(types[i].name, n) == 0)
|
||||
return types[i].type;
|
||||
}
|
||||
abort();
|
||||
return GL_NONE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Read a config file.
|
||||
*/
|
||||
static void
|
||||
ReadConfigFile(const char *filename, struct config_file *conf)
|
||||
{
|
||||
char line[1000];
|
||||
FILE *f;
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Unable to open config file %s\n", filename);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
conf->num_uniforms = 0;
|
||||
|
||||
/* ugly but functional parser */
|
||||
while (!feof(f)) {
|
||||
fgets(line, sizeof(line), f);
|
||||
if (!feof(f) && line[0]) {
|
||||
if (strncmp(line, "vs ", 3) == 0) {
|
||||
VertShaderFile = strdup(line + 3);
|
||||
VertShaderFile[strlen(VertShaderFile) - 1] = 0;
|
||||
}
|
||||
else if (strncmp(line, "fs ", 3) == 0) {
|
||||
FragShaderFile = strdup(line + 3);
|
||||
FragShaderFile[strlen(FragShaderFile) - 1] = 0;
|
||||
}
|
||||
else if (strncmp(line, "texture ", 8) == 0) {
|
||||
char texFileName[100];
|
||||
int unit, k;
|
||||
k = sscanf(line + 8, "%d %s", &unit, texFileName);
|
||||
assert(k == 2);
|
||||
LoadTexture(unit, texFileName);
|
||||
}
|
||||
else if (strncmp(line, "uniform ", 8) == 0) {
|
||||
char name[1000], typeName[100];
|
||||
int k;
|
||||
float v1 = 0.0F, v2 = 0.0F, v3 = 0.0F, v4 = 0.0F;
|
||||
GLenum type;
|
||||
|
||||
k = sscanf(line + 8, "%s %s %f %f %f %f", name, typeName,
|
||||
&v1, &v2, &v3, &v4);
|
||||
|
||||
type = TypeFromName(typeName);
|
||||
|
||||
strcpy(conf->uniforms[conf->num_uniforms].name, name);
|
||||
conf->uniforms[conf->num_uniforms].value[0] = v1;
|
||||
conf->uniforms[conf->num_uniforms].value[1] = v2;
|
||||
conf->uniforms[conf->num_uniforms].value[2] = v3;
|
||||
conf->uniforms[conf->num_uniforms].value[3] = v4;
|
||||
conf->uniforms[conf->num_uniforms].type = type;
|
||||
conf->num_uniforms++;
|
||||
}
|
||||
else {
|
||||
if (strlen(line) > 1) {
|
||||
fprintf(stderr, "syntax error in: %s\n", line);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
struct config_file config;
|
||||
memset(&config, 0, sizeof(config));
|
||||
|
||||
if (ConfigFile)
|
||||
ReadConfigFile(ConfigFile, &config);
|
||||
|
||||
if (!VertShaderFile) {
|
||||
fprintf(stderr, "Error: no vertex shader\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!FragShaderFile) {
|
||||
fprintf(stderr, "Error: no fragment shader\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!ShadersSupported())
|
||||
exit(1);
|
||||
|
||||
vertShader = CompileShaderFile(GL_VERTEX_SHADER, VertShaderFile);
|
||||
fragShader = CompileShaderFile(GL_FRAGMENT_SHADER, FragShaderFile);
|
||||
Program = LinkShaders(vertShader, fragShader);
|
||||
|
||||
glUseProgram(Program);
|
||||
|
||||
NumUniforms = GetUniforms(Program, Uniforms);
|
||||
if (config.num_uniforms) {
|
||||
InitUniforms(&config, Uniforms);
|
||||
}
|
||||
else {
|
||||
RandomUniformValues();
|
||||
}
|
||||
SetUniformValues(Program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
NumAttribs = GetAttribs(Program, Attribs);
|
||||
PrintAttribs(Attribs);
|
||||
|
||||
//assert(glGetError() == 0);
|
||||
|
||||
glClearColor(0.4f, 0.4f, 0.8f, 0.0f);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
glColor3f(1, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Keys(void)
|
||||
{
|
||||
printf("Keyboard:\n");
|
||||
printf(" a Animation toggle\n");
|
||||
printf(" r Randomize uniform values\n");
|
||||
printf(" o Change object\n");
|
||||
printf(" arrows Rotate object\n");
|
||||
printf(" ESC Exit\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
Usage(void)
|
||||
{
|
||||
printf("Usage:\n");
|
||||
printf(" shtest config.shtest\n");
|
||||
printf(" Run w/ given config file.\n");
|
||||
printf(" shtest --vs vertShader --fs fragShader\n");
|
||||
printf(" Load/compile given shaders.\n");
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
ParseOptions(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc == 1) {
|
||||
Usage();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "--fs") == 0) {
|
||||
FragShaderFile = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else if (strcmp(argv[i], "--vs") == 0) {
|
||||
VertShaderFile = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
/* assume the arg is a config file */
|
||||
ConfigFile = argv[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
glewInit();
|
||||
glutReshapeFunc(Reshape);
|
||||
glutKeyboardFunc(Key);
|
||||
glutSpecialFunc(SpecialKey);
|
||||
glutDisplayFunc(Redisplay);
|
||||
ParseOptions(argc, argv);
|
||||
Init();
|
||||
Keys();
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -351,7 +351,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ static int win = 0;
|
|||
|
||||
|
||||
static struct uniform_info ReflectUniforms[] = {
|
||||
{ "cubeTex", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
|
||||
{ "cubeTex", 1, GL_SAMPLER_CUBE, { 0, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 1, GL_FLOAT_VEC3, { 10, 10, 20, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
static struct uniform_info SimpleUniforms[] = {
|
||||
{ "tex2d", 1, GL_INT, { 1, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 3, GL_FLOAT, { 10, 10, 20, 0 }, -1 },
|
||||
{ "tex2d", 1, GL_SAMPLER_2D, { 1, 0, 0, 0 }, -1 },
|
||||
{ "lightPos", 1, GL_FLOAT_VEC3, { 10, 10, 20, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -382,7 +382,8 @@ CreateProgram(const char *vertProgFile, const char *fragProgFile,
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, uniforms);
|
||||
SetUniformValues(program, uniforms);
|
||||
PrintUniforms(uniforms);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,18 +24,18 @@ static GLuint program;
|
|||
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "LightDir", 4, GL_FLOAT, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "HVector", 4, GL_FLOAT, { 0.32506, 0.32506, 0.88808, 0.0 }, -1 },
|
||||
{ "BallCenter", 4, GL_FLOAT, { 0.0, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "SpecularColor", 4, GL_FLOAT, { 0.4, 0.4, 0.4, 60.0 }, -1 },
|
||||
{ "Red", 4, GL_FLOAT, { 0.6, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "Blue", 4, GL_FLOAT, { 0.0, 0.3, 0.6, 1.0 }, -1 },
|
||||
{ "Yellow", 4, GL_FLOAT, { 0.6, 0.5, 0.0, 1.0 }, -1 },
|
||||
{ "HalfSpace0", 4, GL_FLOAT, { 1.0, 0.0, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace1", 4, GL_FLOAT, { 0.309016994, 0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace2", 4, GL_FLOAT, { -0.809016994, 0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace3", 4, GL_FLOAT, { -0.809016994, -0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace4", 4, GL_FLOAT, { 0.309116994, -0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "LightDir", 1, GL_FLOAT_VEC4, { 0.57737, 0.57735, 0.57735, 0.0 }, -1 },
|
||||
{ "HVector", 1, GL_FLOAT_VEC4, { 0.32506, 0.32506, 0.88808, 0.0 }, -1 },
|
||||
{ "BallCenter", 1, GL_FLOAT_VEC4, { 0.0, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "SpecularColor", 1, GL_FLOAT_VEC4, { 0.4, 0.4, 0.4, 60.0 }, -1 },
|
||||
{ "Red", 1, GL_FLOAT_VEC4, { 0.6, 0.0, 0.0, 1.0 }, -1 },
|
||||
{ "Blue", 1, GL_FLOAT_VEC4, { 0.0, 0.3, 0.6, 1.0 }, -1 },
|
||||
{ "Yellow", 1, GL_FLOAT_VEC4, { 0.6, 0.5, 0.0, 1.0 }, -1 },
|
||||
{ "HalfSpace0", 1, GL_FLOAT_VEC4, { 1.0, 0.0, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace1", 1, GL_FLOAT_VEC4, { 0.309016994, 0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace2", 1, GL_FLOAT_VEC4, { -0.809016994, 0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace3", 1, GL_FLOAT_VEC4, { -0.809016994, -0.587785252, 0.0, 0.2 }, -1 },
|
||||
{ "HalfSpace4", 1, GL_FLOAT_VEC4, { 0.309116994, -0.951056516, 0.0, 0.2 }, -1 },
|
||||
{ "InOrOutInit", 1, GL_FLOAT, { -3.0, 0, 0, 0 }, -1 },
|
||||
{ "StripeWidth", 1, GL_FLOAT, { 0.3, 0, 0, 0 }, -1 },
|
||||
{ "FWidth", 1, GL_FLOAT, { 0.005, 0, 0, 0 }, -1 },
|
||||
|
|
@ -173,7 +173,8 @@ Init(void)
|
|||
|
||||
glUseProgram(program);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
PrintUniforms(Uniforms);
|
||||
|
||||
assert(glGetError() == 0);
|
||||
|
||||
|
|
@ -204,7 +205,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 400);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
17
progs/glsl/toyball.shtest
Normal file
17
progs/glsl/toyball.shtest
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
vs CH11-toyball.vert
|
||||
fs CH11-toyball.frag
|
||||
uniform LightDir GL_FLOAT_VEC4 0.57737 0.57735 0.57735 0.0
|
||||
uniform HVector GL_FLOAT_VEC4 0.32506 0.32506 0.88808 0.0
|
||||
uniform BallCenter GL_FLOAT_VEC4 0.0 0.0 0.0 1.0
|
||||
uniform SpecularColor GL_FLOAT_VEC4 0.4 0.4 0.4 60.0
|
||||
uniform Red GL_FLOAT_VEC4 0.6 0.0 0.0 1.0
|
||||
uniform Blue GL_FLOAT_VEC4 0.0 0.3 0.6 1.0
|
||||
uniform Yellow GL_FLOAT_VEC4 0.6 0.5 0.0 1.0
|
||||
uniform HalfSpace0 GL_FLOAT_VEC4 1.0 0.0 0.0 0.2
|
||||
uniform HalfSpace1 GL_FLOAT_VEC4 .309016994 0.951056516 0.0 0.2
|
||||
uniform HalfSpace2 GL_FLOAT_VEC4 -0.809016994 0.587785252 0.0 0.2
|
||||
uniform HalfSpace3 GL_FLOAT_VEC4 -0.809016994 -0.587785252 0.0 0.2
|
||||
uniform HalfSpace4 GL_FLOAT_VEC4 .309116994 -0.951056516 0.0 0.2
|
||||
uniform InOrOutInit GL_FLOAT -3.0
|
||||
uniform StripeWidth GL_FLOAT 0.3
|
||||
uniform FWidth GL_FLOAT .005
|
||||
|
|
@ -239,7 +239,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -285,7 +285,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(WinWidth, WinHeight);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
|
||||
win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -173,7 +173,6 @@ int
|
|||
main(int argc, char *argv[])
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitWindowPosition( 0, 0);
|
||||
glutInitWindowSize(400, 200);
|
||||
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
|
||||
Win = glutCreateWindow(argv[0]);
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ static GLfloat xRot = -70.0f, yRot = 0.0f, zRot = 0.0f;
|
|||
|
||||
/* value[0] = tex unit */
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "tex1", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
|
||||
{ "tex1", 1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,7 @@ progs = [
|
|||
'fogcoord',
|
||||
'fptest1',
|
||||
'fptexture',
|
||||
'getteximage',
|
||||
'glutfx',
|
||||
'interleave',
|
||||
'invert',
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ static const char *VertShaderText =
|
|||
"} \n";
|
||||
|
||||
static struct uniform_info Uniforms[] = {
|
||||
{ "tex1", 1, GL_INT, { 0, 0, 0, 0 }, -1 },
|
||||
{ "tex1", 1, GL_SAMPLER_2D, { 0, 0, 0, 0 }, -1 },
|
||||
END_OF_UNIFORMS
|
||||
};
|
||||
|
||||
|
|
@ -189,7 +189,7 @@ CreateProgram(void)
|
|||
|
||||
glUseProgram_func(program);
|
||||
|
||||
InitUniforms(program, Uniforms);
|
||||
SetUniformValues(program, Uniforms);
|
||||
|
||||
return program;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -52,7 +52,7 @@ static struct name_test_pair functions[] = {"""
|
|||
prev_category = None
|
||||
|
||||
|
||||
for f in api.functionIterateByOffset():
|
||||
for f in api.functionIterateByCategory():
|
||||
[category, num] = api.get_category_for_name( f.name )
|
||||
if category != prev_category:
|
||||
print ' { "-%s", NULL},' % category
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ static int Win;
|
|||
|
||||
|
||||
static void
|
||||
TestGetTexImage(void)
|
||||
TestGetTexImage(GLboolean npot)
|
||||
{
|
||||
GLuint iter;
|
||||
GLubyte *data = (GLubyte *) malloc(1024 * 1024 * 4);
|
||||
|
|
@ -27,8 +27,8 @@ TestGetTexImage(void)
|
|||
|
||||
for (iter = 0; iter < 8; iter++) {
|
||||
GLint p = (iter % 8) + 3;
|
||||
GLint w = (1 << p);
|
||||
GLint h = (1 << p);
|
||||
GLint w = npot ? (p * 20) : (1 << p);
|
||||
GLint h = npot ? (p * 10) : (1 << p);
|
||||
GLuint i;
|
||||
GLint level = 0;
|
||||
|
||||
|
|
@ -83,63 +83,94 @@ ColorsEqual(const GLubyte ref[4], const GLubyte act[4])
|
|||
|
||||
|
||||
static void
|
||||
TestGetTexImageRTT(void)
|
||||
TestGetTexImageRTT(GLboolean npot)
|
||||
{
|
||||
GLuint iter;
|
||||
GLuint fb, tex;
|
||||
GLint w = 512;
|
||||
GLint h = 256;
|
||||
GLint level = 0;
|
||||
|
||||
glGenTextures(1, &tex);
|
||||
glGenFramebuffersEXT(1, &fb);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, fb);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, tex, level);
|
||||
|
||||
printf("Render to texture + glGetTexImage:\n");
|
||||
printf(" Testing %d x %d tex image\n", w, h);
|
||||
|
||||
for (iter = 0; iter < 8; iter++) {
|
||||
GLubyte color[4];
|
||||
GLubyte *data2 = (GLubyte *) malloc(w * h * 4);
|
||||
GLuint i;
|
||||
|
||||
/* random clear color */
|
||||
for (i = 0; i < 4; i++) {
|
||||
color[i] = rand() % 256;
|
||||
GLuint fb, tex;
|
||||
GLint w, h;
|
||||
GLint level = 0;
|
||||
|
||||
if (npot) {
|
||||
w = 200 + iter * 40;
|
||||
h = 200 + iter * 12;
|
||||
}
|
||||
else {
|
||||
w = 4 << iter;
|
||||
h = 4 << iter;
|
||||
}
|
||||
|
||||
glClearColor(color[0] / 255.0,
|
||||
color[1] / 255.0,
|
||||
color[2] / 255.0,
|
||||
color[3] / 255.0);
|
||||
glGenTextures(1, &tex);
|
||||
glGenFramebuffersEXT(1, &fb);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
glBindTexture(GL_TEXTURE_2D, tex);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
|
||||
/* get */
|
||||
glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2);
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);
|
||||
glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
|
||||
GL_TEXTURE_2D, tex, level);
|
||||
|
||||
/* compare */
|
||||
for (i = 0; i < w * h; i += 4) {
|
||||
if (!ColorsEqual(color, data2 + i * 4)) {
|
||||
printf("Render to texture failure!\n");
|
||||
abort();
|
||||
glViewport(0, 0, w, h);
|
||||
|
||||
printf(" Testing %d x %d tex image\n", w, h);
|
||||
{
|
||||
static const GLubyte blue[4] = {0, 0, 255, 255};
|
||||
GLubyte color[4];
|
||||
GLubyte *data2 = (GLubyte *) malloc(w * h * 4);
|
||||
GLuint i;
|
||||
|
||||
/* random clear color */
|
||||
for (i = 0; i < 4; i++) {
|
||||
color[i] = rand() % 256;
|
||||
}
|
||||
|
||||
glClearColor(color[0] / 255.0,
|
||||
color[1] / 255.0,
|
||||
color[2] / 255.0,
|
||||
color[3] / 255.0);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
/* draw polygon over top half, in blue */
|
||||
glColor4ubv(blue);
|
||||
glRectf(0, 0.5, 1.0, 1.0);
|
||||
|
||||
/* get */
|
||||
glGetTexImage(GL_TEXTURE_2D, level, GL_RGBA, GL_UNSIGNED_BYTE, data2);
|
||||
|
||||
/* compare */
|
||||
for (i = 0; i < w * h; i += 4) {
|
||||
if (i < w * h / 2) {
|
||||
/* lower half */
|
||||
if (!ColorsEqual(color, data2 + i * 4)) {
|
||||
printf("Render to texture failure (expected clear color)!\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* upper half */
|
||||
if (!ColorsEqual(blue, data2 + i * 4)) {
|
||||
printf("Render to texture failure (expected blue)!\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(data2);
|
||||
}
|
||||
|
||||
free(data2);
|
||||
}
|
||||
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT(1, &fb);
|
||||
glDeleteTextures(1, &tex);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
|
||||
glDeleteFramebuffersEXT(1, &fb);
|
||||
glDeleteTextures(1, &tex);
|
||||
}
|
||||
|
||||
printf("Passed\n");
|
||||
}
|
||||
|
|
@ -152,11 +183,16 @@ Draw(void)
|
|||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
TestGetTexImage();
|
||||
TestGetTexImage(GL_FALSE);
|
||||
if (glutExtensionSupported("GL_ARB_texture_non_power_of_two"))
|
||||
TestGetTexImage(GL_TRUE);
|
||||
|
||||
if (glutExtensionSupported("GL_EXT_framebuffer_object") ||
|
||||
glutExtensionSupported("GL_ARB_framebuffer_object"))
|
||||
TestGetTexImageRTT();
|
||||
glutExtensionSupported("GL_ARB_framebuffer_object")) {
|
||||
TestGetTexImageRTT(GL_FALSE);
|
||||
if (glutExtensionSupported("GL_ARB_texture_non_power_of_two"))
|
||||
TestGetTexImageRTT(GL_TRUE);
|
||||
}
|
||||
|
||||
glutDestroyWindow(Win);
|
||||
exit(0);
|
||||
|
|
@ -171,10 +207,10 @@ Reshape(int width, int height)
|
|||
glViewport(0, 0, width, height);
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 5.0, 25.0);
|
||||
glOrtho(0, 1, 0, 1, -1, 1);
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -15.0);
|
||||
glTranslatef(0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
|
||||
|
|
@ -31,6 +32,8 @@ CheckError(int line)
|
|||
static void
|
||||
LoadCompressedImage(void)
|
||||
{
|
||||
unsigned char ImgDataTemp[ImgSize / 4];
|
||||
unsigned i;
|
||||
const GLenum filter = GL_LINEAR;
|
||||
glTexImage2D(Target, 0, CompFormat, ImgWidth, ImgHeight, 0,
|
||||
GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||
|
|
@ -40,11 +43,24 @@ LoadCompressedImage(void)
|
|||
0, 0, /* pos */
|
||||
ImgWidth, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 2, ImgData + ImgSize / 2);
|
||||
/* top half */
|
||||
|
||||
/* top left */
|
||||
for (i = 0; i < ImgHeight / 8; i++) {
|
||||
memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth], ImgWidth);
|
||||
}
|
||||
glCompressedTexSubImage2DARB(Target, 0,
|
||||
0, ImgHeight / 2, /* pos */
|
||||
ImgWidth, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 2, ImgData);
|
||||
ImgWidth / 2, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 4, ImgDataTemp);
|
||||
|
||||
/* top right */
|
||||
for (i = 0; i < ImgHeight / 8; i++) {
|
||||
memcpy(&ImgDataTemp[i * ImgWidth], &ImgData[i * 2 * ImgWidth + ImgWidth], ImgWidth);
|
||||
}
|
||||
glCompressedTexSubImage2DARB(Target, 0,
|
||||
ImgWidth / 2, ImgHeight / 2, /* pos */
|
||||
ImgWidth / 2, ImgHeight / 2,
|
||||
CompFormat, ImgSize / 4, ImgDataTemp);
|
||||
|
||||
glTexParameteri(Target, GL_TEXTURE_MIN_FILTER, filter);
|
||||
glTexParameteri(Target, GL_TEXTURE_MAG_FILTER, filter);
|
||||
|
|
|
|||
|
|
@ -258,8 +258,26 @@ static void Init( void )
|
|||
}
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, BORDER_TEXTURE);
|
||||
#ifdef TEST_PBO_DLIST
|
||||
/* test fetching teximage from PBO in display list */
|
||||
{
|
||||
GLuint b = 42, l = 10;
|
||||
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, b);
|
||||
glBufferDataARB(GL_PIXEL_UNPACK_BUFFER, sizeof(BorderImage),
|
||||
BorderImage, GL_STREAM_DRAW);
|
||||
|
||||
glNewList(l, GL_COMPILE);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, (void *) 0/* BorderImage*/);
|
||||
glEndList();
|
||||
glCallList(l);
|
||||
glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||
}
|
||||
#else
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, SIZE+2, SIZE+2, 1,
|
||||
GL_RGBA, GL_UNSIGNED_BYTE, (void *) BorderImage);
|
||||
#endif
|
||||
|
||||
for (i = 0; i < SIZE; i++) {
|
||||
for (j = 0; j < SIZE; j++) {
|
||||
|
|
|
|||
15
progs/trivial/.gitignore
vendored
15
progs/trivial/.gitignore
vendored
|
|
@ -5,10 +5,17 @@ clear-random
|
|||
clear-repeat
|
||||
clear-scissor
|
||||
clear-undefined
|
||||
createwin
|
||||
dlist-begin-call-end
|
||||
dlist-dangling
|
||||
dlist-degenerate
|
||||
dlist-edgeflag
|
||||
dlist-edgeflag-dangling
|
||||
dlist-flat-tri
|
||||
dlist-mat-tri
|
||||
dlist-recursive-call
|
||||
dlist-tri-flat-tri
|
||||
dlist-tri-mat-tri
|
||||
draw2arrays
|
||||
drawarrays
|
||||
drawelements
|
||||
|
|
@ -31,6 +38,7 @@ lineloop
|
|||
lineloop-clip
|
||||
lineloop-elts
|
||||
linestrip
|
||||
linestrip-clip
|
||||
linestrip-flat-stipple
|
||||
linestrip-stipple
|
||||
linestrip-stipple-wide
|
||||
|
|
@ -71,8 +79,10 @@ quadstrip-cont
|
|||
quadstrip-flat
|
||||
readtex.c
|
||||
readtex.h
|
||||
readpixels
|
||||
tri
|
||||
tri-alpha
|
||||
tri-alpha-tex
|
||||
tri-array-interleaved
|
||||
tri-blend
|
||||
tri-blend-color
|
||||
|
|
@ -80,6 +90,7 @@ tri-blend-max
|
|||
tri-blend-min
|
||||
tri-blend-revsub
|
||||
tri-blend-sub
|
||||
tri-clear
|
||||
tri-clip
|
||||
tri-cull
|
||||
tri-cull-both
|
||||
|
|
@ -94,6 +105,7 @@ tri-fog
|
|||
tri-fp
|
||||
tri-fp-const-imm
|
||||
tri-lit
|
||||
tri-lit-material
|
||||
tri-logicop-none
|
||||
tri-logicop-xor
|
||||
tri-mask-tri
|
||||
|
|
@ -102,6 +114,7 @@ tri-orig
|
|||
tri-query
|
||||
tri-repeat
|
||||
tri-scissor-tri
|
||||
tri-square
|
||||
tri-stencil
|
||||
tri-stipple
|
||||
tri-tex
|
||||
|
|
@ -111,6 +124,7 @@ tri-unfilled
|
|||
tri-unfilled-clip
|
||||
tri-unfilled-edgeflag
|
||||
tri-unfilled-fog
|
||||
tri-unfilled-point
|
||||
tri-unfilled-smooth
|
||||
tri-unfilled-tri
|
||||
tri-unfilled-tri-lit
|
||||
|
|
@ -119,6 +133,7 @@ tri-unfilled-userclip-stip
|
|||
tri-userclip
|
||||
tri-viewport
|
||||
tri-z
|
||||
tri-z-9
|
||||
tri-z-eq
|
||||
trifan
|
||||
trifan-flat
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ SOURCES = \
|
|||
clear-repeat.c \
|
||||
clear-random.c \
|
||||
clear.c \
|
||||
createwin.c \
|
||||
dlist-dangling.c \
|
||||
dlist-flat-tri.c \
|
||||
dlist-mat-tri.c \
|
||||
|
|
@ -48,6 +49,7 @@ SOURCES = \
|
|||
lineloop-clip.c \
|
||||
lineloop-elts.c \
|
||||
lineloop.c \
|
||||
linestrip-clip.c \
|
||||
linestrip-flat-stipple.c \
|
||||
linestrip-stipple-wide.c \
|
||||
linestrip-stipple.c \
|
||||
|
|
@ -87,7 +89,9 @@ SOURCES = \
|
|||
quadstrip-cont.c \
|
||||
quadstrip-flat.c \
|
||||
quadstrip.c \
|
||||
readpixels.c \
|
||||
tri-alpha.c \
|
||||
tri-alpha-tex.c \
|
||||
tri-array-interleaved.c \
|
||||
tri-blend-color.c \
|
||||
tri-blend-max.c \
|
||||
|
|
@ -95,6 +99,7 @@ SOURCES = \
|
|||
tri-blend-revsub.c \
|
||||
tri-blend-sub.c \
|
||||
tri-blend.c \
|
||||
tri-clear.c \
|
||||
tri-clip.c \
|
||||
tri-cull-both.c \
|
||||
tri-cull.c \
|
||||
|
|
@ -117,6 +122,7 @@ SOURCES = \
|
|||
tri-query.c \
|
||||
tri-repeat.c \
|
||||
tri-scissor-tri.c \
|
||||
tri-square.c \
|
||||
tri-stencil.c \
|
||||
tri-stipple.c \
|
||||
tri-multitex-vbo.c \
|
||||
|
|
@ -126,6 +132,7 @@ SOURCES = \
|
|||
tri-unfilled-fog.c \
|
||||
tri-unfilled-edgeflag.c \
|
||||
tri-unfilled-clip.c \
|
||||
tri-unfilled-point.c \
|
||||
tri-unfilled-smooth.c \
|
||||
tri-unfilled-tri.c \
|
||||
tri-unfilled-tri-lit.c \
|
||||
|
|
@ -134,6 +141,7 @@ SOURCES = \
|
|||
tri-unfilled.c \
|
||||
tri-userclip.c \
|
||||
tri-viewport.c \
|
||||
tri-z-9.c \
|
||||
tri-z-eq.c \
|
||||
tri-z.c \
|
||||
tri.c \
|
||||
|
|
|
|||
|
|
@ -9,21 +9,12 @@
|
|||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <GL/glew.h>
|
||||
#include <GL/glut.h>
|
||||
#include "shaderutil.h"
|
||||
|
||||
|
||||
static void
|
||||
Init(void)
|
||||
{
|
||||
static GLboolean firstCall = GL_TRUE;
|
||||
if (firstCall) {
|
||||
firstCall = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GLboolean
|
||||
ShadersSupported(void)
|
||||
{
|
||||
|
|
@ -47,8 +38,6 @@ CompileShaderText(GLenum shaderType, const char *text)
|
|||
GLuint shader;
|
||||
GLint stat;
|
||||
|
||||
Init();
|
||||
|
||||
shader = glCreateShader(shaderType);
|
||||
glShaderSource(shader, 1, (const GLchar **) &text, NULL);
|
||||
glCompileShader(shader);
|
||||
|
|
@ -79,9 +68,6 @@ CompileShaderFile(GLenum shaderType, const char *filename)
|
|||
GLuint shader;
|
||||
FILE *f;
|
||||
|
||||
Init();
|
||||
|
||||
|
||||
f = fopen(filename, "r");
|
||||
if (!f) {
|
||||
fprintf(stderr, "Unable to open shader file %s\n", filename);
|
||||
|
|
@ -136,7 +122,7 @@ LinkShaders(GLuint vertShader, GLuint fragShader)
|
|||
|
||||
|
||||
void
|
||||
InitUniforms(GLuint program, struct uniform_info uniforms[])
|
||||
SetUniformValues(GLuint program, struct uniform_info uniforms[])
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
|
|
@ -144,28 +130,133 @@ InitUniforms(GLuint program, struct uniform_info uniforms[])
|
|||
uniforms[i].location
|
||||
= glGetUniformLocation(program, uniforms[i].name);
|
||||
|
||||
printf("Uniform %s location: %d\n", uniforms[i].name,
|
||||
uniforms[i].location);
|
||||
|
||||
switch (uniforms[i].size) {
|
||||
case 1:
|
||||
if (uniforms[i].type == GL_INT)
|
||||
glUniform1i(uniforms[i].location,
|
||||
(GLint) uniforms[i].value[0]);
|
||||
else
|
||||
glUniform1fv(uniforms[i].location, 1, uniforms[i].value);
|
||||
switch (uniforms[i].type) {
|
||||
case GL_INT:
|
||||
case GL_SAMPLER_1D:
|
||||
case GL_SAMPLER_2D:
|
||||
case GL_SAMPLER_3D:
|
||||
case GL_SAMPLER_CUBE:
|
||||
case GL_SAMPLER_2D_RECT_ARB:
|
||||
glUniform1i(uniforms[i].location,
|
||||
(GLint) uniforms[i].value[0]);
|
||||
break;
|
||||
case 2:
|
||||
case GL_FLOAT:
|
||||
glUniform1fv(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case GL_FLOAT_VEC2:
|
||||
glUniform2fv(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 3:
|
||||
case GL_FLOAT_VEC3:
|
||||
glUniform3fv(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
case 4:
|
||||
case GL_FLOAT_VEC4:
|
||||
glUniform4fv(uniforms[i].location, 1, uniforms[i].value);
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
if (strncmp(uniforms[i].name, "gl_", 3) == 0) {
|
||||
/* built-in uniform: ignore */
|
||||
}
|
||||
else {
|
||||
fprintf(stderr,
|
||||
"Unexpected uniform data type in SetUniformValues\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Get list of uniforms used in the program */
|
||||
GLuint
|
||||
GetUniforms(GLuint program, struct uniform_info uniforms[])
|
||||
{
|
||||
GLint n, max, i;
|
||||
|
||||
glGetProgramiv(program, GL_ACTIVE_UNIFORMS, &n);
|
||||
glGetProgramiv(program, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint size, len;
|
||||
GLenum type;
|
||||
char name[100];
|
||||
|
||||
glGetActiveUniform(program, i, 100, &len, &size, &type, name);
|
||||
|
||||
uniforms[i].name = strdup(name);
|
||||
uniforms[i].size = size;
|
||||
uniforms[i].type = type;
|
||||
uniforms[i].location = glGetUniformLocation(program, name);
|
||||
}
|
||||
|
||||
uniforms[i].name = NULL; /* end of list */
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrintUniforms(const struct uniform_info uniforms[])
|
||||
{
|
||||
GLint i;
|
||||
|
||||
printf("Uniforms:\n");
|
||||
|
||||
for (i = 0; uniforms[i].name; i++) {
|
||||
printf(" %d: %s size=%d type=0x%x loc=%d value=%g, %g, %g, %g\n",
|
||||
i,
|
||||
uniforms[i].name,
|
||||
uniforms[i].size,
|
||||
uniforms[i].type,
|
||||
uniforms[i].location,
|
||||
uniforms[i].value[0],
|
||||
uniforms[i].value[1],
|
||||
uniforms[i].value[2],
|
||||
uniforms[i].value[3]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Get list of attribs used in the program */
|
||||
GLuint
|
||||
GetAttribs(GLuint program, struct attrib_info attribs[])
|
||||
{
|
||||
GLint n, max, i;
|
||||
|
||||
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &n);
|
||||
glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max);
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
GLint size, len;
|
||||
GLenum type;
|
||||
char name[100];
|
||||
|
||||
glGetActiveAttrib(program, i, 100, &len, &size, &type, name);
|
||||
|
||||
attribs[i].name = strdup(name);
|
||||
attribs[i].size = size;
|
||||
attribs[i].type = type;
|
||||
attribs[i].location = glGetAttribLocation(program, name);
|
||||
}
|
||||
|
||||
attribs[i].name = NULL; /* end of list */
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
PrintAttribs(const struct attrib_info attribs[])
|
||||
{
|
||||
GLint i;
|
||||
|
||||
printf("Attribs:\n");
|
||||
|
||||
for (i = 0; attribs[i].name; i++) {
|
||||
printf(" %d: %s size=%d type=0x%x loc=%d\n",
|
||||
i,
|
||||
attribs[i].name,
|
||||
attribs[i].size,
|
||||
attribs[i].type,
|
||||
attribs[i].location);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@
|
|||
struct uniform_info
|
||||
{
|
||||
const char *name;
|
||||
GLuint size;
|
||||
GLenum type; /**< GL_FLOAT or GL_INT */
|
||||
GLuint size; /**< number of value[] elements: 1, 2, 3 or 4 */
|
||||
GLenum type; /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */
|
||||
GLfloat value[4];
|
||||
GLint location; /**< filled in by InitUniforms() */
|
||||
};
|
||||
|
|
@ -15,6 +15,15 @@ struct uniform_info
|
|||
#define END_OF_UNIFORMS { NULL, 0, GL_NONE, { 0, 0, 0, 0 }, -1 }
|
||||
|
||||
|
||||
struct attrib_info
|
||||
{
|
||||
const char *name;
|
||||
GLuint size; /**< number of value[] elements: 1, 2, 3 or 4 */
|
||||
GLenum type; /**< GL_FLOAT, GL_FLOAT_VEC4, GL_INT, etc */
|
||||
GLint location;
|
||||
};
|
||||
|
||||
|
||||
extern GLboolean
|
||||
ShadersSupported(void);
|
||||
|
||||
|
|
@ -28,7 +37,18 @@ extern GLuint
|
|||
LinkShaders(GLuint vertShader, GLuint fragShader);
|
||||
|
||||
extern void
|
||||
InitUniforms(GLuint program, struct uniform_info uniforms[]);
|
||||
SetUniformValues(GLuint program, struct uniform_info uniforms[]);
|
||||
|
||||
extern GLuint
|
||||
GetUniforms(GLuint program, struct uniform_info uniforms[]);
|
||||
|
||||
extern void
|
||||
PrintUniforms(const struct uniform_info uniforms[]);
|
||||
|
||||
extern GLuint
|
||||
GetAttribs(GLuint program, struct attrib_info attribs[]);
|
||||
|
||||
extern void
|
||||
PrintAttribs(const struct attrib_info attribs[]);
|
||||
|
||||
#endif /* SHADER_UTIL_H */
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
!!ARBvp1.0
|
||||
PARAM arr[5] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}};
|
||||
PARAM arr[7] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}};
|
||||
ADDRESS addr;
|
||||
ARL addr.x, {3}.x;
|
||||
MOV result.color, arr[addr.x];
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
!!ARBvp1.0
|
||||
PARAM arr[5] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}};
|
||||
PARAM arr[7] = { {.0,.1,.2,.3}, {.4,.5,.6,.7}, {.8,.9,.10,.1}, {.12,.3,.4,.14}, {.5,.8,.1,.9}, {.2,0,.4,.1}, {.6,.1,.8,.9}};
|
||||
ADDRESS addr;
|
||||
ARL addr.x, {3}.x; # not actually used
|
||||
MOV result.color, arr[3];
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ PROGS = \
|
|||
glxsnoop \
|
||||
glxswapcontrol \
|
||||
manywin \
|
||||
multictx \
|
||||
offset \
|
||||
overlay \
|
||||
pbinfo \
|
||||
|
|
|
|||
|
|
@ -378,6 +378,9 @@ make_window( Display *dpy, const char *name,
|
|||
scrnum = DefaultScreen( dpy );
|
||||
root = RootWindow( dpy, scrnum );
|
||||
|
||||
if (visinfo)
|
||||
XFree(visinfo);
|
||||
|
||||
visinfo = glXChooseVisual( dpy, scrnum, attribs );
|
||||
if (!visinfo) {
|
||||
printf("Error: couldn't get an RGB, Double-buffered visual\n");
|
||||
|
|
|
|||
|
|
@ -23,10 +23,7 @@
|
|||
* This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
|
||||
* Port by Brian Paul 23 March 2001
|
||||
*
|
||||
* Command line options:
|
||||
* -info print GL implementation information
|
||||
* -stereo use stereo enabled GLX visual
|
||||
*
|
||||
* See usage() below for command line options.
|
||||
*/
|
||||
|
||||
|
||||
|
|
@ -45,10 +42,6 @@ typedef int (*PFNGLXGETSWAPINTERVALMESAPROC)(void);
|
|||
#endif
|
||||
|
||||
|
||||
static int is_glx_extension_supported(Display *dpy, const char *query);
|
||||
|
||||
static void query_vsync(Display *dpy);
|
||||
|
||||
#define BENCHMARK
|
||||
|
||||
#ifdef BENCHMARK
|
||||
|
|
@ -572,7 +565,7 @@ make_window( Display *dpy, const char *name,
|
|||
/**
|
||||
* Determine whether or not a GLX extension is supported.
|
||||
*/
|
||||
int
|
||||
static int
|
||||
is_glx_extension_supported(Display *dpy, const char *query)
|
||||
{
|
||||
const int scrnum = DefaultScreen(dpy);
|
||||
|
|
@ -592,7 +585,7 @@ is_glx_extension_supported(Display *dpy, const char *query)
|
|||
/**
|
||||
* Attempt to determine whether or not the display is synched to vblank.
|
||||
*/
|
||||
void
|
||||
static void
|
||||
query_vsync(Display *dpy)
|
||||
{
|
||||
int interval = 0;
|
||||
|
|
|
|||
|
|
@ -587,6 +587,9 @@ event_loop(Display *dpy, Window win)
|
|||
angle += 2.0;
|
||||
|
||||
draw();
|
||||
|
||||
glXSwapBuffers(dpy, win);
|
||||
|
||||
if ( get_frame_usage != NULL ) {
|
||||
GLfloat temp;
|
||||
|
||||
|
|
@ -594,8 +597,6 @@ event_loop(Display *dpy, Window win)
|
|||
frame_usage += temp;
|
||||
}
|
||||
|
||||
glXSwapBuffers(dpy, win);
|
||||
|
||||
/* calc framerate */
|
||||
{
|
||||
static int t0 = -1;
|
||||
|
|
|
|||
585
progs/xdemos/multictx.c
Normal file
585
progs/xdemos/multictx.c
Normal file
|
|
@ -0,0 +1,585 @@
|
|||
/*
|
||||
* Copyright (C) 2009 VMware, Inc. All Rights Reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
||||
* AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Test rendering with two contexts into one window.
|
||||
* Setup different rendering state for each context to check that
|
||||
* context switching is handled properly.
|
||||
*
|
||||
* Brian Paul
|
||||
* 6 Aug 2009
|
||||
*/
|
||||
|
||||
|
||||
#include <math.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/keysym.h>
|
||||
#include <GL/gl.h>
|
||||
#include <GL/glx.h>
|
||||
|
||||
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265
|
||||
#endif
|
||||
|
||||
|
||||
/** Event handler results: */
|
||||
#define NOP 0
|
||||
#define EXIT 1
|
||||
#define DRAW 2
|
||||
|
||||
static GLfloat view_rotx = 0.0, view_roty = 210.0, view_rotz = 0.0;
|
||||
static GLint gear1, gear2;
|
||||
static GLfloat angle = 0.0;
|
||||
|
||||
static GLboolean animate = GL_TRUE; /* Animation */
|
||||
|
||||
|
||||
static double
|
||||
current_time(void)
|
||||
{
|
||||
struct timeval tv;
|
||||
#ifdef __VMS
|
||||
(void) gettimeofday(&tv, NULL );
|
||||
#else
|
||||
struct timezone tz;
|
||||
(void) gettimeofday(&tv, &tz);
|
||||
#endif
|
||||
return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
* Draw a gear wheel. You'll probably want to call this function when
|
||||
* building a display list since we do a lot of trig here.
|
||||
*
|
||||
* Input: inner_radius - radius of hole at center
|
||||
* outer_radius - radius at center of teeth
|
||||
* width - width of gear
|
||||
* teeth - number of teeth
|
||||
* tooth_depth - depth of tooth
|
||||
*/
|
||||
static void
|
||||
gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
|
||||
GLint teeth, GLfloat tooth_depth)
|
||||
{
|
||||
GLint i;
|
||||
GLfloat r0, r1, r2;
|
||||
GLfloat angle, da;
|
||||
GLfloat u, v, len;
|
||||
|
||||
r0 = inner_radius;
|
||||
r1 = outer_radius - tooth_depth / 2.0;
|
||||
r2 = outer_radius + tooth_depth / 2.0;
|
||||
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
|
||||
glShadeModel(GL_FLAT);
|
||||
|
||||
glNormal3f(0.0, 0.0, 1.0);
|
||||
|
||||
/* draw front face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw front sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
glNormal3f(0.0, 0.0, -1.0);
|
||||
|
||||
/* draw back face */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
if (i < teeth) {
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
}
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw back sides of teeth */
|
||||
glBegin(GL_QUADS);
|
||||
da = 2.0 * M_PI / teeth / 4.0;
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
|
||||
/* draw outward faces of teeth */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i < teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
|
||||
glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
|
||||
u = r2 * cos(angle + da) - r1 * cos(angle);
|
||||
v = r2 * sin(angle + da) - r1 * sin(angle);
|
||||
len = sqrt(u * u + v * v);
|
||||
u /= len;
|
||||
v /= len;
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
|
||||
-width * 0.5);
|
||||
u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
|
||||
v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
|
||||
glNormal3f(v, -u, 0.0);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
width * 0.5);
|
||||
glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
|
||||
-width * 0.5);
|
||||
glNormal3f(cos(angle), sin(angle), 0.0);
|
||||
}
|
||||
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
|
||||
glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
|
||||
|
||||
glEnd();
|
||||
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
/* draw inside radius cylinder */
|
||||
glBegin(GL_QUAD_STRIP);
|
||||
for (i = 0; i <= teeth; i++) {
|
||||
angle = i * 2.0 * M_PI / teeth;
|
||||
glNormal3f(-cos(angle), -sin(angle), 0.0);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
|
||||
glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
|
||||
}
|
||||
glEnd();
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
draw(int ctx)
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glPushMatrix();
|
||||
glRotatef(view_rotx, 1.0, 0.0, 0.0);
|
||||
glRotatef(view_roty + angle, 0.0, 1.0, 0.0);
|
||||
glRotatef(view_rotz, 0.0, 0.0, 1.0);
|
||||
|
||||
if (ctx == 0) {
|
||||
glDisable(GL_CULL_FACE);
|
||||
glPushMatrix();
|
||||
glRotatef(angle, 0.0, 0.0, 1.0);
|
||||
glCallList(gear1);
|
||||
glPopMatrix();
|
||||
/* This should not effect the other context's rendering */
|
||||
glEnable(GL_CULL_FACE);
|
||||
glCullFace(GL_FRONT_AND_BACK);
|
||||
}
|
||||
else {
|
||||
glPushMatrix();
|
||||
glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
|
||||
glCallList(gear2);
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
glPopMatrix();
|
||||
|
||||
/* this flush is important since we'll be switching contexts next */
|
||||
glFlush();
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
draw_frame(Display *dpy, Window win, GLXContext ctx1, GLXContext ctx2)
|
||||
{
|
||||
static double tRot0 = -1.0;
|
||||
double dt, t = current_time();
|
||||
|
||||
if (tRot0 < 0.0)
|
||||
tRot0 = t;
|
||||
dt = t - tRot0;
|
||||
tRot0 = t;
|
||||
|
||||
if (animate) {
|
||||
/* advance rotation for next frame */
|
||||
angle += 70.0 * dt; /* 70 degrees per second */
|
||||
if (angle > 3600.0)
|
||||
angle -= 3600.0;
|
||||
}
|
||||
|
||||
glXMakeCurrent(dpy, (GLXDrawable) win, ctx1);
|
||||
draw(0);
|
||||
|
||||
glXMakeCurrent(dpy, (GLXDrawable) win, ctx2);
|
||||
draw(1);
|
||||
|
||||
glXSwapBuffers(dpy, win);
|
||||
}
|
||||
|
||||
|
||||
/* new window size or exposure */
|
||||
static void
|
||||
reshape(Display *dpy, Window win,
|
||||
GLXContext ctx1, GLXContext ctx2, int width, int height)
|
||||
{
|
||||
int i;
|
||||
|
||||
width /= 2;
|
||||
|
||||
/* loop: left half of window, right half of window */
|
||||
for (i = 0; i < 2; i++) {
|
||||
if (i == 0)
|
||||
glXMakeCurrent(dpy, win, ctx1);
|
||||
else
|
||||
glXMakeCurrent(dpy, win, ctx2);
|
||||
|
||||
glViewport(width * i, 0, width, height);
|
||||
glScissor(width * i, 0, width, height);
|
||||
|
||||
{
|
||||
GLfloat h = (GLfloat) height / (GLfloat) width;
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
|
||||
}
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glTranslatef(0.0, 0.0, -30.0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
init(Display *dpy, Window win, GLXContext ctx1, GLXContext ctx2)
|
||||
{
|
||||
static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
|
||||
static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
|
||||
static GLfloat green[4] = { 0.0, 0.8, 0.2, 0.5 };
|
||||
/*static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };*/
|
||||
|
||||
/* first ctx */
|
||||
{
|
||||
static GLuint stipple[32] = {
|
||||
0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff,
|
||||
0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff,
|
||||
|
||||
0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
|
||||
0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
|
||||
|
||||
0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff,
|
||||
0x00ff00ff, 0x00ff00ff, 0x00ff00ff, 0x00ff00ff,
|
||||
|
||||
0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00,
|
||||
0xff00ff00, 0xff00ff00, 0xff00ff00, 0xff00ff00
|
||||
};
|
||||
|
||||
glXMakeCurrent(dpy, win, ctx1);
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
gear1 = glGenLists(1);
|
||||
glNewList(gear1, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
|
||||
gear(1.0, 4.0, 1.0, 20, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glClearColor(0.4, 0.4, 0.4, 1.0);
|
||||
|
||||
glPolygonStipple((GLubyte *) stipple);
|
||||
glEnable(GL_POLYGON_STIPPLE);
|
||||
}
|
||||
|
||||
/* second ctx */
|
||||
{
|
||||
glXMakeCurrent(dpy, win, ctx2);
|
||||
|
||||
glLightfv(GL_LIGHT0, GL_POSITION, pos);
|
||||
glEnable(GL_LIGHTING);
|
||||
glEnable(GL_LIGHT0);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
|
||||
gear2 = glGenLists(1);
|
||||
glNewList(gear2, GL_COMPILE);
|
||||
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
|
||||
gear(1.5, 3.0, 1.5, 16, 0.7);
|
||||
glEndList();
|
||||
|
||||
glEnable(GL_NORMALIZE);
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glClearColor(0.6, 0.6, 0.6, 1.0);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create an RGB, double-buffered window.
|
||||
* Return the window and two context handles.
|
||||
*/
|
||||
static void
|
||||
make_window_and_contexts( Display *dpy, const char *name,
|
||||
int x, int y, int width, int height,
|
||||
Window *winRet,
|
||||
GLXContext *ctxRet1,
|
||||
GLXContext *ctxRet2)
|
||||
{
|
||||
int attribs[] = { GLX_RGBA,
|
||||
GLX_RED_SIZE, 1,
|
||||
GLX_GREEN_SIZE, 1,
|
||||
GLX_BLUE_SIZE, 1,
|
||||
GLX_DOUBLEBUFFER,
|
||||
GLX_DEPTH_SIZE, 1,
|
||||
None };
|
||||
int scrnum;
|
||||
XSetWindowAttributes attr;
|
||||
unsigned long mask;
|
||||
Window root;
|
||||
Window win;
|
||||
XVisualInfo *visinfo;
|
||||
|
||||
scrnum = DefaultScreen( dpy );
|
||||
root = RootWindow( dpy, scrnum );
|
||||
|
||||
visinfo = glXChooseVisual( dpy, scrnum, attribs );
|
||||
if (!visinfo) {
|
||||
printf("Error: couldn't get an RGB, Double-buffered visual\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
/* window attributes */
|
||||
attr.background_pixel = 0;
|
||||
attr.border_pixel = 0;
|
||||
attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
|
||||
attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
|
||||
mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
|
||||
|
||||
win = XCreateWindow( dpy, root, x, y, width, height,
|
||||
0, visinfo->depth, InputOutput,
|
||||
visinfo->visual, mask, &attr );
|
||||
|
||||
/* set hints and properties */
|
||||
{
|
||||
XSizeHints sizehints;
|
||||
sizehints.x = x;
|
||||
sizehints.y = y;
|
||||
sizehints.width = width;
|
||||
sizehints.height = height;
|
||||
sizehints.flags = USSize | USPosition;
|
||||
XSetNormalHints(dpy, win, &sizehints);
|
||||
XSetStandardProperties(dpy, win, name, name,
|
||||
None, (char **)NULL, 0, &sizehints);
|
||||
}
|
||||
|
||||
*winRet = win;
|
||||
*ctxRet1 = glXCreateContext( dpy, visinfo, NULL, True );
|
||||
*ctxRet2 = glXCreateContext( dpy, visinfo, NULL, True );
|
||||
|
||||
if (!*ctxRet1 || !*ctxRet2) {
|
||||
printf("Error: glXCreateContext failed\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
XFree(visinfo);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle one X event.
|
||||
* \return NOP, EXIT or DRAW
|
||||
*/
|
||||
static int
|
||||
handle_event(Display *dpy, Window win, GLXContext ctx1, GLXContext ctx2,
|
||||
XEvent *event)
|
||||
{
|
||||
(void) dpy;
|
||||
(void) win;
|
||||
|
||||
switch (event->type) {
|
||||
case Expose:
|
||||
return DRAW;
|
||||
case ConfigureNotify:
|
||||
reshape(dpy, win, ctx1, ctx2,
|
||||
event->xconfigure.width, event->xconfigure.height);
|
||||
break;
|
||||
case KeyPress:
|
||||
{
|
||||
char buffer[10];
|
||||
int r, code;
|
||||
code = XLookupKeysym(&event->xkey, 0);
|
||||
if (code == XK_Left) {
|
||||
view_roty += 5.0;
|
||||
}
|
||||
else if (code == XK_Right) {
|
||||
view_roty -= 5.0;
|
||||
}
|
||||
else if (code == XK_Up) {
|
||||
view_rotx += 5.0;
|
||||
}
|
||||
else if (code == XK_Down) {
|
||||
view_rotx -= 5.0;
|
||||
}
|
||||
else {
|
||||
r = XLookupString(&event->xkey, buffer, sizeof(buffer),
|
||||
NULL, NULL);
|
||||
if (buffer[0] == 27) {
|
||||
/* escape */
|
||||
return EXIT;
|
||||
}
|
||||
else if (buffer[0] == 'a' || buffer[0] == 'A') {
|
||||
animate = !animate;
|
||||
}
|
||||
}
|
||||
return DRAW;
|
||||
}
|
||||
}
|
||||
return NOP;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
event_loop(Display *dpy, Window win, GLXContext ctx1, GLXContext ctx2)
|
||||
{
|
||||
while (1) {
|
||||
int op;
|
||||
while (!animate || XPending(dpy) > 0) {
|
||||
XEvent event;
|
||||
XNextEvent(dpy, &event);
|
||||
op = handle_event(dpy, win, ctx1, ctx2, &event);
|
||||
if (op == EXIT)
|
||||
return;
|
||||
else if (op == DRAW)
|
||||
break;
|
||||
}
|
||||
|
||||
draw_frame(dpy, win, ctx1, ctx2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
unsigned int winWidth = 800, winHeight = 400;
|
||||
int x = 0, y = 0;
|
||||
Display *dpy;
|
||||
Window win;
|
||||
GLXContext ctx1, ctx2;
|
||||
char *dpyName = NULL;
|
||||
GLboolean printInfo = GL_FALSE;
|
||||
int i;
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (strcmp(argv[i], "-display") == 0) {
|
||||
dpyName = argv[i+1];
|
||||
i++;
|
||||
}
|
||||
else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
dpy = XOpenDisplay(dpyName);
|
||||
if (!dpy) {
|
||||
printf("Error: couldn't open display %s\n",
|
||||
dpyName ? dpyName : getenv("DISPLAY"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
make_window_and_contexts(dpy, "multictx", x, y, winWidth, winHeight,
|
||||
&win, &ctx1, &ctx2);
|
||||
XMapWindow(dpy, win);
|
||||
|
||||
if (printInfo) {
|
||||
printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
|
||||
printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
|
||||
printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
|
||||
printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
|
||||
}
|
||||
|
||||
init(dpy, win, ctx1, ctx2);
|
||||
|
||||
/* Set initial projection/viewing transformation.
|
||||
* We can't be sure we'll get a ConfigureNotify event when the window
|
||||
* first appears.
|
||||
*/
|
||||
reshape(dpy, win, ctx1, ctx2, winWidth, winHeight);
|
||||
|
||||
event_loop(dpy, win, ctx1, ctx2);
|
||||
|
||||
glDeleteLists(gear1, 1);
|
||||
glDeleteLists(gear2, 1);
|
||||
glXDestroyContext(dpy, ctx1);
|
||||
glXDestroyContext(dpy, ctx2);
|
||||
XDestroyWindow(dpy, win);
|
||||
XCloseDisplay(dpy);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -462,6 +462,8 @@ def generate(env):
|
|||
shlinkflags += [
|
||||
'-Wl,-Bsymbolic',
|
||||
]
|
||||
# Handle circular dependencies in the libraries
|
||||
env['_LIBFLAGS'] = '-Wl,--start-group ' + env['_LIBFLAGS'] + ' -Wl,--end-group'
|
||||
if platform == 'windows' and msvc:
|
||||
# See also:
|
||||
# - http://msdn2.microsoft.com/en-us/library/y0zzbyt4.aspx
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ TOP = ../../../..
|
|||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/egl/main
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/egl/main $(X11_INCLUDES)
|
||||
|
||||
|
||||
SOURCES = demo.c
|
||||
|
|
|
|||
|
|
@ -236,7 +236,7 @@ demoDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
{
|
||||
DemoSurface *fs = LookupDemoSurface(surface);
|
||||
_eglUnlinkSurface(&fs->Base);
|
||||
if (!fs->Base.IsBound)
|
||||
if (!_eglIsSurfaceBound(&fs->Base))
|
||||
free(fs);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -247,7 +247,7 @@ demoDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
{
|
||||
DemoContext *fc = LookupDemoContext(context);
|
||||
_eglUnlinkContext(&fc->Base);
|
||||
if (!fc->Base.IsBound)
|
||||
if (!_eglIsContextBound(&fc->Base))
|
||||
free(fc);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@ install:
|
|||
clean:
|
||||
-rm -f *.o
|
||||
-rm -f *.so
|
||||
-rm -f depend depend.bak
|
||||
|
||||
depend: $(SOURCES) $(HEADERS)
|
||||
@ echo "running $(MKDEP)"
|
||||
|
|
|
|||
|
|
@ -296,7 +296,7 @@ _eglDRIDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
|
||||
fs->drawable.destroyDrawable(disp, fs->drawable.private);
|
||||
|
||||
if (!fs->Base.IsBound)
|
||||
if (!_eglIsSurfaceBound(&fs->Base))
|
||||
free(fs);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -312,7 +312,7 @@ _eglDRIDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext context)
|
|||
|
||||
fc->driContext.destroyContext(disp, 0, fc->driContext.private);
|
||||
|
||||
if (!fc->Base.IsBound)
|
||||
if (!_eglIsContextBound(&fc->Base))
|
||||
free(fc);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -739,7 +739,7 @@ GLX_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
return EGL_TRUE;
|
||||
if (surf) {
|
||||
_eglUnlinkSurface(surf);
|
||||
if (!surf->IsBound)
|
||||
if (!_eglIsSurfaceBound(surf))
|
||||
free(surf);
|
||||
|
||||
return EGL_TRUE;
|
||||
|
|
|
|||
|
|
@ -958,7 +958,7 @@ xdri_eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
struct xdri_egl_surface *xdri_surf = lookup_surface(surface);
|
||||
if (xdri_surf) {
|
||||
_eglUnlinkSurface(&xdri_surf->Base);
|
||||
if (!xdri_surf->Base.IsBound) {
|
||||
if (!_eglIsSurfaceBound(&xdri_surf->Base)) {
|
||||
/*
|
||||
st_unreference_framebuffer(surf->Framebuffer);
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ TOP = ../../..
|
|||
include $(TOP)/configs/current
|
||||
|
||||
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi
|
||||
INCLUDE_DIRS = -I$(TOP)/include -I$(TOP)/src/mesa/glapi $(X11_INCLUDES)
|
||||
|
||||
HEADERS = \
|
||||
eglcompiler.h \
|
||||
|
|
@ -20,6 +20,7 @@ HEADERS = \
|
|||
eglhash.h \
|
||||
eglmisc.h \
|
||||
eglmode.h \
|
||||
eglmutex.h \
|
||||
eglscreen.h \
|
||||
eglstring.h \
|
||||
eglsurface.h \
|
||||
|
|
@ -74,6 +75,7 @@ install: default
|
|||
clean:
|
||||
-rm -f *.o *.so*
|
||||
-rm -f core.*
|
||||
-rm -f depend depend.bak
|
||||
|
||||
|
||||
depend: $(SOURCES) $(HEADERS)
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ EGLDisplay EGLAPIENTRY
|
|||
eglGetDisplay(NativeDisplayType nativeDisplay)
|
||||
{
|
||||
_EGLDisplay *dpy;
|
||||
_eglInitGlobals();
|
||||
dpy = _eglFindDisplay(nativeDisplay);
|
||||
if (!dpy) {
|
||||
dpy = _eglNewDisplay(nativeDisplay);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,39 @@
|
|||
#define EGLCOMPILER_INCLUDED
|
||||
|
||||
|
||||
/**
|
||||
* Get standard integer types
|
||||
*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
||||
# include <stdint.h>
|
||||
#elif defined(_MSC_VER)
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
# ifndef __eglplatform_h_
|
||||
typedef __int32 int32_t;
|
||||
# endif
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
# if defined(_WIN64)
|
||||
typedef __int64 intptr_t;
|
||||
typedef unsigned __int64 uintptr_t;
|
||||
# else
|
||||
typedef __int32 intptr_t;
|
||||
typedef unsigned __int32 uintptr_t;
|
||||
# endif
|
||||
|
||||
# define INT64_C(__val) __val##i64
|
||||
# define UINT64_C(__val) __val##ui64
|
||||
#else
|
||||
/* hope the best instead of adding a bunch of ifdef's */
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Function inlining
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ void
|
|||
_eglInitConfig(_EGLConfig *config, EGLint id)
|
||||
{
|
||||
memset(config, 0, sizeof(*config));
|
||||
config->Handle = (EGLConfig) id;
|
||||
config->Handle = (EGLConfig) _eglUIntToPointer((unsigned int) id);
|
||||
_eglSetConfigAttrib(config, EGL_CONFIG_ID, id);
|
||||
_eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGB, EGL_DONT_CARE);
|
||||
_eglSetConfigAttrib(config, EGL_BIND_TO_TEXTURE_RGBA, EGL_DONT_CARE);
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ _eglFillInConfigs(_EGLConfig * configs,
|
|||
{0x000000FF, 0x0000FF00, 0x00FF0000, 0xFF000000}, /* 8_8_8_8_REV */
|
||||
};
|
||||
|
||||
#if 0
|
||||
static const uint32_t masks_table_bgr[8][4] = {
|
||||
{0x00000000, 0x00000000, 0x00000000, 0x00000000},
|
||||
{0x00000000, 0x00000000, 0x00000000, 0x00000000},
|
||||
|
|
@ -177,6 +178,7 @@ _eglFillInConfigs(_EGLConfig * configs,
|
|||
{0x00000000, 0x00000000, 0x00000000, 0x00000000},
|
||||
{0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000}, /* 8_8_8_8_REV */
|
||||
};
|
||||
#endif
|
||||
|
||||
static const uint8_t bytes_per_pixel[8] = {
|
||||
0, 0, 0, 2, 2, 4, 0, 4
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ _eglDestroyContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx)
|
|||
_EGLContext *context = _eglLookupContext(ctx);
|
||||
if (context) {
|
||||
_eglUnlinkContext(context);
|
||||
if (!context->IsBound)
|
||||
if (!_eglIsContextBound(context))
|
||||
free(context);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
@ -146,10 +146,11 @@ _eglQueryContext(_EGLDriver *drv, EGLDisplay dpy, EGLContext ctx,
|
|||
* Then, the driver will do its device-dependent Make-Current stuff.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
||||
_eglMakeCurrent(_EGLDriver *drv, EGLDisplay display, EGLSurface d,
|
||||
EGLSurface r, EGLContext context)
|
||||
{
|
||||
_EGLThreadInfo *t = _eglGetCurrentThread();
|
||||
_EGLDisplay *dpy = _eglLookupDisplay(display);
|
||||
_EGLContext *ctx = _eglLookupContext(context);
|
||||
_EGLSurface *draw = _eglLookupSurface(d);
|
||||
_EGLSurface *read = _eglLookupSurface(r);
|
||||
|
|
@ -160,21 +161,23 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
|
||||
if (_eglIsCurrentThreadDummy())
|
||||
return _eglError(EGL_BAD_ALLOC, "eglMakeCurrent");
|
||||
if (dpy == NULL)
|
||||
return _eglError(EGL_BAD_DISPLAY, "eglMakeCurrent");
|
||||
|
||||
/* error checking */
|
||||
if (ctx) {
|
||||
/* error checking */
|
||||
if (ctx->Binding && ctx->Binding != t)
|
||||
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
|
||||
if (draw == NULL || read == NULL) {
|
||||
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
if (draw->Config != ctx->Config) {
|
||||
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
if (read->Config != ctx->Config) {
|
||||
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
return EGL_FALSE;
|
||||
EGLint err = (d == EGL_NO_SURFACE || r == EGL_NO_SURFACE)
|
||||
? EGL_BAD_MATCH : EGL_BAD_SURFACE;
|
||||
return _eglError(err, "eglMakeCurrent");
|
||||
}
|
||||
if (draw->Config != ctx->Config || read->Config != ctx->Config)
|
||||
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
if ((draw->Binding && draw->Binding->Binding != t) ||
|
||||
(read->Binding && read->Binding->Binding != t))
|
||||
return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
|
||||
|
||||
#ifdef EGL_VERSION_1_4
|
||||
/* OpenGL and OpenGL ES are conflicting */
|
||||
|
|
@ -194,6 +197,10 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
apiIndex = _eglConvertApiToIndex(ctx->ClientAPI);
|
||||
}
|
||||
else {
|
||||
if (context != EGL_NO_CONTEXT)
|
||||
return _eglError(EGL_BAD_CONTEXT, "eglMakeCurrent");
|
||||
if (draw != NULL || read != NULL)
|
||||
return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
apiIndex = t->CurrentAPIIndex;
|
||||
}
|
||||
|
||||
|
|
@ -201,60 +208,47 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface d,
|
|||
if (oldContext) {
|
||||
oldDrawSurface = oldContext->DrawSurface;
|
||||
oldReadSurface = oldContext->ReadSurface;
|
||||
}
|
||||
assert(oldDrawSurface);
|
||||
assert(oldReadSurface);
|
||||
|
||||
/*
|
||||
* check if the old context or surfaces need to be deleted
|
||||
*/
|
||||
if (oldDrawSurface != NULL) {
|
||||
oldDrawSurface->IsBound = EGL_FALSE;
|
||||
/* break old bindings */
|
||||
t->CurrentContexts[apiIndex] = NULL;
|
||||
oldContext->Binding = NULL;
|
||||
oldContext->DrawSurface = NULL;
|
||||
oldContext->ReadSurface = NULL;
|
||||
oldDrawSurface->Binding = NULL;
|
||||
oldReadSurface->Binding = NULL;
|
||||
|
||||
/*
|
||||
* check if the old context or surfaces need to be deleted
|
||||
* FIXME They are linked so that they can be unlinked. This is ugly.
|
||||
*/
|
||||
if (!_eglIsSurfaceLinked(oldDrawSurface)) {
|
||||
/* make sure we don't try to rebind a deleted surface */
|
||||
if (draw == oldDrawSurface || draw == oldReadSurface) {
|
||||
draw = NULL;
|
||||
}
|
||||
/* really delete surface now */
|
||||
drv->API.DestroySurface(drv, dpy, oldDrawSurface->Handle);
|
||||
assert(draw != oldDrawSurface && read != oldDrawSurface);
|
||||
drv->API.DestroySurface(drv, display,
|
||||
_eglLinkSurface(oldDrawSurface, dpy));
|
||||
}
|
||||
}
|
||||
if (oldReadSurface != NULL && oldReadSurface != oldDrawSurface) {
|
||||
oldReadSurface->IsBound = EGL_FALSE;
|
||||
if (!_eglIsSurfaceLinked(oldReadSurface)) {
|
||||
/* make sure we don't try to rebind a deleted surface */
|
||||
if (read == oldDrawSurface || read == oldReadSurface) {
|
||||
read = NULL;
|
||||
}
|
||||
/* really delete surface now */
|
||||
drv->API.DestroySurface(drv, dpy, oldReadSurface->Handle);
|
||||
if (oldReadSurface != oldDrawSurface &&
|
||||
!_eglIsSurfaceLinked(oldReadSurface)) {
|
||||
assert(draw != oldReadSurface && read != oldReadSurface);
|
||||
drv->API.DestroySurface(drv, display,
|
||||
_eglLinkSurface(oldReadSurface, dpy));
|
||||
}
|
||||
}
|
||||
if (oldContext != NULL) {
|
||||
oldContext->IsBound = EGL_FALSE;
|
||||
if (!_eglIsContextLinked(oldContext)) {
|
||||
/* make sure we don't try to rebind a deleted context */
|
||||
if (ctx == oldContext) {
|
||||
ctx = NULL;
|
||||
}
|
||||
/* really delete context now */
|
||||
drv->API.DestroyContext(drv, dpy, _eglGetContextHandle(oldContext));
|
||||
assert(ctx != oldContext);
|
||||
drv->API.DestroyContext(drv, display,
|
||||
_eglLinkContext(oldContext, dpy));
|
||||
}
|
||||
}
|
||||
|
||||
/* build new bindings */
|
||||
if (ctx) {
|
||||
/* check read/draw again, in case we deleted them above */
|
||||
if (draw == NULL || read == NULL) {
|
||||
_eglError(EGL_BAD_MATCH, "eglMakeCurrent");
|
||||
return EGL_FALSE;
|
||||
}
|
||||
t->CurrentContexts[apiIndex] = ctx;
|
||||
ctx->Binding = t;
|
||||
ctx->DrawSurface = draw;
|
||||
ctx->ReadSurface = read;
|
||||
ctx->IsBound = EGL_TRUE;
|
||||
draw->IsBound = EGL_TRUE;
|
||||
read->IsBound = EGL_TRUE;
|
||||
t->CurrentContexts[apiIndex] = ctx;
|
||||
}
|
||||
else {
|
||||
t->CurrentContexts[apiIndex] = NULL;
|
||||
draw->Binding = ctx;
|
||||
read->Binding = ctx;
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ struct _egl_context
|
|||
_EGLDisplay *Display;
|
||||
_EGLContext *Next;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
/* The bound status of the context */
|
||||
_EGLThreadInfo *Binding;
|
||||
_EGLSurface *DrawSurface;
|
||||
_EGLSurface *ReadSurface;
|
||||
|
||||
EGLBoolean IsBound;
|
||||
_EGLConfig *Config;
|
||||
|
||||
EGLint ClientAPI; /**< EGL_OPENGL_ES_API, EGL_OPENGL_API, EGL_OPENVG_API */
|
||||
EGLint ClientVersion; /**< 1 = OpenGLES 1.x, 2 = OpenGLES 2.x */
|
||||
|
|
@ -51,4 +51,15 @@ _eglMakeCurrent(_EGLDriver *drv, EGLDisplay dpy, EGLSurface draw, EGLSurface rea
|
|||
extern EGLBoolean
|
||||
_eglCopyContextMESA(_EGLDriver *drv, EGLDisplay dpy, EGLContext source, EGLContext dest, EGLint mask);
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the context is bound to a thread.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglIsContextBound(_EGLContext *ctx)
|
||||
{
|
||||
return (ctx->Binding != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLCONTEXT_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -3,39 +3,51 @@
|
|||
#include "eglcurrent.h"
|
||||
#include "eglcontext.h"
|
||||
#include "egllog.h"
|
||||
#include "eglmutex.h"
|
||||
#include "eglglobals.h"
|
||||
|
||||
|
||||
/* This should be kept in sync with _eglInitThreadInfo() */
|
||||
#define _EGL_THREAD_INFO_INITIALIZER \
|
||||
{ EGL_SUCCESS, { NULL }, 1 }
|
||||
|
||||
/* a fallback thread info to guarantee that every thread always has one */
|
||||
static _EGLThreadInfo dummy_thread;
|
||||
static _EGLThreadInfo dummy_thread = _EGL_THREAD_INFO_INITIALIZER;
|
||||
|
||||
|
||||
#ifdef GLX_USE_TLS
|
||||
static __thread const _EGLThreadInfo *_egl_TSD;
|
||||
__attribute__ ((tls_model("initial-exec")));
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void) { return EGL_TRUE; }
|
||||
static INLINE void _eglFiniTSD(void) { }
|
||||
static INLINE void _eglSetTSD(const _EGLThreadInfo *t) { _egl_TSD = t; }
|
||||
static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
|
||||
{
|
||||
_egl_TSD = t;
|
||||
}
|
||||
|
||||
static INLINE _EGLThreadInfo *_eglGetTSD(void)
|
||||
{
|
||||
return (_EGLThreadInfo *) _egl_TSD;
|
||||
}
|
||||
|
||||
static INLINE void _eglFiniTSD(void)
|
||||
{
|
||||
}
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
|
||||
{
|
||||
/* TODO destroy TSD */
|
||||
(void) dtor;
|
||||
(void) _eglFiniTSD;
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
#elif PTHREADS
|
||||
#include <pthread.h>
|
||||
|
||||
static _EGL_DECLARE_MUTEX(_egl_TSDMutex);
|
||||
static EGLBoolean _egl_TSDInitialized;
|
||||
static pthread_key_t _egl_TSD;
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void)
|
||||
{
|
||||
return (pthread_key_create(&_egl_TSD, NULL) == 0);
|
||||
}
|
||||
|
||||
static INLINE void _eglFiniTSD(void)
|
||||
{
|
||||
pthread_key_delete(_egl_TSD);
|
||||
}
|
||||
static void (*_egl_FreeTSD)(_EGLThreadInfo *);
|
||||
|
||||
static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
|
||||
{
|
||||
|
|
@ -47,17 +59,71 @@ static INLINE _EGLThreadInfo *_eglGetTSD(void)
|
|||
return (_EGLThreadInfo *) pthread_getspecific(_egl_TSD);
|
||||
}
|
||||
|
||||
static INLINE void _eglFiniTSD(void)
|
||||
{
|
||||
_eglLockMutex(&_egl_TSDMutex);
|
||||
if (_egl_TSDInitialized) {
|
||||
_EGLThreadInfo *t = _eglGetTSD();
|
||||
|
||||
_egl_TSDInitialized = EGL_FALSE;
|
||||
if (t && _egl_FreeTSD)
|
||||
_egl_FreeTSD((void *) t);
|
||||
pthread_key_delete(_egl_TSD);
|
||||
}
|
||||
_eglUnlockMutex(&_egl_TSDMutex);
|
||||
}
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
|
||||
{
|
||||
if (!_egl_TSDInitialized) {
|
||||
_eglLockMutex(&_egl_TSDMutex);
|
||||
|
||||
/* check again after acquiring lock */
|
||||
if (!_egl_TSDInitialized) {
|
||||
if (pthread_key_create(&_egl_TSD, (void (*)(void *)) dtor) != 0) {
|
||||
_eglUnlockMutex(&_egl_TSDMutex);
|
||||
return EGL_FALSE;
|
||||
}
|
||||
_egl_FreeTSD = dtor;
|
||||
_eglAddAtExitCall(_eglFiniTSD);
|
||||
_egl_TSDInitialized = EGL_TRUE;
|
||||
}
|
||||
|
||||
_eglUnlockMutex(&_egl_TSDMutex);
|
||||
}
|
||||
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
#else /* PTHREADS */
|
||||
static const _EGLThreadInfo *_egl_TSD;
|
||||
static void (*_egl_FreeTSD)(_EGLThreadInfo *);
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void) { return EGL_TRUE; }
|
||||
static INLINE void _eglFiniTSD(void) { }
|
||||
static INLINE void _eglSetTSD(const _EGLThreadInfo *t) { _egl_TSD = t; }
|
||||
static INLINE void _eglSetTSD(const _EGLThreadInfo *t)
|
||||
{
|
||||
_egl_TSD = t;
|
||||
}
|
||||
|
||||
static INLINE _EGLThreadInfo *_eglGetTSD(void)
|
||||
{
|
||||
return (_EGLThreadInfo *) _egl_TSD;
|
||||
}
|
||||
|
||||
static INLINE void _eglFiniTSD(void)
|
||||
{
|
||||
if (_egl_FreeTSD && _egl_TSD)
|
||||
_egl_FreeTSD((_EGLThreadInfo *) _egl_TSD);
|
||||
}
|
||||
|
||||
static INLINE EGLBoolean _eglInitTSD(void (*dtor)(_EGLThreadInfo *))
|
||||
{
|
||||
if (!_egl_FreeTSD && dtor) {
|
||||
_egl_FreeTSD = dtor;
|
||||
_eglAddAtExitCall(_eglFiniTSD);
|
||||
}
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
||||
#endif /* !PTHREADS */
|
||||
|
||||
|
||||
|
|
@ -98,24 +164,17 @@ _eglDestroyThreadInfo(_EGLThreadInfo *t)
|
|||
|
||||
|
||||
/**
|
||||
* Initialize "current thread" management.
|
||||
* Make sure TSD is initialized and return current value.
|
||||
*/
|
||||
EGLBoolean
|
||||
_eglInitCurrent(void)
|
||||
static INLINE _EGLThreadInfo *
|
||||
_eglCheckedGetTSD(void)
|
||||
{
|
||||
_eglInitThreadInfo(&dummy_thread);
|
||||
return _eglInitTSD();
|
||||
}
|
||||
if (_eglInitTSD(&_eglDestroyThreadInfo) != EGL_TRUE) {
|
||||
_eglLog(_EGL_FATAL, "failed to initialize \"current\" system");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Finish "current thread" management.
|
||||
*/
|
||||
void
|
||||
_eglFiniCurrent(void)
|
||||
{
|
||||
/* TODO trace and release all threads... */
|
||||
_eglFiniTSD();
|
||||
return _eglGetTSD();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -129,7 +188,7 @@ _eglFiniCurrent(void)
|
|||
_EGLThreadInfo *
|
||||
_eglGetCurrentThread(void)
|
||||
{
|
||||
_EGLThreadInfo *t = _eglGetTSD();
|
||||
_EGLThreadInfo *t = _eglCheckedGetTSD();
|
||||
if (!t) {
|
||||
t = _eglCreateThreadInfo();
|
||||
_eglSetTSD(t);
|
||||
|
|
@ -145,7 +204,7 @@ _eglGetCurrentThread(void)
|
|||
void
|
||||
_eglDestroyCurrentThread(void)
|
||||
{
|
||||
_EGLThreadInfo *t = _eglGetTSD();
|
||||
_EGLThreadInfo *t = _eglCheckedGetTSD();
|
||||
if (t) {
|
||||
_eglDestroyThreadInfo(t);
|
||||
_eglSetTSD(NULL);
|
||||
|
|
@ -162,7 +221,7 @@ _eglDestroyCurrentThread(void)
|
|||
EGLBoolean
|
||||
_eglIsCurrentThreadDummy(void)
|
||||
{
|
||||
_EGLThreadInfo *t = _eglGetTSD();
|
||||
_EGLThreadInfo *t = _eglCheckedGetTSD();
|
||||
return (!t || t == &dummy_thread);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,6 @@ struct _egl_thread_info
|
|||
};
|
||||
|
||||
|
||||
extern EGLBoolean
|
||||
_eglInitCurrent(void);
|
||||
|
||||
|
||||
extern void
|
||||
_eglFiniCurrent(void);
|
||||
|
||||
|
||||
/**
|
||||
* Return true if a client API enum can be converted to an index.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
/**
|
||||
* Functions related to EGLDisplay.
|
||||
*/
|
||||
|
|
@ -13,6 +12,67 @@
|
|||
#include "eglglobals.h"
|
||||
#include "eglhash.h"
|
||||
#include "eglstring.h"
|
||||
#include "eglmutex.h"
|
||||
#include "egllog.h"
|
||||
|
||||
|
||||
static _EGL_DECLARE_MUTEX(_eglDisplayInitMutex);
|
||||
static _EGLHashtable *_eglDisplayHash;
|
||||
/* TODO surface hash table should be per-display */
|
||||
static _EGLHashtable *_eglSurfaceHash;
|
||||
|
||||
|
||||
/**
|
||||
* Finish display management.
|
||||
*/
|
||||
static void
|
||||
_eglFiniDisplay(void)
|
||||
{
|
||||
_eglLockMutex(&_eglDisplayInitMutex);
|
||||
if (_eglDisplayHash) {
|
||||
EGLuint key = _eglHashFirstEntry(_eglDisplayHash);
|
||||
|
||||
while (key) {
|
||||
_EGLDisplay *dpy = (_EGLDisplay *)
|
||||
_eglHashLookup(_eglDisplayHash, key);
|
||||
assert(dpy);
|
||||
|
||||
if (dpy->ContextList || dpy->SurfaceList)
|
||||
_eglLog(_EGL_DEBUG, "Display %u is destroyed with resources", key);
|
||||
|
||||
_eglCleanupDisplay(dpy);
|
||||
free(dpy);
|
||||
|
||||
key = _eglHashNextEntry(_eglDisplayHash, key);
|
||||
}
|
||||
|
||||
_eglDeleteHashTable(_eglDisplayHash);
|
||||
_eglDisplayHash = NULL;
|
||||
_eglDeleteHashTable(_eglSurfaceHash);
|
||||
_eglSurfaceHash = NULL;
|
||||
}
|
||||
_eglUnlockMutex(&_eglDisplayInitMutex);
|
||||
}
|
||||
|
||||
|
||||
/* This can be avoided if hash table can be statically initialized */
|
||||
static INLINE void
|
||||
_eglInitDisplay(void)
|
||||
{
|
||||
if (!_eglDisplayHash) {
|
||||
_eglLockMutex(&_eglDisplayInitMutex);
|
||||
|
||||
/* check again after acquiring lock */
|
||||
if (!_eglDisplayHash) {
|
||||
_eglDisplayHash = _eglNewHashTable();
|
||||
_eglSurfaceHash = _eglNewHashTable();
|
||||
|
||||
_eglAddAtExitCall(_eglFiniDisplay);
|
||||
}
|
||||
|
||||
_eglUnlockMutex(&_eglDisplayInitMutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -31,6 +91,9 @@ _eglNewDisplay(NativeDisplayType nativeDisplay)
|
|||
dpy->Xdpy = (Display *) nativeDisplay;
|
||||
#endif
|
||||
|
||||
_eglInitDisplay();
|
||||
dpy->SurfaceHash = _eglSurfaceHash;
|
||||
|
||||
dpy->DriverName = _eglChooseDriver(dpy);
|
||||
if (!dpy->DriverName) {
|
||||
free(dpy);
|
||||
|
|
@ -49,11 +112,14 @@ EGLDisplay
|
|||
_eglLinkDisplay(_EGLDisplay *dpy)
|
||||
{
|
||||
EGLuint key;
|
||||
key = _eglHashGenKey(_eglGlobal.Displays);
|
||||
|
||||
_eglInitDisplay();
|
||||
|
||||
key = _eglHashGenKey(_eglDisplayHash);
|
||||
assert(key);
|
||||
/* "link" the display to the hash table */
|
||||
_eglHashInsert(_eglGlobal.Displays, key, dpy);
|
||||
dpy->Handle = (EGLDisplay) key;
|
||||
_eglHashInsert(_eglDisplayHash, key, dpy);
|
||||
dpy->Handle = (EGLDisplay) _eglUIntToPointer(key);
|
||||
|
||||
return dpy->Handle;
|
||||
}
|
||||
|
|
@ -66,7 +132,11 @@ _eglLinkDisplay(_EGLDisplay *dpy)
|
|||
void
|
||||
_eglUnlinkDisplay(_EGLDisplay *dpy)
|
||||
{
|
||||
_eglHashRemove(_eglGlobal.Displays, (EGLuint) dpy->Handle);
|
||||
EGLuint key = _eglPointerToUInt((void *) dpy->Handle);
|
||||
|
||||
_eglInitDisplay();
|
||||
|
||||
_eglHashRemove(_eglDisplayHash, key);
|
||||
dpy->Handle = EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
|
|
@ -83,7 +153,7 @@ _eglGetDisplayHandle(_EGLDisplay *display)
|
|||
return EGL_NO_DISPLAY;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Lookup a handle to find the linked display.
|
||||
* Return NULL if the handle has no corresponding linked display.
|
||||
|
|
@ -91,8 +161,11 @@ _eglGetDisplayHandle(_EGLDisplay *display)
|
|||
_EGLDisplay *
|
||||
_eglLookupDisplay(EGLDisplay dpy)
|
||||
{
|
||||
EGLuint key = (EGLuint) dpy;
|
||||
return (_EGLDisplay *) _eglHashLookup(_eglGlobal.Displays, key);
|
||||
EGLuint key = _eglPointerToUInt((void *) dpy);
|
||||
|
||||
_eglInitDisplay();
|
||||
|
||||
return (_EGLDisplay *) _eglHashLookup(_eglDisplayHash, key);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -103,17 +176,20 @@ _eglLookupDisplay(EGLDisplay dpy)
|
|||
_EGLDisplay *
|
||||
_eglFindDisplay(NativeDisplayType nativeDisplay)
|
||||
{
|
||||
EGLuint key = _eglHashFirstEntry(_eglGlobal.Displays);
|
||||
EGLuint key;
|
||||
|
||||
_eglInitDisplay();
|
||||
|
||||
/* Walk the hash table. Should switch to list if it is a problem. */
|
||||
key = _eglHashFirstEntry(_eglDisplayHash);
|
||||
while (key) {
|
||||
_EGLDisplay *dpy = (_EGLDisplay *)
|
||||
_eglHashLookup(_eglGlobal.Displays, key);
|
||||
_eglHashLookup(_eglDisplayHash, key);
|
||||
assert(dpy);
|
||||
|
||||
if (dpy->NativeDisplay == nativeDisplay)
|
||||
return dpy;
|
||||
key = _eglHashNextEntry(_eglGlobal.Displays, key);
|
||||
key = _eglHashNextEntry(_eglDisplayHash, key);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
|
|
@ -224,7 +300,7 @@ _eglUnlinkContext(_EGLContext *ctx)
|
|||
EGLContext
|
||||
_eglGetContextHandle(_EGLContext *ctx)
|
||||
{
|
||||
return (EGLContext) (ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT;
|
||||
return (EGLContext) ((ctx && ctx->Display) ? ctx : EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -253,11 +329,11 @@ _eglLinkSurface(_EGLSurface *surf, _EGLDisplay *dpy)
|
|||
surf->Next = dpy->SurfaceList;
|
||||
dpy->SurfaceList = surf;
|
||||
|
||||
key = _eglHashGenKey(_eglGlobal.Surfaces);
|
||||
key = _eglHashGenKey(dpy->SurfaceHash);
|
||||
assert(key);
|
||||
_eglHashInsert(_eglGlobal.Surfaces, key, surf);
|
||||
_eglHashInsert(dpy->SurfaceHash, key, surf);
|
||||
|
||||
surf->Handle = (EGLSurface) key;
|
||||
surf->Handle = (EGLSurface) _eglUIntToPointer(key);
|
||||
return surf->Handle;
|
||||
}
|
||||
|
||||
|
|
@ -270,8 +346,9 @@ void
|
|||
_eglUnlinkSurface(_EGLSurface *surf)
|
||||
{
|
||||
_EGLSurface *prev;
|
||||
EGLuint key = _eglPointerToUInt((void *) surf->Handle);
|
||||
|
||||
_eglHashRemove(_eglGlobal.Surfaces, (EGLuint) surf->Handle);
|
||||
_eglHashRemove(surf->Display->SurfaceHash, key);
|
||||
surf->Handle = EGL_NO_SURFACE;
|
||||
|
||||
prev = surf->Display->SurfaceList;
|
||||
|
|
@ -314,7 +391,6 @@ _eglGetSurfaceHandle(_EGLSurface *surface)
|
|||
_EGLSurface *
|
||||
_eglLookupSurface(EGLSurface surf)
|
||||
{
|
||||
_EGLSurface *c = (_EGLSurface *) _eglHashLookup(_eglGlobal.Surfaces,
|
||||
(EGLuint) surf);
|
||||
return c;
|
||||
EGLuint key = _eglPointerToUInt((void *) surf);
|
||||
return (_EGLSurface *) _eglHashLookup(_eglSurfaceHash, key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#endif
|
||||
|
||||
#include "egltypedefs.h"
|
||||
#include "eglhash.h"
|
||||
|
||||
|
||||
struct _egl_display
|
||||
|
|
@ -26,6 +27,10 @@ struct _egl_display
|
|||
/* lists of linked contexts and surface */
|
||||
_EGLContext *ContextList;
|
||||
_EGLSurface *SurfaceList;
|
||||
|
||||
/* hash table to map surfaces to handles */
|
||||
_EGLHashtable *SurfaceHash;
|
||||
|
||||
#ifdef _EGL_PLATFORM_X
|
||||
Display *Xdpy;
|
||||
#endif
|
||||
|
|
@ -125,4 +130,25 @@ _eglIsSurfaceLinked(_EGLSurface *surf)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cast an unsigned int to a pointer.
|
||||
*/
|
||||
static INLINE void *
|
||||
_eglUIntToPointer(unsigned int v)
|
||||
{
|
||||
return (void *) ((uintptr_t) v);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Cast a pointer to an unsigned int. The pointer must be one that is
|
||||
* returned by _eglUIntToPointer.
|
||||
*/
|
||||
static INLINE unsigned int
|
||||
_eglPointerToUInt(const void *p)
|
||||
{
|
||||
return (unsigned int) ((uintptr_t) p);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLDISPLAY_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -1,41 +1,53 @@
|
|||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include "eglglobals.h"
|
||||
#include "egldisplay.h"
|
||||
#include "egllog.h"
|
||||
#include "eglmutex.h"
|
||||
|
||||
struct _egl_global _eglGlobal =
|
||||
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
|
||||
|
||||
static _EGL_DECLARE_MUTEX(_eglGlobalMutex);
|
||||
struct _egl_global _eglGlobal =
|
||||
{
|
||||
EGL_FALSE
|
||||
&_eglGlobalMutex, /* Mutex */
|
||||
1, /* FreeScreenHandle */
|
||||
0x0, /* ClientAPIsMask */
|
||||
{ 0x0 }, /* ClientAPIs */
|
||||
0, /* NumDrivers */
|
||||
{ NULL }, /* Drivers */
|
||||
0, /* NumAtExitCalls */
|
||||
{ NULL }, /* AtExitCalls */
|
||||
};
|
||||
|
||||
/**
|
||||
* Init the fields in the _eglGlobal struct
|
||||
* May be safely called more than once.
|
||||
*/
|
||||
void
|
||||
_eglInitGlobals(void)
|
||||
|
||||
static void
|
||||
_eglAtExit(void)
|
||||
{
|
||||
if (!_eglGlobal.Initialized) {
|
||||
_eglGlobal.Displays = _eglNewHashTable();
|
||||
_eglGlobal.Surfaces = _eglNewHashTable();
|
||||
_eglGlobal.FreeScreenHandle = 1;
|
||||
_eglGlobal.Initialized = EGL_TRUE;
|
||||
EGLint i;
|
||||
for (i = _eglGlobal.NumAtExitCalls - 1; i >= 0; i--)
|
||||
_eglGlobal.AtExitCalls[i]();
|
||||
}
|
||||
|
||||
_eglGlobal.ClientAPIsMask = 0x0;
|
||||
|
||||
if (!_eglInitCurrent())
|
||||
_eglLog(_EGL_FATAL, "failed to initialize \"current\" system");
|
||||
void
|
||||
_eglAddAtExitCall(void (*func)(void))
|
||||
{
|
||||
if (func) {
|
||||
static EGLBoolean registered = EGL_FALSE;
|
||||
|
||||
_eglLockMutex(_eglGlobal.Mutex);
|
||||
|
||||
if (!registered) {
|
||||
atexit(_eglAtExit);
|
||||
registered = EGL_TRUE;
|
||||
}
|
||||
|
||||
assert(_eglGlobal.NumAtExitCalls < ARRAY_SIZE(_eglGlobal.AtExitCalls));
|
||||
_eglGlobal.AtExitCalls[_eglGlobal.NumAtExitCalls++] = func;
|
||||
|
||||
_eglUnlockMutex(_eglGlobal.Mutex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should call this via an atexit handler.
|
||||
*/
|
||||
void
|
||||
_eglDestroyGlobals(void)
|
||||
{
|
||||
_eglFiniCurrent();
|
||||
/* XXX TODO walk over table entries, deleting each */
|
||||
_eglDeleteHashTable(_eglGlobal.Displays);
|
||||
_eglDeleteHashTable(_eglGlobal.Surfaces);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
#include "egltypedefs.h"
|
||||
#include "eglhash.h"
|
||||
#include "eglcurrent.h"
|
||||
#include "eglmutex.h"
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -11,12 +12,7 @@
|
|||
*/
|
||||
struct _egl_global
|
||||
{
|
||||
EGLBoolean Initialized;
|
||||
|
||||
/* these are private to egldisplay.c */
|
||||
_EGLHashtable *Displays;
|
||||
_EGLHashtable *Surfaces;
|
||||
|
||||
_EGLMutex *Mutex;
|
||||
EGLScreenMESA FreeScreenHandle;
|
||||
|
||||
/* bitmaks of supported APIs (supported by _some_ driver) */
|
||||
|
|
@ -26,6 +22,9 @@ struct _egl_global
|
|||
|
||||
EGLint NumDrivers;
|
||||
_EGLDriver *Drivers[10];
|
||||
|
||||
EGLint NumAtExitCalls;
|
||||
void (*AtExitCalls[10])(void);
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -33,11 +32,7 @@ extern struct _egl_global _eglGlobal;
|
|||
|
||||
|
||||
extern void
|
||||
_eglInitGlobals(void);
|
||||
|
||||
|
||||
extern void
|
||||
_eglDestroyGlobals(void);
|
||||
_eglAddAtExitCall(void (*func)(void));
|
||||
|
||||
|
||||
#endif /* EGLGLOBALS_INCLUDED */
|
||||
|
|
|
|||
52
src/egl/main/eglmutex.h
Normal file
52
src/egl/main/eglmutex.h
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
#ifndef EGLMUTEX_INCLUDED
|
||||
#define EGLMUTEX_INCLUDED
|
||||
|
||||
#include "eglcompiler.h"
|
||||
|
||||
#ifdef PTHREADS
|
||||
#include <pthread.h>
|
||||
|
||||
typedef pthread_mutex_t _EGLMutex;
|
||||
|
||||
static INLINE void _eglInitMutex(_EGLMutex *m)
|
||||
{
|
||||
pthread_mutex_init(m, NULL);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
_eglDestroyMutex(_EGLMutex *m)
|
||||
{
|
||||
pthread_mutex_destroy(m);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
_eglLockMutex(_EGLMutex *m)
|
||||
{
|
||||
pthread_mutex_lock(m);
|
||||
}
|
||||
|
||||
static INLINE void
|
||||
_eglUnlockMutex(_EGLMutex *m)
|
||||
{
|
||||
pthread_mutex_unlock(m);
|
||||
}
|
||||
|
||||
#define _EGL_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
|
||||
#define _EGL_DECLARE_MUTEX(m) \
|
||||
_EGLMutex m = _EGL_MUTEX_INITIALIZER
|
||||
|
||||
#else
|
||||
|
||||
typedef int _EGLMutex;
|
||||
static INLINE void _eglInitMutex(_EGLMutex *m) { (void) m; }
|
||||
static INLINE void _eglDestroyMutex(_EGLMutex *m) { (void) m; }
|
||||
static INLINE void _eglLockMutex(_EGLMutex *m) { (void) m; }
|
||||
static INLINE void _eglUnlockMutex(_EGLMutex *m) { (void) m; }
|
||||
|
||||
#define _EGL_MUTEX_INITIALIZER 0
|
||||
#define _EGL_DECLARE_MUTEX(m) \
|
||||
_EGLMutex m = _EGL_MUTEX_INITIALIZER
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* EGLMUTEX_INCLUDED */
|
||||
|
|
@ -26,7 +26,8 @@ _eglInitSurface(_EGLDriver *drv, _EGLSurface *surf, EGLint type,
|
|||
{
|
||||
const char *func;
|
||||
EGLint width = 0, height = 0, largest = 0;
|
||||
EGLint texFormat = 0, texTarget = 0, mipmapTex = 0;
|
||||
EGLint texFormat = EGL_NO_TEXTURE, texTarget = EGL_NO_TEXTURE;
|
||||
EGLint mipmapTex = EGL_FALSE;
|
||||
EGLint renderBuffer = EGL_BACK_BUFFER;
|
||||
#ifdef EGL_VERSION_1_2
|
||||
EGLint colorspace = EGL_COLORSPACE_sRGB;
|
||||
|
|
@ -413,7 +414,7 @@ _eglDestroySurface(_EGLDriver *drv, EGLDisplay dpy, EGLSurface surface)
|
|||
_EGLSurface *surf = _eglLookupSurface(surface);
|
||||
if (surf) {
|
||||
_eglUnlinkSurface(surf);
|
||||
if (!surf->IsBound)
|
||||
if (!_eglIsSurfaceBound(surf))
|
||||
free(surf);
|
||||
return EGL_TRUE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,12 +15,12 @@ struct _egl_surface
|
|||
_EGLSurface *Next;
|
||||
EGLSurface Handle;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
/* May need reference counting here */
|
||||
EGLBoolean IsBound;
|
||||
/* The bound status of the surface */
|
||||
_EGLContext *Binding;
|
||||
EGLBoolean BoundToTexture;
|
||||
|
||||
_EGLConfig *Config;
|
||||
|
||||
EGLint Type; /* one of EGL_WINDOW_BIT, EGL_PIXMAP_BIT or EGL_PBUFFER_BIT */
|
||||
EGLint Width, Height;
|
||||
EGLint TextureFormat, TextureTarget;
|
||||
|
|
@ -100,5 +100,16 @@ _eglCreatePbufferFromClientBuffer(_EGLDriver *drv, EGLDisplay dpy,
|
|||
#endif /* EGL_VERSION_1_2 */
|
||||
|
||||
|
||||
/**
|
||||
* Return true if the surface is bound to a thread.
|
||||
* A surface bound to a texutre is not considered bound by
|
||||
* this function.
|
||||
*/
|
||||
static INLINE EGLBoolean
|
||||
_eglIsSurfaceBound(_EGLSurface *surf)
|
||||
{
|
||||
return (surf->Binding != NULL);
|
||||
}
|
||||
|
||||
|
||||
#endif /* EGLSURFACE_INCLUDED */
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ INCLUDES = \
|
|||
|
||||
default: depend lib$(LIBNAME).a
|
||||
|
||||
lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
|
||||
$(MKLIB) -o $(LIBNAME) -static $(OBJECTS)
|
||||
lib$(LIBNAME).a: $(OBJECTS) $(EXTRA_OBJECTS) Makefile $(TOP)/src/gallium/Makefile.template
|
||||
$(MKLIB) -o $(LIBNAME) -static $(OBJECTS) $(EXTRA_OBJECTS)
|
||||
|
||||
depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS)
|
||||
rm -f depend
|
||||
|
|
|
|||
|
|
@ -158,6 +158,60 @@ static void do_triangle( struct draw_context *draw,
|
|||
|
||||
|
||||
|
||||
#define QUAD(i0,i1,i2,i3) \
|
||||
do_triangle( draw, \
|
||||
( DRAW_PIPE_RESET_STIPPLE | \
|
||||
DRAW_PIPE_EDGE_FLAG_0 | \
|
||||
DRAW_PIPE_EDGE_FLAG_2 ), \
|
||||
verts + stride * elts[i0], \
|
||||
verts + stride * elts[i1], \
|
||||
verts + stride * elts[i3]); \
|
||||
do_triangle( draw, \
|
||||
( DRAW_PIPE_EDGE_FLAG_0 | \
|
||||
DRAW_PIPE_EDGE_FLAG_1 ), \
|
||||
verts + stride * elts[i1], \
|
||||
verts + stride * elts[i2], \
|
||||
verts + stride * elts[i3])
|
||||
|
||||
#define TRIANGLE(flags,i0,i1,i2) \
|
||||
do_triangle( draw, \
|
||||
elts[i0], /* flags */ \
|
||||
verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \
|
||||
verts + stride * elts[i1], \
|
||||
verts + stride * elts[i2])
|
||||
|
||||
#define LINE(flags,i0,i1) \
|
||||
do_line( draw, \
|
||||
elts[i0], \
|
||||
verts + stride * (elts[i0] & ~DRAW_PIPE_FLAG_MASK), \
|
||||
verts + stride * elts[i1])
|
||||
|
||||
#define POINT(i0) \
|
||||
do_point( draw, \
|
||||
verts + stride * elts[i0] )
|
||||
|
||||
#define FUNC pipe_run
|
||||
#define ARGS \
|
||||
struct draw_context *draw, \
|
||||
unsigned prim, \
|
||||
struct vertex_header *vertices, \
|
||||
unsigned stride, \
|
||||
const ushort *elts
|
||||
|
||||
#define LOCAL_VARS \
|
||||
char *verts = (char *)vertices; \
|
||||
boolean flatfirst = (draw->rasterizer->flatshade && \
|
||||
draw->rasterizer->flatshade_first); \
|
||||
unsigned i; \
|
||||
ushort flags
|
||||
|
||||
#define FLUSH
|
||||
|
||||
#include "draw_pt_decompose.h"
|
||||
#undef ARGS
|
||||
#undef LOCAL_VARS
|
||||
|
||||
|
||||
|
||||
/* Code to run the pipeline on a fairly arbitary collection of vertices.
|
||||
*
|
||||
|
|
@ -178,34 +232,12 @@ void draw_pipeline_run( struct draw_context *draw,
|
|||
unsigned count )
|
||||
{
|
||||
char *verts = (char *)vertices;
|
||||
unsigned i;
|
||||
|
||||
draw->pipeline.verts = verts;
|
||||
draw->pipeline.vertex_stride = stride;
|
||||
draw->pipeline.vertex_count = vertex_count;
|
||||
|
||||
switch (prim) {
|
||||
case PIPE_PRIM_POINTS:
|
||||
for (i = 0; i < count; i++)
|
||||
do_point( draw,
|
||||
verts + stride * elts[i] );
|
||||
break;
|
||||
case PIPE_PRIM_LINES:
|
||||
for (i = 0; i+1 < count; i += 2)
|
||||
do_line( draw,
|
||||
elts[i+0], /* flags */
|
||||
verts + stride * (elts[i+0] & ~DRAW_PIPE_FLAG_MASK),
|
||||
verts + stride * elts[i+1]);
|
||||
break;
|
||||
case PIPE_PRIM_TRIANGLES:
|
||||
for (i = 0; i+2 < count; i += 3)
|
||||
do_triangle( draw,
|
||||
elts[i+0], /* flags */
|
||||
verts + stride * (elts[i+0] & ~DRAW_PIPE_FLAG_MASK),
|
||||
verts + stride * elts[i+1],
|
||||
verts + stride * elts[i+2]);
|
||||
break;
|
||||
}
|
||||
pipe_run(draw, prim, vertices, stride, elts, count);
|
||||
|
||||
draw->pipeline.verts = NULL;
|
||||
draw->pipeline.vertex_count = 0;
|
||||
|
|
|
|||
|
|
@ -256,7 +256,10 @@ pstip_transform_inst(struct tgsi_transform_context *ctx,
|
|||
uint size = 4;
|
||||
immed = tgsi_default_full_immediate();
|
||||
immed.Immediate.NrTokens = 1 + size; /* one for the token itself */
|
||||
immed.u.Pointer = (void *) value;
|
||||
immed.u[0].Float = value[0];
|
||||
immed.u[1].Float = value[1];
|
||||
immed.u[2].Float = value[2];
|
||||
immed.u[3].Float = value[3];
|
||||
ctx->emit_immediate(ctx, &immed);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,30 @@
|
|||
/* Authors: Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
/**
|
||||
* Notes on wide points and sprite mode:
|
||||
*
|
||||
* In wide point/sprite mode we effectively need to convert each incoming
|
||||
* vertex into four outgoing vertices specifying the corners of a quad.
|
||||
* Since we don't (yet) have geometry shaders, we have to handle this here
|
||||
* in the draw module.
|
||||
*
|
||||
* For sprites, it also means that this is where we have to handle texcoords
|
||||
* for the vertices of the quad. OpenGL's GL_COORD_REPLACE state specifies
|
||||
* if/how enabled texcoords are automatically generated for sprites. We pass
|
||||
* that info through gallium in the pipe_rasterizer_state::sprite_coord_mode
|
||||
* array.
|
||||
*
|
||||
* Additionally, GLSL's gl_PointCoord fragment attribute has to be handled
|
||||
* here as well. This is basically an additional texture/generic attribute
|
||||
* that varies .x from 0 to 1 horizontally across the point and varies .y
|
||||
* vertically from 0 to 1 down the sprite.
|
||||
*
|
||||
* With geometry shaders, the state tracker could create a GS to do
|
||||
* most/all of this.
|
||||
*/
|
||||
|
||||
|
||||
#include "util/u_math.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "pipe/p_defines.h"
|
||||
|
|
@ -52,7 +76,7 @@ struct widepoint_stage {
|
|||
|
||||
int psize_slot;
|
||||
|
||||
int point_coord_fs_input; /**< input for pointcoord (and fog) */
|
||||
int point_coord_fs_input; /**< input for pointcoord */
|
||||
};
|
||||
|
||||
|
||||
|
|
@ -64,8 +88,6 @@ widepoint_stage( struct draw_stage *stage )
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Set the vertex texcoords for sprite mode.
|
||||
* Coords may be left untouched or set to a right-side-up or upside-down
|
||||
|
|
@ -89,10 +111,12 @@ static void set_texcoords(const struct widepoint_stage *wide,
|
|||
}
|
||||
|
||||
if (wide->point_coord_fs_input >= 0) {
|
||||
/* put gl_PointCoord into extra vertex output's zw components */
|
||||
uint k = wide->stage.draw->extra_vp_outputs.slot;
|
||||
v->data[k][2] = tc[0];
|
||||
v->data[k][3] = tc[1];
|
||||
/* put gl_PointCoord into the extra vertex slot */
|
||||
uint slot = wide->stage.draw->extra_vp_outputs.slot;
|
||||
v->data[slot][0] = tc[0];
|
||||
v->data[slot][1] = tc[1];
|
||||
v->data[slot][2] = 0.0F;
|
||||
v->data[slot][3] = 1.0F;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -182,10 +206,10 @@ static void widepoint_point( struct draw_stage *stage,
|
|||
|
||||
|
||||
static int
|
||||
find_fog_input_attrib(struct draw_context *draw)
|
||||
find_pntc_input_attrib(struct draw_context *draw)
|
||||
{
|
||||
/* Scan the fragment program's input decls to find the fogcoord
|
||||
* attribute. The z/w components will store the point coord.
|
||||
/* Scan the fragment program's input decls to find the pointcoord
|
||||
* attribute. The xy components will store the point coord.
|
||||
*/
|
||||
return 0; /* XXX fix this */
|
||||
}
|
||||
|
|
@ -229,8 +253,8 @@ static void widepoint_first_point( struct draw_stage *stage,
|
|||
}
|
||||
wide->num_texcoords = j;
|
||||
|
||||
/* find fragment shader PointCoord/Fog input */
|
||||
wide->point_coord_fs_input = find_fog_input_attrib(draw);
|
||||
/* find fragment shader PointCoord input */
|
||||
wide->point_coord_fs_input = find_pntc_input_attrib(draw);
|
||||
|
||||
/* setup extra vp output (point coord implemented as a texcoord) */
|
||||
draw->extra_vp_outputs.semantic_name = TGSI_SEMANTIC_GENERIC;
|
||||
|
|
|
|||
|
|
@ -1758,24 +1758,24 @@ emit_instruction( struct aos_compilation *cp,
|
|||
case TGSI_OPCODE_SUB:
|
||||
return emit_SUB(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_LERP:
|
||||
case TGSI_OPCODE_LRP:
|
||||
// return emit_LERP(cp, inst);
|
||||
return FALSE;
|
||||
|
||||
case TGSI_OPCODE_FRAC:
|
||||
case TGSI_OPCODE_FRC:
|
||||
return emit_FRC(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_CLAMP:
|
||||
// return emit_CLAMP(cp, inst);
|
||||
return FALSE;
|
||||
|
||||
case TGSI_OPCODE_FLOOR:
|
||||
case TGSI_OPCODE_FLR:
|
||||
return emit_FLR(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_ROUND:
|
||||
return emit_RND(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_EXPBASE2:
|
||||
case TGSI_OPCODE_EX2:
|
||||
#if FAST_MATH
|
||||
return emit_EXPBASE2(cp, inst);
|
||||
#elif 0
|
||||
|
|
@ -1787,13 +1787,13 @@ emit_instruction( struct aos_compilation *cp,
|
|||
return FALSE;
|
||||
#endif
|
||||
|
||||
case TGSI_OPCODE_LOGBASE2:
|
||||
case TGSI_OPCODE_LG2:
|
||||
return emit_LG2(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_POWER:
|
||||
case TGSI_OPCODE_POW:
|
||||
return emit_POW(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_CROSSPRODUCT:
|
||||
case TGSI_OPCODE_XPD:
|
||||
return emit_XPD(cp, inst);
|
||||
|
||||
case TGSI_OPCODE_ABS:
|
||||
|
|
@ -1891,8 +1891,9 @@ static boolean note_immediate( struct aos_compilation *cp,
|
|||
unsigned pos = cp->num_immediates++;
|
||||
unsigned j;
|
||||
|
||||
assert( imm->Immediate.NrTokens <= 4 + 1 );
|
||||
for (j = 0; j < imm->Immediate.NrTokens - 1; j++) {
|
||||
cp->vaos->machine->immediate[pos][j] = imm->u.ImmediateFloat32[j].Float;
|
||||
cp->vaos->machine->immediate[pos][j] = imm->u[j].Float;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ draw_create_vs_llvm(struct draw_context *draw,
|
|||
vs->base.create_varient = draw_vs_varient_generic;
|
||||
vs->base.run_linear = vs_llvm_run_linear;
|
||||
vs->base.delete = vs_llvm_delete;
|
||||
vs->machine = &draw->vs.machine;
|
||||
vs->machine = draw->vs.machine;
|
||||
|
||||
{
|
||||
struct gallivm_ir *ir = gallivm_ir_new(GALLIVM_VS);
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ void InstructionsSoa::createFunctionMap()
|
|||
m_functionsMap[TGSI_OPCODE_DP4] = "dp4";
|
||||
m_functionsMap[TGSI_OPCODE_MIN] = "min";
|
||||
m_functionsMap[TGSI_OPCODE_MAX] = "max";
|
||||
m_functionsMap[TGSI_OPCODE_POWER] = "pow";
|
||||
m_functionsMap[TGSI_OPCODE_POW] = "pow";
|
||||
m_functionsMap[TGSI_OPCODE_LIT] = "lit";
|
||||
m_functionsMap[TGSI_OPCODE_RSQ] = "rsq";
|
||||
m_functionsMap[TGSI_OPCODE_SLT] = "slt";
|
||||
|
|
@ -311,7 +311,7 @@ std::vector<llvm::Value*> InstructionsSoa::mul(const std::vector<llvm::Value*> i
|
|||
std::vector<llvm::Value*> InstructionsSoa::pow(const std::vector<llvm::Value*> in1,
|
||||
const std::vector<llvm::Value*> in2)
|
||||
{
|
||||
llvm::Function *func = function(TGSI_OPCODE_POWER);
|
||||
llvm::Function *func = function(TGSI_OPCODE_POW);
|
||||
return callBuiltin(func, in1, in2);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,10 +160,11 @@ translate_immediate(Storage *storage,
|
|||
{
|
||||
float vec[4];
|
||||
int i;
|
||||
assert( imm->Immediate.NrTokens <= 4 + 1 );
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
vec[i] = imm->u.ImmediateFloat32[i].Float;
|
||||
vec[i] = imm->u[i].Float;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -179,10 +180,11 @@ translate_immediateir(StorageSoa *storage,
|
|||
{
|
||||
float vec[4];
|
||||
int i;
|
||||
assert( imm->Immediate.NrTokens <= 4 + 1 );
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; ++i) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
vec[i] = imm->u.ImmediateFloat32[i].Float;
|
||||
vec[i] = imm->u[i].Float;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -336,7 +338,7 @@ translate_instruction(llvm::Module *module,
|
|||
out = instr->sub(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LERP: {
|
||||
case TGSI_OPCODE_LRP: {
|
||||
out = instr->lerp(inputs[0], inputs[1], inputs[2]);
|
||||
}
|
||||
break;
|
||||
|
|
@ -348,17 +350,11 @@ translate_instruction(llvm::Module *module,
|
|||
out = instr->cnd0(inputs[0], inputs[1], inputs[2]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_DOT2ADD: {
|
||||
case TGSI_OPCODE_DP2A: {
|
||||
out = instr->dot2add(inputs[0], inputs[1], inputs[2]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_INDEX:
|
||||
break;
|
||||
case TGSI_OPCODE_NEGATE: {
|
||||
out = instr->neg(inputs[0]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_FRAC: {
|
||||
case TGSI_OPCODE_FRC: {
|
||||
out = instr->frc(inputs[0]);
|
||||
}
|
||||
break;
|
||||
|
|
@ -366,30 +362,28 @@ translate_instruction(llvm::Module *module,
|
|||
out = instr->clamp(inputs[0]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_FLOOR: {
|
||||
case TGSI_OPCODE_FLR: {
|
||||
out = instr->floor(inputs[0]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ROUND:
|
||||
break;
|
||||
case TGSI_OPCODE_EXPBASE2: {
|
||||
case TGSI_OPCODE_EX2: {
|
||||
out = instr->ex2(inputs[0]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LOGBASE2: {
|
||||
case TGSI_OPCODE_LG2: {
|
||||
out = instr->lg2(inputs[0]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_POWER: {
|
||||
case TGSI_OPCODE_POW: {
|
||||
out = instr->pow(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_CROSSPRODUCT: {
|
||||
case TGSI_OPCODE_XPD: {
|
||||
out = instr->cross(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_MULTIPLYMATRIX:
|
||||
break;
|
||||
case TGSI_OPCODE_ABS: {
|
||||
out = instr->abs(inputs[0]);
|
||||
}
|
||||
|
|
@ -522,7 +516,7 @@ translate_instruction(llvm::Module *module,
|
|||
return; //just update the state
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LOOP:
|
||||
case TGSI_OPCODE_BGNFOR:
|
||||
break;
|
||||
case TGSI_OPCODE_REP:
|
||||
break;
|
||||
|
|
@ -538,7 +532,7 @@ translate_instruction(llvm::Module *module,
|
|||
return; //just update the state
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ENDLOOP:
|
||||
case TGSI_OPCODE_ENDFOR:
|
||||
break;
|
||||
case TGSI_OPCODE_ENDREP:
|
||||
break;
|
||||
|
|
@ -580,7 +574,7 @@ translate_instruction(llvm::Module *module,
|
|||
break;
|
||||
case TGSI_OPCODE_ENDPRIM:
|
||||
break;
|
||||
case TGSI_OPCODE_BGNLOOP2: {
|
||||
case TGSI_OPCODE_BGNLOOP: {
|
||||
instr->beginLoop();
|
||||
storage->setCurrentBlock(instr->currentBlock());
|
||||
return;
|
||||
|
|
@ -593,7 +587,7 @@ translate_instruction(llvm::Module *module,
|
|||
return;
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ENDLOOP2: {
|
||||
case TGSI_OPCODE_ENDLOOP: {
|
||||
instr->endLoop();
|
||||
storage->setCurrentBlock(instr->currentBlock());
|
||||
return;
|
||||
|
|
@ -617,14 +611,6 @@ translate_instruction(llvm::Module *module,
|
|||
break;
|
||||
case TGSI_OPCODE_NOP:
|
||||
break;
|
||||
case TGSI_OPCODE_M4X3:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X4:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X3:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X2:
|
||||
break;
|
||||
case TGSI_OPCODE_CALLNZ:
|
||||
break;
|
||||
case TGSI_OPCODE_IFC:
|
||||
|
|
@ -778,44 +764,38 @@ translate_instructionir(llvm::Module *module,
|
|||
out = instr->sub(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LERP: {
|
||||
case TGSI_OPCODE_LRP: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_CND:
|
||||
break;
|
||||
case TGSI_OPCODE_CND0:
|
||||
break;
|
||||
case TGSI_OPCODE_DOT2ADD:
|
||||
case TGSI_OPCODE_DP2A:
|
||||
break;
|
||||
case TGSI_OPCODE_INDEX:
|
||||
break;
|
||||
case TGSI_OPCODE_NEGATE:
|
||||
break;
|
||||
case TGSI_OPCODE_FRAC: {
|
||||
case TGSI_OPCODE_FRC: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_CLAMP:
|
||||
break;
|
||||
case TGSI_OPCODE_FLOOR: {
|
||||
case TGSI_OPCODE_FLR: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ROUND:
|
||||
break;
|
||||
case TGSI_OPCODE_EXPBASE2: {
|
||||
case TGSI_OPCODE_EX2: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LOGBASE2: {
|
||||
case TGSI_OPCODE_LG2: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_POWER: {
|
||||
case TGSI_OPCODE_POW: {
|
||||
out = instr->pow(inputs[0], inputs[1]);
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_CROSSPRODUCT: {
|
||||
case TGSI_OPCODE_XPD: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_MULTIPLYMATRIX:
|
||||
break;
|
||||
case TGSI_OPCODE_ABS: {
|
||||
out = instr->abs(inputs[0]);
|
||||
}
|
||||
|
|
@ -910,7 +890,7 @@ translate_instructionir(llvm::Module *module,
|
|||
case TGSI_OPCODE_IF: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_LOOP:
|
||||
case TGSI_OPCODE_BGNFOR:
|
||||
break;
|
||||
case TGSI_OPCODE_REP:
|
||||
break;
|
||||
|
|
@ -920,7 +900,7 @@ translate_instructionir(llvm::Module *module,
|
|||
case TGSI_OPCODE_ENDIF: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ENDLOOP:
|
||||
case TGSI_OPCODE_ENDFOR:
|
||||
break;
|
||||
case TGSI_OPCODE_ENDREP:
|
||||
break;
|
||||
|
|
@ -961,13 +941,13 @@ translate_instructionir(llvm::Module *module,
|
|||
break;
|
||||
case TGSI_OPCODE_ENDPRIM:
|
||||
break;
|
||||
case TGSI_OPCODE_BGNLOOP2: {
|
||||
case TGSI_OPCODE_BGNLOOP: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_BGNSUB: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ENDLOOP2: {
|
||||
case TGSI_OPCODE_ENDLOOP: {
|
||||
}
|
||||
break;
|
||||
case TGSI_OPCODE_ENDSUB: {
|
||||
|
|
@ -983,14 +963,6 @@ translate_instructionir(llvm::Module *module,
|
|||
break;
|
||||
case TGSI_OPCODE_NOP:
|
||||
break;
|
||||
case TGSI_OPCODE_M4X3:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X4:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X3:
|
||||
break;
|
||||
case TGSI_OPCODE_M3X2:
|
||||
break;
|
||||
case TGSI_OPCODE_NRM4:
|
||||
break;
|
||||
case TGSI_OPCODE_CALLNZ:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ C_SOURCES = \
|
|||
tgsi_sse2.c \
|
||||
tgsi_text.c \
|
||||
tgsi_transform.c \
|
||||
tgsi_ureg.c \
|
||||
tgsi_util.c
|
||||
|
||||
include ../../Makefile.template
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ tgsi = env.ConvenienceLibrary(
|
|||
'tgsi_sse2.c',
|
||||
'tgsi_text.c',
|
||||
'tgsi_transform.c',
|
||||
'tgsi_ureg.c',
|
||||
'tgsi_util.c',
|
||||
])
|
||||
|
||||
|
|
|
|||
|
|
@ -665,9 +665,18 @@ TGSI Instruction Specification
|
|||
TBD
|
||||
|
||||
|
||||
1.9.8 LOOP - Loop
|
||||
1.9.8 BGNFOR - Begin a For-Loop
|
||||
|
||||
TBD
|
||||
dst.x = floor(src.x)
|
||||
dst.y = floor(src.y)
|
||||
dst.z = floor(src.z)
|
||||
|
||||
if (dst.y <= 0)
|
||||
pc = [matching ENDFOR] + 1
|
||||
endif
|
||||
|
||||
Note: The destination must be a loop register.
|
||||
The source must be a constant register.
|
||||
|
||||
|
||||
1.9.9 REP - Repeat
|
||||
|
|
@ -685,9 +694,16 @@ TGSI Instruction Specification
|
|||
TBD
|
||||
|
||||
|
||||
1.9.12 ENDLOOP - End Loop
|
||||
1.9.12 ENDFOR - End a For-Loop
|
||||
|
||||
TBD
|
||||
dst.x = dst.x + dst.z
|
||||
dst.y = dst.y - 1.0
|
||||
|
||||
if (dst.y > 0)
|
||||
pc = [matching BGNFOR instruction] + 1
|
||||
endif
|
||||
|
||||
Note: The destination must be a loop register.
|
||||
|
||||
|
||||
1.9.13 ENDREP - End Repeat
|
||||
|
|
@ -840,7 +856,7 @@ TGSI Instruction Specification
|
|||
----------
|
||||
|
||||
|
||||
1.13.1 BGNLOOP2 - Begin Loop
|
||||
1.13.1 BGNLOOP - Begin a Loop
|
||||
|
||||
TBD
|
||||
|
||||
|
|
@ -850,7 +866,7 @@ TGSI Instruction Specification
|
|||
TBD
|
||||
|
||||
|
||||
1.13.3 ENDLOOP2 - End Loop
|
||||
1.13.3 ENDLOOP - End a Loop
|
||||
|
||||
TBD
|
||||
|
||||
|
|
|
|||
|
|
@ -335,7 +335,10 @@ tgsi_default_full_immediate( void )
|
|||
struct tgsi_full_immediate fullimm;
|
||||
|
||||
fullimm.Immediate = tgsi_default_immediate();
|
||||
fullimm.u.Pointer = (void *) 0;
|
||||
fullimm.u[0].Float = 0.0f;
|
||||
fullimm.u[1].Float = 0.0f;
|
||||
fullimm.u[2].Float = 0.0f;
|
||||
fullimm.u[3].Float = 0.0f;
|
||||
|
||||
return fullimm;
|
||||
}
|
||||
|
|
@ -352,19 +355,19 @@ immediate_grow(
|
|||
header_bodysize_grow( header );
|
||||
}
|
||||
|
||||
struct tgsi_immediate_float32
|
||||
union tgsi_immediate_data
|
||||
tgsi_build_immediate_float32(
|
||||
float value,
|
||||
struct tgsi_immediate *immediate,
|
||||
struct tgsi_header *header )
|
||||
{
|
||||
struct tgsi_immediate_float32 immediate_float32;
|
||||
union tgsi_immediate_data immediate_data;
|
||||
|
||||
immediate_float32.Float = value;
|
||||
immediate_data.Float = value;
|
||||
|
||||
immediate_grow( immediate, header );
|
||||
|
||||
return immediate_float32;
|
||||
return immediate_data;
|
||||
}
|
||||
|
||||
unsigned
|
||||
|
|
@ -384,16 +387,18 @@ tgsi_build_full_immediate(
|
|||
|
||||
*immediate = tgsi_build_immediate( header );
|
||||
|
||||
assert( full_imm->Immediate.NrTokens <= 4 + 1 );
|
||||
|
||||
for( i = 0; i < full_imm->Immediate.NrTokens - 1; i++ ) {
|
||||
struct tgsi_immediate_float32 *if32;
|
||||
union tgsi_immediate_data *data;
|
||||
|
||||
if( maxsize <= size )
|
||||
return 0;
|
||||
if32 = (struct tgsi_immediate_float32 *) &tokens[size];
|
||||
data = (union tgsi_immediate_data *) &tokens[size];
|
||||
size++;
|
||||
|
||||
*if32 = tgsi_build_immediate_float32(
|
||||
full_imm->u.ImmediateFloat32[i].Float,
|
||||
*data = tgsi_build_immediate_float32(
|
||||
full_imm->u[i].Float,
|
||||
immediate,
|
||||
header );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ tgsi_build_immediate(
|
|||
struct tgsi_full_immediate
|
||||
tgsi_default_full_immediate( void );
|
||||
|
||||
struct tgsi_immediate_float32
|
||||
union tgsi_immediate_data
|
||||
tgsi_build_immediate_float32(
|
||||
float value,
|
||||
struct tgsi_immediate *immediate,
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ static const char *processor_type_names[] =
|
|||
"GEOM"
|
||||
};
|
||||
|
||||
static const char *file_names[] =
|
||||
static const char *file_names[TGSI_FILE_COUNT] =
|
||||
{
|
||||
"NULL",
|
||||
"CONST",
|
||||
|
|
@ -91,7 +91,8 @@ static const char *file_names[] =
|
|||
"TEMP",
|
||||
"SAMP",
|
||||
"ADDR",
|
||||
"IMM"
|
||||
"IMM",
|
||||
"LOOP"
|
||||
};
|
||||
|
||||
static const char *interpolate_names[] =
|
||||
|
|
@ -295,10 +296,12 @@ iter_immediate(
|
|||
ENM( imm->Immediate.DataType, immediate_type_names );
|
||||
|
||||
TXT( " { " );
|
||||
|
||||
assert( imm->Immediate.NrTokens <= 4 + 1 );
|
||||
for (i = 0; i < imm->Immediate.NrTokens - 1; i++) {
|
||||
switch (imm->Immediate.DataType) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
FLT( imm->u.ImmediateFloat32[i].Float );
|
||||
FLT( imm->u[i].Float );
|
||||
break;
|
||||
default:
|
||||
assert( 0 );
|
||||
|
|
@ -470,8 +473,8 @@ iter_instruction(
|
|||
switch (inst->Instruction.Opcode) {
|
||||
case TGSI_OPCODE_IF:
|
||||
case TGSI_OPCODE_ELSE:
|
||||
case TGSI_OPCODE_BGNLOOP2:
|
||||
case TGSI_OPCODE_ENDLOOP2:
|
||||
case TGSI_OPCODE_BGNLOOP:
|
||||
case TGSI_OPCODE_ENDLOOP:
|
||||
case TGSI_OPCODE_CAL:
|
||||
TXT( " :" );
|
||||
UID( inst->InstructionExtLabel.Label );
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ static const char *TGSI_TOKEN_TYPES[] =
|
|||
"TOKEN_TYPE_INSTRUCTION"
|
||||
};
|
||||
|
||||
static const char *TGSI_FILES[] =
|
||||
static const char *TGSI_FILES[TGSI_FILE_COUNT] =
|
||||
{
|
||||
"FILE_NULL",
|
||||
"FILE_CONSTANT",
|
||||
|
|
@ -78,7 +78,8 @@ static const char *TGSI_FILES[] =
|
|||
"FILE_TEMPORARY",
|
||||
"FILE_SAMPLER",
|
||||
"FILE_ADDRESS",
|
||||
"FILE_IMMEDIATE"
|
||||
"FILE_IMMEDIATE",
|
||||
"FILE_LOOP"
|
||||
};
|
||||
|
||||
static const char *TGSI_INTERPOLATES[] =
|
||||
|
|
@ -283,12 +284,13 @@ dump_immediate_verbose(
|
|||
UIX( imm->Immediate.Padding );
|
||||
}
|
||||
|
||||
assert( imm->Immediate.NrTokens <= 4 + 1 );
|
||||
for( i = 0; i < imm->Immediate.NrTokens - 1; i++ ) {
|
||||
EOL();
|
||||
switch( imm->Immediate.DataType ) {
|
||||
case TGSI_IMM_FLOAT32:
|
||||
TXT( "\nFloat: " );
|
||||
FLT( imm->u.ImmediateFloat32[i].Float );
|
||||
FLT( imm->u[i].Float );
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -301,14 +301,14 @@ tgsi_exec_machine_bind_shader(
|
|||
case TGSI_TOKEN_TYPE_IMMEDIATE:
|
||||
{
|
||||
uint size = parse.FullToken.FullImmediate.Immediate.NrTokens - 1;
|
||||
assert( size % 4 == 0 );
|
||||
assert( mach->ImmLimit + size / 4 <= TGSI_EXEC_NUM_IMMEDIATES );
|
||||
assert( size <= 4 );
|
||||
assert( mach->ImmLimit + 1 <= TGSI_EXEC_NUM_IMMEDIATES );
|
||||
|
||||
for( i = 0; i < size; i++ ) {
|
||||
mach->Imms[mach->ImmLimit + i / 4][i % 4] =
|
||||
parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float;
|
||||
mach->Imms[mach->ImmLimit][i] =
|
||||
parse.FullToken.FullImmediate.u[i].Float;
|
||||
}
|
||||
mach->ImmLimit += size / 4;
|
||||
mach->ImmLimit += 1;
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -375,15 +375,9 @@ tgsi_exec_machine_create( void )
|
|||
if (!mach)
|
||||
goto fail;
|
||||
|
||||
mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR];
|
||||
memset(mach, 0, sizeof(*mach));
|
||||
|
||||
mach->Samplers = NULL;
|
||||
mach->Consts = NULL;
|
||||
mach->Tokens = NULL;
|
||||
mach->Primitives = NULL;
|
||||
mach->InterpCoefs = NULL;
|
||||
mach->Instructions = NULL;
|
||||
mach->Declarations = NULL;
|
||||
mach->Addrs = &mach->Temps[TGSI_EXEC_TEMP_ADDR];
|
||||
|
||||
/* Setup constants. */
|
||||
for( i = 0; i < 4; i++ ) {
|
||||
|
|
@ -2020,8 +2014,7 @@ exec_instruction(
|
|||
|
||||
switch (inst->Instruction.Opcode) {
|
||||
case TGSI_OPCODE_ARL:
|
||||
case TGSI_OPCODE_FLOOR:
|
||||
/* TGSI_OPCODE_FLR */
|
||||
case TGSI_OPCODE_FLR:
|
||||
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
|
||||
FETCH( &r[0], 0, chan_index );
|
||||
micro_flr( &r[0], &r[0] );
|
||||
|
|
@ -2290,8 +2283,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_LERP:
|
||||
/* TGSI_OPCODE_LRP */
|
||||
case TGSI_OPCODE_LRP:
|
||||
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
|
||||
FETCH(&r[0], 0, chan_index);
|
||||
FETCH(&r[1], 1, chan_index);
|
||||
|
|
@ -2325,8 +2317,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_DOT2ADD:
|
||||
/* TGSI_OPCODE_DP2A */
|
||||
case TGSI_OPCODE_DP2A:
|
||||
FETCH( &r[0], 0, CHAN_X );
|
||||
FETCH( &r[1], 1, CHAN_X );
|
||||
micro_mul( &r[0], &r[0], &r[1] );
|
||||
|
|
@ -2344,18 +2335,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_INDEX:
|
||||
/* XXX: considered for removal */
|
||||
assert (0);
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_NEGATE:
|
||||
/* XXX: considered for removal */
|
||||
assert (0);
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_FRAC:
|
||||
/* TGSI_OPCODE_FRC */
|
||||
case TGSI_OPCODE_FRC:
|
||||
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
|
||||
FETCH( &r[0], 0, chan_index );
|
||||
micro_frc( &r[0], &r[0] );
|
||||
|
|
@ -2383,8 +2363,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_EXPBASE2:
|
||||
/* TGSI_OPCODE_EX2 */
|
||||
case TGSI_OPCODE_EX2:
|
||||
FETCH(&r[0], 0, CHAN_X);
|
||||
|
||||
#if FAST_MATH
|
||||
|
|
@ -2398,8 +2377,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_LOGBASE2:
|
||||
/* TGSI_OPCODE_LG2 */
|
||||
case TGSI_OPCODE_LG2:
|
||||
FETCH( &r[0], 0, CHAN_X );
|
||||
micro_lg2( &r[0], &r[0] );
|
||||
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
|
||||
|
|
@ -2407,8 +2385,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_POWER:
|
||||
/* TGSI_OPCODE_POW */
|
||||
case TGSI_OPCODE_POW:
|
||||
FETCH(&r[0], 0, CHAN_X);
|
||||
FETCH(&r[1], 1, CHAN_X);
|
||||
|
||||
|
|
@ -2419,8 +2396,7 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_CROSSPRODUCT:
|
||||
/* TGSI_OPCODE_XPD */
|
||||
case TGSI_OPCODE_XPD:
|
||||
FETCH(&r[0], 0, CHAN_Y);
|
||||
FETCH(&r[1], 1, CHAN_Z);
|
||||
|
||||
|
|
@ -2462,11 +2438,6 @@ exec_instruction(
|
|||
}
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_MULTIPLYMATRIX:
|
||||
/* XXX: considered for removal */
|
||||
assert (0);
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_ABS:
|
||||
FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) {
|
||||
FETCH(&r[0], 0, chan_index);
|
||||
|
|
@ -3110,9 +3081,9 @@ exec_instruction(
|
|||
mach->Primitives[mach->Temps[TEMP_PRIMITIVE_I].xyzw[TEMP_PRIMITIVE_C].u[0]] = 0;
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_LOOP:
|
||||
case TGSI_OPCODE_BGNFOR:
|
||||
/* fall-through (for now) */
|
||||
case TGSI_OPCODE_BGNLOOP2:
|
||||
case TGSI_OPCODE_BGNLOOP:
|
||||
/* push LoopMask and ContMasks */
|
||||
assert(mach->LoopStackTop < TGSI_EXEC_MAX_LOOP_NESTING);
|
||||
mach->LoopStack[mach->LoopStackTop++] = mach->LoopMask;
|
||||
|
|
@ -3120,9 +3091,9 @@ exec_instruction(
|
|||
mach->ContStack[mach->ContStackTop++] = mach->ContMask;
|
||||
break;
|
||||
|
||||
case TGSI_OPCODE_ENDLOOP:
|
||||
case TGSI_OPCODE_ENDFOR:
|
||||
/* fall-through (for now at least) */
|
||||
case TGSI_OPCODE_ENDLOOP2:
|
||||
case TGSI_OPCODE_ENDLOOP:
|
||||
/* Restore ContMask, but don't pop */
|
||||
assert(mach->ContStackTop > 0);
|
||||
mach->ContMask = mach->ContStack[mach->ContStackTop - 1];
|
||||
|
|
|
|||
|
|
@ -26,136 +26,156 @@
|
|||
**************************************************************************/
|
||||
|
||||
#include "util/u_debug.h"
|
||||
#include "util/u_memory.h"
|
||||
#include "tgsi_info.h"
|
||||
|
||||
static const struct tgsi_opcode_info opcode_info[TGSI_OPCODE_LAST] =
|
||||
{
|
||||
{ 1, 1, 0, 0, "ARL", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "MOV", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "LIT", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "RCP", "RECIP", NULL },
|
||||
{ 1, 1, 0, 0, "RSQ", "RECIPSQRT", NULL },
|
||||
{ 1, 1, 0, 0, "EXP", "EXPP", NULL },
|
||||
{ 1, 1, 0, 0, "LOG", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "MUL", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "ADD", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "DP3", "DOT3", NULL },
|
||||
{ 1, 2, 0, 0, "DP4", "DOT4", NULL },
|
||||
{ 1, 2, 0, 0, "DST", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "MIN", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "MAX", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SLT", "SETLT", NULL },
|
||||
{ 1, 2, 0, 0, "SGE", "SETGE", NULL },
|
||||
{ 1, 3, 0, 0, "MAD", "MADD", NULL },
|
||||
{ 1, 2, 0, 0, "SUB", NULL, NULL },
|
||||
{ 1, 3, 0, 0, "LRP", "LERP", NULL },
|
||||
{ 1, 3, 0, 0, "CND", NULL, NULL },
|
||||
{ 1, 3, 0, 0, "CND0", NULL, NULL },
|
||||
{ 1, 3, 0, 0, "DP2A", "DP2ADD", "DOT2ADD" },
|
||||
{ 1, 2, 0, 0, "INDEX", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NEGATE", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "FRC", "FRAC", NULL },
|
||||
{ 1, 3, 0, 0, "CLAMP", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "FLR", "FLOOR", NULL },
|
||||
{ 1, 1, 0, 0, "ROUND", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "EX2", "EXPBASE2", NULL },
|
||||
{ 1, 1, 0, 0, "LG2", "LOGBASE2", "LOGP" },
|
||||
{ 1, 2, 0, 0, "POW", "POWER", NULL },
|
||||
{ 1, 2, 0, 0, "XPD", "CRS", "CROSSPRODUCT" },
|
||||
{ 1, 2, 0, 0, "M4X4", "MULTIPLYMATRIX", NULL },
|
||||
{ 1, 1, 0, 0, "ABS", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "RCC", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "DPH", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "COS", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "DDX", "DSX", NULL },
|
||||
{ 1, 1, 0, 0, "DDY", "DSY", NULL },
|
||||
{ 0, 0, 0, 0, "KILP", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "PK2H", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "PK2US", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "PK4B", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "PK4UB", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "RFL", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SEQ", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SFL", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SGT", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "SIN", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SLE", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SNE", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "STR", NULL, NULL },
|
||||
{ 1, 2, 1, 0, "TEX", "TEXLD", NULL },
|
||||
{ 1, 4, 1, 0, "TXD", "TEXLDD", NULL },
|
||||
{ 1, 2, 1, 0, "TXP", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "UP2H", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "UP2US", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "UP4B", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "UP4UB", NULL, NULL },
|
||||
{ 1, 3, 0, 0, "X2D", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "ARA", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "ARR", "MOVA", NULL },
|
||||
{ 0, 1, 0, 0, "BRA", NULL, NULL },
|
||||
{ 0, 0, 0, 1, "CAL", "CALL", NULL },
|
||||
{ 0, 0, 0, 0, "RET", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "SGN", "SSG", NULL },
|
||||
{ 1, 3, 0, 0, "CMP", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "SCS", "SINCOS", NULL },
|
||||
{ 1, 2, 1, 0, "TXB", "TEXLDB", NULL },
|
||||
{ 1, 1, 0, 0, "NRM", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "DIV", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "DP2", NULL, NULL },
|
||||
{ 1, 2, 1, 0, "TXL", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "BRK", "BREAK", NULL },
|
||||
{ 0, 1, 0, 1, "IF", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "LOOP", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "REP", NULL, NULL },
|
||||
{ 0, 0, 0, 1, "ELSE", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "ENDIF", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "ENDLOOP", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "ENDREP", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "PUSHA", NULL, NULL },
|
||||
{ 1, 0, 0, 0, "POPA", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "CEIL", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "I2F", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NOT", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "INT", "TRUNC", NULL },
|
||||
{ 1, 2, 0, 0, "SHL", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "SHR", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "AND", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "OR", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "MOD", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "XOR", NULL, NULL },
|
||||
{ 1, 3, 0, 0, "SAD", NULL, NULL },
|
||||
{ 1, 2, 1, 0, "TXF", NULL, NULL },
|
||||
{ 1, 2, 1, 0, "TXQ", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "CONT", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "EMIT", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "ENDPRIM", NULL, NULL },
|
||||
{ 0, 0, 0, 1, "BGNLOOP2", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "BGNSUB", NULL, NULL },
|
||||
{ 0, 0, 0, 1, "ENDLOOP2", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "ENDSUB", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NOISE1", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NOISE2", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NOISE3", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NOISE4", NULL, NULL },
|
||||
{ 0, 0, 0, 0, "NOP", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "M4X3", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "M3X4", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "M3X3", NULL, NULL },
|
||||
{ 1, 2, 0, 0, "M3X2", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "NRM4", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "CALLNZ", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "IFC", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "BREAKC", NULL, NULL },
|
||||
{ 0, 1, 0, 0, "KIL", "TEXKILL", NULL },
|
||||
{ 0, 0, 0, 0, "END", NULL, NULL },
|
||||
{ 1, 1, 0, 0, "SWZ", NULL, NULL }
|
||||
{ 1, 1, 0, 0, "ARL", TGSI_OPCODE_ARL },
|
||||
{ 1, 1, 0, 0, "MOV", TGSI_OPCODE_MOV },
|
||||
{ 1, 1, 0, 0, "LIT", TGSI_OPCODE_LIT },
|
||||
{ 1, 1, 0, 0, "RCP", TGSI_OPCODE_RCP },
|
||||
{ 1, 1, 0, 0, "RSQ", TGSI_OPCODE_RSQ },
|
||||
{ 1, 1, 0, 0, "EXP", TGSI_OPCODE_EXP },
|
||||
{ 1, 1, 0, 0, "LOG", TGSI_OPCODE_LOG },
|
||||
{ 1, 2, 0, 0, "MUL", TGSI_OPCODE_MUL },
|
||||
{ 1, 2, 0, 0, "ADD", TGSI_OPCODE_ADD },
|
||||
{ 1, 2, 0, 0, "DP3", TGSI_OPCODE_DP3 },
|
||||
{ 1, 2, 0, 0, "DP4", TGSI_OPCODE_DP4 },
|
||||
{ 1, 2, 0, 0, "DST", TGSI_OPCODE_DST },
|
||||
{ 1, 2, 0, 0, "MIN", TGSI_OPCODE_MIN },
|
||||
{ 1, 2, 0, 0, "MAX", TGSI_OPCODE_MAX },
|
||||
{ 1, 2, 0, 0, "SLT", TGSI_OPCODE_SLT },
|
||||
{ 1, 2, 0, 0, "SGE", TGSI_OPCODE_SGE },
|
||||
{ 1, 3, 0, 0, "MAD", TGSI_OPCODE_MAD },
|
||||
{ 1, 2, 0, 0, "SUB", TGSI_OPCODE_SUB },
|
||||
{ 1, 3, 0, 0, "LRP", TGSI_OPCODE_LRP },
|
||||
{ 1, 3, 0, 0, "CND", TGSI_OPCODE_CND },
|
||||
{ 1, 3, 0, 0, "CND0", TGSI_OPCODE_CND0 },
|
||||
{ 1, 3, 0, 0, "DP2A", TGSI_OPCODE_DP2A },
|
||||
{ 0, 0, 0, 0, "", 22 }, /* removed */
|
||||
{ 0, 0, 0, 0, "", 23 }, /* removed */
|
||||
{ 1, 1, 0, 0, "FRC", TGSI_OPCODE_FRC },
|
||||
{ 1, 3, 0, 0, "CLAMP", TGSI_OPCODE_CLAMP },
|
||||
{ 1, 1, 0, 0, "FLR", TGSI_OPCODE_FLR },
|
||||
{ 1, 1, 0, 0, "ROUND", TGSI_OPCODE_ROUND },
|
||||
{ 1, 1, 0, 0, "EX2", TGSI_OPCODE_EX2 },
|
||||
{ 1, 1, 0, 0, "LG2", TGSI_OPCODE_LG2 },
|
||||
{ 1, 2, 0, 0, "POW", TGSI_OPCODE_POW },
|
||||
{ 1, 2, 0, 0, "XPD", TGSI_OPCODE_XPD },
|
||||
{ 0, 0, 0, 0, "", 32 }, /* removed */
|
||||
{ 1, 1, 0, 0, "ABS", TGSI_OPCODE_ABS },
|
||||
{ 1, 1, 0, 0, "RCC", TGSI_OPCODE_RCC },
|
||||
{ 1, 2, 0, 0, "DPH", TGSI_OPCODE_DPH },
|
||||
{ 1, 1, 0, 0, "COS", TGSI_OPCODE_COS },
|
||||
{ 1, 1, 0, 0, "DDX", TGSI_OPCODE_DDX },
|
||||
{ 1, 1, 0, 0, "DDY", TGSI_OPCODE_DDY },
|
||||
{ 0, 0, 0, 0, "KILP", TGSI_OPCODE_KILP },
|
||||
{ 1, 1, 0, 0, "PK2H", TGSI_OPCODE_PK2H },
|
||||
{ 1, 1, 0, 0, "PK2US", TGSI_OPCODE_PK2US },
|
||||
{ 1, 1, 0, 0, "PK4B", TGSI_OPCODE_PK4B },
|
||||
{ 1, 1, 0, 0, "PK4UB", TGSI_OPCODE_PK4UB },
|
||||
{ 1, 2, 0, 0, "RFL", TGSI_OPCODE_RFL },
|
||||
{ 1, 2, 0, 0, "SEQ", TGSI_OPCODE_SEQ },
|
||||
{ 1, 2, 0, 0, "SFL", TGSI_OPCODE_SFL },
|
||||
{ 1, 2, 0, 0, "SGT", TGSI_OPCODE_SGT },
|
||||
{ 1, 1, 0, 0, "SIN", TGSI_OPCODE_SIN },
|
||||
{ 1, 2, 0, 0, "SLE", TGSI_OPCODE_SLE },
|
||||
{ 1, 2, 0, 0, "SNE", TGSI_OPCODE_SNE },
|
||||
{ 1, 2, 0, 0, "STR", TGSI_OPCODE_STR },
|
||||
{ 1, 2, 1, 0, "TEX", TGSI_OPCODE_TEX },
|
||||
{ 1, 4, 1, 0, "TXD", TGSI_OPCODE_TXD },
|
||||
{ 1, 2, 1, 0, "TXP", TGSI_OPCODE_TXP },
|
||||
{ 1, 1, 0, 0, "UP2H", TGSI_OPCODE_UP2H },
|
||||
{ 1, 1, 0, 0, "UP2US", TGSI_OPCODE_UP2US },
|
||||
{ 1, 1, 0, 0, "UP4B", TGSI_OPCODE_UP4B },
|
||||
{ 1, 1, 0, 0, "UP4UB", TGSI_OPCODE_UP4UB },
|
||||
{ 1, 3, 0, 0, "X2D", TGSI_OPCODE_X2D },
|
||||
{ 1, 1, 0, 0, "ARA", TGSI_OPCODE_ARA },
|
||||
{ 1, 1, 0, 0, "ARR", TGSI_OPCODE_ARR },
|
||||
{ 0, 1, 0, 0, "BRA", TGSI_OPCODE_BRA },
|
||||
{ 0, 0, 0, 1, "CAL", TGSI_OPCODE_CAL },
|
||||
{ 0, 0, 0, 0, "RET", TGSI_OPCODE_RET },
|
||||
{ 1, 1, 0, 0, "SSG", TGSI_OPCODE_SSG },
|
||||
{ 1, 3, 0, 0, "CMP", TGSI_OPCODE_CMP },
|
||||
{ 1, 1, 0, 0, "SCS", TGSI_OPCODE_SCS },
|
||||
{ 1, 2, 1, 0, "TXB", TGSI_OPCODE_TXB },
|
||||
{ 1, 1, 0, 0, "NRM", TGSI_OPCODE_NRM },
|
||||
{ 1, 2, 0, 0, "DIV", TGSI_OPCODE_DIV },
|
||||
{ 1, 2, 0, 0, "DP2", TGSI_OPCODE_DP2 },
|
||||
{ 1, 2, 1, 0, "TXL", TGSI_OPCODE_TXL },
|
||||
{ 0, 0, 0, 0, "BRK", TGSI_OPCODE_BRK },
|
||||
{ 0, 1, 0, 1, "IF", TGSI_OPCODE_IF },
|
||||
{ 1, 1, 0, 0, "BGNFOR", TGSI_OPCODE_BGNFOR },
|
||||
{ 0, 1, 0, 0, "REP", TGSI_OPCODE_REP },
|
||||
{ 0, 0, 0, 1, "ELSE", TGSI_OPCODE_ELSE },
|
||||
{ 0, 0, 0, 0, "ENDIF", TGSI_OPCODE_ENDIF },
|
||||
{ 1, 0, 0, 0, "ENDFOR", TGSI_OPCODE_ENDFOR },
|
||||
{ 0, 0, 0, 0, "ENDREP", TGSI_OPCODE_ENDREP },
|
||||
{ 0, 1, 0, 0, "PUSHA", TGSI_OPCODE_PUSHA },
|
||||
{ 1, 0, 0, 0, "POPA", TGSI_OPCODE_POPA },
|
||||
{ 1, 1, 0, 0, "CEIL", TGSI_OPCODE_CEIL },
|
||||
{ 1, 1, 0, 0, "I2F", TGSI_OPCODE_I2F },
|
||||
{ 1, 1, 0, 0, "NOT", TGSI_OPCODE_NOT },
|
||||
{ 1, 1, 0, 0, "TRUNC", TGSI_OPCODE_TRUNC },
|
||||
{ 1, 2, 0, 0, "SHL", TGSI_OPCODE_SHL },
|
||||
{ 1, 2, 0, 0, "SHR", TGSI_OPCODE_SHR },
|
||||
{ 1, 2, 0, 0, "AND", TGSI_OPCODE_AND },
|
||||
{ 1, 2, 0, 0, "OR", TGSI_OPCODE_OR },
|
||||
{ 1, 2, 0, 0, "MOD", TGSI_OPCODE_MOD },
|
||||
{ 1, 2, 0, 0, "XOR", TGSI_OPCODE_XOR },
|
||||
{ 1, 3, 0, 0, "SAD", TGSI_OPCODE_SAD },
|
||||
{ 1, 2, 1, 0, "TXF", TGSI_OPCODE_TXF },
|
||||
{ 1, 2, 1, 0, "TXQ", TGSI_OPCODE_TXQ },
|
||||
{ 0, 0, 0, 0, "CONT", TGSI_OPCODE_CONT },
|
||||
{ 0, 0, 0, 0, "EMIT", TGSI_OPCODE_EMIT },
|
||||
{ 0, 0, 0, 0, "ENDPRIM", TGSI_OPCODE_ENDPRIM },
|
||||
{ 0, 0, 0, 1, "BGNLOOP", TGSI_OPCODE_BGNLOOP },
|
||||
{ 0, 0, 0, 0, "BGNSUB", TGSI_OPCODE_BGNSUB },
|
||||
{ 0, 0, 0, 1, "ENDLOOP", TGSI_OPCODE_ENDLOOP },
|
||||
{ 0, 0, 0, 0, "ENDSUB", TGSI_OPCODE_ENDSUB },
|
||||
{ 1, 1, 0, 0, "NOISE1", TGSI_OPCODE_NOISE1 },
|
||||
{ 1, 1, 0, 0, "NOISE2", TGSI_OPCODE_NOISE2 },
|
||||
{ 1, 1, 0, 0, "NOISE3", TGSI_OPCODE_NOISE3 },
|
||||
{ 1, 1, 0, 0, "NOISE4", TGSI_OPCODE_NOISE4 },
|
||||
{ 0, 0, 0, 0, "NOP", TGSI_OPCODE_NOP },
|
||||
{ 0, 0, 0, 0, "", 108 }, /* removed */
|
||||
{ 0, 0, 0, 0, "", 109 }, /* removed */
|
||||
{ 0, 0, 0, 0, "", 110 }, /* removed */
|
||||
{ 0, 0, 0, 0, "", 111 }, /* removed */
|
||||
{ 1, 1, 0, 0, "NRM4", TGSI_OPCODE_NRM4 },
|
||||
{ 0, 1, 0, 0, "CALLNZ", TGSI_OPCODE_CALLNZ },
|
||||
{ 0, 1, 0, 0, "IFC", TGSI_OPCODE_IFC },
|
||||
{ 0, 1, 0, 0, "BREAKC", TGSI_OPCODE_BREAKC },
|
||||
{ 0, 1, 0, 0, "KIL", TGSI_OPCODE_KIL },
|
||||
{ 0, 0, 0, 0, "END", TGSI_OPCODE_END },
|
||||
{ 1, 1, 0, 0, "SWZ", TGSI_OPCODE_SWZ }
|
||||
};
|
||||
|
||||
const struct tgsi_opcode_info *
|
||||
tgsi_get_opcode_info( uint opcode )
|
||||
{
|
||||
static boolean firsttime = 1;
|
||||
|
||||
if (firsttime) {
|
||||
unsigned i;
|
||||
firsttime = 0;
|
||||
for (i = 0; i < Elements(opcode_info); i++)
|
||||
assert(opcode_info[i].opcode == i);
|
||||
}
|
||||
|
||||
if (opcode < TGSI_OPCODE_LAST)
|
||||
return &opcode_info[opcode];
|
||||
|
||||
assert( 0 );
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const char *
|
||||
tgsi_get_opcode_name( uint opcode )
|
||||
{
|
||||
const struct tgsi_opcode_info *info = tgsi_get_opcode_info(opcode);
|
||||
return info->mnemonic;
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue