Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 1 | /* |
| 2 | * XGL |
| 3 | * |
| 4 | * Copyright (C) 2014 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
Chia-I Wu | 44e4236 | 2014-09-02 08:32:09 +0800 | [diff] [blame] | 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #ifndef MEM_H |
| 29 | #define MEM_H |
| 30 | |
Chia-I Wu | 37fe841 | 2014-08-07 13:34:57 +0800 | [diff] [blame] | 31 | #include "kmd/winsys.h" |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 32 | #include "intel.h" |
Chia-I Wu | 3ada4cb | 2014-08-30 18:55:54 +0800 | [diff] [blame] | 33 | #include "obj.h" |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 34 | |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 35 | struct intel_mem { |
| 36 | struct intel_base base; |
| 37 | |
| 38 | struct intel_bo *bo; |
Chia-I Wu | 000747d | 2014-08-20 15:39:36 +0800 | [diff] [blame] | 39 | XGL_GPU_SIZE size; |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | XGL_RESULT intel_mem_alloc(struct intel_dev *dev, |
| 43 | const XGL_MEMORY_ALLOC_INFO *info, |
| 44 | struct intel_mem **mem_ret); |
| 45 | void intel_mem_free(struct intel_mem *mem); |
| 46 | |
Chia-I Wu | 2cd1e07 | 2015-03-06 12:10:13 -0700 | [diff] [blame^] | 47 | XGL_RESULT intel_mem_import_userptr(struct intel_dev *dev, |
| 48 | const void *userptr, |
| 49 | size_t size, |
| 50 | struct intel_mem **mem_ret); |
| 51 | |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 52 | XGL_RESULT intel_mem_set_priority(struct intel_mem *mem, |
| 53 | XGL_MEMORY_PRIORITY priority); |
| 54 | |
Chia-I Wu | 37fe841 | 2014-08-07 13:34:57 +0800 | [diff] [blame] | 55 | static inline void *intel_mem_map(struct intel_mem *mem, XGL_FLAGS flags) |
| 56 | { |
Chia-I Wu | e1ae375 | 2015-02-25 09:47:30 -0700 | [diff] [blame] | 57 | return intel_bo_map_async(mem->bo); |
Chia-I Wu | 37fe841 | 2014-08-07 13:34:57 +0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | static inline void *intel_mem_map_sync(struct intel_mem *mem, bool rw) |
| 61 | { |
| 62 | return intel_bo_map(mem->bo, rw); |
| 63 | } |
| 64 | |
| 65 | static inline void intel_mem_unmap(struct intel_mem *mem) |
| 66 | { |
| 67 | intel_bo_unmap(mem->bo); |
| 68 | } |
| 69 | |
| 70 | static inline bool intel_mem_is_busy(struct intel_mem *mem) |
| 71 | { |
| 72 | return intel_bo_is_busy(mem->bo); |
| 73 | } |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 74 | |
| 75 | static inline struct intel_mem *intel_mem(XGL_GPU_MEMORY mem) |
| 76 | { |
| 77 | return (struct intel_mem *) mem; |
| 78 | } |
| 79 | |
Chia-I Wu | f9911eb | 2014-08-06 13:50:31 +0800 | [diff] [blame] | 80 | #endif /* MEM_H */ |