aboutsummaryrefslogtreecommitdiffstats
path: root/src/intel/vulkan/genX_state.c
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-03-03 16:43:49 -0800
committerKenneth Graunke <[email protected]>2016-03-04 11:35:46 -0800
commit9d7faadd8a319d07616d7288451562bf8b9a4be8 (patch)
tree57d7795e5d039dcc2dd2c85a671935d796a596d8 /src/intel/vulkan/genX_state.c
parent3ed260f54cc353398965037f12f39aafa086bcc5 (diff)
anv: Fix backwards shadow comparisons
sample_c is backwards from what GL and Vulkan expect. See intel_state.c in i965. v2: Drop unused vk_to_gen_compare_op. Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/intel/vulkan/genX_state.c')
-rw-r--r--src/intel/vulkan/genX_state.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/intel/vulkan/genX_state.c b/src/intel/vulkan/genX_state.c
index 63ea26937e5..900f6dc8eec 100644
--- a/src/intel/vulkan/genX_state.c
+++ b/src/intel/vulkan/genX_state.c
@@ -173,15 +173,26 @@ static const uint32_t vk_to_gen_tex_address[] = {
[VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER] = TCM_CLAMP_BORDER,
};
-static const uint32_t vk_to_gen_compare_op[] = {
- [VK_COMPARE_OP_NEVER] = PREFILTEROPNEVER,
- [VK_COMPARE_OP_LESS] = PREFILTEROPLESS,
- [VK_COMPARE_OP_EQUAL] = PREFILTEROPEQUAL,
- [VK_COMPARE_OP_LESS_OR_EQUAL] = PREFILTEROPLEQUAL,
- [VK_COMPARE_OP_GREATER] = PREFILTEROPGREATER,
- [VK_COMPARE_OP_NOT_EQUAL] = PREFILTEROPNOTEQUAL,
- [VK_COMPARE_OP_GREATER_OR_EQUAL] = PREFILTEROPGEQUAL,
- [VK_COMPARE_OP_ALWAYS] = PREFILTEROPALWAYS,
+/* Vulkan specifies the result of shadow comparisons as:
+ * 1 if ref <op> texel,
+ * 0 otherwise.
+ *
+ * The hardware does:
+ * 0 if texel <op> ref,
+ * 1 otherwise.
+ *
+ * So, these look a bit strange because there's both a negation
+ * and swapping of the arguments involved.
+ */
+static const uint32_t vk_to_gen_shadow_compare_op[] = {
+ [VK_COMPARE_OP_NEVER] = PREFILTEROPALWAYS,
+ [VK_COMPARE_OP_LESS] = PREFILTEROPLEQUAL,
+ [VK_COMPARE_OP_EQUAL] = PREFILTEROPNOTEQUAL,
+ [VK_COMPARE_OP_LESS_OR_EQUAL] = PREFILTEROPLESS,
+ [VK_COMPARE_OP_GREATER] = PREFILTEROPGEQUAL,
+ [VK_COMPARE_OP_NOT_EQUAL] = PREFILTEROPEQUAL,
+ [VK_COMPARE_OP_GREATER_OR_EQUAL] = PREFILTEROPGREATER,
+ [VK_COMPARE_OP_ALWAYS] = PREFILTEROPNEVER,
};
VkResult genX(CreateSampler)(
@@ -228,7 +239,7 @@ VkResult genX(CreateSampler)(
.ChromaKeyEnable = 0,
.ChromaKeyIndex = 0,
.ChromaKeyMode = 0,
- .ShadowFunction = vk_to_gen_compare_op[pCreateInfo->compareOp],
+ .ShadowFunction = vk_to_gen_shadow_compare_op[pCreateInfo->compareOp],
.CubeSurfaceControlMode = OVERRIDE,
.BorderColorPointer = border_color_offset,