diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index 1fb8013..5d90b33 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -284,6 +284,9 @@ public: /// Allocate an object in memory, resulting in a copy to it. Id OpVariable(Id result_type, spv::StorageClass storage_class, Id initializer = nullptr); + /// Form a pointer to a texel of an image. Use of such a pointer is limited to atomic operations. + Id OpImageTexelPointer(Id result_type, Id image, Id coordinate, Id sample); + /// Load through a pointer. Id OpLoad(Id result_type, Id pointer, std::optional memory_access = {}); diff --git a/src/instructions/memory.cpp b/src/instructions/memory.cpp index c2cdb52..33c8b07 100644 --- a/src/instructions/memory.cpp +++ b/src/instructions/memory.cpp @@ -19,6 +19,14 @@ Id Module::OpVariable(Id result_type, spv::StorageClass storage_class, Id initia return code_store.emplace_back(std::move(op)).get(); } +Id Module::OpImageTexelPointer(Id result_type, Id image, Id coordinate, Id sample) { + auto op{std::make_unique(spv::Op::OpImageTexelPointer, bound++, result_type)}; + op->Add(image); + op->Add(coordinate); + op->Add(sample); + return AddCode(std::move(op)); +} + Id Module::OpLoad(Id result_type, Id pointer, std::optional memory_access) { auto op{std::make_unique(spv::Op::OpLoad, bound++, result_type)}; op->Add(pointer);