Lines Matching refs:res
43 struct virgl_resource *res = (struct virgl_resource *)val; in virgl_resource_destroy_func() local
45 if (res->pipe_resource) in virgl_resource_destroy_func()
46 pipe_callbacks.unref(res->pipe_resource, pipe_callbacks.data); in virgl_resource_destroy_func()
47 if (res->fd_type != VIRGL_RESOURCE_FD_INVALID) in virgl_resource_destroy_func()
48 close(res->fd); in virgl_resource_destroy_func()
50 free(res); in virgl_resource_destroy_func()
83 struct virgl_resource *res; in virgl_resource_create() local
86 res = calloc(1, sizeof(*res)); in virgl_resource_create()
87 if (!res) in virgl_resource_create()
92 res); in virgl_resource_create()
94 free(res); in virgl_resource_create()
98 res->res_id = res_id; in virgl_resource_create()
99 res->fd_type = VIRGL_RESOURCE_FD_INVALID; in virgl_resource_create()
100 res->fd = -1; in virgl_resource_create()
102 return res; in virgl_resource_create()
111 struct virgl_resource *res; in virgl_resource_create_from_pipe() local
113 res = virgl_resource_create(res_id); in virgl_resource_create_from_pipe()
114 if (!res) in virgl_resource_create_from_pipe()
118 res->pipe_resource = pres; in virgl_resource_create_from_pipe()
120 res->iov = iov; in virgl_resource_create_from_pipe()
121 res->iov_count = iov_count; in virgl_resource_create_from_pipe()
123 return res; in virgl_resource_create_from_pipe()
133 struct virgl_resource *res; in virgl_resource_create_from_fd() local
137 res = virgl_resource_create(res_id); in virgl_resource_create_from_fd()
138 if (!res) in virgl_resource_create_from_fd()
141 res->fd_type = fd_type; in virgl_resource_create_from_fd()
143 res->fd = fd; in virgl_resource_create_from_fd()
145 res->iov = iov; in virgl_resource_create_from_fd()
146 res->iov_count = iov_count; in virgl_resource_create_from_fd()
148 return res; in virgl_resource_create_from_fd()
156 struct virgl_resource *res; in virgl_resource_create_from_iov() local
161 res = virgl_resource_create(res_id); in virgl_resource_create_from_iov()
162 if (!res) in virgl_resource_create_from_iov()
165 res->iov = iov; in virgl_resource_create_from_iov()
166 res->iov_count = iov_count; in virgl_resource_create_from_iov()
168 return res; in virgl_resource_create_from_iov()
184 virgl_resource_attach_iov(struct virgl_resource *res, in virgl_resource_attach_iov() argument
188 if (res->iov) in virgl_resource_attach_iov()
191 res->iov = iov; in virgl_resource_attach_iov()
192 res->iov_count = iov_count; in virgl_resource_attach_iov()
194 if (res->pipe_resource) { in virgl_resource_attach_iov()
195 pipe_callbacks.attach_iov(res->pipe_resource, in virgl_resource_attach_iov()
205 virgl_resource_detach_iov(struct virgl_resource *res) in virgl_resource_detach_iov() argument
207 if (!res->iov) in virgl_resource_detach_iov()
210 if (res->pipe_resource) in virgl_resource_detach_iov()
211 pipe_callbacks.detach_iov(res->pipe_resource, pipe_callbacks.data); in virgl_resource_detach_iov()
213 res->iov = NULL; in virgl_resource_detach_iov()
214 res->iov_count = 0; in virgl_resource_detach_iov()
218 virgl_resource_export_fd(struct virgl_resource *res, int *fd) in virgl_resource_export_fd() argument
220 if (res->fd_type != VIRGL_RESOURCE_FD_INVALID) { in virgl_resource_export_fd()
222 *fd = fcntl(res->fd, F_DUPFD_CLOEXEC, 0); in virgl_resource_export_fd()
224 *fd = dup(res->fd); in virgl_resource_export_fd()
226 *fd = dup(res->fd); in virgl_resource_export_fd()
228 return *fd >= 0 ? res->fd_type : VIRGL_RESOURCE_FD_INVALID; in virgl_resource_export_fd()
229 } else if (res->pipe_resource) { in virgl_resource_export_fd()
230 return pipe_callbacks.export_fd(res->pipe_resource, in virgl_resource_export_fd()