Comparing version 0.4.4 to 0.4.5
@@ -1,2 +0,795 @@ | ||
const t=0,e=1,n=2,i=3,s=0,a=0,r=2,o=0,l=1,f=160,U=161,h=162,c=163,_=166,p=0,g=1,y=0,x=1,u=2,b=3,d=4,w=5,m=6,D=7,B=8,L=9,v=10,A=11,k=12,O=13,S=14,V=15,I=16,T=17,E=18,F=0,P=1,C=2,z=3,M=4,W=5,N=6,j=7,H=8,K=9,X=10,R=11,Y=0,q=1,G=2,J=13,Q=14,Z=15,$=128,tt=64,et=32,nt=16,it=0,st=1,at=2,rt=3,ot=4,lt=5,ft=6,Ut=7,ht=8,ct=9,_t=10,pt=13,gt=14,yt=15,xt=16,ut=17,bt=20,dt=21,wt=22,mt=23,Dt=24,Bt=27,Lt=28,vt=29,At=30,kt=31,Ot=34,St=35,Vt=36,It=37,Tt=38,Et=41,Ft=42,Pt=43,Ct=44,zt=45,Mt=48,Wt=49,Nt=50,jt=58,Ht=59,Kt=62,Xt=63,Rt=64,Yt=65,qt=68,Gt=69,Jt=70,Qt=71,Zt=74,$t=75,te=76,ee=77,ne=78,ie=81,se=82,ae=83,re=84,oe=85,le=88,fe=89,Ue=90,he=91,ce=92,_e=95,pe=96,ge=97,ye=98,xe=99,ue=100,be=101,de=102,we=103,me=104,De=105,Be=106,Le=107,ve=108,Ae=109,ke=110,Oe=111,Se=112,Ve=113,Ie=114,Te=115,Ee=116,Fe=117,Pe=118,Ce=119,ze=120,Me=121,We=122,Ne=123,je=124,He=125,Ke=126,Xe=127,Re=128,Ye=129,qe=130,Ge=131,Je=132,Qe=133,Ze=134,$e=135,tn=136,en=137,nn=138,sn=139,an=140,rn=141,on=142,ln=143,fn=144,Un=145,hn=146,cn=147,_n=148,pn=149,gn=150,yn=151,xn=152,un=153,bn=154,dn=155,wn=156,mn=157,Dn=158,Bn=159,Ln=160,vn=161,An=162,kn=163,On=164,Sn=165,Vn=166,In=167,Tn=168,En=169,Fn=170,Pn=171,Cn=172,zn=173,Mn=174,Wn=175,Nn=176,jn=177,Hn=178,Kn=179,Xn=180,Rn=181,Yn=182,qn=183,Gn=184,Jn=1000156007,Qn=1000156008,Zn=1000156009,$n=1000156010,ti=1000156011,ei=1000156017,ni=1000156018,ii=1000156019,si=1000156020,ai=1000156021,ri=1000054e3,oi=1000054001,li=1000054002,fi=1000054003,Ui=1000054004,hi=1000054005,ci=1000054006,_i=1000054007,pi=1000066e3,gi=1000066001,yi=1000066002,xi=1000066003,ui=1000066004,bi=1000066005,di=1000066006,wi=1000066007,mi=1000066008,Di=1000066009,Bi=1000066010,Li=1000066011,vi=1000066012,Ai=1000066013,ki=100034e4,Oi=1000340001;class Si{constructor(){this.vkFormat=0,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=0,this.levels=[],this.dataFormatDescriptor=[{vendorId:0,descriptorType:0,descriptorBlockSize:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Vi{constructor(t,e,n,i){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(t.buffer,t.byteOffset+e,n),this._littleEndian=i,this._offset=0}_nextUint8(){const t=this._dataView.getUint8(this._offset);return this._offset+=1,t}_nextUint16(){const t=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,t}_nextUint32(){const t=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,t}_nextUint64(){const t=this._dataView.getUint32(this._offset,this._littleEndian)+2**32*this._dataView.getUint32(this._offset+4,this._littleEndian);return this._offset+=8,t}_nextInt32(){const t=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,t}_skip(t){return this._offset+=t,this}_scan(t,e=0){const n=this._offset;let i=0;for(;this._dataView.getUint8(this._offset)!==e&&i<t;)i++,this._offset++;return i<t&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+n,i)}}const Ii=new Uint8Array([0]),Ti=[171,75,84,88,32,50,48,187,13,10,26,10];function Ei(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t):Buffer.from(t)}function Fi(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}function Pi(t){let e=0;for(const n of t)e+=n.byteLength;const n=new Uint8Array(e);let i=0;for(const e of t)n.set(new Uint8Array(e),i),i+=e.byteLength;return n}function Ci(t){const e=new Uint8Array(t.buffer,t.byteOffset,Ti.length);if(e[0]!==Ti[0]||e[1]!==Ti[1]||e[2]!==Ti[2]||e[3]!==Ti[3]||e[4]!==Ti[4]||e[5]!==Ti[5]||e[6]!==Ti[6]||e[7]!==Ti[7]||e[8]!==Ti[8]||e[9]!==Ti[9]||e[10]!==Ti[10]||e[11]!==Ti[11])throw new Error("Missing KTX 2.0 identifier.");const n=new Si,i=17*Uint32Array.BYTES_PER_ELEMENT,s=new Vi(t,Ti.length,i,!0);n.vkFormat=s._nextUint32(),n.typeSize=s._nextUint32(),n.pixelWidth=s._nextUint32(),n.pixelHeight=s._nextUint32(),n.pixelDepth=s._nextUint32(),n.layerCount=s._nextUint32(),n.faceCount=s._nextUint32();const a=s._nextUint32();n.supercompressionScheme=s._nextUint32();const r=s._nextUint32(),o=s._nextUint32(),l=s._nextUint32(),f=s._nextUint32(),U=s._nextUint64(),h=s._nextUint64(),c=new Vi(t,Ti.length+i,3*a*8,!0);for(let e=0;e<a;e++)n.levels.push({levelData:new Uint8Array(t.buffer,t.byteOffset+c._nextUint64(),c._nextUint64()),uncompressedByteLength:c._nextUint64()});const _=new Vi(t,r,o,!0),p={vendorId:_._skip(4)._nextUint16(),descriptorType:_._nextUint16(),versionNumber:_._nextUint16(),descriptorBlockSize:_._nextUint16(),colorModel:_._nextUint8(),colorPrimaries:_._nextUint8(),transferFunction:_._nextUint8(),flags:_._nextUint8(),texelBlockDimension:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],bytesPlane:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],samples:[]},g=(p.descriptorBlockSize/4-6)/4;for(let t=0;t<g;t++){const e={bitOffset:_._nextUint16(),bitLength:_._nextUint8(),channelType:_._nextUint8(),samplePosition:[_._nextUint8(),_._nextUint8(),_._nextUint8(),_._nextUint8()],sampleLower:-Infinity,sampleUpper:Infinity};64&e.channelType?(e.sampleLower=_._nextInt32(),e.sampleUpper=_._nextInt32()):(e.sampleLower=_._nextUint32(),e.sampleUpper=_._nextUint32()),p.samples[t]=e}n.dataFormatDescriptor.length=0,n.dataFormatDescriptor.push(p);const y=new Vi(t,l,f,!0);for(;y._offset<f;){const t=y._nextUint32(),e=y._scan(t),i=Fi(e),s=y._scan(t-e.byteLength);n.keyValue[i]=i.match(/^ktx/i)?Fi(s):s,y._offset%4&&y._skip(4-y._offset%4)}if(h<=0)return n;const x=new Vi(t,U,h,!0),u=x._nextUint16(),b=x._nextUint16(),d=x._nextUint32(),w=x._nextUint32(),m=x._nextUint32(),D=x._nextUint32(),B=[];for(let t=0;t<a;t++)B.push({imageFlags:x._nextUint32(),rgbSliceByteOffset:x._nextUint32(),rgbSliceByteLength:x._nextUint32(),alphaSliceByteOffset:x._nextUint32(),alphaSliceByteLength:x._nextUint32()});const L=U+x._offset,v=L+d,A=v+w,k=A+m,O=new Uint8Array(t.buffer,t.byteOffset+L,d),S=new Uint8Array(t.buffer,t.byteOffset+v,w),V=new Uint8Array(t.buffer,t.byteOffset+A,m),I=new Uint8Array(t.buffer,t.byteOffset+k,D);return n.globalData={endpointCount:u,selectorCount:b,imageDescs:B,endpointsData:O,selectorsData:S,tablesData:V,extendedData:I},n}function zi(){return zi=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(t[i]=n[i])}return t},zi.apply(this,arguments)}const Mi={keepWriter:!1};function Wi(t,e={}){e=zi({},Mi,e);let n=new ArrayBuffer(0);if(t.globalData){const e=new ArrayBuffer(20+5*t.globalData.imageDescs.length*4),i=new DataView(e);i.setUint16(0,t.globalData.endpointCount,!0),i.setUint16(2,t.globalData.selectorCount,!0),i.setUint32(4,t.globalData.endpointsData.byteLength,!0),i.setUint32(8,t.globalData.selectorsData.byteLength,!0),i.setUint32(12,t.globalData.tablesData.byteLength,!0),i.setUint32(16,t.globalData.extendedData.byteLength,!0);for(let e=0;e<t.globalData.imageDescs.length;e++){const n=t.globalData.imageDescs[e];i.setUint32(20+5*e*4+0,n.imageFlags,!0),i.setUint32(20+5*e*4+4,n.rgbSliceByteOffset,!0),i.setUint32(20+5*e*4+8,n.rgbSliceByteLength,!0),i.setUint32(20+5*e*4+12,n.alphaSliceByteOffset,!0),i.setUint32(20+5*e*4+16,n.alphaSliceByteLength,!0)}n=Pi([e,t.globalData.endpointsData,t.globalData.selectorsData,t.globalData.tablesData,t.globalData.extendedData])}const i=[];let s=t.keyValue;e.keepWriter||(s=zi({},t.keyValue,{KTXwriter:"KTX-Parse v0.4.4"}));for(const t in s){const e=s[t],n=Ei(t),a="string"==typeof e?Ei(e):e,r=n.byteLength+1+a.byteLength+1,o=r%4?4-r%4:0;i.push(Pi([new Uint32Array([r]),n,Ii,a,Ii,new Uint8Array(o).fill(0)]))}const a=Pi(i);if(1!==t.dataFormatDescriptor.length||0!==t.dataFormatDescriptor[0].descriptorType)throw new Error("Only BASICFORMAT Data Format Descriptor output supported.");const r=t.dataFormatDescriptor[0],o=new ArrayBuffer(28+16*r.samples.length),l=new DataView(o),f=24+16*r.samples.length;if(l.setUint32(0,o.byteLength,!0),l.setUint16(4,r.vendorId,!0),l.setUint16(6,r.descriptorType,!0),l.setUint16(8,r.versionNumber,!0),l.setUint16(10,f,!0),l.setUint8(12,r.colorModel),l.setUint8(13,r.colorPrimaries),l.setUint8(14,r.transferFunction),l.setUint8(15,r.flags),!Array.isArray(r.texelBlockDimension))throw new Error("texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.");l.setUint8(16,r.texelBlockDimension[0]),l.setUint8(17,r.texelBlockDimension[1]),l.setUint8(18,r.texelBlockDimension[2]),l.setUint8(19,r.texelBlockDimension[3]);for(let t=0;t<8;t++)l.setUint8(20+t,r.bytesPlane[t]);for(let t=0;t<r.samples.length;t++){const e=r.samples[t],n=28+16*t;if(e.channelID)throw new Error("channelID has been renamed to channelType.");l.setUint16(n+0,e.bitOffset,!0),l.setUint8(n+2,e.bitLength),l.setUint8(n+3,e.channelType),l.setUint8(n+4,e.samplePosition[0]),l.setUint8(n+5,e.samplePosition[1]),l.setUint8(n+6,e.samplePosition[2]),l.setUint8(n+7,e.samplePosition[3]),64&e.channelType?(l.setInt32(n+8,e.sampleLower,!0),l.setInt32(n+12,e.sampleUpper,!0)):(l.setUint32(n+8,e.sampleLower,!0),l.setUint32(n+12,e.sampleUpper,!0))}const U=Ti.length+68+3*t.levels.length*8,h=U+o.byteLength;let c=n.byteLength>0?h+a.byteLength:0;c%8&&(c+=8-c%8);const _=[],p=new DataView(new ArrayBuffer(3*t.levels.length*8));let g=(c||h+a.byteLength)+n.byteLength;for(let e=0;e<t.levels.length;e++){const n=t.levels[e];_.push(n.levelData),p.setBigUint64(24*e+0,BigInt(g),!0),p.setBigUint64(24*e+8,BigInt(n.levelData.byteLength),!0),p.setBigUint64(24*e+16,BigInt(n.uncompressedByteLength),!0),g+=n.levelData.byteLength}const y=new ArrayBuffer(68),x=new DataView(y);return x.setUint32(0,t.vkFormat,!0),x.setUint32(4,t.typeSize,!0),x.setUint32(8,t.pixelWidth,!0),x.setUint32(12,t.pixelHeight,!0),x.setUint32(16,t.pixelDepth,!0),x.setUint32(20,t.layerCount,!0),x.setUint32(24,t.faceCount,!0),x.setUint32(28,t.levels.length,!0),x.setUint32(32,t.supercompressionScheme,!0),x.setUint32(36,U,!0),x.setUint32(40,o.byteLength,!0),x.setUint32(44,h,!0),x.setUint32(48,a.byteLength,!0),x.setBigUint64(52,BigInt(n.byteLength>0?c:0),!0),x.setBigUint64(60,BigInt(n.byteLength),!0),new Uint8Array(Pi([new Uint8Array(Ti).buffer,y,p.buffer,o,a,c>0?new ArrayBuffer(c-(h+a.byteLength)):new ArrayBuffer(0),n,..._]))}export{Z as KHR_DF_CHANNEL_RGBSDA_ALPHA,G as KHR_DF_CHANNEL_RGBSDA_BLUE,Q as KHR_DF_CHANNEL_RGBSDA_DEPTH,q as KHR_DF_CHANNEL_RGBSDA_GREEN,Y as KHR_DF_CHANNEL_RGBSDA_RED,J as KHR_DF_CHANNEL_RGBSDA_STENCIL,g as KHR_DF_FLAG_ALPHA_PREMULTIPLIED,p as KHR_DF_FLAG_ALPHA_STRAIGHT,s as KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT,h as KHR_DF_MODEL_ASTC,f as KHR_DF_MODEL_ETC1,c as KHR_DF_MODEL_ETC1S,U as KHR_DF_MODEL_ETC2,l as KHR_DF_MODEL_RGBSDA,_ as KHR_DF_MODEL_UASTC,o as KHR_DF_MODEL_UNSPECIFIED,N as KHR_DF_PRIMARIES_ACES,j as KHR_DF_PRIMARIES_ACESCC,R as KHR_DF_PRIMARIES_ADOBERGB,M as KHR_DF_PRIMARIES_BT2020,C as KHR_DF_PRIMARIES_BT601_EBU,z as KHR_DF_PRIMARIES_BT601_SMPTE,P as KHR_DF_PRIMARIES_BT709,W as KHR_DF_PRIMARIES_CIEXYZ,X as KHR_DF_PRIMARIES_DISPLAYP3,H as KHR_DF_PRIMARIES_NTSC1953,K as KHR_DF_PRIMARIES_PAL525,F as KHR_DF_PRIMARIES_UNSPECIFIED,et as KHR_DF_SAMPLE_DATATYPE_EXPONENT,$ as KHR_DF_SAMPLE_DATATYPE_FLOAT,nt as KHR_DF_SAMPLE_DATATYPE_LINEAR,tt as KHR_DF_SAMPLE_DATATYPE_SIGNED,I as KHR_DF_TRANSFER_ACESCC,T as KHR_DF_TRANSFER_ACESCCT,E as KHR_DF_TRANSFER_ADOBERGB,D as KHR_DF_TRANSFER_BT1886,k as KHR_DF_TRANSFER_DCIP3,L as KHR_DF_TRANSFER_HLG_EOTF,B as KHR_DF_TRANSFER_HLG_OETF,b as KHR_DF_TRANSFER_ITU,x as KHR_DF_TRANSFER_LINEAR,d as KHR_DF_TRANSFER_NTSC,S as KHR_DF_TRANSFER_PAL625_EOTF,O as KHR_DF_TRANSFER_PAL_OETF,v as KHR_DF_TRANSFER_PQ_EOTF,A as KHR_DF_TRANSFER_PQ_OETF,w as KHR_DF_TRANSFER_SLOG,m as KHR_DF_TRANSFER_SLOG2,u as KHR_DF_TRANSFER_SRGB,V as KHR_DF_TRANSFER_ST240,y as KHR_DF_TRANSFER_UNSPECIFIED,a as KHR_DF_VENDORID_KHRONOS,r as KHR_DF_VERSION,e as KHR_SUPERCOMPRESSION_BASISLZ,t as KHR_SUPERCOMPRESSION_NONE,i as KHR_SUPERCOMPRESSION_ZLIB,n as KHR_SUPERCOMPRESSION_ZSTD,Si as KTX2Container,ht as VK_FORMAT_A1R5G5B5_UNORM_PACK16,Gt as VK_FORMAT_A2B10G10R10_SINT_PACK32,Yt as VK_FORMAT_A2B10G10R10_SNORM_PACK32,qt as VK_FORMAT_A2B10G10R10_UINT_PACK32,Rt as VK_FORMAT_A2B10G10R10_UNORM_PACK32,Xt as VK_FORMAT_A2R10G10B10_SINT_PACK32,Ht as VK_FORMAT_A2R10G10B10_SNORM_PACK32,Kt as VK_FORMAT_A2R10G10B10_UINT_PACK32,jt as VK_FORMAT_A2R10G10B10_UNORM_PACK32,Oi as VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT,ki as VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT,Li as VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT,Xn as VK_FORMAT_ASTC_10x10_SRGB_BLOCK,Kn as VK_FORMAT_ASTC_10x10_UNORM_BLOCK,mi as VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT,Mn as VK_FORMAT_ASTC_10x5_SRGB_BLOCK,zn as VK_FORMAT_ASTC_10x5_UNORM_BLOCK,Di as VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT,Nn as VK_FORMAT_ASTC_10x6_SRGB_BLOCK,Wn as VK_FORMAT_ASTC_10x6_UNORM_BLOCK,Bi as VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT,Hn as VK_FORMAT_ASTC_10x8_SRGB_BLOCK,jn as VK_FORMAT_ASTC_10x8_UNORM_BLOCK,vi as VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT,Yn as VK_FORMAT_ASTC_12x10_SRGB_BLOCK,Rn as VK_FORMAT_ASTC_12x10_UNORM_BLOCK,Ai as VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT,Gn as VK_FORMAT_ASTC_12x12_SRGB_BLOCK,qn as VK_FORMAT_ASTC_12x12_UNORM_BLOCK,pi as VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT,Dn as VK_FORMAT_ASTC_4x4_SRGB_BLOCK,mn as VK_FORMAT_ASTC_4x4_UNORM_BLOCK,gi as VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT,Ln as VK_FORMAT_ASTC_5x4_SRGB_BLOCK,Bn as VK_FORMAT_ASTC_5x4_UNORM_BLOCK,yi as VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT,An as VK_FORMAT_ASTC_5x5_SRGB_BLOCK,vn as VK_FORMAT_ASTC_5x5_UNORM_BLOCK,xi as VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT,On as VK_FORMAT_ASTC_6x5_SRGB_BLOCK,kn as VK_FORMAT_ASTC_6x5_UNORM_BLOCK,ui as VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT,Vn as VK_FORMAT_ASTC_6x6_SRGB_BLOCK,Sn as VK_FORMAT_ASTC_6x6_UNORM_BLOCK,bi as VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT,Tn as VK_FORMAT_ASTC_8x5_SRGB_BLOCK,In as VK_FORMAT_ASTC_8x5_UNORM_BLOCK,di as VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT,Fn as VK_FORMAT_ASTC_8x6_SRGB_BLOCK,En as VK_FORMAT_ASTC_8x6_UNORM_BLOCK,wi as VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT,Cn as VK_FORMAT_ASTC_8x8_SRGB_BLOCK,Pn as VK_FORMAT_ASTC_8x8_UNORM_BLOCK,We as VK_FORMAT_B10G11R11_UFLOAT_PACK32,ti as VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16,ai as VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16,rt as VK_FORMAT_B4G4R4A4_UNORM_PACK16,Ut as VK_FORMAT_B5G5R5A1_UNORM_PACK16,lt as VK_FORMAT_B5G6R5_UNORM_PACK16,Wt as VK_FORMAT_B8G8R8A8_SINT,zt as VK_FORMAT_B8G8R8A8_SNORM,Nt as VK_FORMAT_B8G8R8A8_SRGB,Mt as VK_FORMAT_B8G8R8A8_UINT,Ct as VK_FORMAT_B8G8R8A8_UNORM,St as VK_FORMAT_B8G8R8_SINT,kt as VK_FORMAT_B8G8R8_SNORM,Vt as VK_FORMAT_B8G8R8_SRGB,Ot as VK_FORMAT_B8G8R8_UINT,At as VK_FORMAT_B8G8R8_UNORM,Ze as VK_FORMAT_BC1_RGBA_SRGB_BLOCK,Qe as VK_FORMAT_BC1_RGBA_UNORM_BLOCK,Je as VK_FORMAT_BC1_RGB_SRGB_BLOCK,Ge as VK_FORMAT_BC1_RGB_UNORM_BLOCK,tn as VK_FORMAT_BC2_SRGB_BLOCK,$e as VK_FORMAT_BC2_UNORM_BLOCK,nn as VK_FORMAT_BC3_SRGB_BLOCK,en as VK_FORMAT_BC3_UNORM_BLOCK,an as VK_FORMAT_BC4_SNORM_BLOCK,sn as VK_FORMAT_BC4_UNORM_BLOCK,on as VK_FORMAT_BC5_SNORM_BLOCK,rn as VK_FORMAT_BC5_UNORM_BLOCK,fn as VK_FORMAT_BC6H_SFLOAT_BLOCK,ln as VK_FORMAT_BC6H_UFLOAT_BLOCK,hn as VK_FORMAT_BC7_SRGB_BLOCK,Un as VK_FORMAT_BC7_UNORM_BLOCK,je as VK_FORMAT_D16_UNORM,Re as VK_FORMAT_D16_UNORM_S8_UINT,Ye as VK_FORMAT_D24_UNORM_S8_UINT,Ke as VK_FORMAT_D32_SFLOAT,qe as VK_FORMAT_D32_SFLOAT_S8_UINT,Ne as VK_FORMAT_E5B9G9R9_UFLOAT_PACK32,wn as VK_FORMAT_EAC_R11G11_SNORM_BLOCK,dn as VK_FORMAT_EAC_R11G11_UNORM_BLOCK,bn as VK_FORMAT_EAC_R11_SNORM_BLOCK,un as VK_FORMAT_EAC_R11_UNORM_BLOCK,gn as VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,pn as VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,xn as VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,yn as VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,_n as VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK,cn as VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK,$n as VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16,si as VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16,Ui as VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG,ri as VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG,hi as VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG,oi as VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG,ci as VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG,li as VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG,_i as VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG,fi as VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG,Zn as VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16,Qn as VK_FORMAT_R10X6G10X6_UNORM_2PACK16,Jn as VK_FORMAT_R10X6_UNORM_PACK16,ii as VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16,ni as VK_FORMAT_R12X4G12X4_UNORM_2PACK16,ei as VK_FORMAT_R12X4_UNORM_PACK16,ge as VK_FORMAT_R16G16B16A16_SFLOAT,pe as VK_FORMAT_R16G16B16A16_SINT,ce as VK_FORMAT_R16G16B16A16_SNORM,_e as VK_FORMAT_R16G16B16A16_UINT,he as VK_FORMAT_R16G16B16A16_UNORM,Ue as VK_FORMAT_R16G16B16_SFLOAT,fe as VK_FORMAT_R16G16B16_SINT,oe as VK_FORMAT_R16G16B16_SNORM,le as VK_FORMAT_R16G16B16_UINT,re as VK_FORMAT_R16G16B16_UNORM,ae as VK_FORMAT_R16G16_SFLOAT,se as VK_FORMAT_R16G16_SINT,ne as VK_FORMAT_R16G16_SNORM,ie as VK_FORMAT_R16G16_UINT,ee as VK_FORMAT_R16G16_UNORM,te as VK_FORMAT_R16_SFLOAT,$t as VK_FORMAT_R16_SINT,Qt as VK_FORMAT_R16_SNORM,Zt as VK_FORMAT_R16_UINT,Jt as VK_FORMAT_R16_UNORM,Ae as VK_FORMAT_R32G32B32A32_SFLOAT,ve as VK_FORMAT_R32G32B32A32_SINT,Le as VK_FORMAT_R32G32B32A32_UINT,Be as VK_FORMAT_R32G32B32_SFLOAT,De as VK_FORMAT_R32G32B32_SINT,me as VK_FORMAT_R32G32B32_UINT,we as VK_FORMAT_R32G32_SFLOAT,de as VK_FORMAT_R32G32_SINT,be as VK_FORMAT_R32G32_UINT,ue as VK_FORMAT_R32_SFLOAT,xe as VK_FORMAT_R32_SINT,ye as VK_FORMAT_R32_UINT,at as VK_FORMAT_R4G4B4A4_UNORM_PACK16,st as VK_FORMAT_R4G4_UNORM_PACK8,ft as VK_FORMAT_R5G5B5A1_UNORM_PACK16,ot as VK_FORMAT_R5G6B5_UNORM_PACK16,Me as VK_FORMAT_R64G64B64A64_SFLOAT,ze as VK_FORMAT_R64G64B64A64_SINT,Ce as VK_FORMAT_R64G64B64A64_UINT,Pe as VK_FORMAT_R64G64B64_SFLOAT,Fe as VK_FORMAT_R64G64B64_SINT,Ee as VK_FORMAT_R64G64B64_UINT,Te as VK_FORMAT_R64G64_SFLOAT,Ie as VK_FORMAT_R64G64_SINT,Ve as VK_FORMAT_R64G64_UINT,Se as VK_FORMAT_R64_SFLOAT,Oe as VK_FORMAT_R64_SINT,ke as VK_FORMAT_R64_UINT,Ft as VK_FORMAT_R8G8B8A8_SINT,Tt as VK_FORMAT_R8G8B8A8_SNORM,Pt as VK_FORMAT_R8G8B8A8_SRGB,Et as VK_FORMAT_R8G8B8A8_UINT,It as VK_FORMAT_R8G8B8A8_UNORM,Lt as VK_FORMAT_R8G8B8_SINT,Dt as VK_FORMAT_R8G8B8_SNORM,vt as VK_FORMAT_R8G8B8_SRGB,Bt as VK_FORMAT_R8G8B8_UINT,mt as VK_FORMAT_R8G8B8_UNORM,dt as VK_FORMAT_R8G8_SINT,ut as VK_FORMAT_R8G8_SNORM,wt as VK_FORMAT_R8G8_SRGB,bt as VK_FORMAT_R8G8_UINT,xt as VK_FORMAT_R8G8_UNORM,gt as VK_FORMAT_R8_SINT,_t as VK_FORMAT_R8_SNORM,yt as VK_FORMAT_R8_SRGB,pt as VK_FORMAT_R8_UINT,ct as VK_FORMAT_R8_UNORM,Xe as VK_FORMAT_S8_UINT,it as VK_FORMAT_UNDEFINED,He as VK_FORMAT_X8_D24_UNORM_PACK32,Ci as read,Wi as write}; | ||
/////////////////////////////////////////////////// | ||
// KTX2 Header. | ||
/////////////////////////////////////////////////// | ||
const KHR_SUPERCOMPRESSION_NONE = 0; | ||
const KHR_SUPERCOMPRESSION_BASISLZ = 1; | ||
const KHR_SUPERCOMPRESSION_ZSTD = 2; | ||
const KHR_SUPERCOMPRESSION_ZLIB = 3; /////////////////////////////////////////////////// | ||
// Data Format Descriptor (DFD). | ||
/////////////////////////////////////////////////// | ||
const KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT = 0; | ||
const KHR_DF_VENDORID_KHRONOS = 0; | ||
const KHR_DF_VERSION = 2; | ||
const KHR_DF_MODEL_UNSPECIFIED = 0; | ||
const KHR_DF_MODEL_RGBSDA = 1; // ... | ||
const KHR_DF_MODEL_ETC1 = 160; | ||
const KHR_DF_MODEL_ETC2 = 161; | ||
const KHR_DF_MODEL_ASTC = 162; | ||
const KHR_DF_MODEL_ETC1S = 163; | ||
const KHR_DF_MODEL_UASTC = 166; | ||
const KHR_DF_FLAG_ALPHA_STRAIGHT = 0; | ||
const KHR_DF_FLAG_ALPHA_PREMULTIPLIED = 1; | ||
const KHR_DF_TRANSFER_UNSPECIFIED = 0; | ||
const KHR_DF_TRANSFER_LINEAR = 1; | ||
const KHR_DF_TRANSFER_SRGB = 2; | ||
const KHR_DF_TRANSFER_ITU = 3; | ||
const KHR_DF_TRANSFER_NTSC = 4; | ||
const KHR_DF_TRANSFER_SLOG = 5; | ||
const KHR_DF_TRANSFER_SLOG2 = 6; | ||
const KHR_DF_TRANSFER_BT1886 = 7; | ||
const KHR_DF_TRANSFER_HLG_OETF = 8; | ||
const KHR_DF_TRANSFER_HLG_EOTF = 9; | ||
const KHR_DF_TRANSFER_PQ_EOTF = 10; | ||
const KHR_DF_TRANSFER_PQ_OETF = 11; | ||
const KHR_DF_TRANSFER_DCIP3 = 12; | ||
const KHR_DF_TRANSFER_PAL_OETF = 13; | ||
const KHR_DF_TRANSFER_PAL625_EOTF = 14; | ||
const KHR_DF_TRANSFER_ST240 = 15; | ||
const KHR_DF_TRANSFER_ACESCC = 16; | ||
const KHR_DF_TRANSFER_ACESCCT = 17; | ||
const KHR_DF_TRANSFER_ADOBERGB = 18; | ||
const KHR_DF_PRIMARIES_UNSPECIFIED = 0; | ||
const KHR_DF_PRIMARIES_BT709 = 1; | ||
const KHR_DF_PRIMARIES_BT601_EBU = 2; | ||
const KHR_DF_PRIMARIES_BT601_SMPTE = 3; | ||
const KHR_DF_PRIMARIES_BT2020 = 4; | ||
const KHR_DF_PRIMARIES_CIEXYZ = 5; | ||
const KHR_DF_PRIMARIES_ACES = 6; | ||
const KHR_DF_PRIMARIES_ACESCC = 7; | ||
const KHR_DF_PRIMARIES_NTSC1953 = 8; | ||
const KHR_DF_PRIMARIES_PAL525 = 9; | ||
const KHR_DF_PRIMARIES_DISPLAYP3 = 10; | ||
const KHR_DF_PRIMARIES_ADOBERGB = 11; | ||
const KHR_DF_CHANNEL_RGBSDA_RED = 0; | ||
const KHR_DF_CHANNEL_RGBSDA_GREEN = 1; | ||
const KHR_DF_CHANNEL_RGBSDA_BLUE = 2; | ||
const KHR_DF_CHANNEL_RGBSDA_STENCIL = 13; | ||
const KHR_DF_CHANNEL_RGBSDA_DEPTH = 14; | ||
const KHR_DF_CHANNEL_RGBSDA_ALPHA = 15; | ||
const KHR_DF_SAMPLE_DATATYPE_FLOAT = 0x80; | ||
const KHR_DF_SAMPLE_DATATYPE_SIGNED = 0x40; | ||
const KHR_DF_SAMPLE_DATATYPE_EXPONENT = 0x20; | ||
const KHR_DF_SAMPLE_DATATYPE_LINEAR = 0x10; /////////////////////////////////////////////////// | ||
// VK FORMAT. | ||
/////////////////////////////////////////////////// | ||
const VK_FORMAT_UNDEFINED = 0; | ||
const VK_FORMAT_R4G4_UNORM_PACK8 = 1; | ||
const VK_FORMAT_R4G4B4A4_UNORM_PACK16 = 2; | ||
const VK_FORMAT_B4G4R4A4_UNORM_PACK16 = 3; | ||
const VK_FORMAT_R5G6B5_UNORM_PACK16 = 4; | ||
const VK_FORMAT_B5G6R5_UNORM_PACK16 = 5; | ||
const VK_FORMAT_R5G5B5A1_UNORM_PACK16 = 6; | ||
const VK_FORMAT_B5G5R5A1_UNORM_PACK16 = 7; | ||
const VK_FORMAT_A1R5G5B5_UNORM_PACK16 = 8; | ||
const VK_FORMAT_R8_UNORM = 9; | ||
const VK_FORMAT_R8_SNORM = 10; | ||
const VK_FORMAT_R8_UINT = 13; | ||
const VK_FORMAT_R8_SINT = 14; | ||
const VK_FORMAT_R8_SRGB = 15; | ||
const VK_FORMAT_R8G8_UNORM = 16; | ||
const VK_FORMAT_R8G8_SNORM = 17; | ||
const VK_FORMAT_R8G8_UINT = 20; | ||
const VK_FORMAT_R8G8_SINT = 21; | ||
const VK_FORMAT_R8G8_SRGB = 22; | ||
const VK_FORMAT_R8G8B8_UNORM = 23; | ||
const VK_FORMAT_R8G8B8_SNORM = 24; | ||
const VK_FORMAT_R8G8B8_UINT = 27; | ||
const VK_FORMAT_R8G8B8_SINT = 28; | ||
const VK_FORMAT_R8G8B8_SRGB = 29; | ||
const VK_FORMAT_B8G8R8_UNORM = 30; | ||
const VK_FORMAT_B8G8R8_SNORM = 31; | ||
const VK_FORMAT_B8G8R8_UINT = 34; | ||
const VK_FORMAT_B8G8R8_SINT = 35; | ||
const VK_FORMAT_B8G8R8_SRGB = 36; | ||
const VK_FORMAT_R8G8B8A8_UNORM = 37; | ||
const VK_FORMAT_R8G8B8A8_SNORM = 38; | ||
const VK_FORMAT_R8G8B8A8_UINT = 41; | ||
const VK_FORMAT_R8G8B8A8_SINT = 42; | ||
const VK_FORMAT_R8G8B8A8_SRGB = 43; | ||
const VK_FORMAT_B8G8R8A8_UNORM = 44; | ||
const VK_FORMAT_B8G8R8A8_SNORM = 45; | ||
const VK_FORMAT_B8G8R8A8_UINT = 48; | ||
const VK_FORMAT_B8G8R8A8_SINT = 49; | ||
const VK_FORMAT_B8G8R8A8_SRGB = 50; | ||
const VK_FORMAT_A2R10G10B10_UNORM_PACK32 = 58; | ||
const VK_FORMAT_A2R10G10B10_SNORM_PACK32 = 59; | ||
const VK_FORMAT_A2R10G10B10_UINT_PACK32 = 62; | ||
const VK_FORMAT_A2R10G10B10_SINT_PACK32 = 63; | ||
const VK_FORMAT_A2B10G10R10_UNORM_PACK32 = 64; | ||
const VK_FORMAT_A2B10G10R10_SNORM_PACK32 = 65; | ||
const VK_FORMAT_A2B10G10R10_UINT_PACK32 = 68; | ||
const VK_FORMAT_A2B10G10R10_SINT_PACK32 = 69; | ||
const VK_FORMAT_R16_UNORM = 70; | ||
const VK_FORMAT_R16_SNORM = 71; | ||
const VK_FORMAT_R16_UINT = 74; | ||
const VK_FORMAT_R16_SINT = 75; | ||
const VK_FORMAT_R16_SFLOAT = 76; | ||
const VK_FORMAT_R16G16_UNORM = 77; | ||
const VK_FORMAT_R16G16_SNORM = 78; | ||
const VK_FORMAT_R16G16_UINT = 81; | ||
const VK_FORMAT_R16G16_SINT = 82; | ||
const VK_FORMAT_R16G16_SFLOAT = 83; | ||
const VK_FORMAT_R16G16B16_UNORM = 84; | ||
const VK_FORMAT_R16G16B16_SNORM = 85; | ||
const VK_FORMAT_R16G16B16_UINT = 88; | ||
const VK_FORMAT_R16G16B16_SINT = 89; | ||
const VK_FORMAT_R16G16B16_SFLOAT = 90; | ||
const VK_FORMAT_R16G16B16A16_UNORM = 91; | ||
const VK_FORMAT_R16G16B16A16_SNORM = 92; | ||
const VK_FORMAT_R16G16B16A16_UINT = 95; | ||
const VK_FORMAT_R16G16B16A16_SINT = 96; | ||
const VK_FORMAT_R16G16B16A16_SFLOAT = 97; | ||
const VK_FORMAT_R32_UINT = 98; | ||
const VK_FORMAT_R32_SINT = 99; | ||
const VK_FORMAT_R32_SFLOAT = 100; | ||
const VK_FORMAT_R32G32_UINT = 101; | ||
const VK_FORMAT_R32G32_SINT = 102; | ||
const VK_FORMAT_R32G32_SFLOAT = 103; | ||
const VK_FORMAT_R32G32B32_UINT = 104; | ||
const VK_FORMAT_R32G32B32_SINT = 105; | ||
const VK_FORMAT_R32G32B32_SFLOAT = 106; | ||
const VK_FORMAT_R32G32B32A32_UINT = 107; | ||
const VK_FORMAT_R32G32B32A32_SINT = 108; | ||
const VK_FORMAT_R32G32B32A32_SFLOAT = 109; | ||
const VK_FORMAT_R64_UINT = 110; | ||
const VK_FORMAT_R64_SINT = 111; | ||
const VK_FORMAT_R64_SFLOAT = 112; | ||
const VK_FORMAT_R64G64_UINT = 113; | ||
const VK_FORMAT_R64G64_SINT = 114; | ||
const VK_FORMAT_R64G64_SFLOAT = 115; | ||
const VK_FORMAT_R64G64B64_UINT = 116; | ||
const VK_FORMAT_R64G64B64_SINT = 117; | ||
const VK_FORMAT_R64G64B64_SFLOAT = 118; | ||
const VK_FORMAT_R64G64B64A64_UINT = 119; | ||
const VK_FORMAT_R64G64B64A64_SINT = 120; | ||
const VK_FORMAT_R64G64B64A64_SFLOAT = 121; | ||
const VK_FORMAT_B10G11R11_UFLOAT_PACK32 = 122; | ||
const VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 = 123; | ||
const VK_FORMAT_D16_UNORM = 124; | ||
const VK_FORMAT_X8_D24_UNORM_PACK32 = 125; | ||
const VK_FORMAT_D32_SFLOAT = 126; | ||
const VK_FORMAT_S8_UINT = 127; | ||
const VK_FORMAT_D16_UNORM_S8_UINT = 128; | ||
const VK_FORMAT_D24_UNORM_S8_UINT = 129; | ||
const VK_FORMAT_D32_SFLOAT_S8_UINT = 130; | ||
const VK_FORMAT_BC1_RGB_UNORM_BLOCK = 131; | ||
const VK_FORMAT_BC1_RGB_SRGB_BLOCK = 132; | ||
const VK_FORMAT_BC1_RGBA_UNORM_BLOCK = 133; | ||
const VK_FORMAT_BC1_RGBA_SRGB_BLOCK = 134; | ||
const VK_FORMAT_BC2_UNORM_BLOCK = 135; | ||
const VK_FORMAT_BC2_SRGB_BLOCK = 136; | ||
const VK_FORMAT_BC3_UNORM_BLOCK = 137; | ||
const VK_FORMAT_BC3_SRGB_BLOCK = 138; | ||
const VK_FORMAT_BC4_UNORM_BLOCK = 139; | ||
const VK_FORMAT_BC4_SNORM_BLOCK = 140; | ||
const VK_FORMAT_BC5_UNORM_BLOCK = 141; | ||
const VK_FORMAT_BC5_SNORM_BLOCK = 142; | ||
const VK_FORMAT_BC6H_UFLOAT_BLOCK = 143; | ||
const VK_FORMAT_BC6H_SFLOAT_BLOCK = 144; | ||
const VK_FORMAT_BC7_UNORM_BLOCK = 145; | ||
const VK_FORMAT_BC7_SRGB_BLOCK = 146; | ||
const VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK = 147; | ||
const VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK = 148; | ||
const VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK = 149; | ||
const VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK = 150; | ||
const VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK = 151; | ||
const VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK = 152; | ||
const VK_FORMAT_EAC_R11_UNORM_BLOCK = 153; | ||
const VK_FORMAT_EAC_R11_SNORM_BLOCK = 154; | ||
const VK_FORMAT_EAC_R11G11_UNORM_BLOCK = 155; | ||
const VK_FORMAT_EAC_R11G11_SNORM_BLOCK = 156; | ||
const VK_FORMAT_ASTC_4x4_UNORM_BLOCK = 157; | ||
const VK_FORMAT_ASTC_4x4_SRGB_BLOCK = 158; | ||
const VK_FORMAT_ASTC_5x4_UNORM_BLOCK = 159; | ||
const VK_FORMAT_ASTC_5x4_SRGB_BLOCK = 160; | ||
const VK_FORMAT_ASTC_5x5_UNORM_BLOCK = 161; | ||
const VK_FORMAT_ASTC_5x5_SRGB_BLOCK = 162; | ||
const VK_FORMAT_ASTC_6x5_UNORM_BLOCK = 163; | ||
const VK_FORMAT_ASTC_6x5_SRGB_BLOCK = 164; | ||
const VK_FORMAT_ASTC_6x6_UNORM_BLOCK = 165; | ||
const VK_FORMAT_ASTC_6x6_SRGB_BLOCK = 166; | ||
const VK_FORMAT_ASTC_8x5_UNORM_BLOCK = 167; | ||
const VK_FORMAT_ASTC_8x5_SRGB_BLOCK = 168; | ||
const VK_FORMAT_ASTC_8x6_UNORM_BLOCK = 169; | ||
const VK_FORMAT_ASTC_8x6_SRGB_BLOCK = 170; | ||
const VK_FORMAT_ASTC_8x8_UNORM_BLOCK = 171; | ||
const VK_FORMAT_ASTC_8x8_SRGB_BLOCK = 172; | ||
const VK_FORMAT_ASTC_10x5_UNORM_BLOCK = 173; | ||
const VK_FORMAT_ASTC_10x5_SRGB_BLOCK = 174; | ||
const VK_FORMAT_ASTC_10x6_UNORM_BLOCK = 175; | ||
const VK_FORMAT_ASTC_10x6_SRGB_BLOCK = 176; | ||
const VK_FORMAT_ASTC_10x8_UNORM_BLOCK = 177; | ||
const VK_FORMAT_ASTC_10x8_SRGB_BLOCK = 178; | ||
const VK_FORMAT_ASTC_10x10_UNORM_BLOCK = 179; | ||
const VK_FORMAT_ASTC_10x10_SRGB_BLOCK = 180; | ||
const VK_FORMAT_ASTC_12x10_UNORM_BLOCK = 181; | ||
const VK_FORMAT_ASTC_12x10_SRGB_BLOCK = 182; | ||
const VK_FORMAT_ASTC_12x12_UNORM_BLOCK = 183; | ||
const VK_FORMAT_ASTC_12x12_SRGB_BLOCK = 184; | ||
const VK_FORMAT_R10X6_UNORM_PACK16 = 1000156007; | ||
const VK_FORMAT_R10X6G10X6_UNORM_2PACK16 = 1000156008; | ||
const VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16 = 1000156009; | ||
const VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16 = 1000156010; | ||
const VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16 = 1000156011; | ||
const VK_FORMAT_R12X4_UNORM_PACK16 = 1000156017; | ||
const VK_FORMAT_R12X4G12X4_UNORM_2PACK16 = 1000156018; | ||
const VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16 = 1000156019; | ||
const VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16 = 1000156020; | ||
const VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16 = 1000156021; | ||
const VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG = 1000054000; | ||
const VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG = 1000054001; | ||
const VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG = 1000054002; | ||
const VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG = 1000054003; | ||
const VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG = 1000054004; | ||
const VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG = 1000054005; | ||
const VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG = 1000054006; | ||
const VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG = 1000054007; | ||
const VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT = 1000066000; | ||
const VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT = 1000066001; | ||
const VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT = 1000066002; | ||
const VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT = 1000066003; | ||
const VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT = 1000066004; | ||
const VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT = 1000066005; | ||
const VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT = 1000066006; | ||
const VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT = 1000066007; | ||
const VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT = 1000066008; | ||
const VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT = 1000066009; | ||
const VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT = 1000066010; | ||
const VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT = 1000066011; | ||
const VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT = 1000066012; | ||
const VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT = 1000066013; | ||
const VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT = 1000340000; | ||
const VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT = 1000340001; | ||
/** | ||
* Represents an unpacked KTX 2.0 texture container. Data for individual mip levels are stored in | ||
* the `.levels` array, typically compressed in Basis Universal formats. Additional properties | ||
* provide metadata required to process, transcode, and upload these textures. | ||
*/ | ||
class KTX2Container { | ||
constructor() { | ||
this.vkFormat = VK_FORMAT_UNDEFINED; | ||
this.typeSize = 1; | ||
this.pixelWidth = 0; | ||
this.pixelHeight = 0; | ||
this.pixelDepth = 0; | ||
this.layerCount = 0; | ||
this.faceCount = 1; | ||
this.supercompressionScheme = KHR_SUPERCOMPRESSION_NONE; | ||
this.levels = []; | ||
this.dataFormatDescriptor = [{ | ||
vendorId: KHR_DF_VENDORID_KHRONOS, | ||
descriptorType: KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, | ||
descriptorBlockSize: 0, | ||
versionNumber: KHR_DF_VERSION, | ||
colorModel: KHR_DF_MODEL_UNSPECIFIED, | ||
colorPrimaries: KHR_DF_PRIMARIES_BT709, | ||
transferFunction: KHR_DF_TRANSFER_SRGB, | ||
flags: KHR_DF_FLAG_ALPHA_STRAIGHT, | ||
texelBlockDimension: [0, 0, 0, 0], | ||
bytesPlane: [0, 0, 0, 0, 0, 0, 0, 0], | ||
samples: [] | ||
}]; | ||
this.keyValue = {}; | ||
this.globalData = null; | ||
} | ||
} | ||
class BufferReader { | ||
constructor(data, byteOffset, byteLength, littleEndian) { | ||
this._dataView = void 0; | ||
this._littleEndian = void 0; | ||
this._offset = void 0; | ||
this._dataView = new DataView(data.buffer, data.byteOffset + byteOffset, byteLength); | ||
this._littleEndian = littleEndian; | ||
this._offset = 0; | ||
} | ||
_nextUint8() { | ||
const value = this._dataView.getUint8(this._offset); | ||
this._offset += 1; | ||
return value; | ||
} | ||
_nextUint16() { | ||
const value = this._dataView.getUint16(this._offset, this._littleEndian); | ||
this._offset += 2; | ||
return value; | ||
} | ||
_nextUint32() { | ||
const value = this._dataView.getUint32(this._offset, this._littleEndian); | ||
this._offset += 4; | ||
return value; | ||
} | ||
_nextUint64() { | ||
const left = this._dataView.getUint32(this._offset, this._littleEndian); | ||
const right = this._dataView.getUint32(this._offset + 4, this._littleEndian); // TODO(cleanup): Just test this... | ||
// const value = this._littleEndian ? left + (2 ** 32 * right) : (2 ** 32 * left) + right; | ||
const value = left + 2 ** 32 * right; | ||
this._offset += 8; | ||
return value; | ||
} | ||
_nextInt32() { | ||
const value = this._dataView.getInt32(this._offset, this._littleEndian); | ||
this._offset += 4; | ||
return value; | ||
} | ||
_skip(bytes) { | ||
this._offset += bytes; | ||
return this; | ||
} | ||
_scan(maxByteLength, term = 0x00) { | ||
const byteOffset = this._offset; | ||
let byteLength = 0; | ||
while (this._dataView.getUint8(this._offset) !== term && byteLength < maxByteLength) { | ||
byteLength++; | ||
this._offset++; | ||
} | ||
if (byteLength < maxByteLength) this._offset++; | ||
return new Uint8Array(this._dataView.buffer, this._dataView.byteOffset + byteOffset, byteLength); | ||
} | ||
} | ||
/////////////////////////////////////////////////// | ||
// Common. | ||
/////////////////////////////////////////////////// | ||
const KTX_WRITER = `KTX-Parse v${"0.4.5"}`; | ||
const NUL = new Uint8Array([0x00]); /////////////////////////////////////////////////// | ||
// KTX2 Header. | ||
/////////////////////////////////////////////////// | ||
const KTX2_ID = [// '´', 'K', 'T', 'X', '2', '0', 'ª', '\r', '\n', '\x1A', '\n' | ||
0xab, 0x4b, 0x54, 0x58, 0x20, 0x32, 0x30, 0xbb, 0x0d, 0x0a, 0x1a, 0x0a]; | ||
const HEADER_BYTE_LENGTH = 68; // 13 * 4 + 2 * 8 | ||
/** Encodes text to an ArrayBuffer. */ | ||
function encodeText(text) { | ||
if (typeof TextEncoder !== 'undefined') { | ||
return new TextEncoder().encode(text); | ||
} | ||
return Buffer.from(text); | ||
} | ||
/** Decodes an ArrayBuffer to text. */ | ||
function decodeText(buffer) { | ||
if (typeof TextDecoder !== 'undefined') { | ||
return new TextDecoder().decode(buffer); | ||
} | ||
return Buffer.from(buffer).toString('utf8'); | ||
} | ||
/** Concatenates N ArrayBuffers. */ | ||
function concat(buffers) { | ||
let totalByteLength = 0; | ||
for (const buffer of buffers) { | ||
totalByteLength += buffer.byteLength; | ||
} | ||
const result = new Uint8Array(totalByteLength); | ||
let byteOffset = 0; | ||
for (const buffer of buffers) { | ||
result.set(new Uint8Array(buffer), byteOffset); | ||
byteOffset += buffer.byteLength; | ||
} | ||
return result; | ||
} | ||
/** | ||
* Parses a KTX 2.0 file, returning an unpacked {@link KTX2Container} instance with all associated | ||
* data. The container's mip levels and other binary data are pointers into the original file, not | ||
* copies, so the original file should not be overwritten after reading. | ||
* | ||
* @param data Bytes of KTX 2.0 file, as Uint8Array or Buffer. | ||
*/ | ||
function read(data) { | ||
/////////////////////////////////////////////////// | ||
// KTX 2.0 Identifier. | ||
/////////////////////////////////////////////////// | ||
const id = new Uint8Array(data.buffer, data.byteOffset, KTX2_ID.length); | ||
if (id[0] !== KTX2_ID[0] || // '´' | ||
id[1] !== KTX2_ID[1] || // 'K' | ||
id[2] !== KTX2_ID[2] || // 'T' | ||
id[3] !== KTX2_ID[3] || // 'X' | ||
id[4] !== KTX2_ID[4] || // ' ' | ||
id[5] !== KTX2_ID[5] || // '2' | ||
id[6] !== KTX2_ID[6] || // '0' | ||
id[7] !== KTX2_ID[7] || // 'ª' | ||
id[8] !== KTX2_ID[8] || // '\r' | ||
id[9] !== KTX2_ID[9] || // '\n' | ||
id[10] !== KTX2_ID[10] || // '\x1A' | ||
id[11] !== KTX2_ID[11] // '\n' | ||
) { | ||
throw new Error('Missing KTX 2.0 identifier.'); | ||
} | ||
const container = new KTX2Container(); /////////////////////////////////////////////////// | ||
// Header. | ||
/////////////////////////////////////////////////// | ||
const headerByteLength = 17 * Uint32Array.BYTES_PER_ELEMENT; | ||
const headerReader = new BufferReader(data, KTX2_ID.length, headerByteLength, true); | ||
container.vkFormat = headerReader._nextUint32(); | ||
container.typeSize = headerReader._nextUint32(); | ||
container.pixelWidth = headerReader._nextUint32(); | ||
container.pixelHeight = headerReader._nextUint32(); | ||
container.pixelDepth = headerReader._nextUint32(); | ||
container.layerCount = headerReader._nextUint32(); | ||
container.faceCount = headerReader._nextUint32(); | ||
const levelCount = headerReader._nextUint32(); | ||
container.supercompressionScheme = headerReader._nextUint32(); | ||
const dfdByteOffset = headerReader._nextUint32(); | ||
const dfdByteLength = headerReader._nextUint32(); | ||
const kvdByteOffset = headerReader._nextUint32(); | ||
const kvdByteLength = headerReader._nextUint32(); | ||
const sgdByteOffset = headerReader._nextUint64(); | ||
const sgdByteLength = headerReader._nextUint64(); /////////////////////////////////////////////////// | ||
// Level Index. | ||
/////////////////////////////////////////////////// | ||
const levelByteLength = levelCount * 3 * 8; | ||
const levelReader = new BufferReader(data, KTX2_ID.length + headerByteLength, levelByteLength, true); | ||
for (let i = 0; i < levelCount; i++) { | ||
container.levels.push({ | ||
levelData: new Uint8Array(data.buffer, data.byteOffset + levelReader._nextUint64(), levelReader._nextUint64()), | ||
uncompressedByteLength: levelReader._nextUint64() | ||
}); | ||
} /////////////////////////////////////////////////// | ||
// Data Format Descriptor (DFD). | ||
/////////////////////////////////////////////////// | ||
const dfdReader = new BufferReader(data, dfdByteOffset, dfdByteLength, true); | ||
const dfd = { | ||
vendorId: dfdReader._skip(4 | ||
/* totalSize */ | ||
)._nextUint16(), | ||
descriptorType: dfdReader._nextUint16(), | ||
versionNumber: dfdReader._nextUint16(), | ||
descriptorBlockSize: dfdReader._nextUint16(), | ||
colorModel: dfdReader._nextUint8(), | ||
colorPrimaries: dfdReader._nextUint8(), | ||
transferFunction: dfdReader._nextUint8(), | ||
flags: dfdReader._nextUint8(), | ||
texelBlockDimension: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], | ||
bytesPlane: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], | ||
samples: [] | ||
}; | ||
const sampleStart = 6; | ||
const sampleWords = 4; | ||
const numSamples = (dfd.descriptorBlockSize / 4 - sampleStart) / sampleWords; | ||
for (let i = 0; i < numSamples; i++) { | ||
const sample = { | ||
bitOffset: dfdReader._nextUint16(), | ||
bitLength: dfdReader._nextUint8(), | ||
channelType: dfdReader._nextUint8(), | ||
samplePosition: [dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8(), dfdReader._nextUint8()], | ||
sampleLower: -Infinity, | ||
sampleUpper: Infinity | ||
}; | ||
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) { | ||
sample.sampleLower = dfdReader._nextInt32(); | ||
sample.sampleUpper = dfdReader._nextInt32(); | ||
} else { | ||
sample.sampleLower = dfdReader._nextUint32(); | ||
sample.sampleUpper = dfdReader._nextUint32(); | ||
} | ||
dfd.samples[i] = sample; | ||
} | ||
container.dataFormatDescriptor.length = 0; | ||
container.dataFormatDescriptor.push(dfd); /////////////////////////////////////////////////// | ||
// Key/Value Data (KVD). | ||
/////////////////////////////////////////////////// | ||
const kvdReader = new BufferReader(data, kvdByteOffset, kvdByteLength, true); | ||
while (kvdReader._offset < kvdByteLength) { | ||
const keyValueByteLength = kvdReader._nextUint32(); | ||
const keyData = kvdReader._scan(keyValueByteLength); | ||
const key = decodeText(keyData); | ||
const valueData = kvdReader._scan(keyValueByteLength - keyData.byteLength); | ||
container.keyValue[key] = key.match(/^ktx/i) ? decodeText(valueData) : valueData; // 4-byte alignment. | ||
if (kvdReader._offset % 4) kvdReader._skip(4 - kvdReader._offset % 4); | ||
} /////////////////////////////////////////////////// | ||
// Supercompression Global Data (SGD). | ||
/////////////////////////////////////////////////// | ||
if (sgdByteLength <= 0) return container; | ||
const sgdReader = new BufferReader(data, sgdByteOffset, sgdByteLength, true); | ||
const endpointCount = sgdReader._nextUint16(); | ||
const selectorCount = sgdReader._nextUint16(); | ||
const endpointsByteLength = sgdReader._nextUint32(); | ||
const selectorsByteLength = sgdReader._nextUint32(); | ||
const tablesByteLength = sgdReader._nextUint32(); | ||
const extendedByteLength = sgdReader._nextUint32(); | ||
const imageDescs = []; | ||
for (let i = 0; i < levelCount; i++) { | ||
imageDescs.push({ | ||
imageFlags: sgdReader._nextUint32(), | ||
rgbSliceByteOffset: sgdReader._nextUint32(), | ||
rgbSliceByteLength: sgdReader._nextUint32(), | ||
alphaSliceByteOffset: sgdReader._nextUint32(), | ||
alphaSliceByteLength: sgdReader._nextUint32() | ||
}); | ||
} | ||
const endpointsByteOffset = sgdByteOffset + sgdReader._offset; | ||
const selectorsByteOffset = endpointsByteOffset + endpointsByteLength; | ||
const tablesByteOffset = selectorsByteOffset + selectorsByteLength; | ||
const extendedByteOffset = tablesByteOffset + tablesByteLength; | ||
const endpointsData = new Uint8Array(data.buffer, data.byteOffset + endpointsByteOffset, endpointsByteLength); | ||
const selectorsData = new Uint8Array(data.buffer, data.byteOffset + selectorsByteOffset, selectorsByteLength); | ||
const tablesData = new Uint8Array(data.buffer, data.byteOffset + tablesByteOffset, tablesByteLength); | ||
const extendedData = new Uint8Array(data.buffer, data.byteOffset + extendedByteOffset, extendedByteLength); | ||
container.globalData = { | ||
endpointCount, | ||
selectorCount, | ||
imageDescs, | ||
endpointsData, | ||
selectorsData, | ||
tablesData, | ||
extendedData | ||
}; | ||
return container; | ||
} | ||
function _extends() { | ||
_extends = Object.assign ? Object.assign.bind() : function (target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i]; | ||
for (var key in source) { | ||
if (Object.prototype.hasOwnProperty.call(source, key)) { | ||
target[key] = source[key]; | ||
} | ||
} | ||
} | ||
return target; | ||
}; | ||
return _extends.apply(this, arguments); | ||
} | ||
const DEFAULT_OPTIONS = { | ||
keepWriter: false | ||
}; | ||
/** | ||
* Serializes a {@link KTX2Container} instance to a KTX 2.0 file. Mip levels and other binary data | ||
* are copied into the resulting Uint8Array, so the original container can safely be edited or | ||
* destroyed after it is serialized. | ||
* | ||
* Options: | ||
* - keepWriter: If true, 'KTXWriter' key/value field is written as provided by the container. | ||
* Otherwise, a string for the current ktx-parse version is generated. Default: false. | ||
* | ||
* @param container | ||
* @param options | ||
*/ | ||
function write(container, options = {}) { | ||
options = _extends({}, DEFAULT_OPTIONS, options); /////////////////////////////////////////////////// | ||
// Supercompression Global Data (SGD). | ||
/////////////////////////////////////////////////// | ||
let sgdBuffer = new ArrayBuffer(0); | ||
if (container.globalData) { | ||
const sgdHeaderBuffer = new ArrayBuffer(20 + container.globalData.imageDescs.length * 5 * 4); | ||
const sgdHeaderView = new DataView(sgdHeaderBuffer); | ||
sgdHeaderView.setUint16(0, container.globalData.endpointCount, true); | ||
sgdHeaderView.setUint16(2, container.globalData.selectorCount, true); | ||
sgdHeaderView.setUint32(4, container.globalData.endpointsData.byteLength, true); | ||
sgdHeaderView.setUint32(8, container.globalData.selectorsData.byteLength, true); | ||
sgdHeaderView.setUint32(12, container.globalData.tablesData.byteLength, true); | ||
sgdHeaderView.setUint32(16, container.globalData.extendedData.byteLength, true); | ||
for (let i = 0; i < container.globalData.imageDescs.length; i++) { | ||
const imageDesc = container.globalData.imageDescs[i]; | ||
sgdHeaderView.setUint32(20 + i * 5 * 4 + 0, imageDesc.imageFlags, true); | ||
sgdHeaderView.setUint32(20 + i * 5 * 4 + 4, imageDesc.rgbSliceByteOffset, true); | ||
sgdHeaderView.setUint32(20 + i * 5 * 4 + 8, imageDesc.rgbSliceByteLength, true); | ||
sgdHeaderView.setUint32(20 + i * 5 * 4 + 12, imageDesc.alphaSliceByteOffset, true); | ||
sgdHeaderView.setUint32(20 + i * 5 * 4 + 16, imageDesc.alphaSliceByteLength, true); | ||
} | ||
sgdBuffer = concat([sgdHeaderBuffer, container.globalData.endpointsData, container.globalData.selectorsData, container.globalData.tablesData, container.globalData.extendedData]); | ||
} /////////////////////////////////////////////////// | ||
// Key/Value Data (KVD). | ||
/////////////////////////////////////////////////// | ||
const keyValueData = []; | ||
let keyValue = container.keyValue; | ||
if (!options.keepWriter) { | ||
keyValue = _extends({}, container.keyValue, { | ||
KTXwriter: KTX_WRITER | ||
}); | ||
} | ||
for (const key in keyValue) { | ||
const value = keyValue[key]; | ||
const keyData = encodeText(key); | ||
const valueData = typeof value === 'string' ? encodeText(value) : value; | ||
const kvByteLength = keyData.byteLength + 1 + valueData.byteLength + 1; | ||
const kvPadding = kvByteLength % 4 ? 4 - kvByteLength % 4 : 0; // align(4) | ||
keyValueData.push(concat([new Uint32Array([kvByteLength]), keyData, NUL, valueData, NUL, new Uint8Array(kvPadding).fill(0x00) // align(4) | ||
])); | ||
} | ||
const kvdBuffer = concat(keyValueData); /////////////////////////////////////////////////// | ||
// Data Format Descriptor (DFD). | ||
/////////////////////////////////////////////////// | ||
if (container.dataFormatDescriptor.length !== 1 || container.dataFormatDescriptor[0].descriptorType !== KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT) { | ||
throw new Error('Only BASICFORMAT Data Format Descriptor output supported.'); | ||
} | ||
const dfd = container.dataFormatDescriptor[0]; | ||
const dfdBuffer = new ArrayBuffer(28 + dfd.samples.length * 16); | ||
const dfdView = new DataView(dfdBuffer); | ||
const descriptorBlockSize = 24 + dfd.samples.length * 16; | ||
dfdView.setUint32(0, dfdBuffer.byteLength, true); | ||
dfdView.setUint16(4, dfd.vendorId, true); | ||
dfdView.setUint16(6, dfd.descriptorType, true); | ||
dfdView.setUint16(8, dfd.versionNumber, true); | ||
dfdView.setUint16(10, descriptorBlockSize, true); | ||
dfdView.setUint8(12, dfd.colorModel); | ||
dfdView.setUint8(13, dfd.colorPrimaries); | ||
dfdView.setUint8(14, dfd.transferFunction); | ||
dfdView.setUint8(15, dfd.flags); | ||
if (!Array.isArray(dfd.texelBlockDimension)) { | ||
throw new Error('texelBlockDimension is now an array. For dimensionality `d`, set `d - 1`.'); | ||
} | ||
dfdView.setUint8(16, dfd.texelBlockDimension[0]); | ||
dfdView.setUint8(17, dfd.texelBlockDimension[1]); | ||
dfdView.setUint8(18, dfd.texelBlockDimension[2]); | ||
dfdView.setUint8(19, dfd.texelBlockDimension[3]); | ||
for (let i = 0; i < 8; i++) dfdView.setUint8(20 + i, dfd.bytesPlane[i]); | ||
for (let i = 0; i < dfd.samples.length; i++) { | ||
const sample = dfd.samples[i]; | ||
const sampleByteOffset = 28 + i * 16; | ||
if (sample.channelID) { | ||
throw new Error('channelID has been renamed to channelType.'); | ||
} | ||
dfdView.setUint16(sampleByteOffset + 0, sample.bitOffset, true); | ||
dfdView.setUint8(sampleByteOffset + 2, sample.bitLength); | ||
dfdView.setUint8(sampleByteOffset + 3, sample.channelType); | ||
dfdView.setUint8(sampleByteOffset + 4, sample.samplePosition[0]); | ||
dfdView.setUint8(sampleByteOffset + 5, sample.samplePosition[1]); | ||
dfdView.setUint8(sampleByteOffset + 6, sample.samplePosition[2]); | ||
dfdView.setUint8(sampleByteOffset + 7, sample.samplePosition[3]); | ||
if (sample.channelType & KHR_DF_SAMPLE_DATATYPE_SIGNED) { | ||
dfdView.setInt32(sampleByteOffset + 8, sample.sampleLower, true); | ||
dfdView.setInt32(sampleByteOffset + 12, sample.sampleUpper, true); | ||
} else { | ||
dfdView.setUint32(sampleByteOffset + 8, sample.sampleLower, true); | ||
dfdView.setUint32(sampleByteOffset + 12, sample.sampleUpper, true); | ||
} | ||
} /////////////////////////////////////////////////// | ||
// Data alignment. | ||
/////////////////////////////////////////////////// | ||
const dfdByteOffset = KTX2_ID.length + HEADER_BYTE_LENGTH + container.levels.length * 3 * 8; | ||
const kvdByteOffset = dfdByteOffset + dfdBuffer.byteLength; | ||
let sgdByteOffset = sgdBuffer.byteLength > 0 ? kvdByteOffset + kvdBuffer.byteLength : 0; | ||
if (sgdByteOffset % 8) sgdByteOffset += 8 - sgdByteOffset % 8; // align(8) | ||
/////////////////////////////////////////////////// | ||
// Level Index. | ||
/////////////////////////////////////////////////// | ||
const levelData = []; | ||
const levelIndex = new DataView(new ArrayBuffer(container.levels.length * 3 * 8)); | ||
let levelDataByteOffset = (sgdByteOffset || kvdByteOffset + kvdBuffer.byteLength) + sgdBuffer.byteLength; | ||
for (let i = 0; i < container.levels.length; i++) { | ||
const level = container.levels[i]; | ||
levelData.push(level.levelData); | ||
levelIndex.setBigUint64(i * 24 + 0, BigInt(levelDataByteOffset), true); | ||
levelIndex.setBigUint64(i * 24 + 8, BigInt(level.levelData.byteLength), true); | ||
levelIndex.setBigUint64(i * 24 + 16, BigInt(level.uncompressedByteLength), true); | ||
levelDataByteOffset += level.levelData.byteLength; | ||
} /////////////////////////////////////////////////// | ||
// Header. | ||
/////////////////////////////////////////////////// | ||
const headerBuffer = new ArrayBuffer(HEADER_BYTE_LENGTH); | ||
const headerView = new DataView(headerBuffer); | ||
headerView.setUint32(0, container.vkFormat, true); | ||
headerView.setUint32(4, container.typeSize, true); | ||
headerView.setUint32(8, container.pixelWidth, true); | ||
headerView.setUint32(12, container.pixelHeight, true); | ||
headerView.setUint32(16, container.pixelDepth, true); | ||
headerView.setUint32(20, container.layerCount, true); | ||
headerView.setUint32(24, container.faceCount, true); | ||
headerView.setUint32(28, container.levels.length, true); | ||
headerView.setUint32(32, container.supercompressionScheme, true); | ||
headerView.setUint32(36, dfdByteOffset, true); | ||
headerView.setUint32(40, dfdBuffer.byteLength, true); | ||
headerView.setUint32(44, kvdByteOffset, true); | ||
headerView.setUint32(48, kvdBuffer.byteLength, true); | ||
headerView.setBigUint64(52, BigInt(sgdBuffer.byteLength > 0 ? sgdByteOffset : 0), true); | ||
headerView.setBigUint64(60, BigInt(sgdBuffer.byteLength), true); /////////////////////////////////////////////////// | ||
// Compose. | ||
/////////////////////////////////////////////////// | ||
return new Uint8Array(concat([new Uint8Array(KTX2_ID).buffer, headerBuffer, levelIndex.buffer, dfdBuffer, kvdBuffer, sgdByteOffset > 0 ? new ArrayBuffer(sgdByteOffset - (kvdByteOffset + kvdBuffer.byteLength)) // align(8) | ||
: new ArrayBuffer(0), sgdBuffer, ...levelData])); | ||
} | ||
export { KHR_DF_CHANNEL_RGBSDA_ALPHA, KHR_DF_CHANNEL_RGBSDA_BLUE, KHR_DF_CHANNEL_RGBSDA_DEPTH, KHR_DF_CHANNEL_RGBSDA_GREEN, KHR_DF_CHANNEL_RGBSDA_RED, KHR_DF_CHANNEL_RGBSDA_STENCIL, KHR_DF_FLAG_ALPHA_PREMULTIPLIED, KHR_DF_FLAG_ALPHA_STRAIGHT, KHR_DF_KHR_DESCRIPTORTYPE_BASICFORMAT, KHR_DF_MODEL_ASTC, KHR_DF_MODEL_ETC1, KHR_DF_MODEL_ETC1S, KHR_DF_MODEL_ETC2, KHR_DF_MODEL_RGBSDA, KHR_DF_MODEL_UASTC, KHR_DF_MODEL_UNSPECIFIED, KHR_DF_PRIMARIES_ACES, KHR_DF_PRIMARIES_ACESCC, KHR_DF_PRIMARIES_ADOBERGB, KHR_DF_PRIMARIES_BT2020, KHR_DF_PRIMARIES_BT601_EBU, KHR_DF_PRIMARIES_BT601_SMPTE, KHR_DF_PRIMARIES_BT709, KHR_DF_PRIMARIES_CIEXYZ, KHR_DF_PRIMARIES_DISPLAYP3, KHR_DF_PRIMARIES_NTSC1953, KHR_DF_PRIMARIES_PAL525, KHR_DF_PRIMARIES_UNSPECIFIED, KHR_DF_SAMPLE_DATATYPE_EXPONENT, KHR_DF_SAMPLE_DATATYPE_FLOAT, KHR_DF_SAMPLE_DATATYPE_LINEAR, KHR_DF_SAMPLE_DATATYPE_SIGNED, KHR_DF_TRANSFER_ACESCC, KHR_DF_TRANSFER_ACESCCT, KHR_DF_TRANSFER_ADOBERGB, KHR_DF_TRANSFER_BT1886, KHR_DF_TRANSFER_DCIP3, KHR_DF_TRANSFER_HLG_EOTF, KHR_DF_TRANSFER_HLG_OETF, KHR_DF_TRANSFER_ITU, KHR_DF_TRANSFER_LINEAR, KHR_DF_TRANSFER_NTSC, KHR_DF_TRANSFER_PAL625_EOTF, KHR_DF_TRANSFER_PAL_OETF, KHR_DF_TRANSFER_PQ_EOTF, KHR_DF_TRANSFER_PQ_OETF, KHR_DF_TRANSFER_SLOG, KHR_DF_TRANSFER_SLOG2, KHR_DF_TRANSFER_SRGB, KHR_DF_TRANSFER_ST240, KHR_DF_TRANSFER_UNSPECIFIED, KHR_DF_VENDORID_KHRONOS, KHR_DF_VERSION, KHR_SUPERCOMPRESSION_BASISLZ, KHR_SUPERCOMPRESSION_NONE, KHR_SUPERCOMPRESSION_ZLIB, KHR_SUPERCOMPRESSION_ZSTD, KTX2Container, VK_FORMAT_A1R5G5B5_UNORM_PACK16, VK_FORMAT_A2B10G10R10_SINT_PACK32, VK_FORMAT_A2B10G10R10_SNORM_PACK32, VK_FORMAT_A2B10G10R10_UINT_PACK32, VK_FORMAT_A2B10G10R10_UNORM_PACK32, VK_FORMAT_A2R10G10B10_SINT_PACK32, VK_FORMAT_A2R10G10B10_SNORM_PACK32, VK_FORMAT_A2R10G10B10_UINT_PACK32, VK_FORMAT_A2R10G10B10_UNORM_PACK32, VK_FORMAT_A4B4G4R4_UNORM_PACK16_EXT, VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT, VK_FORMAT_ASTC_10x10_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_10x10_SRGB_BLOCK, VK_FORMAT_ASTC_10x10_UNORM_BLOCK, VK_FORMAT_ASTC_10x5_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_10x5_SRGB_BLOCK, VK_FORMAT_ASTC_10x5_UNORM_BLOCK, VK_FORMAT_ASTC_10x6_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_10x6_SRGB_BLOCK, VK_FORMAT_ASTC_10x6_UNORM_BLOCK, VK_FORMAT_ASTC_10x8_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_10x8_SRGB_BLOCK, VK_FORMAT_ASTC_10x8_UNORM_BLOCK, VK_FORMAT_ASTC_12x10_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_12x10_SRGB_BLOCK, VK_FORMAT_ASTC_12x10_UNORM_BLOCK, VK_FORMAT_ASTC_12x12_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_12x12_SRGB_BLOCK, VK_FORMAT_ASTC_12x12_UNORM_BLOCK, VK_FORMAT_ASTC_4x4_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_4x4_SRGB_BLOCK, VK_FORMAT_ASTC_4x4_UNORM_BLOCK, VK_FORMAT_ASTC_5x4_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_5x4_SRGB_BLOCK, VK_FORMAT_ASTC_5x4_UNORM_BLOCK, VK_FORMAT_ASTC_5x5_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_5x5_SRGB_BLOCK, VK_FORMAT_ASTC_5x5_UNORM_BLOCK, VK_FORMAT_ASTC_6x5_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_6x5_SRGB_BLOCK, VK_FORMAT_ASTC_6x5_UNORM_BLOCK, VK_FORMAT_ASTC_6x6_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_6x6_SRGB_BLOCK, VK_FORMAT_ASTC_6x6_UNORM_BLOCK, VK_FORMAT_ASTC_8x5_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_8x5_SRGB_BLOCK, VK_FORMAT_ASTC_8x5_UNORM_BLOCK, VK_FORMAT_ASTC_8x6_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_8x6_SRGB_BLOCK, VK_FORMAT_ASTC_8x6_UNORM_BLOCK, VK_FORMAT_ASTC_8x8_SFLOAT_BLOCK_EXT, VK_FORMAT_ASTC_8x8_SRGB_BLOCK, VK_FORMAT_ASTC_8x8_UNORM_BLOCK, VK_FORMAT_B10G11R11_UFLOAT_PACK32, VK_FORMAT_B10X6G10X6R10X6G10X6_422_UNORM_4PACK16, VK_FORMAT_B12X4G12X4R12X4G12X4_422_UNORM_4PACK16, VK_FORMAT_B4G4R4A4_UNORM_PACK16, VK_FORMAT_B5G5R5A1_UNORM_PACK16, VK_FORMAT_B5G6R5_UNORM_PACK16, VK_FORMAT_B8G8R8A8_SINT, VK_FORMAT_B8G8R8A8_SNORM, VK_FORMAT_B8G8R8A8_SRGB, VK_FORMAT_B8G8R8A8_UINT, VK_FORMAT_B8G8R8A8_UNORM, VK_FORMAT_B8G8R8_SINT, VK_FORMAT_B8G8R8_SNORM, VK_FORMAT_B8G8R8_SRGB, VK_FORMAT_B8G8R8_UINT, VK_FORMAT_B8G8R8_UNORM, VK_FORMAT_BC1_RGBA_SRGB_BLOCK, VK_FORMAT_BC1_RGBA_UNORM_BLOCK, VK_FORMAT_BC1_RGB_SRGB_BLOCK, VK_FORMAT_BC1_RGB_UNORM_BLOCK, VK_FORMAT_BC2_SRGB_BLOCK, VK_FORMAT_BC2_UNORM_BLOCK, VK_FORMAT_BC3_SRGB_BLOCK, VK_FORMAT_BC3_UNORM_BLOCK, VK_FORMAT_BC4_SNORM_BLOCK, VK_FORMAT_BC4_UNORM_BLOCK, VK_FORMAT_BC5_SNORM_BLOCK, VK_FORMAT_BC5_UNORM_BLOCK, VK_FORMAT_BC6H_SFLOAT_BLOCK, VK_FORMAT_BC6H_UFLOAT_BLOCK, VK_FORMAT_BC7_SRGB_BLOCK, VK_FORMAT_BC7_UNORM_BLOCK, VK_FORMAT_D16_UNORM, VK_FORMAT_D16_UNORM_S8_UINT, VK_FORMAT_D24_UNORM_S8_UINT, VK_FORMAT_D32_SFLOAT, VK_FORMAT_D32_SFLOAT_S8_UINT, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32, VK_FORMAT_EAC_R11G11_SNORM_BLOCK, VK_FORMAT_EAC_R11G11_UNORM_BLOCK, VK_FORMAT_EAC_R11_SNORM_BLOCK, VK_FORMAT_EAC_R11_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK, VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK, VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK, VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK, VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK, VK_FORMAT_G10X6B10X6G10X6R10X6_422_UNORM_4PACK16, VK_FORMAT_G12X4B12X4G12X4R12X4_422_UNORM_4PACK16, VK_FORMAT_PVRTC1_2BPP_SRGB_BLOCK_IMG, VK_FORMAT_PVRTC1_2BPP_UNORM_BLOCK_IMG, VK_FORMAT_PVRTC1_4BPP_SRGB_BLOCK_IMG, VK_FORMAT_PVRTC1_4BPP_UNORM_BLOCK_IMG, VK_FORMAT_PVRTC2_2BPP_SRGB_BLOCK_IMG, VK_FORMAT_PVRTC2_2BPP_UNORM_BLOCK_IMG, VK_FORMAT_PVRTC2_4BPP_SRGB_BLOCK_IMG, VK_FORMAT_PVRTC2_4BPP_UNORM_BLOCK_IMG, VK_FORMAT_R10X6G10X6B10X6A10X6_UNORM_4PACK16, VK_FORMAT_R10X6G10X6_UNORM_2PACK16, VK_FORMAT_R10X6_UNORM_PACK16, VK_FORMAT_R12X4G12X4B12X4A12X4_UNORM_4PACK16, VK_FORMAT_R12X4G12X4_UNORM_2PACK16, VK_FORMAT_R12X4_UNORM_PACK16, VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R16G16B16A16_SINT, VK_FORMAT_R16G16B16A16_SNORM, VK_FORMAT_R16G16B16A16_UINT, VK_FORMAT_R16G16B16A16_UNORM, VK_FORMAT_R16G16B16_SFLOAT, VK_FORMAT_R16G16B16_SINT, VK_FORMAT_R16G16B16_SNORM, VK_FORMAT_R16G16B16_UINT, VK_FORMAT_R16G16B16_UNORM, VK_FORMAT_R16G16_SFLOAT, VK_FORMAT_R16G16_SINT, VK_FORMAT_R16G16_SNORM, VK_FORMAT_R16G16_UINT, VK_FORMAT_R16G16_UNORM, VK_FORMAT_R16_SFLOAT, VK_FORMAT_R16_SINT, VK_FORMAT_R16_SNORM, VK_FORMAT_R16_UINT, VK_FORMAT_R16_UNORM, VK_FORMAT_R32G32B32A32_SFLOAT, VK_FORMAT_R32G32B32A32_SINT, VK_FORMAT_R32G32B32A32_UINT, VK_FORMAT_R32G32B32_SFLOAT, VK_FORMAT_R32G32B32_SINT, VK_FORMAT_R32G32B32_UINT, VK_FORMAT_R32G32_SFLOAT, VK_FORMAT_R32G32_SINT, VK_FORMAT_R32G32_UINT, VK_FORMAT_R32_SFLOAT, VK_FORMAT_R32_SINT, VK_FORMAT_R32_UINT, VK_FORMAT_R4G4B4A4_UNORM_PACK16, VK_FORMAT_R4G4_UNORM_PACK8, VK_FORMAT_R5G5B5A1_UNORM_PACK16, VK_FORMAT_R5G6B5_UNORM_PACK16, VK_FORMAT_R64G64B64A64_SFLOAT, VK_FORMAT_R64G64B64A64_SINT, VK_FORMAT_R64G64B64A64_UINT, VK_FORMAT_R64G64B64_SFLOAT, VK_FORMAT_R64G64B64_SINT, VK_FORMAT_R64G64B64_UINT, VK_FORMAT_R64G64_SFLOAT, VK_FORMAT_R64G64_SINT, VK_FORMAT_R64G64_UINT, VK_FORMAT_R64_SFLOAT, VK_FORMAT_R64_SINT, VK_FORMAT_R64_UINT, VK_FORMAT_R8G8B8A8_SINT, VK_FORMAT_R8G8B8A8_SNORM, VK_FORMAT_R8G8B8A8_SRGB, VK_FORMAT_R8G8B8A8_UINT, VK_FORMAT_R8G8B8A8_UNORM, VK_FORMAT_R8G8B8_SINT, VK_FORMAT_R8G8B8_SNORM, VK_FORMAT_R8G8B8_SRGB, VK_FORMAT_R8G8B8_UINT, VK_FORMAT_R8G8B8_UNORM, VK_FORMAT_R8G8_SINT, VK_FORMAT_R8G8_SNORM, VK_FORMAT_R8G8_SRGB, VK_FORMAT_R8G8_UINT, VK_FORMAT_R8G8_UNORM, VK_FORMAT_R8_SINT, VK_FORMAT_R8_SNORM, VK_FORMAT_R8_SRGB, VK_FORMAT_R8_UINT, VK_FORMAT_R8_UNORM, VK_FORMAT_S8_UINT, VK_FORMAT_UNDEFINED, VK_FORMAT_X8_D24_UNORM_PACK32, read, write }; | ||
//# sourceMappingURL=ktx-parse.modern.js.map |
{ | ||
"name": "ktx-parse", | ||
"version": "0.4.4", | ||
"version": "0.4.5", | ||
"description": "KTX 2.0 (.ktx2) parser and serializer.", | ||
@@ -8,5 +8,9 @@ "type": "module", | ||
"source": "./src/index.ts", | ||
"types": "./dist/index.d.ts", | ||
"main": "./dist/ktx-parse.cjs", | ||
"exports": "./dist/ktx-parse.modern.js", | ||
"types": "./dist/index.d.ts", | ||
"module": "./dist/ktx-parse.esm.js", | ||
"exports": { | ||
"require": "./dist/ktx-parse.cjs", | ||
"default": "./dist/ktx-parse.modern.js" | ||
}, | ||
"repository": "github:donmccurdy/ktx-parse", | ||
@@ -16,5 +20,4 @@ "author": "Don McCurdy <dm@donmccurdy.com>", | ||
"scripts": { | ||
"dist": "microbundle --format modern,cjs --define PACKAGE_VERSION=$npm_package_version", | ||
"watch": "microbundle watch --format modern,cjs --define PACKAGE_VERSION=$npm_package_version", | ||
"watch:debug": "microbundle watch --no-compress --format modern,cjs --define PACKAGE_VERSION=$npm_package_version", | ||
"dist": "microbundle --format cjs,esm,modern --no-compress --define PACKAGE_VERSION=$npm_package_version", | ||
"watch": "microbundle watch --format cjs,esm,modern --no-compress --define PACKAGE_VERSION=$npm_package_version", | ||
"test": "ava test/test.ts", | ||
@@ -52,2 +55,7 @@ "coverage": "c8 --reporter=lcov --reporter=text ava test/test.ts --tap", | ||
], | ||
"browserslist": [ | ||
"defaults", | ||
"not IE 11", | ||
"node >= 14" | ||
], | ||
"ava": { | ||
@@ -54,0 +62,0 @@ "extensions": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
416642
25
3602