|
58 | 58 | <param index="2" name="size_bytes" type="int" default="0" />
|
59 | 59 | <description>
|
60 | 60 | Returns a copy of the data of the specified [param buffer], optionally [param offset_bytes] and [param size_bytes] can be set to copy only a portion of the buffer.
|
| 61 | + [b]Note:[/b] This method will block the GPU from working until the data is retrieved. Refer to [method buffer_get_data_async] for an alternative that returns the data in more performant way. |
| 62 | + </description> |
| 63 | + </method> |
| 64 | + <method name="buffer_get_data_async"> |
| 65 | + <return type="int" enum="Error" /> |
| 66 | + <param index="0" name="buffer" type="RID" /> |
| 67 | + <param index="1" name="callback" type="Callable" /> |
| 68 | + <param index="2" name="offset_bytes" type="int" default="0" /> |
| 69 | + <param index="3" name="size_bytes" type="int" default="0" /> |
| 70 | + <description> |
| 71 | + Asynchronous version of [method buffer_get_data]. RenderingDevice will call [param callback] in a certain amount of frames with the data the buffer had at the time of the request. |
| 72 | + [b]Note:[/b] At the moment, the delay corresponds to the amount of frames specified by [member ProjectSettings.rendering/rendering_device/vsync/frame_queue_size]. |
| 73 | + [b]Note:[/b] Downloading large buffers can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as [member ProjectSettings.rendering/rendering_device/staging_buffer/block_size_kb] to improve the transfer speed at the cost of extra memory. |
| 74 | + [codeblock] |
| 75 | + func _buffer_get_data_callback(array): |
| 76 | + value = array.decode_u32(0) |
| 77 | + |
| 78 | + ... |
| 79 | + |
| 80 | + rd.buffer_get_data_async(buffer, _buffer_get_data_callback) |
| 81 | + [/codeblock] |
61 | 82 | </description>
|
62 | 83 | </method>
|
63 | 84 | <method name="buffer_update">
|
|
928 | 949 | Returns the [param texture] data for the specified [param layer] as raw binary data. For 2D textures (which only have one layer), [param layer] must be [code]0[/code].
|
929 | 950 | [b]Note:[/b] [param texture] can't be retrieved while a draw list that uses it as part of a framebuffer is being created. Ensure the draw list is finalized (and that the color/depth texture using it is not set to [constant FINAL_ACTION_CONTINUE]) to retrieve this texture. Otherwise, an error is printed and a empty [PackedByteArray] is returned.
|
930 | 951 | [b]Note:[/b] [param texture] requires the [constant TEXTURE_USAGE_CAN_COPY_FROM_BIT] to be retrieved. Otherwise, an error is printed and a empty [PackedByteArray] is returned.
|
| 952 | + [b]Note:[/b] This method will block the GPU from working until the data is retrieved. Refer to [method texture_get_data_async] for an alternative that returns the data in more performant way. |
| 953 | + </description> |
| 954 | + </method> |
| 955 | + <method name="texture_get_data_async"> |
| 956 | + <return type="int" enum="Error" /> |
| 957 | + <param index="0" name="texture" type="RID" /> |
| 958 | + <param index="1" name="layer" type="int" /> |
| 959 | + <param index="2" name="callback" type="Callable" /> |
| 960 | + <description> |
| 961 | + Asynchronous version of [method texture_get_data]. RenderingDevice will call [param callback] in a certain amount of frames with the data the texture had at the time of the request. |
| 962 | + [b]Note:[/b] At the moment, the delay corresponds to the amount of frames specified by [member ProjectSettings.rendering/rendering_device/vsync/frame_queue_size]. |
| 963 | + [b]Note:[/b] Downloading large textures can have a prohibitive cost for real-time even when using the asynchronous method due to hardware bandwidth limitations. When dealing with large resources, you can adjust settings such as [member ProjectSettings.rendering/rendering_device/staging_buffer/texture_download_region_size_px] and [member ProjectSettings.rendering/rendering_device/staging_buffer/block_size_kb] to improve the transfer speed at the cost of extra memory. |
| 964 | + [codeblock] |
| 965 | + func _texture_get_data_callback(array): |
| 966 | + value = array.decode_u32(0) |
| 967 | + |
| 968 | + ... |
| 969 | + |
| 970 | + rd.texture_get_data_async(texture, 0, _texture_get_data_callback) |
| 971 | + [/codeblock] |
931 | 972 | </description>
|
932 | 973 | </method>
|
933 | 974 | <method name="texture_get_format">
|
|
0 commit comments