---
title: "dpdx(): IR builder function in typeshade/core/ir, TypeShade"
description: "dpdx, an IR builder function in typeshade/core/ir. dpdx(x): the screen-space partial derivative of x along the X axis, component-wise."
url: https://typeshade.dev/api/dpdx/
language: en
---

# `dpdx()`

Function in Builtins

`dpdx(x)`: the screen-space partial derivative of x along the X axis, component-wise.

`import { dpdx } from 'typeshade/core/ir'`

This export returns an IR node. A `"use typeshade"` file calls the builtin itself: [`dpdx()`](https://typeshade.dev/reference/functions/dpdx/)

The signature, the description and the examples come from the compiler's own source at commit af54ddad5.

## Syntax

```ts
const dpdx: <K extends FloatKey>(x: ReadonlyNode<K>) => Node<K>
```

## Parameters

**`x` `ReadonlyNode<K>`**

## Return value

`Node<K>`

## Exceptions

**[`SD0109`](https://typeshade.dev/reference/errors/sd0109/)**

Like fwidth it exists only on the GPU and only in a fragment shader; the fragment-only-builtin lint rule reports SD0109 elsewhere.

## Description

Like [`fwidth`](https://typeshade.dev/api/fwidth/) it exists only on the GPU (the CPU evaluation returns 0) and only in a fragment shader; the `fragment-only-builtin` lint rule reports [`SD0109`](https://typeshade.dev/reference/errors/sd0109/) elsewhere. Spelled `dpdx` on WGSL and `dFdx` on GLSL ES 3.00; [`dpdy`](https://typeshade.dev/api/dpdy/) is the Y-axis partner.

## Targets

| Target | Support | Notes |
| --- | --- | --- |
| WGSL (WebGPU) | Supported | `dpdx(x)`. |
| GLSL ES 3.00 (WebGL2) | Supported | `dFdx(x)`. |
| CPU oracle | Stub | The oracle has no texture memory and no neighbouring fragments. The call throws unless the module was compiled with `{ gpuStubs: true }`, which returns a placeholder. |

## In the guide

- [Layouts and resources](https://typeshade.dev/guide/internals/layouts-and-resources/)
- [The CPU oracle](https://typeshade.dev/guide/internals/the-cpu-oracle/)

## See also

- [`dpdx()`](https://typeshade.dev/reference/functions/dpdx/)
- [`fwidth`](https://typeshade.dev/api/fwidth/)
- [`dpdy`](https://typeshade.dev/api/dpdy/)

## Source

[`src/core/ir/node.ts`, line 1979](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1979), at commit af54ddad5
