Module: Mesa Branch: main Commit: 0a072bb31c0aa99ba6f8348e0e601053b643a584 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0a072bb31c0aa99ba6f8348e0e601053b643a584
Author: Karol Herbst <kher...@redhat.com> Date: Tue Sep 26 23:05:38 2023 +0200 rusticl/context: fix importing gl cube maps Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21305> --- src/gallium/frontends/rusticl/core/context.rs | 3 ++- src/gallium/frontends/rusticl/core/memory.rs | 1 + src/gallium/frontends/rusticl/core/util.rs | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/gallium/frontends/rusticl/core/context.rs b/src/gallium/frontends/rusticl/core/context.rs index b9e518fe35f..15593ebcdd8 100644 --- a/src/gallium/frontends/rusticl/core/context.rs +++ b/src/gallium/frontends/rusticl/core/context.rs @@ -211,11 +211,12 @@ impl Context { handle: u32, modifier: u64, image_type: cl_mem_object_type, + gl_target: cl_GLenum, format: pipe_format, gl_props: GLMemProps, ) -> CLResult<HashMap<&'static Device, Arc<PipeResource>>> { let mut res = HashMap::new(); - let target = cl_mem_type_to_texture_target(image_type); + let target = cl_mem_type_to_texture_target_gl(image_type, gl_target); for dev in &self.devs { let resource = dev diff --git a/src/gallium/frontends/rusticl/core/memory.rs b/src/gallium/frontends/rusticl/core/memory.rs index 60f5c067780..8e17b9deb6d 100644 --- a/src/gallium/frontends/rusticl/core/memory.rs +++ b/src/gallium/frontends/rusticl/core/memory.rs @@ -457,6 +457,7 @@ impl Mem { export_out.dmabuf_fd as u32, export_out.modifier, mem_type, + export_in.target, pipe_format, gl_mem_props.clone(), )?; diff --git a/src/gallium/frontends/rusticl/core/util.rs b/src/gallium/frontends/rusticl/core/util.rs index 8bb42184a41..ce8907e1906 100644 --- a/src/gallium/frontends/rusticl/core/util.rs +++ b/src/gallium/frontends/rusticl/core/util.rs @@ -5,6 +5,8 @@ use rusticl_opencl_gen::*; use std::mem; +use super::gl::is_cube_map_face; + pub fn cl_mem_type_to_texture_target(mem_type: cl_mem_object_type) -> pipe_texture_target { match mem_type { CL_MEM_OBJECT_BUFFER => pipe_texture_target::PIPE_BUFFER, @@ -18,6 +20,18 @@ pub fn cl_mem_type_to_texture_target(mem_type: cl_mem_object_type) -> pipe_textu } } +pub fn cl_mem_type_to_texture_target_gl( + mem_type: cl_mem_object_type, + target: cl_GLenum, +) -> pipe_texture_target { + if is_cube_map_face(target) { + debug_assert_eq!(mem_type, CL_MEM_OBJECT_IMAGE2D); + pipe_texture_target::PIPE_TEXTURE_CUBE + } else { + cl_mem_type_to_texture_target(mem_type) + } +} + pub fn create_pipe_box( base: CLVec<usize>, region: CLVec<usize>,