Skip to content

Commit

Permalink
Squash of library_webgpu branch onto 1.38.47
Browse files Browse the repository at this point in the history
acba607 2019-10-02 Fix stencilFaceStateDescriptor (13 days ago) <Corentin Wallez>
bade160 2019-10-02 Fix BeginRenderPass [depth|stencil|]l\LoadValue (13 days ago) <Corentin Wallez>
3c8c196 2019-10-01 more fixes (2 weeks ago) <Kai Ninomiya>
49e0031 2019-10-01 Merge tag '1.38.46' of https://github.com/emscripten-core/emscripten into library_webgpu (2 weeks ago) <Kai Ninomiya>
f76fed7 2019-10-01 tweak (2 weeks ago) <Kai Ninomiya>
b5de062 2019-10-01 Fixes for Aquarium (2 weeks ago) <Kai Ninomiya>
48499b6 2019-09-28 update dawn.h (2 weeks ago) <Kai Ninomiya>
942ab98 2019-09-28 fix makeGetBool (2 weeks ago) <Kai Ninomiya>
671ef41 2019-09-28 [WebGPU] Implement the functions needed for Aquarium (emscripten-core#1) (2 weeks ago) <Corentin Wallez>
44a16c5 2019-09-28 add webgpu canvas support (2 weeks ago) <Kai Ninomiya>
ef164cf 2019-09-28 fix TODOs (2 weeks ago) <Kai Ninomiya>
52164bd 2019-09-27 ton more stuff (3 weeks ago) <Kai Ninomiya>
44b7536 2019-09-26 implement much of what is needed for rendering (3 weeks ago) <Kai Ninomiya>
b1fa126 2019-09-25 refactors (3 weeks ago) <Kai Ninomiya>
80bba8a 2019-09-19 make device less hack, refactors for future, implement a few things (4 weeks ago) <Kai Ninomiya>
f951f63 2019-09-06 Support a few simple WebGPU entry points (via dawn.h) (6 weeks ago) <Kai Ninomiya>
  • Loading branch information
kainino0x authored and hugoam committed Jan 14, 2020
1 parent eecf6f5 commit 75204f7
Show file tree
Hide file tree
Showing 10 changed files with 2,352 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/library_html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,28 @@ var LibraryJSEvents = {
return !GL.contexts[target] || GL.contexts[target].GLctx.isContextLost(); // No context ~> lost context.
},

#if USE_WEBGPU
emscripten_webgpu_get_device__sig: 'i',
emscripten_webgpu_get_device: 'emscripten_webgpu_do_get_device',
emscripten_webgpu_do_get_device__deps: ['$WebGPU'],
emscripten_webgpu_do_get_device: function() {
// TODO(kainino0x): make it possible to actually create devices
assert(Module['preinitializedWebGPUDevice']);
WebGPU.initManagers();
return WebGPU.mgrDevice.create(Module['preinitializedWebGPUDevice']);
},

emscripten_webgpu_get_current_texture__sig: 'i',
emscripten_webgpu_get_current_texture: 'emscripten_webgpu_do_get_current_texture',
emscripten_webgpu_do_get_current_texture__deps: ['$WebGPU'],
emscripten_webgpu_do_get_current_texture: function() {
var swapchain = Module['preinitializedWebGPUSwapChain'];
assert(swapchain);
WebGPU.initManagers();
return WebGPU.mgrTexture.create(swapchain.getCurrentTexture());
},
#endif

#if USE_PTHREADS
emscripten_set_canvas_element_size_calling_thread__deps: ['$JSEvents', 'emscripten_set_offscreencanvas_size_on_target_thread', '_findCanvasEventTarget'],
emscripten_set_canvas_element_size_calling_thread: function(target, width, height) {
Expand Down
890 changes: 890 additions & 0 deletions src/library_webgpu.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/modules.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ var LibraryManager = {
if (AUTO_JS_LIBRARIES) {
libraries = libraries.concat([
'library_webgl.js',
'library_webgpu.js',
'library_openal.js',
'library_vr.js',
'library_sdl.js',
Expand Down
9 changes: 9 additions & 0 deletions src/parseTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -1640,3 +1640,12 @@ function buildStringArray(array) {
return '[]';
}
}

function makeU64ToNumber(lowName, highName) {
var ret = '('
if (ASSERTIONS) {
ret += 'assert(' + highName + ' < 0x200000), ';
}
ret += highName + ' * 0x100000000 + ' + lowName + ')\n'
return ret;
}
3 changes: 3 additions & 0 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ var GL_FFP_ONLY = 0;
// WebGL initialization afterwards will use this GL context to render.
var GL_PREINITIALIZED_CONTEXT = 0;

// If true, enables WebGPU support via dawn.h.
var USE_WEBGPU = 0;

// Enables building of stb-image, a tiny public-domain library for decoding
// images, allowing decoding of images without using the browser's built-in
// decoders. The benefit is that this can be done synchronously, however, it
Expand Down
247 changes: 247 additions & 0 deletions src/struct_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -1629,5 +1629,252 @@
"EMSCRIPTEN_FETCH_SYNCHRONOUS",
"EMSCRIPTEN_FETCH_WAITABLE"
]
},
// ===========================================
// WebGPU
// ===========================================
{
"file": "dawn/dawn.h",
"defines": [],
"structs": {
"DawnBindGroupBinding": [
"binding",
"buffer",
"offset",
"size",
"sampler",
"textureView"
],
"DawnBindGroupLayoutBinding": [
"binding",
"visibility",
"type",
"hasDynamicOffset",
"multisampled",
"textureDimension",
"textureComponentType"
],
"DawnBlendDescriptor": [
"operation",
"srcFactor",
"dstFactor"
],
"DawnBufferCopyView": [
"nextInChain",
"buffer",
"offset",
"rowPitch",
"imageHeight"
],
"DawnBufferDescriptor": [
"nextInChain",
"usage",
"size"
],
"DawnColor": [
"r",
"g",
"b",
"a"
],
"DawnCommandBufferDescriptor": [
"nextInChain",
"label"
],
"DawnCommandEncoderDescriptor": [
"nextInChain"
],
"DawnComputePassDescriptor": [
"nextInChain",
"label"
],
"DawnCreateBufferMappedResult": [
"buffer",
"dataLength",
"data"
],
"DawnExtent3D": [
"width",
"height",
"depth"
],
"DawnFenceDescriptor": [
"nextInChain",
"initialValue"
],
"DawnOrigin3D": [
"x",
"y",
"z"
],
"DawnPipelineLayoutDescriptor": [
"nextInChain",
"bindGroupLayoutCount",
"bindGroupLayouts"
],
"DawnPipelineStageDescriptor": [
"nextInChain",
"module",
"entryPoint"
],
"DawnRasterizationStateDescriptor": [
"nextInChain",
"frontFace",
"cullMode",
"depthBias",
"depthBiasSlopeScale",
"depthBiasClamp"
],
"DawnRenderBundleDescriptor": [
"nextInChain"
],
"DawnRenderBundleEncoderDescriptor": [
"nextInChain",
"colorFormatsCount",
"colorFormats",
"depthStencilFormat",
"sampleCount"
],
"DawnRenderPassDepthStencilAttachmentDescriptor": [
"attachment",
"depthLoadOp",
"depthStoreOp",
"clearDepth",
"stencilLoadOp",
"stencilStoreOp",
"clearStencil"
],
"DawnSamplerDescriptor": [
"nextInChain",
"addressModeU",
"addressModeV",
"addressModeW",
"magFilter",
"minFilter",
"mipmapFilter",
"lodMinClamp",
"lodMaxClamp",
"compare"
],
"DawnShaderModuleDescriptor": [
"nextInChain",
"codeSize",
"code"
],
"DawnStencilStateFaceDescriptor": [
"compare",
"failOp",
"depthFailOp",
"passOp"
],
"DawnSwapChainDescriptor": [
"nextInChain",
"implementation"
],
"DawnTextureViewDescriptor": [
"nextInChain",
"format",
"dimension",
"baseMipLevel",
"mipLevelCount",
"baseArrayLayer",
"arrayLayerCount",
"aspect"
],
"DawnVertexAttributeDescriptor": [
"shaderLocation",
"offset",
"format"
],
"DawnBindGroupDescriptor": [
"nextInChain",
"layout",
"bindingCount",
"bindings"
],
"DawnBindGroupLayoutDescriptor": [
"nextInChain",
"bindingCount",
"bindings"
],
"DawnColorStateDescriptor": [
"nextInChain",
"format",
"alphaBlend",
"colorBlend",
"writeMask"
],
"DawnComputePipelineDescriptor": [
"nextInChain",
"layout",
"computeStage"
],
"DawnDepthStencilStateDescriptor": [
"nextInChain",
"format",
"depthWriteEnabled",
"depthCompare",
"stencilFront",
"stencilBack",
"stencilReadMask",
"stencilWriteMask"
],
"DawnRenderPassColorAttachmentDescriptor": [
"attachment",
"resolveTarget",
"loadOp",
"storeOp",
"clearColor"
],
"DawnTextureCopyView": [
"nextInChain",
"texture",
"mipLevel",
"arrayLayer",
"origin"
],
"DawnTextureDescriptor": [
"nextInChain",
"usage",
"dimension",
"size",
"arrayLayerCount",
"format",
"mipLevelCount",
"sampleCount"
],
"DawnVertexBufferDescriptor": [
"stride",
"stepMode",
"attributeCount",
"attributes"
],
"DawnRenderPassDescriptor": [
"colorAttachmentCount",
"colorAttachments",
"depthStencilAttachment"
],
"DawnVertexInputDescriptor": [
"nextInChain",
"indexFormat",
"bufferCount",
"buffers"
],
"DawnRenderPipelineDescriptor": [
"nextInChain",
"layout",
"vertexStage",
"fragmentStage",
"vertexInput",
"primitiveTopology",
"rasterizationState",
"sampleCount",
"depthStencilState",
"colorStateCount",
"colorStates",
"sampleMask",
"alphaToCoverageEnabled"
]
}
}
]
2 changes: 1 addition & 1 deletion src/support.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ function makeBigInt(low, high, unsigned) {
function dynCall(sig, ptr, args) {
if (args && args.length) {
#if ASSERTIONS
assert(args.length == sig.length-1);
assert(args.length === sig.substring(1).replace(/j/g, '--').length);
#endif
#if ASSERTIONS
assert(('dynCall_' + sig) in Module, 'bad function pointer type - no table for sig \'' + sig + '\'');
Expand Down
Loading

0 comments on commit 75204f7

Please sign in to comment.