v3d,v3dv: simplify USE_V3D_SIMULATOR/using_v3d_simulator logic
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30287>
This commit is contained in:
committed by
Marge Bot
parent
5577078ac1
commit
eae740f2e4
@@ -11,11 +11,8 @@ files_per_version = files(
|
||||
'v3dx_simulator.c',
|
||||
)
|
||||
|
||||
v3d_simulator_arg = []
|
||||
dep_v3d_hw = dependency('v3d_hw', required: false)
|
||||
if dep_v3d_hw.found()
|
||||
v3d_simulator_arg += '-DUSE_V3D_SIMULATOR'
|
||||
endif
|
||||
v3d_simulator_arg = '-DUSE_V3D_SIMULATOR=@0@'.format(dep_v3d_hw.found().to_int())
|
||||
|
||||
per_version_libs = []
|
||||
foreach ver : v3d_versions
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
* BOs).
|
||||
*/
|
||||
|
||||
#ifdef USE_V3D_SIMULATOR
|
||||
#if USE_V3D_SIMULATOR
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
* v3d_simulator.c code to use.
|
||||
*/
|
||||
|
||||
#ifdef USE_V3D_SIMULATOR
|
||||
#if USE_V3D_SIMULATOR
|
||||
|
||||
#include "v3d_simulator_wrapper.h"
|
||||
#include "v3d_hw_auto.h"
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
* we support.
|
||||
*/
|
||||
|
||||
#ifdef USE_V3D_SIMULATOR
|
||||
#if USE_V3D_SIMULATOR
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -648,7 +648,7 @@ physical_device_finish(struct v3dv_physical_device *device)
|
||||
|
||||
free(device->name);
|
||||
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
v3d_simulator_destroy(device->sim_file);
|
||||
#endif
|
||||
|
||||
@@ -685,7 +685,7 @@ v3dv_DestroyInstance(VkInstance _instance,
|
||||
static uint64_t
|
||||
compute_heap_size()
|
||||
{
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
/* Query the total ram from the system */
|
||||
struct sysinfo info;
|
||||
sysinfo(&info);
|
||||
@@ -715,7 +715,7 @@ compute_memory_budget(struct v3dv_physical_device *device)
|
||||
uint64_t heap_size = device->memory.memoryHeaps[0].size;
|
||||
uint64_t heap_used = device->heap_used;
|
||||
uint64_t sys_available;
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
ASSERTED bool has_available_memory =
|
||||
os_get_available_system_memory(&sys_available);
|
||||
assert(has_available_memory);
|
||||
@@ -1300,7 +1300,7 @@ create_physical_device(struct v3dv_instance *instance,
|
||||
*/
|
||||
|
||||
const char *primary_path;
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
if (display_device)
|
||||
primary_path = display_device->nodes[DRM_NODE_PRIMARY];
|
||||
else
|
||||
@@ -1332,7 +1332,7 @@ create_physical_device(struct v3dv_instance *instance,
|
||||
device->has_render = true;
|
||||
device->render_devid = render_stat.st_rdev;
|
||||
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
device->device_id = gpu_device->deviceinfo.pci->device_id;
|
||||
#endif
|
||||
|
||||
@@ -1341,7 +1341,7 @@ create_physical_device(struct v3dv_instance *instance,
|
||||
instance->vk.enabled_extensions.KHR_xlib_surface ||
|
||||
instance->vk.enabled_extensions.KHR_wayland_surface ||
|
||||
instance->vk.enabled_extensions.EXT_acquire_drm_display) {
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
/* Open the primary node on the vc4 display device */
|
||||
assert(display_device);
|
||||
display_fd = open(primary_path, O_RDWR | O_CLOEXEC);
|
||||
@@ -1353,7 +1353,7 @@ create_physical_device(struct v3dv_instance *instance,
|
||||
#endif
|
||||
}
|
||||
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
device->sim_file = v3d_simulator_init(render_fd);
|
||||
#endif
|
||||
|
||||
@@ -1494,12 +1494,12 @@ enumerate_devices(struct vk_instance *vk_instance)
|
||||
|
||||
VkResult result = VK_SUCCESS;
|
||||
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
int32_t v3d_idx = -1;
|
||||
int32_t vc4_idx = -1;
|
||||
#endif
|
||||
for (unsigned i = 0; i < (unsigned)max_devices; i++) {
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
/* In the simulator, we look for an Intel/AMD render node */
|
||||
const int required_nodes = (1 << DRM_NODE_RENDER) | (1 << DRM_NODE_PRIMARY);
|
||||
if ((devices[i]->available_nodes & required_nodes) == required_nodes &&
|
||||
@@ -1547,7 +1547,7 @@ enumerate_devices(struct vk_instance *vk_instance)
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !using_v3d_simulator
|
||||
#if !USE_V3D_SIMULATOR
|
||||
if (v3d_idx != -1) {
|
||||
drmDevicePtr v3d_device = devices[v3d_idx];
|
||||
drmDevicePtr vc4_device = vc4_idx != -1 ? devices[vc4_idx] : NULL;
|
||||
@@ -1569,7 +1569,7 @@ v3dv_physical_device_vendor_id(const struct v3dv_physical_device *dev)
|
||||
uint32_t
|
||||
v3dv_physical_device_device_id(const struct v3dv_physical_device *dev)
|
||||
{
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
return dev->device_id;
|
||||
#else
|
||||
switch (dev->devinfo.ver) {
|
||||
@@ -2057,7 +2057,7 @@ device_alloc_for_wsi(struct v3dv_device *device,
|
||||
* hardware we need to allocate our winsys BOs on the vc4 display device
|
||||
* and import them into v3d.
|
||||
*/
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
return device_alloc(device, mem, size);
|
||||
#else
|
||||
VkResult result;
|
||||
|
||||
@@ -115,12 +115,6 @@
|
||||
|
||||
struct v3dv_instance;
|
||||
|
||||
#ifdef USE_V3D_SIMULATOR
|
||||
#define using_v3d_simulator true
|
||||
#else
|
||||
#define using_v3d_simulator false
|
||||
#endif
|
||||
|
||||
struct v3d_simulator_file;
|
||||
|
||||
/* Minimum required by the Vulkan 1.1 spec */
|
||||
@@ -145,7 +139,7 @@ struct v3dv_physical_device {
|
||||
dev_t primary_devid;
|
||||
dev_t render_devid;
|
||||
|
||||
#if using_v3d_simulator
|
||||
#if USE_V3D_SIMULATOR
|
||||
uint32_t device_id;
|
||||
#endif
|
||||
|
||||
@@ -2568,7 +2562,7 @@ VK_DEFINE_NONDISP_HANDLE_CASTS(v3dv_sampler, base, VkSampler,
|
||||
static inline int
|
||||
v3dv_ioctl(int fd, unsigned long request, void *arg)
|
||||
{
|
||||
if (using_v3d_simulator)
|
||||
if (USE_V3D_SIMULATOR)
|
||||
return v3d_simulator_ioctl(fd, request, arg);
|
||||
else
|
||||
return drmIoctl(fd, request, arg);
|
||||
|
||||
Reference in New Issue
Block a user