---
name: "SDL_CreateGPUTexture"
section: "3"
platform: "linux"
package: "libsdl3-doc"
version: "3.2.10+ds-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/SDL_CreateGPUTexture"
---

# SDL\_CreateGPUTexture(3)

Creates a texture object to be used in graphics or compute workflows.

## NAME

SDL\_CreateGPUTexture - Creates a texture object to be used in graphics or compute workflows.

## HEADER FILE

Defined in SDL3/SDL\_gpu.h

## SYNOPSIS

```
#include "SDL3/SDL.h"
```

**SDL\_GPUTexture \* SDL\_CreateGPUTexture(**     **SDL\_GPUDevice \*device,**     **const SDL\_GPUTextureCreateInfo \*createinfo);**

## DESCRIPTION

The contents of this texture are undefined until data is written to the texture.

Note that certain combinations of usage flags are invalid. For example, a texture cannot have both the SAMPLER and GRAPHICS\_STORAGE\_READ flags.

If you request a sample count higher than the hardware supports, the implementation will automatically fall back to the highest available sample count.

There are optional properties that can be provided through

**SDL\_GPUTextureCreateInfo** **props** . These are the supported properties:

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_R\_FLOAT** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_COLOR\_TARGET** ,\
   clear the texture to a color with this red intensity. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_G\_FLOAT** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_COLOR\_TARGET** ,\
   clear the texture to a color with this green intensity. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_B\_FLOAT** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_COLOR\_TARGET** ,\
   clear the texture to a color with this blue intensity. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_A\_FLOAT** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_COLOR\_TARGET** ,\
   clear the texture to a color with this alpha intensity. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_DEPTH\_FLOAT** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_DEPTH\_STENCIL\_TARGET** ,\
   clear the texture to a depth of this value. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_D3D12\_CLEAR\_STENCIL\_UINT8** :\
   (Direct3D 12 only) if the texture usage is

**SDL\_GPU\_TEXTUREUSAGE\_DEPTH\_STENCIL\_TARGET** ,\
   clear the texture to a stencil of this value. Defaults to zero.

•  **SDL\_PROP\_GPU\_TEXTURE\_CREATE\_NAME\_STRING** :\
   a name that can be displayed in debugging tools.

## FUNCTION PARAMETERS

- *device*

  a GPU Context.

- *createinfo*

  a struct describing the state of the texture to create.

## RETURN VALUE

( **SDL\_GPUTexture**\
  \*) Returns a texture object on success, or NULL on failure; call  **SDL\_GetError** () for more information.

## AVAILABILITY

This function is available since SDL 3.2.0.

## SEE ALSO

**•**(3), [**SDL\_UploadToGPUTexture**(3)](/SDL_UploadToGPUTexture/3.md), **•**(3), [**SDL\_DownloadFromGPUTexture**(3)](/SDL_DownloadFromGPUTexture/3.md), **•**(3), [**SDL\_BindGPUVertexSamplers**(3)](/SDL_BindGPUVertexSamplers/3.md), **•**(3), [**SDL\_BindGPUVertexStorageTextures**(3)](/SDL_BindGPUVertexStorageTextures/3.md), **•**(3), [**SDL\_BindGPUFragmentSamplers**(3)](/SDL_BindGPUFragmentSamplers/3.md), **•**(3), [**SDL\_BindGPUFragmentStorageTextures**(3)](/SDL_BindGPUFragmentStorageTextures/3.md), **•**(3), [**SDL\_BindGPUComputeStorageTextures**(3)](/SDL_BindGPUComputeStorageTextures/3.md), **•**(3), [**SDL\_BlitGPUTexture**(3)](/SDL_BlitGPUTexture/3.md), **•**(3), [**SDL\_ReleaseGPUTexture**(3)](/SDL_ReleaseGPUTexture/3.md), **•**(3), [**SDL\_GPUTextureSupportsFormat**(3)](/SDL_GPUTextureSupportsFormat/3.md)
