Skip to content

Commit

Permalink
image: Remove assumed lod in image samples
Browse files Browse the repository at this point in the history
This commits breaks the API. Depth image samples assumed a lod operand,
this made using Grad samples clumsy to use.
  • Loading branch information
ReinUsesLisp committed Dec 15, 2019
1 parent 88d37be commit 9f4d057
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
27 changes: 12 additions & 15 deletions include/sirit/sirit.h
Original file line number Diff line number Diff line change
Expand Up @@ -767,14 +767,14 @@ class Module {

/// 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<Id>& operands = {});

/// Sample an image using an explicit level of detail.
template <typename... Ts>
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...});
}

Expand All @@ -793,16 +793,15 @@ class Module {

/// 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<Id>& operands = {});

/// Sample an image doing depth-comparison using an explicit level of detail.
template <typename... Ts>
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.
Expand All @@ -820,16 +819,15 @@ class Module {

/// 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<Id>& operands = {});

/// Sample an image with a project coordinate using an explicit level of detail.
template <typename... Ts>
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
Expand All @@ -850,17 +848,16 @@ class Module {
/// 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<Id>& operands = {});

/// Sample an image with a project coordinate, doing depth-comparison, using an explicit level
/// of detail.
template <typename... Ts>
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.
Expand Down
8 changes: 2 additions & 6 deletions src/instructions/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ static void AddImageOperands(Op* op, std::optional<spv::ImageOperandsMask> 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<Id>& operands) { \
spv::ImageOperandsMask image_operands, const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
}
Expand All @@ -56,14 +54,12 @@ static void AddImageOperands(Op* op, std::optional<spv::ImageOperandsMask> 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<Id>& operands) { \
spv::ImageOperandsMask image_operands, const std::vector<Id>& operands) { \
auto op{std::make_unique<Op>(spv::Op::opcode, bound++, result_type)}; \
op->Add(sampled_image); \
op->Add(coordinate); \
op->Add(extra); \
op->Add(static_cast<u32>(image_operands)); \
op->Add(lod); \
op->Add(operands); \
return AddCode(std::move(op)); \
}
Expand Down

0 comments on commit 9f4d057

Please sign in to comment.