Skip to content

Commit

Permalink
GENERATOR Embed size calculations from the spec as part of the lamba …
Browse files Browse the repository at this point in the history
…operation for size
  • Loading branch information
mcfletch committed Dec 29, 2024
1 parent 9406606 commit dc317d7
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 32 deletions.
2 changes: 1 addition & 1 deletion OpenGL/GL/AMD/performance_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def glInitPerformanceMonitorAMD():
glGetPerfMonitorCounterDataAMD=wrapper.wrapper(glGetPerfMonitorCounterDataAMD).setOutput(
'bytesWritten',size=(1,),orPassIn=True
).setOutput(
'data',size=lambda x:(x,),pnameArg='dataSize / 4',orPassIn=True
'data',size=lambda x: (x//4),pnameArg='dataSize',orPassIn=True
)
### END AUTOGENERATED SECTION
12 changes: 6 additions & 6 deletions OpenGL/GL/ARB/robustness.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,19 +124,19 @@ def glInitRobustnessARB():
'img',size=lambda x:(x,),pnameArg='bufSize',orPassIn=True
)
glGetnUniformfvARB=wrapper.wrapper(glGetnUniformfvARB).setOutput(
'params',size=lambda x:(x,),pnameArg='bufSize / 4',orPassIn=True
'params',size=lambda x: (x//4),pnameArg='bufSize',orPassIn=True
)
glGetnUniformivARB=wrapper.wrapper(glGetnUniformivARB).setOutput(
'params',size=lambda x:(x,),pnameArg='bufSize / 4',orPassIn=True
'params',size=lambda x: (x//4),pnameArg='bufSize',orPassIn=True
)
glGetnUniformuivARB=wrapper.wrapper(glGetnUniformuivARB).setOutput(
'params',size=lambda x:(x,),pnameArg='bufSize / 4',orPassIn=True
'params',size=lambda x: (x//4),pnameArg='bufSize',orPassIn=True
)
glGetnUniformdvARB=wrapper.wrapper(glGetnUniformdvARB).setOutput(
'params',size=lambda x:(x,),pnameArg='bufSize / 8',orPassIn=True
'params',size=lambda x: (x//8),pnameArg='bufSize',orPassIn=True
)
glGetnMapdvARB=wrapper.wrapper(glGetnMapdvARB).setOutput(
'v',size=lambda x:(x,),pnameArg='bufSize / 8',orPassIn=True
'v',size=lambda x: (x//8),pnameArg='bufSize',orPassIn=True
)
glGetnMapfvARB=wrapper.wrapper(glGetnMapfvARB).setOutput(
'v',size=lambda x:(x,),pnameArg='bufSize',orPassIn=True
Expand All @@ -145,7 +145,7 @@ def glInitRobustnessARB():
'v',size=lambda x:(x,),pnameArg='bufSize',orPassIn=True
)
glGetnPixelMapfvARB=wrapper.wrapper(glGetnPixelMapfvARB).setOutput(
'values',size=lambda x:(x,),pnameArg='bufSize / 4',orPassIn=True
'values',size=lambda x: (x//4),pnameArg='bufSize',orPassIn=True
)
glGetnPixelMapuivARB=wrapper.wrapper(glGetnPixelMapuivARB).setOutput(
'values',size=lambda x:(x,),pnameArg='bufSize',orPassIn=True
Expand Down
2 changes: 1 addition & 1 deletion OpenGL/GLES2/AMD/performance_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ def glInitPerformanceMonitorAMD():
glGetPerfMonitorCounterDataAMD=wrapper.wrapper(glGetPerfMonitorCounterDataAMD).setOutput(
'bytesWritten',size=(1,),orPassIn=True
).setOutput(
'data',size=lambda x:(x,),pnameArg='dataSize / 4',orPassIn=True
'data',size=lambda x: (x//4),pnameArg='dataSize',orPassIn=True
)
### END AUTOGENERATED SECTION
File renamed without changes.
13 changes: 12 additions & 1 deletion src/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,19 @@ def output_wrapping(self):
% locals()
)
elif isinstance(dependency, xmlreg.Dynamicsize):
if '/' in dependency:
fragments = [x.strip() for x in dependency.split('/')]
functor = 'lambda x: (x//%s)' % (fragments[1])
dependency = fragments[0]
elif '*' in dependency:
fragments = [x.strip() for x in dependency.split('/')]
functor = 'lambda x: (x*%s)' % (fragments[1])
dependency = fragments[0]
else:
functor = 'lambda x:(x,)'

base.append(
'.setOutput(\n %(param)r,size=lambda x:(x,),pnameArg=%(dependency)r,orPassIn=True\n)'
'.setOutput(\n %(param)r,size=%(functor)s,pnameArg=%(dependency)r,orPassIn=True\n)'
% locals()
)
elif isinstance(dependency, xmlreg.Multiple):
Expand Down
51 changes: 28 additions & 23 deletions src/xml_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,38 +4,43 @@
import os, logging, subprocess, glob
import xmlreg, codegenerator
import ctypetopytype
log = logging.getLogger( 'xml-generate' )

log = logging.getLogger('xml-generate')

KHRONOS_URL = 'https://github.com/KhronosGroup/OpenGL-Registry.git'
KHRONOS_API = os.path.join( os.path.dirname(__file__), 'khronosapi' )
KHRONOS_API = os.path.join(os.path.dirname(__file__), 'khronosapi')


def get_khronos(khronosapi):
if not os.path.exists(khronosapi):
log.info("Cloning the Khronos API into %s", khronosapi)
subprocess.check_call(['git', 'clone', KHRONOS_URL, khronosapi])
else:
log.info("Pulling new commits from Khronos API")
subprocess.check_call(['git', 'pull', '--ff-only'], cwd=khronosapi)

def get_khronos( khronosapi ):
if not os.path.exists( khronosapi ):
subprocess.check_call(['git','clone', KHRONOS_URL, khronosapi ])

def main(khronosapi=None):
khronosapi = khronosapi or KHRONOS_API
get_khronos( khronosapi )
files = sorted( glob.glob( os.path.join( khronosapi, 'xml','*.xml' ) ))
get_khronos(khronosapi)

files = sorted(glob.glob(os.path.join(khronosapi, 'xml', '*.xml')))
for file in files:
generate_for_file( file )

def generate_for_file( filename ):
log.info( 'Starting file: %s', filename )
registry = xmlreg.parse( filename )
generator = codegenerator.Generator(
registry,
ctypetopytype.ctype_to_pytype
)
for name,feature in registry.feature_set.items():
generate_for_file(file)


def generate_for_file(filename):
log.info('Starting file: %s', filename)
registry = xmlreg.parse(filename)
generator = codegenerator.Generator(registry, ctypetopytype.ctype_to_pytype)
for name, feature in registry.feature_set.items():
print(feature.name, feature.api)
generator.module( feature )
for name,extension in registry.extension_set.items():
generator.module(feature)
for name, extension in registry.extension_set.items():
print(extension.name, extension.apis)
generator.module( extension )
generator.module(extension)


if __name__ == "__main__":
logging.basicConfig( level=logging.INFO )
logging.basicConfig(level=logging.INFO)
main()

0 comments on commit dc317d7

Please sign in to comment.