diff --git a/src/broadcom/simulator/meson.build b/src/broadcom/simulator/meson.build index 17a835d8fdd..6179d7ab6aa 100644 --- a/src/broadcom/simulator/meson.build +++ b/src/broadcom/simulator/meson.build @@ -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 diff --git a/src/broadcom/simulator/v3d_simulator.c b/src/broadcom/simulator/v3d_simulator.c index 306d4877dda..04ea4194a25 100644 --- a/src/broadcom/simulator/v3d_simulator.c +++ b/src/broadcom/simulator/v3d_simulator.c @@ -46,7 +46,7 @@ * BOs). */ -#ifdef USE_V3D_SIMULATOR +#if USE_V3D_SIMULATOR #include #include diff --git a/src/broadcom/simulator/v3d_simulator_wrapper.cpp b/src/broadcom/simulator/v3d_simulator_wrapper.cpp index fc0531cd0b8..5ae36b6262c 100644 --- a/src/broadcom/simulator/v3d_simulator_wrapper.cpp +++ b/src/broadcom/simulator/v3d_simulator_wrapper.cpp @@ -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" diff --git a/src/broadcom/simulator/v3dx_simulator.c b/src/broadcom/simulator/v3dx_simulator.c index 8d8145fac13..9491bfacbd6 100644 --- a/src/broadcom/simulator/v3dx_simulator.c +++ b/src/broadcom/simulator/v3dx_simulator.c @@ -31,7 +31,7 @@ * we support. */ -#ifdef USE_V3D_SIMULATOR +#if USE_V3D_SIMULATOR #include #include diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 8389a4dfb25..6a420ed8e80 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -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; diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index 3b920e75a59..8766b554f0f 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -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); diff --git a/src/gallium/drivers/v3d/v3d_bufmgr.c b/src/gallium/drivers/v3d/v3d_bufmgr.c index 914153a9bbc..23fbcf48456 100644 --- a/src/gallium/drivers/v3d/v3d_bufmgr.c +++ b/src/gallium/drivers/v3d/v3d_bufmgr.c @@ -201,7 +201,7 @@ v3d_bo_free(struct v3d_bo *bo) struct v3d_screen *screen = bo->screen; if (bo->map) { - if (using_v3d_simulator && bo->name && + if (USE_V3D_SIMULATOR && bo->name && strcmp(bo->name, "winsys") == 0) { free(bo->map); } else { @@ -347,7 +347,7 @@ v3d_bo_open_handle(struct v3d_screen *screen, bo->name = "winsys"; bo->private = false; -#ifdef USE_V3D_SIMULATOR +#if USE_V3D_SIMULATOR v3d_simulator_open_from_handle(screen->fd, bo->handle, bo->size); bo->map = malloc(bo->size); #endif diff --git a/src/gallium/drivers/v3d/v3d_context.h b/src/gallium/drivers/v3d/v3d_context.h index 16f782f1a75..6dfb817f57d 100644 --- a/src/gallium/drivers/v3d/v3d_context.h +++ b/src/gallium/drivers/v3d/v3d_context.h @@ -52,12 +52,6 @@ void v3d_job_add_bo(struct v3d_job *job, struct v3d_bo *bo); #include "v3d_resource.h" #include "v3d_cl.h" -#ifdef USE_V3D_SIMULATOR -#define using_v3d_simulator true -#else -#define using_v3d_simulator false -#endif - #define V3D_DIRTY_BLEND (1ull << 0) #define V3D_DIRTY_RASTERIZER (1ull << 1) #define V3D_DIRTY_ZSA (1ull << 2) @@ -741,7 +735,7 @@ void v3d_query_init(struct pipe_context *pctx); static inline int v3d_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); diff --git a/src/gallium/drivers/v3d/v3d_resource.c b/src/gallium/drivers/v3d/v3d_resource.c index 937cc999a74..5f24c674078 100644 --- a/src/gallium/drivers/v3d/v3d_resource.c +++ b/src/gallium/drivers/v3d/v3d_resource.c @@ -812,7 +812,7 @@ v3d_resource_create_with_modifiers(struct pipe_screen *pscreen, /* Scanout BOs for simulator need to be linear for interaction with * i965. */ - if (using_v3d_simulator && + if (USE_V3D_SIMULATOR && tmpl->bind & (PIPE_BIND_SHARED | PIPE_BIND_SCANOUT)) should_tile = false; diff --git a/src/gallium/drivers/v3d/v3d_screen.c b/src/gallium/drivers/v3d/v3d_screen.c index 91c5c2a1aa0..c3d08d7f0a4 100644 --- a/src/gallium/drivers/v3d/v3d_screen.c +++ b/src/gallium/drivers/v3d/v3d_screen.c @@ -84,7 +84,7 @@ v3d_screen_destroy(struct pipe_screen *pscreen) if (screen->ro) screen->ro->destroy(screen->ro); - if (using_v3d_simulator) + if (USE_V3D_SIMULATOR) v3d_simulator_destroy(screen->sim_file); v3d_compiler_free(screen->compiler); @@ -922,7 +922,7 @@ v3d_screen_create(int fd, const struct pipe_screen_config *config, (void)mtx_init(&screen->bo_handles_mutex, mtx_plain); screen->bo_handles = util_hash_table_create_ptr_keys(); -#if defined(USE_V3D_SIMULATOR) +#if USE_V3D_SIMULATOR screen->sim_file = v3d_simulator_init(screen->fd); #endif