1287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "util/u_debug.h" 2287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 3287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_resource.h" 4287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_context.h" 5287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell#include "i915_screen.h" 6287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 7287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 8287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstatic struct pipe_resource * 9287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_resource_create(struct pipe_screen *screen, 101a69b50b3b441ce8f7a00af3a7f02c37df50f6c3Stéphane Marchesin const struct pipe_resource *template) 11287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 12287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (template->target == PIPE_BUFFER) 13287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell return i915_buffer_create(screen, template); 14287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell else 15e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy { 16e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy if (!(template->bind & PIPE_BIND_LINEAR)) 17e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy return i915_texture_create(screen, template, FALSE); 18e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy else 19e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy return i915_texture_create(screen, template, TRUE); 20e8f9195e5fb34a45783d6491d2e0305a0b137439Axel Davy } 21287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 22287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 23287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellstatic struct pipe_resource * 24287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_resource_from_handle(struct pipe_screen * screen, 25287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell const struct pipe_resource *template, 2682db518f1519cec9e3842f23455a105e2006afbdMarek Olšák struct winsys_handle *whandle, 2782db518f1519cec9e3842f23455a105e2006afbdMarek Olšák unsigned usage) 28287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 29287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell if (template->target == PIPE_BUFFER) 30287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell return NULL; 31287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell else 32287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell return i915_texture_from_handle(screen, template, whandle); 33287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 34287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 35287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 36287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 37287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_init_resource_functions(struct i915_context *i915 ) 38287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 39287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell i915->base.transfer_map = u_transfer_map_vtbl; 40287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell i915->base.transfer_flush_region = u_transfer_flush_region_vtbl; 41287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell i915->base.transfer_unmap = u_transfer_unmap_vtbl; 421ffe77e7bb2486ea74cda077ed2a9622b758395cMarek Olšák i915->base.buffer_subdata = i915_buffer_subdata; 431ffe77e7bb2486ea74cda077ed2a9622b758395cMarek Olšák i915->base.texture_subdata = u_default_texture_subdata; 44287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 45287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell 46287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwellvoid 47287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwelli915_init_screen_resource_functions(struct i915_screen *is) 48287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell{ 49287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell is->base.resource_create = i915_resource_create; 50287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell is->base.resource_from_handle = i915_resource_from_handle; 51287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell is->base.resource_get_handle = u_resource_get_handle_vtbl; 52287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell is->base.resource_destroy = u_resource_destroy_vtbl; 53287c94ea4987033f9c99a2f91c5750c9083504caKeith Whitwell} 54