From 240c0746d1617690ede440794eb4aa981784f5df Mon Sep 17 00:00:00 2001 From: Lionel Landwerlin Date: Tue, 11 Aug 2020 00:30:10 +0300 Subject: [PATCH] anv: centralize vk to gen arrays MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Lionel Landwerlin Reviewed-by: Tapani Pälli Part-of: --- src/intel/vulkan/anv_genX.h | 12 +++++- src/intel/vulkan/gen7_cmd_buffer.c | 70 ++++++------------------------ src/intel/vulkan/gen8_cmd_buffer.c | 87 +++++++++----------------------------- src/intel/vulkan/genX_pipeline.c | 83 +++++++++++++++++++++--------------- 4 files changed, 92 insertions(+), 160 deletions(-) diff --git a/src/intel/vulkan/anv_genX.h b/src/intel/vulkan/anv_genX.h index 662daa0..aede549 100644 --- a/src/intel/vulkan/anv_genX.h +++ b/src/intel/vulkan/anv_genX.h @@ -28,7 +28,7 @@ /* * Gen-specific function declarations. This header must *not* be included * directly. Instead, it is included multiple times by anv_private.h. - * + * * In this header file, the usual genx() macro is available. */ @@ -36,6 +36,16 @@ #error This file is included by means other than anv_private.h #endif +extern const uint32_t genX(vk_to_gen_cullmode)[]; + +extern const uint32_t genX(vk_to_gen_front_face)[]; + +extern const uint32_t genX(vk_to_gen_primitive_type)[]; + +extern const uint32_t genX(vk_to_gen_compare_op)[]; + +extern const uint32_t genX(vk_to_gen_stencil_op)[]; + VkResult genX(init_device_state)(struct anv_device *device); void genX(cmd_buffer_emit_state_base_address)(struct anv_cmd_buffer *cmd_buffer); diff --git a/src/intel/vulkan/gen7_cmd_buffer.c b/src/intel/vulkan/gen7_cmd_buffer.c index 1de4715..bfe9a39 100644 --- a/src/intel/vulkan/gen7_cmd_buffer.c +++ b/src/intel/vulkan/gen7_cmd_buffer.c @@ -198,39 +198,6 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) struct anv_graphics_pipeline *pipeline = cmd_buffer->state.gfx.pipeline; struct anv_dynamic_state *d = &cmd_buffer->state.gfx.dynamic; - static const uint32_t vk_to_gen_cullmode[] = { - [VK_CULL_MODE_NONE] = CULLMODE_NONE, - [VK_CULL_MODE_FRONT_BIT] = CULLMODE_FRONT, - [VK_CULL_MODE_BACK_BIT] = CULLMODE_BACK, - [VK_CULL_MODE_FRONT_AND_BACK] = CULLMODE_BOTH - }; - static const uint32_t vk_to_gen_front_face[] = { - [VK_FRONT_FACE_COUNTER_CLOCKWISE] = 1, - [VK_FRONT_FACE_CLOCKWISE] = 0 - }; - - 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, - }; - - static const uint32_t vk_to_gen_stencil_op[] = { - [VK_STENCIL_OP_KEEP] = STENCILOP_KEEP, - [VK_STENCIL_OP_ZERO] = STENCILOP_ZERO, - [VK_STENCIL_OP_REPLACE] = STENCILOP_REPLACE, - [VK_STENCIL_OP_INCREMENT_AND_CLAMP] = STENCILOP_INCRSAT, - [VK_STENCIL_OP_DECREMENT_AND_CLAMP] = STENCILOP_DECRSAT, - [VK_STENCIL_OP_INVERT] = STENCILOP_INVERT, - [VK_STENCIL_OP_INCREMENT_AND_WRAP] = STENCILOP_INCR, - [VK_STENCIL_OP_DECREMENT_AND_WRAP] = STENCILOP_DECR, - }; - if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | ANV_CMD_DIRTY_RENDER_TARGETS | ANV_CMD_DIRTY_DYNAMIC_LINE_WIDTH | @@ -245,8 +212,8 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) .GlobalDepthOffsetConstant = d->depth_bias.bias, .GlobalDepthOffsetScale = d->depth_bias.slope, .GlobalDepthOffsetClamp = d->depth_bias.clamp, - .FrontWinding = vk_to_gen_front_face[d->front_face], - .CullMode = vk_to_gen_cullmode[d->cull_mode], + .FrontWinding = genX(vk_to_gen_front_face)[d->front_face], + .CullMode = genX(vk_to_gen_cullmode)[d->cull_mode], }; GENX(3DSTATE_SF_pack)(NULL, sf_dw, &sf); @@ -307,16 +274,16 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) .DepthTestEnable = d->depth_test_enable, .DepthBufferWriteEnable = d->depth_test_enable && d->depth_write_enable, - .DepthTestFunction = vk_to_gen_compare_op[d->depth_compare_op], + .DepthTestFunction = genX(vk_to_gen_compare_op)[d->depth_compare_op], .StencilTestEnable = d->stencil_test_enable, - .StencilFailOp = vk_to_gen_stencil_op[d->stencil_op.front.fail_op], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.front.pass_op], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[d->stencil_op.front.depth_fail_op], - .StencilTestFunction = vk_to_gen_compare_op[d->stencil_op.front.compare_op], - .BackfaceStencilFailOp = vk_to_gen_stencil_op[d->stencil_op.back.fail_op], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.back.pass_op], - .BackfaceStencilPassDepthFailOp = vk_to_gen_stencil_op[d->stencil_op.back.depth_fail_op], - .BackfaceStencilTestFunction = vk_to_gen_compare_op[d->stencil_op.back.compare_op], + .StencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.fail_op], + .StencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.pass_op], + .StencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.depth_fail_op], + .StencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.front.compare_op], + .BackfaceStencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.fail_op], + .BackfaceStencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.pass_op], + .BackfaceStencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.depth_fail_op], + .BackfaceStencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.back.compare_op], }; GENX(DEPTH_STENCIL_STATE_pack)(NULL, depth_stencil_dw, &depth_stencil); @@ -359,26 +326,13 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) } } - static const uint32_t vk_to_gen_primitive_type[] = { - [VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST, - [VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = _3DPRIM_LINELIST, - [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = _3DPRIM_LINESTRIP, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = _3DPRIM_TRILIST, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = _3DPRIM_TRISTRIP, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = _3DPRIM_TRIFAN, - [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = _3DPRIM_LINELIST_ADJ, - [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = _3DPRIM_LINESTRIP_ADJ, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = _3DPRIM_TRILIST_ADJ, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = _3DPRIM_TRISTRIP_ADJ, - }; - if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | ANV_CMD_DIRTY_DYNAMIC_PRIMITIVE_TOPOLOGY)) { uint32_t topology; if (anv_pipeline_has_stage(pipeline, MESA_SHADER_TESS_EVAL)) topology = d->primitive_topology; else - topology = vk_to_gen_primitive_type[d->primitive_topology]; + topology = genX(vk_to_gen_primitive_type)[d->primitive_topology]; cmd_buffer->state.gfx.primitive_topology = topology; } diff --git a/src/intel/vulkan/gen8_cmd_buffer.c b/src/intel/vulkan/gen8_cmd_buffer.c index 92aa2b6..cc63a4b 100644 --- a/src/intel/vulkan/gen8_cmd_buffer.c +++ b/src/intel/vulkan/gen8_cmd_buffer.c @@ -439,51 +439,6 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) anv_batch_emit_merge(&cmd_buffer->batch, sf_dw, pipeline->gen8.sf); } - static const uint32_t vk_to_gen_cullmode[] = { - [VK_CULL_MODE_NONE] = CULLMODE_NONE, - [VK_CULL_MODE_FRONT_BIT] = CULLMODE_FRONT, - [VK_CULL_MODE_BACK_BIT] = CULLMODE_BACK, - [VK_CULL_MODE_FRONT_AND_BACK] = CULLMODE_BOTH - }; - static const uint32_t vk_to_gen_front_face[] = { - [VK_FRONT_FACE_COUNTER_CLOCKWISE] = 1, - [VK_FRONT_FACE_CLOCKWISE] = 0 - }; - static const uint32_t vk_to_gen_primitive_type[] = { - [VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST, - [VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = _3DPRIM_LINELIST, - [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = _3DPRIM_LINESTRIP, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = _3DPRIM_TRILIST, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = _3DPRIM_TRISTRIP, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = _3DPRIM_TRIFAN, - [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = _3DPRIM_LINELIST_ADJ, - [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = _3DPRIM_LINESTRIP_ADJ, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = _3DPRIM_TRILIST_ADJ, - [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = _3DPRIM_TRISTRIP_ADJ, - }; - - 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, - }; - - static const uint32_t vk_to_gen_stencil_op[] = { - [VK_STENCIL_OP_KEEP] = STENCILOP_KEEP, - [VK_STENCIL_OP_ZERO] = STENCILOP_ZERO, - [VK_STENCIL_OP_REPLACE] = STENCILOP_REPLACE, - [VK_STENCIL_OP_INCREMENT_AND_CLAMP] = STENCILOP_INCRSAT, - [VK_STENCIL_OP_DECREMENT_AND_CLAMP] = STENCILOP_DECRSAT, - [VK_STENCIL_OP_INVERT] = STENCILOP_INVERT, - [VK_STENCIL_OP_INCREMENT_AND_WRAP] = STENCILOP_INCR, - [VK_STENCIL_OP_DECREMENT_AND_WRAP] = STENCILOP_DECR, - }; - if (cmd_buffer->state.gfx.dirty & (ANV_CMD_DIRTY_PIPELINE | ANV_CMD_DIRTY_DYNAMIC_DEPTH_BIAS | ANV_CMD_DIRTY_DYNAMIC_CULL_MODE | @@ -494,8 +449,8 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) .GlobalDepthOffsetConstant = d->depth_bias.bias, .GlobalDepthOffsetScale = d->depth_bias.slope, .GlobalDepthOffsetClamp = d->depth_bias.clamp, - .CullMode = vk_to_gen_cullmode[d->cull_mode], - .FrontWinding = vk_to_gen_front_face[d->front_face], + .CullMode = genX(vk_to_gen_cullmode)[d->cull_mode], + .FrontWinding = genX(vk_to_gen_front_face)[d->front_face], }; GENX(3DSTATE_RASTER_pack)(NULL, raster_dw, &raster); anv_batch_emit_merge(&cmd_buffer->batch, raster_dw, @@ -556,16 +511,16 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) .DepthTestEnable = d->depth_test_enable, .DepthBufferWriteEnable = d->depth_test_enable && d->depth_write_enable, - .DepthTestFunction = vk_to_gen_compare_op[d->depth_compare_op], + .DepthTestFunction = genX(vk_to_gen_compare_op)[d->depth_compare_op], .StencilTestEnable = d->stencil_test_enable, - .StencilFailOp = vk_to_gen_stencil_op[d->stencil_op.front.fail_op], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.front.pass_op], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[d->stencil_op.front.depth_fail_op], - .StencilTestFunction = vk_to_gen_compare_op[d->stencil_op.front.compare_op], - .BackfaceStencilFailOp = vk_to_gen_stencil_op[d->stencil_op.back.fail_op], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.back.pass_op], - .BackfaceStencilPassDepthFailOp = vk_to_gen_stencil_op[d->stencil_op.back.depth_fail_op], - .BackfaceStencilTestFunction = vk_to_gen_compare_op[d->stencil_op.back.compare_op], + .StencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.fail_op], + .StencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.pass_op], + .StencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.depth_fail_op], + .StencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.front.compare_op], + .BackfaceStencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.fail_op], + .BackfaceStencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.pass_op], + .BackfaceStencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.depth_fail_op], + .BackfaceStencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.back.compare_op], }; GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, wm_depth_stencil_dw, &wm_depth_stencil); @@ -625,16 +580,16 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) .DepthTestEnable = d->depth_test_enable, .DepthBufferWriteEnable = d->depth_test_enable && d->depth_write_enable, - .DepthTestFunction = vk_to_gen_compare_op[d->depth_compare_op], + .DepthTestFunction = genX(vk_to_gen_compare_op)[d->depth_compare_op], .StencilTestEnable = d->stencil_test_enable, - .StencilFailOp = vk_to_gen_stencil_op[d->stencil_op.front.fail_op], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.front.pass_op], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[d->stencil_op.front.depth_fail_op], - .StencilTestFunction = vk_to_gen_compare_op[d->stencil_op.front.compare_op], - .BackfaceStencilFailOp = vk_to_gen_stencil_op[d->stencil_op.back.fail_op], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[d->stencil_op.back.pass_op], - .BackfaceStencilPassDepthFailOp =vk_to_gen_stencil_op[d->stencil_op.back.depth_fail_op], - .BackfaceStencilTestFunction = vk_to_gen_compare_op[d->stencil_op.back.compare_op], + .StencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.fail_op], + .StencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.pass_op], + .StencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.front.depth_fail_op], + .StencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.front.compare_op], + .BackfaceStencilFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.fail_op], + .BackfaceStencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.pass_op], + .BackfaceStencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[d->stencil_op.back.depth_fail_op], + .BackfaceStencilTestFunction = genX(vk_to_gen_compare_op)[d->stencil_op.back.compare_op], }; GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, dwords, &wm_depth_stencil); @@ -684,7 +639,7 @@ genX(cmd_buffer_flush_dynamic_state)(struct anv_cmd_buffer *cmd_buffer) if (anv_pipeline_has_stage(pipeline, MESA_SHADER_TESS_EVAL)) topology = d->primitive_topology; else - topology = vk_to_gen_primitive_type[d->primitive_topology]; + topology = genX(vk_to_gen_primitive_type)[d->primitive_topology]; cmd_buffer->state.gfx.primitive_topology = topology; diff --git a/src/intel/vulkan/genX_pipeline.c b/src/intel/vulkan/genX_pipeline.c index e76dd87..d4b9368 100644 --- a/src/intel/vulkan/genX_pipeline.c +++ b/src/intel/vulkan/genX_pipeline.c @@ -438,24 +438,6 @@ emit_3dstate_sbe(struct anv_graphics_pipeline *pipeline) #endif } -static const uint32_t vk_to_gen_cullmode[] = { - [VK_CULL_MODE_NONE] = CULLMODE_NONE, - [VK_CULL_MODE_FRONT_BIT] = CULLMODE_FRONT, - [VK_CULL_MODE_BACK_BIT] = CULLMODE_BACK, - [VK_CULL_MODE_FRONT_AND_BACK] = CULLMODE_BOTH -}; - -static const uint32_t vk_to_gen_fillmode[] = { - [VK_POLYGON_MODE_FILL] = FILL_MODE_SOLID, - [VK_POLYGON_MODE_LINE] = FILL_MODE_WIREFRAME, - [VK_POLYGON_MODE_POINT] = FILL_MODE_POINT, -}; - -static const uint32_t vk_to_gen_front_face[] = { - [VK_FRONT_FACE_COUNTER_CLOCKWISE] = 1, - [VK_FRONT_FACE_CLOCKWISE] = 0 -}; - static VkLineRasterizationModeEXT vk_line_rasterization_mode(const VkPipelineRasterizationLineStateCreateInfoEXT *line_info, const VkPipelineMultisampleStateCreateInfo *ms_info) @@ -574,6 +556,24 @@ gen7_ms_rast_mode(struct anv_graphics_pipeline *pipeline, } #endif +const uint32_t genX(vk_to_gen_cullmode)[] = { + [VK_CULL_MODE_NONE] = CULLMODE_NONE, + [VK_CULL_MODE_FRONT_BIT] = CULLMODE_FRONT, + [VK_CULL_MODE_BACK_BIT] = CULLMODE_BACK, + [VK_CULL_MODE_FRONT_AND_BACK] = CULLMODE_BOTH +}; + +const uint32_t genX(vk_to_gen_fillmode)[] = { + [VK_POLYGON_MODE_FILL] = FILL_MODE_SOLID, + [VK_POLYGON_MODE_LINE] = FILL_MODE_WIREFRAME, + [VK_POLYGON_MODE_POINT] = FILL_MODE_POINT, +}; + +const uint32_t genX(vk_to_gen_front_face)[] = { + [VK_FRONT_FACE_COUNTER_CLOCKWISE] = 1, + [VK_FRONT_FACE_CLOCKWISE] = 0 +}; + static void emit_rs_state(struct anv_graphics_pipeline *pipeline, const VkPipelineInputAssemblyStateCreateInfo *ia_info, @@ -681,13 +681,13 @@ emit_rs_state(struct anv_graphics_pipeline *pipeline, raster.FrontWinding = dynamic_states & ANV_CMD_DIRTY_DYNAMIC_FRONT_FACE ? - 0 : vk_to_gen_front_face[rs_info->frontFace]; + 0 : genX(vk_to_gen_front_face)[rs_info->frontFace]; raster.CullMode = dynamic_states & ANV_CMD_DIRTY_DYNAMIC_CULL_MODE ? - 0 : vk_to_gen_cullmode[rs_info->cullMode]; + 0 : genX(vk_to_gen_cullmode)[rs_info->cullMode]; - raster.FrontFaceFillMode = vk_to_gen_fillmode[rs_info->polygonMode]; - raster.BackFaceFillMode = vk_to_gen_fillmode[rs_info->polygonMode]; + raster.FrontFaceFillMode = genX(vk_to_gen_fillmode)[rs_info->polygonMode]; + raster.BackFaceFillMode = genX(vk_to_gen_fillmode)[rs_info->polygonMode]; raster.ScissorRectangleEnable = true; #if GEN_GEN >= 9 @@ -843,7 +843,7 @@ static const uint32_t vk_to_gen_blend_op[] = { [VK_BLEND_OP_MAX] = BLENDFUNCTION_MAX, }; -static const uint32_t vk_to_gen_compare_op[] = { +const uint32_t genX(vk_to_gen_compare_op)[] = { [VK_COMPARE_OP_NEVER] = PREFILTEROPNEVER, [VK_COMPARE_OP_LESS] = PREFILTEROPLESS, [VK_COMPARE_OP_EQUAL] = PREFILTEROPEQUAL, @@ -854,7 +854,7 @@ static const uint32_t vk_to_gen_compare_op[] = { [VK_COMPARE_OP_ALWAYS] = PREFILTEROPALWAYS, }; -static const uint32_t vk_to_gen_stencil_op[] = { +const uint32_t genX(vk_to_gen_stencil_op)[] = { [VK_STENCIL_OP_KEEP] = STENCILOP_KEEP, [VK_STENCIL_OP_ZERO] = STENCILOP_ZERO, [VK_STENCIL_OP_REPLACE] = STENCILOP_REPLACE, @@ -865,6 +865,19 @@ static const uint32_t vk_to_gen_stencil_op[] = { [VK_STENCIL_OP_DECREMENT_AND_WRAP] = STENCILOP_DECR, }; +const uint32_t genX(vk_to_gen_primitive_type)[] = { + [VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST, + [VK_PRIMITIVE_TOPOLOGY_LINE_LIST] = _3DPRIM_LINELIST, + [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP] = _3DPRIM_LINESTRIP, + [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST] = _3DPRIM_TRILIST, + [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP] = _3DPRIM_TRISTRIP, + [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN] = _3DPRIM_TRIFAN, + [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_WITH_ADJACENCY] = _3DPRIM_LINELIST_ADJ, + [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_WITH_ADJACENCY] = _3DPRIM_LINESTRIP_ADJ, + [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_WITH_ADJACENCY] = _3DPRIM_TRILIST_ADJ, + [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_WITH_ADJACENCY] = _3DPRIM_TRISTRIP_ADJ, +}; + /* This function sanitizes the VkStencilOpState by looking at the compare ops * and trying to determine whether or not a given stencil op can ever actually * occur. Stencil ops which can never occur are set to VK_STENCIL_OP_KEEP. @@ -1056,7 +1069,7 @@ emit_ds_state(struct anv_graphics_pipeline *pipeline, .DepthTestFunction = dynamic_states & ANV_CMD_DIRTY_DYNAMIC_DEPTH_COMPARE_OP ? - 0 : vk_to_gen_compare_op[info.depthCompareOp], + 0 : genX(vk_to_gen_compare_op)[info.depthCompareOp], .DoubleSidedStencilEnable = true, @@ -1064,14 +1077,14 @@ emit_ds_state(struct anv_graphics_pipeline *pipeline, dynamic_states & ANV_CMD_DIRTY_DYNAMIC_STENCIL_TEST_ENABLE ? 0 : info.stencilTestEnable, - .StencilFailOp = vk_to_gen_stencil_op[info.front.failOp], - .StencilPassDepthPassOp = vk_to_gen_stencil_op[info.front.passOp], - .StencilPassDepthFailOp = vk_to_gen_stencil_op[info.front.depthFailOp], - .StencilTestFunction = vk_to_gen_compare_op[info.front.compareOp], - .BackfaceStencilFailOp = vk_to_gen_stencil_op[info.back.failOp], - .BackfaceStencilPassDepthPassOp = vk_to_gen_stencil_op[info.back.passOp], - .BackfaceStencilPassDepthFailOp =vk_to_gen_stencil_op[info.back.depthFailOp], - .BackfaceStencilTestFunction = vk_to_gen_compare_op[info.back.compareOp], + .StencilFailOp = genX(vk_to_gen_stencil_op)[info.front.failOp], + .StencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[info.front.passOp], + .StencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[info.front.depthFailOp], + .StencilTestFunction = genX(vk_to_gen_compare_op)[info.front.compareOp], + .BackfaceStencilFailOp = genX(vk_to_gen_stencil_op)[info.back.failOp], + .BackfaceStencilPassDepthPassOp = genX(vk_to_gen_stencil_op)[info.back.passOp], + .BackfaceStencilPassDepthFailOp = genX(vk_to_gen_stencil_op)[info.back.depthFailOp], + .BackfaceStencilTestFunction = genX(vk_to_gen_compare_op)[info.back.compareOp], }; if (dynamic_stencil_op) { @@ -1339,8 +1352,8 @@ emit_3dstate_clip(struct anv_graphics_pipeline *pipeline, !(last->vue_map.slots_valid & VARYING_BIT_LAYER); #if GEN_GEN == 7 - clip.FrontWinding = vk_to_gen_front_face[rs_info->frontFace]; - clip.CullMode = vk_to_gen_cullmode[rs_info->cullMode]; + clip.FrontWinding = genX(vk_to_gen_front_face)[rs_info->frontFace]; + clip.CullMode = genX(vk_to_gen_cullmode)[rs_info->cullMode]; clip.ViewportZClipTestEnable = pipeline->depth_clip_enable; clip.UserClipDistanceClipTestEnableBitmask = last->clip_distance_mask; clip.UserClipDistanceCullTestEnableBitmask = last->cull_distance_mask; -- 2.7.4