code wiki / (root) / nx_gltf_render_descriptor_normal_t281.nx

nx_gltf_render_descriptor_normal_t281.nx source

↩ module page · 181 lines · 16877 B

1// nx_gltf_render_descriptor_normal_t281.nx -- Encodes normal maps from GLTF assets into a render descriptor with specified encoding and texture binding. 2import "nx_gltf_pose_candidate_t181.nx" 3import "nx_sha256.nx" 4import "nx_normal_encoding_contract.nx" 5// A present but unsupported map is explicit refusal, never an absent/legacy map. 6// Image offsets inherit this descriptor's exact sourceSha256/sourceBytes identity. 7func gpd_normal_binding(w:*i64,cx:*i64,mat:i64)->i64{ 8 let have:i64=gli_member(cx,mat,"normalTexture");if have<0{return -1};if have==0{return 0} 9 let sp:*i64=cx[4] as *i64;let at:i64=sp[0];let tok:*NxJsonTok=cx[2] as *NxJsonTok 10 glp_reset(tok,cx[0] as *u8,cx[1],at) 11 var reason:*u8="";var valid:i64=1;var texture:i64=-1 12 if tok.kind!=NX_JSON_LBRACE{valid=0;reason="normal-texture-not-object"} 13 if valid==1{if gli_member(cx,at,"extensions")!=0{valid=0;reason="normal-texture-extension-unsupported"}} 14 if valid==1{if gld_int(cx,at,"texCoord",0)!=0{valid=0;reason="normal-texture-uv-set-unsupported"}} 15 if valid==1{ 16 texture=gld_int(cx,at,"index",-1) 17 if texture<0{valid=0;reason="normal-texture-index-invalid"} 18 } 19 // Preserve the original numeric token after checking the existing native numeric range. 20 // Negative scale is legal. Values beyond this representation are explicitly unsupported. 21 if valid==1{ 22 let sh:i64=gli_member(cx,at,"scale") 23 if sh<0{valid=0;reason="normal-scale-invalid"}else{if sh==1{ 24 glp_reset(tok,cx[0] as *u8,cx[1],sp[0]);var fixed:i64=0 25 if tok.kind!=NX_JSON_NUMBER{valid=0;reason="normal-scale-invalid"}else{ 26 if gld_number_fixed((tok.src as i64+tok.tok_off) as *u8,tok.tok_len,FBB_Q,&fixed)!=0{valid=0;reason="normal-scale-native-range-unsupported"} 27 } 28 }} 29 } 30 if valid==1{ 31 let bytes:i64=4*__size_of(i64);let check:*i64=sys_mmap_try(bytes) as *i64 32 if (check as i64)==0{return -7};var k:i64=0;while k<4{check[k]=0;k=k+1} 33 let ir:i64=gpd_image(check,cx,texture);let failed:i64=check[3] 34 sys_munmap_direct(check as *u8,bytes) 35 if ir!=0||failed!=0{valid=0;reason="normal-image-binding-unsupported"} 36 } 37 gpd_s(w,",\"normalMap\":{\"state\":") 38 if valid==0{gpd_s(w,"\"refused\",\"reason\":\"");gpd_s(w,reason);return gpd_s(w,"\"}")} 39 let encoding:i64=ntb_normal_encoding_admit(1,NTB_NORMAL_ENCODING_GLTF_UNORM) 40 if encoding!=NTB_NORMAL_ENCODING_GLTF_UNORM{return -2} 41 gpd_s(w,"\"prepared\",\"sourceIdentity\":\"descriptor.sourceSha256+sourceBytes\",\"texture\":");gpd_n(w,texture) 42 gpd_s(w,",\"image\":");if gpd_image(w,cx,texture)!=0{return -2} 43 gpd_s(w,",\"texCoord\":0,\"scale\":");if gpd_raw(w,cx,at,"scale","1")!=0{return -2} 44 gpd_s(w,",\"normalEncoding\":{\"id\":");gpd_n(w,encoding) 45 gpd_s(w,",\"name\":\"gltf-rgb8-unorm-v1\",\"linearTransfer\":true,\"normalizationRequired\":true},\"tangentFrame\":\"gltf-tangent-xyz-and-w-handedness\",\"renderQualified\":false}") 46 return 0 47} 48 49func gpd_source_identity(w:*i64,cx:*i64)->i64{ 50 let digest:*u8=sys_mmap_try(32);if (digest as i64)==0{return -7};sha256_digest(cx[6] as *u8,cx[7],digest);let hex:*u8="0123456789abcdef";gpd_s(w,"\"sourceSha256\":\"");var i:i64=0;while i<32{let b:i64=digest[i] as i64;gpd_put(w,(hex as i64+b/16) as *u8,1);gpd_put(w,(hex as i64+b%16) as *u8,1);i=i+1};gpd_s(w,"\",");sys_munmap_direct(digest,32);return 0 51} 52 53// Native render descriptor over retained GLB bytes. No geometry or image transcoding. 54// Writer state: output, capacity, position, failure. A null output performs sizing. 55func gpd_put(w:*i64,s:*u8,n:i64)->i64{ 56 if w[3]!=0{return -1};if n<0||w[2]>GLD_I64_MAX-n{w[3]=-1;return -1} 57 if w[0]>0{if n>w[1]-w[2]{w[3]=-1;return -1};let b:*u8=w[0] as *u8;var i:i64=0;while i<n{b[w[2]+i]=s[i];i=i+1}} 58 w[2]=w[2]+n;return 0 59} 60func gpd_s(w:*i64,s:*u8)->i64{return gpd_put(w,s,gll_slen(s))} 61func gpd_n(w:*i64,n:i64)->i64{ 62 if n<0{w[3]=-1;return -1};var d:i64=1;while d<=n/10{d=d*10};var left:i64=n 63 while d>0{let digit:i64=48+left/d;let chars:*u8="0123456789";if gpd_put(w,(chars as i64+digit-48) as *u8,1)!=0{return -1};left=left%d;d=d/10};return 0 64} 65func gpd_raw(w:*i64,cx:*i64,parent:i64,key:*u8,fallback:*u8)->i64{ 66 let h:i64=gli_member(cx,parent,key);if h<0{return -1};if h==0{return gpd_s(w,fallback)} 67 let sp:*i64=cx[4] as *i64;return gpd_put(w,(cx[0]+sp[0]) as *u8,sp[1]-sp[0]) 68} 69func gpd_view(w:*i64,cx:*i64,accessor:i64,v:*i64)->i64{ 70 let st:*i64=cx[5] as *i64;if gltf_accessor_view(cx,accessor,st[2],v)!=0{return -1} 71 gpd_s(w,"[");gpd_n(w,accessor);var i:i64=0;while i<GLD_VIEW_WORDS{gpd_s(w,",");gpd_n(w,v[i]);i=i+1};return gpd_s(w,"]") 72} 73func gpd_alpha(cx:*i64,mat:i64)->i64{ 74 let have:i64=gli_member(cx,mat,"alphaMode");if have<0{return -1};if have==0{return 0} 75 let t:*NxJsonTok=cx[2] as *NxJsonTok;let sp:*i64=cx[4] as *i64;glp_reset(t,cx[0] as *u8,cx[1],sp[0]) 76 if glp_eq(t,"OPAQUE")==1{return 0};if glp_eq(t,"MASK")==1{return 1};if glp_eq(t,"BLEND")==1{return 2};return -1 77} 78func gpd_image(w:*i64,cx:*i64,texture:i64)->i64{ 79 let tx:i64=gld_nth(cx,0,"textures",texture);if tx<0||gli_member(cx,tx,"extensions")!=0{return -1} 80 let image:i64=gld_int(cx,tx,"source",-1);let im:i64=gld_nth(cx,0,"images",image);if im<0||gli_member(cx,im,"uri")!=0{return -1} 81 let vi:i64=gld_int(cx,im,"bufferView",-1);let view:i64=gld_nth(cx,0,"bufferViews",vi);if view<0||gld_int(cx,view,"buffer",-1)!=0||gli_member(cx,view,"extensions")!=0{return -1} 82 let off:i64=gld_int(cx,view,"byteOffset",0);let len:i64=gld_int(cx,view,"byteLength",-1);let bf:i64=gld_nth(cx,0,"buffers",0);let declared:i64=gld_int(cx,bf,"byteLength",-1) 83 if off<0||len<=0||off>declared||len>declared-off{return -1} 84 gpd_s(w,"{\"image\":");gpd_n(w,image);gpd_s(w,",\"offset\":");gpd_n(w,cx[8]-cx[6]+off);gpd_s(w,",\"bytes\":");gpd_n(w,len);gpd_s(w,",\"mime\":");if gpd_raw(w,cx,im,"mimeType","null")!=0{return -1} 85 let samplerHave:i64=gli_member(cx,tx,"sampler");if samplerHave<0{return -1} 86 var sampler:i64=-1 87 if samplerHave==1{let si:i64=gld_int(cx,tx,"sampler",-1);if si<0{return -1};sampler=gld_nth(cx,0,"samplers",si);if sampler<0{return -1}} 88 gpd_s(w,",\"sampler\":{");var mag:i64=9729;var min:i64=9987;var ws:i64=10497;var wt:i64=10497 89 if sampler>=0{mag=gld_int(cx,sampler,"magFilter",9729);min=gld_int(cx,sampler,"minFilter",9987);ws=gld_int(cx,sampler,"wrapS",10497);wt=gld_int(cx,sampler,"wrapT",10497)} 90 if mag!=9728&&mag!=9729{return -1};if min!=9728&&min!=9729&&min!=9984&&min!=9985&&min!=9986&&min!=9987{return -1} 91 if ws!=10497&&ws!=33071&&ws!=33648{return -1};if wt!=10497&&wt!=33071&&wt!=33648{return -1} 92 gpd_s(w,"\"mag\":");gpd_n(w,mag);gpd_s(w,",\"min\":");gpd_n(w,min);gpd_s(w,",\"wrapS\":");gpd_n(w,ws);gpd_s(w,",\"wrapT\":");gpd_n(w,wt);return gpd_s(w,"}}") 93} 94// Validate unit-interval decimals exactly; fixed-point truncation alone admits values just outside endpoints. 95func gpd_unit_token(s:*u8,n:i64)->i64{ 96 var value:i64=0;if gld_number_fixed(s,n,1,&value)!=0{return -1} 97 var start:i64=0;if s[0]==(45 as u8){start=1} 98 var i:i64=start;var digits:i64=0;var before:i64=0;var dotted:i64=0;var first:i64=-1;var leading:i64=0;var tail:i64=0 99 while i<n&&s[i]!=(101 as u8)&&s[i]!=(69 as u8){let c:i64=s[i] as i64;if c==46{before=digits;dotted=1}else{if c!=48{if first<0{first=digits;leading=c-48}else{tail=1}};digits=digits+1};i=i+1} 100 if first<0{return 0};if start!=0{return -1};if dotted==0{before=digits} 101 var exponent:i64=0;var sign:i64=1;let bound:i64=n+1 102 if i<n{i=i+1;if s[i]==(45 as u8){sign=0-1;i=i+1}else{if s[i]==(43 as u8){i=i+1}};while i<n{let d:i64=(s[i] as i64)-48;if exponent>(bound-d)/10{exponent=bound}else{exponent=exponent*10+d};i=i+1}} 103 let magnitude:i64=before-first-1+sign*exponent;if magnitude<0{return 0};if magnitude>0||leading!=1||tail!=0{return -1};return 0 104} 105func gpd_unit_field(w:*i64,cx:*i64,parent:i64,key:*u8,fallback:*u8,count:i64)->i64{ 106 if parent<0{return gpd_s(w,fallback)};let have:i64=gli_member(cx,parent,key);if have<0{return -1};if have==0{return gpd_s(w,fallback)} 107 let sp:*i64=cx[4] as *i64;let begin:i64=sp[0];let end:i64=sp[1];let t:*NxJsonTok=cx[2] as *NxJsonTok;glp_reset(t,cx[0] as *u8,cx[1],begin) 108 if count>1{if t.kind!=NX_JSON_LBRACKET{return -1};nx_json_next(t)};var i:i64=0 109 while i<count{if t.kind!=NX_JSON_NUMBER||gpd_unit_token((t.src as i64+t.tok_off) as *u8,t.tok_len)!=0{return -1};i=i+1;nx_json_next(t);if i<count{if t.kind!=NX_JSON_COMMA{return -1};nx_json_next(t)}} 110 if count>1&&t.kind!=NX_JSON_RBRACKET{return -1};return gpd_put(w,(cx[0]+begin) as *u8,end-begin) 111} 112// Retain unsupported map metadata and expose lit admission instead of silently dropping it. 113func gpd_material_inputs(w:*i64,cx:*i64,mat:i64,pbr:i64)->i64{ 114 var unsupported:i64=0;gpd_s(w,",\"mapInputs\":{");var i:i64=0 115 while i<4{var key:*u8="normalTexture";var parent:i64=mat;if i==1{key="occlusionTexture"};if i==2{key="emissiveTexture"};if i==3{key="metallicRoughnessTexture";parent=pbr} 116 if i>0{gpd_s(w,",")};gpd_s(w,"\"");gpd_s(w,key);gpd_s(w,"\":");var have:i64=0;if parent>=0{have=gli_member(cx,parent,key)};if have<0{return -1};if have==0{gpd_s(w,"null")}else{unsupported=unsupported+1;if gpd_raw(w,cx,parent,key,"null")!=0{return -1}};i=i+1 117 };gpd_s(w,"},\"litEligible\":");if unsupported==0{gpd_s(w,"true")}else{gpd_s(w,"false")};gpd_s(w,",\"litUnsupportedInputs\":");gpd_n(w,unsupported);gpd_s(w,",\"litReason\":\"");if unsupported==0{gpd_s(w,"scalar-basecolor-inputs-supported")}else{gpd_s(w,"material-map-inputs-not-rendered")};gpd_s(w,"\"");return 0 118} 119func gpd_material(w:*i64,cx:*i64,index:i64)->i64{ 120 let mat:i64=gld_nth(cx,0,"materials",index);if mat<0||gli_member(cx,mat,"extensions")!=0{return -1} 121 let mode:i64=gpd_alpha(cx,mat);if mode<0{return -1} 122 gpd_s(w,"{\"index\":");gpd_n(w,index);gpd_s(w,",\"alpha\":");gpd_n(w,mode);gpd_s(w,",\"cutoff\":");if gpd_raw(w,cx,mat,"alphaCutoff","0.5")!=0{return -1} 123 gpd_s(w,",\"doubleSided\":");if gpd_raw(w,cx,mat,"doubleSided","false")!=0{return -1} 124 var h:i64=gli_member(cx,mat,"pbrMetallicRoughness");if h<0{return -1};let sp:*i64=cx[4] as *i64;var pbr:i64=-1;if h==1{pbr=sp[0]} 125 gpd_s(w,",\"factor\":");if gpd_unit_field(w,cx,pbr,"baseColorFactor","[1,1,1,1]",4)!=0{return -1} 126 gpd_s(w,",\"metallicFactor\":");if gpd_unit_field(w,cx,pbr,"metallicFactor","1",1)!=0{return -1} 127 gpd_s(w,",\"roughnessFactor\":");if gpd_unit_field(w,cx,pbr,"roughnessFactor","1",1)!=0{return -1} 128 gpd_s(w,",\"emissiveFactor\":");if gpd_unit_field(w,cx,mat,"emissiveFactor","[0,0,0]",3)!=0{return -1} 129 gpd_s(w,",\"baseColor\":");var texture:i64=-1 130 if pbr>=0{h=gli_member(cx,pbr,"baseColorTexture");if h<0{return -1};if h==1{let bt:i64=sp[0];if gli_member(cx,bt,"extensions")!=0||gld_int(cx,bt,"texCoord",0)!=0{return -1};texture=gld_int(cx,bt,"index",-1);if texture<0{return -1}}} 131 if texture<0{gpd_s(w,"null")}else{if gpd_image(w,cx,texture)!=0{return -1}} 132 if gpd_material_inputs(w,cx,mat,pbr)!=0{return -1} 133 if gpd_normal_binding(w,cx,mat)!=0{return -1} 134 return gpd_s(w,"}") 135} 136func gltf_render_descriptor(cx:*i64,mesh:i64,skin:i64,w:*i64)->i64{ 137 if (cx as i64)<=0||(w as i64)<=0{return -1};let st:*i64=cx[5] as *i64 138 let m:i64=gld_nth(cx,0,"meshes",mesh);let sk:i64=gld_nth(cx,0,"skins",skin);if m<0||sk<0{return -1} 139 if gli_member(cx,m,"extensions")!=0||gli_member(cx,m,"weights")!=0{return -2} 140 let n:i64=gli_array(cx,m,"primitives",0);if n<=0{return -1};let joints:i64=gli_array(cx,sk,"joints",0);if joints<=0{return -1} 141 let v:*i64=sys_mmap_try(GLD_VIEW_WORDS*8) as *i64;if (v as i64)==0{return -7};var rc:i64=0 142 gpd_s(w,"{");if gpd_source_identity(w,cx)!=0{sys_munmap_direct(v as *u8,GLD_VIEW_WORDS*8);return -7};gpd_s(w,"\"schema\":\"nishi-authored-render/1\",\"scope\":\"source-albedo-and-discrete-native-pose\",\"basis\":\"gltf-Y-up\",\"physicalScale\":null,\"sourceBytes\":");gpd_n(w,cx[7]);gpd_s(w,",\"binOffset\":");gpd_n(w,cx[8]-cx[6]);gpd_s(w,",\"mesh\":");gpd_n(w,mesh);gpd_s(w,",\"skin\":");gpd_n(w,skin);gpd_s(w,",\"joints\":");gpd_n(w,joints);gpd_s(w,",\"parts\":[") 143 var i:i64=0 144 while i<n{ 145 let p:i64=gld_nth(cx,m,"primitives",i);if p<0||gli_member(cx,p,"extensions")!=0||gli_member(cx,p,"targets")!=0||gld_int(cx,p,"mode",4)!=4{rc=-2;break} 146 let h:i64=gli_member(cx,p,"attributes");let sp:*i64=cx[4] as *i64;if h!=1{rc=-1;break};let a:i64=sp[0] 147 let vertexColor:i64=gli_member(cx,a,"COLOR_0");if vertexColor<0{rc=-2;break} 148 if i>0{gpd_s(w,",")};gpd_s(w,"{\"attributes\":{");var j:i64=0 149 while j<6{var key:*u8="POSITION";if j==1{key="JOINTS_0"};if j==2{key="WEIGHTS_0"};if j==3{key="TEXCOORD_0"};if j==4{key="NORMAL"};if j==5{key="TANGENT"} 150 let ai:i64=gld_int(cx,a,key,-1);if ai<0{rc=-2;break};if j>0{gpd_s(w,",")};gpd_s(w,"\"");gpd_s(w,key);gpd_s(w,"\":");if gpd_view(w,cx,ai,v)!=0{rc=-2;break};j=j+1 151 };if rc!=0{break};gpd_s(w,"},\"vertexColorInput\":");if gpd_raw(w,cx,a,"COLOR_0","null")!=0{rc=-2;break};gpd_s(w,",\"litGeometryEligible\":");if vertexColor==0{gpd_s(w,"true")}else{gpd_s(w,"false")};gpd_s(w,",\"litGeometryReason\":\"");if vertexColor==0{gpd_s(w,"vertex-color-absent")}else{gpd_s(w,"linear-vertex-color-not-rendered")};gpd_s(w,"\",\"indices\":");let ix:i64=gld_int(cx,p,"indices",-1);if ix<0||gpd_view(w,cx,ix,v)!=0{rc=-2;break};if v[5]!=1||v[6]!=0||(v[3]!=5121&&v[3]!=5123&&v[3]!=5125)||v[1]%3!=0{rc=-2;break} 152 gpd_s(w,",\"material\":");let ma:i64=gld_int(cx,p,"material",-1);if ma<0||gpd_material(w,cx,ma)!=0{rc=-2;break};gpd_s(w,"}");i=i+1 153 } 154 gpd_s(w,"]}");sys_munmap_direct(v as *u8,GLD_VIEW_WORDS*8);if w[3]!=0{return -3};return rc 155} 156 157func gpd_i(w:*i64,n:i64)->i64{if n==0-GLD_I64_MAX-1{return -1};if n<0{gpd_s(w,"-");return gpd_n(w,0-n)};return gpd_n(w,n)} 158// Caller selects exact native sample times; no baked matrix interpolation. 159func gltf_render_poses(cx:*i64,animation:i64,skin:i64,position:i64,jointattr:i64,weightattr:i64,times:*i64,samples:i64,w:*i64)->i64{ 160 if samples<=0||(times as i64)<=0{return -1};let st:*i64=cx[5] as *i64;let count:i64=st[5];let sk:i64=gld_nth(cx,0,"skins",skin);if sk<0{return -1};let joints:i64=gli_array(cx,sk,"joints",0) 161 if count<=0||joints<=0||count>GLD_I64_MAX/368||joints>GLD_I64_MAX/128{return -1} 162 let need:i64=count*368;if joints*128>GLD_I64_MAX-need-GLD_VIEW_WORDS*24-72{return -1};let bytes:i64=need+joints*128+GLD_VIEW_WORDS*24+72 163 let mem:*u8=sys_mmap_try(bytes);if (mem as i64)==0{return -7};let parents:*i64=mem as *i64;let local:*i64=(mem as i64+count*8) as *i64;let world:*i64=(local as i64+count*128) as *i64;let done:*i64=(world as i64+count*128) as *i64;let trs:*i64=(done as i64+count*8) as *i64;let flags:*i64=(trs as i64+count*80) as *i64;let masks:*i64=(flags as i64+count*8) as *i64;let palette:*i64=(masks as i64+count*8) as *i64;let pv:*i64=(palette as i64+joints*128) as *i64;let jv:*i64=(pv as i64+GLD_VIEW_WORDS*8) as *i64;let wv:*i64=(jv as i64+GLD_VIEW_WORDS*8) as *i64;let vertex:*i64=(wv as i64+GLD_VIEW_WORDS*8) as *i64;let bounds:*i64=(vertex as i64+24) as *i64 164 var rc:i64=0 165 if gltf_accessor_view(cx,position,st[2],pv)!=0||gltf_accessor_view(cx,jointattr,st[2],jv)!=0||gltf_accessor_view(cx,weightattr,st[2],wv)!=0||gld_parents(cx,count,parents)!=0{rc=-2} 166 gpd_s(w,"{");if gpd_source_identity(w,cx)!=0{sys_munmap_direct(mem,bytes);return -7};gpd_s(w,"\"schema\":\"nishi-native-discrete-lbs/1\",\"q\":");gpd_n(w,FBB_Q);gpd_s(w,",\"timeQ\":");gpd_n(w,VM_Q30);gpd_s(w,",\"animation\":");gpd_n(w,animation);gpd_s(w,",\"skin\":");gpd_n(w,skin);gpd_s(w,",\"samples\":[") 167 var sample:i64=0 168 while sample<samples&&rc==0{ 169 var i:i64=0;while i<count{flags[i]=gld_node_trs(cx,i,(trs as i64+i*80) as *i64,(local as i64+i*128) as *i64);if flags[i]<0{rc=-2;break};i=i+1};if rc!=0{break} 170 let channels:i64=gld_animate(cx,animation,times[sample],trs,count,masks);if channels<0{rc=-3;break} 171 i=0;while i<count{if flags[i]==0{if gld_trs_matrix((trs as i64+i*80) as *i64,(local as i64+i*128) as *i64)!=0{rc=-4;break}};i=i+1};if rc!=0{break} 172 if gld_world_matrices(count,parents,local,world,done)!=0||gld_skin_palette(cx,skin,world,count,palette,joints)!=joints{rc=-5;break} 173 if sample>0{gpd_s(w,",")};gpd_s(w,"{\"time\":");gpd_i(w,times[sample]);gpd_s(w,",\"channels\":");gpd_n(w,channels);gpd_s(w,",\"palette\":[");i=0 174 while i<joints*16{if i>0{gpd_s(w,",")};gpd_i(w,palette[i]);i=i+1};gpd_s(w,"],\"jointWorld\":[");i=0 175 while i<joints{let at:i64=gld_nth(cx,sk,"joints",i);let tok:*NxJsonTok=cx[2] as *NxJsonTok;glp_reset(tok,cx[0] as *u8,cx[1],at);let sourceNode:i64=gld_uint(tok);if sourceNode<0||sourceNode>=count{rc=-5;break};if i>0{gpd_s(w,",")};gpd_s(w,"[");var axis:i64=0;while axis<3{if axis>0{gpd_s(w,",")};gpd_i(w,world[sourceNode*16+12+axis]);axis=axis+1};gpd_s(w,"]");i=i+1};if rc!=0{break};gpd_s(w,"],\"bounds\":[") 176 i=0;while i<pv[1]{if gld_skin_vertex(cx,pv,jv,wv,i,palette,joints,vertex)!=0{rc=-6;break};var k:i64=0;while k<3{if i==0||vertex[k]<bounds[k]{bounds[k]=vertex[k]};if i==0||vertex[k]>bounds[k+3]{bounds[k+3]=vertex[k]};k=k+1};i=i+1};if rc!=0{break} 177 i=0;while i<6{if i>0{gpd_s(w,",")};gpd_i(w,bounds[i]);i=i+1};gpd_s(w,"]}");sample=sample+1 178 } 179 gpd_s(w,"]}");sys_munmap_direct(mem,bytes);if w[3]!=0{return -3};return rc 180} 181