mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 13:28:06 +02:00
rusticl/mem: set bind flags for gl imports
We have to tell the driver how we want to use the resource. Fixes:2645003bdc("rusticl: Create CL mem objects from GL") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33325> (cherry picked from commit46454f01d3)
This commit is contained in:
parent
f2f488ced5
commit
3aa3ec625d
4 changed files with 26 additions and 4 deletions
|
|
@ -644,7 +644,7 @@
|
||||||
"description": "rusticl/mem: set bind flags for gl imports",
|
"description": "rusticl/mem: set bind flags for gl imports",
|
||||||
"nominated": true,
|
"nominated": true,
|
||||||
"nomination_type": 2,
|
"nomination_type": 2,
|
||||||
"resolution": 0,
|
"resolution": 1,
|
||||||
"main_sha": null,
|
"main_sha": null,
|
||||||
"because_sha": "2645003bdc527b5dc046366fce5e65b44b27334f",
|
"because_sha": "2645003bdc527b5dc046366fce5e65b44b27334f",
|
||||||
"notes": null
|
"notes": null
|
||||||
|
|
|
||||||
|
|
@ -200,25 +200,37 @@ impl Context {
|
||||||
modifier: u64,
|
modifier: u64,
|
||||||
image_type: cl_mem_object_type,
|
image_type: cl_mem_object_type,
|
||||||
gl_target: cl_GLenum,
|
gl_target: cl_GLenum,
|
||||||
format: pipe_format,
|
format: cl_image_format,
|
||||||
gl_props: GLMemProps,
|
gl_props: GLMemProps,
|
||||||
) -> CLResult<HashMap<&'static Device, Arc<PipeResource>>> {
|
) -> CLResult<HashMap<&'static Device, Arc<PipeResource>>> {
|
||||||
let mut res = HashMap::new();
|
let mut res = HashMap::new();
|
||||||
let target = cl_mem_type_to_texture_target_gl(image_type, gl_target);
|
let target = cl_mem_type_to_texture_target_gl(image_type, gl_target);
|
||||||
|
let pipe_format = if image_type == CL_MEM_OBJECT_BUFFER {
|
||||||
|
pipe_format::PIPE_FORMAT_NONE
|
||||||
|
} else {
|
||||||
|
format.to_pipe_format().unwrap()
|
||||||
|
};
|
||||||
|
|
||||||
for dev in &self.devs {
|
for dev in &self.devs {
|
||||||
|
let enable_bind_as_image = if target != pipe_texture_target::PIPE_BUFFER {
|
||||||
|
dev.formats[&format][&image_type] as u32 & CL_MEM_WRITE_ONLY != 0
|
||||||
|
} else {
|
||||||
|
false
|
||||||
|
};
|
||||||
|
|
||||||
let resource = dev
|
let resource = dev
|
||||||
.screen()
|
.screen()
|
||||||
.resource_import_dmabuf(
|
.resource_import_dmabuf(
|
||||||
handle,
|
handle,
|
||||||
modifier,
|
modifier,
|
||||||
target,
|
target,
|
||||||
format,
|
pipe_format,
|
||||||
gl_props.stride,
|
gl_props.stride,
|
||||||
gl_props.width,
|
gl_props.width,
|
||||||
gl_props.height,
|
gl_props.height,
|
||||||
gl_props.depth,
|
gl_props.depth,
|
||||||
gl_props.array_size,
|
gl_props.array_size,
|
||||||
|
enable_bind_as_image,
|
||||||
)
|
)
|
||||||
.ok_or(CL_OUT_OF_RESOURCES)?;
|
.ok_or(CL_OUT_OF_RESOURCES)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -950,7 +950,7 @@ impl MemBase {
|
||||||
export_out.modifier,
|
export_out.modifier,
|
||||||
mem_type,
|
mem_type,
|
||||||
export_in.target,
|
export_in.target,
|
||||||
pipe_format,
|
image_format,
|
||||||
gl_mem_props.clone(),
|
gl_mem_props.clone(),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -249,6 +249,7 @@ impl PipeScreen {
|
||||||
height: u16,
|
height: u16,
|
||||||
depth: u16,
|
depth: u16,
|
||||||
array_size: u16,
|
array_size: u16,
|
||||||
|
support_image: bool,
|
||||||
) -> Option<PipeResource> {
|
) -> Option<PipeResource> {
|
||||||
let mut tmpl = pipe_resource::default();
|
let mut tmpl = pipe_resource::default();
|
||||||
let mut handle = winsys_handle {
|
let mut handle = winsys_handle {
|
||||||
|
|
@ -267,6 +268,15 @@ impl PipeScreen {
|
||||||
tmpl.depth0 = depth;
|
tmpl.depth0 = depth;
|
||||||
tmpl.array_size = array_size;
|
tmpl.array_size = array_size;
|
||||||
|
|
||||||
|
if target == pipe_texture_target::PIPE_BUFFER {
|
||||||
|
tmpl.bind = PIPE_BIND_GLOBAL
|
||||||
|
} else {
|
||||||
|
tmpl.bind = PIPE_BIND_SAMPLER_VIEW;
|
||||||
|
if support_image {
|
||||||
|
tmpl.bind |= PIPE_BIND_SHADER_IMAGE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
PipeResource::new(
|
PipeResource::new(
|
||||||
self.screen().resource_from_handle.unwrap()(
|
self.screen().resource_from_handle.unwrap()(
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue