Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Tools.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/opt/replace_invalid_opc.cpp')
-rw-r--r--source/opt/replace_invalid_opc.cpp81
1 files changed, 41 insertions, 40 deletions
diff --git a/source/opt/replace_invalid_opc.cpp b/source/opt/replace_invalid_opc.cpp
index 1dcd06f59..214097398 100644
--- a/source/opt/replace_invalid_opc.cpp
+++ b/source/opt/replace_invalid_opc.cpp
@@ -23,16 +23,16 @@ namespace opt {
Pass::Status ReplaceInvalidOpcodePass::Process() {
bool modified = false;
- if (context()->get_feature_mgr()->HasCapability(SpvCapabilityLinkage)) {
+ if (context()->get_feature_mgr()->HasCapability(spv::Capability::Linkage)) {
return Status::SuccessWithoutChange;
}
- SpvExecutionModel execution_model = GetExecutionModel();
- if (execution_model == SpvExecutionModelKernel) {
+ spv::ExecutionModel execution_model = GetExecutionModel();
+ if (execution_model == spv::ExecutionModel::Kernel) {
// We do not handle kernels.
return Status::SuccessWithoutChange;
}
- if (execution_model == SpvExecutionModelMax) {
+ if (execution_model == spv::ExecutionModel::Max) {
// Mixed execution models for the entry points. This case is not currently
// handled.
return Status::SuccessWithoutChange;
@@ -44,19 +44,19 @@ Pass::Status ReplaceInvalidOpcodePass::Process() {
return (modified ? Status::SuccessWithChange : Status::SuccessWithoutChange);
}
-SpvExecutionModel ReplaceInvalidOpcodePass::GetExecutionModel() {
- SpvExecutionModel result = SpvExecutionModelMax;
+spv::ExecutionModel ReplaceInvalidOpcodePass::GetExecutionModel() {
+ spv::ExecutionModel result = spv::ExecutionModel::Max;
bool first = true;
for (Instruction& entry_point : get_module()->entry_points()) {
if (first) {
- result =
- static_cast<SpvExecutionModel>(entry_point.GetSingleWordInOperand(0));
+ result = static_cast<spv::ExecutionModel>(
+ entry_point.GetSingleWordInOperand(0));
first = false;
} else {
- SpvExecutionModel current_model =
- static_cast<SpvExecutionModel>(entry_point.GetSingleWordInOperand(0));
+ spv::ExecutionModel current_model = static_cast<spv::ExecutionModel>(
+ entry_point.GetSingleWordInOperand(0));
if (current_model != result) {
- result = SpvExecutionModelMax;
+ result = spv::ExecutionModel::Max;
break;
}
}
@@ -65,13 +65,13 @@ SpvExecutionModel ReplaceInvalidOpcodePass::GetExecutionModel() {
}
bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function,
- SpvExecutionModel model) {
+ spv::ExecutionModel model) {
bool modified = false;
Instruction* last_line_dbg_inst = nullptr;
function->ForEachInst(
[model, &modified, &last_line_dbg_inst, this](Instruction* inst) {
// Track the debug information so we can have a meaningful message.
- if (inst->opcode() == SpvOpLabel || inst->IsNoLine()) {
+ if (inst->opcode() == spv::Op::OpLabel || inst->IsNoLine()) {
last_line_dbg_inst = nullptr;
return;
} else if (inst->IsLine()) {
@@ -80,15 +80,15 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function,
}
bool replace = false;
- if (model != SpvExecutionModelFragment &&
+ if (model != spv::ExecutionModel::Fragment &&
IsFragmentShaderOnlyInstruction(inst)) {
replace = true;
}
- if (model != SpvExecutionModelTessellationControl &&
- model != SpvExecutionModelGLCompute) {
- if (inst->opcode() == SpvOpControlBarrier) {
- assert(model != SpvExecutionModelKernel &&
+ if (model != spv::ExecutionModel::TessellationControl &&
+ model != spv::ExecutionModel::GLCompute) {
+ if (inst->opcode() == spv::Op::OpControlBarrier) {
+ assert(model != spv::ExecutionModel::Kernel &&
"Expecting to be working on a shader module.");
replace = true;
}
@@ -101,7 +101,7 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function,
} else {
// Get the name of the source file.
uint32_t file_name_id = 0;
- if (last_line_dbg_inst->opcode() == SpvOpLine) {
+ if (last_line_dbg_inst->opcode() == spv::Op::OpLine) {
file_name_id = last_line_dbg_inst->GetSingleWordInOperand(0);
} else { // Shader100::DebugLine
uint32_t debug_source_id =
@@ -131,26 +131,26 @@ bool ReplaceInvalidOpcodePass::RewriteFunction(Function* function,
bool ReplaceInvalidOpcodePass::IsFragmentShaderOnlyInstruction(
Instruction* inst) {
switch (inst->opcode()) {
- case SpvOpDPdx:
- case SpvOpDPdy:
- case SpvOpFwidth:
- case SpvOpDPdxFine:
- case SpvOpDPdyFine:
- case SpvOpFwidthFine:
- case SpvOpDPdxCoarse:
- case SpvOpDPdyCoarse:
- case SpvOpFwidthCoarse:
- case SpvOpImageSampleImplicitLod:
- case SpvOpImageSampleDrefImplicitLod:
- case SpvOpImageSampleProjImplicitLod:
- case SpvOpImageSampleProjDrefImplicitLod:
- case SpvOpImageSparseSampleImplicitLod:
- case SpvOpImageSparseSampleDrefImplicitLod:
- case SpvOpImageQueryLod:
+ case spv::Op::OpDPdx:
+ case spv::Op::OpDPdy:
+ case spv::Op::OpFwidth:
+ case spv::Op::OpDPdxFine:
+ case spv::Op::OpDPdyFine:
+ case spv::Op::OpFwidthFine:
+ case spv::Op::OpDPdxCoarse:
+ case spv::Op::OpDPdyCoarse:
+ case spv::Op::OpFwidthCoarse:
+ case spv::Op::OpImageSampleImplicitLod:
+ case spv::Op::OpImageSampleDrefImplicitLod:
+ case spv::Op::OpImageSampleProjImplicitLod:
+ case spv::Op::OpImageSampleProjDrefImplicitLod:
+ case spv::Op::OpImageSparseSampleImplicitLod:
+ case spv::Op::OpImageSparseSampleDrefImplicitLod:
+ case spv::Op::OpImageQueryLod:
// TODO: Teach |ReplaceInstruction| to handle block terminators. Then
// uncomment the OpKill case.
- // case SpvOpKill:
- // case SpvOpTerminateInstruction:
+ // case spv::Op::OpKill:
+ // case spv::Op::OpTerminateInstruction:
return true;
default:
return false;
@@ -183,7 +183,7 @@ uint32_t ReplaceInvalidOpcodePass::GetSpecialConstant(uint32_t type_id) {
analysis::TypeManager* type_mgr = context()->get_type_mgr();
Instruction* type = context()->get_def_use_mgr()->GetDef(type_id);
- if (type->opcode() == SpvOpTypeVector) {
+ if (type->opcode() == spv::Op::OpTypeVector) {
uint32_t component_const =
GetSpecialConstant(type->GetSingleWordInOperand(0));
std::vector<uint32_t> ids;
@@ -192,7 +192,8 @@ uint32_t ReplaceInvalidOpcodePass::GetSpecialConstant(uint32_t type_id) {
}
special_const = const_mgr->GetConstant(type_mgr->GetType(type_id), ids);
} else {
- assert(type->opcode() == SpvOpTypeInt || type->opcode() == SpvOpTypeFloat);
+ assert(type->opcode() == spv::Op::OpTypeInt ||
+ type->opcode() == spv::Op::OpTypeFloat);
std::vector<uint32_t> literal_words;
for (uint32_t i = 0; i < type->GetSingleWordInOperand(0); i += 32) {
literal_words.push_back(0xDEADBEEF);
@@ -204,7 +205,7 @@ uint32_t ReplaceInvalidOpcodePass::GetSpecialConstant(uint32_t type_id) {
return const_mgr->GetDefiningInstruction(special_const)->result_id();
}
-std::string ReplaceInvalidOpcodePass::BuildWarningMessage(SpvOp opcode) {
+std::string ReplaceInvalidOpcodePass::BuildWarningMessage(spv::Op opcode) {
spv_opcode_desc opcode_info;
context()->grammar().lookupOpcode(opcode, &opcode_info);
std::string message = "Removing ";