From 9f4d057aa28c4e9509bdc767afb27b4aee303b7e Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 15 Dec 2019 18:23:59 -0300 Subject: [PATCH] image: Remove assumed lod in image samples This commits breaks the API. Depth image samples assumed a lod operand, this made using Grad samples clumsy to use. --- include/sirit/sirit.h | 27 ++++++++++++--------------- src/instructions/image.cpp | 8 ++------ 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index a6d267d..25eed05 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -767,14 +767,14 @@ public: /// Sample an image using an explicit level of detail. Id OpImageSampleExplicitLod(Id result_type, Id sampled_image, Id coordinate, - spv::ImageOperandsMask image_operands, Id lod, + spv::ImageOperandsMask image_operands, const std::vector& operands = {}); /// Sample an image using an explicit level of detail. template Id OpImageSampleExplicitLod(Id result_type, Id sampled_image, Id coordinate, - spv::ImageOperandsMask image_operands, Id lod, Ts&&... operands) { - return OpImageSampleExplicitLod(result_type, sampled_image, coordinate, image_operands, lod, + spv::ImageOperandsMask image_operands, Ts&&... operands) { + return OpImageSampleExplicitLod(result_type, sampled_image, coordinate, image_operands, {operands...}); } @@ -793,16 +793,15 @@ public: /// Sample an image doing depth-comparison using an explicit level of detail. Id OpImageSampleDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, Id lod, + spv::ImageOperandsMask image_operands, const std::vector& operands = {}); /// Sample an image doing depth-comparison using an explicit level of detail. template Id OpImageSampleDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, Id lod, - Ts&&... operands) { + spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleDrefExplicitLod(result_type, sampled_image, coordinate, dref, - image_operands, lod, {operands...}); + image_operands, {operands...}); } /// Sample an image with with a project coordinate and an implicit level of detail. @@ -820,16 +819,15 @@ public: /// Sample an image with a project coordinate using an explicit level of detail. Id OpImageSampleProjExplicitLod(Id result_type, Id sampled_image, Id coordinate, - spv::ImageOperandsMask image_operands, Id lod, + spv::ImageOperandsMask image_operands, const std::vector& operands = {}); /// Sample an image with a project coordinate using an explicit level of detail. template Id OpImageSampleProjExplicitLod(Id result_type, Id sampled_image, Id coordinate, - spv::ImageOperandsMask image_operands, Id lod, - Ts&&... operands) { + spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjExplicitLod(result_type, sampled_image, coordinate, image_operands, - lod, {operands...}); + {operands...}); } /// Sample an image with a project coordinate, doing depth-comparison, with an implicit level of @@ -850,17 +848,16 @@ public: /// Sample an image with a project coordinate, doing depth-comparison, using an explicit level /// of detail. Id OpImageSampleProjDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, Id lod, + spv::ImageOperandsMask image_operands, const std::vector& operands = {}); /// Sample an image with a project coordinate, doing depth-comparison, using an explicit level /// of detail. template Id OpImageSampleProjDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, - spv::ImageOperandsMask image_operands, Id lod, - Ts&&... operands) { + spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjDrefExplicitLod(result_type, sampled_image, coordinate, dref, - image_operands, lod, {operands...}); + image_operands, {operands...}); } /// Fetch a single texel from an image whose Sampled operand is 1. diff --git a/src/instructions/image.cpp b/src/instructions/image.cpp index 6d8cde3..d12dc2c 100644 --- a/src/instructions/image.cpp +++ b/src/instructions/image.cpp @@ -31,13 +31,11 @@ static void AddImageOperands(Op* op, std::optional image #define DEFINE_IMAGE_EXP_OP(opcode) \ Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, \ - spv::ImageOperandsMask image_operands, Id lod, \ - const std::vector& operands) { \ + spv::ImageOperandsMask image_operands, const std::vector& operands) { \ auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ op->Add(sampled_image); \ op->Add(coordinate); \ op->Add(static_cast(image_operands)); \ - op->Add(lod); \ op->Add(operands); \ return AddCode(std::move(op)); \ } @@ -56,14 +54,12 @@ static void AddImageOperands(Op* op, std::optional image #define DEFINE_IMAGE_EXTRA_EXP_OP(opcode) \ Id Module::opcode(Id result_type, Id sampled_image, Id coordinate, Id extra, \ - spv::ImageOperandsMask image_operands, Id lod, \ - const std::vector& operands) { \ + spv::ImageOperandsMask image_operands, const std::vector& operands) { \ auto op{std::make_unique(spv::Op::opcode, bound++, result_type)}; \ op->Add(sampled_image); \ op->Add(coordinate); \ op->Add(extra); \ op->Add(static_cast(image_operands)); \ - op->Add(lod); \ op->Add(operands); \ return AddCode(std::move(op)); \ }