Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support WGPUPrimitiveDepthClipControl / unclippedDepth #21231

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading