Skip to content

Commit 1c656c9

Browse files
authored
Merge fixes to release branch (#3592)
2 parents 921b86c + ce6c6f7 commit 1c656c9

62 files changed

Lines changed: 4194 additions & 142 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

appveyor.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: 1.0.{build}
22

33
image:
4-
- Visual Studio 2017
4+
- Visual Studio 2019
55
- Ubuntu
66

77
platform: x64
@@ -38,7 +38,7 @@ before_build:
3838
- cmd: call utils\hct\hctstart %HLSL_SRC_DIR% %HLSL_BLD_DIR%
3939

4040
build_script:
41-
- cmd: call utils\hct\hctbuild -%PLATFORM% -%CONFIGURATION% -vs2017 -spirvtest
41+
- cmd: call utils\hct\hctbuild -%PLATFORM% -%CONFIGURATION% -show-cmake-log -spirvtest
4242
- sh: mkdir build && cd build
4343
- sh: cmake .. -GNinja $(cat ../utils/cmake-predefined-config-params) -DSPIRV_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-Werror
4444
- sh: ninja

cmake/modules/FindD3D12.cmake

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# Find the win10 SDK path.
1+
# Find the Win10 SDK path.
22
if ("$ENV{WIN10_SDK_PATH}$ENV{WIN10_SDK_VERSION}" STREQUAL "" )
3-
get_filename_component(WIN10_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;InstallationFolder]" ABSOLUTE CACHE)
4-
get_filename_component(TEMP_WIN10_SDK_VERSION "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\Microsoft SDKs\\Windows\\v10.0;ProductVersion]" ABSOLUTE CACHE)
5-
get_filename_component(WIN10_SDK_VERSION ${TEMP_WIN10_SDK_VERSION} NAME)
3+
get_filename_component(WIN10_SDK_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows Kits\\Installed Roots;KitsRoot10]" ABSOLUTE CACHE)
4+
set (WIN10_SDK_VERSION ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION})
65
elseif(TRUE)
76
set (WIN10_SDK_PATH $ENV{WIN10_SDK_PATH})
87
set (WIN10_SDK_VERSION $ENV{WIN10_SDK_VERSION})

include/dxc/DXIL/DxilConstants.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,6 +1489,28 @@ namespace DXIL {
14891489
CandidateProceduralPrimitive = 1,
14901490
};
14911491

1492+
enum class PayloadAccessQualifier : uint32_t {
1493+
NoAccess = 0,
1494+
Read = 1,
1495+
Write = 2,
1496+
ReadWrite = 3
1497+
};
1498+
1499+
enum class PayloadAccessShaderStage : uint32_t {
1500+
Caller = 0,
1501+
Closesthit = 1,
1502+
Miss = 2,
1503+
Anyhit = 3,
1504+
Invalid = 0xffffffffu
1505+
};
1506+
1507+
// Allocate 4 bits per shader stage:
1508+
// bits 0-1 for payload access qualifiers
1509+
// bits 2-3 reserved for future use
1510+
const uint32_t PayloadAccessQualifierBitsPerStage = 4;
1511+
const uint32_t PayloadAccessQualifierValidMaskPerStage = 3;
1512+
const uint32_t PayloadAccessQualifierValidMask = 0x00003333;
1513+
14921514
inline bool IsValidHitGroupType(HitGroupType type) {
14931515
return (type >= HitGroupType::Triangle && type < HitGroupType::LastEntry);
14941516
}

include/dxc/DXIL/DxilMetadataHelper.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MDNode;
3232
class NamedMDNode;
3333
class GlobalVariable;
3434
class StringRef;
35+
class Type;
3536
}
3637

3738
namespace hlsl {
@@ -48,6 +49,8 @@ class DxilSampler;
4849
class DxilTypeSystem;
4950
class DxilStructAnnotation;
5051
class DxilFieldAnnotation;
52+
class DxilPayloadAnnotation;
53+
class DxilPayloadFieldAnnotation;
5154
class DxilTemplateArgAnnotation;
5255
class DxilFunctionAnnotation;
5356
class DxilParameterAnnotation;
@@ -217,6 +220,10 @@ class DxilMDHelper {
217220
static const unsigned kDxilFieldAnnotationPreciseTag = 8;
218221
static const unsigned kDxilFieldAnnotationCBUsedTag = 9;
219222

223+
// DXR Payload Annotations
224+
static const unsigned kDxilPayloadAnnotationStructTag = 0;
225+
static const unsigned kDxilPayloadFieldAnnotationAccessTag = 0;
226+
220227
// StructAnnotation extended property tags (DXIL 1.5+ only, appended)
221228
static const unsigned kDxilTemplateArgumentsTag = 0; // Name for name-value list of extended struct properties
222229
// TemplateArgument tags
@@ -249,6 +256,9 @@ class DxilMDHelper {
249256
static const char kDxilValidatorVersionMDName[];
250257
// Validator version uses the same constants for fields as kDxilVersion*
251258

259+
// DXR Payload Annotations metadata.
260+
static const char kDxilDxrPayloadAnnotationsMDName[];
261+
252262
// Extended shader property tags.
253263
static const unsigned kDxilShaderFlagsTag = 0;
254264
static const unsigned kDxilGSStateTag = 1;
@@ -414,6 +424,16 @@ class DxilMDHelper {
414424
llvm::Metadata *EmitDxilTemplateArgAnnotation(const DxilTemplateArgAnnotation &annotation);
415425
void LoadDxilTemplateArgAnnotation(const llvm::MDOperand &MDO, DxilTemplateArgAnnotation &annotation);
416426

427+
// DXR Payload Annotations
428+
void EmitDxrPayloadAnnotations(DxilTypeSystem &TypeSystem);
429+
llvm::Metadata *EmitDxrPayloadStructAnnotation(const DxilPayloadAnnotation& SA);
430+
llvm::Metadata *EmitDxrPayloadFieldAnnotation(const DxilPayloadFieldAnnotation &FA, llvm::Type* fieldType);
431+
void LoadDxrPayloadAnnotationNode(const llvm::MDTuple &MDT, DxilTypeSystem &TypeSystem);
432+
void LoadDxrPayloadAnnotations(DxilTypeSystem &TypeSystem);
433+
void LoadDxrPayloadFieldAnnoations(const llvm::MDOperand& MDO, DxilPayloadAnnotation& SA);
434+
void LoadDxrPayloadFieldAnnoation(const llvm::MDOperand &MDO, DxilPayloadFieldAnnotation &FA);
435+
void LoadDxrPayloadAccessQualifiers(const llvm::MDOperand &MDO, DxilPayloadFieldAnnotation &FA);
436+
417437
// Function props.
418438
llvm::MDTuple *EmitDxilFunctionProps(const hlsl::DxilFunctionProps *props,
419439
const llvm::Function *F);

include/dxc/DXIL/DxilModule.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ class DxilModule {
166166

167167
// DXIL type system.
168168
DxilTypeSystem &GetTypeSystem();
169+
const DxilTypeSystem &GetTypeSystem() const;
169170

170171
/// Emit llvm.used array to make sure that optimizations do not remove unreferenced globals.
171172
void EmitLLVMUsed();
@@ -386,6 +387,9 @@ class DxilModule {
386387
uint32_t m_IntermediateFlags;
387388
uint32_t m_AutoBindingSpace;
388389

390+
// porperties infered from the DXILTypeSystem
391+
bool m_bHasPayloadQualifiers;
392+
389393
std::unique_ptr<DxilSubobjects> m_pSubobjects;
390394

391395
// m_bMetadataErrors is true if non-fatal metadata errors were encountered.

include/dxc/DXIL/DxilTypeSystem.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#pragma once
1313
#include "llvm/ADT/StringRef.h"
1414
#include "llvm/ADT/MapVector.h"
15+
#include "dxc/DXIL/DxilConstants.h"
1516
#include "dxc/DXIL/DxilCompType.h"
1617
#include "dxc/DXIL/DxilInterpolationMode.h"
1718

@@ -140,6 +141,46 @@ class DxilStructAnnotation {
140141
};
141142

142143

144+
/// Use this class to represent type annotation for DXR payload field.
145+
class DxilPayloadFieldAnnotation {
146+
public:
147+
148+
static unsigned GetBitOffsetForShaderStage(DXIL::PayloadAccessShaderStage shaderStage);
149+
150+
DxilPayloadFieldAnnotation() = default;
151+
152+
bool HasCompType() const;
153+
const CompType &GetCompType() const;
154+
void SetCompType(CompType::Kind kind);
155+
156+
uint32_t GetPayloadFieldQualifierMask() const;
157+
void SetPayloadFieldQualifierMask(uint32_t fieldBitmask);
158+
void AddPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage, DXIL::PayloadAccessQualifier qualifier);
159+
DXIL::PayloadAccessQualifier GetPayloadFieldQualifier(DXIL::PayloadAccessShaderStage shaderStage) const;
160+
bool HasAnnotations() const;
161+
162+
private:
163+
CompType m_CompType;
164+
unsigned m_bitmask = 0;
165+
};
166+
167+
/// Use this class to represent DXR payload structures.
168+
class DxilPayloadAnnotation {
169+
friend class DxilTypeSystem;
170+
171+
public:
172+
unsigned GetNumFields() const;
173+
DxilPayloadFieldAnnotation &GetFieldAnnotation(unsigned FieldIdx);
174+
const DxilPayloadFieldAnnotation &GetFieldAnnotation(unsigned FieldIdx) const;
175+
const llvm::StructType *GetStructType() const;
176+
void SetStructType(const llvm::StructType *Ty);
177+
178+
private:
179+
const llvm::StructType *m_pStructType;
180+
std::vector<DxilPayloadFieldAnnotation> m_FieldAnnotations;
181+
};
182+
183+
143184
enum class DxilParamInputQual {
144185
In,
145186
Out,
@@ -192,6 +233,7 @@ class DxilFunctionAnnotation {
192233
class DxilTypeSystem {
193234
public:
194235
using StructAnnotationMap = llvm::MapVector<const llvm::StructType *, std::unique_ptr<DxilStructAnnotation> >;
236+
using PayloadAnnotationMap = llvm::MapVector<const llvm::StructType *, std::unique_ptr<DxilPayloadAnnotation> >;
195237
using FunctionAnnotationMap = llvm::MapVector<const llvm::Function *, std::unique_ptr<DxilFunctionAnnotation> >;
196238

197239
DxilTypeSystem(llvm::Module *pModule);
@@ -202,6 +244,15 @@ class DxilTypeSystem {
202244
void EraseStructAnnotation(const llvm::StructType *pStructType);
203245

204246
StructAnnotationMap &GetStructAnnotationMap();
247+
const StructAnnotationMap &GetStructAnnotationMap() const;
248+
249+
DxilPayloadAnnotation *AddPayloadAnnotation(const llvm::StructType *pStructType);
250+
DxilPayloadAnnotation *GetPayloadAnnotation(const llvm::StructType *pStructType);
251+
const DxilPayloadAnnotation *GetPayloadAnnotation(const llvm::StructType *pStructType) const;
252+
void ErasePayloadAnnotation(const llvm::StructType *pStructType);
253+
254+
PayloadAnnotationMap &GetPayloadAnnotationMap();
255+
const PayloadAnnotationMap &GetPayloadAnnotationMap() const;
205256

206257
DxilFunctionAnnotation *AddFunctionAnnotation(const llvm::Function *pFunction);
207258
DxilFunctionAnnotation *GetFunctionAnnotation(const llvm::Function *pFunction);
@@ -227,6 +278,7 @@ class DxilTypeSystem {
227278
private:
228279
llvm::Module *m_pModule;
229280
StructAnnotationMap m_StructAnnotations;
281+
PayloadAnnotationMap m_PayloadAnnotations;
230282
FunctionAnnotationMap m_FunctionAnnotations;
231283

232284
DXIL::LowPrecisionMode m_LowPrecisionMode;

include/dxc/Support/HLSLOptions.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,9 @@ class DxcOpts {
172172
bool RecompileFromBinary = false; // OPT _Recompile (Recompiling the DXBC binary file not .hlsl file)
173173
bool StripDebug = false; // OPT Qstrip_debug
174174
bool EmbedDebug = false; // OPT Qembed_debug
175-
bool SourceInDebugModule = false; // OPT Qsource_in_debug_module
175+
bool SourceInDebugModule = false; // OPT Zs
176176
bool SourceOnlyDebug = false; // OPT Qsource_only_debug
177-
bool FullDebug = false; // OPT Qfull_debug
177+
bool PdbInPrivate = false; // OPT Qpdb_in_private
178178
bool StripRootSignature = false; // OPT_Qstrip_rootsignature
179179
bool StripPrivate = false; // OPT_Qstrip_priv
180180
bool StripReflection = false; // OPT_Qstrip_reflect
@@ -200,6 +200,7 @@ class DxcOpts {
200200
std::map<std::string, std::string> DxcOptimizationSelects; // OPT_opt_select
201201

202202
bool PrintAfterAll; // OPT_print_after_all
203+
bool EnablePayloadQualifiers = false; // OPT_enable_payload_qualifiers
203204

204205
// Rewriter Options
205206
RewriterOpts RWOpt;
@@ -210,7 +211,8 @@ class DxcOpts {
210211
bool IsLibraryProfile();
211212

212213
// Helpers to clarify interpretation of flags for behavior in implementation
213-
bool IsDebugInfoEnabled(); // Zi
214+
bool GenerateFullDebugInfo(); // Zi
215+
bool GeneratePDB(); // Zi or Zs
214216
bool EmbedDebugInfo(); // Qembed_debug
215217
bool EmbedPDBName(); // Zi or Fd
216218
bool DebugFileIsDirectory(); // Fd ends in '\\'

include/dxc/Support/HLSLOptions.td

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,10 @@ def enable_lifetime_markers : Flag<["-", "/"], "enable-lifetime-markers">, Group
277277
HelpText<"Enable generation of lifetime markers">;
278278
def disable_lifetime_markers : Flag<["-", "/"], "disable-lifetime-markers">, Group<hlslcomp_Group>, Flags<[CoreOption, HelpHidden]>,
279279
HelpText<"Disable generation of lifetime markers where they would be otherwise (6.6+)">;
280+
def enable_payload_qualifiers : Flag<["-", "/"], "enable-payload-qualifiers">, Group<hlslcomp_Group>, Flags<[CoreOption, RewriteOption, DriverOption]>,
281+
HelpText<"Enables support for payload access qualifiers for raytracing payloads in SM 6.6.">;
282+
def disable_payload_qualifiers : Flag<["-", "/"], "disable-payload-qualifiers">, Group<hlslcomp_Group>, Flags<[CoreOption, RewriteOption, DriverOption]>,
283+
HelpText<"Disables support for payload access qualifiers for raytracing payloads in SM 6.7.">;
280284

281285
// Used with API only
282286
def skip_serialization : Flag<["-", "/"], "skip-serialization">, Group<hlslcore_Group>, Flags<[CoreOption, HelpHidden]>,
@@ -411,10 +415,10 @@ def Qstrip_priv : Flag<["-", "/"], "Qstrip_priv">, Flags<[DriverOption]>, Group<
411415
HelpText<"Strip private data from shader bytecode (must be used with /Fo <file>)">;
412416
def Qsource_in_debug_module : Flag<["-", "/"], "Qsource_in_debug_module">, Flags<[CoreOption, HelpHidden]>, Group<hlslutil_Group>,
413417
HelpText<"Generate old PDB format.">;
414-
def Qsource_only_debug : Flag<["-", "/"], "Qsource_only_debug">, Flags<[CoreOption, HelpHidden]>, Group<hlslutil_Group>,
418+
def Zs : Flag<["-", "/"], "Zs">, Flags<[CoreOption]>, Group<hlslutil_Group>,
415419
HelpText<"Generate small PDB with just sources and compile options.">;
416-
def Qfull_debug : Flag<["-", "/"], "Qfull_debug">, Flags<[CoreOption, HelpHidden]>, Group<hlslutil_Group>,
417-
HelpText<"Generate full debug info for PDB.">;
420+
def Qpdb_in_private : Flag<["-", "/"], "Qpdb_in_private">, Flags<[CoreOption, HelpHidden]>, Group<hlslutil_Group>,
421+
HelpText<"Store PDB in private user data.">;
418422

419423
def Qstrip_rootsignature : Flag<["-", "/"], "Qstrip_rootsignature">, Flags<[CoreOption, DriverOption]>, Group<hlslutil_Group>, HelpText<"Strip root signature data from shader bytecode (must be used with /Fo <file>)">;
420424
def setrootsignature : JoinedOrSeparate<["-", "/"], "setrootsignature">, MetaVarName<"<file>">, Flags<[CoreOption, DriverOption]>, Group<hlslutil_Group>, HelpText<"Attach root signature to shader bytecode">;

include/dxc/Test/DxcTestUtils.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ class FileCheckForTest {
6060
int Run();
6161
};
6262

63+
// wstring because most uses need UTF-16: IDxcResult output names, include handler
64+
typedef std::map<std::wstring, CComPtr<IDxcBlob>> FileMap;
65+
6366
// The result of running a single command in a run pipeline
6467
struct FileRunCommandResult {
6568
CComPtr<IDxcOperationResult> OpResult; // The operation result, if any.
@@ -109,6 +112,7 @@ class FileRunCommandPart {
109112
std::string Command; // Command to run, eg %dxc
110113
std::string Arguments; // Arguments to command
111114
LPCWSTR CommandFileName; // File name replacement for %s
115+
FileMap *pVFS = nullptr; // Files in virtual file system
112116

113117
private:
114118
FileRunCommandResult RunFileChecker(const FileRunCommandResult *Prior, LPCWSTR dumpName = nullptr);
@@ -117,6 +121,7 @@ class FileRunCommandPart {
117121
FileRunCommandResult RunOpt(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
118122
FileRunCommandResult RunD3DReflect(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
119123
FileRunCommandResult RunDxr(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
124+
FileRunCommandResult RunLink(dxc::DxcDllSupport &DllSupport, const FileRunCommandResult *Prior);
120125
FileRunCommandResult RunTee(const FileRunCommandResult *Prior);
121126
FileRunCommandResult RunXFail(const FileRunCommandResult *Prior);
122127
FileRunCommandResult RunDxilVer(dxc::DxcDllSupport& DllSupport, const FileRunCommandResult* Prior);

include/dxc/dxcapi.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ struct IDxcVersionInfo2 : public IDxcVersionInfo {
576576
};
577577

578578
CROSS_PLATFORM_UUIDOF(IDxcVersionInfo3, "5e13e843-9d25-473c-9ad2-03b2d0b44b1e")
579-
struct IDxcVersionInfo3 : public IDxcVersionInfo2 {
579+
struct IDxcVersionInfo3 : public IUnknown {
580580
virtual HRESULT STDMETHODCALLTYPE GetCustomVersionString(
581581
_Outptr_result_z_ char **pVersionString // Custom version string for compiler. (Must be CoTaskMemFree()'d!)
582582
) = 0;

0 commit comments

Comments
 (0)