Request
Retrieves data asynchronously from a GPU resource.
Read time 13 minutesLast updated 6 days ago
Definition
- Type: Method
- Namespace: UnityEngine.Rendering
- Assembly: UnityEngine.CoreModule
Request(ComputeBuffer, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(ComputeBuffer src, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(ComputeBuffer, int, int, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(ComputeBuffer src, int size, int offset, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Size in bytes of the data to be retrieved from the ComputeBuffer or GraphicsBuffer.
Offset in bytes in the ComputeBuffer or GraphicsBuffer.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(GraphicsBuffer, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(GraphicsBuffer src, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(GraphicsBuffer, int, int, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(GraphicsBuffer src, int size, int offset, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Size in bytes of the data to be retrieved from the ComputeBuffer or GraphicsBuffer.
Offset in bytes in the ComputeBuffer or GraphicsBuffer.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex = 0, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, TextureFormat, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex, TextureFormat dstFormat, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
Target TextureFormat of the data. If the target format is different from the format stored on the GPU, the conversion is automatic.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, GraphicsFormat, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex, GraphicsFormat dstFormat, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
Target TextureFormat of the data. If the target format is different from the format stored on the GPU, the conversion is automatic.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, int, int, int, int, int, int, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
Starting X coordinate in pixels of the Texture data to be fetched.
Width in pixels of the Texture data to be fetched.
Starting Y coordinate in pixels of the Texture data to be fetched.
Height in pixels of the Texture data to be fetched.
Start Z coordinate in pixels for the Texture3D being fetched. Index of Start layer for TextureCube, Texture2DArray and TextureCubeArray being fetched.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, int, int, int, int, int, int, TextureFormat, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, TextureFormat dstFormat, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
Starting X coordinate in pixels of the Texture data to be fetched.
Width in pixels of the Texture data to be fetched.
Starting Y coordinate in pixels of the Texture data to be fetched.
Height in pixels of the Texture data to be fetched.
Start Z coordinate in pixels for the Texture3D being fetched. Index of Start layer for TextureCube, Texture2DArray and TextureCubeArray being fetched.
Target TextureFormat of the data. If the target format is different from the format stored on the GPU, the conversion is automatic.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.
Request(Texture, int, int, int, int, int, int, int, GraphicsFormat, Action<AsyncGPUReadbackRequest>)
Retrieves data asynchronously from a GPU resource.
public static AsyncGPUReadbackRequest Request(Texture src, int mipIndex, int x, int width, int y, int height, int z, int depth, GraphicsFormat dstFormat, Action<AsyncGPUReadbackRequest> callback = null)
Parameters
Resource to read the data from.
Index of the mipmap to be fetched.
Starting X coordinate in pixels of the Texture data to be fetched.
Width in pixels of the Texture data to be fetched.
Starting Y coordinate in pixels of the Texture data to be fetched.
Height in pixels of the Texture data to be fetched.
Start Z coordinate in pixels for the Texture3D being fetched. Index of Start layer for TextureCube, Texture2DArray and TextureCubeArray being fetched.
Target TextureFormat of the data. If the target format is different from the format stored on the GPU, the conversion is automatic.
An optional delegate Action called once the request is fullfilled. The completed request is passed as parameter to the Action.
Returns
Type | Description |
|---|---|
| AsyncGPUReadbackRequest | Returns an AsyncGPUReadbackRequest that you can use to determine when the data is available. Otherwise, a request with an error is returned. |
Remarks
If a request with an error is returned, calling AsyncGPUReadbackRequest.hasError returns true.
For texture data, the extents are checked against the size of the source texture. If graphics QualitySettings are set low enough to generate reduced size textures, then the reduced size must be requested. Use QualitySettings.masterTextureLimit to adjust the width and height (and x,y if required), by bit shifting right.
For texture data, use the SystemInfo.IsFormatSupported method with the GraphicsFormatUsage.ReadPixels flag to query if the format is supported.
If you use this function to request data about a temporary render texture, don't release the texture using RenderTexture.ReleaseTemporary until the request is complete.