Skip to content

Commit

Permalink
meta: Add Vulkan profiles.
Browse files Browse the repository at this point in the history
  • Loading branch information
HansKristian-Work committed May 23, 2023
1 parent aac3bf0 commit 2fbc529
Show file tree
Hide file tree
Showing 15 changed files with 1,397 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build
build.*
vkd3d-proton-*.tar.zst
vkd3d-proton-*/

/profiles/vulkan
/profiles/profile-test
754 changes: 754 additions & 0 deletions VP_D3D12_VKD3D_PROTON_profile.json

Large diffs are not rendered by default.

508 changes: 508 additions & 0 deletions profiles/PROFILES.md

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions profiles/generate_profile_solution.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

mkdir -p profiles/vulkan/debug

if [ -z ${VULKAN_PROFILE_PREFIX} ]; then
VULKAN_PROFILE_PREFIX="$HOME/.local"
echo "Using VULKAN_PROFILE_PREFIX=$VULKAN_PROFILE_PREFIX."
fi

# Install Vulkan-Profiles to ~/.local prefix.

python3 "${VULKAN_PROFILE_PREFIX}/share/vulkan/registry/gen_profiles_solution.py" \
--registry subprojects/Vulkan-Headers/registry/vk.xml \
--input . \
--output-library-inc profiles/vulkan \
--output-library-src profiles/vulkan \
--output-doc profiles/PROFILES.md \
--validate --debug
87 changes: 87 additions & 0 deletions profiles/profile-test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* Copyright 2023 Hans-Kristian Arntzen for Valve Corporation
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/

#include "vulkan/vulkan_profiles.h"
#include <stdio.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>

/* Crude ad-hoc check. */

int main(void)
{
VkInstanceCreateInfo instance_create_info;
VpInstanceCreateInfo vp_instance_info;
VkPhysicalDeviceProperties gpu_props;
VkApplicationInfo app_info;
VpProfileProperties *props;
VkPhysicalDevice *gpus;
uint32_t profile_count;
VkInstance instance;
uint32_t gpu_count;
VkBool32 supported;
uint32_t i, j;

vpGetProfiles(&profile_count, NULL);
props = (VpProfileProperties*)calloc(profile_count, sizeof(*props));
vpGetProfiles(&profile_count, props);

for (i = 0; i < profile_count; i++)
{
printf("Testing profile %s.\n", props[i].profileName);

memset(&instance_create_info, 0, sizeof(instance_create_info));
memset(&vp_instance_info, 0, sizeof(vp_instance_info));
memset(&app_info, 0, sizeof(app_info));
instance_create_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
app_info.apiVersion = VK_API_VERSION_1_3;
app_info.pEngineName = "vkd3d";
instance_create_info.pApplicationInfo = &app_info;
vp_instance_info.pCreateInfo = &instance_create_info;

if (vpGetInstanceProfileSupport(NULL, &props[i], &supported) != VK_SUCCESS || !supported)
{
fprintf(stderr, "Profile %s is not supported at instance level.\n",
props[i].profileName);
}

if (vpCreateInstance(&vp_instance_info, NULL, &instance) != VK_SUCCESS)
{
fprintf(stderr, "Failed to create instance ...\n");
continue;
}

vkEnumeratePhysicalDevices(instance, &gpu_count, NULL);
gpus = (VkPhysicalDevice*)calloc(gpu_count, sizeof(*gpus));
vkEnumeratePhysicalDevices(instance, &gpu_count, gpus);

for (j = 0; j < gpu_count; j++)
{
vkGetPhysicalDeviceProperties(gpus[j], &gpu_props);
if (vpGetPhysicalDeviceProfileSupport(instance, gpus[j], &props[i], &supported) != VK_SUCCESS)
supported = VK_FALSE;

printf("[RESULT] GPU: %s, Profile: %s, supported: %s\n",
gpu_props.deviceName, props[i].profileName, supported ? "yes" : "no");
}

free(gpus);
vkDestroyInstance(instance, NULL);
}
}
10 changes: 10 additions & 0 deletions profiles/setup_profile_environment_common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation:VK_LAYER_KHRONOS_profiles
export VK_KHRONOS_PROFILES_DEFAULT_FEATURE_VALUES=DEFAULT_FEATURE_VALUES_FALSE
export VK_KHRONOS_PROFILES_PROFILE_FILE=$(pwd)/VP_D3D12_VKD3D_PROTON_profile.json
export VK_KHRONOS_PROFILES_PROFILE_NAME=${PROFILE_NAME}
export VK_KHRONOS_PROFILES_SIMULATE_CAPABILITIES=SIMULATE_API_VERSION_BIT,SIMULATE_FEATURES_BIT,SIMULATE_PROPERTIES_BIT,SIMULATE_EXTENSIONS_BIT
export VK_LAYER_PATH=/usr/share/vulkan/explicit_layer.d:~/.local/share/vulkan/explicit_layer.d
export VK_KHRONOS_PROFILES_EMULATE_PORTABILITY=false
export LD_LIBRARY_PATH="$HOME/.local/lib:$LD_LIBRARY_PATH"
export VK_KHRONOS_PROFILES_DEBUG_ACTIONS=DEBUG_ACTION_FILE_BIT
export VK_KHRONOS_PROFILES_DEBUG_FILENAME=/dev/null
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_11_0_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_11_0_baseline
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_11_1_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_11_1_baseline
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_12_0_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_12_0_baseline
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_12_0_optimal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_12_0_optimal
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_12_1_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_12_1_baseline
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_12_2_baseline.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_12_2_baseline
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_fl_12_2_optimal.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_FL_12_2_optimal
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_maximum_nv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_maximum_nv
source profiles/setup_profile_environment_common.sh
2 changes: 2 additions & 0 deletions profiles/setup_profile_environment_maximum_radv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PROFILE_NAME=VP_D3D12_maximum_radv
source profiles/setup_profile_environment_common.sh

0 comments on commit 2fbc529

Please sign in to comment.