Skip to content

Commit

Permalink
feat(cloud-picture): fix UpdatePathTracingCPJob->_buildAndSetVertexBu…
Browse files Browse the repository at this point in the history
…fferData->set texCoords

solution
fix index;
flip vertical;
  • Loading branch information
yyc-git committed Sep 27, 2020
1 parent ac0b57b commit 982c5ae
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ let _buildAndSetVertexBufferData = device => {
let length = PointsGeometryCPRepo.getVerticesOffset();

let i = ref(0);
let texCoordsIndex = ref(0);
let j = ref(0);
while (i^ < length) {
Float32Array.unsafe_set(
Expand All @@ -396,12 +397,12 @@ let _buildAndSetVertexBufferData = device => {
Float32Array.unsafe_set(
bufferData,
j^ + 4,
Float32Array.unsafe_get(texCoords, i^),
Float32Array.unsafe_get(texCoords, texCoordsIndex^),
);
Float32Array.unsafe_set(
bufferData,
j^ + 5,
Float32Array.unsafe_get(texCoords, i^ + 1),
1.0 -. Float32Array.unsafe_get(texCoords, texCoordsIndex^ + 1),
);

Float32Array.unsafe_set(
Expand Down Expand Up @@ -437,6 +438,7 @@ let _buildAndSetVertexBufferData = device => {
);

i := i^ + 3;
texCoordsIndex := texCoordsIndex^ + 2;
j := j^ + 16;
};

Expand Down Expand Up @@ -485,7 +487,6 @@ let _getMapLayerIndex = mapImageIdOpt => {
| None => _getMapLayerIndexForNotExist()
| Some(imageId) =>
TextureArrayWebGPUCPRepo.getLayerIndex(imageId->ImageIdVO.value)

->OptionSt.getWithDefault(_getMapLayerIndexForNotExist())
}
)
Expand Down
35 changes: 13 additions & 22 deletions test/run/cloud_picture/integration/updatePathTracingCPJob_test.re
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ let _ =
let queue = WebGPUDependencyTool.createQueueObject();
WebGPUCPTool.setQueue(queue);

PathTracingPassCPTool.buildAndSetAllBufferData(device);
PathTracingPassCPTool.createAndSetShaderBindingTable();
PathTracingPassCPTool.createAndSetAllBindGroupLayoutsAndBindGroupsExceptRayTracing();
PassCPTool.buildAndSetAllBufferData(
Expand Down Expand Up @@ -1016,14 +1015,6 @@ let _ =
});

describe("build and set vertex buffer data", () => {
// beforeEach(() => {
// TestCPTool.updateBufferCount(
// ~geometryCount=2,
// ~geometryPointCount=100,
// (),
// )
// });

describe("build vertex buffer data", () => {
_testCreateBuffer(
~getBufferSizeFunc=
Expand All @@ -1033,7 +1024,7 @@ let _ =
});

testPromise(
"set each render geometry's vertices, texCoords, normals, tangents(compute) to buffer data and set buffer's data",
"set each render geometry's vertices, texCoords(should flip vertical), normals, tangents(compute) to buffer data and set buffer's data",
() => {
let _ = _prepare();
let setSubFloat32DataStubData =
Expand Down Expand Up @@ -1064,7 +1055,7 @@ let _ =
11.,
0.,
0.5,
0.,
1.,
0.,
0.,
1.,
Expand All @@ -1079,8 +1070,8 @@ let _ =
2.,
3.,
0.,
1.,
0.20000000298023224,
0.10000000149011612,
0.,
0.,
0.,
2.,
Expand All @@ -1095,8 +1086,8 @@ let _ =
2.,
3.5,
0.,
0.10000000149011612,
0.10000000149011612,
0.20000000298023224,
0.5,
0.,
0.,
3.,
Expand All @@ -1111,8 +1102,8 @@ let _ =
10.,
11.,
0.,
0.699999988079071,
0.11999999731779099,
0.10000000149011612,
0.8999999761581421,
0.,
0.,
2.,
Expand All @@ -1128,7 +1119,7 @@ let _ =
1.,
0.,
0.6000000238418579,
0.23999999463558197,
0.30000001192092896,
0.,
0.,
2.,
Expand All @@ -1143,8 +1134,8 @@ let _ =
2.5,
(-1.5),
0.,
0.,
0.,
0.11999999731779099,
0.5,
0.,
0.,
3.,
Expand All @@ -1159,8 +1150,8 @@ let _ =
3.,
10.,
0.,
0.,
0.,
0.6000000238418579,
0.7599999904632568,
0.,
0.,
(-1.),
Expand Down

0 comments on commit 982c5ae

Please sign in to comment.