Skip to content

Commit

Permalink
Merge pull request #5 from Wonder-Technology/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
奇变偶不变 authored Sep 15, 2020
2 parents ff6d67c + 5e4a2bf commit 475dd58
Show file tree
Hide file tree
Showing 25 changed files with 246 additions and 76 deletions.
29 changes: 29 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.DS_Store
.merlin
.idea/
.vscode/
jest_0/
reference/
node_modules/
mine/

test/

.github/

donate/

lib/bs/

lib/js/test/

coverage

dist/

npm-debug

.bsb.lock

yarn.lock

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wonder.js",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.2.2",
"authors": "Wonder",
"description": "",
"homepage": "https://github.com/Wonder-Technology/Wonder.js",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ type passEncoderCompute = {
setBindGroup:
(bindingPoint, bindGroupObject, passEncoderComputeObject) => unit,
setDynamicBindGroup:
(bindingPoint, bindGroupObject, array(int), passEncoderRenderObject) =>
(bindingPoint, bindGroupObject, array(int), passEncoderComputeObject) =>
unit,
dispatchX: (x, passEncoderComputeObject) => unit,
endPass: passEncoderComputeObject => unit,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ type queryWidthDimension = int;
type queryHeightDimension = int;
type queryDepthDimension = int;

type passEncoderRayTracing = {
type passEncoder = {
setPipeline: (rayTracingPipelineObject, passEncoderRayTracingObject) => unit,
setBindGroup:
(bindingPoint, bindGroupObject, passEncoderRayTracingObject) => unit,
Expand Down Expand Up @@ -249,7 +249,7 @@ type bufferUsage = {

type webgpuRayTracing = {
accelerationContainer,
passEncoderRayTracing,
passEncoder,
commandEncoder,
device,
accelerationContainerUsage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ let parse = ({name, groups, firstGroup}) => {
pipelineStream
->Obj.magic
->WonderBsMost.Most.map(_ => Result.succeed(), _)
->WonderBsMost.Most.recoverWith(
err => {WonderBsMost.Most.just(err->Result.fail)},
_,
)
})
})
->Result.mapSuccess(Tuple2.create(PipelineEntity.create(name)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ let load = window => {
)
->map(
swapChainFormat => {
(adapter, device, context, queue, swapChainFormat)
(window, adapter, device, context, queue, swapChainFormat)
},
_,
);
Expand Down
18 changes: 12 additions & 6 deletions src/construct/domain_layer/library/structure/Result.re
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ let _buildErr = msg => msg->Exception.buildErr;

let failWith = x => x->_buildErr->fail;

let either = (twoTrackInput, successFunc, failureFunc) =>
switch (twoTrackInput) {
let isSuccess = result => {
switch (result) {
| Success(s) => true
| Fail(f) => false
};
};

let either = (result, successFunc, failureFunc) =>
switch (result) {
| Success(s) => successFunc(s)
| Fail(f) => failureFunc(f)
};

let bind = (twoTrackInput, switchFunc) =>
either(twoTrackInput, switchFunc, fail);
let bind = (result, switchFunc) => either(result, switchFunc, fail);

let tap = (twoTrackInput, oneTrackFunc) =>
let tap = (result, oneTrackFunc) =>
either(
twoTrackInput,
result,
result => {
result->oneTrackFunc->ignore;
result->succeed;
Expand Down
20 changes: 10 additions & 10 deletions src/run/cloud_picture/application_layer/DirectorCPApService.re
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ let _createAndSetAllComponentPOs = () => {
});
};

let prepare = (pictureSize, sampleCount) => {
_createAndSetAllComponentPOs()
->Result.mapSuccess(() => {
PictureCPDoService.setSize(pictureSize);
PassCPDoService.setSampleCount(sampleCount);
});
};

let _injectDependencies = () => {
RepoDpRunAPI.set({
sceneRepo: {
Expand Down Expand Up @@ -173,13 +165,21 @@ let _injectDependencies = () => {
});
};

let prepare = (pictureSize, sampleCount) => {
_injectDependencies();

_createAndSetAllComponentPOs()
->Result.mapSuccess(() => {
PictureCPDoService.setSize(pictureSize);
PassCPDoService.setSampleCount(sampleCount);
});
};

let _parseAndSetPipelineStream = pipelineData => {
pipelineData->PipelineRunAPI.parsePipelineData;
};

let init = () => {
_injectDependencies();

JobCPDoService.registerAllJobs();

PipelineCPDoService.getInitPipelineData()->_parseAndSetPipelineStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ let _createAndSetBindGroup =
(
(resolutionBuffer, resolutionBufferData),
(pixelBuffer, pixelBufferSize),
(commonBuffer, commonBufferData),
(accumulationPixelBuffer, accumulationPixelBufferSize),
),
) => {
Expand All @@ -37,22 +38,25 @@ let _createAndSetBindGroup =
"entries": [|
IWebGPUCoreDp.layoutBinding(
~binding=0,
~visibility=
WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~visibility=WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~type_="storage-buffer",
(),
),
IWebGPUCoreDp.layoutBinding(
~binding=1,
~visibility=
WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~visibility=WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~type_="storage-buffer",
(),
),
IWebGPUCoreDp.layoutBinding(
~binding=2,
~visibility=
WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~visibility=WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~type_="uniform-buffer",
(),
),
IWebGPUCoreDp.layoutBinding(
~binding=3,
~visibility=WebGPUCoreDpRunAPI.unsafeGet().shaderStage.fragment,
~type_="uniform-buffer",
(),
),
Expand Down Expand Up @@ -89,6 +93,13 @@ let _createAndSetBindGroup =
resolutionBufferData->PassCPDoService.getResolutionBufferDataSize,
(),
),
IWebGPUCoreDp.binding(
~binding=3,
~buffer=commonBuffer,
~offset=0,
~size=commonBufferData->PassCPDoService.getCommonBufferDataSize,
(),
),
|],
},
device,
Expand All @@ -99,7 +110,7 @@ let _createAndSetBindGroup =
};

let _createAndSetPipeline = (device, swapChainFormat, bindGroupLayout) => {
let baseShaderPath = "src/run/cloud_picture/domain_layer/domain/pipeline/shader/accumulation";
let baseShaderPath = "src/run/cloud_picture/domain_layer/domain/shader/accumulation";

let vertexShaderModule =
WebGPUCoreDpRunAPI.unsafeGet().device.createShaderModule(
Expand Down Expand Up @@ -168,16 +179,18 @@ let exec = () => {
_buildAccumulationPixelBufferData(window, device)
->AccumulationPassCPRepo.setAccumulationPixelBufferData;

Tuple3.collectOption(
Tuple4.collectOption(
PassCPRepo.getResolutionBufferData(),
PassCPRepo.getPixelBufferData(),
PassCPRepo.getCommonBufferData(),
AccumulationPassCPRepo.getAccumulationPixelBufferData(),
)
->Result.mapSuccess(
(
(
(resolutionBuffer, resolutionBufferData),
(pixelBuffer, pixelBufferSize),
(commonBuffer, commonBufferData),
(accumulationPixelBuffer, accumulationPixelBufferSize),
) as allBufferData,
) => {
Expand All @@ -186,6 +199,7 @@ let exec = () => {
(
(resolutionBuffer->UniformBufferVO.value, resolutionBufferData),
(pixelBuffer->StorageBufferVO.value, pixelBufferSize),
(commonBuffer->UniformBufferVO.value, commonBufferData),
(
accumulationPixelBuffer->StorageBufferVO.value,
accumulationPixelBufferSize,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,24 +240,20 @@ let _createShaderBindingTable = device => {
{
"module": rayGenShaderModule,
"stage":
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_generation,
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_generation,
},
{
"module": rayRChitShaderModule,
"stage":
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_closest_hit,
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_closest_hit,
},
{
"module": rayMissShaderModule,
"stage":
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_miss,
"stage": WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_miss,
},
{
"module": rayMissShadowShaderModule,
"stage":
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_miss,
"stage": WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_miss,
},
|],
"groups": [|
Expand All @@ -271,8 +267,8 @@ let _createShaderBindingTable = device => {
~closestHitIndex=1,
(),
),
IWebGPURayTracingDp.group(~type_="general", ~closestHitIndex=2, ()),
IWebGPURayTracingDp.group(~type_="general", ~closestHitIndex=3, ()),
IWebGPURayTracingDp.group(~type_="general", ~generalIndex=2, ()),
IWebGPURayTracingDp.group(~type_="general", ~generalIndex=3, ()),
|],
},
device,
Expand All @@ -293,9 +289,7 @@ let exec = () => {
~binding=0,
~visibility=
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_generation
lor WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_closest_hit,
ray_generation,
~type_="uniform-buffer",
(),
),
Expand Down Expand Up @@ -338,9 +332,7 @@ let exec = () => {
~binding=0,
~visibility=
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_generation
lor WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_closest_hit,
ray_closest_hit,
~type_="storage-buffer",
(),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ let exec = () => {
})
->WebGPUCoreRunAPI.load
->WonderBsMost.Most.map(
((adapter, device, context, queue, swapChainFormat)) => {
((window, adapter, device, context, queue, swapChainFormat)) => {
let swapChain =
WebGPUCoreDpRunAPI.unsafeGet().context.configureSwapChain(
{"device": device, "format": swapChainFormat},
context,
);

WebGPUCPRepo.setWindow(window);
WebGPUCPRepo.setDevice(device);
WebGPUCPRepo.setAdapter(adapter);
WebGPUCPRepo.setContext(context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ let exec = () => {
commandEncoder,
);

WebGPURayTracingDpRunAPI.unsafeGet().passEncoderRayTracing.
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.
setPipeline(
pipeline,
rtPass,
Expand All @@ -29,15 +29,15 @@ let exec = () => {
PathTracingPassCPRepo.getAllStaticBindGroupData()
->ListSt.forEach(
({setSlot, bindGroup}: PassCPPOType.staticBindGroupData) => {
WebGPURayTracingDpRunAPI.unsafeGet().passEncoderRayTracing.
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.
setBindGroup(
setSlot,
bindGroup,
rtPass,
)
});

WebGPURayTracingDpRunAPI.unsafeGet().passEncoderRayTracing.traceRays(
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.traceRays(
0, // sbt ray-generation offset
1, // sbt ray-hit offset
2, // sbt ray-miss offset
Expand All @@ -47,7 +47,7 @@ let exec = () => {
rtPass,
);

WebGPURayTracingDpRunAPI.unsafeGet().passEncoderRayTracing.endPass(
WebGPURayTracingDpRunAPI.unsafeGet().passEncoder.endPass(
rtPass,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ let _createAndAddRayTracingBindGroup =
IWebGPUCoreDp.layoutBinding(
~binding=2,
~visibility=
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_generation
lor WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.
ray_closest_hit,
WebGPURayTracingDpRunAPI.unsafeGet().shaderStage.ray_generation,
~type_="uniform-buffer",
(),
),
Expand Down Expand Up @@ -401,7 +399,7 @@ let _createAndAddRayTracingBindGroup =
~binding=2,
~buffer=commonBuffer->UniformBufferVO.value,
~offset=0,
~size=commonBufferData->PassCPDoService.getCommonBufferSize,
~size=commonBufferData->PassCPDoService.getCommonBufferDataSize,
(),
),
IWebGPURayTracingDp.binding(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ let setSampleCount = sampleCount => {
PassCPRepo.setSampleCount(sampleCount);
};

let getCommonBufferSize = commonBufferData =>
let getCommonBufferDataSize = commonBufferData =>
commonBufferData->Js.Typed_array.Uint32Array.byteLength;

let getResolutionBufferDataSize = resolutionBufferData =>
Expand Down
Loading

0 comments on commit 475dd58

Please sign in to comment.