GPU: Add Texture Usage Parameter to GPUOffscreen.

Currently the Textures used for offscreen rendering don't have
the `GPU_TEXTURE_USAGE_HOST_READ` flag. But some cases it is
needed. This PR adds a parameter when creating an offscreen
buffer.

Other solution could be to add this flag to all textures, but
we chose not to do this as that reduces the amount of fine-tuning
options for Metal/Vulkan backends. GPU can store textures
differently based on its actual usage.

This option isn't available in the python API as we don't expect
add-on developers to fine-tune texture usages to this extent.

For convenience `GPU_TEXTURE_USAGE_ATTACHMENT` is by default
always added.

Pull Request: blender/blender#106899
This commit is contained in:
2023-04-14 22:02:51 +02:00
parent b86fc55d30
commit db47f82626
9 changed files with 48 additions and 14 deletions

View File

@@ -232,7 +232,12 @@ static PyObject *pygpu_offscreen__tp_new(PyTypeObject *UNUSED(self),
}
if (GPU_context_active_get()) {
ofs = GPU_offscreen_create(width, height, true, pygpu_textureformat.value_found, err_out);
ofs = GPU_offscreen_create(width,
height,
true,
pygpu_textureformat.value_found,
GPU_TEXTURE_USAGE_SHADER_READ | GPU_TEXTURE_USAGE_HOST_READ,
err_out);
}
else {
STRNCPY(err_out, "No active GPU context found");