Lines Matching refs:res
36 struct vmw_resource res; member
49 struct vmw_resource res; member
57 static void vmw_user_shader_free(struct vmw_resource *res);
61 static int vmw_gb_shader_create(struct vmw_resource *res);
62 static int vmw_gb_shader_bind(struct vmw_resource *res,
64 static int vmw_gb_shader_unbind(struct vmw_resource *res,
67 static int vmw_gb_shader_destroy(struct vmw_resource *res);
69 static int vmw_dx_shader_create(struct vmw_resource *res);
70 static int vmw_dx_shader_bind(struct vmw_resource *res,
72 static int vmw_dx_shader_unbind(struct vmw_resource *res,
75 static void vmw_dx_shader_commit_notify(struct vmw_resource *res,
131 vmw_res_to_shader(struct vmw_resource *res) in vmw_res_to_shader() argument
133 return container_of(res, struct vmw_shader, res); in vmw_res_to_shader()
143 vmw_res_to_dx_shader(struct vmw_resource *res) in vmw_res_to_dx_shader() argument
145 return container_of(res, struct vmw_dx_shader, res); in vmw_res_to_dx_shader()
148 static void vmw_hw_shader_destroy(struct vmw_resource *res) in vmw_hw_shader_destroy() argument
150 if (likely(res->func->destroy)) in vmw_hw_shader_destroy()
151 (void) res->func->destroy(res); in vmw_hw_shader_destroy()
153 res->id = -1; in vmw_hw_shader_destroy()
158 struct vmw_resource *res, in vmw_gb_shader_init() argument
165 void (*res_free) (struct vmw_resource *res)) in vmw_gb_shader_init()
167 struct vmw_shader *shader = vmw_res_to_shader(res); in vmw_gb_shader_init()
170 ret = vmw_resource_init(dev_priv, res, true, res_free, in vmw_gb_shader_init()
175 res_free(res); in vmw_gb_shader_init()
177 kfree(res); in vmw_gb_shader_init()
181 res->guest_memory_size = size; in vmw_gb_shader_init()
183 res->guest_memory_bo = vmw_user_bo_ref(byte_code); in vmw_gb_shader_init()
184 res->guest_memory_offset = offset; in vmw_gb_shader_init()
191 res->hw_destroy = vmw_hw_shader_destroy; in vmw_gb_shader_init()
199 static int vmw_gb_shader_create(struct vmw_resource *res) in vmw_gb_shader_create() argument
201 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_shader_create()
202 struct vmw_shader *shader = vmw_res_to_shader(res); in vmw_gb_shader_create()
209 if (likely(res->id != -1)) in vmw_gb_shader_create()
212 ret = vmw_resource_alloc_id(res); in vmw_gb_shader_create()
218 if (unlikely(res->id >= VMWGFX_NUM_GB_SHADER)) { in vmw_gb_shader_create()
231 cmd->body.shid = res->id; in vmw_gb_shader_create()
240 vmw_resource_release_id(res); in vmw_gb_shader_create()
245 static int vmw_gb_shader_bind(struct vmw_resource *res, in vmw_gb_shader_bind() argument
248 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_shader_bind()
263 cmd->body.shid = res->id; in vmw_gb_shader_bind()
265 cmd->body.offsetInBytes = res->guest_memory_offset; in vmw_gb_shader_bind()
266 res->guest_memory_dirty = false; in vmw_gb_shader_bind()
272 static int vmw_gb_shader_unbind(struct vmw_resource *res, in vmw_gb_shader_unbind() argument
276 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_shader_unbind()
283 BUG_ON(res->guest_memory_bo->tbo.resource->mem_type != VMW_PL_MOB); in vmw_gb_shader_unbind()
291 cmd->body.shid = res->id; in vmw_gb_shader_unbind()
311 static int vmw_gb_shader_destroy(struct vmw_resource *res) in vmw_gb_shader_destroy() argument
313 struct vmw_private *dev_priv = res->dev_priv; in vmw_gb_shader_destroy()
319 if (likely(res->id == -1)) in vmw_gb_shader_destroy()
323 vmw_binding_res_list_scrub(&res->binding_head); in vmw_gb_shader_destroy()
333 cmd->body.shid = res->id; in vmw_gb_shader_destroy()
336 vmw_resource_release_id(res); in vmw_gb_shader_destroy()
354 static void vmw_dx_shader_commit_notify(struct vmw_resource *res, in vmw_dx_shader_commit_notify() argument
357 struct vmw_dx_shader *shader = vmw_res_to_dx_shader(res); in vmw_dx_shader_commit_notify()
358 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_commit_notify()
365 res->id = shader->id; in vmw_dx_shader_commit_notify()
371 res->id = -1; in vmw_dx_shader_commit_notify()
383 static int vmw_dx_shader_unscrub(struct vmw_resource *res) in vmw_dx_shader_unscrub() argument
385 struct vmw_dx_shader *shader = vmw_res_to_dx_shader(res); in vmw_dx_shader_unscrub()
386 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_unscrub()
403 cmd->body.mobid = res->guest_memory_bo->tbo.resource->start; in vmw_dx_shader_unscrub()
404 cmd->body.offsetInBytes = res->guest_memory_offset; in vmw_dx_shader_unscrub()
420 static int vmw_dx_shader_create(struct vmw_resource *res) in vmw_dx_shader_create() argument
422 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_create()
423 struct vmw_dx_shader *shader = vmw_res_to_dx_shader(res); in vmw_dx_shader_create()
428 if (vmw_resource_mob_attached(res)) { in vmw_dx_shader_create()
430 ret = vmw_dx_shader_unscrub(res); in vmw_dx_shader_create()
434 res->id = shader->id; in vmw_dx_shader_create()
445 static int vmw_dx_shader_bind(struct vmw_resource *res, in vmw_dx_shader_bind() argument
448 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_bind()
453 vmw_dx_shader_unscrub(res); in vmw_dx_shader_bind()
469 static int vmw_dx_shader_scrub(struct vmw_resource *res) in vmw_dx_shader_scrub() argument
471 struct vmw_dx_shader *shader = vmw_res_to_dx_shader(res); in vmw_dx_shader_scrub()
472 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_scrub()
489 cmd->body.shid = res->id; in vmw_dx_shader_scrub()
493 res->id = -1; in vmw_dx_shader_scrub()
506 static int vmw_dx_shader_unbind(struct vmw_resource *res, in vmw_dx_shader_unbind() argument
510 struct vmw_private *dev_priv = res->dev_priv; in vmw_dx_shader_unbind()
514 BUG_ON(res->guest_memory_bo->tbo.resource->mem_type != VMW_PL_MOB); in vmw_dx_shader_unbind()
517 ret = vmw_dx_shader_scrub(res); in vmw_dx_shader_unbind()
553 WARN_ON(vmw_dx_shader_scrub(&entry->res)); in vmw_dx_shader_cotable_list_scrub()
566 static void vmw_dx_shader_res_free(struct vmw_resource *res) in vmw_dx_shader_res_free() argument
568 struct vmw_dx_shader *shader = vmw_res_to_dx_shader(res); in vmw_dx_shader_res_free()
591 struct vmw_resource *res; in vmw_dx_shader_add() local
603 res = &shader->res; in vmw_dx_shader_add()
610 ret = vmw_resource_init(dev_priv, res, true, in vmw_dx_shader_add()
621 res, list); in vmw_dx_shader_add()
625 res->id = shader->id; in vmw_dx_shader_add()
626 res->hw_destroy = vmw_hw_shader_destroy; in vmw_dx_shader_add()
629 vmw_resource_unreference(&res); in vmw_dx_shader_add()
644 shader.res); in vmw_user_shader_base_to_res()
647 static void vmw_user_shader_free(struct vmw_resource *res) in vmw_user_shader_free() argument
650 container_of(res, struct vmw_user_shader, shader.res); in vmw_user_shader_free()
655 static void vmw_shader_free(struct vmw_resource *res) in vmw_shader_free() argument
657 struct vmw_shader *shader = vmw_res_to_shader(res); in vmw_shader_free()
670 struct vmw_resource *res = vmw_user_shader_base_to_res(base); in vmw_user_shader_base_release() local
673 vmw_resource_unreference(&res); in vmw_user_shader_base_release()
696 struct vmw_resource *res, *tmp; in vmw_user_shader_alloc() local
705 res = &ushader->shader.res; in vmw_user_shader_alloc()
713 ret = vmw_gb_shader_init(dev_priv, res, shader_size, in vmw_user_shader_alloc()
720 tmp = vmw_resource_reference(res); in vmw_user_shader_alloc()
733 vmw_resource_unreference(&res); in vmw_user_shader_alloc()
746 struct vmw_resource *res; in vmw_shader_alloc() local
755 res = &shader->res; in vmw_shader_alloc()
760 ret = vmw_gb_shader_init(dev_priv, res, shader_size, in vmw_shader_alloc()
765 return ret ? ERR_PTR(ret) : res; in vmw_shader_alloc()
893 struct vmw_resource *res; in vmw_compat_shader_add() local
928 res = vmw_shader_alloc(dev_priv, buf, size, 0, shader_type); in vmw_compat_shader_add()
934 res, list); in vmw_compat_shader_add()
935 vmw_resource_unreference(&res); in vmw_compat_shader_add()