{
assert(tex->op == nir_texop_tex ||
tex->op == nir_texop_txb ||
- tex->op == nir_texop_txl);
+ tex->op == nir_texop_txl ||
+ tex->op == nir_texop_txd);
assert(nir_alu_type_get_base_type(tex->dest_type) == nir_type_float);
assert(tex->texture_index == tex->sampler_index);
- SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0;
+ SpvId coord = 0, proj = 0, bias = 0, lod = 0, dref = 0, dx = 0, dy = 0;
unsigned coord_components = 0;
for (unsigned i = 0; i < tex->num_srcs; i++) {
switch (tex->src[i].src_type) {
assert(dref != 0);
break;
+ case nir_tex_src_ddx:
+ dx = get_src_float(ctx, &tex->src[i].src);
+ assert(dx != 0);
+ break;
+
+ case nir_tex_src_ddy:
+ dy = get_src_float(ctx, &tex->src[i].src);
+ assert(dy != 0);
+ break;
+
default:
fprintf(stderr, "texture source: %d\n", tex->src[i].src_type);
unreachable("unknown texture source");
actual_dest_type, load,
coord,
proj != 0,
- lod, bias, dref);
+ lod, bias, dref, dx, dy);
spirv_builder_emit_decoration(&ctx->builder, result,
SpvDecorationRelaxedPrecision);
bool proj,
SpvId lod,
SpvId bias,
- SpvId dref)
+ SpvId dref,
+ SpvId dx,
+ SpvId dy)
{
SpvId result = spirv_builder_new_id(b);
int operands = 5;
if (proj)
opcode += SpvOpImageSampleProjImplicitLod - SpvOpImageSampleImplicitLod;
- if (lod)
+ if (lod || (dx && dy))
opcode += SpvOpImageSampleExplicitLod - SpvOpImageSampleImplicitLod;
if (dref) {
opcode += SpvOpImageSampleDrefImplicitLod - SpvOpImageSampleImplicitLod;
}
SpvImageOperandsMask operand_mask = 0;
- SpvId extra_operands[3];
+ SpvId extra_operands[4];
int num_extra_operands = SpvImageOperandsMaskNone;
if (bias) {
extra_operands[++num_extra_operands] = bias;
if (lod) {
extra_operands[++num_extra_operands] = lod;
operand_mask |= SpvImageOperandsLodMask;
+ } else if (dx && dy) {
+ extra_operands[++num_extra_operands] = dx;
+ extra_operands[++num_extra_operands] = dy;
+ operand_mask |= SpvImageOperandsGradMask;
}
/* finalize num_extra_operands / extra_operands */
return 1 + util_logbase2(screen->props.limits.maxImageDimensionCube);
case PIPE_CAP_BLEND_EQUATION_SEPARATE:
- return 1;
-
case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD:
- return 0; /* TODO: re-enable after implementing nir_texop_txd */
-
case PIPE_CAP_FRAGMENT_SHADER_DERIVATIVES:
case PIPE_CAP_VERTEX_SHADER_SATURATE:
return 1;