| 1 |
/* |
| 2 |
* Copyright © 2022 Imagination Technologies Ltd. |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a copy |
| 5 |
* of this software and associated documentation files (the "Software"), to deal |
| 6 |
* in the Software without restriction, including without limitation the rights |
| 7 |
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 8 |
* copies of the Software, and to permit persons to whom the Software is |
| 9 |
* furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice (including the next |
| 12 |
* paragraph) shall be included in all copies or substantial portions of the |
| 13 |
* Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 |
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 |
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 |
* SOFTWARE. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <stdbool.h> |
| 25 |
#include <stdint.h> |
| 26 |
|
| 27 |
#include "pvr_bo.h" |
| 28 |
#include "pvr_dump_bo.h" |
| 29 |
#include "pvr_dump.h" |
| 30 |
#include "pvr_winsys.h" |
| 31 |
#include "util/u_math.h" |
| 32 |
|
| 33 |
struct pvr_device; |
| 34 |
|
| 35 |
bool pvr_dump_bo_ctx_push(struct pvr_dump_bo_ctx *const ctx, |
| 36 |
struct pvr_dump_ctx *const parent_ctx, |
| 37 |
struct pvr_device *const device, |
| 38 |
struct pvr_bo *const bo) |
| 39 |
{ |
| 40 |
bool did_map_bo = false; |
| 41 |
|
| 42 |
if (!bo->bo->map) { |
| 43 |
if (pvr_bo_cpu_map_unchanged(device, bo) != VK_SUCCESS) |
| 44 |
goto err_out; |
| 45 |
|
| 46 |
did_map_bo = true; |
| 47 |
} |
| 48 |
|
| 49 |
if (bo->bo->size > UINT32_MAX) { |
| 50 |
mesa_logw_once("Attempted to dump a BO larger than 4GiB; time to rework" |
| 51 |
"pvr_dump_buffer_ctx to use 64-bit sizes."); |
| 52 |
goto err_unmap_bo; |
| 53 |
} |
| 54 |
|
| 55 |
if (!pvr_dump_buffer_ctx_push(&ctx->base, |
| 56 |
parent_ctx, |
| 57 |
bo->bo->map, |
| 58 |
bo->bo->size)) { |
| 59 |
goto err_unmap_bo; |
| 60 |
} |
| 61 |
|
| 62 |
ctx->device = device; |
| 63 |
ctx->bo = bo; |
| 64 |
ctx->bo_mapped_in_ctx = did_map_bo; |
| 65 |
|
| 66 |
return true; |
| 67 |
|
| 68 |
err_unmap_bo: |
| 69 |
if (did_map_bo) |
| 70 |
pvr_bo_cpu_unmap(device, bo); |
| 71 |
|
| 72 |
err_out: |
| 73 |
return false; |
| 74 |
} |
| 75 |
|
| 76 |
bool pvr_dump_bo_ctx_pop(struct pvr_dump_bo_ctx *const ctx) |
| 77 |
{ |
| 78 |
if (ctx->bo_mapped_in_ctx) |
| 79 |
pvr_bo_cpu_unmap(ctx->device, ctx->bo); |
| 80 |
|
| 81 |
return pvr_dump_buffer_ctx_pop(&ctx->base); |
| 82 |
} |