rusticl/memory: fallback if allocating linear images fails

Signed-off-by: Karol Herbst <git@karolherbst.de>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25052>
This commit is contained in:
Karol Herbst
2023-09-01 12:21:33 +02:00
committed by Marge Bot
parent 7fd3e53279
commit b70172baff
2 changed files with 17 additions and 3 deletions

View File

@@ -375,13 +375,27 @@ impl Mem {
};
let texture = if parent.is_none() {
Some(context.create_texture(
let mut texture = context.create_texture(
&image_desc,
image_format,
host_ptr,
bit_check(flags, CL_MEM_COPY_HOST_PTR),
res_type,
)?)
);
// if we error allocating a Staging resource, just try with normal as
// `CL_MEM_ALLOC_HOST_PTR` is just a performance hint.
if res_type == ResourceType::Staging && texture.is_err() {
texture = context.create_texture(
&image_desc,
image_format,
host_ptr,
bit_check(flags, CL_MEM_COPY_HOST_PTR),
ResourceType::Normal,
)
}
Some(texture?)
} else {
None
};

View File

@@ -69,7 +69,7 @@ impl ComputeParam<Vec<u64>> for PipeScreen {
}
}
#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum ResourceType {
Normal,
Staging,