vk: Add support for driver-internal custom pipelines

This lets us disable the viewport, use rect lists and repclear.
This commit is contained in:
Kristian Høgsberg
2015-05-11 23:20:01 -07:00
parent ad132bbe48
commit b734e0bcc5
3 changed files with 42 additions and 10 deletions

View File

@@ -1833,9 +1833,6 @@ VkResult VKAPI vkBeginCommandBuffer(
.ConstantBufferOffset = 8, .ConstantBufferOffset = 8,
.ConstantBufferSize = 4); .ConstantBufferSize = 4);
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_CLIP,
.ClipEnable = true,
.ViewportXYClipTestEnable = true);
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_WM_CHROMAKEY, anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_WM_CHROMAKEY,
.ChromaKeyKillEnable = false); .ChromaKeyKillEnable = false);
anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SBE_SWIZ); anv_batch_emit(&cmd_buffer->batch, GEN8_3DSTATE_SBE_SWIZ);

View File

@@ -122,7 +122,9 @@ emit_vertex_input(struct anv_pipeline *pipeline, VkPipelineVertexInputCreateInfo
} }
static void static void
emit_ia_state(struct anv_pipeline *pipeline, VkPipelineIaStateCreateInfo *info) emit_ia_state(struct anv_pipeline *pipeline,
VkPipelineIaStateCreateInfo *info,
const struct anv_pipeline_create_info *extra)
{ {
static const uint32_t vk_to_gen_primitive_type[] = { static const uint32_t vk_to_gen_primitive_type[] = {
[VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST, [VK_PRIMITIVE_TOPOLOGY_POINT_LIST] = _3DPRIM_POINTLIST,
@@ -137,16 +139,22 @@ emit_ia_state(struct anv_pipeline *pipeline, VkPipelineIaStateCreateInfo *info)
[VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ] = _3DPRIM_TRISTRIP_ADJ, [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ] = _3DPRIM_TRISTRIP_ADJ,
[VK_PRIMITIVE_TOPOLOGY_PATCH] = _3DPRIM_PATCHLIST_1 [VK_PRIMITIVE_TOPOLOGY_PATCH] = _3DPRIM_PATCHLIST_1
}; };
uint32_t topology = vk_to_gen_primitive_type[info->topology];
if (extra && extra->use_rectlist)
topology = _3DPRIM_RECTLIST;
anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF, anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF,
.IndexedDrawCutIndexEnable = info->primitiveRestartEnable, .IndexedDrawCutIndexEnable = info->primitiveRestartEnable,
.CutIndex = info->primitiveRestartIndex); .CutIndex = info->primitiveRestartIndex);
anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY, anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY,
.PrimitiveTopologyType = vk_to_gen_primitive_type[info->topology]); .PrimitiveTopologyType = topology);
} }
static void static void
emit_rs_state(struct anv_pipeline *pipeline, VkPipelineRsStateCreateInfo *info) emit_rs_state(struct anv_pipeline *pipeline, VkPipelineRsStateCreateInfo *info,
const struct anv_pipeline_create_info *extra)
{ {
static const uint32_t vk_to_gen_cullmode[] = { static const uint32_t vk_to_gen_cullmode[] = {
[VK_CULL_MODE_NONE] = CULLMODE_NONE, [VK_CULL_MODE_NONE] = CULLMODE_NONE,
@@ -173,7 +181,7 @@ emit_rs_state(struct anv_pipeline *pipeline, VkPipelineRsStateCreateInfo *info)
struct GEN8_3DSTATE_SF sf = { struct GEN8_3DSTATE_SF sf = {
GEN8_3DSTATE_SF_header, GEN8_3DSTATE_SF_header,
.ViewportTransformEnable = true, .ViewportTransformEnable = !(extra && extra->disable_viewport),
.TriangleStripListProvokingVertexSelect = .TriangleStripListProvokingVertexSelect =
info->provokingVertex == VK_PROVOKING_VERTEX_FIRST ? 0 : 2, info->provokingVertex == VK_PROVOKING_VERTEX_FIRST ? 0 : 2,
.LineStripListProvokingVertexSelect = .LineStripListProvokingVertexSelect =
@@ -207,8 +215,19 @@ emit_rs_state(struct anv_pipeline *pipeline, VkPipelineRsStateCreateInfo *info)
} }
VkResult VKAPI vkCreateGraphicsPipeline( VkResult VKAPI vkCreateGraphicsPipeline(
VkDevice device,
const VkGraphicsPipelineCreateInfo* pCreateInfo,
VkPipeline* pPipeline)
{
return anv_pipeline_create(device, pCreateInfo, NULL, pPipeline);
}
VkResult
anv_pipeline_create(
VkDevice _device, VkDevice _device,
const VkGraphicsPipelineCreateInfo* pCreateInfo, const VkGraphicsPipelineCreateInfo* pCreateInfo,
const struct anv_pipeline_create_info * extra,
VkPipeline* pPipeline) VkPipeline* pPipeline)
{ {
struct anv_device *device = (struct anv_device *) _device; struct anv_device *device = (struct anv_device *) _device;
@@ -262,7 +281,7 @@ VkResult VKAPI vkCreateGraphicsPipeline(
} }
} }
pipeline->use_repclear = false; pipeline->use_repclear = extra && extra->use_repclear;
anv_compiler_run(device->compiler, pipeline); anv_compiler_run(device->compiler, pipeline);
@@ -274,8 +293,12 @@ VkResult VKAPI vkCreateGraphicsPipeline(
pipeline->wm_prog_data.num_varying_inputs = vi_info->attributeCount - 2; pipeline->wm_prog_data.num_varying_inputs = vi_info->attributeCount - 2;
emit_vertex_input(pipeline, vi_info); emit_vertex_input(pipeline, vi_info);
emit_ia_state(pipeline, ia_info); emit_ia_state(pipeline, ia_info, extra);
emit_rs_state(pipeline, rs_info); emit_rs_state(pipeline, rs_info, extra);
anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_CLIP,
.ClipEnable = true,
.ViewportXYClipTestEnable = !(extra && extra->disable_viewport));
anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_WM, anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_WM,
.StatisticsEnable = true, .StatisticsEnable = true,

View File

@@ -535,6 +535,18 @@ struct anv_pipeline {
uint32_t state_raster[GEN8_3DSTATE_RASTER_length]; uint32_t state_raster[GEN8_3DSTATE_RASTER_length];
}; };
struct anv_pipeline_create_info {
bool use_repclear;
bool disable_viewport;
bool use_rectlist;
};
VkResult
anv_pipeline_create(VkDevice device,
const VkGraphicsPipelineCreateInfo *pCreateInfo,
const struct anv_pipeline_create_info *extra,
VkPipeline *pPipeline);
VkResult anv_pipeline_destroy(struct anv_pipeline *pipeline); VkResult anv_pipeline_destroy(struct anv_pipeline *pipeline);
struct anv_compiler *anv_compiler_create(int fd); struct anv_compiler *anv_compiler_create(int fd);