radv: Stub sections that don't have _WIN32 support

Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7793>
This commit is contained in:
James Park
2020-12-03 02:15:50 -08:00
committed by Marge Bot
parent 146e326275
commit c0b4b8fc74
5 changed files with 54 additions and 21 deletions

View File

@@ -312,6 +312,7 @@ radv_handle_thread_trace(VkQueue _queue)
} else { } else {
bool frame_trigger = num_frames == queue->device->thread_trace.start_frame; bool frame_trigger = num_frames == queue->device->thread_trace.start_frame;
bool file_trigger = false; bool file_trigger = false;
#ifndef _WIN32
if (queue->device->thread_trace.trigger_file && if (queue->device->thread_trace.trigger_file &&
access(queue->device->thread_trace.trigger_file, W_OK) == 0) { access(queue->device->thread_trace.trigger_file, W_OK) == 0) {
if (unlink(queue->device->thread_trace.trigger_file) == 0) { if (unlink(queue->device->thread_trace.trigger_file) == 0) {
@@ -322,6 +323,7 @@ radv_handle_thread_trace(VkQueue _queue)
fprintf(stderr, "RADV: could not remove thread trace trigger file, ignoring\n"); fprintf(stderr, "RADV: could not remove thread trace trigger file, ignoring\n");
} }
} }
#endif
if (frame_trigger || file_trigger) { if (frame_trigger || file_trigger) {
radv_begin_thread_trace(queue); radv_begin_thread_trace(queue);

View File

@@ -27,7 +27,9 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#ifndef _WIN32
#include <sys/utsname.h> #include <sys/utsname.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
#include "util/mesa-sha1.h" #include "util/mesa-sha1.h"
@@ -511,6 +513,7 @@ radv_dump_queue_state(struct radv_queue *queue, FILE *f)
static void static void
radv_dump_cmd(const char *cmd, FILE *f) radv_dump_cmd(const char *cmd, FILE *f)
{ {
#ifndef _WIN32
char line[2048]; char line[2048];
FILE *p; FILE *p;
@@ -521,6 +524,7 @@ radv_dump_cmd(const char *cmd, FILE *f)
fprintf(f, "\n"); fprintf(f, "\n");
pclose(p); pclose(p);
} }
#endif
} }
static void static void
@@ -579,12 +583,19 @@ static void
radv_dump_device_name(struct radv_device *device, FILE *f) radv_dump_device_name(struct radv_device *device, FILE *f)
{ {
struct radeon_info *info = &device->physical_device->rad_info; struct radeon_info *info = &device->physical_device->rad_info;
#ifndef _WIN32
char kernel_version[128] = {0}; char kernel_version[128] = {0};
struct utsname uname_data; struct utsname uname_data;
#endif
const char *chip_name; const char *chip_name;
chip_name = device->ws->get_chip_name(device->ws); chip_name = device->ws->get_chip_name(device->ws);
#ifdef _WIN32
fprintf(f, "Device name: %s (%s / DRM %i.%i.%i)\n\n",
chip_name, device->physical_device->name,
info->drm_major, info->drm_minor, info->drm_patchlevel);
#else
if (uname(&uname_data) == 0) if (uname(&uname_data) == 0)
snprintf(kernel_version, sizeof(kernel_version), snprintf(kernel_version, sizeof(kernel_version),
" / %s", uname_data.release); " / %s", uname_data.release);
@@ -593,6 +604,7 @@ radv_dump_device_name(struct radv_device *device, FILE *f)
chip_name, device->physical_device->name, chip_name, device->physical_device->name,
info->drm_major, info->drm_minor, info->drm_patchlevel, info->drm_major, info->drm_minor, info->drm_patchlevel,
kernel_version); kernel_version);
#endif
} }
static void static void
@@ -785,6 +797,7 @@ radv_check_gpu_hangs(struct radv_queue *queue, struct radeon_cmdbuf *cs)
void void
radv_print_spirv(const char *data, uint32_t size, FILE *fp) radv_print_spirv(const char *data, uint32_t size, FILE *fp)
{ {
#ifndef _WIN32
char path[] = "/tmp/fileXXXXXX"; char path[] = "/tmp/fileXXXXXX";
char command[128]; char command[128];
int fd; int fd;
@@ -804,6 +817,7 @@ radv_print_spirv(const char *data, uint32_t size, FILE *fp)
fail: fail:
close(fd); close(fd);
unlink(path); unlink(path);
#endif
} }
bool bool

View File

@@ -36,10 +36,14 @@
#include "util/disk_cache.h" #include "util/disk_cache.h"
#include "vk_deferred_operation.h" #include "vk_deferred_operation.h"
#include "vk_util.h" #include "vk_util.h"
#ifdef _WIN32
typedef void* drmDevicePtr;
#else
#include <xf86drm.h> #include <xf86drm.h>
#include <amdgpu.h> #include <amdgpu.h>
#include "drm-uapi/amdgpu_drm.h" #include "drm-uapi/amdgpu_drm.h"
#include "winsys/amdgpu/radv_amdgpu_winsys_public.h" #include "winsys/amdgpu/radv_amdgpu_winsys_public.h"
#endif
#include "winsys/null/radv_null_winsys_public.h" #include "winsys/null/radv_null_winsys_public.h"
#include "ac_llvm_util.h" #include "ac_llvm_util.h"
#include "vk_format.h" #include "vk_format.h"
@@ -293,6 +297,9 @@ radv_physical_device_try_create(struct radv_instance *instance,
int fd = -1; int fd = -1;
int master_fd = -1; int master_fd = -1;
#ifdef _WIN32
assert(drm_device == NULL);
#else
if (drm_device) { if (drm_device) {
const char *path = drm_device->nodes[DRM_NODE_RENDER]; const char *path = drm_device->nodes[DRM_NODE_RENDER];
drmVersionPtr version; drmVersionPtr version;
@@ -330,6 +337,7 @@ radv_physical_device_try_create(struct radv_instance *instance,
if (instance->debug_flags & RADV_DEBUG_STARTUP) if (instance->debug_flags & RADV_DEBUG_STARTUP)
radv_logi("Found compatible device '%s'.", path); radv_logi("Found compatible device '%s'.", path);
} }
#endif
struct radv_physical_device *device = struct radv_physical_device *device =
vk_zalloc2(&instance->alloc, NULL, sizeof(*device), 8, vk_zalloc2(&instance->alloc, NULL, sizeof(*device), 8,
@@ -342,12 +350,16 @@ radv_physical_device_try_create(struct radv_instance *instance,
device->_loader_data.loaderMagic = ICD_LOADER_MAGIC; device->_loader_data.loaderMagic = ICD_LOADER_MAGIC;
device->instance = instance; device->instance = instance;
#ifdef _WIN32
device->ws = radv_null_winsys_create();
#else
if (drm_device) { if (drm_device) {
device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags, device->ws = radv_amdgpu_winsys_create(fd, instance->debug_flags,
instance->perftest_flags); instance->perftest_flags);
} else { } else {
device->ws = radv_null_winsys_create(); device->ws = radv_null_winsys_create();
} }
#endif
if (!device->ws) { if (!device->ws) {
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED, result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
@@ -355,6 +367,7 @@ radv_physical_device_try_create(struct radv_instance *instance,
goto fail_alloc; goto fail_alloc;
} }
#ifndef _WIN32
if (drm_device && instance->enabled_extensions.KHR_display) { if (drm_device && instance->enabled_extensions.KHR_display) {
master_fd = open(drm_device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC); master_fd = open(drm_device->nodes[DRM_NODE_PRIMARY], O_RDWR | O_CLOEXEC);
if (master_fd >= 0) { if (master_fd >= 0) {
@@ -371,6 +384,7 @@ radv_physical_device_try_create(struct radv_instance *instance,
} }
} }
} }
#endif
device->master_fd = master_fd; device->master_fd = master_fd;
device->local_fd = fd; device->local_fd = fd;
@@ -441,8 +455,10 @@ radv_physical_device_try_create(struct radv_instance *instance,
radv_physical_device_get_supported_extensions(device, radv_physical_device_get_supported_extensions(device,
&device->supported_extensions); &device->supported_extensions);
#ifndef _WIN32
if (drm_device) if (drm_device)
device->bus_info = *drm_device->businfo.pci; device->bus_info = *drm_device->businfo.pci;
#endif
if ((device->instance->debug_flags & RADV_DEBUG_INFO)) if ((device->instance->debug_flags & RADV_DEBUG_INFO))
ac_print_gpu_info(&device->rad_info, stdout); ac_print_gpu_info(&device->rad_info, stdout);
@@ -857,10 +873,7 @@ radv_enumerate_physical_devices(struct radv_instance *instance)
instance->physical_devices_enumerated = true; instance->physical_devices_enumerated = true;
/* TODO: Check for more devices ? */
drmDevicePtr devices[8];
VkResult result = VK_SUCCESS; VkResult result = VK_SUCCESS;
int max_devices;
if (getenv("RADV_FORCE_FAMILY")) { if (getenv("RADV_FORCE_FAMILY")) {
/* When RADV_FORCE_FAMILY is set, the driver creates a nul /* When RADV_FORCE_FAMILY is set, the driver creates a nul
@@ -877,7 +890,10 @@ radv_enumerate_physical_devices(struct radv_instance *instance)
return VK_SUCCESS; return VK_SUCCESS;
} }
max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices)); #ifndef _WIN32
/* TODO: Check for more devices ? */
drmDevicePtr devices[8];
int max_devices = drmGetDevices2(0, devices, ARRAY_SIZE(devices));
if (instance->debug_flags & RADV_DEBUG_STARTUP) if (instance->debug_flags & RADV_DEBUG_STARTUP)
radv_logi("Found %d drm nodes", max_devices); radv_logi("Found %d drm nodes", max_devices);
@@ -907,6 +923,7 @@ radv_enumerate_physical_devices(struct radv_instance *instance)
} }
} }
drmFreeDevices(devices, max_devices); drmFreeDevices(devices, max_devices);
#endif
/* If we successfully enumerated any devices, call it success */ /* If we successfully enumerated any devices, call it success */
return result; return result;
@@ -2005,6 +2022,7 @@ void radv_GetPhysicalDeviceProperties2(
properties->conservativeRasterizationPostDepthCoverage = false; properties->conservativeRasterizationPostDepthCoverage = false;
break; break;
} }
#ifndef _WIN32
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT: {
VkPhysicalDevicePCIBusInfoPropertiesEXT *properties = VkPhysicalDevicePCIBusInfoPropertiesEXT *properties =
(VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext; (VkPhysicalDevicePCIBusInfoPropertiesEXT *)ext;
@@ -2014,6 +2032,7 @@ void radv_GetPhysicalDeviceProperties2(
properties->pciFunction = pdevice->bus_info.func; properties->pciFunction = pdevice->bus_info.func;
break; break;
} }
#endif
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES: { case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DRIVER_PROPERTIES: {
VkPhysicalDeviceDriverProperties *properties = VkPhysicalDeviceDriverProperties *properties =
(VkPhysicalDeviceDriverProperties *) ext; (VkPhysicalDeviceDriverProperties *) ext;
@@ -5262,11 +5281,6 @@ PFN_vkVoidFunction radv_GetInstanceProcAddr(
* to work around certain LD_PRELOAD issues seen in apps. * to work around certain LD_PRELOAD issues seen in apps.
*/ */
PUBLIC PUBLIC
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
VkInstance instance,
const char* pName);
PUBLIC
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr( VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
VkInstance instance, VkInstance instance,
const char* pName) const char* pName)
@@ -5274,11 +5288,6 @@ VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetInstanceProcAddr(
return radv_GetInstanceProcAddr(instance, pName); return radv_GetInstanceProcAddr(instance, pName);
} }
PUBLIC
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(
VkInstance _instance,
const char* pName);
PUBLIC PUBLIC
VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr( VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL vk_icdGetPhysicalDeviceProcAddr(
VkInstance _instance, VkInstance _instance,
@@ -7683,12 +7692,6 @@ void radv_DestroySampler(
vk_free2(&device->vk.alloc, pAllocator, sampler); vk_free2(&device->vk.alloc, pAllocator, sampler);
} }
/* vk_icd.h does not declare this function, so we declare it here to
* suppress Wmissing-prototypes.
*/
PUBLIC VKAPI_ATTR VkResult VKAPI_CALL
vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion);
PUBLIC VKAPI_ATTR VkResult VKAPI_CALL PUBLIC VKAPI_ATTR VkResult VKAPI_CALL
vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion) vk_icdNegotiateLoaderICDInterfaceVersion(uint32_t *pSupportedVersion)
{ {

View File

@@ -29,7 +29,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <limits.h> #include <limits.h>
#ifndef _WIN32
#include <pwd.h> #include <pwd.h>
#endif
#include <sys/stat.h> #include <sys/stat.h>
void void
@@ -293,6 +295,7 @@ meta_free(void* _device, void *data)
device->vk.alloc.pfnFree(device->vk.alloc.pUserData, data); device->vk.alloc.pfnFree(device->vk.alloc.pUserData, data);
} }
#ifndef _WIN32
static bool static bool
radv_builtin_cache_path(char *path) radv_builtin_cache_path(char *path)
{ {
@@ -322,10 +325,14 @@ radv_builtin_cache_path(char *path)
pwd.pw_dir, suffix2, sizeof(void *) * 8); pwd.pw_dir, suffix2, sizeof(void *) * 8);
return ret > 0 && ret < PATH_MAX + 1; return ret > 0 && ret < PATH_MAX + 1;
} }
#endif
static bool static bool
radv_load_meta_pipeline(struct radv_device *device) radv_load_meta_pipeline(struct radv_device *device)
{ {
#ifdef _WIN32
return false;
#else
char path[PATH_MAX + 1]; char path[PATH_MAX + 1];
struct stat st; struct stat st;
void *data = NULL; void *data = NULL;
@@ -350,11 +357,13 @@ fail:
free(data); free(data);
close(fd); close(fd);
return ret; return ret;
#endif
} }
static void static void
radv_store_meta_pipeline(struct radv_device *device) radv_store_meta_pipeline(struct radv_device *device)
{ {
#ifndef _WIN32
char path[PATH_MAX + 1], path2[PATH_MAX + 7]; char path[PATH_MAX + 1], path2[PATH_MAX + 7];
size_t size; size_t size;
void *data = NULL; void *data = NULL;
@@ -391,6 +400,7 @@ fail:
free(data); free(data);
close(fd); close(fd);
unlink(path2); unlink(path2);
#endif
} }
VkResult VkResult

View File

@@ -43,7 +43,10 @@
#endif #endif
#include "c11/threads.h" #include "c11/threads.h"
#ifndef _WIN32
#include <amdgpu.h> #include <amdgpu.h>
#include <xf86drm.h>
#endif
#include "compiler/shader_enums.h" #include "compiler/shader_enums.h"
#include "util/cnd_monotonic.h" #include "util/cnd_monotonic.h"
#include "util/macros.h" #include "util/macros.h"
@@ -84,7 +87,6 @@ typedef uint32_t xcb_window_t;
#include "radv_entrypoints.h" #include "radv_entrypoints.h"
#include "wsi_common.h" #include "wsi_common.h"
#include "wsi_common_display.h"
/* Helper to determine if we should compile /* Helper to determine if we should compile
* any of the Android AHB support. * any of the Android AHB support.
@@ -322,7 +324,9 @@ struct radv_physical_device {
enum radeon_bo_flag memory_flags[VK_MAX_MEMORY_TYPES]; enum radeon_bo_flag memory_flags[VK_MAX_MEMORY_TYPES];
unsigned heaps; unsigned heaps;
#ifndef _WIN32
drmPciBusInfo bus_info; drmPciBusInfo bus_info;
#endif
struct radv_device_extension_table supported_extensions; struct radv_device_extension_table supported_extensions;
}; };