Skip to content

Commit

Permalink
Micro-optimize wgpu_command_encoder_begin_render_pass() to avoid an o…
Browse files Browse the repository at this point in the history
…bject
  • Loading branch information
juj committed Jun 28, 2021
1 parent 9be14f0 commit 2038086
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/lib_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -741,21 +741,20 @@ mergeInto(LibraryManager.library, {
var colorAttachments = [];
var numColorAttachments = HEAP32[descriptor++];
var colorAttachmentsIdx = HEAPU32[descriptor++] >> 2;
var colorAttachmentsIdxDbl = colorAttachmentsIdx + 4 >> 1; // Alias the view for HEAPF64.
{{{ wassert('colorAttachmentsIdx % 2 == 0'); }}} // Must be aligned at double boundary
while(numColorAttachments--) {
colorAttachments.push({
'view': wgpu[HEAPU32[colorAttachmentsIdx]],
'resolveTarget': wgpu[HEAPU32[colorAttachmentsIdx+1]],
'storeOp': _wgpuStrings[HEAPU32[colorAttachmentsIdx+2]],
'loadValue': _wgpuStrings[HEAPU32[colorAttachmentsIdx+3]] || {
'r': HEAPF64[colorAttachmentsIdx+4>>1],
'g': HEAPF64[colorAttachmentsIdx+6>>1],
'b': HEAPF64[colorAttachmentsIdx+8>>1],
'a': HEAPF64[colorAttachmentsIdx+10>>1],
}
'loadValue': _wgpuStrings[HEAPU32[colorAttachmentsIdx+3]] ||
[HEAPF64[colorAttachmentsIdxDbl ], HEAPF64[colorAttachmentsIdxDbl+1],
HEAPF64[colorAttachmentsIdxDbl+2], HEAPF64[colorAttachmentsIdxDbl+3]]
});

colorAttachmentsIdx += 12;
colorAttachmentsIdxDbl += 6;
}

var depthStencilView = wgpu[HEAPU32[descriptor]];
Expand Down

0 comments on commit 2038086

Please sign in to comment.