From 72c0522db28b97d9f70b14f28c34f3f0d24b0885 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Jun 2020 13:05:53 -0700 Subject: [PATCH] turnip: Add support for polygon fill modes. Passes the new tests in dEQP-VK.rasterization.culling.* Part-of: --- src/freedreno/vulkan/tu_cmd_buffer.c | 2 -- src/freedreno/vulkan/tu_device.c | 2 +- src/freedreno/vulkan/tu_pipeline.c | 11 +++++++++-- src/freedreno/vulkan/tu_util.h | 15 +++++++++++++++ 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/freedreno/vulkan/tu_cmd_buffer.c b/src/freedreno/vulkan/tu_cmd_buffer.c index 7371f9489ca..db251e0eb7b 100644 --- a/src/freedreno/vulkan/tu_cmd_buffer.c +++ b/src/freedreno/vulkan/tu_cmd_buffer.c @@ -968,9 +968,7 @@ tu6_init_hw(struct tu_cmd_buffer *cmd, struct tu_cs *cs) tu_cs_emit_write_reg(cs, REG_A6XX_VPC_UNKNOWN_9210, 0); tu_cs_emit_write_reg(cs, REG_A6XX_VPC_UNKNOWN_9211, 0); tu_cs_emit_write_reg(cs, REG_A6XX_VPC_UNKNOWN_9602, 0); - tu_cs_emit_write_reg(cs, REG_A6XX_PC_POLYGON_MODE, POLYMODE6_TRIANGLES); tu_cs_emit_write_reg(cs, REG_A6XX_PC_UNKNOWN_9E72, 0); - tu_cs_emit_write_reg(cs, REG_A6XX_VPC_POLYGON_MODE, POLYMODE6_TRIANGLES); tu_cs_emit_write_reg(cs, REG_A6XX_SP_TP_UNKNOWN_B309, 0x000000a2); tu_cs_emit_write_reg(cs, REG_A6XX_HLSQ_CONTROL_5_REG, 0xfc); diff --git a/src/freedreno/vulkan/tu_device.c b/src/freedreno/vulkan/tu_device.c index 994b8a22331..263c6576cf8 100644 --- a/src/freedreno/vulkan/tu_device.c +++ b/src/freedreno/vulkan/tu_device.c @@ -594,7 +594,7 @@ tu_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, .drawIndirectFirstInstance = true, .depthClamp = true, .depthBiasClamp = false, - .fillModeNonSolid = false, + .fillModeNonSolid = true, .depthBounds = true, .wideLines = false, .largePoints = false, diff --git a/src/freedreno/vulkan/tu_pipeline.c b/src/freedreno/vulkan/tu_pipeline.c index b0fb1cc9e46..964d7438ab6 100644 --- a/src/freedreno/vulkan/tu_pipeline.c +++ b/src/freedreno/vulkan/tu_pipeline.c @@ -2194,10 +2194,10 @@ tu_pipeline_builder_parse_rasterization(struct tu_pipeline_builder *builder, const VkPipelineRasterizationStateCreateInfo *rast_info = builder->create_info->pRasterizationState; - assert(rast_info->polygonMode == VK_POLYGON_MODE_FILL); + enum a6xx_polygon_mode mode = tu6_polygon_mode(rast_info->polygonMode); struct tu_cs cs; - tu_cs_begin_sub_stream(&pipeline->cs, 7, &cs); + tu_cs_begin_sub_stream(&pipeline->cs, 11, &cs); tu_cs_emit_regs(&cs, A6XX_GRAS_CL_CNTL( @@ -2206,6 +2206,13 @@ tu_pipeline_builder_parse_rasterization(struct tu_pipeline_builder *builder, .unk5 = rast_info->depthClampEnable, .zero_gb_scale_z = 1, .vp_clip_code_ignore = 1)); + + tu_cs_emit_regs(&cs, + A6XX_VPC_POLYGON_MODE(.mode = mode)); + + tu_cs_emit_regs(&cs, + A6XX_PC_POLYGON_MODE(.mode = mode)); + /* move to hw ctx init? */ tu_cs_emit_regs(&cs, A6XX_GRAS_UNKNOWN_8001()); tu_cs_emit_regs(&cs, diff --git a/src/freedreno/vulkan/tu_util.h b/src/freedreno/vulkan/tu_util.h index dcb4743dd90..fb914cf0ceb 100644 --- a/src/freedreno/vulkan/tu_util.h +++ b/src/freedreno/vulkan/tu_util.h @@ -234,4 +234,19 @@ tu6_pipe2depth(VkFormat format) } } +static inline enum a6xx_polygon_mode +tu6_polygon_mode(VkPolygonMode mode) +{ + switch (mode) { + case VK_POLYGON_MODE_POINT: + return POLYMODE6_POINTS; + case VK_POLYGON_MODE_LINE: + return POLYMODE6_LINES; + case VK_POLYGON_MODE_FILL: + return POLYMODE6_TRIANGLES; + default: + unreachable("bad polygon mode"); + } +} + #endif /* TU_UTIL_H */ -- 2.30.2