1bf215546Sopenharmony_ci#include "util/u_debug.h" 2bf215546Sopenharmony_ci 3bf215546Sopenharmony_ci#include "i915_context.h" 4bf215546Sopenharmony_ci#include "i915_resource.h" 5bf215546Sopenharmony_ci#include "i915_screen.h" 6bf215546Sopenharmony_ci 7bf215546Sopenharmony_cistatic struct pipe_resource * 8bf215546Sopenharmony_cii915_resource_create(struct pipe_screen *screen, 9bf215546Sopenharmony_ci const struct pipe_resource *template) 10bf215546Sopenharmony_ci{ 11bf215546Sopenharmony_ci if (template->target == PIPE_BUFFER) 12bf215546Sopenharmony_ci return i915_buffer_create(screen, template); 13bf215546Sopenharmony_ci else { 14bf215546Sopenharmony_ci if (!(template->bind & PIPE_BIND_LINEAR)) 15bf215546Sopenharmony_ci return i915_texture_create(screen, template, false); 16bf215546Sopenharmony_ci else 17bf215546Sopenharmony_ci return i915_texture_create(screen, template, true); 18bf215546Sopenharmony_ci } 19bf215546Sopenharmony_ci} 20bf215546Sopenharmony_ci 21bf215546Sopenharmony_cistatic struct pipe_resource * 22bf215546Sopenharmony_cii915_resource_from_handle(struct pipe_screen *screen, 23bf215546Sopenharmony_ci const struct pipe_resource *template, 24bf215546Sopenharmony_ci struct winsys_handle *whandle, unsigned usage) 25bf215546Sopenharmony_ci{ 26bf215546Sopenharmony_ci if (template->target == PIPE_BUFFER) 27bf215546Sopenharmony_ci return NULL; 28bf215546Sopenharmony_ci else 29bf215546Sopenharmony_ci return i915_texture_from_handle(screen, template, whandle); 30bf215546Sopenharmony_ci} 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_civoid 33bf215546Sopenharmony_cii915_init_resource_functions(struct i915_context *i915) 34bf215546Sopenharmony_ci{ 35bf215546Sopenharmony_ci i915->base.buffer_map = i915_buffer_transfer_map; 36bf215546Sopenharmony_ci i915->base.texture_map = i915_texture_transfer_map; 37bf215546Sopenharmony_ci i915->base.transfer_flush_region = u_default_transfer_flush_region; 38bf215546Sopenharmony_ci i915->base.buffer_unmap = i915_buffer_transfer_unmap; 39bf215546Sopenharmony_ci i915->base.texture_unmap = i915_texture_transfer_unmap; 40bf215546Sopenharmony_ci i915->base.buffer_subdata = i915_buffer_subdata; 41bf215546Sopenharmony_ci i915->base.texture_subdata = i915_texture_subdata; 42bf215546Sopenharmony_ci} 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_civoid 45bf215546Sopenharmony_cii915_init_screen_resource_functions(struct i915_screen *is) 46bf215546Sopenharmony_ci{ 47bf215546Sopenharmony_ci is->base.resource_create = i915_resource_create; 48bf215546Sopenharmony_ci is->base.resource_from_handle = i915_resource_from_handle; 49bf215546Sopenharmony_ci is->base.resource_get_handle = i915_resource_get_handle; 50bf215546Sopenharmony_ci is->base.resource_destroy = i915_resource_destroy; 51bf215546Sopenharmony_ci} 52