From 9756d385e14eccf0971702dd6268510113ae8ca6 Mon Sep 17 00:00:00 2001 From: Cheng Liao Date: Tue, 15 Apr 2014 13:54:30 +0800 Subject: [PATCH 1/9] add repeat_u_clamp_v, clamp_u_repeat_v and anisotropic instructions --- src/com/adobe/utils/AGALMiniAssembler.as | 12 ++++++++++++ src/com/adobe/utils/extended/AGALMiniAssembler.as | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/src/com/adobe/utils/AGALMiniAssembler.as b/src/com/adobe/utils/AGALMiniAssembler.as index 8320b36..17d32e3 100644 --- a/src/com/adobe/utils/AGALMiniAssembler.as +++ b/src/com/adobe/utils/AGALMiniAssembler.as @@ -527,12 +527,18 @@ package com.adobe.utils SAMPLEMAP[ NOMIP ] = new Sampler( NOMIP, SAMPLER_MIPMAP_SHIFT, 0 ); SAMPLEMAP[ NEAREST ] = new Sampler( NEAREST, SAMPLER_FILTER_SHIFT, 0 ); SAMPLEMAP[ LINEAR ] = new Sampler( LINEAR, SAMPLER_FILTER_SHIFT, 1 ); + SAMPLEMAP[ ANISOTROPIC2X ] = new Sampler( ANISOTROPIC2X, SAMPLER_FILTER_SHIFT, 2 ); + SAMPLEMAP[ ANISOTROPIC4X ] = new Sampler( ANISOTROPIC4X, SAMPLER_FILTER_SHIFT, 3 ); + SAMPLEMAP[ ANISOTROPIC8X ] = new Sampler( ANISOTROPIC8X, SAMPLER_FILTER_SHIFT, 4 ); + SAMPLEMAP[ ANISOTROPIC16X ] = new Sampler( ANISOTROPIC16X, SAMPLER_FILTER_SHIFT,5 ); SAMPLEMAP[ CENTROID ] = new Sampler( CENTROID, SAMPLER_SPECIAL_SHIFT, 1 << 0 ); SAMPLEMAP[ SINGLE ] = new Sampler( SINGLE, SAMPLER_SPECIAL_SHIFT, 1 << 1 ); SAMPLEMAP[ DEPTH ] = new Sampler( DEPTH, SAMPLER_SPECIAL_SHIFT, 1 << 2 ); SAMPLEMAP[ REPEAT ] = new Sampler( REPEAT, SAMPLER_REPEAT_SHIFT, 1 ); SAMPLEMAP[ WRAP ] = new Sampler( WRAP, SAMPLER_REPEAT_SHIFT, 1 ); SAMPLEMAP[ CLAMP ] = new Sampler( CLAMP, SAMPLER_REPEAT_SHIFT, 0 ); + SAMPLEMAP[ CLAMP_U_REPEAT_V ] = new Sampler( CLAMP_U_REPEAT_V, SAMPLER_REPEAT_SHIFT, 2 ); + SAMPLEMAP[ REPEAT_U_CLAMP_V ] = new Sampler( REPEAT_U_CLAMP_V, SAMPLER_REPEAT_SHIFT, 3 ); } // ====================================================================== @@ -641,12 +647,18 @@ package com.adobe.utils private static const NOMIP:String = "nomip"; private static const NEAREST:String = "nearest"; private static const LINEAR:String = "linear"; + private static const ANISOTROPIC2X:String = "anisotropic2x"; //Introduced by Flash 14 + private static const ANISOTROPIC4X:String = "anisotropic4x"; //Introduced by Flash 14 + private static const ANISOTROPIC8X:String = "anisotropic8x"; //Introduced by Flash 14 + private static const ANISOTROPIC16X:String = "anisotropic16x"; //Introduced by Flash 14 private static const CENTROID:String = "centroid"; private static const SINGLE:String = "single"; private static const DEPTH:String = "depth"; private static const REPEAT:String = "repeat"; private static const WRAP:String = "wrap"; private static const CLAMP:String = "clamp"; + private static const REPEAT_U_CLAMP_V:String = "repeat_u_clamp_v"; //Introduced by Flash 13 + private static const CLAMP_U_REPEAT_V:String = "clamp_u_repeat_v"; //Introduced by Flash 13 private static const RGBA:String = "rgba"; private static const DXT1:String = "dxt1"; private static const DXT5:String = "dxt5"; diff --git a/src/com/adobe/utils/extended/AGALMiniAssembler.as b/src/com/adobe/utils/extended/AGALMiniAssembler.as index 6fbde3f..8052488 100644 --- a/src/com/adobe/utils/extended/AGALMiniAssembler.as +++ b/src/com/adobe/utils/extended/AGALMiniAssembler.as @@ -539,12 +539,18 @@ package com.adobe.utils.extended SAMPLEMAP[ NOMIP ] = new Sampler( NOMIP, SAMPLER_MIPMAP_SHIFT, 0 ); SAMPLEMAP[ NEAREST ] = new Sampler( NEAREST, SAMPLER_FILTER_SHIFT, 0 ); SAMPLEMAP[ LINEAR ] = new Sampler( LINEAR, SAMPLER_FILTER_SHIFT, 1 ); + SAMPLEMAP[ ANISOTROPIC2X ] = new Sampler( ANISOTROPIC2X, SAMPLER_FILTER_SHIFT, 2 ); + SAMPLEMAP[ ANISOTROPIC4X ] = new Sampler( ANISOTROPIC4X, SAMPLER_FILTER_SHIFT, 3 ); + SAMPLEMAP[ ANISOTROPIC8X ] = new Sampler( ANISOTROPIC8X, SAMPLER_FILTER_SHIFT, 4 ); + SAMPLEMAP[ ANISOTROPIC16X ] = new Sampler( ANISOTROPIC16X, SAMPLER_FILTER_SHIFT,5 ); SAMPLEMAP[ CENTROID ] = new Sampler( CENTROID, SAMPLER_SPECIAL_SHIFT, 1 << 0 ); SAMPLEMAP[ SINGLE ] = new Sampler( SINGLE, SAMPLER_SPECIAL_SHIFT, 1 << 1 ); SAMPLEMAP[ IGNORESAMPLER ] = new Sampler( IGNORESAMPLER, SAMPLER_SPECIAL_SHIFT, 1 << 2 ); SAMPLEMAP[ REPEAT ] = new Sampler( REPEAT, SAMPLER_REPEAT_SHIFT, 1 ); SAMPLEMAP[ WRAP ] = new Sampler( WRAP, SAMPLER_REPEAT_SHIFT, 1 ); SAMPLEMAP[ CLAMP ] = new Sampler( CLAMP, SAMPLER_REPEAT_SHIFT, 0 ); + SAMPLEMAP[ CLAMP_U_REPEAT_V ] = new Sampler( CLAMP_U_REPEAT_V, SAMPLER_REPEAT_SHIFT, 2 ); + SAMPLEMAP[ REPEAT_U_CLAMP_V ] = new Sampler( REPEAT_U_CLAMP_V, SAMPLER_REPEAT_SHIFT, 3 ); } // ====================================================================== @@ -651,12 +657,18 @@ package com.adobe.utils.extended private static const NOMIP:String = "nomip"; private static const NEAREST:String = "nearest"; private static const LINEAR:String = "linear"; + private static const ANISOTROPIC2X:String = "anisotropic2x"; //Introduced by Flash 14 + private static const ANISOTROPIC4X:String = "anisotropic4x"; //Introduced by Flash 14 + private static const ANISOTROPIC8X:String = "anisotropic8x"; //Introduced by Flash 14 + private static const ANISOTROPIC16X:String = "anisotropic16x"; //Introduced by Flash 14 private static const CENTROID:String = "centroid"; private static const SINGLE:String = "single"; private static const IGNORESAMPLER:String = "ignoresampler"; private static const REPEAT:String = "repeat"; private static const WRAP:String = "wrap"; private static const CLAMP:String = "clamp"; + private static const REPEAT_U_CLAMP_V:String = "repeat_u_clamp_v"; //Introduced by Flash 13 + private static const CLAMP_U_REPEAT_V:String = "clamp_u_repeat_v"; //Introduced by Flash 13 private static const RGBA:String = "rgba"; private static const DXT1:String = "dxt1"; private static const DXT5:String = "dxt5"; From e194c12cca6d171c5e91297db2e735155ac2f65d Mon Sep 17 00:00:00 2001 From: Cheng Liao Date: Wed, 6 Aug 2014 18:27:10 +0800 Subject: [PATCH 2/9] remove ted add correct register number --- src/com/adobe/utils/extended/AGALMiniAssembler.as | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/com/adobe/utils/extended/AGALMiniAssembler.as b/src/com/adobe/utils/extended/AGALMiniAssembler.as index 8052488..4d77688 100644 --- a/src/com/adobe/utils/extended/AGALMiniAssembler.as +++ b/src/com/adobe/utils/extended/AGALMiniAssembler.as @@ -457,12 +457,12 @@ package com.adobe.utils.extended private function initregmap ( version:uint, ignorelimits:Boolean ) : void { // version changes limits REGMAP[ VA ] = new Register( VA, "vertex attribute", 0x0, ignorelimits?1024:7, REG_VERT | REG_READ ); - REGMAP[ VC ] = new Register( VC, "vertex constant", 0x1, ignorelimits?1024:(version==1?127:250), REG_VERT | REG_READ ); - REGMAP[ VT ] = new Register( VT, "vertex temporary", 0x2, ignorelimits?1024:(version==1?7:27), REG_VERT | REG_WRITE | REG_READ ); + REGMAP[ VC ] = new Register( VC, "vertex constant", 0x1, ignorelimits?1024:(version==1?127:249), REG_VERT | REG_READ ); + REGMAP[ VT ] = new Register( VT, "vertex temporary", 0x2, ignorelimits?1024:(version==1?7:25), REG_VERT | REG_WRITE | REG_READ ); REGMAP[ VO ] = new Register( VO, "vertex output", 0x3, ignorelimits?1024:0, REG_VERT | REG_WRITE ); - REGMAP[ VI ] = new Register( VI, "varying", 0x4, ignorelimits?1024:(version==1?7:11), REG_VERT | REG_FRAG | REG_READ | REG_WRITE ); + REGMAP[ VI ] = new Register( VI, "varying", 0x4, ignorelimits?1024:(version==1?7:9), REG_VERT | REG_FRAG | REG_READ | REG_WRITE ); REGMAP[ FC ] = new Register( FC, "fragment constant", 0x1, ignorelimits?1024:(version==1?27:63), REG_FRAG | REG_READ ); - REGMAP[ FT ] = new Register( FT, "fragment temporary", 0x2, ignorelimits?1024:(version==1?7:27), REG_FRAG | REG_WRITE | REG_READ ); + REGMAP[ FT ] = new Register( FT, "fragment temporary", 0x2, ignorelimits?1024:(version==1?7:25), REG_FRAG | REG_WRITE | REG_READ ); REGMAP[ FS ] = new Register( FS, "texture sampler", 0x5, ignorelimits?1024:7, REG_FRAG | REG_READ ); REGMAP[ FO ] = new Register( FO, "fragment output", 0x3, ignorelimits?1024:(version==1?0:3), REG_FRAG | REG_WRITE ); REGMAP[ FD ] = new Register( FD, "fragment depth output",0x6, ignorelimits?1024:(version==1?-1:0), REG_FRAG | REG_WRITE ); @@ -516,7 +516,7 @@ package com.adobe.utils.extended OPMAP[ ELS ] = new OpCode( ELS, 0, 0x20, OP_NO_DEST | OP_VERSION2 | OP_INCNEST | OP_DECNEST | OP_SCALAR ); OPMAP[ EIF ] = new OpCode( EIF, 0, 0x21, OP_NO_DEST | OP_VERSION2 | OP_DECNEST | OP_SCALAR ); // space - OPMAP[ TED ] = new OpCode( TED, 3, 0x26, OP_FRAG_ONLY | OP_SPECIAL_TEX | OP_VERSION2); + //OPMAP[ TED ] = new OpCode( TED, 3, 0x26, OP_FRAG_ONLY | OP_SPECIAL_TEX | OP_VERSION2); //ted is not available in AGAL2 OPMAP[ KIL ] = new OpCode( KIL, 1, 0x27, OP_NO_DEST | OP_FRAG_ONLY ); OPMAP[ TEX ] = new OpCode( TEX, 3, 0x28, OP_FRAG_ONLY | OP_SPECIAL_TEX ); OPMAP[ SGE ] = new OpCode( SGE, 3, 0x29, 0 ); From ca0924f2159c18e253113031d1a6f76cae697f7a Mon Sep 17 00:00:00 2001 From: Mayank Bhagya Date: Mon, 19 Jan 2015 11:23:35 +0530 Subject: [PATCH 3/9] Description: AGAL3 support in AGALMiniAssembler Dev/QA notes: None Bugs fixed: None Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 805 ++++++++++++++++++++ 1 file changed, 805 insertions(+) create mode 100644 src/com/adobe/utils/v3/AGALMiniAssembler.as diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as new file mode 100644 index 0000000..56e0071 --- /dev/null +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -0,0 +1,805 @@ +/* +Copyright (c) 2011, Adobe Systems Incorporated +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +* Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + +* Neither the name of Adobe Systems Incorporated nor the names of its +contributors may be used to endorse or promote products derived from +this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR +CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, +PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ +package com.adobe.utils.extended +{ + // =========================================================================== + // Imports + // --------------------------------------------------------------------------- + import flash.display3D.*; + import flash.utils.*; + + // =========================================================================== + // Class + // --------------------------------------------------------------------------- + public class AGALMiniAssembler + { // ====================================================================== + // Constants + // ---------------------------------------------------------------------- + protected static const REGEXP_OUTER_SPACES:RegExp = /^\s+|\s+$/g; + + // ====================================================================== + // 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; + public var verbose: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 assemble2( ctx3d : Context3D, version:uint, vertexsrc:String, fragmentsrc:String ) : Program3D + { + var agalvertex : ByteArray = assemble ( VERTEX, vertexsrc, version ); + var agalfragment : ByteArray = assemble ( FRAGMENT, fragmentsrc, version ); + var prog : Program3D = ctx3d.createProgram(); + prog.upload(agalvertex,agalfragment); + return prog; + } + + public function assemble( mode:String, source:String, version:uint=1, ignorelimits: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( version ); // AGAL version, big endian, bit pattern will be 0x01000000 + agalcode.writeByte( 0xa1 ); // tag program id + agalcode.writeByte( isFrag ? 1 : 0 ); // vertex or fragment + + initregmap(version, ignorelimits); + + 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] ); + line = line.replace( REGEXP_OUTER_SPACES, "" ); + + // 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 ); + if ( !opCode ) + { + if ( line.length >= 3 ) + trace( "warning: bad line "+i+": "+lines[i] ); + continue; + } + 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 ); + + if ( ( opFound.flags & OP_VERSION2 ) && version<2 ) + { + _error = "error: opcode requires version 2."; + break; + } + + if ( ( opFound.flags & OP_VERT_ONLY ) && isFrag ) + { + _error = "error: opcode is only allowed in vertex programs."; + 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; + + // will match both syntax + regs = line.match( /vc\[([vof][acostdip]?)(\d*)?(\.[xyzw](\+\d{1,3})?)?\](\.[xyzw]{1,4})?|([vof][acostdip]?)(\d*)?(\.[xyzw]{1,4})?/gi ); + + if ( !regs || 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 && 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 ); + if ( !res ) + { + _error = "error: could not parse operand "+j+" ("+regs[j]+")."; + badreg = true; + break; + } + var regFound:Register = REGMAP[ res[ 0 ] ]; + + // if debug is enabled, output the registers + if ( debugEnabled ) + trace( regFound ); + + if ( regFound == null ) + { + _error = "error: could not find register name for 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 == null ? 0 : opts.length; + var bias:Number = 0; + for ( k = 0; k Date: Mon, 2 Feb 2015 18:44:43 +0530 Subject: [PATCH 4/9] Description: Changing copyright header. Models changed: None Docs changed: None Dev/QA notes: None Bugs fixed: None Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 56e0071..3ce9335 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -1,5 +1,5 @@ /* -Copyright (c) 2011, Adobe Systems Incorporated +Copyright (c) 2015, Adobe Systems Incorporated All rights reserved. Redistribution and use in source and binary forms, with or without From d57019cee9179583c52c6bb637b2e93bb9dfb053 Mon Sep 17 00:00:00 2001 From: Mayank Bhagya Date: Thu, 5 Feb 2015 16:58:16 +0530 Subject: [PATCH 5/9] Description: Fixing package name Docs changed: None Dev/QA notes: None Bugs fixed: None Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 3ce9335..2ba970e 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -29,7 +29,7 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -package com.adobe.utils.extended +package com.adobe.utils.v3 { // =========================================================================== // Imports From 91c6f95b5e627916641e65c1459cc756dabb9bc1 Mon Sep 17 00:00:00 2001 From: Mayank Bhagya Date: Wed, 18 Mar 2015 14:07:57 +0530 Subject: [PATCH 6/9] Description: Increasing opcode limit to 4096. Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 2ba970e..8effbb9 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -561,7 +561,7 @@ package com.adobe.utils.v3 private static const SAMPLEMAP:Dictionary = new Dictionary(); private static const MAX_NESTING:int = 4; - private static const MAX_OPCODES:int = 2048; + private static const MAX_OPCODES:int = 4096; private static const FRAGMENT:String = "fragment"; private static const VERTEX:String = "vertex"; From 484f5d7f1217dbbe5a39ef0aaed20f9370123f42 Mon Sep 17 00:00:00 2001 From: Mayank Bhagya Date: Sun, 19 Apr 2015 14:49:13 +0530 Subject: [PATCH 7/9] Description: Renaming DXT1 and DXT5 samplers to COMPRESSED and COMPRESSEDALPHA respectively Docs changed: None Dev/QA notes: None Bugs fixed: None Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 8effbb9..1b55d4d 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -527,8 +527,8 @@ package com.adobe.utils.v3 SAMPLEMAP[ RGBA ] = new Sampler( RGBA, SAMPLER_TYPE_SHIFT, 0 ); - SAMPLEMAP[ DXT1 ] = new Sampler( DXT1, SAMPLER_TYPE_SHIFT, 1 ); - SAMPLEMAP[ DXT5 ] = new Sampler( DXT5, SAMPLER_TYPE_SHIFT, 2 ); + SAMPLEMAP[ COMPRESSED ] = new Sampler( COMPRESSED, SAMPLER_TYPE_SHIFT, 1 ); + SAMPLEMAP[ COMPRESSEDALPHA ] = new Sampler( COMPRESSEDALPHA, SAMPLER_TYPE_SHIFT, 2 ); SAMPLEMAP[ VIDEO ] = new Sampler( VIDEO, SAMPLER_TYPE_SHIFT, 3 ); SAMPLEMAP[ D2 ] = new Sampler( D2, SAMPLER_DIM_SHIFT, 0 ); SAMPLEMAP[ D3 ] = new Sampler( D3, SAMPLER_DIM_SHIFT, 2 ); @@ -670,8 +670,8 @@ package com.adobe.utils.v3 private static const REPEAT_U_CLAMP_V:String = "repeat_u_clamp_v"; //Introduced by Flash 13 private static const CLAMP_U_REPEAT_V:String = "clamp_u_repeat_v"; //Introduced by Flash 13 private static const RGBA:String = "rgba"; - private static const DXT1:String = "dxt1"; - private static const DXT5:String = "dxt5"; + private static const COMPRESSED:String = "compressed"; + private static const COMPRESSEDALPHA:String = "compressedalpha"; private static const VIDEO:String = "video"; } } From b230ab9cd62c58a5aee5f218958028f2223b635f Mon Sep 17 00:00:00 2001 From: Mayank Bhagya Date: Mon, 27 Apr 2015 12:31:16 +0530 Subject: [PATCH 8/9] Description: Re-adding 'DXT1' and 'DXT5' samplers for backward compatibility sake Bugs fixed: None Reviewer: @govindag --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 1b55d4d..7e10e21 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -529,6 +529,8 @@ package com.adobe.utils.v3 SAMPLEMAP[ RGBA ] = new Sampler( RGBA, SAMPLER_TYPE_SHIFT, 0 ); SAMPLEMAP[ COMPRESSED ] = new Sampler( COMPRESSED, SAMPLER_TYPE_SHIFT, 1 ); SAMPLEMAP[ COMPRESSEDALPHA ] = new Sampler( COMPRESSEDALPHA, SAMPLER_TYPE_SHIFT, 2 ); + SAMPLEMAP[ DXT1 ] = new Sampler( DXT1, SAMPLER_TYPE_SHIFT, 1 ); + SAMPLEMAP[ DXT5 ] = new Sampler( DXT5, SAMPLER_TYPE_SHIFT, 2 ); SAMPLEMAP[ VIDEO ] = new Sampler( VIDEO, SAMPLER_TYPE_SHIFT, 3 ); SAMPLEMAP[ D2 ] = new Sampler( D2, SAMPLER_DIM_SHIFT, 0 ); SAMPLEMAP[ D3 ] = new Sampler( D3, SAMPLER_DIM_SHIFT, 2 ); @@ -672,6 +674,8 @@ package com.adobe.utils.v3 private static const RGBA:String = "rgba"; private static const COMPRESSED:String = "compressed"; private static const COMPRESSEDALPHA:String = "compressedalpha"; + private static const DXT1:String = "dxt1"; + private static const DXT5:String = "dxt5"; private static const VIDEO:String = "video"; } } From 3e77294e7728a829f897d0c1c38cd4f07516d50c Mon Sep 17 00:00:00 2001 From: rhy_thm Date: Wed, 18 Nov 2015 10:48:11 +0530 Subject: [PATCH 9/9] changes in agalminiassembler for instanced drawing feature --- src/com/adobe/utils/v3/AGALMiniAssembler.as | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/com/adobe/utils/v3/AGALMiniAssembler.as b/src/com/adobe/utils/v3/AGALMiniAssembler.as index 7e10e21..fd67840 100644 --- a/src/com/adobe/utils/v3/AGALMiniAssembler.as +++ b/src/com/adobe/utils/v3/AGALMiniAssembler.as @@ -189,7 +189,7 @@ package com.adobe.utils.v3 var regs:Array; // will match both syntax - regs = line.match( /vc\[([vof][acostdip]?)(\d*)?(\.[xyzw](\+\d{1,3})?)?\](\.[xyzw]{1,4})?|([vof][acostdip]?)(\d*)?(\.[xyzw]{1,4})?/gi ); + regs = line.match( /vc\[([vofi][acostdip]?[d]?)(\d*)?((\.[xyzw])?(\+\d{1,3})?)?\](\.[xyzw]{1,4})?|([vofi][acostdip]?[d]?)(\d*)?(\.[xyzw]{1,4})?/gi ); if ( !regs || regs.length != opFound.numRegister ) { @@ -214,7 +214,7 @@ package com.adobe.utils.v3 isRelative = true; } - var res:Array = regs[j].match( /^\b[A-Za-z]{1,2}/ig ); + var res:Array = regs[j].match( /^\b[A-Za-z]{1,3}/ig ); if ( !res ) { _error = "error: could not parse operand "+j+" ("+regs[j]+")."; @@ -315,8 +315,8 @@ package com.adobe.utils.v3 if ( isRelative ) { - var relname:Array = relreg[0].match( /[A-Za-z]{1,2}/ig ); - var regFoundRel:Register = REGMAP[ relname[0]]; + var relname:Array = relreg[0].match( /[A-Za-z]{1,3}/ig ); + var regFoundRel:Register = REGMAP[ relname[0]]; if ( regFoundRel == null ) { _error = "error: bad index register"; @@ -466,6 +466,7 @@ package com.adobe.utils.v3 REGMAP[ FS ] = new Register( FS, "texture sampler", 0x5, ignorelimits?1024:7, REG_FRAG | REG_READ ); REGMAP[ FO ] = new Register( FO, "fragment output", 0x3, ignorelimits?1024:(version==1?0:3), REG_FRAG | REG_WRITE ); REGMAP[ FD ] = new Register( FD, "fragment depth output",0x6, ignorelimits?1024:(version==1?-1:0), REG_FRAG | REG_WRITE ); + REGMAP[ IID ] = new Register( IID,"instance id", 0x7, ignorelimits?1024:0, REG_VERT | REG_READ ); // aliases REGMAP[ "op" ] = REGMAP[ VO ]; @@ -647,7 +648,8 @@ package com.adobe.utils.v3 private static const FT:String = "ft"; private static const FS:String = "fs"; private static const FO:String = "fo"; - private static const FD:String = "fd"; + private static const FD:String = "fd"; + private static const IID:String = "iid"; // samplers private static const D2:String = "2d";