Skip to content

Commit

Permalink
Support WGPUPrimitiveDepthClipControl / unclippedDepth (#21231)
Browse files Browse the repository at this point in the history
Co-authored-by: Kai Ninomiya <kainino@chromium.org>
  • Loading branch information
ifiddynine and kainino0x authored Feb 2, 2024
1 parent 01be75a commit 2b9870c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/library_webgpu.js
Original file line number Diff line number Diff line change
Expand Up @@ -1256,7 +1256,15 @@ var LibraryWebGPU = {
{{{ gpu.makeCheckDescriptor('descriptor') }}}
function makePrimitiveState(rsPtr) {
if (!rsPtr) return undefined;
{{{ gpu.makeCheckDescriptor('rsPtr') }}}
{{{ gpu.makeCheck('rsPtr') }}}

// TODO: This small hack assumes that there's only one type that can be in the chain of
// WGPUPrimitiveState. The correct thing would be to traverse the chain, but unclippedDepth
// is going to move into the core object soon, so we'll just do this for now. See:
// https://github.com/webgpu-native/webgpu-headers/issues/212#issuecomment-1682801259
var nextInChainPtr = {{{ makeGetValue('rsPtr', C_STRUCTS.WGPUPrimitiveState.nextInChain, '*') }}};
var sType = nextInChainPtr ? {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}} : 0;

return {
"topology": WebGPU.PrimitiveTopology[
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.topology) }}}],
Expand All @@ -1266,6 +1274,7 @@ var LibraryWebGPU = {
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.frontFace) }}}],
"cullMode": WebGPU.CullMode[
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.cullMode) }}}],
"unclippedDepth": sType === {{{ gpu.SType.PrimitiveDepthClipControl }}} && {{{ gpu.makeGetBool('nextInChainPtr', C_STRUCTS.WGPUPrimitiveDepthClipControl.unclippedDepth) }}},
};
}

Expand Down

0 comments on commit 2b9870c

Please sign in to comment.