Skip to content

Commit

Permalink
Update llpc from commit 1acb5e9b
Browse files Browse the repository at this point in the history
[Continuations] Share WaitMask handling code
lgc: Refine wmma/swmma intrinsic selection via a map
Fix for upstream move to CmpPredicate
[llvmraytracing] Replace `Data.Kind` checks with helper
[Continuations] Move/combinie rematerialization utils into RematSupport
lgc: Allow globallyCoherent flag to be set for InlineBuffer
Do not query entry point for GPURT library
[llvmraytracing] Add lgc.cps.jump.uniform dialect op
lgc: Set correct lds size in InitializeWorkgroupMemory pass
lgc: Support per draw vertex input rate
Fix fast math flag for modfStruct
Rename folder patch to lowering
lgc: Replace InstCombine with Scalarizer in continuation transform
Some renaming in passes
Fix spir-v validation always passes
Update RayTrace test pipeline to remove spv
lgc: use reconfigWorkgroupLayout without foldXY
[Continuations] Promote pointer argument for Traversal
Fix LLVM_OPTIMIZED_TABLEGEN
Add support for WaveMultiPrefixBitOr
[llvmraytracing] Use return value of 'earlyGpurtTransform'
[llvmraytracing] Make lgc.cps the default mode and remove non-lgc.cps mode
[Continuations] Use size_t for enumerate::index instead of long int
[Continuations] Use anonymous namespace instead of static
Cleanup specialize uniform implementation
lgc: Fix logic error in reconfigWorkgroupLayout
[llvmraytracing] Remove remaining references to lgc.cps mode
[Continuations] Check for valid continuation state layout
[llvmraytracing] Handle _AmdVgprArguments struct from the scheduler function.
Fix assertions in vkgcUtil that could never be triggered
  • Loading branch information
qiaojbao committed Feb 6, 2025
1 parent 6aecd3d commit 6222f1f
Show file tree
Hide file tree
Showing 733 changed files with 2,913 additions and 2,265 deletions.
9 changes: 3 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2017-2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2017-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -33,12 +33,9 @@ if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(LLPC_IS_STANDALONE ON)
endif()

### Find LLVM (needed by llpc_version.cmake).
include("cmake/findllvm.cmake")

### Version info ###
### Version info #######################################################################################################
# Also runs findllvm.cmake.
include(cmake/llpc_version.cmake)

add_llpc_version_projects()

### Cached Project Options #############################################################################################
Expand Down
63 changes: 55 additions & 8 deletions cmake/llpc_version.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2023-2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2023-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand All @@ -25,12 +25,59 @@

set(LLPC_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/..")

include("${LLPC_SOURCE_DIR}/cmake/findllvm.cmake")
# Function to set variable named ${varName} to the first of:
#
# - the value it already has (which might be set by driver or developer);
# - the value of the variable whose name has PAL_ instead of LLPC_ (which might be set by driver or developer);
# - the given default.
#
# Then, if the value is true, the function adds it to the target_compile_definitions of ${target} at
# scope ${scope}, and appends the setting to LLPC_SET_PROPERTY_SUMMARY_${target} for the caller to report the
# summary.
#
# This function is defined here so that multiple components in the LLPC repo, starting with llvm_version,
# can use it.
#
function(llpc_set_property target scope varName default propertyName)
if (NOT DEFINED ${varName})
string(REGEX REPLACE "^[A-Z][A-Z]*_(.*)$" "PAL_\\1" palVarName "${varName}")
if (DEFINED ${palVarName})
set(${varName} ${${palVarName}})
else()
set(${varName} ${default})
endif()
# For an LLPC_ variable, cache it as an option so that GPURT can see it.
if ("${varName}" MATCHES "^LLPC_")
option(${varName} "Support ${varName}?" ${${varName}})
endif()
set(${varName} ${${varName}} PARENT_SCOPE)
endif()
if (${${varName}})
target_compile_definitions(${target} ${scope} ${varName}=1)
set(LLPC_SET_PROPERTY_SUMMARY_${target}
"${LLPC_SET_PROPERTY_SUMMARY_${target}} ${varName}=${${varName}}" PARENT_SCOPE)
endif()
endfunction()

if (FALSE
OR ICD_BUILD_LLPC
)

macro(add_llpc_version_projects)
if (NOT TARGET llpc_version)
# Force the binary directory to account for the possibility that LLPC is
# taken from an external source directory.
add_subdirectory(${LLPC_SOURCE_DIR}/version ${CMAKE_CURRENT_BINARY_DIR}/llpc_version)
# Find LLVM source.
if (NOT DISABLE_LLPC_VERSION_USES_LLVM)
include("${LLPC_SOURCE_DIR}/cmake/findllvm.cmake")
endif()
endmacro()

# Macro for caller to call the llpc_version CMakeLists.txt and add its target.
macro(add_llpc_version_projects)
if (NOT TARGET llpc_version)
# Force the binary directory to account for the possibility that LLPC is
# taken from an external source directory.
add_subdirectory(${LLPC_SOURCE_DIR}/version ${CMAKE_CURRENT_BINARY_DIR}/llpc_version)
endif()
endmacro()

else()
macro(add_llpc_version_projects)
endmacro()
endif()
4 changes: 2 additions & 2 deletions cmake/llvm.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -45,7 +45,7 @@ set(LLVM_INCLUDE_UTILS ON CACHE BOOL "LLVM include utils")
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "LLVM enable terminfo")
set(LLVM_RAM_PER_TABLEGEN_JOB 4000 CACHE STRING "LLVM RAM per tablegen job")
set(LLVM_RAM_PER_LINK_JOB 5000 CACHE STRING "LLVM RAM per link job")
if(CMAKE_BUILD_TYPE_DEBUG)
if("${CMAKE_BUILD_TYPE}" STREQUAL Debug)
# Build optimized version of llvm-tblgen even in debug builds, for faster build times.
set(LLVM_OPTIMIZED_TABLEGEN ON CACHE BOOL "Build optimized llvm-tblgen")
#if _WIN32
Expand Down
4 changes: 2 additions & 2 deletions docs/DdnRelocatableShaderElf.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ and the `.vertexInputs` metadata to load all of the vertex input attributes into
registers. See the `FetchShader` class in
[GlueShader.cpp](../lgc/elfLinker/GlueShader.cpp) for the generation of the
prologue. To see how the unlinked shader handles vertex inputs see the
`LowerVertexFetch` pass in [VertexFetch.cpp](../lgc/patch/VertexFetch.cpp).
`LowerVertexFetch` pass in [VertexFetch.cpp](../lgc/lowering/VertexFetch.cpp).

A fragment shader will require a epilogue to export its outputs. The unlinked
fragment shader will have the standard name for the fragment shader. Instead of
Expand All @@ -122,7 +122,7 @@ appended to the end of the unlinked shader. See the `ColorExportShader` class in
[GlueShader.cpp](../lgc/elfLinker/GlueShader.cpp) for the generation of the
epilogue. To see how the unlinked shader handles color export see the
`LowerFragmentColorExport` pass in
[FragmentColorExport.cpp](../lgc/patch/FragmentColorExport.cpp).
[FragmentColorExport.cpp](../lgc/lowering/FragmentColorExport.cpp).

These epilogues and prologues mean that unlinked shaders do not have to depend
on the format of the vertex input attributes and color exports.
Expand Down
40 changes: 8 additions & 32 deletions include/vkgcDefs.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
***********************************************************************************************************************
*
* Copyright (c) 2020-2024 Advanced Micro Devices, Inc. All Rights Reserved.
* Copyright (c) 2020-2025 Advanced Micro Devices, Inc. All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -233,6 +233,9 @@ enum InternalBinding : unsigned {
SpecConstInternalBufferBindingIdEnd = SpecConstInternalBufferBindingId + ShaderStageCount,
ConstantBuffer0Binding = 24, ///< Binding ID of default uniform block
ConstantBuffer0BindingEnd = ConstantBuffer0Binding + ShaderStageGfxCount,
DescHeapBufferBindingId = 32, ///< Binding ID of internal buffer for buffer descriptor heap.
DescHeapImageBindingId = 33, ///< Binding ID of internal buffer for image descriptor heap.
DescHeapSamplerBindingId = 34, ///< Binding ID of internal buffer for sampler descriptor heap.
};

/// Internal vertex attribute location start from 0.
Expand Down Expand Up @@ -494,26 +497,7 @@ struct PipelineOptions {
bool internalRtShaders; ///< Whether this pipeline has internal raytracing shaders
unsigned forceNonUniformResourceIndexStageMask; ///< Mask of the stage to force using non-uniform resource index.
bool reserved16;
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 73
bool replaceSetWithResourceType; ///< For OGL only, replace 'set' with resource type during spirv translate
bool disableSampleMask; ///< For OGL only, disabled if framebuffer doesn't attach multisample texture
bool buildResourcesDataForShaderModule; ///< For OGL only, build resources usage data while building shader module
bool disableTruncCoordForGather; ///< If set, trunc_coord of sampler srd is disabled for gather4
bool enableCombinedTexture; ///< For OGL only, use the 'set' for DescriptorCombinedTexture
///< for sampled images and samplers
bool vertex64BitsAttribSingleLoc; ///< For OGL only, dvec3/dvec4 vertex attrib only consumes 1 location.
bool enableFragColor; ///< For OGL only, need to do frag color broadcast if it is enabled.
bool disableBaseVertex; ///< For OGL only, force the BaseVertex builtin to 0 instead of
/// loading it from userdata
bool bindlessTextureMode; ///< For OGL only, true if bindless textures are used
bool bindlessImageMode; ///< For OGL only, true if bindless images are used
bool enablePolygonStipple; ///< For OGL only, enable polygon stipple pattern.
bool enableLineSmooth; ///< For OGL only, enable line smooth mode.
bool emulateWideLineStipple; ///< For OGL only, enable line AA stipple.
bool enablePointSmooth; ///< For OGL only, enable point smooth mode.
bool enableRemapLocation; ///< For OGL only, enables location remapping.
const auto &getGlState() const { return *this; }
#else

struct GLState {
bool replaceSetWithResourceType; ///< For OGL only, replace 'set' with resource type during spirv translate
bool disableSampleMask; ///< For OGL only, disabled if framebuffer doesn't attach multisample texture
Expand All @@ -533,7 +517,7 @@ struct PipelineOptions {
bool enableRemapLocation; ///< For OGL only, enables location remapping.
} glState;
const auto &getGlState() const { return glState; }
#endif

unsigned reserved20;
bool enablePrimGeneratedQuery; ///< If set, primitive generated query is enabled
bool disablePerCompFetch; ///< Disable per component fetch in uber fetch shader.
Expand Down Expand Up @@ -1386,15 +1370,7 @@ struct GraphicsPipelineBuildInfo {
BinaryData shaderLibrary; ///< SPIR-V library binary data
#endif
RtState rtState; ///< Ray tracing state
#if LLPC_CLIENT_INTERFACE_MAJOR_VERSION < 71
bool originUpperLeft; ///< Whether origin coordinate of framebuffer is upper-left.
unsigned numUniformConstantMaps; ///< Number of uniform constant maps
UniformConstantMap **ppUniformMaps; ///< Pointers to array of pointers for the uniform constant map.
ApiXfbOutData apiXfbOutData; ///< Transform feedback data specified by API interface.
bool vbAddressLowBitsKnown; ///< Whether vbAddressLowBits is valid
uint8_t vbAddressLowBits[MaxVertexBindings]; ///< Lowest two bits of vertex buffer addresses
const auto &getGlState() const { return *this; }
#else

struct {
bool originUpperLeft; ///< Whether origin coordinate of framebuffer is upper-left.
bool vbAddressLowBitsKnown; ///< Whether vbAddressLowBits is valid
Expand All @@ -1417,7 +1393,7 @@ struct GraphicsPipelineBuildInfo {
AlphaTestFunc alphaTestFunc; ///< AlphaTestFunc type
} glState;
const auto &getGlState() const { return glState; }
#endif

const void *pClientMetadata; ///< Pointer to (optional) client-defined data to be stored inside the ELF
size_t clientMetadataSize; ///< Size (in bytes) of the client-defined data
AdvancedBlendInfo advancedBlendInfo; ///< The info of advanced blend
Expand Down
158 changes: 79 additions & 79 deletions lgc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2020-2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2020-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -156,90 +156,90 @@ target_sources(LLVMlgc PRIVATE
elfLinker/NullFragmentShader.h
)

# lgc/patch
# lgc/lowering
target_sources(LLVMlgc PRIVATE
patch/ConfigBuilderBase.cpp
patch/Continufy.cpp
patch/FragmentColorExport.cpp
patch/LowerDebugPrintf.cpp
patch/LowerDesc.cpp
patch/LowerPopsInterlock.cpp
patch/LowerSubgroupOps.cpp
patch/MeshTaskShader.cpp
patch/NggPrimShader.cpp
patch/LgcLowering.cpp
patch/StructurizeBuffers.cpp
patch/LowerBufferOperations.cpp
patch/CheckShaderCache.cpp
patch/GenerateCopyShader.cpp
patch/MutateEntryPoint.cpp
patch/LowerImageDerivatives.cpp
patch/LowerInOut.cpp
patch/LowerInvariantLoads.cpp
patch/IncludeLlvmIr.cpp
patch/InitializeWorkgroupMemory.cpp
patch/ScalarizeLoads.cpp
patch/LowerMulDx9Zero.cpp
patch/AddLoopMetadata.cpp
patch/GenerateNullFragmentShader.cpp
patch/PeepholeOptimization.cpp
patch/PreparePipelineAbi.cpp
patch/LowerReadFirstLane.cpp
patch/CollectResourceUsage.cpp
patch/SetupTargetFeatures.cpp
patch/PassthroughHullShader.cpp
patch/ApplyWorkarounds.cpp
patch/ShaderInputs.cpp
patch/ShaderMerger.cpp
patch/SystemValues.cpp
patch/VertexFetch.cpp
patch/CollectImageOperations.cpp
patch/RegisterMetadataBuilder.cpp
lowering/ConfigBuilderBase.cpp
lowering/Continufy.cpp
lowering/FragmentColorExport.cpp
lowering/LowerDebugPrintf.cpp
lowering/LowerDesc.cpp
lowering/LowerPopsInterlock.cpp
lowering/LowerSubgroupOps.cpp
lowering/MeshTaskShader.cpp
lowering/NggPrimShader.cpp
lowering/LgcLowering.cpp
lowering/StructurizeBuffers.cpp
lowering/LowerBufferOperations.cpp
lowering/CheckShaderCache.cpp
lowering/GenerateCopyShader.cpp
lowering/MutateEntryPoint.cpp
lowering/LowerImageDerivatives.cpp
lowering/LowerInOut.cpp
lowering/LowerInvariantLoads.cpp
lowering/IncludeLlvmIr.cpp
lowering/InitializeWorkgroupMemory.cpp
lowering/ScalarizeLoads.cpp
lowering/LowerMulDx9Zero.cpp
lowering/AddLoopMetadata.cpp
lowering/GenerateNullFragmentShader.cpp
lowering/PeepholeOptimization.cpp
lowering/PreparePipelineAbi.cpp
lowering/LowerReadFirstLane.cpp
lowering/CollectResourceUsage.cpp
lowering/SetupTargetFeatures.cpp
lowering/PassthroughHullShader.cpp
lowering/ApplyWorkarounds.cpp
lowering/ShaderInputs.cpp
lowering/ShaderMerger.cpp
lowering/SystemValues.cpp
lowering/VertexFetch.cpp
lowering/CollectImageOperations.cpp
lowering/RegisterMetadataBuilder.cpp
#if LLPC_BUILD_STRIX1
patch/WorkaroundDsSubdwordWrite.cpp
lowering/WorkaroundDsSubdwordWrite.cpp
#endif
patch/CombineCooperativeMatrix.cpp
patch/LowerCooperativeMatrix.cpp
patch/LowerGpuRt.cpp
patch/LowerRayQueryWrapper.cpp
lowering/CombineCooperativeMatrix.cpp
lowering/LowerCooperativeMatrix.cpp
lowering/LowerGpuRt.cpp
lowering/LowerRayQueryWrapper.cpp
)

# include/lgc/patch
# include/lgc/lowering
target_sources(LLVMlgc PRIVATE
include/lgc/patch/AddLoopMetadata.h
include/lgc/patch/ApplyWorkarounds.h
include/lgc/patch/CheckShaderCache.h
include/lgc/patch/CollectImageOperations.h
include/lgc/patch/CollectResourceUsage.h
include/lgc/patch/CombineCooperativeMatrix.h
include/lgc/patch/Continufy.h
include/lgc/patch/FragmentColorExport.h
include/lgc/patch/GenerateCopyShader.h
include/lgc/patch/IncludeLlvmIr.h
include/lgc/patch/InitializeWorkgroupMemory.h
include/lgc/patch/LgcLowering.h
include/lgc/patch/LowerBufferOperations.h
include/lgc/patch/LowerCooperativeMatrix.h
include/lgc/patch/LowerDebugPrintf.h
include/lgc/patch/LowerDesc.h
include/lgc/patch/LowerGpuRt.h
include/lgc/patch/LowerImageDerivatives.h
include/lgc/patch/LowerInOut.h
include/lgc/patch/LowerInvariantLoads.h
include/lgc/patch/LowerMulDx9Zero.h
include/lgc/patch/LowerReadFirstLane.h
include/lgc/patch/LowerSubgroupOps.h
include/lgc/patch/MutateEntryPoint.h
include/lgc/patch/PassthroughHullShader.h
include/lgc/patch/PeepholeOptimization.h
include/lgc/patch/PreparePipelineAbi.h
include/lgc/patch/ScalarizeLoads.h
include/lgc/patch/SetupTargetFeatures.h
include/lgc/patch/ShaderInputs.h
include/lgc/patch/StructurizeBuffers.h
include/lgc/patch/SystemValues.h
include/lgc/patch/VertexFetch.h
include/lgc/patch/WorkaroundDsSubdwordWrite.h
include/lgc/lowering/AddLoopMetadata.h
include/lgc/lowering/ApplyWorkarounds.h
include/lgc/lowering/CheckShaderCache.h
include/lgc/lowering/CollectImageOperations.h
include/lgc/lowering/CollectResourceUsage.h
include/lgc/lowering/CombineCooperativeMatrix.h
include/lgc/lowering/Continufy.h
include/lgc/lowering/FragmentColorExport.h
include/lgc/lowering/GenerateCopyShader.h
include/lgc/lowering/IncludeLlvmIr.h
include/lgc/lowering/InitializeWorkgroupMemory.h
include/lgc/lowering/LgcLowering.h
include/lgc/lowering/LowerBufferOperations.h
include/lgc/lowering/LowerCooperativeMatrix.h
include/lgc/lowering/LowerDebugPrintf.h
include/lgc/lowering/LowerDesc.h
include/lgc/lowering/LowerGpuRt.h
include/lgc/lowering/LowerImageDerivatives.h
include/lgc/lowering/LowerInOut.h
include/lgc/lowering/LowerInvariantLoads.h
include/lgc/lowering/LowerMulDx9Zero.h
include/lgc/lowering/LowerReadFirstLane.h
include/lgc/lowering/LowerSubgroupOps.h
include/lgc/lowering/MutateEntryPoint.h
include/lgc/lowering/PassthroughHullShader.h
include/lgc/lowering/PeepholeOptimization.h
include/lgc/lowering/PreparePipelineAbi.h
include/lgc/lowering/ScalarizeLoads.h
include/lgc/lowering/SetupTargetFeatures.h
include/lgc/lowering/ShaderInputs.h
include/lgc/lowering/StructurizeBuffers.h
include/lgc/lowering/SystemValues.h
include/lgc/lowering/VertexFetch.h
include/lgc/lowering/WorkaroundDsSubdwordWrite.h
)

# lgc/state
Expand Down
Loading

0 comments on commit 6222f1f

Please sign in to comment.