Skip to content

Commit 349e794

Browse files
committed
Remove the helper function wgpu_command_encoder_begin_render_pass_1color_0depth(). While it was much smaller, the code size benefit does not compose well with larger applications.
1 parent 4a5a32b commit 349e794

File tree

8 files changed

+5
-58
lines changed

8 files changed

+5
-58
lines changed

lib/lib_webgpu.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,8 +2167,6 @@ typedef WGpuObjectBase WGpuCommandEncoder;
21672167
WGPU_BOOL wgpu_is_command_encoder(WGpuObjectBase object);
21682168

21692169
WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass(WGpuCommandEncoder commandEncoder, const WGpuRenderPassDescriptor *renderPassDesc NOTNULL);
2170-
// Like above, but tiny code size path for the case when there is exactly one color and zero depth-stencil targets and no occlusion query set specified for the render pass.
2171-
WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass_1color_0depth(WGpuCommandEncoder commandEncoder, const WGpuRenderPassDescriptor *renderPassDesc NOTNULL);
21722170
WGpuComputePassEncoder wgpu_command_encoder_begin_compute_pass(WGpuCommandEncoder commandEncoder, const WGpuComputePassDescriptor *computePassDesc _WGPU_DEFAULT_VALUE(0));
21732171
void wgpu_command_encoder_copy_buffer_to_buffer(WGpuCommandEncoder commandEncoder, WGpuBuffer source, double_int53_t sourceOffset, WGpuBuffer destination, double_int53_t destinationOffset, double_int53_t size);
21742172
void wgpu_command_encoder_copy_buffer_to_texture(WGpuCommandEncoder commandEncoder, const WGpuImageCopyBuffer *source NOTNULL, const WGpuImageCopyTexture *destination NOTNULL, uint32_t copyWidth, uint32_t copyHeight _WGPU_DEFAULT_VALUE(1), uint32_t copyDepthOrArrayLayers _WGPU_DEFAULT_VALUE(1));

lib/lib_webgpu.js

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2052,39 +2052,6 @@ let api = {
20522052
return wgpuStore(wgpu[commandEncoder]['beginRenderPass'](desc));
20532053
},
20542054

2055-
wgpu_command_encoder_begin_render_pass_1color_0depth__deps: ['$GPULoadOps', '$GPUStoreOps'],
2056-
wgpu_command_encoder_begin_render_pass_1color_0depth: function(commandEncoder, descriptor) {
2057-
{{{ wdebuglog('`wgpu_command_encoder_begin_render_pass_1color_0depth(commandEncoder=${commandEncoder}, descriptor=${descriptor})`'); }}}
2058-
{{{ wassert('commandEncoder != 0'); }}}
2059-
{{{ wassert('wgpu[commandEncoder]'); }}}
2060-
{{{ wassert('wgpu[commandEncoder] instanceof GPUCommandEncoder'); }}}
2061-
{{{ wassert('descriptor != 0'); }}}
2062-
2063-
{{{ ptrToIdx('descriptor', 2); }}}
2064-
2065-
{{{ wassert('HEAP32[descriptor+4] == 1'); }}} // Must be passing exactly one color target.
2066-
{{{ wassert('HEAPU32[descriptor+5] == 0'); }}} // Must be passing no depth-stencil target.
2067-
2068-
let colorAttachmentsIdx = {{{ readIdx32('descriptor+2') }}},
2069-
colorAttachmentsIdxDbl = {{{ shiftIndex('colorAttachmentsIdx + 6', 1) }}}; // Alias the view for HEAPF64.
2070-
2071-
{{{ wassert('colorAttachmentsIdx % 2 == 0'); }}} // Must be aligned at double boundary
2072-
2073-
let desc = {
2074-
'colorAttachments': [{
2075-
'view': wgpu[HEAPU32[colorAttachmentsIdx]],
2076-
'depthSlice': HEAP32[colorAttachmentsIdx+1] < 0 ? void 0 : HEAP32[colorAttachmentsIdx+1], // Awkward polymorphism: spec does not allow 'depthSlice' to be given a value (even 0) if attachment is not a 3D texture.
2077-
'resolveTarget': wgpu[HEAPU32[colorAttachmentsIdx+2]],
2078-
'storeOp': GPUStoreOps[HEAPU32[colorAttachmentsIdx+3]],
2079-
'loadOp': GPULoadOps[HEAPU32[colorAttachmentsIdx+4]],
2080-
'clearValue': [HEAPF64[colorAttachmentsIdxDbl ], HEAPF64[colorAttachmentsIdxDbl+1],
2081-
HEAPF64[colorAttachmentsIdxDbl+2], HEAPF64[colorAttachmentsIdxDbl+3]]
2082-
}]
2083-
};
2084-
{{{ wdebugdir('desc', '`GPUCommandEncoder.beginRenderPass() with descriptor:`') }}};
2085-
return wgpuStore(wgpu[commandEncoder]['beginRenderPass'](desc));
2086-
},
2087-
20882055
wgpu_command_encoder_begin_compute_pass__deps: ['$wgpuReadTimestampWrites'],
20892056
wgpu_command_encoder_begin_compute_pass: function(commandEncoder, descriptor) {
20902057
{{{ wdebuglog('`wgpu_command_encoder_begin_compute_pass(commandEncoder=${commandEncoder}, descriptor=${descriptor})`'); }}}

lib/lib_webgpu_dawn.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,24 +2095,6 @@ WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass(WGpuCommandEncoder
20952095
return _wgpu_store(kWebGPURenderPassEncoder, renderPassEncoder);
20962096
}
20972097

2098-
WGpuRenderPassEncoder wgpu_command_encoder_begin_render_pass_1color_0depth(WGpuCommandEncoder commandEncoder, const WGpuRenderPassDescriptor *renderPassDesc) {
2099-
assert(wgpu_is_command_encoder(commandEncoder));
2100-
assert(renderPassDesc);
2101-
2102-
WGPURenderPassDescriptor _desc = {};
2103-
_desc.colorAttachmentCount = 1;
2104-
WGPURenderPassColorAttachment _attachment = getColorAttachInfo(renderPassDesc->colorAttachments[0]);
2105-
_desc.colorAttachments = &_attachment;
2106-
_desc.depthStencilAttachment = nullptr;
2107-
_desc.occlusionQuerySet = _wgpu_get_dawn<WGPUQuerySet>(renderPassDesc->occlusionQuerySet);
2108-
_desc.timestampWrites = nullptr;
2109-
_desc.label = nullptr;
2110-
_desc.nextInChain = nullptr;
2111-
2112-
WGPURenderPassEncoder renderPassEncoder = wgpuCommandEncoderBeginRenderPass(_wgpu_get_dawn<WGPUCommandEncoder>(commandEncoder), &_desc);
2113-
return _wgpu_store(kWebGPURenderPassEncoder, renderPassEncoder);
2114-
}
2115-
21162098
WGpuComputePassEncoder wgpu_command_encoder_begin_compute_pass(WGpuCommandEncoder commandEncoder, const WGpuComputePassDescriptor *computePassDesc) {
21172099
assert(wgpu_is_command_encoder(commandEncoder));
21182100

samples/clear_screen/clear_screen.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ WGPU_BOOL raf(double time, void *userData)
2626
passDesc.numColorAttachments = 1;
2727
passDesc.colorAttachments = &colorAttachment;
2828

29-
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass_1color_0depth(encoder, &passDesc));
29+
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass(encoder, &passDesc));
3030
wgpu_queue_submit_one_and_destroy(wgpu_device_get_queue(device), wgpu_command_encoder_finish(encoder));
3131

3232
return EM_TRUE;

samples/clear_screen/clear_screen_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int main(int argc, char **argv)
3535
passDesc.numColorAttachments = 1;
3636
passDesc.colorAttachments = &colorAttachment;
3737

38-
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass_1color_0depth(encoder, &passDesc));
38+
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass(encoder, &passDesc));
3939
wgpu_queue_submit_one_and_destroy(wgpu_device_get_queue(device), wgpu_command_encoder_finish(encoder));
4040

4141
// This sample shows how to use a synchronous-looking infinite rendering loop,

samples/offscreen_canvas/offscreen_canvas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ WGPU_BOOL raf(double time, void *userData) // runs in worker thread
112112
passDesc.numColorAttachments = 1;
113113
passDesc.colorAttachments = &colorAttachment;
114114

115-
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass_1color_0depth(encoder, &passDesc));
115+
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass(encoder, &passDesc));
116116
wgpu_queue_submit_one_and_destroy(wgpu_device_get_queue(device), wgpu_command_encoder_finish(encoder));
117117

118118
return EM_TRUE;

samples/offscreen_canvas/offscreen_canvas_proxy_to_pthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ WGPU_BOOL raf(double time, void *userData) // runs in pthread
7878
passDesc.numColorAttachments = 1;
7979
passDesc.colorAttachments = &colorAttachment;
8080

81-
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass_1color_0depth(encoder, &passDesc));
81+
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass(encoder, &passDesc));
8282
wgpu_queue_submit_one_and_destroy(wgpu_device_get_queue(device), wgpu_command_encoder_finish(encoder));
8383

8484
return EM_TRUE;

samples/offscreen_canvas/offscreen_canvas_pthread.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ WGPU_BOOL raf(double time, void *userData) // runs in pthread
127127
passDesc.numColorAttachments = 1;
128128
passDesc.colorAttachments = &colorAttachment;
129129

130-
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass_1color_0depth(encoder, &passDesc));
130+
wgpu_render_pass_encoder_end(wgpu_command_encoder_begin_render_pass(encoder, &passDesc));
131131
wgpu_queue_submit_one_and_destroy(wgpu_device_get_queue(device), wgpu_command_encoder_finish(encoder));
132132

133133
return EM_TRUE;

0 commit comments

Comments
 (0)