• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript array.getFortranOrderStrides函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中neuroglancer/util/array.getFortranOrderStrides函数的典型用法代码示例。如果您正苦于以下问题:TypeScript getFortranOrderStrides函数的具体用法?TypeScript getFortranOrderStrides怎么用?TypeScript getFortranOrderStrides使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getFortranOrderStrides函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: encodeChannels

export function encodeChannels(
    output: Uint32ArrayBuilder, blockSize: ArrayLike<number>, rawData: Uint32Array,
    volumeSize: ArrayLike<number>, baseInputOffset: number = 0,
    inputStrides = getFortranOrderStrides(volumeSize, 2)) {
  return encodeChannelsCommon(
      output, blockSize, rawData, volumeSize, baseInputOffset, inputStrides, encodeBlock);
}
开发者ID:google,项目名称:neuroglancer,代码行数:7,代码来源:encode_uint64.ts


示例2: getFortranOrderStrides

export function chunkFormatTest<TextureLayout extends Disposable>(
    dataType: DataType, volumeSize: Vec4,
    getChunkFormatAndTextureLayout:
        (gl: GL) => [SingleTextureChunkFormat<TextureLayout>, TextureLayout],
    rawData: TypedArray, encodedData: TypedArray) {
  const numChannels = volumeSize[3];
  let strides = getFortranOrderStrides(volumeSize);
  let outputChannelsPerChannel = dataType === DataType.UINT64 ? 2 : 1;
  it(`volumeSize = ${vec3Key(volumeSize)}, numChannels = ${volumeSize[3]}, dataType = ${DataType[dataType]}`,
     () => {
       fragmentShaderTest(outputChannelsPerChannel * numChannels, tester => {
         let {gl, builder} = tester;
         let [chunkFormat, textureLayout] = getChunkFormatAndTextureLayout(gl);
         builder.addUniform('vec3', 'vChunkPosition');
         builder.addUniform('vec3', 'uChunkDataSize');
         builder.addFragmentCode(glsl_getPositionWithinChunk);
         chunkFormat.defineShader(builder);
         {
           let fragmentMain = '';
           let outputChannel = 0;
           for (let channel = 0; channel < numChannels; ++channel) {
             switch (dataType) {
               case DataType.UINT64:
                 fragmentMain += `
{
  uint64_t value = getDataValue(${channel});
  gl_FragData[${outputChannel++}] = value.low;
  gl_FragData[${outputChannel++}] = value.high;
}
`;
                 break;
               case DataType.UINT8:
                 fragmentMain += `
gl_FragData[${outputChannel++}] = vec4(getDataValue(${channel}).value, 0, 0, 0);
`;
                 break;
               case DataType.FLOAT32:
                 fragmentMain += `
gl_FragData[${outputChannel++}] = packFloatIntoVec4(getDataValue(${channel}));
`;
                 break;
               case DataType.UINT16:
                 fragmentMain += `
gl_FragData[${outputChannel++}] = vec4(getDataValue(${channel}).value, 0, 0);
`;
                 break;
               case DataType.UINT32:
                 fragmentMain += `
gl_FragData[${outputChannel++}] = getDataValue(${channel}).value;
`;
                 break;
             }
           }
           builder.setFragmentMain(fragmentMain);
         }
         tester.build();
         let {shader} = tester;
         shader.bind();
         gl.uniform3fv(shader.uniform('uChunkDataSize'), volumeSize.subarray(0, 3));

         let texture = gl.createTexture();
         tester.registerDisposer(() => { gl.deleteTexture(texture); });

         chunkFormat.beginDrawing(gl, shader);
         gl.bindTexture(gl.TEXTURE_2D, texture);
         gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
         setRawTextureParameters(gl);
         chunkFormat.setTextureData(gl, textureLayout, encodedData);
         chunkFormat.setupTextureLayout(gl, shader, textureLayout);


         // Position within chunk in floating point range [0, chunkDataSize].
         function checkPosition(positionInChunk: Vec3) {
           gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
           chunkFormat.beginDrawing(gl, shader);
           chunkFormat.beginSource(gl, shader);
           chunkFormat.setupTextureLayout(gl, shader, textureLayout);
           gl.bindTexture(gl.TEXTURE_2D, texture);
           tester.execute();
           chunkFormat.endDrawing(gl, shader);
           let offset = 0;
           for (let i = 0; i < 3; ++i) {
             offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
                 strides[i];
           }
           let outputChannel = 0;
           for (let channel = 0; channel < numChannels; ++channel) {
             const curOffset = offset + channel * strides[3];
             const msg =
                 `volumeSize = ${vec3Key(volumeSize)}, positionInChunk = ${vec3Key(positionInChunk)}, channel = ${channel}, offset = ${curOffset}`;
             switch (dataType) {
               case DataType.UINT64: {
                 let low = tester.readUint32(outputChannel++);
                 let high = tester.readUint32(outputChannel++);
                 expect(low).toEqual(rawData[curOffset * 2], `${msg} (low)`);
                 expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
                 break;
               }
               case DataType.FLOAT32: {
                 let result = tester.readFloat(outputChannel++);
//.........这里部分代码省略.........
开发者ID:funkey,项目名称:neuroglancer,代码行数:101,代码来源:chunk_format_testing.ts


示例3: getFortranOrderStrides

export function chunkFormatTest<TextureLayout extends Disposable>(
    dataType: DataType, volumeSize: vec4,
    getChunkFormatAndTextureLayout:
        (gl: GL) => [SingleTextureChunkFormat<TextureLayout>, TextureLayout],
    rawData: TypedArray, encodedData: TypedArray) {
  const numChannels = volumeSize[3];
  let strides = getFortranOrderStrides(volumeSize);
  const outputType = dataType === DataType.FLOAT32 ? 'float' : 'uint';
  const outputs: FragmentShaderTestOutputs = {};
  for (let channelIndex = 0; channelIndex < numChannels; ++channelIndex) {
    if (dataType === DataType.UINT64) {
      outputs[`output${channelIndex}Low`] = outputType;
      outputs[`output${channelIndex}High`] = outputType;
    } else {
      outputs[`output${channelIndex}`] = outputType;
    }
  }
  it(`volumeSize = ${vec3Key(volumeSize)}, numChannels = ${volumeSize[3]}, ` +
         `dataType = ${DataType[dataType]}`,
     () => {
       fragmentShaderTest(outputs, tester => {
         let {gl, builder} = tester;
         let [chunkFormat, textureLayout] = getChunkFormatAndTextureLayout(gl);
         builder.addUniform('highp vec3', 'vChunkPosition');
         builder.addUniform('vec3', 'uChunkDataSize');
         builder.addFragmentCode(glsl_getPositionWithinChunk);
         chunkFormat.defineShader(builder);
         {
           let fragmentMain = '';
           for (let channel = 0; channel < numChannels; ++channel) {
             switch (dataType) {
               case DataType.UINT64:
                 fragmentMain += `
{
  uint64_t value = getDataValue(${channel});
  output${channel}Low = value.value[0];
  output${channel}High = value.value[1];
}
`;
                 break;
               case DataType.FLOAT32:
                 fragmentMain += `
output${channel} = getDataValue(${channel});
`;
                 break;
               default:
                 fragmentMain += `
output${channel} = getDataValue(${channel}).value;
`;
                 break;
             }
           }
           builder.setFragmentMain(fragmentMain);
         }
         tester.build();
         let {shader} = tester;
         shader.bind();
         gl.uniform3fv(shader.uniform('uChunkDataSize'), volumeSize.subarray(0, 3));

         let texture = gl.createTexture();
         tester.registerDisposer(() => {
           gl.deleteTexture(texture);
         });
         const textureTarget = textureTargetForSamplerType[chunkFormat.shaderSamplerType];
         chunkFormat.beginDrawing(gl, shader);
         gl.bindTexture(textureTarget, texture);
         chunkFormat.setTextureData(gl, textureLayout, encodedData);
         chunkFormat.setupTextureLayout(gl, shader, textureLayout);


         // Position within chunk in floating point range [0, chunkDataSize].
         function checkPosition(positionInChunk: vec3) {
           gl.uniform3fv(shader.uniform('vChunkPosition'), positionInChunk);
           chunkFormat.beginDrawing(gl, shader);
           chunkFormat.beginSource(gl, shader);
           chunkFormat.setupTextureLayout(gl, shader, textureLayout);
           gl.bindTexture(textureTarget, texture);
           tester.execute();
           chunkFormat.endDrawing(gl, shader);
           let offset = 0;
           for (let i = 0; i < 3; ++i) {
             offset += Math.floor(Math.max(0, Math.min(positionInChunk[i], volumeSize[i] - 1))) *
                 strides[i];
           }
           const values = tester.values;
           for (let channel = 0; channel < numChannels; ++channel) {
             const curOffset = offset + channel * strides[3];
             const msg = `volumeSize = ${vec3Key(volumeSize)}, ` +
                 `positionInChunk = ${vec3Key(positionInChunk)}, ` +
                 `channel = ${channel}, offset = ${curOffset}`;
             switch (dataType) {
               case DataType.UINT64: {
                 let low = values[`output${channel}Low`];
                 let high = values[`output${channel}High`];
                 expect(low).toBe(rawData[curOffset * 2], `${msg} (low)`);
                 expect(high).toEqual(rawData[curOffset * 2 + 1], `${msg} (high)`);
                 break;
               }
               default: {
                 let result = values[`output${channel}`];
//.........这里部分代码省略.........
开发者ID:google,项目名称:neuroglancer,代码行数:101,代码来源:chunk_format_testing.ts



注:本文中的neuroglancer/util/array.getFortranOrderStrides函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript array.tile2dArray函数代码示例发布时间:2022-05-25
下一篇:
TypeScript status.StatusMessage类代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap