added some files needed to make export
This commit is contained in:
parent
b724698236
commit
6711e94bef
7 changed files with 3759 additions and 3078 deletions
77
Makefile.glslopt
Normal file
77
Makefile.glslopt
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
#
|
||||
# Makefile for the GLSL Optimizer component of the Regal runtime.
|
||||
# The GLSL Optimizer is always build into Regal, but you can build
|
||||
# just this target static library with:
|
||||
# make -f Makefile.glslopt
|
||||
#
|
||||
|
||||
ifndef MAKEFILE_GLSLOPT_INCLUDED
|
||||
MAKEFILE_GLSLOPT_INCLUDED := 1
|
||||
|
||||
.PHONY: glslopt.lib glslopt.clean
|
||||
|
||||
include build/common.inc
|
||||
include build/glslopt.inc
|
||||
|
||||
ifdef GLSLOPT.STATIC
|
||||
|
||||
all:: glslopt.lib
|
||||
|
||||
clean:: glslopt.clean
|
||||
|
||||
GLSLOPT.SRCS := $(GLSLOPT.CXX)
|
||||
GLSLOPT.SRCS := $(filter %.c,$(GLSLOPT.SRCS)) $(filter %.cc,$(GLSLOPT.SRCS)) $(filter %.cpp,$(GLSLOPT.SRCS))
|
||||
GLSLOPT.SRCS.NAMES := $(notdir $(GLSLOPT.SRCS))
|
||||
GLSLOPT.OBJS := $(addprefix tmp/$(SYSTEM)/glslopt/static/,$(GLSLOPT.SRCS.NAMES))
|
||||
GLSLOPT.OBJS := $(GLSLOPT.OBJS:.c=.o) $(GLSLOPT.OBJS:.cpp=.o)
|
||||
GLSLOPT.OBJS := $(filter %.o,$(GLSLOPT.OBJS))
|
||||
GLSLOPT.DEPS := $(GLSLOPT.OBJS:.o=.d)
|
||||
GLSLOPT.CFLAGS := $(GLSLOPT.INCLUDE)
|
||||
# quiet build for this thirdparty code for now
|
||||
GLSLOPT.CFLAGS += -Wno-ignored-qualifiers -Wno-sign-compare -Wno-unneeded-internal-declaration -Wno-overloaded-virtual -Wno-unused-private-field
|
||||
|
||||
ifeq ($(MODE),release)
|
||||
GLSLOPT.CFLAGS += -DNDEBUG
|
||||
GLSLOPT.CFLAGS += -DREGAL_NO_ASSERT=1
|
||||
endif
|
||||
|
||||
-include $(GLSLOPT.DEPS) #seth: do I need ot set this?
|
||||
|
||||
glslopt.lib: lib/$(SYSTEM)/$(GLSLOPT.STATIC)
|
||||
|
||||
glslopt.clean:
|
||||
$(RM) -r tmp/$(SYSTEM)/glslopt/static
|
||||
$(RM) -r lib/$(SYSTEM)/$(GLSLOPT.STATIC)
|
||||
|
||||
tmp/$(SYSTEM)/glslopt/static/%.o: src/glsl/src/mesa/main/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_CC)$(CCACHE) $(CC) $(CFLAGS) $(GLSLOPT.CFLAGS) $(PICFLAG) -o $@ -c $<
|
||||
|
||||
tmp/$(SYSTEM)/glslopt/static/%.o: src/glsl/src/mesa/program/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_CC)$(CCACHE) $(CC) $(CFLAGS) $(GLSLOPT.CFLAGS) $(PICFLAG) -o $@ -c $<
|
||||
|
||||
tmp/$(SYSTEM)/glslopt/static/%.o: src/glsl/src/glsl/glcpp/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_CC)$(CCACHE) $(CC) $(CFLAGS) $(GLSLOPT.CFLAGS) $(PICFLAG) -o $@ -c $<
|
||||
|
||||
tmp/$(SYSTEM)/glslopt/static/%.o: src/glsl/src/glsl/%.c
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_CC)$(CCACHE) $(CC) $(CFLAGS) $(GLSLOPT.CFLAGS) $(PICFLAG) -o $@ -c $<
|
||||
|
||||
tmp/$(SYSTEM)/glslopt/static/%.o: src/glsl/src/glsl/%.cpp
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_CXX)$(CCACHE) $(CXX) $(CFLAGS) $(GLSLOPT.CFLAGS) $(PICFLAG) -o $@ -c $<
|
||||
|
||||
lib/$(SYSTEM)/$(GLSLOPT.STATIC): $(GLSLOPT.OBJS)
|
||||
@mkdir -p $(dir $@)
|
||||
$(LOG_AR)$(CCACHE) $(AR) cr $@ $(GLSLOPT.OBJS)
|
||||
ifneq ($(RANLIB),)
|
||||
$(LOG_RANLIB)$(RANLIB) $@
|
||||
endif
|
||||
ifneq ($(STRIP),)
|
||||
$(LOG_STRIP)$(STRIP) -x $@
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
102
build/glslopt.inc
Normal file
102
build/glslopt.inc
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
# glslopt.inc
|
||||
#
|
||||
# Generic gnumake .inc for building GLSL Optimizer
|
||||
#
|
||||
|
||||
# Sources
|
||||
|
||||
GLSLOPT.CXX :=
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ast_array_index.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ast_expr.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ast_function.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ast_to_hir.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ast_type.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/builtin_function.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/builtin_variables.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_lexer.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_optimizer.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_parser.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_parser_extras.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_symbol_table.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glsl_types.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/hir_field_selection.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_basic_block.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_builder.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_clone.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_constant_expression.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_expression_flattening.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_function.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_function_can_inline.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_function_detect_recursion.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_hierarchical_visitor.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_hv_accept.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_import_prototypes.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_print_glsl_visitor.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_print_visitor.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_reader.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_rvalue_visitor.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_unused_structs.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_validate.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ir_variable_refcount.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_functions.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_uniform_block_active_visitor.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_uniform_blocks.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_uniform_initializers.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_uniforms.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/link_varyings.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/linker.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/loop_analysis.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/loop_controls.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/loop_unroll.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_clip_distance.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_discard.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_discard_flow.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_if_to_cond_assign.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_instructions.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_jumps.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_mat_op_to_vec.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_noise.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_packed_varyings.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_variable_index_to_cond_assign.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_vec_index_to_cond_assign.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_vec_index_to_swizzle.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/lower_vector.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_algebraic.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_array_splitting.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_constant_folding.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_constant_propagation.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_constant_variable.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_copy_propagation.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_copy_propagation_elements.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_dead_code.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_dead_code_local.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_dead_functions.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_flatten_nested_if_blocks.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_function_inlining.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_if_simplification.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_noop_swizzle.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_redundant_jumps.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_structure_splitting.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_swizzle_swizzle.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/opt_tree_grafting.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/ralloc.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/s_expression.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/standalone_scaffolding.cpp
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/strtod.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glcpp/glcpp-lex.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glcpp/glcpp-parse.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/glcpp/pp.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/../mesa/main/imports.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/../mesa/main/hash_table.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/../mesa/program/symbol_table.c
|
||||
GLSLOPT.CXX += src/glsl/src/glsl/../mesa/program/prog_hash_table.c
|
||||
|
||||
# Includes
|
||||
|
||||
GLSLOPT.INCLUDE :=
|
||||
GLSLOPT.INCLUDE += -Isrc/glsl/include
|
||||
GLSLOPT.INCLUDE += -Isrc/glsl/src/glsl
|
||||
GLSLOPT.INCLUDE += -Isrc/glsl/src/mesa
|
||||
|
||||
GLSLOPT.STATIC ?= libglslopt.a
|
||||
94
scripts/Dispatch.py
Normal file
94
scripts/Dispatch.py
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#!/usr/bin/python -B
|
||||
|
||||
import re
|
||||
from string import Template
|
||||
from string import join
|
||||
from copy import deepcopy
|
||||
|
||||
#
|
||||
# Apply per-section substitutions
|
||||
#
|
||||
# Inputs:
|
||||
#
|
||||
# code - the substituted code snippets for each section
|
||||
# formula - formula dictionary
|
||||
# subs - substitutions for string.Template.substitute
|
||||
#
|
||||
|
||||
def substitute(entry, formula, section, subs):
|
||||
|
||||
if not section in formula:
|
||||
return
|
||||
|
||||
# Turn a string into a list, if necessary
|
||||
|
||||
tmp = formula[section]
|
||||
if isinstance(tmp,str) or isinstance(tmp,unicode):
|
||||
tmp = tmp.split('\n')
|
||||
|
||||
entry[section] = [ Template(i).substitute(subs) for i in tmp ]
|
||||
|
||||
|
||||
|
||||
def dispatchGenCode(func, formulae):
|
||||
|
||||
if formulae==None:
|
||||
return None
|
||||
|
||||
name = func.name
|
||||
|
||||
# list of function parameter names
|
||||
|
||||
arglist = [ i.name.strip() for i in func.parameters ]
|
||||
|
||||
# arg is a mapping from arg0 to function parameter name...
|
||||
|
||||
arg = {}
|
||||
for i in range(len(arglist)):
|
||||
arg['arg%d' % i] = arglist[i]
|
||||
|
||||
# ... and mappings from arg0plus to lists of function parameters
|
||||
|
||||
for i in range(0,5):
|
||||
label = 'arg%dplus' % i;
|
||||
if len(arglist) > 0 :
|
||||
arg[label] = ', '.join(arglist)
|
||||
arglist.pop(0)
|
||||
else :
|
||||
arg[label] = ''
|
||||
|
||||
# Iterate over the formulae
|
||||
#
|
||||
# k is the key
|
||||
# i is the formula
|
||||
|
||||
for k,i in formulae.iteritems():
|
||||
|
||||
# Cache the compiled regular expressions, as needed
|
||||
|
||||
if 'entries_re' not in i:
|
||||
i['entries_re'] = [ re.compile( '^%s$' % j ) for j in i['entries'] ]
|
||||
|
||||
# A list of matches containing (match object, formula name, formula)
|
||||
# Look for matches, ideally only one
|
||||
|
||||
m = [ [j.match(name),k,i] for k,i in formulae.iteritems() for j in i['entries_re'] ]
|
||||
m = [ j for j in m if j[0] ]
|
||||
|
||||
assert len(m)<=1, 'Ambiguous match (%s) for %s - giving up.'%(', '.join([j[1] for j in m]),name)
|
||||
|
||||
if len(m):
|
||||
match = m[0][0]
|
||||
formula = m[0][2]
|
||||
code = { 'name' : name }
|
||||
subs = deepcopy(arg)
|
||||
for l in range( len(match.groups()) + 1):
|
||||
subs['m%d' % l] = match.group( l )
|
||||
subs['name'] = name
|
||||
substitute( code, formula, 'pre', subs )
|
||||
substitute( code, formula, 'post', subs )
|
||||
|
||||
return code
|
||||
|
||||
return None
|
||||
|
||||
40
scripts/EmuQuads.py
Normal file
40
scripts/EmuQuads.py
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
#!/usr/bin/python -B
|
||||
|
||||
quadsFormulae = {
|
||||
'EnableDisable' : {
|
||||
'entries' : [ 'gl(En|Dis)able' ],
|
||||
'prefix' : [ '_context->quads->gl${m1}able( ${arg0plus} );', ],
|
||||
},
|
||||
'CullFrontFace' : {
|
||||
'entries' : [ 'gl(Cull|Front)Face' ],
|
||||
'prefix' : [ '_context->quads->gl${m1}Face( ${arg0plus} );', ],
|
||||
},
|
||||
'PolygonMode' : {
|
||||
'entries' : [ 'glPolygonMode' ],
|
||||
'prefix' : [ '_context->quads->glPolygonMode( ${arg0plus} );', ],
|
||||
},
|
||||
'ShadeModel' : {
|
||||
'entries' : [ 'glShadeModel' ],
|
||||
'prefix' : [ '_context->quads->glShadeModel( ${arg0plus} );', ],
|
||||
},
|
||||
'ProvokingVertex' : {
|
||||
'entries' : [ 'glProvokingVertex(EXT|)' ],
|
||||
'prefix' : [ '_context->quads->glProvokingVertex( ${arg0plus} );', ],
|
||||
},
|
||||
'BindBuffer' : {
|
||||
'entries' : [ 'glBindBuffer(EXT|)' ],
|
||||
'prefix' : [ '_context->quads->glBindBuffer( ${arg0plus} );', ],
|
||||
},
|
||||
'quads' : {
|
||||
'entries' : [ 'glDrawArrays(EXT|)' ],
|
||||
'impl' : [
|
||||
'''
|
||||
if ( ! _context->quads->glDrawArrays( _context, ${arg0plus} ) ) {
|
||||
DispatchTableGL *_next = _context->dispatcher.emulation.next();
|
||||
RegalAssert(_next);
|
||||
return _next->call(&_next->glDrawArrays)( ${arg0plus} );
|
||||
}
|
||||
'''
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
@ -61,7 +61,8 @@ def apiDispatchTableDefineCode(apis, args, apiNames, structName):
|
|||
if category and not (category == categoryPrev):
|
||||
code += ' // %s\n\n' % category
|
||||
|
||||
code += ' %s(REGAL_CALL *%s)(%s);\n' % (rType, name, params)
|
||||
#code += ' %s(REGAL_CALL *%s)(%s);\n' % (rType, name, params)
|
||||
code += ' PFN%sPROC %s;\n' % (name.upper(), name)
|
||||
|
||||
categoryPrev = category
|
||||
|
||||
|
|
|
|||
367
scripts/regal/RegalDispatchHttp.py
Executable file
367
scripts/regal/RegalDispatchHttp.py
Executable file
|
|
@ -0,0 +1,367 @@
|
|||
#!/usr/bin/python -B
|
||||
|
||||
from string import Template, upper, replace
|
||||
|
||||
from ApiCodeGen import *
|
||||
from ApiUtil import outputCode
|
||||
from ApiUtil import typeIsVoid
|
||||
from ApiUtil import typeIsVoidPointer
|
||||
from ApiRegal import logFunction
|
||||
|
||||
from Dispatch import dispatchGenCode
|
||||
|
||||
from RegalContextInfo import cond
|
||||
|
||||
from RegalDispatchShared import apiDispatchFuncInitCode
|
||||
from RegalDispatchShared import apiDispatchGlobalFuncInitCode
|
||||
|
||||
formulae = {
|
||||
'bindtexture' : {
|
||||
'entries' : [ 'glBindTexture(EXT|)' ],
|
||||
'pre' : [
|
||||
'if( ${arg1} != 0 ) {',
|
||||
' HttpTextureInfo & hti = _context->http.texture[ ${arg1} ];',
|
||||
' RegalAssert( hti.name == 0 || hti.name == ${arg1} );',
|
||||
' if( hti.name == 0 ) {',
|
||||
' hti.name = ${arg1};',
|
||||
' hti.target = ${arg0};',
|
||||
' }',
|
||||
'}',
|
||||
],
|
||||
},
|
||||
'bindmultitexture' : {
|
||||
'entries' : [ 'glBindMultiTextureEXT' ],
|
||||
'pre' : [
|
||||
'if( ${arg2} != 0 ) {',
|
||||
' HttpTextureInfo & hti = _context->http.texture[ ${arg2} ];',
|
||||
' RegalAssert( hti.name == 0 || hti.name == ${arg2} );',
|
||||
' if( hti.name == 0 ) {',
|
||||
' hti.name = ${arg2};',
|
||||
' hti.target = ${arg1};',
|
||||
' }',
|
||||
'}',
|
||||
],
|
||||
},
|
||||
'bindtextures' : {
|
||||
'entries' : [ 'glBindTextures' ],
|
||||
'pre' : [
|
||||
'if( ${arg2} != NULL ) {',
|
||||
' for( int i = 0; i < ${arg1}; i++ ) {',
|
||||
' if( ${arg2}[i] != 0 ) {',
|
||||
' HttpTextureInfo & hti = _context->http.texture[ ${arg2}[i] ];',
|
||||
' RegalAssert( hti.name == 0 || hti.name == ${arg2}[i] );',
|
||||
' if( hti.name == 0 ) {',
|
||||
' hti.name = ${arg2}[i];',
|
||||
' hti.target = ${arg0};',
|
||||
' }',
|
||||
' }',
|
||||
' }',
|
||||
'}',
|
||||
],
|
||||
},
|
||||
|
||||
'deletetextures' : {
|
||||
'entries' : [ 'glDeleteTextures(EXT|)' ],
|
||||
'pre' : [
|
||||
'for( int i = 0; i < ${arg0}; i++ ) {',
|
||||
' _context->http.texture.erase( ${arg1}[i] );',
|
||||
'}',
|
||||
],
|
||||
},
|
||||
|
||||
'createshader' : {
|
||||
'entries' : [ 'glCreateShader(ObjectARB|)' ],
|
||||
'post' : [
|
||||
'_context->http.shader.insert( ret );',
|
||||
],
|
||||
},
|
||||
|
||||
'deleteshader' : {
|
||||
'entries' : [ 'glDeleteShader(ObjectARB|)' ],
|
||||
'post' : [
|
||||
'_context->http.shader.erase( ${arg0} );',
|
||||
],
|
||||
},
|
||||
|
||||
'createprogram' : {
|
||||
'entries' : [ 'glCreateProgram(ObjectARB|)' ],
|
||||
'post' : [
|
||||
'_context->http.program.insert( ret );',
|
||||
],
|
||||
},
|
||||
|
||||
'deleteprogram' : {
|
||||
'entries' : [ 'glDeleteProgram(ObjectARB|)' ],
|
||||
'post' : [
|
||||
'_context->http.program.erase( ${arg0} );',
|
||||
],
|
||||
},
|
||||
|
||||
|
||||
'bindfbo' : {
|
||||
'entries' : [ 'glBindFramebuffer(ARB|)' ],
|
||||
'pre' : [
|
||||
'_context->http.fbo[ ${arg1} ] = HttpFboInfo( ${arg1} );',
|
||||
'_context->http.count.fbo++;',
|
||||
'if( _context->http.runState == RS_NextFbo ) {',
|
||||
' _context->http.runState = RS_Pause;',
|
||||
'}',
|
||||
],
|
||||
'post' : [
|
||||
'_context->http.count.lastFbo = _context->http.count.call;',
|
||||
],
|
||||
},
|
||||
|
||||
'deletefbos' : {
|
||||
'entries' : [ 'glDeleteFramebufferss(EXT|)' ],
|
||||
'pre' : [
|
||||
'for( int i = 0; i < ${arg0}; i++ ) {',
|
||||
' _context->http.fbo.erase( ${arg1}[i] );',
|
||||
'}',
|
||||
],
|
||||
},
|
||||
|
||||
'pushdebuggroup' : {
|
||||
'entries' : [ 'glPushDebugGroup', 'glPushGroupMarkerEXT' ],
|
||||
'pre' : [
|
||||
'_context->http.count.group++;',
|
||||
'if( _context->http.runState == RS_NextGroup ) {',
|
||||
' _context->http.runState = RS_Pause;',
|
||||
'}',
|
||||
'_context->http.debugGroupStackDepth++;',
|
||||
],
|
||||
'post' : [
|
||||
'_context->http.count.lastGroup = _context->http.count.call;',
|
||||
],
|
||||
},
|
||||
|
||||
'popdebuggroup' : {
|
||||
'entries' : [ 'glPopDebugGroup', 'glPopGroupMarkerEXT' ],
|
||||
'post' : [
|
||||
'DispatchHttpState &h = _context->http;',
|
||||
'if( h.runState == RS_StepOutOfGroup || h.runState == RS_NextGroup ) {',
|
||||
' h.runState = RS_Pause;',
|
||||
'}',
|
||||
'if( h.runState == RS_StepOverGroup && h.debugGroupStackDepth == h.stepOverGroupDepth ) {',
|
||||
' h.runState = RS_Pause;',
|
||||
'}',
|
||||
'h.debugGroupStackDepth--;',
|
||||
],
|
||||
},
|
||||
|
||||
'draw' : {
|
||||
'entries' : [ 'gl(Multi|)Draw(Arrays|Elements).*', ],
|
||||
'pre' : [
|
||||
'_context->http.count.draw++;',
|
||||
'if( _context->http.runState == RS_NextDraw ) {',
|
||||
' _context->http.runState = RS_Pause;',
|
||||
'}',
|
||||
],
|
||||
'post' : [
|
||||
'_context->http.count.lastDraw = _context->http.count.call;',
|
||||
],
|
||||
},
|
||||
|
||||
'begin' : {
|
||||
'entries' : [ 'glBegin' ],
|
||||
'pre' : [
|
||||
'_context->http.count.draw++;',
|
||||
'_context->http.inBeginEnd++;',
|
||||
'if( _context->http.runState == RS_NextDraw ) {',
|
||||
' _context->http.runState = RS_Pause;',
|
||||
'}',
|
||||
],
|
||||
'post' : [
|
||||
'_context->http.count.lastDraw = _context->http.count.call;',
|
||||
],
|
||||
},
|
||||
|
||||
'end' : {
|
||||
'entries' : [ 'glEnd' ],
|
||||
'post' : [
|
||||
'_context->http.inBeginEnd--;',
|
||||
'_context->http.YieldToHttpServer( _context, false /*second call, don\'t update log */ );'
|
||||
],
|
||||
},
|
||||
|
||||
'swap' : {
|
||||
'entries' : [ '(glX|wgl|egl)SwapBuffers', 'CGLFlushDrawable' ],
|
||||
'pre' : [
|
||||
'_context->http.count.frame++;',
|
||||
'switch( _context->http.runState ) {',
|
||||
' case RS_Run:',
|
||||
' break;',
|
||||
' default:',
|
||||
' _context->http.runState = RS_Pause;',
|
||||
'}',
|
||||
],
|
||||
'post' : [
|
||||
'_context->http.count.lastFrame = _context->http.count.call;',
|
||||
],
|
||||
},
|
||||
|
||||
}
|
||||
|
||||
# CodeGen for dispatch table init.
|
||||
|
||||
dispatchHttpTemplate = Template('''${AUTOGENERATED}
|
||||
${LICENSE}
|
||||
|
||||
#include "pch.h" /* For MS precompiled header support */
|
||||
|
||||
#include "RegalUtil.h"
|
||||
|
||||
#if ! REGAL_NO_HTTP
|
||||
|
||||
REGAL_GLOBAL_BEGIN
|
||||
|
||||
#include "RegalLog.h"
|
||||
#include "RegalHttp.h"
|
||||
#include "RegalPush.h"
|
||||
#include "RegalToken.h"
|
||||
#include "RegalHelper.h"
|
||||
#include "RegalContext.h"
|
||||
#include "RegalDispatch.h"
|
||||
#include "RegalDispatcherGL.h"
|
||||
#include "RegalDispatcherGlobal.h"
|
||||
|
||||
using namespace ::REGAL_NAMESPACE_INTERNAL::Logging;
|
||||
using namespace ::REGAL_NAMESPACE_INTERNAL::Token;
|
||||
|
||||
REGAL_GLOBAL_END
|
||||
|
||||
REGAL_NAMESPACE_BEGIN
|
||||
|
||||
${API_FUNC_DEFINE}
|
||||
|
||||
void InitDispatchTableHttp(DispatchTableGL &tbl)
|
||||
{
|
||||
${API_GL_DISPATCH_INIT}
|
||||
}
|
||||
|
||||
${API_GLOBAL_DISPATCH_INIT}
|
||||
|
||||
REGAL_NAMESPACE_END
|
||||
|
||||
#endif
|
||||
''')
|
||||
|
||||
|
||||
def generateDispatchHttp(apis, args):
|
||||
|
||||
# CodeGen for API functions.
|
||||
|
||||
code = ''
|
||||
categoryPrev = None
|
||||
|
||||
for api in apis:
|
||||
|
||||
code += '\n'
|
||||
if api.name in cond:
|
||||
code += '#if %s\n' % cond[api.name]
|
||||
|
||||
for function in api.functions:
|
||||
|
||||
if getattr(function,'regalOnly',False)==True:
|
||||
continue
|
||||
|
||||
name = function.name
|
||||
params = paramsDefaultCode(function.parameters, True)
|
||||
callParams = paramsNameCode(function.parameters)
|
||||
rType = typeCode(function.ret.type)
|
||||
rTypes = rType.strip()
|
||||
category = getattr(function, 'category', None)
|
||||
version = getattr(function, 'version', None)
|
||||
|
||||
if category:
|
||||
category = category.replace('_DEPRECATED', '')
|
||||
elif version:
|
||||
category = version.replace('.', '_')
|
||||
category = 'GL_VERSION_' + category
|
||||
|
||||
# Close prev category block.
|
||||
if categoryPrev and not (category == categoryPrev):
|
||||
code += '\n'
|
||||
|
||||
# Begin new category block.
|
||||
if category and not (category == categoryPrev):
|
||||
code += '// %s\n\n' % category
|
||||
|
||||
categoryPrev = category
|
||||
|
||||
code += 'static %sREGAL_CALL %s%s(%s) \n{\n' % (rType, 'http_', name, params)
|
||||
|
||||
generated = dispatchGenCode( function, formulae )
|
||||
|
||||
retInit = ''
|
||||
if not typeIsVoid(rType):
|
||||
if rTypes in api.defaults:
|
||||
retInit += '%s' % ( api.defaults[rTypes] )
|
||||
else:
|
||||
if rType[-1]=='*' or typeIsVoidPointer(rType):
|
||||
retInit += 'NULL'
|
||||
else:
|
||||
retInit += '(%s) 0' % ( rTypes )
|
||||
|
||||
if not typeIsVoid(rType):
|
||||
code += ' %s ret = %s;\n' % (rType, retInit)
|
||||
code += ' RegalContext *_context = REGAL_GET_CONTEXT();\n'
|
||||
if function.needsContext:
|
||||
code += ' RegalAssert( _context );\n'
|
||||
|
||||
code += ' if( _context ) {\n'
|
||||
if generated and 'pre' in generated:
|
||||
for i in generated['pre']:
|
||||
code += ' %s\n' % i
|
||||
|
||||
code += ' if( _context->http.runState == RS_Next ) {\n'
|
||||
code += ' _context->http.runState = RS_Pause;\n'
|
||||
code += ' }\n'
|
||||
code += ' _context->http.YieldToHttpServer( _context );\n'
|
||||
code += ' }\n'
|
||||
|
||||
|
||||
|
||||
if function.needsContext:
|
||||
code += ' DispatchTableGL *_next = _context ? _context->dispatcher.http.next() : NULL;\n'
|
||||
else:
|
||||
code += ' DispatchTableGlobal *_next = dispatcherGlobal.http.next();\n'
|
||||
|
||||
code += ' RegalAssert(_next);\n'
|
||||
|
||||
code += ' '
|
||||
|
||||
if not typeIsVoid(rType):
|
||||
code += 'ret = '
|
||||
code += '_next->call(&_next->%s)(%s);\n' % ( name, callParams )
|
||||
|
||||
|
||||
if generated and 'post' in generated:
|
||||
code += ' if( _context ) {\n'
|
||||
for i in generated['post']:
|
||||
code += ' %s\n' % i
|
||||
code += ' }\n'
|
||||
|
||||
if not typeIsVoid(rType):
|
||||
code += ' return ret;\n'
|
||||
code += '}\n\n'
|
||||
|
||||
if api.name in cond:
|
||||
code += '#endif // %s\n' % cond[api.name]
|
||||
code += '\n'
|
||||
|
||||
# Close pending if block.
|
||||
if categoryPrev:
|
||||
code += '\n'
|
||||
|
||||
# Output
|
||||
|
||||
substitute = {}
|
||||
substitute['LICENSE'] = args.license
|
||||
substitute['AUTOGENERATED'] = args.generated
|
||||
substitute['COPYRIGHT'] = args.copyright
|
||||
substitute['API_FUNC_DEFINE'] = code
|
||||
substitute['API_GL_DISPATCH_INIT'] = apiDispatchFuncInitCode( apis, args, 'http' )
|
||||
substitute['API_GLOBAL_DISPATCH_INIT'] = apiDispatchGlobalFuncInitCode( apis, args, 'http' )
|
||||
|
||||
outputCode( '%s/RegalDispatchHttp.cpp' % args.srcdir, dispatchHttpTemplate.substitute(substitute))
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue