Skip to content

Commit 2b9870c

Browse files
Support WGPUPrimitiveDepthClipControl / unclippedDepth (#21231)
Co-authored-by: Kai Ninomiya <[email protected]>
1 parent 01be75a commit 2b9870c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/library_webgpu.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,15 @@ var LibraryWebGPU = {
12561256
{{{ gpu.makeCheckDescriptor('descriptor') }}}
12571257
function makePrimitiveState(rsPtr) {
12581258
if (!rsPtr) return undefined;
1259-
{{{ gpu.makeCheckDescriptor('rsPtr') }}}
1259+
{{{ gpu.makeCheck('rsPtr') }}}
1260+
1261+
// TODO: This small hack assumes that there's only one type that can be in the chain of
1262+
// WGPUPrimitiveState. The correct thing would be to traverse the chain, but unclippedDepth
1263+
// is going to move into the core object soon, so we'll just do this for now. See:
1264+
// https://github.com/webgpu-native/webgpu-headers/issues/212#issuecomment-1682801259
1265+
var nextInChainPtr = {{{ makeGetValue('rsPtr', C_STRUCTS.WGPUPrimitiveState.nextInChain, '*') }}};
1266+
var sType = nextInChainPtr ? {{{ gpu.makeGetU32('nextInChainPtr', C_STRUCTS.WGPUChainedStruct.sType) }}} : 0;
1267+
12601268
return {
12611269
"topology": WebGPU.PrimitiveTopology[
12621270
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.topology) }}}],
@@ -1266,6 +1274,7 @@ var LibraryWebGPU = {
12661274
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.frontFace) }}}],
12671275
"cullMode": WebGPU.CullMode[
12681276
{{{ gpu.makeGetU32('rsPtr', C_STRUCTS.WGPUPrimitiveState.cullMode) }}}],
1277+
"unclippedDepth": sType === {{{ gpu.SType.PrimitiveDepthClipControl }}} && {{{ gpu.makeGetBool('nextInChainPtr', C_STRUCTS.WGPUPrimitiveDepthClipControl.unclippedDepth) }}},
12691278
};
12701279
}
12711280

0 commit comments

Comments
 (0)