summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-10-27 15:40:33 +1100
committerBen Skeggs <[email protected]>2008-10-27 15:40:33 +1100
commit70a06e03d45f3d2e1cd1d430ba83c4b22471373c (patch)
tree399cc450107d78041a53b61773635560472ae08a
parent295d6f8e8f03192320aa8d4ed767427dd06071a5 (diff)
parent02c9009bb842cd8a47bc36ea274ef54ff47e1528 (diff)
Merge remote branch 'origin/gallium-0.2' into gallium-0.2
-rw-r--r--SConstruct2
-rw-r--r--common.py3
-rw-r--r--configs/linux-cell2
-rw-r--r--configs/linux-dri11
-rw-r--r--docs/cell.html38
-rw-r--r--progs/demos/fslight.c2
-rw-r--r--progs/demos/textures.c104
-rw-r--r--progs/trivial/Makefile4
-rw-r--r--progs/trivial/tri-tex.c168
-rw-r--r--progs/trivial/tri.c17
-rw-r--r--progs/trivial/vp-tri-cb-pos.c156
-rw-r--r--progs/trivial/vp-tri-cb-tex.c189
-rw-r--r--progs/trivial/vp-tri-tex.c137
-rw-r--r--progs/vp/vp-tris.c11
-rw-r--r--progs/vp/xform.txt11
-rw-r--r--scons/gallium.py1
-rw-r--r--src/gallium/auxiliary/draw/Makefile1
-rw-r--r--src/gallium/auxiliary/draw/SConscript1
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.c5
-rw-r--r--src/gallium/auxiliary/draw/draw_vs.h4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_aos_io.c2
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_exec.c4
-rw-r--r--src/gallium/auxiliary/draw/draw_vs_ppc.c274
-rw-r--r--src/gallium/auxiliary/rtasm/Makefile1
-rw-r--r--src/gallium/auxiliary/rtasm/SConscript1
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_ppc.c641
-rw-r--r--src/gallium/auxiliary/rtasm/rtasm_ppc.h151
-rw-r--r--src/gallium/auxiliary/tgsi/Makefile1
-rw-r--r--src/gallium/auxiliary/tgsi/SConscript1
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.c910
-rw-r--r--src/gallium/auxiliary/tgsi/tgsi_ppc.h (renamed from src/gallium/drivers/cell/spu/spu_debug.h)41
-rw-r--r--src/gallium/drivers/cell/common.h70
-rw-r--r--src/gallium/drivers/cell/ppu/Makefile1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_batch.c43
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c23
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.h26
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.c158
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.h57
-rw-r--r--src/gallium/drivers/cell/ppu/cell_gen_fp.c125
-rw-r--r--src/gallium/drivers/cell/ppu/cell_pipe_state.c41
-rw-r--r--src/gallium/drivers/cell/ppu/cell_spu.c38
-rw-r--r--src/gallium/drivers/cell/ppu/cell_spu.h12
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_emit.c68
-rw-r--r--src/gallium/drivers/cell/ppu/cell_state_shader.c2
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c27
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h5
-rw-r--r--src/gallium/drivers/cell/ppu/cell_vbuf.c7
-rw-r--r--src/gallium/drivers/cell/spu/spu_command.c152
-rw-r--r--src/gallium/drivers/cell/spu/spu_dcache.c4
-rw-r--r--src/gallium/drivers/cell/spu/spu_funcs.c34
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.c9
-rw-r--r--src/gallium/drivers/cell/spu/spu_main.h50
-rw-r--r--src/gallium/drivers/cell/spu/spu_per_fragment_op.c122
-rw-r--r--src/gallium/drivers/cell/spu/spu_render.c34
-rw-r--r--src/gallium/drivers/cell/spu/spu_texture.c208
-rw-r--r--src/gallium/drivers/cell/spu/spu_texture.h34
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.c162
-rw-r--r--src/gallium/drivers/cell/spu/spu_tri.h2
-rw-r--r--src/gallium/drivers/softpipe/sp_fs_exec.c7
-rw-r--r--src/gallium/include/pipe/p_config.h5
-rw-r--r--src/gallium/winsys/xlib/SConscript22
-rw-r--r--src/glx/x11/XF86dri.c1003
-rw-r--r--src/glx/x11/clientattrib.c160
-rw-r--r--src/glx/x11/compsize.c246
-rw-r--r--src/glx/x11/dri2.c93
-rw-r--r--src/glx/x11/dri2.h15
-rw-r--r--src/glx/x11/dri2_glx.c43
-rw-r--r--src/glx/x11/dri_common.c3
-rw-r--r--src/glx/x11/dri_common.h18
-rw-r--r--src/glx/x11/dri_glx.c10
-rw-r--r--src/glx/x11/drisw_glx.c593
-rw-r--r--src/glx/x11/eval.c143
-rw-r--r--src/glx/x11/glcontextmodes.c619
-rw-r--r--src/glx/x11/glcontextmodes.h31
-rw-r--r--src/glx/x11/glx_pbuffer.c385
-rw-r--r--src/glx/x11/glx_query.c74
-rw-r--r--src/glx/x11/glxclient.h5
-rw-r--r--src/glx/x11/glxcmds.c8
-rw-r--r--src/glx/x11/glxcurrent.c550
-rw-r--r--src/glx/x11/glxext.c1406
-rw-r--r--src/glx/x11/glxextensions.c362
-rw-r--r--src/glx/x11/glxextensions.h57
-rw-r--r--src/glx/x11/glxhash.c552
-rw-r--r--src/glx/x11/glxhash.h17
-rw-r--r--src/glx/x11/indirect_init.h1
-rw-r--r--src/glx/x11/indirect_texture_compression.c507
-rw-r--r--src/glx/x11/indirect_transpose_matrix.c59
-rw-r--r--src/glx/x11/indirect_vertex_array.c2794
-rw-r--r--src/glx/x11/indirect_vertex_array.h44
-rw-r--r--src/glx/x11/indirect_vertex_array_priv.h110
-rw-r--r--src/glx/x11/indirect_vertex_program.c329
-rw-r--r--src/glx/x11/indirect_window_pos.c71
-rw-r--r--src/glx/x11/packrender.h243
-rw-r--r--src/glx/x11/packsingle.h215
-rw-r--r--src/glx/x11/pixel.c723
-rw-r--r--src/glx/x11/pixelstore.c526
-rw-r--r--src/glx/x11/render2.c569
-rw-r--r--src/glx/x11/renderpix.c214
-rw-r--r--src/glx/x11/single2.c1400
-rw-r--r--src/glx/x11/singlepix.c284
-rw-r--r--src/glx/x11/vertarr.c222
-rw-r--r--src/glx/x11/xf86dri.h106
-rw-r--r--src/glx/x11/xf86dristr.h440
-rw-r--r--src/glx/x11/xfont.c424
-rw-r--r--src/mesa/SConscript4
-rw-r--r--src/mesa/drivers/dri/i915/i915_program.c13
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_draw.c197
-rw-r--r--src/mesa/main/context.c1
-rw-r--r--src/mesa/main/ffvertex_prog.c70
-rw-r--r--src/mesa/main/mtypes.h2
-rw-r--r--src/mesa/main/state.c29
-rw-r--r--src/mesa/main/state.h17
-rw-r--r--src/mesa/main/texenvprogram.c14
-rw-r--r--src/mesa/ppc/common_ppc.c2
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c6
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c4
116 files changed, 12266 insertions, 8209 deletions
diff --git a/SConstruct b/SConstruct
index c1dc6246519..8c96817daef 100644
--- a/SConstruct
+++ b/SConstruct
@@ -70,12 +70,14 @@ platform = env['platform']
# derived options
x86 = machine == 'x86'
+ppc = machine == 'ppc'
gcc = platform in ('linux', 'freebsd', 'darwin')
msvc = platform in ('windows', 'winddk')
Export([
'debug',
'x86',
+ 'ppc',
'dri',
'llvm',
'platform',
diff --git a/common.py b/common.py
index dd64e0f434d..cc2582f1a4e 100644
--- a/common.py
+++ b/common.py
@@ -24,6 +24,7 @@ _machine_map = {
'i486': 'x86',
'i586': 'x86',
'i686': 'x86',
+ 'ppc' : 'ppc',
'x86_64': 'x86_64',
}
if 'PROCESSOR_ARCHITECTURE' in os.environ:
@@ -56,7 +57,7 @@ def AddOptions(opts):
opts.Add(BoolOption('profile', 'profile build', 'no'))
#opts.Add(BoolOption('quiet', 'quiet command lines', 'no'))
opts.Add(EnumOption('machine', 'use machine-specific assembly code', default_machine,
- allowed_values=('generic', 'x86', 'x86_64')))
+ allowed_values=('generic', 'ppc', 'x86', 'x86_64')))
opts.Add(EnumOption('platform', 'target platform', default_platform,
allowed_values=('linux', 'cell', 'windows', 'winddk', 'wince')))
opts.Add(BoolOption('llvm', 'use LLVM', 'no'))
diff --git a/configs/linux-cell b/configs/linux-cell
index 8d74ee469de..f68a6853c32 100644
--- a/configs/linux-cell
+++ b/configs/linux-cell
@@ -24,7 +24,7 @@ OPT_FLAGS = -O3
SDK = /opt/cell/sdk/usr
-CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -mabi=altivec -maltivec \
+CFLAGS = $(OPT_FLAGS) -Wall -Winline -fPIC -m32 -std=c99 -mabi=altivec -maltivec \
-I. -I$(SDK)/include \
-DGALLIUM_CELL -DUSE_XSHM
diff --git a/configs/linux-dri b/configs/linux-dri
index eb6f307dac5..6a61f0c8dba 100644
--- a/configs/linux-dri
+++ b/configs/linux-dri
@@ -55,20 +55,15 @@ SRC_DIRS := glx/x11 egl $(SRC_DIRS)
# Directories
-ifeq ($(USING_EGL), 1)
-SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw
+SRC_DIRS = egl glx/x11 gallium mesa glu glut/glx glw
PROGRAM_DIRS = egl xdemos
-else
-SRC_DIRS = glx/x11 gallium mesa glu glut/glx glw
-PROGRAM_DIRS = xdemos
-endif
# EGL directories
-EGL_DRIVERS_DIRS = demo dri xdri
+EGL_DRIVERS_DIRS = demo glx
DRIVER_DIRS =
WINDOW_SYSTEM = dri
-GALLIUM_WINSYS_DIRS = drm egl_xlib
+GALLIUM_WINSYS_DIRS = drm
# gamma are missing because they have not been converted to use the new
# interface.
diff --git a/docs/cell.html b/docs/cell.html
index 34d9a927231..7fbbba7c7e0 100644
--- a/docs/cell.html
+++ b/docs/cell.html
@@ -83,23 +83,23 @@ Similarly, textures are tiled and brought into local store as needed.
<H2>Status</H2>
<p>
-As of September 2008, the driver supports smooth/flat shaded triangle rendering
-with Z testing and simple texture mapping.
-Simple demos like gears run successfully.
-To test texture mapping, try progs/demos/texcyl (press right mouse button for
-rendering options).
+As of October 2008, the driver runs quite a few OpenGL demos.
+Features that work include:
</p>
+<ul>
+<li>Point/line/triangle rendering, glDrawPixels
+<li>2D, NPOT and cube texture maps with nearest/linear/mipmap filtering
+<li>Dynamic SPU code generation for fragment shaders, but not complete
+<li>Dynamic SPU code generation for fragment ops (blend, Z-test, etc), but not complete
+<li>Dynamic PPU/PPC code generation for vertex shaders, but not complete
+</ul>
<p>
-Runtime/dynamic code generation is being done for per-fragment
-operations (Z test, blend, etc) and for fragment programs (though only a
-few opcodes are implemented now).
+Performance has recently improved with the addition of PPC code generation
+for vertex shaders, but the code quality isn't too great yet.
</p>
<p>
-In general, however, the driver is rather slow because all vertex
-transformation is being done by an interpreter running on the PPU.
-Programs with many vertices or complex vertex shaders will run especially
-slow.
-This will be addressed in the future.
+Another bottleneck is SwapBuffers. It may be the limiting factor for
+many simple GL tests.
</p>
@@ -114,9 +114,21 @@ more of the following debug options:
<li><b>checker</b> - use a different background clear color for each SPU.
This lets you see which SPU is rendering which screen tiles.
<li><b>sync</b> - wait/synchronize after each DMA transfer
+<li><b>asm</b> - print generated SPU assembly code to stdout
+<li><b>fragops</b> - emit fragment ops debug messages
+<li><b>fragopfallback</b> - don't use codegen for fragment ops
+<li><b>cmd</b> - print SPU commands as their received
+<li><b>cache</b> - print texture cache statistics when program exits
</ul>
+<p>
+Note that some of these options may only work for linux-cell-debug builds.
+</p>
<p>
+If the GALLIUM_NOPPC env var is set, PPC code generation will not be used
+and vertex shaders will be run with the TGSI interpreter.
+</p>
+<p>
If the GALLIUM_NOCELL env var is set, the softpipe driver will be used
intead of the Cell driver.
This is useful for comparison/validation.
diff --git a/progs/demos/fslight.c b/progs/demos/fslight.c
index c7931f4697e..e79b5cc1970 100644
--- a/progs/demos/fslight.c
+++ b/progs/demos/fslight.c
@@ -45,7 +45,7 @@ static GLint uTexture;
static GLuint SphereList, RectList, CurList;
static GLint win = 0;
-static GLboolean anim = 0*GL_TRUE;
+static GLboolean anim = GL_TRUE;
static GLboolean wire = GL_FALSE;
static GLboolean pixelLight = GL_TRUE;
diff --git a/progs/demos/textures.c b/progs/demos/textures.c
index 9f116046359..b7bf135d219 100644
--- a/progs/demos/textures.c
+++ b/progs/demos/textures.c
@@ -9,6 +9,9 @@
#include <GL/glut.h>
#include "readtex.h"
+#define TEST_CLAMP 0
+#define TEST_MIPMAPS 0
+
#define MAX_TEXTURES 8
@@ -16,7 +19,8 @@ static int Win;
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
static GLboolean Anim = GL_TRUE;
static GLboolean Blend = GL_FALSE;
-static GLboolean MipMap = 1+GL_FALSE;
+static GLuint Filter = 0;
+static GLboolean Clamp = GL_FALSE;
static GLuint NumTextures;
static GLuint Textures[MAX_TEXTURES];
@@ -32,6 +36,22 @@ static const char *DefaultFiles[] = {
};
+#define NUM_FILTERS 5
+static
+struct filter {
+ GLenum min, mag;
+ const char *name;
+} FilterModes[NUM_FILTERS] = {
+ { GL_NEAREST, GL_NEAREST, "Nearest,Nearest" },
+ { GL_LINEAR, GL_LINEAR, "Linear,Linear" },
+ { GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST, "NearestMipmapNearest,Nearest" },
+ { GL_LINEAR_MIPMAP_NEAREST, GL_LINEAR, "LinearMipmapNearest,Linear" },
+ { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, "LinearMipmapLinear,Linear" }
+};
+
+
+
+
static void
Idle(void)
{
@@ -58,10 +78,17 @@ DrawTextures(void)
glBindTexture(GL_TEXTURE_2D, Textures[i]);
glBegin(GL_POLYGON);
+#if TEST_CLAMP
+ glTexCoord2f( -0.5, -0.5 ); glVertex2f( -ar, -1.0 );
+ glTexCoord2f( 1.5, -0.5 ); glVertex2f( ar, -1.0 );
+ glTexCoord2f( 1.5, 1.5 ); glVertex2f( ar, 1.0 );
+ glTexCoord2f( -0.5, 1.5 ); glVertex2f( -ar, 1.0 );
+#else
glTexCoord2f( 0.0, 0.0 ); glVertex2f( -ar, -1.0 );
glTexCoord2f( 1.0, 0.0 ); glVertex2f( ar, -1.0 );
glTexCoord2f( 1.0, 1.0 ); glVertex2f( ar, 1.0 );
glTexCoord2f( 0.0, 1.0 ); glVertex2f( -ar, 1.0 );
+#endif
glEnd();
glPopMatrix();
@@ -137,19 +164,23 @@ Randomize(void)
static void
-SetTexFilters(void)
+SetTexParams(void)
{
GLuint i;
for (i = 0; i < NumTextures; i++) {
glBindTexture(GL_TEXTURE_2D, Textures[i]);
- if (MipMap) {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
- GL_LINEAR_MIPMAP_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ FilterModes[Filter].min);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ FilterModes[Filter].mag);
+
+ if (Clamp) {
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
}
else {
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
}
}
}
@@ -163,6 +194,7 @@ Key(unsigned char key, int x, int y)
(void) y;
switch (key) {
case 'a':
+ case ' ':
Anim = !Anim;
if (Anim)
glutIdleFunc(Idle);
@@ -172,12 +204,19 @@ Key(unsigned char key, int x, int y)
case 'b':
Blend = !Blend;
break;
- case 'm':
- MipMap = !MipMap;
- SetTexFilters();
+ case 'f':
+ Filter = (Filter + 1) % NUM_FILTERS;
+ SetTexParams();
break;
case 'r':
Randomize();
+ break;
+#if TEST_CLAMP
+ case 'c':
+ Clamp = !Clamp;
+ SetTexParams();
+ break;
+#endif
case 'z':
Zrot -= step;
break;
@@ -190,9 +229,9 @@ Key(unsigned char key, int x, int y)
break;
}
- printf("Blend=%s MipMap=%s\n",
+ printf("Blend=%s Filter=%s\n",
Blend ? "Y" : "n",
- MipMap ? "Y" : "n");
+ FilterModes[Filter].name);
glutPostRedisplay();
}
@@ -231,15 +270,46 @@ LoadTextures(GLuint n, const char *files[])
glGenTextures(n, Textures);
+ SetTexParams();
+
for (i = 0; i < n; i++) {
GLint w, h;
glBindTexture(GL_TEXTURE_2D, Textures[i]);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+#if TEST_MIPMAPS
+ {
+ static const GLubyte color[9][4] = {
+ {255, 0, 0},
+ {0, 255, 0},
+ {0, 0, 255},
+ {0, 255, 255},
+ {255, 0, 255},
+ {255, 255, 0},
+ {255, 128, 255},
+ {128, 128, 128},
+ {64, 64, 64}
+ };
+
+ GLubyte image[256*256*4];
+ int i, level;
+ w = h = 256;
+ for (level = 0; level <= 8; level++) {
+ for (i = 0; i < w * h; i++) {
+ image[i*4+0] = color[level][0];
+ image[i*4+1] = color[level][1];
+ image[i*4+2] = color[level][2];
+ image[i*4+3] = color[level][3];
+ }
+ printf("Load level %d: %d x %d\n", level, w>>level, h>>level);
+ glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA, w>>level, h>>level, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, image);
+ }
+ }
+#else
if (!LoadRGBMipmaps2(files[i], GL_TEXTURE_2D, GL_RGB, &w, &h)) {
printf("Error: couldn't load %s\n", files[i]);
exit(1);
}
+#endif
TexAspect[i] = (float) w / (float) h;
printf("Loaded %s\n", files[i]);
}
@@ -277,7 +347,7 @@ Usage(void)
printf("Keys:\n");
printf(" a - toggle animation\n");
printf(" b - toggle blending\n");
- printf(" m - toggle mipmapping\n");
+ printf(" f - change texture filter mode\n");
printf(" r - randomize\n");
printf(" ESC - exit\n");
}
@@ -288,7 +358,7 @@ main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitWindowPosition(0, 0);
- glutInitWindowSize(400, 400);
+ glutInitWindowSize(700, 700);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
Win = glutCreateWindow(argv[0]);
glutReshapeFunc(Reshape);
diff --git a/progs/trivial/Makefile b/progs/trivial/Makefile
index a4077bd0169..3f26798ca62 100644
--- a/progs/trivial/Makefile
+++ b/progs/trivial/Makefile
@@ -97,6 +97,7 @@ SOURCES = \
tri-query.c \
tri-scissor-tri.c \
tri-stencil.c \
+ tri-tex.c \
tri-tex-3d.c \
tri-tri.c \
tri-unfilled-edgeflag.c \
@@ -126,8 +127,11 @@ SOURCES = \
vp-line-clip.c \
vp-tri.c \
vp-tri-swap.c \
+ vp-tri-tex.c \
vp-tri-imm.c \
vp-tri-cb.c \
+ vp-tri-cb-pos.c \
+ vp-tri-cb-tex.c \
vp-unfilled.c
PROGS = $(SOURCES:%.c=%)
diff --git a/progs/trivial/tri-tex.c b/progs/trivial/tri-tex.c
new file mode 100644
index 00000000000..a0d75b4a331
--- /dev/null
+++ b/progs/trivial/tri-tex.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (c) 1991, 1992, 1993 Silicon Graphics, Inc.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and
+ * its documentation for any purpose is hereby granted without fee, provided
+ * that (i) the above copyright notices and this permission notice appear in
+ * all copies of the software and related documentation, and (ii) the name of
+ * Silicon Graphics may not be used in any advertising or
+ * publicity relating to the software without the specific, prior written
+ * permission of Silicon Graphics.
+ *
+ * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF
+ * ANY KIND,
+ * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
+ * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR
+ * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
+ * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+ * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
+ * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
+ * OF THIS SOFTWARE.
+ */
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <GL/glut.h>
+
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ fprintf(stderr, "GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
+ fprintf(stderr, "GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
+ fprintf(stderr, "GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
+
+ glClearColor(0.0, 0.0, 1.0, 0.0);
+
+
+#define SIZE 32
+ {
+ GLubyte tex2d[SIZE][SIZE][3];
+ GLint s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+#if 0
+ tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex2d[t][s][2] = 0;
+#else
+ tex2d[t][s][0] = s*255/(SIZE-1);
+ tex2d[t][s][1] = t*255/(SIZE-1);
+ tex2d[t][s][2] = 0;
+#endif
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ }
+
+}
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glTexCoord2f(1,-1);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glTexCoord2f(-1,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/tri.c b/progs/trivial/tri.c
index aa45adb6c29..d3c6b59ea5d 100644
--- a/progs/trivial/tri.c
+++ b/progs/trivial/tri.c
@@ -57,16 +57,13 @@ static void Reshape(int width, int height)
static void Key(unsigned char key, int x, int y)
{
-
- switch (key) {
- case 27:
- glutDestroyWindow(win);
- exit(0);
- default:
- return;
- }
-
- glutPostRedisplay();
+ switch (key) {
+ case 27:
+ exit(0);
+ default:
+ glutPostRedisplay();
+ return;
+ }
}
static void Draw(void)
diff --git a/progs/trivial/vp-tri-cb-pos.c b/progs/trivial/vp-tri-cb-pos.c
new file mode 100644
index 00000000000..eb3aa0a8dc6
--- /dev/null
+++ b/progs/trivial/vp-tri-cb-pos.c
@@ -0,0 +1,156 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "PARAM Emission = state.material.emission; \n"
+ "PARAM Ambient = state.material.ambient; \n"
+ "PARAM Diffuse = state.material.diffuse; \n"
+ "PARAM Specular = state.material.specular; \n"
+ "DP4 result.position.x, Ambient, vertex.position;\n"
+ "DP4 result.position.y, Diffuse, vertex.position;\n"
+ "DP4 result.position.z, Specular, vertex.position;\n"
+ "DP4 result.position.w, Emission, vertex.position;\n"
+ "MOV result.color, vertex.color;\n"
+ "END\n";
+
+ const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 };
+ const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 };
+ const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 };
+ const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 };
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+}
+
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glColor3f(0,0,.7);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glColor3f(.8,0,0);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glColor3f(0,.9,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-tri-cb-tex.c b/progs/trivial/vp-tri-cb-tex.c
new file mode 100644
index 00000000000..1e99d5b6abc
--- /dev/null
+++ b/progs/trivial/vp-tri-cb-tex.c
@@ -0,0 +1,189 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+
+
+GLenum doubleBuffer;
+
+static void Init(void)
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "PARAM Emission = state.material.emission; \n"
+ "PARAM Ambient = state.material.ambient; \n"
+ "PARAM Diffuse = state.material.diffuse; \n"
+ "PARAM Specular = state.material.specular; \n"
+ "DP4 result.position.x, Ambient, vertex.position;\n"
+ "DP4 result.position.y, Diffuse, vertex.position;\n"
+ "DP4 result.position.z, Specular, vertex.position;\n"
+ "DP4 result.position.w, Emission, vertex.position;\n"
+ "MOV result.texcoord[0], vertex.texcoord[0];\n"
+ "END\n";
+
+ const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 };
+ const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 };
+ const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 };
+ const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 };
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+#define SIZE 32
+ {
+ GLubyte tex2d[SIZE][SIZE][3];
+ GLint s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+#if 0
+ tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex2d[t][s][2] = 0;
+#else
+ tex2d[t][s][0] = s*255/(SIZE-1);
+ tex2d[t][s][1] = t*255/(SIZE-1);
+ tex2d[t][s][2] = 0;
+#endif
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ }
+
+}
+
+
+static void Reshape(int width, int height)
+{
+
+ glViewport(0, 0, (GLint)width, (GLint)height);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+/* glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0); */
+ glMatrixMode(GL_MODELVIEW);
+}
+
+static void Key(unsigned char key, int x, int y)
+{
+
+ switch (key) {
+ case 27:
+ exit(1);
+ default:
+ return;
+ }
+
+ glutPostRedisplay();
+}
+
+static void Draw(void)
+{
+ glClear(GL_COLOR_BUFFER_BIT);
+
+ glBegin(GL_TRIANGLES);
+ glTexCoord2f(1,-1);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glTexCoord2f(-1,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+ glFlush();
+
+ if (doubleBuffer) {
+ glutSwapBuffers();
+ }
+}
+
+static GLenum Args(int argc, char **argv)
+{
+ GLint i;
+
+ doubleBuffer = GL_FALSE;
+
+ for (i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "-sb") == 0) {
+ doubleBuffer = GL_FALSE;
+ } else if (strcmp(argv[i], "-db") == 0) {
+ doubleBuffer = GL_TRUE;
+ } else {
+ fprintf(stderr, "%s (Bad option).\n", argv[i]);
+ return GL_FALSE;
+ }
+ }
+ return GL_TRUE;
+}
+
+int main(int argc, char **argv)
+{
+ GLenum type;
+
+ glutInit(&argc, argv);
+
+ if (Args(argc, argv) == GL_FALSE) {
+ exit(1);
+ }
+
+ glutInitWindowPosition(0, 0); glutInitWindowSize( 250, 250);
+
+ type = GLUT_RGB | GLUT_ALPHA;
+ type |= (doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE;
+ glutInitDisplayMode(type);
+
+ if (glutCreateWindow("First Tri") == GL_FALSE) {
+ exit(1);
+ }
+
+ Init();
+
+ glutReshapeFunc(Reshape);
+ glutKeyboardFunc(Key);
+ glutDisplayFunc(Draw);
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/trivial/vp-tri-tex.c b/progs/trivial/vp-tri-tex.c
new file mode 100644
index 00000000000..83ec1ef2e2f
--- /dev/null
+++ b/progs/trivial/vp-tri-tex.c
@@ -0,0 +1,137 @@
+/* Test glGenProgramsNV(), glIsProgramNV(), glLoadProgramNV() */
+
+#include <assert.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#define GL_GLEXT_PROTOTYPES
+#include <GL/glut.h>
+
+static void Init( void )
+{
+ GLint errno;
+ GLuint prognum;
+
+ static const char *prog1 =
+ "!!ARBvp1.0\n"
+ "MOV result.texcoord[0], vertex.texcoord[0];\n"
+ "MOV result.position, vertex.position;\n"
+ "END\n";
+
+
+ glGenProgramsARB(1, &prognum);
+
+ glBindProgramARB(GL_VERTEX_PROGRAM_ARB, prognum);
+ glProgramStringARB(GL_VERTEX_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB,
+ strlen(prog1), (const GLubyte *) prog1);
+
+ assert(glIsProgramARB(prognum));
+ errno = glGetError();
+ printf("glGetError = %d\n", errno);
+ if (errno != GL_NO_ERROR)
+ {
+ GLint errorpos;
+
+ glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errorpos);
+ printf("errorpos: %d\n", errorpos);
+ printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+ }
+
+#define SIZE 32
+ {
+ GLubyte tex2d[SIZE][SIZE][3];
+ GLint s, t;
+
+ for (s = 0; s < SIZE; s++) {
+ for (t = 0; t < SIZE; t++) {
+#if 0
+ tex2d[t][s][0] = (s < SIZE/2) ? 0 : 255;
+ tex2d[t][s][1] = (t < SIZE/2) ? 0 : 255;
+ tex2d[t][s][2] = 0;
+#else
+ tex2d[t][s][0] = s*255/(SIZE-1);
+ tex2d[t][s][1] = t*255/(SIZE-1);
+ tex2d[t][s][2] = 0;
+#endif
+ }
+ }
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ glTexImage2D(GL_TEXTURE_2D, 0, 3, SIZE, SIZE, 0,
+ GL_RGB, GL_UNSIGNED_BYTE, tex2d);
+
+ glEnable(GL_TEXTURE_2D);
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_REPEAT);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
+ }
+
+}
+
+static void Display( void )
+{
+ glClearColor(0.3, 0.3, 0.3, 1);
+ glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
+
+ glEnable(GL_VERTEX_PROGRAM_NV);
+
+ glBegin(GL_TRIANGLES);
+ glTexCoord2f(1,-1);
+ glVertex3f( 0.9, -0.9, -0.0);
+ glTexCoord2f(1,1);
+ glVertex3f( 0.9, 0.9, -0.0);
+ glTexCoord2f(-1,0);
+ glVertex3f(-0.9, 0.0, -0.0);
+ glEnd();
+
+
+ glFlush();
+}
+
+
+static void Reshape( int width, int height )
+{
+ glViewport( 0, 0, width, height );
+ glMatrixMode( GL_PROJECTION );
+ glLoadIdentity();
+ glOrtho(-1.0, 1.0, -1.0, 1.0, -0.5, 1000.0);
+ glMatrixMode( GL_MODELVIEW );
+ glLoadIdentity();
+ /*glTranslatef( 0.0, 0.0, -15.0 );*/
+}
+
+
+static void Key( unsigned char key, int x, int y )
+{
+ (void) x;
+ (void) y;
+ switch (key) {
+ case 27:
+ exit(0);
+ break;
+ }
+ glutPostRedisplay();
+}
+
+
+
+
+int main( int argc, char *argv[] )
+{
+ glutInit( &argc, argv );
+ glutInitWindowPosition( 0, 0 );
+ glutInitWindowSize( 250, 250 );
+ glutInitDisplayMode( GLUT_DEPTH | GLUT_RGB | GLUT_SINGLE );
+ glutCreateWindow(argv[0]);
+ glutReshapeFunc( Reshape );
+ glutKeyboardFunc( Key );
+ glutDisplayFunc( Display );
+ Init();
+ glutMainLoop();
+ return 0;
+}
diff --git a/progs/vp/vp-tris.c b/progs/vp/vp-tris.c
index 3fe35f7e3e6..58014dd48de 100644
--- a/progs/vp/vp-tris.c
+++ b/progs/vp/vp-tris.c
@@ -155,6 +155,17 @@ static void Init( void )
printf("errorpos: %d\n", errorpos);
printf("%s\n", (char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB));
}
+
+ {
+ const float Ambient[4] = { 0.0, 1.0, 0.0, 0.0 };
+ const float Diffuse[4] = { 1.0, 0.0, 0.0, 0.0 };
+ const float Specular[4] = { 0.0, 0.0, 1.0, 0.0 };
+ const float Emission[4] = { 0.0, 0.0, 0.0, 1.0 };
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, Ambient);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, Diffuse);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, Specular);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, Emission);
+ }
}
diff --git a/progs/vp/xform.txt b/progs/vp/xform.txt
new file mode 100644
index 00000000000..d1548f1f10d
--- /dev/null
+++ b/progs/vp/xform.txt
@@ -0,0 +1,11 @@
+!!ARBvp1.0
+PARAM Emission = state.material.emission;
+PARAM Ambient = state.material.ambient;
+PARAM Diffuse = state.material.diffuse;
+PARAM Specular = state.material.specular;
+DP4 result.position.x, Ambient, vertex.position;
+DP4 result.position.y, Diffuse, vertex.position;
+DP4 result.position.z, Specular, vertex.position;
+DP4 result.position.w, Emission, vertex.position;
+MOV result.color, vertex.color;
+END
diff --git a/scons/gallium.py b/scons/gallium.py
index 3631607e666..2a42bdf2bb9 100644
--- a/scons/gallium.py
+++ b/scons/gallium.py
@@ -175,6 +175,7 @@ def generate(env):
machine = env['machine']
platform = env['platform']
x86 = env['machine'] == 'x86'
+ ppc = env['machine'] == 'ppc'
gcc = env['platform'] in ('linux', 'freebsd', 'darwin')
msvc = env['platform'] in ('windows', 'winddk', 'wince')
diff --git a/src/gallium/auxiliary/draw/Makefile b/src/gallium/auxiliary/draw/Makefile
index f2e36a89e90..bdbf5a08ede 100644
--- a/src/gallium/auxiliary/draw/Makefile
+++ b/src/gallium/auxiliary/draw/Makefile
@@ -40,6 +40,7 @@ C_SOURCES = \
draw_vs_aos_machine.c \
draw_vs_exec.c \
draw_vs_llvm.c \
+ draw_vs_ppc.c \
draw_vs_sse.c
diff --git a/src/gallium/auxiliary/draw/SConscript b/src/gallium/auxiliary/draw/SConscript
index 544a04918b6..5f05aa324a5 100644
--- a/src/gallium/auxiliary/draw/SConscript
+++ b/src/gallium/auxiliary/draw/SConscript
@@ -38,6 +38,7 @@ draw = env.ConvenienceLibrary(
'draw_vs_aos_machine.c',
'draw_vs_exec.c',
'draw_vs_llvm.c',
+ 'draw_vs_ppc.c',
'draw_vs_sse.c',
'draw_vs_varient.c'
])
diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c
index 34adbd49b00..7f305304ff7 100644
--- a/src/gallium/auxiliary/draw/draw_vs.c
+++ b/src/gallium/auxiliary/draw/draw_vs.c
@@ -85,7 +85,10 @@ draw_create_vertex_shader(struct draw_context *draw,
if (!vs) {
vs = draw_create_vs_sse( draw, shader );
if (!vs) {
- vs = draw_create_vs_exec( draw, shader );
+ vs = draw_create_vs_ppc( draw, shader );
+ if (!vs) {
+ vs = draw_create_vs_exec( draw, shader );
+ }
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs.h b/src/gallium/auxiliary/draw/draw_vs.h
index 68c24abad3b..89ae158751a 100644
--- a/src/gallium/auxiliary/draw/draw_vs.h
+++ b/src/gallium/auxiliary/draw/draw_vs.h
@@ -158,6 +158,10 @@ draw_create_vs_sse(struct draw_context *draw,
const struct pipe_shader_state *templ);
struct draw_vertex_shader *
+draw_create_vs_ppc(struct draw_context *draw,
+ const struct pipe_shader_state *templ);
+
+struct draw_vertex_shader *
draw_create_vs_llvm(struct draw_context *draw,
const struct pipe_shader_state *templ);
diff --git a/src/gallium/auxiliary/draw/draw_vs_aos_io.c b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
index dd79bc799aa..39f75b50b76 100644
--- a/src/gallium/auxiliary/draw/draw_vs_aos_io.c
+++ b/src/gallium/auxiliary/draw/draw_vs_aos_io.c
@@ -338,7 +338,7 @@ static void emit_store_R32G32B32A32( struct aos_compilation *cp,
struct x86_reg dst_ptr,
struct x86_reg dataXMM )
{
- sse_movaps(cp->func, dst_ptr, dataXMM);
+ sse_movups(cp->func, dst_ptr, dataXMM);
}
static void emit_store_R32G32B32( struct aos_compilation *cp,
diff --git a/src/gallium/auxiliary/draw/draw_vs_exec.c b/src/gallium/auxiliary/draw/draw_vs_exec.c
index 79a19d6be2b..13d4fcfdbf6 100644
--- a/src/gallium/auxiliary/draw/draw_vs_exec.c
+++ b/src/gallium/auxiliary/draw/draw_vs_exec.c
@@ -46,7 +46,6 @@
struct exec_vertex_shader {
struct draw_vertex_shader base;
struct tgsi_exec_machine *machine;
- const struct tgsi_token *machine_tokens;
};
static struct exec_vertex_shader *exec_vertex_shader( struct draw_vertex_shader *vs )
@@ -66,12 +65,11 @@ vs_exec_prepare( struct draw_vertex_shader *shader,
/* Specify the vertex program to interpret/execute.
* Avoid rebinding when possible.
*/
- if (evs->machine_tokens != shader->state.tokens) {
+ if (evs->machine->Tokens != shader->state.tokens) {
tgsi_exec_machine_bind_shader(evs->machine,
shader->state.tokens,
PIPE_MAX_SAMPLERS,
NULL /*samplers*/ );
- evs->machine_tokens = shader->state.tokens;
}
}
diff --git a/src/gallium/auxiliary/draw/draw_vs_ppc.c b/src/gallium/auxiliary/draw/draw_vs_ppc.c
new file mode 100644
index 00000000000..8eff6d4fda3
--- /dev/null
+++ b/src/gallium/auxiliary/draw/draw_vs_ppc.c
@@ -0,0 +1,274 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+ /*
+ * Authors:
+ * Keith Whitwell <[email protected]>
+ * Brian Paul
+ */
+
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "pipe/p_config.h"
+
+#include "draw_vs.h"
+
+#if defined(PIPE_ARCH_PPC)
+
+#include "pipe/p_shader_tokens.h"
+
+#include "draw_private.h"
+#include "draw_context.h"
+
+#include "rtasm/rtasm_cpu.h"
+#include "rtasm/rtasm_ppc.h"
+#include "tgsi/tgsi_ppc.h"
+#include "tgsi/tgsi_parse.h"
+
+
+
+typedef void (PIPE_CDECL *codegen_function) (float (*inputs)[4][4],
+ float (*outputs)[4][4],
+ float (*temps)[4][4],
+ float (*immeds)[4][4],
+ float (*consts)[4],
+ const float *builtins);
+
+#if 0
+ const struct tgsi_exec_vector *input,
+ struct tgsi_exec_vector *output,
+ float (*constant)[4], /* 3 */
+ struct tgsi_exec_vector *temporary, /* 4 */
+ float (*immediates)[4], /* 5 */
+ const float (*aos_input)[4], /* 6 */
+ uint num_inputs, /* 7 */
+ uint input_stride, /* 8 */
+ float (*aos_output)[4], /* 9 */
+ uint num_outputs, /* 10 */
+ uint output_stride ); /* 11 */
+#endif
+
+struct draw_ppc_vertex_shader {
+ struct draw_vertex_shader base;
+ struct ppc_function ppc_program;
+
+ codegen_function func;
+
+ struct tgsi_exec_machine *machine;
+};
+
+
+static void
+vs_ppc_prepare( struct draw_vertex_shader *base,
+ struct draw_context *draw )
+{
+}
+
+
+
+/* Simplified vertex shader interface for the pt paths. Given the
+ * complexity of code-generating all the above operations together,
+ * it's time to try doing all the other stuff separately.
+ */
+static void
+vs_ppc_run_linear( struct draw_vertex_shader *base,
+ const float (*input)[4],
+ float (*output)[4],
+ const float (*constants)[4],
+ unsigned count,
+ unsigned input_stride,
+ unsigned output_stride )
+{
+ struct draw_ppc_vertex_shader *shader = (struct draw_ppc_vertex_shader *)base;
+ struct tgsi_exec_machine *machine = shader->machine;
+ unsigned int i;
+
+#define MAX_VERTICES 4
+
+ /* loop over verts */
+ for (i = 0; i < count; i += MAX_VERTICES) {
+ const uint max_vertices = MIN2(MAX_VERTICES, count - i);
+ float inputs_soa[PIPE_MAX_SHADER_INPUTS][4][4] ALIGN16_ATTRIB;
+ float outputs_soa[PIPE_MAX_SHADER_OUTPUTS][4][4] ALIGN16_ATTRIB;
+ float temps_soa[TGSI_EXEC_NUM_TEMPS][4][4] ALIGN16_ATTRIB;
+ uint attr;
+
+ /* convert (up to) four input verts to SoA format */
+ for (attr = 0; attr < base->info.num_inputs; attr++) {
+ const float *vIn = (const float *) input;
+ uint vert;
+ for (vert = 0; vert < max_vertices; vert++) {
+#if 0
+ if (attr==0)
+ printf("Input v%d a%d: %f %f %f %f\n",
+ vert, attr, vIn[0], vIn[1], vIn[2], vIn[3]);
+#endif
+ inputs_soa[attr][0][vert] = vIn[attr * 4 + 0];
+ inputs_soa[attr][1][vert] = vIn[attr * 4 + 1];
+ inputs_soa[attr][2][vert] = vIn[attr * 4 + 2];
+ inputs_soa[attr][3][vert] = vIn[attr * 4 + 3];
+ vIn += input_stride / 4;
+ }
+ }
+
+ /* run compiled shader
+ */
+#if 0
+ shader->func(machine->Inputs,
+ machine->Outputs,
+ (float (*)[4])constants,
+ machine->Temps,
+ (float (*)[4])shader->base.immediates,
+ input,
+ base->info.num_inputs,
+ input_stride,
+ output,
+ base->info.num_outputs,
+ output_stride );
+#else
+ shader->func(inputs_soa, outputs_soa, temps_soa,
+ (float (*)[4][4]) shader->base.immediates,
+ (float (*)[4]) constants,
+ ppc_builtin_constants);
+
+ /*output[0][0] = input[0][0] * 0.5;*/
+#endif
+
+ /* convert (up to) four output verts from SoA back to AoS format */
+ for (attr = 0; attr < base->info.num_outputs; attr++) {
+ float *vOut = (float *) output;
+ uint vert;
+ for (vert = 0; vert < max_vertices; vert++) {
+ vOut[attr * 4 + 0] = outputs_soa[attr][0][vert];
+ vOut[attr * 4 + 1] = outputs_soa[attr][1][vert];
+ vOut[attr * 4 + 2] = outputs_soa[attr][2][vert];
+ vOut[attr * 4 + 3] = outputs_soa[attr][3][vert];
+#if 0
+ if (attr==0)
+ printf("Output v%d a%d: %f %f %f %f\n",
+ vert, attr, vOut[0], vOut[1], vOut[2], vOut[3]);
+#endif
+ vOut += output_stride / 4;
+ }
+ }
+
+ /* advance to next group of four input/output verts */
+ input = (const float (*)[4])((const char *)input + input_stride * max_vertices);
+ output = (float (*)[4])((char *)output + output_stride * max_vertices);
+ }
+}
+
+
+
+
+static void
+vs_ppc_delete( struct draw_vertex_shader *base )
+{
+ struct draw_ppc_vertex_shader *shader = (struct draw_ppc_vertex_shader *)base;
+
+ ppc_release_func( &shader->ppc_program );
+
+ align_free( (void *) shader->base.immediates );
+
+ FREE( (void*) shader->base.state.tokens );
+ FREE( shader );
+}
+
+
+struct draw_vertex_shader *
+draw_create_vs_ppc(struct draw_context *draw,
+ const struct pipe_shader_state *templ)
+{
+ struct draw_ppc_vertex_shader *vs;
+
+ vs = CALLOC_STRUCT( draw_ppc_vertex_shader );
+ if (vs == NULL)
+ return NULL;
+
+ /* we make a private copy of the tokens */
+ vs->base.state.tokens = tgsi_dup_tokens(templ->tokens);
+ if (!vs->base.state.tokens)
+ goto fail;
+
+ tgsi_scan_shader(templ->tokens, &vs->base.info);
+
+ vs->base.draw = draw;
+#if 0
+ if (1)
+ vs->base.create_varient = draw_vs_varient_aos_ppc;
+ else
+#endif
+ vs->base.create_varient = draw_vs_varient_generic;
+ vs->base.prepare = vs_ppc_prepare;
+ vs->base.run_linear = vs_ppc_run_linear;
+ vs->base.delete = vs_ppc_delete;
+
+ vs->base.immediates = align_malloc(TGSI_EXEC_NUM_IMMEDIATES * 4 * 4 *
+ sizeof(float), 16);
+
+ vs->machine = &draw->vs.machine;
+
+ ppc_init_func( &vs->ppc_program, 2000 ); /* XXX fix limit */
+
+ if (!tgsi_emit_ppc( (struct tgsi_token *) vs->base.state.tokens,
+ &vs->ppc_program,
+ (float (*)[4])vs->base.immediates,
+ TRUE ))
+ goto fail;
+
+ vs->func = (codegen_function) ppc_get_func( &vs->ppc_program );
+ if (!vs->func) {
+ goto fail;
+ }
+
+ return &vs->base;
+
+fail:
+ /*
+ debug_error("tgsi_emit_ppc() failed, falling back to interpreter\n");
+ */
+
+ ppc_release_func( &vs->ppc_program );
+
+ FREE(vs);
+ return NULL;
+}
+
+
+
+#else /* PIPE_ARCH_PPC */
+
+
+struct draw_vertex_shader *
+draw_create_vs_ppc( struct draw_context *draw,
+ const struct pipe_shader_state *templ )
+{
+ return (void *) 0;
+}
+
+
+#endif /* PIPE_ARCH_PPC */
diff --git a/src/gallium/auxiliary/rtasm/Makefile b/src/gallium/auxiliary/rtasm/Makefile
index 39b8a4dbd7a..252dc5274ab 100644
--- a/src/gallium/auxiliary/rtasm/Makefile
+++ b/src/gallium/auxiliary/rtasm/Makefile
@@ -7,6 +7,7 @@ C_SOURCES = \
rtasm_cpu.c \
rtasm_execmem.c \
rtasm_x86sse.c \
+ rtasm_ppc.c \
rtasm_ppc_spe.c
include ../../Makefile.template
diff --git a/src/gallium/auxiliary/rtasm/SConscript b/src/gallium/auxiliary/rtasm/SConscript
index 8ea25922aa1..eb48368accb 100644
--- a/src/gallium/auxiliary/rtasm/SConscript
+++ b/src/gallium/auxiliary/rtasm/SConscript
@@ -6,6 +6,7 @@ rtasm = env.ConvenienceLibrary(
'rtasm_cpu.c',
'rtasm_execmem.c',
'rtasm_x86sse.c',
+ 'rtasm_ppc.c',
'rtasm_ppc_spe.c',
])
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.c b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
index 534a23568d5..7dd82637494 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_ppc.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_ppc.c
@@ -23,10 +23,19 @@
/**
* PPC code generation.
+ * For reference, see http://www.power.org/resources/reading/PowerISA_V2.05.pdf
+ * ABI info: http://www.cs.utsa.edu/~whaley/teach/cs6463FHPO/LEC/lec12_ho.pdf
+ *
+ * Other PPC refs:
+ * http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/852569B20050FF778525699600719DF2
+ * http://www.ibm.com/developerworks/eserver/library/es-archguide-v2.html
+ * http://www.freescale.com/files/product/doc/MPCFPE32B.pdf
+ *
* \author Brian Paul
*/
+#include <stdio.h>
#include "util/u_memory.h"
#include "pipe/p_debug.h"
#include "rtasm_ppc.h"
@@ -35,40 +44,148 @@
void
ppc_init_func(struct ppc_function *p, unsigned max_inst)
{
- p->store = align_malloc(max_inst * PPC_INST_SIZE, 16);
- p->num_inst = 0;
- p->max_inst = max_inst;
- p->vec_used = ~0;
+ uint i;
+
+ p->store = align_malloc(max_inst * PPC_INST_SIZE, 16);
+ p->num_inst = 0;
+ p->max_inst = max_inst;
+ p->reg_used = 0x0;
+ p->fp_used = 0x0;
+ p->vec_used = 0x0;
+
+ /* only allow using gp registers 3..12 for now */
+ for (i = 0; i < 3; i++)
+ ppc_reserve_register(p, i);
+ for (i = 12; i < PPC_NUM_REGS; i++)
+ ppc_reserve_register(p, i);
}
void
ppc_release_func(struct ppc_function *p)
{
- assert(p->num_inst <= p->max_inst);
- if (p->store != NULL) {
- align_free(p->store);
- }
- p->store = NULL;
+ assert(p->num_inst <= p->max_inst);
+ if (p->store != NULL) {
+ align_free(p->store);
+ }
+ p->store = NULL;
+}
+
+
+void (*ppc_get_func(struct ppc_function *p))(void)
+{
+#if 0
+ DUMP_END();
+ if (DISASSEM && p->store)
+ debug_printf("disassemble %p %p\n", p->store, p->csr);
+
+ if (p->store == p->error_overflow)
+ return (void (*)(void)) NULL;
+ else
+#endif
+ return (void (*)(void)) p->store;
+}
+
+
+void
+ppc_dump_func(const struct ppc_function *p)
+{
+ uint i;
+ for (i = 0; i < p->num_inst; i++) {
+ debug_printf("%3u: 0x%08x\n", i, p->store[i]);
+ }
+}
+
+
+/**
+ * Mark a register as being unavailable.
+ */
+int
+ppc_reserve_register(struct ppc_function *p, int reg)
+{
+ assert(reg < PPC_NUM_REGS);
+ p->reg_used |= (1 << reg);
+ return reg;
}
/**
- * Alloate a vector register.
+ * Allocate a general purpose register.
* \return register index or -1 if none left.
*/
int
-ppc_allocate_vec_register(struct ppc_function *p, int reg)
+ppc_allocate_register(struct ppc_function *p)
{
unsigned i;
- for (i = 0; i < PPC_NUM_VEC_REGS; i++) {
+ for (i = 0; i < PPC_NUM_REGS; i++) {
const uint64_t mask = 1 << i;
- if ((p->vec_used & mask) != 0) {
- p->vec_used &= ~mask;
+ if ((p->reg_used & mask) == 0) {
+ p->reg_used |= mask;
return i;
}
}
+ return -1;
+}
+
+
+/**
+ * Mark the given general purpose register as "unallocated".
+ */
+void
+ppc_release_register(struct ppc_function *p, int reg)
+{
+ assert(reg < PPC_NUM_REGS);
+ assert(p->reg_used & (1 << reg));
+ p->reg_used &= ~(1 << reg);
+}
+
+/**
+ * Allocate a floating point register.
+ * \return register index or -1 if none left.
+ */
+int
+ppc_allocate_fp_register(struct ppc_function *p)
+{
+ unsigned i;
+ for (i = 0; i < PPC_NUM_FP_REGS; i++) {
+ const uint64_t mask = 1 << i;
+ if ((p->fp_used & mask) == 0) {
+ p->fp_used |= mask;
+ return i;
+ }
+ }
+ return -1;
+}
+
+
+/**
+ * Mark the given floating point register as "unallocated".
+ */
+void
+ppc_release_fp_register(struct ppc_function *p, int reg)
+{
+ assert(reg < PPC_NUM_FP_REGS);
+ assert(p->fp_used & (1 << reg));
+ p->fp_used &= ~(1 << reg);
+}
+
+
+/**
+ * Allocate a vector register.
+ * \return register index or -1 if none left.
+ */
+int
+ppc_allocate_vec_register(struct ppc_function *p)
+{
+ unsigned i;
+ for (i = 0; i < PPC_NUM_VEC_REGS; i++) {
+ const uint64_t mask = 1 << i;
+ if ((p->vec_used & mask) == 0) {
+ p->vec_used |= mask;
+ return i;
+ }
+ }
return -1;
}
@@ -80,9 +197,8 @@ void
ppc_release_vec_register(struct ppc_function *p, int reg)
{
assert(reg < PPC_NUM_VEC_REGS);
- assert((p->vec_used & (1 << reg)) == 0);
-
- p->vec_used |= (1 << reg);
+ assert(p->vec_used & (1 << reg));
+ p->vec_used &= ~(1 << reg);
}
@@ -98,6 +214,20 @@ union vx_inst {
} inst;
};
+static inline void
+emit_vx(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+{
+ union vx_inst inst;
+ inst.inst.op = 4;
+ inst.inst.vD = vD;
+ inst.inst.vA = vA;
+ inst.inst.vB = vB;
+ inst.inst.op2 = op2;
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+};
+
+
union vxr_inst {
uint32_t bits;
struct {
@@ -110,6 +240,21 @@ union vxr_inst {
} inst;
};
+static inline void
+emit_vxr(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+{
+ union vxr_inst inst;
+ inst.inst.op = 4;
+ inst.inst.vD = vD;
+ inst.inst.vA = vA;
+ inst.inst.vB = vB;
+ inst.inst.rC = 0;
+ inst.inst.op2 = op2;
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+};
+
+
union va_inst {
uint32_t bits;
struct {
@@ -122,49 +267,204 @@ union va_inst {
} inst;
};
-
static inline void
-emit_vx(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+emit_va(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB, uint vC)
{
- union vx_inst inst;
+ union va_inst inst;
inst.inst.op = 4;
inst.inst.vD = vD;
inst.inst.vA = vA;
inst.inst.vB = vB;
+ inst.inst.vC = vC;
inst.inst.op2 = op2;
p->store[p->num_inst++] = inst.bits;
assert(p->num_inst <= p->max_inst);
};
-static inline void
-emit_vxr(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB)
+
+union i_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned li:24;
+ unsigned aa:1;
+ unsigned lk:1;
+ } inst;
+};
+
+static INLINE void
+emit_i(struct ppc_function *p, uint op, uint li, uint aa, uint lk)
{
- union vxr_inst inst;
- inst.inst.op = 4;
- inst.inst.vD = vD;
- inst.inst.vA = vA;
- inst.inst.vB = vB;
- inst.inst.rC = 0;
+ union i_inst inst;
+ inst.inst.op = op;
+ inst.inst.li = li;
+ inst.inst.aa = aa;
+ inst.inst.lk = lk;
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+}
+
+
+union xl_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned bo:5;
+ unsigned bi:5;
+ unsigned unused:3;
+ unsigned bh:2;
+ unsigned op2:10;
+ unsigned lk:1;
+ } inst;
+};
+
+static INLINE void
+emit_xl(struct ppc_function *p, uint op, uint bo, uint bi, uint bh,
+ uint op2, uint lk)
+{
+ union xl_inst inst;
+ inst.inst.op = op;
+ inst.inst.bo = bo;
+ inst.inst.bi = bi;
+ inst.inst.unused = 0x0;
+ inst.inst.bh = bh;
inst.inst.op2 = op2;
+ inst.inst.lk = lk;
p->store[p->num_inst++] = inst.bits;
assert(p->num_inst <= p->max_inst);
+}
+
+static INLINE void
+dump_xl(const char *name, uint inst)
+{
+ union xl_inst i;
+
+ i.bits = inst;
+ debug_printf("%s = 0x%08x\n", name, inst);
+ debug_printf(" op: %d 0x%x\n", i.inst.op, i.inst.op);
+ debug_printf(" bo: %d 0x%x\n", i.inst.bo, i.inst.bo);
+ debug_printf(" bi: %d 0x%x\n", i.inst.bi, i.inst.bi);
+ debug_printf(" unused: %d 0x%x\n", i.inst.unused, i.inst.unused);
+ debug_printf(" bh: %d 0x%x\n", i.inst.bh, i.inst.bh);
+ debug_printf(" op2: %d 0x%x\n", i.inst.op2, i.inst.op2);
+ debug_printf(" lk: %d 0x%x\n", i.inst.lk, i.inst.lk);
+}
+
+
+union x_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned vrs:5;
+ unsigned ra:5;
+ unsigned rb:5;
+ unsigned op2:10;
+ unsigned unused:1;
+ } inst;
};
-static inline void
-emit_va(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB, uint vC)
+static INLINE void
+emit_x(struct ppc_function *p, uint op, uint vrs, uint ra, uint rb, uint op2)
{
- union va_inst inst;
- inst.inst.op = 4;
- inst.inst.vD = vD;
- inst.inst.vA = vA;
- inst.inst.vB = vB;
- inst.inst.vC = vC;
+ union x_inst inst;
+ inst.inst.op = op;
+ inst.inst.vrs = vrs;
+ inst.inst.ra = ra;
+ inst.inst.rb = rb;
+ inst.inst.op2 = op2;
+ inst.inst.unused = 0x0;
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+}
+
+
+union d_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned rt:5;
+ unsigned ra:5;
+ unsigned si:16;
+ } inst;
+};
+
+static inline void
+emit_d(struct ppc_function *p, uint op, uint rt, uint ra, int si)
+{
+ union d_inst inst;
+ assert(si >= -32768);
+ assert(si <= 32767);
+ inst.inst.op = op;
+ inst.inst.rt = rt;
+ inst.inst.ra = ra;
+ inst.inst.si = (unsigned) (si & 0xffff);
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+};
+
+
+union a_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned frt:5;
+ unsigned fra:5;
+ unsigned frb:5;
+ unsigned unused:5;
+ unsigned op2:5;
+ unsigned rc:1;
+ } inst;
+};
+
+static inline void
+emit_a(struct ppc_function *p, uint op, uint frt, uint fra, uint frb, uint op2,
+ uint rc)
+{
+ union a_inst inst;
+ inst.inst.op = op;
+ inst.inst.frt = frt;
+ inst.inst.fra = fra;
+ inst.inst.frb = frb;
+ inst.inst.unused = 0x0;
inst.inst.op2 = op2;
+ inst.inst.rc = rc;
p->store[p->num_inst++] = inst.bits;
assert(p->num_inst <= p->max_inst);
};
+union xo_inst {
+ uint32_t bits;
+ struct {
+ unsigned op:6;
+ unsigned rt:5;
+ unsigned ra:5;
+ unsigned rb:5;
+ unsigned oe:1;
+ unsigned op2:9;
+ unsigned rc:1;
+ } inst;
+};
+
+static INLINE void
+emit_xo(struct ppc_function *p, uint op, uint rt, uint ra, uint rb, uint oe,
+ uint op2, uint rc)
+{
+ union xo_inst inst;
+ inst.inst.op = op;
+ inst.inst.rt = rt;
+ inst.inst.ra = ra;
+ inst.inst.rb = rb;
+ inst.inst.oe = oe;
+ inst.inst.op2 = op2;
+ inst.inst.rc = rc;
+ p->store[p->num_inst++] = inst.bits;
+ assert(p->num_inst <= p->max_inst);
+}
+
+
+
+
/**
** float vector arithmetic
@@ -172,7 +472,7 @@ emit_va(struct ppc_function *p, uint op2, uint vD, uint vA, uint vB, uint vC)
/** vector float add */
void
-ppc_vaddfp(struct ppc_function *p,uint vD, uint vA, uint vB)
+ppc_vaddfp(struct ppc_function *p, uint vD, uint vA, uint vB)
{
emit_vx(p, 10, vD, vA, vB);
}
@@ -198,11 +498,11 @@ ppc_vmaxfp(struct ppc_function *p, uint vD, uint vA, uint vB)
emit_vx(p, 1034, vD, vA, vB);
}
-/** vector float mult add */
+/** vector float mult add: vD = vA * vB + vC */
void
ppc_vmaddfp(struct ppc_function *p, uint vD, uint vA, uint vB, uint vC)
{
- emit_va(p, 46, vD, vA, vB, vC);
+ emit_va(p, 46, vD, vA, vC, vB); /* note arg order */
}
/** vector float compare greater than */
@@ -282,13 +582,34 @@ ppc_vrfiz(struct ppc_function *p, uint vD, uint vB)
emit_vx(p, 586, vD, 0, vB);
}
+/** vector store: store vR at mem[vA+vB] */
+void
+ppc_stvx(struct ppc_function *p, uint vR, uint vA, uint vB)
+{
+ emit_x(p, 31, vR, vA, vB, 231);
+}
+
+/** vector load: vR = mem[vA+vB] */
+void
+ppc_lvx(struct ppc_function *p, uint vR, uint vA, uint vB)
+{
+ emit_x(p, 31, vR, vA, vB, 103);
+}
+
+/** load vector element word: vR = mem_word[ra+rb] */
+void
+ppc_lvewx(struct ppc_function *p, uint vr, uint ra, uint rb)
+{
+ emit_x(p, 31, vr, ra, rb, 71);
+}
+
+
/**
- ** bitwise operations
+ ** vector bitwise operations
**/
-
/** vector and */
void
ppc_vand(struct ppc_function *p, uint vD, uint vA, uint vB)
@@ -324,6 +645,22 @@ ppc_vxor(struct ppc_function *p, uint vD, uint vA, uint vB)
emit_vx(p, 1220, vD, vA, vB);
}
+/** Pseudo-instruction: vector move */
+void
+ppc_vmove(struct ppc_function *p, uint vD, uint vA)
+{
+ ppc_vor(p, vD, vA, vA);
+}
+
+/** Set vector register to {0,0,0,0} */
+void
+ppc_vzero(struct ppc_function *p, uint vr)
+{
+ ppc_vxor(p, vr, vr, vr);
+}
+
+
+
/**
** Vector shuffle / select / splat / etc
@@ -363,3 +700,225 @@ ppc_vspltw(struct ppc_function *p, uint vD, uint vB, uint imm)
{
emit_vx(p, 652, vD, imm, vB);
}
+
+/** vector splat signed immediate word */
+void
+ppc_vspltisw(struct ppc_function *p, uint vD, int imm)
+{
+ assert(imm >= -16);
+ assert(imm < 15);
+ emit_vx(p, 908, vD, imm, 0);
+}
+
+/** vector shift left word: vD[word] = vA[word] << (vB[word] & 0x1f) */
+void
+ppc_vslw(struct ppc_function *p, uint vD, uint vA, uint vB)
+{
+ emit_vx(p, 388, vD, vA, vB);
+}
+
+
+
+
+/**
+ ** integer arithmetic
+ **/
+
+/** rt = ra + imm */
+void
+ppc_addi(struct ppc_function *p, uint rt, uint ra, int imm)
+{
+ emit_d(p, 14, rt, ra, imm);
+}
+
+/** rt = ra + (imm << 16) */
+void
+ppc_addis(struct ppc_function *p, uint rt, uint ra, int imm)
+{
+ emit_d(p, 15, rt, ra, imm);
+}
+
+/** rt = ra + rb */
+void
+ppc_add(struct ppc_function *p, uint rt, uint ra, uint rb)
+{
+ emit_xo(p, 31, rt, ra, rb, 0, 266, 0);
+}
+
+/** rt = ra AND ra */
+void
+ppc_and(struct ppc_function *p, uint rt, uint ra, uint rb)
+{
+ emit_x(p, 31, ra, rt, rb, 28); /* note argument order */
+}
+
+/** rt = ra AND imm */
+void
+ppc_andi(struct ppc_function *p, uint rt, uint ra, int imm)
+{
+ emit_d(p, 28, ra, rt, imm); /* note argument order */
+}
+
+/** rt = ra OR ra */
+void
+ppc_or(struct ppc_function *p, uint rt, uint ra, uint rb)
+{
+ emit_x(p, 31, ra, rt, rb, 444); /* note argument order */
+}
+
+/** rt = ra OR imm */
+void
+ppc_ori(struct ppc_function *p, uint rt, uint ra, int imm)
+{
+ emit_d(p, 24, ra, rt, imm); /* note argument order */
+}
+
+/** rt = ra XOR ra */
+void
+ppc_xor(struct ppc_function *p, uint rt, uint ra, uint rb)
+{
+ emit_x(p, 31, ra, rt, rb, 316); /* note argument order */
+}
+
+/** rt = ra XOR imm */
+void
+ppc_xori(struct ppc_function *p, uint rt, uint ra, int imm)
+{
+ emit_d(p, 26, ra, rt, imm); /* note argument order */
+}
+
+/** pseudo instruction: move: rt = ra */
+void
+ppc_mr(struct ppc_function *p, uint rt, uint ra)
+{
+ ppc_or(p, rt, ra, ra);
+}
+
+/** pseudo instruction: load immediate: rt = imm */
+void
+ppc_li(struct ppc_function *p, uint rt, int imm)
+{
+ ppc_addi(p, rt, 0, imm);
+}
+
+/** rt = imm << 16 */
+void
+ppc_lis(struct ppc_function *p, uint rt, int imm)
+{
+ ppc_addis(p, rt, 0, imm);
+}
+
+/** rt = imm */
+void
+ppc_load_int(struct ppc_function *p, uint rt, int imm)
+{
+ ppc_lis(p, rt, (imm >> 16)); /* rt = imm >> 16 */
+ ppc_ori(p, rt, rt, (imm & 0xffff)); /* rt = rt | (imm & 0xffff) */
+}
+
+
+
+
+/**
+ ** integer load/store
+ **/
+
+/** store rs at memory[(ra)+d],
+ * then update ra = (ra)+d
+ */
+void
+ppc_stwu(struct ppc_function *p, uint rs, uint ra, int d)
+{
+ emit_d(p, 37, rs, ra, d);
+}
+
+/** store rs at memory[(ra)+d] */
+void
+ppc_stw(struct ppc_function *p, uint rs, uint ra, int d)
+{
+ emit_d(p, 36, rs, ra, d);
+}
+
+/** Load rt = mem[(ra)+d]; then zero set high 32 bits to zero. */
+void
+ppc_lwz(struct ppc_function *p, uint rt, uint ra, int d)
+{
+ emit_d(p, 32, rt, ra, d);
+}
+
+
+
+/**
+ ** Float (non-vector) arithmetic
+ **/
+
+/** add: frt = fra + frb */
+void
+ppc_fadd(struct ppc_function *p, uint frt, uint fra, uint frb)
+{
+ emit_a(p, 63, frt, fra, frb, 21, 0);
+}
+
+/** sub: frt = fra - frb */
+void
+ppc_fsub(struct ppc_function *p, uint frt, uint fra, uint frb)
+{
+ emit_a(p, 63, frt, fra, frb, 20, 0);
+}
+
+/** convert to int: rt = (int) ra */
+void
+ppc_fctiwz(struct ppc_function *p, uint rt, uint fra)
+{
+ emit_x(p, 63, rt, 0, fra, 15);
+}
+
+/** store frs at mem[(ra)+offset] */
+void
+ppc_stfs(struct ppc_function *p, uint frs, uint ra, int offset)
+{
+ emit_d(p, 52, frs, ra, offset);
+}
+
+/** store frs at mem[(ra)+(rb)] */
+void
+ppc_stfiwx(struct ppc_function *p, uint frs, uint ra, uint rb)
+{
+ emit_x(p, 31, frs, ra, rb, 983);
+}
+
+/** load frt = mem[(ra)+offset] */
+void
+ppc_lfs(struct ppc_function *p, uint frt, uint ra, int offset)
+{
+ emit_d(p, 48, frt, ra, offset);
+}
+
+
+
+
+
+/**
+ ** branch instructions
+ **/
+
+/** BLR: Branch to link register (p. 35) */
+void
+ppc_blr(struct ppc_function *p)
+{
+ emit_i(p, 18, 0, 0, 1);
+}
+
+/** Branch Conditional to Link Register (p. 36) */
+void
+ppc_bclr(struct ppc_function *p, uint condOp, uint branchHint, uint condReg)
+{
+ emit_xl(p, 19, condOp, condReg, branchHint, 16, 0);
+}
+
+/** Pseudo instruction: return from subroutine */
+void
+ppc_return(struct ppc_function *p)
+{
+ ppc_bclr(p, BRANCH_COND_ALWAYS, BRANCH_HINT_SUB_RETURN, 0);
+}
diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.h b/src/gallium/auxiliary/rtasm/rtasm_ppc.h
index ed14e943df6..f938d8d759c 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_ppc.h
+++ b/src/gallium/auxiliary/rtasm/rtasm_ppc.h
@@ -36,27 +36,47 @@
#define PPC_INST_SIZE 4 /**< 4 bytes / instruction */
+#define PPC_NUM_REGS 32
+#define PPC_NUM_FP_REGS 32
#define PPC_NUM_VEC_REGS 32
+/** Stack pointer register */
+#define PPC_REG_SP 1
+
+/** Branch conditions */
+#define BRANCH_COND_ALWAYS 0x14 /* binary 1z1zz (z=ignored) */
+
+/** Branch hints */
+#define BRANCH_HINT_SUB_RETURN 0x0 /* binary 00 */
+
struct ppc_function
{
uint32_t *store; /**< instruction buffer */
uint num_inst;
uint max_inst;
- uint32_t vec_used; /** used/free vector registers bitmask */
uint32_t reg_used; /** used/free general-purpose registers bitmask */
+ uint32_t fp_used; /** used/free floating point registers bitmask */
+ uint32_t vec_used; /** used/free vector registers bitmask */
};
extern void ppc_init_func(struct ppc_function *p, unsigned max_inst);
extern void ppc_release_func(struct ppc_function *p);
-
-extern int ppc_allocate_vec_register(struct ppc_function *p, int reg);
+extern void (*ppc_get_func( struct ppc_function *p ))( void );
+extern void ppc_dump_func(const struct ppc_function *p);
+
+extern int ppc_reserve_register(struct ppc_function *p, int reg);
+extern int ppc_allocate_register(struct ppc_function *p);
+extern void ppc_release_register(struct ppc_function *p, int reg);
+extern int ppc_allocate_fp_register(struct ppc_function *p);
+extern void ppc_release_fp_register(struct ppc_function *p, int reg);
+extern int ppc_allocate_vec_register(struct ppc_function *p);
extern void ppc_release_vec_register(struct ppc_function *p, int reg);
+
/**
** float vector arithmetic
**/
@@ -126,9 +146,22 @@ extern void
ppc_vrfiz(struct ppc_function *p, uint vD, uint vB);
+/** vector store: store vR at mem[vA+vB] */
+extern void
+ppc_stvx(struct ppc_function *p, uint vR, uint vA, uint vB);
+
+/** vector load: vR = mem[vA+vB] */
+extern void
+ppc_lvx(struct ppc_function *p, uint vR, uint vA, uint vB);
+
+/** load vector element word: vR = mem_word[vA+vB] */
+extern void
+ppc_lvewx(struct ppc_function *p, uint vR, uint vA, uint vB);
+
+
/**
- ** bitwise operations
+ ** vector bitwise operations
**/
@@ -152,6 +185,15 @@ ppc_vnor(struct ppc_function *p, uint vD, uint vA, uint vB);
extern void
ppc_vxor(struct ppc_function *p, uint vD, uint vA, uint vB);
+/** Pseudo-instruction: vector move */
+extern void
+ppc_vmove(struct ppc_function *p, uint vD, uint vA);
+
+/** Set vector register to {0,0,0,0} */
+extern void
+ppc_vzero(struct ppc_function *p, uint vr);
+
+
/**
** Vector shuffle / select / splat / etc
@@ -177,5 +219,106 @@ ppc_vsplthw(struct ppc_function *p, uint vD, uint vB, uint imm);
extern void
ppc_vspltw(struct ppc_function *p, uint vD, uint vB, uint imm);
+/** vector splat signed immediate word */
+extern void
+ppc_vspltisw(struct ppc_function *p, uint vD, int imm);
+
+/** vector shift left word: vD[word] = vA[word] << (vB[word] & 0x1f) */
+extern void
+ppc_vslw(struct ppc_function *p, uint vD, uint vA, uint vB);
+
+
+
+/**
+ ** scalar arithmetic
+ **/
+
+extern void
+ppc_add(struct ppc_function *p, uint rt, uint ra, uint rb);
+
+extern void
+ppc_addi(struct ppc_function *p, uint rt, uint ra, int imm);
+
+extern void
+ppc_and(struct ppc_function *p, uint rt, uint ra, uint rb);
+
+extern void
+ppc_andi(struct ppc_function *p, uint rt, uint ra, int imm);
+
+extern void
+ppc_or(struct ppc_function *p, uint rt, uint ra, uint rb);
+
+extern void
+ppc_ori(struct ppc_function *p, uint rt, uint ra, int imm);
+
+extern void
+ppc_xor(struct ppc_function *p, uint rt, uint ra, uint rb);
+
+extern void
+ppc_xori(struct ppc_function *p, uint rt, uint ra, int imm);
+
+extern void
+ppc_mr(struct ppc_function *p, uint rt, uint ra);
+
+extern void
+ppc_li(struct ppc_function *p, uint rt, int imm);
+
+extern void
+ppc_lis(struct ppc_function *p, uint rt, int imm);
+
+extern void
+ppc_load_int(struct ppc_function *p, uint rt, int imm);
+
+
+
+/**
+ ** scalar load/store
+ **/
+
+extern void
+ppc_stwu(struct ppc_function *p, uint rs, uint ra, int d);
+
+extern void
+ppc_stw(struct ppc_function *p, uint rs, uint ra, int d);
+
+extern void
+ppc_lwz(struct ppc_function *p, uint rs, uint ra, int d);
+
+
+
+/**
+ ** Float (non-vector) arithmetic
+ **/
+
+extern void
+ppc_fadd(struct ppc_function *p, uint frt, uint fra, uint frb);
+
+extern void
+ppc_fsub(struct ppc_function *p, uint frt, uint fra, uint frb);
+
+extern void
+ppc_fctiwz(struct ppc_function *p, uint rt, uint ra);
+
+extern void
+ppc_stfs(struct ppc_function *p, uint frs, uint ra, int offset);
+
+extern void
+ppc_stfiwx(struct ppc_function *p, uint frs, uint ra, uint rb);
+
+
+
+/**
+ ** branch instructions
+ **/
+
+extern void
+ppc_blr(struct ppc_function *p);
+
+void
+ppc_bclr(struct ppc_function *p, uint condOp, uint branchHint, uint condReg);
+
+extern void
+ppc_return(struct ppc_function *p);
+
#endif /* RTASM_PPC_H */
diff --git a/src/gallium/auxiliary/tgsi/Makefile b/src/gallium/auxiliary/tgsi/Makefile
index c7155a93168..d7df9490cfa 100644
--- a/src/gallium/auxiliary/tgsi/Makefile
+++ b/src/gallium/auxiliary/tgsi/Makefile
@@ -11,6 +11,7 @@ C_SOURCES = \
tgsi_info.c \
tgsi_iterate.c \
tgsi_parse.c \
+ tgsi_ppc.c \
tgsi_scan.c \
tgsi_sse2.c \
tgsi_text.c \
diff --git a/src/gallium/auxiliary/tgsi/SConscript b/src/gallium/auxiliary/tgsi/SConscript
index 45bf3f6d577..8200cce42f5 100644
--- a/src/gallium/auxiliary/tgsi/SConscript
+++ b/src/gallium/auxiliary/tgsi/SConscript
@@ -12,6 +12,7 @@ tgsi = env.ConvenienceLibrary(
'tgsi_parse.c',
'tgsi_sanity.c',
'tgsi_scan.c',
+ 'tgsi_ppc.c',
'tgsi_sse2.c',
'tgsi_text.c',
'tgsi_transform.c',
diff --git a/src/gallium/auxiliary/tgsi/tgsi_ppc.c b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
new file mode 100644
index 00000000000..9ad7ecd7cfe
--- /dev/null
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.c
@@ -0,0 +1,910 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+/**
+ * TGSI to PowerPC code generation.
+ */
+
+#include "pipe/p_config.h"
+
+#if defined(PIPE_ARCH_PPC)
+
+#include "pipe/p_debug.h"
+#include "pipe/p_shader_tokens.h"
+#include "util/u_math.h"
+#include "util/u_memory.h"
+#include "util/u_sse.h"
+#include "tgsi/tgsi_parse.h"
+#include "tgsi/tgsi_util.h"
+#include "tgsi_exec.h"
+#include "tgsi_ppc.h"
+#include "rtasm/rtasm_ppc.h"
+
+
+/**
+ * Since it's pretty much impossible to form PPC vector immediates, load
+ * them from memory here:
+ */
+const float ppc_builtin_constants[] ALIGN16_ATTRIB = {
+ 1.0f, -128.0f, 128.0, 0.0
+};
+
+
+#define FOR_EACH_CHANNEL( CHAN )\
+ for (CHAN = 0; CHAN < NUM_CHANNELS; CHAN++)
+
+#define IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
+ ((INST).FullDstRegisters[0].DstRegister.WriteMask & (1 << (CHAN)))
+
+#define IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\
+ if (IS_DST0_CHANNEL_ENABLED( INST, CHAN ))
+
+#define FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\
+ FOR_EACH_CHANNEL( CHAN )\
+ IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )
+
+#define CHAN_X 0
+#define CHAN_Y 1
+#define CHAN_Z 2
+#define CHAN_W 3
+
+#define TEMP_ONE_I TGSI_EXEC_TEMP_ONE_I
+#define TEMP_ONE_C TGSI_EXEC_TEMP_ONE_C
+
+#define TEMP_R0 TGSI_EXEC_TEMP_R0
+#define TEMP_ADDR TGSI_EXEC_TEMP_ADDR
+
+
+/**
+ * Context/state used during code gen.
+ */
+struct gen_context
+{
+ struct ppc_function *f;
+ int inputs_reg; /**< GP register pointing to input params */
+ int outputs_reg; /**< GP register pointing to output params */
+ int temps_reg; /**< GP register pointing to temporary "registers" */
+ int immed_reg; /**< GP register pointing to immediates buffer */
+ int const_reg; /**< GP register pointing to constants buffer */
+ int builtins_reg; /**< GP register pointint to built-in constants */
+
+ int one_vec; /**< vector register with {1.0, 1.0, 1.0, 1.0} */
+ int bit31_vec; /**< vector register with {1<<31, 1<<31, 1<<31, 1<<31} */
+};
+
+
+/**
+ * Load the given vector register with {value, value, value, value}.
+ * The value must be in the ppu_builtin_constants[] array.
+ * We wouldn't need this if there was a simple way to load PPC vector
+ * registers with immediate values!
+ */
+static void
+load_constant_vec(struct gen_context *gen, int dst_vec, float value)
+{
+ uint pos;
+ for (pos = 0; pos < Elements(ppc_builtin_constants); pos++) {
+ if (ppc_builtin_constants[pos] == value) {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = pos * 4;
+
+ ppc_li(gen->f, offset_reg, offset);
+ /* Load 4-byte word into vector register.
+ * The vector slot depends on the effective address we load from.
+ * We know that our builtins start at a 16-byte boundary so we
+ * know that 'swizzle' tells us which vector slot will have the
+ * loaded word. The other vector slots will be undefined.
+ */
+ ppc_lvewx(gen->f, dst_vec, gen->builtins_reg, offset_reg);
+ /* splat word[pos % 4] across the vector reg */
+ ppc_vspltw(gen->f, dst_vec, dst_vec, pos % 4);
+ ppc_release_register(gen->f, offset_reg);
+ return;
+ }
+ }
+ assert(0 && "Need to add new constant to ppc_builtin_constants array");
+}
+
+
+/**
+ * Return index of vector register containing {1.0, 1.0, 1.0, 1.0}.
+ */
+static int
+gen_one_vec(struct gen_context *gen)
+{
+ if (gen->one_vec < 0) {
+ gen->one_vec = ppc_allocate_vec_register(gen->f);
+ load_constant_vec(gen, gen->one_vec, 1.0f);
+ }
+ return gen->one_vec;
+}
+
+/**
+ * Return index of vector register containing {1<<31, 1<<31, 1<<31, 1<<31}.
+ */
+static int
+gen_get_bit31_vec(struct gen_context *gen)
+{
+ if (gen->bit31_vec < 0) {
+ gen->bit31_vec = ppc_allocate_vec_register(gen->f);
+ ppc_vspltisw(gen->f, gen->bit31_vec, -1);
+ ppc_vslw(gen->f, gen->bit31_vec, gen->bit31_vec, gen->bit31_vec);
+ }
+ return gen->bit31_vec;
+}
+
+
+/**
+ * Register fetch, put result in 'dst_vec'.
+ */
+static void
+emit_fetch(struct gen_context *gen,
+ unsigned dst_vec,
+ const struct tgsi_full_src_register *reg,
+ const unsigned chan_index)
+{
+ uint swizzle = tgsi_util_get_full_src_register_extswizzle(reg, chan_index);
+
+ switch (swizzle) {
+ case TGSI_EXTSWIZZLE_X:
+ case TGSI_EXTSWIZZLE_Y:
+ case TGSI_EXTSWIZZLE_Z:
+ case TGSI_EXTSWIZZLE_W:
+ switch (reg->SrcRegister.File) {
+ case TGSI_FILE_INPUT:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+ ppc_li(gen->f, offset_reg, offset);
+ ppc_lvx(gen->f, dst_vec, gen->inputs_reg, offset_reg);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+ case TGSI_FILE_TEMPORARY:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+ ppc_li(gen->f, offset_reg, offset);
+ ppc_lvx(gen->f, dst_vec, gen->temps_reg, offset_reg);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+ case TGSI_FILE_IMMEDIATE:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->SrcRegister.Index * 4 + swizzle) * 16;
+ ppc_li(gen->f, offset_reg, offset);
+ ppc_lvx(gen->f, dst_vec, gen->immed_reg, offset_reg);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+ case TGSI_FILE_CONSTANT:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->SrcRegister.Index * 4 + swizzle) * 4;
+ ppc_li(gen->f, offset_reg, offset);
+ /* Load 4-byte word into vector register.
+ * The vector slot depends on the effective address we load from.
+ * We know that our constants start at a 16-byte boundary so we
+ * know that 'swizzle' tells us which vector slot will have the
+ * loaded word. The other vector slots will be undefined.
+ */
+ ppc_lvewx(gen->f, dst_vec, gen->const_reg, offset_reg);
+ /* splat word[swizzle] across the vector reg */
+ ppc_vspltw(gen->f, dst_vec, dst_vec, swizzle);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+ default:
+ assert( 0 );
+ }
+ break;
+ case TGSI_EXTSWIZZLE_ZERO:
+ ppc_vzero(gen->f, dst_vec);
+ break;
+ case TGSI_EXTSWIZZLE_ONE:
+ {
+ int one_vec = gen_one_vec(gen);
+ ppc_vmove(gen->f, dst_vec, one_vec);
+ }
+ break;
+ default:
+ assert( 0 );
+ }
+
+ {
+ uint sign_op = tgsi_util_get_full_src_register_sign_mode(reg, chan_index);
+ if (sign_op != TGSI_UTIL_SIGN_KEEP) {
+ int bit31_vec = gen_get_bit31_vec(gen);
+
+ switch (sign_op) {
+ case TGSI_UTIL_SIGN_CLEAR:
+ /* vec = vec & ~bit31 */
+ ppc_vandc(gen->f, dst_vec, dst_vec, bit31_vec);
+ break;
+ case TGSI_UTIL_SIGN_SET:
+ /* vec = vec | bit31 */
+ ppc_vor(gen->f, dst_vec, dst_vec, bit31_vec);
+ break;
+ case TGSI_UTIL_SIGN_TOGGLE:
+ /* vec = vec ^ bit31 */
+ ppc_vxor(gen->f, dst_vec, dst_vec, bit31_vec);
+ break;
+ default:
+ assert(0);
+ }
+ }
+ }
+}
+
+#define FETCH( GEN, INST, DST_VEC, SRC_REG, CHAN ) \
+ emit_fetch( GEN, DST_VEC, &(INST).FullSrcRegisters[SRC_REG], CHAN )
+
+
+
+/**
+ * Register store. Store 'src_vec' at location indicated by 'reg'.
+ */
+static void
+emit_store(struct gen_context *gen,
+ unsigned src_vec,
+ const struct tgsi_full_dst_register *reg,
+ const struct tgsi_full_instruction *inst,
+ unsigned chan_index)
+{
+ switch (reg->DstRegister.File) {
+ case TGSI_FILE_OUTPUT:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+ ppc_li(gen->f, offset_reg, offset);
+ ppc_stvx(gen->f, src_vec, gen->outputs_reg, offset_reg);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+ case TGSI_FILE_TEMPORARY:
+ {
+ int offset_reg = ppc_allocate_register(gen->f);
+ int offset = (reg->DstRegister.Index * 4 + chan_index) * 16;
+ ppc_li(gen->f, offset_reg, offset);
+ ppc_stvx(gen->f, src_vec, gen->temps_reg, offset_reg);
+ ppc_release_register(gen->f, offset_reg);
+ }
+ break;
+#if 0
+ case TGSI_FILE_ADDRESS:
+ emit_addrs(
+ func,
+ xmm,
+ reg->DstRegister.Index,
+ chan_index );
+ break;
+#endif
+ default:
+ assert( 0 );
+ }
+
+#if 0
+ switch( inst->Instruction.Saturate ) {
+ case TGSI_SAT_NONE:
+ break;
+
+ case TGSI_SAT_ZERO_ONE:
+ /* assert( 0 ); */
+ break;
+
+ case TGSI_SAT_MINUS_PLUS_ONE:
+ assert( 0 );
+ break;
+ }
+#endif
+}
+
+
+#define STORE( GEN, INST, XMM, INDEX, CHAN )\
+ emit_store( GEN, XMM, &(INST).FullDstRegisters[INDEX], &(INST), CHAN )
+
+
+
+static void
+emit_scalar_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ int v1 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+
+ FETCH(gen, *inst, v0, 0, CHAN_X);
+
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_RSQ:
+ /* v1 = 1.0 / sqrt(v0) */
+ ppc_vrsqrtefp(gen->f, v1, v0);
+ break;
+ case TGSI_OPCODE_RCP:
+ /* v1 = 1.0 / v0 */
+ ppc_vrefp(gen->f, v1, v0);
+ break;
+ default:
+ assert(0);
+ }
+
+ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) {
+ STORE(gen, *inst, v1, 0, chan_index);
+ }
+ ppc_release_vec_register(gen->f, v0);
+ ppc_release_vec_register(gen->f, v1);
+}
+
+
+static void
+emit_unaryop(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+ FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(gen, *inst, 0, 0, chan_index); /* v0 = srcreg[0] */
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_ABS:
+ /* turn off the most significant bit of each vector float word */
+ {
+ int v1 = ppc_allocate_vec_register(gen->f);
+ ppc_vspltisw(gen->f, v1, -1); /* v1 = {-1, -1, -1, -1} */
+ ppc_vslw(gen->f, v1, v1, v1); /* v1 = {1<<31, 1<<31, 1<<31, 1<<31} */
+ ppc_vandc(gen->f, v0, v0, v1); /* v0 = v0 & ~v1 */
+ ppc_release_vec_register(gen->f, v1);
+ }
+ break;
+ case TGSI_OPCODE_FLOOR:
+ ppc_vrfim(gen->f, v0, v0); /* v0 = floor(v0) */
+ break;
+ case TGSI_OPCODE_FRAC:
+ {
+ int v1 = ppc_allocate_vec_register(gen->f);
+ ppc_vrfim(gen->f, v1, v0); /* v1 = floor(v0) */
+ ppc_vsubfp(gen->f, v0, v0, v1); /* v0 = v0 - v1 */
+ ppc_release_vec_register(gen->f, v1);
+ }
+ break;
+ case TGSI_OPCODE_EXPBASE2:
+ ppc_vexptefp(gen->f, v0, v0); /* v0 = 2^v0 */
+ break;
+ case TGSI_OPCODE_LOGBASE2:
+ /* XXX this may be broken! */
+ ppc_vlogefp(gen->f, v0, v0); /* v0 = log2(v0) */
+ break;
+ case TGSI_OPCODE_MOV:
+ /* nothing */
+ break;
+ default:
+ assert(0);
+ }
+ STORE(gen, *inst, v0, 0, chan_index); /* store v0 */
+ }
+ ppc_release_vec_register(gen->f, v0);
+}
+
+
+static void
+emit_binop(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ int v1 = ppc_allocate_vec_register(gen->f);
+ int v2 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+ FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(gen, *inst, v0, 0, chan_index); /* v0 = srcreg[0] */
+ FETCH(gen, *inst, v1, 1, chan_index); /* v1 = srcreg[1] */
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_ADD:
+ ppc_vaddfp(gen->f, v2, v0, v1);
+ break;
+ case TGSI_OPCODE_SUB:
+ ppc_vsubfp(gen->f, v2, v0, v1);
+ break;
+ case TGSI_OPCODE_MUL:
+ ppc_vxor(gen->f, v2, v2, v2); /* v2 = {0, 0, 0, 0} */
+ ppc_vmaddfp(gen->f, v2, v0, v1, v2); /* v2 = v0 * v1 + v0 */
+ break;
+ case TGSI_OPCODE_MIN:
+ ppc_vminfp(gen->f, v2, v0, v1);
+ break;
+ case TGSI_OPCODE_MAX:
+ ppc_vmaxfp(gen->f, v2, v0, v1);
+ break;
+ default:
+ assert(0);
+ }
+ STORE(gen, *inst, v2, 0, chan_index); /* store v2 */
+ }
+ ppc_release_vec_register(gen->f, v0);
+ ppc_release_vec_register(gen->f, v1);
+ ppc_release_vec_register(gen->f, v2);
+}
+
+
+/**
+ * Vector comparisons, resulting in 1.0 or 0.0 values.
+ */
+static void
+emit_inequality(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ int v1 = ppc_allocate_vec_register(gen->f);
+ int v2 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+ boolean complement = FALSE;
+ int one_vec = gen_one_vec(gen);
+
+ FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(gen, *inst, v0, 0, chan_index); /* v0 = srcreg[0] */
+ FETCH(gen, *inst, v1, 1, chan_index); /* v1 = srcreg[1] */
+
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_SNE:
+ complement = TRUE;
+ /* fall-through */
+ case TGSI_OPCODE_SEQ:
+ ppc_vcmpeqfpx(gen->f, v2, v0, v1); /* v2 = v0 == v1 ? ~0 : 0 */
+ break;
+
+ case TGSI_OPCODE_SGE:
+ complement = TRUE;
+ /* fall-through */
+ case TGSI_OPCODE_SLT:
+ ppc_vcmpgtfpx(gen->f, v2, v1, v0); /* v2 = v1 > v0 ? ~0 : 0 */
+ break;
+
+ case TGSI_OPCODE_SLE:
+ complement = TRUE;
+ /* fall-through */
+ case TGSI_OPCODE_SGT:
+ ppc_vcmpgtfpx(gen->f, v2, v0, v1); /* v2 = v0 > v1 ? ~0 : 0 */
+ break;
+ default:
+ assert(0);
+ }
+
+ /* v2 is now {0,0,0,0} or {~0,~0,~0,~0} */
+
+ if (complement)
+ ppc_vandc(gen->f, v2, one_vec, v2); /* v2 = one_vec & ~v2 */
+ else
+ ppc_vand(gen->f, v2, one_vec, v2); /* v2 = one_vec & v2 */
+
+ STORE(gen, *inst, v2, 0, chan_index); /* store v2 */
+ }
+
+ ppc_release_vec_register(gen->f, v0);
+ ppc_release_vec_register(gen->f, v1);
+ ppc_release_vec_register(gen->f, v2);
+}
+
+
+static void
+emit_dotprod(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ int v1 = ppc_allocate_vec_register(gen->f);
+ int v2 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+
+ ppc_vxor(gen->f, v2, v2, v2); /* v2 = {0, 0, 0, 0} */
+
+ FETCH(gen, *inst, v0, 0, CHAN_X); /* v0 = src0.XXXX */
+ FETCH(gen, *inst, v1, 1, CHAN_X); /* v1 = src1.XXXX */
+ ppc_vmaddfp(gen->f, v2, v0, v1, v2); /* v2 = v0 * v1 + v2 */
+
+ FETCH(gen, *inst, v0, 0, CHAN_Y); /* v0 = src0.YYYY */
+ FETCH(gen, *inst, v1, 1, CHAN_Y); /* v1 = src1.YYYY */
+ ppc_vmaddfp(gen->f, v2, v0, v1, v2); /* v2 = v0 * v1 + v2 */
+
+ FETCH(gen, *inst, v0, 0, CHAN_Z); /* v0 = src0.ZZZZ */
+ FETCH(gen, *inst, v1, 1, CHAN_Z); /* v1 = src1.ZZZZ */
+ ppc_vmaddfp(gen->f, v2, v0, v1, v2); /* v2 = v0 * v1 + v2 */
+
+ if (inst->Instruction.Opcode == TGSI_OPCODE_DP4) {
+ FETCH(gen, *inst, v0, 0, CHAN_W); /* v0 = src0.WWWW */
+ FETCH(gen, *inst, v1, 1, CHAN_W); /* v1 = src1.WWWW */
+ ppc_vmaddfp(gen->f, v2, v0, v1, v2); /* v2 = v0 * v1 + v2 */
+ }
+ else if (inst->Instruction.Opcode == TGSI_OPCODE_DPH) {
+ FETCH(gen, *inst, v1, 1, CHAN_W); /* v1 = src1.WWWW */
+ ppc_vaddfp(gen->f, v2, v2, v1); /* v2 = v2 + v1 */
+ }
+
+ FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) {
+ STORE(gen, *inst, v2, 0, chan_index); /* store v2 */
+ }
+ ppc_release_vec_register(gen->f, v0);
+ ppc_release_vec_register(gen->f, v1);
+ ppc_release_vec_register(gen->f, v2);
+}
+
+
+static void
+emit_triop(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int v0 = ppc_allocate_vec_register(gen->f);
+ int v1 = ppc_allocate_vec_register(gen->f);
+ int v2 = ppc_allocate_vec_register(gen->f);
+ int v3 = ppc_allocate_vec_register(gen->f);
+ uint chan_index;
+ FOR_EACH_DST0_ENABLED_CHANNEL(*inst, chan_index) {
+ FETCH(gen, *inst, v0, 0, chan_index); /* v0 = srcreg[0] */
+ FETCH(gen, *inst, v1, 1, chan_index); /* v1 = srcreg[1] */
+ FETCH(gen, *inst, v2, 2, chan_index); /* v2 = srcreg[2] */
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_MAD:
+ ppc_vmaddfp(gen->f, v3, v0, v1, v2); /* v3 = v0 * v1 + v2 */
+ break;
+ case TGSI_OPCODE_LRP:
+ ppc_vsubfp(gen->f, v3, v1, v2); /* v3 = v1 - v2 */
+ ppc_vmaddfp(gen->f, v3, v0, v3, v2); /* v3 = v0 * v3 + v2 */
+ break;
+ default:
+ assert(0);
+ }
+ STORE(gen, *inst, v3, 0, chan_index); /* store v3 */
+ }
+ ppc_release_vec_register(gen->f, v0);
+ ppc_release_vec_register(gen->f, v1);
+ ppc_release_vec_register(gen->f, v2);
+ ppc_release_vec_register(gen->f, v3);
+}
+
+
+
+/** Approximation for vr = pow(va, vb) */
+static void
+ppc_vec_pow(struct ppc_function *f, int vr, int va, int vb)
+{
+ /* pow(a,b) ~= exp2(log2(a) * b) */
+ int t_vec = ppc_allocate_vec_register(f);
+ int zero_vec = ppc_allocate_vec_register(f);
+
+ ppc_vzero(f, zero_vec);
+
+ ppc_vlogefp(f, t_vec, va); /* t = log2(va) */
+ ppc_vmaddfp(f, t_vec, t_vec, vb, zero_vec); /* t = t * vb */
+ ppc_vexptefp(f, vr, t_vec); /* vr = 2^t */
+
+ ppc_release_vec_register(f, t_vec);
+ ppc_release_vec_register(f, zero_vec);
+}
+
+
+static void
+emit_lit(struct gen_context *gen, struct tgsi_full_instruction *inst)
+{
+ int one_vec = gen_one_vec(gen);
+
+ /* Compute X */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_X)) {
+ STORE(gen, *inst, one_vec, 0, CHAN_X);
+ }
+
+ /* Compute Y, Z */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y) ||
+ IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ int x_vec = ppc_allocate_vec_register(gen->f);
+ int zero_vec = ppc_allocate_vec_register(gen->f);
+
+ FETCH(gen, *inst, x_vec, 0, CHAN_X); /* x_vec = src[0].x */
+
+ ppc_vzero(gen->f, zero_vec); /* zero = {0,0,0,0} */
+ ppc_vmaxfp(gen->f, x_vec, x_vec, zero_vec); /* x_vec = max(x_vec, 0) */
+
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Y)) {
+ STORE(gen, *inst, x_vec, 0, CHAN_Y); /* store Y */
+ }
+
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_Z)) {
+ int y_vec = ppc_allocate_vec_register(gen->f);
+ int z_vec = ppc_allocate_vec_register(gen->f);
+ int w_vec = ppc_allocate_vec_register(gen->f);
+ int pow_vec = ppc_allocate_vec_register(gen->f);
+ int pos_vec = ppc_allocate_vec_register(gen->f);
+ int p128_vec = ppc_allocate_vec_register(gen->f);
+ int n128_vec = ppc_allocate_vec_register(gen->f);
+
+ FETCH(gen, *inst, y_vec, 0, CHAN_Y); /* y_vec = src[0].y */
+ ppc_vmaxfp(gen->f, y_vec, y_vec, zero_vec); /* y_vec = max(y_vec, 0) */
+
+ FETCH(gen, *inst, w_vec, 0, CHAN_W); /* w_vec = src[0].w */
+
+ /* clamp Y to [-128, 128] */
+ load_constant_vec(gen, p128_vec, 128.0f);
+ load_constant_vec(gen, n128_vec, -128.0f);
+ ppc_vmaxfp(gen->f, y_vec, y_vec, n128_vec); /* y = max(y, -128) */
+ ppc_vminfp(gen->f, y_vec, y_vec, p128_vec); /* y = min(y, 128) */
+
+ /* if temp.x > 0
+ * z = pow(tmp.y, tmp.w)
+ * else
+ * z = 0.0
+ */
+ ppc_vec_pow(gen->f, pow_vec, y_vec, w_vec); /* pow = pow(y, w) */
+ ppc_vcmpgtfpx(gen->f, pos_vec, x_vec, zero_vec); /* pos = x > 0 */
+ ppc_vand(gen->f, z_vec, pow_vec, pos_vec); /* z = pow & pos */
+
+ STORE(gen, *inst, z_vec, 0, CHAN_Z); /* store Z */
+
+ ppc_release_vec_register(gen->f, y_vec);
+ ppc_release_vec_register(gen->f, z_vec);
+ ppc_release_vec_register(gen->f, w_vec);
+ ppc_release_vec_register(gen->f, pow_vec);
+ ppc_release_vec_register(gen->f, pos_vec);
+ ppc_release_vec_register(gen->f, p128_vec);
+ ppc_release_vec_register(gen->f, n128_vec);
+ }
+
+ ppc_release_vec_register(gen->f, x_vec);
+ ppc_release_vec_register(gen->f, zero_vec);
+ }
+
+ /* Compute W */
+ if (IS_DST0_CHANNEL_ENABLED(*inst, CHAN_W)) {
+ STORE(gen, *inst, one_vec, 0, CHAN_W);
+ }
+}
+
+
+static int
+emit_instruction(struct gen_context *gen,
+ struct tgsi_full_instruction *inst)
+{
+ switch (inst->Instruction.Opcode) {
+ case TGSI_OPCODE_MOV:
+ case TGSI_OPCODE_ABS:
+ case TGSI_OPCODE_FLOOR:
+ case TGSI_OPCODE_FRAC:
+ case TGSI_OPCODE_EXPBASE2:
+ case TGSI_OPCODE_LOGBASE2:
+ emit_unaryop(gen, inst);
+ break;
+ case TGSI_OPCODE_RSQ:
+ case TGSI_OPCODE_RCP:
+ emit_scalar_unaryop(gen, inst);
+ break;
+ case TGSI_OPCODE_ADD:
+ case TGSI_OPCODE_SUB:
+ case TGSI_OPCODE_MUL:
+ case TGSI_OPCODE_MIN:
+ case TGSI_OPCODE_MAX:
+ emit_binop(gen, inst);
+ break;
+ case TGSI_OPCODE_SEQ:
+ case TGSI_OPCODE_SNE:
+ case TGSI_OPCODE_SLT:
+ case TGSI_OPCODE_SGT:
+ case TGSI_OPCODE_SLE:
+ case TGSI_OPCODE_SGE:
+ emit_inequality(gen, inst);
+ break;
+ case TGSI_OPCODE_MAD:
+ case TGSI_OPCODE_LRP:
+ emit_triop(gen, inst);
+ break;
+ case TGSI_OPCODE_DP3:
+ case TGSI_OPCODE_DP4:
+ case TGSI_OPCODE_DPH:
+ emit_dotprod(gen, inst);
+ break;
+ case TGSI_OPCODE_LIT:
+ emit_lit(gen, inst);
+ break;
+ case TGSI_OPCODE_END:
+ /* normal end */
+ return 1;
+ default:
+ return 0;
+ }
+
+
+ return 1;
+}
+
+static void
+emit_declaration(
+ struct ppc_function *func,
+ struct tgsi_full_declaration *decl )
+{
+ if( decl->Declaration.File == TGSI_FILE_INPUT ) {
+#if 0
+ unsigned first, last, mask;
+ unsigned i, j;
+
+ first = decl->DeclarationRange.First;
+ last = decl->DeclarationRange.Last;
+ mask = decl->Declaration.UsageMask;
+
+ for( i = first; i <= last; i++ ) {
+ for( j = 0; j < NUM_CHANNELS; j++ ) {
+ if( mask & (1 << j) ) {
+ switch( decl->Declaration.Interpolate ) {
+ case TGSI_INTERPOLATE_CONSTANT:
+ emit_coef_a0( func, 0, i, j );
+ emit_inputs( func, 0, i, j );
+ break;
+
+ case TGSI_INTERPOLATE_LINEAR:
+ emit_tempf( func, 0, 0, TGSI_SWIZZLE_X );
+ emit_coef_dadx( func, 1, i, j );
+ emit_tempf( func, 2, 0, TGSI_SWIZZLE_Y );
+ emit_coef_dady( func, 3, i, j );
+ emit_mul( func, 0, 1 ); /* x * dadx */
+ emit_coef_a0( func, 4, i, j );
+ emit_mul( func, 2, 3 ); /* y * dady */
+ emit_add( func, 0, 4 ); /* x * dadx + a0 */
+ emit_add( func, 0, 2 ); /* x * dadx + y * dady + a0 */
+ emit_inputs( func, 0, i, j );
+ break;
+
+ case TGSI_INTERPOLATE_PERSPECTIVE:
+ emit_tempf( func, 0, 0, TGSI_SWIZZLE_X );
+ emit_coef_dadx( func, 1, i, j );
+ emit_tempf( func, 2, 0, TGSI_SWIZZLE_Y );
+ emit_coef_dady( func, 3, i, j );
+ emit_mul( func, 0, 1 ); /* x * dadx */
+ emit_tempf( func, 4, 0, TGSI_SWIZZLE_W );
+ emit_coef_a0( func, 5, i, j );
+ emit_rcp( func, 4, 4 ); /* 1.0 / w */
+ emit_mul( func, 2, 3 ); /* y * dady */
+ emit_add( func, 0, 5 ); /* x * dadx + a0 */
+ emit_add( func, 0, 2 ); /* x * dadx + y * dady + a0 */
+ emit_mul( func, 0, 4 ); /* (x * dadx + y * dady + a0) / w */
+ emit_inputs( func, 0, i, j );
+ break;
+
+ default:
+ assert( 0 );
+ break;
+ }
+ }
+ }
+ }
+#endif
+ }
+}
+
+
+
+static void
+emit_prologue(struct ppc_function *func)
+{
+ /* XXX set up stack frame */
+}
+
+
+static void
+emit_epilogue(struct ppc_function *func)
+{
+ ppc_return(func);
+ /* XXX restore prev stack frame */
+}
+
+
+
+/**
+ * Translate a TGSI vertex/fragment shader to PPC code.
+ *
+ * \param tokens the TGSI input shader
+ * \param func the output PPC code/function
+ * \param immediates buffer to place immediates, later passed to PPC func
+ * \return TRUE for success, FALSE if translation failed
+ */
+boolean
+tgsi_emit_ppc(const struct tgsi_token *tokens,
+ struct ppc_function *func,
+ float (*immediates)[4],
+ boolean do_swizzles )
+{
+ static int use_ppc_asm = -1;
+ struct tgsi_parse_context parse;
+ /*boolean instruction_phase = FALSE;*/
+ unsigned ok = 1;
+ uint num_immediates = 0;
+ struct gen_context gen;
+
+ if (use_ppc_asm < 0) {
+ /* If GALLIUM_NOPPC is set, don't use PPC codegen */
+ use_ppc_asm = !debug_get_bool_option("GALLIUM_NOPPC", FALSE);
+ }
+ if (!use_ppc_asm)
+ return FALSE;
+
+ util_init_math();
+
+ gen.f = func;
+ gen.inputs_reg = ppc_reserve_register(func, 3); /* first function param */
+ gen.outputs_reg = ppc_reserve_register(func, 4); /* second function param */
+ gen.temps_reg = ppc_reserve_register(func, 5); /* ... */
+ gen.immed_reg = ppc_reserve_register(func, 6);
+ gen.const_reg = ppc_reserve_register(func, 7);
+ gen.builtins_reg = ppc_reserve_register(func, 8);
+ gen.one_vec = -1;
+ gen.bit31_vec = -1;
+
+ emit_prologue(func);
+
+ tgsi_parse_init( &parse, tokens );
+
+ while (!tgsi_parse_end_of_tokens(&parse) && ok) {
+ tgsi_parse_token(&parse);
+
+ switch (parse.FullToken.Token.Type) {
+ case TGSI_TOKEN_TYPE_DECLARATION:
+ if (parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_FRAGMENT) {
+ emit_declaration(func, &parse.FullToken.FullDeclaration );
+ }
+ break;
+
+ case TGSI_TOKEN_TYPE_INSTRUCTION:
+ ok = emit_instruction(&gen, &parse.FullToken.FullInstruction);
+
+ if (!ok) {
+ debug_printf("failed to translate tgsi opcode %d to PPC (%s)\n",
+ parse.FullToken.FullInstruction.Instruction.Opcode,
+ parse.FullHeader.Processor.Processor == TGSI_PROCESSOR_VERTEX ?
+ "vertex shader" : "fragment shader");
+ }
+ break;
+
+ case TGSI_TOKEN_TYPE_IMMEDIATE:
+ /* splat each immediate component into a float[4] vector for SoA */
+ {
+ const uint size = parse.FullToken.FullImmediate.Immediate.Size - 1;
+ float *imm = (float *) immediates;
+ uint i;
+ assert(size <= 4);
+ assert(num_immediates < TGSI_EXEC_NUM_IMMEDIATES);
+ for (i = 0; i < size; i++) {
+ const float value =
+ parse.FullToken.FullImmediate.u.ImmediateFloat32[i].Float;
+ imm[num_immediates * 4 + 0] =
+ imm[num_immediates * 4 + 1] =
+ imm[num_immediates * 4 + 2] =
+ imm[num_immediates * 4 + 3] = value;
+ num_immediates++;
+ }
+ }
+ break;
+
+ default:
+ ok = 0;
+ assert( 0 );
+ }
+ }
+
+ emit_epilogue(func);
+
+ tgsi_parse_free( &parse );
+
+ return ok;
+}
+
+#endif /* PIPE_ARCH_PPC */
diff --git a/src/gallium/drivers/cell/spu/spu_debug.h b/src/gallium/auxiliary/tgsi/tgsi_ppc.h
index eeec0526558..829ec075e7f 100644
--- a/src/gallium/drivers/cell/spu/spu_debug.h
+++ b/src/gallium/auxiliary/tgsi/tgsi_ppc.h
@@ -25,36 +25,27 @@
*
**************************************************************************/
+#ifndef TGSI_PPC_H
+#define TGSI_PPC_H
-#ifndef SPU_DEBUG_H
-#define SPU_DEBUG_H
-
-
-/* Set to 0 to disable all extraneous debugging code */
-#define DEBUG 1
+#if defined __cplusplus
+extern "C" {
+#endif
-#if DEBUG
-extern boolean Debug;
-extern boolean force_fragment_ops_fallback;
+struct tgsi_token;
+struct ppc_function;
-/* These debug macros use the unusual construction ", ##__VA_ARGS__"
- * which expands to the expected comma + args if variadic arguments
- * are supplied, but swallows the comma if there are no variadic
- * arguments (which avoids syntax errors that would otherwise occur).
- */
-#define DEBUG_PRINTF(format,...) \
- if (Debug) \
- printf("SPU %u: " format, spu.init.id, ##__VA_ARGS__)
-#define D_PRINTF(flag, format,...) \
- if (spu.init.debug_flags & (flag)) \
- printf("SPU %u: " format, spu.init.id, ##__VA_ARGS__)
+extern const float ppc_builtin_constants[];
-#else
-#define DEBUG_PRINTF(...)
-#define D_PRINTF(...)
+boolean
+tgsi_emit_ppc(const struct tgsi_token *tokens,
+ struct ppc_function *function,
+ float (*immediates)[4],
+ boolean do_swizzles);
+#if defined __cplusplus
+}
#endif
-
-#endif /* SPU_DEBUG_H */
+#endif /* TGSI_PPC_H */
diff --git a/src/gallium/drivers/cell/common.h b/src/gallium/drivers/cell/common.h
index b0169b8e329..23fb0b0831d 100644
--- a/src/gallium/drivers/cell/common.h
+++ b/src/gallium/drivers/cell/common.h
@@ -64,10 +64,13 @@
#define ROUNDUP16(k) (((k) + 0xf) & ~0xf)
-#define CELL_MAX_SPUS 6
+#define CELL_MAX_SPUS 8
#define CELL_MAX_SAMPLERS 4
#define CELL_MAX_TEXTURE_LEVELS 12 /* 2k x 2k */
+#define CELL_MAX_CONSTANTS 32 /**< number of float[4] constants */
+#define CELL_MAX_WIDTH 1024 /**< max framebuffer width */
+#define CELL_MAX_HEIGHT 1024 /**< max framebuffer width */
#define TILE_SIZE 32
@@ -96,34 +99,67 @@
#define CELL_CMD_STATE_FRAGMENT_PROGRAM 19
#define CELL_CMD_STATE_ATTRIB_FETCH 20
#define CELL_CMD_STATE_FS_CONSTANTS 21
-#define CELL_CMD_VS_EXECUTE 22
-#define CELL_CMD_FLUSH_BUFFER_RANGE 23
+#define CELL_CMD_STATE_RASTERIZER 22
+#define CELL_CMD_VS_EXECUTE 23
+#define CELL_CMD_FLUSH_BUFFER_RANGE 24
+#define CELL_CMD_FENCE 25
+/** Command/batch buffers */
#define CELL_NUM_BUFFERS 4
#define CELL_BUFFER_SIZE (4*1024) /**< 16KB would be the max */
#define CELL_BUFFER_STATUS_FREE 10
#define CELL_BUFFER_STATUS_USED 20
+/** Debug flags */
#define CELL_DEBUG_CHECKER (1 << 0)
#define CELL_DEBUG_ASM (1 << 1)
#define CELL_DEBUG_SYNC (1 << 2)
#define CELL_DEBUG_FRAGMENT_OPS (1 << 3)
#define CELL_DEBUG_FRAGMENT_OP_FALLBACK (1 << 4)
+#define CELL_DEBUG_CMD (1 << 5)
+#define CELL_DEBUG_CACHE (1 << 6)
/** Max instructions for doing per-fragment operations */
#define SPU_MAX_FRAGMENT_OPS_INSTS 64
+
+#define CELL_FENCE_IDLE 0
+#define CELL_FENCE_EMITTED 1
+#define CELL_FENCE_SIGNALLED 2
+
+struct cell_fence
+{
+ /** There's a 16-byte status qword per SPU */
+ volatile uint status[CELL_MAX_SPUS][4];
+};
+
+
+/**
+ * Fence command sent to SPUs. In response, the SPUs will write
+ * CELL_FENCE_STATUS_SIGNALLED back to the fence status word in main memory.
+ */
+struct cell_command_fence
+{
+ uint64_t opcode; /**< CELL_CMD_FENCE */
+ struct cell_fence *fence;
+};
+
+
/**
* Command to specify per-fragment operations state and generated code.
+ * Note that the dsa, blend, blend_color fields are really only needed
+ * for the fallback/C per-pixel code. They're not used when we generate
+ * dynamic SPU fragment code (which is the normal case).
*/
struct cell_command_fragment_ops
{
uint64_t opcode; /**< CELL_CMD_STATE_FRAGMENT_OPS */
struct pipe_depth_stencil_alpha_state dsa;
struct pipe_blend_state blend;
+ struct pipe_blend_color blend_color;
unsigned code[SPU_MAX_FRAGMENT_OPS_INSTS];
};
@@ -147,7 +183,7 @@ struct cell_command_fragment_program
*/
struct cell_command_framebuffer
{
- uint64_t opcode; /**< CELL_CMD_FRAMEBUFFER */
+ uint64_t opcode; /**< CELL_CMD_STATE_FRAMEBUFFER */
int width, height;
void *color_start, *depth_start;
enum pipe_format color_format, depth_format;
@@ -155,6 +191,16 @@ struct cell_command_framebuffer
/**
+ * Tell SPUs about rasterizer state.
+ */
+struct cell_command_rasterizer
+{
+ uint64_t opcode; /**< CELL_CMD_STATE_RASTERIZER */
+ struct pipe_rasterizer_state rasterizer;
+};
+
+
+/**
* Clear framebuffer to the given value/color.
*/
struct cell_command_clear_surface
@@ -229,7 +275,6 @@ struct cell_command_render
float xmin, ymin, xmax, ymax; /* XXX another dummy field */
uint min_index;
boolean inline_verts;
- uint front_winding; /* the rasterizer needs to be able to determine facing to apply front/back-facing stencil */
};
@@ -260,19 +305,6 @@ struct cell_command_texture
};
-/** XXX unions don't seem to work */
-/* XXX this should go away; all commands should be placed in batch buffers */
-struct cell_command
-{
-#if 0
- struct cell_command_framebuffer fb;
- struct cell_command_clear_surface clear;
- struct cell_command_render render;
-#endif
- struct cell_command_vs vs;
-} ALIGN16_ATTRIB;
-
-
#define MAX_SPU_FUNCTIONS 12
/**
* Used to tell the PPU about the address of particular functions in the
@@ -293,7 +325,7 @@ struct cell_init_info
unsigned id;
unsigned num_spus;
unsigned debug_flags; /**< mask of CELL_DEBUG_x flags */
- struct cell_command *cmd;
+ float inv_timebase; /**< 1.0/timebase, for perf measurement */
/** Buffers for command batches, vertex/index data */
ubyte *buffers[CELL_NUM_BUFFERS];
diff --git a/src/gallium/drivers/cell/ppu/Makefile b/src/gallium/drivers/cell/ppu/Makefile
index b28f4c5c31f..9358a47284c 100644
--- a/src/gallium/drivers/cell/ppu/Makefile
+++ b/src/gallium/drivers/cell/ppu/Makefile
@@ -24,6 +24,7 @@ SOURCES = \
cell_clear.c \
cell_context.c \
cell_draw_arrays.c \
+ cell_fence.c \
cell_flush.c \
cell_gen_fragment.c \
cell_gen_fp.c \
diff --git a/src/gallium/drivers/cell/ppu/cell_batch.c b/src/gallium/drivers/cell/ppu/cell_batch.c
index 16882c01295..448b723d85a 100644
--- a/src/gallium/drivers/cell/ppu/cell_batch.c
+++ b/src/gallium/drivers/cell/ppu/cell_batch.c
@@ -28,6 +28,7 @@
#include "cell_context.h"
#include "cell_batch.h"
+#include "cell_fence.h"
#include "cell_spu.h"
@@ -42,7 +43,9 @@
uint
cell_get_empty_buffer(struct cell_context *cell)
{
- uint buf = 0, tries = 0;
+ static uint prev_buffer = 0;
+ uint buf = (prev_buffer + 1) % CELL_NUM_BUFFERS;
+ uint tries = 0;
/* Find a buffer that's marked as free by all SPUs */
while (1) {
@@ -58,8 +61,13 @@ cell_get_empty_buffer(struct cell_context *cell)
cell->buffer_status[spu][buf][0] = CELL_BUFFER_STATUS_USED;
}
/*
- printf("PPU: ALLOC BUFFER %u\n", buf);
+ printf("PPU: ALLOC BUFFER %u, %u tries\n", buf, tries);
*/
+ prev_buffer = buf;
+
+ /* release tex buffer associated w/ prev use of this batch buf */
+ cell_free_fenced_buffers(cell, &cell->fenced_buffers[buf]);
+
return buf;
}
}
@@ -82,6 +90,26 @@ cell_get_empty_buffer(struct cell_context *cell)
/**
+ * Append a fence command to the current batch buffer.
+ * Note that we're sure there's always room for this because of the
+ * adjusted size check in cell_batch_free_space().
+ */
+static void
+emit_fence(struct cell_context *cell)
+{
+ const uint batch = cell->cur_batch;
+ const uint size = cell->buffer_size[batch];
+ struct cell_command_fence *fence_cmd;
+
+ ASSERT(size + sizeof(struct cell_command_fence) <= CELL_BUFFER_SIZE);
+
+ fence_cmd = (struct cell_command_fence *) (cell->buffer[batch] + size);
+ fence_cmd->opcode = CELL_CMD_FENCE;
+ fence_cmd->fence = &cell->fenced_buffers[batch].fence;
+}
+
+
+/**
* Flush the current batch buffer to the SPUs.
* An empty buffer will be found and set as the new current batch buffer
* for subsequent commands/data.
@@ -99,6 +127,12 @@ cell_batch_flush(struct cell_context *cell)
if (size == 0)
return;
+ /* Before we use this batch buffer, make sure any fenced texture buffers
+ * are released.
+ */
+ if (cell->fenced_buffers[batch].head)
+ emit_fence(cell);
+
flushing = TRUE;
assert(batch < CELL_NUM_BUFFERS);
@@ -139,6 +173,7 @@ uint
cell_batch_free_space(const struct cell_context *cell)
{
uint free = CELL_BUFFER_SIZE - cell->buffer_size[cell->cur_batch];
+ free -= sizeof(struct cell_command_fence);
return free;
}
@@ -169,7 +204,7 @@ cell_batch_append(struct cell_context *cell, const void *data, uint bytes)
size = cell->buffer_size[cell->cur_batch];
- if (size + bytes > CELL_BUFFER_SIZE) {
+ if (bytes > cell_batch_free_space(cell)) {
cell_batch_flush(cell);
size = 0;
}
@@ -223,7 +258,7 @@ cell_batch_alloc_aligned(struct cell_context *cell, uint bytes,
padbytes = (alignment - (size % alignment)) % alignment;
- if (padbytes + size + bytes > CELL_BUFFER_SIZE) {
+ if (padbytes + bytes > cell_batch_free_space(cell)) {
cell_batch_flush(cell);
size = 0;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index b66aa9c9d99..22d552d8e3d 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -47,6 +47,7 @@
#include "cell_clear.h"
#include "cell_context.h"
#include "cell_draw_arrays.h"
+#include "cell_fence.h"
#include "cell_flush.h"
#include "cell_state.h"
#include "cell_surface.h"
@@ -93,6 +94,8 @@ static const struct debug_named_value cell_debug_flags[] = {
{"sync", CELL_DEBUG_SYNC}, /**< SPUs do synchronous DMA */
{"fragops", CELL_DEBUG_FRAGMENT_OPS}, /**< SPUs emit fragment ops debug messages*/
{"fragopfallback", CELL_DEBUG_FRAGMENT_OP_FALLBACK}, /**< SPUs use reference implementation for fragment ops*/
+ {"cmd", CELL_DEBUG_CMD}, /**< SPUs dump command buffer info */
+ {"cache", CELL_DEBUG_CACHE}, /**< report texture cache stats on exit */
{NULL, 0}
};
@@ -102,6 +105,7 @@ cell_create_context(struct pipe_screen *screen,
struct cell_winsys *cws)
{
struct cell_context *cell;
+ uint i;
/* some fields need to be 16-byte aligned, so align the whole object */
cell = (struct cell_context*) align_malloc(sizeof(struct cell_context), 16);
@@ -149,13 +153,24 @@ cell_create_context(struct pipe_screen *screen,
cell_debug_flags,
0 );
+ for (i = 0; i < CELL_NUM_BUFFERS; i++)
+ cell_fence_init(&cell->fenced_buffers[i].fence);
+
+
/*
* SPU stuff
*/
- cell->num_spus = 6;
- /* XXX is this in SDK 3.0 only?
- cell->num_spus = spe_cpu_info_get(SPE_COUNT_PHYSICAL_SPES, -1);
- */
+ /* This call only works with SDK 3.0. Anyone still using 2.1??? */
+ cell->num_cells = spe_cpu_info_get(SPE_COUNT_PHYSICAL_CPU_NODES, -1);
+ cell->num_spus = spe_cpu_info_get(SPE_COUNT_USABLE_SPES, 0);
+ if (cell->debug_flags) {
+ printf("Cell: found %d Cell(s) with %u SPUs\n",
+ cell->num_cells, cell->num_spus);
+ }
+ if (getenv("CELL_NUM_SPUS")) {
+ cell->num_spus = atoi(getenv("CELL_NUM_SPUS"));
+ assert(cell->num_spus > 0);
+ }
cell_start_spus(cell);
diff --git a/src/gallium/drivers/cell/ppu/cell_context.h b/src/gallium/drivers/cell/ppu/cell_context.h
index 80a9b3d7e13..4491ae8cdf1 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.h
+++ b/src/gallium/drivers/cell/ppu/cell_context.h
@@ -74,12 +74,26 @@ struct cell_fragment_shader_state
struct cell_fragment_ops_key
{
struct pipe_blend_state blend;
+ struct pipe_blend_color blend_color;
struct pipe_depth_stencil_alpha_state dsa;
enum pipe_format color_format;
enum pipe_format zs_format;
};
+struct cell_buffer_node;
+
+/**
+ * Fenced buffer list. List of buffers which can be unreferenced after
+ * the fence has been executed/signalled.
+ */
+struct cell_buffer_list
+{
+ struct cell_fence fence;
+ struct cell_buffer_node *head;
+};
+
+
/**
* Per-context state, subclass of pipe_context.
*/
@@ -120,6 +134,8 @@ struct cell_context
uint *tex_map;
uint dirty;
+ uint dirty_textures; /* bitmask of texture units */
+ uint dirty_samplers; /* bitmask of sampler units */
/** Cache of code generated for per-fragment ops */
struct keymap *fragment_ops_cache;
@@ -139,7 +155,7 @@ struct cell_context
struct cell_spu_function_info spu_functions ALIGN16_ATTRIB;
- uint num_spus;
+ uint num_cells, num_spus;
/** Buffers for command batches, vertex/index data */
uint buffer_size[CELL_NUM_BUFFERS];
@@ -151,6 +167,14 @@ struct cell_context
uint buffer_status[CELL_MAX_SPUS][CELL_NUM_BUFFERS][4] ALIGN16_ATTRIB;
+ /** Associated with each command/batch buffer is a list of pipe_buffers
+ * that are fenced. When the last command in a buffer is executed, the
+ * fence will be signalled, indicating that any pipe_buffers preceeding
+ * that fence can be unreferenced (and probably freed).
+ */
+ struct cell_buffer_list fenced_buffers[CELL_NUM_BUFFERS];
+
+
struct spe_function attrib_fetch;
unsigned attrib_fetch_offsets[PIPE_MAX_ATTRIBS];
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c
new file mode 100644
index 00000000000..ffb3bea12b9
--- /dev/null
+++ b/src/gallium/drivers/cell/ppu/cell_fence.c
@@ -0,0 +1,158 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+#include <unistd.h>
+#include "util/u_memory.h"
+#include "pipe/p_inlines.h"
+#include "cell_context.h"
+#include "cell_batch.h"
+#include "cell_fence.h"
+#include "cell_texture.h"
+
+
+void
+cell_fence_init(struct cell_fence *fence)
+{
+ uint i;
+ for (i = 0; i < CELL_MAX_SPUS; i++) {
+ fence->status[i][0] = CELL_FENCE_IDLE;
+ }
+}
+
+
+boolean
+cell_fence_signalled(const struct cell_context *cell,
+ const struct cell_fence *fence)
+{
+ uint i;
+ for (i = 0; i < cell->num_spus; i++) {
+ //ASSERT(fence->status[i][0] != CELL_FENCE_IDLE);
+ if (fence->status[i][0] == CELL_FENCE_EMITTED)
+ return FALSE;
+ }
+ return TRUE;
+}
+
+
+void
+cell_fence_finish(const struct cell_context *cell,
+ const struct cell_fence *fence)
+{
+ while (!cell_fence_signalled(cell, fence)) {
+ usleep(10);
+ }
+}
+
+
+
+
+struct cell_buffer_node
+{
+ struct pipe_buffer *buffer;
+ struct cell_buffer_node *next;
+};
+
+
+static void
+cell_add_buffer_to_list(struct cell_context *cell,
+ struct cell_buffer_list *list,
+ struct pipe_buffer *buffer)
+{
+ struct pipe_screen *ps = cell->pipe.screen;
+ struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
+ /* create new list node which references the buffer, insert at head */
+ if (node) {
+ pipe_buffer_reference(ps, &node->buffer, buffer);
+ node->next = list->head;
+ list->head = node;
+ }
+}
+
+
+/**
+ * Wait for completion of the given fence, then unreference any buffers
+ * on the list.
+ * This typically unrefs/frees texture buffers after any rendering which uses
+ * them has completed.
+ */
+void
+cell_free_fenced_buffers(struct cell_context *cell,
+ struct cell_buffer_list *list)
+{
+ if (list->head) {
+ struct pipe_screen *ps = cell->pipe.screen;
+ struct cell_buffer_node *node;
+
+ cell_fence_finish(cell, &list->fence);
+
+ /* traverse the list, unreferencing buffers, freeing nodes */
+ node = list->head;
+ while (node) {
+ struct cell_buffer_node *next = node->next;
+ assert(node->buffer);
+ pipe_buffer_unmap(ps, node->buffer);
+#if 0
+ printf("Unref buffer %p\n", node->buffer);
+ if (node->buffer->refcount == 1)
+ printf(" Delete!\n");
+#endif
+ pipe_buffer_reference(ps, &node->buffer, NULL);
+ FREE(node);
+ node = next;
+ }
+ list->head = NULL;
+ }
+}
+
+
+/**
+ * This should be called for each render command.
+ * Any texture buffers that are current bound will be added to a fenced
+ * list to be freed later when the fence is executed/signalled.
+ */
+void
+cell_add_fenced_textures(struct cell_context *cell)
+{
+ struct cell_buffer_list *list = &cell->fenced_buffers[cell->cur_batch];
+ uint i;
+
+ for (i = 0; i < cell->num_textures; i++) {
+ struct cell_texture *ct = cell->texture[i];
+ if (ct) {
+ uint level;
+ for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
+ if (ct->tiled_buffer[level]) {
+#if 0
+ printf("Adding texture %p buffer %p to list\n",
+ ct, ct->tiled_buffer[level]);
+#endif
+ cell_add_buffer_to_list(cell, list, ct->tiled_buffer[level]);
+ }
+ }
+ }
+ }
+}
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.h b/src/gallium/drivers/cell/ppu/cell_fence.h
new file mode 100644
index 00000000000..536b4ba411a
--- /dev/null
+++ b/src/gallium/drivers/cell/ppu/cell_fence.h
@@ -0,0 +1,57 @@
+/**************************************************************************
+ *
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * 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, sub license, 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 (including the
+ * next paragraph) 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 NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS 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.
+ *
+ **************************************************************************/
+
+
+#ifndef CELL_FENCE_H
+#define CELL_FENCE_H
+
+
+extern void
+cell_fence_init(struct cell_fence *fence);
+
+
+extern boolean
+cell_fence_signalled(const struct cell_context *cell,
+ const struct cell_fence *fence);
+
+
+extern void
+cell_fence_finish(const struct cell_context *cell,
+ const struct cell_fence *fence);
+
+
+
+extern void
+cell_free_fenced_buffers(struct cell_context *cell,
+ struct cell_buffer_list *list);
+
+
+extern void
+cell_add_fenced_textures(struct cell_context *cell);
+
+
+#endif /* CELL_FENCE_H */
diff --git a/src/gallium/drivers/cell/ppu/cell_gen_fp.c b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
index 3dfd5f673dd..d4d644d6e81 100644
--- a/src/gallium/drivers/cell/ppu/cell_gen_fp.c
+++ b/src/gallium/drivers/cell/ppu/cell_gen_fp.c
@@ -84,6 +84,9 @@ struct codegen
/** Index of execution mask register */
int exec_mask_reg;
+ /** KIL mask: indicates which fragments have been killed */
+ int kill_mask_reg;
+
int frame_size; /**< Stack frame size, in words */
struct spe_function *f;
@@ -346,6 +349,22 @@ store_dest_reg(struct codegen *gen,
int value_reg, int channel,
const struct tgsi_full_dst_register *dest)
{
+ /*
+ * XXX need to implement dst reg clamping/saturation
+ */
+#if 0
+ switch (inst->Instruction.Saturate) {
+ case TGSI_SAT_NONE:
+ break;
+ case TGSI_SAT_ZERO_ONE:
+ break;
+ case TGSI_SAT_MINUS_PLUS_ONE:
+ break;
+ default:
+ assert( 0 );
+ }
+#endif
+
switch (dest->DstRegister.File) {
case TGSI_FILE_TEMPORARY:
if (gen->if_nesting > 0) {
@@ -431,8 +450,21 @@ emit_prologue(struct codegen *gen)
static void
emit_epilogue(struct codegen *gen)
{
+ const int return_reg = 3;
+
spe_comment(gen->f, -4, "Function epilogue:");
+ spe_comment(gen->f, 0, "return the killed mask");
+ if (gen->kill_mask_reg > 0) {
+ /* shader called KIL, return the "alive" mask */
+ spe_move(gen->f, return_reg, gen->kill_mask_reg);
+ }
+ else {
+ /* return {0,0,0,0} */
+ spe_load_uint(gen->f, return_reg, 0);
+ }
+
+ spe_comment(gen->f, 0, "restore stack and return");
if (gen->frame_size >= 512) {
/* offset is too large for ai instruction */
int offset_reg = spe_allocate_available_register(gen->f);
@@ -1337,16 +1369,33 @@ emit_function_call(struct codegen *gen,
static boolean
-emit_TXP(struct codegen *gen, const struct tgsi_full_instruction *inst)
+emit_TEX(struct codegen *gen, const struct tgsi_full_instruction *inst)
{
- const uint addr = lookup_function(gen->cell, "spu_txp");
+ const uint target = inst->InstructionExtTexture.Texture;
const uint unit = inst->FullSrcRegisters[1].SrcRegister.Index;
+ uint addr;
int ch;
int coord_regs[4], d_regs[4];
+ switch (target) {
+ case TGSI_TEXTURE_1D:
+ case TGSI_TEXTURE_2D:
+ addr = lookup_function(gen->cell, "spu_tex_2d");
+ break;
+ case TGSI_TEXTURE_3D:
+ addr = lookup_function(gen->cell, "spu_tex_3d");
+ break;
+ case TGSI_TEXTURE_CUBE:
+ addr = lookup_function(gen->cell, "spu_tex_cube");
+ break;
+ default:
+ ASSERT(0 && "unsupported texture target");
+ return FALSE;
+ }
+
assert(inst->FullSrcRegisters[1].SrcRegister.File == TGSI_FILE_SAMPLER);
- spe_comment(gen->f, -4, "CALL txp:");
+ spe_comment(gen->f, -4, "CALL tex:");
/* get src/dst reg info */
for (ch = 0; ch < 4; ch++) {
@@ -1368,7 +1417,7 @@ emit_TXP(struct codegen *gen, const struct tgsi_full_instruction *inst)
spe_stqd(gen->f, reg, SPE_REG_SP, 16 * offset);
}
- /* setup function arguments */
+ /* setup function arguments (XXX depends on target) */
for (i = 0; i < 4; i++) {
spe_move(gen->f, 3 + i, coord_regs[i]);
}
@@ -1407,6 +1456,68 @@ emit_TXP(struct codegen *gen, const struct tgsi_full_instruction *inst)
/**
+ * KILL if any of src reg values are less than zero.
+ */
+static boolean
+emit_KIL(struct codegen *gen, const struct tgsi_full_instruction *inst)
+{
+ int ch;
+ int s_regs[4], kil_reg = -1, cmp_reg, zero_reg;
+
+ spe_comment(gen->f, -4, "CALL kil:");
+
+ /* zero = {0,0,0,0} */
+ zero_reg = get_itemp(gen);
+ spe_load_uint(gen->f, zero_reg, 0);
+
+ cmp_reg = get_itemp(gen);
+
+ /* get src regs */
+ for (ch = 0; ch < 4; ch++) {
+ if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+ s_regs[ch] = get_src_reg(gen, ch, &inst->FullSrcRegisters[0]);
+ }
+ }
+
+ /* test if any src regs are < 0 */
+ for (ch = 0; ch < 4; ch++) {
+ if (inst->FullDstRegisters[0].DstRegister.WriteMask & (1 << ch)) {
+ if (kil_reg >= 0) {
+ /* cmp = 0 > src ? : ~0 : 0 */
+ spe_fcgt(gen->f, cmp_reg, zero_reg, s_regs[ch]);
+ /* kil = kil | cmp */
+ spe_or(gen->f, kil_reg, kil_reg, cmp_reg);
+ }
+ else {
+ kil_reg = get_itemp(gen);
+ /* kil = 0 > src ? : ~0 : 0 */
+ spe_fcgt(gen->f, kil_reg, zero_reg, s_regs[ch]);
+ }
+ }
+ }
+
+ if (gen->if_nesting) {
+ /* may have been a conditional kil */
+ spe_and(gen->f, kil_reg, kil_reg, gen->exec_mask_reg);
+ }
+
+ /* allocate the kill mask reg if needed */
+ if (gen->kill_mask_reg <= 0) {
+ gen->kill_mask_reg = spe_allocate_available_register(gen->f);
+ spe_move(gen->f, gen->kill_mask_reg, kil_reg);
+ }
+ else {
+ spe_or(gen->f, gen->kill_mask_reg, gen->kill_mask_reg, kil_reg);
+ }
+
+ free_itemps(gen);
+
+ return TRUE;
+}
+
+
+
+/**
* Emit max. See emit_SGT for comments.
*/
static boolean
@@ -1674,8 +1785,12 @@ emit_instruction(struct codegen *gen,
/* fall-through for now */
case TGSI_OPCODE_TXB:
/* fall-through for now */
+ case TGSI_OPCODE_TXL:
+ /* fall-through for now */
case TGSI_OPCODE_TXP:
- return emit_TXP(gen, inst);
+ return emit_TEX(gen, inst);
+ case TGSI_OPCODE_KIL:
+ return emit_KIL(gen, inst);
case TGSI_OPCODE_IF:
return emit_IF(gen, inst);
diff --git a/src/gallium/drivers/cell/ppu/cell_pipe_state.c b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
index 2e3086c4fae..825110c62b7 100644
--- a/src/gallium/drivers/cell/ppu/cell_pipe_state.c
+++ b/src/gallium/drivers/cell/ppu/cell_pipe_state.c
@@ -212,17 +212,24 @@ cell_bind_sampler_states(struct pipe_context *pipe,
unsigned num, void **samplers)
{
struct cell_context *cell = cell_context(pipe);
+ uint i, changed = 0x0;
assert(num <= CELL_MAX_SAMPLERS);
draw_flush(cell->draw);
- memcpy(cell->sampler, samplers, num * sizeof(void *));
- memset(&cell->sampler[num], 0, (CELL_MAX_SAMPLERS - num) *
- sizeof(void *));
- cell->num_samplers = num;
+ for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
+ struct pipe_sampler_state *new_samp = i < num ? samplers[i] : NULL;
+ if (cell->sampler[i] != new_samp) {
+ cell->sampler[i] = new_samp;
+ changed |= (1 << i);
+ }
+ }
- cell->dirty |= CELL_NEW_SAMPLER;
+ if (changed) {
+ cell->dirty |= CELL_NEW_SAMPLER;
+ cell->dirty_samplers |= changed;
+ }
}
@@ -240,25 +247,25 @@ cell_set_sampler_textures(struct pipe_context *pipe,
unsigned num, struct pipe_texture **texture)
{
struct cell_context *cell = cell_context(pipe);
- uint i;
+ uint i, changed = 0x0;
assert(num <= CELL_MAX_SAMPLERS);
- /* Check for no-op */
- if (num == cell->num_textures &&
- !memcmp(cell->texture, texture, num * sizeof(struct pipe_texture *)))
- return;
-
- draw_flush(cell->draw);
-
for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
- struct pipe_texture *tex = i < num ? texture[i] : NULL;
-
- pipe_texture_reference((struct pipe_texture **) &cell->texture[i], tex);
+ struct pipe_texture *new_tex = i < num ? texture[i] : NULL;
+ if ((struct pipe_texture *) cell->texture[i] != new_tex) {
+ pipe_texture_reference((struct pipe_texture **) &cell->texture[i],
+ new_tex);
+ changed |= (1 << i);
+ }
}
+
cell->num_textures = num;
- cell->dirty |= CELL_NEW_TEXTURE;
+ if (changed) {
+ cell->dirty |= CELL_NEW_TEXTURE;
+ cell->dirty_textures |= changed;
+ }
}
diff --git a/src/gallium/drivers/cell/ppu/cell_spu.c b/src/gallium/drivers/cell/ppu/cell_spu.c
index df020c4146d..28e5e6d706d 100644
--- a/src/gallium/drivers/cell/ppu/cell_spu.c
+++ b/src/gallium/drivers/cell/ppu/cell_spu.c
@@ -53,6 +53,35 @@ struct cell_global_info cell_global;
/**
+ * Scan /proc/cpuinfo to determine the timebase for the system.
+ * This is used by the SPUs to convert 'decrementer' ticks to seconds.
+ * There may be a better way to get this value...
+ */
+static unsigned
+get_timebase(void)
+{
+ FILE *f = fopen("/proc/cpuinfo", "r");
+ unsigned timebase;
+
+ assert(f);
+ while (!feof(f)) {
+ char line[80];
+ fgets(line, sizeof(line), f);
+ if (strncmp(line, "timebase", 8) == 0) {
+ char *colon = strchr(line, ':');
+ if (colon) {
+ timebase = atoi(colon + 2);
+ break;
+ }
+ }
+ }
+ fclose(f);
+
+ return timebase;
+}
+
+
+/**
* Write a 1-word message to the given SPE mailbox.
*/
void
@@ -115,6 +144,7 @@ cell_start_spus(struct cell_context *cell)
{
static boolean one_time_init = FALSE;
uint i, j;
+ uint timebase = get_timebase();
if (one_time_init) {
fprintf(stderr, "PPU: Multiple rendering contexts not yet supported "
@@ -124,10 +154,7 @@ cell_start_spus(struct cell_context *cell)
one_time_init = TRUE;
- assert(cell->num_spus <= MAX_SPUS);
-
- ASSERT_ALIGN16(&cell_global.command[0]);
- ASSERT_ALIGN16(&cell_global.command[1]);
+ assert(cell->num_spus <= CELL_MAX_SPUS);
ASSERT_ALIGN16(&cell_global.inits[0]);
ASSERT_ALIGN16(&cell_global.inits[1]);
@@ -141,7 +168,8 @@ cell_start_spus(struct cell_context *cell)
cell_global.inits[i].id = i;
cell_global.inits[i].num_spus = cell->num_spus;
cell_global.inits[i].debug_flags = cell->debug_flags;
- cell_global.inits[i].cmd = &cell_global.command[i];
+ cell_global.inits[i].inv_timebase = 1000.0f / timebase;
+
for (j = 0; j < CELL_NUM_BUFFERS; j++) {
cell_global.inits[i].buffers[j] = cell->buffer[j];
}
diff --git a/src/gallium/drivers/cell/ppu/cell_spu.h b/src/gallium/drivers/cell/ppu/cell_spu.h
index 137f26612e4..b633880c256 100644
--- a/src/gallium/drivers/cell/ppu/cell_spu.h
+++ b/src/gallium/drivers/cell/ppu/cell_spu.h
@@ -31,13 +31,12 @@
#include <libspe2.h>
#include <libmisc.h>
+#include <pthread.h>
#include "cell/common.h"
#include "cell_context.h"
-#define MAX_SPUS 8
-
/**
* Global vars, for now anyway.
*/
@@ -46,14 +45,13 @@ struct cell_global_info
/**
* SPU/SPE handles, etc
*/
- spe_context_ptr_t spe_contexts[MAX_SPUS];
- pthread_t spe_threads[MAX_SPUS];
+ spe_context_ptr_t spe_contexts[CELL_MAX_SPUS];
+ pthread_t spe_threads[CELL_MAX_SPUS];
/**
- * Data sent to SPUs
+ * Data sent to SPUs at start-up
*/
- struct cell_init_info inits[MAX_SPUS];
- struct cell_command command[MAX_SPUS];
+ struct cell_init_info inits[CELL_MAX_SPUS];
};
diff --git a/src/gallium/drivers/cell/ppu/cell_state_emit.c b/src/gallium/drivers/cell/ppu/cell_state_emit.c
index bb694aa1073..dd2d7f7d1ef 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_emit.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_emit.c
@@ -52,6 +52,7 @@ lookup_fragment_ops(struct cell_context *cell)
*/
memset(&key, 0, sizeof(key));
key.blend = *cell->blend;
+ key.blend_color = cell->blend_color;
key.dsa = *cell->depth_stencil;
if (cell->framebuffer.cbufs[0])
@@ -146,6 +147,13 @@ cell_emit_state(struct cell_context *cell)
#endif
}
+ if (cell->dirty & (CELL_NEW_RASTERIZER)) {
+ struct cell_command_rasterizer *rast =
+ cell_batch_alloc(cell, sizeof(*rast));
+ rast->opcode = CELL_CMD_STATE_RASTERIZER;
+ rast->rasterizer = *cell->rasterizer;
+ }
+
if (cell->dirty & (CELL_NEW_FS)) {
/* Send new fragment program to SPUs */
struct cell_command_fragment_program *fp
@@ -193,44 +201,50 @@ cell_emit_state(struct cell_context *cell)
if (cell->dirty & CELL_NEW_SAMPLER) {
uint i;
for (i = 0; i < CELL_MAX_SAMPLERS; i++) {
- if (cell->sampler[i]) {
- struct cell_command_sampler *sampler
- = cell_batch_alloc(cell, sizeof(*sampler));
- sampler->opcode = CELL_CMD_STATE_SAMPLER;
- sampler->unit = i;
- sampler->state = *cell->sampler[i];
+ if (cell->dirty_samplers & (1 << i)) {
+ if (cell->sampler[i]) {
+ struct cell_command_sampler *sampler
+ = cell_batch_alloc(cell, sizeof(*sampler));
+ sampler->opcode = CELL_CMD_STATE_SAMPLER;
+ sampler->unit = i;
+ sampler->state = *cell->sampler[i];
+ }
}
}
+ cell->dirty_samplers = 0x0;
}
if (cell->dirty & CELL_NEW_TEXTURE) {
uint i;
for (i = 0;i < CELL_MAX_SAMPLERS; i++) {
- struct cell_command_texture *texture
- = cell_batch_alloc(cell, sizeof(*texture));
- texture->opcode = CELL_CMD_STATE_TEXTURE;
- texture->unit = i;
- if (cell->texture[i]) {
- uint level;
- for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
- texture->start[level] = cell->texture[i]->tiled_data[level];
- texture->width[level] = cell->texture[i]->base.width[level];
- texture->height[level] = cell->texture[i]->base.height[level];
- texture->depth[level] = cell->texture[i]->base.depth[level];
+ if (cell->dirty_textures & (1 << i)) {
+ struct cell_command_texture *texture
+ = cell_batch_alloc(cell, sizeof(*texture));
+ texture->opcode = CELL_CMD_STATE_TEXTURE;
+ texture->unit = i;
+ if (cell->texture[i]) {
+ uint level;
+ for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
+ texture->start[level] = cell->texture[i]->tiled_mapped[level];
+ texture->width[level] = cell->texture[i]->base.width[level];
+ texture->height[level] = cell->texture[i]->base.height[level];
+ texture->depth[level] = cell->texture[i]->base.depth[level];
+ }
+ texture->target = cell->texture[i]->base.target;
}
- texture->target = cell->texture[i]->base.target;
- }
- else {
- uint level;
- for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
- texture->start[level] = NULL;
- texture->width[level] = 0;
- texture->height[level] = 0;
- texture->depth[level] = 0;
+ else {
+ uint level;
+ for (level = 0; level < CELL_MAX_TEXTURE_LEVELS; level++) {
+ texture->start[level] = NULL;
+ texture->width[level] = 0;
+ texture->height[level] = 0;
+ texture->depth[level] = 0;
+ }
+ texture->target = 0;
}
- texture->target = 0;
}
}
+ cell->dirty_textures = 0x0;
}
if (cell->dirty & CELL_NEW_VERTEX_INFO) {
diff --git a/src/gallium/drivers/cell/ppu/cell_state_shader.c b/src/gallium/drivers/cell/ppu/cell_state_shader.c
index 54a17eaf2b7..cda39f8d592 100644
--- a/src/gallium/drivers/cell/ppu/cell_state_shader.c
+++ b/src/gallium/drivers/cell/ppu/cell_state_shader.c
@@ -191,6 +191,8 @@ cell_set_constant_buffer(struct pipe_context *pipe,
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
+ draw_flush(cell->draw);
+
/* note: reference counting */
winsys_buffer_reference(ws,
&cell->constants[shader].buffer,
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 230e1925733..9ac2f3bbb96 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -136,6 +136,9 @@ cell_texture_release(struct pipe_screen *screen,
__FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
*/
if (--(*pt)->refcount <= 0) {
+ /* Delete this texture now.
+ * But note that the underlying pipe_buffer may linger...
+ */
struct cell_texture *ct = cell_texture(*pt);
uint i;
@@ -146,8 +149,12 @@ cell_texture_release(struct pipe_screen *screen,
pipe_buffer_reference(screen, &ct->buffer, NULL);
for (i = 0; i < CELL_MAX_TEXTURE_LEVELS; i++) {
- if (ct->tiled_data[i]) {
- align_free(ct->tiled_data[i]);
+ /* Unreference the tiled image buffer.
+ * It may not actually be deleted until a fence is hit.
+ */
+ if (ct->tiled_buffer[i]) {
+ ct->tiled_mapped[i] = NULL;
+ winsys_buffer_reference(screen->winsys, &ct->tiled_buffer[i], NULL);
}
}
@@ -228,12 +235,18 @@ cell_twiddle_texture(struct pipe_screen *screen,
int offset = bufWidth * bufHeight * 4 * surface->face;
uint *dst;
- if (!ct->tiled_data[level]) {
- ct->tiled_data[level] =
- align_malloc(bufWidth * bufHeight * 4 * numFaces, 16);
+ if (!ct->tiled_buffer[level]) {
+ /* allocate buffer for tiled data now */
+ struct pipe_winsys *ws = screen->winsys;
+ uint bytes = bufWidth * bufHeight * 4 * numFaces;
+ ct->tiled_buffer[level] = ws->buffer_create(ws, 16,
+ PIPE_BUFFER_USAGE_PIXEL,
+ bytes);
+ /* and map it */
+ ct->tiled_mapped[level] = ws->buffer_map(ws, ct->tiled_buffer[level],
+ PIPE_BUFFER_USAGE_GPU_READ);
}
-
- dst = (uint *) ((ubyte *) ct->tiled_data[level] + offset);
+ dst = (uint *) ((ubyte *) ct->tiled_mapped[level] + offset);
twiddle_image_uint(texWidth, texHeight, TILE_SIZE, dst,
surface->stride, src);
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index a0757091b07..2f5fe0dd1b7 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -48,7 +48,10 @@ struct cell_texture
struct pipe_buffer *buffer;
unsigned long buffer_size;
- void *tiled_data[CELL_MAX_TEXTURE_LEVELS]; /* XXX this may be temporary */ /*ALIGN16*/
+ /** Texture data in tiled layout is held here */
+ struct pipe_buffer *tiled_buffer[CELL_MAX_TEXTURE_LEVELS];
+ /** Mapped, tiled texture data */
+ void *tiled_mapped[CELL_MAX_TEXTURE_LEVELS];
};
diff --git a/src/gallium/drivers/cell/ppu/cell_vbuf.c b/src/gallium/drivers/cell/ppu/cell_vbuf.c
index 578ddf62dcb..65ba51b6bb2 100644
--- a/src/gallium/drivers/cell/ppu/cell_vbuf.c
+++ b/src/gallium/drivers/cell/ppu/cell_vbuf.c
@@ -38,6 +38,7 @@
#include "cell_batch.h"
#include "cell_context.h"
+#include "cell_fence.h"
#include "cell_flush.h"
#include "cell_spu.h"
#include "cell_vbuf.h"
@@ -108,6 +109,11 @@ cell_vbuf_release_vertices(struct vbuf_render *vbr, void *vertices,
__FUNCTION__, cvbr->vertex_buf, vertices_used);
*/
+ /* Make sure texture buffers aren't released until we're done rendering
+ * with them.
+ */
+ cell_add_fenced_textures(cell);
+
/* Tell SPUs they can release the vert buf */
if (cvbr->vertex_buf != ~0U) {
struct cell_command_release_verts *release
@@ -214,7 +220,6 @@ cell_vbuf_draw(struct vbuf_render *vbr,
render->opcode = CELL_CMD_RENDER;
render->prim_type = cvbr->prim;
- render->front_winding = cell->rasterizer->front_winding;
render->num_indexes = nr_indices;
render->min_index = min_index;
diff --git a/src/gallium/drivers/cell/spu/spu_command.c b/src/gallium/drivers/cell/spu/spu_command.c
index c28677ebf87..a6ed29ea631 100644
--- a/src/gallium/drivers/cell/spu/spu_command.c
+++ b/src/gallium/drivers/cell/spu/spu_command.c
@@ -44,7 +44,6 @@
#include "spu_tile.h"
#include "spu_vertex_shader.h"
#include "spu_dcache.h"
-#include "spu_debug.h"
#include "cell/common.h"
@@ -77,9 +76,10 @@ static void
release_buffer(uint buffer)
{
/* Evidently, using less than a 16-byte status doesn't work reliably */
- static const uint status[4] ALIGN16_ATTRIB
- = {CELL_BUFFER_STATUS_FREE, 0, 0, 0};
-
+ static const vector unsigned int status = {CELL_BUFFER_STATUS_FREE,
+ CELL_BUFFER_STATUS_FREE,
+ CELL_BUFFER_STATUS_FREE,
+ CELL_BUFFER_STATUS_FREE};
const uint index = 4 * (spu.init.id * CELL_NUM_BUFFERS + buffer);
uint *dst = spu.init.buffer_status + index;
@@ -94,10 +94,33 @@ release_buffer(uint buffer)
}
+/**
+ * Write CELL_FENCE_SIGNALLED back to the fence status qword in main memory.
+ * There's a qword of status per SPU.
+ */
+static void
+cmd_fence(struct cell_command_fence *fence_cmd)
+{
+ static const vector unsigned int status = {CELL_FENCE_SIGNALLED,
+ CELL_FENCE_SIGNALLED,
+ CELL_FENCE_SIGNALLED,
+ CELL_FENCE_SIGNALLED};
+ uint *dst = (uint *) fence_cmd->fence;
+ dst += 4 * spu.init.id; /* main store/memory address, not local store */
+
+ mfc_put((void *) &status, /* src in local memory */
+ (unsigned int) dst, /* dst in main memory */
+ sizeof(status), /* size */
+ TAG_FENCE, /* tag */
+ 0, /* tid */
+ 0 /* rid */);
+}
+
+
static void
cmd_clear_surface(const struct cell_command_clear_surface *clear)
{
- DEBUG_PRINTF("CLEAR SURF %u to 0x%08x\n", clear->surface, clear->value);
+ D_PRINTF(CELL_DEBUG_CMD, "CLEAR SURF %u to 0x%08x\n", clear->surface, clear->value);
if (clear->surface == 0) {
spu.fb.color_clear_value = clear->value;
@@ -165,14 +188,14 @@ cmd_clear_surface(const struct cell_command_clear_surface *clear)
#endif /* CLEAR_OPT */
- DEBUG_PRINTF("CLEAR SURF done\n");
+ D_PRINTF(CELL_DEBUG_CMD, "CLEAR SURF done\n");
}
static void
cmd_release_verts(const struct cell_command_release_verts *release)
{
- DEBUG_PRINTF("RELEASE VERTS %u\n", release->vertex_buf);
+ D_PRINTF(CELL_DEBUG_CMD, "RELEASE VERTS %u\n", release->vertex_buf);
ASSERT(release->vertex_buf != ~0U);
release_buffer(release->vertex_buf);
}
@@ -189,12 +212,13 @@ cmd_state_fragment_ops(const struct cell_command_fragment_ops *fops)
{
static int warned = 0;
- DEBUG_PRINTF("CMD_STATE_FRAGMENT_OPS\n");
+ D_PRINTF(CELL_DEBUG_CMD, "CMD_STATE_FRAGMENT_OPS\n");
/* Copy SPU code from batch buffer to spu buffer */
memcpy(spu.fragment_ops_code, fops->code, SPU_MAX_FRAGMENT_OPS_INSTS * 4);
/* Copy state info (for fallback case only) */
memcpy(&spu.depth_stencil_alpha, &fops->dsa, sizeof(fops->dsa));
memcpy(&spu.blend, &fops->blend, sizeof(fops->blend));
+ memcpy(&spu.blend_color, &fops->blend_color, sizeof(fops->blend_color));
/* Parity twist! For now, always use the fallback code by default,
* only switching to codegen when specifically requested. This
@@ -228,7 +252,7 @@ cmd_state_fragment_ops(const struct cell_command_fragment_ops *fops)
static void
cmd_state_fragment_program(const struct cell_command_fragment_program *fp)
{
- DEBUG_PRINTF("CMD_STATE_FRAGMENT_PROGRAM\n");
+ D_PRINTF(CELL_DEBUG_CMD, "CMD_STATE_FRAGMENT_PROGRAM\n");
/* Copy SPU code from batch buffer to spu buffer */
memcpy(spu.fragment_program_code, fp->code,
SPU_MAX_FRAGMENT_PROGRAM_INSTS * 4);
@@ -246,10 +270,11 @@ cmd_state_fs_constants(const uint64_t *buffer, uint pos)
const float *constants = (const float *) &buffer[pos + 2];
uint i;
- DEBUG_PRINTF("CMD_STATE_FS_CONSTANTS (%u)\n", num_const);
+ D_PRINTF(CELL_DEBUG_CMD, "CMD_STATE_FS_CONSTANTS (%u)\n", num_const);
/* Expand each float to float[4] for SOA execution */
for (i = 0; i < num_const; i++) {
+ D_PRINTF(CELL_DEBUG_CMD, " const[%u] = %f\n", i, constants[i]);
spu.constants[i] = spu_splats(constants[i]);
}
@@ -261,7 +286,7 @@ cmd_state_fs_constants(const uint64_t *buffer, uint pos)
static void
cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
{
- DEBUG_PRINTF("FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n",
+ D_PRINTF(CELL_DEBUG_CMD, "FRAMEBUFFER: %d x %d at %p, cformat 0x%x zformat 0x%x\n",
cmd->width,
cmd->height,
cmd->color_start,
@@ -309,8 +334,7 @@ cmd_state_framebuffer(const struct cell_command_framebuffer *cmd)
*/
static void
update_tex_masks(struct spu_texture *texture,
- const struct pipe_sampler_state *sampler,
- uint unit)
+ const struct pipe_sampler_state *sampler)
{
uint i;
@@ -337,11 +361,6 @@ update_tex_masks(struct spu_texture *texture,
texture->level[i].scale_t = spu_splats(1.0f);
}
}
-
- /* XXX temporary hack */
- if (texture->target == PIPE_TEXTURE_CUBE) {
- spu.sample_texture4[unit] = sample_texture4_cube;
- }
}
@@ -350,18 +369,18 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
{
uint unit = sampler->unit;
- DEBUG_PRINTF("SAMPLER [%u]\n", unit);
+ D_PRINTF(CELL_DEBUG_CMD, "SAMPLER [%u]\n", unit);
spu.sampler[unit] = sampler->state;
switch (spu.sampler[unit].min_img_filter) {
case PIPE_TEX_FILTER_LINEAR:
- spu.min_sample_texture4[unit] = sample_texture4_bilinear;
+ spu.min_sample_texture_2d[unit] = sample_texture_2d_bilinear;
break;
case PIPE_TEX_FILTER_ANISO:
/* fall-through, for now */
case PIPE_TEX_FILTER_NEAREST:
- spu.min_sample_texture4[unit] = sample_texture4_nearest;
+ spu.min_sample_texture_2d[unit] = sample_texture_2d_nearest;
break;
default:
ASSERT(0);
@@ -369,12 +388,12 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
switch (spu.sampler[sampler->unit].mag_img_filter) {
case PIPE_TEX_FILTER_LINEAR:
- spu.mag_sample_texture4[unit] = sample_texture4_bilinear;
+ spu.mag_sample_texture_2d[unit] = sample_texture_2d_bilinear;
break;
case PIPE_TEX_FILTER_ANISO:
/* fall-through, for now */
case PIPE_TEX_FILTER_NEAREST:
- spu.mag_sample_texture4[unit] = sample_texture4_nearest;
+ spu.mag_sample_texture_2d[unit] = sample_texture_2d_nearest;
break;
default:
ASSERT(0);
@@ -383,16 +402,16 @@ cmd_state_sampler(const struct cell_command_sampler *sampler)
switch (spu.sampler[sampler->unit].min_mip_filter) {
case PIPE_TEX_MIPFILTER_NEAREST:
case PIPE_TEX_MIPFILTER_LINEAR:
- spu.sample_texture4[unit] = sample_texture4_lod;
+ spu.sample_texture_2d[unit] = sample_texture_2d_lod;
break;
case PIPE_TEX_MIPFILTER_NONE:
- spu.sample_texture4[unit] = spu.mag_sample_texture4[unit];
+ spu.sample_texture_2d[unit] = spu.mag_sample_texture_2d[unit];
break;
default:
ASSERT(0);
}
- update_tex_masks(&spu.texture[unit], &spu.sampler[unit], unit);
+ update_tex_masks(&spu.texture[unit], &spu.sampler[unit]);
}
@@ -402,9 +421,7 @@ cmd_state_texture(const struct cell_command_texture *texture)
const uint unit = texture->unit;
uint i;
- //if (spu.init.id==0) Debug=1;
-
- DEBUG_PRINTF("TEXTURE [%u]\n", texture->unit);
+ D_PRINTF(CELL_DEBUG_CMD, "TEXTURE [%u]\n", texture->unit);
spu.texture[unit].max_level = 0;
spu.texture[unit].target = texture->target;
@@ -414,7 +431,7 @@ cmd_state_texture(const struct cell_command_texture *texture)
uint height = texture->height[i];
uint depth = texture->depth[i];
- DEBUG_PRINTF(" LEVEL %u: at %p size[0] %u x %u\n", i,
+ D_PRINTF(CELL_DEBUG_CMD, " LEVEL %u: at %p size[0] %u x %u\n", i,
texture->start[i], texture->width[i], texture->height[i]);
spu.texture[unit].level[i].start = texture->start[i];
@@ -435,16 +452,14 @@ cmd_state_texture(const struct cell_command_texture *texture)
spu.texture[unit].max_level = i;
}
- update_tex_masks(&spu.texture[unit], &spu.sampler[unit], unit);
-
- //Debug=0;
+ update_tex_masks(&spu.texture[unit], &spu.sampler[unit]);
}
static void
cmd_state_vertex_info(const struct vertex_info *vinfo)
{
- DEBUG_PRINTF("VERTEX_INFO num_attribs=%u\n", vinfo->num_attribs);
+ D_PRINTF(CELL_DEBUG_CMD, "VERTEX_INFO num_attribs=%u\n", vinfo->num_attribs);
ASSERT(vinfo->num_attribs >= 1);
ASSERT(vinfo->num_attribs <= 8);
memcpy(&spu.vertex_info, vinfo, sizeof(*vinfo));
@@ -483,7 +498,7 @@ cmd_state_attrib_fetch(const struct cell_attribute_fetch_code *code)
static void
cmd_finish(void)
{
- DEBUG_PRINTF("FINISH\n");
+ D_PRINTF(CELL_DEBUG_CMD, "FINISH\n");
really_clear_tiles(0);
/* wait for all outstanding DMAs to finish */
mfc_write_tag_mask(~0);
@@ -508,7 +523,7 @@ cmd_batch(uint opcode)
const unsigned usize = size / sizeof(buffer[0]);
uint pos;
- DEBUG_PRINTF("BATCH buffer %u, len %u, from %p\n",
+ D_PRINTF(CELL_DEBUG_CMD, "BATCH buffer %u, len %u, from %p\n",
buf, size, spu.init.buffers[buf]);
ASSERT((opcode & CELL_CMD_OPCODE_MASK) == CELL_CMD_BATCH);
@@ -528,7 +543,7 @@ cmd_batch(uint opcode)
wait_on_mask(1 << TAG_BATCH_BUFFER);
/* Tell PPU we're done copying the buffer to local store */
- DEBUG_PRINTF("release batch buf %u\n", buf);
+ D_PRINTF(CELL_DEBUG_CMD, "release batch buf %u\n", buf);
release_buffer(buf);
/*
@@ -586,6 +601,14 @@ cmd_batch(uint opcode)
case CELL_CMD_STATE_FS_CONSTANTS:
pos = cmd_state_fs_constants(buffer, pos);
break;
+ case CELL_CMD_STATE_RASTERIZER:
+ {
+ struct cell_command_rasterizer *rast =
+ (struct cell_command_rasterizer *) &buffer[pos];
+ spu.rasterizer = rast->rasterizer;
+ pos += sizeof(*rast) / 8;
+ }
+ break;
case CELL_CMD_STATE_SAMPLER:
{
struct cell_command_sampler *sampler
@@ -638,6 +661,14 @@ cmd_batch(uint opcode)
cmd_finish();
pos += 1;
break;
+ case CELL_CMD_FENCE:
+ {
+ struct cell_command_fence *fence_cmd =
+ (struct cell_command_fence *) &buffer[pos];
+ cmd_fence(fence_cmd);
+ pos += sizeof(*fence_cmd) / 8;
+ }
+ break;
case CELL_CMD_RELEASE_VERTS:
{
struct cell_command_release_verts *release
@@ -661,10 +692,12 @@ cmd_batch(uint opcode)
}
}
- DEBUG_PRINTF("BATCH complete\n");
+ D_PRINTF(CELL_DEBUG_CMD, "BATCH complete\n");
}
+#define PERF 0
+
/**
* Main loop for SPEs: Get a command, execute it, repeat.
@@ -672,41 +705,29 @@ cmd_batch(uint opcode)
void
command_loop(void)
{
- struct cell_command cmd;
int exitFlag = 0;
+ uint t0, t1;
- DEBUG_PRINTF("Enter command loop\n");
-
- ASSERT((sizeof(struct cell_command) & 0xf) == 0);
- ASSERT_ALIGN16(&cmd);
+ D_PRINTF(CELL_DEBUG_CMD, "Enter command loop\n");
while (!exitFlag) {
unsigned opcode;
- int tag = 0;
- DEBUG_PRINTF("Wait for cmd...\n");
+ D_PRINTF(CELL_DEBUG_CMD, "Wait for cmd...\n");
+
+ if (PERF)
+ spu_write_decrementer(~0);
/* read/wait from mailbox */
opcode = (unsigned int) spu_read_in_mbox();
+ D_PRINTF(CELL_DEBUG_CMD, "got cmd 0x%x\n", opcode);
- DEBUG_PRINTF("got cmd 0x%x\n", opcode);
-
- /* command payload */
- mfc_get(&cmd, /* dest */
- (unsigned int) spu.init.cmd, /* src */
- sizeof(struct cell_command), /* bytes */
- tag,
- 0, /* tid */
- 0 /* rid */);
- wait_on_mask( 1 << tag );
-
- /*
- * NOTE: most commands should be contained in a batch buffer
- */
+ if (PERF)
+ t0 = spu_read_decrementer();
switch (opcode & CELL_CMD_OPCODE_MASK) {
case CELL_CMD_EXIT:
- DEBUG_PRINTF("EXIT\n");
+ D_PRINTF(CELL_DEBUG_CMD, "EXIT\n");
exitFlag = 1;
break;
case CELL_CMD_VS_EXECUTE:
@@ -721,9 +742,16 @@ command_loop(void)
printf("Bad opcode 0x%x!\n", opcode & CELL_CMD_OPCODE_MASK);
}
+ if (PERF) {
+ t1 = spu_read_decrementer();
+ printf("wait mbox time: %gms batch time: %gms\n",
+ (~0u - t0) * spu.init.inv_timebase,
+ (t0 - t1) * spu.init.inv_timebase);
+ }
}
- DEBUG_PRINTF("Exit command loop\n");
+ D_PRINTF(CELL_DEBUG_CMD, "Exit command loop\n");
- spu_dcache_report();
+ if (spu.init.debug_flags & CELL_DEBUG_CACHE)
+ spu_dcache_report();
}
diff --git a/src/gallium/drivers/cell/spu/spu_dcache.c b/src/gallium/drivers/cell/spu/spu_dcache.c
index 167404cdc54..a6d67634fd8 100644
--- a/src/gallium/drivers/cell/spu/spu_dcache.c
+++ b/src/gallium/drivers/cell/spu/spu_dcache.c
@@ -36,7 +36,9 @@
#define CACHE_SET_TAGID(set) (((set) & 0x03) + TAG_DCACHE0)
#define CACHE_LOG2NNWAY 2
#define CACHE_LOG2NSETS 6
-/*#define CACHE_STATS 1*/
+#ifdef DEBUG
+#define CACHE_STATS 1
+#endif
#include <cache-api.h>
/* Yes folks, this is ugly.
diff --git a/src/gallium/drivers/cell/spu/spu_funcs.c b/src/gallium/drivers/cell/spu/spu_funcs.c
index 5c3ee305d48..3534b35000d 100644
--- a/src/gallium/drivers/cell/spu/spu_funcs.c
+++ b/src/gallium/drivers/cell/spu/spu_funcs.c
@@ -43,6 +43,7 @@
#include "cell/common.h"
#include "spu_main.h"
#include "spu_funcs.h"
+#include "spu_texture.h"
/** For "return"-ing four vectors */
@@ -102,11 +103,34 @@ spu_log2(vector float x)
static struct vec_4x4
-spu_txp(vector float s, vector float t, vector float r, vector float q,
- unsigned unit)
+spu_tex_2d(vector float s, vector float t, vector float r, vector float q,
+ unsigned unit)
{
struct vec_4x4 colors;
- spu.sample_texture4[unit](s, t, r, q, unit, 0, 0, colors.v);
+ (void) r;
+ (void) q;
+ spu.sample_texture_2d[unit](s, t, unit, 0, 0, colors.v);
+ return colors;
+}
+
+static struct vec_4x4
+spu_tex_3d(vector float s, vector float t, vector float r, vector float q,
+ unsigned unit)
+{
+ struct vec_4x4 colors;
+ (void) r;
+ (void) q;
+ spu.sample_texture_2d[unit](s, t, unit, 0, 0, colors.v);
+ return colors;
+}
+
+static struct vec_4x4
+spu_tex_cube(vector float s, vector float t, vector float r, vector float q,
+ unsigned unit)
+{
+ struct vec_4x4 colors;
+ (void) q;
+ sample_texture_cube(s, t, r, unit, colors.v);
return colors;
}
@@ -147,7 +171,9 @@ return_function_info(void)
export_func(&funcs, "spu_pow", &spu_pow);
export_func(&funcs, "spu_exp2", &spu_exp2);
export_func(&funcs, "spu_log2", &spu_log2);
- export_func(&funcs, "spu_txp", &spu_txp);
+ export_func(&funcs, "spu_tex_2d", &spu_tex_2d);
+ export_func(&funcs, "spu_tex_3d", &spu_tex_3d);
+ export_func(&funcs, "spu_tex_cube", &spu_tex_cube);
/* Send the function info back to the PPU / main memory */
mfc_put((void *) &funcs, /* src in local store */
diff --git a/src/gallium/drivers/cell/spu/spu_main.c b/src/gallium/drivers/cell/spu/spu_main.c
index 4becd0f92a4..c8bb2519050 100644
--- a/src/gallium/drivers/cell/spu/spu_main.c
+++ b/src/gallium/drivers/cell/spu/spu_main.c
@@ -40,7 +40,6 @@
#include "spu_per_fragment_op.h"
#include "spu_texture.h"
//#include "spu_test.h"
-#include "spu_debug.h"
#include "cell/common.h"
@@ -53,12 +52,6 @@ helpful headers:
struct spu_global spu;
-#if DEBUG
-boolean Debug = FALSE;
-boolean force_fragment_ops_fallback = TRUE;
-#endif
-
-
static void
one_time_init(void)
{
@@ -102,7 +95,7 @@ main(main_param_t speid, main_param_t argp)
one_time_init();
- DEBUG_PRINTF("main() speid=%lu\n", (unsigned long) speid);
+ D_PRINTF(CELL_DEBUG_CMD, "main() speid=%lu\n", (unsigned long) speid);
D_PRINTF(CELL_DEBUG_FRAGMENT_OP_FALLBACK, "using fragment op fallback\n");
/* get initialization data */
diff --git a/src/gallium/drivers/cell/spu/spu_main.h b/src/gallium/drivers/cell/spu/spu_main.h
index eff43b870ca..668af10be25 100644
--- a/src/gallium/drivers/cell/spu/spu_main.h
+++ b/src/gallium/drivers/cell/spu/spu_main.h
@@ -36,12 +36,18 @@
#include "pipe/p_state.h"
-
-#define MAX_WIDTH 1024
-#define MAX_HEIGHT 1024
-
-
-#define CELL_MAX_CONSTANTS 32 /**< number of float[4] constants */
+#if DEBUG
+/* These debug macros use the unusual construction ", ##__VA_ARGS__"
+ * which expands to the expected comma + args if variadic arguments
+ * are supplied, but swallows the comma if there are no variadic
+ * arguments (which avoids syntax errors that would otherwise occur).
+ */
+#define D_PRINTF(flag, format,...) \
+ if (spu.init.debug_flags & (flag)) \
+ printf("SPU %u: " format, spu.init.id, ##__VA_ARGS__)
+#else
+#define D_PRINTF(...)
+#endif
/**
@@ -64,12 +70,10 @@ typedef union {
/** Function for sampling textures */
-typedef void (*spu_sample_texture4_func)(vector float s,
- vector float t,
- vector float r,
- vector float q,
- uint unit, uint level, uint face,
- vector float colors[4]);
+typedef void (*spu_sample_texture_2d_func)(vector float s,
+ vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4]);
/** Function for performing per-fragment ops */
@@ -85,9 +89,9 @@ typedef void (*spu_fragment_ops_func)(uint x, uint y,
uint facing);
/** Function for running fragment program */
-typedef void (*spu_fragment_program_func)(vector float *inputs,
- vector float *outputs,
- vector float *constants);
+typedef vector unsigned int (*spu_fragment_program_func)(vector float *inputs,
+ vector float *outputs,
+ vector float *constants);
struct spu_framebuffer
@@ -145,7 +149,9 @@ struct spu_global
struct spu_framebuffer fb;
struct pipe_depth_stencil_alpha_state depth_stencil_alpha;
struct pipe_blend_state blend;
+ struct pipe_blend_color blend_color;
struct pipe_sampler_state sampler[PIPE_MAX_SAMPLERS];
+ struct pipe_rasterizer_state rasterizer;
struct spu_texture texture[PIPE_MAX_SAMPLERS];
struct vertex_info vertex_info;
@@ -161,8 +167,8 @@ struct spu_global
ubyte cur_ctile_status, cur_ztile_status;
/** Status of all tiles in framebuffer */
- ubyte ctile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
- ubyte ztile_status[MAX_HEIGHT/TILE_SIZE][MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
+ ubyte ctile_status[CELL_MAX_HEIGHT/TILE_SIZE][CELL_MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
+ ubyte ztile_status[CELL_MAX_HEIGHT/TILE_SIZE][CELL_MAX_WIDTH/TILE_SIZE] ALIGN16_ATTRIB;
/** Current fragment ops machine code, at 8-byte boundary */
uint fragment_ops_code[SPU_MAX_FRAGMENT_OPS_INSTS] ALIGN8_ATTRIB;
@@ -175,9 +181,9 @@ struct spu_global
spu_fragment_program_func fragment_program;
/** Current texture sampler function */
- spu_sample_texture4_func sample_texture4[CELL_MAX_SAMPLERS];
- spu_sample_texture4_func min_sample_texture4[CELL_MAX_SAMPLERS];
- spu_sample_texture4_func mag_sample_texture4[CELL_MAX_SAMPLERS];
+ spu_sample_texture_2d_func sample_texture_2d[CELL_MAX_SAMPLERS];
+ spu_sample_texture_2d_func min_sample_texture_2d[CELL_MAX_SAMPLERS];
+ spu_sample_texture_2d_func mag_sample_texture_2d[CELL_MAX_SAMPLERS];
/** Fragment program constants */
vector float constants[4 * CELL_MAX_CONSTANTS];
@@ -186,8 +192,6 @@ struct spu_global
extern struct spu_global spu;
-extern boolean Debug;
-
@@ -206,7 +210,7 @@ extern boolean Debug;
#define TAG_DCACHE1 21
#define TAG_DCACHE2 22
#define TAG_DCACHE3 23
-
+#define TAG_FENCE 24
static INLINE void
diff --git a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
index d252fa6dc18..f8ffc704926 100644
--- a/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
+++ b/src/gallium/drivers/cell/spu/spu_per_fragment_op.c
@@ -40,6 +40,24 @@
#define LINEAR_QUAD_LAYOUT 1
+static INLINE vector float
+spu_min(vector float a, vector float b)
+{
+ vector unsigned int m;
+ m = spu_cmpgt(a, b); /* m = a > b ? ~0 : 0 */
+ return spu_sel(a, b, m);
+}
+
+
+static INLINE vector float
+spu_max(vector float a, vector float b)
+{
+ vector unsigned int m;
+ m = spu_cmpgt(a, b); /* m = a > b ? ~0 : 0 */
+ return spu_sel(b, a, m);
+}
+
+
/**
* Called by rasterizer for each quad after the shader has run. Do
* all the per-fragment operations including alpha test, z test,
@@ -242,7 +260,7 @@ spu_fallback_fragment_ops(uint x, uint y,
}
/*
- * Compute Src RGB terms
+ * Compute Src RGB terms (fragment color * factor)
*/
switch (spu.blend.rgb_src_factor) {
case PIPE_BLENDFACTOR_ONE:
@@ -265,13 +283,33 @@ spu_fallback_fragment_ops(uint x, uint y,
term1g = spu_mul(fragG, fragA);
term1b = spu_mul(fragB, fragA);
break;
+ case PIPE_BLENDFACTOR_DST_COLOR:
+ term1r = spu_mul(fragR, fbRGBA[0]);
+ term1g = spu_mul(fragG, fbRGBA[1]);
+ term1b = spu_mul(fragB, fbRGBA[1]);
+ break;
+ case PIPE_BLENDFACTOR_DST_ALPHA:
+ term1r = spu_mul(fragR, fbRGBA[3]);
+ term1g = spu_mul(fragG, fbRGBA[3]);
+ term1b = spu_mul(fragB, fbRGBA[3]);
+ break;
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ term1r = spu_mul(fragR, spu_splats(spu.blend_color.color[0]));
+ term1g = spu_mul(fragG, spu_splats(spu.blend_color.color[1]));
+ term1b = spu_mul(fragB, spu_splats(spu.blend_color.color[2]));
+ break;
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ term1r = spu_mul(fragR, spu_splats(spu.blend_color.color[3]));
+ term1g = spu_mul(fragG, spu_splats(spu.blend_color.color[3]));
+ term1b = spu_mul(fragB, spu_splats(spu.blend_color.color[3]));
+ break;
/* XXX more cases */
default:
ASSERT(0);
}
/*
- * Compute Src Alpha term
+ * Compute Src Alpha term (fragment alpha * factor)
*/
switch (spu.blend.alpha_src_factor) {
case PIPE_BLENDFACTOR_ONE:
@@ -283,19 +321,29 @@ spu_fallback_fragment_ops(uint x, uint y,
case PIPE_BLENDFACTOR_SRC_ALPHA:
term1a = spu_mul(fragA, fragA);
break;
+ case PIPE_BLENDFACTOR_DST_COLOR:
+ /* fall-through */
+ case PIPE_BLENDFACTOR_DST_ALPHA:
+ term1a = spu_mul(fragA, fbRGBA[3]);
+ break;
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ /* fall-through */
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ term1a = spu_mul(fragR, spu_splats(spu.blend_color.color[3]));
+ break;
/* XXX more cases */
default:
ASSERT(0);
}
/*
- * Compute Dest RGB terms
+ * Compute Dest RGB terms (framebuffer color * factor)
*/
switch (spu.blend.rgb_dst_factor) {
case PIPE_BLENDFACTOR_ONE:
- term2r = fragR;
- term2g = fragG;
- term2b = fragB;
+ term2r = fbRGBA[0];
+ term2g = fbRGBA[1];
+ term2b = fbRGBA[2];
break;
case PIPE_BLENDFACTOR_ZERO:
term2r =
@@ -319,17 +367,37 @@ spu_fallback_fragment_ops(uint x, uint y,
term2g = spu_mul(fbRGBA[1], tmp);
term2b = spu_mul(fbRGBA[2], tmp);
break;
- /* XXX more cases */
+ case PIPE_BLENDFACTOR_DST_COLOR:
+ term2r = spu_mul(fbRGBA[0], fbRGBA[0]);
+ term2g = spu_mul(fbRGBA[1], fbRGBA[1]);
+ term2b = spu_mul(fbRGBA[2], fbRGBA[2]);
+ break;
+ case PIPE_BLENDFACTOR_DST_ALPHA:
+ term2r = spu_mul(fbRGBA[0], fbRGBA[3]);
+ term2g = spu_mul(fbRGBA[1], fbRGBA[3]);
+ term2b = spu_mul(fbRGBA[2], fbRGBA[3]);
+ break;
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ term2r = spu_mul(fbRGBA[0], spu_splats(spu.blend_color.color[0]));
+ term2g = spu_mul(fbRGBA[1], spu_splats(spu.blend_color.color[1]));
+ term2b = spu_mul(fbRGBA[2], spu_splats(spu.blend_color.color[2]));
+ break;
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ term2r = spu_mul(fbRGBA[0], spu_splats(spu.blend_color.color[3]));
+ term2g = spu_mul(fbRGBA[1], spu_splats(spu.blend_color.color[3]));
+ term2b = spu_mul(fbRGBA[2], spu_splats(spu.blend_color.color[3]));
+ break;
+ /* XXX more cases */
default:
ASSERT(0);
}
/*
- * Compute Dest Alpha term
+ * Compute Dest Alpha term (framebuffer alpha * factor)
*/
switch (spu.blend.alpha_dst_factor) {
case PIPE_BLENDFACTOR_ONE:
- term2a = fragA;
+ term2a = fbRGBA[3];
break;
case PIPE_BLENDFACTOR_SRC_COLOR:
term2a = spu_splats(0.0f);
@@ -342,6 +410,16 @@ spu_fallback_fragment_ops(uint x, uint y,
tmp = spu_sub(one, fragA);
term2a = spu_mul(fbRGBA[3], tmp);
break;
+ case PIPE_BLENDFACTOR_DST_COLOR:
+ /* fall-through */
+ case PIPE_BLENDFACTOR_DST_ALPHA:
+ term2a = spu_mul(fbRGBA[3], fbRGBA[3]);
+ break;
+ case PIPE_BLENDFACTOR_CONST_COLOR:
+ /* fall-through */
+ case PIPE_BLENDFACTOR_CONST_ALPHA:
+ term2a = spu_mul(fbRGBA[3], spu_splats(spu.blend_color.color[3]));
+ break;
/* XXX more cases */
default:
ASSERT(0);
@@ -361,7 +439,21 @@ spu_fallback_fragment_ops(uint x, uint y,
fragG = spu_sub(term1g, term2g);
fragB = spu_sub(term1b, term2b);
break;
- /* XXX more cases */
+ case PIPE_BLEND_REVERSE_SUBTRACT:
+ fragR = spu_sub(term2r, term1r);
+ fragG = spu_sub(term2g, term1g);
+ fragB = spu_sub(term2b, term1b);
+ break;
+ case PIPE_BLEND_MIN:
+ fragR = spu_min(term1r, term2r);
+ fragG = spu_min(term1g, term2g);
+ fragB = spu_min(term1b, term2b);
+ break;
+ case PIPE_BLEND_MAX:
+ fragR = spu_max(term1r, term2r);
+ fragG = spu_max(term1g, term2g);
+ fragB = spu_max(term1b, term2b);
+ break;
default:
ASSERT(0);
}
@@ -376,7 +468,15 @@ spu_fallback_fragment_ops(uint x, uint y,
case PIPE_BLEND_SUBTRACT:
fragA = spu_sub(term1a, term2a);
break;
- /* XXX more cases */
+ case PIPE_BLEND_REVERSE_SUBTRACT:
+ fragA = spu_sub(term2a, term1a);
+ break;
+ case PIPE_BLEND_MIN:
+ fragA = spu_min(term1a, term2a);
+ break;
+ case PIPE_BLEND_MAX:
+ fragA = spu_max(term1a, term2a);
+ break;
default:
ASSERT(0);
}
diff --git a/src/gallium/drivers/cell/spu/spu_render.c b/src/gallium/drivers/cell/spu/spu_render.c
index 82dbeb26b76..5515bb55c95 100644
--- a/src/gallium/drivers/cell/spu/spu_render.c
+++ b/src/gallium/drivers/cell/spu/spu_render.c
@@ -175,22 +175,14 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
const ubyte *vertices;
const ushort *indexes;
uint i, j;
+ uint num_tiles;
-
- if (Debug) {
- printf("SPU %u: RENDER prim %u, num_vert=%u num_ind=%u "
- "inline_vert=%u\n",
- spu.init.id,
- render->prim_type,
- render->num_verts,
- render->num_indexes,
- render->inline_verts);
-
- /*
- printf(" bound: %g, %g .. %g, %g\n",
- render->xmin, render->ymin, render->xmax, render->ymax);
- */
- }
+ D_PRINTF(CELL_DEBUG_CMD,
+ "RENDER prim=%u num_vert=%u num_ind=%u inline_vert=%u\n",
+ render->prim_type,
+ render->num_verts,
+ render->num_indexes,
+ render->inline_verts);
ASSERT(sizeof(*render) % 4 == 0);
ASSERT(total_vertex_bytes % 16 == 0);
@@ -251,6 +243,8 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
wait_on_mask(1 << TAG_SURFACE_CLEAR); /* XXX temporary */
+ num_tiles = 0;
+
/**
** loop over tiles, rendering tris
**/
@@ -264,6 +258,8 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
if (!my_tile(tx, ty))
continue;
+ num_tiles++;
+
spu.cur_ctile_status = spu.ctile_status[ty][tx];
spu.cur_ztile_status = spu.ztile_status[ty][tx];
@@ -279,7 +275,7 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
v1 = (const float *) (vertices + indexes[j+1] * vertex_size);
v2 = (const float *) (vertices + indexes[j+2] * vertex_size);
- drawn += tri_draw(v0, v1, v2, tx, ty, render->front_winding);
+ drawn += tri_draw(v0, v1, v2, tx, ty);
}
//printf("SPU %u: drew %u of %u\n", spu.init.id, drawn, render->num_indexes/3);
@@ -293,7 +289,7 @@ cmd_render(const struct cell_command_render *render, uint *pos_incr)
spu.ztile_status[ty][tx] = spu.cur_ztile_status;
}
- if (Debug)
- printf("SPU %u: RENDER done\n",
- spu.init.id);
+ D_PRINTF(CELL_DEBUG_CMD,
+ "RENDER done (%u tiles hit)\n",
+ num_tiles);
}
diff --git a/src/gallium/drivers/cell/spu/spu_texture.c b/src/gallium/drivers/cell/spu/spu_texture.c
index 42eb06a3625..69784c89788 100644
--- a/src/gallium/drivers/cell/spu/spu_texture.c
+++ b/src/gallium/drivers/cell/spu/spu_texture.c
@@ -72,10 +72,10 @@ invalidate_tex_cache(void)
* a time.
*/
static void
-get_four_texels(uint unit, uint level, uint face, vec_int4 x, vec_int4 y,
+get_four_texels(const struct spu_texture_level *tlevel, uint face,
+ vec_int4 x, vec_int4 y,
vec_uint4 *texels)
{
- const struct spu_texture_level *tlevel = &spu.texture[unit].level[level];
unsigned texture_ea = (uintptr_t) tlevel->start;
const vec_int4 tile_x = spu_rlmask(x, -5); /* tile_x = x / 32 */
const vec_int4 tile_y = spu_rlmask(y, -5); /* tile_y = y / 32 */
@@ -126,10 +126,9 @@ spu_clamp(vector signed int vec, vector signed int max)
* \param colors returned colors in SOA format (rrrr, gggg, bbbb, aaaa).
*/
void
-sample_texture4_nearest(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4])
+sample_texture_2d_nearest(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4])
{
const struct spu_texture_level *tlevel = &spu.texture[unit].level[level];
vector float ss = spu_mul(s, tlevel->scale_s);
@@ -146,7 +145,7 @@ sample_texture4_nearest(vector float s, vector float t,
is = spu_clamp(is, tlevel->max_s);
it = spu_clamp(it, tlevel->max_t);
- get_four_texels(unit, level, face, is, it, texels);
+ get_four_texels(tlevel, face, is, it, texels);
/* convert four packed ARGBA pixels to float RRRR,GGGG,BBBB,AAAA */
spu_unpack_A8R8G8B8_transpose4(texels, colors);
@@ -158,10 +157,9 @@ sample_texture4_nearest(vector float s, vector float t,
* \param colors returned colors in SOA format (rrrr, gggg, bbbb, aaaa).
*/
void
-sample_texture4_bilinear(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4])
+sample_texture_2d_bilinear(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4])
{
const struct spu_texture_level *tlevel = &spu.texture[unit].level[level];
static const vector float half = {-0.5f, -0.5f, -0.5f, -0.5f};
@@ -190,14 +188,10 @@ sample_texture4_bilinear(vector float s, vector float t,
/* get packed int texels */
vector unsigned int texels[16];
- get_four_texels(unit, level, face, is0, it0, texels + 0); /* upper-left */
- get_four_texels(unit, level, face, is1, it0, texels + 4); /* upper-right */
- get_four_texels(unit, level, face, is0, it1, texels + 8); /* lower-left */
- get_four_texels(unit, level, face, is1, it1, texels + 12); /* lower-right */
-
- /* XXX possibly rework following code to compute the weighted sample
- * colors with integer arithmetic for fewer int->float conversions.
- */
+ get_four_texels(tlevel, face, is0, it0, texels + 0); /* upper-left */
+ get_four_texels(tlevel, face, is1, it0, texels + 4); /* upper-right */
+ get_four_texels(tlevel, face, is0, it1, texels + 8); /* lower-left */
+ get_four_texels(tlevel, face, is1, it1, texels + 12); /* lower-right */
/* convert packed int texels to float colors */
vector float ftexels[16];
@@ -305,13 +299,13 @@ transpose(vector unsigned int *mOut0,
/**
- * Bilinear filtering, using int intead of float arithmetic
+ * Bilinear filtering, using int instead of float arithmetic for computing
+ * sample weights.
*/
void
-sample_texture4_bilinear_2(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4])
+sample_texture_2d_bilinear_int(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4])
{
const struct spu_texture_level *tlevel = &spu.texture[unit].level[level];
static const vector float half = {-0.5f, -0.5f, -0.5f, -0.5f};
@@ -320,19 +314,19 @@ sample_texture4_bilinear_2(vector float s, vector float t,
vector float ss = spu_madd(s, tlevel->scale_s, half);
vector float tt = spu_madd(t, tlevel->scale_t, half);
- /* convert float coords to fixed-pt coords with 8 fraction bits */
- vector signed int is = spu_convts(ss, 8);
- vector signed int it = spu_convts(tt, 8);
+ /* convert float coords to fixed-pt coords with 7 fraction bits */
+ vector signed int is = spu_convts(ss, 7); /* XXX really need floor() here */
+ vector signed int it = spu_convts(tt, 7); /* XXX really need floor() here */
- /* compute integer texel weights in [0, 255] */
- vector signed int sWeights0 = spu_and(is, 255);
- vector signed int tWeights0 = spu_and(it, 255);
- vector signed int sWeights1 = spu_sub(255, sWeights0);
- vector signed int tWeights1 = spu_sub(255, tWeights0);
+ /* compute integer texel weights in [0, 127] */
+ vector signed int sWeights0 = spu_and(is, 127);
+ vector signed int tWeights0 = spu_and(it, 127);
+ vector signed int sWeights1 = spu_sub(127, sWeights0);
+ vector signed int tWeights1 = spu_sub(127, tWeights0);
- /* texel coords: is0 = is / 256, it0 = is / 256 */
- vector signed int is0 = spu_rlmask(is, -8);
- vector signed int it0 = spu_rlmask(it, -8);
+ /* texel coords: is0 = is / 128, it0 = is / 128 */
+ vector signed int is0 = spu_rlmask(is, -7);
+ vector signed int it0 = spu_rlmask(it, -7);
/* texel coords: i1 = is0 + 1, it1 = it0 + 1 */
vector signed int is1 = spu_add(is0, 1);
@@ -352,10 +346,10 @@ sample_texture4_bilinear_2(vector float s, vector float t,
/* get packed int texels */
vector unsigned int texels[16];
- get_four_texels(unit, level, face, is0, it0, texels + 0); /* upper-left */
- get_four_texels(unit, level, face, is1, it0, texels + 4); /* upper-right */
- get_four_texels(unit, level, face, is0, it1, texels + 8); /* lower-left */
- get_four_texels(unit, level, face, is1, it1, texels + 12); /* lower-right */
+ get_four_texels(tlevel, face, is0, it0, texels + 0); /* upper-left */
+ get_four_texels(tlevel, face, is1, it0, texels + 4); /* upper-right */
+ get_four_texels(tlevel, face, is0, it1, texels + 8); /* lower-left */
+ get_four_texels(tlevel, face, is1, it1, texels + 12); /* lower-right */
/* twiddle packed 32-bit BGRA pixels into RGBA as four unsigned ints */
{
@@ -383,36 +377,36 @@ sample_texture4_bilinear_2(vector float s, vector float t,
vector unsigned int c0, c1, c2, c3, cSum;
/* red */
- c0 = (vector unsigned int) si_mpyu((qword) texel0, si_mpyu((qword) sWeights1, (qword) tWeights1)); /*ul*/
- c1 = (vector unsigned int) si_mpyu((qword) texel4, si_mpyu((qword) sWeights0, (qword) tWeights1)); /*ur*/
- c2 = (vector unsigned int) si_mpyu((qword) texel8, si_mpyu((qword) sWeights1, (qword) tWeights0)); /*ll*/
- c3 = (vector unsigned int) si_mpyu((qword) texel12, si_mpyu((qword) sWeights0, (qword) tWeights0)); /*lr*/
+ c0 = (vector unsigned int) si_mpy((qword) texel0, si_mpy((qword) sWeights1, (qword) tWeights1)); /*ul*/
+ c1 = (vector unsigned int) si_mpy((qword) texel4, si_mpy((qword) sWeights0, (qword) tWeights1)); /*ur*/
+ c2 = (vector unsigned int) si_mpy((qword) texel8, si_mpy((qword) sWeights1, (qword) tWeights0)); /*ll*/
+ c3 = (vector unsigned int) si_mpy((qword) texel12, si_mpy((qword) sWeights0, (qword) tWeights0)); /*lr*/
cSum = spu_add(spu_add(c0, c1), spu_add(c2, c3));
- colors[0] = spu_convtf(cSum, 24);
+ colors[0] = spu_convtf(cSum, 22);
/* green */
- c0 = (vector unsigned int) si_mpyu((qword) texel1, si_mpyu((qword) sWeights1, (qword) tWeights1)); /*ul*/
- c1 = (vector unsigned int) si_mpyu((qword) texel5, si_mpyu((qword) sWeights0, (qword) tWeights1)); /*ur*/
- c2 = (vector unsigned int) si_mpyu((qword) texel9, si_mpyu((qword) sWeights1, (qword) tWeights0)); /*ll*/
- c3 = (vector unsigned int) si_mpyu((qword) texel13, si_mpyu((qword) sWeights0, (qword) tWeights0)); /*lr*/
+ c0 = (vector unsigned int) si_mpy((qword) texel1, si_mpy((qword) sWeights1, (qword) tWeights1)); /*ul*/
+ c1 = (vector unsigned int) si_mpy((qword) texel5, si_mpy((qword) sWeights0, (qword) tWeights1)); /*ur*/
+ c2 = (vector unsigned int) si_mpy((qword) texel9, si_mpy((qword) sWeights1, (qword) tWeights0)); /*ll*/
+ c3 = (vector unsigned int) si_mpy((qword) texel13, si_mpy((qword) sWeights0, (qword) tWeights0)); /*lr*/
cSum = spu_add(spu_add(c0, c1), spu_add(c2, c3));
- colors[1] = spu_convtf(cSum, 24);
+ colors[1] = spu_convtf(cSum, 22);
/* blue */
- c0 = (vector unsigned int) si_mpyu((qword) texel2, si_mpyu((qword) sWeights1, (qword) tWeights1)); /*ul*/
- c1 = (vector unsigned int) si_mpyu((qword) texel6, si_mpyu((qword) sWeights0, (qword) tWeights1)); /*ur*/
- c2 = (vector unsigned int) si_mpyu((qword) texel10, si_mpyu((qword) sWeights1, (qword) tWeights0)); /*ll*/
- c3 = (vector unsigned int) si_mpyu((qword) texel14, si_mpyu((qword) sWeights0, (qword) tWeights0)); /*lr*/
+ c0 = (vector unsigned int) si_mpy((qword) texel2, si_mpy((qword) sWeights1, (qword) tWeights1)); /*ul*/
+ c1 = (vector unsigned int) si_mpy((qword) texel6, si_mpy((qword) sWeights0, (qword) tWeights1)); /*ur*/
+ c2 = (vector unsigned int) si_mpy((qword) texel10, si_mpy((qword) sWeights1, (qword) tWeights0)); /*ll*/
+ c3 = (vector unsigned int) si_mpy((qword) texel14, si_mpy((qword) sWeights0, (qword) tWeights0)); /*lr*/
cSum = spu_add(spu_add(c0, c1), spu_add(c2, c3));
- colors[2] = spu_convtf(cSum, 24);
+ colors[2] = spu_convtf(cSum, 22);
/* alpha */
- c0 = (vector unsigned int) si_mpyu((qword) texel3, si_mpyu((qword) sWeights1, (qword) tWeights1)); /*ul*/
- c1 = (vector unsigned int) si_mpyu((qword) texel7, si_mpyu((qword) sWeights0, (qword) tWeights1)); /*ur*/
- c2 = (vector unsigned int) si_mpyu((qword) texel11, si_mpyu((qword) sWeights1, (qword) tWeights0)); /*ll*/
- c3 = (vector unsigned int) si_mpyu((qword) texel15, si_mpyu((qword) sWeights0, (qword) tWeights0)); /*lr*/
+ c0 = (vector unsigned int) si_mpy((qword) texel3, si_mpy((qword) sWeights1, (qword) tWeights1)); /*ul*/
+ c1 = (vector unsigned int) si_mpy((qword) texel7, si_mpy((qword) sWeights0, (qword) tWeights1)); /*ur*/
+ c2 = (vector unsigned int) si_mpy((qword) texel11, si_mpy((qword) sWeights1, (qword) tWeights0)); /*ll*/
+ c3 = (vector unsigned int) si_mpy((qword) texel15, si_mpy((qword) sWeights0, (qword) tWeights0)); /*lr*/
cSum = spu_add(spu_add(c0, c1), spu_add(c2, c3));
- colors[3] = spu_convtf(cSum, 24);
+ colors[3] = spu_convtf(cSum, 22);
}
@@ -420,8 +414,8 @@ sample_texture4_bilinear_2(vector float s, vector float t,
/**
* Compute level of detail factor from texcoords.
*/
-static float
-compute_lambda(uint unit, vector float s, vector float t)
+static INLINE float
+compute_lambda_2d(uint unit, vector float s, vector float t)
{
uint baseLevel = 0;
float width = spu.texture[unit].level[baseLevel].width;
@@ -430,30 +424,60 @@ compute_lambda(uint unit, vector float s, vector float t)
float dsdy = width * (spu_extract(s, 2) - spu_extract(s, 0));
float dtdx = height * (spu_extract(t, 1) - spu_extract(t, 0));
float dtdy = height * (spu_extract(t, 2) - spu_extract(t, 0));
+#if 0
+ /* ideal value */
float x = dsdx * dsdx + dtdx * dtdx;
float y = dsdy * dsdy + dtdy * dtdy;
float rho = x > y ? x : y;
rho = sqrtf(rho);
- float lambda = logf(rho) * 1.442695f;
+#else
+ /* approximation */
+ dsdx = fabsf(dsdx);
+ dsdy = fabsf(dsdy);
+ dtdx = fabsf(dtdx);
+ dtdy = fabsf(dtdy);
+ float rho = (dsdx + dsdy + dtdx + dtdy) * 0.5;
+#endif
+ float lambda = logf(rho) * 1.442695f; /* compute logbase2(rho) */
return lambda;
}
+/**
+ * Blend two sets of colors according to weight.
+ */
+static void
+blend_colors(vector float c0[4], const vector float c1[4], float weight)
+{
+ vector float t = spu_splats(weight);
+ vector float dc0 = spu_sub(c1[0], c0[0]);
+ vector float dc1 = spu_sub(c1[1], c0[1]);
+ vector float dc2 = spu_sub(c1[2], c0[2]);
+ vector float dc3 = spu_sub(c1[3], c0[3]);
+ c0[0] = spu_madd(dc0, t, c0[0]);
+ c0[1] = spu_madd(dc1, t, c0[1]);
+ c0[2] = spu_madd(dc2, t, c0[2]);
+ c0[3] = spu_madd(dc3, t, c0[3]);
+}
+
/**
- * Texture sampling with level of detail selection.
+ * Texture sampling with level of detail selection and possibly mipmap
+ * interpolation.
*/
void
-sample_texture4_lod(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level_ignored, uint face,
- vector float colors[4])
+sample_texture_2d_lod(vector float s, vector float t,
+ uint unit, uint level_ignored, uint face,
+ vector float colors[4])
{
/*
* Note that we're computing a lambda/lod here that's used for all
* four pixels in the quad.
*/
- float lambda = compute_lambda(unit, s, t);
+ float lambda = compute_lambda_2d(unit, s, t);
+
+ (void) face;
+ (void) level_ignored;
/* apply lod bias */
lambda += spu.sampler[unit].lod_bias;
@@ -466,15 +490,34 @@ sample_texture4_lod(vector float s, vector float t,
if (lambda <= 0.0f) {
/* magnify */
- spu.mag_sample_texture4[unit](s, t, r, q, unit, 0, 0, colors);
+ spu.mag_sample_texture_2d[unit](s, t, unit, 0, face, colors);
}
else {
/* minify */
- int level = (int) (lambda + 0.5f);
- if (level > (int) spu.texture[unit].max_level)
- level = spu.texture[unit].max_level;
- spu.min_sample_texture4[unit](s, t, r, q, unit, level, 0, colors);
- /* XXX to do: mipmap level interpolation */
+ if (spu.sampler[unit].min_img_filter == PIPE_TEX_FILTER_LINEAR) {
+ /* sample two mipmap levels and interpolate */
+ int level = (int) lambda;
+ if (level > (int) spu.texture[unit].max_level)
+ level = spu.texture[unit].max_level;
+ spu.min_sample_texture_2d[unit](s, t, unit, level, face, colors);
+ if (spu.sampler[unit].min_img_filter == PIPE_TEX_FILTER_LINEAR) {
+ /* sample second mipmap level */
+ float weight = lambda - (float) level;
+ level++;
+ if (level <= (int) spu.texture[unit].max_level) {
+ vector float colors2[4];
+ spu.min_sample_texture_2d[unit](s, t, unit, level, face, colors2);
+ blend_colors(colors, colors2, weight);
+ }
+ }
+ }
+ else {
+ /* sample one mipmap level */
+ int level = (int) (lambda + 0.5f);
+ if (level > (int) spu.texture[unit].max_level)
+ level = spu.texture[unit].max_level;
+ spu.min_sample_texture_2d[unit](s, t, unit, level, face, colors);
+ }
}
}
@@ -552,16 +595,13 @@ choose_cube_face(float rx, float ry, float rz, float *newS, float *newT)
void
-sample_texture4_cube(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face_ignored,
- vector float colors[4])
+sample_texture_cube(vector float s, vector float t, vector float r,
+ uint unit, vector float colors[4])
{
- static const vector float zero = {0.0f, 0.0f, 0.0f, 0.0f};
- uint p, faces[4];
+ uint p, faces[4], level = 0;
float newS[4], newT[4];
- /* Compute cube face referenced by the four sets of texcoords.
+ /* Compute cube faces referenced by the four sets of texcoords.
* XXX we should SIMD-ize this.
*/
for (p = 0; p < 4; p++) {
@@ -577,15 +617,15 @@ sample_texture4_cube(vector float s, vector float t,
/* GOOD! All four texcoords refer to the same cube face */
s = (vector float) {newS[0], newS[1], newS[2], newS[3]};
t = (vector float) {newT[0], newT[1], newT[2], newT[3]};
- sample_texture4_nearest(s, t, zero, zero, unit, level, faces[0], colors);
+ spu.sample_texture_2d[unit](s, t, unit, level, faces[0], colors);
}
else {
/* BAD! The four texcoords refer to different faces */
for (p = 0; p < 4; p++) {
vector float c[4];
- sample_texture4_nearest(spu_splats(newS[p]), spu_splats(newT[p]),
- zero, zero, unit, level, faces[p], c);
+ spu.sample_texture_2d[unit](spu_splats(newS[p]), spu_splats(newT[p]),
+ unit, level, faces[p], c);
float red = spu_extract(c[0], p);
float green = spu_extract(c[1], p);
diff --git a/src/gallium/drivers/cell/spu/spu_texture.h b/src/gallium/drivers/cell/spu/spu_texture.h
index 387484c3ad3..7b75b007b5a 100644
--- a/src/gallium/drivers/cell/spu/spu_texture.h
+++ b/src/gallium/drivers/cell/spu/spu_texture.h
@@ -37,37 +37,31 @@ invalidate_tex_cache(void);
extern void
-sample_texture4_nearest(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4]);
+sample_texture_2d_nearest(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4]);
extern void
-sample_texture4_bilinear(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4]);
-
-extern void
-sample_texture4_bilinear_2(vector float s, vector float t,
- vector float r, vector float q,
+sample_texture_2d_bilinear(vector float s, vector float t,
uint unit, uint level, uint face,
vector float colors[4]);
+extern void
+sample_texture_2d_bilinear_int(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4]);
+
extern void
-sample_texture4_lod(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level, uint face,
- vector float colors[4]);
+sample_texture_2d_lod(vector float s, vector float t,
+ uint unit, uint level, uint face,
+ vector float colors[4]);
extern void
-sample_texture4_cube(vector float s, vector float t,
- vector float r, vector float q,
- uint unit, uint level_ignored, uint face_ignored,
- vector float colors[4]);
+sample_texture_cube(vector float s, vector float t, vector float r,
+ uint unit, vector float colors[4]);
#endif /* SPU_TEXTURE_H */
diff --git a/src/gallium/drivers/cell/spu/spu_tri.c b/src/gallium/drivers/cell/spu/spu_tri.c
index 03f094373df..4caf7d6b613 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.c
+++ b/src/gallium/drivers/cell/spu/spu_tri.c
@@ -43,11 +43,6 @@
/** Masks are uint[4] vectors with each element being 0 or 0xffffffff */
typedef vector unsigned int mask_t;
-typedef union
-{
- vector float v;
- float f[4];
-} float4;
/**
@@ -91,9 +86,9 @@ struct edge {
struct interp_coef
{
- float4 a0;
- float4 dadx;
- float4 dady;
+ vector float a0;
+ vector float dadx;
+ vector float dady;
};
@@ -116,7 +111,7 @@ struct setup_stage {
struct edge etop;
struct edge emaj;
- float oneOverArea;
+ float oneOverArea; /* XXX maybe make into vector? */
uint facing;
@@ -152,14 +147,14 @@ eval_coeff(uint slot, float x, float y, vector float w, vector float result[4])
result[QUAD_TOP_LEFT] =
result[QUAD_TOP_RIGHT] =
result[QUAD_BOTTOM_LEFT] =
- result[QUAD_BOTTOM_RIGHT] = setup.coef[slot].a0.v;
+ result[QUAD_BOTTOM_RIGHT] = setup.coef[slot].a0;
break;
case INTERP_LINEAR:
{
- vector float dadx = setup.coef[slot].dadx.v;
- vector float dady = setup.coef[slot].dady.v;
+ vector float dadx = setup.coef[slot].dadx;
+ vector float dady = setup.coef[slot].dady;
vector float topLeft =
- spu_add(setup.coef[slot].a0.v,
+ spu_add(setup.coef[slot].a0,
spu_add(spu_mul(spu_splats(x), dadx),
spu_mul(spu_splats(y), dady)));
@@ -171,10 +166,10 @@ eval_coeff(uint slot, float x, float y, vector float w, vector float result[4])
break;
case INTERP_PERSPECTIVE:
{
- vector float dadx = setup.coef[slot].dadx.v;
- vector float dady = setup.coef[slot].dady.v;
+ vector float dadx = setup.coef[slot].dadx;
+ vector float dady = setup.coef[slot].dady;
vector float topLeft =
- spu_add(setup.coef[slot].a0.v,
+ spu_add(setup.coef[slot].a0,
spu_add(spu_mul(spu_splats(x), dadx),
spu_mul(spu_splats(y), dady)));
@@ -212,9 +207,9 @@ static INLINE vector float
eval_z(float x, float y)
{
const uint slot = 0;
- const float dzdx = setup.coef[slot].dadx.f[2];
- const float dzdy = setup.coef[slot].dady.f[2];
- const float topLeft = setup.coef[slot].a0.f[2] + x * dzdx + y * dzdy;
+ const float dzdx = spu_extract(setup.coef[slot].dadx, 2);
+ const float dzdy = spu_extract(setup.coef[slot].dady, 2);
+ const float topLeft = spu_extract(setup.coef[slot].a0, 2) + x * dzdx + y * dzdy;
const vector float topLeftv = spu_splats(topLeft);
const vector float derivs = (vector float) { 0.0, dzdx, dzdy, dzdx + dzdy };
return spu_add(topLeftv, derivs);
@@ -226,9 +221,9 @@ static INLINE vector float
eval_w(float x, float y)
{
const uint slot = 0;
- const float dwdx = setup.coef[slot].dadx.f[3];
- const float dwdy = setup.coef[slot].dady.f[3];
- const float topLeft = setup.coef[slot].a0.f[3] + x * dwdx + y * dwdy;
+ const float dwdx = spu_extract(setup.coef[slot].dadx, 3);
+ const float dwdy = spu_extract(setup.coef[slot].dady, 3);
+ const float topLeft = spu_extract(setup.coef[slot].a0, 3) + x * dwdx + y * dwdy;
const vector float topLeftv = spu_splats(topLeft);
const vector float derivs = (vector float) { 0.0, dwdx, dwdy, dwdx + dwdy };
return spu_add(topLeftv, derivs);
@@ -259,6 +254,7 @@ emit_quad( int x, int y, mask_t mask)
vector float inputs[4*4], outputs[2*4];
vector float fragZ = eval_z((float) x, (float) y);
vector float fragW = eval_w((float) x, (float) y);
+ vector unsigned int kill_mask;
/* setup inputs */
#if 0
@@ -273,7 +269,9 @@ emit_quad( int x, int y, mask_t mask)
ASSERT(spu.fragment_ops);
/* Execute the current fragment program */
- spu.fragment_program(inputs, outputs, spu.constants);
+ kill_mask = spu.fragment_program(inputs, outputs, spu.constants);
+
+ mask = spu_andc(mask, kill_mask);
/* Execute per-fragment/quad operations, including:
* alpha test, z test, stencil test, blend and framebuffer writing.
@@ -404,30 +402,41 @@ flush_spans(void)
static void
print_vertex(const struct vertex_header *v)
{
- int i;
- fprintf(stderr, "Vertex: (%p)\n", v);
- for (i = 0; i < setup.quad.nr_attrs; i++) {
- fprintf(stderr, " %d: %f %f %f %f\n", i,
- v->data[i][0], v->data[i][1], v->data[i][2], v->data[i][3]);
+ uint i;
+ fprintf(stderr, " Vertex: (%p)\n", v);
+ for (i = 0; i < spu.vertex_info.num_attribs; i++) {
+ fprintf(stderr, " %d: %f %f %f %f\n", i,
+ spu_extract(v->data[i], 0),
+ spu_extract(v->data[i], 1),
+ spu_extract(v->data[i], 2),
+ spu_extract(v->data[i], 3));
}
}
#endif
+/**
+ * Sort vertices from top to bottom.
+ * Compute area and determine front vs. back facing.
+ * Do coarse clip test against tile bounds
+ * \return FALSE if tri is totally outside tile, TRUE otherwise
+ */
static boolean
setup_sort_vertices(const struct vertex_header *v0,
const struct vertex_header *v1,
const struct vertex_header *v2)
{
+ float area, sign;
+
#if DEBUG_VERTS
- fprintf(stderr, "Triangle:\n");
- print_vertex(v0);
- print_vertex(v1);
- print_vertex(v2);
+ if (spu.init.id==0) {
+ fprintf(stderr, "SPU %u: Triangle:\n", spu.init.id);
+ print_vertex(v0);
+ print_vertex(v1);
+ print_vertex(v2);
+ }
#endif
- setup.vprovoke = v2;
-
/* determine bottom to top order of vertices */
{
float y0 = spu_extract(v0->data[0], 1);
@@ -439,18 +448,21 @@ setup_sort_vertices(const struct vertex_header *v0,
setup.vmin = v0;
setup.vmid = v1;
setup.vmax = v2;
+ sign = -1.0f;
}
else if (y2 <= y0) {
/* y2<=y0<=y1 */
setup.vmin = v2;
setup.vmid = v0;
setup.vmax = v1;
+ sign = -1.0f;
}
else {
/* y0<=y2<=y1 */
setup.vmin = v0;
setup.vmid = v2;
setup.vmax = v1;
+ sign = 1.0f;
}
}
else {
@@ -459,18 +471,21 @@ setup_sort_vertices(const struct vertex_header *v0,
setup.vmin = v1;
setup.vmid = v0;
setup.vmax = v2;
+ sign = 1.0f;
}
else if (y2 <= y1) {
/* y2<=y1<=y0 */
setup.vmin = v2;
setup.vmid = v1;
setup.vmax = v0;
+ sign = 1.0f;
}
else {
/* y1<=y2<=y0 */
setup.vmin = v1;
setup.vmid = v2;
setup.vmax = v0;
+ sign = -1.0f;
}
}
}
@@ -499,31 +514,16 @@ setup_sort_vertices(const struct vertex_header *v0,
/*
* Compute triangle's area. Use 1/area to compute partial
* derivatives of attributes later.
- *
- * The area will be the same as prim->det, but the sign may be
- * different depending on how the vertices get sorted above.
- *
- * To determine whether the primitive is front or back facing we
- * use the prim->det value because its sign is correct.
*/
- {
- const float area = (setup.emaj.dx * setup.ebot.dy -
- setup.ebot.dx * setup.emaj.dy);
-
- setup.oneOverArea = 1.0f / area;
- /*
- _mesa_printf("%s one-over-area %f area %f det %f\n",
- __FUNCTION__, setup.oneOverArea, area, prim->det );
- */
- }
+ area = setup.emaj.dx * setup.ebot.dy - setup.ebot.dx * setup.emaj.dy;
-#if 0
- /* We need to know if this is a front or back-facing triangle for:
- * - the GLSL gl_FrontFacing fragment attribute (bool)
- * - two-sided stencil test
- */
- setup.quad.facing = (prim->det > 0.0) ^ (setup.softpipe->rasterizer->front_winding == PIPE_WINDING_CW);
-#endif
+ setup.oneOverArea = 1.0f / area;
+
+ /* The product of area * sign indicates front/back orientation (0/1) */
+ setup.facing = (area * sign > 0.0f)
+ ^ (spu.rasterizer.front_winding == PIPE_WINDING_CW);
+
+ setup.vprovoke = v2;
return TRUE;
}
@@ -538,9 +538,9 @@ setup_sort_vertices(const struct vertex_header *v0,
static INLINE void
const_coeff4(uint slot)
{
- setup.coef[slot].dadx.v = (vector float) {0.0, 0.0, 0.0, 0.0};
- setup.coef[slot].dady.v = (vector float) {0.0, 0.0, 0.0, 0.0};
- setup.coef[slot].a0.v = setup.vprovoke->data[slot];
+ setup.coef[slot].dadx = (vector float) {0.0, 0.0, 0.0, 0.0};
+ setup.coef[slot].dady = (vector float) {0.0, 0.0, 0.0, 0.0};
+ setup.coef[slot].a0 = setup.vprovoke->data[slot];
}
@@ -564,13 +564,13 @@ tri_linear_coeff4(uint slot)
vector float b = spu_sub(spu_mul(spu_splats(setup.emaj.dx), botda),
spu_mul(majda, spu_splats(setup.ebot.dx)));
- setup.coef[slot].dadx.v = spu_mul(a, spu_splats(setup.oneOverArea));
- setup.coef[slot].dady.v = spu_mul(b, spu_splats(setup.oneOverArea));
+ setup.coef[slot].dadx = spu_mul(a, spu_splats(setup.oneOverArea));
+ setup.coef[slot].dady = spu_mul(b, spu_splats(setup.oneOverArea));
- vector float tempx = spu_mul(setup.coef[slot].dadx.v, xxxx);
- vector float tempy = spu_mul(setup.coef[slot].dady.v, yyyy);
+ vector float tempx = spu_mul(setup.coef[slot].dadx, xxxx);
+ vector float tempy = spu_mul(setup.coef[slot].dady, yyyy);
- setup.coef[slot].a0.v = spu_sub(vmin_d, spu_add(tempx, tempy));
+ setup.coef[slot].a0 = spu_sub(vmin_d, spu_add(tempx, tempy));
}
@@ -608,13 +608,13 @@ tri_persp_coeff4(uint slot)
vector float b = spu_sub(spu_mul(spu_splats(setup.emaj.dx), botda),
spu_mul(majda, spu_splats(setup.ebot.dx)));
- setup.coef[slot].dadx.v = spu_mul(a, spu_splats(setup.oneOverArea));
- setup.coef[slot].dady.v = spu_mul(b, spu_splats(setup.oneOverArea));
+ setup.coef[slot].dadx = spu_mul(a, spu_splats(setup.oneOverArea));
+ setup.coef[slot].dady = spu_mul(b, spu_splats(setup.oneOverArea));
- vector float tempx = spu_mul(setup.coef[slot].dadx.v, xxxx);
- vector float tempy = spu_mul(setup.coef[slot].dady.v, yyyy);
+ vector float tempx = spu_mul(setup.coef[slot].dadx, xxxx);
+ vector float tempy = spu_mul(setup.coef[slot].dady, yyyy);
- setup.coef[slot].a0.v = spu_sub(vmin_d, spu_add(tempx, tempy));
+ setup.coef[slot].a0 = spu_sub(vmin_d, spu_add(tempx, tempy));
}
@@ -750,27 +750,13 @@ subtriangle(struct edge *eleft, struct edge *eright, unsigned lines)
}
-static float
-determinant(const float *v0, const float *v1, const float *v2)
-{
- /* edge vectors e = v0 - v2, f = v1 - v2 */
- const float ex = v0[0] - v2[0];
- const float ey = v0[1] - v2[1];
- const float fx = v1[0] - v2[0];
- const float fy = v1[1] - v2[1];
-
- /* det = cross(e,f).z */
- return ex * fy - ey * fx;
-}
-
-
/**
* Draw triangle into tile at (tx, ty) (tile coords)
* The tile data should have already been fetched.
*/
boolean
tri_draw(const float *v0, const float *v1, const float *v2,
- uint tx, uint ty, uint front_winding)
+ uint tx, uint ty)
{
setup.tx = tx;
setup.ty = ty;
@@ -781,12 +767,6 @@ tri_draw(const float *v0, const float *v1, const float *v2,
setup.cliprect_maxx = (tx + 1) * TILE_SIZE;
setup.cliprect_maxy = (ty + 1) * TILE_SIZE;
- /* Before we sort vertices, determine the facing of the triangle,
- * which will be needed for front/back-face stencil application
- */
- float det = determinant(v0, v1, v2);
- setup.facing = (det > 0.0) ^ (front_winding == PIPE_WINDING_CW);
-
if (!setup_sort_vertices((struct vertex_header *) v0,
(struct vertex_header *) v1,
(struct vertex_header *) v2)) {
diff --git a/src/gallium/drivers/cell/spu/spu_tri.h b/src/gallium/drivers/cell/spu/spu_tri.h
index abc3d35160e..aa694dd7c93 100644
--- a/src/gallium/drivers/cell/spu/spu_tri.h
+++ b/src/gallium/drivers/cell/spu/spu_tri.h
@@ -31,7 +31,7 @@
extern boolean
-tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty, uint front_winding);
+tri_draw(const float *v0, const float *v1, const float *v2, uint tx, uint ty);
#endif /* SPU_TRI_H */
diff --git a/src/gallium/drivers/softpipe/sp_fs_exec.c b/src/gallium/drivers/softpipe/sp_fs_exec.c
index 4fea71c3140..f472dd0ed2a 100644
--- a/src/gallium/drivers/softpipe/sp_fs_exec.c
+++ b/src/gallium/drivers/softpipe/sp_fs_exec.c
@@ -42,7 +42,6 @@
struct sp_exec_fragment_shader
{
struct sp_fragment_shader base;
- const struct tgsi_token *machine_tokens;
};
@@ -95,19 +94,15 @@ exec_prepare( const struct sp_fragment_shader *base,
struct tgsi_exec_machine *machine,
struct tgsi_sampler *samplers )
{
- struct sp_exec_fragment_shader *spefs =
- sp_exec_fragment_shader(base);
-
/*
* Bind tokens/shader to the interpreter's machine state.
* Avoid redundant binding.
*/
- if (spefs->machine_tokens != base->shader.tokens) {
+ if (machine->Tokens != base->shader.tokens) {
tgsi_exec_machine_bind_shader( machine,
base->shader.tokens,
PIPE_MAX_SAMPLERS,
samplers );
- spefs->machine_tokens = base->shader.tokens;
}
}
diff --git a/src/gallium/include/pipe/p_config.h b/src/gallium/include/pipe/p_config.h
index ef05547819d..05cbd2fc4df 100644
--- a/src/gallium/include/pipe/p_config.h
+++ b/src/gallium/include/pipe/p_config.h
@@ -93,8 +93,11 @@
#endif
#endif
-#if 0 /* FIXME */
+#if defined(__PPC__)
#define PIPE_ARCH_PPC
+#if defined(__PPC64__)
+#define PIPE_ARCH_PPC_64
+#endif
#endif
diff --git a/src/gallium/winsys/xlib/SConscript b/src/gallium/winsys/xlib/SConscript
index 324fbef306a..3aef3b6cedd 100644
--- a/src/gallium/winsys/xlib/SConscript
+++ b/src/gallium/winsys/xlib/SConscript
@@ -5,8 +5,7 @@ Import('*')
if env['platform'] == 'linux' \
and 'mesa' in env['statetrackers'] \
- and 'softpipe' in env['drivers'] \
- and 'i965simple' in env['drivers'] \
+ and ('softpipe' or 'i915simple' or 'trace') in env['drivers'] \
and not env['dri']:
env = env.Clone()
@@ -22,15 +21,20 @@ if env['platform'] == 'linux' \
'xfonts.c',
'xm_api.c',
'xm_winsys.c',
- 'xm_winsys_aub.c',
- 'brw_aub.c',
]
+
+ drivers = [];
+
+ if 'softpipe' in env['drivers']:
+ drivers += [softpipe]
+
+ if 'i965simple' in env['drivers']:
+ drivers += [i965simple]
+ sources += [
+ 'brw_aub.c',
+ 'xm_winsys_aub.c',
+ ]
- drivers = [
- softpipe,
- i965simple,
- ]
-
if 'trace' in env['drivers']:
env.Append(CPPDEFINES = 'GALLIUM_TRACE')
drivers += [trace]
diff --git a/src/glx/x11/XF86dri.c b/src/glx/x11/XF86dri.c
index cd0adc3930f..4faa8bbfb15 100644
--- a/src/glx/x11/XF86dri.c
+++ b/src/glx/x11/XF86dri.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -68,27 +69,28 @@ static char xf86dri_extension_name[] = XF86DRINAME;
* *
*****************************************************************************/
-static int close_display(Display *dpy, XExtCodes *extCodes);
+static int close_display(Display * dpy, XExtCodes * extCodes);
static /* const */ XExtensionHooks xf86dri_extension_hooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- close_display, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- NULL, /* error_string */
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ close_display, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ NULL, /* error_string */
};
-static XEXT_GENERATE_FIND_DISPLAY (find_display, xf86dri_info,
- xf86dri_extension_name,
- &xf86dri_extension_hooks,
- 0, NULL)
+static
+XEXT_GENERATE_FIND_DISPLAY(find_display, xf86dri_info,
+ xf86dri_extension_name,
+ &xf86dri_extension_hooks, 0, NULL)
-static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
+static
+XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86dri_info)
/*****************************************************************************
@@ -96,7 +98,6 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
* public XFree86-DRI Extension routines *
* *
*****************************************************************************/
-
#if 0
#include <stdio.h>
#define TRACE(msg) fprintf(stderr,"XF86DRI%s\n", msg);
@@ -104,550 +105,534 @@ static XEXT_GENERATE_CLOSE_DISPLAY (close_display, xf86dri_info)
#define TRACE(msg)
#endif
-
-PUBLIC Bool XF86DRIQueryExtension (dpy, event_basep, error_basep)
- Display *dpy;
- int *event_basep, *error_basep;
+PUBLIC Bool
+XF86DRIQueryExtension(Display * dpy, int *event_basep,
+ int *error_basep)
{
- XExtDisplayInfo *info = find_display (dpy);
-
- TRACE("QueryExtension...");
- if (XextHasExtension(info)) {
- *event_basep = info->codes->first_event;
- *error_basep = info->codes->first_error;
- TRACE("QueryExtension... return True");
- return True;
- } else {
- TRACE("QueryExtension... return False");
- return False;
- }
+ XExtDisplayInfo *info = find_display(dpy);
+
+ TRACE("QueryExtension...");
+ if (XextHasExtension(info)) {
+ *event_basep = info->codes->first_event;
+ *error_basep = info->codes->first_error;
+ TRACE("QueryExtension... return True");
+ return True;
+ }
+ else {
+ TRACE("QueryExtension... return False");
+ return False;
+ }
}
-PUBLIC Bool XF86DRIQueryVersion(dpy, majorVersion, minorVersion, patchVersion)
- Display* dpy;
- int* majorVersion;
- int* minorVersion;
- int* patchVersion;
+PUBLIC Bool
+XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIQueryVersionReply rep;
- xXF86DRIQueryVersionReq *req;
-
- TRACE("QueryVersion...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIQueryVersion, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIQueryVersion;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryVersion... return False");
- return False;
- }
- *majorVersion = rep.majorVersion;
- *minorVersion = rep.minorVersion;
- *patchVersion = rep.patchVersion;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryVersion... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIQueryVersionReply rep;
+ xXF86DRIQueryVersionReq *req;
+
+ TRACE("QueryVersion...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryVersion, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryVersion;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return False");
+ return False;
+ }
+ *majorVersion = rep.majorVersion;
+ *minorVersion = rep.minorVersion;
+ *patchVersion = rep.patchVersion;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryVersion... return True");
+ return True;
}
-PUBLIC Bool XF86DRIQueryDirectRenderingCapable(dpy, screen, isCapable)
- Display* dpy;
- int screen;
- Bool* isCapable;
+PUBLIC Bool
+XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen,
+ Bool * isCapable)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIQueryDirectRenderingCapableReply rep;
- xXF86DRIQueryDirectRenderingCapableReq *req;
-
- TRACE("QueryDirectRenderingCapable...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIQueryDirectRenderingCapable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryDirectRenderingCapable... return False");
- return False;
- }
- *isCapable = rep.isCapable;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("QueryDirectRenderingCapable... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIQueryDirectRenderingCapableReply rep;
+ xXF86DRIQueryDirectRenderingCapableReq *req;
+
+ TRACE("QueryDirectRenderingCapable...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIQueryDirectRenderingCapable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIQueryDirectRenderingCapable;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return False");
+ return False;
+ }
+ *isCapable = rep.isCapable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("QueryDirectRenderingCapable... return True");
+ return True;
}
-PUBLIC Bool XF86DRIOpenConnection(dpy, screen, hSAREA, busIdString)
- Display* dpy;
- int screen;
- drm_handle_t * hSAREA;
- char **busIdString;
+PUBLIC Bool
+XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
+ char **busIdString)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIOpenConnectionReply rep;
- xXF86DRIOpenConnectionReq *req;
-
- TRACE("OpenConnection...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIOpenConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIOpenConnection;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return False");
- return False;
- }
-
- *hSAREA = rep.hSAREALow;
- if (sizeof(drm_handle_t) == 8) {
- int shift = 32; /* var to prevent warning on next line */
- *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
- }
-
- if (rep.length) {
- if (!(*busIdString = (char *)Xcalloc(rep.busIdStringLength + 1, 1))) {
- _XEatData(dpy, ((rep.busIdStringLength+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return False");
- return False;
- }
- _XReadPad(dpy, *busIdString, rep.busIdStringLength);
- } else {
- *busIdString = NULL;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("OpenConnection... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIOpenConnectionReply rep;
+ xXF86DRIOpenConnectionReq *req;
+
+ TRACE("OpenConnection...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIOpenConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIOpenConnection;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+
+ *hSAREA = rep.hSAREALow;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32; /* var to prevent warning on next line */
+ *hSAREA |= ((drm_handle_t) rep.hSAREAHigh) << shift;
+ }
+
+ if (rep.length) {
+ if (!(*busIdString = (char *) Xcalloc(rep.busIdStringLength + 1, 1))) {
+ _XEatData(dpy, ((rep.busIdStringLength + 3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return False");
+ return False;
+ }
+ _XReadPad(dpy, *busIdString, rep.busIdStringLength);
+ }
+ else {
+ *busIdString = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("OpenConnection... return True");
+ return True;
}
-PUBLIC Bool XF86DRIAuthConnection(dpy, screen, magic)
- Display* dpy;
- int screen;
- drm_magic_t magic;
+PUBLIC Bool
+XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIAuthConnectionReq *req;
- xXF86DRIAuthConnectionReply rep;
-
- TRACE("AuthConnection...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIAuthConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIAuthConnection;
- req->screen = screen;
- req->magic = magic;
- rep.authenticated = 0;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.authenticated) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("AuthConnection... return False");
- return False;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("AuthConnection... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIAuthConnectionReq *req;
+ xXF86DRIAuthConnectionReply rep;
+
+ TRACE("AuthConnection...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIAuthConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIAuthConnection;
+ req->screen = screen;
+ req->magic = magic;
+ rep.authenticated = 0;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse) || !rep.authenticated) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return False");
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("AuthConnection... return True");
+ return True;
}
-PUBLIC Bool XF86DRICloseConnection(dpy, screen)
- Display* dpy;
- int screen;
+PUBLIC Bool
+XF86DRICloseConnection(Display * dpy, int screen)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICloseConnectionReq *req;
-
- TRACE("CloseConnection...");
-
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICloseConnection, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICloseConnection;
- req->screen = screen;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CloseConnection... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRICloseConnectionReq *req;
+
+ TRACE("CloseConnection...");
+
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICloseConnection, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICloseConnection;
+ req->screen = screen;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CloseConnection... return True");
+ return True;
}
-PUBLIC Bool XF86DRIGetClientDriverName(dpy, screen, ddxDriverMajorVersion,
- ddxDriverMinorVersion, ddxDriverPatchVersion, clientDriverName)
- Display* dpy;
- int screen;
- int* ddxDriverMajorVersion;
- int* ddxDriverMinorVersion;
- int* ddxDriverPatchVersion;
- char** clientDriverName;
+PUBLIC Bool
+XF86DRIGetClientDriverName(Display * dpy, int screen,
+ int *ddxDriverMajorVersion,
+ int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion,
+ char **clientDriverName)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetClientDriverNameReply rep;
- xXF86DRIGetClientDriverNameReq *req;
-
- TRACE("GetClientDriverName...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetClientDriverName, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetClientDriverName;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return False");
- return False;
- }
-
- *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
- *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
- *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
-
- if (rep.length) {
- if (!(*clientDriverName = (char *)Xcalloc(rep.clientDriverNameLength + 1, 1))) {
- _XEatData(dpy, ((rep.clientDriverNameLength+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return False");
- return False;
- }
- _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
- } else {
- *clientDriverName = NULL;
- }
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetClientDriverName... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIGetClientDriverNameReply rep;
+ xXF86DRIGetClientDriverNameReq *req;
+
+ TRACE("GetClientDriverName...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetClientDriverName, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetClientDriverName;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+
+ *ddxDriverMajorVersion = rep.ddxDriverMajorVersion;
+ *ddxDriverMinorVersion = rep.ddxDriverMinorVersion;
+ *ddxDriverPatchVersion = rep.ddxDriverPatchVersion;
+
+ if (rep.length) {
+ if (!
+ (*clientDriverName =
+ (char *) Xcalloc(rep.clientDriverNameLength + 1, 1))) {
+ _XEatData(dpy, ((rep.clientDriverNameLength + 3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return False");
+ return False;
+ }
+ _XReadPad(dpy, *clientDriverName, rep.clientDriverNameLength);
+ }
+ else {
+ *clientDriverName = NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetClientDriverName... return True");
+ return True;
}
-PUBLIC Bool XF86DRICreateContextWithConfig(dpy, screen, configID, context,
- hHWContext)
- Display* dpy;
- int screen;
- int configID;
- XID* context;
- drm_context_t * hHWContext;
+PUBLIC Bool
+XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID,
+ XID * context, drm_context_t * hHWContext)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICreateContextReply rep;
- xXF86DRICreateContextReq *req;
-
- TRACE("CreateContext...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICreateContext, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICreateContext;
- req->visual = configID;
- req->screen = screen;
- *context = XAllocID(dpy);
- req->context = *context;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateContext... return False");
- return False;
- }
- *hHWContext = rep.hHWContext;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateContext... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRICreateContextReply rep;
+ xXF86DRICreateContextReq *req;
+
+ TRACE("CreateContext...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateContext;
+ req->visual = configID;
+ req->screen = screen;
+ *context = XAllocID(dpy);
+ req->context = *context;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return False");
+ return False;
+ }
+ *hHWContext = rep.hHWContext;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateContext... return True");
+ return True;
}
-PUBLIC Bool XF86DRICreateContext(dpy, screen, visual, context, hHWContext)
- Display* dpy;
- int screen;
- Visual* visual;
- XID* context;
- drm_context_t * hHWContext;
+PUBLIC Bool
+XF86DRICreateContext(Display * dpy, int screen, Visual * visual,
+ XID * context, drm_context_t * hHWContext)
{
- return XF86DRICreateContextWithConfig( dpy, screen, visual->visualid,
- context, hHWContext );
+ return XF86DRICreateContextWithConfig(dpy, screen, visual->visualid,
+ context, hHWContext);
}
-PUBLIC Bool XF86DRIDestroyContext(Display *dpy, int screen,
- XID context )
+PUBLIC Bool
+XF86DRIDestroyContext(Display * dpy, int screen, XID context)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIDestroyContextReq *req;
-
- TRACE("DestroyContext...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIDestroyContext, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIDestroyContext;
- req->screen = screen;
- req->context = context;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("DestroyContext... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIDestroyContextReq *req;
+
+ TRACE("DestroyContext...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyContext, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyContext;
+ req->screen = screen;
+ req->context = context;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("DestroyContext... return True");
+ return True;
}
-PUBLIC Bool XF86DRICreateDrawable(Display *dpy, int screen,
- XID drawable, drm_drawable_t * hHWDrawable )
+PUBLIC Bool
+XF86DRICreateDrawable(Display * dpy, int screen,
+ XID drawable, drm_drawable_t * hHWDrawable)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRICreateDrawableReply rep;
- xXF86DRICreateDrawableReq *req;
-
- TRACE("CreateDrawable...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRICreateDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRICreateDrawable;
- req->screen = screen;
- req->drawable = drawable;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateDrawable... return False");
- return False;
- }
- *hHWDrawable = rep.hHWDrawable;
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("CreateDrawable... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRICreateDrawableReply rep;
+ xXF86DRICreateDrawableReq *req;
+
+ TRACE("CreateDrawable...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRICreateDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRICreateDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return False");
+ return False;
+ }
+ *hHWDrawable = rep.hHWDrawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("CreateDrawable... return True");
+ return True;
}
-static int noopErrorHandler(Display *dpy, XErrorEvent *xerr)
+static int
+noopErrorHandler(Display * dpy, XErrorEvent * xerr)
{
- return 0;
+ return 0;
}
-PUBLIC Bool XF86DRIDestroyDrawable(Display *dpy, int screen,
- XID drawable )
+PUBLIC Bool
+XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIDestroyDrawableReq *req;
- int (*oldXErrorHandler)(Display *, XErrorEvent *);
-
- TRACE("DestroyDrawable...");
- XF86DRICheckExtension (dpy, info, False);
-
- /* This is called from the DRI driver, which used call it like this
- *
- * if (windowExists(drawable))
- * destroyDrawable(drawable);
- *
- * which is a textbook race condition - the window may disappear
- * from the server between checking for its existance and
- * destroying it. Instead we change the semantics of
- * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
- * the windows is gone, by wrapping the destroy call in an error
- * handler. */
-
- XSync(dpy, False);
- oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
-
- LockDisplay(dpy);
- GetReq(XF86DRIDestroyDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIDestroyDrawable;
- req->screen = screen;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
-
- XSetErrorHandler(oldXErrorHandler);
-
- TRACE("DestroyDrawable... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIDestroyDrawableReq *req;
+ int (*oldXErrorHandler) (Display *, XErrorEvent *);
+
+ TRACE("DestroyDrawable...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ /* This is called from the DRI driver, which used call it like this
+ *
+ * if (windowExists(drawable))
+ * destroyDrawable(drawable);
+ *
+ * which is a textbook race condition - the window may disappear
+ * from the server between checking for its existance and
+ * destroying it. Instead we change the semantics of
+ * __DRIinterfaceMethodsRec::destroyDrawable() to succeed even if
+ * the windows is gone, by wrapping the destroy call in an error
+ * handler. */
+
+ XSync(dpy, False);
+ oldXErrorHandler = XSetErrorHandler(noopErrorHandler);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIDestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIDestroyDrawable;
+ req->screen = screen;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ XSetErrorHandler(oldXErrorHandler);
+
+ TRACE("DestroyDrawable... return True");
+ return True;
}
-PUBLIC Bool XF86DRIGetDrawableInfo(Display* dpy, int screen, Drawable drawable,
- unsigned int* index, unsigned int* stamp,
- int* X, int* Y, int* W, int* H,
- int* numClipRects, drm_clip_rect_t ** pClipRects,
- int* backX, int* backY,
- int* numBackClipRects, drm_clip_rect_t ** pBackClipRects )
+PUBLIC Bool
+XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetDrawableInfoReply rep;
- xXF86DRIGetDrawableInfoReq *req;
- int total_rects;
-
- TRACE("GetDrawableInfo...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetDrawableInfo, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetDrawableInfo;
- req->screen = screen;
- req->drawable = drawable;
-
- if (!_XReply(dpy, (xReply *)&rep, 1, xFalse))
- {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return False");
- return False;
- }
- *index = rep.drawableTableIndex;
- *stamp = rep.drawableTableStamp;
- *X = (int)rep.drawableX;
- *Y = (int)rep.drawableY;
- *W = (int)rep.drawableWidth;
- *H = (int)rep.drawableHeight;
- *numClipRects = rep.numClipRects;
- total_rects = *numClipRects;
-
- *backX = rep.backX;
- *backY = rep.backY;
- *numBackClipRects = rep.numBackClipRects;
- total_rects += *numBackClipRects;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIGetDrawableInfoReply rep;
+ xXF86DRIGetDrawableInfoReq *req;
+ int total_rects;
+
+ TRACE("GetDrawableInfo...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDrawableInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDrawableInfo;
+ req->screen = screen;
+ req->drawable = drawable;
+
+ if (!_XReply(dpy, (xReply *) & rep, 1, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
+ *index = rep.drawableTableIndex;
+ *stamp = rep.drawableTableStamp;
+ *X = (int) rep.drawableX;
+ *Y = (int) rep.drawableY;
+ *W = (int) rep.drawableWidth;
+ *H = (int) rep.drawableHeight;
+ *numClipRects = rep.numClipRects;
+ total_rects = *numClipRects;
+
+ *backX = rep.backX;
+ *backY = rep.backY;
+ *numBackClipRects = rep.numBackClipRects;
+ total_rects += *numBackClipRects;
#if 0
- /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
- * backwards compatibility (Because of the >> 2 shift) but the fix
- * enables multi-threaded apps to work.
- */
- if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
- SIZEOF(xGenericReply) +
- total_rects * sizeof(drm_clip_rect_t)) + 3) & ~3) >> 2)) {
- _XEatData(dpy, rep.length);
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return False");
- return False;
- }
+ /* Because of the fix in Xserver/GL/dri/xf86dri.c, this check breaks
+ * backwards compatibility (Because of the >> 2 shift) but the fix
+ * enables multi-threaded apps to work.
+ */
+ if (rep.length != ((((SIZEOF(xXF86DRIGetDrawableInfoReply) -
+ SIZEOF(xGenericReply) +
+ total_rects * sizeof(drm_clip_rect_t)) +
+ 3) & ~3) >> 2)) {
+ _XEatData(dpy, rep.length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return False");
+ return False;
+ }
#endif
- if (*numClipRects) {
- int len = sizeof(drm_clip_rect_t) * (*numClipRects);
-
- *pClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
- if (*pClipRects)
- _XRead(dpy, (char*)*pClipRects, len);
- } else {
- *pClipRects = NULL;
- }
-
- if (*numBackClipRects) {
- int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
-
- *pBackClipRects = (drm_clip_rect_t *)Xcalloc(len, 1);
- if (*pBackClipRects)
- _XRead(dpy, (char*)*pBackClipRects, len);
- } else {
- *pBackClipRects = NULL;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDrawableInfo... return True");
- return True;
+ if (*numClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numClipRects);
+
+ *pClipRects = (drm_clip_rect_t *) Xcalloc(len, 1);
+ if (*pClipRects)
+ _XRead(dpy, (char *) *pClipRects, len);
+ }
+ else {
+ *pClipRects = NULL;
+ }
+
+ if (*numBackClipRects) {
+ int len = sizeof(drm_clip_rect_t) * (*numBackClipRects);
+
+ *pBackClipRects = (drm_clip_rect_t *) Xcalloc(len, 1);
+ if (*pBackClipRects)
+ _XRead(dpy, (char *) *pBackClipRects, len);
+ }
+ else {
+ *pBackClipRects = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDrawableInfo... return True");
+ return True;
}
-PUBLIC Bool XF86DRIGetDeviceInfo(dpy, screen, hFrameBuffer,
- fbOrigin, fbSize, fbStride, devPrivateSize, pDevPrivate)
- Display* dpy;
- int screen;
- drm_handle_t * hFrameBuffer;
- int* fbOrigin;
- int* fbSize;
- int* fbStride;
- int* devPrivateSize;
- void** pDevPrivate;
+PUBLIC Bool
+XF86DRIGetDeviceInfo(Display * dpy, int screen, drm_handle_t * hFrameBuffer,
+ int *fbOrigin, int *fbSize, int *fbStride,
+ int *devPrivateSize, void **pDevPrivate)
{
- XExtDisplayInfo *info = find_display (dpy);
- xXF86DRIGetDeviceInfoReply rep;
- xXF86DRIGetDeviceInfoReq *req;
-
- TRACE("GetDeviceInfo...");
- XF86DRICheckExtension (dpy, info, False);
-
- LockDisplay(dpy);
- GetReq(XF86DRIGetDeviceInfo, req);
- req->reqType = info->codes->major_opcode;
- req->driReqType = X_XF86DRIGetDeviceInfo;
- req->screen = screen;
- if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return False");
- return False;
- }
-
- *hFrameBuffer = rep.hFrameBufferLow;
- if (sizeof(drm_handle_t) == 8) {
- int shift = 32; /* var to prevent warning on next line */
- *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
- }
-
- *fbOrigin = rep.framebufferOrigin;
- *fbSize = rep.framebufferSize;
- *fbStride = rep.framebufferStride;
- *devPrivateSize = rep.devPrivateSize;
-
- if (rep.length) {
- if (!(*pDevPrivate = (void *)Xcalloc(rep.devPrivateSize, 1))) {
- _XEatData(dpy, ((rep.devPrivateSize+3) & ~3));
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return False");
- return False;
- }
- _XRead(dpy, (char*)*pDevPrivate, rep.devPrivateSize);
- } else {
- *pDevPrivate = NULL;
- }
-
- UnlockDisplay(dpy);
- SyncHandle();
- TRACE("GetDeviceInfo... return True");
- return True;
+ XExtDisplayInfo *info = find_display(dpy);
+ xXF86DRIGetDeviceInfoReply rep;
+ xXF86DRIGetDeviceInfoReq *req;
+
+ TRACE("GetDeviceInfo...");
+ XF86DRICheckExtension(dpy, info, False);
+
+ LockDisplay(dpy);
+ GetReq(XF86DRIGetDeviceInfo, req);
+ req->reqType = info->codes->major_opcode;
+ req->driReqType = X_XF86DRIGetDeviceInfo;
+ req->screen = screen;
+ if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+
+ *hFrameBuffer = rep.hFrameBufferLow;
+ if (sizeof(drm_handle_t) == 8) {
+ int shift = 32; /* var to prevent warning on next line */
+ *hFrameBuffer |= ((drm_handle_t) rep.hFrameBufferHigh) << shift;
+ }
+
+ *fbOrigin = rep.framebufferOrigin;
+ *fbSize = rep.framebufferSize;
+ *fbStride = rep.framebufferStride;
+ *devPrivateSize = rep.devPrivateSize;
+
+ if (rep.length) {
+ if (!(*pDevPrivate = (void *) Xcalloc(rep.devPrivateSize, 1))) {
+ _XEatData(dpy, ((rep.devPrivateSize + 3) & ~3));
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return False");
+ return False;
+ }
+ _XRead(dpy, (char *) *pDevPrivate, rep.devPrivateSize);
+ }
+ else {
+ *pDevPrivate = NULL;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ TRACE("GetDeviceInfo... return True");
+ return True;
}
-PUBLIC Bool XF86DRIOpenFullScreen(dpy, screen, drawable)
- Display* dpy;
- int screen;
- Drawable drawable;
+PUBLIC Bool
+XF86DRIOpenFullScreen(Display * dpy, int screen, Drawable drawable)
{
- /* This function and the underlying X protocol are deprecated.
- */
- (void) dpy;
- (void) screen;
- (void) drawable;
- return False;
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return False;
}
-PUBLIC Bool XF86DRICloseFullScreen(dpy, screen, drawable)
- Display* dpy;
- int screen;
- Drawable drawable;
+PUBLIC Bool
+XF86DRICloseFullScreen(Display * dpy, int screen, Drawable drawable)
{
- /* This function and the underlying X protocol are deprecated.
- */
- (void) dpy;
- (void) screen;
- (void) drawable;
- return True;
+ /* This function and the underlying X protocol are deprecated.
+ */
+ (void) dpy;
+ (void) screen;
+ (void) drawable;
+ return True;
}
#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/clientattrib.c b/src/glx/x11/clientattrib.c
index fb45f621425..3be59c67d71 100644
--- a/src/glx/x11/clientattrib.c
+++ b/src/glx/x11/clientattrib.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -36,100 +37,107 @@
/*****************************************************************************/
static void
-do_enable_disable(GLenum array, GLboolean val )
+do_enable_disable(GLenum array, GLboolean val)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- unsigned index = 0;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ unsigned index = 0;
- if ( array == GL_TEXTURE_COORD_ARRAY ) {
- index = __glXGetActiveTextureUnit( state );
- }
+ if (array == GL_TEXTURE_COORD_ARRAY) {
+ index = __glXGetActiveTextureUnit(state);
+ }
- if ( ! __glXSetArrayEnable( state, array, index, val ) ) {
- __glXSetError(gc, GL_INVALID_ENUM);
- }
+ if (!__glXSetArrayEnable(state, array, index, val)) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
}
-void __indirect_glEnableClientState(GLenum array)
+void
+__indirect_glEnableClientState(GLenum array)
{
- do_enable_disable( array, GL_TRUE );
+ do_enable_disable(array, GL_TRUE);
}
-void __indirect_glDisableClientState(GLenum array)
+void
+__indirect_glDisableClientState(GLenum array)
{
- do_enable_disable( array, GL_FALSE );
+ do_enable_disable(array, GL_FALSE);
}
/************************************************************************/
-void __indirect_glPushClientAttrib(GLuint mask)
+void
+__indirect_glPushClientAttrib(GLuint mask)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- __GLXattribute **spp = gc->attributes.stackPointer, *sp;
-
- if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
- if (!(sp = *spp)) {
- sp = (__GLXattribute *)Xmalloc(sizeof(__GLXattribute));
- *spp = sp;
- }
- sp->mask = mask;
- gc->attributes.stackPointer = spp + 1;
- if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
- sp->storePack = state->storePack;
- sp->storeUnpack = state->storeUnpack;
- }
- if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
- __glXPushArrayState( state );
- }
- } else {
- __glXSetError(gc, GL_STACK_OVERFLOW);
- return;
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+
+ if (spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]) {
+ if (!(sp = *spp)) {
+ sp = (__GLXattribute *) Xmalloc(sizeof(__GLXattribute));
+ *spp = sp;
+ }
+ sp->mask = mask;
+ gc->attributes.stackPointer = spp + 1;
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ sp->storePack = state->storePack;
+ sp->storeUnpack = state->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ __glXPushArrayState(state);
+ }
+ }
+ else {
+ __glXSetError(gc, GL_STACK_OVERFLOW);
+ return;
+ }
}
-void __indirect_glPopClientAttrib(void)
+void
+__indirect_glPopClientAttrib(void)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- __GLXattribute **spp = gc->attributes.stackPointer, *sp;
- GLuint mask;
-
- if (spp > &gc->attributes.stack[0]) {
- --spp;
- sp = *spp;
- assert(sp != 0);
- mask = sp->mask;
- gc->attributes.stackPointer = spp;
-
- if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
- state->storePack = sp->storePack;
- state->storeUnpack = sp->storeUnpack;
- }
- if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
- __glXPopArrayState( state );
- }
-
- sp->mask = 0;
- } else {
- __glXSetError(gc, GL_STACK_UNDERFLOW);
- return;
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ __GLXattribute **spp = gc->attributes.stackPointer, *sp;
+ GLuint mask;
+
+ if (spp > &gc->attributes.stack[0]) {
+ --spp;
+ sp = *spp;
+ assert(sp != 0);
+ mask = sp->mask;
+ gc->attributes.stackPointer = spp;
+
+ if (mask & GL_CLIENT_PIXEL_STORE_BIT) {
+ state->storePack = sp->storePack;
+ state->storeUnpack = sp->storeUnpack;
+ }
+ if (mask & GL_CLIENT_VERTEX_ARRAY_BIT) {
+ __glXPopArrayState(state);
+ }
+
+ sp->mask = 0;
+ }
+ else {
+ __glXSetError(gc, GL_STACK_UNDERFLOW);
+ return;
+ }
}
-void __glFreeAttributeState(__GLXcontext *gc)
+void
+__glFreeAttributeState(__GLXcontext * gc)
{
- __GLXattribute *sp, **spp;
-
- for (spp = &gc->attributes.stack[0];
- spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
- spp++) {
- sp = *spp;
- if (sp) {
- XFree((char *)sp);
- } else {
- break;
- }
- }
+ __GLXattribute *sp, **spp;
+
+ for (spp = &gc->attributes.stack[0];
+ spp < &gc->attributes.stack[__GL_CLIENT_ATTRIB_STACK_DEPTH]; spp++) {
+ sp = *spp;
+ if (sp) {
+ XFree((char *) sp);
+ }
+ else {
+ break;
+ }
+ }
}
diff --git a/src/glx/x11/compsize.c b/src/glx/x11/compsize.c
index d46d3d41d1f..f8f453d8910 100644
--- a/src/glx/x11/compsize.c
+++ b/src/glx/x11/compsize.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -35,151 +36,156 @@
/*
** Return the number of elements per group of a specified format
*/
-GLint __glElementsPerGroup(GLenum format, GLenum type)
+GLint
+__glElementsPerGroup(GLenum format, GLenum type)
{
- /*
+ /*
** To make row length computation valid for image extraction,
** packed pixel types assume elements per group equals one.
*/
- switch(type) {
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_SHORT_8_8_APPLE:
- case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
- case GL_UNSIGNED_SHORT_15_1_MESA:
- case GL_UNSIGNED_SHORT_1_15_REV_MESA:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_24_8_NV:
- case GL_UNSIGNED_INT_24_8_MESA:
- case GL_UNSIGNED_INT_8_24_REV_MESA:
+ switch (type) {
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
return 1;
- default:
+ default:
break;
- }
+ }
- switch(format) {
- case GL_RGB:
- case GL_BGR:
- return 3;
- case GL_422_EXT:
- case GL_422_REV_EXT:
- case GL_422_AVERAGE_EXT:
- case GL_422_REV_AVERAGE_EXT:
- case GL_YCBCR_422_APPLE:
- case GL_LUMINANCE_ALPHA:
- return 2;
- case GL_RGBA:
- case GL_BGRA:
- case GL_ABGR_EXT:
- return 4;
- case GL_COLOR_INDEX:
- case GL_STENCIL_INDEX:
- case GL_DEPTH_COMPONENT:
- case GL_RED:
- case GL_GREEN:
- case GL_BLUE:
- case GL_ALPHA:
- case GL_LUMINANCE:
- case GL_INTENSITY:
- return 1;
- default:
- return 0;
- }
+ switch (format) {
+ case GL_RGB:
+ case GL_BGR:
+ return 3;
+ case GL_422_EXT:
+ case GL_422_REV_EXT:
+ case GL_422_AVERAGE_EXT:
+ case GL_422_REV_AVERAGE_EXT:
+ case GL_YCBCR_422_APPLE:
+ case GL_LUMINANCE_ALPHA:
+ return 2;
+ case GL_RGBA:
+ case GL_BGRA:
+ case GL_ABGR_EXT:
+ return 4;
+ case GL_COLOR_INDEX:
+ case GL_STENCIL_INDEX:
+ case GL_DEPTH_COMPONENT:
+ case GL_RED:
+ case GL_GREEN:
+ case GL_BLUE:
+ case GL_ALPHA:
+ case GL_LUMINANCE:
+ case GL_INTENSITY:
+ return 1;
+ default:
+ return 0;
+ }
}
/*
** Return the number of bytes per element, based on the element type (other
** than GL_BITMAP).
*/
-GLint __glBytesPerElement(GLenum type)
+GLint
+__glBytesPerElement(GLenum type)
{
- switch(type) {
- case GL_UNSIGNED_SHORT:
- case GL_SHORT:
- case GL_UNSIGNED_SHORT_5_6_5:
- case GL_UNSIGNED_SHORT_5_6_5_REV:
- case GL_UNSIGNED_SHORT_4_4_4_4:
- case GL_UNSIGNED_SHORT_4_4_4_4_REV:
- case GL_UNSIGNED_SHORT_5_5_5_1:
- case GL_UNSIGNED_SHORT_1_5_5_5_REV:
- case GL_UNSIGNED_SHORT_8_8_APPLE:
- case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
- case GL_UNSIGNED_SHORT_15_1_MESA:
- case GL_UNSIGNED_SHORT_1_15_REV_MESA:
- return 2;
- case GL_UNSIGNED_BYTE:
- case GL_BYTE:
- case GL_UNSIGNED_BYTE_3_3_2:
- case GL_UNSIGNED_BYTE_2_3_3_REV:
- return 1;
- case GL_INT:
- case GL_UNSIGNED_INT:
- case GL_FLOAT:
- case GL_UNSIGNED_INT_8_8_8_8:
- case GL_UNSIGNED_INT_8_8_8_8_REV:
- case GL_UNSIGNED_INT_10_10_10_2:
- case GL_UNSIGNED_INT_2_10_10_10_REV:
- case GL_UNSIGNED_INT_24_8_NV:
- case GL_UNSIGNED_INT_24_8_MESA:
- case GL_UNSIGNED_INT_8_24_REV_MESA:
- return 4;
- default:
- return 0;
- }
+ switch (type) {
+ case GL_UNSIGNED_SHORT:
+ case GL_SHORT:
+ case GL_UNSIGNED_SHORT_5_6_5:
+ case GL_UNSIGNED_SHORT_5_6_5_REV:
+ case GL_UNSIGNED_SHORT_4_4_4_4:
+ case GL_UNSIGNED_SHORT_4_4_4_4_REV:
+ case GL_UNSIGNED_SHORT_5_5_5_1:
+ case GL_UNSIGNED_SHORT_1_5_5_5_REV:
+ case GL_UNSIGNED_SHORT_8_8_APPLE:
+ case GL_UNSIGNED_SHORT_8_8_REV_APPLE:
+ case GL_UNSIGNED_SHORT_15_1_MESA:
+ case GL_UNSIGNED_SHORT_1_15_REV_MESA:
+ return 2;
+ case GL_UNSIGNED_BYTE:
+ case GL_BYTE:
+ case GL_UNSIGNED_BYTE_3_3_2:
+ case GL_UNSIGNED_BYTE_2_3_3_REV:
+ return 1;
+ case GL_INT:
+ case GL_UNSIGNED_INT:
+ case GL_FLOAT:
+ case GL_UNSIGNED_INT_8_8_8_8:
+ case GL_UNSIGNED_INT_8_8_8_8_REV:
+ case GL_UNSIGNED_INT_10_10_10_2:
+ case GL_UNSIGNED_INT_2_10_10_10_REV:
+ case GL_UNSIGNED_INT_24_8_NV:
+ case GL_UNSIGNED_INT_24_8_MESA:
+ case GL_UNSIGNED_INT_8_24_REV_MESA:
+ return 4;
+ default:
+ return 0;
+ }
}
/*
** Compute memory required for internal packed array of data of given type
** and format.
*/
-GLint __glImageSize(GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLenum type, GLenum target)
+GLint
+__glImageSize(GLsizei width, GLsizei height, GLsizei depth,
+ GLenum format, GLenum type, GLenum target)
{
- int bytes_per_row;
- int components;
+ int bytes_per_row;
+ int components;
- switch( target ) {
- case GL_PROXY_TEXTURE_1D:
- case GL_PROXY_TEXTURE_2D:
- case GL_PROXY_TEXTURE_3D:
- case GL_PROXY_TEXTURE_4D_SGIS:
- case GL_PROXY_TEXTURE_CUBE_MAP:
- case GL_PROXY_TEXTURE_RECTANGLE_ARB:
- case GL_PROXY_HISTOGRAM:
- case GL_PROXY_COLOR_TABLE:
- case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
- case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
- case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
- case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
- return 0;
- }
+ switch (target) {
+ case GL_PROXY_TEXTURE_1D:
+ case GL_PROXY_TEXTURE_2D:
+ case GL_PROXY_TEXTURE_3D:
+ case GL_PROXY_TEXTURE_4D_SGIS:
+ case GL_PROXY_TEXTURE_CUBE_MAP:
+ case GL_PROXY_TEXTURE_RECTANGLE_ARB:
+ case GL_PROXY_HISTOGRAM:
+ case GL_PROXY_COLOR_TABLE:
+ case GL_PROXY_TEXTURE_COLOR_TABLE_SGI:
+ case GL_PROXY_POST_CONVOLUTION_COLOR_TABLE:
+ case GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE:
+ case GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP:
+ return 0;
+ }
- if (width < 0 || height < 0 || depth < 0) {
- return 0;
- }
+ if (width < 0 || height < 0 || depth < 0) {
+ return 0;
+ }
- /*
+ /*
** Zero is returned if either format or type are invalid.
*/
- components = __glElementsPerGroup(format,type);
- if (type == GL_BITMAP) {
- if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
- bytes_per_row = (width + 7) >> 3;
- } else {
- return 0;
- }
- } else {
- bytes_per_row = __glBytesPerElement(type) * width;
- }
+ components = __glElementsPerGroup(format, type);
+ if (type == GL_BITMAP) {
+ if (format == GL_COLOR_INDEX || format == GL_STENCIL_INDEX) {
+ bytes_per_row = (width + 7) >> 3;
+ }
+ else {
+ return 0;
+ }
+ }
+ else {
+ bytes_per_row = __glBytesPerElement(type) * width;
+ }
- return bytes_per_row * height * depth * components;
+ return bytes_per_row * height * depth * components;
}
diff --git a/src/glx/x11/dri2.c b/src/glx/x11/dri2.c
index 5acf7ac5311..91a9c2af935 100644
--- a/src/glx/x11/dri2.c
+++ b/src/glx/x11/dri2.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright © 2008 Red Hat, Inc.
*
@@ -101,8 +102,8 @@ Bool DRI2QueryVersion(Display *dpy, int *major, int *minor)
return True;
}
-Bool DRI2Connect(Display *dpy, int screen,
- char **driverName, char **busId, unsigned int *sareaHandle)
+Bool DRI2Connect(Display *dpy, XID window,
+ char **driverName, char **deviceName)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
xDRI2ConnectReply rep;
@@ -114,14 +115,15 @@ Bool DRI2Connect(Display *dpy, int screen,
GetReq(DRI2Connect, req);
req->reqType = info->codes->major_opcode;
req->dri2ReqType = X_DRI2Connect;
- req->screen = screen;
+ req->window = window;
+ req->driverType = DRI2DriverDRI;
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
- if (rep.driverNameLength == 0 && rep.busIdLength == 0) {
+ if (rep.driverNameLength == 0 && rep.deviceNameLength == 0) {
UnlockDisplay(dpy);
SyncHandle();
return False;
@@ -131,7 +133,7 @@ Bool DRI2Connect(Display *dpy, int screen,
if (*driverName == NULL) {
_XEatData(dpy,
((rep.driverNameLength + 3) & ~3) +
- ((rep.busIdLength + 3) & ~3));
+ ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
@@ -139,16 +141,16 @@ Bool DRI2Connect(Display *dpy, int screen,
_XReadPad(dpy, *driverName, rep.driverNameLength);
(*driverName)[rep.driverNameLength] = '\0';
- *busId = Xmalloc(rep.busIdLength + 1);
- if (*busId == NULL) {
+ *deviceName = Xmalloc(rep.deviceNameLength + 1);
+ if (*deviceName == NULL) {
Xfree(*driverName);
- _XEatData(dpy, ((rep.busIdLength + 3) & ~3));
+ _XEatData(dpy, ((rep.deviceNameLength + 3) & ~3));
UnlockDisplay(dpy);
SyncHandle();
return False;
}
- _XReadPad(dpy, *busId, rep.busIdLength);
- (*busId)[rep.busIdLength] = '\0';
+ _XReadPad(dpy, *deviceName, rep.deviceNameLength);
+ (*deviceName)[rep.deviceNameLength] = '\0';
UnlockDisplay(dpy);
SyncHandle();
@@ -156,26 +158,27 @@ Bool DRI2Connect(Display *dpy, int screen,
return True;
}
-Bool DRI2AuthConnection(Display *dpy, int screen, drm_magic_t magic)
+Bool DRI2Authenticate(Display *dpy, XID window, drm_magic_t magic)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2AuthConnectionReq *req;
- xDRI2AuthConnectionReply rep;
+ xDRI2AuthenticateReq *req;
+ xDRI2AuthenticateReply rep;
XextCheckExtension (dpy, info, dri2ExtensionName, False);
LockDisplay(dpy);
- GetReq(DRI2AuthConnection, req);
+ GetReq(DRI2Authenticate, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2AuthConnection;
- req->screen = screen;
+ req->dri2ReqType = X_DRI2Authenticate;
+ req->window = window;
req->magic = magic;
- rep.authenticated = 0;
+
if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
UnlockDisplay(dpy);
SyncHandle();
return False;
}
+
UnlockDisplay(dpy);
SyncHandle();
@@ -198,6 +201,24 @@ void DRI2CreateDrawable(Display *dpy, XID drawable)
SyncHandle();
}
+void DRI2DestroyDrawable(Display *dpy, XID drawable)
+{
+ XExtDisplayInfo *info = DRI2FindDisplay(dpy);
+ xDRI2DestroyDrawableReq *req;
+
+ XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
+
+ XSync(dpy, False);
+
+ LockDisplay(dpy);
+ GetReq(DRI2DestroyDrawable, req);
+ req->reqType = info->codes->major_opcode;
+ req->dri2ReqType = X_DRI2DestroyDrawable;
+ req->drawable = drawable;
+ UnlockDisplay(dpy);
+ SyncHandle();
+}
+
DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
@@ -256,45 +277,27 @@ DRI2Buffer *DRI2GetBuffers(Display *dpy, XID drawable,
return buffers;
}
-void DRI2SwapBuffers(Display *dpy, XID drawable,
- int x, int y, int width, int height)
+void DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+ CARD32 dest, CARD32 src)
{
XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2SwapBuffersReq *req;
- xDRI2SwapBuffersReply rep;
+ xDRI2CopyRegionReq *req;
+ xDRI2CopyRegionReply rep;
XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
LockDisplay(dpy);
- GetReq(DRI2SwapBuffers, req);
+ GetReq(DRI2CopyRegion, req);
req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2SwapBuffers;
+ req->dri2ReqType = X_DRI2CopyRegion;
req->drawable = drawable;
- req->x = x;
- req->y = y;
- req->width = width;
- req->height = height;
+ req->region = region;
+ req->dest = dest;
+ req->src = src;
+ req->bitmask = 0;
_XReply(dpy, (xReply *)&rep, 0, xFalse);
UnlockDisplay(dpy);
SyncHandle();
}
-
-void DRI2DestroyDrawable(Display *dpy, XID drawable)
-{
- XExtDisplayInfo *info = DRI2FindDisplay(dpy);
- xDRI2DestroyDrawableReq *req;
-
- XextSimpleCheckExtension (dpy, info, dri2ExtensionName);
-
- XSync(dpy, False);
-
- LockDisplay(dpy);
- GetReq(DRI2DestroyDrawable, req);
- req->reqType = info->codes->major_opcode;
- req->dri2ReqType = X_DRI2DestroyDrawable;
- req->drawable = drawable;
- UnlockDisplay(dpy);
- SyncHandle();
-}
diff --git a/src/glx/x11/dri2.h b/src/glx/x11/dri2.h
index e57c4ce644f..c1bfa664bb8 100644
--- a/src/glx/x11/dri2.h
+++ b/src/glx/x11/dri2.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright © 2007,2008 Red Hat, Inc.
*
@@ -33,6 +34,9 @@
#ifndef _DRI2_H_
#define _DRI2_H_
+#include <X11/extensions/Xfixes.h>
+#include <X11/extensions/dri2tokens.h>
+
typedef struct {
unsigned int attachment;
unsigned int name;
@@ -46,10 +50,10 @@ DRI2QueryExtension(Display *display, int *eventBase, int *errorBase);
extern Bool
DRI2QueryVersion(Display *display, int *major, int *minor);
extern Bool
-DRI2Connect(Display *display, int screen,
- char **driverName, char **busId, unsigned int *sareaHandle);
+DRI2Connect(Display *display, XID window,
+ char **driverName, char **deviceName);
extern Bool
-DRI2AuthConnection(Display *display, int screen, drm_magic_t magic);
+DRI2Authenticate(Display *display, XID window, drm_magic_t magic);
extern void
DRI2CreateDrawable(Display *display, XID drawable);
extern void
@@ -59,8 +63,9 @@ DRI2GetBuffers(Display *dpy, XID drawable,
int *width, int *height,
unsigned int *attachments, int count,
int *outCount);
+
extern void
-DRI2SwapBuffers(Display *dpy, XID drawable,
- int x, int y, int width, int height);
+DRI2CopyRegion(Display *dpy, XID drawable, XserverRegion region,
+ CARD32 dest, CARD32 src);
#endif
diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c
index ed9054627fa..bf76d1899bb 100644
--- a/src/glx/x11/dri2_glx.c
+++ b/src/glx/x11/dri2_glx.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright © 2008 Red Hat, Inc.
*
@@ -38,8 +39,9 @@
#include "glxclient.h"
#include "glcontextmodes.h"
#include "xf86dri.h"
-#include "sarea.h"
#include <dlfcn.h>
+#include <fcntl.h>
+#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include "xf86drm.h"
@@ -182,19 +184,35 @@ static __GLXDRIdrawable *dri2CreateDrawable(__GLXscreenConfigs *psc,
return &pdraw->base;
}
+static void dri2CopySubBuffer(__GLXDRIdrawable *pdraw,
+ int x, int y, int width, int height)
+{
+ XRectangle xrect;
+ XserverRegion region;
+
+ xrect.x = x;
+ xrect.y = y;
+ xrect.width = width;
+ xrect.height = height;
+
+ region = XFixesCreateRegion(pdraw->psc->dpy, &xrect, 1);
+ DRI2CopyRegion(pdraw->psc->dpy, pdraw->drawable, region,
+ DRI2BufferFrontLeft, DRI2BufferBackLeft);
+ XFixesDestroyRegion(pdraw->psc->dpy, region);
+}
+
static void dri2SwapBuffers(__GLXDRIdrawable *pdraw)
{
__GLXDRIdrawablePrivate *priv = (__GLXDRIdrawablePrivate *) pdraw;
- DRI2SwapBuffers(pdraw->psc->dpy, pdraw->drawable,
- 0, 0, priv->width, priv->height);
+ dri2CopySubBuffer(pdraw, 0, 0, priv->width, priv->height);
}
static void dri2DestroyScreen(__GLXscreenConfigs *psc)
{
/* Free the direct rendering per screen data */
(*psc->core->destroyScreen)(psc->__driScreen);
- drmClose(psc->fd);
+ close(psc->fd);
psc->__driScreen = NULL;
}
@@ -248,8 +266,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
const __DRIconfig **driver_configs;
const __DRIextension **extensions;
__GLXDRIscreen *psp;
- unsigned int sareaHandle;
- char *driverName, *busID;
+ char *driverName, *deviceName;
drm_magic_t magic;
int i;
@@ -260,7 +277,8 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
/* Initialize per screen dynamic client GLX extensions */
psc->ext_list_first_time = GL_TRUE;
- if (!DRI2Connect(psc->dpy, screen, &driverName, &busID, &sareaHandle))
+ if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen),
+ &driverName, &deviceName))
return NULL;
psc->driver = driOpenDriver(driverName);
@@ -285,7 +303,7 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
goto handle_error;
}
- psc->fd = drmOpen(NULL, busID);
+ psc->fd = open(deviceName, O_RDWR);
if (psc->fd < 0) {
ErrorMessageF("failed to open drm device: %s\n", strerror(errno));
return NULL;
@@ -294,10 +312,8 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
if (drmGetMagic(psc->fd, &magic))
return NULL;
- if (!DRI2AuthConnection(psc->dpy, screen, magic)) {
- ErrorMessageF("failed to authenticate drm access\n");
+ if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic))
return NULL;
- }
psc->__driScreen =
psc->dri2->createNewScreen(screen, psc->fd,
@@ -316,15 +332,16 @@ static __GLXDRIscreen *dri2CreateScreen(__GLXscreenConfigs *psc, int screen,
psp->createContext = dri2CreateContext;
psp->createDrawable = dri2CreateDrawable;
psp->swapBuffers = dri2SwapBuffers;
+ psp->copySubBuffer = dri2CopySubBuffer;
Xfree(driverName);
- Xfree(busID);
+ Xfree(deviceName);
return psp;
handle_error:
Xfree(driverName);
- Xfree(busID);
+ Xfree(deviceName);
/* FIXME: clean up here */
diff --git a/src/glx/x11/dri_common.c b/src/glx/x11/dri_common.c
index fbce6ac3e3d..f6e16fa856a 100644
--- a/src/glx/x11/dri_common.c
+++ b/src/glx/x11/dri_common.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright © 2008 Red Hat, Inc.
@@ -339,7 +340,7 @@ driBindExtensions(__GLXscreenConfigs *psc, int dri2)
for (i = 0; extensions[i]; i++) {
#ifdef __DRI_COPY_SUB_BUFFER
if (strcmp(extensions[i]->name, __DRI_COPY_SUB_BUFFER) == 0) {
- psc->copySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
+ psc->driCopySubBuffer = (__DRIcopySubBufferExtension *) extensions[i];
__glXEnableDirectExtension(psc, "GLX_MESA_copy_sub_buffer_bit");
}
#endif
diff --git a/src/glx/x11/dri_common.h b/src/glx/x11/dri_common.h
index 15f6cc87b9f..faa6adc10fe 100644
--- a/src/glx/x11/dri_common.h
+++ b/src/glx/x11/dri_common.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* Copyright © 2008 Red Hat, Inc.
@@ -36,16 +37,17 @@
#ifndef _DRI_COMMON_H
#define _DRI_COMMON_H
-typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
+typedef struct __GLXDRIconfigPrivateRec __GLXDRIconfigPrivate;
-struct __GLXDRIconfigPrivateRec {
- __GLcontextModes modes;
- const __DRIconfig *driConfig;
+struct __GLXDRIconfigPrivateRec
+{
+ __GLcontextModes modes;
+ const __DRIconfig *driConfig;
};
-extern __GLcontextModes *
-driConvertConfigs(const __DRIcoreExtension *core,
- __GLcontextModes *modes, const __DRIconfig **configs);
+extern __GLcontextModes *driConvertConfigs(const __DRIcoreExtension * core,
+ __GLcontextModes * modes,
+ const __DRIconfig ** configs);
extern const __DRIsystemTimeExtension systemTimeExtension;
@@ -55,6 +57,6 @@ extern void ErrorMessageF(const char *f, ...);
extern void *driOpenDriver(const char *driverName);
-extern void driBindExtensions(__GLXscreenConfigs *psc, int dri2);
+extern void driBindExtensions(__GLXscreenConfigs * psc, int dri2);
#endif /* _DRI_COMMON_H */
diff --git a/src/glx/x11/dri_glx.c b/src/glx/x11/dri_glx.c
index 47203f50087..7aa97b9ee90 100644
--- a/src/glx/x11/dri_glx.c
+++ b/src/glx/x11/dri_glx.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -574,6 +575,13 @@ static void driSwapBuffers(__GLXDRIdrawable *pdraw)
(*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
}
+static void driCopySubBuffer(__GLXDRIdrawable *pdraw,
+ int x, int y, int width, int height)
+{
+ (*pdraw->psc->driCopySubBuffer->copySubBuffer)(pdraw->driDrawable,
+ x, y, width, height);
+}
+
static void driDestroyScreen(__GLXscreenConfigs *psc)
{
/* Free the direct rendering per screen data */
@@ -641,6 +649,8 @@ static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
}
driBindExtensions(psc, 0);
+ if (psc->driCopySubBuffer)
+ psp->copySubBuffer = driCopySubBuffer;
psp->destroyScreen = driDestroyScreen;
psp->createContext = driCreateContext;
diff --git a/src/glx/x11/drisw_glx.c b/src/glx/x11/drisw_glx.c
index 7bb4794f30c..78ed32f497f 100644
--- a/src/glx/x11/drisw_glx.c
+++ b/src/glx/x11/drisw_glx.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright 2008 George Sapountzis
*
@@ -33,395 +34,398 @@ typedef struct __GLXDRIdisplayPrivateRec __GLXDRIdisplayPrivate;
typedef struct __GLXDRIcontextPrivateRec __GLXDRIcontextPrivate;
typedef struct __GLXDRIdrawablePrivateRec __GLXDRIdrawablePrivate;
-struct __GLXDRIdisplayPrivateRec {
- __GLXDRIdisplay base;
+struct __GLXDRIdisplayPrivateRec
+{
+ __GLXDRIdisplay base;
};
-struct __GLXDRIcontextPrivateRec {
- __GLXDRIcontext base;
- __DRIcontext *driContext;
- __GLXscreenConfigs *psc;
+struct __GLXDRIcontextPrivateRec
+{
+ __GLXDRIcontext base;
+ __DRIcontext *driContext;
+ __GLXscreenConfigs *psc;
};
-struct __GLXDRIdrawablePrivateRec {
- __GLXDRIdrawable base;
+struct __GLXDRIdrawablePrivateRec
+{
+ __GLXDRIdrawable base;
- GC gc;
- GC swapgc;
+ GC gc;
+ GC swapgc;
- XVisualInfo *visinfo;
- XImage *ximage;
- int bpp;
+ XVisualInfo *visinfo;
+ XImage *ximage;
+ int bpp;
};
/**
* swrast loader functions
*/
-static Bool XCreateDrawable(__GLXDRIdrawablePrivate *pdp,
- Display *dpy, XID drawable, int visualid)
+static Bool
+XCreateDrawable(__GLXDRIdrawablePrivate * pdp,
+ Display * dpy, XID drawable, int visualid)
{
- XGCValues gcvalues;
- long visMask;
- XVisualInfo visTemp;
- int num_visuals;
-
- /* create GC's */
- pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
- pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
-
- gcvalues.function = GXcopy;
- gcvalues.graphics_exposures = False;
- XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
- XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
- XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
-
- /* create XImage */
- visTemp.screen = DefaultScreen(dpy);
- visTemp.visualid = visualid;
- visMask = (VisualScreenMask | VisualIDMask);
- pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
-
- pdp->ximage = XCreateImage(dpy,
- pdp->visinfo->visual,
- pdp->visinfo->depth,
- ZPixmap, 0, /* format, offset */
- NULL, /* data */
- 0, 0, /* size */
- 32, /* bitmap_pad */
- 0); /* bytes_per_line */
-
- /* get the true number of bits per pixel */
- pdp->bpp = pdp->ximage->bits_per_pixel;
-
- return True;
+ XGCValues gcvalues;
+ long visMask;
+ XVisualInfo visTemp;
+ int num_visuals;
+
+ /* create GC's */
+ pdp->gc = XCreateGC(dpy, drawable, 0, NULL);
+ pdp->swapgc = XCreateGC(dpy, drawable, 0, NULL);
+
+ gcvalues.function = GXcopy;
+ gcvalues.graphics_exposures = False;
+ XChangeGC(dpy, pdp->gc, GCFunction, &gcvalues);
+ XChangeGC(dpy, pdp->swapgc, GCFunction, &gcvalues);
+ XChangeGC(dpy, pdp->swapgc, GCGraphicsExposures, &gcvalues);
+
+ /* create XImage */
+ visTemp.screen = DefaultScreen(dpy);
+ visTemp.visualid = visualid;
+ visMask = (VisualScreenMask | VisualIDMask);
+ pdp->visinfo = XGetVisualInfo(dpy, visMask, &visTemp, &num_visuals);
+
+ pdp->ximage = XCreateImage(dpy, pdp->visinfo->visual, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */
+ NULL, /* data */
+ 0, 0, /* size */
+ 32, /* bitmap_pad */
+ 0); /* bytes_per_line */
+
+ /* get the true number of bits per pixel */
+ pdp->bpp = pdp->ximage->bits_per_pixel;
+
+ return True;
}
-static void XDestroyDrawable(__GLXDRIdrawablePrivate *pdp,
- Display *dpy, XID drawable)
+static void
+XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable)
{
- XDestroyImage(pdp->ximage);
- XFree(pdp->visinfo);
+ XDestroyImage(pdp->ximage);
+ XFree(pdp->visinfo);
- XFreeGC(dpy, pdp->gc);
- XFreeGC(dpy, pdp->swapgc);
+ XFreeGC(dpy, pdp->gc);
+ XFreeGC(dpy, pdp->swapgc);
}
static void
-swrastGetDrawableInfo(__DRIdrawable *draw,
- int *x, int *y, int *w, int *h,
- void *loaderPrivate)
+swrastGetDrawableInfo(__DRIdrawable * draw,
+ int *x, int *y, int *w, int *h, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
- __GLXDRIdrawable *pdraw = &(pdp->base);;
- Display *dpy = pdraw->psc->dpy;
- Drawable drawable;
+ __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ __GLXDRIdrawable *pdraw = &(pdp->base);;
+ Display *dpy = pdraw->psc->dpy;
+ Drawable drawable;
- Window root;
- Status stat;
- unsigned int bw, depth;
+ Window root;
+ Status stat;
+ unsigned int bw, depth;
- drawable = pdraw->xDrawable;
+ drawable = pdraw->xDrawable;
- stat = XGetGeometry(dpy, drawable, &root,
- x, y, (unsigned int *)w, (unsigned int *)h,
- &bw, &depth);
+ stat = XGetGeometry(dpy, drawable, &root,
+ x, y, (unsigned int *) w, (unsigned int *) h,
+ &bw, &depth);
}
static inline int
bytes_per_line(int w, int bpp, unsigned mul)
{
- unsigned mask = mul - 1;
+ unsigned mask = mul - 1;
- return ((w * bpp + mask) & ~mask) / 8;
+ return ((w * bpp + mask) & ~mask) / 8;
}
static void
-swrastPutImage(__DRIdrawable *draw, int op,
- int x, int y, int w, int h, char *data,
- void *loaderPrivate)
+swrastPutImage(__DRIdrawable * draw, int op,
+ int x, int y, int w, int h, char *data, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
- __GLXDRIdrawable *pdraw = &(pdp->base);;
- Display *dpy = pdraw->psc->dpy;
- Drawable drawable;
- XImage *ximage;
- GC gc;
-
- switch (op) {
- case __DRI_SWRAST_IMAGE_OP_DRAW:
- gc = pdp->gc;
- break;
- case __DRI_SWRAST_IMAGE_OP_SWAP:
- gc = pdp->swapgc;
- break;
- default:
- return;
- }
-
- drawable = pdraw->xDrawable;
-
- ximage = pdp->ximage;
- ximage->data = data;
- ximage->width = w;
- ximage->height = h;
- ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
-
- XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
-
- ximage->data = NULL;
+ __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ __GLXDRIdrawable *pdraw = &(pdp->base);;
+ Display *dpy = pdraw->psc->dpy;
+ Drawable drawable;
+ XImage *ximage;
+ GC gc;
+
+ switch (op) {
+ case __DRI_SWRAST_IMAGE_OP_DRAW:
+ gc = pdp->gc;
+ break;
+ case __DRI_SWRAST_IMAGE_OP_SWAP:
+ gc = pdp->swapgc;
+ break;
+ default:
+ return;
+ }
+
+ drawable = pdraw->xDrawable;
+
+ ximage = pdp->ximage;
+ ximage->data = data;
+ ximage->width = w;
+ ximage->height = h;
+ ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+
+ XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h);
+
+ ximage->data = NULL;
}
static void
-swrastGetImage(__DRIdrawable *draw,
- int x, int y, int w, int h, char *data,
- void *loaderPrivate)
+swrastGetImage(__DRIdrawable * draw,
+ int x, int y, int w, int h, char *data, void *loaderPrivate)
{
- __GLXDRIdrawablePrivate *pdp = loaderPrivate;
- __GLXDRIdrawable *pdraw = &(pdp->base);;
- Display *dpy = pdraw->psc->dpy;
- Drawable drawable;
- XImage *ximage;
+ __GLXDRIdrawablePrivate *pdp = loaderPrivate;
+ __GLXDRIdrawable *pdraw = &(pdp->base);;
+ Display *dpy = pdraw->psc->dpy;
+ Drawable drawable;
+ XImage *ximage;
- drawable = pdraw->xDrawable;
+ drawable = pdraw->xDrawable;
- ximage = pdp->ximage;
- ximage->data = data;
- ximage->width = w;
- ximage->height = h;
- ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
+ ximage = pdp->ximage;
+ ximage->data = data;
+ ximage->width = w;
+ ximage->height = h;
+ ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32);
- XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
+ XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0);
- ximage->data = NULL;
+ ximage->data = NULL;
}
static const __DRIswrastLoaderExtension swrastLoaderExtension = {
- { __DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION },
- swrastGetDrawableInfo,
- swrastPutImage,
- swrastGetImage
+ {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION},
+ swrastGetDrawableInfo,
+ swrastPutImage,
+ swrastGetImage
};
static const __DRIextension *loader_extensions[] = {
- &systemTimeExtension.base,
- &swrastLoaderExtension.base,
- NULL
+ &systemTimeExtension.base,
+ &swrastLoaderExtension.base,
+ NULL
};
/**
* GLXDRI functions
*/
-static void driDestroyContext(__GLXDRIcontext *context,
- __GLXscreenConfigs *psc, Display *dpy)
+static void
+driDestroyContext(__GLXDRIcontext * context,
+ __GLXscreenConfigs * psc, Display * dpy)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+ const __DRIcoreExtension *core = pcp->psc->core;
- (*core->destroyContext)(pcp->driContext);
+ (*core->destroyContext) (pcp->driContext);
- Xfree(pcp);
+ Xfree(pcp);
}
-static Bool driBindContext(__GLXDRIcontext *context,
- __GLXDRIdrawable *draw, __GLXDRIdrawable *read)
+static Bool
+driBindContext(__GLXDRIcontext * context,
+ __GLXDRIdrawable * draw, __GLXDRIdrawable * read)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+ const __DRIcoreExtension *core = pcp->psc->core;
- return (*core->bindContext)(pcp->driContext,
- draw->driDrawable,
- read->driDrawable);
+ return (*core->bindContext) (pcp->driContext,
+ draw->driDrawable, read->driDrawable);
}
-static void driUnbindContext(__GLXDRIcontext *context)
+static void
+driUnbindContext(__GLXDRIcontext * context)
{
- __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
- const __DRIcoreExtension *core = pcp->psc->core;
+ __GLXDRIcontextPrivate *pcp = (__GLXDRIcontextPrivate *) context;
+ const __DRIcoreExtension *core = pcp->psc->core;
- (*core->unbindContext)(pcp->driContext);
+ (*core->unbindContext) (pcp->driContext);
}
-static __GLXDRIcontext *driCreateContext(__GLXscreenConfigs *psc,
- const __GLcontextModes *mode,
- GLXContext gc,
- GLXContext shareList, int renderType)
+static __GLXDRIcontext *
+driCreateContext(__GLXscreenConfigs * psc,
+ const __GLcontextModes * mode,
+ GLXContext gc, GLXContext shareList, int renderType)
{
- __GLXDRIcontextPrivate *pcp, *pcp_shared;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
- const __DRIcoreExtension *core = psc->core;
- __DRIcontext *shared = NULL;
-
- if (!psc || !psc->driScreen)
- return NULL;
-
- if (shareList) {
- pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
- shared = pcp_shared->driContext;
- }
-
- pcp = Xmalloc(sizeof *pcp);
- if (pcp == NULL)
- return NULL;
-
- pcp->psc = psc;
- pcp->driContext =
- (*core->createNewContext)(psc->__driScreen,
- config->driConfig, shared, pcp);
- if (pcp->driContext == NULL) {
- Xfree(pcp);
- return NULL;
- }
-
- pcp->base.destroyContext = driDestroyContext;
- pcp->base.bindContext = driBindContext;
- pcp->base.unbindContext = driUnbindContext;
-
- return &pcp->base;
+ __GLXDRIcontextPrivate *pcp, *pcp_shared;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) mode;
+ const __DRIcoreExtension *core = psc->core;
+ __DRIcontext *shared = NULL;
+
+ if (!psc || !psc->driScreen)
+ return NULL;
+
+ if (shareList) {
+ pcp_shared = (__GLXDRIcontextPrivate *) shareList->driContext;
+ shared = pcp_shared->driContext;
+ }
+
+ pcp = Xmalloc(sizeof *pcp);
+ if (pcp == NULL)
+ return NULL;
+
+ pcp->psc = psc;
+ pcp->driContext =
+ (*core->createNewContext) (psc->__driScreen,
+ config->driConfig, shared, pcp);
+ if (pcp->driContext == NULL) {
+ Xfree(pcp);
+ return NULL;
+ }
+
+ pcp->base.destroyContext = driDestroyContext;
+ pcp->base.bindContext = driBindContext;
+ pcp->base.unbindContext = driUnbindContext;
+
+ return &pcp->base;
}
-static void driDestroyDrawable(__GLXDRIdrawable *pdraw)
+static void
+driDestroyDrawable(__GLXDRIdrawable * pdraw)
{
- __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw;
- const __DRIcoreExtension *core = pdraw->psc->core;
+ __GLXDRIdrawablePrivate *pdp = (__GLXDRIdrawablePrivate *) pdraw;
+ const __DRIcoreExtension *core = pdraw->psc->core;
- (*core->destroyDrawable)(pdraw->driDrawable);
+ (*core->destroyDrawable) (pdraw->driDrawable);
- XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
- Xfree(pdp);
+ XDestroyDrawable(pdp, pdraw->psc->dpy, pdraw->drawable);
+ Xfree(pdp);
}
-static __GLXDRIdrawable *driCreateDrawable(__GLXscreenConfigs *psc,
- XID xDrawable,
- GLXDrawable drawable,
- const __GLcontextModes *modes)
+static __GLXDRIdrawable *
+driCreateDrawable(__GLXscreenConfigs * psc,
+ XID xDrawable,
+ GLXDrawable drawable, const __GLcontextModes * modes)
{
- __GLXDRIdrawable *pdraw;
- __GLXDRIdrawablePrivate *pdp;
- __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
- const __DRIswrastExtension *swrast = psc->swrast;
+ __GLXDRIdrawable *pdraw;
+ __GLXDRIdrawablePrivate *pdp;
+ __GLXDRIconfigPrivate *config = (__GLXDRIconfigPrivate *) modes;
+ const __DRIswrastExtension *swrast = psc->swrast;
- /* Old dri can't handle GLX 1.3+ drawable constructors. */
- if (xDrawable != drawable)
- return NULL;
+ /* Old dri can't handle GLX 1.3+ drawable constructors. */
+ if (xDrawable != drawable)
+ return NULL;
- pdp = Xmalloc(sizeof(*pdp));
- if (!pdp)
- return NULL;
+ pdp = Xmalloc(sizeof(*pdp));
+ if (!pdp)
+ return NULL;
- pdraw = &(pdp->base);
- pdraw->xDrawable = xDrawable;
- pdraw->drawable = drawable;
- pdraw->psc = psc;
+ pdraw = &(pdp->base);
+ pdraw->xDrawable = xDrawable;
+ pdraw->drawable = drawable;
+ pdraw->psc = psc;
- XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
+ XCreateDrawable(pdp, psc->dpy, xDrawable, modes->visualID);
- /* Create a new drawable */
- pdraw->driDrawable =
- (*swrast->createNewDrawable)(psc->__driScreen,
- config->driConfig,
- pdp);
+ /* Create a new drawable */
+ pdraw->driDrawable =
+ (*swrast->createNewDrawable) (psc->__driScreen, config->driConfig, pdp);
- if (!pdraw->driDrawable) {
- XDestroyDrawable(pdp, psc->dpy, xDrawable);
- Xfree(pdp);
- return NULL;
- }
+ if (!pdraw->driDrawable) {
+ XDestroyDrawable(pdp, psc->dpy, xDrawable);
+ Xfree(pdp);
+ return NULL;
+ }
- pdraw->destroyDrawable = driDestroyDrawable;
+ pdraw->destroyDrawable = driDestroyDrawable;
- return pdraw;
+ return pdraw;
}
-static void driSwapBuffers(__GLXDRIdrawable *pdraw)
+static void
+driSwapBuffers(__GLXDRIdrawable * pdraw)
{
- (*pdraw->psc->core->swapBuffers)(pdraw->driDrawable);
+ (*pdraw->psc->core->swapBuffers) (pdraw->driDrawable);
}
-static void driDestroyScreen(__GLXscreenConfigs *psc)
+static void
+driDestroyScreen(__GLXscreenConfigs * psc)
{
- /* Free the direct rendering per screen data */
- (*psc->core->destroyScreen)(psc->__driScreen);
- psc->__driScreen = NULL;
- if (psc->driver)
- dlclose(psc->driver);
+ /* Free the direct rendering per screen data */
+ (*psc->core->destroyScreen) (psc->__driScreen);
+ psc->__driScreen = NULL;
+ if (psc->driver)
+ dlclose(psc->driver);
}
-static __GLXDRIscreen *driCreateScreen(__GLXscreenConfigs *psc, int screen,
- __GLXdisplayPrivate *priv)
+static __GLXDRIscreen *
+driCreateScreen(__GLXscreenConfigs * psc, int screen,
+ __GLXdisplayPrivate * priv)
{
- __GLXDRIscreen *psp;
- const __DRIconfig **driver_configs;
- const __DRIextension **extensions;
- const char *driverName = "swrast";
- int i;
-
- psp = Xmalloc(sizeof *psp);
- if (psp == NULL)
- return NULL;
-
- /* Initialize per screen dynamic client GLX extensions */
- psc->ext_list_first_time = GL_TRUE;
-
- psc->driver = driOpenDriver(driverName);
- if (psc->driver == NULL)
- goto handle_error;
-
- extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
- if (extensions == NULL) {
- ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
- goto handle_error;
- }
-
- for (i = 0; extensions[i]; i++) {
- if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
- psc->core = (__DRIcoreExtension *) extensions[i];
- if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
- psc->swrast = (__DRIswrastExtension *) extensions[i];
- }
-
- if (psc->core == NULL || psc->swrast == NULL) {
- ErrorMessageF("core dri extension not found\n");
- goto handle_error;
- }
-
- psc->__driScreen =
- psc->swrast->createNewScreen(screen,
- loader_extensions, &driver_configs, psc);
- if (psc->__driScreen == NULL) {
- ErrorMessageF("failed to create dri screen\n");
- goto handle_error;
- }
-
- driBindExtensions(psc, 0);
-
- psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
- psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
-
- psp->destroyScreen = driDestroyScreen;
- psp->createContext = driCreateContext;
- psp->createDrawable = driCreateDrawable;
- psp->swapBuffers = driSwapBuffers;
-
- return psp;
+ __GLXDRIscreen *psp;
+ const __DRIconfig **driver_configs;
+ const __DRIextension **extensions;
+ const char *driverName = "swrast";
+ int i;
+
+ psp = Xmalloc(sizeof *psp);
+ if (psp == NULL)
+ return NULL;
+
+ /* Initialize per screen dynamic client GLX extensions */
+ psc->ext_list_first_time = GL_TRUE;
+
+ psc->driver = driOpenDriver(driverName);
+ if (psc->driver == NULL)
+ goto handle_error;
+
+ extensions = dlsym(psc->driver, __DRI_DRIVER_EXTENSIONS);
+ if (extensions == NULL) {
+ ErrorMessageF("driver exports no extensions (%s)\n", dlerror());
+ goto handle_error;
+ }
+
+ for (i = 0; extensions[i]; i++) {
+ if (strcmp(extensions[i]->name, __DRI_CORE) == 0)
+ psc->core = (__DRIcoreExtension *) extensions[i];
+ if (strcmp(extensions[i]->name, __DRI_SWRAST) == 0)
+ psc->swrast = (__DRIswrastExtension *) extensions[i];
+ }
+
+ if (psc->core == NULL || psc->swrast == NULL) {
+ ErrorMessageF("core dri extension not found\n");
+ goto handle_error;
+ }
+
+ psc->__driScreen =
+ psc->swrast->createNewScreen(screen,
+ loader_extensions, &driver_configs, psc);
+ if (psc->__driScreen == NULL) {
+ ErrorMessageF("failed to create dri screen\n");
+ goto handle_error;
+ }
+
+ driBindExtensions(psc, 0);
+
+ psc->configs = driConvertConfigs(psc->core, psc->configs, driver_configs);
+ psc->visuals = driConvertConfigs(psc->core, psc->visuals, driver_configs);
+
+ psp->destroyScreen = driDestroyScreen;
+ psp->createContext = driCreateContext;
+ psp->createDrawable = driCreateDrawable;
+ psp->swapBuffers = driSwapBuffers;
+
+ return psp;
handle_error:
- Xfree(psp);
+ Xfree(psp);
- if (psc->driver)
- dlclose(psc->driver);
+ if (psc->driver)
+ dlclose(psc->driver);
- ErrorMessageF("reverting to indirect rendering\n");
+ ErrorMessageF("reverting to indirect rendering\n");
- return NULL;
+ return NULL;
}
/* Called from __glXFreeDisplayPrivate.
*/
-static void driDestroyDisplay(__GLXDRIdisplay *dpy)
+static void
+driDestroyDisplay(__GLXDRIdisplay * dpy)
{
- Xfree(dpy);
+ Xfree(dpy);
}
/*
@@ -429,18 +433,19 @@ static void driDestroyDisplay(__GLXDRIdisplay *dpy)
* This is called from __glXInitialize() when we are given a new
* display pointer.
*/
-_X_HIDDEN __GLXDRIdisplay *driswCreateDisplay(Display *dpy)
+_X_HIDDEN __GLXDRIdisplay *
+driswCreateDisplay(Display * dpy)
{
- __GLXDRIdisplayPrivate *pdpyp;
+ __GLXDRIdisplayPrivate *pdpyp;
- pdpyp = Xmalloc(sizeof *pdpyp);
- if (pdpyp == NULL)
- return NULL;
+ pdpyp = Xmalloc(sizeof *pdpyp);
+ if (pdpyp == NULL)
+ return NULL;
- pdpyp->base.destroyDisplay = driDestroyDisplay;
- pdpyp->base.createScreen = driCreateScreen;
+ pdpyp->base.destroyDisplay = driDestroyDisplay;
+ pdpyp->base.createScreen = driCreateScreen;
- return &pdpyp->base;
+ return &pdpyp->base;
}
#endif /* GLX_DIRECT_RENDERING */
diff --git a/src/glx/x11/eval.c b/src/glx/x11/eval.c
index 58075e22313..418093565c6 100644
--- a/src/glx/x11/eval.c
+++ b/src/glx/x11/eval.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -36,91 +37,97 @@
** the information that the GL needs.
*/
-void __glFillMap1f(GLint k, GLint order, GLint stride,
- const GLfloat *points, GLubyte *pc)
+void
+__glFillMap1f(GLint k, GLint order, GLint stride,
+ const GLfloat * points, GLubyte * pc)
{
- if (stride == k) {
- /* Just copy the data */
- __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
- } else {
- GLint i;
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_FLOAT_ARRAY(0, points, order * k);
+ }
+ else {
+ GLint i;
- for (i = 0; i < order; i++) {
- __GLX_PUT_FLOAT_ARRAY(0, points, k);
- points += stride;
- pc += k * __GLX_SIZE_FLOAT32;
- }
- }
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_FLOAT_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT32;
+ }
+ }
}
-void __glFillMap1d(GLint k, GLint order, GLint stride,
- const GLdouble *points, GLubyte *pc)
+void
+__glFillMap1d(GLint k, GLint order, GLint stride,
+ const GLdouble * points, GLubyte * pc)
{
- if (stride == k) {
- /* Just copy the data */
- __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
- } else {
- GLint i;
- for (i = 0; i < order; i++) {
- __GLX_PUT_DOUBLE_ARRAY(0, points, k);
- points += stride;
- pc += k * __GLX_SIZE_FLOAT64;
- }
- }
+ if (stride == k) {
+ /* Just copy the data */
+ __GLX_PUT_DOUBLE_ARRAY(0, points, order * k);
+ }
+ else {
+ GLint i;
+ for (i = 0; i < order; i++) {
+ __GLX_PUT_DOUBLE_ARRAY(0, points, k);
+ points += stride;
+ pc += k * __GLX_SIZE_FLOAT64;
+ }
+ }
}
-void __glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
- GLint majorStride, GLint minorStride,
- const GLfloat *points, GLfloat *data)
+void
+__glFillMap2f(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLfloat * points, GLfloat * data)
{
- GLint i, j, x;
+ GLint i, j, x;
- if ((minorStride == k) && (majorStride == minorOrder*k)) {
- /* Just copy the data */
- __GLX_MEM_COPY(data, points, majorOrder * majorStride *
- __GLX_SIZE_FLOAT32);
- return;
- }
- for (i = 0; i < majorOrder; i++) {
- for (j = 0; j < minorOrder; j++) {
- for (x = 0; x < k; x++) {
- data[x] = points[x];
- }
- points += minorStride;
- data += k;
- }
- points += majorStride - minorStride * minorOrder;
- }
+ if ((minorStride == k) && (majorStride == minorOrder * k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT32);
+ return;
+ }
+ for (i = 0; i < majorOrder; i++) {
+ for (j = 0; j < minorOrder; j++) {
+ for (x = 0; x < k; x++) {
+ data[x] = points[x];
+ }
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
}
-void __glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
- GLint majorStride, GLint minorStride,
- const GLdouble *points, GLdouble *data)
+void
+__glFillMap2d(GLint k, GLint majorOrder, GLint minorOrder,
+ GLint majorStride, GLint minorStride,
+ const GLdouble * points, GLdouble * data)
{
- int i,j,x;
+ int i, j, x;
- if ((minorStride == k) && (majorStride == minorOrder*k)) {
- /* Just copy the data */
- __GLX_MEM_COPY(data, points, majorOrder * majorStride *
- __GLX_SIZE_FLOAT64);
- return;
- }
+ if ((minorStride == k) && (majorStride == minorOrder * k)) {
+ /* Just copy the data */
+ __GLX_MEM_COPY(data, points, majorOrder * majorStride *
+ __GLX_SIZE_FLOAT64);
+ return;
+ }
#ifdef __GLX_ALIGN64
- x = k * __GLX_SIZE_FLOAT64;
+ x = k * __GLX_SIZE_FLOAT64;
#endif
- for (i = 0; i<majorOrder; i++) {
- for (j = 0; j<minorOrder; j++) {
+ for (i = 0; i < majorOrder; i++) {
+ for (j = 0; j < minorOrder; j++) {
#ifdef __GLX_ALIGN64
- __GLX_MEM_COPY(data, points, x);
+ __GLX_MEM_COPY(data, points, x);
#else
- for (x = 0; x<k; x++) {
- data[x] = points[x];
- }
+ for (x = 0; x < k; x++) {
+ data[x] = points[x];
+ }
#endif
- points += minorStride;
- data += k;
- }
- points += majorStride - minorStride * minorOrder;
- }
+ points += minorStride;
+ data += k;
+ }
+ points += majorStride - minorStride * minorOrder;
+ }
}
diff --git a/src/glx/x11/glcontextmodes.c b/src/glx/x11/glcontextmodes.c
index 326c8b2357c..d179b7e520e 100644
--- a/src/glx/x11/glcontextmodes.c
+++ b/src/glx/x11/glcontextmodes.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2003
* All Rights Reserved.
@@ -78,16 +79,16 @@
* be returned. Otherwise \c GLX_NONE will be returned.
*/
GLint
-_gl_convert_from_x_visual_type( int visualType )
+_gl_convert_from_x_visual_type(int visualType)
{
- static const int glx_visual_types[ NUM_VISUAL_TYPES ] = {
- GLX_STATIC_GRAY, GLX_GRAY_SCALE,
- GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
- GLX_TRUE_COLOR, GLX_DIRECT_COLOR
- };
-
- return ( (unsigned) visualType < NUM_VISUAL_TYPES )
- ? glx_visual_types[ visualType ] : GLX_NONE;
+ static const int glx_visual_types[NUM_VISUAL_TYPES] = {
+ GLX_STATIC_GRAY, GLX_GRAY_SCALE,
+ GLX_STATIC_COLOR, GLX_PSEUDO_COLOR,
+ GLX_TRUE_COLOR, GLX_DIRECT_COLOR
+ };
+
+ return ((unsigned) visualType < NUM_VISUAL_TYPES)
+ ? glx_visual_types[visualType] : GLX_NONE;
}
@@ -100,16 +101,16 @@ _gl_convert_from_x_visual_type( int visualType )
* be returned. Otherwise -1 will be returned.
*/
GLint
-_gl_convert_to_x_visual_type( int visualType )
+_gl_convert_to_x_visual_type(int visualType)
{
- static const int x_visual_types[ NUM_VISUAL_TYPES ] = {
- TrueColor, DirectColor,
- PseudoColor, StaticColor,
- GrayScale, StaticGray
- };
-
- return ( (unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES )
- ? x_visual_types[ visualType - GLX_TRUE_COLOR ] : -1;
+ static const int x_visual_types[NUM_VISUAL_TYPES] = {
+ TrueColor, DirectColor,
+ PseudoColor, StaticColor,
+ GrayScale, StaticGray
+ };
+
+ return ((unsigned) (visualType - GLX_TRUE_COLOR) < NUM_VISUAL_TYPES)
+ ? x_visual_types[visualType - GLX_TRUE_COLOR] : -1;
}
@@ -128,76 +129,76 @@ _gl_convert_to_x_visual_type( int visualType )
* structure will be set to the \c vid of the \c __GLXvisualConfig structure.
*/
void
-_gl_copy_visual_to_context_mode( __GLcontextModes * mode,
- const __GLXvisualConfig * config )
+_gl_copy_visual_to_context_mode(__GLcontextModes * mode,
+ const __GLXvisualConfig * config)
{
- __GLcontextModes * const next = mode->next;
-
- (void) _mesa_memset( mode, 0, sizeof( __GLcontextModes ) );
- mode->next = next;
-
- mode->visualID = config->vid;
- mode->visualType = _gl_convert_from_x_visual_type( config->class );
- mode->xRenderable = GL_TRUE;
- mode->fbconfigID = config->vid;
- mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
-
- mode->rgbMode = (config->rgba != 0);
- mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
-
- mode->colorIndexMode = !(mode->rgbMode);
- mode->doubleBufferMode = (config->doubleBuffer != 0);
- mode->stereoMode = (config->stereo != 0);
-
- mode->haveAccumBuffer = ((config->accumRedSize +
- config->accumGreenSize +
- config->accumBlueSize +
- config->accumAlphaSize) > 0);
- mode->haveDepthBuffer = (config->depthSize > 0);
- mode->haveStencilBuffer = (config->stencilSize > 0);
-
- mode->redBits = config->redSize;
- mode->greenBits = config->greenSize;
- mode->blueBits = config->blueSize;
- mode->alphaBits = config->alphaSize;
- mode->redMask = config->redMask;
- mode->greenMask = config->greenMask;
- mode->blueMask = config->blueMask;
- mode->alphaMask = config->alphaMask;
- mode->rgbBits = mode->rgbMode ? config->bufferSize : 0;
- mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0;
-
- mode->accumRedBits = config->accumRedSize;
- mode->accumGreenBits = config->accumGreenSize;
- mode->accumBlueBits = config->accumBlueSize;
- mode->accumAlphaBits = config->accumAlphaSize;
- mode->depthBits = config->depthSize;
- mode->stencilBits = config->stencilSize;
-
- mode->numAuxBuffers = config->auxBuffers;
- mode->level = config->level;
-
- mode->visualRating = config->visualRating;
- mode->transparentPixel = config->transparentPixel;
- mode->transparentRed = config->transparentRed;
- mode->transparentGreen = config->transparentGreen;
- mode->transparentBlue = config->transparentBlue;
- mode->transparentAlpha = config->transparentAlpha;
- mode->transparentIndex = config->transparentIndex;
- mode->samples = config->multiSampleSize;
- mode->sampleBuffers = config->nMultiSampleBuffers;
- /* mode->visualSelectGroup = config->visualSelectGroup; ? */
-
- mode->swapMethod = GLX_SWAP_UNDEFINED_OML;
-
- mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE;
- mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ?
- GL_TRUE : GL_FALSE;
- mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE;
- mode->bindToTextureTargets = mode->rgbMode ?
- GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
- GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
- mode->yInverted = GL_FALSE;
+ __GLcontextModes *const next = mode->next;
+
+ (void) _mesa_memset(mode, 0, sizeof(__GLcontextModes));
+ mode->next = next;
+
+ mode->visualID = config->vid;
+ mode->visualType = _gl_convert_from_x_visual_type(config->class);
+ mode->xRenderable = GL_TRUE;
+ mode->fbconfigID = config->vid;
+ mode->drawableType = GLX_WINDOW_BIT | GLX_PIXMAP_BIT;
+
+ mode->rgbMode = (config->rgba != 0);
+ mode->renderType = (mode->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ mode->colorIndexMode = !(mode->rgbMode);
+ mode->doubleBufferMode = (config->doubleBuffer != 0);
+ mode->stereoMode = (config->stereo != 0);
+
+ mode->haveAccumBuffer = ((config->accumRedSize +
+ config->accumGreenSize +
+ config->accumBlueSize +
+ config->accumAlphaSize) > 0);
+ mode->haveDepthBuffer = (config->depthSize > 0);
+ mode->haveStencilBuffer = (config->stencilSize > 0);
+
+ mode->redBits = config->redSize;
+ mode->greenBits = config->greenSize;
+ mode->blueBits = config->blueSize;
+ mode->alphaBits = config->alphaSize;
+ mode->redMask = config->redMask;
+ mode->greenMask = config->greenMask;
+ mode->blueMask = config->blueMask;
+ mode->alphaMask = config->alphaMask;
+ mode->rgbBits = mode->rgbMode ? config->bufferSize : 0;
+ mode->indexBits = mode->colorIndexMode ? config->bufferSize : 0;
+
+ mode->accumRedBits = config->accumRedSize;
+ mode->accumGreenBits = config->accumGreenSize;
+ mode->accumBlueBits = config->accumBlueSize;
+ mode->accumAlphaBits = config->accumAlphaSize;
+ mode->depthBits = config->depthSize;
+ mode->stencilBits = config->stencilSize;
+
+ mode->numAuxBuffers = config->auxBuffers;
+ mode->level = config->level;
+
+ mode->visualRating = config->visualRating;
+ mode->transparentPixel = config->transparentPixel;
+ mode->transparentRed = config->transparentRed;
+ mode->transparentGreen = config->transparentGreen;
+ mode->transparentBlue = config->transparentBlue;
+ mode->transparentAlpha = config->transparentAlpha;
+ mode->transparentIndex = config->transparentIndex;
+ mode->samples = config->multiSampleSize;
+ mode->sampleBuffers = config->nMultiSampleBuffers;
+ /* mode->visualSelectGroup = config->visualSelectGroup; ? */
+
+ mode->swapMethod = GLX_SWAP_UNDEFINED_OML;
+
+ mode->bindToTextureRgb = (mode->rgbMode) ? GL_TRUE : GL_FALSE;
+ mode->bindToTextureRgba = (mode->rgbMode && mode->alphaBits) ?
+ GL_TRUE : GL_FALSE;
+ mode->bindToMipmapTexture = mode->rgbMode ? GL_TRUE : GL_FALSE;
+ mode->bindToTextureTargets = mode->rgbMode ?
+ GLX_TEXTURE_1D_BIT_EXT | GLX_TEXTURE_2D_BIT_EXT |
+ GLX_TEXTURE_RECTANGLE_BIT_EXT : 0;
+ mode->yInverted = GL_FALSE;
}
@@ -211,149 +212,149 @@ _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
* returned. Otherwise \c GLX_BAD_ATTRIBUTE is returned.
*/
int
-_gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
- int *value_return)
+_gl_get_context_mode_data(const __GLcontextModes * mode, int attribute,
+ int *value_return)
{
- switch (attribute) {
- case GLX_USE_GL:
- *value_return = GL_TRUE;
- return 0;
- case GLX_BUFFER_SIZE:
- *value_return = mode->rgbBits;
- return 0;
- case GLX_RGBA:
- *value_return = mode->rgbMode;
- return 0;
- case GLX_RED_SIZE:
- *value_return = mode->redBits;
- return 0;
- case GLX_GREEN_SIZE:
- *value_return = mode->greenBits;
- return 0;
- case GLX_BLUE_SIZE:
- *value_return = mode->blueBits;
- return 0;
- case GLX_ALPHA_SIZE:
- *value_return = mode->alphaBits;
- return 0;
- case GLX_DOUBLEBUFFER:
- *value_return = mode->doubleBufferMode;
- return 0;
- case GLX_STEREO:
- *value_return = mode->stereoMode;
- return 0;
- case GLX_AUX_BUFFERS:
- *value_return = mode->numAuxBuffers;
- return 0;
- case GLX_DEPTH_SIZE:
- *value_return = mode->depthBits;
- return 0;
- case GLX_STENCIL_SIZE:
- *value_return = mode->stencilBits;
- return 0;
- case GLX_ACCUM_RED_SIZE:
- *value_return = mode->accumRedBits;
- return 0;
- case GLX_ACCUM_GREEN_SIZE:
- *value_return = mode->accumGreenBits;
- return 0;
- case GLX_ACCUM_BLUE_SIZE:
- *value_return = mode->accumBlueBits;
- return 0;
- case GLX_ACCUM_ALPHA_SIZE:
- *value_return = mode->accumAlphaBits;
- return 0;
- case GLX_LEVEL:
- *value_return = mode->level;
- return 0;
- case GLX_TRANSPARENT_TYPE_EXT:
- *value_return = mode->transparentPixel;
- return 0;
- case GLX_TRANSPARENT_RED_VALUE:
- *value_return = mode->transparentRed;
- return 0;
- case GLX_TRANSPARENT_GREEN_VALUE:
- *value_return = mode->transparentGreen;
- return 0;
- case GLX_TRANSPARENT_BLUE_VALUE:
- *value_return = mode->transparentBlue;
- return 0;
- case GLX_TRANSPARENT_ALPHA_VALUE:
- *value_return = mode->transparentAlpha;
- return 0;
- case GLX_TRANSPARENT_INDEX_VALUE:
- *value_return = mode->transparentIndex;
- return 0;
- case GLX_X_VISUAL_TYPE:
- *value_return = mode->visualType;
- return 0;
- case GLX_CONFIG_CAVEAT:
- *value_return = mode->visualRating;
- return 0;
- case GLX_VISUAL_ID:
- *value_return = mode->visualID;
- return 0;
- case GLX_DRAWABLE_TYPE:
- *value_return = mode->drawableType;
- return 0;
- case GLX_RENDER_TYPE:
- *value_return = mode->renderType;
- return 0;
- case GLX_X_RENDERABLE:
- *value_return = mode->xRenderable;
- return 0;
- case GLX_FBCONFIG_ID:
- *value_return = mode->fbconfigID;
- return 0;
- case GLX_MAX_PBUFFER_WIDTH:
- *value_return = mode->maxPbufferWidth;
- return 0;
- case GLX_MAX_PBUFFER_HEIGHT:
- *value_return = mode->maxPbufferHeight;
- return 0;
- case GLX_MAX_PBUFFER_PIXELS:
- *value_return = mode->maxPbufferPixels;
- return 0;
- case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
- *value_return = mode->optimalPbufferWidth;
- return 0;
- case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
- *value_return = mode->optimalPbufferHeight;
- return 0;
- case GLX_SWAP_METHOD_OML:
- *value_return = mode->swapMethod;
- return 0;
- case GLX_SAMPLE_BUFFERS_SGIS:
- *value_return = mode->sampleBuffers;
- return 0;
- case GLX_SAMPLES_SGIS:
- *value_return = mode->samples;
- return 0;
- case GLX_BIND_TO_TEXTURE_RGB_EXT:
- *value_return = mode->bindToTextureRgb;
- return 0;
- case GLX_BIND_TO_TEXTURE_RGBA_EXT:
- *value_return = mode->bindToTextureRgba;
- return 0;
- case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
- *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
- GL_FALSE;
- return 0;
- case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
- *value_return = mode->bindToTextureTargets;
- return 0;
- case GLX_Y_INVERTED_EXT:
- *value_return = mode->yInverted;
- return 0;
+ switch (attribute) {
+ case GLX_USE_GL:
+ *value_return = GL_TRUE;
+ return 0;
+ case GLX_BUFFER_SIZE:
+ *value_return = mode->rgbBits;
+ return 0;
+ case GLX_RGBA:
+ *value_return = mode->rgbMode;
+ return 0;
+ case GLX_RED_SIZE:
+ *value_return = mode->redBits;
+ return 0;
+ case GLX_GREEN_SIZE:
+ *value_return = mode->greenBits;
+ return 0;
+ case GLX_BLUE_SIZE:
+ *value_return = mode->blueBits;
+ return 0;
+ case GLX_ALPHA_SIZE:
+ *value_return = mode->alphaBits;
+ return 0;
+ case GLX_DOUBLEBUFFER:
+ *value_return = mode->doubleBufferMode;
+ return 0;
+ case GLX_STEREO:
+ *value_return = mode->stereoMode;
+ return 0;
+ case GLX_AUX_BUFFERS:
+ *value_return = mode->numAuxBuffers;
+ return 0;
+ case GLX_DEPTH_SIZE:
+ *value_return = mode->depthBits;
+ return 0;
+ case GLX_STENCIL_SIZE:
+ *value_return = mode->stencilBits;
+ return 0;
+ case GLX_ACCUM_RED_SIZE:
+ *value_return = mode->accumRedBits;
+ return 0;
+ case GLX_ACCUM_GREEN_SIZE:
+ *value_return = mode->accumGreenBits;
+ return 0;
+ case GLX_ACCUM_BLUE_SIZE:
+ *value_return = mode->accumBlueBits;
+ return 0;
+ case GLX_ACCUM_ALPHA_SIZE:
+ *value_return = mode->accumAlphaBits;
+ return 0;
+ case GLX_LEVEL:
+ *value_return = mode->level;
+ return 0;
+ case GLX_TRANSPARENT_TYPE_EXT:
+ *value_return = mode->transparentPixel;
+ return 0;
+ case GLX_TRANSPARENT_RED_VALUE:
+ *value_return = mode->transparentRed;
+ return 0;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ *value_return = mode->transparentGreen;
+ return 0;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ *value_return = mode->transparentBlue;
+ return 0;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ *value_return = mode->transparentAlpha;
+ return 0;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ *value_return = mode->transparentIndex;
+ return 0;
+ case GLX_X_VISUAL_TYPE:
+ *value_return = mode->visualType;
+ return 0;
+ case GLX_CONFIG_CAVEAT:
+ *value_return = mode->visualRating;
+ return 0;
+ case GLX_VISUAL_ID:
+ *value_return = mode->visualID;
+ return 0;
+ case GLX_DRAWABLE_TYPE:
+ *value_return = mode->drawableType;
+ return 0;
+ case GLX_RENDER_TYPE:
+ *value_return = mode->renderType;
+ return 0;
+ case GLX_X_RENDERABLE:
+ *value_return = mode->xRenderable;
+ return 0;
+ case GLX_FBCONFIG_ID:
+ *value_return = mode->fbconfigID;
+ return 0;
+ case GLX_MAX_PBUFFER_WIDTH:
+ *value_return = mode->maxPbufferWidth;
+ return 0;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ *value_return = mode->maxPbufferHeight;
+ return 0;
+ case GLX_MAX_PBUFFER_PIXELS:
+ *value_return = mode->maxPbufferPixels;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ *value_return = mode->optimalPbufferWidth;
+ return 0;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ *value_return = mode->optimalPbufferHeight;
+ return 0;
+ case GLX_SWAP_METHOD_OML:
+ *value_return = mode->swapMethod;
+ return 0;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ *value_return = mode->sampleBuffers;
+ return 0;
+ case GLX_SAMPLES_SGIS:
+ *value_return = mode->samples;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGB_EXT:
+ *value_return = mode->bindToTextureRgb;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+ *value_return = mode->bindToTextureRgba;
+ return 0;
+ case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+ *value_return = mode->bindToMipmapTexture == GL_TRUE ? GL_TRUE :
+ GL_FALSE;
+ return 0;
+ case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+ *value_return = mode->bindToTextureTargets;
+ return 0;
+ case GLX_Y_INVERTED_EXT:
+ *value_return = mode->yInverted;
+ return 0;
/* Applications are NOT allowed to query GLX_VISUAL_SELECT_GROUP_SGIX.
* It is ONLY for communication between the GLX client and the GLX
* server.
*/
- case GLX_VISUAL_SELECT_GROUP_SGIX:
- default:
- return GLX_BAD_ATTRIBUTE;
- }
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ default:
+ return GLX_BAD_ATTRIBUTE;
+ }
}
#endif /* !defined(IN_MINI_GLX) */
@@ -385,24 +386,24 @@ _gl_get_context_mode_data(const __GLcontextModes *mode, int attribute,
* extend the \c __GLcontextModes data-structure.
*/
__GLcontextModes *
-_gl_context_modes_create( unsigned count, size_t minimum_size )
+_gl_context_modes_create(unsigned count, size_t minimum_size)
{
- const size_t size = (minimum_size > sizeof( __GLcontextModes ))
- ? minimum_size : sizeof( __GLcontextModes );
- __GLcontextModes * base = NULL;
- __GLcontextModes ** next;
- unsigned i;
-
- next = & base;
- for ( i = 0 ; i < count ; i++ ) {
- *next = (__GLcontextModes *) _mesa_malloc( size );
- if ( *next == NULL ) {
- _gl_context_modes_destroy( base );
- base = NULL;
- break;
+ const size_t size = (minimum_size > sizeof(__GLcontextModes))
+ ? minimum_size : sizeof(__GLcontextModes);
+ __GLcontextModes *base = NULL;
+ __GLcontextModes **next;
+ unsigned i;
+
+ next = &base;
+ for (i = 0; i < count; i++) {
+ *next = (__GLcontextModes *) _mesa_malloc(size);
+ if (*next == NULL) {
+ _gl_context_modes_destroy(base);
+ base = NULL;
+ break;
}
-
- (void) _mesa_memset( *next, 0, size );
+
+ (void) _mesa_memset(*next, 0, size);
(*next)->visualID = GLX_DONT_CARE;
(*next)->visualType = GLX_DONT_CARE;
(*next)->visualRating = GLX_NONE;
@@ -421,7 +422,7 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
(*next)->bindToTextureTargets = GLX_DONT_CARE;
(*next)->yInverted = GLX_DONT_CARE;
- next = & ((*next)->next);
+ next = &((*next)->next);
}
return base;
@@ -436,12 +437,12 @@ _gl_context_modes_create( unsigned count, size_t minimum_size )
* in the list will be freed.
*/
void
-_gl_context_modes_destroy( __GLcontextModes * modes )
+_gl_context_modes_destroy(__GLcontextModes * modes)
{
- while ( modes != NULL ) {
- __GLcontextModes * const next = modes->next;
+ while (modes != NULL) {
+ __GLcontextModes *const next = modes->next;
- _mesa_free( modes );
+ _mesa_free(modes);
modes = next;
}
}
@@ -457,27 +458,27 @@ _gl_context_modes_destroy( __GLcontextModes * modes )
*/
__GLcontextModes *
-_gl_context_modes_find_visual(__GLcontextModes *modes, int vid)
+_gl_context_modes_find_visual(__GLcontextModes * modes, int vid)
{
- __GLcontextModes *m;
+ __GLcontextModes *m;
- for (m = modes; m != NULL; m = m->next)
- if (m->visualID == vid)
- return m;
+ for (m = modes; m != NULL; m = m->next)
+ if (m->visualID == vid)
+ return m;
- return NULL;
+ return NULL;
}
__GLcontextModes *
-_gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
+_gl_context_modes_find_fbconfig(__GLcontextModes * modes, int fbid)
{
- __GLcontextModes *m;
+ __GLcontextModes *m;
- for (m = modes; m != NULL; m = m->next)
- if (m->fbconfigID == fbid)
- return m;
+ for (m = modes; m != NULL; m = m->next)
+ if (m->fbconfigID == fbid)
+ return m;
- return NULL;
+ return NULL;
}
/**
@@ -490,61 +491,55 @@ _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid)
* returned otherwise.
*/
GLboolean
-_gl_context_modes_are_same( const __GLcontextModes * a,
- const __GLcontextModes * b )
+_gl_context_modes_are_same(const __GLcontextModes * a,
+ const __GLcontextModes * b)
{
- return( (a->rgbMode == b->rgbMode) &&
- (a->floatMode == b->floatMode) &&
- (a->colorIndexMode == b->colorIndexMode) &&
- (a->doubleBufferMode == b->doubleBufferMode) &&
- (a->stereoMode == b->stereoMode) &&
- (a->redBits == b->redBits) &&
- (a->greenBits == b->greenBits) &&
- (a->blueBits == b->blueBits) &&
- (a->alphaBits == b->alphaBits) &&
-#if 0 /* For some reason these don't get set on the client-side in libGL. */
- (a->redMask == b->redMask) &&
- (a->greenMask == b->greenMask) &&
- (a->blueMask == b->blueMask) &&
- (a->alphaMask == b->alphaMask) &&
+ return ((a->rgbMode == b->rgbMode) &&
+ (a->floatMode == b->floatMode) &&
+ (a->colorIndexMode == b->colorIndexMode) &&
+ (a->doubleBufferMode == b->doubleBufferMode) &&
+ (a->stereoMode == b->stereoMode) &&
+ (a->redBits == b->redBits) &&
+ (a->greenBits == b->greenBits) &&
+ (a->blueBits == b->blueBits) && (a->alphaBits == b->alphaBits) &&
+#if 0 /* For some reason these don't get set on the client-side in libGL. */
+ (a->redMask == b->redMask) &&
+ (a->greenMask == b->greenMask) &&
+ (a->blueMask == b->blueMask) && (a->alphaMask == b->alphaMask) &&
#endif
- (a->rgbBits == b->rgbBits) &&
- (a->indexBits == b->indexBits) &&
- (a->accumRedBits == b->accumRedBits) &&
- (a->accumGreenBits == b->accumGreenBits) &&
- (a->accumBlueBits == b->accumBlueBits) &&
- (a->accumAlphaBits == b->accumAlphaBits) &&
- (a->depthBits == b->depthBits) &&
- (a->stencilBits == b->stencilBits) &&
- (a->numAuxBuffers == b->numAuxBuffers) &&
- (a->level == b->level) &&
- (a->pixmapMode == b->pixmapMode) &&
- (a->visualRating == b->visualRating) &&
-
- (a->transparentPixel == b->transparentPixel) &&
-
- ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
- ((a->transparentRed == b->transparentRed) &&
- (a->transparentGreen == b->transparentGreen) &&
- (a->transparentBlue == b->transparentBlue) &&
- (a->transparentAlpha == b->transparentAlpha))) &&
-
- ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
- (a->transparentIndex == b->transparentIndex)) &&
-
- (a->sampleBuffers == b->sampleBuffers) &&
- (a->samples == b->samples) &&
- ((a->drawableType & b->drawableType) != 0) &&
- (a->renderType == b->renderType) &&
- (a->maxPbufferWidth == b->maxPbufferWidth) &&
- (a->maxPbufferHeight == b->maxPbufferHeight) &&
- (a->maxPbufferPixels == b->maxPbufferPixels) &&
- (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
- (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
- (a->swapMethod == b->swapMethod) &&
- (a->bindToTextureRgb == b->bindToTextureRgb) &&
- (a->bindToTextureRgba == b->bindToTextureRgba) &&
- (a->bindToMipmapTexture == b->bindToMipmapTexture) &&
- (a->bindToTextureTargets == b->bindToTextureTargets) &&
- (a->yInverted == b->yInverted) );
+ (a->rgbBits == b->rgbBits) &&
+ (a->indexBits == b->indexBits) &&
+ (a->accumRedBits == b->accumRedBits) &&
+ (a->accumGreenBits == b->accumGreenBits) &&
+ (a->accumBlueBits == b->accumBlueBits) &&
+ (a->accumAlphaBits == b->accumAlphaBits) &&
+ (a->depthBits == b->depthBits) &&
+ (a->stencilBits == b->stencilBits) &&
+ (a->numAuxBuffers == b->numAuxBuffers) &&
+ (a->level == b->level) &&
+ (a->pixmapMode == b->pixmapMode) &&
+ (a->visualRating == b->visualRating) &&
+ (a->transparentPixel == b->transparentPixel) &&
+ ((a->transparentPixel != GLX_TRANSPARENT_RGB) ||
+ ((a->transparentRed == b->transparentRed) &&
+ (a->transparentGreen == b->transparentGreen) &&
+ (a->transparentBlue == b->transparentBlue) &&
+ (a->transparentAlpha == b->transparentAlpha))) &&
+ ((a->transparentPixel != GLX_TRANSPARENT_INDEX) ||
+ (a->transparentIndex == b->transparentIndex)) &&
+ (a->sampleBuffers == b->sampleBuffers) &&
+ (a->samples == b->samples) &&
+ ((a->drawableType & b->drawableType) != 0) &&
+ (a->renderType == b->renderType) &&
+ (a->maxPbufferWidth == b->maxPbufferWidth) &&
+ (a->maxPbufferHeight == b->maxPbufferHeight) &&
+ (a->maxPbufferPixels == b->maxPbufferPixels) &&
+ (a->optimalPbufferWidth == b->optimalPbufferWidth) &&
+ (a->optimalPbufferHeight == b->optimalPbufferHeight) &&
+ (a->swapMethod == b->swapMethod) &&
+ (a->bindToTextureRgb == b->bindToTextureRgb) &&
+ (a->bindToTextureRgba == b->bindToTextureRgba) &&
+ (a->bindToMipmapTexture == b->bindToMipmapTexture) &&
+ (a->bindToTextureTargets == b->bindToTextureTargets) &&
+ (a->yInverted == b->yInverted));
}
diff --git a/src/glx/x11/glcontextmodes.h b/src/glx/x11/glcontextmodes.h
index afd09cd7fbd..caf6a0daa53 100644
--- a/src/glx/x11/glcontextmodes.h
+++ b/src/glx/x11/glcontextmodes.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2003
* All Rights Reserved.
@@ -33,22 +34,22 @@
#include "GL/internal/glcore.h"
#if !defined(IN_MINI_GLX)
-extern GLint _gl_convert_from_x_visual_type( int visualType );
-extern GLint _gl_convert_to_x_visual_type( int visualType );
-extern void _gl_copy_visual_to_context_mode( __GLcontextModes * mode,
- const __GLXvisualConfig * config );
-extern int _gl_get_context_mode_data( const __GLcontextModes *mode,
- int attribute, int *value_return );
+extern GLint _gl_convert_from_x_visual_type(int visualType);
+extern GLint _gl_convert_to_x_visual_type(int visualType);
+extern void _gl_copy_visual_to_context_mode(__GLcontextModes * mode,
+ const __GLXvisualConfig * config);
+extern int _gl_get_context_mode_data(const __GLcontextModes * mode,
+ int attribute, int *value_return);
#endif /* !defined(IN_MINI_GLX) */
-extern __GLcontextModes * _gl_context_modes_create( unsigned count,
- size_t minimum_size );
-extern void _gl_context_modes_destroy( __GLcontextModes * modes );
-extern __GLcontextModes *
- _gl_context_modes_find_visual(__GLcontextModes *modes, int vid);
-extern __GLcontextModes *
- _gl_context_modes_find_fbconfig(__GLcontextModes *modes, int fbid);
-extern GLboolean _gl_context_modes_are_same( const __GLcontextModes * a,
- const __GLcontextModes * b );
+extern __GLcontextModes *_gl_context_modes_create(unsigned count,
+ size_t minimum_size);
+extern void _gl_context_modes_destroy(__GLcontextModes * modes);
+extern __GLcontextModes *_gl_context_modes_find_visual(__GLcontextModes *
+ modes, int vid);
+extern __GLcontextModes *_gl_context_modes_find_fbconfig(__GLcontextModes *
+ modes, int fbid);
+extern GLboolean _gl_context_modes_are_same(const __GLcontextModes * a,
+ const __GLcontextModes * b);
#endif /* GLCONTEXTMODES_H */
diff --git a/src/glx/x11/glx_pbuffer.c b/src/glx/x11/glx_pbuffer.c
index fb2610a4900..4b3c7f2202b 100644
--- a/src/glx/x11/glx_pbuffer.c
+++ b/src/glx/x11/glx_pbuffer.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
@@ -54,14 +55,14 @@
* This function needs to be modified to work with direct-rendering drivers.
*/
static void
-ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
- const CARD32 * attribs, size_t num_attribs )
+ChangeDrawableAttribute(Display * dpy, GLXDrawable drawable,
+ const CARD32 * attribs, size_t num_attribs)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
- CARD32 * output;
+ CARD32 *output;
CARD8 opcode;
- if ( (dpy == NULL) || (drawable == 0) ) {
+ if ((dpy == NULL) || (drawable == 0)) {
return;
}
@@ -71,10 +72,10 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
LockDisplay(dpy);
- if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
+ if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
xGLXChangeDrawableAttributesReq *req;
- GetReqExtra( GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req );
+ GetReqExtra(GLXChangeDrawableAttributes, 8 + (8 * num_attribs), req);
output = (CARD32 *) (req + 1);
req->reqType = opcode;
@@ -85,7 +86,7 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
else {
xGLXVendorPrivateWithReplyReq *vpreq;
- GetReqExtra( GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq );
+ GetReqExtra(GLXVendorPrivateWithReply, 4 + (8 * num_attribs), vpreq);
output = (CARD32 *) (vpreq + 1);
vpreq->reqType = opcode;
@@ -96,7 +97,7 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
output++;
}
- (void) memcpy( output, attribs, sizeof( CARD32 ) * 2 * num_attribs );
+ (void) memcpy(output, attribs, sizeof(CARD32) * 2 * num_attribs);
UnlockDisplay(dpy);
SyncHandle();
@@ -119,12 +120,12 @@ ChangeDrawableAttribute( Display * dpy, GLXDrawable drawable,
* This function needs to be modified to work with direct-rendering drivers.
*/
static void
-DestroyPbuffer( Display * dpy, GLXDrawable drawable )
+DestroyPbuffer(Display * dpy, GLXDrawable drawable)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
CARD8 opcode;
- if ( (dpy == NULL) || (drawable == 0) ) {
+ if ((dpy == NULL) || (drawable == 0)) {
return;
}
@@ -134,19 +135,19 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
LockDisplay(dpy);
- if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
- xGLXDestroyPbufferReq * req;
+ if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+ xGLXDestroyPbufferReq *req;
- GetReq( GLXDestroyPbuffer, req );
+ GetReq(GLXDestroyPbuffer, req);
req->reqType = opcode;
req->glxCode = X_GLXDestroyPbuffer;
req->pbuffer = (GLXPbuffer) drawable;
}
else {
xGLXVendorPrivateWithReplyReq *vpreq;
- CARD32 * data;
+ CARD32 *data;
- GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
data = (CARD32 *) (vpreq + 1);
data[0] = (CARD32) drawable;
@@ -164,29 +165,30 @@ DestroyPbuffer( Display * dpy, GLXDrawable drawable )
#ifdef GLX_DIRECT_RENDERING
-extern __GLXDRIdrawable *
-GetGLXDRIDrawable(Display *dpy, GLXDrawable drawable, int * const scrn_num);
+extern __GLXDRIdrawable *GetGLXDRIDrawable(Display * dpy,
+ GLXDrawable drawable,
+ int *const scrn_num);
static GLenum
determineTextureTarget(const int *attribs, int numAttribs)
{
- GLenum target = 0;
- int i;
-
- for (i = 0; i < numAttribs; i++) {
- if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
- switch (attribs[2 * i + 1]) {
- case GLX_TEXTURE_2D_EXT:
- target = GL_TEXTURE_2D;
- break;
- case GLX_TEXTURE_RECTANGLE_EXT:
- target = GL_TEXTURE_RECTANGLE_ARB;
- break;
- }
- }
- }
-
- return target;
+ GLenum target = 0;
+ int i;
+
+ for (i = 0; i < numAttribs; i++) {
+ if (attribs[2 * i] == GLX_TEXTURE_TARGET_EXT) {
+ switch (attribs[2 * i + 1]) {
+ case GLX_TEXTURE_2D_EXT:
+ target = GL_TEXTURE_2D;
+ break;
+ case GLX_TEXTURE_RECTANGLE_EXT:
+ target = GL_TEXTURE_RECTANGLE_ARB;
+ break;
+ }
+ }
+ }
+
+ return target;
}
#endif
@@ -209,24 +211,24 @@ determineTextureTarget(const int *attribs, int numAttribs)
* This function needs to be modified to work with direct-rendering drivers.
*/
static int
-GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
- int attribute, unsigned int *value )
+GetDrawableAttribute(Display * dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value)
{
__GLXdisplayPrivate *priv;
xGLXGetDrawableAttributesReply reply;
- CARD32 * data;
+ CARD32 *data;
CARD8 opcode;
unsigned int length;
unsigned int i;
unsigned int num_attributes;
- if ( (dpy == NULL) || (drawable == 0) ) {
+ if ((dpy == NULL) || (drawable == 0)) {
return 0;
}
priv = __glXInitialize(dpy);
GLboolean use_glx_1_3 = ((priv->majorVersion > 1)
- || (priv->minorVersion >= 3));
+ || (priv->minorVersion >= 3));
*value = 0;
@@ -237,10 +239,10 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
LockDisplay(dpy);
- if ( use_glx_1_3 ) {
+ if (use_glx_1_3) {
xGLXGetDrawableAttributesReq *req;
- GetReqExtra( GLXGetDrawableAttributes, 4, req );
+ GetReqExtra(GLXGetDrawableAttributes, 4, req);
req->reqType = opcode;
req->glxCode = X_GLXGetDrawableAttributes;
req->drawable = drawable;
@@ -248,7 +250,7 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
else {
xGLXVendorPrivateWithReplyReq *vpreq;
- GetReqExtra( GLXVendorPrivateWithReply, 4, vpreq );
+ GetReqExtra(GLXVendorPrivateWithReply, 4, vpreq);
data = (CARD32 *) (vpreq + 1);
data[0] = (CARD32) drawable;
@@ -257,48 +259,47 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
vpreq->vendorCode = X_GLXvop_GetDrawableAttributesSGIX;
}
- _XReply(dpy, (xReply*) &reply, 0, False);
+ _XReply(dpy, (xReply *) & reply, 0, False);
- if (reply.type == X_Error)
- {
- UnlockDisplay(dpy);
- SyncHandle();
- return 0;
+ if (reply.type == X_Error) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
}
length = reply.length;
- if (length)
- {
- num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
- data = (CARD32 *) Xmalloc( length * sizeof(CARD32) );
- if ( data == NULL ) {
- /* Throw data on the floor */
- _XEatData(dpy, length);
- } else {
- _XRead(dpy, (char *)data, length * sizeof(CARD32) );
-
- /* Search the set of returned attributes for the attribute requested by
- * the caller.
- */
- for ( i = 0 ; i < num_attributes ; i++ ) {
- if ( data[i*2] == attribute ) {
- *value = data[ (i*2) + 1 ];
- break;
- }
- }
+ if (length) {
+ num_attributes = (use_glx_1_3) ? reply.numAttribs : length / 2;
+ data = (CARD32 *) Xmalloc(length * sizeof(CARD32));
+ if (data == NULL) {
+ /* Throw data on the floor */
+ _XEatData(dpy, length);
+ }
+ else {
+ _XRead(dpy, (char *) data, length * sizeof(CARD32));
+
+ /* Search the set of returned attributes for the attribute requested by
+ * the caller.
+ */
+ for (i = 0; i < num_attributes; i++) {
+ if (data[i * 2] == attribute) {
+ *value = data[(i * 2) + 1];
+ break;
+ }
+ }
#ifdef GLX_DIRECT_RENDERING
- {
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
+ {
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, NULL);
- if (pdraw != NULL && !pdraw->textureTarget)
- pdraw->textureTarget = determineTextureTarget((const int *)data,
- num_attributes);
- }
+ if (pdraw != NULL && !pdraw->textureTarget)
+ pdraw->textureTarget =
+ determineTextureTarget((const int *) data, num_attributes);
+ }
#endif
- Xfree( data );
- }
+ Xfree(data);
+ }
}
UnlockDisplay(dpy);
@@ -314,19 +315,18 @@ GetDrawableAttribute( Display *dpy, GLXDrawable drawable,
* This function needs to be modified to work with direct-rendering drivers.
*/
static GLXDrawable
-CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
- Drawable drawable, const int *attrib_list,
- CARD8 glxCode )
+CreateDrawable(Display * dpy, const __GLcontextModes * fbconfig,
+ Drawable drawable, const int *attrib_list, CARD8 glxCode)
{
- xGLXCreateWindowReq * req;
- CARD32 * data;
+ xGLXCreateWindowReq *req;
+ CARD32 *data;
unsigned int i;
CARD8 opcode;
i = 0;
if (attrib_list) {
- while (attrib_list[i * 2] != None)
- i++;
+ while (attrib_list[i * 2] != None)
+ i++;
}
opcode = __glXSetupForCommand(dpy);
@@ -334,7 +334,7 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
return None;
LockDisplay(dpy);
- GetReqExtra( GLXCreateWindow, 8 * i, req );
+ GetReqExtra(GLXCreateWindow, 8 * i, req);
data = (CARD32 *) (req + 1);
req->reqType = opcode;
@@ -345,40 +345,40 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
req->glxwindow = (GLXWindow) XAllocID(dpy);
req->numAttribs = (CARD32) i;
- memcpy( data, attrib_list, 8 * i );
-
+ memcpy(data, attrib_list, 8 * i);
+
UnlockDisplay(dpy);
SyncHandle();
-
+
#ifdef GLX_DIRECT_RENDERING
do {
- /* FIXME: Maybe delay __DRIdrawable creation until the drawable
- * is actually bound to a context... */
-
- __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
- __GLXDRIdrawable *pdraw;
- __GLXscreenConfigs *psc;
-
- psc = &priv->screenConfigs[fbconfig->screen];
- if (psc->driScreen == NULL)
- break;
- pdraw = psc->driScreen->createDrawable(psc, drawable,
- req->glxwindow, fbconfig);
- if (pdraw == NULL) {
- fprintf(stderr, "failed to create drawable\n");
- break;
- }
-
- if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) {
- (*pdraw->destroyDrawable)(pdraw);
- return None; /* FIXME: Check what we're supposed to do here... */
- }
-
- pdraw->textureTarget = determineTextureTarget(attrib_list, i);
+ /* FIXME: Maybe delay __DRIdrawable creation until the drawable
+ * is actually bound to a context... */
+
+ __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+ __GLXDRIdrawable *pdraw;
+ __GLXscreenConfigs *psc;
+
+ psc = &priv->screenConfigs[fbconfig->screen];
+ if (psc->driScreen == NULL)
+ break;
+ pdraw = psc->driScreen->createDrawable(psc, drawable,
+ req->glxwindow, fbconfig);
+ if (pdraw == NULL) {
+ fprintf(stderr, "failed to create drawable\n");
+ break;
+ }
+
+ if (__glxHashInsert(psc->drawHash, req->glxwindow, pdraw)) {
+ (*pdraw->destroyDrawable) (pdraw);
+ return None; /* FIXME: Check what we're supposed to do here... */
+ }
+
+ pdraw->textureTarget = determineTextureTarget(attrib_list, i);
} while (0);
#endif
- return (GLXDrawable)req->glxwindow;
+ return (GLXDrawable) req->glxwindow;
}
@@ -389,12 +389,12 @@ CreateDrawable( Display *dpy, const __GLcontextModes * fbconfig,
* This function needs to be modified to work with direct-rendering drivers.
*/
static void
-DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
+DestroyDrawable(Display * dpy, GLXDrawable drawable, CARD32 glxCode)
{
- xGLXDestroyPbufferReq * req;
+ xGLXDestroyPbufferReq *req;
CARD8 opcode;
- if ( (dpy == NULL) || (drawable == 0) ) {
+ if ((dpy == NULL) || (drawable == 0)) {
return;
}
@@ -405,7 +405,7 @@ DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
LockDisplay(dpy);
- GetReqExtra( GLXDestroyPbuffer, 4, req );
+ GetReqExtra(GLXDestroyPbuffer, 4, req);
req->reqType = opcode;
req->glxCode = glxCode;
req->pbuffer = (GLXPbuffer) drawable;
@@ -415,15 +415,15 @@ DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
#ifdef GLX_DIRECT_RENDERING
{
- int screen;
- __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
- __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
- __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
-
- if (pdraw != NULL) {
- (*pdraw->destroyDrawable)(pdraw);
- __glxHashDelete(psc->drawHash, drawable);
- }
+ int screen;
+ __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+ __GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
+ __GLXscreenConfigs *psc = &priv->screenConfigs[screen];
+
+ if (pdraw != NULL) {
+ (*pdraw->destroyDrawable) (pdraw);
+ __glxHashDelete(psc->drawHash, drawable);
+ }
}
#endif
@@ -445,20 +445,20 @@ DestroyDrawable( Display * dpy, GLXDrawable drawable, CARD32 glxCode )
* This function needs to be modified to work with direct-rendering drivers.
*/
static GLXDrawable
-CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
- unsigned int width, unsigned int height,
- const int *attrib_list, GLboolean size_in_attribs )
+CreatePbuffer(Display * dpy, const __GLcontextModes * fbconfig,
+ unsigned int width, unsigned int height,
+ const int *attrib_list, GLboolean size_in_attribs)
{
__GLXdisplayPrivate *priv = __glXInitialize(dpy);
GLXDrawable id = 0;
- CARD32 * data;
+ CARD32 *data;
CARD8 opcode;
- unsigned int i;
+ unsigned int i;
i = 0;
if (attrib_list) {
- while (attrib_list[i * 2])
- i++;
+ while (attrib_list[i * 2])
+ i++;
}
opcode = __glXSetupForCommand(dpy);
@@ -468,11 +468,11 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
LockDisplay(dpy);
id = XAllocID(dpy);
- if ( (priv->majorVersion > 1) || (priv->minorVersion >= 3) ) {
- xGLXCreatePbufferReq * req;
+ if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+ xGLXCreatePbufferReq *req;
unsigned int extra = (size_in_attribs) ? 0 : 2;
- GetReqExtra( GLXCreatePbuffer, (8 * (i + extra)), req );
+ GetReqExtra(GLXCreatePbuffer, (8 * (i + extra)), req);
data = (CARD32 *) (req + 1);
req->reqType = opcode;
@@ -482,18 +482,18 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
req->pbuffer = (GLXPbuffer) id;
req->numAttribs = (CARD32) (i + extra);
- if ( ! size_in_attribs ) {
- data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
- data[(2 * i) + 1] = width;
- data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
- data[(2 * i) + 3] = height;
- data += 4;
+ if (!size_in_attribs) {
+ data[(2 * i) + 0] = GLX_PBUFFER_WIDTH;
+ data[(2 * i) + 1] = width;
+ data[(2 * i) + 2] = GLX_PBUFFER_HEIGHT;
+ data[(2 * i) + 3] = height;
+ data += 4;
}
}
else {
xGLXVendorPrivateReq *vpreq;
- GetReqExtra( GLXVendorPrivate, 20 + (8 * i), vpreq );
+ GetReqExtra(GLXVendorPrivate, 20 + (8 * i), vpreq);
data = (CARD32 *) (vpreq + 1);
vpreq->reqType = opcode;
@@ -508,7 +508,7 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
data += 5;
}
- (void) memcpy( data, attrib_list, sizeof(CARD32) * 2 * i );
+ (void) memcpy(data, attrib_list, sizeof(CARD32) * 2 * i);
UnlockDisplay(dpy);
SyncHandle();
@@ -521,13 +521,13 @@ CreatePbuffer( Display *dpy, const __GLcontextModes * fbconfig,
* Create a new pbuffer.
*/
PUBLIC GLXPbufferSGIX
-glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
- unsigned int width, unsigned int height,
- int *attrib_list)
+glXCreateGLXPbufferSGIX(Display * dpy, GLXFBConfigSGIX config,
+ unsigned int width, unsigned int height,
+ int *attrib_list)
{
- return (GLXPbufferSGIX) CreatePbuffer( dpy, (__GLcontextModes *) config,
- width, height,
- attrib_list, GL_FALSE );
+ return (GLXPbufferSGIX) CreatePbuffer(dpy, (__GLcontextModes *) config,
+ width, height,
+ attrib_list, GL_FALSE);
}
@@ -535,7 +535,7 @@ glXCreateGLXPbufferSGIX(Display *dpy, GLXFBConfigSGIX config,
* Create a new pbuffer.
*/
PUBLIC GLXPbuffer
-glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
+glXCreatePbuffer(Display * dpy, GLXFBConfig config, const int *attrib_list)
{
int i, width, height;
@@ -545,17 +545,16 @@ glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
for (i = 0; attrib_list[i * 2]; i++) {
switch (attrib_list[i * 2]) {
case GLX_PBUFFER_WIDTH:
- width = attrib_list[i * 2 + 1];
- break;
+ width = attrib_list[i * 2 + 1];
+ break;
case GLX_PBUFFER_HEIGHT:
- height = attrib_list[i * 2 + 1];
- break;
+ height = attrib_list[i * 2 + 1];
+ break;
}
}
- return (GLXPbuffer) CreatePbuffer( dpy, (__GLcontextModes *) config,
- width, height,
- attrib_list, GL_TRUE );
+ return (GLXPbuffer) CreatePbuffer(dpy, (__GLcontextModes *) config,
+ width, height, attrib_list, GL_TRUE);
}
@@ -563,9 +562,9 @@ glXCreatePbuffer(Display *dpy, GLXFBConfig config, const int *attrib_list)
* Destroy an existing pbuffer.
*/
PUBLIC void
-glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
+glXDestroyPbuffer(Display * dpy, GLXPbuffer pbuf)
{
- DestroyPbuffer( dpy, pbuf );
+ DestroyPbuffer(dpy, pbuf);
}
@@ -573,10 +572,10 @@ glXDestroyPbuffer(Display *dpy, GLXPbuffer pbuf)
* Query an attribute of a drawable.
*/
PUBLIC void
-glXQueryDrawable(Display *dpy, GLXDrawable drawable,
- int attribute, unsigned int *value)
+glXQueryDrawable(Display * dpy, GLXDrawable drawable,
+ int attribute, unsigned int *value)
{
- GetDrawableAttribute( dpy, drawable, attribute, value );
+ GetDrawableAttribute(dpy, drawable, attribute, value);
}
@@ -584,10 +583,10 @@ glXQueryDrawable(Display *dpy, GLXDrawable drawable,
* Query an attribute of a pbuffer.
*/
PUBLIC int
-glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX drawable,
- int attribute, unsigned int *value)
+glXQueryGLXPbufferSGIX(Display * dpy, GLXPbufferSGIX drawable,
+ int attribute, unsigned int *value)
{
- return GetDrawableAttribute( dpy, drawable, attribute, value );
+ return GetDrawableAttribute(dpy, drawable, attribute, value);
}
@@ -595,14 +594,14 @@ glXQueryGLXPbufferSGIX(Display *dpy, GLXPbufferSGIX drawable,
* Select the event mask for a drawable.
*/
PUBLIC void
-glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
+glXSelectEvent(Display * dpy, GLXDrawable drawable, unsigned long mask)
{
CARD32 attribs[2];
attribs[0] = (CARD32) GLX_EVENT_MASK;
attribs[1] = (CARD32) mask;
- ChangeDrawableAttribute( dpy, drawable, attribs, 1 );
+ ChangeDrawableAttribute(dpy, drawable, attribs, 1);
}
@@ -610,7 +609,7 @@ glXSelectEvent(Display *dpy, GLXDrawable drawable, unsigned long mask)
* Get the selected event mask for a drawable.
*/
PUBLIC void
-glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
+glXGetSelectedEvent(Display * dpy, GLXDrawable drawable, unsigned long *mask)
{
unsigned int value;
@@ -620,56 +619,56 @@ glXGetSelectedEvent(Display *dpy, GLXDrawable drawable, unsigned long *mask)
* we could just type-cast the pointer, but why?
*/
- GetDrawableAttribute( dpy, drawable, GLX_EVENT_MASK_SGIX, & value );
+ GetDrawableAttribute(dpy, drawable, GLX_EVENT_MASK_SGIX, &value);
*mask = value;
}
PUBLIC GLXPixmap
-glXCreatePixmap( Display *dpy, GLXFBConfig config, Pixmap pixmap,
- const int *attrib_list )
+glXCreatePixmap(Display * dpy, GLXFBConfig config, Pixmap pixmap,
+ const int *attrib_list)
{
- return CreateDrawable( dpy, (__GLcontextModes *) config,
- (Drawable) pixmap, attrib_list,
- X_GLXCreatePixmap );
+ return CreateDrawable(dpy, (__GLcontextModes *) config,
+ (Drawable) pixmap, attrib_list, X_GLXCreatePixmap);
}
PUBLIC GLXWindow
-glXCreateWindow( Display *dpy, GLXFBConfig config, Window win,
- const int *attrib_list )
+glXCreateWindow(Display * dpy, GLXFBConfig config, Window win,
+ const int *attrib_list)
{
- return CreateDrawable( dpy, (__GLcontextModes *) config,
- (Drawable) win, attrib_list,
- X_GLXCreateWindow );
+ return CreateDrawable(dpy, (__GLcontextModes *) config,
+ (Drawable) win, attrib_list, X_GLXCreateWindow);
}
PUBLIC void
-glXDestroyPixmap(Display *dpy, GLXPixmap pixmap)
+glXDestroyPixmap(Display * dpy, GLXPixmap pixmap)
{
- DestroyDrawable( dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap );
+ DestroyDrawable(dpy, (GLXDrawable) pixmap, X_GLXDestroyPixmap);
}
PUBLIC void
-glXDestroyWindow(Display *dpy, GLXWindow win)
+glXDestroyWindow(Display * dpy, GLXWindow win)
{
- DestroyDrawable( dpy, (GLXDrawable) win, X_GLXDestroyWindow );
+ DestroyDrawable(dpy, (GLXDrawable) win, X_GLXDestroyWindow);
}
-PUBLIC GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
- (Display *dpy, GLXPbufferSGIX pbuf),
- (dpy, pbuf),
- glXDestroyPbuffer)
+PUBLIC
+GLX_ALIAS_VOID(glXDestroyGLXPbufferSGIX,
+ (Display * dpy, GLXPbufferSGIX pbuf),
+ (dpy, pbuf), glXDestroyPbuffer)
-PUBLIC GLX_ALIAS_VOID(glXSelectEventSGIX,
- (Display *dpy, GLXDrawable drawable, unsigned long mask),
- (dpy, drawable, mask),
- glXSelectEvent)
+PUBLIC
+GLX_ALIAS_VOID(glXSelectEventSGIX,
+ (Display * dpy, GLXDrawable drawable,
+ unsigned long mask), (dpy, drawable, mask),
+ glXSelectEvent)
-PUBLIC GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
- (Display *dpy, GLXDrawable drawable, unsigned long *mask),
- (dpy, drawable, mask),
- glXGetSelectedEvent)
+PUBLIC
+GLX_ALIAS_VOID(glXGetSelectedEventSGIX,
+ (Display * dpy, GLXDrawable drawable,
+ unsigned long *mask), (dpy, drawable, mask),
+ glXGetSelectedEvent)
diff --git a/src/glx/x11/glx_query.c b/src/glx/x11/glx_query.c
index e93cd2afd43..9664243d8ef 100644
--- a/src/glx/x11/glx_query.c
+++ b/src/glx/x11/glx_query.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
@@ -39,12 +40,13 @@
* an identical binary layout. The only difference between them is the
* meaning of the \c for_whom field and the value of the \c glxCode.
*/
-typedef struct GLXGenericGetString {
- CARD8 reqType;
- CARD8 glxCode;
- CARD16 length B16;
- CARD32 for_whom B32;
- CARD32 name B32;
+typedef struct GLXGenericGetString
+{
+ CARD8 reqType;
+ CARD8 glxCode;
+ CARD16 length B16;
+ CARD32 for_whom B32;
+ CARD32 name B32;
} xGLXGenericGetStringReq;
/* These defines are only needed to make the GetReq macro happy.
@@ -57,46 +59,46 @@ typedef struct GLXGenericGetString {
* This routine will allocate the necessay space for the string.
*/
char *
-__glXGetStringFromServer( Display * dpy, int opcode, CARD32 glxCode,
- CARD32 for_whom, CARD32 name )
+__glXGetStringFromServer(Display * dpy, int opcode, CARD32 glxCode,
+ CARD32 for_whom, CARD32 name)
{
- xGLXGenericGetStringReq *req;
- xGLXSingleReply reply;
- int length;
- int numbytes;
- char * buf;
+ xGLXGenericGetStringReq *req;
+ xGLXSingleReply reply;
+ int length;
+ int numbytes;
+ char *buf;
- LockDisplay( dpy );
+ LockDisplay(dpy);
- /* All of the GLX protocol requests for getting a string from the server
- * look the same. The exact meaning of the for_whom field is usually
- * either the screen number (for glXQueryServerString) or the context tag
- * (for GLXSingle).
- */
+ /* All of the GLX protocol requests for getting a string from the server
+ * look the same. The exact meaning of the for_whom field is usually
+ * either the screen number (for glXQueryServerString) or the context tag
+ * (for GLXSingle).
+ */
- GetReq( GLXGenericGetString, req );
- req->reqType = opcode;
- req->glxCode = glxCode;
- req->for_whom = for_whom;
- req->name = name;
+ GetReq(GLXGenericGetString, req);
+ req->reqType = opcode;
+ req->glxCode = glxCode;
+ req->for_whom = for_whom;
+ req->name = name;
- _XReply( dpy, (xReply *) & reply, 0, False );
+ _XReply(dpy, (xReply *) & reply, 0, False);
- length = reply.length * 4;
- numbytes = reply.size;
+ length = reply.length * 4;
+ numbytes = reply.size;
- buf = (char *) Xmalloc( numbytes );
- if ( buf != NULL ) {
- _XRead( dpy, buf, numbytes );
- length -= numbytes;
- }
+ buf = (char *) Xmalloc(numbytes);
+ if (buf != NULL) {
+ _XRead(dpy, buf, numbytes);
+ length -= numbytes;
+ }
- _XEatData( dpy, length );
+ _XEatData(dpy, length);
- UnlockDisplay( dpy );
- SyncHandle();
+ UnlockDisplay(dpy);
+ SyncHandle();
- return buf;
+ return buf;
}
diff --git a/src/glx/x11/glxclient.h b/src/glx/x11/glxclient.h
index ac44e950a7c..80f28332b7c 100644
--- a/src/glx/x11/glxclient.h
+++ b/src/glx/x11/glxclient.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -137,6 +138,8 @@ struct __GLXDRIscreenRec {
const __GLcontextModes *modes);
void (*swapBuffers)(__GLXDRIdrawable *pdraw);
+ void (*copySubBuffer)(__GLXDRIdrawable *pdraw,
+ int x, int y, int width, int height);
};
struct __GLXDRIcontextRec {
@@ -492,7 +495,7 @@ struct __GLXscreenConfigsRec {
__GLXDRIscreen *driScreen;
#ifdef __DRI_COPY_SUB_BUFFER
- const __DRIcopySubBufferExtension *copySubBuffer;
+ const __DRIcopySubBufferExtension *driCopySubBuffer;
#endif
#ifdef __DRI_SWAP_CONTROL
diff --git a/src/glx/x11/glxcmds.c b/src/glx/x11/glxcmds.c
index cac39a59048..ff04853e931 100644
--- a/src/glx/x11/glxcmds.c
+++ b/src/glx/x11/glxcmds.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -2498,10 +2499,9 @@ static void __glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
int screen;
__GLXDRIdrawable *pdraw = GetGLXDRIDrawable(dpy, drawable, &screen);
if ( pdraw != NULL ) {
- __GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
- if (psc->copySubBuffer != NULL) {
- (*psc->copySubBuffer->copySubBuffer)(pdraw->driDrawable,
- x, y, width, height);
+ __GLXscreenConfigs * const psc = GetGLXScreenConfigs(dpy, screen);
+ if (psc->driScreen->copySubBuffer != NULL) {
+ (*psc->driScreen->copySubBuffer)(pdraw, x, y, width, height);
}
return;
diff --git a/src/glx/x11/glxcurrent.c b/src/glx/x11/glxcurrent.c
index 67fba59a3f7..89be63c5fa3 100644
--- a/src/glx/x11/glxcurrent.c
+++ b/src/glx/x11/glxcurrent.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -55,11 +56,11 @@ static GLubyte dummyBuffer[__GLX_BUFFER_LIMIT_SIZE];
** the dummy context structure.
*/
static __GLXcontext dummyContext = {
- &dummyBuffer[0],
- &dummyBuffer[0],
- &dummyBuffer[0],
- &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
- sizeof(dummyBuffer),
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[0],
+ &dummyBuffer[__GLX_BUFFER_LIMIT_SIZE],
+ sizeof(dummyBuffer),
};
@@ -79,7 +80,8 @@ static __GLapi *IndirectAPI = NULL;
static GLboolean TSDinitialized = GL_FALSE;
static xthread_key_t ContextTSD;
-_X_HIDDEN __GLXcontext *__glXGetCurrentContext(void)
+_X_HIDDEN __GLXcontext *
+__glXGetCurrentContext(void)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
@@ -96,7 +98,8 @@ _X_HIDDEN __GLXcontext *__glXGetCurrentContext(void)
}
}
-_X_HIDDEN void __glXSetCurrentContext(__GLXcontext *c)
+_X_HIDDEN void
+__glXSetCurrentContext(__GLXcontext * c)
{
if (!TSDinitialized) {
xthread_key_create(&ContextTSD, NULL);
@@ -122,12 +125,13 @@ _X_HIDDEN pthread_mutex_t __glXmutex = PTHREAD_MUTEX_INITIALIZER;
* \b never be \c NULL. This is important! Because of this
* \c __glXGetCurrentContext can be implemented as trivial macro.
*/
-__thread void * __glX_tls_Context __attribute__((tls_model("initial-exec")))
- = &dummyContext;
+__thread void *__glX_tls_Context __attribute__ ((tls_model("initial-exec")))
+ = &dummyContext;
-_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
+_X_HIDDEN void
+__glXSetCurrentContext(__GLXcontext * c)
{
- __glX_tls_Context = (c != NULL) ? c : &dummyContext;
+ __glX_tls_Context = (c != NULL) ? c : &dummyContext;
}
# else
@@ -150,28 +154,31 @@ static pthread_key_t ContextTSD;
* initialize the per-thread data key. This is ideally done using the
* \c pthread_once mechanism.
*/
-static void init_thread_data( void )
+static void
+init_thread_data(void)
{
- if ( pthread_key_create( & ContextTSD, NULL ) != 0 ) {
- perror( "pthread_key_create" );
- exit( -1 );
- }
+ if (pthread_key_create(&ContextTSD, NULL) != 0) {
+ perror("pthread_key_create");
+ exit(-1);
+ }
}
-_X_HIDDEN void __glXSetCurrentContext( __GLXcontext * c )
+_X_HIDDEN void
+__glXSetCurrentContext(__GLXcontext * c)
{
- pthread_once( & once_control, init_thread_data );
- pthread_setspecific( ContextTSD, c );
+ pthread_once(&once_control, init_thread_data);
+ pthread_setspecific(ContextTSD, c);
}
-_X_HIDDEN __GLXcontext * __glXGetCurrentContext( void )
+_X_HIDDEN __GLXcontext *
+__glXGetCurrentContext(void)
{
- void * v;
+ void *v;
- pthread_once( & once_control, init_thread_data );
+ pthread_once(&once_control, init_thread_data);
- v = pthread_getspecific( ContextTSD );
- return (v == NULL) ? & dummyContext : (__GLXcontext *) v;
+ v = pthread_getspecific(ContextTSD);
+ return (v == NULL) ? &dummyContext : (__GLXcontext *) v;
}
# endif /* defined( GLX_USE_TLS ) */
@@ -188,32 +195,36 @@ _X_HIDDEN __GLXcontext *__glXcurrentContext = &dummyContext;
#endif
-_X_HIDDEN void __glXSetCurrentContextNull(void)
+_X_HIDDEN void
+__glXSetCurrentContextNull(void)
{
- __glXSetCurrentContext(&dummyContext);
+ __glXSetCurrentContext(&dummyContext);
#ifdef GLX_DIRECT_RENDERING
- _glapi_set_dispatch(NULL); /* no-op functions */
+ _glapi_set_dispatch(NULL); /* no-op functions */
#endif
}
/************************************************************************/
-PUBLIC GLXContext glXGetCurrentContext(void)
+PUBLIC GLXContext
+glXGetCurrentContext(void)
{
- GLXContext cx = __glXGetCurrentContext();
-
- if (cx == &dummyContext) {
- return NULL;
- } else {
- return cx;
- }
+ GLXContext cx = __glXGetCurrentContext();
+
+ if (cx == &dummyContext) {
+ return NULL;
+ }
+ else {
+ return cx;
+ }
}
-PUBLIC GLXDrawable glXGetCurrentDrawable(void)
+PUBLIC GLXDrawable
+glXGetCurrentDrawable(void)
{
- GLXContext gc = __glXGetCurrentContext();
- return gc->currentDrawable;
+ GLXContext gc = __glXGetCurrentContext();
+ return gc->currentDrawable;
}
@@ -233,107 +244,109 @@ PUBLIC GLXDrawable glXGetCurrentDrawable(void)
* \warning
* This function assumes that \c dpy is locked with \c LockDisplay on entry.
*/
-static Bool SendMakeCurrentRequest(Display *dpy, CARD8 opcode,
- GLXContextID gc_id, GLXContextTag gc_tag,
- GLXDrawable draw, GLXDrawable read,
- xGLXMakeCurrentReply *reply)
+static Bool
+SendMakeCurrentRequest(Display * dpy, CARD8 opcode,
+ GLXContextID gc_id, GLXContextTag gc_tag,
+ GLXDrawable draw, GLXDrawable read,
+ xGLXMakeCurrentReply * reply)
{
- Bool ret;
-
-
- LockDisplay(dpy);
-
- if (draw == read) {
- xGLXMakeCurrentReq *req;
-
- GetReq(GLXMakeCurrent,req);
- req->reqType = opcode;
- req->glxCode = X_GLXMakeCurrent;
- req->drawable = draw;
- req->context = gc_id;
- req->oldContextTag = gc_tag;
- }
- else {
- __GLXdisplayPrivate *priv = __glXInitialize(dpy);
-
- /* If the server can support the GLX 1.3 version, we should
- * perfer that. Not only that, some servers support GLX 1.3 but
- * not the SGI extension.
- */
-
- if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
- xGLXMakeContextCurrentReq *req;
-
- GetReq(GLXMakeContextCurrent,req);
- req->reqType = opcode;
- req->glxCode = X_GLXMakeContextCurrent;
- req->drawable = draw;
- req->readdrawable = read;
- req->context = gc_id;
- req->oldContextTag = gc_tag;
- }
- else {
- xGLXVendorPrivateWithReplyReq *vpreq;
- xGLXMakeCurrentReadSGIReq *req;
-
- GetReqExtra(GLXVendorPrivateWithReply,
- sz_xGLXMakeCurrentReadSGIReq-sz_xGLXVendorPrivateWithReplyReq,vpreq);
- req = (xGLXMakeCurrentReadSGIReq *)vpreq;
- req->reqType = opcode;
- req->glxCode = X_GLXVendorPrivateWithReply;
- req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
- req->drawable = draw;
- req->readable = read;
- req->context = gc_id;
- req->oldContextTag = gc_tag;
- }
- }
-
- ret = _XReply(dpy, (xReply*) reply, 0, False);
-
- UnlockDisplay(dpy);
- SyncHandle();
-
- return ret;
+ Bool ret;
+
+
+ LockDisplay(dpy);
+
+ if (draw == read) {
+ xGLXMakeCurrentReq *req;
+
+ GetReq(GLXMakeCurrent, req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeCurrent;
+ req->drawable = draw;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ __GLXdisplayPrivate *priv = __glXInitialize(dpy);
+
+ /* If the server can support the GLX 1.3 version, we should
+ * perfer that. Not only that, some servers support GLX 1.3 but
+ * not the SGI extension.
+ */
+
+ if ((priv->majorVersion > 1) || (priv->minorVersion >= 3)) {
+ xGLXMakeContextCurrentReq *req;
+
+ GetReq(GLXMakeContextCurrent, req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXMakeContextCurrent;
+ req->drawable = draw;
+ req->readdrawable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ else {
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXMakeCurrentReadSGIReq *req;
+
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXMakeCurrentReadSGIReq -
+ sz_xGLXVendorPrivateWithReplyReq, vpreq);
+ req = (xGLXMakeCurrentReadSGIReq *) vpreq;
+ req->reqType = opcode;
+ req->glxCode = X_GLXVendorPrivateWithReply;
+ req->vendorCode = X_GLXvop_MakeCurrentReadSGI;
+ req->drawable = draw;
+ req->readable = read;
+ req->context = gc_id;
+ req->oldContextTag = gc_tag;
+ }
+ }
+
+ ret = _XReply(dpy, (xReply *) reply, 0, False);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return ret;
}
#ifdef GLX_DIRECT_RENDERING
static __GLXDRIdrawable *
-FetchDRIDrawable(Display *dpy,
- GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
+FetchDRIDrawable(Display * dpy,
+ GLXDrawable glxDrawable, GLXContext gc, Bool pre13)
{
- __GLXdisplayPrivate * const priv = __glXInitialize(dpy);
- __GLXDRIdrawable *pdraw;
- __GLXscreenConfigs *psc;
- XID drawable;
-
- if (priv == NULL)
- return NULL;
-
- psc = &priv->screenConfigs[gc->screen];
- if (psc->drawHash == NULL)
- return NULL;
-
- if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
- return pdraw;
-
- /* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
- * GLX drawable on the fly. Otherwise we pass None as the X
- * drawable */
- if (pre13)
- drawable = glxDrawable;
- else
- drawable = None;
-
- pdraw = psc->driScreen->createDrawable(psc, drawable,
- glxDrawable, gc->mode);
- if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
- (*pdraw->destroyDrawable)(pdraw);
- return NULL;
- }
-
- return pdraw;
+ __GLXdisplayPrivate *const priv = __glXInitialize(dpy);
+ __GLXDRIdrawable *pdraw;
+ __GLXscreenConfigs *psc;
+ XID drawable;
+
+ if (priv == NULL)
+ return NULL;
+
+ psc = &priv->screenConfigs[gc->screen];
+ if (psc->drawHash == NULL)
+ return NULL;
+
+ if (__glxHashLookup(psc->drawHash, glxDrawable, (void *) &pdraw) == 0)
+ return pdraw;
+
+ /* If this is glXMakeCurrent (pre GLX 1.3) we allow creating the
+ * GLX drawable on the fly. Otherwise we pass None as the X
+ * drawable */
+ if (pre13)
+ drawable = glxDrawable;
+ else
+ drawable = None;
+
+ pdraw = psc->driScreen->createDrawable(psc, drawable,
+ glxDrawable, gc->mode);
+ if (__glxHashInsert(psc->drawHash, glxDrawable, pdraw)) {
+ (*pdraw->destroyDrawable) (pdraw);
+ return NULL;
+ }
+
+ return pdraw;
}
#endif /* GLX_DIRECT_RENDERING */
@@ -343,170 +356,177 @@ FetchDRIDrawable(Display *dpy,
*
* \note This is in this file so that it can access dummyContext.
*/
-static Bool MakeContextCurrent(Display *dpy, GLXDrawable draw,
- GLXDrawable read, GLXContext gc,
- Bool pre13)
+static Bool
+MakeContextCurrent(Display * dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext gc, Bool pre13)
{
- xGLXMakeCurrentReply reply;
- const GLXContext oldGC = __glXGetCurrentContext();
- const CARD8 opcode = __glXSetupForCommand(dpy);
- const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
+ xGLXMakeCurrentReply reply;
+ const GLXContext oldGC = __glXGetCurrentContext();
+ const CARD8 opcode = __glXSetupForCommand(dpy);
+ const CARD8 oldOpcode = ((gc == oldGC) || (oldGC == &dummyContext))
? opcode : __glXSetupForCommand(oldGC->currentDpy);
- Bool bindReturnValue;
+ Bool bindReturnValue;
- if (!opcode || !oldOpcode) {
- return GL_FALSE;
- }
+ if (!opcode || !oldOpcode) {
+ return GL_FALSE;
+ }
- /* Make sure that the new context has a nonzero ID. In the request,
- * a zero context ID is used only to mean that we bind to no current
- * context.
- */
- if ((gc != NULL) && (gc->xid == None)) {
- return GL_FALSE;
- }
+ /* Make sure that the new context has a nonzero ID. In the request,
+ * a zero context ID is used only to mean that we bind to no current
+ * context.
+ */
+ if ((gc != NULL) && (gc->xid == None)) {
+ return GL_FALSE;
+ }
- _glapi_check_multithread();
+ _glapi_check_multithread();
#ifdef GLX_DIRECT_RENDERING
- /* Bind the direct rendering context to the drawable */
- if (gc && gc->driContext) {
- __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
- __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
-
- bindReturnValue =
- (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
- } else
+ /* Bind the direct rendering context to the drawable */
+ if (gc && gc->driContext) {
+ __GLXDRIdrawable *pdraw = FetchDRIDrawable(dpy, draw, gc, pre13);
+ __GLXDRIdrawable *pread = FetchDRIDrawable(dpy, read, gc, pre13);
+
+ bindReturnValue =
+ (gc->driContext->bindContext) (gc->driContext, pdraw, pread);
+ }
+ else
#endif
- {
- /* Send a glXMakeCurrent request to bind the new context. */
- bindReturnValue =
- SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
- ((dpy != oldGC->currentDpy) || oldGC->isDirect)
- ? None : oldGC->currentContextTag,
- draw, read, &reply);
- }
+ {
+ /* Send a glXMakeCurrent request to bind the new context. */
+ bindReturnValue =
+ SendMakeCurrentRequest(dpy, opcode, gc ? gc->xid : None,
+ ((dpy != oldGC->currentDpy)
+ || oldGC->isDirect)
+ ? None : oldGC->currentContextTag, draw, read,
+ &reply);
+ }
- if (!bindReturnValue) {
- return False;
- }
+ if (!bindReturnValue) {
+ return False;
+ }
#ifdef GLX_DIRECT_RENDERING
- if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
- !oldGC->isDirect && oldGC != &dummyContext) {
+ if ((dpy != oldGC->currentDpy || (gc && gc->driContext)) &&
+ !oldGC->isDirect && oldGC != &dummyContext) {
#else
- if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
+ if ((dpy != oldGC->currentDpy) && oldGC != &dummyContext) {
#endif
- xGLXMakeCurrentReply dummy_reply;
-
- /* We are either switching from one dpy to another and have to
- * send a request to the previous dpy to unbind the previous
- * context, or we are switching away from a indirect context to
- * a direct context and have to send a request to the dpy to
- * unbind the previous context.
- */
- (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
- oldGC->currentContextTag, None, None,
- & dummy_reply);
- }
+ xGLXMakeCurrentReply dummy_reply;
+
+ /* We are either switching from one dpy to another and have to
+ * send a request to the previous dpy to unbind the previous
+ * context, or we are switching away from a indirect context to
+ * a direct context and have to send a request to the dpy to
+ * unbind the previous context.
+ */
+ (void) SendMakeCurrentRequest(oldGC->currentDpy, oldOpcode, None,
+ oldGC->currentContextTag, None, None,
+ &dummy_reply);
+ }
#ifdef GLX_DIRECT_RENDERING
- else if (oldGC->driContext) {
- oldGC->driContext->unbindContext(oldGC->driContext);
- }
+ else if (oldGC->driContext) {
+ oldGC->driContext->unbindContext(oldGC->driContext);
+ }
#endif
- /* Update our notion of what is current */
- __glXLock();
- if (gc == oldGC) {
- /* Even though the contexts are the same the drawable might have
- * changed. Note that gc cannot be the dummy, and that oldGC
- * cannot be NULL, therefore if they are the same, gc is not
- * NULL and not the dummy.
- */
- gc->currentDrawable = draw;
- gc->currentReadable = read;
- } else {
- if (oldGC != &dummyContext) {
- /* Old current context is no longer current to anybody */
- oldGC->currentDpy = 0;
- oldGC->currentDrawable = None;
- oldGC->currentReadable = None;
- oldGC->currentContextTag = 0;
-
- if (oldGC->xid == None) {
- /* We are switching away from a context that was
- * previously destroyed, so we need to free the memory
- * for the old handle.
- */
+ /* Update our notion of what is current */
+ __glXLock();
+ if (gc == oldGC) {
+ /* Even though the contexts are the same the drawable might have
+ * changed. Note that gc cannot be the dummy, and that oldGC
+ * cannot be NULL, therefore if they are the same, gc is not
+ * NULL and not the dummy.
+ */
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+ }
+ else {
+ if (oldGC != &dummyContext) {
+ /* Old current context is no longer current to anybody */
+ oldGC->currentDpy = 0;
+ oldGC->currentDrawable = None;
+ oldGC->currentReadable = None;
+ oldGC->currentContextTag = 0;
+
+ if (oldGC->xid == None) {
+ /* We are switching away from a context that was
+ * previously destroyed, so we need to free the memory
+ * for the old handle.
+ */
#ifdef GLX_DIRECT_RENDERING
- /* Destroy the old direct rendering context */
- if (oldGC->driContext) {
- oldGC->driContext->destroyContext(oldGC->driContext,
- oldGC->psc,
- oldGC->createDpy);
- oldGC->driContext = NULL;
- }
+ /* Destroy the old direct rendering context */
+ if (oldGC->driContext) {
+ oldGC->driContext->destroyContext(oldGC->driContext,
+ oldGC->psc,
+ oldGC->createDpy);
+ oldGC->driContext = NULL;
+ }
#endif
- __glXFreeContext(oldGC);
- }
- }
- if (gc) {
- __glXSetCurrentContext(gc);
-
- gc->currentDpy = dpy;
- gc->currentDrawable = draw;
- gc->currentReadable = read;
-
-#ifdef GLX_DIRECT_RENDERING
- if (!gc->driContext) {
+ __glXFreeContext(oldGC);
+ }
+ }
+ if (gc) {
+ __glXSetCurrentContext(gc);
+
+ gc->currentDpy = dpy;
+ gc->currentDrawable = draw;
+ gc->currentReadable = read;
+
+#ifdef GLX_DIRECT_RENDERING
+ if (!gc->driContext) {
#endif
- if (!IndirectAPI)
- IndirectAPI = __glXNewIndirectAPI();
- _glapi_set_dispatch(IndirectAPI);
+ if (!IndirectAPI)
+ IndirectAPI = __glXNewIndirectAPI();
+ _glapi_set_dispatch(IndirectAPI);
#ifdef GLX_USE_APPLEGL
- do {
- extern void XAppleDRIUseIndirectDispatch(void);
- XAppleDRIUseIndirectDispatch();
- } while (0);
+ do {
+ extern void XAppleDRIUseIndirectDispatch(void);
+ XAppleDRIUseIndirectDispatch();
+ } while (0);
#endif
- __GLXattribute *state =
- (__GLXattribute *)(gc->client_state_private);
-
- gc->currentContextTag = reply.contextTag;
- if (state->array_state == NULL) {
- (void) glGetString(GL_EXTENSIONS);
- (void) glGetString(GL_VERSION);
- __glXInitVertexArrayState(gc);
- }
-#ifdef GLX_DIRECT_RENDERING
- }
- else {
- gc->currentContextTag = -1;
- }
+ __GLXattribute *state =
+ (__GLXattribute *) (gc->client_state_private);
+
+ gc->currentContextTag = reply.contextTag;
+ if (state->array_state == NULL) {
+ (void) glGetString(GL_EXTENSIONS);
+ (void) glGetString(GL_VERSION);
+ __glXInitVertexArrayState(gc);
+ }
+#ifdef GLX_DIRECT_RENDERING
+ }
+ else {
+ gc->currentContextTag = -1;
+ }
#endif
- } else {
- __glXSetCurrentContextNull();
- }
- }
- __glXUnlock();
- return GL_TRUE;
+ }
+ else {
+ __glXSetCurrentContextNull();
+ }
+ }
+ __glXUnlock();
+ return GL_TRUE;
}
-PUBLIC Bool glXMakeCurrent(Display *dpy, GLXDrawable draw, GLXContext gc)
+PUBLIC Bool
+glXMakeCurrent(Display * dpy, GLXDrawable draw, GLXContext gc)
{
- return MakeContextCurrent(dpy, draw, draw, gc, True);
+ return MakeContextCurrent(dpy, draw, draw, gc, True);
}
-PUBLIC GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
- (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
- (dpy, d, r, ctx, False), MakeContextCurrent)
+PUBLIC
+GLX_ALIAS(Bool, glXMakeCurrentReadSGI,
+ (Display * dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
+ (dpy, d, r, ctx, False), MakeContextCurrent)
-PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
- (Display *dpy, GLXDrawable d, GLXDrawable r, GLXContext ctx),
- (dpy, d, r, ctx, False), MakeContextCurrent)
+ PUBLIC GLX_ALIAS(Bool, glXMakeContextCurrent,
+ (Display * dpy, GLXDrawable d, GLXDrawable r,
+ GLXContext ctx), (dpy, d, r, ctx, False),
+ MakeContextCurrent)
diff --git a/src/glx/x11/glxext.c b/src/glx/x11/glxext.c
index eaf1ec2dfd3..0b7a7af731f 100644
--- a/src/glx/x11/glxext.c
+++ b/src/glx/x11/glxext.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -35,7 +36,7 @@
* Direct rendering support added by Precision Insight, Inc.
*
* \author Kevin E. Martin <[email protected]>
- */
+ */
#include <assert.h>
#include "glxclient.h"
@@ -53,20 +54,20 @@
#ifdef DEBUG
-void __glXDumpDrawBuffer(__GLXcontext *ctx);
+void __glXDumpDrawBuffer(__GLXcontext * ctx);
#endif
#ifdef USE_SPARC_ASM
static void _glx_mesa_init_sparc_glapi_relocs(void);
static int _mesa_sparc_needs_init = 1;
-#define INIT_MESA_SPARC { \
- if(_mesa_sparc_needs_init) { \
+#define INIT_MESA_SPARC do { \
+ if (_mesa_sparc_needs_init) { \
_glx_mesa_init_sparc_glapi_relocs(); \
- _mesa_sparc_needs_init = 0; \
- } \
-}
+ _mesa_sparc_needs_init = 0; \
+ } \
+ } while(0)
#else
-#define INIT_MESA_SPARC
+#define INIT_MESA_SPARC do { } while(0)
#endif
/*
@@ -81,133 +82,135 @@ static char *__glXExtensionName = GLX_EXTENSION_NAME;
XExtensionInfo *__glXExtensionInfo = NULL;
static /* const */ char *error_list[] = {
- "GLXBadContext",
- "GLXBadContextState",
- "GLXBadDrawable",
- "GLXBadPixmap",
- "GLXBadContextTag",
- "GLXBadCurrentWindow",
- "GLXBadRenderRequest",
- "GLXBadLargeRequest",
- "GLXUnsupportedPrivateRequest",
- "GLXBadFBConfig",
- "GLXBadPbuffer",
- "GLXBadCurrentDrawable",
- "GLXBadWindow",
+ "GLXBadContext",
+ "GLXBadContextState",
+ "GLXBadDrawable",
+ "GLXBadPixmap",
+ "GLXBadContextTag",
+ "GLXBadCurrentWindow",
+ "GLXBadRenderRequest",
+ "GLXBadLargeRequest",
+ "GLXUnsupportedPrivateRequest",
+ "GLXBadFBConfig",
+ "GLXBadPbuffer",
+ "GLXBadCurrentDrawable",
+ "GLXBadWindow",
};
-static int __glXCloseDisplay(Display *dpy, XExtCodes *codes)
+static int
+__glXCloseDisplay(Display * dpy, XExtCodes * codes)
{
- GLXContext gc;
+ GLXContext gc;
- gc = __glXGetCurrentContext();
- if (dpy == gc->currentDpy) {
- __glXSetCurrentContextNull();
- __glXFreeContext(gc);
- }
+ gc = __glXGetCurrentContext();
+ if (dpy == gc->currentDpy) {
+ __glXSetCurrentContextNull();
+ __glXFreeContext(gc);
+ }
- return XextRemoveDisplay(__glXExtensionInfo, dpy);
+ return XextRemoveDisplay(__glXExtensionInfo, dpy);
}
-static XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
- __GLX_NUMBER_ERRORS, error_list)
-
-static /* const */ XExtensionHooks __glXExtensionHooks = {
- NULL, /* create_gc */
- NULL, /* copy_gc */
- NULL, /* flush_gc */
- NULL, /* free_gc */
- NULL, /* create_font */
- NULL, /* free_font */
- __glXCloseDisplay, /* close_display */
- NULL, /* wire_to_event */
- NULL, /* event_to_wire */
- NULL, /* error */
- __glXErrorString, /* error_string */
-};
+static
+XEXT_GENERATE_ERROR_STRING(__glXErrorString, __glXExtensionName,
+ __GLX_NUMBER_ERRORS, error_list)
+
+ static /* const */ XExtensionHooks __glXExtensionHooks = {
+ NULL, /* create_gc */
+ NULL, /* copy_gc */
+ NULL, /* flush_gc */
+ NULL, /* free_gc */
+ NULL, /* create_font */
+ NULL, /* free_font */
+ __glXCloseDisplay, /* close_display */
+ NULL, /* wire_to_event */
+ NULL, /* event_to_wire */
+ NULL, /* error */
+ __glXErrorString, /* error_string */
+ };
static
XEXT_GENERATE_FIND_DISPLAY(__glXFindDisplay, __glXExtensionInfo,
- __glXExtensionName, &__glXExtensionHooks,
- __GLX_NUMBER_EVENTS, NULL)
+ __glXExtensionName, &__glXExtensionHooks,
+ __GLX_NUMBER_EVENTS, NULL)
/************************************************************************/
-
/*
** Free the per screen configs data as well as the array of
** __glXScreenConfigs.
*/
-static void FreeScreenConfigs(__GLXdisplayPrivate *priv)
+ static void FreeScreenConfigs(__GLXdisplayPrivate * priv)
{
- __GLXscreenConfigs *psc;
- GLint i, screens;
-
- /* Free screen configuration information */
- psc = priv->screenConfigs;
- screens = ScreenCount(priv->dpy);
- for (i = 0; i < screens; i++, psc++) {
- if (psc->configs) {
- _gl_context_modes_destroy( psc->configs );
- if (psc->effectiveGLXexts)
- Xfree(psc->effectiveGLXexts);
- psc->configs = NULL; /* NOTE: just for paranoia */
- }
- if (psc->visuals) {
- _gl_context_modes_destroy( psc->visuals );
- psc->visuals = NULL; /* NOTE: just for paranoia */
- }
- Xfree((char*) psc->serverGLXexts);
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
+
+ /* Free screen configuration information */
+ psc = priv->screenConfigs;
+ screens = ScreenCount(priv->dpy);
+ for (i = 0; i < screens; i++, psc++) {
+ if (psc->configs) {
+ _gl_context_modes_destroy(psc->configs);
+ if (psc->effectiveGLXexts)
+ Xfree(psc->effectiveGLXexts);
+ psc->configs = NULL; /* NOTE: just for paranoia */
+ }
+ if (psc->visuals) {
+ _gl_context_modes_destroy(psc->visuals);
+ psc->visuals = NULL; /* NOTE: just for paranoia */
+ }
+ Xfree((char *) psc->serverGLXexts);
#ifdef GLX_DIRECT_RENDERING
- if (psc->driScreen) {
- psc->driScreen->destroyScreen(psc);
- __glxHashDestroy(psc->drawHash);
- XFree(psc->driScreen);
- psc->driScreen = NULL;
- }
+ if (psc->driScreen) {
+ psc->driScreen->destroyScreen(psc);
+ __glxHashDestroy(psc->drawHash);
+ XFree(psc->driScreen);
+ psc->driScreen = NULL;
+ }
#endif
- }
- XFree((char*) priv->screenConfigs);
- priv->screenConfigs = NULL;
+ }
+ XFree((char *) priv->screenConfigs);
+ priv->screenConfigs = NULL;
}
/*
** Release the private memory referred to in a display private
** structure. The caller will free the extension structure.
*/
-static int __glXFreeDisplayPrivate(XExtData *extension)
+static int
+__glXFreeDisplayPrivate(XExtData * extension)
{
- __GLXdisplayPrivate *priv;
-
- priv = (__GLXdisplayPrivate*) extension->private_data;
- FreeScreenConfigs(priv);
- if(priv->serverGLXvendor) {
- Xfree((char*)priv->serverGLXvendor);
- priv->serverGLXvendor = 0x0; /* to protect against double free's */
- }
- if(priv->serverGLXversion) {
- Xfree((char*)priv->serverGLXversion);
- priv->serverGLXversion = 0x0; /* to protect against double free's */
- }
+ __GLXdisplayPrivate *priv;
+
+ priv = (__GLXdisplayPrivate *) extension->private_data;
+ FreeScreenConfigs(priv);
+ if (priv->serverGLXvendor) {
+ Xfree((char *) priv->serverGLXvendor);
+ priv->serverGLXvendor = 0x0; /* to protect against double free's */
+ }
+ if (priv->serverGLXversion) {
+ Xfree((char *) priv->serverGLXversion);
+ priv->serverGLXversion = 0x0; /* to protect against double free's */
+ }
#ifdef GLX_DIRECT_RENDERING
- /* Free the direct rendering per display data */
- if (priv->driswDisplay)
- (*priv->driswDisplay->destroyDisplay)(priv->driswDisplay);
- priv->driswDisplay = NULL;
-
- if (priv->driDisplay)
- (*priv->driDisplay->destroyDisplay)(priv->driDisplay);
- priv->driDisplay = NULL;
-
- if (priv->dri2Display)
- (*priv->dri2Display->destroyDisplay)(priv->dri2Display);
- priv->dri2Display = NULL;
+ /* Free the direct rendering per display data */
+ if (priv->driswDisplay)
+ (*priv->driswDisplay->destroyDisplay) (priv->driswDisplay);
+ priv->driswDisplay = NULL;
+
+ if (priv->driDisplay)
+ (*priv->driDisplay->destroyDisplay) (priv->driDisplay);
+ priv->driDisplay = NULL;
+
+ if (priv->dri2Display)
+ (*priv->dri2Display->destroyDisplay) (priv->dri2Display);
+ priv->dri2Display = NULL;
#endif
- Xfree((char*) priv);
- return 0;
+ Xfree((char *) priv);
+ return 0;
}
/************************************************************************/
@@ -216,72 +219,73 @@ static int __glXFreeDisplayPrivate(XExtData *extension)
** Query the version of the GLX extension. This procedure works even if
** the client extension is not completely set up.
*/
-static Bool QueryVersion(Display *dpy, int opcode, int *major, int *minor)
+static Bool
+QueryVersion(Display * dpy, int opcode, int *major, int *minor)
{
- xGLXQueryVersionReq *req;
- xGLXQueryVersionReply reply;
-
- /* Send the glXQueryVersion request */
- LockDisplay(dpy);
- GetReq(GLXQueryVersion,req);
- req->reqType = opcode;
- req->glxCode = X_GLXQueryVersion;
- req->majorVersion = GLX_MAJOR_VERSION;
- req->minorVersion = GLX_MINOR_VERSION;
- _XReply(dpy, (xReply*) &reply, 0, False);
- UnlockDisplay(dpy);
- SyncHandle();
-
- if (reply.majorVersion != GLX_MAJOR_VERSION) {
- /*
- ** The server does not support the same major release as this
- ** client.
- */
- return GL_FALSE;
- }
- *major = reply.majorVersion;
- *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
- return GL_TRUE;
+ xGLXQueryVersionReq *req;
+ xGLXQueryVersionReply reply;
+
+ /* Send the glXQueryVersion request */
+ LockDisplay(dpy);
+ GetReq(GLXQueryVersion, req);
+ req->reqType = opcode;
+ req->glxCode = X_GLXQueryVersion;
+ req->majorVersion = GLX_MAJOR_VERSION;
+ req->minorVersion = GLX_MINOR_VERSION;
+ _XReply(dpy, (xReply *) & reply, 0, False);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ if (reply.majorVersion != GLX_MAJOR_VERSION) {
+ /*
+ ** The server does not support the same major release as this
+ ** client.
+ */
+ return GL_FALSE;
+ }
+ *major = reply.majorVersion;
+ *minor = min(reply.minorVersion, GLX_MINOR_VERSION);
+ return GL_TRUE;
}
-_X_HIDDEN void
-__glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
- const INT32 *bp, Bool tagged_only,
- Bool fbconfig_style_tags )
+_X_HIDDEN void
+__glXInitializeVisualConfigFromTags(__GLcontextModes * config, int count,
+ const INT32 * bp, Bool tagged_only,
+ Bool fbconfig_style_tags)
{
- int i;
+ int i;
- if (!tagged_only) {
- /* Copy in the first set of properties */
- config->visualID = *bp++;
+ if (!tagged_only) {
+ /* Copy in the first set of properties */
+ config->visualID = *bp++;
- config->visualType = _gl_convert_from_x_visual_type( *bp++ );
+ config->visualType = _gl_convert_from_x_visual_type(*bp++);
- config->rgbMode = *bp++;
+ config->rgbMode = *bp++;
- config->redBits = *bp++;
- config->greenBits = *bp++;
- config->blueBits = *bp++;
- config->alphaBits = *bp++;
- config->accumRedBits = *bp++;
- config->accumGreenBits = *bp++;
- config->accumBlueBits = *bp++;
- config->accumAlphaBits = *bp++;
+ config->redBits = *bp++;
+ config->greenBits = *bp++;
+ config->blueBits = *bp++;
+ config->alphaBits = *bp++;
+ config->accumRedBits = *bp++;
+ config->accumGreenBits = *bp++;
+ config->accumBlueBits = *bp++;
+ config->accumAlphaBits = *bp++;
- config->doubleBufferMode = *bp++;
- config->stereoMode = *bp++;
+ config->doubleBufferMode = *bp++;
+ config->stereoMode = *bp++;
- config->rgbBits = *bp++;
- config->depthBits = *bp++;
- config->stencilBits = *bp++;
- config->numAuxBuffers = *bp++;
- config->level = *bp++;
+ config->rgbBits = *bp++;
+ config->depthBits = *bp++;
+ config->stencilBits = *bp++;
+ config->numAuxBuffers = *bp++;
+ config->level = *bp++;
- count -= __GLX_MIN_CONFIG_PROPS;
- }
+ count -= __GLX_MIN_CONFIG_PROPS;
+ }
- /*
+ /*
** Additional properties may be in a list at the end
** of the reply. They are in pairs of property type
** and property value.
@@ -290,491 +294,498 @@ __glXInitializeVisualConfigFromTags( __GLcontextModes *config, int count,
#define FETCH_OR_SET(tag) \
config-> tag = ( fbconfig_style_tags ) ? *bp++ : 1
- for (i = 0; i < count; i += 2 ) {
- switch(*bp++) {
- case GLX_RGBA:
- FETCH_OR_SET( rgbMode );
- break;
- case GLX_BUFFER_SIZE:
- config->rgbBits = *bp++;
- break;
- case GLX_LEVEL:
- config->level = *bp++;
- break;
- case GLX_DOUBLEBUFFER:
- FETCH_OR_SET( doubleBufferMode );
- break;
- case GLX_STEREO:
- FETCH_OR_SET( stereoMode );
- break;
- case GLX_AUX_BUFFERS:
- config->numAuxBuffers = *bp++;
- break;
- case GLX_RED_SIZE:
- config->redBits = *bp++;
- break;
- case GLX_GREEN_SIZE:
- config->greenBits = *bp++;
- break;
- case GLX_BLUE_SIZE:
- config->blueBits = *bp++;
- break;
- case GLX_ALPHA_SIZE:
- config->alphaBits = *bp++;
- break;
- case GLX_DEPTH_SIZE:
- config->depthBits = *bp++;
- break;
- case GLX_STENCIL_SIZE:
- config->stencilBits = *bp++;
- break;
- case GLX_ACCUM_RED_SIZE:
- config->accumRedBits = *bp++;
- break;
- case GLX_ACCUM_GREEN_SIZE:
- config->accumGreenBits = *bp++;
- break;
- case GLX_ACCUM_BLUE_SIZE:
- config->accumBlueBits = *bp++;
- break;
- case GLX_ACCUM_ALPHA_SIZE:
- config->accumAlphaBits = *bp++;
- break;
- case GLX_VISUAL_CAVEAT_EXT:
- config->visualRating = *bp++;
- break;
- case GLX_X_VISUAL_TYPE:
- config->visualType = *bp++;
- break;
- case GLX_TRANSPARENT_TYPE:
- config->transparentPixel = *bp++;
- break;
- case GLX_TRANSPARENT_INDEX_VALUE:
- config->transparentIndex = *bp++;
- break;
- case GLX_TRANSPARENT_RED_VALUE:
- config->transparentRed = *bp++;
- break;
- case GLX_TRANSPARENT_GREEN_VALUE:
- config->transparentGreen = *bp++;
- break;
- case GLX_TRANSPARENT_BLUE_VALUE:
- config->transparentBlue = *bp++;
- break;
- case GLX_TRANSPARENT_ALPHA_VALUE:
- config->transparentAlpha = *bp++;
- break;
- case GLX_VISUAL_ID:
- config->visualID = *bp++;
- break;
- case GLX_DRAWABLE_TYPE:
- config->drawableType = *bp++;
- break;
- case GLX_RENDER_TYPE:
- config->renderType = *bp++;
- break;
- case GLX_X_RENDERABLE:
- config->xRenderable = *bp++;
- break;
- case GLX_FBCONFIG_ID:
- config->fbconfigID = *bp++;
- break;
- case GLX_MAX_PBUFFER_WIDTH:
- config->maxPbufferWidth = *bp++;
- break;
- case GLX_MAX_PBUFFER_HEIGHT:
- config->maxPbufferHeight = *bp++;
- break;
- case GLX_MAX_PBUFFER_PIXELS:
- config->maxPbufferPixels = *bp++;
- break;
- case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
- config->optimalPbufferWidth = *bp++;
- break;
- case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
- config->optimalPbufferHeight = *bp++;
- break;
- case GLX_VISUAL_SELECT_GROUP_SGIX:
- config->visualSelectGroup = *bp++;
- break;
- case GLX_SWAP_METHOD_OML:
- config->swapMethod = *bp++;
- break;
- case GLX_SAMPLE_BUFFERS_SGIS:
- config->sampleBuffers = *bp++;
- break;
- case GLX_SAMPLES_SGIS:
- config->samples = *bp++;
- break;
- case GLX_BIND_TO_TEXTURE_RGB_EXT:
- config->bindToTextureRgb = *bp++;
- break;
- case GLX_BIND_TO_TEXTURE_RGBA_EXT:
- config->bindToTextureRgba = *bp++;
- break;
- case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
- config->bindToMipmapTexture = *bp++;
- break;
- case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
- config->bindToTextureTargets = *bp++;
- break;
- case GLX_Y_INVERTED_EXT:
- config->yInverted = *bp++;
- break;
- case None:
- i = count;
- break;
- default:
- break;
- }
- }
-
- config->renderType = (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
-
- config->haveAccumBuffer = ((config->accumRedBits +
- config->accumGreenBits +
- config->accumBlueBits +
- config->accumAlphaBits) > 0);
- config->haveDepthBuffer = (config->depthBits > 0);
- config->haveStencilBuffer = (config->stencilBits > 0);
+ for (i = 0; i < count; i += 2) {
+ switch (*bp++) {
+ case GLX_RGBA:
+ FETCH_OR_SET(rgbMode);
+ break;
+ case GLX_BUFFER_SIZE:
+ config->rgbBits = *bp++;
+ break;
+ case GLX_LEVEL:
+ config->level = *bp++;
+ break;
+ case GLX_DOUBLEBUFFER:
+ FETCH_OR_SET(doubleBufferMode);
+ break;
+ case GLX_STEREO:
+ FETCH_OR_SET(stereoMode);
+ break;
+ case GLX_AUX_BUFFERS:
+ config->numAuxBuffers = *bp++;
+ break;
+ case GLX_RED_SIZE:
+ config->redBits = *bp++;
+ break;
+ case GLX_GREEN_SIZE:
+ config->greenBits = *bp++;
+ break;
+ case GLX_BLUE_SIZE:
+ config->blueBits = *bp++;
+ break;
+ case GLX_ALPHA_SIZE:
+ config->alphaBits = *bp++;
+ break;
+ case GLX_DEPTH_SIZE:
+ config->depthBits = *bp++;
+ break;
+ case GLX_STENCIL_SIZE:
+ config->stencilBits = *bp++;
+ break;
+ case GLX_ACCUM_RED_SIZE:
+ config->accumRedBits = *bp++;
+ break;
+ case GLX_ACCUM_GREEN_SIZE:
+ config->accumGreenBits = *bp++;
+ break;
+ case GLX_ACCUM_BLUE_SIZE:
+ config->accumBlueBits = *bp++;
+ break;
+ case GLX_ACCUM_ALPHA_SIZE:
+ config->accumAlphaBits = *bp++;
+ break;
+ case GLX_VISUAL_CAVEAT_EXT:
+ config->visualRating = *bp++;
+ break;
+ case GLX_X_VISUAL_TYPE:
+ config->visualType = *bp++;
+ break;
+ case GLX_TRANSPARENT_TYPE:
+ config->transparentPixel = *bp++;
+ break;
+ case GLX_TRANSPARENT_INDEX_VALUE:
+ config->transparentIndex = *bp++;
+ break;
+ case GLX_TRANSPARENT_RED_VALUE:
+ config->transparentRed = *bp++;
+ break;
+ case GLX_TRANSPARENT_GREEN_VALUE:
+ config->transparentGreen = *bp++;
+ break;
+ case GLX_TRANSPARENT_BLUE_VALUE:
+ config->transparentBlue = *bp++;
+ break;
+ case GLX_TRANSPARENT_ALPHA_VALUE:
+ config->transparentAlpha = *bp++;
+ break;
+ case GLX_VISUAL_ID:
+ config->visualID = *bp++;
+ break;
+ case GLX_DRAWABLE_TYPE:
+ config->drawableType = *bp++;
+ break;
+ case GLX_RENDER_TYPE:
+ config->renderType = *bp++;
+ break;
+ case GLX_X_RENDERABLE:
+ config->xRenderable = *bp++;
+ break;
+ case GLX_FBCONFIG_ID:
+ config->fbconfigID = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_WIDTH:
+ config->maxPbufferWidth = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_HEIGHT:
+ config->maxPbufferHeight = *bp++;
+ break;
+ case GLX_MAX_PBUFFER_PIXELS:
+ config->maxPbufferPixels = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_WIDTH_SGIX:
+ config->optimalPbufferWidth = *bp++;
+ break;
+ case GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX:
+ config->optimalPbufferHeight = *bp++;
+ break;
+ case GLX_VISUAL_SELECT_GROUP_SGIX:
+ config->visualSelectGroup = *bp++;
+ break;
+ case GLX_SWAP_METHOD_OML:
+ config->swapMethod = *bp++;
+ break;
+ case GLX_SAMPLE_BUFFERS_SGIS:
+ config->sampleBuffers = *bp++;
+ break;
+ case GLX_SAMPLES_SGIS:
+ config->samples = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_RGB_EXT:
+ config->bindToTextureRgb = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_RGBA_EXT:
+ config->bindToTextureRgba = *bp++;
+ break;
+ case GLX_BIND_TO_MIPMAP_TEXTURE_EXT:
+ config->bindToMipmapTexture = *bp++;
+ break;
+ case GLX_BIND_TO_TEXTURE_TARGETS_EXT:
+ config->bindToTextureTargets = *bp++;
+ break;
+ case GLX_Y_INVERTED_EXT:
+ config->yInverted = *bp++;
+ break;
+ case None:
+ i = count;
+ break;
+ default:
+ break;
+ }
+ }
+
+ config->renderType =
+ (config->rgbMode) ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
+
+ config->haveAccumBuffer = ((config->accumRedBits +
+ config->accumGreenBits +
+ config->accumBlueBits +
+ config->accumAlphaBits) > 0);
+ config->haveDepthBuffer = (config->depthBits > 0);
+ config->haveStencilBuffer = (config->stencilBits > 0);
}
static __GLcontextModes *
-createConfigsFromProperties(Display *dpy, int nvisuals, int nprops,
- int screen, GLboolean tagged_only)
+createConfigsFromProperties(Display * dpy, int nvisuals, int nprops,
+ int screen, GLboolean tagged_only)
{
- INT32 buf[__GLX_TOTAL_CONFIG], *props;
- unsigned prop_size;
- __GLcontextModes *modes, *m;
- int i;
-
- if (nprops == 0)
- return NULL;
-
- /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
-
- /* Check number of properties */
- if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
- return NULL;
-
- /* Allocate memory for our config structure */
- modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
- if (!modes)
- return NULL;
-
- prop_size = nprops * __GLX_SIZE_INT32;
- if (prop_size <= sizeof(buf))
- props = buf;
- else
- props = Xmalloc(prop_size);
-
- /* Read each config structure and convert it into our format */
- m = modes;
- for (i = 0; i < nvisuals; i++) {
- _XRead(dpy, (char *)props, prop_size);
- /* Older X servers don't send this so we default it here. */
- m->drawableType = GLX_WINDOW_BIT;
- __glXInitializeVisualConfigFromTags(m, nprops, props,
- tagged_only, GL_TRUE);
- m->screen = screen;
- m = m->next;
- }
-
- if (props != buf)
- Xfree(props);
-
- return modes;
+ INT32 buf[__GLX_TOTAL_CONFIG], *props;
+ unsigned prop_size;
+ __GLcontextModes *modes, *m;
+ int i;
+
+ if (nprops == 0)
+ return NULL;
+
+ /* FIXME: Is the __GLX_MIN_CONFIG_PROPS test correct for FBconfigs? */
+
+ /* Check number of properties */
+ if (nprops < __GLX_MIN_CONFIG_PROPS || nprops > __GLX_MAX_CONFIG_PROPS)
+ return NULL;
+
+ /* Allocate memory for our config structure */
+ modes = _gl_context_modes_create(nvisuals, sizeof(__GLcontextModes));
+ if (!modes)
+ return NULL;
+
+ prop_size = nprops * __GLX_SIZE_INT32;
+ if (prop_size <= sizeof(buf))
+ props = buf;
+ else
+ props = Xmalloc(prop_size);
+
+ /* Read each config structure and convert it into our format */
+ m = modes;
+ for (i = 0; i < nvisuals; i++) {
+ _XRead(dpy, (char *) props, prop_size);
+ /* Older X servers don't send this so we default it here. */
+ m->drawableType = GLX_WINDOW_BIT;
+ __glXInitializeVisualConfigFromTags(m, nprops, props,
+ tagged_only, GL_TRUE);
+ m->screen = screen;
+ m = m->next;
+ }
+
+ if (props != buf)
+ Xfree(props);
+
+ return modes;
}
static GLboolean
-getVisualConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+getVisualConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
{
- xGLXGetVisualConfigsReq *req;
- __GLXscreenConfigs *psc;
- xGLXGetVisualConfigsReply reply;
-
- LockDisplay(dpy);
-
- psc = priv->screenConfigs + screen;
- psc->visuals = NULL;
- GetReq(GLXGetVisualConfigs, req);
- req->reqType = priv->majorOpcode;
- req->glxCode = X_GLXGetVisualConfigs;
- req->screen = screen;
-
- if (!_XReply(dpy, (xReply*) &reply, 0, False))
- goto out;
-
- psc->visuals = createConfigsFromProperties(dpy,
- reply.numVisuals,
- reply.numProps,
- screen, GL_FALSE);
+ xGLXGetVisualConfigsReq *req;
+ __GLXscreenConfigs *psc;
+ xGLXGetVisualConfigsReply reply;
+
+ LockDisplay(dpy);
+
+ psc = priv->screenConfigs + screen;
+ psc->visuals = NULL;
+ GetReq(GLXGetVisualConfigs, req);
+ req->reqType = priv->majorOpcode;
+ req->glxCode = X_GLXGetVisualConfigs;
+ req->screen = screen;
+
+ if (!_XReply(dpy, (xReply *) & reply, 0, False))
+ goto out;
+
+ psc->visuals = createConfigsFromProperties(dpy,
+ reply.numVisuals,
+ reply.numProps,
+ screen, GL_FALSE);
out:
- UnlockDisplay(dpy);
- return psc->visuals != NULL;
+ UnlockDisplay(dpy);
+ return psc->visuals != NULL;
}
static GLboolean
-getFBConfigs(Display *dpy, __GLXdisplayPrivate *priv, int screen)
+getFBConfigs(Display * dpy, __GLXdisplayPrivate * priv, int screen)
{
- xGLXGetFBConfigsReq *fb_req;
- xGLXGetFBConfigsSGIXReq *sgi_req;
- xGLXVendorPrivateWithReplyReq *vpreq;
- xGLXGetFBConfigsReply reply;
- __GLXscreenConfigs *psc;
-
- psc = priv->screenConfigs + screen;
- psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- screen, GLX_EXTENSIONS);
-
- LockDisplay(dpy);
-
- psc->configs = NULL;
- if (atof(priv->serverGLXversion) >= 1.3) {
- GetReq(GLXGetFBConfigs, fb_req);
- fb_req->reqType = priv->majorOpcode;
- fb_req->glxCode = X_GLXGetFBConfigs;
- fb_req->screen = screen;
- } else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
- GetReqExtra(GLXVendorPrivateWithReply,
- sz_xGLXGetFBConfigsSGIXReq +
- sz_xGLXVendorPrivateWithReplyReq, vpreq);
- sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
- sgi_req->reqType = priv->majorOpcode;
- sgi_req->glxCode = X_GLXVendorPrivateWithReply;
- sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
- sgi_req->screen = screen;
- } else
- goto out;
-
- if (!_XReply(dpy, (xReply*) &reply, 0, False))
- goto out;
-
- psc->configs = createConfigsFromProperties(dpy,
- reply.numFBConfigs,
- reply.numAttribs * 2,
- screen, GL_TRUE);
+ xGLXGetFBConfigsReq *fb_req;
+ xGLXGetFBConfigsSGIXReq *sgi_req;
+ xGLXVendorPrivateWithReplyReq *vpreq;
+ xGLXGetFBConfigsReply reply;
+ __GLXscreenConfigs *psc;
+
+ psc = priv->screenConfigs + screen;
+ psc->serverGLXexts = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ screen, GLX_EXTENSIONS);
+
+ LockDisplay(dpy);
+
+ psc->configs = NULL;
+ if (atof(priv->serverGLXversion) >= 1.3) {
+ GetReq(GLXGetFBConfigs, fb_req);
+ fb_req->reqType = priv->majorOpcode;
+ fb_req->glxCode = X_GLXGetFBConfigs;
+ fb_req->screen = screen;
+ }
+ else if (strstr(psc->serverGLXexts, "GLX_SGIX_fbconfig") != NULL) {
+ GetReqExtra(GLXVendorPrivateWithReply,
+ sz_xGLXGetFBConfigsSGIXReq +
+ sz_xGLXVendorPrivateWithReplyReq, vpreq);
+ sgi_req = (xGLXGetFBConfigsSGIXReq *) vpreq;
+ sgi_req->reqType = priv->majorOpcode;
+ sgi_req->glxCode = X_GLXVendorPrivateWithReply;
+ sgi_req->vendorCode = X_GLXvop_GetFBConfigsSGIX;
+ sgi_req->screen = screen;
+ }
+ else
+ goto out;
+
+ if (!_XReply(dpy, (xReply *) & reply, 0, False))
+ goto out;
+
+ psc->configs = createConfigsFromProperties(dpy,
+ reply.numFBConfigs,
+ reply.numAttribs * 2,
+ screen, GL_TRUE);
out:
- UnlockDisplay(dpy);
- return psc->configs != NULL;
+ UnlockDisplay(dpy);
+ return psc->configs != NULL;
}
/*
** Allocate the memory for the per screen configs for each screen.
** If that works then fetch the per screen configs data.
*/
-static Bool AllocAndFetchScreenConfigs(Display *dpy, __GLXdisplayPrivate *priv)
+static Bool
+AllocAndFetchScreenConfigs(Display * dpy, __GLXdisplayPrivate * priv)
{
- __GLXscreenConfigs *psc;
- GLint i, screens;
+ __GLXscreenConfigs *psc;
+ GLint i, screens;
- /*
+ /*
** First allocate memory for the array of per screen configs.
*/
- screens = ScreenCount(dpy);
- psc = (__GLXscreenConfigs*) Xmalloc(screens * sizeof(__GLXscreenConfigs));
- if (!psc) {
- return GL_FALSE;
- }
- memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
- priv->screenConfigs = psc;
-
- priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
- X_GLXQueryServerString,
- 0, GLX_VERSION);
- if ( priv->serverGLXversion == NULL ) {
- FreeScreenConfigs(priv);
- return GL_FALSE;
- }
-
- for (i = 0; i < screens; i++, psc++) {
- getVisualConfigs(dpy, priv, i);
- getFBConfigs(dpy, priv, i);
+ screens = ScreenCount(dpy);
+ psc = (__GLXscreenConfigs *) Xmalloc(screens * sizeof(__GLXscreenConfigs));
+ if (!psc) {
+ return GL_FALSE;
+ }
+ memset(psc, 0, screens * sizeof(__GLXscreenConfigs));
+ priv->screenConfigs = psc;
+
+ priv->serverGLXversion = __glXGetStringFromServer(dpy, priv->majorOpcode,
+ X_GLXQueryServerString,
+ 0, GLX_VERSION);
+ if (priv->serverGLXversion == NULL) {
+ FreeScreenConfigs(priv);
+ return GL_FALSE;
+ }
+
+ for (i = 0; i < screens; i++, psc++) {
+ getVisualConfigs(dpy, priv, i);
+ getFBConfigs(dpy, priv, i);
#ifdef GLX_DIRECT_RENDERING
- psc->scr = i;
- psc->dpy = dpy;
- psc->drawHash = __glxHashCreate();
- if (psc->drawHash == NULL)
- continue;
+ psc->scr = i;
+ psc->dpy = dpy;
+ psc->drawHash = __glxHashCreate();
+ if (psc->drawHash == NULL)
+ continue;
- if (priv->dri2Display)
- psc->driScreen = (*priv->dri2Display->createScreen)(psc, i, priv);
+ if (priv->dri2Display)
+ psc->driScreen = (*priv->dri2Display->createScreen) (psc, i, priv);
- if (psc->driScreen == NULL && priv->driDisplay)
- psc->driScreen = (*priv->driDisplay->createScreen)(psc, i, priv);
+ if (psc->driScreen == NULL && priv->driDisplay)
+ psc->driScreen = (*priv->driDisplay->createScreen) (psc, i, priv);
- if (psc->driScreen == NULL && priv->driswDisplay)
- psc->driScreen = (*priv->driswDisplay->createScreen)(psc, i, priv);
+ if (psc->driScreen == NULL && priv->driswDisplay)
+ psc->driScreen = (*priv->driswDisplay->createScreen) (psc, i, priv);
- if (psc->driScreen == NULL) {
- __glxHashDestroy(psc->drawHash);
- psc->drawHash = NULL;
- }
+ if (psc->driScreen == NULL) {
+ __glxHashDestroy(psc->drawHash);
+ psc->drawHash = NULL;
+ }
#endif
- }
- SyncHandle();
- return GL_TRUE;
+ }
+ SyncHandle();
+ return GL_TRUE;
}
/*
** Initialize the client side extension code.
*/
-_X_HIDDEN __GLXdisplayPrivate *__glXInitialize(Display* dpy)
+_X_HIDDEN __GLXdisplayPrivate *
+__glXInitialize(Display * dpy)
{
- XExtDisplayInfo *info = __glXFindDisplay(dpy);
- XExtData **privList, *private, *found;
- __GLXdisplayPrivate *dpyPriv;
- XEDataObject dataObj;
- int major, minor;
+ XExtDisplayInfo *info = __glXFindDisplay(dpy);
+ XExtData **privList, *private, *found;
+ __GLXdisplayPrivate *dpyPriv;
+ XEDataObject dataObj;
+ int major, minor;
#ifdef GLX_DIRECT_RENDERING
- Bool glx_direct, glx_accel;
+ Bool glx_direct, glx_accel;
#endif
#if defined(USE_XTHREADS)
- {
- static int firstCall = 1;
- if (firstCall) {
- /* initialize the GLX mutexes */
- xmutex_init(&__glXmutex);
- firstCall = 0;
- }
- }
+ {
+ static int firstCall = 1;
+ if (firstCall) {
+ /* initialize the GLX mutexes */
+ xmutex_init(&__glXmutex);
+ firstCall = 0;
+ }
+ }
#endif
- INIT_MESA_SPARC
- /* The one and only long long lock */
- __glXLock();
-
- if (!XextHasExtension(info)) {
- /* No GLX extension supported by this server. Oh well. */
- __glXUnlock();
- XMissingExtension(dpy, __glXExtensionName);
- return 0;
- }
-
- /* See if a display private already exists. If so, return it */
- dataObj.display = dpy;
- privList = XEHeadOfExtensionList(dataObj);
- found = XFindOnExtensionList(privList, info->codes->extension);
- if (found) {
- __glXUnlock();
- return (__GLXdisplayPrivate *) found->private_data;
- }
-
- /* See if the versions are compatible */
- if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
- /* The client and server do not agree on versions. Punt. */
- __glXUnlock();
- return 0;
- }
-
- /*
+ INIT_MESA_SPARC;
+ /* The one and only long long lock */
+ __glXLock();
+
+ if (!XextHasExtension(info)) {
+ /* No GLX extension supported by this server. Oh well. */
+ __glXUnlock();
+ XMissingExtension(dpy, __glXExtensionName);
+ return 0;
+ }
+
+ /* See if a display private already exists. If so, return it */
+ dataObj.display = dpy;
+ privList = XEHeadOfExtensionList(dataObj);
+ found = XFindOnExtensionList(privList, info->codes->extension);
+ if (found) {
+ __glXUnlock();
+ return (__GLXdisplayPrivate *) found->private_data;
+ }
+
+ /* See if the versions are compatible */
+ if (!QueryVersion(dpy, info->codes->major_opcode, &major, &minor)) {
+ /* The client and server do not agree on versions. Punt. */
+ __glXUnlock();
+ return 0;
+ }
+
+ /*
** Allocate memory for all the pieces needed for this buffer.
*/
- private = (XExtData *) Xmalloc(sizeof(XExtData));
- if (!private) {
- __glXUnlock();
- return 0;
- }
- dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
- if (!dpyPriv) {
- __glXUnlock();
- Xfree((char*) private);
- return 0;
- }
-
- /*
+ private = (XExtData *) Xmalloc(sizeof(XExtData));
+ if (!private) {
+ __glXUnlock();
+ return 0;
+ }
+ dpyPriv = (__GLXdisplayPrivate *) Xcalloc(1, sizeof(__GLXdisplayPrivate));
+ if (!dpyPriv) {
+ __glXUnlock();
+ Xfree((char *) private);
+ return 0;
+ }
+
+ /*
** Init the display private and then read in the screen config
** structures from the server.
*/
- dpyPriv->majorOpcode = info->codes->major_opcode;
- dpyPriv->majorVersion = major;
- dpyPriv->minorVersion = minor;
- dpyPriv->dpy = dpy;
+ dpyPriv->majorOpcode = info->codes->major_opcode;
+ dpyPriv->majorVersion = major;
+ dpyPriv->minorVersion = minor;
+ dpyPriv->dpy = dpy;
- dpyPriv->serverGLXvendor = 0x0;
- dpyPriv->serverGLXversion = 0x0;
+ dpyPriv->serverGLXvendor = 0x0;
+ dpyPriv->serverGLXversion = 0x0;
#ifdef GLX_DIRECT_RENDERING
- glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
- glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
+ glx_direct = (getenv("LIBGL_ALWAYS_INDIRECT") == NULL);
+ glx_accel = (getenv("LIBGL_ALWAYS_SOFTWARE") == NULL);
- /*
+ /*
** Initialize the direct rendering per display data and functions.
** Note: This _must_ be done before calling any other DRI routines
** (e.g., those called in AllocAndFetchScreenConfigs).
*/
- if (glx_direct && glx_accel) {
- dpyPriv->dri2Display = dri2CreateDisplay(dpy);
- dpyPriv->driDisplay = driCreateDisplay(dpy);
- }
- if (glx_direct)
- dpyPriv->driswDisplay = driswCreateDisplay(dpy);
+ if (glx_direct && glx_accel) {
+ dpyPriv->dri2Display = dri2CreateDisplay(dpy);
+ dpyPriv->driDisplay = driCreateDisplay(dpy);
+ }
+ if (glx_direct)
+ dpyPriv->driswDisplay = driswCreateDisplay(dpy);
#endif
- if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
- __glXUnlock();
- Xfree((char*) dpyPriv);
- Xfree((char*) private);
- return 0;
- }
+ if (!AllocAndFetchScreenConfigs(dpy, dpyPriv)) {
+ __glXUnlock();
+ Xfree((char *) dpyPriv);
+ Xfree((char *) private);
+ return 0;
+ }
- /*
+ /*
** Fill in the private structure. This is the actual structure that
** hangs off of the Display structure. Our private structure is
** referred to by this structure. Got that?
*/
- private->number = info->codes->extension;
- private->next = 0;
- private->free_private = __glXFreeDisplayPrivate;
- private->private_data = (char *) dpyPriv;
- XAddToExtensionList(privList, private);
-
- if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
- __glXClientInfo(dpy, dpyPriv->majorOpcode);
- }
- __glXUnlock();
-
- return dpyPriv;
+ private->number = info->codes->extension;
+ private->next = 0;
+ private->free_private = __glXFreeDisplayPrivate;
+ private->private_data = (char *) dpyPriv;
+ XAddToExtensionList(privList, private);
+
+ if (dpyPriv->majorVersion == 1 && dpyPriv->minorVersion >= 1) {
+ __glXClientInfo(dpy, dpyPriv->majorOpcode);
+ }
+ __glXUnlock();
+
+ return dpyPriv;
}
/*
** Setup for sending a GLX command on dpy. Make sure the extension is
** initialized. Try to avoid calling __glXInitialize as its kinda slow.
*/
-_X_HIDDEN CARD8 __glXSetupForCommand(Display *dpy)
+_X_HIDDEN CARD8
+__glXSetupForCommand(Display * dpy)
{
- GLXContext gc;
- __GLXdisplayPrivate *priv;
-
- /* If this thread has a current context, flush its rendering commands */
- gc = __glXGetCurrentContext();
- if (gc->currentDpy) {
- /* Flush rendering buffer of the current context, if any */
- (void) __glXFlushRenderBuffer(gc, gc->pc);
-
- if (gc->currentDpy == dpy) {
- /* Use opcode from gc because its right */
- INIT_MESA_SPARC
- return gc->majorOpcode;
- } else {
- /*
- ** Have to get info about argument dpy because it might be to
- ** a different server
- */
- }
- }
-
- /* Forced to lookup extension via the slow initialize route */
- priv = __glXInitialize(dpy);
- if (!priv) {
- return 0;
- }
- return priv->majorOpcode;
+ GLXContext gc;
+ __GLXdisplayPrivate *priv;
+
+ /* If this thread has a current context, flush its rendering commands */
+ gc = __glXGetCurrentContext();
+ if (gc->currentDpy) {
+ /* Flush rendering buffer of the current context, if any */
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+
+ if (gc->currentDpy == dpy) {
+ /* Use opcode from gc because its right */
+ INIT_MESA_SPARC;
+ return gc->majorOpcode;
+ }
+ else {
+ /*
+ ** Have to get info about argument dpy because it might be to
+ ** a different server
+ */
+ }
+ }
+
+ /* Forced to lookup extension via the slow initialize route */
+ priv = __glXInitialize(dpy);
+ if (!priv) {
+ return 0;
+ }
+ return priv->majorOpcode;
}
/**
@@ -787,37 +798,38 @@ _X_HIDDEN CARD8 __glXSetupForCommand(Display *dpy)
* Modify this function to use \c ctx->pc instead of the explicit
* \c pc parameter.
*/
-_X_HIDDEN GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
+_X_HIDDEN GLubyte *
+__glXFlushRenderBuffer(__GLXcontext * ctx, GLubyte * pc)
{
- Display * const dpy = ctx->currentDpy;
+ Display *const dpy = ctx->currentDpy;
#ifdef USE_XCB
- xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_connection_t *c = XGetXCBConnection(dpy);
#else
- xGLXRenderReq *req;
+ xGLXRenderReq *req;
#endif /* USE_XCB */
- const GLint size = pc - ctx->buf;
+ const GLint size = pc - ctx->buf;
- if ( (dpy != NULL) && (size > 0) ) {
+ if ((dpy != NULL) && (size > 0)) {
#ifdef USE_XCB
- xcb_glx_render(c, ctx->currentContextTag, size,
- (const uint8_t *)ctx->buf);
+ xcb_glx_render(c, ctx->currentContextTag, size,
+ (const uint8_t *) ctx->buf);
#else
- /* Send the entire buffer as an X request */
- LockDisplay(dpy);
- GetReq(GLXRender,req);
- req->reqType = ctx->majorOpcode;
- req->glxCode = X_GLXRender;
- req->contextTag = ctx->currentContextTag;
- req->length += (size + 3) >> 2;
- _XSend(dpy, (char *)ctx->buf, size);
- UnlockDisplay(dpy);
- SyncHandle();
+ /* Send the entire buffer as an X request */
+ LockDisplay(dpy);
+ GetReq(GLXRender, req);
+ req->reqType = ctx->majorOpcode;
+ req->glxCode = X_GLXRender;
+ req->contextTag = ctx->currentContextTag;
+ req->length += (size + 3) >> 2;
+ _XSend(dpy, (char *) ctx->buf, size);
+ UnlockDisplay(dpy);
+ SyncHandle();
#endif
- }
+ }
- /* Reset pointer and return it */
- ctx->pc = ctx->buf;
- return ctx->pc;
+ /* Reset pointer and return it */
+ ctx->pc = ctx->buf;
+ return ctx->pc;
}
@@ -837,35 +849,36 @@ _X_HIDDEN GLubyte *__glXFlushRenderBuffer(__GLXcontext *ctx, GLubyte *pc)
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
-_X_HIDDEN void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
- GLint totalRequests,
- const GLvoid * data, GLint dataLen)
+_X_HIDDEN void
+__glXSendLargeChunk(__GLXcontext * gc, GLint requestNumber,
+ GLint totalRequests, const GLvoid * data, GLint dataLen)
{
- Display *dpy = gc->currentDpy;
+ Display *dpy = gc->currentDpy;
#ifdef USE_XCB
- xcb_connection_t *c = XGetXCBConnection(dpy);
- xcb_glx_render_large(c, gc->currentContextTag, requestNumber, totalRequests, dataLen, data);
+ xcb_connection_t *c = XGetXCBConnection(dpy);
+ xcb_glx_render_large(c, gc->currentContextTag, requestNumber,
+ totalRequests, dataLen, data);
#else
- xGLXRenderLargeReq *req;
-
- if ( requestNumber == 1 ) {
- LockDisplay(dpy);
- }
-
- GetReq(GLXRenderLarge,req);
- req->reqType = gc->majorOpcode;
- req->glxCode = X_GLXRenderLarge;
- req->contextTag = gc->currentContextTag;
- req->length += (dataLen + 3) >> 2;
- req->requestNumber = requestNumber;
- req->requestTotal = totalRequests;
- req->dataBytes = dataLen;
- Data(dpy, data, dataLen);
-
- if ( requestNumber == totalRequests ) {
- UnlockDisplay(dpy);
- SyncHandle();
- }
+ xGLXRenderLargeReq *req;
+
+ if (requestNumber == 1) {
+ LockDisplay(dpy);
+ }
+
+ GetReq(GLXRenderLarge, req);
+ req->reqType = gc->majorOpcode;
+ req->glxCode = X_GLXRenderLarge;
+ req->contextTag = gc->currentContextTag;
+ req->length += (dataLen + 3) >> 2;
+ req->requestNumber = requestNumber;
+ req->requestTotal = totalRequests;
+ req->dataBytes = dataLen;
+ Data(dpy, data, dataLen);
+
+ if (requestNumber == totalRequests) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
#endif /* USE_XCB */
}
@@ -885,65 +898,69 @@ _X_HIDDEN void __glXSendLargeChunk(__GLXcontext *gc, GLint requestNumber,
* \param data Command data.
* \param dataLen Size, in bytes, of the command data.
*/
-_X_HIDDEN void __glXSendLargeCommand(__GLXcontext *ctx,
- const GLvoid *header, GLint headerLen,
- const GLvoid *data, GLint dataLen)
+_X_HIDDEN void
+__glXSendLargeCommand(__GLXcontext * ctx,
+ const GLvoid * header, GLint headerLen,
+ const GLvoid * data, GLint dataLen)
{
- GLint maxSize;
- GLint totalRequests, requestNumber;
+ GLint maxSize;
+ GLint totalRequests, requestNumber;
- /*
+ /*
** Calculate the maximum amount of data can be stuffed into a single
** packet. sz_xGLXRenderReq is added because bufSize is the maximum
** packet size minus sz_xGLXRenderReq.
*/
- maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
- totalRequests = 1 + (dataLen / maxSize);
- if (dataLen % maxSize) totalRequests++;
+ maxSize = (ctx->bufSize + sz_xGLXRenderReq) - sz_xGLXRenderLargeReq;
+ totalRequests = 1 + (dataLen / maxSize);
+ if (dataLen % maxSize)
+ totalRequests++;
- /*
+ /*
** Send all of the command, except the large array, as one request.
*/
- assert( headerLen <= maxSize );
- __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
+ assert(headerLen <= maxSize);
+ __glXSendLargeChunk(ctx, 1, totalRequests, header, headerLen);
- /*
+ /*
** Send enough requests until the whole array is sent.
*/
- for ( requestNumber = 2 ; requestNumber <= (totalRequests - 1) ; requestNumber++ ) {
- __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
- data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
- dataLen -= maxSize;
- assert( dataLen > 0 );
- }
-
- assert( dataLen <= maxSize );
- __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
+ for (requestNumber = 2; requestNumber <= (totalRequests - 1);
+ requestNumber++) {
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, maxSize);
+ data = (const GLvoid *) (((const GLubyte *) data) + maxSize);
+ dataLen -= maxSize;
+ assert(dataLen > 0);
+ }
+
+ assert(dataLen <= maxSize);
+ __glXSendLargeChunk(ctx, requestNumber, totalRequests, data, dataLen);
}
/************************************************************************/
#ifdef DEBUG
-_X_HIDDEN void __glXDumpDrawBuffer(__GLXcontext *ctx)
+_X_HIDDEN void
+__glXDumpDrawBuffer(__GLXcontext * ctx)
{
- GLubyte *p = ctx->buf;
- GLubyte *end = ctx->pc;
- GLushort opcode, length;
-
- while (p < end) {
- /* Fetch opcode */
- opcode = *((GLushort*) p);
- length = *((GLushort*) (p + 2));
- printf("%2x: %5d: ", opcode, length);
- length -= 4;
- p += 4;
- while (length > 0) {
- printf("%08x ", *((unsigned *) p));
- p += 4;
- length -= 4;
- }
- printf("\n");
- }
+ GLubyte *p = ctx->buf;
+ GLubyte *end = ctx->pc;
+ GLushort opcode, length;
+
+ while (p < end) {
+ /* Fetch opcode */
+ opcode = *((GLushort *) p);
+ length = *((GLushort *) (p + 2));
+ printf("%2x: %5d: ", opcode, length);
+ length -= 4;
+ p += 4;
+ while (length > 0) {
+ printf("%08x ", *((unsigned *) p));
+ p += 4;
+ length -= 4;
+ }
+ printf("\n");
+ }
}
#endif
@@ -970,29 +987,29 @@ extern void __glapi_sparc_icache_flush(unsigned int *);
static void
_glx_mesa_init_sparc_glapi_relocs(void)
{
- unsigned int *insn_ptr, *end_ptr;
- unsigned long disp_addr;
-
- insn_ptr = &_mesa_sparc_glapi_begin;
- end_ptr = &_mesa_sparc_glapi_end;
- disp_addr = (unsigned long) &_glapi_Dispatch;
-
- /*
- * Verbatim from Mesa sparc.c. It's needed because there doesn't
- * seem to be a better way to do this:
- *
- * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
- *
- * This code is patching in the ADDRESS of the pointer to the
- * dispatch table. Hence, it must be called exactly once, because
- * that address is not going to change.
- *
- * What it points to can change, but Mesa (and hence, we) assume
- * that there is only one pointer.
- *
- */
- while (insn_ptr < end_ptr) {
-#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )
+ unsigned int *insn_ptr, *end_ptr;
+ unsigned long disp_addr;
+
+ insn_ptr = &_mesa_sparc_glapi_begin;
+ end_ptr = &_mesa_sparc_glapi_end;
+ disp_addr = (unsigned long) &_glapi_Dispatch;
+
+ /*
+ * Verbatim from Mesa sparc.c. It's needed because there doesn't
+ * seem to be a better way to do this:
+ *
+ * UNCONDITIONAL_JUMP ( (*_glapi_Dispatch) + entry_offset )
+ *
+ * This code is patching in the ADDRESS of the pointer to the
+ * dispatch table. Hence, it must be called exactly once, because
+ * that address is not going to change.
+ *
+ * What it points to can change, but Mesa (and hence, we) assume
+ * that there is only one pointer.
+ *
+ */
+ while (insn_ptr < end_ptr) {
+#if ( defined(__sparc_v9__) && ( !defined(__linux__) || defined(__linux_64__) ) )
/*
This code patches for 64-bit addresses. This had better
not happen for Sparc/Linux, no matter what architecture we
@@ -1001,20 +1018,19 @@ _glx_mesa_init_sparc_glapi_relocs(void)
The 'defined(__linux_64__)' is used here as a placeholder for
when we do do 64-bit usermode on sparc linux.
*/
- insn_ptr[0] |= (disp_addr >> (32 + 10));
- insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
- __glapi_sparc_icache_flush(&insn_ptr[0]);
- insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
- insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
- __glapi_sparc_icache_flush(&insn_ptr[2]);
- insn_ptr += 11;
+ insn_ptr[0] |= (disp_addr >> (32 + 10));
+ insn_ptr[1] |= ((disp_addr & 0xffffffff) >> 10);
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr[2] |= ((disp_addr >> 32) & ((1 << 10) - 1));
+ insn_ptr[3] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[2]);
+ insn_ptr += 11;
#else
- insn_ptr[0] |= (disp_addr >> 10);
- insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
- __glapi_sparc_icache_flush(&insn_ptr[0]);
- insn_ptr += 5;
+ insn_ptr[0] |= (disp_addr >> 10);
+ insn_ptr[1] |= (disp_addr & ((1 << 10) - 1));
+ __glapi_sparc_icache_flush(&insn_ptr[0]);
+ insn_ptr += 5;
#endif
- }
+ }
}
-#endif /* sparc ASM in use */
-
+#endif /* sparc ASM in use */
diff --git a/src/glx/x11/glxextensions.c b/src/glx/x11/glxextensions.c
index f2b169a0e40..92109d67bfb 100644
--- a/src/glx/x11/glxextensions.c
+++ b/src/glx/x11/glxextensions.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2002, 2004
* All Rights Reserved.
@@ -48,27 +49,29 @@
#define EXT_ENABLED(bit,supported) (IS_SET( supported, bit ))
-struct extension_info {
- const char * const name;
- unsigned name_len;
+struct extension_info
+{
+ const char *const name;
+ unsigned name_len;
- unsigned char bit;
+ unsigned char bit;
/* This is the lowest version of GLX that "requires" this extension.
* For example, GLX 1.3 requires SGIX_fbconfig, SGIX_pbuffer, and
* SGI_make_current_read. If the extension is not required by any known
* version of GLX, use 0, 0.
*/
- unsigned char version_major;
- unsigned char version_minor;
- unsigned char client_support;
- unsigned char direct_support;
- unsigned char client_only; /** Is the extension client-side only? */
- unsigned char direct_only; /** Is the extension for direct
+ unsigned char version_major;
+ unsigned char version_minor;
+ unsigned char client_support;
+ unsigned char direct_support;
+ unsigned char client_only; /** Is the extension client-side only? */
+ unsigned char direct_only; /** Is the extension for direct
* contexts only?
*/
};
+/* *INDENT-OFF* */
static const struct extension_info known_glx_extensions[] = {
{ GLX(ARB_get_proc_address), VER(1,4), Y, N, Y, N },
{ GLX(ARB_multisample), VER(1,4), Y, Y, N, N },
@@ -245,14 +248,15 @@ static const struct extension_info known_gl_extensions[] = {
{ GL(SUN_slice_accum), VER(0,0), Y, N, N, N },
{ NULL }
};
+/* *INDENT-ON* */
/* global bit-fields of available extensions and their characteristics */
static unsigned char client_glx_support[8];
static unsigned char client_glx_only[8];
static unsigned char direct_glx_only[8];
-static unsigned char client_gl_support[ __GL_EXT_BYTES ];
-static unsigned char client_gl_only[ __GL_EXT_BYTES ];
+static unsigned char client_gl_support[__GL_EXT_BYTES];
+static unsigned char client_gl_only[__GL_EXT_BYTES];
/**
* Bits representing the set of extensions that are enabled by default in all
@@ -267,12 +271,13 @@ static const unsigned gl_major = 1;
static const unsigned gl_minor = 4;
/* client extensions string */
-static const char * __glXGLXClientExtensions = NULL;
+static const char *__glXGLXClientExtensions = NULL;
-static void __glXExtensionsCtr( void );
-static void __glXExtensionsCtrScreen( __GLXscreenConfigs *psc );
-static void __glXProcessServerString( const struct extension_info * ext,
- const char * server_string, unsigned char * server_support );
+static void __glXExtensionsCtr(void);
+static void __glXExtensionsCtrScreen(__GLXscreenConfigs * psc);
+static void __glXProcessServerString(const struct extension_info *ext,
+ const char *server_string,
+ unsigned char *server_support);
/**
* Set the state of a GLX extension.
@@ -283,24 +288,24 @@ static void __glXProcessServerString( const struct extension_info * ext,
* \param supported Table in which the state of the extension is to be set.
*/
static void
-set_glx_extension( const struct extension_info * ext,
- const char * name, unsigned name_len, GLboolean state,
- unsigned char * supported )
+set_glx_extension(const struct extension_info *ext,
+ const char *name, unsigned name_len, GLboolean state,
+ unsigned char *supported)
{
- unsigned i;
+ unsigned i;
- for ( i = 0 ; ext[i].name != NULL ; i++ ) {
- if ( (name_len == ext[i].name_len)
- && (strncmp( ext[i].name, name, name_len ) == 0) ) {
- if ( state ) {
- SET_BIT( supported, ext[i].bit );
- }
- else {
- CLR_BIT( supported, ext[i].bit );
- }
+ for (i = 0; ext[i].name != NULL; i++) {
+ if ((name_len == ext[i].name_len)
+ && (strncmp(ext[i].name, name, name_len) == 0)) {
+ if (state) {
+ SET_BIT(supported, ext[i].bit);
+ }
+ else {
+ CLR_BIT(supported, ext[i].bit);
+ }
- return;
+ return;
}
}
}
@@ -321,49 +326,47 @@ set_glx_extension( const struct extension_info * ext,
* the data pointed by \c server_support must be preinitialized to zero.
*/
static void
-__glXProcessServerString( const struct extension_info * ext,
- const char * server_string,
- unsigned char * server_support )
+__glXProcessServerString(const struct extension_info *ext,
+ const char *server_string,
+ unsigned char *server_support)
{
- unsigned base;
- unsigned len;
+ unsigned base;
+ unsigned len;
- for ( base = 0 ; server_string[ base ] != NUL ; /* empty */ ) {
+ for (base = 0; server_string[base] != NUL; /* empty */ ) {
/* Determine the length of the next extension name.
*/
- for ( len = 0
- ; (server_string[ base + len ] != SEPARATOR)
- && (server_string[ base + len ] != NUL)
- ; len++ ) {
- /* empty */
+ for (len = 0; (server_string[base + len] != SEPARATOR)
+ && (server_string[base + len] != NUL);
+ len++) {
+ /* empty */
}
/* Set the bit for the extension in the server_support table.
*/
- set_glx_extension( ext, & server_string[ base ], len, GL_TRUE,
- server_support );
+ set_glx_extension(ext, &server_string[base], len, GL_TRUE,
+ server_support);
+
-
/* Advance to the next extension string. This means that we skip
* over the previous string and any trialing white-space.
*/
- for ( base += len ;
- (server_string[ base ] == SEPARATOR)
- && (server_string[ base ] != NUL)
- ; base++ ) {
- /* empty */
+ for (base += len; (server_string[base] == SEPARATOR)
+ && (server_string[base] != NUL);
+ base++) {
+ /* empty */
}
}
}
void
-__glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
+__glXEnableDirectExtension(__GLXscreenConfigs * psc, const char *name)
{
- __glXExtensionsCtr();
- __glXExtensionsCtrScreen(psc);
+ __glXExtensionsCtr();
+ __glXExtensionsCtrScreen(psc);
- set_glx_extension(known_glx_extensions,
- name, strlen(name), GL_TRUE, psc->direct_support);
+ set_glx_extension(known_glx_extensions,
+ name, strlen(name), GL_TRUE, psc->direct_support);
}
/**
@@ -371,58 +374,58 @@ __glXEnableDirectExtension(__GLXscreenConfigs *psc, const char *name)
*/
static void
-__glXExtensionsCtr( void )
+__glXExtensionsCtr(void)
{
- unsigned i;
+ unsigned i;
static GLboolean ext_list_first_time = GL_TRUE;
- if ( ext_list_first_time ) {
+ if (ext_list_first_time) {
ext_list_first_time = GL_FALSE;
- (void) memset( client_glx_support, 0, sizeof( client_glx_support ) );
- (void) memset( direct_glx_support, 0, sizeof( direct_glx_support ) );
- (void) memset( client_glx_only, 0, sizeof( client_glx_only ) );
- (void) memset( direct_glx_only, 0, sizeof( direct_glx_only ) );
+ (void) memset(client_glx_support, 0, sizeof(client_glx_support));
+ (void) memset(direct_glx_support, 0, sizeof(direct_glx_support));
+ (void) memset(client_glx_only, 0, sizeof(client_glx_only));
+ (void) memset(direct_glx_only, 0, sizeof(direct_glx_only));
- (void) memset( client_gl_support, 0, sizeof( client_gl_support ) );
- (void) memset( client_gl_only, 0, sizeof( client_gl_only ) );
+ (void) memset(client_gl_support, 0, sizeof(client_gl_support));
+ (void) memset(client_gl_only, 0, sizeof(client_gl_only));
- for ( i = 0 ; known_glx_extensions[i].name != NULL ; i++ ) {
- const unsigned bit = known_glx_extensions[i].bit;
+ for (i = 0; known_glx_extensions[i].name != NULL; i++) {
+ const unsigned bit = known_glx_extensions[i].bit;
- if ( known_glx_extensions[i].client_support ) {
- SET_BIT( client_glx_support, bit );
- }
+ if (known_glx_extensions[i].client_support) {
+ SET_BIT(client_glx_support, bit);
+ }
- if ( known_glx_extensions[i].direct_support ) {
- SET_BIT( direct_glx_support, bit );
- }
+ if (known_glx_extensions[i].direct_support) {
+ SET_BIT(direct_glx_support, bit);
+ }
- if ( known_glx_extensions[i].client_only ) {
- SET_BIT( client_glx_only, bit );
- }
+ if (known_glx_extensions[i].client_only) {
+ SET_BIT(client_glx_only, bit);
+ }
- if ( known_glx_extensions[i].direct_only ) {
- SET_BIT( direct_glx_only, bit );
- }
+ if (known_glx_extensions[i].direct_only) {
+ SET_BIT(direct_glx_only, bit);
+ }
}
- for ( i = 0 ; known_gl_extensions[i].name != NULL ; i++ ) {
- const unsigned bit = known_gl_extensions[i].bit;
+ for (i = 0; known_gl_extensions[i].name != NULL; i++) {
+ const unsigned bit = known_gl_extensions[i].bit;
- if ( known_gl_extensions[i].client_support ) {
- SET_BIT( client_gl_support, bit );
- }
+ if (known_gl_extensions[i].client_support) {
+ SET_BIT(client_gl_support, bit);
+ }
- if ( known_gl_extensions[i].client_only ) {
- SET_BIT( client_gl_only, bit );
- }
+ if (known_gl_extensions[i].client_only) {
+ SET_BIT(client_gl_only, bit);
+ }
}
-
+
#if 0
- fprintf( stderr, "[%s:%u] Maximum client library version: %u.%u\n",
- __func__, __LINE__, gl_major, gl_minor );
+ fprintf(stderr, "[%s:%u] Maximum client library version: %u.%u\n",
+ __func__, __LINE__, gl_major, gl_minor);
#endif
}
}
@@ -435,13 +438,13 @@ __glXExtensionsCtr( void )
*/
static void
-__glXExtensionsCtrScreen( __GLXscreenConfigs *psc )
+__glXExtensionsCtrScreen(__GLXscreenConfigs * psc)
{
- if (psc->ext_list_first_time) {
- psc->ext_list_first_time = GL_FALSE;
- (void) memcpy( psc->direct_support, direct_glx_support,
- sizeof( direct_glx_support ) );
- }
+ if (psc->ext_list_first_time) {
+ psc->ext_list_first_time = GL_FALSE;
+ (void) memcpy(psc->direct_support, direct_glx_support,
+ sizeof(direct_glx_support));
+ }
}
@@ -455,14 +458,14 @@ __glXExtensionsCtrScreen( __GLXscreenConfigs *psc )
* \c NULL, then \c GL_FALSE is returned.
*/
GLboolean
-__glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
+__glXExtensionBitIsEnabled(__GLXscreenConfigs * psc, unsigned bit)
{
GLboolean enabled = GL_FALSE;
- if ( psc != NULL ) {
+ if (psc != NULL) {
__glXExtensionsCtr();
- __glXExtensionsCtrScreen( psc );
- enabled = EXT_ENABLED( bit, psc->direct_support );
+ __glXExtensionsCtrScreen(psc);
+ enabled = EXT_ENABLED(bit, psc->direct_support);
}
return enabled;
@@ -474,12 +477,12 @@ __glXExtensionBitIsEnabled( __GLXscreenConfigs *psc, unsigned bit )
*
*/
GLboolean
-__glExtensionBitIsEnabled( const __GLXcontext * gc, unsigned bit )
+__glExtensionBitIsEnabled(const __GLXcontext * gc, unsigned bit)
{
GLboolean enabled = GL_FALSE;
- if ( gc != NULL ) {
- enabled = EXT_ENABLED( bit, gc->gl_extension_bits );
+ if (gc != NULL) {
+ enabled = EXT_ENABLED(bit, gc->gl_extension_bits);
}
return enabled;
@@ -491,34 +494,34 @@ __glExtensionBitIsEnabled( const __GLXcontext * gc, unsigned bit )
* Convert a bit-field to a string of supported extensions.
*/
static char *
-__glXGetStringFromTable( const struct extension_info * ext,
- const unsigned char * supported )
+__glXGetStringFromTable(const struct extension_info *ext,
+ const unsigned char *supported)
{
- unsigned i;
- unsigned ext_str_len;
- char * ext_str;
- char * point;
+ unsigned i;
+ unsigned ext_str_len;
+ char *ext_str;
+ char *point;
ext_str_len = 0;
- for ( i = 0 ; ext[i].name != NULL ; i++ ) {
- if ( EXT_ENABLED( ext[i].bit, supported ) ) {
- ext_str_len += ext[i].name_len + 1;
+ for (i = 0; ext[i].name != NULL; i++) {
+ if (EXT_ENABLED(ext[i].bit, supported)) {
+ ext_str_len += ext[i].name_len + 1;
}
}
- ext_str = Xmalloc( ext_str_len + 1 );
- if ( ext_str != NULL ) {
+ ext_str = Xmalloc(ext_str_len + 1);
+ if (ext_str != NULL) {
point = ext_str;
- for ( i = 0 ; ext[i].name != NULL ; i++ ) {
- if ( EXT_ENABLED( ext[i].bit, supported ) ) {
- (void) memcpy( point, ext[i].name, ext[i].name_len );
- point += ext[i].name_len;
+ for (i = 0; ext[i].name != NULL; i++) {
+ if (EXT_ENABLED(ext[i].bit, supported)) {
+ (void) memcpy(point, ext[i].name, ext[i].name_len);
+ point += ext[i].name_len;
- *point = ' ';
- point++;
- }
+ *point = ' ';
+ point++;
+ }
}
*point = '\0';
@@ -532,12 +535,12 @@ __glXGetStringFromTable( const struct extension_info * ext,
* Get the string of client library supported extensions.
*/
const char *
-__glXGetClientExtensions( void )
+__glXGetClientExtensions(void)
{
- if ( __glXGLXClientExtensions == NULL ) {
+ if (__glXGLXClientExtensions == NULL) {
__glXExtensionsCtr();
- __glXGLXClientExtensions = __glXGetStringFromTable( known_glx_extensions,
- client_glx_support );
+ __glXGLXClientExtensions = __glXGetStringFromTable(known_glx_extensions,
+ client_glx_support);
}
return __glXGLXClientExtensions;
@@ -555,20 +558,20 @@ __glXGetClientExtensions( void )
*/
void
-__glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
- GLboolean display_is_direct_capable,
- int minor_version )
+__glXCalculateUsableExtensions(__GLXscreenConfigs * psc,
+ GLboolean display_is_direct_capable,
+ int minor_version)
{
unsigned char server_support[8];
unsigned char usable[8];
- unsigned i;
+ unsigned i;
__glXExtensionsCtr();
- __glXExtensionsCtrScreen( psc );
+ __glXExtensionsCtrScreen(psc);
- (void) memset( server_support, 0, sizeof( server_support ) );
- __glXProcessServerString( known_glx_extensions,
- psc->serverGLXexts, server_support );
+ (void) memset(server_support, 0, sizeof(server_support));
+ __glXProcessServerString(known_glx_extensions,
+ psc->serverGLXexts, server_support);
/* This is a hack. Some servers support GLX 1.3 but don't export
@@ -577,20 +580,20 @@ __glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
* "emulated" as well.
*/
- if ( minor_version >= 3 ) {
- SET_BIT( server_support, EXT_visual_info_bit );
- SET_BIT( server_support, EXT_visual_rating_bit );
- SET_BIT( server_support, SGI_make_current_read_bit );
- SET_BIT( server_support, SGIX_fbconfig_bit );
- SET_BIT( server_support, SGIX_pbuffer_bit );
-
+ if (minor_version >= 3) {
+ SET_BIT(server_support, EXT_visual_info_bit);
+ SET_BIT(server_support, EXT_visual_rating_bit);
+ SET_BIT(server_support, SGI_make_current_read_bit);
+ SET_BIT(server_support, SGIX_fbconfig_bit);
+ SET_BIT(server_support, SGIX_pbuffer_bit);
+
/* This one is a little iffy. GLX 1.3 doesn't incorporate all of this
* extension. However, the only part that is not strictly client-side
* is shared. That's the glXQueryContext / glXQueryContextInfoEXT
* function.
*/
- SET_BIT( server_support, EXT_import_context_bit );
+ SET_BIT(server_support, EXT_import_context_bit);
}
@@ -604,22 +607,24 @@ __glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
* support it.
*/
- if ( display_is_direct_capable ) {
- for ( i = 0 ; i < 8 ; i++ ) {
- usable[i] = (client_glx_support[i] & client_glx_only[i])
- | (client_glx_support[i] & psc->direct_support[i] & server_support[i])
- | (client_glx_support[i] & psc->direct_support[i] & direct_glx_only[i]);
+ if (display_is_direct_capable) {
+ for (i = 0; i < 8; i++) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & psc->
+ direct_support[i] & server_support[i])
+ | (client_glx_support[i] & psc->
+ direct_support[i] & direct_glx_only[i]);
}
}
else {
- for ( i = 0 ; i < 8 ; i++ ) {
- usable[i] = (client_glx_support[i] & client_glx_only[i])
- | (client_glx_support[i] & server_support[i]);
+ for (i = 0; i < 8; i++) {
+ usable[i] = (client_glx_support[i] & client_glx_only[i])
+ | (client_glx_support[i] & server_support[i]);
}
}
- psc->effectiveGLXexts = __glXGetStringFromTable( known_glx_extensions,
- usable );
+ psc->effectiveGLXexts = __glXGetStringFromTable(known_glx_extensions,
+ usable);
}
@@ -634,32 +639,33 @@ __glXCalculateUsableExtensions( __GLXscreenConfigs *psc,
*/
void
-__glXCalculateUsableGLExtensions( __GLXcontext * gc,
- const char * server_string,
- int major_version, int minor_version )
+__glXCalculateUsableGLExtensions(__GLXcontext * gc,
+ const char *server_string,
+ int major_version, int minor_version)
{
- unsigned char server_support[ __GL_EXT_BYTES ];
- unsigned char usable[ __GL_EXT_BYTES ];
- unsigned i;
+ unsigned char server_support[__GL_EXT_BYTES];
+ unsigned char usable[__GL_EXT_BYTES];
+ unsigned i;
__glXExtensionsCtr();
- (void) memset( server_support, 0, sizeof( server_support ) );
- __glXProcessServerString( known_gl_extensions, server_string,
- server_support );
+ (void) memset(server_support, 0, sizeof(server_support));
+ __glXProcessServerString(known_gl_extensions, server_string,
+ server_support);
/* Handle lazy servers that don't export all the extensions strings that
* are part of the GL core version that they support.
*/
- for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
- if ( (known_gl_extensions[i].version_major != 0)
- && ((major_version > known_gl_extensions[i].version_major)
- || ((major_version == known_gl_extensions[i].version_major)
- && (minor_version >= known_gl_extensions[i].version_minor))) ) {
- SET_BIT( server_support, known_gl_extensions[i].bit );
+ for (i = 0; i < __GL_EXT_BYTES; i++) {
+ if ((known_gl_extensions[i].version_major != 0)
+ && ((major_version > known_gl_extensions[i].version_major)
+ || ((major_version == known_gl_extensions[i].version_major)
+ && (minor_version >=
+ known_gl_extensions[i].version_minor)))) {
+ SET_BIT(server_support, known_gl_extensions[i].bit);
}
}
@@ -669,14 +675,14 @@ __glXCalculateUsableGLExtensions( __GLXcontext * gc,
* and it only needs client-side support.
*/
- for ( i = 0 ; i < __GL_EXT_BYTES ; i++ ) {
+ for (i = 0; i < __GL_EXT_BYTES; i++) {
usable[i] = (client_gl_support[i] & client_gl_only[i])
- | (client_gl_support[i] & server_support[i]);
+ | (client_gl_support[i] & server_support[i]);
}
- gc->extensions = (unsigned char *)
- __glXGetStringFromTable( known_gl_extensions, usable );
- (void) memcpy( gc->gl_extension_bits, usable, sizeof( usable ) );
+ gc->extensions = (unsigned char *)
+ __glXGetStringFromTable(known_gl_extensions, usable);
+ (void) memcpy(gc->gl_extension_bits, usable, sizeof(usable));
}
@@ -685,11 +691,11 @@ __glXCalculateUsableGLExtensions( __GLXcontext * gc,
* rendering.
*/
void
-__glXGetGLVersion( int * major_version, int * minor_version )
-{
- __glXExtensionsCtr();
- *major_version = gl_major;
- *minor_version = gl_minor;
+__glXGetGLVersion(int *major_version, int *minor_version)
+{
+ __glXExtensionsCtr();
+ *major_version = gl_major;
+ *minor_version = gl_minor;
}
@@ -699,8 +705,8 @@ __glXGetGLVersion( int * major_version, int * minor_version )
* supported by the client to the server.
*/
char *
-__glXGetClientGLExtensionString( void )
+__glXGetClientGLExtensionString(void)
{
- __glXExtensionsCtr();
- return __glXGetStringFromTable( known_gl_extensions, client_gl_support );
+ __glXExtensionsCtr();
+ return __glXGetStringFromTable(known_gl_extensions, client_gl_support);
}
diff --git a/src/glx/x11/glxextensions.h b/src/glx/x11/glxextensions.h
index b99cebbdfaf..e7998986da3 100644
--- a/src/glx/x11/glxextensions.h
+++ b/src/glx/x11/glxextensions.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2002, 2004
* All Rights Reserved.
@@ -31,7 +32,8 @@
#ifndef GLX_GLXEXTENSIONS_H
#define GLX_GLXEXTENSIONS_H
-enum {
+enum
+{
ARB_get_proc_address_bit = 0,
ARB_multisample_bit,
ARB_render_texture_bit,
@@ -40,7 +42,7 @@ enum {
EXT_visual_rating_bit,
EXT_import_context_bit,
MESA_agp_offset_bit,
- MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
+ MESA_allocate_memory_bit, /* Replaces MESA_agp_offset & NV_vertex_array_range */
MESA_copy_sub_buffer_bit,
MESA_depth_float_bit,
MESA_pixmap_colormap_bit,
@@ -67,7 +69,8 @@ enum {
EXT_texture_from_pixmap_bit
};
-enum {
+enum
+{
GL_ARB_depth_texture_bit = 0,
GL_ARB_draw_buffers_bit,
GL_ARB_fragment_program_bit,
@@ -230,28 +233,34 @@ enum {
struct __GLXscreenConfigsRec;
struct __GLXcontextRec;
-extern GLboolean __glXExtensionBitIsEnabled( struct __GLXscreenConfigsRec *psc, unsigned bit );
-extern const char * __glXGetClientExtensions( void );
-extern void __glXCalculateUsableExtensions( struct __GLXscreenConfigsRec *psc,
- GLboolean display_is_direct_capable, int server_minor_version );
+extern GLboolean __glXExtensionBitIsEnabled(struct __GLXscreenConfigsRec *psc,
+ unsigned bit);
+extern const char *__glXGetClientExtensions(void);
+extern void __glXCalculateUsableExtensions(struct __GLXscreenConfigsRec *psc,
+ GLboolean
+ display_is_direct_capable,
+ int server_minor_version);
-extern void __glXCalculateUsableGLExtensions( struct __GLXcontextRec * gc,
- const char * server_string, int major_version, int minor_version );
-extern void __glXGetGLVersion( int * major_version, int * minor_version );
-extern char * __glXGetClientGLExtensionString( void );
+extern void __glXCalculateUsableGLExtensions(struct __GLXcontextRec *gc,
+ const char *server_string,
+ int major_version,
+ int minor_version);
+extern void __glXGetGLVersion(int *major_version, int *minor_version);
+extern char *__glXGetClientGLExtensionString(void);
-extern GLboolean __glExtensionBitIsEnabled( const struct __GLXcontextRec * gc,
- unsigned bit );
+extern GLboolean __glExtensionBitIsEnabled(const struct __GLXcontextRec *gc,
+ unsigned bit);
extern void
-__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc, const char *name);
+__glXEnableDirectExtension(struct __GLXscreenConfigsRec *psc,
+ const char *name);
/* Source-level backwards compatibility with old drivers. They won't
* find the respective functions, though.
*/
-typedef void (* PFNGLXENABLEEXTENSIONPROC) ( const char * name,
- GLboolean force_client );
-typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
+typedef void (*PFNGLXENABLEEXTENSIONPROC) (const char *name,
+ GLboolean force_client);
+typedef void (*PFNGLXDISABLEEXTENSIONPROC) (const char *name);
/* GLX_ALIAS should be used for functions with a non-void return type.
GLX_ALIAS_VOID is for functions with a void return type. */
@@ -261,17 +270,17 @@ typedef void (* PFNGLXDISABLEEXTENSIONPROC) ( const char * name );
#else
# if defined(__GNUC__) && !defined(GLX_ALIAS_UNSUPPORTED)
# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
- return_type real_func proto_args \
- __attribute__ ((alias( # aliased_func ) ));
+ return_type real_func proto_args \
+ __attribute__ ((alias( # aliased_func ) ));
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
- GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
+ GLX_ALIAS(void, real_func, proto_args, args, aliased_func)
# else
# define GLX_ALIAS(return_type, real_func, proto_args, args, aliased_func) \
- return_type real_func proto_args \
- { return aliased_func args ; }
+ return_type real_func proto_args \
+ { return aliased_func args ; }
# define GLX_ALIAS_VOID(real_func, proto_args, args, aliased_func) \
- void real_func proto_args \
- { aliased_func args ; }
+ void real_func proto_args \
+ { aliased_func args ; }
# endif /* __GNUC__ */
#endif /* GLX_NO_STATIC_EXTENSION_FUNCTIONS */
diff --git a/src/glx/x11/glxhash.c b/src/glx/x11/glxhash.c
index b7b8fb27385..22d5995aa50 100644
--- a/src/glx/x11/glxhash.c
+++ b/src/glx/x11/glxhash.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/* glxhash.c -- Small hash table support for integer -> integer mapping
* Taken from libdrm.
*
@@ -80,8 +81,8 @@
#define HASH_MAGIC 0xdeadbeef
#define HASH_DEBUG 0
-#define HASH_SIZE 512 /* Good for about 100 entries */
- /* If you change this value, you probably
+#define HASH_SIZE 512 /* Good for about 100 entries */
+ /* If you change this value, you probably
have to change the HashHash hashing
function! */
@@ -92,323 +93,370 @@
#define HASH_RANDOM random()
#define HASH_RANDOM_DESTROY
-typedef struct __glxHashBucket {
- unsigned long key;
- void *value;
- struct __glxHashBucket *next;
+typedef struct __glxHashBucket
+{
+ unsigned long key;
+ void *value;
+ struct __glxHashBucket *next;
} __glxHashBucket, *__glxHashBucketPtr;
typedef struct __glxHashTable *__glxHashTablePtr;
-struct __glxHashTable {
- unsigned long magic;
- unsigned long hits; /* At top of linked list */
- unsigned long partials; /* Not at top of linked list */
- unsigned long misses; /* Not in table */
- __glxHashBucketPtr buckets[HASH_SIZE];
- int p0;
- __glxHashBucketPtr p1;
+struct __glxHashTable
+{
+ unsigned long magic;
+ unsigned long hits; /* At top of linked list */
+ unsigned long partials; /* Not at top of linked list */
+ unsigned long misses; /* Not in table */
+ __glxHashBucketPtr buckets[HASH_SIZE];
+ int p0;
+ __glxHashBucketPtr p1;
};
-static unsigned long HashHash(unsigned long key)
+static unsigned long
+HashHash(unsigned long key)
{
- unsigned long hash = 0;
- unsigned long tmp = key;
- static int init = 0;
- static unsigned long scatter[256];
- int i;
-
- if (!init) {
- HASH_RANDOM_DECL;
- HASH_RANDOM_INIT(37);
- for (i = 0; i < 256; i++) scatter[i] = HASH_RANDOM;
- HASH_RANDOM_DESTROY;
- ++init;
- }
-
- while (tmp) {
- hash = (hash << 1) + scatter[tmp & 0xff];
- tmp >>= 8;
- }
-
- hash %= HASH_SIZE;
+ unsigned long hash = 0;
+ unsigned long tmp = key;
+ static int init = 0;
+ static unsigned long scatter[256];
+ int i;
+
+ if (!init) {
+ HASH_RANDOM_DECL;
+ HASH_RANDOM_INIT(37);
+ for (i = 0; i < 256; i++)
+ scatter[i] = HASH_RANDOM;
+ HASH_RANDOM_DESTROY;
+ ++init;
+ }
+
+ while (tmp) {
+ hash = (hash << 1) + scatter[tmp & 0xff];
+ tmp >>= 8;
+ }
+
+ hash %= HASH_SIZE;
#if HASH_DEBUG
- printf( "Hash(%d) = %d\n", key, hash);
+ printf("Hash(%d) = %d\n", key, hash);
#endif
- return hash;
+ return hash;
}
-_X_HIDDEN __glxHashTable *__glxHashCreate(void)
+_X_HIDDEN __glxHashTable *
+__glxHashCreate(void)
{
- __glxHashTablePtr table;
- int i;
-
- table = HASH_ALLOC(sizeof(*table));
- if (!table) return NULL;
- table->magic = HASH_MAGIC;
- table->hits = 0;
- table->partials = 0;
- table->misses = 0;
-
- for (i = 0; i < HASH_SIZE; i++) table->buckets[i] = NULL;
- return table;
+ __glxHashTablePtr table;
+ int i;
+
+ table = HASH_ALLOC(sizeof(*table));
+ if (!table)
+ return NULL;
+ table->magic = HASH_MAGIC;
+ table->hits = 0;
+ table->partials = 0;
+ table->misses = 0;
+
+ for (i = 0; i < HASH_SIZE; i++)
+ table->buckets[i] = NULL;
+ return table;
}
-_X_HIDDEN int __glxHashDestroy(__glxHashTable *t)
+_X_HIDDEN int
+__glxHashDestroy(__glxHashTable * t)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
- __glxHashBucketPtr bucket;
- __glxHashBucketPtr next;
- int i;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- for (i = 0; i < HASH_SIZE; i++) {
- for (bucket = table->buckets[i]; bucket;) {
- next = bucket->next;
- HASH_FREE(bucket);
- bucket = next;
- }
- }
- HASH_FREE(table);
- return 0;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
+ __glxHashBucketPtr bucket;
+ __glxHashBucketPtr next;
+ int i;
+
+ if (table->magic != HASH_MAGIC)
+ return -1; /* Bad magic */
+
+ for (i = 0; i < HASH_SIZE; i++) {
+ for (bucket = table->buckets[i]; bucket;) {
+ next = bucket->next;
+ HASH_FREE(bucket);
+ bucket = next;
+ }
+ }
+ HASH_FREE(table);
+ return 0;
}
/* Find the bucket and organize the list so that this bucket is at the
top. */
-static __glxHashBucketPtr HashFind(__glxHashTablePtr table,
- unsigned long key, unsigned long *h)
+static __glxHashBucketPtr
+HashFind(__glxHashTablePtr table, unsigned long key, unsigned long *h)
{
- unsigned long hash = HashHash(key);
- __glxHashBucketPtr prev = NULL;
- __glxHashBucketPtr bucket;
-
- if (h) *h = hash;
-
- for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
- if (bucket->key == key) {
- if (prev) {
- /* Organize */
- prev->next = bucket->next;
- bucket->next = table->buckets[hash];
- table->buckets[hash] = bucket;
- ++table->partials;
- } else {
- ++table->hits;
- }
- return bucket;
- }
- prev = bucket;
- }
- ++table->misses;
- return NULL;
+ unsigned long hash = HashHash(key);
+ __glxHashBucketPtr prev = NULL;
+ __glxHashBucketPtr bucket;
+
+ if (h)
+ *h = hash;
+
+ for (bucket = table->buckets[hash]; bucket; bucket = bucket->next) {
+ if (bucket->key == key) {
+ if (prev) {
+ /* Organize */
+ prev->next = bucket->next;
+ bucket->next = table->buckets[hash];
+ table->buckets[hash] = bucket;
+ ++table->partials;
+ }
+ else {
+ ++table->hits;
+ }
+ return bucket;
+ }
+ prev = bucket;
+ }
+ ++table->misses;
+ return NULL;
}
-_X_HIDDEN int __glxHashLookup(__glxHashTable *t,
- unsigned long key, void **value)
+_X_HIDDEN int
+__glxHashLookup(__glxHashTable * t, unsigned long key, void **value)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
- __glxHashBucketPtr bucket;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
+ __glxHashBucketPtr bucket;
- if (!table || table->magic != HASH_MAGIC) return -1; /* Bad magic */
+ if (!table || table->magic != HASH_MAGIC)
+ return -1; /* Bad magic */
- bucket = HashFind(table, key, NULL);
- if (!bucket) return 1; /* Not found */
- *value = bucket->value;
- return 0; /* Found */
+ bucket = HashFind(table, key, NULL);
+ if (!bucket)
+ return 1; /* Not found */
+ *value = bucket->value;
+ return 0; /* Found */
}
-_X_HIDDEN int __glxHashInsert(__glxHashTable *t,
- unsigned long key, void *value)
+_X_HIDDEN int
+__glxHashInsert(__glxHashTable * t, unsigned long key, void *value)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
- __glxHashBucketPtr bucket;
- unsigned long hash;
-
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
-
- if (HashFind(table, key, &hash)) return 1; /* Already in table */
-
- bucket = HASH_ALLOC(sizeof(*bucket));
- if (!bucket) return -1; /* Error */
- bucket->key = key;
- bucket->value = value;
- bucket->next = table->buckets[hash];
- table->buckets[hash] = bucket;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
+ __glxHashBucketPtr bucket;
+ unsigned long hash;
+
+ if (table->magic != HASH_MAGIC)
+ return -1; /* Bad magic */
+
+ if (HashFind(table, key, &hash))
+ return 1; /* Already in table */
+
+ bucket = HASH_ALLOC(sizeof(*bucket));
+ if (!bucket)
+ return -1; /* Error */
+ bucket->key = key;
+ bucket->value = value;
+ bucket->next = table->buckets[hash];
+ table->buckets[hash] = bucket;
#if HASH_DEBUG
- printf("Inserted %d at %d/%p\n", key, hash, bucket);
+ printf("Inserted %d at %d/%p\n", key, hash, bucket);
#endif
- return 0; /* Added to table */
+ return 0; /* Added to table */
}
-_X_HIDDEN int __glxHashDelete(__glxHashTable *t, unsigned long key)
+_X_HIDDEN int
+__glxHashDelete(__glxHashTable * t, unsigned long key)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
- unsigned long hash;
- __glxHashBucketPtr bucket;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
+ unsigned long hash;
+ __glxHashBucketPtr bucket;
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+ if (table->magic != HASH_MAGIC)
+ return -1; /* Bad magic */
- bucket = HashFind(table, key, &hash);
+ bucket = HashFind(table, key, &hash);
- if (!bucket) return 1; /* Not found */
+ if (!bucket)
+ return 1; /* Not found */
- table->buckets[hash] = bucket->next;
- HASH_FREE(bucket);
- return 0;
+ table->buckets[hash] = bucket->next;
+ HASH_FREE(bucket);
+ return 0;
}
-_X_HIDDEN int __glxHashNext(__glxHashTable *t,
- unsigned long *key, void **value)
+_X_HIDDEN int
+__glxHashNext(__glxHashTable * t, unsigned long *key, void **value)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
-
- while (table->p0 < HASH_SIZE) {
- if (table->p1) {
- *key = table->p1->key;
- *value = table->p1->value;
- table->p1 = table->p1->next;
- return 1;
- }
- table->p1 = table->buckets[table->p0];
- ++table->p0;
- }
- return 0;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
+
+ while (table->p0 < HASH_SIZE) {
+ if (table->p1) {
+ *key = table->p1->key;
+ *value = table->p1->value;
+ table->p1 = table->p1->next;
+ return 1;
+ }
+ table->p1 = table->buckets[table->p0];
+ ++table->p0;
+ }
+ return 0;
}
-_X_HIDDEN int __glxHashFirst(__glxHashTable *t,
- unsigned long *key, void **value)
+_X_HIDDEN int
+__glxHashFirst(__glxHashTable * t, unsigned long *key, void **value)
{
- __glxHashTablePtr table = (__glxHashTablePtr)t;
+ __glxHashTablePtr table = (__glxHashTablePtr) t;
- if (table->magic != HASH_MAGIC) return -1; /* Bad magic */
+ if (table->magic != HASH_MAGIC)
+ return -1; /* Bad magic */
- table->p0 = 0;
- table->p1 = table->buckets[0];
- return __glxHashNext(table, key, value);
+ table->p0 = 0;
+ table->p1 = table->buckets[0];
+ return __glxHashNext(table, key, value);
}
#if HASH_MAIN
#define DIST_LIMIT 10
static int dist[DIST_LIMIT];
-static void clear_dist(void) {
- int i;
+static void
+clear_dist(void)
+{
+ int i;
- for (i = 0; i < DIST_LIMIT; i++) dist[i] = 0;
+ for (i = 0; i < DIST_LIMIT; i++)
+ dist[i] = 0;
}
-static int count_entries(__glxHashBucketPtr bucket)
+static int
+count_entries(__glxHashBucketPtr bucket)
{
- int count = 0;
+ int count = 0;
- for (; bucket; bucket = bucket->next) ++count;
- return count;
+ for (; bucket; bucket = bucket->next)
+ ++count;
+ return count;
}
-static void update_dist(int count)
+static void
+update_dist(int count)
{
- if (count >= DIST_LIMIT) ++dist[DIST_LIMIT-1];
- else ++dist[count];
+ if (count >= DIST_LIMIT)
+ ++dist[DIST_LIMIT - 1];
+ else
+ ++dist[count];
}
-static void compute_dist(__glxHashTablePtr table)
+static void
+compute_dist(__glxHashTablePtr table)
{
- int i;
- __glxHashBucketPtr bucket;
-
- printf("Hits = %ld, partials = %ld, misses = %ld\n",
- table->hits, table->partials, table->misses);
- clear_dist();
- for (i = 0; i < HASH_SIZE; i++) {
- bucket = table->buckets[i];
- update_dist(count_entries(bucket));
- }
- for (i = 0; i < DIST_LIMIT; i++) {
- if (i != DIST_LIMIT-1) printf("%5d %10d\n", i, dist[i]);
- else printf("other %10d\n", dist[i]);
- }
+ int i;
+ __glxHashBucketPtr bucket;
+
+ printf("Hits = %ld, partials = %ld, misses = %ld\n",
+ table->hits, table->partials, table->misses);
+ clear_dist();
+ for (i = 0; i < HASH_SIZE; i++) {
+ bucket = table->buckets[i];
+ update_dist(count_entries(bucket));
+ }
+ for (i = 0; i < DIST_LIMIT; i++) {
+ if (i != DIST_LIMIT - 1)
+ printf("%5d %10d\n", i, dist[i]);
+ else
+ printf("other %10d\n", dist[i]);
+ }
}
-static void check_table(__glxHashTablePtr table,
- unsigned long key, unsigned long value)
+static void
+check_table(__glxHashTablePtr table, unsigned long key, unsigned long value)
{
- unsigned long retval = 0;
- int retcode = __glxHashLookup(table, key, &retval);
-
- switch (retcode) {
- case -1:
- printf("Bad magic = 0x%08lx:"
- " key = %lu, expected = %lu, returned = %lu\n",
- table->magic, key, value, retval);
- break;
- case 1:
- printf("Not found: key = %lu, expected = %lu returned = %lu\n",
- key, value, retval);
- break;
- case 0:
- if (value != retval)
- printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
- key, value, retval);
- break;
- default:
- printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
- retcode, key, value, retval);
- break;
- }
+ unsigned long retval = 0;
+ int retcode = __glxHashLookup(table, key, &retval);
+
+ switch (retcode) {
+ case -1:
+ printf("Bad magic = 0x%08lx:"
+ " key = %lu, expected = %lu, returned = %lu\n",
+ table->magic, key, value, retval);
+ break;
+ case 1:
+ printf("Not found: key = %lu, expected = %lu returned = %lu\n",
+ key, value, retval);
+ break;
+ case 0:
+ if (value != retval)
+ printf("Bad value: key = %lu, expected = %lu, returned = %lu\n",
+ key, value, retval);
+ break;
+ default:
+ printf("Bad retcode = %d: key = %lu, expected = %lu, returned = %lu\n",
+ retcode, key, value, retval);
+ break;
+ }
}
-int main(void)
+int
+main(void)
{
- __glxHashTablePtr table;
- int i;
-
- printf("\n***** 256 consecutive integers ****\n");
- table = __glxHashCreate();
- for (i = 0; i < 256; i++) __glxHashInsert(table, i, i);
- for (i = 0; i < 256; i++) check_table(table, i, i);
- for (i = 256; i >= 0; i--) check_table(table, i, i);
- compute_dist(table);
- __glxHashDestroy(table);
-
- printf("\n***** 1024 consecutive integers ****\n");
- table = __glxHashCreate();
- for (i = 0; i < 1024; i++) __glxHashInsert(table, i, i);
- for (i = 0; i < 1024; i++) check_table(table, i, i);
- for (i = 1024; i >= 0; i--) check_table(table, i, i);
- compute_dist(table);
- __glxHashDestroy(table);
-
- printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
- table = __glxHashCreate();
- for (i = 0; i < 1024; i++) __glxHashInsert(table, i*4096, i);
- for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
- for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
- compute_dist(table);
- __glxHashDestroy(table);
-
- printf("\n***** 1024 random integers ****\n");
- table = __glxHashCreate();
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) __glxHashInsert(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) check_table(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) check_table(table, random(), i);
- compute_dist(table);
- __glxHashDestroy(table);
-
- printf("\n***** 5000 random integers ****\n");
- table = __glxHashCreate();
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) __glxHashInsert(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) check_table(table, random(), i);
- srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) check_table(table, random(), i);
- compute_dist(table);
- __glxHashDestroy(table);
-
- return 0;
+ __glxHashTablePtr table;
+ int i;
+
+ printf("\n***** 256 consecutive integers ****\n");
+ table = __glxHashCreate();
+ for (i = 0; i < 256; i++)
+ __glxHashInsert(table, i, i);
+ for (i = 0; i < 256; i++)
+ check_table(table, i, i);
+ for (i = 256; i >= 0; i--)
+ check_table(table, i, i);
+ compute_dist(table);
+ __glxHashDestroy(table);
+
+ printf("\n***** 1024 consecutive integers ****\n");
+ table = __glxHashCreate();
+ for (i = 0; i < 1024; i++)
+ __glxHashInsert(table, i, i);
+ for (i = 0; i < 1024; i++)
+ check_table(table, i, i);
+ for (i = 1024; i >= 0; i--)
+ check_table(table, i, i);
+ compute_dist(table);
+ __glxHashDestroy(table);
+
+ printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
+ table = __glxHashCreate();
+ for (i = 0; i < 1024; i++)
+ __glxHashInsert(table, i * 4096, i);
+ for (i = 0; i < 1024; i++)
+ check_table(table, i * 4096, i);
+ for (i = 1024; i >= 0; i--)
+ check_table(table, i * 4096, i);
+ compute_dist(table);
+ __glxHashDestroy(table);
+
+ printf("\n***** 1024 random integers ****\n");
+ table = __glxHashCreate();
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++)
+ __glxHashInsert(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++)
+ check_table(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 1024; i++)
+ check_table(table, random(), i);
+ compute_dist(table);
+ __glxHashDestroy(table);
+
+ printf("\n***** 5000 random integers ****\n");
+ table = __glxHashCreate();
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++)
+ __glxHashInsert(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++)
+ check_table(table, random(), i);
+ srandom(0xbeefbeef);
+ for (i = 0; i < 5000; i++)
+ check_table(table, random(), i);
+ compute_dist(table);
+ __glxHashDestroy(table);
+
+ return 0;
}
#endif
diff --git a/src/glx/x11/glxhash.h b/src/glx/x11/glxhash.h
index 66012fb889d..e97848fa8d3 100644
--- a/src/glx/x11/glxhash.h
+++ b/src/glx/x11/glxhash.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
#ifndef _GLX_HASH_H_
#define _GLX_HASH_H_
@@ -6,11 +7,15 @@ typedef struct __glxHashTable __glxHashTable;
/* Hash table routines */
extern __glxHashTable *__glxHashCreate(void);
-extern int __glxHashDestroy(__glxHashTable *t);
-extern int __glxHashLookup(__glxHashTable *t, unsigned long key, void **value);
-extern int __glxHashInsert(__glxHashTable *t, unsigned long key, void *value);
-extern int __glxHashDelete(__glxHashTable *t, unsigned long key);
-extern int __glxHashFirst(__glxHashTable *t, unsigned long *key, void **value);
-extern int __glxHashNext(__glxHashTable *t, unsigned long *key, void **value);
+extern int __glxHashDestroy(__glxHashTable * t);
+extern int __glxHashLookup(__glxHashTable * t, unsigned long key,
+ void **value);
+extern int __glxHashInsert(__glxHashTable * t, unsigned long key,
+ void *value);
+extern int __glxHashDelete(__glxHashTable * t, unsigned long key);
+extern int __glxHashFirst(__glxHashTable * t, unsigned long *key,
+ void **value);
+extern int __glxHashNext(__glxHashTable * t, unsigned long *key,
+ void **value);
#endif /* _GLX_HASH_H_ */
diff --git a/src/glx/x11/indirect_init.h b/src/glx/x11/indirect_init.h
index 72255f13014..8a75fb04523 100644
--- a/src/glx/x11/indirect_init.h
+++ b/src/glx/x11/indirect_init.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
diff --git a/src/glx/x11/indirect_texture_compression.c b/src/glx/x11/indirect_texture_compression.c
index 56768580177..68837668204 100644
--- a/src/glx/x11/indirect_texture_compression.c
+++ b/src/glx/x11/indirect_texture_compression.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
@@ -40,31 +41,31 @@
void
-__indirect_glGetCompressedTexImageARB( GLenum target, GLint level,
- GLvoid * img )
+__indirect_glGetCompressedTexImageARB(GLenum target, GLint level,
+ GLvoid * img)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXGetTexImageReply reply;
- size_t image_bytes;
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN( X_GLsop_GetCompressedTexImage, 8 );
- __GLX_SINGLE_PUT_LONG( 0, target );
- __GLX_SINGLE_PUT_LONG( 4, level );
- __GLX_SINGLE_READ_XREPLY();
-
- image_bytes = reply.width;
- assert( image_bytes <= ((4 * reply.length) - 0) );
- assert( image_bytes >= ((4 * reply.length) - 3) );
-
- if ( image_bytes != 0 ) {
- _XRead( dpy, (char *) img, image_bytes );
- if ( image_bytes < (4 * reply.length) ) {
- _XEatData( dpy, (4 * reply.length) - image_bytes );
- }
- }
-
- __GLX_SINGLE_END();
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXGetTexImageReply reply;
+ size_t image_bytes;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetCompressedTexImage, 8);
+ __GLX_SINGLE_PUT_LONG(0, target);
+ __GLX_SINGLE_PUT_LONG(4, level);
+ __GLX_SINGLE_READ_XREPLY();
+
+ image_bytes = reply.width;
+ assert(image_bytes <= ((4 * reply.length) - 0));
+ assert(image_bytes >= ((4 * reply.length) - 3));
+
+ if (image_bytes != 0) {
+ _XRead(dpy, (char *) img, image_bytes);
+ if (image_bytes < (4 * reply.length)) {
+ _XEatData(dpy, (4 * reply.length) - image_bytes);
+ }
+ }
+
+ __GLX_SINGLE_END();
}
@@ -73,60 +74,59 @@ __indirect_glGetCompressedTexImageARB( GLenum target, GLint level,
* \c glCompressedTexImage2D.
*/
static void
-CompressedTexImage1D2D( GLenum target, GLint level,
- GLenum internal_format,
- GLsizei width, GLsizei height,
- GLint border, GLsizei image_size,
- const GLvoid *data, CARD32 rop )
+CompressedTexImage1D2D(GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid * data, CARD32 rop)
{
- __GLX_DECLARE_VARIABLES();
-
- __GLX_LOAD_VARIABLES();
- if ( gc->currentDpy == NULL ) {
- return;
- }
-
- if ( (target == GL_PROXY_TEXTURE_1D)
- || (target == GL_PROXY_TEXTURE_2D)
- || (target == GL_PROXY_TEXTURE_CUBE_MAP) ) {
- compsize = 0;
- }
- else {
- compsize = image_size;
- }
-
- cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE
- + compsize );
- if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
- __GLX_BEGIN_VARIABLE( rop, cmdlen );
- __GLX_PUT_LONG( 4, target );
- __GLX_PUT_LONG( 8, level );
- __GLX_PUT_LONG( 12, internal_format );
- __GLX_PUT_LONG( 16, width );
- __GLX_PUT_LONG( 20, height );
- __GLX_PUT_LONG( 24, border );
- __GLX_PUT_LONG( 28, image_size );
- if ( compsize != 0 ) {
- __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE,
- data, image_size );
- }
- __GLX_END( cmdlen );
- }
- else {
- assert( compsize != 0 );
-
- __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
- __GLX_PUT_LONG( 8, target );
- __GLX_PUT_LONG( 12, level );
- __GLX_PUT_LONG( 16, internal_format );
- __GLX_PUT_LONG( 20, width );
- __GLX_PUT_LONG( 24, height );
- __GLX_PUT_LONG( 28, border );
- __GLX_PUT_LONG( 32, image_size );
- __glXSendLargeCommand( gc, gc->pc,
- __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4,
- data, image_size );
- }
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (gc->currentDpy == NULL) {
+ return;
+ }
+
+ if ((target == GL_PROXY_TEXTURE_1D)
+ || (target == GL_PROXY_TEXTURE_2D)
+ || (target == GL_PROXY_TEXTURE_CUBE_MAP)) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + compsize);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ __GLX_BEGIN_VARIABLE(rop, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_LONG(8, level);
+ __GLX_PUT_LONG(12, internal_format);
+ __GLX_PUT_LONG(16, width);
+ __GLX_PUT_LONG(20, height);
+ __GLX_PUT_LONG(24, border);
+ __GLX_PUT_LONG(28, image_size);
+ if (compsize != 0) {
+ __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE,
+ data, image_size);
+ }
+ __GLX_END(cmdlen);
+ }
+ else {
+ assert(compsize != 0);
+
+ __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_LONG(12, level);
+ __GLX_PUT_LONG(16, internal_format);
+ __GLX_PUT_LONG(20, width);
+ __GLX_PUT_LONG(24, height);
+ __GLX_PUT_LONG(28, border);
+ __GLX_PUT_LONG(32, image_size);
+ __glXSendLargeCommand(gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size);
+ }
}
@@ -135,213 +135,210 @@ CompressedTexImage1D2D( GLenum target, GLint level,
* \c glCompressedTexSubImage2D.
*/
static void
-CompressedTexSubImage1D2D( GLenum target, GLint level,
- GLsizei xoffset, GLsizei yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLsizei image_size,
- const GLvoid *data, CARD32 rop )
+CompressedTexSubImage1D2D(GLenum target, GLint level,
+ GLsizei xoffset, GLsizei yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid * data, CARD32 rop)
{
- __GLX_DECLARE_VARIABLES();
-
- __GLX_LOAD_VARIABLES();
- if ( gc->currentDpy == NULL ) {
- return;
- }
-
- if ( target == GL_PROXY_TEXTURE_3D ) {
- compsize = 0;
- }
- else {
- compsize = image_size;
- }
-
- cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE
- + compsize );
- if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
- __GLX_BEGIN_VARIABLE( rop, cmdlen );
- __GLX_PUT_LONG( 4, target );
- __GLX_PUT_LONG( 8, level );
- __GLX_PUT_LONG( 12, xoffset );
- __GLX_PUT_LONG( 16, yoffset );
- __GLX_PUT_LONG( 20, width );
- __GLX_PUT_LONG( 24, height );
- __GLX_PUT_LONG( 28, format );
- __GLX_PUT_LONG( 32, image_size );
- if ( compsize != 0 ) {
- __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE,
- data, image_size );
- }
- __GLX_END( cmdlen );
- }
- else {
- assert( compsize != 0 );
-
- __GLX_BEGIN_VARIABLE_LARGE( rop, cmdlen + 4 );
- __GLX_PUT_LONG( 8, target );
- __GLX_PUT_LONG( 12, level );
- __GLX_PUT_LONG( 16, xoffset );
- __GLX_PUT_LONG( 20, yoffset );
- __GLX_PUT_LONG( 24, width );
- __GLX_PUT_LONG( 28, height );
- __GLX_PUT_LONG( 32, format );
- __GLX_PUT_LONG( 36, image_size );
- __glXSendLargeCommand( gc, gc->pc,
- __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4,
- data, image_size );
- }
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (gc->currentDpy == NULL) {
+ return;
+ }
+
+ if (target == GL_PROXY_TEXTURE_3D) {
+ compsize = 0;
+ }
+ else {
+ compsize = image_size;
+ }
+
+ cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + compsize);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ __GLX_BEGIN_VARIABLE(rop, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_LONG(8, level);
+ __GLX_PUT_LONG(12, xoffset);
+ __GLX_PUT_LONG(16, yoffset);
+ __GLX_PUT_LONG(20, width);
+ __GLX_PUT_LONG(24, height);
+ __GLX_PUT_LONG(28, format);
+ __GLX_PUT_LONG(32, image_size);
+ if (compsize != 0) {
+ __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE,
+ data, image_size);
+ }
+ __GLX_END(cmdlen);
+ }
+ else {
+ assert(compsize != 0);
+
+ __GLX_BEGIN_VARIABLE_LARGE(rop, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_LONG(12, level);
+ __GLX_PUT_LONG(16, xoffset);
+ __GLX_PUT_LONG(20, yoffset);
+ __GLX_PUT_LONG(24, width);
+ __GLX_PUT_LONG(28, height);
+ __GLX_PUT_LONG(32, format);
+ __GLX_PUT_LONG(36, image_size);
+ __glXSendLargeCommand(gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_CMD_HDR_SIZE + 4,
+ data, image_size);
+ }
}
void
-__indirect_glCompressedTexImage1DARB( GLenum target, GLint level,
- GLenum internal_format, GLsizei width,
- GLint border, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexImage1DARB(GLenum target, GLint level,
+ GLenum internal_format, GLsizei width,
+ GLint border, GLsizei image_size,
+ const GLvoid * data)
{
- CompressedTexImage1D2D( target, level, internal_format, width, 0,
- border, image_size, data,
- X_GLrop_CompressedTexImage1D );
+ CompressedTexImage1D2D(target, level, internal_format, width, 0,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage1D);
}
void
-__indirect_glCompressedTexImage2DARB( GLenum target, GLint level,
- GLenum internal_format,
- GLsizei width, GLsizei height,
- GLint border, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexImage2DARB(GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLint border, GLsizei image_size,
+ const GLvoid * data)
{
- CompressedTexImage1D2D( target, level, internal_format, width, height,
- border, image_size, data,
- X_GLrop_CompressedTexImage2D );
+ CompressedTexImage1D2D(target, level, internal_format, width, height,
+ border, image_size, data,
+ X_GLrop_CompressedTexImage2D);
}
void
-__indirect_glCompressedTexImage3DARB( GLenum target, GLint level,
- GLenum internal_format,
- GLsizei width, GLsizei height, GLsizei depth,
- GLint border, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexImage3DARB(GLenum target, GLint level,
+ GLenum internal_format,
+ GLsizei width, GLsizei height,
+ GLsizei depth, GLint border,
+ GLsizei image_size, const GLvoid * data)
{
- __GLX_DECLARE_VARIABLES();
-
- __GLX_LOAD_VARIABLES();
- if ( gc->currentDpy == NULL ) {
- return;
- }
-
- cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE
- + image_size );
- if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
- __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexImage3D, cmdlen );
- __GLX_PUT_LONG( 4, target );
- __GLX_PUT_LONG( 8, level );
- __GLX_PUT_LONG( 12, internal_format );
- __GLX_PUT_LONG( 16, width );
- __GLX_PUT_LONG( 20, height );
- __GLX_PUT_LONG( 24, depth );
- __GLX_PUT_LONG( 28, border );
- __GLX_PUT_LONG( 32, image_size );
- if ( image_size != 0 ) {
- __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE,
- data, image_size );
- }
- __GLX_END( cmdlen );
- }
- else {
- __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexImage3D,
- cmdlen + 4 );
- __GLX_PUT_LONG( 8, target );
- __GLX_PUT_LONG( 12, level );
- __GLX_PUT_LONG( 16, internal_format );
- __GLX_PUT_LONG( 20, width );
- __GLX_PUT_LONG( 24, height );
- __GLX_PUT_LONG( 28, depth );
- __GLX_PUT_LONG( 32, border );
- __GLX_PUT_LONG( 36, image_size );
- __glXSendLargeCommand( gc, gc->pc,
- __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4,
- data, image_size );
- }
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (gc->currentDpy == NULL) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + image_size);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexImage3D, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_LONG(8, level);
+ __GLX_PUT_LONG(12, internal_format);
+ __GLX_PUT_LONG(16, width);
+ __GLX_PUT_LONG(20, height);
+ __GLX_PUT_LONG(24, depth);
+ __GLX_PUT_LONG(28, border);
+ __GLX_PUT_LONG(32, image_size);
+ if (image_size != 0) {
+ __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size);
+ }
+ __GLX_END(cmdlen);
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexImage3D, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_LONG(12, level);
+ __GLX_PUT_LONG(16, internal_format);
+ __GLX_PUT_LONG(20, width);
+ __GLX_PUT_LONG(24, height);
+ __GLX_PUT_LONG(28, depth);
+ __GLX_PUT_LONG(32, border);
+ __GLX_PUT_LONG(36, image_size);
+ __glXSendLargeCommand(gc, gc->pc,
+ __GLX_COMPRESSED_TEXIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size);
+ }
}
void
-__indirect_glCompressedTexSubImage1DARB( GLenum target, GLint level,
- GLint xoffset,
- GLsizei width,
- GLenum format, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexSubImage1DARB(GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width,
+ GLenum format, GLsizei image_size,
+ const GLvoid * data)
{
- CompressedTexSubImage1D2D( target, level, xoffset, 0, width, 0,
- format, image_size, data,
- X_GLrop_CompressedTexSubImage1D );
+ CompressedTexSubImage1D2D(target, level, xoffset, 0, width, 0,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage1D);
}
void
-__indirect_glCompressedTexSubImage2DARB( GLenum target, GLint level,
- GLint xoffset, GLint yoffset,
- GLsizei width, GLsizei height,
- GLenum format, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexSubImage2DARB(GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLsizei image_size,
+ const GLvoid * data)
{
- CompressedTexSubImage1D2D( target, level, xoffset, yoffset, width, height,
- format, image_size, data,
- X_GLrop_CompressedTexSubImage2D );
+ CompressedTexSubImage1D2D(target, level, xoffset, yoffset, width, height,
+ format, image_size, data,
+ X_GLrop_CompressedTexSubImage2D);
}
void
-__indirect_glCompressedTexSubImage3DARB( GLenum target, GLint level,
- GLint xoffset, GLint yoffset, GLint zoffset,
- GLsizei width, GLsizei height, GLsizei depth,
- GLenum format, GLsizei image_size,
- const GLvoid *data )
+__indirect_glCompressedTexSubImage3DARB(GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format, GLsizei image_size,
+ const GLvoid * data)
{
- __GLX_DECLARE_VARIABLES();
-
- __GLX_LOAD_VARIABLES();
- if ( gc->currentDpy == NULL ) {
- return;
- }
-
- cmdlen = __GLX_PAD( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE
- + image_size );
- if ( cmdlen <= gc->maxSmallRenderCommandSize ) {
- __GLX_BEGIN_VARIABLE( X_GLrop_CompressedTexSubImage3D, cmdlen );
- __GLX_PUT_LONG( 4, target );
- __GLX_PUT_LONG( 8, level );
- __GLX_PUT_LONG( 12, xoffset );
- __GLX_PUT_LONG( 16, yoffset );
- __GLX_PUT_LONG( 20, zoffset );
- __GLX_PUT_LONG( 24, width );
- __GLX_PUT_LONG( 28, height );
- __GLX_PUT_LONG( 32, depth );
- __GLX_PUT_LONG( 36, format );
- __GLX_PUT_LONG( 40, image_size );
- if ( image_size != 0 ) {
- __GLX_PUT_CHAR_ARRAY( __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE,
- data, image_size );
- }
- __GLX_END( cmdlen );
- }
- else {
- __GLX_BEGIN_VARIABLE_LARGE( X_GLrop_CompressedTexSubImage3D,
- cmdlen + 4 );
- __GLX_PUT_LONG( 8, target );
- __GLX_PUT_LONG( 12, level );
- __GLX_PUT_LONG( 16, xoffset );
- __GLX_PUT_LONG( 20, yoffset );
- __GLX_PUT_LONG( 24, zoffset );
- __GLX_PUT_LONG( 28, width );
- __GLX_PUT_LONG( 32, height );
- __GLX_PUT_LONG( 36, depth );
- __GLX_PUT_LONG( 40, format );
- __GLX_PUT_LONG( 44, image_size );
- __glXSendLargeCommand( gc, gc->pc,
- __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4,
- data, image_size );
- }
+ __GLX_DECLARE_VARIABLES();
+
+ __GLX_LOAD_VARIABLES();
+ if (gc->currentDpy == NULL) {
+ return;
+ }
+
+ cmdlen = __GLX_PAD(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE
+ + image_size);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ __GLX_BEGIN_VARIABLE(X_GLrop_CompressedTexSubImage3D, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_LONG(8, level);
+ __GLX_PUT_LONG(12, xoffset);
+ __GLX_PUT_LONG(16, yoffset);
+ __GLX_PUT_LONG(20, zoffset);
+ __GLX_PUT_LONG(24, width);
+ __GLX_PUT_LONG(28, height);
+ __GLX_PUT_LONG(32, depth);
+ __GLX_PUT_LONG(36, format);
+ __GLX_PUT_LONG(40, image_size);
+ if (image_size != 0) {
+ __GLX_PUT_CHAR_ARRAY(__GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE,
+ data, image_size);
+ }
+ __GLX_END(cmdlen);
+ }
+ else {
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_CompressedTexSubImage3D, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_LONG(12, level);
+ __GLX_PUT_LONG(16, xoffset);
+ __GLX_PUT_LONG(20, yoffset);
+ __GLX_PUT_LONG(24, zoffset);
+ __GLX_PUT_LONG(28, width);
+ __GLX_PUT_LONG(32, height);
+ __GLX_PUT_LONG(36, depth);
+ __GLX_PUT_LONG(40, format);
+ __GLX_PUT_LONG(44, image_size);
+ __glXSendLargeCommand(gc, gc->pc,
+ __GLX_COMPRESSED_TEXSUBIMAGE_3D_CMD_HDR_SIZE + 4,
+ data, image_size);
+ }
}
diff --git a/src/glx/x11/indirect_transpose_matrix.c b/src/glx/x11/indirect_transpose_matrix.c
index 2144410e5ac..14acee8eecf 100644
--- a/src/glx/x11/indirect_transpose_matrix.c
+++ b/src/glx/x11/indirect_transpose_matrix.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004
* All Rights Reserved.
@@ -25,59 +26,61 @@
#include <GL/gl.h>
#include "indirect.h"
-static void TransposeMatrixf(const GLfloat s[16], GLfloat d[16])
+static void
+TransposeMatrixf(const GLfloat s[16], GLfloat d[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- d[i*4+j] = s[j*4+i];
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ d[i * 4 + j] = s[j * 4 + i];
+ }
+ }
}
-static void TransposeMatrixd(const GLdouble s[16], GLdouble d[16])
+static void
+TransposeMatrixd(const GLdouble s[16], GLdouble d[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < 4; j++) {
- d[i*4+j] = s[j*4+i];
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < 4; j++) {
+ d[i * 4 + j] = s[j * 4 + i];
+ }
+ }
}
void
-__indirect_glLoadTransposeMatrixdARB( const GLdouble * m )
+__indirect_glLoadTransposeMatrixdARB(const GLdouble * m)
{
GLdouble mt[16];
-
- TransposeMatrixd( m, mt );
- __indirect_glLoadMatrixd( mt );
+
+ TransposeMatrixd(m, mt);
+ __indirect_glLoadMatrixd(mt);
}
void
-__indirect_glLoadTransposeMatrixfARB( const GLfloat * m )
+__indirect_glLoadTransposeMatrixfARB(const GLfloat * m)
{
GLfloat mt[16];
- TransposeMatrixf( m, mt );
- __indirect_glLoadMatrixf( mt );
+ TransposeMatrixf(m, mt);
+ __indirect_glLoadMatrixf(mt);
}
void
-__indirect_glMultTransposeMatrixdARB( const GLdouble * m )
+__indirect_glMultTransposeMatrixdARB(const GLdouble * m)
{
GLdouble mt[16];
-
- TransposeMatrixd( m, mt );
- __indirect_glMultMatrixd( mt );
+
+ TransposeMatrixd(m, mt);
+ __indirect_glMultMatrixd(mt);
}
void
-__indirect_glMultTransposeMatrixfARB( const GLfloat * m )
+__indirect_glMultTransposeMatrixfARB(const GLfloat * m)
{
GLfloat mt[16];
- TransposeMatrixf( m, mt );
- __indirect_glMultMatrixf( mt );
+ TransposeMatrixf(m, mt);
+ __indirect_glMultMatrixf(mt);
}
diff --git a/src/glx/x11/indirect_vertex_array.c b/src/glx/x11/indirect_vertex_array.c
index c7a20e2bc56..b7744bceacd 100644
--- a/src/glx/x11/indirect_vertex_array.c
+++ b/src/glx/x11/indirect_vertex_array.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
@@ -65,25 +66,28 @@
* \author Ian Romanick <[email protected]>
*/
-static void emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count );
-static void emit_DrawArrays_old ( GLenum mode, GLint first, GLsizei count );
+static void emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count);
+static void emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count);
-static void emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices );
-static void emit_DrawElements_old ( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices );
+static void emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices);
+static void emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices);
-static GLubyte * emit_element_none( GLubyte * dst,
- const struct array_state_vector * arrays, unsigned index );
-static GLubyte * emit_element_old( GLubyte * dst,
- const struct array_state_vector * arrays, unsigned index );
-static struct array_state * get_array_entry(
- const struct array_state_vector * arrays, GLenum key, unsigned index );
-static void fill_array_info_cache( struct array_state_vector * arrays );
-static GLboolean validate_mode(__GLXcontext *gc, GLenum mode);
-static GLboolean validate_count(__GLXcontext *gc, GLsizei count);
-static GLboolean validate_type(__GLXcontext *gc, GLenum type);
+static GLubyte *emit_element_none(GLubyte * dst,
+ const struct array_state_vector *arrays,
+ unsigned index);
+static GLubyte *emit_element_old(GLubyte * dst,
+ const struct array_state_vector *arrays,
+ unsigned index);
+static struct array_state *get_array_entry(const struct array_state_vector
+ *arrays, GLenum key,
+ unsigned index);
+static void fill_array_info_cache(struct array_state_vector *arrays);
+static GLboolean validate_mode(__GLXcontext * gc, GLenum mode);
+static GLboolean validate_count(__GLXcontext * gc, GLsizei count);
+static GLboolean validate_type(__GLXcontext * gc, GLenum type);
/**
@@ -97,7 +101,7 @@ static GLboolean validate_type(__GLXcontext *gc, GLenum type);
* \c GL_3_BYTES, or \c GL_4_BYTES.
*/
const GLuint __glXTypeSize_table[16] = {
- 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0
+ 1, 1, 2, 2, 4, 4, 4, 0, 0, 0, 8, 0, 0, 0, 0, 0
};
@@ -106,24 +110,23 @@ const GLuint __glXTypeSize_table[16] = {
* __glXInitVertexArrayState().
*/
void
-__glXFreeVertexArrayState( __GLXcontext * gc )
+__glXFreeVertexArrayState(__GLXcontext * gc)
{
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector* arrays = state->array_state;
-
- if (arrays) {
- if (arrays->stack) {
- free(arrays->stack);
- arrays->stack = NULL;
- }
- if (arrays->arrays) {
- free(arrays->arrays);
- arrays->arrays = NULL;
- }
- free(arrays);
- arrays = NULL;
- state->array_state = NULL;
- }
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+
+ if (arrays) {
+ if (arrays->stack) {
+ free(arrays->stack);
+ arrays->stack = NULL;
+ }
+ if (arrays->arrays) {
+ free(arrays->arrays);
+ arrays->arrays = NULL;
+ }
+ free(arrays);
+ state->array_state = NULL;
+ }
}
@@ -142,154 +145,154 @@ __glXFreeVertexArrayState( __GLXcontext * gc )
* Return values from malloc are not properly tested.
*/
void
-__glXInitVertexArrayState( __GLXcontext * gc )
+__glXInitVertexArrayState(__GLXcontext * gc)
{
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays;
-
- unsigned array_count;
- int texture_units = 1, vertex_program_attribs = 0;
- unsigned i, j;
-
- GLboolean got_fog = GL_FALSE;
- GLboolean got_secondary_color = GL_FALSE;
-
-
- arrays = calloc( 1, sizeof( struct array_state_vector ) );
- state->array_state = arrays;
-
- arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
- arrays->new_DrawArrays_possible = GL_FALSE;
- arrays->DrawArrays = NULL;
-
- arrays->active_texture_unit = 0;
-
-
- /* Determine how many arrays are actually needed. Only arrays that
- * are supported by the server are create. For example, if the server
- * supports only 2 texture units, then only 2 texture coordinate arrays
- * are created.
- *
- * At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY,
- * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
- * GL_EDGE_FLAG_ARRAY are supported.
- */
-
- array_count = 5;
-
- if ( __glExtensionBitIsEnabled( gc, GL_EXT_fog_coord_bit )
- || (gc->server_major > 1) || (gc->server_minor >= 4) ) {
- got_fog = GL_TRUE;
- array_count++;
- }
-
- if ( __glExtensionBitIsEnabled( gc, GL_EXT_secondary_color_bit )
- || (gc->server_major > 1) || (gc->server_minor >= 4) ) {
- got_secondary_color = GL_TRUE;
- array_count++;
- }
-
- if ( __glExtensionBitIsEnabled( gc, GL_ARB_multitexture_bit )
- || (gc->server_major > 1) || (gc->server_minor >= 3) ) {
- __indirect_glGetIntegerv( GL_MAX_TEXTURE_UNITS, & texture_units );
- }
-
- if ( __glExtensionBitIsEnabled( gc, GL_ARB_vertex_program_bit ) ) {
- __indirect_glGetProgramivARB( GL_VERTEX_PROGRAM_ARB,
- GL_MAX_PROGRAM_ATTRIBS_ARB,
- & vertex_program_attribs );
- }
-
- arrays->num_texture_units = texture_units;
- arrays->num_vertex_program_attribs = vertex_program_attribs;
- array_count += texture_units + vertex_program_attribs;
- arrays->num_arrays = array_count;
- arrays->arrays = calloc( array_count, sizeof( struct array_state ) );
-
- arrays->arrays[0].data_type = GL_FLOAT;
- arrays->arrays[0].count = 3;
- arrays->arrays[0].key = GL_NORMAL_ARRAY;
- arrays->arrays[0].normalized = GL_TRUE;
- arrays->arrays[0].old_DrawArrays_possible = GL_TRUE;
-
- arrays->arrays[1].data_type = GL_FLOAT;
- arrays->arrays[1].count = 4;
- arrays->arrays[1].key = GL_COLOR_ARRAY;
- arrays->arrays[1].normalized = GL_TRUE;
- arrays->arrays[1].old_DrawArrays_possible = GL_TRUE;
-
- arrays->arrays[2].data_type = GL_FLOAT;
- arrays->arrays[2].count = 1;
- arrays->arrays[2].key = GL_INDEX_ARRAY;
- arrays->arrays[2].old_DrawArrays_possible = GL_TRUE;
-
- arrays->arrays[3].data_type = GL_UNSIGNED_BYTE;
- arrays->arrays[3].count = 1;
- arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY;
- arrays->arrays[3].old_DrawArrays_possible = GL_TRUE;
-
- for ( i = 0 ; i < texture_units ; i++ ) {
- arrays->arrays[4 + i].data_type = GL_FLOAT;
- arrays->arrays[4 + i].count = 4;
- arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY;
-
- arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0);
- arrays->arrays[4 + i].index = i;
-
- arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0;
- }
-
- i = 4 + texture_units;
-
- if ( got_fog ) {
- arrays->arrays[i].data_type = GL_FLOAT;
- arrays->arrays[i].count = 1;
- arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY;
- arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
- i++;
- }
-
- if ( got_secondary_color ) {
- arrays->arrays[i].data_type = GL_FLOAT;
- arrays->arrays[i].count = 3;
- arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY;
- arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
- arrays->arrays[i].normalized = GL_TRUE;
- i++;
- }
-
-
- for ( j = 0 ; j < vertex_program_attribs ; j++ ) {
- const unsigned idx = (vertex_program_attribs - (j + 1));
-
-
- arrays->arrays[idx + i].data_type = GL_FLOAT;
- arrays->arrays[idx + i].count = 4;
- arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER;
-
- arrays->arrays[idx + i].old_DrawArrays_possible = 0;
- arrays->arrays[idx + i].index = idx;
-
- arrays->arrays[idx + i].header[1] = idx;
- }
-
- i += vertex_program_attribs;
-
-
- /* Vertex array *must* be last becuase of the way that
- * emit_DrawArrays_none works.
- */
-
- arrays->arrays[i].data_type = GL_FLOAT;
- arrays->arrays[i].count = 4;
- arrays->arrays[i].key = GL_VERTEX_ARRAY;
- arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
-
- assert( (i + 1) == arrays->num_arrays );
-
- arrays->stack_index = 0;
- arrays->stack = malloc( sizeof( struct array_stack_state )
- * arrays->num_arrays );
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays;
+
+ unsigned array_count;
+ int texture_units = 1, vertex_program_attribs = 0;
+ unsigned i, j;
+
+ GLboolean got_fog = GL_FALSE;
+ GLboolean got_secondary_color = GL_FALSE;
+
+
+ arrays = calloc(1, sizeof(struct array_state_vector));
+ state->array_state = arrays;
+
+ arrays->old_DrawArrays_possible = !state->NoDrawArraysProtocol;
+ arrays->new_DrawArrays_possible = GL_FALSE;
+ arrays->DrawArrays = NULL;
+
+ arrays->active_texture_unit = 0;
+
+
+ /* Determine how many arrays are actually needed. Only arrays that
+ * are supported by the server are create. For example, if the server
+ * supports only 2 texture units, then only 2 texture coordinate arrays
+ * are created.
+ *
+ * At the very least, GL_VERTEX_ARRAY, GL_NORMAL_ARRAY,
+ * GL_COLOR_ARRAY, GL_INDEX_ARRAY, GL_TEXTURE_COORD_ARRAY, and
+ * GL_EDGE_FLAG_ARRAY are supported.
+ */
+
+ array_count = 5;
+
+ if (__glExtensionBitIsEnabled(gc, GL_EXT_fog_coord_bit)
+ || (gc->server_major > 1) || (gc->server_minor >= 4)) {
+ got_fog = GL_TRUE;
+ array_count++;
+ }
+
+ if (__glExtensionBitIsEnabled(gc, GL_EXT_secondary_color_bit)
+ || (gc->server_major > 1) || (gc->server_minor >= 4)) {
+ got_secondary_color = GL_TRUE;
+ array_count++;
+ }
+
+ if (__glExtensionBitIsEnabled(gc, GL_ARB_multitexture_bit)
+ || (gc->server_major > 1) || (gc->server_minor >= 3)) {
+ __indirect_glGetIntegerv(GL_MAX_TEXTURE_UNITS, &texture_units);
+ }
+
+ if (__glExtensionBitIsEnabled(gc, GL_ARB_vertex_program_bit)) {
+ __indirect_glGetProgramivARB(GL_VERTEX_PROGRAM_ARB,
+ GL_MAX_PROGRAM_ATTRIBS_ARB,
+ &vertex_program_attribs);
+ }
+
+ arrays->num_texture_units = texture_units;
+ arrays->num_vertex_program_attribs = vertex_program_attribs;
+ array_count += texture_units + vertex_program_attribs;
+ arrays->num_arrays = array_count;
+ arrays->arrays = calloc(array_count, sizeof(struct array_state));
+
+ arrays->arrays[0].data_type = GL_FLOAT;
+ arrays->arrays[0].count = 3;
+ arrays->arrays[0].key = GL_NORMAL_ARRAY;
+ arrays->arrays[0].normalized = GL_TRUE;
+ arrays->arrays[0].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[1].data_type = GL_FLOAT;
+ arrays->arrays[1].count = 4;
+ arrays->arrays[1].key = GL_COLOR_ARRAY;
+ arrays->arrays[1].normalized = GL_TRUE;
+ arrays->arrays[1].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[2].data_type = GL_FLOAT;
+ arrays->arrays[2].count = 1;
+ arrays->arrays[2].key = GL_INDEX_ARRAY;
+ arrays->arrays[2].old_DrawArrays_possible = GL_TRUE;
+
+ arrays->arrays[3].data_type = GL_UNSIGNED_BYTE;
+ arrays->arrays[3].count = 1;
+ arrays->arrays[3].key = GL_EDGE_FLAG_ARRAY;
+ arrays->arrays[3].old_DrawArrays_possible = GL_TRUE;
+
+ for (i = 0; i < texture_units; i++) {
+ arrays->arrays[4 + i].data_type = GL_FLOAT;
+ arrays->arrays[4 + i].count = 4;
+ arrays->arrays[4 + i].key = GL_TEXTURE_COORD_ARRAY;
+
+ arrays->arrays[4 + i].old_DrawArrays_possible = (i == 0);
+ arrays->arrays[4 + i].index = i;
+
+ arrays->arrays[4 + i].header[1] = i + GL_TEXTURE0;
+ }
+
+ i = 4 + texture_units;
+
+ if (got_fog) {
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 1;
+ arrays->arrays[i].key = GL_FOG_COORDINATE_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+ i++;
+ }
+
+ if (got_secondary_color) {
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 3;
+ arrays->arrays[i].key = GL_SECONDARY_COLOR_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+ arrays->arrays[i].normalized = GL_TRUE;
+ i++;
+ }
+
+
+ for (j = 0; j < vertex_program_attribs; j++) {
+ const unsigned idx = (vertex_program_attribs - (j + 1));
+
+
+ arrays->arrays[idx + i].data_type = GL_FLOAT;
+ arrays->arrays[idx + i].count = 4;
+ arrays->arrays[idx + i].key = GL_VERTEX_ATTRIB_ARRAY_POINTER;
+
+ arrays->arrays[idx + i].old_DrawArrays_possible = 0;
+ arrays->arrays[idx + i].index = idx;
+
+ arrays->arrays[idx + i].header[1] = idx;
+ }
+
+ i += vertex_program_attribs;
+
+
+ /* Vertex array *must* be last becuase of the way that
+ * emit_DrawArrays_none works.
+ */
+
+ arrays->arrays[i].data_type = GL_FLOAT;
+ arrays->arrays[i].count = 4;
+ arrays->arrays[i].key = GL_VERTEX_ARRAY;
+ arrays->arrays[i].old_DrawArrays_possible = GL_TRUE;
+
+ assert((i + 1) == arrays->num_arrays);
+
+ arrays->stack_index = 0;
+ arrays->stack = malloc(sizeof(struct array_stack_state)
+ * arrays->num_arrays);
}
@@ -299,19 +302,19 @@ __glXInitVertexArrayState( __GLXcontext * gc )
* implement the enabled vertex arrays.
*/
static size_t
-calculate_single_vertex_size_none( const struct array_state_vector * arrays )
+calculate_single_vertex_size_none(const struct array_state_vector *arrays)
{
- size_t single_vertex_size = 0;
- unsigned i;
+ size_t single_vertex_size = 0;
+ unsigned i;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- single_vertex_size += ((uint16_t *)arrays->arrays[i].header)[0];
- }
- }
-
- return single_vertex_size;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ single_vertex_size += ((uint16_t *) arrays->arrays[i].header)[0];
+ }
+ }
+
+ return single_vertex_size;
}
@@ -319,39 +322,37 @@ calculate_single_vertex_size_none( const struct array_state_vector * arrays )
* Emit a single element using non-DrawArrays protocol.
*/
GLubyte *
-emit_element_none( GLubyte * dst,
- const struct array_state_vector * arrays,
- unsigned index )
+emit_element_none(GLubyte * dst,
+ const struct array_state_vector * arrays, unsigned index)
{
- unsigned i;
+ unsigned i;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- const size_t offset = index * arrays->arrays[i].true_stride;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ const size_t offset = index * arrays->arrays[i].true_stride;
- /* The generic attributes can have more data than is in the
- * elements. This is because a vertex array can be a 2 element,
- * normalized, unsigned short, but the "closest" immediate mode
- * protocol is for a 4Nus. Since the sizes are small, the
- * performance impact on modern processors should be negligible.
- */
- (void) memset( dst, 0,
- ((uint16_t *)arrays->arrays[i].header)[0] );
+ /* The generic attributes can have more data than is in the
+ * elements. This is because a vertex array can be a 2 element,
+ * normalized, unsigned short, but the "closest" immediate mode
+ * protocol is for a 4Nus. Since the sizes are small, the
+ * performance impact on modern processors should be negligible.
+ */
+ (void) memset(dst, 0, ((uint16_t *) arrays->arrays[i].header)[0]);
- (void) memcpy( dst, arrays->arrays[i].header,
- arrays->arrays[i].header_size );
+ (void) memcpy(dst, arrays->arrays[i].header,
+ arrays->arrays[i].header_size);
- dst += arrays->arrays[i].header_size;
+ dst += arrays->arrays[i].header_size;
- (void) memcpy( dst, ((GLubyte *) arrays->arrays[i].data) + offset,
- arrays->arrays[i].element_size );
+ (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset,
+ arrays->arrays[i].element_size);
- dst += __GLX_PAD( arrays->arrays[i].element_size );
- }
- }
+ dst += __GLX_PAD(arrays->arrays[i].element_size);
+ }
+ }
- return dst;
+ return dst;
}
@@ -360,120 +361,119 @@ emit_element_none( GLubyte * dst,
* EXT_vertex_arrays / OpenGL 1.1.
*/
GLubyte *
-emit_element_old( GLubyte * dst,
- const struct array_state_vector * arrays,
- unsigned index )
+emit_element_old(GLubyte * dst,
+ const struct array_state_vector * arrays, unsigned index)
{
- unsigned i;
+ unsigned i;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- const size_t offset = index * arrays->arrays[i].true_stride;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ const size_t offset = index * arrays->arrays[i].true_stride;
- (void) memcpy( dst, ((GLubyte *) arrays->arrays[i].data) + offset,
- arrays->arrays[i].element_size );
+ (void) memcpy(dst, ((GLubyte *) arrays->arrays[i].data) + offset,
+ arrays->arrays[i].element_size);
- dst += __GLX_PAD( arrays->arrays[i].element_size );
- }
- }
+ dst += __GLX_PAD(arrays->arrays[i].element_size);
+ }
+ }
- return dst;
+ return dst;
}
struct array_state *
-get_array_entry( const struct array_state_vector * arrays,
- GLenum key, unsigned index )
+get_array_entry(const struct array_state_vector *arrays,
+ GLenum key, unsigned index)
{
- unsigned i;
-
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( (arrays->arrays[i].key == key)
- && (arrays->arrays[i].index == index) ) {
- return & arrays->arrays[i];
- }
- }
-
- return NULL;
+ unsigned i;
+
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if ((arrays->arrays[i].key == key)
+ && (arrays->arrays[i].index == index)) {
+ return &arrays->arrays[i];
+ }
+ }
+
+ return NULL;
}
static GLboolean
-allocate_array_info_cache( struct array_state_vector * arrays,
- size_t required_size )
+allocate_array_info_cache(struct array_state_vector *arrays,
+ size_t required_size)
{
#define MAX_HEADER_SIZE 20
- if ( arrays->array_info_cache_buffer_size < required_size ) {
- GLubyte * temp = realloc( arrays->array_info_cache_base,
- required_size + MAX_HEADER_SIZE );
+ if (arrays->array_info_cache_buffer_size < required_size) {
+ GLubyte *temp = realloc(arrays->array_info_cache_base,
+ required_size + MAX_HEADER_SIZE);
- if ( temp == NULL ) {
- return GL_FALSE;
- }
+ if (temp == NULL) {
+ return GL_FALSE;
+ }
- arrays->array_info_cache_base = temp;
- arrays->array_info_cache = temp + MAX_HEADER_SIZE;
- arrays->array_info_cache_buffer_size = required_size;
- }
+ arrays->array_info_cache_base = temp;
+ arrays->array_info_cache = temp + MAX_HEADER_SIZE;
+ arrays->array_info_cache_buffer_size = required_size;
+ }
- arrays->array_info_cache_size = required_size;
- return GL_TRUE;
+ arrays->array_info_cache_size = required_size;
+ return GL_TRUE;
}
/**
*/
void
-fill_array_info_cache( struct array_state_vector * arrays )
+fill_array_info_cache(struct array_state_vector *arrays)
{
- GLboolean old_DrawArrays_possible;
- unsigned i;
-
-
- /* Determine how many arrays are enabled.
- */
-
- arrays->enabled_client_array_count = 0;
- old_DrawArrays_possible = arrays->old_DrawArrays_possible;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- arrays->enabled_client_array_count++;
- old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible;
- }
- }
-
- if ( arrays->new_DrawArrays_possible ) {
- assert( ! arrays->new_DrawArrays_possible );
- }
- else if ( old_DrawArrays_possible ) {
- const size_t required_size = arrays->enabled_client_array_count * 12;
- uint32_t * info;
-
-
- if ( ! allocate_array_info_cache( arrays, required_size ) ) {
- return;
- }
-
-
- info = (uint32_t *) arrays->array_info_cache;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- *(info++) = arrays->arrays[i].data_type;
- *(info++) = arrays->arrays[i].count;
- *(info++) = arrays->arrays[i].key;
- }
- }
-
- arrays->DrawArrays = emit_DrawArrays_old;
- arrays->DrawElements = emit_DrawElements_old;
- }
- else {
- arrays->DrawArrays = emit_DrawArrays_none;
- arrays->DrawElements = emit_DrawElements_none;
- }
-
- arrays->array_info_cache_valid = GL_TRUE;
+ GLboolean old_DrawArrays_possible;
+ unsigned i;
+
+
+ /* Determine how many arrays are enabled.
+ */
+
+ arrays->enabled_client_array_count = 0;
+ old_DrawArrays_possible = arrays->old_DrawArrays_possible;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ arrays->enabled_client_array_count++;
+ old_DrawArrays_possible &= arrays->arrays[i].old_DrawArrays_possible;
+ }
+ }
+
+ if (arrays->new_DrawArrays_possible) {
+ assert(!arrays->new_DrawArrays_possible);
+ }
+ else if (old_DrawArrays_possible) {
+ const size_t required_size = arrays->enabled_client_array_count * 12;
+ uint32_t *info;
+
+
+ if (!allocate_array_info_cache(arrays, required_size)) {
+ return;
+ }
+
+
+ info = (uint32_t *) arrays->array_info_cache;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ *(info++) = arrays->arrays[i].data_type;
+ *(info++) = arrays->arrays[i].count;
+ *(info++) = arrays->arrays[i].key;
+ }
+ }
+
+ arrays->DrawArrays = emit_DrawArrays_old;
+ arrays->DrawElements = emit_DrawElements_old;
+ }
+ else {
+ arrays->DrawArrays = emit_DrawArrays_none;
+ arrays->DrawElements = emit_DrawElements_none;
+ }
+
+ arrays->array_info_cache_valid = GL_TRUE;
}
@@ -485,48 +485,48 @@ fill_array_info_cache( struct array_state_vector * arrays )
* vertex state is enabled that is not compatible with that protocol.
*/
void
-emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count )
+emit_DrawArrays_none(GLenum mode, GLint first, GLsizei count)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
- size_t single_vertex_size;
- GLubyte * pc;
- unsigned i;
- static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
- static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
+ size_t single_vertex_size;
+ GLubyte *pc;
+ unsigned i;
+ static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
+ static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
- single_vertex_size = calculate_single_vertex_size_none( arrays );
+ single_vertex_size = calculate_single_vertex_size_none(arrays);
- pc = gc->pc;
+ pc = gc->pc;
- (void) memcpy( pc, begin_cmd, 4 );
- *(int *)(pc + 4) = mode;
+ (void) memcpy(pc, begin_cmd, 4);
+ *(int *) (pc + 4) = mode;
- pc += 8;
+ pc += 8;
- for ( i = 0 ; i < count ; i++ ) {
- if ( (pc + single_vertex_size) >= gc->bufEnd ) {
- pc = __glXFlushRenderBuffer(gc, pc);
- }
+ for (i = 0; i < count; i++) {
+ if ((pc + single_vertex_size) >= gc->bufEnd) {
+ pc = __glXFlushRenderBuffer(gc, pc);
+ }
- pc = emit_element_none( pc, arrays, first + i );
- }
+ pc = emit_element_none(pc, arrays, first + i);
+ }
- if ( (pc + 4) >= gc->bufEnd ) {
- pc = __glXFlushRenderBuffer(gc, pc);
- }
+ if ((pc + 4) >= gc->bufEnd) {
+ pc = __glXFlushRenderBuffer(gc, pc);
+ }
- (void) memcpy( pc, end_cmd, 4 );
- pc += 4;
+ (void) memcpy(pc, end_cmd, 4);
+ pc += 4;
- gc->pc = pc;
- if ( gc->pc > gc->limit ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
+ gc->pc = pc;
+ if (gc->pc > gc->limit) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
}
@@ -549,323 +549,321 @@ emit_DrawArrays_none( GLenum mode, GLint first, GLsizei count )
* A pointer to the buffer for array data.
*/
static GLubyte *
-emit_DrawArrays_header_old( __GLXcontext * gc,
- struct array_state_vector * arrays,
- size_t * elements_per_request,
- unsigned int * total_requests,
- GLenum mode, GLsizei count )
+emit_DrawArrays_header_old(__GLXcontext * gc,
+ struct array_state_vector *arrays,
+ size_t * elements_per_request,
+ unsigned int *total_requests,
+ GLenum mode, GLsizei count)
{
- size_t command_size;
- size_t single_vertex_size;
- const unsigned header_size = 16;
- unsigned i;
- GLubyte * pc;
-
-
- /* Determine the size of the whole command. This includes the header,
- * the ARRAY_INFO data and the array data. Once this size is calculated,
- * it will be known whether a Render or RenderLarge command is needed.
- */
-
- single_vertex_size = 0;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- if ( arrays->arrays[i].enabled ) {
- single_vertex_size += __GLX_PAD( arrays->arrays[i].element_size );
- }
- }
-
- command_size = arrays->array_info_cache_size + header_size
+ size_t command_size;
+ size_t single_vertex_size;
+ const unsigned header_size = 16;
+ unsigned i;
+ GLubyte *pc;
+
+
+ /* Determine the size of the whole command. This includes the header,
+ * the ARRAY_INFO data and the array data. Once this size is calculated,
+ * it will be known whether a Render or RenderLarge command is needed.
+ */
+
+ single_vertex_size = 0;
+ for (i = 0; i < arrays->num_arrays; i++) {
+ if (arrays->arrays[i].enabled) {
+ single_vertex_size += __GLX_PAD(arrays->arrays[i].element_size);
+ }
+ }
+
+ command_size = arrays->array_info_cache_size + header_size
+ (single_vertex_size * count);
- /* Write the header for either a Render command or a RenderLarge
- * command. After the header is written, write the ARRAY_INFO data.
- */
+ /* Write the header for either a Render command or a RenderLarge
+ * command. After the header is written, write the ARRAY_INFO data.
+ */
+
+ if (command_size > gc->maxSmallRenderCommandSize) {
+ /* maxSize is the maximum amount of data can be stuffed into a single
+ * packet. sz_xGLXRenderReq is added because bufSize is the maximum
+ * packet size minus sz_xGLXRenderReq.
+ */
+ const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq)
+ - sz_xGLXRenderLargeReq;
+ unsigned vertex_requests;
- if ( command_size > gc->maxSmallRenderCommandSize ) {
- /* maxSize is the maximum amount of data can be stuffed into a single
- * packet. sz_xGLXRenderReq is added because bufSize is the maximum
- * packet size minus sz_xGLXRenderReq.
- */
- const size_t maxSize = (gc->bufSize + sz_xGLXRenderReq)
- - sz_xGLXRenderLargeReq;
- unsigned vertex_requests;
+ /* Calculate the number of data packets that will be required to send
+ * the whole command. To do this, the number of verticies that
+ * will fit in a single buffer must be calculated.
+ *
+ * The important value here is elements_per_request. This is the
+ * number of complete array elements that will fit in a single
+ * buffer. There may be some wasted space at the end of the buffer,
+ * but splitting elements across buffer boundries would be painful.
+ */
- /* Calculate the number of data packets that will be required to send
- * the whole command. To do this, the number of verticies that
- * will fit in a single buffer must be calculated.
- *
- * The important value here is elements_per_request. This is the
- * number of complete array elements that will fit in a single
- * buffer. There may be some wasted space at the end of the buffer,
- * but splitting elements across buffer boundries would be painful.
- */
+ elements_per_request[0] = maxSize / single_vertex_size;
- elements_per_request[0] = maxSize / single_vertex_size;
+ vertex_requests = (count + elements_per_request[0] - 1)
+ / elements_per_request[0];
- vertex_requests = (count + elements_per_request[0] - 1)
- / elements_per_request[0];
-
- *total_requests = vertex_requests + 1;
+ *total_requests = vertex_requests + 1;
- __glXFlushRenderBuffer(gc, gc->pc);
+ __glXFlushRenderBuffer(gc, gc->pc);
- command_size += 4;
+ command_size += 4;
- pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
- *(uint32_t *)(pc + 0) = command_size;
- *(uint32_t *)(pc + 4) = X_GLrop_DrawArrays;
- *(uint32_t *)(pc + 8) = count;
- *(uint32_t *)(pc + 12) = arrays->enabled_client_array_count;
- *(uint32_t *)(pc + 16) = mode;
+ pc = ((GLubyte *) arrays->array_info_cache) - (header_size + 4);
+ *(uint32_t *) (pc + 0) = command_size;
+ *(uint32_t *) (pc + 4) = X_GLrop_DrawArrays;
+ *(uint32_t *) (pc + 8) = count;
+ *(uint32_t *) (pc + 12) = arrays->enabled_client_array_count;
+ *(uint32_t *) (pc + 16) = mode;
- __glXSendLargeChunk( gc, 1, *total_requests, pc,
- header_size + 4 + arrays->array_info_cache_size );
+ __glXSendLargeChunk(gc, 1, *total_requests, pc,
+ header_size + 4 + arrays->array_info_cache_size);
- pc = gc->pc;
- }
- else {
- if ( (gc->pc + command_size) >= gc->bufEnd ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
+ pc = gc->pc;
+ }
+ else {
+ if ((gc->pc + command_size) >= gc->bufEnd) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
- pc = gc->pc;
- *(uint16_t *)(pc + 0) = command_size;
- *(uint16_t *)(pc + 2) = X_GLrop_DrawArrays;
- *(uint32_t *)(pc + 4) = count;
- *(uint32_t *)(pc + 8) = arrays->enabled_client_array_count;
- *(uint32_t *)(pc + 12) = mode;
+ pc = gc->pc;
+ *(uint16_t *) (pc + 0) = command_size;
+ *(uint16_t *) (pc + 2) = X_GLrop_DrawArrays;
+ *(uint32_t *) (pc + 4) = count;
+ *(uint32_t *) (pc + 8) = arrays->enabled_client_array_count;
+ *(uint32_t *) (pc + 12) = mode;
- pc += header_size;
+ pc += header_size;
- (void) memcpy( pc, arrays->array_info_cache,
- arrays->array_info_cache_size );
- pc += arrays->array_info_cache_size;
+ (void) memcpy(pc, arrays->array_info_cache,
+ arrays->array_info_cache_size);
+ pc += arrays->array_info_cache_size;
- *elements_per_request = count;
- *total_requests = 0;
- }
+ *elements_per_request = count;
+ *total_requests = 0;
+ }
- return pc;
+ return pc;
}
/**
*/
void
-emit_DrawArrays_old( GLenum mode, GLint first, GLsizei count )
+emit_DrawArrays_old(GLenum mode, GLint first, GLsizei count)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+
+ GLubyte *pc;
+ size_t elements_per_request;
+ unsigned total_requests = 0;
+ unsigned i;
+ size_t total_sent = 0;
- GLubyte * pc;
- size_t elements_per_request;
- unsigned total_requests = 0;
- unsigned i;
- size_t total_sent = 0;
+ pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request,
+ &total_requests, mode, count);
- pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
- & total_requests, mode, count);
-
- /* Write the arrays.
- */
+ /* Write the arrays.
+ */
- if ( total_requests == 0 ) {
- assert( elements_per_request >= count );
+ if (total_requests == 0) {
+ assert(elements_per_request >= count);
- for ( i = 0 ; i < count ; i++ ) {
- pc = emit_element_old( pc, arrays, i + first );
- }
+ for (i = 0; i < count; i++) {
+ pc = emit_element_old(pc, arrays, i + first);
+ }
- assert( pc <= gc->bufEnd );
+ assert(pc <= gc->bufEnd);
- gc->pc = pc;
- if ( gc->pc > gc->limit ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
- }
- else {
- unsigned req;
+ gc->pc = pc;
+ if (gc->pc > gc->limit) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ }
+ else {
+ unsigned req;
- for ( req = 2 ; req <= total_requests ; req++ ) {
- if ( count < elements_per_request ) {
- elements_per_request = count;
- }
+ for (req = 2; req <= total_requests; req++) {
+ if (count < elements_per_request) {
+ elements_per_request = count;
+ }
- pc = gc->pc;
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- pc = emit_element_old( pc, arrays, i + first );
- }
+ pc = gc->pc;
+ for (i = 0; i < elements_per_request; i++) {
+ pc = emit_element_old(pc, arrays, i + first);
+ }
- first += elements_per_request;
+ first += elements_per_request;
- total_sent += (size_t) (pc - gc->pc);
- __glXSendLargeChunk( gc, req, total_requests, gc->pc,
- pc - gc->pc );
+ total_sent += (size_t) (pc - gc->pc);
+ __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc);
- count -= elements_per_request;
- }
- }
+ count -= elements_per_request;
+ }
+ }
}
void
-emit_DrawElements_none( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices )
+emit_DrawElements_none(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
- static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ static const uint16_t begin_cmd[2] = { 8, X_GLrop_Begin };
+ static const uint16_t end_cmd[2] = { 4, X_GLrop_End };
- GLubyte * pc;
- size_t single_vertex_size;
- unsigned i;
+ GLubyte *pc;
+ size_t single_vertex_size;
+ unsigned i;
- single_vertex_size = calculate_single_vertex_size_none( arrays );
+ single_vertex_size = calculate_single_vertex_size_none(arrays);
- if ( (gc->pc + single_vertex_size) >= gc->bufEnd ) {
- gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
- }
+ if ((gc->pc + single_vertex_size) >= gc->bufEnd) {
+ gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
- pc = gc->pc;
+ pc = gc->pc;
- (void) memcpy( pc, begin_cmd, 4 );
- *(int *)(pc + 4) = mode;
+ (void) memcpy(pc, begin_cmd, 4);
+ *(int *) (pc + 4) = mode;
- pc += 8;
+ pc += 8;
- for ( i = 0 ; i < count ; i++ ) {
- unsigned index = 0;
+ for (i = 0; i < count; i++) {
+ unsigned index = 0;
- if ( (pc + single_vertex_size) >= gc->bufEnd ) {
- pc = __glXFlushRenderBuffer(gc, pc);
- }
+ if ((pc + single_vertex_size) >= gc->bufEnd) {
+ pc = __glXFlushRenderBuffer(gc, pc);
+ }
- switch( type ) {
- case GL_UNSIGNED_INT:
- index = (unsigned) (((GLuint *) indices)[i]);
- break;
- case GL_UNSIGNED_SHORT:
- index = (unsigned) (((GLushort *) indices)[i]);
- break;
- case GL_UNSIGNED_BYTE:
- index = (unsigned) (((GLubyte *) indices)[i]);
- break;
- }
- pc = emit_element_none( pc, arrays, index );
- }
+ switch (type) {
+ case GL_UNSIGNED_INT:
+ index = (unsigned) (((GLuint *) indices)[i]);
+ break;
+ case GL_UNSIGNED_SHORT:
+ index = (unsigned) (((GLushort *) indices)[i]);
+ break;
+ case GL_UNSIGNED_BYTE:
+ index = (unsigned) (((GLubyte *) indices)[i]);
+ break;
+ }
+ pc = emit_element_none(pc, arrays, index);
+ }
- if ( (pc + 4) >= gc->bufEnd ) {
- pc = __glXFlushRenderBuffer(gc, pc);
- }
+ if ((pc + 4) >= gc->bufEnd) {
+ pc = __glXFlushRenderBuffer(gc, pc);
+ }
- (void) memcpy( pc, end_cmd, 4 );
- pc += 4;
+ (void) memcpy(pc, end_cmd, 4);
+ pc += 4;
- gc->pc = pc;
- if ( gc->pc > gc->limit ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
+ gc->pc = pc;
+ if (gc->pc > gc->limit) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
}
/**
*/
void
-emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices )
+emit_DrawElements_old(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
-
- GLubyte * pc;
- size_t elements_per_request;
- unsigned total_requests = 0;
- unsigned i;
- unsigned req;
- unsigned req_element=0;
-
-
- pc = emit_DrawArrays_header_old( gc, arrays, & elements_per_request,
- & total_requests, mode, count);
-
-
- /* Write the arrays.
- */
-
- req = 2;
- while ( count > 0 ) {
- if ( count < elements_per_request ) {
- elements_per_request = count;
- }
-
- switch( type ) {
- case GL_UNSIGNED_INT: {
- const GLuint * ui_ptr = (const GLuint *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(ui_ptr++);
- pc = emit_element_old( pc, arrays, index );
- }
- break;
- }
- case GL_UNSIGNED_SHORT: {
- const GLushort * us_ptr = (const GLushort *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(us_ptr++);
- pc = emit_element_old( pc, arrays, index );
- }
- break;
- }
- case GL_UNSIGNED_BYTE: {
- const GLubyte * ub_ptr = (const GLubyte *) indices + req_element;
-
- for ( i = 0 ; i < elements_per_request ; i++ ) {
- const GLint index = (GLint) *(ub_ptr++);
- pc = emit_element_old( pc, arrays, index );
- }
- break;
- }
- }
-
- if ( total_requests != 0 ) {
- __glXSendLargeChunk( gc, req, total_requests, gc->pc,
- pc - gc->pc );
- pc = gc->pc;
- req++;
- }
-
- count -= elements_per_request;
- req_element += elements_per_request;
- }
-
-
- assert( (total_requests == 0) || ((req - 1) == total_requests) );
-
- if ( total_requests == 0 ) {
- assert( pc <= gc->bufEnd );
-
- gc->pc = pc;
- if ( gc->pc > gc->limit ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+
+ GLubyte *pc;
+ size_t elements_per_request;
+ unsigned total_requests = 0;
+ unsigned i;
+ unsigned req;
+ unsigned req_element = 0;
+
+
+ pc = emit_DrawArrays_header_old(gc, arrays, &elements_per_request,
+ &total_requests, mode, count);
+
+
+ /* Write the arrays.
+ */
+
+ req = 2;
+ while (count > 0) {
+ if (count < elements_per_request) {
+ elements_per_request = count;
+ }
+
+ switch (type) {
+ case GL_UNSIGNED_INT:{
+ const GLuint *ui_ptr = (const GLuint *) indices + req_element;
+
+ for (i = 0; i < elements_per_request; i++) {
+ const GLint index = (GLint) * (ui_ptr++);
+ pc = emit_element_old(pc, arrays, index);
+ }
+ break;
+ }
+ case GL_UNSIGNED_SHORT:{
+ const GLushort *us_ptr = (const GLushort *) indices + req_element;
+
+ for (i = 0; i < elements_per_request; i++) {
+ const GLint index = (GLint) * (us_ptr++);
+ pc = emit_element_old(pc, arrays, index);
+ }
+ break;
+ }
+ case GL_UNSIGNED_BYTE:{
+ const GLubyte *ub_ptr = (const GLubyte *) indices + req_element;
+
+ for (i = 0; i < elements_per_request; i++) {
+ const GLint index = (GLint) * (ub_ptr++);
+ pc = emit_element_old(pc, arrays, index);
+ }
+ break;
+ }
+ }
+
+ if (total_requests != 0) {
+ __glXSendLargeChunk(gc, req, total_requests, gc->pc, pc - gc->pc);
+ pc = gc->pc;
+ req++;
+ }
+
+ count -= elements_per_request;
+ req_element += elements_per_request;
+ }
+
+
+ assert((total_requests == 0) || ((req - 1) == total_requests));
+
+ if (total_requests == 0) {
+ assert(pc <= gc->bufEnd);
+
+ gc->pc = pc;
+ if (gc->pc > gc->limit) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
+ }
}
@@ -877,26 +875,26 @@ emit_DrawElements_old( GLenum mode, GLsizei count, GLenum type,
* \c GL_TRUE if the argument is valid, \c GL_FALSE if is not.
*/
static GLboolean
-validate_mode(__GLXcontext *gc, GLenum mode)
+validate_mode(__GLXcontext * gc, GLenum mode)
{
- switch(mode) {
- case GL_POINTS:
- case GL_LINE_STRIP:
- case GL_LINE_LOOP:
- case GL_LINES:
- case GL_TRIANGLE_STRIP:
- case GL_TRIANGLE_FAN:
- case GL_TRIANGLES:
- case GL_QUAD_STRIP:
- case GL_QUADS:
- case GL_POLYGON:
- break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return GL_FALSE;
- }
-
- return GL_TRUE;
+ switch (mode) {
+ case GL_POINTS:
+ case GL_LINE_STRIP:
+ case GL_LINE_LOOP:
+ case GL_LINES:
+ case GL_TRIANGLE_STRIP:
+ case GL_TRIANGLE_FAN:
+ case GL_TRIANGLES:
+ case GL_QUAD_STRIP:
+ case GL_QUADS:
+ case GL_POLYGON:
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
}
@@ -910,13 +908,13 @@ validate_mode(__GLXcontext *gc, GLenum mode)
* \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
*/
static GLboolean
-validate_count(__GLXcontext *gc, GLsizei count)
+validate_count(__GLXcontext * gc, GLsizei count)
{
- if (count < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- }
+ if (count < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ }
- return (count > 0);
+ return (count > 0);
}
@@ -928,154 +926,161 @@ validate_count(__GLXcontext *gc, GLsizei count)
* \returns
* \c GL_TRUE if the argument is valid, \c GL_FALSE if it is not.
*/
-static GLboolean validate_type(__GLXcontext *gc, GLenum type)
+static GLboolean
+validate_type(__GLXcontext * gc, GLenum type)
{
- switch( type ) {
- case GL_UNSIGNED_INT:
- case GL_UNSIGNED_SHORT:
- case GL_UNSIGNED_BYTE:
- return GL_TRUE;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return GL_FALSE;
- }
+ switch (type) {
+ case GL_UNSIGNED_INT:
+ case GL_UNSIGNED_SHORT:
+ case GL_UNSIGNED_BYTE:
+ return GL_TRUE;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return GL_FALSE;
+ }
}
-void __indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
+void
+__indirect_glDrawArrays(GLenum mode, GLint first, GLsizei count)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
-
-
- if ( validate_mode(gc, mode) && validate_count(gc, count) ) {
- if ( ! arrays->array_info_cache_valid ) {
- fill_array_info_cache( arrays );
- }
-
- arrays->DrawArrays(mode, first, count);
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+
+
+ if (validate_mode(gc, mode) && validate_count(gc, count)) {
+ if (!arrays->array_info_cache_valid) {
+ fill_array_info_cache(arrays);
+ }
+
+ arrays->DrawArrays(mode, first, count);
+ }
}
-void __indirect_glArrayElement(GLint index)
+void
+__indirect_glArrayElement(GLint index)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
- size_t single_vertex_size;
+ size_t single_vertex_size;
- single_vertex_size = calculate_single_vertex_size_none( arrays );
+ single_vertex_size = calculate_single_vertex_size_none(arrays);
- if ( (gc->pc + single_vertex_size) >= gc->bufEnd ) {
- gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
- }
+ if ((gc->pc + single_vertex_size) >= gc->bufEnd) {
+ gc->pc = __glXFlushRenderBuffer(gc, gc->pc);
+ }
- gc->pc = emit_element_none( gc->pc, arrays, index );
+ gc->pc = emit_element_none(gc->pc, arrays, index);
- if ( gc->pc > gc->limit ) {
- (void) __glXFlushRenderBuffer(gc, gc->pc);
- }
+ if (gc->pc > gc->limit) {
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ }
}
-void __indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices)
+void
+__indirect_glDrawElements(GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
- if ( validate_mode(gc, mode) && validate_count(gc, count)
- && validate_type(gc, type) ) {
- if ( ! arrays->array_info_cache_valid ) {
- fill_array_info_cache( arrays );
- }
+ if (validate_mode(gc, mode) && validate_count(gc, count)
+ && validate_type(gc, type)) {
+ if (!arrays->array_info_cache_valid) {
+ fill_array_info_cache(arrays);
+ }
- arrays->DrawElements(mode, count, type, indices);
- }
+ arrays->DrawElements(mode, count, type, indices);
+ }
}
-void __indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
- GLsizei count, GLenum type,
- const GLvoid *indices)
+void
+__indirect_glDrawRangeElements(GLenum mode, GLuint start, GLuint end,
+ GLsizei count, GLenum type,
+ const GLvoid * indices)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
- if ( validate_mode(gc, mode) && validate_count(gc, count)
- && validate_type(gc, type) ) {
- if (end < start) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
+ if (validate_mode(gc, mode) && validate_count(gc, count)
+ && validate_type(gc, type)) {
+ if (end < start) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
- if ( ! arrays->array_info_cache_valid ) {
- fill_array_info_cache( arrays );
- }
+ if (!arrays->array_info_cache_valid) {
+ fill_array_info_cache(arrays);
+ }
- arrays->DrawElements(mode, count, type, indices);
- }
+ arrays->DrawElements(mode, count, type, indices);
+ }
}
-void __indirect_glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count,
- GLsizei primcount)
+void
+__indirect_glMultiDrawArraysEXT(GLenum mode, GLint * first, GLsizei * count,
+ GLsizei primcount)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- GLsizei i;
-
-
- if ( validate_mode(gc, mode) ) {
- if ( ! arrays->array_info_cache_valid ) {
- fill_array_info_cache( arrays );
- }
-
- for ( i = 0 ; i < primcount ; i++ ) {
- if ( validate_count( gc, count[i] ) ) {
- arrays->DrawArrays(mode, first[i], count[i]);
- }
- }
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ GLsizei i;
+
+
+ if (validate_mode(gc, mode)) {
+ if (!arrays->array_info_cache_valid) {
+ fill_array_info_cache(arrays);
+ }
+
+ for (i = 0; i < primcount; i++) {
+ if (validate_count(gc, count[i])) {
+ arrays->DrawArrays(mode, first[i], count[i]);
+ }
+ }
+ }
}
-void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
- GLenum type, const GLvoid ** indices,
- GLsizei primcount)
+void
+__indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei * count,
+ GLenum type, const GLvoid ** indices,
+ GLsizei primcount)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- const __GLXattribute * state =
- (const __GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- GLsizei i;
-
-
- if ( validate_mode(gc, mode) && validate_type(gc, type) ) {
- if ( ! arrays->array_info_cache_valid ) {
- fill_array_info_cache( arrays );
- }
-
- for ( i = 0 ; i < primcount ; i++ ) {
- if ( validate_count( gc, count[i] ) ) {
- arrays->DrawElements(mode, count[i], type, indices[i]);
- }
- }
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ const __GLXattribute *state =
+ (const __GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ GLsizei i;
+
+
+ if (validate_mode(gc, mode) && validate_type(gc, type)) {
+ if (!arrays->array_info_cache_valid) {
+ fill_array_info_cache(arrays);
+ }
+
+ for (i = 0; i < primcount; i++) {
+ if (validate_count(gc, count[i])) {
+ arrays->DrawElements(mode, count[i], type, indices[i]);
+ }
+ }
+ }
}
@@ -1097,475 +1102,577 @@ void __indirect_glMultiDrawElementsEXT(GLenum mode, const GLsizei *count,
} while(0)
-void __indirect_glVertexPointer( GLint size, GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glVertexPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- static const uint16_t short_ops[5] = {
- 0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv
- };
- static const uint16_t int_ops[5] = {
- 0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv
- };
- static const uint16_t float_ops[5] = {
- 0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv
- };
- static const uint16_t double_ops[5] = {
- 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv
- };
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (size < 2 || size > 4 || stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_SHORT: opcode = short_ops[size]; break;
- case GL_INT: opcode = int_ops[size]; break;
- case GL_FLOAT: opcode = float_ops[size]; break;
- case GL_DOUBLE: opcode = double_ops[size]; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_VERTEX_ARRAY, 0 );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ static const uint16_t short_ops[5] = {
+ 0, 0, X_GLrop_Vertex2sv, X_GLrop_Vertex3sv, X_GLrop_Vertex4sv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, 0, X_GLrop_Vertex2iv, X_GLrop_Vertex3iv, X_GLrop_Vertex4iv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, 0, X_GLrop_Vertex2fv, X_GLrop_Vertex3fv, X_GLrop_Vertex4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, 0, X_GLrop_Vertex2dv, X_GLrop_Vertex3dv, X_GLrop_Vertex4dv
+ };
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (size < 2 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_SHORT:
+ opcode = short_ops[size];
+ break;
+ case GL_INT:
+ opcode = int_ops[size];
+ break;
+ case GL_FLOAT:
+ opcode = float_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = double_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_VERTEX_ARRAY, 0);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE, 4,
+ opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glNormalPointer( GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glNormalPointer(GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_BYTE: opcode = X_GLrop_Normal3bv; break;
- case GL_SHORT: opcode = X_GLrop_Normal3sv; break;
- case GL_INT: opcode = X_GLrop_Normal3iv; break;
- case GL_FLOAT: opcode = X_GLrop_Normal3fv; break;
- case GL_DOUBLE: opcode = X_GLrop_Normal3dv; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_NORMAL_ARRAY, 0 );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 3, GL_TRUE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_BYTE:
+ opcode = X_GLrop_Normal3bv;
+ break;
+ case GL_SHORT:
+ opcode = X_GLrop_Normal3sv;
+ break;
+ case GL_INT:
+ opcode = X_GLrop_Normal3iv;
+ break;
+ case GL_FLOAT:
+ opcode = X_GLrop_Normal3fv;
+ break;
+ case GL_DOUBLE:
+ opcode = X_GLrop_Normal3dv;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_NORMAL_ARRAY, 0);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 3, GL_TRUE, 4, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glColorPointer( GLint size, GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glColorPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- static const uint16_t byte_ops[5] = {
- 0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv
- };
- static const uint16_t ubyte_ops[5] = {
- 0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv
- };
- static const uint16_t short_ops[5] = {
- 0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv
- };
- static const uint16_t ushort_ops[5] = {
- 0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv
- };
- static const uint16_t int_ops[5] = {
- 0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv
- };
- static const uint16_t uint_ops[5] = {
- 0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv
- };
- static const uint16_t float_ops[5] = {
- 0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv
- };
- static const uint16_t double_ops[5] = {
- 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv
- };
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (size < 3 || size > 4 || stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_BYTE: opcode = byte_ops[size]; break;
- case GL_UNSIGNED_BYTE: opcode = ubyte_ops[size]; break;
- case GL_SHORT: opcode = short_ops[size]; break;
- case GL_UNSIGNED_SHORT: opcode = ushort_ops[size]; break;
- case GL_INT: opcode = int_ops[size]; break;
- case GL_UNSIGNED_INT: opcode = uint_ops[size]; break;
- case GL_FLOAT: opcode = float_ops[size]; break;
- case GL_DOUBLE: opcode = double_ops[size]; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_COLOR_ARRAY, 0 );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ static const uint16_t byte_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3bv, X_GLrop_Color4bv
+ };
+ static const uint16_t ubyte_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3ubv, X_GLrop_Color4ubv
+ };
+ static const uint16_t short_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3sv, X_GLrop_Color4sv
+ };
+ static const uint16_t ushort_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3usv, X_GLrop_Color4usv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3iv, X_GLrop_Color4iv
+ };
+ static const uint16_t uint_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3uiv, X_GLrop_Color4uiv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3fv, X_GLrop_Color4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, 0, 0, X_GLrop_Color3dv, X_GLrop_Color4dv
+ };
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (size < 3 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_BYTE:
+ opcode = byte_ops[size];
+ break;
+ case GL_UNSIGNED_BYTE:
+ opcode = ubyte_ops[size];
+ break;
+ case GL_SHORT:
+ opcode = short_ops[size];
+ break;
+ case GL_UNSIGNED_SHORT:
+ opcode = ushort_ops[size];
+ break;
+ case GL_INT:
+ opcode = int_ops[size];
+ break;
+ case GL_UNSIGNED_INT:
+ opcode = uint_ops[size];
+ break;
+ case GL_FLOAT:
+ opcode = float_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = double_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_COLOR_ARRAY, 0);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glIndexPointer( GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glIndexPointer(GLenum type, GLsizei stride, const GLvoid * pointer)
{
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_UNSIGNED_BYTE: opcode = X_GLrop_Indexubv; break;
- case GL_SHORT: opcode = X_GLrop_Indexsv; break;
- case GL_INT: opcode = X_GLrop_Indexiv; break;
- case GL_FLOAT: opcode = X_GLrop_Indexfv; break;
- case GL_DOUBLE: opcode = X_GLrop_Indexdv; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_INDEX_ARRAY, 0 );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ opcode = X_GLrop_Indexubv;
+ break;
+ case GL_SHORT:
+ opcode = X_GLrop_Indexsv;
+ break;
+ case GL_INT:
+ opcode = X_GLrop_Indexiv;
+ break;
+ case GL_FLOAT:
+ opcode = X_GLrop_Indexfv;
+ break;
+ case GL_DOUBLE:
+ opcode = X_GLrop_Indexdv;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_INDEX_ARRAY, 0);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glEdgeFlagPointer( GLsizei stride, const GLvoid * pointer )
+void
+__indirect_glEdgeFlagPointer(GLsizei stride, const GLvoid * pointer)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
-
- a = get_array_entry( arrays, GL_EDGE_FLAG_ARRAY, 0 );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE,
- 4, X_GLrop_EdgeFlagv );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+
+ a = get_array_entry(arrays, GL_EDGE_FLAG_ARRAY, 0);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, GL_UNSIGNED_BYTE, stride, 1, GL_FALSE,
+ 4, X_GLrop_EdgeFlagv);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glTexCoordPointer( GLint size, GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glTexCoordPointer(GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- static const uint16_t short_ops[5] = {
- 0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv, X_GLrop_TexCoord4sv
- };
- static const uint16_t int_ops[5] = {
- 0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv, X_GLrop_TexCoord4iv
- };
- static const uint16_t float_ops[5] = {
- 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv, X_GLrop_TexCoord4fv
- };
- static const uint16_t double_ops[5] = {
- 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv, X_GLrop_TexCoord4dv
- };
-
- static const uint16_t mshort_ops[5] = {
- 0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB, X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB
- };
- static const uint16_t mint_ops[5] = {
- 0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB, X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB
- };
- static const uint16_t mfloat_ops[5] = {
- 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB, X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB
- };
- static const uint16_t mdouble_ops[5] = {
- 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB, X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB
- };
-
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
- unsigned header_size;
- unsigned index;
-
-
- if (size < 1 || size > 4 || stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- index = arrays->active_texture_unit;
- if ( index == 0 ) {
- switch ( type ) {
- case GL_SHORT: opcode = short_ops[size]; break;
- case GL_INT: opcode = int_ops[size]; break;
- case GL_FLOAT: opcode = float_ops[size]; break;
- case GL_DOUBLE: opcode = double_ops[size]; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- header_size = 4;
- }
- else {
- switch ( type ) {
- case GL_SHORT: opcode = mshort_ops[size]; break;
- case GL_INT: opcode = mint_ops[size]; break;
- case GL_FLOAT: opcode = mfloat_ops[size]; break;
- case GL_DOUBLE: opcode = mdouble_ops[size]; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- header_size = 8;
- }
-
- a = get_array_entry( arrays, GL_TEXTURE_COORD_ARRAY, index );
- assert( a != NULL );
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_FALSE,
- header_size, opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ static const uint16_t short_ops[5] = {
+ 0, X_GLrop_TexCoord1sv, X_GLrop_TexCoord2sv, X_GLrop_TexCoord3sv,
+ X_GLrop_TexCoord4sv
+ };
+ static const uint16_t int_ops[5] = {
+ 0, X_GLrop_TexCoord1iv, X_GLrop_TexCoord2iv, X_GLrop_TexCoord3iv,
+ X_GLrop_TexCoord4iv
+ };
+ static const uint16_t float_ops[5] = {
+ 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2fv, X_GLrop_TexCoord3fv,
+ X_GLrop_TexCoord4fv
+ };
+ static const uint16_t double_ops[5] = {
+ 0, X_GLrop_TexCoord1dv, X_GLrop_TexCoord2dv, X_GLrop_TexCoord3dv,
+ X_GLrop_TexCoord4dv
+ };
+
+ static const uint16_t mshort_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1svARB, X_GLrop_MultiTexCoord2svARB,
+ X_GLrop_MultiTexCoord3svARB, X_GLrop_MultiTexCoord4svARB
+ };
+ static const uint16_t mint_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1ivARB, X_GLrop_MultiTexCoord2ivARB,
+ X_GLrop_MultiTexCoord3ivARB, X_GLrop_MultiTexCoord4ivARB
+ };
+ static const uint16_t mfloat_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2fvARB,
+ X_GLrop_MultiTexCoord3fvARB, X_GLrop_MultiTexCoord4fvARB
+ };
+ static const uint16_t mdouble_ops[5] = {
+ 0, X_GLrop_MultiTexCoord1dvARB, X_GLrop_MultiTexCoord2dvARB,
+ X_GLrop_MultiTexCoord3dvARB, X_GLrop_MultiTexCoord4dvARB
+ };
+
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+ unsigned header_size;
+ unsigned index;
+
+
+ if (size < 1 || size > 4 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ index = arrays->active_texture_unit;
+ if (index == 0) {
+ switch (type) {
+ case GL_SHORT:
+ opcode = short_ops[size];
+ break;
+ case GL_INT:
+ opcode = int_ops[size];
+ break;
+ case GL_FLOAT:
+ opcode = float_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = double_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ header_size = 4;
+ }
+ else {
+ switch (type) {
+ case GL_SHORT:
+ opcode = mshort_ops[size];
+ break;
+ case GL_INT:
+ opcode = mint_ops[size];
+ break;
+ case GL_FLOAT:
+ opcode = mfloat_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = mdouble_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ header_size = 8;
+ }
+
+ a = get_array_entry(arrays, GL_TEXTURE_COORD_ARRAY, index);
+ assert(a != NULL);
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_FALSE,
+ header_size, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glSecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glSecondaryColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (size != 3 || stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_BYTE: opcode = 4126; break;
- case GL_UNSIGNED_BYTE: opcode = 4131; break;
- case GL_SHORT: opcode = 4127; break;
- case GL_UNSIGNED_SHORT: opcode = 4132; break;
- case GL_INT: opcode = 4128; break;
- case GL_UNSIGNED_INT: opcode = 4133; break;
- case GL_FLOAT: opcode = 4129; break;
- case GL_DOUBLE: opcode = 4130; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_SECONDARY_COLOR_ARRAY, 0 );
- if ( a == NULL ) {
- __glXSetError(gc, GL_INVALID_OPERATION);
- return;
- }
-
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, GL_TRUE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (size != 3 || stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_BYTE:
+ opcode = 4126;
+ break;
+ case GL_UNSIGNED_BYTE:
+ opcode = 4131;
+ break;
+ case GL_SHORT:
+ opcode = 4127;
+ break;
+ case GL_UNSIGNED_SHORT:
+ opcode = 4132;
+ break;
+ case GL_INT:
+ opcode = 4128;
+ break;
+ case GL_UNSIGNED_INT:
+ opcode = 4133;
+ break;
+ case GL_FLOAT:
+ opcode = 4129;
+ break;
+ case GL_DOUBLE:
+ opcode = 4130;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_SECONDARY_COLOR_ARRAY, 0);
+ if (a == NULL) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, GL_TRUE, 4, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glFogCoordPointerEXT( GLenum type, GLsizei stride,
- const GLvoid * pointer )
+void
+__indirect_glFogCoordPointerEXT(GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
-
- if (stride < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- switch ( type ) {
- case GL_FLOAT: opcode = 4124; break;
- case GL_DOUBLE: opcode = 4125; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- a = get_array_entry( arrays, GL_FOG_COORD_ARRAY, 0 );
- if ( a == NULL ) {
- __glXSetError(gc, GL_INVALID_OPERATION);
- return;
- }
-
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, 1, GL_FALSE, 4,
- opcode );
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ switch (type) {
+ case GL_FLOAT:
+ opcode = 4124;
+ break;
+ case GL_DOUBLE:
+ opcode = 4125;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ a = get_array_entry(arrays, GL_FOG_COORD_ARRAY, 0);
+ if (a == NULL) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, 1, GL_FALSE, 4, opcode);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
-void __indirect_glVertexAttribPointerARB(GLuint index, GLint size,
- GLenum type, GLboolean normalized,
- GLsizei stride,
- const GLvoid * pointer)
+void
+__indirect_glVertexAttribPointerARB(GLuint index, GLint size,
+ GLenum type, GLboolean normalized,
+ GLsizei stride, const GLvoid * pointer)
{
- static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 };
- static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 };
- static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 };
-
- uint16_t opcode;
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
- unsigned true_immediate_count;
- unsigned true_immediate_size;
-
-
- if ( (size < 1) || (size > 4) || (stride < 0)
- || (index > arrays->num_vertex_program_attribs) ){
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
- if ( normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) {
- switch( type ) {
- case GL_BYTE: opcode = X_GLrop_VertexAttrib4NbvARB; break;
- case GL_UNSIGNED_BYTE: opcode = X_GLrop_VertexAttrib4NubvARB; break;
- case GL_SHORT: opcode = X_GLrop_VertexAttrib4NsvARB; break;
- case GL_UNSIGNED_SHORT: opcode = X_GLrop_VertexAttrib4NusvARB; break;
- case GL_INT: opcode = X_GLrop_VertexAttrib4NivARB; break;
- case GL_UNSIGNED_INT: opcode = X_GLrop_VertexAttrib4NuivARB; break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- true_immediate_count = 4;
- }
- else {
- true_immediate_count = size;
-
- switch( type ) {
- case GL_BYTE:
- opcode = X_GLrop_VertexAttrib4bvARB;
- true_immediate_count = 4;
- break;
- case GL_UNSIGNED_BYTE:
- opcode = X_GLrop_VertexAttrib4ubvARB;
- true_immediate_count = 4;
- break;
- case GL_SHORT:
- opcode = short_ops[size];
- break;
- case GL_UNSIGNED_SHORT:
- opcode = X_GLrop_VertexAttrib4usvARB;
- true_immediate_count = 4;
- break;
- case GL_INT:
- opcode = X_GLrop_VertexAttrib4ivARB;
- true_immediate_count = 4;
- break;
- case GL_UNSIGNED_INT:
- opcode = X_GLrop_VertexAttrib4uivARB;
- true_immediate_count = 4;
- break;
- case GL_FLOAT:
- opcode = float_ops[size];
- break;
- case GL_DOUBLE:
- opcode = double_ops[size];
- break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
- }
-
- a = get_array_entry( arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index );
- if ( a == NULL ) {
- __glXSetError(gc, GL_INVALID_OPERATION);
- return;
- }
-
- COMMON_ARRAY_DATA_INIT( a, pointer, type, stride, size, normalized, 8,
- opcode );
-
- true_immediate_size = __glXTypeSize(type) * true_immediate_count;
- ((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size
- + true_immediate_size);
-
- if ( a->enabled ) {
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ static const uint16_t short_ops[5] = { 0, 4189, 4190, 4191, 4192 };
+ static const uint16_t float_ops[5] = { 0, 4193, 4194, 4195, 4196 };
+ static const uint16_t double_ops[5] = { 0, 4197, 4198, 4199, 4200 };
+
+ uint16_t opcode;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+ unsigned true_immediate_count;
+ unsigned true_immediate_size;
+
+
+ if ((size < 1) || (size > 4) || (stride < 0)
+ || (index > arrays->num_vertex_program_attribs)) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+ if (normalized && (type != GL_FLOAT) && (type != GL_DOUBLE)) {
+ switch (type) {
+ case GL_BYTE:
+ opcode = X_GLrop_VertexAttrib4NbvARB;
+ break;
+ case GL_UNSIGNED_BYTE:
+ opcode = X_GLrop_VertexAttrib4NubvARB;
+ break;
+ case GL_SHORT:
+ opcode = X_GLrop_VertexAttrib4NsvARB;
+ break;
+ case GL_UNSIGNED_SHORT:
+ opcode = X_GLrop_VertexAttrib4NusvARB;
+ break;
+ case GL_INT:
+ opcode = X_GLrop_VertexAttrib4NivARB;
+ break;
+ case GL_UNSIGNED_INT:
+ opcode = X_GLrop_VertexAttrib4NuivARB;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ true_immediate_count = 4;
+ }
+ else {
+ true_immediate_count = size;
+
+ switch (type) {
+ case GL_BYTE:
+ opcode = X_GLrop_VertexAttrib4bvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_UNSIGNED_BYTE:
+ opcode = X_GLrop_VertexAttrib4ubvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_SHORT:
+ opcode = short_ops[size];
+ break;
+ case GL_UNSIGNED_SHORT:
+ opcode = X_GLrop_VertexAttrib4usvARB;
+ true_immediate_count = 4;
+ break;
+ case GL_INT:
+ opcode = X_GLrop_VertexAttrib4ivARB;
+ true_immediate_count = 4;
+ break;
+ case GL_UNSIGNED_INT:
+ opcode = X_GLrop_VertexAttrib4uivARB;
+ true_immediate_count = 4;
+ break;
+ case GL_FLOAT:
+ opcode = float_ops[size];
+ break;
+ case GL_DOUBLE:
+ opcode = double_ops[size];
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ }
+
+ a = get_array_entry(arrays, GL_VERTEX_ATTRIB_ARRAY_POINTER, index);
+ if (a == NULL) {
+ __glXSetError(gc, GL_INVALID_OPERATION);
+ return;
+ }
+
+ COMMON_ARRAY_DATA_INIT(a, pointer, type, stride, size, normalized, 8,
+ opcode);
+
+ true_immediate_size = __glXTypeSize(type) * true_immediate_count;
+ ((uint16_t *) (a)->header)[0] = __GLX_PAD(a->header_size
+ + true_immediate_size);
+
+ if (a->enabled) {
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
}
@@ -1578,50 +1685,52 @@ void __indirect_glVertexAttribPointerARB(GLuint index, GLint size,
* client just sends all the data to the server and lets the server deal
* with it.
*/
-void __indirect_glVertexAttribPointerNV( GLuint index, GLint size,
- GLenum type, GLsizei stride,
- const GLvoid * pointer)
+void
+__indirect_glVertexAttribPointerNV(GLuint index, GLint size,
+ GLenum type, GLsizei stride,
+ const GLvoid * pointer)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- GLboolean normalized = GL_FALSE;
-
-
- switch( type ) {
- case GL_UNSIGNED_BYTE:
- if ( size != 4 ) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- normalized = GL_TRUE;
-
- case GL_SHORT:
- case GL_FLOAT:
- case GL_DOUBLE:
- __indirect_glVertexAttribPointerARB(index, size, type,
- normalized,
- stride, pointer);
- return;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ GLboolean normalized = GL_FALSE;
+
+
+ switch (type) {
+ case GL_UNSIGNED_BYTE:
+ if (size != 4) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ normalized = GL_TRUE;
+
+ case GL_SHORT:
+ case GL_FLOAT:
+ case GL_DOUBLE:
+ __indirect_glVertexAttribPointerARB(index, size, type,
+ normalized, stride, pointer);
+ return;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
}
-void __indirect_glClientActiveTextureARB(GLenum texture)
+void
+__indirect_glClientActiveTextureARB(GLenum texture)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- __GLXattribute * const state = (__GLXattribute *)(gc->client_state_private);
- struct array_state_vector * const arrays = state->array_state;
- const GLint unit = (GLint) texture - GL_TEXTURE0;
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ __GLXattribute *const state =
+ (__GLXattribute *) (gc->client_state_private);
+ struct array_state_vector *const arrays = state->array_state;
+ const GLint unit = (GLint) texture - GL_TEXTURE0;
- if ( (unit < 0) || (unit >= arrays->num_texture_units) ) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
+ if ((unit < 0) || (unit >= arrays->num_texture_units)) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
- arrays->active_texture_unit = unit;
+ arrays->active_texture_unit = unit;
}
@@ -1629,248 +1738,249 @@ void __indirect_glClientActiveTextureARB(GLenum texture)
* Modify the enable state for the selected array
*/
GLboolean
-__glXSetArrayEnable(__GLXattribute *state, GLenum key, unsigned index,
+__glXSetArrayEnable(__GLXattribute * state, GLenum key, unsigned index,
GLboolean enable)
{
- struct array_state_vector * arrays = state->array_state;
- struct array_state * a;
-
+ struct array_state_vector *arrays = state->array_state;
+ struct array_state *a;
+
- /* Texture coordinate arrays have an implict index set when the
- * application calls glClientActiveTexture.
- */
- if (key == GL_TEXTURE_COORD_ARRAY) {
- index = arrays->active_texture_unit;
- }
+ /* Texture coordinate arrays have an implict index set when the
+ * application calls glClientActiveTexture.
+ */
+ if (key == GL_TEXTURE_COORD_ARRAY) {
+ index = arrays->active_texture_unit;
+ }
- a = get_array_entry( arrays, key, index );
+ a = get_array_entry(arrays, key, index);
- if ( (a != NULL) && (a->enabled != enable) ) {
- a->enabled = enable;
- arrays->array_info_cache_valid = GL_FALSE;
- }
+ if ((a != NULL) && (a->enabled != enable)) {
+ a->enabled = enable;
+ arrays->array_info_cache_valid = GL_FALSE;
+ }
- return (a != NULL);
+ return (a != NULL);
}
void
-__glXArrayDisableAll( __GLXattribute * state )
+__glXArrayDisableAll(__GLXattribute * state)
{
- struct array_state_vector * arrays = state->array_state;
- unsigned i;
+ struct array_state_vector *arrays = state->array_state;
+ unsigned i;
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- arrays->arrays[i].enabled = GL_FALSE;
- }
+ for (i = 0; i < arrays->num_arrays; i++) {
+ arrays->arrays[i].enabled = GL_FALSE;
+ }
- arrays->array_info_cache_valid = GL_FALSE;
+ arrays->array_info_cache_valid = GL_FALSE;
}
/**
*/
GLboolean
-__glXGetArrayEnable( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest )
+__glXGetArrayEnable(const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (GLintptr) a->enabled;
- }
+ if (a != NULL) {
+ *dest = (GLintptr) a->enabled;
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLboolean
-__glXGetArrayType( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest )
+__glXGetArrayType(const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (GLintptr) a->data_type;
- }
+ if (a != NULL) {
+ *dest = (GLintptr) a->data_type;
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLboolean
-__glXGetArraySize( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest )
+__glXGetArraySize(const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (GLintptr) a->count;
- }
+ if (a != NULL) {
+ *dest = (GLintptr) a->count;
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLboolean
-__glXGetArrayStride( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest )
+__glXGetArrayStride(const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (GLintptr) a->user_stride;
- }
+ if (a != NULL) {
+ *dest = (GLintptr) a->user_stride;
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLboolean
-__glXGetArrayPointer( const __GLXattribute * const state,
- GLenum key, unsigned index, void ** dest )
+__glXGetArrayPointer(const __GLXattribute * const state,
+ GLenum key, unsigned index, void **dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (void *) (a->data);
- }
+ if (a != NULL) {
+ *dest = (void *) (a->data);
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLboolean
-__glXGetArrayNormalized( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest )
+__glXGetArrayNormalized(const __GLXattribute * const state,
+ GLenum key, unsigned index, GLintptr * dest)
{
- const struct array_state_vector * arrays = state->array_state;
- const struct array_state * a = get_array_entry( (struct array_state_vector *) arrays,
- key, index );
+ const struct array_state_vector *arrays = state->array_state;
+ const struct array_state *a =
+ get_array_entry((struct array_state_vector *) arrays,
+ key, index);
- if ( a != NULL ) {
- *dest = (GLintptr) a->normalized;
- }
+ if (a != NULL) {
+ *dest = (GLintptr) a->normalized;
+ }
- return (a != NULL);
+ return (a != NULL);
}
/**
*/
GLuint
-__glXGetActiveTextureUnit( const __GLXattribute * const state )
+__glXGetActiveTextureUnit(const __GLXattribute * const state)
{
- return state->array_state->active_texture_unit;
+ return state->array_state->active_texture_unit;
}
void
-__glXPushArrayState( __GLXattribute * state )
+__glXPushArrayState(__GLXattribute * state)
{
- struct array_state_vector * arrays = state->array_state;
- struct array_stack_state * stack = & arrays->stack[ (arrays->stack_index * arrays->num_arrays)];
- unsigned i;
-
- /* XXX are we pushing _all_ the necessary fields? */
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- stack[i].data = arrays->arrays[i].data;
- stack[i].data_type = arrays->arrays[i].data_type;
- stack[i].user_stride = arrays->arrays[i].user_stride;
- stack[i].count = arrays->arrays[i].count;
- stack[i].key = arrays->arrays[i].key;
- stack[i].index = arrays->arrays[i].index;
- stack[i].enabled = arrays->arrays[i].enabled;
- }
-
- arrays->active_texture_unit_stack[ arrays->stack_index ] =
+ struct array_state_vector *arrays = state->array_state;
+ struct array_stack_state *stack =
+ &arrays->stack[(arrays->stack_index * arrays->num_arrays)];
+ unsigned i;
+
+ /* XXX are we pushing _all_ the necessary fields? */
+ for (i = 0; i < arrays->num_arrays; i++) {
+ stack[i].data = arrays->arrays[i].data;
+ stack[i].data_type = arrays->arrays[i].data_type;
+ stack[i].user_stride = arrays->arrays[i].user_stride;
+ stack[i].count = arrays->arrays[i].count;
+ stack[i].key = arrays->arrays[i].key;
+ stack[i].index = arrays->arrays[i].index;
+ stack[i].enabled = arrays->arrays[i].enabled;
+ }
+
+ arrays->active_texture_unit_stack[arrays->stack_index] =
arrays->active_texture_unit;
- arrays->stack_index++;
+ arrays->stack_index++;
}
void
-__glXPopArrayState( __GLXattribute * state )
+__glXPopArrayState(__GLXattribute * state)
{
- struct array_state_vector * arrays = state->array_state;
- struct array_stack_state * stack;
- unsigned i;
-
-
- arrays->stack_index--;
- stack = & arrays->stack[ (arrays->stack_index * arrays->num_arrays) ];
-
- for ( i = 0 ; i < arrays->num_arrays ; i++ ) {
- switch ( stack[i].key ) {
- case GL_NORMAL_ARRAY:
- __indirect_glNormalPointer( stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
- case GL_COLOR_ARRAY:
- __indirect_glColorPointer( stack[i].count,
- stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
- case GL_INDEX_ARRAY:
- __indirect_glIndexPointer( stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
- case GL_EDGE_FLAG_ARRAY:
- __indirect_glEdgeFlagPointer( stack[i].user_stride,
- stack[i].data );
- break;
- case GL_TEXTURE_COORD_ARRAY:
- arrays->active_texture_unit = stack[i].index;
- __indirect_glTexCoordPointer( stack[i].count,
- stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
- case GL_SECONDARY_COLOR_ARRAY:
- __indirect_glSecondaryColorPointerEXT( stack[i].count,
- stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
- case GL_FOG_COORDINATE_ARRAY:
- __indirect_glFogCoordPointerEXT( stack[i].data_type,
- stack[i].user_stride,
- stack[i].data );
- break;
-
- }
-
- __glXSetArrayEnable( state, stack[i].key, stack[i].index,
- stack[i].enabled );
- }
-
- arrays->active_texture_unit =
- arrays->active_texture_unit_stack[ arrays->stack_index ];
+ struct array_state_vector *arrays = state->array_state;
+ struct array_stack_state *stack;
+ unsigned i;
+
+
+ arrays->stack_index--;
+ stack = &arrays->stack[(arrays->stack_index * arrays->num_arrays)];
+
+ for (i = 0; i < arrays->num_arrays; i++) {
+ switch (stack[i].key) {
+ case GL_NORMAL_ARRAY:
+ __indirect_glNormalPointer(stack[i].data_type,
+ stack[i].user_stride, stack[i].data);
+ break;
+ case GL_COLOR_ARRAY:
+ __indirect_glColorPointer(stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride, stack[i].data);
+ break;
+ case GL_INDEX_ARRAY:
+ __indirect_glIndexPointer(stack[i].data_type,
+ stack[i].user_stride, stack[i].data);
+ break;
+ case GL_EDGE_FLAG_ARRAY:
+ __indirect_glEdgeFlagPointer(stack[i].user_stride, stack[i].data);
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ arrays->active_texture_unit = stack[i].index;
+ __indirect_glTexCoordPointer(stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride, stack[i].data);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY:
+ __indirect_glSecondaryColorPointerEXT(stack[i].count,
+ stack[i].data_type,
+ stack[i].user_stride,
+ stack[i].data);
+ break;
+ case GL_FOG_COORDINATE_ARRAY:
+ __indirect_glFogCoordPointerEXT(stack[i].data_type,
+ stack[i].user_stride, stack[i].data);
+ break;
+
+ }
+
+ __glXSetArrayEnable(state, stack[i].key, stack[i].index,
+ stack[i].enabled);
+ }
+
+ arrays->active_texture_unit =
+ arrays->active_texture_unit_stack[arrays->stack_index];
}
diff --git a/src/glx/x11/indirect_vertex_array.h b/src/glx/x11/indirect_vertex_array.h
index caab62b672e..2867f6fd535 100644
--- a/src/glx/x11/indirect_vertex_array.h
+++ b/src/glx/x11/indirect_vertex_array.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
@@ -31,27 +32,34 @@ extern const GLuint __glXTypeSize_table[16];
#define __glXTypeSize(e) ((((e) & ~0x0f) != 0x1400) \
? 0 : __glXTypeSize_table[ (e) & 0x0f ])
-extern void __glXArrayDisableAll( __GLXattribute * state );
+extern void __glXArrayDisableAll(__GLXattribute * state);
-extern GLboolean __glXSetArrayEnable( __GLXattribute * state,
- GLenum key, unsigned index, GLboolean enable );
+extern GLboolean __glXSetArrayEnable(__GLXattribute * state,
+ GLenum key, unsigned index,
+ GLboolean enable);
-extern GLboolean __glXGetArrayEnable( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest );
-extern GLboolean __glXGetArraySize( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest );
-extern GLboolean __glXGetArrayType( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest );
-extern GLboolean __glXGetArrayStride( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest );
-extern GLboolean __glXGetArrayPointer( const __GLXattribute * const state,
- GLenum key, unsigned index, void ** dest );
-extern GLboolean __glXGetArrayNormalized( const __GLXattribute * const state,
- GLenum key, unsigned index, GLintptr * dest );
+extern GLboolean __glXGetArrayEnable(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ GLintptr * dest);
+extern GLboolean __glXGetArraySize(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ GLintptr * dest);
+extern GLboolean __glXGetArrayType(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ GLintptr * dest);
+extern GLboolean __glXGetArrayStride(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ GLintptr * dest);
+extern GLboolean __glXGetArrayPointer(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ void **dest);
+extern GLboolean __glXGetArrayNormalized(const __GLXattribute * const state,
+ GLenum key, unsigned index,
+ GLintptr * dest);
-extern void __glXPushArrayState( __GLXattribute * state );
-extern void __glXPopArrayState( __GLXattribute * state );
+extern void __glXPushArrayState(__GLXattribute * state);
+extern void __glXPopArrayState(__GLXattribute * state);
-extern GLuint __glXGetActiveTextureUnit( const __GLXattribute * const state );
+extern GLuint __glXGetActiveTextureUnit(const __GLXattribute * const state);
#endif /* INDIRECT_VERTEX_ARRAY_H */
diff --git a/src/glx/x11/indirect_vertex_array_priv.h b/src/glx/x11/indirect_vertex_array_priv.h
index ab97dc645fb..240839cae7b 100644
--- a/src/glx/x11/indirect_vertex_array_priv.h
+++ b/src/glx/x11/indirect_vertex_array_priv.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2004, 2005
* All Rights Reserved.
@@ -42,86 +43,87 @@
/**
* State descriptor for a single array of vertex data.
*/
-struct array_state {
+struct array_state
+{
/**
* Pointer to the application supplied data.
*/
- const void * data;
-
+ const void *data;
+
/**
* Enum representing the type of the application supplied data.
*/
- GLenum data_type;
+ GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
- GLsizei user_stride;
+ GLsizei user_stride;
/**
* Calculated size, in bytes, of a single element in the array. This
* is calculated based on \c count and the size of the data type
* represented by \c data_type.
*/
- GLsizei element_size;
+ GLsizei element_size;
/**
* Actual byte-stride from one element to the next. This value will
* be equal to either \c user_stride or \c element_stride.
*/
- GLsizei true_stride;
+ GLsizei true_stride;
/**
* Number of data values in each element.
*/
- GLint count;
+ GLint count;
/**
* "Normalized" data is on the range [0,1] (unsigned) or [-1,1] (signed).
* This is used for mapping integral types to floating point types.
*/
- GLboolean normalized;
+ GLboolean normalized;
/**
* Pre-calculated GLX protocol command header.
*/
- uint32_t header[2];
-
+ uint32_t header[2];
+
/**
* Size of the header data. For simple data, like glColorPointerfv,
* this is 4. For complex data that requires either a count (e.g.,
* glWeightfvARB), an index (e.g., glVertexAttrib1fvARB), or a
* selector enum (e.g., glMultiTexCoord2fv) this is 8.
*/
- unsigned header_size;
-
+ unsigned header_size;
+
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
- GLboolean enabled;
+ GLboolean enabled;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
- unsigned index;
-
+ unsigned index;
+
/**
* Per-array-type key. For most arrays, this will be the GL enum for
* that array (e.g., GL_VERTEX_ARRAY for vertex data, GL_NORMAL_ARRAY
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
- GLenum key;
+ GLenum key;
/**
* If this array can be used with the "classic" \c glDrawArrays protocol,
* this is set to \c GL_TRUE. Otherwise, it is set to \c GL_FALSE.
*/
- GLboolean old_DrawArrays_possible;
+ GLboolean old_DrawArrays_possible;
};
@@ -129,28 +131,29 @@ struct array_state {
* Array state that is pushed / poped by \c glPushClientAttrib and
* \c glPopClientAttrib.
*/
-struct array_stack_state {
+struct array_stack_state
+{
/**
* Pointer to the application supplied data.
*/
- const void * data;
-
+ const void *data;
+
/**
* Enum representing the type of the application supplied data.
*/
- GLenum data_type;
+ GLenum data_type;
/**
* Stride value supplied by the application. This value is not used
* internally. It is only kept so that it can be queried by the
* application using glGet*v.
*/
- GLsizei user_stride;
+ GLsizei user_stride;
/**
* Number of data values in each element.
*/
- GLint count;
+ GLint count;
/**
* Per-array-type key. For most arrays, this will be the GL enum for
@@ -158,30 +161,31 @@ struct array_stack_state {
* for normal data, GL_TEXTURE_COORD_ARRAY for texture coordinate data,
* etc.).
*/
- GLenum key;
+ GLenum key;
/**
* For multi-arrayed data (e.g., texture coordinates, generic vertex
* program attributes, etc.), this specifies which array this is.
*/
- unsigned index;
+ unsigned index;
/**
* Set to \c GL_TRUE if this array is enabled. Otherwise, it is set
* to \c GL_FALSE.
*/
- GLboolean enabled;
+ GLboolean enabled;
};
/**
* Collection of all the vertex array state.
*/
-struct array_state_vector {
+struct array_state_vector
+{
/**
* Number of arrays tracked by \c ::arrays.
*/
- size_t num_arrays;
+ size_t num_arrays;
/**
* Array of vertex array state. This array contains all of the valid
@@ -190,13 +194,13 @@ struct array_state_vector {
* EXT_fog_coord, there won't be a GL_FOG_COORD_ARRAY entry in this
* array.
*/
- struct array_state * arrays;
+ struct array_state *arrays;
/**
* Number of currently enabled client-side arrays. The value of this
* field is only valid if \c array_info_cache_valid is true.
*/
- size_t enabled_client_array_count;
+ size_t enabled_client_array_count;
/**
* \name ARRAY_INFO cache.
@@ -214,12 +218,12 @@ struct array_state_vector {
* \c array_info_cache_buffer_size. \c array_info_cache_base stores a
* pointer to the true start of the buffer (i.e., what malloc returned).
*/
- /*@{*/
- size_t array_info_cache_size;
- size_t array_info_cache_buffer_size;
- void * array_info_cache;
- void * array_info_cache_base;
- /*@}*/
+ /*@{ */
+ size_t array_info_cache_size;
+ size_t array_info_cache_buffer_size;
+ void *array_info_cache;
+ void *array_info_cache_base;
+ /*@} */
/**
@@ -228,7 +232,7 @@ struct array_state_vector {
* modifying the array settings for an enabled array and enabling /
* disabling an array.
*/
- GLboolean array_info_cache_valid;
+ GLboolean array_info_cache_valid;
/**
* Is it possible to use the GL 1.1 / EXT_vertex_arrays protocol? Use
@@ -241,7 +245,7 @@ struct array_state_vector {
* opcodes for \c glDrawArrays. For servers that advertise one or the
* other, there should be a way to select which opcode to use.
*/
- GLboolean old_DrawArrays_possible;
+ GLboolean old_DrawArrays_possible;
/**
* Is it possible to use the new GL X.X / ARB_vertex_buffer_object
@@ -251,15 +255,15 @@ struct array_state_vector {
* This protocol has not yet been defined by the ARB, but is currently a
* work in progress. This field is a place-holder.
*/
- GLboolean new_DrawArrays_possible;
+ GLboolean new_DrawArrays_possible;
/**
* Active texture unit set by \c glClientActiveTexture.
*
* \sa __glXGetActiveTextureUnit
*/
- unsigned active_texture_unit;
-
+ unsigned active_texture_unit;
+
/**
* Number of supported texture units. Even if ARB_multitexture /
* GL 1.3 are not supported, this will be at least 1. When multitexture
@@ -271,7 +275,7 @@ struct array_state_vector {
* instead (if GL 2.0 / ARB_fragment_shader / ARB_fragment_program /
* NV_fragment_program are supported).
*/
- unsigned num_texture_units;
+ unsigned num_texture_units;
/**
* Number of generic vertex program attribs. If GL_ARB_vertex_program
@@ -279,7 +283,7 @@ struct array_state_vector {
* queries by calling \c glGetProgramiv with \c GL_VERTEX_PROGRAM_ARB
* and \c GL_MAX_PROGRAM_ATTRIBS_ARB.
*/
- unsigned num_vertex_program_attribs;
+ unsigned num_vertex_program_attribs;
/**
* \n Methods for implementing various GL functions.
@@ -294,15 +298,15 @@ struct array_state_vector {
* \todo
* Write code to plug these functions directly into the dispatch table.
*/
- /*@{*/
- void (*DrawArrays)( GLenum, GLint, GLsizei );
- void (*DrawElements)( GLenum mode, GLsizei count, GLenum type,
- const GLvoid *indices );
- /*@}*/
-
- struct array_stack_state * stack;
- unsigned active_texture_unit_stack[ __GL_CLIENT_ATTRIB_STACK_DEPTH ];
- unsigned stack_index;
+ /*@{ */
+ void (*DrawArrays) (GLenum, GLint, GLsizei);
+ void (*DrawElements) (GLenum mode, GLsizei count, GLenum type,
+ const GLvoid * indices);
+ /*@} */
+
+ struct array_stack_state *stack;
+ unsigned active_texture_unit_stack[__GL_CLIENT_ATTRIB_STACK_DEPTH];
+ unsigned stack_index;
};
#endif /* _INDIRECT_VA_PRIVATE_ */
diff --git a/src/glx/x11/indirect_vertex_program.c b/src/glx/x11/indirect_vertex_program.c
index 0a1091eaefc..7d0ab3f2a86 100644
--- a/src/glx/x11/indirect_vertex_program.c
+++ b/src/glx/x11/indirect_vertex_program.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* (C) Copyright IBM Corporation 2005
* All Rights Reserved.
@@ -31,96 +32,104 @@
#include <GL/glxproto.h>
static void
-do_vertex_attrib_enable( GLuint index, GLboolean val )
+do_vertex_attrib_enable(GLuint index, GLboolean val)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
- if ( ! __glXSetArrayEnable( state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
- index, val ) ) {
- __glXSetError(gc, GL_INVALID_ENUM);
- }
+ if (!__glXSetArrayEnable(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
+ index, val)) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
}
-void __indirect_glEnableVertexAttribArrayARB( GLuint index )
+void
+__indirect_glEnableVertexAttribArrayARB(GLuint index)
{
- do_vertex_attrib_enable( index, GL_TRUE );
+ do_vertex_attrib_enable(index, GL_TRUE);
}
-void __indirect_glDisableVertexAttribArrayARB( GLuint index )
+void
+__indirect_glDisableVertexAttribArrayARB(GLuint index)
{
- do_vertex_attrib_enable( index, GL_FALSE );
+ do_vertex_attrib_enable(index, GL_FALSE);
}
static void
-get_parameter( unsigned opcode, unsigned size, GLenum target, GLuint index,
- void * params )
+get_parameter(unsigned opcode, unsigned size, GLenum target, GLuint index,
+ void *params)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- Display * const dpy = gc->currentDpy;
- const GLuint cmdlen = 12;
-
- if (__builtin_expect(dpy != NULL, 1)) {
- GLubyte const * pc = __glXSetupVendorRequest(gc,
- X_GLXVendorPrivateWithReply,
- opcode, cmdlen);
-
- *((GLenum *)(pc + 0)) = target;
- *((GLuint *)(pc + 4)) = index;
- *((GLuint *)(pc + 8)) = 0;
-
- (void) __glXReadReply(dpy, size, params, GL_FALSE);
- UnlockDisplay(dpy); SyncHandle();
- }
- return;
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ Display *const dpy = gc->currentDpy;
+ const GLuint cmdlen = 12;
+
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const *pc = __glXSetupVendorRequest(gc,
+ X_GLXVendorPrivateWithReply,
+ opcode, cmdlen);
+
+ *((GLenum *) (pc + 0)) = target;
+ *((GLuint *) (pc + 4)) = index;
+ *((GLuint *) (pc + 8)) = 0;
+
+ (void) __glXReadReply(dpy, size, params, GL_FALSE);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ return;
}
-void __indirect_glGetProgramEnvParameterfvARB( GLenum target, GLuint index,
- GLfloat * params )
+void
+__indirect_glGetProgramEnvParameterfvARB(GLenum target, GLuint index,
+ GLfloat * params)
{
- get_parameter( 1296, 4, target, index, params );
+ get_parameter(1296, 4, target, index, params);
}
-void __indirect_glGetProgramEnvParameterdvARB( GLenum target, GLuint index,
- GLdouble * params )
+void
+__indirect_glGetProgramEnvParameterdvARB(GLenum target, GLuint index,
+ GLdouble * params)
{
- get_parameter( 1297, 8, target, index, params );
+ get_parameter(1297, 8, target, index, params);
}
-void __indirect_glGetProgramLocalParameterfvARB( GLenum target, GLuint index,
- GLfloat * params )
+void
+__indirect_glGetProgramLocalParameterfvARB(GLenum target, GLuint index,
+ GLfloat * params)
{
- get_parameter( 1305, 4, target, index, params );
+ get_parameter(1305, 4, target, index, params);
}
-void __indirect_glGetProgramLocalParameterdvARB( GLenum target, GLuint index,
- GLdouble * params )
+void
+__indirect_glGetProgramLocalParameterdvARB(GLenum target, GLuint index,
+ GLdouble * params)
{
- get_parameter( 1306, 8, target, index, params );
+ get_parameter(1306, 8, target, index, params);
}
-void __indirect_glGetVertexAttribPointervNV( GLuint index, GLenum pname,
- GLvoid ** pointer )
+void
+__indirect_glGetVertexAttribPointervNV(GLuint index, GLenum pname,
+ GLvoid ** pointer)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
-
- if ( pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB ) {
- __glXSetError( gc, GL_INVALID_ENUM );
- }
-
- if ( ! __glXGetArrayPointer( state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
- index, pointer ) ) {
- __glXSetError( gc, GL_INVALID_VALUE );
- }
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+
+ if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ }
+
+ if (!__glXGetArrayPointer(state, GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB,
+ index, pointer)) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ }
}
@@ -131,149 +140,151 @@ void __indirect_glGetVertexAttribPointervNV( GLuint index, GLenum pname,
* On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
*/
static GLboolean
-get_attrib_array_data( __GLXattribute * state, GLuint index, GLenum cap,
- GLintptr * data )
+get_attrib_array_data(__GLXattribute * state, GLuint index, GLenum cap,
+ GLintptr * data)
{
- GLboolean retval = GL_FALSE;
- const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB;
+ GLboolean retval = GL_FALSE;
+ const GLenum attrib = GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB;
+
+ switch (cap) {
+ case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
+ retval = __glXGetArrayEnable(state, attrib, index, data);
+ break;
- switch( cap ) {
- case GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB:
- retval = __glXGetArrayEnable( state, attrib, index, data );
- break;
+ case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
+ retval = __glXGetArraySize(state, attrib, index, data);
+ break;
- case GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB:
- retval = __glXGetArraySize( state, attrib, index, data );
- break;
+ case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
+ retval = __glXGetArrayStride(state, attrib, index, data);
+ break;
- case GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB:
- retval = __glXGetArrayStride( state, attrib, index, data );
- break;
+ case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
+ retval = __glXGetArrayType(state, attrib, index, data);
+ break;
- case GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB:
- retval = __glXGetArrayType( state, attrib, index, data );
- break;
+ case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
+ retval = __glXGetArrayNormalized(state, attrib, index, data);
+ break;
+ }
- case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB:
- retval = __glXGetArrayNormalized( state, attrib, index, data );
- break;
- }
-
- return retval;
+ return retval;
}
-static void get_vertex_attrib( __GLXcontext * gc, unsigned vop,
- GLuint index, GLenum pname,
- xReply * reply )
+static void
+get_vertex_attrib(__GLXcontext * gc, unsigned vop,
+ GLuint index, GLenum pname, xReply * reply)
{
- Display * const dpy = gc->currentDpy;
- GLubyte * const pc = __glXSetupVendorRequest(gc,
- X_GLXVendorPrivateWithReply,
- vop, 8);
-
- *((uint32_t *)(pc + 0)) = index;
- *((uint32_t *)(pc + 4)) = pname;
-
- (void) _XReply( dpy, reply, 0, False );
+ Display *const dpy = gc->currentDpy;
+ GLubyte *const pc = __glXSetupVendorRequest(gc,
+ X_GLXVendorPrivateWithReply,
+ vop, 8);
+
+ *((uint32_t *) (pc + 0)) = index;
+ *((uint32_t *) (pc + 4)) = pname;
+
+ (void) _XReply(dpy, reply, 0, False);
}
-void __indirect_glGetVertexAttribivARB( GLuint index, GLenum pname,
- GLint * params )
+void
+__indirect_glGetVertexAttribivARB(GLuint index, GLenum pname, GLint * params)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- Display * const dpy = gc->currentDpy;
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- xGLXSingleReply reply;
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ Display *const dpy = gc->currentDpy;
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ xGLXSingleReply reply;
- get_vertex_attrib( gc, 1303, index, pname, (xReply *) & reply );
+ get_vertex_attrib(gc, 1303, index, pname, (xReply *) & reply);
- if ( reply.size != 0 ) {
- GLintptr data;
+ if (reply.size != 0) {
+ GLintptr data;
- if ( get_attrib_array_data( state, index, pname, & data ) ) {
- *params = (GLint) data;
- }
- else {
- if (reply.size == 1) {
- *params = (GLint) reply.pad3;
- }
- else {
- _XRead(dpy, (void *) params, 4 * reply.size);
- }
- }
- }
+ if (get_attrib_array_data(state, index, pname, &data)) {
+ *params = (GLint) data;
+ }
+ else {
+ if (reply.size == 1) {
+ *params = (GLint) reply.pad3;
+ }
+ else {
+ _XRead(dpy, (void *) params, 4 * reply.size);
+ }
+ }
+ }
- UnlockDisplay(dpy);
- SyncHandle();
+ UnlockDisplay(dpy);
+ SyncHandle();
}
-void __indirect_glGetVertexAttribfvARB( GLuint index, GLenum pname,
- GLfloat * params )
+void
+__indirect_glGetVertexAttribfvARB(GLuint index, GLenum pname,
+ GLfloat * params)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- Display * const dpy = gc->currentDpy;
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- xGLXSingleReply reply;
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ Display *const dpy = gc->currentDpy;
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ xGLXSingleReply reply;
- get_vertex_attrib( gc, 1302, index, pname, (xReply *) & reply );
+ get_vertex_attrib(gc, 1302, index, pname, (xReply *) & reply);
- if ( reply.size != 0 ) {
- GLintptr data;
+ if (reply.size != 0) {
+ GLintptr data;
- if ( get_attrib_array_data( state, index, pname, & data ) ) {
- *params = (GLfloat) data;
- }
- else {
- if (reply.size == 1) {
- (void) memcpy( params, & reply.pad3, sizeof( GLfloat ) );
- }
- else {
- _XRead(dpy, (void *) params, 4 * reply.size);
- }
- }
- }
+ if (get_attrib_array_data(state, index, pname, &data)) {
+ *params = (GLfloat) data;
+ }
+ else {
+ if (reply.size == 1) {
+ (void) memcpy(params, &reply.pad3, sizeof(GLfloat));
+ }
+ else {
+ _XRead(dpy, (void *) params, 4 * reply.size);
+ }
+ }
+ }
- UnlockDisplay(dpy);
- SyncHandle();
+ UnlockDisplay(dpy);
+ SyncHandle();
}
-void __indirect_glGetVertexAttribdvARB( GLuint index, GLenum pname,
- GLdouble * params )
+void
+__indirect_glGetVertexAttribdvARB(GLuint index, GLenum pname,
+ GLdouble * params)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
- Display * const dpy = gc->currentDpy;
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- xGLXSingleReply reply;
+ __GLXcontext *const gc = __glXGetCurrentContext();
+ Display *const dpy = gc->currentDpy;
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ xGLXSingleReply reply;
- get_vertex_attrib( gc, 1301, index, pname, (xReply *) & reply );
+ get_vertex_attrib(gc, 1301, index, pname, (xReply *) & reply);
- if ( reply.size != 0 ) {
- GLintptr data;
+ if (reply.size != 0) {
+ GLintptr data;
- if ( get_attrib_array_data( state, index, pname, & data ) ) {
- *params = (GLdouble) data;
- }
- else {
- if (reply.size == 1) {
- (void) memcpy( params, & reply.pad3, sizeof( GLdouble ) );
- }
- else {
- _XRead(dpy, (void *) params, 8 * reply.size);
- }
- }
- }
+ if (get_attrib_array_data(state, index, pname, &data)) {
+ *params = (GLdouble) data;
+ }
+ else {
+ if (reply.size == 1) {
+ (void) memcpy(params, &reply.pad3, sizeof(GLdouble));
+ }
+ else {
+ _XRead(dpy, (void *) params, 8 * reply.size);
+ }
+ }
+ }
- UnlockDisplay(dpy);
- SyncHandle();
+ UnlockDisplay(dpy);
+ SyncHandle();
}
diff --git a/src/glx/x11/indirect_window_pos.c b/src/glx/x11/indirect_window_pos.c
index 533f8ef1a40..b24b481c43d 100644
--- a/src/glx/x11/indirect_window_pos.c
+++ b/src/glx/x11/indirect_window_pos.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
* (C) Copyright IBM Corporation 2004
@@ -27,72 +28,86 @@
#include <GL/gl.h>
#include "indirect.h"
-void __indirect_glWindowPos2dMESA(GLdouble x, GLdouble y)
+void
+__indirect_glWindowPos2dMESA(GLdouble x, GLdouble y)
{
- __indirect_glWindowPos3fMESA(x, y, 0.0);
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
}
-void __indirect_glWindowPos2iMESA(GLint x, GLint y)
+void
+__indirect_glWindowPos2iMESA(GLint x, GLint y)
{
- __indirect_glWindowPos3fMESA(x, y, 0.0);
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
}
-void __indirect_glWindowPos2fMESA(GLfloat x, GLfloat y)
+void
+__indirect_glWindowPos2fMESA(GLfloat x, GLfloat y)
{
- __indirect_glWindowPos3fMESA(x, y, 0.0);
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
}
-void __indirect_glWindowPos2sMESA(GLshort x, GLshort y)
+void
+__indirect_glWindowPos2sMESA(GLshort x, GLshort y)
{
- __indirect_glWindowPos3fMESA(x, y, 0.0);
+ __indirect_glWindowPos3fMESA(x, y, 0.0);
}
-void __indirect_glWindowPos2dvMESA(const GLdouble * p)
+void
+__indirect_glWindowPos2dvMESA(const GLdouble * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
}
-void __indirect_glWindowPos2fvMESA(const GLfloat * p)
+void
+__indirect_glWindowPos2fvMESA(const GLfloat * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
}
-void __indirect_glWindowPos2ivMESA(const GLint * p)
+void
+__indirect_glWindowPos2ivMESA(const GLint * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
}
-void __indirect_glWindowPos2svMESA(const GLshort * p)
+void
+__indirect_glWindowPos2svMESA(const GLshort * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
+ __indirect_glWindowPos3fMESA(p[0], p[1], 0.0);
}
-void __indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
+void
+__indirect_glWindowPos3dMESA(GLdouble x, GLdouble y, GLdouble z)
{
- __indirect_glWindowPos3fMESA(x, y, z);
+ __indirect_glWindowPos3fMESA(x, y, z);
}
-void __indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z)
+void
+__indirect_glWindowPos3iMESA(GLint x, GLint y, GLint z)
{
- __indirect_glWindowPos3fMESA(x, y, z);
+ __indirect_glWindowPos3fMESA(x, y, z);
}
-void __indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z)
+void
+__indirect_glWindowPos3sMESA(GLshort x, GLshort y, GLshort z)
{
- __indirect_glWindowPos3fMESA(x, y, z);
+ __indirect_glWindowPos3fMESA(x, y, z);
}
-void __indirect_glWindowPos3dvMESA(const GLdouble * p)
+void
+__indirect_glWindowPos3dvMESA(const GLdouble * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
}
-void __indirect_glWindowPos3ivMESA(const GLint * p)
+void
+__indirect_glWindowPos3ivMESA(const GLint * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
}
-void __indirect_glWindowPos3svMESA(const GLshort * p)
+void
+__indirect_glWindowPos3svMESA(const GLshort * p)
{
- __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
+ __indirect_glWindowPos3fMESA(p[0], p[1], p[2]);
}
diff --git a/src/glx/x11/packrender.h b/src/glx/x11/packrender.h
index cee827663a9..6db6ea721ff 100644
--- a/src/glx/x11/packrender.h
+++ b/src/glx/x11/packrender.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
#ifndef __GLX_packrender_h__
#define __GLX_packrender_h__
@@ -48,23 +49,23 @@
#define __GLX_PAD(a) (((a)+3) & ~3)
/*
- ** Network size parameters
- */
+** Network size parameters
+*/
#define sz_double 8
/* Setup for all commands */
-#define __GLX_DECLARE_VARIABLES() \
- __GLXcontext *gc; \
- GLubyte *pc, *pixelHeaderPC; \
- GLuint compsize, cmdlen
-
-#define __GLX_LOAD_VARIABLES() \
- gc = __glXGetCurrentContext(); \
- pc = gc->pc; \
- /* Muffle compilers */ \
- cmdlen = 0; (void)cmdlen; \
- compsize = 0; (void)compsize; \
- pixelHeaderPC = 0; (void)pixelHeaderPC
+#define __GLX_DECLARE_VARIABLES() \
+ __GLXcontext *gc; \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen
+
+#define __GLX_LOAD_VARIABLES() \
+ gc = __glXGetCurrentContext(); \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ cmdlen = 0; (void)cmdlen; \
+ compsize = 0; (void)compsize; \
+ pixelHeaderPC = 0; (void)pixelHeaderPC
/*
** Variable sized command support macro. This macro is used by calls
@@ -73,53 +74,53 @@
** If the buffer can't hold the command then it is flushed so that
** the command will fit in the next buffer.
*/
-#define __GLX_BEGIN_VARIABLE(opcode,size) \
- if (pc + (size) > gc->bufEnd) { \
- pc = __glXFlushRenderBuffer(gc, pc); \
- } \
- __GLX_PUT_SHORT(0,size); \
- __GLX_PUT_SHORT(2,opcode)
-
-#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
- pc = __glXFlushRenderBuffer(gc, pc); \
- __GLX_PUT_LONG(0,size); \
- __GLX_PUT_LONG(4,opcode)
-
-#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \
- if (pc + (size) > gc->bufEnd) { \
- pc = __glXFlushRenderBuffer(gc, pc); \
- } \
- __GLX_PUT_SHORT(0,size); \
- __GLX_PUT_SHORT(2,opcode); \
- pc += __GLX_RENDER_HDR_SIZE; \
- pixelHeaderPC = pc; \
- pc += __GLX_PIXEL_HDR_SIZE
-
-#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \
- pc = __glXFlushRenderBuffer(gc, pc); \
- __GLX_PUT_LONG(0,size); \
- __GLX_PUT_LONG(4,opcode); \
- pc += __GLX_RENDER_LARGE_HDR_SIZE; \
- pixelHeaderPC = pc; \
- pc += __GLX_PIXEL_HDR_SIZE
-
-#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \
- if (pc + (size) > gc->bufEnd) { \
- pc = __glXFlushRenderBuffer(gc, pc); \
- } \
- __GLX_PUT_SHORT(0,size); \
- __GLX_PUT_SHORT(2,opcode); \
- pc += __GLX_RENDER_HDR_SIZE; \
- pixelHeaderPC = pc; \
- pc += __GLX_PIXEL_3D_HDR_SIZE
-
-#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \
- pc = __glXFlushRenderBuffer(gc, pc); \
- __GLX_PUT_LONG(0,size); \
- __GLX_PUT_LONG(4,opcode); \
- pc += __GLX_RENDER_LARGE_HDR_SIZE; \
- pixelHeaderPC = pc; \
- pc += __GLX_PIXEL_3D_HDR_SIZE
+#define __GLX_BEGIN_VARIABLE(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
+
+#define __GLX_BEGIN_VARIABLE_LARGE(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode)
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_WITH_PIXEL_3D(opcode,size) \
+ if (pc + (size) > gc->bufEnd) { \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ } \
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode); \
+ pc += __GLX_RENDER_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
+
+#define __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL_3D(opcode,size) \
+ pc = __glXFlushRenderBuffer(gc, pc); \
+ __GLX_PUT_LONG(0,size); \
+ __GLX_PUT_LONG(4,opcode); \
+ pc += __GLX_RENDER_LARGE_HDR_SIZE; \
+ pixelHeaderPC = pc; \
+ pc += __GLX_PIXEL_3D_HDR_SIZE
/*
** Fixed size command support macro. This macro is used by calls that
@@ -129,8 +130,8 @@
** before doing the storage work.
*/
#define __GLX_BEGIN(opcode,size) \
- __GLX_PUT_SHORT(0,size); \
- __GLX_PUT_SHORT(2,opcode)
+ __GLX_PUT_SHORT(0,size); \
+ __GLX_PUT_SHORT(2,opcode)
/*
** Finish a rendering command by advancing the pc. If the pc is now past
@@ -140,52 +141,52 @@
** rendering buffer is flushed out into the X protocol stream (which may
** or may not do I/O).
*/
-#define __GLX_END(size) \
- pc += size; \
- if (pc > gc->limit) { \
- (void) __glXFlushRenderBuffer(gc, pc); \
- } else { \
- gc->pc = pc; \
- }
+#define __GLX_END(size) \
+ pc += size; \
+ if (pc > gc->limit) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ } else { \
+ gc->pc = pc; \
+ }
/* Array copy macros */
-#define __GLX_MEM_COPY(dest,src,bytes) \
- if (src && dest) \
- memcpy(dest, src, bytes)
+#define __GLX_MEM_COPY(dest,src,bytes) \
+ if (src && dest) \
+ memcpy(dest, src, bytes)
/* Single item copy macros */
-#define __GLX_PUT_CHAR(offset,a) \
- *((INT8 *) (pc + offset)) = a
+#define __GLX_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
#ifndef _CRAY
-#define __GLX_PUT_SHORT(offset,a) \
- *((INT16 *) (pc + offset)) = a
+#define __GLX_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
-#define __GLX_PUT_LONG(offset,a) \
- *((INT32 *) (pc + offset)) = a
+#define __GLX_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
-#define __GLX_PUT_FLOAT(offset,a) \
- *((FLOAT32 *) (pc + offset)) = a
+#define __GLX_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
#else
-#define __GLX_PUT_SHORT(offset,a) \
- { GLubyte *cp = (pc+offset); \
- int shift = (64-16) - ((int)(cp) >> (64-6)); \
- *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
+#define __GLX_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
-#define __GLX_PUT_LONG(offset,a) \
- { GLubyte *cp = (pc+offset); \
- int shift = (64-32) - ((int)(cp) >> (64-6)); \
- *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
+#define __GLX_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
+ *(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
-#define __GLX_PUT_FLOAT(offset,a) \
- gl_put_float((pc + offset),a)
+#define __GLX_PUT_FLOAT(offset,a) \
+ gl_put_float((pc + offset),a)
-#define __GLX_PUT_DOUBLE(offset,a) \
- gl_put_double(pc + offset, a)
+#define __GLX_PUT_DOUBLE(offset,a) \
+ gl_put_double(pc + offset, a)
-extern void gl_put_float(/*GLubyte *, struct cray_single*/);
-extern void gl_put_double(/*GLubyte *, struct cray_double*/);
+extern void gl_put_float( /*GLubyte *, struct cray_single */ );
+extern void gl_put_double( /*GLubyte *, struct cray_double */ );
#endif
#ifndef _CRAY
@@ -195,48 +196,48 @@ extern void gl_put_double(/*GLubyte *, struct cray_double*/);
** This can certainly be done better for a particular machine
** architecture!
*/
-#define __GLX_PUT_DOUBLE(offset,a) \
- __GLX_MEM_COPY(pc + offset, &a, 8)
+#define __GLX_PUT_DOUBLE(offset,a) \
+ __GLX_MEM_COPY(pc + offset, &a, 8)
#else
-#define __GLX_PUT_DOUBLE(offset,a) \
- *((FLOAT64 *) (pc + offset)) = a
+#define __GLX_PUT_DOUBLE(offset,a) \
+ *((FLOAT64 *) (pc + offset)) = a
#endif
#endif
-#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \
- __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
+#define __GLX_PUT_CHAR_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT8)
#ifndef _CRAY
-#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
- __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT16)
-#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
- __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_INT32)
-#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
- __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT32)
-#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
- __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ __GLX_MEM_COPY(pc + offset, a, alen * __GLX_SIZE_FLOAT64)
#else
-#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
- gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
+#define __GLX_PUT_SHORT_ARRAY(offset,a,alen) \
+ gl_put_short_array((GLubyte *)(pc + offset), a, alen * __GLX_SIZE_INT16)
-#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
- gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
+#define __GLX_PUT_LONG_ARRAY(offset,a,alen) \
+ gl_put_long_array((GLubyte *)(pc + offset), (long *)a, alen * __GLX_SIZE_INT32)
-#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
- gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
+#define __GLX_PUT_FLOAT_ARRAY(offset,a,alen) \
+ gl_put_float_array((GLubyte *)(pc + offset), (float *)a, alen * __GLX_SIZE_FLOAT32)
-#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
- gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
+#define __GLX_PUT_DOUBLE_ARRAY(offset,a,alen) \
+ gl_put_double_array((GLubyte *)(pc + offset), (double *)a, alen * __GLX_SIZE_FLOAT64)
-extern gl_put_short_array (GLubyte *, short *, int);
-extern gl_put_long_array (GLubyte *, long *, int);
-extern gl_put_float_array (GLubyte *, float *, int);
-extern gl_put_double_array (GLubyte *, double *, int);
+extern gl_put_short_array(GLubyte *, short *, int);
+extern gl_put_long_array(GLubyte *, long *, int);
+extern gl_put_float_array(GLubyte *, float *, int);
+extern gl_put_double_array(GLubyte *, double *, int);
#endif /* _CRAY */
diff --git a/src/glx/x11/packsingle.h b/src/glx/x11/packsingle.h
index 9dbf8ec9141..1a4d321094e 100644
--- a/src/glx/x11/packsingle.h
+++ b/src/glx/x11/packsingle.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
#ifndef __GLX_packsingle_h__
#define __GLX_packsingle_h__
@@ -48,107 +49,107 @@
#define X_GLXSingle 0
/* Declare common variables used during a single command */
-#define __GLX_SINGLE_DECLARE_VARIABLES() \
- __GLXcontext *gc = __glXGetCurrentContext(); \
- GLubyte *pc, *pixelHeaderPC; \
- GLuint compsize, cmdlen; \
- Display *dpy = gc->currentDpy; \
- xGLXSingleReq *req
-
-#define __GLX_SINGLE_LOAD_VARIABLES() \
- pc = gc->pc; \
- /* Muffle compilers */ \
- pixelHeaderPC = 0; (void)pixelHeaderPC; \
- compsize = 0; (void)compsize; \
- cmdlen = 0; (void)cmdlen
+#define __GLX_SINGLE_DECLARE_VARIABLES() \
+ __GLXcontext *gc = __glXGetCurrentContext(); \
+ GLubyte *pc, *pixelHeaderPC; \
+ GLuint compsize, cmdlen; \
+ Display *dpy = gc->currentDpy; \
+ xGLXSingleReq *req
+
+#define __GLX_SINGLE_LOAD_VARIABLES() \
+ pc = gc->pc; \
+ /* Muffle compilers */ \
+ pixelHeaderPC = 0; (void)pixelHeaderPC; \
+ compsize = 0; (void)compsize; \
+ cmdlen = 0; (void)cmdlen
/* Start a single command */
-#define __GLX_SINGLE_BEGIN(opcode,bytes) \
- if (dpy) { \
- (void) __glXFlushRenderBuffer(gc, pc); \
- LockDisplay(dpy); \
- GetReqExtra(GLXSingle,bytes,req); \
- req->reqType = gc->majorOpcode; \
- req->glxCode = opcode; \
- req->contextTag = gc->currentContextTag; \
- pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
+#define __GLX_SINGLE_BEGIN(opcode,bytes) \
+ if (dpy) { \
+ (void) __glXFlushRenderBuffer(gc, pc); \
+ LockDisplay(dpy); \
+ GetReqExtra(GLXSingle,bytes,req); \
+ req->reqType = gc->majorOpcode; \
+ req->glxCode = opcode; \
+ req->contextTag = gc->currentContextTag; \
+ pc = ((GLubyte *)(req) + sz_xGLXSingleReq)
/* End a single command */
-#define __GLX_SINGLE_END() \
- UnlockDisplay(dpy); \
- SyncHandle(); \
- }
+#define __GLX_SINGLE_END() \
+ UnlockDisplay(dpy); \
+ SyncHandle(); \
+ }
/* Store data to sending for a single command */
-#define __GLX_SINGLE_PUT_CHAR(offset,a) \
- *((INT8 *) (pc + offset)) = a
+#define __GLX_SINGLE_PUT_CHAR(offset,a) \
+ *((INT8 *) (pc + offset)) = a
#ifndef CRAY
-#define __GLX_SINGLE_PUT_SHORT(offset,a) \
- *((INT16 *) (pc + offset)) = a
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ *((INT16 *) (pc + offset)) = a
-#define __GLX_SINGLE_PUT_LONG(offset,a) \
- *((INT32 *) (pc + offset)) = a
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ *((INT32 *) (pc + offset)) = a
-#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
- *((FLOAT32 *) (pc + offset)) = a
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ *((FLOAT32 *) (pc + offset)) = a
#else
-#define __GLX_SINGLE_PUT_SHORT(offset,a) \
- { GLubyte *cp = (pc+offset); \
- int shift = (64-16) - ((int)(cp) >> (64-6)); \
+#define __GLX_SINGLE_PUT_SHORT(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-16) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffff << shift)) | ((a & 0xffff) << shift); }
-#define __GLX_SINGLE_PUT_LONG(offset,a) \
- { GLubyte *cp = (pc+offset); \
- int shift = (64-32) - ((int)(cp) >> (64-6)); \
+#define __GLX_SINGLE_PUT_LONG(offset,a) \
+ { GLubyte *cp = (pc+offset); \
+ int shift = (64-32) - ((int)(cp) >> (64-6)); \
*(int *)cp = (*(int *)cp & ~(0xffffffff << shift)) | ((a & 0xffffffff) << shift); }
-#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
- gl_put_float(pc + offset, a)
+#define __GLX_SINGLE_PUT_FLOAT(offset,a) \
+ gl_put_float(pc + offset, a)
#endif
/* Read support macros */
-#define __GLX_SINGLE_READ_XREPLY() \
- (void) _XReply(dpy, (xReply*) &reply, 0, False)
+#define __GLX_SINGLE_READ_XREPLY() \
+ (void) _XReply(dpy, (xReply*) &reply, 0, False)
-#define __GLX_SINGLE_GET_RETVAL(a,cast) \
- a = (cast) reply.retval
+#define __GLX_SINGLE_GET_RETVAL(a,cast) \
+ a = (cast) reply.retval
-#define __GLX_SINGLE_GET_SIZE(a) \
- a = (GLint) reply.size
+#define __GLX_SINGLE_GET_SIZE(a) \
+ a = (GLint) reply.size
#ifndef _CRAY
-#define __GLX_SINGLE_GET_CHAR(p) \
- *p = *(GLbyte *)&reply.pad3;
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = *(GLbyte *)&reply.pad3;
-#define __GLX_SINGLE_GET_SHORT(p) \
- *p = *(GLshort *)&reply.pad3;
+#define __GLX_SINGLE_GET_SHORT(p) \
+ *p = *(GLshort *)&reply.pad3;
-#define __GLX_SINGLE_GET_LONG(p) \
- *p = *(GLint *)&reply.pad3;
+#define __GLX_SINGLE_GET_LONG(p) \
+ *p = *(GLint *)&reply.pad3;
-#define __GLX_SINGLE_GET_FLOAT(p) \
- *p = *(GLfloat *)&reply.pad3;
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = *(GLfloat *)&reply.pad3;
#else
-#define __GLX_SINGLE_GET_CHAR(p) \
- *p = reply.pad3 >> 24;
+#define __GLX_SINGLE_GET_CHAR(p) \
+ *p = reply.pad3 >> 24;
-#define __GLX_SINGLE_GET_SHORT(p) \
- {int t = reply.pad3 >> 16; \
- *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
+#define __GLX_SINGLE_GET_SHORT(p) \
+ {int t = reply.pad3 >> 16; \
+ *p = (t & 0x8000) ? (t | ~0xffff) : (t & 0xffff);}
-#define __GLX_SINGLE_GET_LONG(p) \
- {int t = reply.pad3; \
- *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
+#define __GLX_SINGLE_GET_LONG(p) \
+ {int t = reply.pad3; \
+ *p = (t & 0x80000000) ? (t | ~0xffffffff) : (t & 0xffffffff);}
#define PAD3OFFSET 16
-#define __GLX_SINGLE_GET_FLOAT(p) \
- *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
+#define __GLX_SINGLE_GET_FLOAT(p) \
+ *p = gl_ntoh_float((GLubyte *)&reply + PAD3OFFSET);
-#define __GLX_SINGLE_GET_DOUBLE(p) \
- *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = gl_ntoh_double((GLubyte *)&reply + PAD3OFFSET);
extern float gl_ntoh_float(GLubyte *);
extern float gl_ntoh_double(GLubyte *);
@@ -157,57 +158,57 @@ extern float gl_ntoh_double(GLubyte *);
#ifndef _CRAY
#ifdef __GLX_ALIGN64
-#define __GLX_SINGLE_GET_DOUBLE(p) \
- __GLX_MEM_COPY(p, &reply.pad3, 8)
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ __GLX_MEM_COPY(p, &reply.pad3, 8)
#else
-#define __GLX_SINGLE_GET_DOUBLE(p) \
- *p = *(GLdouble *)&reply.pad3
+#define __GLX_SINGLE_GET_DOUBLE(p) \
+ *p = *(GLdouble *)&reply.pad3
#endif
#endif
-
+
/* Get an array of typed data */
-#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
-{ \
- GLint slop = alen*__GLX_SIZE_INT8 & 3; \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
- if (slop) _XEatData(dpy,4-slop); \
-}
-
-#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
-{ \
- GLint slop = alen*__GLX_SIZE_INT8 & 3; \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
- if (slop) _XEatData(dpy,4-slop); \
-}
-
-
-#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
-{ \
- GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16);\
- if (slop) _XEatData(dpy,4-slop); \
-}
-
-#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
+#define __GLX_SINGLE_GET_VOID_ARRAY(a,alen) \
+ { \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+ }
+
+#define __GLX_SINGLE_GET_CHAR_ARRAY(a,alen) \
+ { \
+ GLint slop = alen*__GLX_SIZE_INT8 & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT8); \
+ if (slop) _XEatData(dpy,4-slop); \
+ }
+
+
+#define __GLX_SINGLE_GET_SHORT_ARRAY(a,alen) \
+ { \
+ GLint slop = (alen*__GLX_SIZE_INT16) & 3; \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT16); \
+ if (slop) _XEatData(dpy,4-slop); \
+ }
+
+#define __GLX_SINGLE_GET_LONG_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_INT32);
#ifndef _CRAY
-#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT32);
-#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
- _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ _XRead(dpy,(char *)a,alen*__GLX_SIZE_FLOAT64);
#else
-#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
- gl_get_float_array(dpy,a,alen);
+#define __GLX_SINGLE_GET_FLOAT_ARRAY(a,alen) \
+ gl_get_float_array(dpy,a,alen);
-#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
- gl_get_double_array(dpy, a, alen);
+#define __GLX_SINGLE_GET_DOUBLE_ARRAY(a,alen) \
+ gl_get_double_array(dpy, a, alen);
-extern void gl_get_float_array(Display *dpy, float *a, int alen);
-extern void gl_get_double_array(Display *dpy, double *a, int alen);
+extern void gl_get_float_array(Display * dpy, float *a, int alen);
+extern void gl_get_double_array(Display * dpy, double *a, int alen);
#endif
#endif /* !__GLX_packsingle_h__ */
diff --git a/src/glx/x11/pixel.c b/src/glx/x11/pixel.c
index 2174305b0c8..c5d3ca45218 100644
--- a/src/glx/x11/pixel.c
+++ b/src/glx/x11/pixel.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -31,46 +32,46 @@
#include "packrender.h"
static const GLubyte MsbToLsbTable[256] = {
- 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
- 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
- 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
- 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
- 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
- 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
- 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
- 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
- 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
- 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
- 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
- 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
- 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
- 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
- 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
- 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
- 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
- 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
- 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
- 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
- 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
- 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
- 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
- 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
- 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
- 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
- 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
- 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
- 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
- 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
- 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
- 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
};
static const GLubyte LowBitsMask[9] = {
- 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
+ 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff,
};
static const GLubyte HighBitsMask[9] = {
- 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
+ 0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff,
};
@@ -79,76 +80,80 @@ static const GLubyte HighBitsMask[9] = {
** data is transfered into the destImage buffer. Return in modes the
** set of pixel modes that are to be done by the server.
*/
-static void FillBitmap(__GLXcontext *gc, GLint width, GLint height,
- GLenum format, const GLvoid *userdata,
- GLubyte *destImage)
+static void
+FillBitmap(__GLXcontext * gc, GLint width, GLint height,
+ GLenum format, const GLvoid * userdata, GLubyte * destImage)
{
- const __GLXattribute * state = gc->client_state_private;
- GLint rowLength = state->storeUnpack.rowLength;
- GLint alignment = state->storeUnpack.alignment;
- GLint skipPixels = state->storeUnpack.skipPixels;
- GLint skipRows = state->storeUnpack.skipRows;
- GLint lsbFirst = state->storeUnpack.lsbFirst;
- GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
- GLint lowBitMask, i;
- GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
- const GLubyte *start, *iter;
+ const __GLXattribute *state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint lsbFirst = state->storeUnpack.lsbFirst;
+ GLint elementsLeft, bitOffset, currentByte, nextByte, highBitMask;
+ GLint lowBitMask, i;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ const GLubyte *start, *iter;
- if (rowLength > 0) {
- groupsPerRow = rowLength;
- } else {
- groupsPerRow = width;
- }
- components = __glElementsPerGroup(format,GL_BITMAP);
- rowSize = (groupsPerRow * components + 7) >> 3;
- padding = (rowSize % alignment);
- if (padding) {
- rowSize += alignment - padding;
- }
- start = ((const GLubyte*) userdata) + skipRows * rowSize +
- ((skipPixels * components) >> 3);
- bitOffset = (skipPixels * components) & 7;
- highBitMask = LowBitsMask[8-bitOffset];
- lowBitMask = HighBitsMask[bitOffset];
- elementsPerRow = width * components;
- for (i = 0; i < height; i++) {
- elementsLeft = elementsPerRow;
- iter = start;
- while (elementsLeft) {
- /* First retrieve low bits from current byte */
- if (lsbFirst) {
- currentByte = MsbToLsbTable[iter[0]];
- } else {
- currentByte = iter[0];
- }
- if (bitOffset) {
- /* Need to read next byte to finish current byte */
- if (elementsLeft > (8 - bitOffset)) {
- if (lsbFirst) {
- nextByte = MsbToLsbTable[iter[1]];
- } else {
- nextByte = iter[1];
- }
- currentByte =
- ((currentByte & highBitMask) << bitOffset) |
- ((nextByte & lowBitMask) >> (8 - bitOffset));
- } else {
- currentByte =
- ((currentByte & highBitMask) << bitOffset);
- }
- }
- if (elementsLeft >= 8) {
- *destImage = currentByte;
- elementsLeft -= 8;
- } else {
- *destImage = currentByte & HighBitsMask[elementsLeft];
- elementsLeft = 0;
- }
- destImage++;
- iter++;
- }
- start += rowSize;
- }
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ }
+ else {
+ groupsPerRow = width;
+ }
+ components = __glElementsPerGroup(format, GL_BITMAP);
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ start = ((const GLubyte *) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8 - bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ while (elementsLeft) {
+ /* First retrieve low bits from current byte */
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ }
+ else {
+ currentByte = iter[0];
+ }
+ if (bitOffset) {
+ /* Need to read next byte to finish current byte */
+ if (elementsLeft > (8 - bitOffset)) {
+ if (lsbFirst) {
+ nextByte = MsbToLsbTable[iter[1]];
+ }
+ else {
+ nextByte = iter[1];
+ }
+ currentByte =
+ ((currentByte & highBitMask) << bitOffset) |
+ ((nextByte & lowBitMask) >> (8 - bitOffset));
+ }
+ else {
+ currentByte = ((currentByte & highBitMask) << bitOffset);
+ }
+ }
+ if (elementsLeft >= 8) {
+ *destImage = currentByte;
+ elementsLeft -= 8;
+ }
+ else {
+ *destImage = currentByte & HighBitsMask[elementsLeft];
+ elementsLeft = 0;
+ }
+ destImage++;
+ iter++;
+ }
+ start += rowSize;
+ }
}
/*
@@ -156,209 +161,224 @@ static void FillBitmap(__GLXcontext *gc, GLint width, GLint height,
** The internal packed array format used has LSB_FIRST = FALSE and
** ALIGNMENT = 1.
*/
-void __glFillImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
- GLint depth, GLenum format, GLenum type,
- const GLvoid *userdata, GLubyte *newimage, GLubyte *modes)
+void
+__glFillImage(__GLXcontext * gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLvoid * userdata, GLubyte * newimage, GLubyte * modes)
{
- const __GLXattribute * state = gc->client_state_private;
- GLint rowLength = state->storeUnpack.rowLength;
- GLint imageHeight = state->storeUnpack.imageHeight;
- GLint alignment = state->storeUnpack.alignment;
- GLint skipPixels = state->storeUnpack.skipPixels;
- GLint skipRows = state->storeUnpack.skipRows;
- GLint skipImages = state->storeUnpack.skipImages;
- GLint swapBytes = state->storeUnpack.swapEndian;
- GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
- GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
- const GLubyte *start, *iter, *itera, *iterb, *iterc;
- GLubyte *iter2;
+ const __GLXattribute *state = gc->client_state_private;
+ GLint rowLength = state->storeUnpack.rowLength;
+ GLint imageHeight = state->storeUnpack.imageHeight;
+ GLint alignment = state->storeUnpack.alignment;
+ GLint skipPixels = state->storeUnpack.skipPixels;
+ GLint skipRows = state->storeUnpack.skipRows;
+ GLint skipImages = state->storeUnpack.skipImages;
+ GLint swapBytes = state->storeUnpack.swapEndian;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, imageSize, rowsPerImage, h, i, j, k;
+ const GLubyte *start, *iter, *itera, *iterb, *iterc;
+ GLubyte *iter2;
- if (type == GL_BITMAP) {
- FillBitmap(gc, width, height, format, userdata, newimage);
- } else {
- components = __glElementsPerGroup(format,type);
- if (rowLength > 0) {
- groupsPerRow = rowLength;
- } else {
- groupsPerRow = width;
- }
- if (imageHeight > 0) {
- rowsPerImage = imageHeight;
- } else {
- rowsPerImage = height;
- }
+ if (type == GL_BITMAP) {
+ FillBitmap(gc, width, height, format, userdata, newimage);
+ }
+ else {
+ components = __glElementsPerGroup(format, type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ }
+ else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ }
+ else {
+ rowsPerImage = height;
+ }
- elementSize = __glBytesPerElement(type);
- groupSize = elementSize * components;
- if (elementSize == 1) swapBytes = 0;
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ if (elementSize == 1)
+ swapBytes = 0;
- rowSize = groupsPerRow * groupSize;
- padding = (rowSize % alignment);
- if (padding) {
- rowSize += alignment - padding;
- }
- imageSize = rowSize * rowsPerImage;
- start = ((const GLubyte*) userdata) + skipImages * imageSize +
- skipRows * rowSize + skipPixels * groupSize;
- iter2 = newimage;
- elementsPerRow = width * components;
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ imageSize = rowSize * rowsPerImage;
+ start = ((const GLubyte *) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ iter2 = newimage;
+ elementsPerRow = width * components;
- if (swapBytes) {
- itera = start;
- for (h = 0; h < depth; h++) {
- iterb = itera;
- for (i = 0; i < height; i++) {
- iterc = iterb;
- for (j = 0; j < elementsPerRow; j++) {
- for (k = 1; k <= elementSize; k++) {
- iter2[k-1] = iterc[elementSize - k];
- }
- iter2 += elementSize;
- iterc += elementSize;
- }
- iterb += rowSize;
- }
- itera += imageSize;
- }
- } else {
- itera = start;
- for (h = 0; h < depth; h++) {
- if (rowSize == elementsPerRow * elementSize) {
- /* Ha! This is mondo easy! */
- __GLX_MEM_COPY(iter2, itera,
- elementsPerRow * elementSize * height);
- iter2 += elementsPerRow * elementSize * height;
- } else {
- iter = itera;
- for (i = 0; i < height; i++) {
- __GLX_MEM_COPY(iter2, iter, elementsPerRow*elementSize);
- iter2 += elementsPerRow * elementSize;
- iter += rowSize;
- }
- }
- itera += imageSize;
- }
- }
- }
+ if (swapBytes) {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ iterb = itera;
+ for (i = 0; i < height; i++) {
+ iterc = iterb;
+ for (j = 0; j < elementsPerRow; j++) {
+ for (k = 1; k <= elementSize; k++) {
+ iter2[k - 1] = iterc[elementSize - k];
+ }
+ iter2 += elementSize;
+ iterc += elementSize;
+ }
+ iterb += rowSize;
+ }
+ itera += imageSize;
+ }
+ }
+ else {
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if (rowSize == elementsPerRow * elementSize) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(iter2, itera,
+ elementsPerRow * elementSize * height);
+ iter2 += elementsPerRow * elementSize * height;
+ }
+ else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter2, iter, elementsPerRow * elementSize);
+ iter2 += elementsPerRow * elementSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
+ }
- /* Setup store modes that describe what we just did */
- if (modes) {
- if ( dim < 3 ) {
- (void) memcpy( modes, __glXDefaultPixelStore + 4, 20 );
- }
- else {
- (void) memcpy( modes, __glXDefaultPixelStore + 0, 36 );
- }
- }
+ /* Setup store modes that describe what we just did */
+ if (modes) {
+ if (dim < 3) {
+ (void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
+ }
+ else {
+ (void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
+ }
+ }
}
/*
** Empty a bitmap in LSB_FIRST=GL_FALSE and ALIGNMENT=4 format packing it
** into the clients memory using the pixel store PACK modes.
*/
-static void EmptyBitmap(__GLXcontext *gc, GLint width, GLint height,
- GLenum format, const GLubyte *sourceImage,
- GLvoid *userdata)
+static void
+EmptyBitmap(__GLXcontext * gc, GLint width, GLint height,
+ GLenum format, const GLubyte * sourceImage, GLvoid * userdata)
{
- const __GLXattribute * state = gc->client_state_private;
- GLint rowLength = state->storePack.rowLength;
- GLint alignment = state->storePack.alignment;
- GLint skipPixels = state->storePack.skipPixels;
- GLint skipRows = state->storePack.skipRows;
- GLint lsbFirst = state->storePack.lsbFirst;
- GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
- GLint sourceRowSize, sourcePadding, sourceSkip;
- GLubyte *start, *iter;
- GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
- GLint writeMask, i;
- GLubyte writeByte;
+ const __GLXattribute *state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint lsbFirst = state->storePack.lsbFirst;
+ GLint components, groupsPerRow, rowSize, padding, elementsPerRow;
+ GLint sourceRowSize, sourcePadding, sourceSkip;
+ GLubyte *start, *iter;
+ GLint elementsLeft, bitOffset, currentByte, highBitMask, lowBitMask;
+ GLint writeMask, i;
+ GLubyte writeByte;
- components = __glElementsPerGroup(format,GL_BITMAP);
- if (rowLength > 0) {
- groupsPerRow = rowLength;
- } else {
- groupsPerRow = width;
- }
+ components = __glElementsPerGroup(format, GL_BITMAP);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ }
+ else {
+ groupsPerRow = width;
+ }
- rowSize = (groupsPerRow * components + 7) >> 3;
- padding = (rowSize % alignment);
- if (padding) {
- rowSize += alignment - padding;
- }
- sourceRowSize = (width * components + 7) >> 3;
- sourcePadding = (sourceRowSize % 4);
- if (sourcePadding) {
- sourceSkip = 4 - sourcePadding;
- } else {
- sourceSkip = 0;
- }
- start = ((GLubyte*) userdata) + skipRows * rowSize +
- ((skipPixels * components) >> 3);
- bitOffset = (skipPixels * components) & 7;
- highBitMask = LowBitsMask[8-bitOffset];
- lowBitMask = HighBitsMask[bitOffset];
- elementsPerRow = width * components;
- for (i = 0; i < height; i++) {
- elementsLeft = elementsPerRow;
- iter = start;
- writeMask = highBitMask;
- writeByte = 0;
- while (elementsLeft) {
- /* Set up writeMask (to write to current byte) */
- if (elementsLeft + bitOffset < 8) {
- /* Need to trim writeMask */
- writeMask &= HighBitsMask[bitOffset+elementsLeft];
- }
+ rowSize = (groupsPerRow * components + 7) >> 3;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = (width * components + 7) >> 3;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceSkip = 4 - sourcePadding;
+ }
+ else {
+ sourceSkip = 0;
+ }
+ start = ((GLubyte *) userdata) + skipRows * rowSize +
+ ((skipPixels * components) >> 3);
+ bitOffset = (skipPixels * components) & 7;
+ highBitMask = LowBitsMask[8 - bitOffset];
+ lowBitMask = HighBitsMask[bitOffset];
+ elementsPerRow = width * components;
+ for (i = 0; i < height; i++) {
+ elementsLeft = elementsPerRow;
+ iter = start;
+ writeMask = highBitMask;
+ writeByte = 0;
+ while (elementsLeft) {
+ /* Set up writeMask (to write to current byte) */
+ if (elementsLeft + bitOffset < 8) {
+ /* Need to trim writeMask */
+ writeMask &= HighBitsMask[bitOffset + elementsLeft];
+ }
- if (lsbFirst) {
- currentByte = MsbToLsbTable[iter[0]];
- } else {
- currentByte = iter[0];
- }
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ }
+ else {
+ currentByte = iter[0];
+ }
- if (bitOffset) {
- writeByte |= (sourceImage[0] >> bitOffset);
- currentByte = (currentByte & ~writeMask) |
- (writeByte & writeMask);
- writeByte = (sourceImage[0] << (8 - bitOffset));
- } else {
- currentByte = (currentByte & ~writeMask) |
- (sourceImage[0] & writeMask);
- }
+ if (bitOffset) {
+ writeByte |= (sourceImage[0] >> bitOffset);
+ currentByte = (currentByte & ~writeMask) |
+ (writeByte & writeMask);
+ writeByte = (sourceImage[0] << (8 - bitOffset));
+ }
+ else {
+ currentByte = (currentByte & ~writeMask) |
+ (sourceImage[0] & writeMask);
+ }
- if (lsbFirst) {
- iter[0] = MsbToLsbTable[currentByte];
- } else {
- iter[0] = currentByte;
- }
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ }
+ else {
+ iter[0] = currentByte;
+ }
- if (elementsLeft >= 8) {
- elementsLeft -= 8;
- } else {
- elementsLeft = 0;
- }
- sourceImage++;
- iter++;
- writeMask = 0xff;
- }
- if (writeByte) {
- /* Some data left over that still needs writing */
- writeMask &= lowBitMask;
- if (lsbFirst) {
- currentByte = MsbToLsbTable[iter[0]];
- } else {
- currentByte = iter[0];
- }
- currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
- if (lsbFirst) {
- iter[0] = MsbToLsbTable[currentByte];
- } else {
- iter[0] = currentByte;
- }
- }
- start += rowSize;
- sourceImage += sourceSkip;
- }
+ if (elementsLeft >= 8) {
+ elementsLeft -= 8;
+ }
+ else {
+ elementsLeft = 0;
+ }
+ sourceImage++;
+ iter++;
+ writeMask = 0xff;
+ }
+ if (writeByte) {
+ /* Some data left over that still needs writing */
+ writeMask &= lowBitMask;
+ if (lsbFirst) {
+ currentByte = MsbToLsbTable[iter[0]];
+ }
+ else {
+ currentByte = iter[0];
+ }
+ currentByte = (currentByte & ~writeMask) | (writeByte & writeMask);
+ if (lsbFirst) {
+ iter[0] = MsbToLsbTable[currentByte];
+ }
+ else {
+ iter[0] = currentByte;
+ }
+ }
+ start += rowSize;
+ sourceImage += sourceSkip;
+ }
}
/*
@@ -368,70 +388,75 @@ static void EmptyBitmap(__GLXcontext *gc, GLint width, GLint height,
** Named __glEmptyImage() because it is the opposite of __glFillImage().
*/
/* ARGSUSED */
-void __glEmptyImage(__GLXcontext *gc, GLint dim, GLint width, GLint height,
- GLint depth, GLenum format, GLenum type,
- const GLubyte *sourceImage, GLvoid *userdata)
+void
+__glEmptyImage(__GLXcontext * gc, GLint dim, GLint width, GLint height,
+ GLint depth, GLenum format, GLenum type,
+ const GLubyte * sourceImage, GLvoid * userdata)
{
- const __GLXattribute * state = gc->client_state_private;
- GLint rowLength = state->storePack.rowLength;
- GLint imageHeight = state->storePack.imageHeight;
- GLint alignment = state->storePack.alignment;
- GLint skipPixels = state->storePack.skipPixels;
- GLint skipRows = state->storePack.skipRows;
- GLint skipImages = state->storePack.skipImages;
- GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
- GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
- GLint imageSize, rowsPerImage;
- GLubyte *start, *iter, *itera;
+ const __GLXattribute *state = gc->client_state_private;
+ GLint rowLength = state->storePack.rowLength;
+ GLint imageHeight = state->storePack.imageHeight;
+ GLint alignment = state->storePack.alignment;
+ GLint skipPixels = state->storePack.skipPixels;
+ GLint skipRows = state->storePack.skipRows;
+ GLint skipImages = state->storePack.skipImages;
+ GLint components, elementSize, rowSize, padding, groupsPerRow, groupSize;
+ GLint elementsPerRow, sourceRowSize, sourcePadding, h, i;
+ GLint imageSize, rowsPerImage;
+ GLubyte *start, *iter, *itera;
- if (type == GL_BITMAP) {
- EmptyBitmap(gc, width, height, format, sourceImage, userdata);
- } else {
- components = __glElementsPerGroup(format,type);
- if (rowLength > 0) {
- groupsPerRow = rowLength;
- } else {
- groupsPerRow = width;
- }
- if (imageHeight > 0) {
- rowsPerImage = imageHeight;
- } else {
- rowsPerImage = height;
- }
- elementSize = __glBytesPerElement(type);
- groupSize = elementSize * components;
- rowSize = groupsPerRow * groupSize;
- padding = (rowSize % alignment);
- if (padding) {
- rowSize += alignment - padding;
- }
- sourceRowSize = width * groupSize;
- sourcePadding = (sourceRowSize % 4);
- if (sourcePadding) {
- sourceRowSize += 4 - sourcePadding;
- }
- imageSize = sourceRowSize * rowsPerImage;
- start = ((GLubyte*) userdata) + skipImages * imageSize +
- skipRows * rowSize + skipPixels * groupSize;
- elementsPerRow = width * components;
+ if (type == GL_BITMAP) {
+ EmptyBitmap(gc, width, height, format, sourceImage, userdata);
+ }
+ else {
+ components = __glElementsPerGroup(format, type);
+ if (rowLength > 0) {
+ groupsPerRow = rowLength;
+ }
+ else {
+ groupsPerRow = width;
+ }
+ if (imageHeight > 0) {
+ rowsPerImage = imageHeight;
+ }
+ else {
+ rowsPerImage = height;
+ }
+ elementSize = __glBytesPerElement(type);
+ groupSize = elementSize * components;
+ rowSize = groupsPerRow * groupSize;
+ padding = (rowSize % alignment);
+ if (padding) {
+ rowSize += alignment - padding;
+ }
+ sourceRowSize = width * groupSize;
+ sourcePadding = (sourceRowSize % 4);
+ if (sourcePadding) {
+ sourceRowSize += 4 - sourcePadding;
+ }
+ imageSize = sourceRowSize * rowsPerImage;
+ start = ((GLubyte *) userdata) + skipImages * imageSize +
+ skipRows * rowSize + skipPixels * groupSize;
+ elementsPerRow = width * components;
- itera = start;
- for (h = 0; h < depth; h++) {
- if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
- /* Ha! This is mondo easy! */
- __GLX_MEM_COPY(itera, sourceImage,
- elementsPerRow * elementSize * height);
- sourceImage += elementsPerRow * elementSize * height;
- } else {
- iter = itera;
- for (i = 0; i < height; i++) {
- __GLX_MEM_COPY(iter, sourceImage,
- elementsPerRow * elementSize);
- sourceImage += sourceRowSize;
- iter += rowSize;
- }
- }
- itera += imageSize;
- }
- }
+ itera = start;
+ for (h = 0; h < depth; h++) {
+ if ((rowSize == sourceRowSize) && (sourcePadding == 0)) {
+ /* Ha! This is mondo easy! */
+ __GLX_MEM_COPY(itera, sourceImage,
+ elementsPerRow * elementSize * height);
+ sourceImage += elementsPerRow * elementSize * height;
+ }
+ else {
+ iter = itera;
+ for (i = 0; i < height; i++) {
+ __GLX_MEM_COPY(iter, sourceImage,
+ elementsPerRow * elementSize);
+ sourceImage += sourceRowSize;
+ iter += rowSize;
+ }
+ }
+ itera += imageSize;
+ }
+ }
}
diff --git a/src/glx/x11/pixelstore.c b/src/glx/x11/pixelstore.c
index 0bc16854aed..e6bed20a495 100644
--- a/src/glx/x11/pixelstore.c
+++ b/src/glx/x11/pixelstore.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -42,148 +43,157 @@
* \sa __indirect_glPixelStorei, __indirect_glPixelStoref
*/
static void
-send_PixelStore( __GLXcontext * gc, unsigned sop, GLenum pname,
- const void * param )
+send_PixelStore(__GLXcontext * gc, unsigned sop, GLenum pname,
+ const void *param)
{
- Display * const dpy = gc->currentDpy;
- const GLuint cmdlen = 8;
- if (__builtin_expect(dpy != NULL, 1)) {
- GLubyte const * pc = __glXSetupSingleRequest(gc, sop, cmdlen);
- (void) memcpy((void *)(pc + 0), (void *)(&pname), 4);
- (void) memcpy((void *)(pc + 4), param, 4);
- UnlockDisplay(dpy); SyncHandle();
- }
- return;
+ Display *const dpy = gc->currentDpy;
+ const GLuint cmdlen = 8;
+ if (__builtin_expect(dpy != NULL, 1)) {
+ GLubyte const *pc = __glXSetupSingleRequest(gc, sop, cmdlen);
+ (void) memcpy((void *) (pc + 0), (void *) (&pname), 4);
+ (void) memcpy((void *) (pc + 4), param, 4);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ return;
}
/*
** Specify parameters that control the storage format of pixel arrays.
*/
-void __indirect_glPixelStoref(GLenum pname, GLfloat param)
+void
+__indirect_glPixelStoref(GLenum pname, GLfloat param)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = gc->client_state_private;
- Display *dpy = gc->currentDpy;
- GLuint a;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
+ GLuint a;
- if (!dpy) return;
+ if (!dpy)
+ return;
- switch (pname) {
- case GL_PACK_ROW_LENGTH:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.rowLength = a;
- break;
- case GL_PACK_IMAGE_HEIGHT:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.imageHeight = a;
- break;
- case GL_PACK_SKIP_ROWS:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipRows = a;
- break;
- case GL_PACK_SKIP_PIXELS:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipPixels = a;
- break;
- case GL_PACK_SKIP_IMAGES:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipImages = a;
- break;
- case GL_PACK_ALIGNMENT:
- a = (GLint) (param + 0.5);
- switch (a) {
- case 1: case 2: case 4: case 8:
- state->storePack.alignment = a;
- break;
- default:
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- break;
- case GL_PACK_SWAP_BYTES:
- state->storePack.swapEndian = (param != 0);
- break;
- case GL_PACK_LSB_FIRST:
- state->storePack.lsbFirst = (param != 0);
- break;
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = a;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = a;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = a;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = a;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = a;
+ break;
+ case GL_PACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ state->storePack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
- case GL_UNPACK_ROW_LENGTH:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.rowLength = a;
- break;
- case GL_UNPACK_IMAGE_HEIGHT:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.imageHeight = a;
- break;
- case GL_UNPACK_SKIP_ROWS:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipRows = a;
- break;
- case GL_UNPACK_SKIP_PIXELS:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipPixels = a;
- break;
- case GL_UNPACK_SKIP_IMAGES:
- a = (GLuint) (param + 0.5);
- if (((GLint) a) < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipImages = a;
- break;
- case GL_UNPACK_ALIGNMENT:
- a = (GLint) (param + 0.5);
- switch (a) {
- case 1: case 2: case 4: case 8:
- state->storeUnpack.alignment = a;
- break;
- default:
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- break;
- case GL_UNPACK_SWAP_BYTES:
- state->storeUnpack.swapEndian = (param != 0);
- break;
- case GL_UNPACK_LSB_FIRST:
- state->storeUnpack.lsbFirst = (param != 0);
- break;
+ case GL_UNPACK_ROW_LENGTH:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = a;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = a;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = a;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = a;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ a = (GLuint) (param + 0.5);
+ if (((GLint) a) < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = a;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ a = (GLint) (param + 0.5);
+ switch (a) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ state->storeUnpack.alignment = a;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
/* Group all of the pixel store modes that need to be sent to the
* server here. Care must be used to only send modes to the server that
@@ -191,128 +201,136 @@ void __indirect_glPixelStoref(GLenum pname, GLfloat param)
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
* future modes may not be.
*/
- case GL_PACK_INVERT_MESA:
- send_PixelStore( gc, X_GLsop_PixelStoref, pname, & param );
- break;
+ case GL_PACK_INVERT_MESA:
+ send_PixelStore(gc, X_GLsop_PixelStoref, pname, &param);
+ break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- break;
- }
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
}
-void __indirect_glPixelStorei(GLenum pname, GLint param)
+void
+__indirect_glPixelStorei(GLenum pname, GLint param)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = gc->client_state_private;
- Display *dpy = gc->currentDpy;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = gc->client_state_private;
+ Display *dpy = gc->currentDpy;
- if (!dpy) return;
+ if (!dpy)
+ return;
- switch (pname) {
- case GL_PACK_ROW_LENGTH:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.rowLength = param;
- break;
- case GL_PACK_IMAGE_HEIGHT:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.imageHeight = param;
- break;
- case GL_PACK_SKIP_ROWS:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipRows = param;
- break;
- case GL_PACK_SKIP_PIXELS:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipPixels = param;
- break;
- case GL_PACK_SKIP_IMAGES:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storePack.skipImages = param;
- break;
- case GL_PACK_ALIGNMENT:
- switch (param) {
- case 1: case 2: case 4: case 8:
- state->storePack.alignment = param;
- break;
- default:
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- break;
- case GL_PACK_SWAP_BYTES:
- state->storePack.swapEndian = (param != 0);
- break;
- case GL_PACK_LSB_FIRST:
- state->storePack.lsbFirst = (param != 0);
- break;
+ switch (pname) {
+ case GL_PACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.rowLength = param;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.imageHeight = param;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipRows = param;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipPixels = param;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storePack.skipImages = param;
+ break;
+ case GL_PACK_ALIGNMENT:
+ switch (param) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ state->storePack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_PACK_SWAP_BYTES:
+ state->storePack.swapEndian = (param != 0);
+ break;
+ case GL_PACK_LSB_FIRST:
+ state->storePack.lsbFirst = (param != 0);
+ break;
- case GL_UNPACK_ROW_LENGTH:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.rowLength = param;
- break;
- case GL_UNPACK_IMAGE_HEIGHT:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.imageHeight = param;
- break;
- case GL_UNPACK_SKIP_ROWS:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipRows = param;
- break;
- case GL_UNPACK_SKIP_PIXELS:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipPixels = param;
- break;
- case GL_UNPACK_SKIP_IMAGES:
- if (param < 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- state->storeUnpack.skipImages = param;
- break;
- case GL_UNPACK_ALIGNMENT:
- switch (param) {
- case 1: case 2: case 4: case 8:
- state->storeUnpack.alignment = param;
- break;
- default:
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- break;
- case GL_UNPACK_SWAP_BYTES:
- state->storeUnpack.swapEndian = (param != 0);
- break;
- case GL_UNPACK_LSB_FIRST:
- state->storeUnpack.lsbFirst = (param != 0);
- break;
+ case GL_UNPACK_ROW_LENGTH:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.rowLength = param;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.imageHeight = param;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipRows = param;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipPixels = param;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ if (param < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ state->storeUnpack.skipImages = param;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ switch (param) {
+ case 1:
+ case 2:
+ case 4:
+ case 8:
+ state->storeUnpack.alignment = param;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ state->storeUnpack.swapEndian = (param != 0);
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ state->storeUnpack.lsbFirst = (param != 0);
+ break;
/* Group all of the pixel store modes that need to be sent to the
* server here. Care must be used to only send modes to the server that
@@ -320,12 +338,12 @@ void __indirect_glPixelStorei(GLenum pname, GLint param)
* server. GL_PACK_INVERT_MESA is safe in this respect, but other,
* future modes may not be.
*/
- case GL_PACK_INVERT_MESA:
- send_PixelStore( gc, X_GLsop_PixelStorei, pname, & param );
- break;
+ case GL_PACK_INVERT_MESA:
+ send_PixelStore(gc, X_GLsop_PixelStorei, pname, &param);
+ break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- break;
- }
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ break;
+ }
}
diff --git a/src/glx/x11/render2.c b/src/glx/x11/render2.c
index 025becbd197..f1740bcffb2 100644
--- a/src/glx/x11/render2.c
+++ b/src/glx/x11/render2.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -38,320 +39,344 @@
** use the pixel header. See renderpix.c for those routines.
*/
-void __indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
- GLint order, const GLdouble *pnts)
+void
+__indirect_glMap1d(GLenum target, GLdouble u1, GLdouble u2, GLint stride,
+ GLint order, const GLdouble * pnts)
{
- __GLX_DECLARE_VARIABLES();
- GLint k;
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
- __GLX_LOAD_VARIABLES();
- k = __glMap1d_size(target);
- if (k == 0) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- } else if (stride < k || order <= 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- compsize = k * order * __GLX_SIZE_FLOAT64;
- cmdlen = 28+compsize;
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ k = __glMap1d_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT64;
+ cmdlen = 28 + compsize;
+ if (!gc->currentDpy)
+ return;
- if (cmdlen <= gc->maxSmallRenderCommandSize) {
- /* Use GLXRender protocol to send small command */
- __GLX_BEGIN_VARIABLE(X_GLrop_Map1d,cmdlen);
- __GLX_PUT_DOUBLE(4,u1);
- __GLX_PUT_DOUBLE(12,u2);
- __GLX_PUT_LONG(20,target);
- __GLX_PUT_LONG(24,order);
- /*
- ** NOTE: the doubles that follow are not aligned because of 3
- ** longs preceeding
- */
- __glFillMap1d(k, order, stride, pnts, (pc+28));
- __GLX_END(cmdlen);
- } else {
- /* Use GLXRenderLarge protocol to send command */
- __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d,cmdlen+4);
- __GLX_PUT_DOUBLE(8,u1);
- __GLX_PUT_DOUBLE(16,u2);
- __GLX_PUT_LONG(24,target);
- __GLX_PUT_LONG(28,order);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1d, cmdlen);
+ __GLX_PUT_DOUBLE(4, u1);
+ __GLX_PUT_DOUBLE(12, u2);
+ __GLX_PUT_LONG(20, target);
+ __GLX_PUT_LONG(24, order);
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ __glFillMap1d(k, order, stride, pnts, (pc + 28));
+ __GLX_END(cmdlen);
+ }
+ else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1d, cmdlen + 4);
+ __GLX_PUT_DOUBLE(8, u1);
+ __GLX_PUT_DOUBLE(16, u2);
+ __GLX_PUT_LONG(24, target);
+ __GLX_PUT_LONG(28, order);
- /*
- ** NOTE: the doubles that follow are not aligned because of 3
- ** longs preceeding
- */
- if (stride != k) {
- GLubyte *buf;
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 3
+ ** longs preceeding
+ */
+ if (stride != k) {
+ GLubyte *buf;
- buf = (GLubyte *) Xmalloc(compsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
- __glFillMap1d(k, order, stride, pnts, buf);
- __glXSendLargeCommand(gc, pc, 32, buf, compsize);
- Xfree((char*) buf);
- } else {
- /* Data is already packed. Just send it out */
- __glXSendLargeCommand(gc, pc, 32, pnts, compsize);
- }
- }
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1d(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 32, buf, compsize);
+ Xfree((char *) buf);
+ }
+ else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 32, pnts, compsize);
+ }
+ }
}
-void __indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
- GLint order, const GLfloat *pnts)
+void
+__indirect_glMap1f(GLenum target, GLfloat u1, GLfloat u2, GLint stride,
+ GLint order, const GLfloat * pnts)
{
- __GLX_DECLARE_VARIABLES();
- GLint k;
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
- __GLX_LOAD_VARIABLES();
- k = __glMap1f_size(target);
- if (k == 0) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- } else if (stride < k || order <= 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- compsize = k * order * __GLX_SIZE_FLOAT32;
- cmdlen = 20+compsize;
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ k = __glMap1f_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ else if (stride < k || order <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * order * __GLX_SIZE_FLOAT32;
+ cmdlen = 20 + compsize;
+ if (!gc->currentDpy)
+ return;
- /*
+ /*
** The order that arguments are packed is different from the order
** for glMap1d.
*/
- if (cmdlen <= gc->maxSmallRenderCommandSize) {
- /* Use GLXRender protocol to send small command */
- __GLX_BEGIN_VARIABLE(X_GLrop_Map1f,cmdlen);
- __GLX_PUT_LONG(4,target);
- __GLX_PUT_FLOAT(8,u1);
- __GLX_PUT_FLOAT(12,u2);
- __GLX_PUT_LONG(16,order);
- __glFillMap1f(k, order, stride, pnts, (GLubyte*) (pc+20));
- __GLX_END(cmdlen);
- } else {
- /* Use GLXRenderLarge protocol to send command */
- __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f,cmdlen+4);
- __GLX_PUT_LONG(8,target);
- __GLX_PUT_FLOAT(12,u1);
- __GLX_PUT_FLOAT(16,u2);
- __GLX_PUT_LONG(20,order);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map1f, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_FLOAT(8, u1);
+ __GLX_PUT_FLOAT(12, u2);
+ __GLX_PUT_LONG(16, order);
+ __glFillMap1f(k, order, stride, pnts, (GLubyte *) (pc + 20));
+ __GLX_END(cmdlen);
+ }
+ else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map1f, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_FLOAT(12, u1);
+ __GLX_PUT_FLOAT(16, u2);
+ __GLX_PUT_LONG(20, order);
- if (stride != k) {
- GLubyte *buf;
+ if (stride != k) {
+ GLubyte *buf;
- buf = (GLubyte *) Xmalloc(compsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
- __glFillMap1f(k, order, stride, pnts, buf);
- __glXSendLargeCommand(gc, pc, 24, buf, compsize);
- Xfree((char*) buf);
- } else {
- /* Data is already packed. Just send it out */
- __glXSendLargeCommand(gc, pc, 24, pnts, compsize);
- }
- }
+ buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ __glFillMap1f(k, order, stride, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 24, buf, compsize);
+ Xfree((char *) buf);
+ }
+ else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 24, pnts, compsize);
+ }
+ }
}
-void __indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr, GLint uord,
- GLdouble v1, GLdouble v2, GLint vstr, GLint vord,
- const GLdouble *pnts)
+void
+__indirect_glMap2d(GLenum target, GLdouble u1, GLdouble u2, GLint ustr,
+ GLint uord, GLdouble v1, GLdouble v2, GLint vstr,
+ GLint vord, const GLdouble * pnts)
{
- __GLX_DECLARE_VARIABLES();
- GLint k;
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
- __GLX_LOAD_VARIABLES();
- k = __glMap2d_size(target);
- if (k == 0) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- compsize = k * uord * vord * __GLX_SIZE_FLOAT64;
- cmdlen = 48+compsize;
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ k = __glMap2d_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT64;
+ cmdlen = 48 + compsize;
+ if (!gc->currentDpy)
+ return;
- if (cmdlen <= gc->maxSmallRenderCommandSize) {
- /* Use GLXRender protocol to send small command */
- __GLX_BEGIN_VARIABLE(X_GLrop_Map2d,cmdlen);
- __GLX_PUT_DOUBLE(4,u1);
- __GLX_PUT_DOUBLE(12,u2);
- __GLX_PUT_DOUBLE(20,v1);
- __GLX_PUT_DOUBLE(28,v2);
- __GLX_PUT_LONG(36,target);
- __GLX_PUT_LONG(40,uord);
- __GLX_PUT_LONG(44,vord);
- /*
- ** Pack into a u-major ordering.
- ** NOTE: the doubles that follow are not aligned because of 5
- ** longs preceeding
- */
- __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble*) (pc+48));
- __GLX_END(cmdlen);
- } else {
- /* Use GLXRenderLarge protocol to send command */
- __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d,cmdlen+4);
- __GLX_PUT_DOUBLE(8,u1);
- __GLX_PUT_DOUBLE(16,u2);
- __GLX_PUT_DOUBLE(24,v1);
- __GLX_PUT_DOUBLE(32,v2);
- __GLX_PUT_LONG(40,target);
- __GLX_PUT_LONG(44,uord);
- __GLX_PUT_LONG(48,vord);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2d, cmdlen);
+ __GLX_PUT_DOUBLE(4, u1);
+ __GLX_PUT_DOUBLE(12, u2);
+ __GLX_PUT_DOUBLE(20, v1);
+ __GLX_PUT_DOUBLE(28, v2);
+ __GLX_PUT_LONG(36, target);
+ __GLX_PUT_LONG(40, uord);
+ __GLX_PUT_LONG(44, vord);
+ /*
+ ** Pack into a u-major ordering.
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, (GLdouble *) (pc + 48));
+ __GLX_END(cmdlen);
+ }
+ else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2d, cmdlen + 4);
+ __GLX_PUT_DOUBLE(8, u1);
+ __GLX_PUT_DOUBLE(16, u2);
+ __GLX_PUT_DOUBLE(24, v1);
+ __GLX_PUT_DOUBLE(32, v2);
+ __GLX_PUT_LONG(40, target);
+ __GLX_PUT_LONG(44, uord);
+ __GLX_PUT_LONG(48, vord);
- /*
- ** NOTE: the doubles that follow are not aligned because of 5
- ** longs preceeding
- */
- if ((vstr != k) || (ustr != k*vord)) {
- GLdouble *buf;
+ /*
+ ** NOTE: the doubles that follow are not aligned because of 5
+ ** longs preceeding
+ */
+ if ((vstr != k) || (ustr != k * vord)) {
+ GLdouble *buf;
- buf = (GLdouble *) Xmalloc(compsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
- /*
- ** Pack into a u-major ordering.
- */
- __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
- __glXSendLargeCommand(gc, pc, 52, buf, compsize);
- Xfree((char*) buf);
- } else {
- /* Data is already packed. Just send it out */
- __glXSendLargeCommand(gc, pc, 52, pnts, compsize);
- }
- }
+ buf = (GLdouble *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2d(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 52, buf, compsize);
+ Xfree((char *) buf);
+ }
+ else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 52, pnts, compsize);
+ }
+ }
}
-void __indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr, GLint uord,
- GLfloat v1, GLfloat v2, GLint vstr, GLint vord,
- const GLfloat *pnts)
+void
+__indirect_glMap2f(GLenum target, GLfloat u1, GLfloat u2, GLint ustr,
+ GLint uord, GLfloat v1, GLfloat v2, GLint vstr, GLint vord,
+ const GLfloat * pnts)
{
- __GLX_DECLARE_VARIABLES();
- GLint k;
+ __GLX_DECLARE_VARIABLES();
+ GLint k;
- __GLX_LOAD_VARIABLES();
- k = __glMap2f_size(target);
- if (k == 0) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- } else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
- compsize = k * uord * vord * __GLX_SIZE_FLOAT32;
- cmdlen = 32+compsize;
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ k = __glMap2f_size(target);
+ if (k == 0) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+ else if (vstr < k || ustr < k || vord <= 0 || uord <= 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+ compsize = k * uord * vord * __GLX_SIZE_FLOAT32;
+ cmdlen = 32 + compsize;
+ if (!gc->currentDpy)
+ return;
- /*
+ /*
** The order that arguments are packed is different from the order
** for glMap2d.
*/
- if (cmdlen <= gc->maxSmallRenderCommandSize) {
- /* Use GLXRender protocol to send small command */
- __GLX_BEGIN_VARIABLE(X_GLrop_Map2f,cmdlen);
- __GLX_PUT_LONG(4,target);
- __GLX_PUT_FLOAT(8,u1);
- __GLX_PUT_FLOAT(12,u2);
- __GLX_PUT_LONG(16,uord);
- __GLX_PUT_FLOAT(20,v1);
- __GLX_PUT_FLOAT(24,v2);
- __GLX_PUT_LONG(28,vord);
- /*
- ** Pack into a u-major ordering.
- */
- __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat*) (pc+32));
- __GLX_END(cmdlen);
- } else {
- /* Use GLXRenderLarge protocol to send command */
- __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f,cmdlen+4);
- __GLX_PUT_LONG(8,target);
- __GLX_PUT_FLOAT(12,u1);
- __GLX_PUT_FLOAT(16,u2);
- __GLX_PUT_LONG(20,uord);
- __GLX_PUT_FLOAT(24,v1);
- __GLX_PUT_FLOAT(28,v2);
- __GLX_PUT_LONG(32,vord);
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE(X_GLrop_Map2f, cmdlen);
+ __GLX_PUT_LONG(4, target);
+ __GLX_PUT_FLOAT(8, u1);
+ __GLX_PUT_FLOAT(12, u2);
+ __GLX_PUT_LONG(16, uord);
+ __GLX_PUT_FLOAT(20, v1);
+ __GLX_PUT_FLOAT(24, v2);
+ __GLX_PUT_LONG(28, vord);
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, (GLfloat *) (pc + 32));
+ __GLX_END(cmdlen);
+ }
+ else {
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE(X_GLrop_Map2f, cmdlen + 4);
+ __GLX_PUT_LONG(8, target);
+ __GLX_PUT_FLOAT(12, u1);
+ __GLX_PUT_FLOAT(16, u2);
+ __GLX_PUT_LONG(20, uord);
+ __GLX_PUT_FLOAT(24, v1);
+ __GLX_PUT_FLOAT(28, v2);
+ __GLX_PUT_LONG(32, vord);
- if ((vstr != k) || (ustr != k*vord)) {
- GLfloat *buf;
+ if ((vstr != k) || (ustr != k * vord)) {
+ GLfloat *buf;
- buf = (GLfloat *) Xmalloc(compsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
- /*
- ** Pack into a u-major ordering.
- */
- __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
- __glXSendLargeCommand(gc, pc, 36, buf, compsize);
- Xfree((char*) buf);
- } else {
- /* Data is already packed. Just send it out */
- __glXSendLargeCommand(gc, pc, 36, pnts, compsize);
- }
- }
+ buf = (GLfloat *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ /*
+ ** Pack into a u-major ordering.
+ */
+ __glFillMap2f(k, uord, vord, ustr, vstr, pnts, buf);
+ __glXSendLargeCommand(gc, pc, 36, buf, compsize);
+ Xfree((char *) buf);
+ }
+ else {
+ /* Data is already packed. Just send it out */
+ __glXSendLargeCommand(gc, pc, 36, pnts, compsize);
+ }
+ }
}
-void __indirect_glEnable(GLenum cap)
+void
+__indirect_glEnable(GLenum cap)
{
- __GLX_DECLARE_VARIABLES();
+ __GLX_DECLARE_VARIABLES();
- __GLX_LOAD_VARIABLES();
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy)
+ return;
- switch(cap) {
- case GL_COLOR_ARRAY:
- case GL_EDGE_FLAG_ARRAY:
- case GL_INDEX_ARRAY:
- case GL_NORMAL_ARRAY:
- case GL_TEXTURE_COORD_ARRAY:
- case GL_VERTEX_ARRAY:
- case GL_SECONDARY_COLOR_ARRAY:
- case GL_FOG_COORD_ARRAY:
- __indirect_glEnableClientState(cap);
- return;
- default:
- break;
- }
+ switch (cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ __indirect_glEnableClientState(cap);
+ return;
+ default:
+ break;
+ }
- __GLX_BEGIN(X_GLrop_Enable,8);
- __GLX_PUT_LONG(4,cap);
- __GLX_END(8);
+ __GLX_BEGIN(X_GLrop_Enable, 8);
+ __GLX_PUT_LONG(4, cap);
+ __GLX_END(8);
}
-void __indirect_glDisable(GLenum cap)
+void
+__indirect_glDisable(GLenum cap)
{
- __GLX_DECLARE_VARIABLES();
+ __GLX_DECLARE_VARIABLES();
- __GLX_LOAD_VARIABLES();
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ if (!gc->currentDpy)
+ return;
- switch(cap) {
- case GL_COLOR_ARRAY:
- case GL_EDGE_FLAG_ARRAY:
- case GL_INDEX_ARRAY:
- case GL_NORMAL_ARRAY:
- case GL_TEXTURE_COORD_ARRAY:
- case GL_VERTEX_ARRAY:
- case GL_SECONDARY_COLOR_ARRAY:
- case GL_FOG_COORD_ARRAY:
- __indirect_glDisableClientState(cap);
- return;
- default:
- break;
- }
+ switch (cap) {
+ case GL_COLOR_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_TEXTURE_COORD_ARRAY:
+ case GL_VERTEX_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ __indirect_glDisableClientState(cap);
+ return;
+ default:
+ break;
+ }
- __GLX_BEGIN(X_GLrop_Disable,8);
- __GLX_PUT_LONG(4,cap);
- __GLX_END(8);
+ __GLX_BEGIN(X_GLrop_Disable, 8);
+ __GLX_PUT_LONG(4, cap);
+ __GLX_END(8);
}
diff --git a/src/glx/x11/renderpix.c b/src/glx/x11/renderpix.c
index 0b7b77c7420..e7d7c04dc69 100644
--- a/src/glx/x11/renderpix.c
+++ b/src/glx/x11/renderpix.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -82,42 +83,43 @@
* broken.
*/
void
-__glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
- GLint width, GLint height, GLint depth,
- GLenum format, GLenum type, const GLvoid *src,
- GLubyte *pc, GLubyte *modes)
+__glXSendLargeImage(__GLXcontext * gc, GLint compsize, GLint dim,
+ GLint width, GLint height, GLint depth,
+ GLenum format, GLenum type, const GLvoid * src,
+ GLubyte * pc, GLubyte * modes)
{
- if ( !gc->fastImageUnpack || (src == NULL) ) {
- /* Allocate a temporary holding buffer */
- GLubyte *buf = (GLubyte *) Xmalloc(compsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
+ if (!gc->fastImageUnpack || (src == NULL)) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(compsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
- /* Apply pixel store unpack modes to copy data into buf */
- if ( src != NULL ) {
- (*gc->fillImage)(gc, dim, width, height, depth, format, type,
- src, buf, modes);
- }
- else {
- if ( dim < 3 ) {
- (void) memcpy( modes, __glXDefaultPixelStore + 4, 20 );
- }
- else {
- (void) memcpy( modes, __glXDefaultPixelStore + 0, 36 );
- }
- }
+ /* Apply pixel store unpack modes to copy data into buf */
+ if (src != NULL) {
+ (*gc->fillImage) (gc, dim, width, height, depth, format, type,
+ src, buf, modes);
+ }
+ else {
+ if (dim < 3) {
+ (void) memcpy(modes, __glXDefaultPixelStore + 4, 20);
+ }
+ else {
+ (void) memcpy(modes, __glXDefaultPixelStore + 0, 36);
+ }
+ }
- /* Send large command */
- __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, buf, compsize);
- /* Free buffer */
- Xfree((char*) buf);
- } else {
- /* Just send the data straight as is */
- __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize);
- }
+ /* Free buffer */
+ Xfree((char *) buf);
+ }
+ else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, pc - gc->pc, pc, compsize);
+ }
}
/************************************************************************/
@@ -129,81 +131,89 @@ __glXSendLargeImage(__GLXcontext *gc, GLint compsize, GLint dim,
* The \c fastImageUnpack path, which is thankfully never used, is completely
* broken.
*/
-void __indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
- GLsizei width, GLsizei height, GLenum format,
- GLenum type, const GLvoid *row,
- const GLvoid *column)
+void
+__indirect_glSeparableFilter2D(GLenum target, GLenum internalformat,
+ GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid * row,
+ const GLvoid * column)
{
- __GLX_DECLARE_VARIABLES();
- GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
+ __GLX_DECLARE_VARIABLES();
+ GLuint compsize2, hdrlen, totalhdrlen, image1len, image2len;
- __GLX_LOAD_VARIABLES();
- compsize = __glImageSize(width, 1, 1, format, type, 0);
- compsize2 = __glImageSize(height, 1, 1, format, type, 0);
- totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
- hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
- image1len = __GLX_PAD(compsize);
- image2len = __GLX_PAD(compsize2);
- cmdlen = totalhdrlen + image1len + image2len;
- if (!gc->currentDpy) return;
+ __GLX_LOAD_VARIABLES();
+ compsize = __glImageSize(width, 1, 1, format, type, 0);
+ compsize2 = __glImageSize(height, 1, 1, format, type, 0);
+ totalhdrlen = __GLX_PAD(__GLX_CONV_FILT_CMD_HDR_SIZE);
+ hdrlen = __GLX_PAD(__GLX_CONV_FILT_HDR_SIZE);
+ image1len = __GLX_PAD(compsize);
+ image2len = __GLX_PAD(compsize2);
+ cmdlen = totalhdrlen + image1len + image2len;
+ if (!gc->currentDpy)
+ return;
- if (cmdlen <= gc->maxSmallRenderCommandSize) {
- /* Use GLXRender protocol to send small command */
- __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
- __GLX_PUT_LONG(0,target);
- __GLX_PUT_LONG(4,internalformat);
- __GLX_PUT_LONG(8,width);
- __GLX_PUT_LONG(12,height);
- __GLX_PUT_LONG(16,format);
- __GLX_PUT_LONG(20,type);
- pc += hdrlen;
- if (compsize > 0) {
- (*gc->fillImage)(gc, 1, width, 1, 1, format, type,
- row, pc, pixelHeaderPC);
- pc += image1len;
- }
- if (compsize2 > 0) {
- (*gc->fillImage)(gc, 1, height, 1, 1, format, type,
- column, pc, NULL);
- pc += image2len;
- }
- if ((compsize == 0) && (compsize2 == 0)) {
- /* Setup default store modes */
- (void) memcpy( pixelHeaderPC, __glXDefaultPixelStore + 4, 20 );
- }
- __GLX_END(0);
- } else {
- const GLint bufsize = image1len + image2len;
+ if (cmdlen <= gc->maxSmallRenderCommandSize) {
+ /* Use GLXRender protocol to send small command */
+ __GLX_BEGIN_VARIABLE_WITH_PIXEL(X_GLrop_SeparableFilter2D, cmdlen);
+ __GLX_PUT_LONG(0, target);
+ __GLX_PUT_LONG(4, internalformat);
+ __GLX_PUT_LONG(8, width);
+ __GLX_PUT_LONG(12, height);
+ __GLX_PUT_LONG(16, format);
+ __GLX_PUT_LONG(20, type);
+ pc += hdrlen;
+ if (compsize > 0) {
+ (*gc->fillImage) (gc, 1, width, 1, 1, format, type,
+ row, pc, pixelHeaderPC);
+ pc += image1len;
+ }
+ if (compsize2 > 0) {
+ (*gc->fillImage) (gc, 1, height, 1, 1, format, type,
+ column, pc, NULL);
+ pc += image2len;
+ }
+ if ((compsize == 0) && (compsize2 == 0)) {
+ /* Setup default store modes */
+ (void) memcpy(pixelHeaderPC, __glXDefaultPixelStore + 4, 20);
+ }
+ __GLX_END(0);
+ }
+ else {
+ const GLint bufsize = image1len + image2len;
- /* Use GLXRenderLarge protocol to send command */
- __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,cmdlen+4);
- __GLX_PUT_LONG(0,target);
- __GLX_PUT_LONG(4,internalformat);
- __GLX_PUT_LONG(8,width);
- __GLX_PUT_LONG(12,height);
- __GLX_PUT_LONG(16,format);
- __GLX_PUT_LONG(20,type);
- pc += hdrlen;
+ /* Use GLXRenderLarge protocol to send command */
+ __GLX_BEGIN_VARIABLE_LARGE_WITH_PIXEL(X_GLrop_SeparableFilter2D,
+ cmdlen + 4);
+ __GLX_PUT_LONG(0, target);
+ __GLX_PUT_LONG(4, internalformat);
+ __GLX_PUT_LONG(8, width);
+ __GLX_PUT_LONG(12, height);
+ __GLX_PUT_LONG(16, format);
+ __GLX_PUT_LONG(20, type);
+ pc += hdrlen;
- if (!gc->fastImageUnpack) {
- /* Allocate a temporary holding buffer */
- GLubyte *buf = (GLubyte *) Xmalloc(bufsize);
- if (!buf) {
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- return;
- }
- (*gc->fillImage)(gc, 1, width, 1, 1, format, type, row, buf, pixelHeaderPC);
+ if (!gc->fastImageUnpack) {
+ /* Allocate a temporary holding buffer */
+ GLubyte *buf = (GLubyte *) Xmalloc(bufsize);
+ if (!buf) {
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ return;
+ }
+ (*gc->fillImage) (gc, 1, width, 1, 1, format, type, row, buf,
+ pixelHeaderPC);
- (*gc->fillImage)(gc, 1, height, 1, 1, format, type, column,
- buf + image1len, pixelHeaderPC);
+ (*gc->fillImage) (gc, 1, height, 1, 1, format, type, column,
+ buf + image1len, pixelHeaderPC);
- /* Send large command */
- __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), buf, bufsize);
- /* Free buffer */
- Xfree((char*) buf);
- } else {
- /* Just send the data straight as is */
- __glXSendLargeCommand(gc, gc->pc, (GLint)(pc - gc->pc), pc, bufsize);
- }
- }
+ /* Send large command */
+ __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), buf,
+ bufsize);
+ /* Free buffer */
+ Xfree((char *) buf);
+ }
+ else {
+ /* Just send the data straight as is */
+ __glXSendLargeCommand(gc, gc->pc, (GLint) (pc - gc->pc), pc,
+ bufsize);
+ }
+ }
}
diff --git a/src/glx/x11/single2.c b/src/glx/x11/single2.c
index a97d4c7def8..9732b6ef046 100644
--- a/src/glx/x11/single2.c
+++ b/src/glx/x11/single2.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -37,55 +38,59 @@
#include "indirect_vertex_array.h"
/* Used for GL_ARB_transpose_matrix */
-static void TransposeMatrixf(GLfloat m[16])
+static void
+TransposeMatrixf(GLfloat m[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < i; j++) {
- GLfloat tmp = m[i*4+j];
- m[i*4+j] = m[j*4+i];
- m[j*4+i] = tmp;
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLfloat tmp = m[i * 4 + j];
+ m[i * 4 + j] = m[j * 4 + i];
+ m[j * 4 + i] = tmp;
+ }
+ }
}
/* Used for GL_ARB_transpose_matrix */
-static void TransposeMatrixb(GLboolean m[16])
+static void
+TransposeMatrixb(GLboolean m[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < i; j++) {
- GLboolean tmp = m[i*4+j];
- m[i*4+j] = m[j*4+i];
- m[j*4+i] = tmp;
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLboolean tmp = m[i * 4 + j];
+ m[i * 4 + j] = m[j * 4 + i];
+ m[j * 4 + i] = tmp;
+ }
+ }
}
/* Used for GL_ARB_transpose_matrix */
-static void TransposeMatrixd(GLdouble m[16])
+static void
+TransposeMatrixd(GLdouble m[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < i; j++) {
- GLdouble tmp = m[i*4+j];
- m[i*4+j] = m[j*4+i];
- m[j*4+i] = tmp;
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLdouble tmp = m[i * 4 + j];
+ m[i * 4 + j] = m[j * 4 + i];
+ m[j * 4 + i] = tmp;
+ }
+ }
}
/* Used for GL_ARB_transpose_matrix */
-static void TransposeMatrixi(GLint m[16])
+static void
+TransposeMatrixi(GLint m[16])
{
- int i, j;
- for (i = 0; i < 4; i++) {
- for (j = 0; j < i; j++) {
- GLint tmp = m[i*4+j];
- m[i*4+j] = m[j*4+i];
- m[j*4+i] = tmp;
- }
- }
+ int i, j;
+ for (i = 0; i < 4; i++) {
+ for (j = 0; j < i; j++) {
+ GLint tmp = m[i * 4 + j];
+ m[i * 4 + j] = m[j * 4 + i];
+ m[j * 4 + i] = tmp;
+ }
+ }
}
@@ -94,41 +99,42 @@ static void TransposeMatrixi(GLint m[16])
* that are not transpose-matrix enums are unaffected.
*/
static GLenum
-RemapTransposeEnum( GLenum e )
+RemapTransposeEnum(GLenum e)
{
- switch( e ) {
- case GL_TRANSPOSE_MODELVIEW_MATRIX:
- case GL_TRANSPOSE_PROJECTION_MATRIX:
- case GL_TRANSPOSE_TEXTURE_MATRIX:
- return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
- case GL_TRANSPOSE_COLOR_MATRIX:
- return GL_COLOR_MATRIX;
- default:
- return e;
- };
+ switch (e) {
+ case GL_TRANSPOSE_MODELVIEW_MATRIX:
+ case GL_TRANSPOSE_PROJECTION_MATRIX:
+ case GL_TRANSPOSE_TEXTURE_MATRIX:
+ return e - (GL_TRANSPOSE_MODELVIEW_MATRIX - GL_MODELVIEW_MATRIX);
+ case GL_TRANSPOSE_COLOR_MATRIX:
+ return GL_COLOR_MATRIX;
+ default:
+ return e;
+ };
}
-GLenum __indirect_glGetError(void)
+GLenum
+__indirect_glGetError(void)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- GLuint retval = GL_NO_ERROR;
- xGLXGetErrorReply reply;
-
- if (gc->error) {
- /* Use internal error first */
- retval = gc->error;
- gc->error = GL_NO_ERROR;
- return retval;
- }
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_GetError,0);
- __GLX_SINGLE_READ_XREPLY();
- retval = reply.error;
- __GLX_SINGLE_END();
-
- return retval;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLuint retval = GL_NO_ERROR;
+ xGLXGetErrorReply reply;
+
+ if (gc->error) {
+ /* Use internal error first */
+ retval = gc->error;
+ gc->error = GL_NO_ERROR;
+ return retval;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetError, 0);
+ __GLX_SINGLE_READ_XREPLY();
+ retval = reply.error;
+ __GLX_SINGLE_END();
+
+ return retval;
}
@@ -139,447 +145,473 @@ GLenum __indirect_glGetError(void)
* On success \c GL_TRUE is returned. Otherwise, \c GL_FALSE is returned.
*/
static GLboolean
-get_client_data( __GLXcontext * gc, GLenum cap, GLintptr * data )
+get_client_data(__GLXcontext * gc, GLenum cap, GLintptr * data)
{
- GLboolean retval = GL_TRUE;
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- const GLint tex_unit = __glXGetActiveTextureUnit( state );
-
-
- switch( cap ) {
- case GL_VERTEX_ARRAY:
- case GL_NORMAL_ARRAY:
- case GL_COLOR_ARRAY:
- case GL_INDEX_ARRAY:
- case GL_EDGE_FLAG_ARRAY:
- case GL_SECONDARY_COLOR_ARRAY:
- case GL_FOG_COORD_ARRAY:
- retval = __glXGetArrayEnable( state, cap, 0, data );
- break;
-
- case GL_VERTEX_ARRAY_SIZE:
- retval = __glXGetArraySize( state, GL_VERTEX_ARRAY, 0, data );
- break;
- case GL_COLOR_ARRAY_SIZE:
- retval = __glXGetArraySize( state, GL_COLOR_ARRAY, 0, data );
- break;
- case GL_SECONDARY_COLOR_ARRAY_SIZE:
- retval = __glXGetArraySize( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
- break;
-
- case GL_VERTEX_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_VERTEX_ARRAY, 0, data );
- break;
- case GL_NORMAL_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_NORMAL_ARRAY, 0, data );
- break;
- case GL_INDEX_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_INDEX_ARRAY, 0, data );
- break;
- case GL_COLOR_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_COLOR_ARRAY, 0, data );
- break;
- case GL_SECONDARY_COLOR_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
- break;
- case GL_FOG_COORD_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_FOG_COORD_ARRAY, 0, data );
- break;
-
- case GL_VERTEX_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_VERTEX_ARRAY, 0, data );
- break;
- case GL_NORMAL_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_NORMAL_ARRAY, 0, data );
- break;
- case GL_INDEX_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_INDEX_ARRAY, 0, data );
- break;
- case GL_EDGE_FLAG_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_EDGE_FLAG_ARRAY, 0, data );
- break;
- case GL_COLOR_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_COLOR_ARRAY, 0, data );
- break;
- case GL_SECONDARY_COLOR_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_SECONDARY_COLOR_ARRAY, 0, data );
- break;
- case GL_FOG_COORD_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_FOG_COORD_ARRAY, 0, data );
- break;
-
- case GL_TEXTURE_COORD_ARRAY:
- retval = __glXGetArrayEnable( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
- break;
- case GL_TEXTURE_COORD_ARRAY_SIZE:
- retval = __glXGetArraySize( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
- break;
- case GL_TEXTURE_COORD_ARRAY_TYPE:
- retval = __glXGetArrayType( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
- break;
- case GL_TEXTURE_COORD_ARRAY_STRIDE:
- retval = __glXGetArrayStride( state, GL_TEXTURE_COORD_ARRAY, tex_unit, data );
- break;
-
- case GL_MAX_ELEMENTS_VERTICES:
- case GL_MAX_ELEMENTS_INDICES:
- retval = GL_TRUE;
- *data = ~0UL;
- break;
-
-
- case GL_PACK_ROW_LENGTH:
- *data = (GLintptr)state->storePack.rowLength;
- break;
- case GL_PACK_IMAGE_HEIGHT:
- *data = (GLintptr)state->storePack.imageHeight;
- break;
- case GL_PACK_SKIP_ROWS:
- *data = (GLintptr)state->storePack.skipRows;
- break;
- case GL_PACK_SKIP_PIXELS:
- *data = (GLintptr)state->storePack.skipPixels;
- break;
- case GL_PACK_SKIP_IMAGES:
- *data = (GLintptr)state->storePack.skipImages;
- break;
- case GL_PACK_ALIGNMENT:
- *data = (GLintptr)state->storePack.alignment;
- break;
- case GL_PACK_SWAP_BYTES:
- *data = (GLintptr)state->storePack.swapEndian;
- break;
- case GL_PACK_LSB_FIRST:
- *data = (GLintptr)state->storePack.lsbFirst;
- break;
- case GL_UNPACK_ROW_LENGTH:
- *data = (GLintptr)state->storeUnpack.rowLength;
- break;
- case GL_UNPACK_IMAGE_HEIGHT:
- *data = (GLintptr)state->storeUnpack.imageHeight;
- break;
- case GL_UNPACK_SKIP_ROWS:
- *data = (GLintptr)state->storeUnpack.skipRows;
- break;
- case GL_UNPACK_SKIP_PIXELS:
- *data = (GLintptr)state->storeUnpack.skipPixels;
- break;
- case GL_UNPACK_SKIP_IMAGES:
- *data = (GLintptr)state->storeUnpack.skipImages;
- break;
- case GL_UNPACK_ALIGNMENT:
- *data = (GLintptr)state->storeUnpack.alignment;
- break;
- case GL_UNPACK_SWAP_BYTES:
- *data = (GLintptr)state->storeUnpack.swapEndian;
- break;
- case GL_UNPACK_LSB_FIRST:
- *data = (GLintptr)state->storeUnpack.lsbFirst;
- break;
- case GL_CLIENT_ATTRIB_STACK_DEPTH:
- *data = (GLintptr)(gc->attributes.stackPointer - gc->attributes.stack);
- break;
- case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
- *data = (GLintptr)__GL_CLIENT_ATTRIB_STACK_DEPTH;
- break;
- case GL_CLIENT_ACTIVE_TEXTURE:
- *data = (GLintptr)(tex_unit + GL_TEXTURE0);
- break;
-
- default:
- retval = GL_FALSE;
- break;
- }
-
-
- return retval;
+ GLboolean retval = GL_TRUE;
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ const GLint tex_unit = __glXGetActiveTextureUnit(state);
+
+
+ switch (cap) {
+ case GL_VERTEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ retval = __glXGetArrayEnable(state, cap, 0, data);
+ break;
+
+ case GL_VERTEX_ARRAY_SIZE:
+ retval = __glXGetArraySize(state, GL_VERTEX_ARRAY, 0, data);
+ break;
+ case GL_COLOR_ARRAY_SIZE:
+ retval = __glXGetArraySize(state, GL_COLOR_ARRAY, 0, data);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_SIZE:
+ retval = __glXGetArraySize(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
+ break;
+
+ case GL_VERTEX_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_VERTEX_ARRAY, 0, data);
+ break;
+ case GL_NORMAL_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_NORMAL_ARRAY, 0, data);
+ break;
+ case GL_INDEX_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_INDEX_ARRAY, 0, data);
+ break;
+ case GL_COLOR_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_COLOR_ARRAY, 0, data);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
+ break;
+ case GL_FOG_COORD_ARRAY_TYPE:
+ retval = __glXGetArrayType(state, GL_FOG_COORD_ARRAY, 0, data);
+ break;
+
+ case GL_VERTEX_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_VERTEX_ARRAY, 0, data);
+ break;
+ case GL_NORMAL_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_NORMAL_ARRAY, 0, data);
+ break;
+ case GL_INDEX_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_INDEX_ARRAY, 0, data);
+ break;
+ case GL_EDGE_FLAG_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_EDGE_FLAG_ARRAY, 0, data);
+ break;
+ case GL_COLOR_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_COLOR_ARRAY, 0, data);
+ break;
+ case GL_SECONDARY_COLOR_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_SECONDARY_COLOR_ARRAY, 0, data);
+ break;
+ case GL_FOG_COORD_ARRAY_STRIDE:
+ retval = __glXGetArrayStride(state, GL_FOG_COORD_ARRAY, 0, data);
+ break;
+
+ case GL_TEXTURE_COORD_ARRAY:
+ retval =
+ __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_SIZE:
+ retval =
+ __glXGetArraySize(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_TYPE:
+ retval =
+ __glXGetArrayType(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
+ break;
+ case GL_TEXTURE_COORD_ARRAY_STRIDE:
+ retval =
+ __glXGetArrayStride(state, GL_TEXTURE_COORD_ARRAY, tex_unit, data);
+ break;
+
+ case GL_MAX_ELEMENTS_VERTICES:
+ case GL_MAX_ELEMENTS_INDICES:
+ retval = GL_TRUE;
+ *data = ~0UL;
+ break;
+
+
+ case GL_PACK_ROW_LENGTH:
+ *data = (GLintptr) state->storePack.rowLength;
+ break;
+ case GL_PACK_IMAGE_HEIGHT:
+ *data = (GLintptr) state->storePack.imageHeight;
+ break;
+ case GL_PACK_SKIP_ROWS:
+ *data = (GLintptr) state->storePack.skipRows;
+ break;
+ case GL_PACK_SKIP_PIXELS:
+ *data = (GLintptr) state->storePack.skipPixels;
+ break;
+ case GL_PACK_SKIP_IMAGES:
+ *data = (GLintptr) state->storePack.skipImages;
+ break;
+ case GL_PACK_ALIGNMENT:
+ *data = (GLintptr) state->storePack.alignment;
+ break;
+ case GL_PACK_SWAP_BYTES:
+ *data = (GLintptr) state->storePack.swapEndian;
+ break;
+ case GL_PACK_LSB_FIRST:
+ *data = (GLintptr) state->storePack.lsbFirst;
+ break;
+ case GL_UNPACK_ROW_LENGTH:
+ *data = (GLintptr) state->storeUnpack.rowLength;
+ break;
+ case GL_UNPACK_IMAGE_HEIGHT:
+ *data = (GLintptr) state->storeUnpack.imageHeight;
+ break;
+ case GL_UNPACK_SKIP_ROWS:
+ *data = (GLintptr) state->storeUnpack.skipRows;
+ break;
+ case GL_UNPACK_SKIP_PIXELS:
+ *data = (GLintptr) state->storeUnpack.skipPixels;
+ break;
+ case GL_UNPACK_SKIP_IMAGES:
+ *data = (GLintptr) state->storeUnpack.skipImages;
+ break;
+ case GL_UNPACK_ALIGNMENT:
+ *data = (GLintptr) state->storeUnpack.alignment;
+ break;
+ case GL_UNPACK_SWAP_BYTES:
+ *data = (GLintptr) state->storeUnpack.swapEndian;
+ break;
+ case GL_UNPACK_LSB_FIRST:
+ *data = (GLintptr) state->storeUnpack.lsbFirst;
+ break;
+ case GL_CLIENT_ATTRIB_STACK_DEPTH:
+ *data = (GLintptr) (gc->attributes.stackPointer - gc->attributes.stack);
+ break;
+ case GL_MAX_CLIENT_ATTRIB_STACK_DEPTH:
+ *data = (GLintptr) __GL_CLIENT_ATTRIB_STACK_DEPTH;
+ break;
+ case GL_CLIENT_ACTIVE_TEXTURE:
+ *data = (GLintptr) (tex_unit + GL_TEXTURE0);
+ break;
+
+ default:
+ retval = GL_FALSE;
+ break;
+ }
+
+
+ return retval;
}
-void __indirect_glGetBooleanv(GLenum val, GLboolean *b)
+void
+__indirect_glGetBooleanv(GLenum val, GLboolean * b)
{
- const GLenum origVal = val;
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXSingleReply reply;
-
- val = RemapTransposeEnum( val );
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv,4);
- __GLX_SINGLE_PUT_LONG(0,val);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_SIZE(compsize);
-
- if (compsize == 0) {
- /*
- ** Error occured; don't modify user's buffer.
- */
- } else {
- GLintptr data;
-
- /*
- ** We still needed to send the request to the server in order to
- ** find out whether it was legal to make a query (it's illegal,
- ** for example, to call a query between glBegin() and glEnd()).
- */
-
- if ( get_client_data( gc, val, & data ) ) {
- *b = (GLboolean) data;
- }
- else {
- /*
- ** Not a local value, so use what we got from the server.
- */
- if (compsize == 1) {
- __GLX_SINGLE_GET_CHAR(b);
- } else {
- __GLX_SINGLE_GET_CHAR_ARRAY(b,compsize);
- if (val != origVal) {
- /* matrix transpose */
- TransposeMatrixb(b);
- }
- }
- }
- }
- __GLX_SINGLE_END();
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum(val);
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetBooleanv, 4);
+ __GLX_SINGLE_PUT_LONG(0, val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ }
+ else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if (get_client_data(gc, val, &data)) {
+ *b = (GLboolean) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_CHAR(b);
+ }
+ else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(b, compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixb(b);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
}
-void __indirect_glGetDoublev(GLenum val, GLdouble *d)
+void
+__indirect_glGetDoublev(GLenum val, GLdouble * d)
{
- const GLenum origVal = val;
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXSingleReply reply;
-
- val = RemapTransposeEnum( val );
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev,4);
- __GLX_SINGLE_PUT_LONG(0,val);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_SIZE(compsize);
-
- if (compsize == 0) {
- /*
- ** Error occured; don't modify user's buffer.
- */
- } else {
- GLintptr data;
-
- /*
- ** We still needed to send the request to the server in order to
- ** find out whether it was legal to make a query (it's illegal,
- ** for example, to call a query between glBegin() and glEnd()).
- */
-
- if ( get_client_data( gc, val, & data ) ) {
- *d = (GLdouble) data;
- }
- else {
- /*
- ** Not a local value, so use what we got from the server.
- */
- if (compsize == 1) {
- __GLX_SINGLE_GET_DOUBLE(d);
- } else {
- __GLX_SINGLE_GET_DOUBLE_ARRAY(d,compsize);
- if (val != origVal) {
- /* matrix transpose */
- TransposeMatrixd(d);
- }
- }
- }
- }
- __GLX_SINGLE_END();
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum(val);
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetDoublev, 4);
+ __GLX_SINGLE_PUT_LONG(0, val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ }
+ else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if (get_client_data(gc, val, &data)) {
+ *d = (GLdouble) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_DOUBLE(d);
+ }
+ else {
+ __GLX_SINGLE_GET_DOUBLE_ARRAY(d, compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixd(d);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
}
-void __indirect_glGetFloatv(GLenum val, GLfloat *f)
+void
+__indirect_glGetFloatv(GLenum val, GLfloat * f)
{
- const GLenum origVal = val;
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXSingleReply reply;
-
- val = RemapTransposeEnum( val );
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv,4);
- __GLX_SINGLE_PUT_LONG(0,val);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_SIZE(compsize);
-
- if (compsize == 0) {
- /*
- ** Error occured; don't modify user's buffer.
- */
- } else {
- GLintptr data;
-
- /*
- ** We still needed to send the request to the server in order to
- ** find out whether it was legal to make a query (it's illegal,
- ** for example, to call a query between glBegin() and glEnd()).
- */
-
- if ( get_client_data( gc, val, & data ) ) {
- *f = (GLfloat) data;
- }
- else {
- /*
- ** Not a local value, so use what we got from the server.
- */
- if (compsize == 1) {
- __GLX_SINGLE_GET_FLOAT(f);
- } else {
- __GLX_SINGLE_GET_FLOAT_ARRAY(f,compsize);
- if (val != origVal) {
- /* matrix transpose */
- TransposeMatrixf(f);
- }
- }
- }
- }
- __GLX_SINGLE_END();
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum(val);
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetFloatv, 4);
+ __GLX_SINGLE_PUT_LONG(0, val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ }
+ else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if (get_client_data(gc, val, &data)) {
+ *f = (GLfloat) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_FLOAT(f);
+ }
+ else {
+ __GLX_SINGLE_GET_FLOAT_ARRAY(f, compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixf(f);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
}
-void __indirect_glGetIntegerv(GLenum val, GLint *i)
+void
+__indirect_glGetIntegerv(GLenum val, GLint * i)
{
- const GLenum origVal = val;
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXSingleReply reply;
-
- val = RemapTransposeEnum( val );
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv,4);
- __GLX_SINGLE_PUT_LONG(0,val);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_SIZE(compsize);
-
- if (compsize == 0) {
- /*
- ** Error occured; don't modify user's buffer.
- */
- } else {
- GLintptr data;
-
- /*
- ** We still needed to send the request to the server in order to
- ** find out whether it was legal to make a query (it's illegal,
- ** for example, to call a query between glBegin() and glEnd()).
- */
-
- if ( get_client_data( gc, val, & data ) ) {
- *i = (GLint) data;
- }
- else {
- /*
- ** Not a local value, so use what we got from the server.
- */
- if (compsize == 1) {
- __GLX_SINGLE_GET_LONG(i);
- } else {
- __GLX_SINGLE_GET_LONG_ARRAY(i,compsize);
- if (val != origVal) {
- /* matrix transpose */
- TransposeMatrixi(i);
- }
- }
- }
- }
- __GLX_SINGLE_END();
+ const GLenum origVal = val;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
+
+ val = RemapTransposeEnum(val);
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_GetIntegerv, 4);
+ __GLX_SINGLE_PUT_LONG(0, val);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_SIZE(compsize);
+
+ if (compsize == 0) {
+ /*
+ ** Error occured; don't modify user's buffer.
+ */
+ }
+ else {
+ GLintptr data;
+
+ /*
+ ** We still needed to send the request to the server in order to
+ ** find out whether it was legal to make a query (it's illegal,
+ ** for example, to call a query between glBegin() and glEnd()).
+ */
+
+ if (get_client_data(gc, val, &data)) {
+ *i = (GLint) data;
+ }
+ else {
+ /*
+ ** Not a local value, so use what we got from the server.
+ */
+ if (compsize == 1) {
+ __GLX_SINGLE_GET_LONG(i);
+ }
+ else {
+ __GLX_SINGLE_GET_LONG_ARRAY(i, compsize);
+ if (val != origVal) {
+ /* matrix transpose */
+ TransposeMatrixi(i);
+ }
+ }
+ }
+ }
+ __GLX_SINGLE_END();
}
/*
** Send all pending commands to server.
*/
-void __indirect_glFlush(void)
+void
+__indirect_glFlush(void)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_DECLARE_VARIABLES();
- if (!dpy) return;
+ if (!dpy)
+ return;
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_Flush,0);
- __GLX_SINGLE_END();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Flush, 0);
+ __GLX_SINGLE_END();
- /* And finally flush the X protocol data */
- XFlush(dpy);
+ /* And finally flush the X protocol data */
+ XFlush(dpy);
}
-void __indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat *buffer)
+void
+__indirect_glFeedbackBuffer(GLsizei size, GLenum type, GLfloat * buffer)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_DECLARE_VARIABLES();
- if (!dpy) return;
+ if (!dpy)
+ return;
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer,8);
- __GLX_SINGLE_PUT_LONG(0,size);
- __GLX_SINGLE_PUT_LONG(4,type);
- __GLX_SINGLE_END();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_FeedbackBuffer, 8);
+ __GLX_SINGLE_PUT_LONG(0, size);
+ __GLX_SINGLE_PUT_LONG(4, type);
+ __GLX_SINGLE_END();
- gc->feedbackBuf = buffer;
+ gc->feedbackBuf = buffer;
}
-void __indirect_glSelectBuffer(GLsizei numnames, GLuint *buffer)
+void
+__indirect_glSelectBuffer(GLsizei numnames, GLuint * buffer)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLX_SINGLE_DECLARE_VARIABLES();
- if (!dpy) return;
+ if (!dpy)
+ return;
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer,4);
- __GLX_SINGLE_PUT_LONG(0,numnames);
- __GLX_SINGLE_END();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_SelectBuffer, 4);
+ __GLX_SINGLE_PUT_LONG(0, numnames);
+ __GLX_SINGLE_END();
- gc->selectBuf = buffer;
+ gc->selectBuf = buffer;
}
-GLint __indirect_glRenderMode(GLenum mode)
+GLint
+__indirect_glRenderMode(GLenum mode)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- GLint retval = 0;
- xGLXRenderModeReply reply;
-
- if (!dpy) return -1;
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_RenderMode,4);
- __GLX_SINGLE_PUT_LONG(0,mode);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_RETVAL(retval,GLint);
-
- if (reply.newMode != mode) {
- /*
- ** Switch to new mode did not take effect, therefore an error
- ** occured. When an error happens the server won't send us any
- ** other data.
- */
- } else {
- /* Read the feedback or selection data */
- if (gc->renderMode == GL_FEEDBACK) {
- __GLX_SINGLE_GET_SIZE(compsize);
- __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
- } else
- if (gc->renderMode == GL_SELECT) {
- __GLX_SINGLE_GET_SIZE(compsize);
- __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
- }
- gc->renderMode = mode;
- }
- __GLX_SINGLE_END();
-
- return retval;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ GLint retval = 0;
+ xGLXRenderModeReply reply;
+
+ if (!dpy)
+ return -1;
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_RenderMode, 4);
+ __GLX_SINGLE_PUT_LONG(0, mode);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLint);
+
+ if (reply.newMode != mode) {
+ /*
+ ** Switch to new mode did not take effect, therefore an error
+ ** occured. When an error happens the server won't send us any
+ ** other data.
+ */
+ }
+ else {
+ /* Read the feedback or selection data */
+ if (gc->renderMode == GL_FEEDBACK) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_FLOAT_ARRAY(gc->feedbackBuf, compsize);
+ }
+ else if (gc->renderMode == GL_SELECT) {
+ __GLX_SINGLE_GET_SIZE(compsize);
+ __GLX_SINGLE_GET_LONG_ARRAY(gc->selectBuf, compsize);
+ }
+ gc->renderMode = mode;
+ }
+ __GLX_SINGLE_END();
+
+ return retval;
}
-void __indirect_glFinish(void)
+void
+__indirect_glFinish(void)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- xGLXSingleReply reply;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ xGLXSingleReply reply;
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_Finish,0);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_END();
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_Finish, 0);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_END();
}
@@ -587,241 +619,247 @@ void __indirect_glFinish(void)
* Extract the major and minor version numbers from a version string.
*/
static void
-version_from_string( const char * ver,
- int * major_version, int * minor_version )
+version_from_string(const char *ver, int *major_version, int *minor_version)
{
- const char * end;
- long major;
- long minor;
-
- major = strtol( ver, (char **) & end, 10 );
- minor = strtol( end + 1, NULL, 10 );
- *major_version = major;
- *minor_version = minor;
+ const char *end;
+ long major;
+ long minor;
+
+ major = strtol(ver, (char **) &end, 10);
+ minor = strtol(end + 1, NULL, 10);
+ *major_version = major;
+ *minor_version = minor;
}
-const GLubyte *__indirect_glGetString(GLenum name)
+const GLubyte *
+__indirect_glGetString(GLenum name)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- Display *dpy = gc->currentDpy;
- GLubyte *s = NULL;
+ __GLXcontext *gc = __glXGetCurrentContext();
+ Display *dpy = gc->currentDpy;
+ GLubyte *s = NULL;
- if (!dpy) return 0;
+ if (!dpy)
+ return 0;
- /*
+ /*
** Return the cached copy if the string has already been fetched
*/
- switch(name) {
- case GL_VENDOR:
- if (gc->vendor) return gc->vendor;
- break;
- case GL_RENDERER:
- if (gc->renderer) return gc->renderer;
- break;
- case GL_VERSION:
- if (gc->version) return gc->version;
- break;
- case GL_EXTENSIONS:
- if (gc->extensions) return gc->extensions;
- break;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return 0;
- }
-
- /*
+ switch (name) {
+ case GL_VENDOR:
+ if (gc->vendor)
+ return gc->vendor;
+ break;
+ case GL_RENDERER:
+ if (gc->renderer)
+ return gc->renderer;
+ break;
+ case GL_VERSION:
+ if (gc->version)
+ return gc->version;
+ break;
+ case GL_EXTENSIONS:
+ if (gc->extensions)
+ return gc->extensions;
+ break;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return 0;
+ }
+
+ /*
** Get requested string from server
*/
- (void) __glXFlushRenderBuffer( gc, gc->pc );
- s = (GLubyte *) __glXGetStringFromServer( dpy, gc->majorOpcode,
- X_GLsop_GetString, gc->currentContextTag,
- name );
- if (!s) {
- /* Throw data on the floor */
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- } else {
- /*
- ** Update local cache
- */
- switch(name) {
- case GL_VENDOR:
- gc->vendor = s;
- break;
-
- case GL_RENDERER:
- gc->renderer = s;
- break;
-
- case GL_VERSION: {
- int client_major;
- int client_minor;
-
- version_from_string( (char *) s,
- & gc->server_major, & gc->server_minor );
- __glXGetGLVersion( & client_major, & client_minor );
-
- if ( (gc->server_major < client_major)
- || ((gc->server_major == client_major)
- && (gc->server_minor <= client_minor)) ) {
- gc->version = s;
- }
- else {
- /* Allow 7 bytes for the client-side GL version. This allows
- * for upto version 999.999. I'm not holding my breath for
- * that one! The extra 4 is for the ' ()\0' that will be
- * added.
- */
- const size_t size = 7 + strlen( (char *) s ) + 4;
-
- gc->version = Xmalloc( size );
- if ( gc->version == NULL ) {
- /* If we couldn't allocate memory for the new string,
- * make a best-effort and just copy the client-side version
- * to the string and use that. It probably doesn't
- * matter what is done here. If there not memory available
- * for a short string, the system is probably going to die
- * soon anyway.
- */
- snprintf( (char *) s, strlen( (char *) s ) + 1, "%u.%u",
- client_major, client_minor );
- gc->version = s;
- }
- else {
- snprintf( (char *)gc->version, size, "%u.%u (%s)",
- client_major, client_minor, s );
- Xfree( s );
- s = gc->version;
- }
- }
- break;
- }
-
- case GL_EXTENSIONS: {
- int major = 1;
- int minor = 0;
-
- /* This code is currently disabled. I was reminded that some
- * vendors intentionally exclude some extensions from their
- * extension string that are part of the core version they
- * advertise. In particular, on Nvidia drivers this means that
- * the functionality is supported by the driver, but is not
- * hardware accelerated. For example, a TNT will show core
- * version 1.5, but most of the post-1.2 functionality is a
- * software fallback.
- *
- * I don't want to break applications that rely on this odd
- * behavior. At the same time, the code is written and tested,
- * so I didn't want to throw it away. Therefore, the code is here
- * but disabled. In the future, we may wish to and an environment
- * variable to enable it.
- */
-
+ (void) __glXFlushRenderBuffer(gc, gc->pc);
+ s = (GLubyte *) __glXGetStringFromServer(dpy, gc->majorOpcode,
+ X_GLsop_GetString,
+ gc->currentContextTag, name);
+ if (!s) {
+ /* Throw data on the floor */
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ }
+ else {
+ /*
+ ** Update local cache
+ */
+ switch (name) {
+ case GL_VENDOR:
+ gc->vendor = s;
+ break;
+
+ case GL_RENDERER:
+ gc->renderer = s;
+ break;
+
+ case GL_VERSION:{
+ int client_major;
+ int client_minor;
+
+ version_from_string((char *) s,
+ &gc->server_major, &gc->server_minor);
+ __glXGetGLVersion(&client_major, &client_minor);
+
+ if ((gc->server_major < client_major)
+ || ((gc->server_major == client_major)
+ && (gc->server_minor <= client_minor))) {
+ gc->version = s;
+ }
+ else {
+ /* Allow 7 bytes for the client-side GL version. This allows
+ * for upto version 999.999. I'm not holding my breath for
+ * that one! The extra 4 is for the ' ()\0' that will be
+ * added.
+ */
+ const size_t size = 7 + strlen((char *) s) + 4;
+
+ gc->version = Xmalloc(size);
+ if (gc->version == NULL) {
+ /* If we couldn't allocate memory for the new string,
+ * make a best-effort and just copy the client-side version
+ * to the string and use that. It probably doesn't
+ * matter what is done here. If there not memory available
+ * for a short string, the system is probably going to die
+ * soon anyway.
+ */
+ snprintf((char *) s, strlen((char *) s) + 1, "%u.%u",
+ client_major, client_minor);
+ gc->version = s;
+ }
+ else {
+ snprintf((char *) gc->version, size, "%u.%u (%s)",
+ client_major, client_minor, s);
+ Xfree(s);
+ s = gc->version;
+ }
+ }
+ break;
+ }
+
+ case GL_EXTENSIONS:{
+ int major = 1;
+ int minor = 0;
+
+ /* This code is currently disabled. I was reminded that some
+ * vendors intentionally exclude some extensions from their
+ * extension string that are part of the core version they
+ * advertise. In particular, on Nvidia drivers this means that
+ * the functionality is supported by the driver, but is not
+ * hardware accelerated. For example, a TNT will show core
+ * version 1.5, but most of the post-1.2 functionality is a
+ * software fallback.
+ *
+ * I don't want to break applications that rely on this odd
+ * behavior. At the same time, the code is written and tested,
+ * so I didn't want to throw it away. Therefore, the code is here
+ * but disabled. In the future, we may wish to and an environment
+ * variable to enable it.
+ */
+
#if 0
- /* Call glGetString just to make sure that gc->server_major and
- * gc->server_minor are set. This version may be higher than we
- * can completely support, but it may imply support for some
- * extensions that we can support.
- *
- * For example, at the time of this writing, the client-side
- * library only supports upto core GL version 1.2. However, cubic
- * textures, multitexture, multisampling, and some other 1.3
- * features are supported. If the server reports back version
- * 1.3, but does not report all of those extensions, we will
- * enable them.
- */
- (void *) glGetString( GL_VERSION );
- major = gc->server_major,
- minor = gc->server_minor;
+ /* Call glGetString just to make sure that gc->server_major and
+ * gc->server_minor are set. This version may be higher than we
+ * can completely support, but it may imply support for some
+ * extensions that we can support.
+ *
+ * For example, at the time of this writing, the client-side
+ * library only supports upto core GL version 1.2. However, cubic
+ * textures, multitexture, multisampling, and some other 1.3
+ * features are supported. If the server reports back version
+ * 1.3, but does not report all of those extensions, we will
+ * enable them.
+ */
+ (void *) glGetString(GL_VERSION);
+ major = gc->server_major, minor = gc->server_minor;
#endif
- __glXCalculateUsableGLExtensions( gc, (char *) s, major, minor );
- XFree( s );
- s = gc->extensions;
- break;
- }
- }
- }
- return s;
+ __glXCalculateUsableGLExtensions(gc, (char *) s, major, minor);
+ XFree(s);
+ s = gc->extensions;
+ break;
+ }
+ }
+ }
+ return s;
}
-GLboolean __indirect_glIsEnabled(GLenum cap)
+GLboolean
+__indirect_glIsEnabled(GLenum cap)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- xGLXSingleReply reply;
- GLboolean retval = 0;
- GLintptr enable;
-
- if (!dpy) return 0;
-
- switch(cap) {
- case GL_VERTEX_ARRAY:
- case GL_NORMAL_ARRAY:
- case GL_COLOR_ARRAY:
- case GL_INDEX_ARRAY:
- case GL_EDGE_FLAG_ARRAY:
- case GL_SECONDARY_COLOR_ARRAY:
- case GL_FOG_COORD_ARRAY:
- retval = __glXGetArrayEnable( state, cap, 0, & enable );
- assert( retval );
- return (GLboolean) enable;
- break;
- case GL_TEXTURE_COORD_ARRAY:
- retval = __glXGetArrayEnable( state, GL_TEXTURE_COORD_ARRAY,
- __glXGetActiveTextureUnit( state ), & enable );
- assert( retval );
- return (GLboolean) enable;
- break;
- }
-
- __GLX_SINGLE_LOAD_VARIABLES();
- __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled,4);
- __GLX_SINGLE_PUT_LONG(0,cap);
- __GLX_SINGLE_READ_XREPLY();
- __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
- __GLX_SINGLE_END();
- return retval;
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ xGLXSingleReply reply;
+ GLboolean retval = 0;
+ GLintptr enable;
+
+ if (!dpy)
+ return 0;
+
+ switch (cap) {
+ case GL_VERTEX_ARRAY:
+ case GL_NORMAL_ARRAY:
+ case GL_COLOR_ARRAY:
+ case GL_INDEX_ARRAY:
+ case GL_EDGE_FLAG_ARRAY:
+ case GL_SECONDARY_COLOR_ARRAY:
+ case GL_FOG_COORD_ARRAY:
+ retval = __glXGetArrayEnable(state, cap, 0, &enable);
+ assert(retval);
+ return (GLboolean) enable;
+ break;
+ case GL_TEXTURE_COORD_ARRAY:
+ retval = __glXGetArrayEnable(state, GL_TEXTURE_COORD_ARRAY,
+ __glXGetActiveTextureUnit(state), &enable);
+ assert(retval);
+ return (GLboolean) enable;
+ break;
+ }
+
+ __GLX_SINGLE_LOAD_VARIABLES();
+ __GLX_SINGLE_BEGIN(X_GLsop_IsEnabled, 4);
+ __GLX_SINGLE_PUT_LONG(0, cap);
+ __GLX_SINGLE_READ_XREPLY();
+ __GLX_SINGLE_GET_RETVAL(retval, GLboolean);
+ __GLX_SINGLE_END();
+ return retval;
}
-void __indirect_glGetPointerv(GLenum pname, void **params)
+void
+__indirect_glGetPointerv(GLenum pname, void **params)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
- Display *dpy = gc->currentDpy;
-
- if (!dpy) return;
-
- switch(pname) {
- case GL_VERTEX_ARRAY_POINTER:
- case GL_NORMAL_ARRAY_POINTER:
- case GL_COLOR_ARRAY_POINTER:
- case GL_INDEX_ARRAY_POINTER:
- case GL_EDGE_FLAG_ARRAY_POINTER:
- __glXGetArrayPointer( state, pname - GL_VERTEX_ARRAY_POINTER
- + GL_VERTEX_ARRAY,
- 0, params );
- return;
- case GL_TEXTURE_COORD_ARRAY_POINTER:
- __glXGetArrayPointer( state, GL_TEXTURE_COORD_ARRAY,
- __glXGetActiveTextureUnit( state ), params );
- return;
- case GL_SECONDARY_COLOR_ARRAY_POINTER:
- case GL_FOG_COORD_ARRAY_POINTER:
- __glXGetArrayPointer( state, pname - GL_FOG_COORD_ARRAY_POINTER
- + GL_FOG_COORD_ARRAY,
- 0, params );
- return;
- case GL_FEEDBACK_BUFFER_POINTER:
- *params = (void *)gc->feedbackBuf;
- return;
- case GL_SELECTION_BUFFER_POINTER:
- *params = (void *)gc->selectBuf;
- return;
- default:
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
+ Display *dpy = gc->currentDpy;
+
+ if (!dpy)
+ return;
+
+ switch (pname) {
+ case GL_VERTEX_ARRAY_POINTER:
+ case GL_NORMAL_ARRAY_POINTER:
+ case GL_COLOR_ARRAY_POINTER:
+ case GL_INDEX_ARRAY_POINTER:
+ case GL_EDGE_FLAG_ARRAY_POINTER:
+ __glXGetArrayPointer(state, pname - GL_VERTEX_ARRAY_POINTER
+ + GL_VERTEX_ARRAY, 0, params);
+ return;
+ case GL_TEXTURE_COORD_ARRAY_POINTER:
+ __glXGetArrayPointer(state, GL_TEXTURE_COORD_ARRAY,
+ __glXGetActiveTextureUnit(state), params);
+ return;
+ case GL_SECONDARY_COLOR_ARRAY_POINTER:
+ case GL_FOG_COORD_ARRAY_POINTER:
+ __glXGetArrayPointer(state, pname - GL_FOG_COORD_ARRAY_POINTER
+ + GL_FOG_COORD_ARRAY, 0, params);
+ return;
+ case GL_FEEDBACK_BUFFER_POINTER:
+ *params = (void *) gc->feedbackBuf;
+ return;
+ case GL_SELECTION_BUFFER_POINTER:
+ *params = (void *) gc->selectBuf;
+ return;
+ default:
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
}
-
diff --git a/src/glx/x11/singlepix.c b/src/glx/x11/singlepix.c
index a093931bd2c..032696a5403 100644
--- a/src/glx/x11/singlepix.c
+++ b/src/glx/x11/singlepix.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -36,153 +37,160 @@
#include "glapioffsets.h"
#include <GL/glxproto.h>
-void __indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
- GLvoid *row, GLvoid *column, GLvoid *span)
+void
+__indirect_glGetSeparableFilter(GLenum target, GLenum format, GLenum type,
+ GLvoid * row, GLvoid * column, GLvoid * span)
{
- __GLX_SINGLE_DECLARE_VARIABLES();
- const __GLXattribute * state;
- xGLXGetSeparableFilterReply reply;
- GLubyte *rowBuf, *colBuf;
-
- if (!dpy) return;
- __GLX_SINGLE_LOAD_VARIABLES();
- state = gc->client_state_private;
-
- /* Send request */
- __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
- __GLX_SINGLE_PUT_LONG(0,target);
- __GLX_SINGLE_PUT_LONG(4,format);
- __GLX_SINGLE_PUT_LONG(8,type);
- __GLX_SINGLE_PUT_CHAR(12,state->storePack.swapEndian);
- __GLX_SINGLE_READ_XREPLY();
- compsize = reply.length << 2;
-
- if (compsize != 0) {
- GLint width, height;
- GLint widthsize, heightsize;
-
- width = reply.width;
- height = reply.height;
-
- widthsize = __glImageSize(width,1,1,format, type, 0);
- heightsize = __glImageSize(height,1,1,format, type, 0);
-
- /* Allocate a holding buffer to transform the data from */
- rowBuf = (GLubyte*) Xmalloc(widthsize);
- if (!rowBuf) {
- /* Throw data away */
- _XEatData(dpy, compsize);
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- UnlockDisplay(dpy);
- SyncHandle();
- return;
- } else {
- __GLX_SINGLE_GET_CHAR_ARRAY(((char*)rowBuf),widthsize);
- __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
- Xfree((char*) rowBuf);
- }
- colBuf = (GLubyte*) Xmalloc(heightsize);
- if (!colBuf) {
- /* Throw data away */
- _XEatData(dpy, compsize - __GLX_PAD(widthsize));
- __glXSetError(gc, GL_OUT_OF_MEMORY);
- UnlockDisplay(dpy);
- SyncHandle();
- return;
- } else {
- __GLX_SINGLE_GET_CHAR_ARRAY(((char*)colBuf),heightsize);
- __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
- Xfree((char*) colBuf);
- }
- } else {
- /*
- ** don't modify user's buffer.
- */
- }
- __GLX_SINGLE_END();
-
+ __GLX_SINGLE_DECLARE_VARIABLES();
+ const __GLXattribute *state;
+ xGLXGetSeparableFilterReply reply;
+ GLubyte *rowBuf, *colBuf;
+
+ if (!dpy)
+ return;
+ __GLX_SINGLE_LOAD_VARIABLES();
+ state = gc->client_state_private;
+
+ /* Send request */
+ __GLX_SINGLE_BEGIN(X_GLsop_GetSeparableFilter, __GLX_PAD(13));
+ __GLX_SINGLE_PUT_LONG(0, target);
+ __GLX_SINGLE_PUT_LONG(4, format);
+ __GLX_SINGLE_PUT_LONG(8, type);
+ __GLX_SINGLE_PUT_CHAR(12, state->storePack.swapEndian);
+ __GLX_SINGLE_READ_XREPLY();
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ GLint width, height;
+ GLint widthsize, heightsize;
+
+ width = reply.width;
+ height = reply.height;
+
+ widthsize = __glImageSize(width, 1, 1, format, type, 0);
+ heightsize = __glImageSize(height, 1, 1, format, type, 0);
+
+ /* Allocate a holding buffer to transform the data from */
+ rowBuf = (GLubyte *) Xmalloc(widthsize);
+ if (!rowBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ }
+ else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char *) rowBuf), widthsize);
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, rowBuf, row);
+ Xfree((char *) rowBuf);
+ }
+ colBuf = (GLubyte *) Xmalloc(heightsize);
+ if (!colBuf) {
+ /* Throw data away */
+ _XEatData(dpy, compsize - __GLX_PAD(widthsize));
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ }
+ else {
+ __GLX_SINGLE_GET_CHAR_ARRAY(((char *) colBuf), heightsize);
+ __glEmptyImage(gc, 1, height, 1, 1, format, type, colBuf, column);
+ Xfree((char *) colBuf);
+ }
+ }
+ else {
+ /*
+ ** don't modify user's buffer.
+ */
+ }
+ __GLX_SINGLE_END();
+
}
#define CONCAT(a,b) a ## b
#define NAME(o) CONCAT(gl_dispatch_stub_, o)
-void NAME(_gloffset_GetSeparableFilter)(GLenum target, GLenum format, GLenum type,
- GLvoid *row, GLvoid *column, GLvoid *span)
+void NAME(_gloffset_GetSeparableFilter) (GLenum target, GLenum format,
+ GLenum type, GLvoid * row,
+ GLvoid * column, GLvoid * span)
{
- __GLXcontext * const gc = __glXGetCurrentContext();
+ __GLXcontext *const gc = __glXGetCurrentContext();
#ifdef GLX_DIRECT_RENDERING
- if (gc->driContext) {
- CALL_GetSeparableFilter(GET_DISPATCH(),
- (target, format, type, row, column, span));
- return;
- } else
+ if (gc->driContext) {
+ CALL_GetSeparableFilter(GET_DISPATCH(),
+ (target, format, type, row, column, span));
+ return;
+ }
+ else
#endif
- {
- Display *const dpy = gc->currentDpy;
- const GLuint cmdlen = __GLX_PAD(13);
-
- if (dpy != NULL) {
- const __GLXattribute * const state = gc->client_state_private;
- xGLXGetSeparableFilterReply reply;
- GLubyte const *pc =
- __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
- X_GLvop_GetSeparableFilterEXT, cmdlen);
- unsigned compsize;
-
-
- (void) memcpy((void *) (pc + 0), (void *) (&target), 4);
- (void) memcpy((void *) (pc + 4), (void *) (&format), 4);
- (void) memcpy((void *) (pc + 8), (void *) (&type), 4);
- *(int8_t *) (pc + 12) = state->storePack.swapEndian;
-
- (void) _XReply(dpy, (xReply *) & reply, 0, False);
-
- compsize = reply.length << 2;
-
- if (compsize != 0) {
- const GLint width = reply.width;
- const GLint height = reply.height;
- const GLint widthsize =
- __glImageSize(width, 1, 1, format, type, 0);
- const GLint heightsize =
- __glImageSize(height, 1, 1, format, type, 0);
- GLubyte * const buf =
- (GLubyte*) Xmalloc((widthsize > heightsize) ? widthsize : heightsize);
-
- if (buf == NULL) {
- /* Throw data away */
- _XEatData(dpy, compsize);
- __glXSetError(gc, GL_OUT_OF_MEMORY);
-
- UnlockDisplay(dpy);
- SyncHandle();
- return;
- } else {
- int extra;
-
- extra = 4 - (widthsize & 3);
- _XRead(dpy, (char *)buf, widthsize);
- if (extra < 4) {
- _XEatData(dpy, extra);
- }
-
- __glEmptyImage(gc, 1, width, 1, 1, format, type, buf,
- row);
-
- extra = 4 - (heightsize & 3);
- _XRead(dpy, (char *)buf, heightsize);
- if (extra < 4) {
- _XEatData(dpy, extra);
- }
-
- __glEmptyImage(gc, 1, height, 1, 1, format, type, buf,
- column);
-
- Xfree((char*) buf);
- }
- }
- }
- }
+ {
+ Display *const dpy = gc->currentDpy;
+ const GLuint cmdlen = __GLX_PAD(13);
+
+ if (dpy != NULL) {
+ const __GLXattribute *const state = gc->client_state_private;
+ xGLXGetSeparableFilterReply reply;
+ GLubyte const *pc =
+ __glXSetupVendorRequest(gc, X_GLXVendorPrivateWithReply,
+ X_GLvop_GetSeparableFilterEXT, cmdlen);
+ unsigned compsize;
+
+
+ (void) memcpy((void *) (pc + 0), (void *) (&target), 4);
+ (void) memcpy((void *) (pc + 4), (void *) (&format), 4);
+ (void) memcpy((void *) (pc + 8), (void *) (&type), 4);
+ *(int8_t *) (pc + 12) = state->storePack.swapEndian;
+
+ (void) _XReply(dpy, (xReply *) & reply, 0, False);
+
+ compsize = reply.length << 2;
+
+ if (compsize != 0) {
+ const GLint width = reply.width;
+ const GLint height = reply.height;
+ const GLint widthsize =
+ __glImageSize(width, 1, 1, format, type, 0);
+ const GLint heightsize =
+ __glImageSize(height, 1, 1, format, type, 0);
+ GLubyte *const buf =
+ (GLubyte *) Xmalloc((widthsize > heightsize) ? widthsize :
+ heightsize);
+
+ if (buf == NULL) {
+ /* Throw data away */
+ _XEatData(dpy, compsize);
+ __glXSetError(gc, GL_OUT_OF_MEMORY);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return;
+ }
+ else {
+ int extra;
+
+ extra = 4 - (widthsize & 3);
+ _XRead(dpy, (char *) buf, widthsize);
+ if (extra < 4) {
+ _XEatData(dpy, extra);
+ }
+
+ __glEmptyImage(gc, 1, width, 1, 1, format, type, buf, row);
+
+ extra = 4 - (heightsize & 3);
+ _XRead(dpy, (char *) buf, heightsize);
+ if (extra < 4) {
+ _XEatData(dpy, extra);
+ }
+
+ __glEmptyImage(gc, 1, height, 1, 1, format, type, buf, column);
+
+ Xfree((char *) buf);
+ }
+ }
+ }
+ }
}
diff --git a/src/glx/x11/vertarr.c b/src/glx/x11/vertarr.c
index 031aa48427f..23f6370261d 100644
--- a/src/glx/x11/vertarr.c
+++ b/src/glx/x11/vertarr.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
* Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
@@ -45,153 +46,168 @@
* happen.
*/
/*@{*/
-void __indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride,
- GLsizei count, const GLvoid * pointer )
+void
+__indirect_glColorPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer)
{
- (void) count; __indirect_glColorPointer( size, type, stride, pointer );
+ (void) count;
+ __indirect_glColorPointer(size, type, stride, pointer);
}
-void __indirect_glEdgeFlagPointerEXT(GLsizei stride,
- GLsizei count, const GLboolean * pointer )
+void
+__indirect_glEdgeFlagPointerEXT(GLsizei stride,
+ GLsizei count, const GLboolean * pointer)
{
- (void) count; __indirect_glEdgeFlagPointer( stride, pointer );
+ (void) count;
+ __indirect_glEdgeFlagPointer(stride, pointer);
}
-void __indirect_glIndexPointerEXT(GLenum type, GLsizei stride,
- GLsizei count, const GLvoid * pointer )
+void
+__indirect_glIndexPointerEXT(GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer)
{
- (void) count; __indirect_glIndexPointer( type, stride, pointer );
+ (void) count;
+ __indirect_glIndexPointer(type, stride, pointer);
}
-void __indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
- const GLvoid * pointer )
+void
+__indirect_glNormalPointerEXT(GLenum type, GLsizei stride, GLsizei count,
+ const GLvoid * pointer)
{
- (void) count; __indirect_glNormalPointer( type, stride, pointer );
+ (void) count;
+ __indirect_glNormalPointer(type, stride, pointer);
}
-void __indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
- GLsizei count, const GLvoid * pointer )
+void
+__indirect_glTexCoordPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer)
{
- (void) count; __indirect_glTexCoordPointer( size, type, stride, pointer );
+ (void) count;
+ __indirect_glTexCoordPointer(size, type, stride, pointer);
}
-void __indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride,
- GLsizei count, const GLvoid * pointer )
+void
+__indirect_glVertexPointerEXT(GLint size, GLenum type, GLsizei stride,
+ GLsizei count, const GLvoid * pointer)
{
- (void) count; __indirect_glVertexPointer( size, type, stride, pointer );
+ (void) count;
+ __indirect_glVertexPointer(size, type, stride, pointer);
}
+
/*@}*/
/*****************************************************************************/
-void __indirect_glInterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer)
+void
+__indirect_glInterleavedArrays(GLenum format, GLsizei stride,
+ const GLvoid * pointer)
{
- __GLXcontext *gc = __glXGetCurrentContext();
- __GLXattribute * state = (__GLXattribute *)(gc->client_state_private);
+ __GLXcontext *gc = __glXGetCurrentContext();
+ __GLXattribute *state = (__GLXattribute *) (gc->client_state_private);
#define NONE {0, 0, 0}
#define F(x) {GL_FLOAT, x, x * sizeof(GLfloat)}
#define UB4 {GL_UNSIGNED_BYTE, 4, 4 * sizeof(GLubyte)}
- /* Each row in this array describes the elements of a particular
- * interleaved array mode. Each column describes, in the order in which
- * they appear in the interleaved arrays, one of the four possible types
- * of vertex data that can appear in an interleaved array.
- */
- struct {
+ /* Each row in this array describes the elements of a particular
+ * interleaved array mode. Each column describes, in the order in which
+ * they appear in the interleaved arrays, one of the four possible types
+ * of vertex data that can appear in an interleaved array.
+ */
+ struct
+ {
/**
* The enum describing the GL type, as would be passed to the
* appropriate gl*Pointer function.
*/
- GLushort type;
+ GLushort type;
/**
* Number of elements in the subarray, as would be passed (as the
* \c size parameter) to the appropriate gl*Pointer function.
*/
- GLubyte count;
-
+ GLubyte count;
+
/**
* True size of a single element in the subarray, as would be passed
* (as the \c stride parameter) to the appropriate gl*Pointer
* function.
*/
- GLubyte size;
- }
- static const modes[14][4] = {
+ GLubyte size;
+ }
+ static const modes[14][4] = {
/* texture color normal vertex */
- {NONE, NONE, NONE, F(2)}, /* GL_V2F */
- {NONE, NONE, NONE, F(3)}, /* GL_V3F */
- {NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */
- {NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */
- {NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */
- {NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */
- {NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */
- {F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */
- {F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */
- {F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */
- {F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */
- {F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */
- {F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */
- {F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */
- };
+ {NONE, NONE, NONE, F(2)}, /* GL_V2F */
+ {NONE, NONE, NONE, F(3)}, /* GL_V3F */
+ {NONE, UB4, NONE, F(2)}, /* GL_C4UB_V2F */
+ {NONE, UB4, NONE, F(3)}, /* GL_C4UB_V3F */
+ {NONE, F(3), NONE, F(3)}, /* GL_C3F_V3F */
+ {NONE, NONE, F(3), F(3)}, /* GL_N3F_V3F */
+ {NONE, F(4), F(3), F(3)}, /* GL_C4F_N3F_V3F */
+ {F(2), NONE, NONE, F(3)}, /* GL_T2F_V3F */
+ {F(4), NONE, NONE, F(4)}, /* GL_T4F_V4F */
+ {F(2), UB4, NONE, F(3)}, /* GL_T2F_C4UB_V3F */
+ {F(2), F(3), NONE, F(3)}, /* GL_T2F_C3F_V3F */
+ {F(2), NONE, F(3), F(3)}, /* GL_T2F_N3F_V3F */
+ {F(2), F(4), F(3), F(3)}, /* GL_T2F_C4F_N3F_V3F */
+ {F(4), F(4), F(3), F(4)}, /* GL_T4F_C4F_N3F_V4F */
+ };
#undef NONE
#undef F
#undef UB4
- GLint trueStride, size;
- int offsets[4];
- unsigned i;
- const int idx = format - GL_V2F;
-
-
- /* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx
- * is just the format biased by -GL_V2F, all valid idx values are on the
- * range [0, 0x0D].
- */
- if ( (idx < 0) || (idx > 0x0D) ) {
- __glXSetError(gc, GL_INVALID_ENUM);
- return;
- }
-
- if ( stride < 0 ) {
- __glXSetError(gc, GL_INVALID_VALUE);
- return;
- }
-
-
- /* If the 'count' for a subarray is non-zero, then the offset of its
- * first element is at the currently accumulated 'size'.
- */
- size = 0;
- for ( i = 0 ; i < 4 ; i++ ) {
- offsets[i] = (modes[idx][i].count != 0) ? size : -1;
- size += modes[idx][i].size;
- }
-
- trueStride = (stride == 0) ? size : stride;
-
- __glXArrayDisableAll( state );
-
- if ( offsets[0] >= 0 ) {
- __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
- __indirect_glTexCoordPointer( modes[idx][0].count, GL_FLOAT,
- trueStride,
- (const char *) pointer );
- }
- if ( offsets[1] >= 0 ) {
- __indirect_glEnableClientState(GL_COLOR_ARRAY);
- __indirect_glColorPointer( modes[idx][1].count, modes[idx][1].type,
- trueStride,
- (const char *) pointer + offsets[1] );
- }
- if ( offsets[2] >= 0 ) {
- __indirect_glEnableClientState(GL_NORMAL_ARRAY);
- __indirect_glNormalPointer( GL_FLOAT, trueStride,
- (const char *)pointer + offsets[2] );
- }
- __indirect_glEnableClientState(GL_VERTEX_ARRAY);
- __indirect_glVertexPointer( modes[idx][3].count, GL_FLOAT,
- trueStride,
- (const char *)pointer + offsets[3] );
+ GLint trueStride, size;
+ int offsets[4];
+ unsigned i;
+ const int idx = format - GL_V2F;
+
+
+ /* All valid formats are on the range [GL_V2F, GL_V2F+0x0D]. Since idx
+ * is just the format biased by -GL_V2F, all valid idx values are on the
+ * range [0, 0x0D].
+ */
+ if ((idx < 0) || (idx > 0x0D)) {
+ __glXSetError(gc, GL_INVALID_ENUM);
+ return;
+ }
+
+ if (stride < 0) {
+ __glXSetError(gc, GL_INVALID_VALUE);
+ return;
+ }
+
+
+ /* If the 'count' for a subarray is non-zero, then the offset of its
+ * first element is at the currently accumulated 'size'.
+ */
+ size = 0;
+ for (i = 0; i < 4; i++) {
+ offsets[i] = (modes[idx][i].count != 0) ? size : -1;
+ size += modes[idx][i].size;
+ }
+
+ trueStride = (stride == 0) ? size : stride;
+
+ __glXArrayDisableAll(state);
+
+ if (offsets[0] >= 0) {
+ __indirect_glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ __indirect_glTexCoordPointer(modes[idx][0].count, GL_FLOAT,
+ trueStride, (const char *) pointer);
+ }
+ if (offsets[1] >= 0) {
+ __indirect_glEnableClientState(GL_COLOR_ARRAY);
+ __indirect_glColorPointer(modes[idx][1].count, modes[idx][1].type,
+ trueStride,
+ (const char *) pointer + offsets[1]);
+ }
+ if (offsets[2] >= 0) {
+ __indirect_glEnableClientState(GL_NORMAL_ARRAY);
+ __indirect_glNormalPointer(GL_FLOAT, trueStride,
+ (const char *) pointer + offsets[2]);
+ }
+ __indirect_glEnableClientState(GL_VERTEX_ARRAY);
+ __indirect_glVertexPointer(modes[idx][3].count, GL_FLOAT,
+ trueStride,
+ (const char *) pointer + offsets[3]);
}
diff --git a/src/glx/x11/xf86dri.h b/src/glx/x11/xf86dri.h
index 2aec3211dbe..30e2c9e5348 100644
--- a/src/glx/x11/xf86dri.h
+++ b/src/glx/x11/xf86dri.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -41,79 +42,80 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <X11/Xfuncproto.h>
#include <xf86drm.h>
-#define X_XF86DRIQueryVersion 0
-#define X_XF86DRIQueryDirectRenderingCapable 1
-#define X_XF86DRIOpenConnection 2
-#define X_XF86DRICloseConnection 3
-#define X_XF86DRIGetClientDriverName 4
-#define X_XF86DRICreateContext 5
-#define X_XF86DRIDestroyContext 6
-#define X_XF86DRICreateDrawable 7
-#define X_XF86DRIDestroyDrawable 8
-#define X_XF86DRIGetDrawableInfo 9
-#define X_XF86DRIGetDeviceInfo 10
+#define X_XF86DRIQueryVersion 0
+#define X_XF86DRIQueryDirectRenderingCapable 1
+#define X_XF86DRIOpenConnection 2
+#define X_XF86DRICloseConnection 3
+#define X_XF86DRIGetClientDriverName 4
+#define X_XF86DRICreateContext 5
+#define X_XF86DRIDestroyContext 6
+#define X_XF86DRICreateDrawable 7
+#define X_XF86DRIDestroyDrawable 8
+#define X_XF86DRIGetDrawableInfo 9
+#define X_XF86DRIGetDeviceInfo 10
#define X_XF86DRIAuthConnection 11
-#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
-#define X_XF86DRICloseFullScreen 13 /* Deprecated */
+#define X_XF86DRIOpenFullScreen 12 /* Deprecated */
+#define X_XF86DRICloseFullScreen 13 /* Deprecated */
-#define XF86DRINumberEvents 0
+#define XF86DRINumberEvents 0
-#define XF86DRIClientNotLocal 0
-#define XF86DRIOperationNotSupported 1
-#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
+#define XF86DRIClientNotLocal 0
+#define XF86DRIOperationNotSupported 1
+#define XF86DRINumberErrors (XF86DRIOperationNotSupported + 1)
#ifndef _XF86DRI_SERVER_
_XFUNCPROTOBEGIN
+ Bool XF86DRIQueryExtension(Display * dpy, int *event_base,
+ int *error_base);
-Bool XF86DRIQueryExtension( Display *dpy, int *event_base, int *error_base );
+Bool XF86DRIQueryVersion(Display * dpy, int *majorVersion, int *minorVersion,
+ int *patchVersion);
-Bool XF86DRIQueryVersion( Display *dpy, int *majorVersion, int *minorVersion,
- int *patchVersion );
+Bool XF86DRIQueryDirectRenderingCapable(Display * dpy, int screen,
+ Bool * isCapable);
-Bool XF86DRIQueryDirectRenderingCapable( Display *dpy, int screen,
- Bool *isCapable );
+Bool XF86DRIOpenConnection(Display * dpy, int screen, drm_handle_t * hSAREA,
+ char **busIDString);
-Bool XF86DRIOpenConnection( Display *dpy, int screen, drm_handle_t *hSAREA,
- char **busIDString );
+Bool XF86DRIAuthConnection(Display * dpy, int screen, drm_magic_t magic);
-Bool XF86DRIAuthConnection( Display *dpy, int screen, drm_magic_t magic );
+Bool XF86DRICloseConnection(Display * dpy, int screen);
-Bool XF86DRICloseConnection( Display *dpy, int screen );
+Bool XF86DRIGetClientDriverName(Display * dpy, int screen,
+ int *ddxDriverMajorVersion,
+ int *ddxDriverMinorVersion,
+ int *ddxDriverPatchVersion,
+ char **clientDriverName);
-Bool XF86DRIGetClientDriverName( Display *dpy, int screen,
- int *ddxDriverMajorVersion, int *ddxDriverMinorVersion,
- int *ddxDriverPatchVersion, char **clientDriverName );
+Bool XF86DRICreateContext(Display * dpy, int screen, Visual * visual,
+ XID * ptr_to_returned_context_id,
+ drm_context_t * hHWContext);
-Bool XF86DRICreateContext( Display *dpy, int screen, Visual *visual,
- XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+Bool XF86DRICreateContextWithConfig(Display * dpy, int screen, int configID,
+ XID * ptr_to_returned_context_id,
+ drm_context_t * hHWContext);
-Bool XF86DRICreateContextWithConfig( Display *dpy, int screen, int configID,
- XID *ptr_to_returned_context_id, drm_context_t *hHWContext );
+extern Bool XF86DRIDestroyContext(Display * dpy, int screen, XID context_id);
-extern Bool XF86DRIDestroyContext( Display *dpy, int screen,
- XID context_id );
+extern Bool XF86DRICreateDrawable(Display * dpy, int screen,
+ XID drawable, drm_drawable_t * hHWDrawable);
-extern Bool XF86DRICreateDrawable( Display *dpy, int screen,
- XID drawable, drm_drawable_t *hHWDrawable );
+extern Bool XF86DRIDestroyDrawable(Display * dpy, int screen, XID drawable);
-extern Bool XF86DRIDestroyDrawable( Display *dpy, int screen,
- XID drawable);
+Bool XF86DRIGetDrawableInfo(Display * dpy, int screen, Drawable drawable,
+ unsigned int *index, unsigned int *stamp,
+ int *X, int *Y, int *W, int *H,
+ int *numClipRects, drm_clip_rect_t ** pClipRects,
+ int *backX, int *backY,
+ int *numBackClipRects,
+ drm_clip_rect_t ** pBackClipRects);
-Bool XF86DRIGetDrawableInfo( Display *dpy, int screen, Drawable drawable,
- unsigned int *index, unsigned int *stamp,
- int *X, int *Y, int *W, int *H,
- int *numClipRects, drm_clip_rect_t ** pClipRects,
- int *backX, int *backY,
- int *numBackClipRects, drm_clip_rect_t **pBackClipRects );
-
-Bool XF86DRIGetDeviceInfo( Display *dpy, int screen,
- drm_handle_t *hFrameBuffer, int *fbOrigin, int *fbSize,
- int *fbStride, int *devPrivateSize, void **pDevPrivate );
+Bool XF86DRIGetDeviceInfo(Display * dpy, int screen,
+ drm_handle_t * hFrameBuffer, int *fbOrigin,
+ int *fbSize, int *fbStride, int *devPrivateSize,
+ void **pDevPrivate);
_XFUNCPROTOEND
-
#endif /* _XF86DRI_SERVER_ */
-
#endif /* _XF86DRI_H_ */
-
diff --git a/src/glx/x11/xf86dristr.h b/src/glx/x11/xf86dristr.h
index b834bd1a1a0..f3d13297ddf 100644
--- a/src/glx/x11/xf86dristr.h
+++ b/src/glx/x11/xf86dristr.h
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/**************************************************************************
Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
@@ -54,287 +55,312 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define XF86DRI_MINOR_VERSION 1
#define XF86DRI_PATCH_VERSION 0
-typedef struct _XF86DRIQueryVersion {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIQueryVersion */
- CARD16 length B16;
+typedef struct _XF86DRIQueryVersion
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIQueryVersion */
+ CARD16 length B16;
} xXF86DRIQueryVersionReq;
#define sz_xXF86DRIQueryVersionReq 4
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD16 majorVersion B16; /* major version of DRI protocol */
- CARD16 minorVersion B16; /* minor version of DRI protocol */
- CARD32 patchVersion B32; /* patch version of DRI protocol */
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD16 majorVersion B16; /* major version of DRI protocol */
+ CARD16 minorVersion B16; /* minor version of DRI protocol */
+ CARD32 patchVersion B32; /* patch version of DRI protocol */
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRIQueryVersionReply;
#define sz_xXF86DRIQueryVersionReply 32
-typedef struct _XF86DRIQueryDirectRenderingCapable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _XF86DRIQueryDirectRenderingCapable
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* X_DRIQueryDirectRenderingCapable */
+ CARD16 length B16;
+ CARD32 screen B32;
} xXF86DRIQueryDirectRenderingCapableReq;
#define sz_xXF86DRIQueryDirectRenderingCapableReq 8
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- BOOL isCapable;
- BOOL pad2;
- BOOL pad3;
- BOOL pad4;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
- CARD32 pad9 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ BOOL isCapable;
+ BOOL pad2;
+ BOOL pad3;
+ BOOL pad4;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
+ CARD32 pad9 B32;
} xXF86DRIQueryDirectRenderingCapableReply;
#define sz_xXF86DRIQueryDirectRenderingCapableReply 32
-typedef struct _XF86DRIOpenConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIOpenConnection */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _XF86DRIOpenConnection
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
} xXF86DRIOpenConnectionReq;
#define sz_xXF86DRIOpenConnectionReq 8
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hSAREALow B32;
- CARD32 hSAREAHigh B32;
- CARD32 busIdStringLength B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
- CARD32 pad8 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hSAREALow B32;
+ CARD32 hSAREAHigh B32;
+ CARD32 busIdStringLength B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
+ CARD32 pad8 B32;
} xXF86DRIOpenConnectionReply;
#define sz_xXF86DRIOpenConnectionReply 32
-typedef struct _XF86DRIAuthConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 magic B32;
+typedef struct _XF86DRIAuthConnection
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 magic B32;
} xXF86DRIAuthConnectionReq;
#define sz_xXF86DRIAuthConnectionReq 12
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 authenticated B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 authenticated B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRIAuthConnectionReply;
#define zx_xXF86DRIAuthConnectionReply 32
-typedef struct _XF86DRICloseConnection {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseConnection */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _XF86DRICloseConnection
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseConnection */
+ CARD16 length B16;
+ CARD32 screen B32;
} xXF86DRICloseConnectionReq;
#define sz_xXF86DRICloseConnectionReq 8
-typedef struct _XF86DRIGetClientDriverName {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetClientDriverName */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _XF86DRIGetClientDriverName
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetClientDriverName */
+ CARD16 length B16;
+ CARD32 screen B32;
} xXF86DRIGetClientDriverNameReq;
#define sz_xXF86DRIGetClientDriverNameReq 8
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 ddxDriverMajorVersion B32;
- CARD32 ddxDriverMinorVersion B32;
- CARD32 ddxDriverPatchVersion B32;
- CARD32 clientDriverNameLength B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 ddxDriverMajorVersion B32;
+ CARD32 ddxDriverMinorVersion B32;
+ CARD32 ddxDriverPatchVersion B32;
+ CARD32 clientDriverNameLength B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRIGetClientDriverNameReply;
#define sz_xXF86DRIGetClientDriverNameReply 32
-typedef struct _XF86DRICreateContext {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateContext */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 visual B32;
- CARD32 context B32;
+typedef struct _XF86DRICreateContext
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 visual B32;
+ CARD32 context B32;
} xXF86DRICreateContextReq;
#define sz_xXF86DRICreateContextReq 16
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hHWContext B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWContext B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRICreateContextReply;
#define sz_xXF86DRICreateContextReply 32
-typedef struct _XF86DRIDestroyContext {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroyContext */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 context B32;
+typedef struct _XF86DRIDestroyContext
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyContext */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 context B32;
} xXF86DRIDestroyContextReq;
#define sz_xXF86DRIDestroyContextReq 12
-typedef struct _XF86DRICreateDrawable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICreateDrawable */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _XF86DRICreateDrawable
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICreateDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xXF86DRICreateDrawableReq;
#define sz_xXF86DRICreateDrawableReq 12
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hHWDrawable B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hHWDrawable B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRICreateDrawableReply;
#define sz_xXF86DRICreateDrawableReply 32
-typedef struct _XF86DRIDestroyDrawable {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIDestroyDrawable */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _XF86DRIDestroyDrawable
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIDestroyDrawable */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xXF86DRIDestroyDrawableReq;
#define sz_xXF86DRIDestroyDrawableReq 12
-typedef struct _XF86DRIGetDrawableInfo {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetDrawableInfo */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _XF86DRIGetDrawableInfo
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDrawableInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xXF86DRIGetDrawableInfoReq;
#define sz_xXF86DRIGetDrawableInfoReq 12
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 drawableTableIndex B32;
- CARD32 drawableTableStamp B32;
- INT16 drawableX B16;
- INT16 drawableY B16;
- INT16 drawableWidth B16;
- INT16 drawableHeight B16;
- CARD32 numClipRects B32;
- INT16 backX B16;
- INT16 backY B16;
- CARD32 numBackClipRects B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 drawableTableIndex B32;
+ CARD32 drawableTableStamp B32;
+ INT16 drawableX B16;
+ INT16 drawableY B16;
+ INT16 drawableWidth B16;
+ INT16 drawableHeight B16;
+ CARD32 numClipRects B32;
+ INT16 backX B16;
+ INT16 backY B16;
+ CARD32 numBackClipRects B32;
} xXF86DRIGetDrawableInfoReply;
#define sz_xXF86DRIGetDrawableInfoReply 36
-typedef struct _XF86DRIGetDeviceInfo {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIGetDeviceInfo */
- CARD16 length B16;
- CARD32 screen B32;
+typedef struct _XF86DRIGetDeviceInfo
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIGetDeviceInfo */
+ CARD16 length B16;
+ CARD32 screen B32;
} xXF86DRIGetDeviceInfoReq;
#define sz_xXF86DRIGetDeviceInfoReq 8
-typedef struct {
- BYTE type; /* X_Reply */
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 hFrameBufferLow B32;
- CARD32 hFrameBufferHigh B32;
- CARD32 framebufferOrigin B32;
- CARD32 framebufferSize B32;
- CARD32 framebufferStride B32;
- CARD32 devPrivateSize B32;
+typedef struct
+{
+ BYTE type; /* X_Reply */
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 hFrameBufferLow B32;
+ CARD32 hFrameBufferHigh B32;
+ CARD32 framebufferOrigin B32;
+ CARD32 framebufferSize B32;
+ CARD32 framebufferStride B32;
+ CARD32 devPrivateSize B32;
} xXF86DRIGetDeviceInfoReply;
#define sz_xXF86DRIGetDeviceInfoReply 32
-typedef struct _XF86DRIOpenFullScreen {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRIOpenFullScreen */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _XF86DRIOpenFullScreen
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRIOpenFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xXF86DRIOpenFullScreenReq;
#define sz_xXF86DRIOpenFullScreenReq 12
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 isFullScreen B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
+typedef struct
+{
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 isFullScreen B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
} xXF86DRIOpenFullScreenReply;
#define sz_xXF86DRIOpenFullScreenReply 32
-typedef struct _XF86DRICloseFullScreen {
- CARD8 reqType; /* always DRIReqCode */
- CARD8 driReqType; /* always X_DRICloseFullScreen */
- CARD16 length B16;
- CARD32 screen B32;
- CARD32 drawable B32;
+typedef struct _XF86DRICloseFullScreen
+{
+ CARD8 reqType; /* always DRIReqCode */
+ CARD8 driReqType; /* always X_DRICloseFullScreen */
+ CARD16 length B16;
+ CARD32 screen B32;
+ CARD32 drawable B32;
} xXF86DRICloseFullScreenReq;
#define sz_xXF86DRICloseFullScreenReq 12
-typedef struct {
- BYTE type;
- BOOL pad1;
- CARD16 sequenceNumber B16;
- CARD32 length B32;
- CARD32 pad2 B32;
- CARD32 pad3 B32;
- CARD32 pad4 B32;
- CARD32 pad5 B32;
- CARD32 pad6 B32;
- CARD32 pad7 B32;
+typedef struct
+{
+ BYTE type;
+ BOOL pad1;
+ CARD16 sequenceNumber B16;
+ CARD32 length B32;
+ CARD32 pad2 B32;
+ CARD32 pad3 B32;
+ CARD32 pad4 B32;
+ CARD32 pad5 B32;
+ CARD32 pad6 B32;
+ CARD32 pad7 B32;
} xXF86DRICloseFullScreenReply;
#define sz_xXF86DRICloseFullScreenReply 32
diff --git a/src/glx/x11/xfont.c b/src/glx/x11/xfont.c
index 6ec8c2d6bf6..8e46063a322 100644
--- a/src/glx/x11/xfont.c
+++ b/src/glx/x11/xfont.c
@@ -1,3 +1,4 @@
+/* -*- mode: c; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 3; coding: utf-8-unix -*- */
/*
* Mesa 3-D graphics library
* Version: 3.1
@@ -48,59 +49,56 @@
int debug_xfonts = 0;
static void
-dump_char_struct (XCharStruct *ch, char *prefix)
+dump_char_struct(XCharStruct * ch, char *prefix)
{
- printf ("%slbearing = %d, rbearing = %d, width = %d\n",
+ printf("%slbearing = %d, rbearing = %d, width = %d\n",
prefix, ch->lbearing, ch->rbearing, ch->width);
- printf ("%sascent = %d, descent = %d, attributes = %u\n",
+ printf("%sascent = %d, descent = %d, attributes = %u\n",
prefix, ch->ascent, ch->descent, (unsigned int) ch->attributes);
}
static void
-dump_font_struct (XFontStruct *font)
+dump_font_struct(XFontStruct * font)
{
- printf ("ascent = %d, descent = %d\n", font->ascent, font->descent);
- printf ("char_or_byte2 = (%u,%u)\n",
+ printf("ascent = %d, descent = %d\n", font->ascent, font->descent);
+ printf("char_or_byte2 = (%u,%u)\n",
font->min_char_or_byte2, font->max_char_or_byte2);
- printf ("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
- printf ("all_chars_exist = %s\n", font->all_chars_exist ? "True" :
-"False");
- printf ("default_char = %c (\\%03o)\n",
- (char) (isprint (font->default_char) ? font->default_char : ' '),
+ printf("byte1 = (%u,%u)\n", font->min_byte1, font->max_byte1);
+ printf("all_chars_exist = %s\n", font->all_chars_exist ? "True" : "False");
+ printf("default_char = %c (\\%03o)\n",
+ (char) (isprint(font->default_char) ? font->default_char : ' '),
font->default_char);
- dump_char_struct (&font->min_bounds, "min> ");
- dump_char_struct (&font->max_bounds, "max> ");
+ dump_char_struct(&font->min_bounds, "min> ");
+ dump_char_struct(&font->max_bounds, "max> ");
#if 0
- for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++)
- {
+ for (c = font->min_char_or_byte2; c <= font->max_char_or_byte2; c++) {
char prefix[8];
- sprintf (prefix, "%d> ", c);
- dump_char_struct (&font->per_char[c], prefix);
- }
+ sprintf(prefix, "%d> ", c);
+ dump_char_struct(&font->per_char[c], prefix);
+ }
#endif
}
static void
-dump_bitmap (unsigned int width, unsigned int height, GLubyte *bitmap)
+dump_bitmap(unsigned int width, unsigned int height, GLubyte * bitmap)
{
- unsigned int x, y;
-
- printf (" ");
- for (x = 0; x < 8*width; x++)
- printf ("%o", 7 - (x % 8));
- putchar ('\n');
- for (y = 0; y < height; y++)
- {
- printf ("%3o:", y);
- for (x = 0; x < 8*width; x++)
- putchar ((bitmap[width*(height - y - 1) + x/8] & (1 << (7 - (x %
-8))))
+ unsigned int x, y;
+
+ printf(" ");
+ for (x = 0; x < 8 * width; x++)
+ printf("%o", 7 - (x % 8));
+ putchar('\n');
+ for (y = 0; y < height; y++) {
+ printf("%3o:", y);
+ for (x = 0; x < 8 * width; x++)
+ putchar((bitmap[width * (height - y - 1) + x / 8] & (1 << (7 - (x %
+ 8))))
? '*' : '.');
- printf (" ");
+ printf(" ");
for (x = 0; x < width; x++)
- printf ("0x%02x, ", bitmap[width*(height - y - 1) + x]);
- putchar ('\n');
- }
+ printf("0x%02x, ", bitmap[width * (height - y - 1) + x]);
+ putchar('\n');
+ }
}
#endif /* DEBUG */
@@ -132,169 +130,172 @@ dump_bitmap (unsigned int width, unsigned int height, GLubyte *bitmap)
* Generate OpenGL-compatible bitmap.
*/
static void
-fill_bitmap (Display *dpy, Window win, GC gc,
- unsigned int width, unsigned int height,
- int x0, int y0, unsigned int c, GLubyte *bitmap)
+fill_bitmap(Display * dpy, Window win, GC gc,
+ unsigned int width, unsigned int height,
+ int x0, int y0, unsigned int c, GLubyte * bitmap)
{
- XImage *image;
- unsigned int x, y;
- Pixmap pixmap;
- XChar2b char2b;
-
- pixmap = XCreatePixmap (dpy, win, 8*width, height, 1);
- XSetForeground(dpy, gc, 0);
- XFillRectangle (dpy, pixmap, gc, 0, 0, 8*width, height);
- XSetForeground(dpy, gc, 1);
-
- char2b.byte1 = (c >> 8) & 0xff;
- char2b.byte2 = (c & 0xff);
-
- XDrawString16 (dpy, pixmap, gc, x0, y0, &char2b, 1);
-
- image = XGetImage (dpy, pixmap, 0, 0, 8*width, height, 1, XYPixmap);
- if (image) {
- /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
- for (y = 0; y < height; y++)
- for (x = 0; x < 8*width; x++)
- if (XGetPixel (image, x, y))
- bitmap[width*(height - y - 1) + x/8] |= (1 << (7 - (x % 8)));
- XDestroyImage (image);
- }
-
- XFreePixmap (dpy, pixmap);
+ XImage *image;
+ unsigned int x, y;
+ Pixmap pixmap;
+ XChar2b char2b;
+
+ pixmap = XCreatePixmap(dpy, win, 8 * width, height, 1);
+ XSetForeground(dpy, gc, 0);
+ XFillRectangle(dpy, pixmap, gc, 0, 0, 8 * width, height);
+ XSetForeground(dpy, gc, 1);
+
+ char2b.byte1 = (c >> 8) & 0xff;
+ char2b.byte2 = (c & 0xff);
+
+ XDrawString16(dpy, pixmap, gc, x0, y0, &char2b, 1);
+
+ image = XGetImage(dpy, pixmap, 0, 0, 8 * width, height, 1, XYPixmap);
+ if (image) {
+ /* Fill the bitmap (X11 and OpenGL are upside down wrt each other). */
+ for (y = 0; y < height; y++)
+ for (x = 0; x < 8 * width; x++)
+ if (XGetPixel(image, x, y))
+ bitmap[width * (height - y - 1) + x / 8] |=
+ (1 << (7 - (x % 8)));
+ XDestroyImage(image);
+ }
+
+ XFreePixmap(dpy, pixmap);
}
/*
* determine if a given glyph is valid and return the
* corresponding XCharStruct.
*/
-static XCharStruct *isvalid(XFontStruct *fs, int which)
+static XCharStruct *
+isvalid(XFontStruct * fs, int which)
{
- unsigned int rows,pages;
- int byte1 = 0, byte2 = 0;
- int i,valid = 1;
-
- rows = fs->max_byte1 - fs->min_byte1 + 1;
- pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
-
- if (rows == 1) {
- /* "linear" fonts */
- if ((fs->min_char_or_byte2 > which) ||
- (fs->max_char_or_byte2 < which)) valid = 0;
- } else {
- /* "matrix" fonts */
- byte2 = which & 0xff;
- byte1 = which >> 8;
- if ((fs->min_char_or_byte2 > byte2) ||
- (fs->max_char_or_byte2 < byte2) ||
- (fs->min_byte1 > byte1) ||
- (fs->max_byte1 < byte1)) valid = 0;
- }
-
- if (valid) {
- if (fs->per_char) {
- if (rows == 1) {
- /* "linear" fonts */
- return(fs->per_char + (which-fs->min_char_or_byte2) );
- } else {
- /* "matrix" fonts */
- i = ((byte1 - fs->min_byte1) * pages) +
- (byte2 - fs->min_char_or_byte2);
- return(fs->per_char + i);
+ unsigned int rows, pages;
+ int byte1 = 0, byte2 = 0;
+ int i, valid = 1;
+
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+
+ if (rows == 1) {
+ /* "linear" fonts */
+ if ((fs->min_char_or_byte2 > which) || (fs->max_char_or_byte2 < which))
+ valid = 0;
+ }
+ else {
+ /* "matrix" fonts */
+ byte2 = which & 0xff;
+ byte1 = which >> 8;
+ if ((fs->min_char_or_byte2 > byte2) ||
+ (fs->max_char_or_byte2 < byte2) ||
+ (fs->min_byte1 > byte1) || (fs->max_byte1 < byte1))
+ valid = 0;
+ }
+
+ if (valid) {
+ if (fs->per_char) {
+ if (rows == 1) {
+ /* "linear" fonts */
+ return (fs->per_char + (which - fs->min_char_or_byte2));
+ }
+ else {
+ /* "matrix" fonts */
+ i = ((byte1 - fs->min_byte1) * pages) +
+ (byte2 - fs->min_char_or_byte2);
+ return (fs->per_char + i);
+ }
}
- } else {
- return(&fs->min_bounds);
- }
- }
- return(NULL);
+ else {
+ return (&fs->min_bounds);
+ }
+ }
+ return (NULL);
}
-_X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
+_X_HIDDEN void
+DRI_glXUseXFont(Font font, int first, int count, int listbase)
{
- GLXContext CC;
- Display *dpy;
- Window win;
- Pixmap pixmap;
- GC gc;
- XGCValues values;
- unsigned long valuemask;
- XFontStruct *fs;
-
- GLint swapbytes, lsbfirst, rowlength;
- GLint skiprows, skippixels, alignment;
-
- unsigned int max_width, max_height, max_bm_width, max_bm_height;
- GLubyte *bm;
-
- int i;
-
- CC = __glXGetCurrentContext();
- dpy = CC->currentDpy;
- win = CC->currentDrawable;
-
- fs = XQueryFont (dpy, font);
- if (!fs)
- {
+ GLXContext CC;
+ Display *dpy;
+ Window win;
+ Pixmap pixmap;
+ GC gc;
+ XGCValues values;
+ unsigned long valuemask;
+ XFontStruct *fs;
+
+ GLint swapbytes, lsbfirst, rowlength;
+ GLint skiprows, skippixels, alignment;
+
+ unsigned int max_width, max_height, max_bm_width, max_bm_height;
+ GLubyte *bm;
+
+ int i;
+
+ CC = __glXGetCurrentContext();
+ dpy = CC->currentDpy;
+ win = CC->currentDrawable;
+
+ fs = XQueryFont(dpy, font);
+ if (!fs) {
__glXSetError(CC, GL_INVALID_VALUE);
return;
- }
-
- /* Allocate a bitmap that can fit all characters. */
- max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
- max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
- max_bm_width = (max_width + 7) / 8;
- max_bm_height = max_height;
-
- bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof
-(GLubyte));
- if (!bm) {
- XFreeFontInfo( NULL, fs, 1 );
+ }
+
+ /* Allocate a bitmap that can fit all characters. */
+ max_width = fs->max_bounds.rbearing - fs->min_bounds.lbearing;
+ max_height = fs->max_bounds.ascent + fs->max_bounds.descent;
+ max_bm_width = (max_width + 7) / 8;
+ max_bm_height = max_height;
+
+ bm = (GLubyte *) Xmalloc((max_bm_width * max_bm_height) * sizeof(GLubyte));
+ if (!bm) {
+ XFreeFontInfo(NULL, fs, 1);
__glXSetError(CC, GL_OUT_OF_MEMORY);
return;
- }
+ }
#if 0
- /* get the page info */
- pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
- firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
- lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
- rows = fs->max_byte1 - fs->min_byte1 + 1;
- unsigned int first_char, last_char, pages, rows;
+ /* get the page info */
+ pages = fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1;
+ firstchar = (fs->min_byte1 << 8) + fs->min_char_or_byte2;
+ lastchar = (fs->max_byte1 << 8) + fs->max_char_or_byte2;
+ rows = fs->max_byte1 - fs->min_byte1 + 1;
+ unsigned int first_char, last_char, pages, rows;
#endif
- /* Save the current packing mode for bitmaps. */
- glGetIntegerv (GL_UNPACK_SWAP_BYTES, &swapbytes);
- glGetIntegerv (GL_UNPACK_LSB_FIRST, &lsbfirst);
- glGetIntegerv (GL_UNPACK_ROW_LENGTH, &rowlength);
- glGetIntegerv (GL_UNPACK_SKIP_ROWS, &skiprows);
- glGetIntegerv (GL_UNPACK_SKIP_PIXELS, &skippixels);
- glGetIntegerv (GL_UNPACK_ALIGNMENT, &alignment);
-
- /* Enforce a standard packing mode which is compatible with
- fill_bitmap() from above. This is actually the default mode,
- except for the (non)alignment. */
- glPixelStorei (GL_UNPACK_SWAP_BYTES, GL_FALSE);
- glPixelStorei (GL_UNPACK_LSB_FIRST, GL_FALSE);
- glPixelStorei (GL_UNPACK_ROW_LENGTH, 0);
- glPixelStorei (GL_UNPACK_SKIP_ROWS, 0);
- glPixelStorei (GL_UNPACK_SKIP_PIXELS, 0);
- glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
-
- pixmap = XCreatePixmap (dpy, win, 10, 10, 1);
- values.foreground = BlackPixel (dpy, DefaultScreen (dpy));
- values.background = WhitePixel (dpy, DefaultScreen (dpy));
- values.font = fs->fid;
- valuemask = GCForeground | GCBackground | GCFont;
- gc = XCreateGC (dpy, pixmap, valuemask, &values);
- XFreePixmap (dpy, pixmap);
+ /* Save the current packing mode for bitmaps. */
+ glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
+ glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
+ glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
+ glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
+ glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
+ glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);
+
+ /* Enforce a standard packing mode which is compatible with
+ fill_bitmap() from above. This is actually the default mode,
+ except for the (non)alignment. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+
+ pixmap = XCreatePixmap(dpy, win, 10, 10, 1);
+ values.foreground = BlackPixel(dpy, DefaultScreen(dpy));
+ values.background = WhitePixel(dpy, DefaultScreen(dpy));
+ values.font = fs->fid;
+ valuemask = GCForeground | GCBackground | GCFont;
+ gc = XCreateGC(dpy, pixmap, valuemask, &values);
+ XFreePixmap(dpy, pixmap);
#ifdef DEBUG
- if (debug_xfonts)
- dump_font_struct (fs);
+ if (debug_xfonts)
+ dump_font_struct(fs);
#endif
- for (i = 0; i < count; i++)
- {
+ for (i = 0; i < count; i++) {
unsigned int width, height, bm_width, bm_height;
GLfloat x0, y0, dx, dy;
XCharStruct *ch;
@@ -306,17 +307,18 @@ _X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
/* check on index validity and get the bounds */
ch = isvalid(fs, c);
if (!ch) {
- ch = &fs->max_bounds;
- valid = 0;
- } else {
- valid = 1;
+ ch = &fs->max_bounds;
+ valid = 0;
+ }
+ else {
+ valid = 1;
}
#ifdef DEBUG
if (debug_xfonts) {
- char s[7];
- sprintf (s, isprint (c) ? "%c> " : "\\%03o> ", c);
- dump_char_struct (ch, s);
+ char s[7];
+ sprintf(s, isprint(c) ? "%c> " : "\\%03o> ", c);
+ dump_char_struct(ch, s);
}
#endif
@@ -324,13 +326,13 @@ _X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
straight from the glXUseXFont(3) manpage. */
width = ch->rbearing - ch->lbearing;
height = ch->ascent + ch->descent;
- x0 = - ch->lbearing;
+ x0 = -ch->lbearing;
y0 = ch->descent - 1;
dx = ch->width;
dy = 0;
/* X11's starting point. */
- x = - ch->lbearing;
+ x = -ch->lbearing;
y = ch->ascent;
/* Round the width to a multiple of eight. We will use this also
@@ -339,38 +341,38 @@ _X_HIDDEN void DRI_glXUseXFont( Font font, int first, int count, int listbase )
bm_width = (width + 7) / 8;
bm_height = height;
- glNewList (list, GL_COMPILE);
- if (valid && (bm_width > 0) && (bm_height > 0)) {
+ glNewList(list, GL_COMPILE);
+ if (valid && (bm_width > 0) && (bm_height > 0)) {
- memset (bm, '\0', bm_width * bm_height);
- fill_bitmap (dpy, win, gc, bm_width, bm_height, x, y, c, bm);
+ memset(bm, '\0', bm_width * bm_height);
+ fill_bitmap(dpy, win, gc, bm_width, bm_height, x, y, c, bm);
- glBitmap (width, height, x0, y0, dx, dy, bm);
+ glBitmap(width, height, x0, y0, dx, dy, bm);
#ifdef DEBUG
- if (debug_xfonts) {
- printf ("width/height = %u/%u\n", width, height);
- printf ("bm_width/bm_height = %u/%u\n", bm_width,
-bm_height);
- dump_bitmap (bm_width, bm_height, bm);
- }
+ if (debug_xfonts) {
+ printf("width/height = %u/%u\n", width, height);
+ printf("bm_width/bm_height = %u/%u\n", bm_width, bm_height);
+ dump_bitmap(bm_width, bm_height, bm);
+ }
#endif
- } else {
- glBitmap (0, 0, 0.0, 0.0, dx, dy, NULL);
- }
- glEndList ();
- }
-
- Xfree(bm);
- XFreeFontInfo( NULL, fs, 1 );
- XFreeGC (dpy, gc);
-
- /* Restore saved packing modes. */
- glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
- glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
- glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
- glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
- glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
- glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
+ }
+ else {
+ glBitmap(0, 0, 0.0, 0.0, dx, dy, NULL);
+ }
+ glEndList();
+ }
+
+ Xfree(bm);
+ XFreeFontInfo(NULL, fs, 1);
+ XFreeGC(dpy, gc);
+
+ /* Restore saved packing modes. */
+ glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
+ glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
+ glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
+ glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
}
#endif
diff --git a/src/mesa/SConscript b/src/mesa/SConscript
index af8dfcb4930..89b98b37ab0 100644
--- a/src/mesa/SConscript
+++ b/src/mesa/SConscript
@@ -283,6 +283,10 @@ if env['platform'] != 'winddk':
'x86-64/glapi_x86-64.S'
]
elif gcc and env['machine'] == 'ppc':
+ env.Append(CPPDEFINES = [
+ 'USE_PPC_ASM',
+ 'USE_VMX_ASM',
+ ])
mesa_sources += [
'ppc/common_ppc.c',
]
diff --git a/src/mesa/drivers/dri/i915/i915_program.c b/src/mesa/drivers/dri/i915/i915_program.c
index 350da5e1697..e87700f8e0a 100644
--- a/src/mesa/drivers/dri/i915/i915_program.c
+++ b/src/mesa/drivers/dri/i915/i915_program.c
@@ -245,6 +245,19 @@ GLuint i915_emit_texld( struct i915_fragment_program *p,
*/
assert(GET_UREG_TYPE(coord) != REG_TYPE_U);
+ if ((GET_UREG_TYPE(coord) != REG_TYPE_R) &&
+ (GET_UREG_TYPE(coord) != REG_TYPE_OC) &&
+ (GET_UREG_TYPE(coord) != REG_TYPE_OD) &&
+ (GET_UREG_TYPE(coord) != REG_TYPE_T)) {
+ GLuint tmpCoord = get_free_rreg(p, live_regs);
+
+ if (tmpCoord == UREG_BAD)
+ return 0;
+
+ i915_emit_arith(p, A0_MOV, tmpCoord, A0_DEST_CHANNEL_ALL, 0, coord, 0, 0);
+ coord = tmpCoord;
+ }
+
/* Output register being oC or oD defines a phase boundary */
if (GET_UREG_TYPE(dest) == REG_TYPE_OC ||
GET_UREG_TYPE(dest) == REG_TYPE_OD)
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
index b60dad74601..50518a68792 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
@@ -40,6 +40,12 @@
#include "main/varray.h"
#include "main/attrib.h"
#include "main/enable.h"
+#include "main/buffers.h"
+#include "main/fbobject.h"
+#include "main/renderbuffer.h"
+#include "main/depth.h"
+#include "main/hash.h"
+#include "main/blend.h"
#include "glapi/dispatch.h"
#include "swrast/swrast.h"
@@ -51,7 +57,7 @@
#include "intel_regions.h"
#include "intel_pixel.h"
#include "intel_buffer_objects.h"
-
+#include "intel_fbo.h"
static GLboolean
intel_texture_drawpixels(GLcontext * ctx,
@@ -89,6 +95,15 @@ intel_texture_drawpixels(GLcontext * ctx,
if (format == GL_STENCIL_INDEX)
return GL_FALSE;
+ /* Check that we can load in a texture this big. */
+ if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) ||
+ height > (1 << (ctx->Const.MaxTextureLevels - 1))) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "glDrawPixels() fallback: bitmap too large (%dx%d)\n",
+ width, height);
+ return GL_FALSE;
+ }
+
/* To do DEPTH_COMPONENT, we would need to change our setup to not draw to
* the color buffer, and sample the texture values into the fragment depth
* in a program.
@@ -170,6 +185,182 @@ intel_texture_drawpixels(GLcontext * ctx,
return GL_TRUE;
}
+static GLboolean
+intel_stencil_drawpixels(GLcontext * ctx,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format,
+ GLenum type,
+ const struct gl_pixelstore_attrib *unpack,
+ const GLvoid *pixels)
+{
+ GLuint texname, rb_name, fb_name, old_fb_name;
+ GLfloat vertices[4][2];
+ GLfloat texcoords[4][2];
+ struct intel_renderbuffer *irb;
+ struct intel_renderbuffer *depth_irb;
+ struct gl_renderbuffer *rb;
+ struct gl_pixelstore_attrib old_unpack;
+ GLstencil *stencil_pixels;
+ int row;
+
+ if (format != GL_STENCIL_INDEX)
+ return GL_FALSE;
+
+ /* If there's nothing to write, we're done. */
+ if (ctx->Stencil.WriteMask[0] == 0)
+ return GL_TRUE;
+
+ /* Can't do a per-bit writemask while treating stencil as rgba data. */
+ if ((ctx->Stencil.WriteMask[0] & 0xff) != 0xff)
+ return GL_FALSE;
+
+ /* We use FBOs for our wrapping of the depthbuffer into a color
+ * destination.
+ */
+ if (!ctx->Extensions.EXT_framebuffer_object)
+ return GL_FALSE;
+
+ /* We're going to mess with texturing with no regard to existing texture
+ * state, so if there is some set up we have to bail.
+ */
+ if (ctx->Texture._EnabledUnits != 0)
+ return GL_FALSE;
+
+ /* Can't do textured DrawPixels with a fragment program, unless we were
+ * to generate a new program that sampled our texture and put the results
+ * in the fragment color before the user's program started.
+ */
+ if (ctx->FragmentProgram.Enabled)
+ return GL_FALSE;
+
+ /* Check that we can load in a texture this big. */
+ if (width > (1 << (ctx->Const.MaxTextureLevels - 1)) ||
+ height > (1 << (ctx->Const.MaxTextureLevels - 1))) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "glDrawPixels(STENCIL_IDNEX) fallback: "
+ "bitmap too large (%dx%d)\n",
+ width, height);
+ return GL_FALSE;
+ }
+
+ _mesa_PushAttrib(GL_ENABLE_BIT | GL_TRANSFORM_BIT | GL_TEXTURE_BIT |
+ GL_CURRENT_BIT | GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ _mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT);
+ old_fb_name = ctx->DrawBuffer->Name;
+
+ _mesa_Disable(GL_POLYGON_STIPPLE);
+ _mesa_Disable(GL_DEPTH_TEST);
+ _mesa_Disable(GL_STENCIL_TEST);
+
+ /* Unpack the supplied stencil values into a ubyte buffer. */
+ assert(sizeof(GLstencil) == sizeof(GLubyte));
+ stencil_pixels = _mesa_malloc(width * height * sizeof(GLstencil));
+ for (row = 0; row < height; row++) {
+ GLvoid *source = _mesa_image_address2d(unpack, pixels,
+ width, height,
+ GL_COLOR_INDEX, type,
+ row, 0);
+ _mesa_unpack_stencil_span(ctx, width, GL_UNSIGNED_BYTE,
+ stencil_pixels +
+ row * width * sizeof(GLstencil),
+ type, source, unpack, ctx->_ImageTransferState);
+ }
+
+ /* Take the current depth/stencil renderbuffer, and make a new one wrapping
+ * it which will be treated as GL_RGBA8 so we can render to it as a color
+ * buffer.
+ */
+ depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
+ irb = intel_create_renderbuffer(GL_RGBA8);
+ rb = &irb->Base;
+ irb->Base.Width = depth_irb->Base.Width;
+ irb->Base.Height = depth_irb->Base.Height;
+ intel_renderbuffer_set_region(irb, depth_irb->region);
+
+ /* Create a name for our renderbuffer, which lets us use other mesa
+ * rb functions for convenience.
+ */
+ _mesa_GenRenderbuffersEXT(1, &rb_name);
+ irb->Base.RefCount++;
+ _mesa_HashInsert(ctx->Shared->RenderBuffers, rb_name, &irb->Base);
+
+ /* Bind the new renderbuffer to the color attachment point. */
+ _mesa_GenFramebuffersEXT(1, &fb_name);
+ _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb_name);
+ _mesa_FramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT,
+ GL_RENDERBUFFER_EXT,
+ rb_name);
+ /* Choose to render to the color attachment. */
+ _mesa_DrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+
+ _mesa_DepthMask(GL_FALSE);
+ _mesa_ColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_TRUE);
+
+ _mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
+ _mesa_Enable(GL_TEXTURE_2D);
+ _mesa_GenTextures(1, &texname);
+ _mesa_BindTexture(GL_TEXTURE_2D, texname);
+ _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+ _mesa_TexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+ _mesa_TexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ old_unpack = ctx->Unpack;
+ ctx->Unpack = ctx->DefaultPacking;
+ _mesa_TexImage2D(GL_TEXTURE_2D, 0, GL_INTENSITY, width, height, 0,
+ GL_RED, GL_UNSIGNED_BYTE, stencil_pixels);
+ ctx->Unpack = old_unpack;
+ _mesa_free(stencil_pixels);
+
+ _mesa_MatrixMode(GL_PROJECTION);
+ _mesa_PushMatrix();
+ _mesa_LoadIdentity();
+ _mesa_Ortho(0, ctx->DrawBuffer->Width, 0, ctx->DrawBuffer->Height, 1, -1);
+
+ _mesa_MatrixMode(GL_MODELVIEW);
+ _mesa_PushMatrix();
+ _mesa_LoadIdentity();
+
+ vertices[0][0] = x;
+ vertices[0][1] = y;
+ vertices[1][0] = x + width * ctx->Pixel.ZoomX;
+ vertices[1][1] = y;
+ vertices[2][0] = x + width * ctx->Pixel.ZoomX;
+ vertices[2][1] = y + height * ctx->Pixel.ZoomY;
+ vertices[3][0] = x;
+ vertices[3][1] = y + height * ctx->Pixel.ZoomY;
+
+ texcoords[0][0] = 0.0;
+ texcoords[0][1] = 0.0;
+ texcoords[1][0] = 1.0;
+ texcoords[1][1] = 0.0;
+ texcoords[2][0] = 1.0;
+ texcoords[2][1] = 1.0;
+ texcoords[3][0] = 0.0;
+ texcoords[3][1] = 1.0;
+
+ _mesa_VertexPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &vertices);
+ _mesa_TexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), &texcoords);
+ _mesa_Enable(GL_VERTEX_ARRAY);
+ _mesa_Enable(GL_TEXTURE_COORD_ARRAY);
+ CALL_DrawArrays(ctx->Exec, (GL_TRIANGLE_FAN, 0, 4));
+
+ _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT, old_fb_name);
+
+ _mesa_MatrixMode(GL_PROJECTION);
+ _mesa_PopMatrix();
+ _mesa_MatrixMode(GL_MODELVIEW);
+ _mesa_PopMatrix();
+ _mesa_PopClientAttrib();
+ _mesa_PopAttrib();
+
+ _mesa_DeleteTextures(1, &texname);
+ _mesa_DeleteFramebuffersEXT(1, &fb_name);
+ _mesa_DeleteRenderbuffersEXT(1, &rb_name);
+
+ return GL_TRUE;
+}
+
void
intelDrawPixels(GLcontext * ctx,
GLint x, GLint y,
@@ -183,6 +374,10 @@ intelDrawPixels(GLcontext * ctx,
unpack, pixels))
return;
+ if (intel_stencil_drawpixels(ctx, x, y, width, height, format, type,
+ unpack, pixels))
+ return;
+
if (INTEL_DEBUG & DEBUG_PIXEL)
_mesa_printf("%s: fallback to swrast\n", __FUNCTION__);
diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c
index c6ff8c13c68..61c0861cbd4 100644
--- a/src/mesa/main/context.c
+++ b/src/mesa/main/context.c
@@ -1063,6 +1063,7 @@ init_attrib_groups(GLcontext *ctx)
/* Miscellaneous */
ctx->NewState = _NEW_ALL;
ctx->ErrorValue = (GLenum) GL_NO_ERROR;
+ ctx->varying_vp_inputs = ~0;
return GL_TRUE;
}
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index 308b4ef7115..da2640dd8fc 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -47,17 +47,17 @@
struct state_key {
+ unsigned light_color_material_mask:12;
+ unsigned light_material_mask:12;
unsigned light_global_enabled:1;
unsigned light_local_viewer:1;
unsigned light_twoside:1;
unsigned light_color_material:1;
- unsigned light_color_material_mask:12;
- unsigned light_material_mask:12;
unsigned material_shininess_is_zero:1;
-
unsigned need_eye_coords:1;
unsigned normalize:1;
unsigned rescale_normals:1;
+
unsigned fog_source_is_depth:1;
unsigned tnl_do_vertex_fog:1;
unsigned separate_specular:1;
@@ -67,6 +67,8 @@ struct state_key {
unsigned texture_enabled_global:1;
unsigned fragprog_inputs_read:12;
+ unsigned varying_vp_inputs;
+
struct {
unsigned light_enabled:1;
unsigned light_eyepos3_is_zero:1;
@@ -193,6 +195,7 @@ static void make_state_key( GLcontext *ctx, struct state_key *key )
key->need_eye_coords = ctx->_NeedEyeCoords;
key->fragprog_inputs_read = fp->Base.InputsRead;
+ key->varying_vp_inputs = ctx->varying_vp_inputs;
if (ctx->RenderMode == GL_FEEDBACK) {
/* make sure the vertprog emits color and tex0 */
@@ -448,14 +451,46 @@ static void release_temps( struct tnl_program *p )
}
+static struct ureg register_param5(struct tnl_program *p,
+ GLint s0,
+ GLint s1,
+ GLint s2,
+ GLint s3,
+ GLint s4)
+{
+ gl_state_index tokens[STATE_LENGTH];
+ GLint idx;
+ tokens[0] = s0;
+ tokens[1] = s1;
+ tokens[2] = s2;
+ tokens[3] = s3;
+ tokens[4] = s4;
+ idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
+ return make_ureg(PROGRAM_STATE_VAR, idx);
+}
+
+
+#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
+#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
+#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
+#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
+
+
/**
* \param input one of VERT_ATTRIB_x tokens.
*/
static struct ureg register_input( struct tnl_program *p, GLuint input )
{
- p->program->Base.InputsRead |= (1<<input);
- return make_ureg(PROGRAM_INPUT, input);
+ /* Material attribs are passed here as inputs >= 32
+ */
+ if (input >= 32 || (p->state->varying_vp_inputs & (1<<input))) {
+ p->program->Base.InputsRead |= (1<<input);
+ return make_ureg(PROGRAM_INPUT, input);
+ }
+ else {
+ return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, input );
+ }
}
/**
@@ -504,31 +539,6 @@ static struct ureg get_identity_param( struct tnl_program *p )
return p->identity;
}
-static struct ureg register_param5(struct tnl_program *p,
- GLint s0,
- GLint s1,
- GLint s2,
- GLint s3,
- GLint s4)
-{
- gl_state_index tokens[STATE_LENGTH];
- GLint idx;
- tokens[0] = s0;
- tokens[1] = s1;
- tokens[2] = s2;
- tokens[3] = s3;
- tokens[4] = s4;
- idx = _mesa_add_state_reference( p->program->Base.Parameters, tokens );
- return make_ureg(PROGRAM_STATE_VAR, idx);
-}
-
-
-#define register_param1(p,s0) register_param5(p,s0,0,0,0,0)
-#define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0)
-#define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0)
-#define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0)
-
-
static void register_matrix_param5( struct tnl_program *p,
GLint s0, /* modelview, projection, etc */
GLint s1, /* texture matrix number */
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 052da2c18e1..7ad8cb244d5 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1987,6 +1987,8 @@ struct gl_vertex_program_state
GLboolean CallbackEnabled;
GLuint CurrentPosition;
#endif
+
+ GLboolean _Overriden;
};
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 2f0e7cc368e..5e073a18637 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -508,10 +508,12 @@ _mesa_update_state_locked( GLcontext *ctx )
if (ctx->FragmentProgram._MaintainTexEnvProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE_MATRIX | _NEW_LIGHT |
+ _NEW_RENDERMODE |
_NEW_TEXTURE | _NEW_FOG | _DD_NEW_SEPARATE_SPECULAR);
}
if (ctx->VertexProgram._MaintainTnlProgram) {
prog_flags |= (_NEW_ARRAY | _NEW_TEXTURE | _NEW_TEXTURE_MATRIX |
+ _NEW_RENDERMODE |
_NEW_TRANSFORM | _NEW_POINT |
_NEW_FOG | _NEW_LIGHT |
_MESA_NEW_NEED_EYE_COORDS);
@@ -551,7 +553,8 @@ _mesa_update_state( GLcontext *ctx )
-/* Want to figure out which fragment program inputs are actually
+/**
+ * Want to figure out which fragment program inputs are actually
* constant/current values from ctx->Current. These should be
* referenced as a tracked state variable rather than a fragment
* program input, to save the overhead of putting a constant value in
@@ -579,6 +582,26 @@ _mesa_set_varying_vp_inputs( GLcontext *ctx,
if (ctx->varying_vp_inputs != varying_inputs) {
ctx->varying_vp_inputs = varying_inputs;
ctx->NewState |= _NEW_ARRAY;
- //_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);
+ /*_mesa_printf("%s %x\n", __FUNCTION__, varying_inputs);*/
+ }
+}
+
+
+/**
+ * Used by drivers to tell core Mesa that the driver is going to
+ * install/ use its own vertex program. In particular, this will
+ * prevent generated fragment programs from using state vars instead
+ * of ordinary varyings/inputs.
+ */
+void
+_mesa_set_vp_override(GLcontext *ctx, GLboolean flag)
+{
+ if (ctx->VertexProgram._Overriden != flag) {
+ ctx->VertexProgram._Overriden = flag;
+
+ /* Set one of the bits which will trigger fragment program
+ * regeneration:
+ */
+ ctx->NewState |= _NEW_ARRAY;
}
}
diff --git a/src/mesa/main/state.h b/src/mesa/main/state.h
index 79f2f6beb0c..29db08a0b95 100644
--- a/src/mesa/main/state.h
+++ b/src/mesa/main/state.h
@@ -1,6 +1,6 @@
/*
* Mesa 3-D graphics library
- * Version: 7.1
+ * Version: 7.3
*
* Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
*
@@ -29,16 +29,21 @@
#include "mtypes.h"
extern void
-_mesa_update_state( GLcontext *ctx );
+_mesa_update_state(GLcontext *ctx);
/* As above but can only be called between _mesa_lock_context_textures() and
* _mesa_unlock_context_textures().
*/
extern void
-_mesa_update_state_locked( GLcontext *ctx );
+_mesa_update_state_locked(GLcontext *ctx);
+
+
+extern void
+_mesa_set_varying_vp_inputs(GLcontext *ctx, GLbitfield varying_inputs);
+
+
+extern void
+_mesa_set_vp_override(GLcontext *ctx, GLboolean flag);
-void
-_mesa_set_varying_vp_inputs( GLcontext *ctx,
- GLbitfield varying_inputs );
#endif
diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c
index c23173014de..2c7df7b8d9a 100644
--- a/src/mesa/main/texenvprogram.c
+++ b/src/mesa/main/texenvprogram.c
@@ -217,8 +217,18 @@ static GLbitfield get_fp_input_mask( GLcontext *ctx )
{
GLbitfield fp_inputs = 0x0;
- if (!ctx->VertexProgram._Enabled ||
- !ctx->VertexProgram._Current) {
+ if (ctx->VertexProgram._Overriden) {
+ /* Somebody's messing with the vertex program and we don't have
+ * a clue what's happening. Assume that it could be producing
+ * all possible outputs.
+ */
+ fp_inputs = ~0;
+ }
+ else if (ctx->RenderMode == GL_FEEDBACK) {
+ fp_inputs = (FRAG_BIT_COL0 | FRAG_BIT_TEX0);
+ }
+ else if (!ctx->VertexProgram._Enabled ||
+ !ctx->VertexProgram._Current) {
/* Fixed function logic */
GLbitfield varying_inputs = ctx->varying_vp_inputs;
diff --git a/src/mesa/ppc/common_ppc.c b/src/mesa/ppc/common_ppc.c
index 786e1817acf..c7cec96e5d5 100644
--- a/src/mesa/ppc/common_ppc.c
+++ b/src/mesa/ppc/common_ppc.c
@@ -85,7 +85,7 @@ void _mesa_init_all_ppc_transform_asm( void )
}
# ifndef USE_VMX_ASM
- _mesa_ppc_cpu_features &= ~PPC_FEATURES_HAS_ALTIVEC;
+ _mesa_ppc_cpu_features &= ~PPC_FEATURE_HAS_ALTIVEC;
# endif
#endif
}
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 00bbcae32ae..5b24b9f0687 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -35,6 +35,7 @@
#include "main/bufferobj.h"
#include "main/macros.h"
#include "main/texformat.h"
+#include "main/state.h"
#include "shader/program.h"
#include "shader/prog_parameter.h"
#include "shader/prog_print.h"
@@ -835,6 +836,9 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
return;
}
+ _mesa_set_vp_override( ctx, TRUE );
+ _mesa_update_state( ctx );
+
st_validate_state(st);
if (format == GL_DEPTH_COMPONENT) {
@@ -874,6 +878,8 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
/* blit */
draw_blit(st, width, height, format, type, pixels);
}
+
+ _mesa_set_vp_override( ctx, FALSE );
}
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index acaf1de8823..d08229b57a3 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -156,7 +156,7 @@ st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
}
if (texImage->Data) {
- free(texImage->Data);
+ _mesa_align_free(texImage->Data);
texImage->Data = NULL;
}
}
@@ -541,7 +541,7 @@ st_TexImage(GLcontext * ctx,
sizeInBytes = depth * dstRowStride * postConvHeight;
}
- texImage->Data = malloc(sizeInBytes);
+ texImage->Data = _mesa_align_malloc(sizeInBytes, 16);
}
if (!texImage->Data) {