shader: Implement ImageGradient

This commit is contained in:
FernandoS27 2021-03-29 02:00:43 +02:00 committed by ameerj
parent be3e94ae55
commit d5bfc63088
8 changed files with 84 additions and 2 deletions

View file

@ -1573,6 +1573,13 @@ Value IREmitter::ImageQueryLod(const Value& handle, const Value& coords, Texture
return Inst(op, Flags{info}, handle, coords);
}
Value IREmitter::ImageGradient(const Value& handle, const Value& coords, const Value& derivates,
const Value& offset, const F32& lod_clamp, TextureInstInfo info) {
const Opcode op{handle.IsImmediate() ? Opcode::BoundImageGradient
: Opcode::BindlessImageGradient};
return Inst(op, Flags{info}, handle, coords, derivates, offset, lod_clamp);
}
U1 IREmitter::VoteAll(const U1& value) {
return Inst<U1>(Opcode::VoteAll, value);
}

View file

@ -268,6 +268,10 @@ public:
[[nodiscard]] Value ImageFetch(const Value& handle, const Value& coords, const Value& offset,
const U32& lod, const U32& multisampling, TextureInstInfo info);
[[nodiscard]] Value ImageGradient(const Value& handle, const Value& coords,
const Value& derivates, const Value& offset,
const F32& lod_clamp, TextureInstInfo info);
[[nodiscard]] U1 VoteAll(const U1& value);
[[nodiscard]] U1 VoteAny(const U1& value);
[[nodiscard]] U1 VoteEqual(const U1& value);

View file

@ -39,6 +39,7 @@ union TextureInstInfo {
BitField<9, 1, u32> has_lod_clamp;
BitField<10, 1, u32> relaxed_precision;
BitField<11, 2, u32> gather_component;
BitField<13, 2, u32> num_derivates;
};
static_assert(sizeof(TextureInstInfo) <= sizeof(u32));

View file

@ -381,6 +381,7 @@ OPCODE(BindlessImageGatherDref, F32x4, U32,
OPCODE(BindlessImageFetch, F32x4, U32, Opaque, Opaque, Opaque, Opaque, )
OPCODE(BindlessImageQueryDimensions, U32x4, U32, U32, )
OPCODE(BindlessImageQueryLod, F32x4, U32, Opaque, )
OPCODE(BindlessImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, )
OPCODE(BoundImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
OPCODE(BoundImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
@ -391,6 +392,7 @@ OPCODE(BoundImageGatherDref, F32x4, U32,
OPCODE(BoundImageFetch, F32x4, U32, Opaque, Opaque, Opaque, Opaque, )
OPCODE(BoundImageQueryDimensions, U32x4, U32, U32, )
OPCODE(BoundImageQueryLod, F32x4, U32, Opaque, )
OPCODE(BoundImageGradient, F32x4, U32, Opaque, Opaque, Opaque, Opaque, )
OPCODE(ImageSampleImplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
OPCODE(ImageSampleExplicitLod, F32x4, U32, Opaque, Opaque, Opaque, )
@ -401,6 +403,7 @@ OPCODE(ImageGatherDref, F32x4, U32,
OPCODE(ImageFetch, F32x4, U32, Opaque, Opaque, Opaque, Opaque, )
OPCODE(ImageQueryDimensions, U32x4, U32, U32, )
OPCODE(ImageQueryLod, F32x4, U32, Opaque, )
OPCODE(ImageGradient, F32x4, U32, Opaque, Opaque, Opaque, F32, )
// Warp operations
OPCODE(VoteAll, U1, U1, )