This commit is contained in:
Lei Zhang 2017-07-16 21:28:35 -04:00 коммит произвёл Marcelo Lopez Ruiz
Родитель 3abf46ab73
Коммит 4ff631148d
3 изменённых файлов: 15 добавлений и 38 удалений

Просмотреть файл

@ -76,13 +76,8 @@ const Semantic *Semantic::GetArbitrary() {
}
bool Semantic::HasSVPrefix(llvm::StringRef Name) {
if (Name.size() >= 3)
if (Name[0] == 'S' || Name[0] == 's')
if (Name[1] == 'V' || Name[1] == 'v')
if (Name[2] == '_')
return true;
return false;
return Name.size() >= 3 && (Name[0] == 'S' || Name[0] == 's') &&
(Name[1] == 'V' || Name[1] == 'v') && Name[2] == '_';
}
void Semantic::DecomposeNameAndIndex(llvm::StringRef FullName, llvm::StringRef *pName, unsigned *pIndex) {

Просмотреть файл

@ -11,6 +11,7 @@
#include "dxc/HLSL/DxilSignature.h"
#include "dxc/HLSL/DxilSignatureAllocator.h"
#include "dxc/HLSL/DxilSigPoint.h"
#include "llvm/ADT/STLExtras.h"
using std::vector;
using std::unique_ptr;
@ -53,7 +54,7 @@ bool DxilSignature::IsOutput() const {
}
unique_ptr<DxilSignatureElement> DxilSignature::CreateElement() {
return unique_ptr<DxilSignatureElement>(new DxilSignatureElement(m_sigPointKind));
return llvm::make_unique<DxilSignatureElement>(m_sigPointKind);
}
unsigned DxilSignature::AppendElement(std::unique_ptr<DxilSignatureElement> pSE, bool bSetID) {
@ -67,11 +68,11 @@ unsigned DxilSignature::AppendElement(std::unique_ptr<DxilSignatureElement> pSE,
}
DxilSignatureElement &DxilSignature::GetElement(unsigned idx) {
return *m_Elements[idx].get();
return *m_Elements[idx];
}
const DxilSignatureElement &DxilSignature::GetElement(unsigned idx) const {
return *m_Elements[idx].get();
return *m_Elements[idx];
}
const std::vector<std::unique_ptr<DxilSignatureElement> > &DxilSignature::GetElements() const {

Просмотреть файл

@ -25,6 +25,7 @@
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Lex/HLSLMacroExpander.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/GetElementPtrTypeIterator.h"
@ -425,13 +426,11 @@ SourceLocation
CGMSHLSLRuntime::SetSemantic(const NamedDecl *decl,
DxilParameterAnnotation &paramInfo) {
for (const hlsl::UnusualAnnotation *it : decl->getUnusualAnnotations()) {
switch (it->getKind()) {
case hlsl::UnusualAnnotation::UA_SemanticDecl: {
if (it->getKind() == hlsl::UnusualAnnotation::UA_SemanticDecl) {
const hlsl::SemanticDecl *sd = cast<hlsl::SemanticDecl>(it);
paramInfo.SetSemanticString(sd->SemanticName);
return it->Loc;
}
}
}
return SourceLocation();
}
@ -674,10 +673,7 @@ static void ConstructFieldAttributedAnnotation(DxilFieldAnnotation &fieldAnnotat
}
}
unsigned row, col;
hlsl::GetHLSLMatRowColCount(Ty, row, col);
Matrix.Cols = col;
Matrix.Rows = row;
hlsl::GetHLSLMatRowColCount(Ty, Matrix.Rows, Matrix.Cols);
fieldAnnotation.SetMatrixAnnotation(Matrix);
EltTy = hlsl::GetHLSLMatElementType(Ty);
}
@ -972,16 +968,13 @@ static DxilResource::Kind KeywordToKind(StringRef keyword) {
return DxilResource::Kind::Invalid;
}
static DxilSampler::SamplerKind KeywordToSamplerKind(const std::string &keyword) {
static DxilSampler::SamplerKind KeywordToSamplerKind(llvm::StringRef keyword) {
// TODO: refactor for faster search (switch by 1/2/3 first letters, then
// compare)
if (keyword == "SamplerState")
return DxilSampler::SamplerKind::Default;
if (keyword == "SamplerComparisonState")
return DxilSampler::SamplerKind::Comparison;
return DxilSampler::SamplerKind::Invalid;
return llvm::StringSwitch<DxilSampler::SamplerKind>(keyword)
.Case("SamplerState", DxilSampler::SamplerKind::Default)
.Case("SamplerComparisonState", DxilSampler::SamplerKind::Comparison)
.Default(DxilSampler::SamplerKind::Invalid);
}
void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
@ -1351,19 +1344,7 @@ void CGMSHLSLRuntime::AddHLSLFunctionInfo(Function *F, const FunctionDecl *FD) {
funcProps->shaderKind = DXIL::ShaderKind::Pixel;
}
unsigned profileAttributes = 0;
if (isCS)
profileAttributes++;
if (isHS)
profileAttributes++;
if (isDS)
profileAttributes++;
if (isGS)
profileAttributes++;
if (isVS)
profileAttributes++;
if (isPS)
profileAttributes++;
const unsigned profileAttributes = isCS + isHS + isDS + isGS + isVS + isPS;
// TODO: check this in front-end and report error.
DXASSERT(profileAttributes < 2, "profile attributes are mutual exclusive");