|
@@ -725,6 +725,8 @@ void SpirvEmitter::doDecl(const Decl *decl) {
|
|
doHLSLBufferDecl(bufferDecl);
|
|
doHLSLBufferDecl(bufferDecl);
|
|
} else if (const auto *recordDecl = dyn_cast<RecordDecl>(decl)) {
|
|
} else if (const auto *recordDecl = dyn_cast<RecordDecl>(decl)) {
|
|
doRecordDecl(recordDecl);
|
|
doRecordDecl(recordDecl);
|
|
|
|
+ } else if (const auto *enumDecl = dyn_cast<EnumDecl>(decl)) {
|
|
|
|
+ doEnumDecl(enumDecl);
|
|
} else {
|
|
} else {
|
|
emitError("decl type %0 unimplemented", decl->getLocation())
|
|
emitError("decl type %0 unimplemented", decl->getLocation())
|
|
<< decl->getDeclKindName();
|
|
<< decl->getDeclKindName();
|
|
@@ -1251,6 +1253,11 @@ void SpirvEmitter::doRecordDecl(const RecordDecl *recordDecl) {
|
|
doVarDecl(varDecl);
|
|
doVarDecl(varDecl);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void SpirvEmitter::doEnumDecl(const EnumDecl *decl) {
|
|
|
|
+ for (auto it = decl->enumerator_begin(); it != decl->enumerator_end(); ++it)
|
|
|
|
+ declIdMapper.createEnumConstant(*it);
|
|
|
|
+}
|
|
|
|
+
|
|
void SpirvEmitter::doVarDecl(const VarDecl *decl) {
|
|
void SpirvEmitter::doVarDecl(const VarDecl *decl) {
|
|
if (!validateVKAttributes(decl))
|
|
if (!validateVKAttributes(decl))
|
|
return;
|
|
return;
|
|
@@ -5429,7 +5436,7 @@ void SpirvEmitter::initOnce(QualType varType, std::string varName,
|
|
var->setStorageClass(spv::StorageClass::Private);
|
|
var->setStorageClass(spv::StorageClass::Private);
|
|
storeValue(
|
|
storeValue(
|
|
// Static function variable are of private storage class
|
|
// Static function variable are of private storage class
|
|
- var, doExpr(varInit), varInit->getType(), varInit->getLocEnd());
|
|
|
|
|
|
+ var, loadIfGLValue(varInit), varInit->getType(), varInit->getLocEnd());
|
|
} else {
|
|
} else {
|
|
spvBuilder.createStore(var, spvBuilder.getConstantNull(varType), loc);
|
|
spvBuilder.createStore(var, spvBuilder.getConstantNull(varType), loc);
|
|
}
|
|
}
|
|
@@ -6565,6 +6572,9 @@ SpirvInstruction *SpirvEmitter::castToBool(SpirvInstruction *fromVal,
|
|
SpirvInstruction *SpirvEmitter::castToInt(SpirvInstruction *fromVal,
|
|
SpirvInstruction *SpirvEmitter::castToInt(SpirvInstruction *fromVal,
|
|
QualType fromType, QualType toIntType,
|
|
QualType fromType, QualType toIntType,
|
|
SourceLocation srcLoc) {
|
|
SourceLocation srcLoc) {
|
|
|
|
+ if (isEnumType(fromType))
|
|
|
|
+ fromType = astContext.IntTy;
|
|
|
|
+
|
|
if (isSameType(astContext, fromType, toIntType))
|
|
if (isSameType(astContext, fromType, toIntType))
|
|
return fromVal;
|
|
return fromVal;
|
|
|
|
|
|
@@ -10253,7 +10263,7 @@ bool SpirvEmitter::emitEntryFunctionWrapperForRayTracing(
|
|
const auto varInfo =
|
|
const auto varInfo =
|
|
declIdMapper.getDeclEvalInfo(varDecl, varDecl->getLocation());
|
|
declIdMapper.getDeclEvalInfo(varDecl, varDecl->getLocation());
|
|
if (const auto *init = varDecl->getInit()) {
|
|
if (const auto *init = varDecl->getInit()) {
|
|
- storeValue(varInfo, doExpr(init), varDecl->getType(),
|
|
|
|
|
|
+ storeValue(varInfo, loadIfGLValue(init), varDecl->getType(),
|
|
init->getLocStart());
|
|
init->getLocStart());
|
|
|
|
|
|
// Update counter variable associated with global variables
|
|
// Update counter variable associated with global variables
|
|
@@ -10623,7 +10633,7 @@ bool SpirvEmitter::emitEntryFunctionWrapper(const FunctionDecl *decl,
|
|
const auto varInfo =
|
|
const auto varInfo =
|
|
declIdMapper.getDeclEvalInfo(varDecl, varDecl->getLocation());
|
|
declIdMapper.getDeclEvalInfo(varDecl, varDecl->getLocation());
|
|
if (const auto *init = varDecl->getInit()) {
|
|
if (const auto *init = varDecl->getInit()) {
|
|
- storeValue(varInfo, doExpr(init), varDecl->getType(),
|
|
|
|
|
|
+ storeValue(varInfo, loadIfGLValue(init), varDecl->getType(),
|
|
init->getLocStart());
|
|
init->getLocStart());
|
|
|
|
|
|
// Update counter variable associated with global variables
|
|
// Update counter variable associated with global variables
|