diff --git a/.gitignore b/.gitignore index 1b0226a9f5..d904e63815 100644 --- a/.gitignore +++ b/.gitignore @@ -76,3 +76,17 @@ WexLogFileOutput/* #==============================================================================# bindings/go/llvm/llvm_config.go bindings/go/llvm/workdir + +# RTC ignores + +# Premake generated files # +########################### +*.vcxproj* +*.sln +*.make +Makefile +*.xcworkspace +*.xcodeproj +compile_commands.json +*_single_file_build.cpp +*_unity_build.cpp diff --git a/conanfile_rtc.py b/conanfile_rtc.py new file mode 100644 index 0000000000..c1d1096ab5 --- /dev/null +++ b/conanfile_rtc.py @@ -0,0 +1,22 @@ +from conans import ConanFile + +class DirectXShaderCompilerConan(ConanFile): + name = "DirectXShaderCompiler" + version = "0.0.1" + url = "https://github.com/Esri/DirectXShaderCompiler/blob/runtimecore" + license = "https://github.com/Esri/DirectXShaderCompiler/blob/runtimecore/LICENSE.TXT" + description = "A compiler and related tools used to compile High-Level Shader Language (HLSL) programs into DirectX Intermediate Language (DXIL) representation" + + # RTC specific triple + settings = "platform_architecture_target" + + def package(self): + base = self.source_folder + relative = "3rdparty/DirectXShaderCompiler" + + # headers + self.copy("*.h", src=base + "/include/dxc", dst=relative + "/include/dxc") + self.copy("*.hpp", src=base + "/include/dxc", dst=relative + "/include/dxc") + + # libraries + # Only headers are required by RTC, at present: no library diff --git a/tools/clang/lib/SPIRV/AstTypeProbe.cpp b/tools/clang/lib/SPIRV/AstTypeProbe.cpp index fda9a3ab3e..f7914680d7 100644 --- a/tools/clang/lib/SPIRV/AstTypeProbe.cpp +++ b/tools/clang/lib/SPIRV/AstTypeProbe.cpp @@ -23,6 +23,25 @@ clang::DiagnosticBuilder emitError(const clang::ASTContext &astContext, clang::DiagnosticsEngine::Error, message); return astContext.getDiagnostics().Report(srcLoc, diagId); } + +// Returns the attribute of the given type attached to the record declaration +// behind \p type, or nullptr if there is none. Attributes live on the +// declaration, so they cannot be retrieved with QualType::getAs (which only +// navigates the clang::Type hierarchy). +template AttrType *getAttr(clang::QualType type) { + type = type.getCanonicalType(); + if (const clang::RecordType *RT = type->getAs()) { + if (const auto *Spec = + clang::dyn_cast( + RT->getDecl())) + if (const auto *Template = clang::dyn_cast( + Spec->getSpecializedTemplate())) + return Template->getTemplatedDecl()->getAttr(); + if (const auto *Decl = clang::dyn_cast(RT->getDecl())) + return Decl->getAttr(); + } + return nullptr; +} } // namespace namespace clang { @@ -1001,8 +1020,8 @@ bool isResourceDescriptorHeap(const Decl *D) { } bool isResourceDescriptorHeap(QualType T) { - const RecordType *RT = T->getAs(); - return RT && RT->getDecl()->getName() == ".Resource"; + const HLSLDynamicResourceAttr *Attr = getAttr(T); + return Attr && !Attr->getIsSampler(); } bool isSamplerDescriptorHeap(const Decl *D) { @@ -1011,8 +1030,8 @@ bool isSamplerDescriptorHeap(const Decl *D) { } bool isSamplerDescriptorHeap(QualType T) { - const RecordType *RT = T->getAs(); - return RT && RT->getDecl()->getName() == ".Sampler"; + const HLSLDynamicResourceAttr *Attr = getAttr(T); + return Attr && Attr->getIsSampler(); } bool isAKindOfStructuredOrByteBuffer(QualType type) {