Merge "Error when attempting to lock buffer alloc'd without CPU_ usage" into main am: 22c6d554b2
Original change: https://android-review.googlesource.com/c/platform/external/minigbm/+/3204926 Change-Id: I879c3a611615b888660af6cba272be908417bcc0 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
25ad577bd6
3 changed files with 36 additions and 1 deletions
|
|
@ -14,6 +14,8 @@
|
|||
#include <syscall.h>
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include "../drv_helpers.h"
|
||||
#include "../drv_priv.h"
|
||||
#include "../util.h"
|
||||
#include "cros_gralloc_buffer_metadata.h"
|
||||
|
||||
|
|
@ -156,7 +158,15 @@ static void drv_destroy_and_close(struct driver *drv)
|
|||
close(fd);
|
||||
}
|
||||
|
||||
cros_gralloc_driver::cros_gralloc_driver() : drv_(init_try_nodes(), drv_destroy_and_close)
|
||||
static bool is_running_with_software_rendering()
|
||||
{
|
||||
const char *vulkan_driver = drv_get_os_option("ro.hardware.vulkan");
|
||||
return (vulkan_driver != nullptr && strstr(vulkan_driver, "pastel") != nullptr);
|
||||
}
|
||||
|
||||
cros_gralloc_driver::cros_gralloc_driver()
|
||||
: drv_(init_try_nodes(), drv_destroy_and_close),
|
||||
is_running_with_software_rendering_(is_running_with_software_rendering())
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -179,6 +189,11 @@ bool cros_gralloc_driver::get_resolved_format_and_use_flags(
|
|||
uint64_t resolved_use_flags;
|
||||
struct combination *combo;
|
||||
|
||||
uint64_t use_flags = descriptor->use_flags;
|
||||
if (is_running_with_software_rendering_ && (use_flags & BO_USE_GPU_HW) != 0) {
|
||||
use_flags |= (BO_USE_SW_READ_OFTEN | BO_USE_SW_WRITE_OFTEN);
|
||||
}
|
||||
|
||||
drv_resolve_format_and_use_flags(drv_.get(), descriptor->drm_format, descriptor->use_flags,
|
||||
&resolved_format, &resolved_use_flags);
|
||||
|
||||
|
|
@ -469,6 +484,15 @@ int32_t cros_gralloc_driver::lock(buffer_handle_t handle, int32_t acquire_fence,
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!is_running_with_software_rendering_) {
|
||||
if ((hnd->usage & (GRALLOC_USAGE_SW_READ_MASK | GRALLOC_USAGE_SW_WRITE_MASK)) ==
|
||||
0) {
|
||||
ALOGE("Attempted to lock() a buffer that was not allocated with a "
|
||||
"BufferUsage::CPU_* usage.");
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
auto buffer = get_buffer(hnd);
|
||||
if (!buffer) {
|
||||
ALOGE("Invalid reference (lock() called on unregistered handle).");
|
||||
|
|
|
|||
|
|
@ -81,6 +81,9 @@ class cros_gralloc_driver
|
|||
std::mutex mutex_;
|
||||
std::unordered_map<uint32_t, std::unique_ptr<cros_gralloc_buffer>> buffers_;
|
||||
std::unordered_map<cros_gralloc_handle_t, cros_gralloc_imported_handle_info> handles_;
|
||||
|
||||
/* TODO(b/242184599): remove after SwiftShader is moved to the host. */
|
||||
const bool is_running_with_software_rendering_ = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@
|
|||
#ifndef DRV_HELPERS_H
|
||||
#define DRV_HELPERS_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "drv.h"
|
||||
|
|
@ -72,4 +76,8 @@ struct lru_entry *lru_find(struct lru *lru, bool (*eq)(struct lru_entry *e, void
|
|||
void lru_insert(struct lru *lru, struct lru_entry *entry);
|
||||
void lru_init(struct lru *lru, int max);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue