diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index dd45d4f..7e1fd22 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -61,11 +62,14 @@ public: std::span interfaces = {}); /// Adds an entry point. + // TODO: Change std::is_convertible_v to std::convertible_to when compilers + // support it; same elsewhere. template + requires (... && std::is_convertible_v) void AddEntryPoint(spv::ExecutionModel execution_model, Id entry_point, std::string_view name, Ts&&... interfaces) { AddEntryPoint(execution_model, std::move(entry_point), name, - std::span{std::array{interfaces...}}); + std::span({interfaces...})); } /// Declare an execution mode for an entry point. @@ -74,9 +78,9 @@ public: /// Declare an execution mode for an entry point. template + requires (... && std::is_convertible_v) void AddExecutionMode(Id entry_point, spv::ExecutionMode mode, Ts&&... literals) { - const Literal stack_literals[] = {std::forward(literals)...}; - AddExecutionMode(entry_point, mode, std::span{stack_literals}); + AddExecutionMode(entry_point, mode, std::span({literals...})); } /** @@ -144,8 +148,9 @@ public: /// Returns type struct. template + requires (... && std::is_convertible_v) Id TypeStruct(Ts&&... members) { - return TypeStruct(std::span{std::array{members...}}); + return TypeStruct(std::span({members...})); } /// Returns type opaque. @@ -159,8 +164,9 @@ public: /// Returns type function. template + requires (... && std::is_convertible_v) Id TypeFunction(Id return_type, Ts&&... arguments) { - return TypeFunction(return_type, std::span{std::array{arguments...}}); + return TypeFunction(return_type, std::span({arguments...})); } /// Returns type event. @@ -194,8 +200,9 @@ public: /// Returns a numeric scalar constant. template + requires (... && std::is_convertible_v) Id ConstantComposite(Id result_type, Ts&&... constituents) { - return ConstantComposite(result_type, std::span{std::array{constituents...}}); + return ConstantComposite(result_type, std::span({constituents...})); } /// Returns a sampler constant. @@ -218,8 +225,9 @@ public: /// Call a function. template + requires (... && std::is_convertible_v) Id OpFunctionCall(Id result_type, Id function, Ts&&... arguments) { - return OpFunctionCall(result_type, function, std::span{std::array{arguments...}}); + return OpFunctionCall(result_type, function, std::span({arguments...})); } // Flow @@ -230,10 +238,11 @@ public: /// Declare a structured loop. template + requires (... && std::is_convertible_v) Id OpLoopMerge(Id merge_block, Id continue_target, spv::LoopControlMask loop_control, Ts&&... literals) { return OpLoopMerge(merge_block, continue_target, loop_control, - std::span{std::array{literals...}}); + std::span({literals...})); } /// Declare a structured selection. @@ -301,8 +310,9 @@ public: /// Create a pointer into a composite object that can be used with OpLoad and OpStore. template + requires (... && std::is_convertible_v) Id OpAccessChain(Id result_type, Id base, Ts&&... indexes) { - return OpAccessChain(result_type, base, std::span{std::array{indexes...}}); + return OpAccessChain(result_type, base, std::span({indexes...})); } /// Extract a single, dynamically selected, component of a vector. @@ -317,6 +327,7 @@ public: /// Make a copy of a composite object, while modifying one part of it. template + requires (... && std::is_convertible_v) Id OpCompositeInsert(Id result_type, Id object, Id composite, Ts&&... indexes) { const Literal stack_indexes[] = {std::forward(indexes)...}; return OpCompositeInsert(result_type, object, composite, @@ -328,6 +339,7 @@ public: /// Extract a part of a composite object. template + requires (... && std::is_convertible_v) Id OpCompositeExtract(Id result_type, Id composite, Ts&&... indexes) { const Literal stack_indexes[] = {std::forward(indexes)...}; return OpCompositeExtract(result_type, composite, std::span{stack_indexes}); @@ -338,8 +350,9 @@ public: /// Construct a new composite object from a set of constituent objects that will fully form it. template + requires (... && std::is_convertible_v) Id OpCompositeConstruct(Id result_type, Ts&&... ids) { - return OpCompositeConstruct(result_type, std::span{std::array{ids...}}); + return OpCompositeConstruct(result_type, std::span({ids...})); } // Annotation @@ -349,6 +362,7 @@ public: /// Add a decoration to target. template + requires (... && std::is_convertible_v) Id Decorate(Id target, spv::Decoration decoration, Ts&&... literals) { const Literal stack_literals[] = {std::forward(literals)...}; return Decorate(target, decoration, std::span{stack_literals}); @@ -358,6 +372,7 @@ public: std::span literals = {}); template + requires (... && std::is_convertible_v) Id MemberDecorate(Id structure_type, Literal member, spv::Decoration decoration, Ts&&... literals) { const Literal stack_literals[] = {std::forward(literals)...}; @@ -621,9 +636,10 @@ public: /// Execute an instruction in an imported set of extended instructions. template + requires (... && std::is_convertible_v) Id OpExtInst(Id result_type, Id set, std::uint32_t instruction, Ts&&... operands) { return OpExtInst(result_type, set, instruction, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Result is x if x >= 0; otherwise result is -x. @@ -777,10 +793,11 @@ public: /// Sample an image with an implicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleImplicitLod(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleImplicitLod(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image using an explicit level of detail. @@ -790,10 +807,11 @@ public: /// Sample an image using an explicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleExplicitLod(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleExplicitLod(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image doing depth-comparison with an implicit level of detail. @@ -803,11 +821,12 @@ public: /// Sample an image doing depth-comparison with an implicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleDrefImplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleDrefImplicitLod(result_type, sampled_image, coordinate, dref, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image doing depth-comparison using an explicit level of detail. @@ -817,11 +836,12 @@ public: /// Sample an image doing depth-comparison using an explicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleDrefExplicitLod(result_type, sampled_image, coordinate, dref, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image with with a project coordinate and an implicit level of detail. @@ -831,10 +851,11 @@ public: /// Sample an image with with a project coordinate and an implicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleProjImplicitLod(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjImplicitLod(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image with a project coordinate using an explicit level of detail. @@ -844,10 +865,11 @@ public: /// Sample an image with a project coordinate using an explicit level of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleProjExplicitLod(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjExplicitLod(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image with a project coordinate, doing depth-comparison, with an implicit level of @@ -859,11 +881,12 @@ public: /// Sample an image with a project coordinate, doing depth-comparison, with an implicit level of /// detail. template + requires (... && std::is_convertible_v) Id OpImageSampleProjDrefImplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjDrefImplicitLod(result_type, sampled_image, coordinate, dref, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Sample an image with a project coordinate, doing depth-comparison, using an explicit level @@ -875,11 +898,12 @@ public: /// Sample an image with a project coordinate, doing depth-comparison, using an explicit level /// of detail. template + requires (... && std::is_convertible_v) Id OpImageSampleProjDrefExplicitLod(Id result_type, Id sampled_image, Id coordinate, Id dref, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageSampleProjDrefExplicitLod(result_type, sampled_image, coordinate, dref, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Fetch a single texel from an image whose Sampled operand is 1. @@ -889,10 +913,11 @@ public: /// Fetch a single texel from an image whose Sampled operand is 1. template + requires (... && std::is_convertible_v) Id OpImageFetch(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageFetch(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Gathers the requested component from four texels. @@ -902,10 +927,11 @@ public: /// Gathers the requested component from four texels. template + requires (... && std::is_convertible_v) Id OpImageGather(Id result_type, Id sampled_image, Id coordinate, Id component, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageGather(result_type, sampled_image, coordinate, component, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Gathers the requested depth-comparison from four texels. @@ -915,10 +941,11 @@ public: /// Gathers the requested depth-comparison from four texels. template + requires (... && std::is_convertible_v) Id OpImageDrefGather(Id result_type, Id sampled_image, Id coordinate, Id dref, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageDrefGather(result_type, sampled_image, coordinate, dref, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Read a texel from an image without a sampler. @@ -928,10 +955,11 @@ public: /// Read a texel from an image without a sampler. template + requires (... && std::is_convertible_v) Id OpImageRead(Id result_type, Id sampled_image, Id coordinate, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageRead(result_type, sampled_image, coordinate, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Write a texel to an image without a sampler. @@ -941,10 +969,11 @@ public: /// Write a texel to an image without a sampler. template + requires (... && std::is_convertible_v) Id OpImageWrite(Id image, Id coordinate, Id texel, spv::ImageOperandsMask image_operands, Ts&&... operands) { return OpImageWrite(image, coordinate, texel, image_operands, - std::span{std::array{operands...}}); + std::span({operands...})); } /// Extract the image from a sampled image.