@@ -533,7 +533,7 @@ function getOutput5DCoords(
533
533
shape : [ number , number , number , number , number ] ,
534
534
texShape : [ number , number ] ) : string {
535
535
const coordsFromIndexSnippet = shader_util . getLogicalCoordinatesFromFlatIndex (
536
- [ 'r' , 'c' , 'd' , 'd2' , 'd3' ] , shape ) ;
536
+ [ 'r' , 'c' , 'd' , 'd2' , 'd3' ] , shape , 'index' , 'outputShape' ) ;
537
537
538
538
return `
539
539
ivec5 getOutputCoords() {
@@ -554,7 +554,7 @@ function getOutput6DCoords(
554
554
shape : [ number , number , number , number , number , number ] ,
555
555
texShape : [ number , number ] ) : string {
556
556
const coordsFromIndexSnippet = shader_util . getLogicalCoordinatesFromFlatIndex (
557
- [ 'r' , 'c' , 'd' , 'd2' , 'd3' , 'd4' ] , shape ) ;
557
+ [ 'r' , 'c' , 'd' , 'd2' , 'd3' , 'd4' ] , shape , 'index' , 'outputShape' ) ;
558
558
559
559
return `
560
560
ivec6 getOutputCoords() {
@@ -847,7 +847,7 @@ function getSampler2D(inputInfo: InputInfo): string {
847
847
// index is used directly as physical (no risk of float16 overflow).
848
848
return `
849
849
float ${ funcName } (int row, int col) {
850
- float index = dot(vec3(row, col, ${ offset } ),
850
+ float index = dot(vec3(row, col, ${ offset } ),
851
851
vec3(${ shapeUniform } [1], 1, 1));
852
852
vec2 uv = vec2(0.5, (index + 0.5) / float(${ texShapeUniform } [0]));
853
853
return sampleTexture(${ texName } , uv);
@@ -858,7 +858,7 @@ function getSampler2D(inputInfo: InputInfo): string {
858
858
// index is used directly as physical (no risk of float16 overflow).
859
859
return `
860
860
float ${ funcName } (int row, int col) {
861
- float index = dot(vec3(row, col, ${ offset } ),
861
+ float index = dot(vec3(row, col, ${ offset } ),
862
862
vec3(${ shapeUniform } [1], 1, 1));
863
863
vec2 uv = vec2((index + 0.5) / float(${ texShapeUniform } [1]), 0.5);
864
864
return sampleTexture(${ texName } , uv);
@@ -870,7 +870,7 @@ function getSampler2D(inputInfo: InputInfo): string {
870
870
float ${ funcName } (int row, int col) {
871
871
// Explicitly use integer operations as dot() only works on floats.
872
872
int index = row * ${ shapeUniform } [1] + col + ${ offset } ;
873
- vec2 uv = uvFromFlat(${ texShapeUniform } [0],
873
+ vec2 uv = uvFromFlat(${ texShapeUniform } [0],
874
874
${ texShapeUniform } [1], index);
875
875
return sampleTexture(${ texName } , uv);
876
876
}
@@ -961,7 +961,7 @@ function getSampler3D(inputInfo: InputInfo): string {
961
961
float texR = float(row);
962
962
float texC = dot(vec2(col, depth), vec2(${ stride1Prog } , 1));
963
963
vec2 uv = (vec2(texC, texR) + halfCR) /
964
- vec2(float(${ texShapeUniform } [1]),
964
+ vec2(float(${ texShapeUniform } [1]),
965
965
float(${ texShapeUniform } [0]));
966
966
return sampleTexture(${ texName } , uv);
967
967
}
@@ -985,9 +985,9 @@ function getSampler3D(inputInfo: InputInfo): string {
985
985
return `
986
986
float ${ funcName } (int row, int col, int depth) {
987
987
// Explicitly use integer operations as dot() only works on floats.
988
- int index = row * ${ stride0Prog } + col * ${ stride1Prog } + depth +
988
+ int index = row * ${ stride0Prog } + col * ${ stride1Prog } + depth +
989
989
${ offset } ;
990
- vec2 uv = uvFromFlat(${ texShapeUniform } [0],
990
+ vec2 uv = uvFromFlat(${ texShapeUniform } [0],
991
991
${ texShapeUniform } [1], index);
992
992
return sampleTexture(${ texName } , uv);
993
993
}
@@ -1077,7 +1077,7 @@ function getSampler4D(inputInfo: InputInfo): string {
1077
1077
dot(vec3(col, depth, depth2),
1078
1078
vec3(${ stride1Prog } , ${ stride2Prog } , 1));
1079
1079
vec2 uv = (vec2(texC, texR) + halfCR) /
1080
- vec2(float(${ texShapeUniform } [1]),
1080
+ vec2(float(${ texShapeUniform } [1]),
1081
1081
float(${ texShapeUniform } [0]));
1082
1082
return sampleTexture(${ texName } , uv);
1083
1083
}
@@ -1089,7 +1089,7 @@ function getSampler4D(inputInfo: InputInfo): string {
1089
1089
float ${ funcName } (int row, int col, int depth, int depth2) {
1090
1090
float texR = dot(vec3(row, col, depth),
1091
1091
vec3(
1092
- ${ shapeUniform } [1] * ${ shapeUniform } [2],
1092
+ ${ shapeUniform } [1] * ${ shapeUniform } [2],
1093
1093
${ shapeUniform } [2], 1));
1094
1094
float texC = float(depth2);
1095
1095
vec2 uv = (vec2(texC, texR) + halfCR) /
@@ -1107,8 +1107,8 @@ function getSampler4D(inputInfo: InputInfo): string {
1107
1107
int index = row * ${ stride0Prog } + col * ${ stride1Prog } +
1108
1108
depth * ${ stride2Prog } + depth2;
1109
1109
vec2 uv = uvFromFlat(
1110
- ${ texShapeUniform } [0],
1111
- ${ texShapeUniform } [1],
1110
+ ${ texShapeUniform } [0],
1111
+ ${ texShapeUniform } [1],
1112
1112
index + ${ offset } );
1113
1113
return sampleTexture(${ texName } , uv);
1114
1114
}
@@ -1168,10 +1168,10 @@ function getSampler5D(inputInfo: InputInfo): string {
1168
1168
float ${ funcName } (int row, int col, int depth, int depth2, int depth3) {
1169
1169
int texR = row;
1170
1170
float texC = dot(vec4(col, depth, depth2, depth3),
1171
- vec4(${ stride1Prog } , ${ stride2Prog } ,
1171
+ vec4(${ stride1Prog } , ${ stride2Prog } ,
1172
1172
${ stride3Prog } , 1));
1173
1173
vec2 uv = (vec2(texC, texR) + halfCR) /
1174
- vec2(float(${ texShapeUniform } [1]),
1174
+ vec2(float(${ texShapeUniform } [1]),
1175
1175
float(${ texShapeUniform } [0]));
1176
1176
return sampleTexture(${ texName } , uv);
1177
1177
}
@@ -1188,7 +1188,7 @@ function getSampler5D(inputInfo: InputInfo): string {
1188
1188
${ shapeUniform } [2] * ${ shapeUniform } [3], ${ shapeUniform } [3], 1));
1189
1189
int texC = depth3;
1190
1190
vec2 uv = (vec2(texC, texR) + halfCR) /
1191
- vec2(float(${ texShapeUniform } [1]),
1191
+ vec2(float(${ texShapeUniform } [1]),
1192
1192
float(${ texShapeUniform } [0]));
1193
1193
return sampleTexture(${ texName } , uv);
1194
1194
}
@@ -1270,7 +1270,7 @@ function getSampler6D(inputInfo: InputInfo): string {
1270
1270
vec4(${ stride1Prog } , ${ stride2Prog } , ${ stride3Prog } , ${ stride4Prog } ))
1271
1271
+ float(depth4);
1272
1272
vec2 uv = (vec2(texC, texR) + halfCR) /
1273
- vec2(float(${ texShapeUniform } [1]),
1273
+ vec2(float(${ texShapeUniform } [1]),
1274
1274
float(${ texShapeUniform } [0]));
1275
1275
return sampleTexture(${ texName } , uv);
1276
1276
}
@@ -1282,7 +1282,7 @@ function getSampler6D(inputInfo: InputInfo): string {
1282
1282
float ${ funcName } (int row, int col, int depth,
1283
1283
int depth2, int depth3, int depth4) {
1284
1284
float texR = dot(vec4(row, col, depth, depth2),
1285
- vec4(${ shapeUniform } [1] * ${ shapeUniform } [2] * ${ shapeUniform } [3]
1285
+ vec4(${ shapeUniform } [1] * ${ shapeUniform } [2] * ${ shapeUniform } [3]
1286
1286
* ${ shapeUniform } [4]},
1287
1287
${ shapeUniform } [2] * ${ shapeUniform } [3] * ${ shapeUniform [ 4 ] } ,
1288
1288
${ shapeUniform } [3] * ${ shapeUniform } [4],
@@ -1300,7 +1300,7 @@ function getSampler6D(inputInfo: InputInfo): string {
1300
1300
int depth2, int depth3, int depth4) {
1301
1301
// Explicitly use integer operations as dot() only works on floats.
1302
1302
int index = row * ${ stride0Prog } + col * ${ stride1Prog } + depth * ${
1303
- stride2Prog } + depth2 * ${ stride3Prog } + depth3 * ${ stride4Prog } +
1303
+ stride2Prog } + depth2 * ${ stride3Prog } + depth3 * ${ stride4Prog } +
1304
1304
depth4 + ${ offset } ;
1305
1305
vec2 uv = uvFromFlat(${ texShapeUniform } [0], ${ texShapeUniform } [1], index);
1306
1306
return sampleTexture(${ texName } , uv);
0 commit comments