-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(architecture): add UpdateAccumulationCPJobEntity, RenderAccumula…
…tionCPJobEntity, RenderPathTracingCPJobEntity, EndRenderCPJobEntity pass unit test;
- Loading branch information
Showing
19 changed files
with
932 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/run/domain_layer/domain/pipeline/pipeline/entity/jobs/render/EndRenderCPJobEntity.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
let create = () => JobEntity.create("end_render"); | ||
|
||
let exec = () => { | ||
Tuple2.collectOption(WebGPUCPRepo.getWindow(), WebGPUCPRepo.getSwapChain()) | ||
->Result.mapSuccess(((window, swapChain)) => { | ||
WebGPUCoreDpRunAPI.unsafeGet().swapChain.present(swapChain); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().window.pollEvents(window); | ||
}) | ||
->WonderBsMost.Most.just; | ||
}; |
88 changes: 88 additions & 0 deletions
88
...domain_layer/domain/pipeline/pipeline/entity/jobs/render/RenderAccumulationCPJobEntity.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
let create = () => JobEntity.create("render_accumulation"); | ||
|
||
let exec = () => { | ||
Tuple6.collectOption( | ||
WebGPUCPRepo.getDevice(), | ||
WebGPUCPRepo.getQueue(), | ||
WebGPUCPRepo.getWindow(), | ||
WebGPUCPRepo.getSwapChain(), | ||
AccumulationPassCPRepo.getStaticBindGroupData(), | ||
AccumulationPassCPRepo.getPipeline(), | ||
) | ||
->Result.mapSuccess( | ||
( | ||
( | ||
device, | ||
queue, | ||
window, | ||
swapChain, | ||
{setSlot, bindGroup}: PassCPPOType.staticBindGroupData, | ||
pipeline, | ||
), | ||
) => { | ||
let backBufferView = | ||
WebGPUCoreDpRunAPI.unsafeGet().swapChain.getCurrentTextureView( | ||
(), | ||
swapChain, | ||
); | ||
|
||
let commandEncoder = | ||
WebGPUCoreDpRunAPI.unsafeGet().device.createCommandEncoder( | ||
IWebGPUCoreDp.commandEncoderDescriptor(), | ||
device, | ||
); | ||
let renderPass = | ||
WebGPUCoreDpRunAPI.unsafeGet().commandEncoder.beginRenderPass( | ||
IWebGPUCoreDp.passEncoderRenderDescriptor( | ||
~colorAttachments=[| | ||
{ | ||
"clearColor": { | ||
"r": 0.0, | ||
"g": 0.0, | ||
"b": 0.0, | ||
"a": 1.0, | ||
}, | ||
"loadOp": "clear", | ||
"storeOp": "store", | ||
"attachment": backBufferView, | ||
}, | ||
|], | ||
(), | ||
), | ||
commandEncoder, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().passEncoder.render.setPipeline( | ||
pipeline, | ||
renderPass, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().passEncoder.render.setBindGroup( | ||
setSlot, | ||
bindGroup, | ||
renderPass, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().passEncoder.render.draw( | ||
3, | ||
1, | ||
0, | ||
0, | ||
renderPass, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().passEncoder.render.endPass( | ||
renderPass, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().queue.submit( | ||
[| | ||
WebGPUCoreDpRunAPI.unsafeGet().commandEncoder.finish( | ||
commandEncoder, | ||
), | ||
|], | ||
queue, | ||
); | ||
}) | ||
->WonderBsMost.Most.just; | ||
}; |
64 changes: 64 additions & 0 deletions
64
.../domain_layer/domain/pipeline/pipeline/entity/jobs/render/RenderPathTracingCPJobEntity.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
let create = () => JobEntity.create("render_pathTracing"); | ||
|
||
let exec = () => { | ||
Tuple4.collectOption( | ||
WebGPUCPRepo.getDevice(), | ||
WebGPUCPRepo.getQueue(), | ||
WebGPUCPRepo.getWindow(), | ||
PathTracingPassCPRepo.getPipeline(), | ||
) | ||
->Result.mapSuccess(((device, queue, window, pipeline)) => { | ||
let commandEncoder = | ||
WebGPUCoreDpRunAPI.unsafeGet().device.createCommandEncoder( | ||
IWebGPUCoreDp.commandEncoderDescriptor(), | ||
device, | ||
); | ||
let rtPass = | ||
WebGPURayTracingDpRunAPI.unsafeGet().commandEncoder. | ||
beginRayTracingPass( | ||
IWebGPURayTracingDp.passEncoderRayTracingDescriptor(), | ||
commandEncoder, | ||
); | ||
|
||
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder. | ||
setPipeline( | ||
pipeline, | ||
rtPass, | ||
); | ||
|
||
PathTracingPassCPRepo.getAllStaticBindGroupData() | ||
->ListSt.forEach( | ||
({setSlot, bindGroup}: PassCPPOType.staticBindGroupData) => { | ||
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder. | ||
setBindGroup( | ||
setSlot, | ||
bindGroup, | ||
rtPass, | ||
) | ||
}); | ||
|
||
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.traceRays( | ||
0, // sbt ray_generation offset | ||
1, // sbt ray-hit offset | ||
2, // sbt ray_miss offset | ||
WebGPUCoreDpRunAPI.unsafeGet().window.getWidth(window), | ||
WebGPUCoreDpRunAPI.unsafeGet().window.getHeight(window), | ||
1, // query depth dimension | ||
rtPass, | ||
); | ||
|
||
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.endPass( | ||
rtPass, | ||
); | ||
|
||
WebGPUCoreDpRunAPI.unsafeGet().queue.submit( | ||
[| | ||
WebGPUCoreDpRunAPI.unsafeGet().commandEncoder.finish( | ||
commandEncoder, | ||
), | ||
|], | ||
queue, | ||
); | ||
}) | ||
->WonderBsMost.Most.just; | ||
}; |
7 changes: 7 additions & 0 deletions
7
...domain_layer/domain/pipeline/pipeline/entity/jobs/render/UpdateAccumulationCPJobEntity.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
let create = () => JobEntity.create("update_accumulation"); | ||
|
||
let exec = () => { | ||
AccumulationPassCPDoService.increaseSampleAccumulation() | ||
->Result.succeed | ||
->WonderBsMost.Most.just; | ||
}; |
25 changes: 25 additions & 0 deletions
25
...omain_layer/domain/pipeline/pipeline/entity/jobs/render/UpdatePassForRenderCPJobEntity.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
let create = () => JobEntity.create("update_pass_for_render"); | ||
|
||
let _updateCommonBufferData = ((commonBuffer, commonBufferData)) => { | ||
let totalSampleCount = PassCPRepo.getTotalSampleCount(); | ||
|
||
TypeArrayCPRepoUtils.setUint32_1(1, totalSampleCount, commonBufferData) | ||
->Result.tap(() => { | ||
WebGPUCoreDpRunAPI.unsafeGet().buffer.setSubUint32Data( | ||
0, | ||
commonBufferData, | ||
commonBuffer->UniformBufferVO.value, | ||
); | ||
|
||
PassCPRepo.setCommonBufferData((commonBuffer, commonBufferData)); | ||
}); | ||
}; | ||
|
||
let exec = () => { | ||
PassCPRepo.getCommonBufferData() | ||
->OptionSt.get | ||
->Result.bind(((commonBuffer, commonBufferData)) => { | ||
_updateCommonBufferData((commonBuffer, commonBufferData)) | ||
}) | ||
->WonderBsMost.Most.just; | ||
}; |
5 changes: 5 additions & 0 deletions
5
src/run/domain_layer/domain/pipeline/pipeline/service/AccumulationPassCPDoService.re
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
let increaseSampleAccumulation = () => { | ||
PassCPRepo.setTotalSampleCount( | ||
PassCPRepo.getTotalSampleCount() + PassCPRepo.getSampleCount(), | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.