1848b8605Smrg#include "util/u_debug.h" 2848b8605Smrg 3848b8605Smrg#include "i915_resource.h" 4848b8605Smrg#include "i915_context.h" 5848b8605Smrg#include "i915_screen.h" 6848b8605Smrg 7848b8605Smrg 8848b8605Smrgstatic struct pipe_resource * 9848b8605Smrgi915_resource_create(struct pipe_screen *screen, 10848b8605Smrg const struct pipe_resource *template) 11848b8605Smrg{ 12848b8605Smrg if (template->target == PIPE_BUFFER) 13848b8605Smrg return i915_buffer_create(screen, template); 14848b8605Smrg else 15848b8605Smrg { 16848b8605Smrg if (!(template->bind & PIPE_BIND_LINEAR)) 17848b8605Smrg return i915_texture_create(screen, template, FALSE); 18848b8605Smrg else 19848b8605Smrg return i915_texture_create(screen, template, TRUE); 20848b8605Smrg } 21848b8605Smrg} 22848b8605Smrg 23848b8605Smrgstatic struct pipe_resource * 24848b8605Smrgi915_resource_from_handle(struct pipe_screen * screen, 25848b8605Smrg const struct pipe_resource *template, 26b8e80941Smrg struct winsys_handle *whandle, 27b8e80941Smrg unsigned usage) 28848b8605Smrg{ 29848b8605Smrg if (template->target == PIPE_BUFFER) 30848b8605Smrg return NULL; 31848b8605Smrg else 32848b8605Smrg return i915_texture_from_handle(screen, template, whandle); 33848b8605Smrg} 34848b8605Smrg 35848b8605Smrg 36848b8605Smrgvoid 37848b8605Smrgi915_init_resource_functions(struct i915_context *i915 ) 38848b8605Smrg{ 39848b8605Smrg i915->base.transfer_map = u_transfer_map_vtbl; 40848b8605Smrg i915->base.transfer_flush_region = u_transfer_flush_region_vtbl; 41848b8605Smrg i915->base.transfer_unmap = u_transfer_unmap_vtbl; 42b8e80941Smrg i915->base.buffer_subdata = i915_buffer_subdata; 43b8e80941Smrg i915->base.texture_subdata = u_default_texture_subdata; 44848b8605Smrg} 45848b8605Smrg 46848b8605Smrgvoid 47848b8605Smrgi915_init_screen_resource_functions(struct i915_screen *is) 48848b8605Smrg{ 49848b8605Smrg is->base.resource_create = i915_resource_create; 50848b8605Smrg is->base.resource_from_handle = i915_resource_from_handle; 51848b8605Smrg is->base.resource_get_handle = u_resource_get_handle_vtbl; 52848b8605Smrg is->base.resource_destroy = u_resource_destroy_vtbl; 53848b8605Smrg} 54