mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 09:20:13 +01:00
rusticl/mesa: rework Context creation
Reviewed-by: Seán de Búrca <sdeburca@fastmail.net> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37377>
This commit is contained in:
parent
6a71ecaad7
commit
f7fcd7ed5d
3 changed files with 12 additions and 19 deletions
|
|
@ -1141,7 +1141,7 @@ impl DeviceBase {
|
|||
let res = (prio == PipeContextPrio::Med)
|
||||
.then(|| self.reusable_ctx().pop())
|
||||
.flatten()
|
||||
.or_else(|| self.screen.create_context(prio))?;
|
||||
.or_else(|| PipeContext::new(prio, &self.screen))?;
|
||||
|
||||
debug_assert_eq!(res.prio, prio);
|
||||
|
||||
|
|
@ -1281,7 +1281,7 @@ impl Device {
|
|||
let screen = Arc::new(screen);
|
||||
// Create before loading libclc as llvmpipe only creates the shader cache with the first
|
||||
// context being created.
|
||||
let helper_ctx = screen.create_context(PipeContextPrio::Med)?;
|
||||
let helper_ctx = PipeContext::new(PipeContextPrio::Med, &screen)?;
|
||||
let mut dev_base = DeviceBase {
|
||||
caps: DeviceCaps::new(&screen, &helper_ctx),
|
||||
helper_ctx: Mutex::new(helper_ctx),
|
||||
|
|
|
|||
|
|
@ -52,11 +52,8 @@ impl From<RWFlags> for pipe_map_flags {
|
|||
}
|
||||
|
||||
impl PipeContext {
|
||||
pub(super) fn new(
|
||||
context: *mut pipe_context,
|
||||
prio: PipeContextPrio,
|
||||
screen: &Arc<PipeScreen>,
|
||||
) -> Option<Self> {
|
||||
pub fn new(prio: PipeContextPrio, screen: &Arc<PipeScreen>) -> Option<Self> {
|
||||
let context = screen.create_context(prio);
|
||||
let s = Self {
|
||||
pipe: NonNull::new(context)?,
|
||||
screen: Arc::clone(screen),
|
||||
|
|
|
|||
|
|
@ -98,19 +98,15 @@ impl PipeScreen {
|
|||
&self.screen().caps
|
||||
}
|
||||
|
||||
pub fn create_context(self: &Arc<Self>, prio: PipeContextPrio) -> Option<PipeContext> {
|
||||
pub(super) fn create_context(&self, prio: PipeContextPrio) -> *mut pipe_context {
|
||||
let flags: u32 = prio.into();
|
||||
PipeContext::new(
|
||||
unsafe {
|
||||
self.screen().context_create.unwrap()(
|
||||
self.screen.as_ptr(),
|
||||
ptr::null_mut(),
|
||||
flags | PIPE_CONTEXT_COMPUTE_ONLY | PIPE_CONTEXT_NO_LOD_BIAS,
|
||||
)
|
||||
},
|
||||
prio,
|
||||
self,
|
||||
)
|
||||
unsafe {
|
||||
self.screen().context_create.unwrap()(
|
||||
self.pipe(),
|
||||
ptr::null_mut(),
|
||||
flags | PIPE_CONTEXT_COMPUTE_ONLY | PIPE_CONTEXT_NO_LOD_BIAS,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn alloc_vm(&self, start: NonZeroU64, size: NonZeroU64) -> Option<ScreenVMAllocation<'_>> {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue