Skip to content

Commit

Permalink
spirv-opt : SPV_NV_bindless_texture related changes (#4870)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmistryNV authored Jul 29, 2022
1 parent b5d0bf2 commit 54cd5e1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 2 additions & 0 deletions source/opt/ir_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ bool IrLoader::AddInstruction(const spv_parsed_instruction_t* inst) {
module_->AddExtInstImport(std::move(spv_inst));
} else if (opcode == SpvOpMemoryModel) {
module_->SetMemoryModel(std::move(spv_inst));
} else if (opcode == SpvOpSamplerImageAddressingModeNV) {
module_->SetSampledImageAddressMode(std::move(spv_inst));
} else if (opcode == SpvOpEntryPoint) {
module_->AddEntryPoint(std::move(spv_inst));
} else if (opcode == SpvOpExecutionMode ||
Expand Down
5 changes: 5 additions & 0 deletions source/opt/module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ void Module::ForEachInst(const std::function<void(Instruction*)>& f,
DELEGATE(extensions_);
DELEGATE(ext_inst_imports_);
if (memory_model_) memory_model_->ForEachInst(f, run_on_debug_line_insts);
if (sampled_image_address_mode_)
sampled_image_address_mode_->ForEachInst(f, run_on_debug_line_insts);
DELEGATE(entry_points_);
DELEGATE(execution_modes_);
DELEGATE(debugs1_);
Expand All @@ -114,6 +116,9 @@ void Module::ForEachInst(const std::function<void(const Instruction*)>& f,
if (memory_model_)
static_cast<const Instruction*>(memory_model_.get())
->ForEachInst(f, run_on_debug_line_insts);
if (sampled_image_address_mode_)
static_cast<const Instruction*>(sampled_image_address_mode_.get())
->ForEachInst(f, run_on_debug_line_insts);
for (auto& i : entry_points_) DELEGATE(i);
for (auto& i : execution_modes_) DELEGATE(i);
for (auto& i : debugs1_) DELEGATE(i);
Expand Down
19 changes: 18 additions & 1 deletion source/opt/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ class Module {
// Set the memory model for this module.
inline void SetMemoryModel(std::unique_ptr<Instruction> m);

// Set the sampled image addressing mode for this module.
inline void SetSampledImageAddressMode(std::unique_ptr<Instruction> m);

// Appends an entry point instruction to this module.
inline void AddEntryPoint(std::unique_ptr<Instruction> e);

Expand Down Expand Up @@ -158,12 +161,20 @@ class Module {
inline IteratorRange<inst_iterator> ext_inst_imports();
inline IteratorRange<const_inst_iterator> ext_inst_imports() const;

// Return the memory model instruction contained inthis module.
// Return the memory model instruction contained in this module.
inline Instruction* GetMemoryModel() { return memory_model_.get(); }
inline const Instruction* GetMemoryModel() const {
return memory_model_.get();
}

// Return the sampled image address mode instruction contained in this module.
inline Instruction* GetSampledImageAddressMode() {
return sampled_image_address_mode_.get();
}
inline const Instruction* GetSampledImageAddressMode() const {
return sampled_image_address_mode_.get();
}

// There are several kinds of debug instructions, according to where they can
// appear in the logical layout of a module:
// - Section 7a: OpString, OpSourceExtension, OpSource, OpSourceContinued
Expand Down Expand Up @@ -288,6 +299,8 @@ class Module {
InstructionList ext_inst_imports_;
// A module only has one memory model instruction.
std::unique_ptr<Instruction> memory_model_;
// A module can only have one optional sampled image addressing mode
std::unique_ptr<Instruction> sampled_image_address_mode_;
InstructionList entry_points_;
InstructionList execution_modes_;
InstructionList debugs1_;
Expand Down Expand Up @@ -326,6 +339,10 @@ inline void Module::SetMemoryModel(std::unique_ptr<Instruction> m) {
memory_model_ = std::move(m);
}

inline void Module::SetSampledImageAddressMode(std::unique_ptr<Instruction> m) {
sampled_image_address_mode_ = std::move(m);
}

inline void Module::AddEntryPoint(std::unique_ptr<Instruction> e) {
entry_points_.push_back(std::move(e));
}
Expand Down

0 comments on commit 54cd5e1

Please sign in to comment.