diff options
author | ReinUsesLisp <[email protected]> | 2021-03-08 18:31:00 -0300 |
---|---|---|
committer | ReinUsesLisp <[email protected]> | 2021-03-08 18:31:00 -0300 |
commit | 4b1ff612c45c9b518c0e5cb8230805829c0cd12a (patch) | |
tree | ce3d0129fd67ae76274e65aba3a07ef022ce4fb5 /src/instructions | |
parent | f6a713048603381aa07e37c16b3cb30925719730 (diff) | |
download | sirit-4b1ff612c45c9b518c0e5cb8230805829c0cd12a.tar.gz sirit-4b1ff612c45c9b518c0e5cb8230805829c0cd12a.zip |
Add support for sparse texture instructions
Diffstat (limited to 'src/instructions')
-rw-r--r-- | src/instructions/image.cpp | 79 |
1 files changed, 76 insertions, 3 deletions
diff --git a/src/instructions/image.cpp b/src/instructions/image.cpp index 292ae8b..4c94f5e 100644 --- a/src/instructions/image.cpp +++ b/src/instructions/image.cpp @@ -10,6 +10,8 @@ #include "stream.h" +#pragma optimize("", off) + namespace Sirit { #define DEFINE_IMAGE_OP(opcode) \ @@ -24,8 +26,8 @@ namespace Sirit { #define DEFINE_IMAGE_EXP_OP(opcode) \ Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \ spv::ImageOperandsMask image_operands, std::span<const Id> operands) { \ - code->Reserve(7 + operands.size()); \ - return *code << OpId{spv::Op::OpDecorate, result_type} << sampled_image << coordinate \ + code->Reserve(6 + operands.size()); \ + return *code << OpId{spv::Op::opcode, result_type} << sampled_image << coordinate \ << image_operands << operands << EndOp{}; \ } @@ -55,7 +57,7 @@ namespace Sirit { #define DEFINE_IMAGE_QUERY_BIN_OP(opcode) \ Id Module::opcode(Id result_type, Id image, Id extra) { \ code->Reserve(5); \ - return *code << OpId{spv::Op::OpDecorate, result_type} << image << extra << EndOp{}; \ + return *code << OpId{spv::Op::opcode, result_type} << image << extra << EndOp{}; \ } DEFINE_IMAGE_OP(OpImageSampleImplicitLod) @@ -95,4 +97,75 @@ Id Module::OpImage(Id result_type, Id sampled_image) { return *code << OpId{spv::Op::OpImage, result_type} << sampled_image << EndOp{}; } +Id Module::OpImageSparseSampleImplicitLod(Id result_type, Id sampled_image, Id coordinate, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(5 + (image_operands.has_value() ? 1 : 0) + operands.size()); + return *code << OpId{spv::Op::OpImageSparseSampleImplicitLod, result_type} << sampled_image + << coordinate << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseSampleExplicitLod(Id result_type, Id sampled_image, Id coordinate, + spv::ImageOperandsMask image_operands, + std::span<const Id> operands) { + code->Reserve(6 + operands.size()); + return *code << OpId{spv::Op::OpImageSparseSampleExplicitLod, result_type} << sampled_image + << coordinate << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseSampleDrefImplicitLod(Id result_type, Id sampled_image, Id coordinate, + Id dref, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(6 + (image_operands.has_value() ? 1 : 0) + operands.size()); + return *code << OpId{spv::Op::OpImageSparseSampleDrefImplicitLod, result_type} << sampled_image + << coordinate << dref << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseSampleDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, + Id dref, spv::ImageOperandsMask image_operands, + std::span<const Id> operands) { + code->Reserve(7 + operands.size()); + return *code << OpId{spv::Op::OpImageSparseSampleDrefExplicitLod, result_type} << sampled_image + << coordinate << dref << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseFetch(Id result_type, Id image, Id coordinate, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(5 + (image_operands.has_value() ? 1 : 0) + operands.size()); + return *code << OpId{spv::Op::OpImageSparseFetch, result_type} << image << coordinate + << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseGather(Id result_type, Id sampled_image, Id coordinate, Id component, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(6 + operands.size()); + return *code << OpId{spv::Op::OpImageSparseGather, result_type} << sampled_image << coordinate + << component << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseDrefGather(Id result_type, Id sampled_image, Id coordinate, Id dref, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(6 + operands.size()); + return *code << OpId{spv::Op::OpImageSparseDrefGather, result_type} << sampled_image + << coordinate << dref << image_operands << operands << EndOp{}; +} + +Id Module::OpImageSparseTexelsResident(Id result_type, Id resident_code) { + code->Reserve(4); + return *code << OpId{spv::Op::OpImageSparseTexelsResident, result_type} << resident_code + << EndOp{}; +} + +Id Module::OpImageSparseRead(Id result_type, Id image, Id coordinate, + std::optional<spv::ImageOperandsMask> image_operands, + std::span<const Id> operands) { + code->Reserve(5 + (image_operands.has_value() ? 1 : 0) + operands.size()); + return *code << OpId{spv::Op::OpImageSparseTexelsResident, result_type} << image << coordinate + << image_operands << operands << EndOp{}; +} + } // namespace Sirit |