From 0309ff1699994b46f99c401a8fadd6fc0cd3e49e Mon Sep 17 00:00:00 2001 From: maltsev Date: Wed, 28 Mar 2012 17:56:35 +0600 Subject: [PATCH] First commit --- license.txt | 10 + pom-standalone.xml | 56 -- pom.xml | 57 -- .../engine3d/effects/AGALMiniAssembler.as | 724 ------------------ 4 files changed, 10 insertions(+), 837 deletions(-) create mode 100644 license.txt delete mode 100644 pom-standalone.xml delete mode 100644 pom.xml delete mode 100644 src/alternativa/engine3d/effects/AGALMiniAssembler.as diff --git a/license.txt b/license.txt new file mode 100644 index 0000000..25568e4 --- /dev/null +++ b/license.txt @@ -0,0 +1,10 @@ +/** + * Exhibit A - Source Code Form License Notice + * + * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + * If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. + * You may add additional accurate notices of copyright ownership. + * + * It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/ + * */ + diff --git a/pom-standalone.xml b/pom-standalone.xml deleted file mode 100644 index d16c79c..0000000 --- a/pom-standalone.xml +++ /dev/null @@ -1,56 +0,0 @@ - - 4.0.0 - platform.clients.fp10.libraries - Alternativa3D - swc - 8.5.0.0-SNAPSHOT - - platform.clients.fp11.tools.maven - BasePom - 2.11.1.0 - - - - scm:svn:https://svndev.alternativaplatform.com/platform/clients/fp11/libraries/Alternativa3D/trunk/ - - - - - platform.client - A3DModelsBase - 0.0.1.0 - swc - merged - - - platform.clients.fp10 - OSGiBase - 2.0.2.0 - swc - merged - - - - - - - - - - platform.clients.fp10.libraries - AlternativaProtocol - 2.0.15.0 - swc - merged - - - platform.clients.fp10.libraries - ProtocolTypes - 1.0.1.0 - swc - merged - - - - diff --git a/pom.xml b/pom.xml deleted file mode 100644 index f860c34..0000000 --- a/pom.xml +++ /dev/null @@ -1,57 +0,0 @@ - - 4.0.0 - platform.clients.fp11.libraries - Alternativa3D - swc - 8.28.0-SNAPSHOT - - platform.clients.fp11.tools.maven - BasePom - 2.58.0 - - - - scm:svn:https://svndev.alternativaplatform.com/platform/clients/fp11/libraries/Alternativa3D/trunk/ - - - - - - - platform.client.formats - A3DModelsBase - 2.5.2 - swc - external - - - platform.clients.fp10.libraries - AlternativaProtocol - 2.53.0 - swc - external - - - - - - - platform.client.formats - A3DModelsBase - swc - external - - - platform.clients.fp10 - OSGiBase - swc - external - - - platform.clients.fp10.libraries - AlternativaProtocol - swc - external - - - diff --git a/src/alternativa/engine3d/effects/AGALMiniAssembler.as b/src/alternativa/engine3d/effects/AGALMiniAssembler.as deleted file mode 100644 index a867090..0000000 --- a/src/alternativa/engine3d/effects/AGALMiniAssembler.as +++ /dev/null @@ -1,724 +0,0 @@ -/** - * Exhibit A - Source Code Form License Notice - * - * This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. - * If it is not possible or desirable to put the notice in a particular file, then You may include the notice in a location (such as a LICENSE file in a relevant directory) where a recipient would be likely to look for such a notice. - * You may add additional accurate notices of copyright ownership. - * - * It is desirable to notify that Covered Software was "Powered by AlternativaPlatform" with link to http://www.alternativaplatform.com/ - * */ - -package alternativa.engine3d.effects { - // =========================================================================== - // Imports - // --------------------------------------------------------------------------- - //import flash.display3D.*; - - import flash.utils.*; - - /** - * @private - */ - public class AGALMiniAssembler - { - // ====================================================================== - // Properties - // ---------------------------------------------------------------------- - // AGAL bytes and error buffer - private var _agalcode:ByteArray = null; - private var _error:String = ""; - - private var debugEnabled:Boolean = false; - - private static var initialized:Boolean = false; - - // ====================================================================== - // Getters - // ---------------------------------------------------------------------- - public function get error():String { return _error; } - public function get agalcode():ByteArray { return _agalcode; } - - // ====================================================================== - // Constructor - // ---------------------------------------------------------------------- - public function AGALMiniAssembler( debugging:Boolean = false ):void - { - debugEnabled = debugging; - if ( !initialized ) - init(); - } - // ====================================================================== - // Methods - // ---------------------------------------------------------------------- - public function assemble( mode:String, source:String, verbose:Boolean = false ):ByteArray - { - var start:uint = getTimer(); - - _agalcode = new ByteArray(); - _error = ""; - - var isFrag:Boolean = false; - - if ( mode == FRAGMENT ) - isFrag = true - else if ( mode != VERTEX ) - _error = 'ERROR: mode needs to be "' + FRAGMENT + '" or "' + VERTEX + '" but is "' + mode + '".'; - - agalcode.endian = Endian.LITTLE_ENDIAN; - agalcode.writeByte( 0xa0 ); // tag version - agalcode.writeUnsignedInt( 0x1 ); // AGAL version, big endian, bit pattern will be 0x01000000 - agalcode.writeByte( 0xa1 ); // tag program id - agalcode.writeByte( isFrag ? 1 : 0 ); // vertex or fragment - - var lines:Array = source.replace( /[\f\n\r\v]+/g, "\n" ).split( "\n" ); - var nest:int = 0; - var nops:int = 0; - var i:int; - var lng:int = lines.length; - - for ( i = 0; i < lng && _error == ""; i++ ) - { - var line:String = new String( lines[i] ); - - // remove comments - var startcomment:int = line.search( "//" ); - if ( startcomment != -1 ) - line = line.slice( 0, startcomment ); - - // grab options - var optsi:int = line.search( /<.*>/g ); - var opts:Array; - if ( optsi != -1 ) - { - opts = line.slice( optsi ).match( /([\w\.\-\+]+)/gi ); - line = line.slice( 0, optsi ); - } - - // find opcode - var opCode:Array = line.match( /^\w{3}/ig ); - var opFound:OpCode = OPMAP[ opCode[0] ]; - - // if debug is enabled, output the opcodes - if ( debugEnabled ) - trace( opFound ); - - if ( opFound == null ) - { - if ( line.length >= 3 ) - trace( "warning: bad line "+i+": "+lines[i] ); - continue; - } - - line = line.slice( line.search( opFound.name ) + opFound.name.length ); - - // nesting check - if ( opFound.flags & OP_DEC_NEST ) - { - nest--; - if ( nest < 0 ) - { - _error = "error: conditional closes without open."; - break; - } - } - if ( opFound.flags & OP_INC_NEST ) - { - nest++; - if ( nest > MAX_NESTING ) - { - _error = "error: nesting to deep, maximum allowed is "+MAX_NESTING+"."; - break; - } - } - if ( ( opFound.flags & OP_FRAG_ONLY ) && !isFrag ) - { - _error = "error: opcode is only allowed in fragment programs."; - break; - } - if ( verbose ) - trace( "emit opcode=" + opFound ); - - agalcode.writeUnsignedInt( opFound.emitCode ); - nops++; - - if ( nops > MAX_OPCODES ) - { - _error = "error: too many opcodes. maximum is "+MAX_OPCODES+"."; - break; - } - - // get operands, use regexp - var regs:Array = line.match( /vc\[([vof][actps]?)(\d*)?(\.[xyzw](\+\d{1,3})?)?\](\.[xyzw]{1,4})?|([vof][actps]?)(\d*)?(\.[xyzw]{1,4})?/gi ); - if ( regs.length != opFound.numRegister ) - { - _error = "error: wrong number of operands. found "+regs.length+" but expected "+opFound.numRegister+"."; - break; - } - - var badreg:Boolean = false; - var pad:uint = 64 + 64 + 32; - var regLength:uint = regs.length; - - for ( var j:int = 0; j < regLength; j++ ) - { - var isRelative:Boolean = false; - var relreg:Array = regs[ j ].match( /\[.*\]/ig ); - if ( relreg.length > 0 ) - { - regs[ j ] = regs[ j ].replace( relreg[ 0 ], "0" ); - - if ( verbose ) - trace( "IS REL" ); - isRelative = true; - } - - var res:Array = regs[j].match( /^\b[A-Za-z]{1,2}/ig ); - var regFound:Register = REGMAP[ res[ 0 ] ]; - - // if debug is enabled, output the registers - if ( debugEnabled ) - trace( regFound ); - - if ( regFound == null ) - { - _error = "error: could not parse operand "+j+" ("+regs[j]+")."; - badreg = true; - break; - } - - if ( isFrag ) - { - if ( !( regFound.flags & REG_FRAG ) ) - { - _error = "error: register operand "+j+" ("+regs[j]+") only allowed in vertex programs."; - badreg = true; - break; - } - if ( isRelative ) - { - _error = "error: register operand "+j+" ("+regs[j]+") relative adressing not allowed in fragment programs."; - badreg = true; - break; - } - } - else - { - if ( !( regFound.flags & REG_VERT ) ) - { - _error = "error: register operand "+j+" ("+regs[j]+") only allowed in fragment programs."; - badreg = true; - break; - } - } - - regs[j] = regs[j].slice( regs[j].search( regFound.name ) + regFound.name.length ); - //trace( "REGNUM: " +regs[j] ); - var idxmatch:Array = isRelative ? relreg[0].match( /\d+/ ) : regs[j].match( /\d+/ ); - var regidx:uint = 0; - - if ( idxmatch ) - regidx = uint( idxmatch[0] ); - - if ( regFound.range < regidx ) - { - _error = "error: register operand "+j+" ("+regs[j]+") index exceeds limit of "+(regFound.range+1)+"."; - badreg = true; - break; - } - - var regmask:uint = 0; - var maskmatch:Array = regs[j].match( /(\.[xyzw]{1,4})/ ); - var isDest:Boolean = ( j == 0 && !( opFound.flags & OP_NO_DEST ) ); - var isSampler:Boolean = ( j == 2 && ( opFound.flags & OP_SPECIAL_TEX ) ); - var reltype:uint = 0; - var relsel:uint = 0; - var reloffset:int = 0; - - if ( isDest && isRelative ) - { - _error = "error: relative can not be destination"; - badreg = true; - break; - } - - if ( maskmatch ) - { - regmask = 0; - var cv:uint; - var maskLength:uint = maskmatch[0].length; - for ( var k:int = 1; k < maskLength; k++ ) - { - cv = maskmatch[0].charCodeAt(k) - "x".charCodeAt(0); - if ( cv > 2 ) - cv = 3; - if ( isDest ) - regmask |= 1 << cv; - else - regmask |= cv << ( ( k - 1 ) << 1 ); - } - if ( !isDest ) - for ( ; k <= 4; k++ ) - regmask |= cv << ( ( k - 1 ) << 1 ) // repeat last - } - else - { - regmask = isDest ? 0xf : 0xe4; // id swizzle or mask - } - - if ( isRelative ) - { - var relname:Array = relreg[0].match( /[A-Za-z]{1,2}/ig ); - var regFoundRel:Register = REGMAP[ relname[0]]; - if ( regFoundRel == null ) - { - _error = "error: bad index register"; - badreg = true; - break; - } - reltype = regFoundRel.emitCode; - var selmatch:Array = relreg[0].match( /(\.[xyzw]{1,1})/ ); - if ( selmatch.length==0 ) - { - _error = "error: bad index register select"; - badreg = true; - break; - } - relsel = selmatch[0].charCodeAt(1) - "x".charCodeAt(0); - if ( relsel > 2 ) - relsel = 3; - var relofs:Array = relreg[0].match( /\+\d{1,3}/ig ); - if ( relofs.length > 0 ) - reloffset = relofs[0]; - if ( reloffset < 0 || reloffset > 255 ) - { - _error = "error: index offset "+reloffset+" out of bounds. [0..255]"; - badreg = true; - break; - } - if ( verbose ) - trace( "RELATIVE: type="+reltype+"=="+relname[0]+" sel="+relsel+"=="+selmatch[0]+" idx="+regidx+" offset="+reloffset ); - } - - if ( verbose ) - trace( " emit argcode="+regFound+"["+regidx+"]["+regmask+"]" ); - if ( isDest ) - { - agalcode.writeShort( regidx ); - agalcode.writeByte( regmask ); - agalcode.writeByte( regFound.emitCode ); - pad -= 32; - } else - { - if ( isSampler ) - { - if ( verbose ) - trace( " emit sampler" ); - var samplerbits:uint = 5; // type 5 - var optsLength:uint = opts.length; - var bias:Number = 0; - for ( k = 0; k