Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -136,20 +136,10 @@ endif()
# HLSL Change Ends

# SPIRV change starts
option(ENABLE_SPIRV_CODEGEN "Enables SPIR-V code generation." OFF)
option(SPIRV_BUILD_TESTS "Build targets for the SPIR-V unit tests." OFF)

# Enable SPIR-V CodeGen for Linux by default.
if(NOT WIN32)
set(ENABLE_SPIRV_CODEGEN ON)
endif()

if (${SPIRV_BUILD_TESTS})
enable_testing()
set(ENABLE_SPIRV_CODEGEN ON)
endif()
if (${ENABLE_SPIRV_CODEGEN})
add_definitions(-DENABLE_SPIRV_CODEGEN)
endif()
# SPIRV change ends

Expand Down
1 change: 0 additions & 1 deletion cmake/caches/PredefinedParams.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ set(CLANG_CL OFF CACHE BOOL "")
set(CLANG_ENABLE_ARCMT OFF CACHE BOOL "")
set(CLANG_ENABLE_STATIC_ANALYZER OFF CACHE BOOL "")
set(HLSL_INCLUDE_TESTS ON CACHE BOOL "")
set(ENABLE_SPIRV_CODEGEN ON CACHE BOOL "")
set(SPIRV_BUILD_TESTS ON CACHE BOOL "")
set(LLVM_ENABLE_TERMINFO OFF CACHE BOOL "")
91 changes: 44 additions & 47 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,58 +18,55 @@ if (NOT DIRECTX_HEADER_INCLUDE_DIR)
endif (NOT WIN32)
endif(NOT DIRECTX_HEADER_INCLUDE_DIR)

# Enabling SPIR-V codegen requires SPIRV-Headers for spirv.hpp and
# SPIR-V codegen requires SPIRV-Headers for spirv.hpp and
# SPIRV-Tools for SPIR-V disassembling functionality.
if (${ENABLE_SPIRV_CODEGEN})
set(DXC_SPIRV_HEADERS_DIR "${DXC_EXTERNAL_ROOT_DIR}/SPIRV-Headers"
CACHE STRING "Location of SPIRV-Headers source")
set(DXC_SPIRV_TOOLS_DIR "${DXC_EXTERNAL_ROOT_DIR}/SPIRV-Tools"
CACHE STRING "Location of SPIRV-Tools source")
set(DXC_SPIRV_HEADERS_DIR "${DXC_EXTERNAL_ROOT_DIR}/SPIRV-Headers"
CACHE STRING "Location of SPIRV-Headers source")
set(DXC_SPIRV_TOOLS_DIR "${DXC_EXTERNAL_ROOT_DIR}/SPIRV-Tools"
CACHE STRING "Location of SPIRV-Tools source")

if (NOT DEFINED SPIRV-Headers_SOURCE_DIR)
if (IS_DIRECTORY ${DXC_SPIRV_HEADERS_DIR})
add_subdirectory(${DXC_SPIRV_HEADERS_DIR}
"${CMAKE_BINARY_DIR}/external/SPIRV-Headers"
EXCLUDE_FROM_ALL)
endif()
endif()
if (NOT DEFINED SPIRV-Headers_SOURCE_DIR)
message(FATAL_ERROR "SPIRV-Headers was not found - required for SPIR-V codegen")
else()
set(SPIRV_HEADER_INCLUDE_DIR ${SPIRV-Headers_SOURCE_DIR}/include PARENT_SCOPE)
if (NOT DEFINED SPIRV-Headers_SOURCE_DIR)
if (IS_DIRECTORY ${DXC_SPIRV_HEADERS_DIR})
add_subdirectory(${DXC_SPIRV_HEADERS_DIR}
"${CMAKE_BINARY_DIR}/external/SPIRV-Headers"
EXCLUDE_FROM_ALL)
endif()
endif()
if (NOT DEFINED SPIRV-Headers_SOURCE_DIR)
message(FATAL_ERROR "SPIRV-Headers was not found - required for SPIR-V codegen")
else()
set(SPIRV_HEADER_INCLUDE_DIR ${SPIRV-Headers_SOURCE_DIR}/include PARENT_SCOPE)
endif()

if (NOT TARGET SPIRV-Tools)
if (IS_DIRECTORY ${DXC_SPIRV_TOOLS_DIR})
# Avoid implicit fallthrough warning from clang
# This add_compile_options() will only affect the current directory and its subdirectories.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-implicit-fallthrough)
endif()
# We only need the library from SPIRV-Tools.
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables")
if (NOT HLSL_ENABLE_DEBUG_ITERATORS)
set(SPIRV_TOOLS_EXTRA_DEFINITIONS /D_ITERATOR_DEBUG_LEVEL=0)
endif()
add_subdirectory(${DXC_SPIRV_TOOLS_DIR}
"${CMAKE_BINARY_DIR}/external/SPIRV-Tools"
EXCLUDE_FROM_ALL)
if (NOT TARGET SPIRV-Tools)
if (IS_DIRECTORY ${DXC_SPIRV_TOOLS_DIR})
# Avoid implicit fallthrough warning from clang
# This add_compile_options() will only affect the current directory and its subdirectories.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-implicit-fallthrough)
endif()
# We only need the library from SPIRV-Tools.
set(SPIRV_SKIP_EXECUTABLES ON CACHE BOOL "Skip building SPIRV-Tools executables")
if (NOT HLSL_ENABLE_DEBUG_ITERATORS)
set(SPIRV_TOOLS_EXTRA_DEFINITIONS /D_ITERATOR_DEBUG_LEVEL=0)
endif()
add_subdirectory(${DXC_SPIRV_TOOLS_DIR}
"${CMAKE_BINARY_DIR}/external/SPIRV-Tools"
EXCLUDE_FROM_ALL)
endif()
if (NOT TARGET SPIRV-Tools)
message(FATAL_ERROR "SPIRV-Tools was not found - required for SPIR-V codegen")
else()
set(SPIRV_TOOLS_INCLUDE_DIR ${spirv-tools_SOURCE_DIR}/include PARENT_SCOPE)
endif()

set(SPIRV_DEP_TARGETS
SPIRV-Tools-static
SPIRV-Tools-opt
)
endif()
if (NOT TARGET SPIRV-Tools)
message(FATAL_ERROR "SPIRV-Tools was not found - required for SPIR-V codegen")
else()
set(SPIRV_TOOLS_INCLUDE_DIR ${spirv-tools_SOURCE_DIR}/include PARENT_SCOPE)
endif()

# Organize these targets better in Visual Studio
foreach(target ${SPIRV_DEP_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER "External dependencies")
endforeach()
set(SPIRV_DEP_TARGETS
SPIRV-Tools-static
SPIRV-Tools-opt
)

endif()
# Organize these targets better in Visual Studio
foreach(target ${SPIRV_DEP_TARGETS})
set_property(TARGET ${target} PROPERTY FOLDER "External dependencies")
endforeach()
1 change: 0 additions & 1 deletion gcp-pipelines/x86_64-linux-clang.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ steps:
- '-DCMAKE_CXX_COMPILER=clang++'
- '-DCMAKE_C_COMPILER=clang'
- '-DCMAKE_INSTALL_PREFIX=artifacts'
- '-DENABLE_SPIRV_CODEGEN=ON'
- '-DSPIRV_BUILD_TESTS=ON'
- '-DLLVM_ENABLE_WERROR=On'
- '-C'
Expand Down
12 changes: 0 additions & 12 deletions include/dxc/HlslIntrinsicOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -226,21 +226,11 @@ enum class IntrinsicOp {
IOP_unpack_s8s32,
IOP_unpack_u8u16,
IOP_unpack_u8u32,
#ifdef ENABLE_SPIRV_CODEGEN
IOP_VkRawBufferLoad,
#endif // ENABLE_SPIRV_CODEGEN
#ifdef ENABLE_SPIRV_CODEGEN
IOP_VkRawBufferStore,
#endif // ENABLE_SPIRV_CODEGEN
#ifdef ENABLE_SPIRV_CODEGEN
IOP_VkReadClock,
#endif // ENABLE_SPIRV_CODEGEN
#ifdef ENABLE_SPIRV_CODEGEN
IOP_Vkext_execution_mode,
#endif // ENABLE_SPIRV_CODEGEN
#ifdef ENABLE_SPIRV_CODEGEN
IOP_Vkext_execution_mode_id,
#endif // ENABLE_SPIRV_CODEGEN
MOP_Append,
MOP_RestartStrip,
MOP_CalculateLevelOfDetail,
Expand Down Expand Up @@ -351,9 +341,7 @@ enum class IntrinsicOp {
MOP_GroupIncrementOutputCount,
MOP_ThreadIncrementOutputCount,
MOP_OutputComplete,
#ifdef ENABLE_SPIRV_CODEGEN
MOP_SubpassLoad,
#endif // ENABLE_SPIRV_CODEGEN
// unsigned
IOP_InterlockedUMax,
IOP_InterlockedUMin,
Expand Down
2 changes: 0 additions & 2 deletions include/dxc/Support/HLSLOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,9 @@ class DxcOpts {
llvm::StringRef GetPDBName() const; // Fd name

// SPIRV Change Starts
#ifdef ENABLE_SPIRV_CODEGEN
bool GenSPIRV; // OPT_spirv
clang::spirv::SpirvCodeGenOptions
SpirvOptions; // All SPIR-V CodeGen-related options
#endif
// SPIRV Change Ends

bool GenMetal = false; // OPT_metal
Expand Down
3 changes: 0 additions & 3 deletions include/dxc/Support/SPIRVOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
#ifndef LLVM_SPIRV_OPTIONS_H
#define LLVM_SPIRV_OPTIONS_H

#ifdef ENABLE_SPIRV_CODEGEN

#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Option/ArgList.h"
Expand Down Expand Up @@ -123,5 +121,4 @@ struct SpirvCodeGenOptions {
} // namespace spirv
} // namespace clang

#endif // ENABLE_SPIRV_CODEGEN
#endif // LLVM_SPIRV_OPTIONS_H
43 changes: 0 additions & 43 deletions lib/DxcSupport/HLSLOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ using namespace llvm::opt;
using namespace dxc;
using namespace hlsl;
using namespace hlsl::options;
#ifdef ENABLE_SPIRV_CODEGEN
using namespace clang::spirv;
#endif

#define PREFIX(NAME, VALUE) static const char *const NAME[] = VALUE;
#include "dxc/Support/HLSLOptions.inc"
Expand Down Expand Up @@ -275,7 +273,6 @@ static std::pair<std::string, std::string> ParseDefine(std::string &argVal) {
}

// SPIRV Change Starts
#ifdef ENABLE_SPIRV_CODEGEN
/// Checks and collects the arguments for -fvk-{b|s|t|u}-shift into *shifts.
static bool handleVkShiftArgs(const InputArgList &args, OptSpecifier id,
const char *name,
Expand Down Expand Up @@ -392,7 +389,6 @@ static const uint32_t kDefaultMaximumSourceLength = 0xFFFDu;
static const uint32_t kTestingMaximumSourceLength = 13u;

} // namespace
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV Change Ends

namespace hlsl {
Expand Down Expand Up @@ -1092,7 +1088,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
opts.GenMetal = Args.hasFlag(OPT_metal, OPT_INVALID, false);

// SPIRV Change Starts
#ifdef ENABLE_SPIRV_CODEGEN
opts.GenSPIRV = Args.hasFlag(OPT_spirv, OPT_INVALID, false);
opts.SpirvOptions.invertY =
Args.hasFlag(OPT_fvk_invert_y, OPT_INVALID, false);
Expand Down Expand Up @@ -1275,44 +1270,6 @@ int ReadDxcOpts(const OptTable *optionTable, unsigned flagsToInclude,
return 1;

opts.SpirvOptions.floatDenormalMode = Args.getLastArgValue(OPT_denorm);

#else
if (Args.hasFlag(OPT_spirv, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_invert_y, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_use_dx_position_w, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_support_nonzero_base_instance, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_use_gl_layout, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_use_dx_layout, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_use_scalar_layout, OPT_INVALID, false) ||
Args.hasFlag(OPT_fspv_use_legacy_buffer_matrix_order, OPT_INVALID,
false) ||
Args.hasFlag(OPT_fspv_flatten_resource_arrays, OPT_INVALID, false) ||
Args.hasFlag(OPT_fspv_reduce_load_size, OPT_INVALID, false) ||
Args.hasFlag(OPT_fspv_reflect, OPT_INVALID, false) ||
Args.hasFlag(OPT_fspv_fix_func_call_arguments, OPT_INVALID, false) ||
Args.hasFlag(OPT_fspv_print_all, OPT_INVALID, false) ||
Args.hasFlag(OPT_Wno_vk_ignored_features, OPT_INVALID, false) ||
Args.hasFlag(OPT_Wno_vk_emulated_features, OPT_INVALID, false) ||
Args.hasFlag(OPT_fvk_auto_shift_bindings, OPT_INVALID, false) ||
!Args.getLastArgValue(OPT_fvk_stage_io_order_EQ).empty() ||
!Args.getLastArgValue(OPT_fspv_debug_EQ).empty() ||
!Args.getLastArgValue(OPT_fspv_extension_EQ).empty() ||
!Args.getLastArgValue(OPT_fspv_target_env_EQ).empty() ||
!Args.getLastArgValue(OPT_Oconfig).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_register).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_globals).empty() ||
!Args.getLastArgValue(OPT_fvk_b_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_t_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_s_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_u_shift).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_resource_heap).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_sampler_heap).empty() ||
!Args.getLastArgValue(OPT_fvk_bind_counter_heap).empty()) {
errors << "SPIR-V CodeGen not available. "
"Please recompile with -DENABLE_SPIRV_CODEGEN=ON.";
return 1;
}
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV Change Ends

#ifndef ENABLE_METAL_CODEGEN
Expand Down
8 changes: 1 addition & 7 deletions lib/HLSL/HLOperationLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6156,7 +6156,6 @@ Value *EmptyLower(CallInst *CI, IntrinsicOp IOP, DXIL::OpCode opcode,
}

// SPIRV change starts
#ifdef ENABLE_SPIRV_CODEGEN
Value *UnsupportedVulkanIntrinsic(CallInst *CI, IntrinsicOp IOP,
DXIL::OpCode opcode,
HLOperationLowerHelper &helper,
Expand All @@ -6166,7 +6165,6 @@ Value *UnsupportedVulkanIntrinsic(CallInst *CI, IntrinsicOp IOP,
dxilutil::EmitErrorOnInstruction(CI, "Unsupported Vulkan intrinsic.");
return nullptr;
}
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

Value *StreamOutputLower(CallInst *CI, IntrinsicOp IOP, DXIL::OpCode opcode,
Expand Down Expand Up @@ -6511,7 +6509,6 @@ IntrinsicLower gLowerTable[] = {
{IntrinsicOp::IOP_unpack_s8s32, TranslateUnpack, DXIL::OpCode::Unpack4x8},
{IntrinsicOp::IOP_unpack_u8u16, TranslateUnpack, DXIL::OpCode::Unpack4x8},
{IntrinsicOp::IOP_unpack_u8u32, TranslateUnpack, DXIL::OpCode::Unpack4x8},
#ifdef ENABLE_SPIRV_CODEGEN
{IntrinsicOp::IOP_VkRawBufferLoad, UnsupportedVulkanIntrinsic,
DXIL::OpCode::NumOpCodes},
{IntrinsicOp::IOP_VkRawBufferStore, UnsupportedVulkanIntrinsic,
Expand All @@ -6522,7 +6519,6 @@ IntrinsicLower gLowerTable[] = {
DXIL::OpCode::NumOpCodes},
{IntrinsicOp::IOP_Vkext_execution_mode_id, UnsupportedVulkanIntrinsic,
DXIL::OpCode::NumOpCodes},
#endif // ENABLE_SPIRV_CODEGEN
{IntrinsicOp::MOP_Append, StreamOutputLower, DXIL::OpCode::EmitStream},
{IntrinsicOp::MOP_RestartStrip, StreamOutputLower, DXIL::OpCode::CutStream},
{IntrinsicOp::MOP_CalculateLevelOfDetail, TranslateCalculateLOD,
Expand Down Expand Up @@ -6750,11 +6746,9 @@ IntrinsicLower gLowerTable[] = {
{IntrinsicOp::MOP_OutputComplete, TranslateNodeOutputComplete,
DXIL::OpCode::OutputComplete},

// SPIRV change starts
#ifdef ENABLE_SPIRV_CODEGEN
// SPIRV change starts
{IntrinsicOp::MOP_SubpassLoad, UnsupportedVulkanIntrinsic,
DXIL::OpCode::NumOpCodes},
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV change ends

// Manually added part.
Expand Down
2 changes: 0 additions & 2 deletions tools/clang/include/clang/AST/HlslTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,13 @@ DeclareNodeOrRecordType(clang::ASTContext &Ctx, DXIL::NodeIOKind Type,
bool HasGetMethods = false, bool IsArray = false,
bool IsCompleteType = false);

#ifdef ENABLE_SPIRV_CODEGEN
clang::CXXRecordDecl *DeclareInlineSpirvType(clang::ASTContext &context,
clang::DeclContext *declContext,
llvm::StringRef typeName,
bool opaque);
clang::CXXRecordDecl *DeclareVkIntegralConstant(
clang::ASTContext &context, clang::DeclContext *declContext,
llvm::StringRef typeName, clang::ClassTemplateDecl **templateDecl);
#endif

clang::CXXRecordDecl *DeclareNodeOutputArray(clang::ASTContext &Ctx,
DXIL::NodeIOKind Type,
Expand Down
2 changes: 0 additions & 2 deletions tools/clang/include/clang/Frontend/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,7 @@ class CodeGenOptions : public CodeGenOptionsBase {
// HLSL Change Ends

// SPIRV Change Starts
#ifdef ENABLE_SPIRV_CODEGEN
clang::spirv::SpirvCodeGenOptions SpirvOptions;
#endif
// SPIRV Change Ends

/// Regular expression to select optimizations for which we should enable
Expand Down
2 changes: 0 additions & 2 deletions tools/clang/lib/AST/ASTContextHLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,6 @@ CXXRecordDecl *hlsl::DeclareNodeOrRecordType(
return Builder.getRecordDecl();
}

#ifdef ENABLE_SPIRV_CODEGEN
CXXRecordDecl *hlsl::DeclareInlineSpirvType(clang::ASTContext &context,
clang::DeclContext *declContext,
llvm::StringRef typeName,
Expand Down Expand Up @@ -1312,7 +1311,6 @@ CXXRecordDecl *hlsl::DeclareVkIntegralConstant(
*templateDecl = typeDeclBuilder.getTemplateDecl();
return typeDeclBuilder.getRecordDecl();
}
#endif

CXXRecordDecl *hlsl::DeclareNodeOutputArray(clang::ASTContext &Ctx,
DXIL::NodeIOKind Type,
Expand Down
4 changes: 1 addition & 3 deletions tools/clang/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,5 @@ if(CLANG_ENABLE_STATIC_ANALYZER)
endif()
add_subdirectory(Format)
# SPIRV change starts
if (ENABLE_SPIRV_CODEGEN)
add_subdirectory(SPIRV)
endif (ENABLE_SPIRV_CODEGEN)
# SPIRV change ends
# SPIRV change ends
2 changes: 0 additions & 2 deletions tools/clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -398,15 +398,13 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
Builder.defineMacro("__SHADER_TARGET_MAJOR", Twine(SM->GetMajor()));
Builder.defineMacro("__SHADER_TARGET_MINOR", Twine(SM->GetMinor()));
// SPIRV Change Starts
#ifdef ENABLE_SPIRV_CODEGEN
if (LangOpts.SPIRV) {
Builder.defineMacro("__spirv__");
Builder.defineMacro("__SPIRV_MAJOR_VERSION__",
Twine(LangOpts.SpirvMajorVersion));
Builder.defineMacro("__SPIRV_MINOR_VERSION__",
Twine(LangOpts.SpirvMinorVersion));
}
#endif // ENABLE_SPIRV_CODEGEN
// SPIRV Change Ends
}
return;
Expand Down
Loading
Loading