zink: prepare for shadow-samplers
authorErik Faye-Lund <erik.faye-lund@collabora.com>
Thu, 20 Jun 2019 13:41:37 +0000 (15:41 +0200)
committerErik Faye-Lund <erik.faye-lund@collabora.com>
Mon, 28 Oct 2019 08:51:45 +0000 (08:51 +0000)
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
src/gallium/drivers/zink/zink_context.c

index 6c8b0bb641de35b74a70d8c74ebd13d13aca89a9..a2ed26267a9b5edc21b9bc2d7aa9c06c4265e77f 100644 (file)
@@ -107,6 +107,22 @@ sampler_address_mode(enum pipe_tex_wrap filter)
    unreachable("unexpected wrap");
 }
 
+static VkCompareOp
+compare_op(enum pipe_compare_func op)
+{
+   switch (op) {
+      case PIPE_FUNC_NEVER: return VK_COMPARE_OP_NEVER;
+      case PIPE_FUNC_LESS: return VK_COMPARE_OP_LESS;
+      case PIPE_FUNC_EQUAL: return VK_COMPARE_OP_EQUAL;
+      case PIPE_FUNC_LEQUAL: return VK_COMPARE_OP_LESS_OR_EQUAL;
+      case PIPE_FUNC_GREATER: return VK_COMPARE_OP_GREATER;
+      case PIPE_FUNC_NOTEQUAL: return VK_COMPARE_OP_NOT_EQUAL;
+      case PIPE_FUNC_GEQUAL: return VK_COMPARE_OP_GREATER_OR_EQUAL;
+      case PIPE_FUNC_ALWAYS: return VK_COMPARE_OP_ALWAYS;
+   }
+   unreachable("unexpected compare");
+}
+
 static void *
 zink_create_sampler_state(struct pipe_context *pctx,
                           const struct pipe_sampler_state *state)
@@ -132,7 +148,12 @@ zink_create_sampler_state(struct pipe_context *pctx,
    sci.addressModeV = sampler_address_mode(state->wrap_t);
    sci.addressModeW = sampler_address_mode(state->wrap_r);
    sci.mipLodBias = state->lod_bias;
-   sci.compareOp = VK_COMPARE_OP_NEVER; // TODO
+
+   if (state->compare_mode == PIPE_TEX_COMPARE_NONE)
+      sci.compareOp = VK_COMPARE_OP_NEVER;
+   else
+      sci.compareOp = compare_op(state->compare_func);
+
    sci.borderColor = VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK; // TODO
    sci.unnormalizedCoordinates = !state->normalized_coords;