Skip to content

Commit

Permalink
Update xgl from commit: c664796825
Browse files Browse the repository at this point in the history
* Runtime Setting `PipelineCachingEnvironmentVariable' Incorrect Behavior
* Add app profile for angle
* Handle all flag combinations in VkToPalWaitPipePoint()
* Update PAL Version in XGL 685
* Remove CreatePartialPipelineBinary()
* Implement Dispatch Tunneling
* Add optional preferred present mode for XWayland
* Fix compiler warnings
* limit the maximun memory size of pipeline cache in 32-bit system
* Update Khronos Vulkan Headers to 1.2.195
* Fix memory size requirements
* Assert if the gpu address is not found
  • Loading branch information
JaxLinAMD committed Nov 2, 2021
1 parent a194b09 commit 477361f
Show file tree
Hide file tree
Showing 51 changed files with 710 additions and 358 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

cmake_minimum_required(VERSION 3.13.4)

# This part set before "project(XGL VERSION 1 LANGUAGES C CXX)".
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@

# Vulkan® API Layer (XGL)

The Vulkan API Layer (XGL) translates Vulkan API commands into PAL commands. It compiles shaders that compose a particular `VkPipeline` object as a single entity using the LLVM-Based Pipeline Compiler (LLPC) library.
The Vulkan API Layer (XGL) translates Vulkan API commands into PAL commands. It compiles shaders
that compose a particular `VkPipeline` object as a single entity using the LLVM-Based Pipeline
Compiler (LLPC) library.

### Build

For an overview and build instructions, see the [AMDVLK readme](https://github.com/GPUOpen-Drivers/AMDVLK).
1 change: 1 addition & 0 deletions cmake/Modules/AmdCmakeHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

# Include Frequently Used Modules ##################################################################
Expand Down
9 changes: 1 addition & 8 deletions cmake/XglCompileDefinitions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

macro(xgl_set_compile_definitions)
Expand Down Expand Up @@ -50,8 +51,6 @@ macro(xgl_set_compile_definitions)

target_compile_definitions(xgl PRIVATE PAL_BUILD_GFX9=1)

target_compile_definitions(xgl PRIVATE PAL_BUILD_GFX10)

target_compile_definitions(xgl PRIVATE PAL_BUILD_RAVEN2)

target_compile_definitions(xgl PRIVATE PAL_BUILD_RENOIR)
Expand Down Expand Up @@ -98,12 +97,6 @@ macro(xgl_set_compile_definitions)
endif()
#endif

#if VKI_EXPOSE_EXT_CONDITIONAL_RENDERING
if(VKI_EXPOSE_EXT_CONDITIONAL_RENDERING)
target_compile_definitions(xgl PRIVATE VKI_EXPOSE_EXT_CONDITIONAL_RENDERING)
endif()
#endif

if(BUILD_WAYLAND_SUPPORT)
target_compile_definitions(xgl PRIVATE VK_USE_PLATFORM_WAYLAND_KHR)
endif()
Expand Down
3 changes: 3 additions & 0 deletions cmake/XglCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

macro(xgl_use_clang_compiler)
Expand Down Expand Up @@ -216,6 +217,8 @@ function(xgl_compiler_options TARGET)
# -Wunused-const-variable
# -Wunused-value
-Wno-unused
# This is part of -Wextra in clang, so we need to disable it explicitly
-Wno-unused-parameter
)

if(ICD_ANALYSIS_WARNINGS_AS_ERRORS)
Expand Down
1 change: 1 addition & 0 deletions cmake/XglHelper.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

macro(xgl_append_common_sanitizer_flags)
Expand Down
1 change: 1 addition & 0 deletions cmake/XglOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

macro(xgl_options)
Expand Down
3 changes: 1 addition & 2 deletions cmake/XglOverrides.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

include_guard()

macro(xgl_get_version)
Expand Down Expand Up @@ -150,8 +151,6 @@ macro(xgl_overrides_pal)

set(PAL_BUILD_VEGA20 ${XGL_BUILD_VEGA20} CACHE BOOL "${PROJECT_NAME} override." FORCE)

set(PAL_BUILD_GFX10 ON CACHE BOOL "${PROJECT_NAME} override." FORCE)

set(PAL_BUILD_NAVI12 ${XGL_BUILD_NAVI12} CACHE BOOL "${PROJECT_NAME} override." FORCE)

set(PAL_BUILD_NAVI14 ON CACHE BOOL "${PROJECT_NAME} override." FORCE)
Expand Down
1 change: 1 addition & 0 deletions cmake/XglPackaging.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# SOFTWARE.
#
#######################################################################################################################

set(supported_package_types
DEB
RPM
Expand Down
2 changes: 2 additions & 0 deletions icd/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# SOFTWARE.
#
#######################################################################################################################

### Create XGL Library #################################################################################################
add_library(xgl SHARED)

set(ICD_TARGET amdvlk${TARGET_ARCHITECTURE_BITS})
Expand Down
4 changes: 2 additions & 2 deletions icd/Loader/LunarG/Lnx/amd-icd.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
"file_format_version": "1.0.0",
"ICD": {
"library_path": "@AMDVLK_INSTALL_PATH@/amdvlk@[email protected]",
"api_version": "1.2.191"
"api_version": "1.2.195"
},
"layer": {
"name": "VK_LAYER_AMD_switchable_graphics_@ISABITS@",
"type": "GLOBAL",
"library_path": "@AMDVLK_INSTALL_PATH@/amdvlk@[email protected]",
"api_version": "1.2.191",
"api_version": "1.2.195",
"implementation_version": "1",
"description": "AMD switchable graphics layer",
"functions": {
Expand Down
14 changes: 14 additions & 0 deletions icd/api/app_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ constexpr AppProfilePatternEntry AppEngineUnity =
"unity"
};

constexpr AppProfilePatternEntry AppEngineAngle =
{
PatternEngineNameLower,
"angle"
};

constexpr AppProfilePatternEntry AppNameValheim =
{
PatternExeNameLower,
Expand Down Expand Up @@ -854,6 +860,14 @@ AppProfilePattern AppPatternTable[] =
}
},

{
AppProfile::AngleEngine,
{
AppEngineAngle,
PatternEnd
}
},

};

static char* GetExecutableName(size_t* pLength, bool includeExtension = false);
Expand Down
116 changes: 2 additions & 114 deletions icd/api/compiler_solution_llpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ VkResult CompilerSolutionLlpc::BuildShaderModule(

auto pPipelineCompiler = m_pPhysicalDevice->GetCompiler();
pPipelineCompiler->ApplyPipelineOptions(pDevice, 0, &moduleInfo.options.pipelineOptions);
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 50
moduleInfo.options.enableOpt = (flags & VK_SHADER_MODULE_ENABLE_OPT_BIT) ? true : false;
#endif

Vkgc::Result llpcResult = m_pLlpc->BuildShaderModule(&moduleInfo, &buildOut);

Expand Down Expand Up @@ -175,120 +177,6 @@ void CompilerSolutionLlpc::FreeShaderModule(ShaderModuleHandle* pShaderModule)
pInstance->FreeMem(pShaderModule->pLlpcShaderModule);
}

// =====================================================================================================================
// Creates partial pipeline binary for compute shader and fragment shader
VkResult CompilerSolutionLlpc::CreatePartialPipelineBinary(
uint32_t deviceIdx,
void* pShaderModuleData,
Vkgc::ShaderModuleEntryData* pShaderModuleEntryData,
const Vkgc::ResourceMappingRootNode* pResourceMappingNode,
uint32_t mappingNodeCount,
Vkgc::ColorTarget* pColorTarget)
{
auto pInstance = m_pPhysicalDevice->Manager()->VkInstance();

VkResult result = VK_SUCCESS;

#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 41
Vkgc::ResourceMappingNode* pRawNodes =
static_cast<Vkgc::ResourceMappingNode*>(pInstance->AllocMem(mappingNodeCount * sizeof(Vkgc::ResourceMappingNodeType),
VK_DEFAULT_MEM_ALIGN,
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND));

if (pRawNodes != nullptr)
{
for (uint32_t i = 0; i < mappingNodeCount; ++i)
{
pRawNodes[i] = pResourceMappingNode[i].node;
}
}
else
{
result = VK_ERROR_OUT_OF_HOST_MEMORY;
}
#endif

if (result == VK_SUCCESS)
{
if (pShaderModuleEntryData->stage == Vkgc::ShaderStageCompute)
{
Vkgc::ComputePipelineBuildInfo pipelineBuildInfo = {};
Llpc::ComputePipelineBuildOut pipelineOut = {};
void* pLlpcPipelineBuffer = nullptr;

// Fill pipeline create info for LLPC
pipelineBuildInfo.pInstance = pInstance;
pipelineBuildInfo.pfnOutputAlloc = AllocateShaderOutput;
pipelineBuildInfo.pUserData = &pLlpcPipelineBuffer;
pipelineBuildInfo.deviceIndex = deviceIdx;
pipelineBuildInfo.cs.pModuleData = pShaderModuleData;
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 41
pipelineBuildInfo.cs.pUserDataNodes = pRawNodes;
pipelineBuildInfo.cs.userDataNodeCount = mappingNodeCount;
#else
pipelineBuildInfo.resourceMapping.pUserDataNodes = pResourceMappingNode;
pipelineBuildInfo.resourceMapping.userDataNodeCount = mappingNodeCount;
#endif

auto llpcResult = m_pLlpc->BuildComputePipeline(&pipelineBuildInfo, &pipelineOut, nullptr);
if (llpcResult != Vkgc::Result::Success)
{
// There shouldn't be anything to free for the failure case
VK_ASSERT(pLlpcPipelineBuffer == nullptr);
result = VK_ERROR_INITIALIZATION_FAILED;
}
pInstance->FreeMem(const_cast<void*>(pipelineOut.pipelineBin.pCode));
}
else
{
Vkgc::GraphicsPipelineBuildInfo pipelineBuildInfo = {};
// Build the LLPC pipeline
Llpc::GraphicsPipelineBuildOut pipelineOut = {};
void* pLlpcPipelineBuffer = nullptr;

// Fill pipeline create info for LLPC
pipelineBuildInfo.pInstance = pInstance;
pipelineBuildInfo.pfnOutputAlloc = AllocateShaderOutput;
pipelineBuildInfo.pUserData = &pLlpcPipelineBuffer;
pipelineBuildInfo.iaState.deviceIndex = deviceIdx;
pipelineBuildInfo.fs.pModuleData = pShaderModuleData;

pipelineBuildInfo.fs.pEntryTarget = pShaderModuleEntryData->pEntryName;
pipelineBuildInfo.fs.entryStage = pShaderModuleEntryData->stage;
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 41
pipelineBuildInfo.fs.pUserDataNodes = pRawNodes;
pipelineBuildInfo.fs.userDataNodeCount = mappingNodeCount;
#else
pipelineBuildInfo.resourceMapping.pUserDataNodes = pResourceMappingNode;
pipelineBuildInfo.resourceMapping.userDataNodeCount = mappingNodeCount;
#endif

VK_ASSERT(pColorTarget != 0);
for (uint32_t i = 0; i < Vkgc::MaxColorTargets; ++i)
{
pipelineBuildInfo.cbState.target[i] = pColorTarget[i];
}
auto llpcResult = m_pLlpc->BuildGraphicsPipeline(&pipelineBuildInfo, &pipelineOut, nullptr);
if (llpcResult != Vkgc::Result::Success)
{
// There shouldn't be anything to free for the failure case
VK_ASSERT(pLlpcPipelineBuffer == nullptr);
result = VK_ERROR_INITIALIZATION_FAILED;
}
pInstance->FreeMem(const_cast<void*>(pipelineOut.pipelineBin.pCode));
}
}

#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 41
if (pRawNodes != nullptr)
{
pInstance->FreeMem(pRawNodes);
}
#endif

return result;
}

// =====================================================================================================================
// Creates graphics pipeline binary.
VkResult CompilerSolutionLlpc::CreateGraphicsPipelineBinary(
Expand Down
12 changes: 8 additions & 4 deletions icd/api/graphics_pipeline_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,14 @@ static VkFormat GetDepthFormat(
const uint32_t subpassIndex
)
{
return (pRenderPass != nullptr) ?
pRenderPass->GetDepthStencilAttachmentFormat(subpassIndex) :
VK_FORMAT_UNDEFINED;
VkFormat format = VK_FORMAT_UNDEFINED;

if (pRenderPass != nullptr)
{
format = pRenderPass->GetDepthStencilAttachmentFormat(subpassIndex);
}

return format;
}

// =====================================================================================================================
Expand Down Expand Up @@ -1003,7 +1008,6 @@ static void BuildRenderingState(
pInfo->pipeline.viewInstancingDesc.viewId[viewIndex] = viewIndex;
}
}

}

// =====================================================================================================================
Expand Down
1 change: 1 addition & 0 deletions icd/api/include/app_profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ enum class AppProfile : uint32_t
UnityEngine, // Unity Engine by Unity Technologies (Default)
SaschaWillemsExamples, // Vulkan Examples by Sascha Willems
Maxon, // Maxon
AngleEngine, // Angle Engine
};

struct ProfileSettings
Expand Down
8 changes: 0 additions & 8 deletions icd/api/include/compiler_solution.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@ class CompilerSolution

virtual void FreeShaderModule(ShaderModuleHandle* pShaderModule) = 0;

virtual VkResult CreatePartialPipelineBinary(
uint32_t deviceIdx,
void* pShaderModuleData,
Vkgc::ShaderModuleEntryData* pShaderModuleEntryData,
const Vkgc::ResourceMappingRootNode* pResourceMappingNode,
uint32_t mappingNodeCount,
Vkgc::ColorTarget* pColorTarget) = 0;

virtual VkResult CreateGraphicsPipelineBinary(
Device* pDevice,
uint32_t deviceIdx,
Expand Down
9 changes: 1 addition & 8 deletions icd/api/include/compiler_solution_llpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,6 @@ class CompilerSolutionLlpc final : public CompilerSolution

virtual void FreeShaderModule(ShaderModuleHandle* pShaderModule) override;

virtual VkResult CreatePartialPipelineBinary(
uint32_t deviceIdx,
void* pShaderModuleData,
Vkgc::ShaderModuleEntryData* pShaderModuleEntryData,
const Vkgc::ResourceMappingRootNode* pResourceMappingNode,
uint32_t mappingNodeCount,
Vkgc::ColorTarget* pColorTarget) override;

virtual VkResult CreateGraphicsPipelineBinary(
Device* pDevice,
uint32_t deviceIdx,
Expand Down Expand Up @@ -109,6 +101,7 @@ class CompilerSolutionLlpc final : public CompilerSolution
virtual void FreeComputePipelineBinary(
const void* pPipelineBinary,
size_t binarySize) override;

private:
PAL_DISALLOW_COPY_AND_ASSIGN(CompilerSolutionLlpc);

Expand Down
Loading

0 comments on commit 477361f

Please sign in to comment.