mesa/es: Add OpenGL ES overlay.

This is primitive support for OpenGL ES.  It uses a subset of mesa
sources to build libesXgallium.a and libesXapi.a, where X is 1 for
OpenGL ES 1.x, 2 for OpenGL ES 2.x.  The static libraries serve the same
purpose as libmesagallium.a and libglapi.a do for OpenGL.

This is based on the work of opengl-es branch.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
This commit is contained in:
Chia-I Wu 2009-09-21 17:57:57 +08:00 committed by Brian Paul
parent f68bf0621d
commit bfa66bd6f9
17 changed files with 7087 additions and 2 deletions

View File

@ -303,10 +303,25 @@ MAIN_FILES = \
$(DIRECTORY)/progs/util/sampleMakefile \
$(DIRECTORY)/windows/VC8/
EGL_FILES = \
$(DIRECTORY)/include/EGL/*.h \
ES_FILES = \
$(DIRECTORY)/include/GLES/*.h \
$(DIRECTORY)/include/GLES2/*.h \
$(DIRECTORY)/src/mesa/glapi/*.xml \
$(DIRECTORY)/src/mesa/glapi/*.py \
$(DIRECTORY)/src/mesa/glapi/*.dtd \
$(DIRECTORY)/src/mesa/es/glapi/Makefile \
$(DIRECTORY)/src/mesa/es/glapi/*.xml \
$(DIRECTORY)/src/mesa/es/glapi/*.py \
$(DIRECTORY)/src/mesa/es/state_tracker/*.[ch] \
$(DIRECTORY)/src/mesa/es/main/*.[ch] \
$(DIRECTORY)/src/mesa/es/main/*.py \
$(DIRECTORY)/src/mesa/es/main/*.txt \
$(DIRECTORY)/src/mesa/es/main/es*_special \
$(DIRECTORY)/src/mesa/es/Makefile \
$(DIRECTORY)/src/mesa/es/sources.mak \
EGL_FILES = \
$(DIRECTORY)/include/EGL/*.h \
$(DIRECTORY)/src/egl/Makefile \
$(DIRECTORY)/src/egl/*/Makefile \
$(DIRECTORY)/src/egl/*/*.[ch] \
@ -477,6 +492,7 @@ DEPEND_FILES = \
LIB_FILES = \
$(MAIN_FILES) \
$(ES_FILES) \
$(EGL_FILES) \
$(GALLIUM_FILES) \
$(DRI_FILES) \

125
src/mesa/es/Makefile Normal file
View File

@ -0,0 +1,125 @@
# src/mesa/es/Makefile
#
TOP := ../../..
MESA := ..
include $(TOP)/configs/current
include sources.mak
ES1_LIBS := libes1gallium.a libes1api.a
ES2_LIBS := libes2gallium.a libes2api.a
# Default rule: create ES1 and ES2 libs
.PHONY: default
default: subdirs depend es1 es2
es1: $(ES1_LIBS)
es2: $(ES2_LIBS)
# force the inclusion of es's mfeatures.h
ES1_CPPFLAGS := -include main/mfeatures_es1.h -D__GL_EXPORTS
ES2_CPPFLAGS := -include main/mfeatures_es2.h -D__GL_EXPORTS
ES1_OBJ_DIR := objs-es1
ES2_OBJ_DIR := objs-es2
# adjust output dirs
ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_OBJECTS))
ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_GALLIUM_OBJECTS))
ES1_API_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(ES1_API_OBJECTS))
ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_OBJECTS))
ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_GALLIUM_OBJECTS))
ES2_API_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(ES2_API_OBJECTS))
# compile either ES1 or ES2 sources
define es-compile
@mkdir -p $(dir $@)
$(CC) -c $(CFLAGS) $(ES$(1)_CPPFLAGS) $(ES$(1)_INCLUDES) -o $@ $<
endef
$(ES1_OBJ_DIR)/%.o: %.c
$(call es-compile,1)
$(ES1_OBJ_DIR)/%.o: %.S
$(call es-compile,1)
$(ES1_OBJ_DIR)/%.o: $(MESA)/%.c
$(call es-compile,1)
$(ES1_OBJ_DIR)/%.o: $(MESA)/%.S
$(call es-compile,1)
$(ES2_OBJ_DIR)/%.o: %.c
$(call es-compile,2)
$(ES2_OBJ_DIR)/%.o: %.S
$(call es-compile,2)
$(ES2_OBJ_DIR)/%.o: $(MESA)/%.c
$(call es-compile,2)
$(ES2_OBJ_DIR)/%.o: $(MESA)/%.S
$(call es-compile,2)
libes1.a: $(ES1_OBJECTS)
@$(TOP)/bin/mklib -o es1 -static $(ES1_OBJECTS)
libes2.a: $(ES2_OBJECTS)
@$(TOP)/bin/mklib -o es2 -static $(ES1_OBJECTS)
libes1gallium.a: $(ES1_GALLIUM_OBJECTS)
@$(TOP)/bin/mklib -o es1gallium -static $(ES1_GALLIUM_OBJECTS)
libes2gallium.a: $(ES2_GALLIUM_OBJECTS)
@$(TOP)/bin/mklib -o es2gallium -static $(ES2_GALLIUM_OBJECTS)
libes1api.a: $(ES1_API_OBJECTS)
@$(TOP)/bin/mklib -o es1api -static $(ES1_API_OBJECTS)
libes2api.a: $(ES2_API_OBJECTS)
@$(TOP)/bin/mklib -o es2api -static $(ES2_API_OBJECTS)
GENERATED_SOURCES := \
main/api_exec_es1.c \
main/api_exec_es2.c \
main/get_es1.c \
main/get_es2.c
main/api_exec_es1.c: main/APIspec.txt main/es_generator.py main/apiutil.py main/es1_special
$(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.txt -V GLES1.1 > $@
main/api_exec_es2.c: main/APIspec.txt main/es_generator.py main/apiutil.py main/es2_special
$(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.txt -V GLES2.0 > $@
main/get_es1.c: main/get_gen.py
$(PYTHON2) $(PYTHON_FLAGS) $< 1 > $@
main/get_es2.c: main/get_gen.py
$(PYTHON2) $(PYTHON_FLAGS) $< 2 > $@
.PHONY: clean
clean:
-rm -f $(ES1_LIBS) $(ES2_LIBS)
-rm -rf $(ES1_OBJ_DIR) $(ES2_OBJ_DIR)
-rm -f $(GENERATED_SOURCES)
-rm -f depend
-rm -f *~
subdirs:
make -C glapi
make -C $(MESA) asm_subdirs
depend: $(ES1_ALL_SOURCES) $(ES2_ALL_SOURCES)
@echo "running $(MKDEP)"
@touch depend
@# MESA is "..", but luckily, directories are longer than 2 characters
@$(MKDEP) -f- -p$(ES1_OBJ_DIR)/ $(DEFINES) $(ES1_CFLAGS) \
$(ES1_INCLUDES) $(ES1_ALL_SOURCES) 2>/dev/null | \
sed -e 's,^$(ES1_OBJ_DIR)/$(MESA)/,$(ES1_OBJ_DIR)/,' > depend
@$(MKDEP) -f- -p$(ES2_OBJ_DIR)/ $(DEFINES) $(ES2_CFLAGS) \
$(ES2_INCLUDES) $(ES2_ALL_SOURCES) 2>/dev/null | \
sed -e 's,^$(ES2_OBJ_DIR)/$(MESA)/,$(ES2_OBJ_DIR)/,' >> depend
-include depend

2886
src/mesa/es/main/APIspec.txt Normal file

File diff suppressed because it is too large Load Diff

1117
src/mesa/es/main/apiutil.py Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
# GetString is always special.
GetString
# CompressedTexImage2D calls out to two different functions based on
# whether the image is a paletted image or not
CompressedTexImage2D
# QueryMatrixx returns values in an unusual, decomposed, fixed-value
# form; it has its own code for this
QueryMatrixx

View File

@ -0,0 +1,5 @@
# GetString must always have its own implementation, so we return our
# implementation values instead of Mesa's.
GetString
CompressedTexImage2D
RenderbufferStorage

View File

@ -0,0 +1,240 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
**************************************************************************/
/**
* Code to convert compressed/paletted texture images to ordinary 4-byte RGBA.
* See the GL_OES_compressed_paletted_texture spec at
* http://khronos.org/registry/gles/extensions/OES/OES_compressed_paletted_texture.txt
*/
#include <stdlib.h>
#include <assert.h>
#include "GLES/gl.h"
#include "GLES/glext.h"
void GL_APIENTRY _es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
void GL_APIENTRY _mesa_TexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
void GL_APIENTRY _mesa_CompressedTexImage2DARB(GLenum target, GLint level, GLenum internalFormat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
static const struct {
GLenum format;
GLuint palette_size;
GLuint size;
} formats[] = {
{ GL_PALETTE4_RGB8_OES, 16, 3 },
{ GL_PALETTE4_RGBA8_OES, 16, 4 },
{ GL_PALETTE4_R5_G6_B5_OES, 16, 2 },
{ GL_PALETTE4_RGBA4_OES, 16, 2 },
{ GL_PALETTE4_RGB5_A1_OES, 16, 2 },
{ GL_PALETTE8_RGB8_OES, 256, 3 },
{ GL_PALETTE8_RGBA8_OES, 256, 4 },
{ GL_PALETTE8_R5_G6_B5_OES, 256, 2 },
{ GL_PALETTE8_RGBA4_OES, 256, 2 },
{ GL_PALETTE8_RGB5_A1_OES, 256, 2 }
};
/**
* Get a color/entry from the palette. Convert to GLubyte/RGBA format.
*/
static void
get_palette_entry(GLenum format, const void *palette, GLuint index,
GLubyte rgba[4])
{
switch (format) {
case GL_PALETTE4_RGB8_OES:
case GL_PALETTE8_RGB8_OES:
{
const GLubyte *pal = (const GLubyte *) palette;
rgba[0] = pal[index * 3 + 0];
rgba[1] = pal[index * 3 + 1];
rgba[2] = pal[index * 3 + 2];
rgba[3] = 255;
}
break;
case GL_PALETTE4_RGBA8_OES:
case GL_PALETTE8_RGBA8_OES:
{
const GLubyte *pal = (const GLubyte *) palette;
rgba[0] = pal[index * 4 + 0];
rgba[1] = pal[index * 4 + 1];
rgba[2] = pal[index * 4 + 2];
rgba[3] = pal[index * 4 + 3];
}
break;
case GL_PALETTE4_R5_G6_B5_OES:
case GL_PALETTE8_R5_G6_B5_OES:
{
const GLushort *pal = (const GLushort *) palette;
const GLushort color = pal[index];
rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x3);
rgba[1] = ((color >> 3) & 0xfc) | ((color >> 1 ) & 0x3);
rgba[2] = ((color << 3) & 0xf8) | ((color ) & 0x7);
rgba[3] = 255;
}
break;
case GL_PALETTE4_RGBA4_OES:
case GL_PALETTE8_RGBA4_OES:
{
const GLushort *pal = (const GLushort *) palette;
const GLushort color = pal[index];
rgba[0] = ((color & 0xf000) >> 8) | ((color & 0xf000) >> 12);
rgba[1] = ((color & 0x0f00) >> 4) | ((color & 0x0f00) >> 8);
rgba[2] = ((color & 0x00f0) ) | ((color & 0x00f0) >> 4);
rgba[3] = ((color & 0x000f) << 4) | ((color & 0x000f) );
}
break;
case GL_PALETTE4_RGB5_A1_OES:
case GL_PALETTE8_RGB5_A1_OES:
{
const GLushort *pal = (const GLushort *) palette;
const GLushort color = pal[index];
rgba[0] = ((color >> 8) & 0xf8) | ((color >> 11) & 0x7);
rgba[1] = ((color >> 3) & 0xf8) | ((color >> 6) & 0x7);
rgba[2] = ((color << 2) & 0xf8) | ((color >> 1) & 0x7);
rgba[3] = (color & 0x1) * 255;
}
break;
default:
assert(0);
}
}
/**
* Convert paletted texture to simple GLubyte/RGBA format.
*/
static void
paletted_to_rgba(GLenum src_format,
const void *palette,
const void *indexes,
GLsizei width, GLsizei height,
GLubyte *rgba)
{
GLuint pal_ents, i;
assert(src_format >= GL_PALETTE4_RGB8_OES);
assert(src_format <= GL_PALETTE8_RGB5_A1_OES);
assert(formats[src_format - GL_PALETTE4_RGB8_OES].format == src_format);
pal_ents = formats[src_format - GL_PALETTE4_RGB8_OES].palette_size;
if (pal_ents == 16) {
/* 4 bits per index */
const GLubyte *ind = (const GLubyte *) indexes;
if (width * height == 1) {
/* special case the only odd-sized image */
GLuint index0 = ind[0] >> 4;
get_palette_entry(src_format, palette, index0, rgba);
return;
}
/* two pixels per iteration */
for (i = 0; i < width * height / 2; i++) {
GLuint index0 = ind[i] >> 4;
GLuint index1 = ind[i] & 0xf;
get_palette_entry(src_format, palette, index0, rgba + i * 8);
get_palette_entry(src_format, palette, index1, rgba + i * 8 + 4);
}
}
else {
/* 8 bits per index */
const GLubyte *ind = (const GLubyte *) indexes;
for (i = 0; i < width * height; i++) {
GLuint index = ind[i];
get_palette_entry(src_format, palette, index, rgba + i * 4);
}
}
}
/**
* Convert a call to glCompressedTexImage2D() where internalFormat is a
* compressed palette format into a regular GLubyte/RGBA glTexImage2D() call.
*/
static void
cpal_compressed_teximage2d(GLenum target, GLint level,
GLenum internalFormat,
GLsizei width, GLsizei height,
const void *pixels)
{
GLuint pal_ents, pal_ent_size, pal_bytes;
const GLint num_levels = level + 1;
GLint lvl;
const GLubyte *indexes;
assert(internalFormat >= GL_PALETTE4_RGB8_OES);
assert(internalFormat <= GL_PALETTE8_RGB5_A1_OES);
assert(formats[internalFormat - GL_PALETTE4_RGB8_OES].format == internalFormat);
pal_ents = formats[internalFormat - GL_PALETTE4_RGB8_OES].palette_size;
pal_ent_size = formats[internalFormat - GL_PALETTE4_RGB8_OES].size;
pal_bytes = pal_ents * pal_ent_size;
/* first image follows the palette */
indexes = (const GLubyte *) pixels + pal_bytes;
/* No worries about glPixelStore state since the only supported parameter is
* GL_UNPACK_ALIGNMENT and it doesn't matter when unpacking GLubyte/RGBA.
*/
for (lvl = 0; lvl < num_levels; lvl++) {
/* Allocate GLubyte/RGBA dest image buffer */
GLubyte *rgba = (GLubyte *) malloc(width * height * 4);
if (pixels)
paletted_to_rgba(internalFormat, pixels, indexes, width, height, rgba);
_mesa_TexImage2D(target, lvl, GL_RGBA, width, height, 0,
GL_RGBA, GL_UNSIGNED_BYTE, rgba);
free(rgba);
/* advance index pointer to point to next src mipmap */
if (pal_ents == 4)
indexes += width * height / 2;
else
indexes += width * height;
/* next mipmap level size */
if (width > 1)
width /= 2;
if (height > 1)
height /= 2;
}
}
void GL_APIENTRY
_es_CompressedTexImage2D(GLenum target, GLint level, GLenum internalFormat,
GLsizei width, GLsizei height, GLint border,
GLsizei imageSize, const GLvoid *data)
{
switch (internalFormat) {
case GL_PALETTE4_RGB8_OES:
case GL_PALETTE4_RGBA8_OES:
case GL_PALETTE4_R5_G6_B5_OES:
case GL_PALETTE4_RGBA4_OES:
case GL_PALETTE4_RGB5_A1_OES:
case GL_PALETTE8_RGB8_OES:
case GL_PALETTE8_RGBA8_OES:
case GL_PALETTE8_R5_G6_B5_OES:
case GL_PALETTE8_RGBA4_OES:
case GL_PALETTE8_RGB5_A1_OES:
cpal_compressed_teximage2d(target, level, internalFormat,
width, height, data);
break;
default:
_mesa_CompressedTexImage2DARB(target, level, internalFormat,
width, height, border, imageSize, data);
}
}

37
src/mesa/es/main/es_fbo.c Normal file
View File

@ -0,0 +1,37 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
**************************************************************************/
#include "GLES2/gl2.h"
#include "GLES2/gl2ext.h"
extern void GL_APIENTRY _es_RenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
extern void GL_APIENTRY _mesa_RenderbufferStorageEXT(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height);
void GL_APIENTRY
_es_RenderbufferStorage(GLenum target, GLenum internalFormat,
GLsizei width, GLsizei height)
{
switch (internalFormat) {
case GL_RGBA4:
case GL_RGB5_A1:
case GL_RGB565:
internalFormat = GL_RGBA;
break;
case GL_STENCIL_INDEX1_OES:
case GL_STENCIL_INDEX4_OES:
case GL_STENCIL_INDEX8:
internalFormat = GL_STENCIL_INDEX;
break;
default:
; /* no op */
}
_mesa_RenderbufferStorageEXT(target, internalFormat, width, height);
}

View File

@ -0,0 +1,773 @@
#*************************************************************************
# 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, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# TUNGSTEN GRAPHICS 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.
#*************************************************************************
import sys, os
import apiutil
# These dictionary entries are used for automatic conversion.
# The string will be used as a format string with the conversion
# variable.
Converters = {
'GLfloat': {
'GLdouble': "(GLdouble) (%s)",
'GLfixed' : "(GLint) (%s * 65536)",
},
'GLfixed': {
'GLfloat': "(GLfloat) (%s / 65536.0f)",
'GLdouble': "(GLdouble) (%s / 65536.0)",
},
'GLdouble': {
'GLfloat': "(GLfloat) (%s)",
'GLfixed': "(GLfixed) (%s * 65536)",
},
'GLclampf': {
'GLclampd': "(GLclampd) (%s)",
'GLclampx': "(GLclampx) (%s * 65536)",
},
'GLclampx': {
'GLclampf': "(GLclampf) (%s / 65536.0f)",
'GLclampd': "(GLclampd) (%s / 65536.0)",
},
'GLubyte': {
'GLfloat': "(GLfloat) (%s / 255.0f)",
},
}
def GetBaseType(type):
typeTokens = type.split(' ')
baseType = None
typeModifiers = []
for t in typeTokens:
if t in ['const', '*']:
typeModifiers.append(t)
else:
baseType = t
return (baseType, typeModifiers)
def ConvertValue(value, fromType, toType):
"""Returns a string that represents the given parameter string,
type-converted if necessary."""
if not Converters.has_key(fromType):
print >> sys.stderr, "No base converter for type '%s' found. Ignoring." % fromType
return value
if not Converters[fromType].has_key(toType):
print >> sys.stderr, "No converter found for type '%s' to type '%s'. Ignoring." % (fromType, toType)
return value
# This part is simple. Return the proper conversion.
conversionString = Converters[fromType][toType]
return conversionString % value
def GetLoopSizeExpression(funcName, paramName, paramMaxVecSize):
# The VariantArrays() list will have all the information (for all
# parameters) on how to calculate variant array sizes.
variantArrays = apiutil.VariantArrays(funcName)
defaultSize = paramMaxVecSize
loopSizeExpression = ''
# There can be many different entries in the variantArrays for the
# same parameter. We have to look at all of them and pick out the
# ones of interest.
for (variantName, variantSize, controllingParam, controllingValues) in variantArrays:
if paramName == variantName:
# This variant specification applies to us. It may be of
# the form "param size default", meaning that the value should
# replace the default size, or it may be
# "param size controlParam value...", in which case the size should
# be used if the controlParam has any one of the given values.
if len(controllingValues) == 0:
defaultSize = variantSize
else:
# Create a compound conditional that expresses
# all the possible values in the list
conditional = ''
for value in controllingValues:
if len(conditional) > 0:
conditional = conditional + " || "
conditional = conditional + "%s == %s" % (controllingParam, value)
# Add the possibly compound conditional and
# the associated vector size to the
# loop control expression
loopSizeExpression = loopSizeExpression + "(%s) ? %s : " % (conditional, variantSize)
# end if the name matches
# end for the list of all variant array declarations
# Return the expression that returns the actual size of the
# array. Note that 'loopSizeExpression' will already have a
# trailing ": " if it is nonempty.
if len(loopSizeExpression) > 0:
return "(%s%s)" % (loopSizeExpression, defaultSize)
else:
return "%s" % defaultSize
FormatStrings = {
'GLenum' : '0x%x',
'GLfloat' : '%f',
'GLint' : '%d',
'GLbitfield' : '0x%x',
}
def GetFormatString(type):
if FormatStrings.has_key(type):
return FormatStrings[type]
else:
return None
######################################################################
# Version-specific values to be used in the main script
# header: which header file to include
# api: what text specifies an API-level function
# special: the name of the "specials" file
VersionSpecificValues = {
'GLES1.1' : {
'description' : 'GLES1.1 functions',
'header' : 'GLES/gl.h',
'extheader' : 'GLES/glext.h',
'special' : 'es1_special',
},
'GLES2.0': {
'description' : 'GLES2.0 functions',
'header' : 'GLES2/gl2.h',
'extheader' : 'GLES2/gl2ext.h',
'special' : 'es2_special',
}
}
######################################################################
# Main code for the script begins here.
# Get the name of the program (without the directory part) for use in
# error messages.
program = os.path.basename(sys.argv[0])
# We assume that the directory that the Python script is in also
# houses the "special" files.
programDir = os.path.dirname(sys.argv[0])
# Set default values
verbose = 0
functionList = "APIspec.txt"
version = "GLES1.1"
# Allow for command-line switches
import getopt, time
options = "hvV:S:"
try:
optlist, args = getopt.getopt(sys.argv[1:], options)
except getopt.GetoptError, message:
sys.stderr.write("%s: %s. Use -h for help.\n" % (program, message))
sys.exit(1)
for option, optarg in optlist:
if option == "-h":
sys.stderr.write("Usage: %s [-%s]\n" % (program, options))
sys.stderr.write("Parse an API specification file and generate wrapper functions for a given GLES version\n")
sys.stderr.write("-h gives help\n")
sys.stderr.write("-v is verbose\n")
sys.stderr.write("-V specifies GLES version to generate [%s]:\n" % version)
for key in VersionSpecificValues.keys():
sys.stderr.write(" %s - %s\n" % (key, VersionSpecificValues[key]['description']))
sys.stderr.write("-S specifies API specification file to use [%s]\n" % functionList)
sys.exit(1)
elif option == "-v":
verbose += 1
elif option == "-V":
version = optarg
elif option == "-S":
functionList = optarg
# Beyond switches, we support no further command-line arguments
if len(args) > 0:
sys.stderr.write("%s: only switch arguments are supported - use -h for help\n" % program)
sys.exit(1)
# If we don't have a valid version, abort.
if not VersionSpecificValues.has_key(version):
sys.stderr.write("%s: version '%s' is not valid - use -h for help\n" % (program, version))
sys.exit(1)
# Grab the version-specific items we need to use
versionHeader = VersionSpecificValues[version]['header']
versionExtHeader = VersionSpecificValues[version]['extheader']
versionSpecial = VersionSpecificValues[version]['special']
# We're probably being invoked from a different directory,
# so look for the "special" file in the same directory that
# holds the Python script
specialFile = os.path.join(programDir, versionSpecial)
if not os.path.isfile(specialFile):
sys.stderr.write("%s: can't find special file '%s' for version '%s' - aborting" % (program, specialFile, version))
sys.exit(1)
allSpecials = apiutil.AllSpecials(specialFile.split("_")[0])
# If we get to here, we're good to go. The "version" parameter
# directs GetDispatchedFunctions to only allow functions from
# that "category" (version in our parlance). This allows
# functions with different declarations in different categories
# to exist (glTexImage2D, for example, is different between
# GLES1 and GLES2).
keys = apiutil.GetAllFunctions(functionList, version)
print """/* DO NOT EDIT *************************************************
* THIS FILE AUTOMATICALLY GENERATED BY THE %s SCRIPT
* API specification file: %s
* GLES version: %s
* date: %s
*/
""" % (program, functionList, version, time.strftime("%Y-%m-%d %H:%M:%S"))
# The headers we choose are version-specific.
print """
#include "%s"
#include "%s"
""" % (versionHeader, versionExtHeader)
# Everyone needs these types.
print """
/* These types are needed for the Mesa veneer, but are not defined in
* the standard GLES headers.
*/
typedef double GLdouble;
typedef double GLclampd;
/* This type is normally in glext.h, but needed here */
typedef char GLchar;
/* Mesa error handling requires these */
extern void *_mesa_get_current_context(void);
extern void _mesa_error(void *ctx, GLenum error, const char *fmtString, ... );
#include "main/compiler.h"
#include "main/api_exec.h"
#include "glapi/dispatch.h"
typedef void (*_glapi_proc)(void); /* generic function pointer */
"""
# All variant-length arrays in the GLES API are controlled by some
# selector parameter. Almost all of those are constant length based
# on the selector parameter (e.g., in glFogfv(), if the "pname"
# parameter is GL_FOG_COLOR, the "params" array is considered to be
# 4 floats long; for any other value of "pname", the "params' array
# is considered to be 1 float long.
#
# There are a very few instances where the selector parameter chooses
# a runtime-determined value:
# glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS)
# glGetIntegerv(GL_SHADER_BINARY_FORMATS)
# plus the glGetBooleanv, glGetFloatv, glGetFixedv counterparts.
#
# The number of formats in both cases is not a constant, but is a
# runtime-determined value (based on the return value of
# glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS) or
# glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS).
#
# Rather than hard-code some value (and risk memory errors when we
# overshoot arrays), in these cases we'll use a constant expresssion
# (e.g. _get_size(GL_NUM_COMPRESSED_TEXTURE_FORMATS)) to get the
# value of the variant array. Note, though, that in these cases the
# "vector" parameter should be set to some size large enough to hold
# all values (and must be set for GLfixed-based conversions, which
# need it to define an auxiliary array size).
#
# Here's the function itself. Although we only need a couple of values,
# we'll make it general.
print """
extern void GLAPIENTRY _mesa_GetIntegerv(GLenum, GLint *);
static INLINE unsigned int _get_size(GLenum pname)
{
/* In case of error, make sure the value returned is 0. */
GLint value = 0;
_mesa_GetIntegerv(pname, &value);
return (unsigned int) value;
}
"""
# Finally we get to the all-important functions
print """/*************************************************************
* Generated functions begin here
*/
"""
for funcName in keys:
if verbose > 0: sys.stderr.write("%s: processing function %s\n" % (program, funcName))
# start figuring out what this function will look like.
returnType = apiutil.ReturnType(funcName)
props = apiutil.Properties(funcName)
params = apiutil.Parameters(funcName)
declarationString = apiutil.MakeDeclarationString(params)
# In case of error, a function may have to return. Make
# sure we have valid return values in this case.
if returnType == "void":
errorReturn = "return"
elif returnType == "GLboolean":
errorReturn = "return GL_FALSE"
else:
errorReturn = "return (%s) 0" % returnType
# These are the output of this large calculation block.
# passthroughDeclarationString: a typed set of parameters that
# will be used to create the "extern" reference for the
# underlying Mesa or support function. Note that as generated
# these have an extra ", " at the beginning, which will be
# removed before use.
#
# passthroughDeclarationString: an untyped list of parameters
# that will be used to call the underlying Mesa or support
# function (including references to converted parameters).
# This will also be generated with an extra ", " at the
# beginning, which will be removed before use.
#
# variables: C code to create any local variables determined to
# be necessary.
# conversionCodeOutgoing: C code to convert application parameters
# to a necessary type before calling the underlying support code.
# May be empty if no conversion is required.
# conversionCodeIncoming: C code to do the converse: convert
# values returned by underlying Mesa code to the types needed
# by the application.
# Note that *either* the conversionCodeIncoming will be used (for
# generated query functions), *or* the conversionCodeOutgoing will
# be used (for generated non-query functions), never both.
passthroughFuncName = ""
passthroughDeclarationString = ""
passthroughCallString = ""
variables = []
conversionCodeOutgoing = []
conversionCodeIncoming = []
switchCode = []
# Calculate the name of the underlying support function to call.
# By default, the passthrough function is named _mesa_<funcName>.
# We're allowed to override the prefix and/or the function name
# for each function record, though. The "ConversionFunction"
# utility is poorly named, BTW...
aliasprefix = apiutil.AliasPrefix(funcName)
alias = apiutil.ConversionFunction(funcName)
if not alias:
# There may still be a Mesa alias for the function
if apiutil.Alias(funcName):
passthroughFuncName = "%s%s" % (aliasprefix, apiutil.Alias(funcName))
else:
passthroughFuncName = "%s%s" % (aliasprefix, funcName)
else: # a specific alias is provided
passthroughFuncName = "%s%s" % (aliasprefix, alias)
# Look at every parameter: each one may have only specific
# allowed values, or dependent parameters to check, or
# variant-sized vector arrays to calculate
for (paramName, paramType, paramMaxVecSize, paramConvertToType, paramValidValues, paramValueConversion) in params:
# We'll need this below if we're doing conversions
(paramBaseType, paramTypeModifiers) = GetBaseType(paramType)
# Conversion management.
# We'll handle three cases, easiest to hardest: a parameter
# that doesn't require conversion, a scalar parameter that
# requires conversion, and a vector parameter that requires
# conversion.
if paramConvertToType == None:
# Unconverted parameters are easy, whether they're vector
# or scalar - just add them to the call list. No conversions
# or anything to worry about.
passthroughDeclarationString += ", %s %s" % (paramType, paramName)
passthroughCallString += ", %s" % paramName
elif paramMaxVecSize == 0: # a scalar parameter that needs conversion
# A scalar to hold a converted parameter
variables.append(" %s converted_%s;" % (paramConvertToType, paramName))
# Outgoing conversion depends on whether we have to conditionally
# perform value conversion.
if paramValueConversion == "none":
conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName))
elif paramValueConversion == "some":
# We'll need a conditional variable to keep track of
# whether we're converting values or not.
if (" int convert_%s_value = 1;" % paramName) not in variables:
variables.append(" int convert_%s_value = 1;" % paramName)
# Write code based on that conditional.
conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName)
conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType)))
conversionCodeOutgoing.append(" } else {")
conversionCodeOutgoing.append(" converted_%s = (%s) %s;" % (paramName, paramConvertToType, paramName))
conversionCodeOutgoing.append(" }")
else: # paramValueConversion == "all"
conversionCodeOutgoing.append(" converted_%s = %s;" % (paramName, ConvertValue(paramName, paramBaseType, paramConvertToType)))
# Note that there can be no incoming conversion for a
# scalar parameter; changing the scalar will only change
# the local value, and won't ultimately change anything
# that passes back to the application.
# Call strings. The unusual " ".join() call will join the
# array of parameter modifiers with spaces as separators.
passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName)
passthroughCallString += ", converted_%s" % paramName
else: # a vector parameter that needs conversion
# We'll need an index variable for conversions
if " register unsigned int i;" not in variables:
variables.append(" register unsigned int i;")
# This variable will hold the (possibly variant) size of
# this array needing conversion. By default, we'll set
# it to the maximal size (which is correct for functions
# with a constant-sized vector parameter); for true
# variant arrays, we'll modify it with other code.
variables.append(" unsigned int n_%s = %d;" % (paramName, paramMaxVecSize))
# This array will hold the actual converted values.
variables.append(" %s converted_%s[%d];" % (paramConvertToType, paramName, paramMaxVecSize))
# Again, we choose the conversion code based on whether we
# have to always convert values, never convert values, or
# conditionally convert values.
if paramValueConversion == "none":
conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName))
conversionCodeOutgoing.append(" }")
elif paramValueConversion == "some":
# We'll need a conditional variable to keep track of
# whether we're converting values or not.
if (" int convert_%s_value = 1;" % paramName) not in variables:
variables.append(" int convert_%s_value = 1;" % paramName)
# Write code based on that conditional.
conversionCodeOutgoing.append(" if (convert_%s_value) {" % paramName)
conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType)))
conversionCodeOutgoing.append(" }")
conversionCodeOutgoing.append(" } else {")
conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeOutgoing.append(" converted_%s[i] = (%s) %s[i];" % (paramName, paramConvertToType, paramName))
conversionCodeOutgoing.append(" }")
conversionCodeOutgoing.append(" }")
else: # paramValueConversion == "all"
conversionCodeOutgoing.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeOutgoing.append(" converted_%s[i] = %s;" % (paramName, ConvertValue("%s[i]" % paramName, paramBaseType, paramConvertToType)))
conversionCodeOutgoing.append(" }")
# If instead we need an incoming conversion (i.e. results
# from Mesa have to be converted before handing back
# to the application), this is it. Fortunately, we don't
# have to worry about conditional value conversion - the
# functions that do (e.g. glGetFixedv()) are handled
# specially, outside this code generation.
#
# Whether we use incoming conversion or outgoing conversion
# is determined later - we only ever use one or the other.
if paramValueConversion == "none":
conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramConvertToType, paramName))
conversionCodeIncoming.append(" }")
elif paramValueConversion == "some":
# We'll need a conditional variable to keep track of
# whether we're converting values or not.
if (" int convert_%s_value = 1;" % paramName) not in variables:
variables.append(" int convert_%s_value = 1;" % paramName)
# Write code based on that conditional.
conversionCodeIncoming.append(" if (convert_%s_value) {" % paramName)
conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType)))
conversionCodeIncoming.append(" }")
conversionCodeIncoming.append(" } else {")
conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeIncoming.append(" %s[i] = (%s) converted_%s[i];" % (paramName, paramBaseType, paramName))
conversionCodeIncoming.append(" }")
conversionCodeIncoming.append(" }")
else: # paramValueConversion == "all"
conversionCodeIncoming.append(" for (i = 0; i < n_%s; i++) {" % paramName)
conversionCodeIncoming.append(" %s[i] = %s;" % (paramName, ConvertValue("converted_%s[i]" % paramName, paramConvertToType, paramBaseType)))
conversionCodeIncoming.append(" }")
# Call strings. The unusual " ".join() call will join the
# array of parameter modifiers with spaces as separators.
passthroughDeclarationString += ", %s %s %s" % (paramConvertToType, " ".join(paramTypeModifiers), paramName)
passthroughCallString += ", converted_%s" % paramName
# endif conversion management
# Parameter checking. If the parameter has a specific list of
# valid values, we have to make sure that the passed-in values
# match these, or we make an error.
if len(paramValidValues) > 0:
# We're about to make a big switch statement with an
# error at the end. By default, the error is GL_INVALID_ENUM,
# unless we find a "case" statement in the middle with a
# non-GLenum value.
errorDefaultCase = "GL_INVALID_ENUM"
# This parameter has specific valid values. Make a big
# switch statement to handle it. Note that the original
# parameters are always what is checked, not the
# converted parameters.
switchCode.append(" switch(%s) {" % paramName)
for valueIndex in range(len(paramValidValues)):
(paramValue, dependentVecSize, dependentParamName, dependentValidValues, errorCode, valueConvert) = paramValidValues[valueIndex]
# We're going to need information on the dependent param
# as well.
if dependentParamName:
depParamIndex = apiutil.FindParamIndex(params, dependentParamName)
if depParamIndex == None:
sys.stderr.write("%s: can't find dependent param '%s' for function '%s'\n" % (program, dependentParamName, funcName))
(depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = params[depParamIndex]
else:
(depParamName, depParamType, depParamMaxVecSize, depParamConvertToType, depParamValidValues, depParamValueConversion) = (None, None, None, None, [], None)
# This is a sneaky trick. It's valid syntax for a parameter
# that is *not* going to be converted to be declared
# with a dependent vector size; but in this case, the
# dependent vector size is unused and unnecessary.
# So check for this and ignore the dependent vector size
# if the parameter is not going to be converted.
if depParamConvertToType:
usedDependentVecSize = dependentVecSize
else:
usedDependentVecSize = None
# We'll peek ahead at the next parameter, to see whether
# we can combine cases
if valueIndex + 1 < len(paramValidValues) :
(nextParamValue, nextDependentVecSize, nextDependentParamName, nextDependentValidValues, nextErrorCode, nextValueConvert) = paramValidValues[valueIndex + 1]
if depParamConvertToType:
usedNextDependentVecSize = nextDependentVecSize
else:
usedNextDependentVecSize = None
# Create a case for this value. As a mnemonic,
# if we have a dependent vector size that we're ignoring,
# add it as a comment.
if usedDependentVecSize == None and dependentVecSize != None:
switchCode.append(" case %s: /* size %s */" % (paramValue, dependentVecSize))
else:
switchCode.append(" case %s:" % paramValue)
# If this is not a GLenum case, then switch our error
# if no value is matched to be GL_INVALID_VALUE instead
# of GL_INVALID_ENUM. (Yes, this does get confused
# if there are both values and GLenums in the same
# switch statement, which shouldn't happen.)
if paramValue[0:3] != "GL_":
errorDefaultCase = "GL_INVALID_VALUE"
# If all the remaining parameters are identical to the
# next set, then we're done - we'll just create the
# official code on the next pass through, and the two
# cases will share the code.
if valueIndex + 1 < len(paramValidValues) and usedDependentVecSize == usedNextDependentVecSize and dependentParamName == nextDependentParamName and dependentValidValues == nextDependentValidValues and errorCode == nextErrorCode and valueConvert == nextValueConvert:
continue
# Otherwise, we'll have to generate code for this case.
# Start off with a check: if there is a dependent parameter,
# and a list of valid values for that parameter, we need
# to generate an error if something other than one
# of those values is passed.
if len(dependentValidValues) > 0:
conditional=""
# If the parameter being checked is actually an array,
# check only its first element.
if depParamMaxVecSize == 0:
valueToCheck = dependentParamName
else:
valueToCheck = "%s[0]" % dependentParamName
for v in dependentValidValues:
conditional += " && %s != %s" % (valueToCheck, v)
switchCode.append(" if (%s) {" % conditional[4:])
if errorCode == None:
errorCode = "GL_INVALID_ENUM"
switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=0x%s)", %s);' % (errorCode, funcName, paramName, "%x", paramName))
switchCode.append(" %s;" % errorReturn)
switchCode.append(" }")
# endif there are dependent valid values
# The dependent parameter may require conditional
# value conversion. If it does, and we don't want
# to convert values, we'll have to generate code for that
if depParamValueConversion == "some" and valueConvert == "noconvert":
switchCode.append(" convert_%s_value = 0;" % dependentParamName)
# If there's a dependent vector size for this parameter
# that we're actually going to use (i.e. we need conversion),
# mark it.
if usedDependentVecSize:
switchCode.append(" n_%s = %s;" % (dependentParamName, dependentVecSize))
# In all cases, break out of the switch if any valid
# value is found.
switchCode.append(" break;")
# Need a default case to catch all the other, invalid
# parameter values. These will all generate errors.
switchCode.append(" default:")
if errorCode == None:
errorCode = "GL_INVALID_ENUM"
formatString = GetFormatString(paramType)
if formatString == None:
switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s)");' % (errorCode, funcName, paramName))
else:
switchCode.append(' _mesa_error(_mesa_get_current_context(), %s, "gl%s(%s=%s)", %s);' % (errorCode, funcName, paramName, formatString, paramName))
switchCode.append(" %s;" % errorReturn)
# End of our switch code.
switchCode.append(" }")
# endfor every recognized parameter value
# endfor every param
# Here, the passthroughDeclarationString and passthroughCallString
# are complete; remove the extra ", " at the front of each.
passthroughDeclarationString = passthroughDeclarationString[2:]
passthroughCallString = passthroughCallString[2:]
# The Mesa functions are scattered across all the Mesa
# header files. The easiest way to manage declarations
# is to create them ourselves.
if funcName not in allSpecials:
print "extern %s GLAPIENTRY %s(%s);" % (returnType, passthroughFuncName, passthroughDeclarationString)
# A function may be a core function (i.e. it exists in
# the core specification), a core addition (extension
# functions added officially to the core), a required
# extension (usually an extension for an earlier version
# that has been officially adopted), or an optional extension.
#
# Core functions have a simple category (e.g. "GLES1.1");
# we generate only a simple callback for them.
#
# Core additions have two category listings, one simple
# and one compound (e.g. ["GLES1.1", "GLES1.1:OES_fixed_point"]).
# We generate the core function, and also an extension function.
#
# Required extensions and implemented optional extensions
# have a single compound category "GLES1.1:OES_point_size_array".
# For these we generate just the extension function.
for categorySpec in apiutil.Categories(funcName):
compoundCategory = categorySpec.split(":")
# This category isn't for us, if the base category doesn't match
# our version
if compoundCategory[0] != version:
continue
# Otherwise, determine if we're writing code for a core
# function (no suffix) or an extension function.
if len(compoundCategory) == 1:
# This is a core function
extensionName = None
fullFuncName = "_es_" + funcName
else:
# This is an extension function. We'll need to append
# the extension suffix.
extensionName = compoundCategory[1]
extensionSuffix = extensionName.split("_")[0]
fullFuncName = "_es_" + funcName + extensionSuffix
# Now the generated function. The text used to mark an API-level
# function, oddly, is version-specific.
if extensionName:
print "/* Extension %s */" % extensionName
if funcName in allSpecials:
print "/* this function is special and is defined elsewhere */"
print "extern %s %s(%s);" % (returnType, fullFuncName, declarationString)
print
continue
print "static %s %s(%s)" % (returnType, fullFuncName, declarationString)
print "{"
# Start printing our code pieces. Start with any local
# variables we need. This unusual syntax joins the
# lines in the variables[] array with the "\n" separator.
if len(variables) > 0:
print "\n".join(variables) + "\n"
# If there's any sort of parameter checking or variable
# array sizing, the switch code will contain it.
if len(switchCode) > 0:
print "\n".join(switchCode) + "\n"
# In the case of an outgoing conversion (i.e. parameters must
# be converted before calling the underlying Mesa function),
# use the appropriate code.
if "get" not in props and len(conversionCodeOutgoing) > 0:
print "\n".join(conversionCodeOutgoing) + "\n"
# Call the Mesa function. Note that there are very few functions
# that return a value (i.e. returnType is not "void"), and that
# none of them require incoming translation; so we're safe
# to generate code that directly returns in those cases,
# even though it's not completely independent.
if returnType == "void":
print " %s(%s);" % (passthroughFuncName, passthroughCallString)
else:
print " return %s(%s);" % (passthroughFuncName, passthroughCallString)
# If the function is one that returns values (i.e. "get" in props),
# it might return values of a different type than we need, that
# require conversion before passing back to the application.
if "get" in props and len(conversionCodeIncoming) > 0:
print "\n".join(conversionCodeIncoming)
# All done.
print "}"
print
# end for each category provided for a function
# end for each function
print "void"
print "_mesa_init_exec_table(struct _glapi_table *exec)"
print "{"
for func in keys:
for spec in apiutil.Categories(func):
ext = spec.split(":")
# version does not match
if ext.pop(0) != version:
continue
entry = func
if ext:
suffix = ext[0].split("_")[0]
entry += suffix
print " SET_%s(exec, _es_%s);" % (entry, entry)
print "}"

View File

@ -0,0 +1,199 @@
/**************************************************************************
*
* Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
**************************************************************************/
/**
* Code to implement GL_OES_query_matrix. See the spec at:
* http://www.khronos.org/registry/gles/extensions/OES/OES_query_matrix.txt
*/
#include <stdlib.h>
#include <math.h>
#include "GLES/gl.h"
#include "GLES/glext.h"
/**
* This is from the GL_OES_query_matrix extension specification:
*
* GLbitfield glQueryMatrixxOES( GLfixed mantissa[16],
* GLint exponent[16] )
* mantissa[16] contains the contents of the current matrix in GLfixed
* format. exponent[16] contains the unbiased exponents applied to the
* matrix components, so that the internal representation of component i
* is close to mantissa[i] * 2^exponent[i]. The function returns a status
* word which is zero if all the components are valid. If
* status & (1<<i) != 0, the component i is invalid (e.g., NaN, Inf).
* The implementations are not required to keep track of overflows. In
* that case, the invalid bits are never set.
*/
#define INT_TO_FIXED(x) ((GLfixed) ((x) << 16))
#define FLOAT_TO_FIXED(x) ((GLfixed) ((x) * 65536.0))
#if defined(WIN32) || defined(_WIN32_WCE)
/* Oddly, the fpclassify() function doesn't exist in such a form
* on Windows. This is an implementation using slightly different
* lower-level Windows functions.
*/
#include <float.h>
enum {FP_NAN, FP_INFINITE, FP_ZERO, FP_SUBNORMAL, FP_NORMAL}
fpclassify(double x)
{
switch(_fpclass(x)) {
case _FPCLASS_SNAN: /* signaling NaN */
case _FPCLASS_QNAN: /* quiet NaN */
return FP_NAN;
case _FPCLASS_NINF: /* negative infinity */
case _FPCLASS_PINF: /* positive infinity */
return FP_INFINITE;
case _FPCLASS_NN: /* negative normal */
case _FPCLASS_PN: /* positive normal */
return FP_NORMAL;
case _FPCLASS_ND: /* negative denormalized */
case _FPCLASS_PD: /* positive denormalized */
return FP_SUBNORMAL;
case _FPCLASS_NZ: /* negative zero */
case _FPCLASS_PZ: /* positive zero */
return FP_ZERO;
default:
/* Should never get here; but if we do, this will guarantee
* that the pattern is not treated like a number.
*/
return FP_NAN;
}
}
#endif
extern GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16]);
/* The Mesa functions we'll need */
extern void GL_APIENTRY _mesa_GetIntegerv(GLenum pname, GLint *params);
extern void GL_APIENTRY _mesa_GetFloatv(GLenum pname, GLfloat *params);
GLbitfield GL_APIENTRY _es_QueryMatrixxOES(GLfixed mantissa[16], GLint exponent[16])
{
GLfloat matrix[16];
GLint tmp;
GLenum currentMode = GL_FALSE;
GLenum desiredMatrix = GL_FALSE;
/* The bitfield returns 1 for each component that is invalid (i.e.
* NaN or Inf). In case of error, everything is invalid.
*/
GLbitfield rv;
register unsigned int i;
unsigned int bit;
/* This data structure defines the mapping between the current matrix
* mode and the desired matrix identifier.
*/
static struct {
GLenum currentMode;
GLenum desiredMatrix;
} modes[] = {
{GL_MODELVIEW, GL_MODELVIEW_MATRIX},
{GL_PROJECTION, GL_PROJECTION_MATRIX},
{GL_TEXTURE, GL_TEXTURE_MATRIX},
#if 0
/* this doesn't exist in GLES */
{GL_COLOR, GL_COLOR_MATRIX},
#endif
};
/* Call Mesa to get the current matrix in floating-point form. First,
* we have to figure out what the current matrix mode is.
*/
_mesa_GetIntegerv(GL_MATRIX_MODE, &tmp);
currentMode = (GLenum) tmp;
/* The mode is either GL_FALSE, if for some reason we failed to query
* the mode, or a given mode from the above table. Search for the
* returned mode to get the desired matrix; if we don't find it,
* we can return immediately, as _mesa_GetInteger() will have
* logged the necessary error already.
*/
for (i = 0; i < sizeof(modes)/sizeof(modes[0]); i++) {
if (modes[i].currentMode == currentMode) {
desiredMatrix = modes[i].desiredMatrix;
break;
}
}
if (desiredMatrix == GL_FALSE) {
/* Early error means all values are invalid. */
return 0xffff;
}
/* Now pull the matrix itself. */
_mesa_GetFloatv(desiredMatrix, matrix);
rv = 0;
for (i = 0, bit = 1; i < 16; i++, bit<<=1) {
float normalizedFraction;
int exp;
switch (fpclassify(matrix[i])) {
/* A "subnormal" or denormalized number is too small to be
* represented in normal format; but despite that it's a
* valid floating point number. FP_ZERO and FP_NORMAL
* are both valid as well. We should be fine treating
* these three cases as legitimate floating-point numbers.
*/
case FP_SUBNORMAL:
case FP_NORMAL:
case FP_ZERO:
normalizedFraction = (GLfloat)frexp(matrix[i], &exp);
mantissa[i] = FLOAT_TO_FIXED(normalizedFraction);
exponent[i] = (GLint) exp;
break;
/* If the entry is not-a-number or an infinity, then the
* matrix component is invalid. The invalid flag for
* the component is already set; might as well set the
* other return values to known values. We'll set
* distinct values so that a savvy end user could determine
* whether the matrix component was a NaN or an infinity,
* but this is more useful for debugging than anything else
* since the standard doesn't specify any such magic
* values to return.
*/
case FP_NAN:
mantissa[i] = INT_TO_FIXED(0);
exponent[i] = (GLint) 0;
rv |= bit;
break;
case FP_INFINITE:
/* Return +/- 1 based on whether it's a positive or
* negative infinity.
*/
if (matrix[i] > 0) {
mantissa[i] = INT_TO_FIXED(1);
}
else {
mantissa[i] = -INT_TO_FIXED(1);
}
exponent[i] = (GLint) 0;
rv |= bit;
break;
/* We should never get here; but here's a catching case
* in case fpclassify() is returnings something unexpected.
*/
default:
mantissa[i] = INT_TO_FIXED(2);
exponent[i] = (GLint) 0;
rv |= bit;
break;
}
} /* for each component */
/* All done */
return rv;
}

785
src/mesa/es/main/get_gen.py Normal file
View File

@ -0,0 +1,785 @@
#!/usr/bin/env python
# Mesa 3-D graphics library
#
# Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# This script is used to generate the get.c file:
# python get_gen.py > get.c
import string
import sys
GLint = 1
GLenum = 2
GLfloat = 3
GLdouble = 4
GLboolean = 5
GLfloatN = 6 # A normalized value, such as a color or depth range
TypeStrings = {
GLint : "GLint",
GLenum : "GLenum",
GLfloat : "GLfloat",
GLdouble : "GLdouble",
GLboolean : "GLboolean"
}
# Each entry is a tuple of:
# - the GL state name, such as GL_CURRENT_COLOR
# - the state datatype, one of GLint, GLfloat, GLboolean or GLenum
# - list of code fragments to get the state, such as ["ctx->Foo.Bar"]
# - optional extra code or empty string
# - optional extensions to check, or None
#
# Present in ES 1.x and 2.x:
StateVars_common = [
( "GL_ALPHA_BITS", GLint, ["ctx->DrawBuffer->Visual.alphaBits"],
"", None ),
( "GL_BLEND", GLboolean, ["ctx->Color.BlendEnabled"], "", None ),
( "GL_BLEND_SRC", GLenum, ["ctx->Color.BlendSrcRGB"], "", None ),
( "GL_BLUE_BITS", GLint, ["ctx->DrawBuffer->Visual.blueBits"], "", None ),
( "GL_COLOR_CLEAR_VALUE", GLfloatN,
[ "ctx->Color.ClearColor[0]",
"ctx->Color.ClearColor[1]",
"ctx->Color.ClearColor[2]",
"ctx->Color.ClearColor[3]" ], "", None ),
( "GL_COLOR_WRITEMASK", GLint,
[ "ctx->Color.ColorMask[RCOMP] ? 1 : 0",
"ctx->Color.ColorMask[GCOMP] ? 1 : 0",
"ctx->Color.ColorMask[BCOMP] ? 1 : 0",
"ctx->Color.ColorMask[ACOMP] ? 1 : 0" ], "", None ),
( "GL_CULL_FACE", GLboolean, ["ctx->Polygon.CullFlag"], "", None ),
( "GL_CULL_FACE_MODE", GLenum, ["ctx->Polygon.CullFaceMode"], "", None ),
( "GL_DEPTH_BITS", GLint, ["ctx->DrawBuffer->Visual.depthBits"],
"", None ),
( "GL_DEPTH_CLEAR_VALUE", GLfloatN, ["ctx->Depth.Clear"], "", None ),
( "GL_DEPTH_FUNC", GLenum, ["ctx->Depth.Func"], "", None ),
( "GL_DEPTH_RANGE", GLfloatN,
[ "ctx->Viewport.Near", "ctx->Viewport.Far" ], "", None ),
( "GL_DEPTH_TEST", GLboolean, ["ctx->Depth.Test"], "", None ),
( "GL_DEPTH_WRITEMASK", GLboolean, ["ctx->Depth.Mask"], "", None ),
( "GL_DITHER", GLboolean, ["ctx->Color.DitherFlag"], "", None ),
( "GL_FRONT_FACE", GLenum, ["ctx->Polygon.FrontFace"], "", None ),
( "GL_GREEN_BITS", GLint, ["ctx->DrawBuffer->Visual.greenBits"],
"", None ),
( "GL_LINE_WIDTH", GLfloat, ["ctx->Line.Width"], "", None ),
( "GL_ALIASED_LINE_WIDTH_RANGE", GLfloat,
["ctx->Const.MinLineWidth",
"ctx->Const.MaxLineWidth"], "", None ),
( "GL_MAX_ELEMENTS_INDICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
( "GL_MAX_ELEMENTS_VERTICES", GLint, ["ctx->Const.MaxArrayLockSize"], "", None ),
( "GL_MAX_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.MaxTextureLevels - 1)"], "", None ),
( "GL_MAX_VIEWPORT_DIMS", GLint,
["ctx->Const.MaxViewportWidth", "ctx->Const.MaxViewportHeight"],
"", None ),
( "GL_PACK_ALIGNMENT", GLint, ["ctx->Pack.Alignment"], "", None ),
( "GL_ALIASED_POINT_SIZE_RANGE", GLfloat,
["ctx->Const.MinPointSize",
"ctx->Const.MaxPointSize"], "", None ),
( "GL_POLYGON_OFFSET_FACTOR", GLfloat, ["ctx->Polygon.OffsetFactor "], "", None ),
( "GL_POLYGON_OFFSET_UNITS", GLfloat, ["ctx->Polygon.OffsetUnits "], "", None ),
( "GL_RED_BITS", GLint, ["ctx->DrawBuffer->Visual.redBits"], "", None ),
( "GL_SCISSOR_BOX", GLint,
["ctx->Scissor.X",
"ctx->Scissor.Y",
"ctx->Scissor.Width",
"ctx->Scissor.Height"], "", None ),
( "GL_SCISSOR_TEST", GLboolean, ["ctx->Scissor.Enabled"], "", None ),
( "GL_STENCIL_BITS", GLint, ["ctx->DrawBuffer->Visual.stencilBits"], "", None ),
( "GL_STENCIL_CLEAR_VALUE", GLint, ["ctx->Stencil.Clear"], "", None ),
( "GL_STENCIL_FAIL", GLenum,
["ctx->Stencil.FailFunc[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_FUNC", GLenum,
["ctx->Stencil.Function[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_PASS_DEPTH_FAIL", GLenum,
["ctx->Stencil.ZFailFunc[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_PASS_DEPTH_PASS", GLenum,
["ctx->Stencil.ZPassFunc[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_REF", GLint,
["ctx->Stencil.Ref[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_TEST", GLboolean, ["ctx->Stencil.Enabled"], "", None ),
( "GL_STENCIL_VALUE_MASK", GLint,
["ctx->Stencil.ValueMask[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_STENCIL_WRITEMASK", GLint,
["ctx->Stencil.WriteMask[ctx->Stencil.ActiveFace]"], "", None ),
( "GL_SUBPIXEL_BITS", GLint, ["ctx->Const.SubPixelBits"], "", None ),
( "GL_TEXTURE_BINDING_2D", GLint,
["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_2D_INDEX]->Name"], "", None ),
( "GL_UNPACK_ALIGNMENT", GLint, ["ctx->Unpack.Alignment"], "", None ),
( "GL_VIEWPORT", GLint, [ "ctx->Viewport.X", "ctx->Viewport.Y",
"ctx->Viewport.Width", "ctx->Viewport.Height" ], "", None ),
# GL_ARB_multitexture
( "GL_ACTIVE_TEXTURE_ARB", GLint,
[ "GL_TEXTURE0_ARB + ctx->Texture.CurrentUnit"], "", ["ARB_multitexture"] ),
# Note that all the OES_* extensions require that the Mesa
# "struct gl_extensions" include a member with the name of
# the extension. That structure does not yet include OES
# extensions (and we're not sure whether it will). If
# it does, all the OES_* extensions below should mark the
# dependency.
# OES_texture_cube_map
( "GL_TEXTURE_BINDING_CUBE_MAP_ARB", GLint,
["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_CUBE_INDEX]->Name"],
"", None),
( "GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB", GLint,
["(1 << (ctx->Const.MaxCubeTextureLevels - 1))"],
"", None),
# OES_blend_subtract
( "GL_BLEND_SRC_RGB_EXT", GLenum, ["ctx->Color.BlendSrcRGB"], "", None),
( "GL_BLEND_DST_RGB_EXT", GLenum, ["ctx->Color.BlendDstRGB"], "", None),
( "GL_BLEND_SRC_ALPHA_EXT", GLenum, ["ctx->Color.BlendSrcA"], "", None),
( "GL_BLEND_DST_ALPHA_EXT", GLenum, ["ctx->Color.BlendDstA"], "", None),
# GL_BLEND_EQUATION_RGB, which is what we're really after,
# is defined identically to GL_BLEND_EQUATION.
( "GL_BLEND_EQUATION", GLenum, ["ctx->Color.BlendEquationRGB "], "", None),
( "GL_BLEND_EQUATION_ALPHA_EXT", GLenum, ["ctx->Color.BlendEquationA "],
"", None),
# GL_ARB_texture_compression */
# ( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
# ["_mesa_get_compressed_formats(ctx, NULL, GL_FALSE)"],
# "", ["ARB_texture_compression"] ),
# ( "GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLenum,
# [],
# """GLint formats[100];
# GLuint i, n = _mesa_get_compressed_formats(ctx, formats, GL_FALSE);
# ASSERT(n <= 100);
# for (i = 0; i < n; i++)
# params[i] = ENUM_TO_INT(formats[i]);""",
# ["ARB_texture_compression"] ),
# GL_ARB_multisample
( "GL_SAMPLE_ALPHA_TO_COVERAGE_ARB", GLboolean,
["ctx->Multisample.SampleAlphaToCoverage"], "", ["ARB_multisample"] ),
( "GL_SAMPLE_COVERAGE_ARB", GLboolean,
["ctx->Multisample.SampleCoverage"], "", ["ARB_multisample"] ),
( "GL_SAMPLE_COVERAGE_VALUE_ARB", GLfloat,
["ctx->Multisample.SampleCoverageValue"], "", ["ARB_multisample"] ),
( "GL_SAMPLE_COVERAGE_INVERT_ARB", GLboolean,
["ctx->Multisample.SampleCoverageInvert"], "", ["ARB_multisample"] ),
( "GL_SAMPLE_BUFFERS_ARB", GLint,
["ctx->DrawBuffer->Visual.sampleBuffers"], "", ["ARB_multisample"] ),
( "GL_SAMPLES_ARB", GLint,
["ctx->DrawBuffer->Visual.samples"], "", ["ARB_multisample"] ),
# GL_SGIS_generate_mipmap
( "GL_GENERATE_MIPMAP_HINT_SGIS", GLenum, ["ctx->Hint.GenerateMipmap"],
"", ["SGIS_generate_mipmap"] ),
# GL_ARB_vertex_buffer_object
( "GL_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ArrayBufferObj->Name"], "", ["ARB_vertex_buffer_object"] ),
# GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB - not supported
( "GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ElementArrayBufferObj->Name"],
"", ["ARB_vertex_buffer_object"] ),
# GL_OES_read_format
( "GL_IMPLEMENTATION_COLOR_READ_TYPE_OES", GLint,
["ctx->Const.ColorReadType"], "", None),
( "GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES", GLint,
["ctx->Const.ColorReadFormat"], "", None),
# GL_OES_framebuffer_object
( "GL_FRAMEBUFFER_BINDING_EXT", GLint, ["ctx->DrawBuffer->Name"], "",
None),
( "GL_RENDERBUFFER_BINDING_EXT", GLint,
["ctx->CurrentRenderbuffer ? ctx->CurrentRenderbuffer->Name : 0"], "",
None),
( "GL_MAX_RENDERBUFFER_SIZE_EXT", GLint,
["ctx->Const.MaxRenderbufferSize"], "",
None),
# OpenGL ES 1/2 special:
( "GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
[ "ARRAY_SIZE(compressed_formats)" ],
"",
None ),
("GL_COMPRESSED_TEXTURE_FORMATS_ARB", GLint,
[],
"""
int i;
for (i = 0; i < ARRAY_SIZE(compressed_formats); i++) {
params[i] = compressed_formats[i];
}""",
None ),
( "GL_POLYGON_OFFSET_FILL", GLboolean, ["ctx->Polygon.OffsetFill"], "", None ),
]
# Only present in ES 1.x:
StateVars_es1 = [
( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ),
( "GL_LIGHT0", GLboolean, ["ctx->Light.Light[0].Enabled"], "", None ),
( "GL_LIGHT1", GLboolean, ["ctx->Light.Light[1].Enabled"], "", None ),
( "GL_LIGHT2", GLboolean, ["ctx->Light.Light[2].Enabled"], "", None ),
( "GL_LIGHT3", GLboolean, ["ctx->Light.Light[3].Enabled"], "", None ),
( "GL_LIGHT4", GLboolean, ["ctx->Light.Light[4].Enabled"], "", None ),
( "GL_LIGHT5", GLboolean, ["ctx->Light.Light[5].Enabled"], "", None ),
( "GL_LIGHT6", GLboolean, ["ctx->Light.Light[6].Enabled"], "", None ),
( "GL_LIGHT7", GLboolean, ["ctx->Light.Light[7].Enabled"], "", None ),
( "GL_LIGHTING", GLboolean, ["ctx->Light.Enabled"], "", None ),
( "GL_LIGHT_MODEL_AMBIENT", GLfloatN,
["ctx->Light.Model.Ambient[0]",
"ctx->Light.Model.Ambient[1]",
"ctx->Light.Model.Ambient[2]",
"ctx->Light.Model.Ambient[3]"], "", None ),
( "GL_LIGHT_MODEL_TWO_SIDE", GLboolean, ["ctx->Light.Model.TwoSide"], "", None ),
( "GL_ALPHA_TEST", GLboolean, ["ctx->Color.AlphaEnabled"], "", None ),
( "GL_ALPHA_TEST_FUNC", GLenum, ["ctx->Color.AlphaFunc"], "", None ),
( "GL_ALPHA_TEST_REF", GLfloatN, ["ctx->Color.AlphaRef"], "", None ),
( "GL_BLEND_DST", GLenum, ["ctx->Color.BlendDstRGB"], "", None ),
( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ),
( "GL_CLIP_PLANE0", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 0) & 1" ], "", None ),
( "GL_CLIP_PLANE1", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 1) & 1" ], "", None ),
( "GL_CLIP_PLANE2", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 2) & 1" ], "", None ),
( "GL_CLIP_PLANE3", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 3) & 1" ], "", None ),
( "GL_CLIP_PLANE4", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 4) & 1" ], "", None ),
( "GL_CLIP_PLANE5", GLboolean,
[ "(ctx->Transform.ClipPlanesEnabled >> 5) & 1" ], "", None ),
( "GL_COLOR_MATERIAL", GLboolean,
["ctx->Light.ColorMaterialEnabled"], "", None ),
( "GL_CURRENT_COLOR", GLfloatN,
[ "ctx->Current.Attrib[VERT_ATTRIB_COLOR0][0]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][1]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][2]",
"ctx->Current.Attrib[VERT_ATTRIB_COLOR0][3]" ],
"FLUSH_CURRENT(ctx, 0);", None ),
( "GL_CURRENT_NORMAL", GLfloatN,
[ "ctx->Current.Attrib[VERT_ATTRIB_NORMAL][0]",
"ctx->Current.Attrib[VERT_ATTRIB_NORMAL][1]",
"ctx->Current.Attrib[VERT_ATTRIB_NORMAL][2]"],
"FLUSH_CURRENT(ctx, 0);", None ),
( "GL_CURRENT_TEXTURE_COORDS", GLfloat,
["ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][0]",
"ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][1]",
"ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][2]",
"ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texUnit][3]"],
"const GLuint texUnit = ctx->Texture.CurrentUnit;", None ),
( "GL_DISTANCE_ATTENUATION_EXT", GLfloat,
["ctx->Point.Params[0]",
"ctx->Point.Params[1]",
"ctx->Point.Params[2]"], "", None ),
( "GL_FOG", GLboolean, ["ctx->Fog.Enabled"], "", None ),
( "GL_FOG_COLOR", GLfloatN,
[ "ctx->Fog.Color[0]",
"ctx->Fog.Color[1]",
"ctx->Fog.Color[2]",
"ctx->Fog.Color[3]" ], "", None ),
( "GL_FOG_DENSITY", GLfloat, ["ctx->Fog.Density"], "", None ),
( "GL_FOG_END", GLfloat, ["ctx->Fog.End"], "", None ),
( "GL_FOG_HINT", GLenum, ["ctx->Hint.Fog"], "", None ),
( "GL_FOG_MODE", GLenum, ["ctx->Fog.Mode"], "", None ),
( "GL_FOG_START", GLfloat, ["ctx->Fog.Start"], "", None ),
( "GL_LINE_SMOOTH", GLboolean, ["ctx->Line.SmoothFlag"], "", None ),
( "GL_LINE_SMOOTH_HINT", GLenum, ["ctx->Hint.LineSmooth"], "", None ),
( "GL_LINE_WIDTH_RANGE", GLfloat,
["ctx->Const.MinLineWidthAA",
"ctx->Const.MaxLineWidthAA"], "", None ),
( "GL_COLOR_LOGIC_OP", GLboolean, ["ctx->Color.ColorLogicOpEnabled"], "", None ),
( "GL_LOGIC_OP_MODE", GLenum, ["ctx->Color.LogicOp"], "", None ),
( "GL_MATRIX_MODE", GLenum, ["ctx->Transform.MatrixMode"], "", None ),
( "GL_MAX_MODELVIEW_STACK_DEPTH", GLint, ["MAX_MODELVIEW_STACK_DEPTH"], "", None ),
( "GL_MAX_PROJECTION_STACK_DEPTH", GLint, ["MAX_PROJECTION_STACK_DEPTH"], "", None ),
( "GL_MAX_TEXTURE_STACK_DEPTH", GLint, ["MAX_TEXTURE_STACK_DEPTH"], "", None ),
( "GL_MODELVIEW_MATRIX", GLfloat,
[ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
"matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
"matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
"matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
"const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;", None ),
( "GL_MODELVIEW_STACK_DEPTH", GLint, ["ctx->ModelviewMatrixStack.Depth + 1"], "", None ),
( "GL_NORMALIZE", GLboolean, ["ctx->Transform.Normalize"], "", None ),
( "GL_PACK_SKIP_IMAGES_EXT", GLint, ["ctx->Pack.SkipImages"], "", None ),
( "GL_PERSPECTIVE_CORRECTION_HINT", GLenum,
["ctx->Hint.PerspectiveCorrection"], "", None ),
( "GL_POINT_SIZE", GLfloat, ["ctx->Point.Size"], "", None ),
( "GL_POINT_SIZE_RANGE", GLfloat,
["ctx->Const.MinPointSizeAA",
"ctx->Const.MaxPointSizeAA"], "", None ),
( "GL_POINT_SMOOTH", GLboolean, ["ctx->Point.SmoothFlag"], "", None ),
( "GL_POINT_SMOOTH_HINT", GLenum, ["ctx->Hint.PointSmooth"], "", None ),
( "GL_POINT_SIZE_MIN_EXT", GLfloat, ["ctx->Point.MinSize"], "", None ),
( "GL_POINT_SIZE_MAX_EXT", GLfloat, ["ctx->Point.MaxSize"], "", None ),
( "GL_POINT_FADE_THRESHOLD_SIZE_EXT", GLfloat,
["ctx->Point.Threshold"], "", None ),
( "GL_PROJECTION_MATRIX", GLfloat,
[ "matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
"matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
"matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
"matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
"const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;", None ),
( "GL_PROJECTION_STACK_DEPTH", GLint,
["ctx->ProjectionMatrixStack.Depth + 1"], "", None ),
( "GL_RESCALE_NORMAL", GLboolean,
["ctx->Transform.RescaleNormals"], "", None ),
( "GL_SHADE_MODEL", GLenum, ["ctx->Light.ShadeModel"], "", None ),
( "GL_TEXTURE_2D", GLboolean, ["_mesa_IsEnabled(GL_TEXTURE_2D)"], "", None ),
( "GL_TEXTURE_MATRIX", GLfloat,
["matrix[0]", "matrix[1]", "matrix[2]", "matrix[3]",
"matrix[4]", "matrix[5]", "matrix[6]", "matrix[7]",
"matrix[8]", "matrix[9]", "matrix[10]", "matrix[11]",
"matrix[12]", "matrix[13]", "matrix[14]", "matrix[15]" ],
"const GLfloat *matrix = ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;", None ),
( "GL_TEXTURE_STACK_DEPTH", GLint,
["ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Depth + 1"], "", None ),
( "GL_VERTEX_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Vertex.Enabled"], "", None ),
( "GL_VERTEX_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Vertex.Size"], "", None ),
( "GL_VERTEX_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Vertex.Type"], "", None ),
( "GL_VERTEX_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Vertex.Stride"], "", None ),
( "GL_NORMAL_ARRAY", GLenum, ["ctx->Array.ArrayObj->Normal.Enabled"], "", None ),
( "GL_NORMAL_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Normal.Type"], "", None ),
( "GL_NORMAL_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Normal.Stride"], "", None ),
( "GL_COLOR_ARRAY", GLboolean, ["ctx->Array.ArrayObj->Color.Enabled"], "", None ),
( "GL_COLOR_ARRAY_SIZE", GLint, ["ctx->Array.ArrayObj->Color.Size"], "", None ),
( "GL_COLOR_ARRAY_TYPE", GLenum, ["ctx->Array.ArrayObj->Color.Type"], "", None ),
( "GL_COLOR_ARRAY_STRIDE", GLint, ["ctx->Array.ArrayObj->Color.Stride"], "", None ),
( "GL_TEXTURE_COORD_ARRAY", GLboolean,
["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Enabled"], "", None ),
( "GL_TEXTURE_COORD_ARRAY_SIZE", GLint,
["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Size"], "", None ),
( "GL_TEXTURE_COORD_ARRAY_TYPE", GLenum,
["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Type"], "", None ),
( "GL_TEXTURE_COORD_ARRAY_STRIDE", GLint,
["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].Stride"], "", None ),
# GL_ARB_multitexture
( "GL_MAX_TEXTURE_UNITS_ARB", GLint,
["ctx->Const.MaxTextureUnits"], "", ["ARB_multitexture"] ),
( "GL_CLIENT_ACTIVE_TEXTURE_ARB", GLint,
["GL_TEXTURE0_ARB + ctx->Array.ActiveTexture"], "", ["ARB_multitexture"] ),
# OES_texture_cube_map
( "GL_TEXTURE_CUBE_MAP_ARB", GLboolean,
["_mesa_IsEnabled(GL_TEXTURE_CUBE_MAP_ARB)"], "", None),
( "GL_TEXTURE_GEN_S", GLboolean,
["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & S_BIT) ? 1 : 0)"], "", None),
( "GL_TEXTURE_GEN_T", GLboolean,
["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & T_BIT) ? 1 : 0)"], "", None),
( "GL_TEXTURE_GEN_R", GLboolean,
["((ctx->Texture.Unit[ctx->Texture.CurrentUnit].TexGenEnabled & R_BIT) ? 1 : 0)"], "", None),
# ARB_multisample
( "GL_MULTISAMPLE_ARB", GLboolean,
["ctx->Multisample.Enabled"], "", ["ARB_multisample"] ),
( "GL_SAMPLE_ALPHA_TO_ONE_ARB", GLboolean,
["ctx->Multisample.SampleAlphaToOne"], "", ["ARB_multisample"] ),
( "GL_VERTEX_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ArrayObj->Vertex.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ),
( "GL_NORMAL_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ArrayObj->Normal.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ),
( "GL_COLOR_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ArrayObj->Color.BufferObj->Name"], "", ["ARB_vertex_buffer_object"] ),
( "GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB", GLint,
["ctx->Array.ArrayObj->TexCoord[ctx->Array.ActiveTexture].BufferObj->Name"],
"", ["ARB_vertex_buffer_object"] ),
# OES_point_sprite
( "GL_POINT_SPRITE_NV", GLboolean, ["ctx->Point.PointSprite"], # == GL_POINT_SPRITE_ARB
"", None),
# GL_ARB_fragment_shader
( "GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB", GLint,
["ctx->Const.FragmentProgram.MaxUniformComponents"], "",
["ARB_fragment_shader"] ),
# GL_ARB_vertex_shader
( "GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB", GLint,
["ctx->Const.VertexProgram.MaxUniformComponents"], "",
["ARB_vertex_shader"] ),
( "GL_MAX_VARYING_FLOATS_ARB", GLint,
["ctx->Const.MaxVarying * 4"], "", ["ARB_vertex_shader"] ),
# OES_matrix_get
( "GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [],
"""
/* See GL_OES_matrix_get */
{
const GLfloat *matrix = ctx->ModelviewMatrixStack.Top->m;
memcpy(params, matrix, 16 * sizeof(GLint));
}""",
None),
( "GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [],
"""
/* See GL_OES_matrix_get */
{
const GLfloat *matrix = ctx->ProjectionMatrixStack.Top->m;
memcpy(params, matrix, 16 * sizeof(GLint));
}""",
None),
( "GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES", GLint, [],
"""
/* See GL_OES_matrix_get */
{
const GLfloat *matrix =
ctx->TextureMatrixStack[ctx->Texture.CurrentUnit].Top->m;
memcpy(params, matrix, 16 * sizeof(GLint));
}""",
None),
# OES_point_size_array
("GL_POINT_SIZE_ARRAY_OES", GLboolean,
["ctx->Array.ArrayObj->PointSize.Enabled"], "", None),
("GL_POINT_SIZE_ARRAY_TYPE_OES", GLenum,
["ctx->Array.ArrayObj->PointSize.Type"], "", None),
("GL_POINT_SIZE_ARRAY_STRIDE_OES", GLint,
["ctx->Array.ArrayObj->PointSize.Stride"], "", None),
("GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES", GLint,
["ctx->Array.ArrayObj->PointSize.BufferObj->Name"], "", None),
# GL_EXT_texture_filter_anisotropic
( "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", GLfloat,
["ctx->Const.MaxTextureMaxAnisotropy"], "", ["EXT_texture_filter_anisotropic"]),
]
# Only present in ES 2.x:
StateVars_es2 = [
# XXX These entries are not spec'ed for GLES 2, but are
# needed for Mesa's GLSL:
( "GL_MAX_LIGHTS", GLint, ["ctx->Const.MaxLights"], "", None ),
( "GL_MAX_CLIP_PLANES", GLint, ["ctx->Const.MaxClipPlanes"], "", None ),
( "GL_MAX_TEXTURE_COORDS_ARB", GLint, # == GL_MAX_TEXTURE_COORDS_NV
["ctx->Const.MaxTextureCoordUnits"], "",
["ARB_fragment_program", "NV_fragment_program"] ),
( "GL_MAX_DRAW_BUFFERS_ARB", GLint,
["ctx->Const.MaxDrawBuffers"], "", ["ARB_draw_buffers"] ),
( "GL_BLEND_COLOR_EXT", GLfloatN,
[ "ctx->Color.BlendColor[0]",
"ctx->Color.BlendColor[1]",
"ctx->Color.BlendColor[2]",
"ctx->Color.BlendColor[3]"], "", None ),
# This is required for GLES2, but also needed for GLSL:
( "GL_MAX_TEXTURE_IMAGE_UNITS_ARB", GLint, # == GL_MAX_TEXTURE_IMAGE_UNI
["ctx->Const.MaxTextureImageUnits"], "",
["ARB_fragment_program", "NV_fragment_program"] ),
( "GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB", GLint,
["ctx->Const.MaxVertexTextureImageUnits"], "", ["ARB_vertex_shader"] ),
( "GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB", GLint,
["MAX_COMBINED_TEXTURE_IMAGE_UNITS"], "", ["ARB_vertex_shader"] ),
# GL_ARB_shader_objects
# Actually, this token isn't part of GL_ARB_shader_objects, but is
# close enough for now.
( "GL_CURRENT_PROGRAM", GLint,
["ctx->Shader.CurrentProgram ? ctx->Shader.CurrentProgram->Name : 0"],
"", ["ARB_shader_objects"] ),
# OpenGL 2.0
( "GL_STENCIL_BACK_FUNC", GLenum, ["ctx->Stencil.Function[1]"], "", None ),
( "GL_STENCIL_BACK_VALUE_MASK", GLint, ["ctx->Stencil.ValueMask[1]"], "", None ),
( "GL_STENCIL_BACK_WRITEMASK", GLint, ["ctx->Stencil.WriteMask[1]"], "", None ),
( "GL_STENCIL_BACK_REF", GLint, ["ctx->Stencil.Ref[1]"], "", None ),
( "GL_STENCIL_BACK_FAIL", GLenum, ["ctx->Stencil.FailFunc[1]"], "", None ),
( "GL_STENCIL_BACK_PASS_DEPTH_FAIL", GLenum, ["ctx->Stencil.ZFailFunc[1]"], "", None ),
( "GL_STENCIL_BACK_PASS_DEPTH_PASS", GLenum, ["ctx->Stencil.ZPassFunc[1]"], "", None ),
( "GL_MAX_VERTEX_ATTRIBS_ARB", GLint,
["ctx->Const.VertexProgram.MaxAttribs"], "", ["ARB_vertex_program"] ),
# OES_texture_3D
( "GL_TEXTURE_BINDING_3D", GLint,
["ctx->Texture.Unit[ctx->Texture.CurrentUnit].CurrentTex[TEXTURE_3D_INDEX]->Name"], "", None),
( "GL_MAX_3D_TEXTURE_SIZE", GLint, ["1 << (ctx->Const.Max3DTextureLevels - 1)"], "", None),
# OES_standard_derivatives
( "GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB", GLenum,
["ctx->Hint.FragmentShaderDerivative"], "", ["ARB_fragment_shader"] ),
# Unique to ES 2 (not in full GL)
( "GL_MAX_FRAGMENT_UNIFORM_VECTORS", GLint,
["ctx->Const.FragmentProgram.MaxUniformComponents / 4"], "", None),
( "GL_MAX_VARYING_VECTORS", GLint,
["ctx->Const.MaxVarying"], "", None),
( "GL_MAX_VERTEX_UNIFORM_VECTORS", GLint,
["ctx->Const.VertexProgram.MaxUniformComponents / 4"], "", None),
( "GL_SHADER_COMPILER", GLint, ["1"], "", None),
# OES_get_program_binary
( "GL_NUM_SHADER_BINARY_FORMATS", GLint, ["0"], "", None),
( "GL_SHADER_BINARY_FORMATS", GLint, [], "", None),
]
def ConversionFunc(fromType, toType):
"""Return the name of the macro to convert between two data types."""
if fromType == toType:
return ""
elif fromType == GLfloat and toType == GLint:
return "IROUND"
elif fromType == GLfloatN and toType == GLfloat:
return ""
elif fromType == GLint and toType == GLfloat: # but not GLfloatN!
return "(GLfloat)"
else:
if fromType == GLfloatN:
fromType = GLfloat
fromStr = TypeStrings[fromType]
fromStr = string.upper(fromStr[2:])
toStr = TypeStrings[toType]
toStr = string.upper(toStr[2:])
return fromStr + "_TO_" + toStr
def EmitGetFunction(stateVars, returnType):
"""Emit the code to implement glGetBooleanv, glGetIntegerv or glGetFloatv."""
assert (returnType == GLboolean or
returnType == GLint or
returnType == GLfloat)
strType = TypeStrings[returnType]
# Capitalize first letter of return type
if returnType == GLint:
function = "_mesa_GetIntegerv"
elif returnType == GLboolean:
function = "_mesa_GetBooleanv"
elif returnType == GLfloat:
function = "_mesa_GetFloatv"
else:
abort()
print "void GLAPIENTRY"
print "%s( GLenum pname, %s *params )" % (function, strType)
print "{"
print " GET_CURRENT_CONTEXT(ctx);"
print " ASSERT_OUTSIDE_BEGIN_END(ctx);"
print ""
print " if (!params)"
print " return;"
print ""
print " if (ctx->NewState)"
print " _mesa_update_state(ctx);"
print ""
print " switch (pname) {"
for (name, varType, state, optionalCode, extensions) in stateVars:
print " case " + name + ":"
if extensions:
if len(extensions) == 1:
print (' CHECK_EXT1(%s, "%s");' %
(extensions[0], function))
elif len(extensions) == 2:
print (' CHECK_EXT2(%s, %s, "%s");' %
(extensions[0], extensions[1], function))
elif len(extensions) == 3:
print (' CHECK_EXT3(%s, %s, %s, "%s");' %
(extensions[0], extensions[1], extensions[2], function))
else:
assert len(extensions) == 4
print (' CHECK_EXT4(%s, %s, %s, %s, "%s");' %
(extensions[0], extensions[1], extensions[2], extensions[3], function))
if optionalCode:
print " {"
print " " + optionalCode
conversion = ConversionFunc(varType, returnType)
n = len(state)
for i in range(n):
if conversion:
print " params[%d] = %s(%s);" % (i, conversion, state[i])
else:
print " params[%d] = %s;" % (i, state[i])
if optionalCode:
print " }"
print " break;"
print " default:"
print ' _mesa_error(ctx, GL_INVALID_ENUM, "gl%s(pname=0x%%x)", pname);' % function
print " }"
print "}"
print ""
return
def EmitHeader():
"""Print the get.c file header."""
print """
/***
*** NOTE!!! DO NOT EDIT THIS FILE!!! IT IS GENERATED BY get_gen.py
***/
#include "main/glheader.h"
#include "main/context.h"
#include "main/enable.h"
#include "main/extensions.h"
#include "main/fbobject.h"
#include "main/get.h"
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/state.h"
#include "main/texcompress.h"
/* ES1 tokens that should be in gl.h but aren't */
#define GL_MAX_ELEMENTS_INDICES 0x80E9
#define GL_MAX_ELEMENTS_VERTICES 0x80E8
/* ES2 special tokens */
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_VARYING_VECTORS 0x8DFC
#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB
#define GL_SHADER_COMPILER 0x8DFA
#define GL_PLATFORM_BINARY 0x8D63
#define GL_SHADER_BINARY_FORMATS 0x8DF8
#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9
#ifndef GL_OES_matrix_get
#define GL_MODELVIEW_MATRIX_FLOAT_AS_INT_BITS_OES 0x898D
#define GL_PROJECTION_MATRIX_FLOAT_AS_INT_BITS_OES 0x898E
#define GL_TEXTURE_MATRIX_FLOAT_AS_INT_BITS_OES 0x898F
#endif
#ifndef GL_OES_compressed_paletted_texture
#define GL_PALETTE4_RGB8_OES 0x8B90
#define GL_PALETTE4_RGBA8_OES 0x8B91
#define GL_PALETTE4_R5_G6_B5_OES 0x8B92
#define GL_PALETTE4_RGBA4_OES 0x8B93
#define GL_PALETTE4_RGB5_A1_OES 0x8B94
#define GL_PALETTE8_RGB8_OES 0x8B95
#define GL_PALETTE8_RGBA8_OES 0x8B96
#define GL_PALETTE8_R5_G6_B5_OES 0x8B97
#define GL_PALETTE8_RGBA4_OES 0x8B98
#define GL_PALETTE8_RGB5_A1_OES 0x8B99
#endif
#define FLOAT_TO_BOOLEAN(X) ( (X) ? GL_TRUE : GL_FALSE )
#define INT_TO_BOOLEAN(I) ( (I) ? GL_TRUE : GL_FALSE )
#define BOOLEAN_TO_INT(B) ( (GLint) (B) )
#define BOOLEAN_TO_FLOAT(B) ( (B) ? 1.0F : 0.0F )
/*
* Check if named extension is enabled, if not generate error and return.
*/
#define CHECK_EXT1(EXT1, FUNC) \\
if (!ctx->Extensions.EXT1) { \\
_mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\
return; \\
}
/*
* Check if either of two extensions is enabled.
*/
#define CHECK_EXT2(EXT1, EXT2, FUNC) \\
if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2) { \\
_mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\
return; \\
}
/*
* Check if either of three extensions is enabled.
*/
#define CHECK_EXT3(EXT1, EXT2, EXT3, FUNC) \\
if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\
!ctx->Extensions.EXT3) { \\
_mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\
return; \\
}
/*
* Check if either of four extensions is enabled.
*/
#define CHECK_EXT4(EXT1, EXT2, EXT3, EXT4, FUNC) \\
if (!ctx->Extensions.EXT1 && !ctx->Extensions.EXT2 && \\
!ctx->Extensions.EXT3 && !ctx->Extensions.EXT4) { \\
_mesa_error(ctx, GL_INVALID_ENUM, FUNC "(0x%x)", (int) pname); \\
return; \\
}
/**
* List of compressed texture formats supported by ES.
*/
static GLenum compressed_formats[] = {
GL_PALETTE4_RGB8_OES,
GL_PALETTE4_RGBA8_OES,
GL_PALETTE4_R5_G6_B5_OES,
GL_PALETTE4_RGBA4_OES,
GL_PALETTE4_RGB5_A1_OES,
GL_PALETTE8_RGB8_OES,
GL_PALETTE8_RGBA8_OES,
GL_PALETTE8_R5_G6_B5_OES,
GL_PALETTE8_RGBA4_OES,
GL_PALETTE8_RGB5_A1_OES
};
#define ARRAY_SIZE(A) (sizeof(A) / sizeof(A[0]))
"""
return
def EmitAll(stateVars):
EmitHeader()
EmitGetFunction(stateVars, GLboolean)
EmitGetFunction(stateVars, GLfloat)
EmitGetFunction(stateVars, GLint)
def main(args):
# Determine whether to generate ES1 or ES2 queries
if len(args) > 1 and args[1] == "1":
API = 1
elif len(args) > 1 and args[1] == "2":
API = 2
else:
API = 1
#print "len args = %d API = %d" % (len(args), API)
if API == 1:
vars = StateVars_common + StateVars_es1
else:
vars = StateVars_common + StateVars_es2
EmitAll(vars)
main(sys.argv)

View File

@ -0,0 +1,115 @@
/**************************************************************************
*
* 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.
*
**************************************************************************/
/**
* \file mfeatures.h
*
* The #defines in this file enable/disable Mesa features needed
* for OpenGL ES 1.1.
*/
#ifndef MFEATURES_ES1_H
#define MFEATURES_ES1_H
/* this file replaces main/mfeatures.h */
#ifdef FEATURES_H
#error "main/mfeatures.h was wrongly included"
#endif
#define FEATURES_H
#define ASSERT_NO_FEATURE() ASSERT(0)
/*
* Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1.
*/
#ifndef _HAVE_FULL_GL
#define _HAVE_FULL_GL 1
#endif
#ifdef IN_DRI_DRIVER
#define FEATURE_remap_table 1
#else
#define FEATURE_remap_table 0
#endif
#define FEATURE_accum 0
#define FEATURE_arrayelt 0
#define FEATURE_attrib 0
#define FEATURE_beginend 0
#define FEATURE_colortable 0
#define FEATURE_convolve 0
#define FEATURE_dispatch 1
#define FEATURE_dlist 0
#define FEATURE_draw_read_buffer 0
#define FEATURE_drawpix 0
#define FEATURE_eval 0
#define FEATURE_feedback 0
#define FEATURE_fixedpt 1
#define FEATURE_histogram 0
#define FEATURE_pixel 0
#define FEATURE_point_size_array 1
#define FEATURE_queryobj 0
#define FEATURE_rastpos 0
#define FEATURE_texgen 1
#define FEATURE_texture_fxt1 0
#define FEATURE_texture_s3tc 0
#define FEATURE_userclip 1
#define FEATURE_vertex_array_byte 1
#define FEATURE_es2_glsl 0
#define FEATURE_ARB_fragment_program _HAVE_FULL_GL
#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL
#define FEATURE_ARB_vertex_program _HAVE_FULL_GL
#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
#define FEATURE_EXT_framebuffer_blit 0
#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL
#define FEATURE_EXT_texture_sRGB 0
#define FEATURE_ATI_fragment_shader 0
#define FEATURE_MESA_program_debug _HAVE_FULL_GL
#define FEATURE_NV_fence 0
#define FEATURE_NV_fragment_program 0
#define FEATURE_NV_vertex_program 0
#define FEATURE_OES_framebuffer_object 1
#define FEATURE_OES_mapbuffer 1
#define FEATURE_extra_context_init 1
/*@}*/
#endif /* MFEATURES_ES1_H */

View File

@ -0,0 +1,115 @@
/**************************************************************************
*
* 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.
*
**************************************************************************/
/**
* \file mfeatures.h
*
* The #defines in this file enable/disable Mesa features needed
* for OpenGL ES 2.0.
*/
#ifndef MFEATURES_ES2_H
#define MFEATURES_ES2_H
/* this file replaces main/mfeatures.h */
#ifdef FEATURES_H
#error "main/mfeatures.h was wrongly included"
#endif
#define FEATURES_H
#define ASSERT_NO_FEATURE() ASSERT(0)
/*
* Enable/disable features (blocks of code) by setting FEATURE_xyz to 0 or 1.
*/
#ifndef _HAVE_FULL_GL
#define _HAVE_FULL_GL 1
#endif
#ifdef IN_DRI_DRIVER
#define FEATURE_remap_table 1
#else
#define FEATURE_remap_table 0
#endif
#define FEATURE_accum 0
#define FEATURE_arrayelt 0
#define FEATURE_attrib 0
#define FEATURE_beginend 0
#define FEATURE_colortable 0
#define FEATURE_convolve 0
#define FEATURE_dispatch 1
#define FEATURE_dlist 0
#define FEATURE_draw_read_buffer 0
#define FEATURE_drawpix 0
#define FEATURE_eval 0
#define FEATURE_feedback 0
#define FEATURE_fixedpt 1
#define FEATURE_histogram 0
#define FEATURE_pixel 0
#define FEATURE_point_size_array 1
#define FEATURE_queryobj 0
#define FEATURE_rastpos 0
#define FEATURE_texgen 1
#define FEATURE_texture_fxt1 0
#define FEATURE_texture_s3tc 0
#define FEATURE_userclip 1
#define FEATURE_vertex_array_byte 1
#define FEATURE_es2_glsl 1
#define FEATURE_ARB_fragment_program _HAVE_FULL_GL
#define FEATURE_ARB_vertex_buffer_object _HAVE_FULL_GL
#define FEATURE_ARB_vertex_program _HAVE_FULL_GL
#define FEATURE_ARB_vertex_shader _HAVE_FULL_GL
#define FEATURE_ARB_fragment_shader _HAVE_FULL_GL
#define FEATURE_ARB_shader_objects (FEATURE_ARB_vertex_shader || FEATURE_ARB_fragment_shader)
#define FEATURE_ARB_shading_language_100 FEATURE_ARB_shader_objects
#define FEATURE_ARB_shading_language_120 FEATURE_ARB_shader_objects
#define FEATURE_EXT_framebuffer_blit 0
#define FEATURE_EXT_framebuffer_object _HAVE_FULL_GL
#define FEATURE_EXT_pixel_buffer_object _HAVE_FULL_GL
#define FEATURE_EXT_texture_sRGB 0
#define FEATURE_ATI_fragment_shader 0
#define FEATURE_MESA_program_debug _HAVE_FULL_GL
#define FEATURE_NV_fence 0
#define FEATURE_NV_fragment_program 0
#define FEATURE_NV_vertex_program 0
#define FEATURE_OES_framebuffer_object 1
#define FEATURE_OES_mapbuffer 1
#define FEATURE_extra_context_init 1
/*@}*/
#endif /* MFEATURES_ES2_H */

View File

@ -0,0 +1,186 @@
/**************************************************************************
*
* 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, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* TUNGSTEN GRAPHICS 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 "main/mtypes.h"
#include "main/context.h"
#include "main/imports.h"
#include "main/get.h"
extern const GLubyte * GLAPIENTRY _es_GetString(GLenum name);
static const GLubyte *
compute_es_version(void)
{
GET_CURRENT_CONTEXT(ctx);
static const char es_1_0[] = "OpenGL ES-CM 1.0";
static const char es_1_1[] = "OpenGL ES-CM 1.1";
/* OpenGL ES 1.0 is derived from OpenGL 1.3 */
const GLboolean ver_1_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.EXT_texture_env_add &&
ctx->Extensions.ARB_texture_env_combine &&
ctx->Extensions.ARB_texture_env_dot3);
/* OpenGL ES 1.1 is derived from OpenGL 1.5 */
const GLboolean ver_1_1 = (ver_1_0 &&
ctx->Extensions.EXT_point_parameters &&
ctx->Extensions.SGIS_generate_mipmap &&
ctx->Extensions.ARB_vertex_buffer_object);
if (ver_1_1)
return (const GLubyte *) es_1_1;
if (!ver_1_0)
_mesa_problem(ctx, "Incomplete OpenGL ES 1.0 support.");
return (const GLubyte *) es_1_0;
}
static size_t
append_extension(char **str, const char *ext)
{
char *s = *str;
size_t len = strlen(ext);
if (s) {
memcpy(s, ext, len);
s[len++] = ' ';
s[len] = '\0';
*str += len;
}
else {
len++;
}
return len;
}
static size_t
make_extension_string(const GLcontext *ctx, char *str)
{
size_t len = 0;
/* Core additions */
len += append_extension(&str, "GL_OES_byte_coordinates");
len += append_extension(&str, "GL_OES_fixed_point");
len += append_extension(&str, "GL_OES_single_precision");
len += append_extension(&str, "GL_OES_matrix_get");
/* 1.1 required extensions */
len += append_extension(&str, "GL_OES_read_format");
len += append_extension(&str, "GL_OES_compressed_paletted_texture");
len += append_extension(&str, "GL_OES_point_size_array");
len += append_extension(&str, "GL_OES_point_sprite");
/* 1.1 deprecated extensions */
len += append_extension(&str, "GL_OES_query_matrix");
if (ctx->Extensions.EXT_blend_equation_separate)
len += append_extension(&str, "GL_OES_blend_equation_separate");
if (ctx->Extensions.EXT_blend_func_separate)
len += append_extension(&str, "GL_OES_blend_func_separate");
if (ctx->Extensions.EXT_blend_subtract)
len += append_extension(&str, "GL_OES_blend_subtract");
if (ctx->Extensions.EXT_stencil_wrap)
len += append_extension(&str, "GL_OES_stencil_wrap");
if (ctx->Extensions.ARB_texture_cube_map)
len += append_extension(&str, "GL_OES_texture_cube_map");
if (ctx->Extensions.ARB_texture_env_crossbar)
len += append_extension(&str, "GL_OES_texture_env_crossbar");
if (ctx->Extensions.ARB_texture_mirrored_repeat)
len += append_extension(&str, "GL_OES_texture_mirrored_repeat");
if (ctx->Extensions.ARB_framebuffer_object) {
len += append_extension(&str, "GL_OES_framebuffer_object");
len += append_extension(&str, "GL_OES_depth24");
len += append_extension(&str, "GL_OES_depth32");
len += append_extension(&str, "GL_OES_fbo_render_mipmap");
len += append_extension(&str, "GL_OES_rgb8_rgba8");
len += append_extension(&str, "GL_OES_stencil1");
len += append_extension(&str, "GL_OES_stencil4");
len += append_extension(&str, "GL_OES_stencil8");
}
if (ctx->Extensions.EXT_vertex_array)
len += append_extension(&str, "GL_OES_element_index_uint");
if (ctx->Extensions.ARB_vertex_buffer_object)
len += append_extension(&str, "GL_OES_mapbuffer");
if (ctx->Extensions.EXT_texture_filter_anisotropic)
len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
if (ctx->Extensions.ARB_texture_non_power_of_two)
len += append_extension(&str, "GL_ARB_texture_non_power_of_two");
if (ctx->Extensions.EXT_multi_draw_arrays)
len += append_extension(&str, "GL_EXT_multi_draw_arrays");
return len;
}
static const GLubyte *
compute_es_extensions(void)
{
GET_CURRENT_CONTEXT(ctx);
if (!ctx->Extensions.String) {
char *s;
unsigned int len;
len = make_extension_string(ctx, NULL);
s = (char *) _mesa_malloc(len + 1);
if (!s)
return NULL;
make_extension_string(ctx, s);
ctx->Extensions.String = (const GLubyte *) s;
}
return ctx->Extensions.String;
}
const GLubyte * GLAPIENTRY
_es_GetString(GLenum name)
{
switch (name) {
case GL_VERSION:
return compute_es_version();
case GL_EXTENSIONS:
return compute_es_extensions();
default:
return _mesa_GetString(name);
}
}
void
_mesa_initialize_context_extra(GLcontext *ctx)
{
/* nothing here */
}

View File

@ -0,0 +1,176 @@
/**************************************************************************
*
* 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, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* TUNGSTEN GRAPHICS 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 "main/mtypes.h"
#include "main/context.h"
#include "main/imports.h"
#include "main/get.h"
const GLubyte * GLAPIENTRY _es_GetString(GLenum name);
static const GLubyte *
compute_es_version(void)
{
GET_CURRENT_CONTEXT(ctx);
static const char es_2_0[] = "OpenGL ES 2.0";
/* OpenGL ES 2.0 is derived from OpenGL 2.0 */
const GLboolean ver_2_0 = (ctx->Extensions.ARB_multisample &&
ctx->Extensions.ARB_multitexture &&
ctx->Extensions.ARB_texture_compression &&
ctx->Extensions.ARB_texture_cube_map &&
ctx->Extensions.ARB_texture_mirrored_repeat &&
ctx->Extensions.EXT_blend_color &&
ctx->Extensions.EXT_blend_func_separate &&
ctx->Extensions.EXT_blend_minmax &&
ctx->Extensions.EXT_blend_subtract &&
ctx->Extensions.EXT_stencil_wrap &&
ctx->Extensions.ARB_vertex_buffer_object &&
ctx->Extensions.ARB_shader_objects &&
ctx->Extensions.ARB_vertex_shader &&
ctx->Extensions.ARB_fragment_shader &&
ctx->Extensions.ARB_texture_non_power_of_two &&
ctx->Extensions.EXT_blend_equation_separate);
if (!ver_2_0)
_mesa_problem(ctx, "Incomplete OpenGL ES 2.0 support.");
return (const GLubyte *) es_2_0;
}
static size_t
append_extension(char **str, const char *ext)
{
char *s = *str;
size_t len = strlen(ext);
if (s) {
memcpy(s, ext, len);
s[len++] = ' ';
s[len] = '\0';
*str += len;
}
else {
len++;
}
return len;
}
static size_t
make_extension_string(const GLcontext *ctx, char *str)
{
size_t len = 0;
/* Core additions */
len += append_extension(&str, "GL_OES_single_precision");
/* Required extensions */
len += append_extension(&str, "GL_OES_compressed_paletted_texture");
if (ctx->Extensions.ARB_framebuffer_object) {
len += append_extension(&str, "GL_OES_framebuffer_object");
len += append_extension(&str, "GL_OES_depth24");
len += append_extension(&str, "GL_OES_depth32");
len += append_extension(&str, "GL_OES_fbo_render_mipmap");
len += append_extension(&str, "GL_OES_rgb8_rgba8");
len += append_extension(&str, "GL_OES_stencil1");
len += append_extension(&str, "GL_OES_stencil4");
len += append_extension(&str, "GL_OES_stencil8");
}
if (ctx->Extensions.EXT_vertex_array)
len += append_extension(&str, "GL_OES_element_index_uint");
if (ctx->Extensions.ARB_vertex_buffer_object)
len += append_extension(&str, "GL_OES_mapbuffer");
if (ctx->Extensions.EXT_texture3D)
len += append_extension(&str, "GL_OES_texture_3D");
if (ctx->Extensions.ARB_texture_non_power_of_two)
len += append_extension(&str, "GL_OES_texture_npot");
if (ctx->Extensions.EXT_texture_filter_anisotropic)
len += append_extension(&str, "GL_EXT_texture_filter_anisotropic");
len += append_extension(&str, "GL_EXT_texture_type_2_10_10_10_REV");
if (ctx->Extensions.ARB_depth_texture)
len += append_extension(&str, "GL_OES_depth_texture");
if (ctx->Extensions.EXT_packed_depth_stencil)
len += append_extension(&str, "GL_OES_packed_depth_stencil");
if (ctx->Extensions.ARB_fragment_shader)
len += append_extension(&str, "GL_OES_standard_derivatives");
if (ctx->Extensions.EXT_multi_draw_arrays)
len += append_extension(&str, "GL_EXT_multi_draw_arrays");
return len;
}
static const GLubyte *
compute_es_extensions(void)
{
GET_CURRENT_CONTEXT(ctx);
if (!ctx->Extensions.String) {
char *s;
unsigned int len;
len = make_extension_string(ctx, NULL);
s = (char *) _mesa_malloc(len + 1);
if (!s)
return NULL;
make_extension_string(ctx, s);
ctx->Extensions.String = (const GLubyte *) s;
}
return ctx->Extensions.String;
}
const GLubyte * GLAPIENTRY
_es_GetString(GLenum name)
{
switch (name) {
case GL_VERSION:
return compute_es_version();
case GL_SHADING_LANGUAGE_VERSION:
return (const GLubyte *) "OpenGL ES GLSL ES 1.0.16";
case GL_EXTENSIONS:
return compute_es_extensions();
default:
return _mesa_GetString(name);
}
}
void
_mesa_initialize_context_extra(GLcontext *ctx)
{
ctx->FragmentProgram._MaintainTexEnvProgram = GL_TRUE;
ctx->VertexProgram._MaintainTnlProgram = GL_TRUE;
ctx->Point.PointSprite = GL_TRUE; /* always on for ES 2.x */
}

138
src/mesa/es/main/stubs.c Normal file
View File

@ -0,0 +1,138 @@
/**************************************************************************
*
* 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, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* TUNGSTEN GRAPHICS 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.
**************************************************************************/
/**
* Temporary stubs for "missing" mesa functions.
*/
#include "main/mtypes.h"
#include "main/imports.h"
#include "vbo/vbo.h"
#define NEED_IMPLEMENT() do { \
GET_CURRENT_CONTEXT(ctx); \
_mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); \
} while (0)
#if FEATURE_accum
/* This is a sanity check that to be sure we're using the correct mfeatures.h
* header. We don't want to accidentally use the one from mainline Mesa.
*/
#error "The wrong mfeatures.h file is being included!"
#endif
/* silence compiler warnings */
extern void GLAPIENTRY _vbo_Materialf(GLenum face, GLenum pname, GLfloat param);
extern void GLAPIENTRY _mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision);
extern void GLAPIENTRY _mesa_ReleaseShaderCompiler(void);
extern void GLAPIENTRY _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat, const void* binary, GLint length);
extern void GLAPIENTRY _vbo_VertexAttrib1f(GLuint indx, GLfloat x);
extern void GLAPIENTRY _vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values);
extern void GLAPIENTRY _vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y);
extern void GLAPIENTRY _vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values);
extern void GLAPIENTRY _vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z);
extern void GLAPIENTRY _vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values);
extern void GLAPIENTRY _vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values);
void GLAPIENTRY
_vbo_Materialf(GLenum face, GLenum pname, GLfloat param)
{
_vbo_Materialfv(face, pname, &param);
}
void GLAPIENTRY
_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype,
GLint* range, GLint* precision)
{
NEED_IMPLEMENT();
}
void GLAPIENTRY
_mesa_ReleaseShaderCompiler(void)
{
NEED_IMPLEMENT();
}
void GLAPIENTRY
_mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat,
const void* binary, GLint length)
{
NEED_IMPLEMENT();
}
void GLAPIENTRY
_vbo_VertexAttrib1f(GLuint indx, GLfloat x)
{
_vbo_VertexAttrib4f(indx, x, 0.0, 0.0, 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib1fv(GLuint indx, const GLfloat* values)
{
_vbo_VertexAttrib4f(indx, values[0], 0.0, 0.0, 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib2f(GLuint indx, GLfloat x, GLfloat y)
{
_vbo_VertexAttrib4f(indx, x, y, 0.0, 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib2fv(GLuint indx, const GLfloat* values)
{
_vbo_VertexAttrib4f(indx, values[0], values[1], 0.0, 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib3f(GLuint indx, GLfloat x, GLfloat y, GLfloat z)
{
_vbo_VertexAttrib4f(indx, x, y, z, 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib3fv(GLuint indx, const GLfloat* values)
{
_vbo_VertexAttrib4f(indx, values[0], values[1], values[2], 1.0f);
}
void GLAPIENTRY
_vbo_VertexAttrib4fv(GLuint indx, const GLfloat* values)
{
_vbo_VertexAttrib4f(indx, values[0], values[1], values[2], values[3]);
}

164
src/mesa/es/sources.mak Normal file
View File

@ -0,0 +1,164 @@
include $(MESA)/sources.mak
# LOCAL sources
LOCAL_ES1_SOURCES := \
main/api_exec_es1.c \
main/get_es1.c \
main/specials_es1.c \
main/drawtex.c \
main/es_cpaltex.c \
main/es_fbo.c \
main/es_query_matrix.c \
main/stubs.c \
glapi/glapi-es1/main/enums.c
LOCAL_ES1_GALLIUM_SOURCES := \
$(LOCAL_ES1_SOURCES)
# always use local version of GLAPI_ASM_SOURCES
LOCAL_ES1_API_ASM := $(addprefix glapi/glapi-es1/, $(GLAPI_ASM_SOURCES))
LOCAL_ES1_INCLUDES := \
-I. \
-I./glapi/glapi-es1 \
-I./state_tracker \
-I$(MESA)/state_tracker
LOCAL_ES2_SOURCES := \
main/api_exec_es2.c \
main/get_es2.c \
main/specials_es2.c \
main/es_cpaltex.c \
main/es_fbo.c \
main/stubs.c \
glapi/glapi-es2/main/enums.c
LOCAL_ES2_GALLIUM_SOURCES := \
$(LOCAL_ES2_SOURCES)
LOCAL_ES2_API_ASM := $(subst es1,es2, $(LOCAL_ES1_API_ASM))
LOCAL_ES2_INCLUDES := $(subst es1,es2, $(LOCAL_ES1_INCLUDES))
# MESA sources
MAIN_OMITTED := \
main/api_exec.c \
main/dlopen.c \
main/enums.c \
main/get.c
MAIN_SOURCES := $(filter-out $(MAIN_OMITTED), $(MAIN_SOURCES))
VBO_OMITTED := \
vbo/vbo_save.c \
vbo/vbo_save_api.c \
vbo/vbo_save_draw.c \
vbo/vbo_save_loopback.c
VBO_SOURCES := $(filter-out $(VBO_OMITTED), $(VBO_SOURCES))
STATETRACKER_OMITTED := \
state_tracker/st_api.c \
state_tracker/st_cb_drawpixels.c \
state_tracker/st_cb_feedback.c \
state_tracker/st_cb_rasterpos.c \
state_tracker/st_draw_feedback.c
STATETRACKER_SOURCES := $(filter-out $(STATETRACKER_OMITTED), $(STATETRACKER_SOURCES))
SHADER_OMITTED := \
shader/atifragshader.c \
shader/nvfragparse.c \
shader/nvprogram.c \
shader/nvvertparse.c
SHADER_SOURCES := $(filter-out $(SHADER_OMITTED), $(SHADER_SOURCES))
MESA_ES1_SOURCES := \
$(MAIN_SOURCES) \
$(MATH_SOURCES) \
$(MATH_XFORM_SOURCES) \
$(VBO_SOURCES) \
$(TNL_SOURCES) \
$(SHADER_SOURCES) \
$(SWRAST_SOURCES) \
$(SWRAST_SETUP_SOURCES) \
$(COMMON_DRIVER_SOURCES) \
$(ASM_C_SOURCES) \
$(SLANG_SOURCES)
MESA_ES1_GALLIUM_SOURCES := \
$(MAIN_SOURCES) \
$(MATH_SOURCES) \
$(VBO_SOURCES) \
$(STATETRACKER_SOURCES) \
$(SHADER_SOURCES) \
ppc/common_ppc.c \
x86/common_x86.c \
$(SLANG_SOURCES)
MESA_ES1_API_SOURCES := \
$(GLAPI_SOURCES)
MESA_ES1_INCLUDES := $(INCLUDE_DIRS)
# remove LOCAL sources from MESA sources
MESA_ES1_SOURCES := $(filter-out $(LOCAL_ES1_SOURCES), $(MESA_ES1_SOURCES))
MESA_ES1_GALLIUM_SOURCES := $(filter-out $(LOCAL_ES1_GALLIUM_SOURCES), $(MESA_ES1_GALLIUM_SOURCES))
# right now es2 and es1 share MESA sources
MESA_ES2_SOURCES := $(MESA_ES1_SOURCES)
MESA_ES2_GALLIUM_SOURCES := $(MESA_ES1_GALLIUM_SOURCES)
MESA_ES2_API_SOURCES := $(MESA_ES1_API_SOURCES)
MESA_ES2_INCLUDES := $(MESA_ES1_INCLUDES)
# asm is shared by any ES version and any library
MESA_ES_ASM := $(MESA_ASM_SOURCES)
# collect sources, adjust the pathes
ES1_SOURCES := $(LOCAL_ES1_SOURCES) $(addprefix $(MESA)/,$(MESA_ES1_SOURCES))
ES1_GALLIUM_SOURCES := $(LOCAL_ES1_GALLIUM_SOURCES) $(addprefix $(MESA)/,$(MESA_ES1_GALLIUM_SOURCES))
ES1_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES1_API_SOURCES))
ES2_SOURCES := $(LOCAL_ES2_SOURCES) $(addprefix $(MESA)/,$(MESA_ES2_SOURCES))
ES2_GALLIUM_SOURCES := $(LOCAL_ES2_GALLIUM_SOURCES) $(addprefix $(MESA)/,$(MESA_ES2_GALLIUM_SOURCES))
ES2_API_SOURCES := $(addprefix $(MESA)/,$(MESA_ES2_API_SOURCES))
# collect includes
ES1_INCLUDES := $(LOCAL_ES1_INCLUDES) $(MESA_ES1_INCLUDES)
ES2_INCLUDES := $(LOCAL_ES2_INCLUDES) $(MESA_ES2_INCLUDES)
# collect objects, including asm
ES1_OBJECTS := \
$(LOCAL_ES1_SOURCES:.c=.o) \
$(MESA_ES1_SOURCES:.c=.o) \
$(MESA_ES_ASM:.S=.o)
ES1_GALLIUM_OBJECTS := \
$(LOCAL_ES1_GALLIUM_SOURCES:.c=.o) \
$(MESA_ES1_GALLIUM_SOURCES:.c=.o) \
$(MESA_ES_ASM:.S=.o)
ES1_API_OBJECTS := \
$(LOCAL_ES1_API_ASM:.S=.o) \
$(MESA_ES1_API_SOURCES:.c=.o)
ES2_OBJECTS := \
$(LOCAL_ES2_SOURCES:.c=.o) \
$(MESA_ES2_SOURCES:.c=.o) \
$(MESA_ES_ASM:.S=.o)
ES2_GALLIUM_OBJECTS := \
$(LOCAL_ES2_GALLIUM_SOURCES:.c=.o) \
$(MESA_ES2_GALLIUM_SOURCES:.c=.o) \
$(MESA_ES_ASM:.S=.o)
ES2_API_OBJECTS := \
$(LOCAL_ES2_API_ASM:.S=.o) \
$(MESA_ES2_API_SOURCES:.c=.o)
# collect sources for makedepend
ES1_ALL_SOURCES := $(ES1_SOURCES) $(ES1_GALLIUM_SOURCES) $(ES1_API_SOURCES)
ES2_ALL_SOURCES := $(ES2_SOURCES) $(ES2_GALLIUM_SOURCES) $(ES2_API_SOURCES)
# sort to remove duplicates
ES1_ALL_SOURCES := $(sort $(ES1_ALL_SOURCES))
ES2_ALL_SOURCES := $(sort $(ES2_ALL_SOURCES))