summaryrefslogtreecommitdiffstats
path: root/src/vulkan/gen8_pipeline.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vulkan/gen8_pipeline.c')
-rw-r--r--src/vulkan/gen8_pipeline.c164
1 files changed, 110 insertions, 54 deletions
diff --git a/src/vulkan/gen8_pipeline.c b/src/vulkan/gen8_pipeline.c
index 6e2e65d6344..0038bca01b4 100644
--- a/src/vulkan/gen8_pipeline.c
+++ b/src/vulkan/gen8_pipeline.c
@@ -30,6 +30,7 @@
#include "anv_private.h"
#include "gen8_pack.h"
+#include "gen9_pack.h"
static void
emit_vertex_input(struct anv_pipeline *pipeline,
@@ -38,9 +39,11 @@ emit_vertex_input(struct anv_pipeline *pipeline,
const uint32_t num_dwords = 1 + info->attributeCount * 2;
uint32_t *p;
+ static_assert(ANV_GEN >= 8, "should be compiling this for gen < 8");
+
if (info->attributeCount > 0) {
p = anv_batch_emitn(&pipeline->batch, num_dwords,
- GEN8_3DSTATE_VERTEX_ELEMENTS);
+ GENX(3DSTATE_VERTEX_ELEMENTS));
}
for (uint32_t i = 0; i < info->attributeCount; i++) {
@@ -48,7 +51,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
&info->pVertexAttributeDescriptions[i];
const struct anv_format *format = anv_format_for_vk_format(desc->format);
- struct GEN8_VERTEX_ELEMENT_STATE element = {
+ struct GENX(VERTEX_ELEMENT_STATE) element = {
.VertexBufferIndex = desc->binding,
.Valid = true,
.SourceElementFormat = format->surface_format,
@@ -59,9 +62,9 @@ emit_vertex_input(struct anv_pipeline *pipeline,
.Component2Control = format->num_channels >= 3 ? VFCOMP_STORE_SRC : VFCOMP_STORE_0,
.Component3Control = format->num_channels >= 4 ? VFCOMP_STORE_SRC : VFCOMP_STORE_1_FP
};
- GEN8_VERTEX_ELEMENT_STATE_pack(NULL, &p[1 + i * 2], &element);
+ GENX(VERTEX_ELEMENT_STATE_pack)(NULL, &p[1 + i * 2], &element);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_INSTANCING,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_INSTANCING),
.InstancingEnable = pipeline->instancing_enable[desc->binding],
.VertexElementIndex = i,
/* Vulkan so far doesn't have an instance divisor, so
@@ -69,7 +72,7 @@ emit_vertex_input(struct anv_pipeline *pipeline,
.InstanceDataStepRate = 1);
}
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_SGVS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_SGVS),
.VertexIDEnable = pipeline->vs_prog_data.uses_vertexid,
.VertexIDComponentNumber = 2,
.VertexIDElementOffset = info->bindingCount,
@@ -83,7 +86,7 @@ emit_ia_state(struct anv_pipeline *pipeline,
const VkPipelineInputAssemblyStateCreateInfo *info,
const struct anv_graphics_pipeline_create_info *extra)
{
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_TOPOLOGY,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_TOPOLOGY),
.PrimitiveTopologyType = pipeline->topology);
}
@@ -110,8 +113,8 @@ emit_rs_state(struct anv_pipeline *pipeline,
[VK_FRONT_FACE_CW] = Clockwise
};
- struct GEN8_3DSTATE_SF sf = {
- GEN8_3DSTATE_SF_header,
+ struct GENX(3DSTATE_SF) sf = {
+ GENX(3DSTATE_SF_header),
.ViewportTransformEnable = !(extra && extra->disable_viewport),
.TriangleStripListProvokingVertexSelect = 0,
.LineStripListProvokingVertexSelect = 0,
@@ -122,19 +125,25 @@ emit_rs_state(struct anv_pipeline *pipeline,
/* FINISHME: VkBool32 rasterizerDiscardEnable; */
- GEN8_3DSTATE_SF_pack(NULL, pipeline->gen8.sf, &sf);
+ GENX(3DSTATE_SF_pack)(NULL, pipeline->gen8.sf, &sf);
- struct GEN8_3DSTATE_RASTER raster = {
- GEN8_3DSTATE_RASTER_header,
+ struct GENX(3DSTATE_RASTER) raster = {
+ GENX(3DSTATE_RASTER_header),
.FrontWinding = vk_to_gen_front_face[info->frontFace],
.CullMode = vk_to_gen_cullmode[info->cullMode],
.FrontFaceFillMode = vk_to_gen_fillmode[info->fillMode],
.BackFaceFillMode = vk_to_gen_fillmode[info->fillMode],
.ScissorRectangleEnable = !(extra && extra->disable_scissor),
+#if ANV_GEN == 8
.ViewportZClipTestEnable = info->depthClipEnable
+#else
+ /* GEN9+ splits ViewportZClipTestEnable into near and far enable bits */
+ .ViewportZFarClipTestEnable = info->depthClipEnable,
+ .ViewportZNearClipTestEnable = info->depthClipEnable,
+#endif
};
- GEN8_3DSTATE_RASTER_pack(NULL, pipeline->gen8.raster, &raster);
+ GENX(3DSTATE_RASTER_pack)(NULL, pipeline->gen8.raster, &raster);
}
static void
@@ -192,11 +201,11 @@ emit_cb_state(struct anv_pipeline *pipeline,
[VK_BLEND_OP_MAX] = BLENDFUNCTION_MAX,
};
- uint32_t num_dwords = GEN8_BLEND_STATE_length;
+ uint32_t num_dwords = GENX(BLEND_STATE_length);
pipeline->blend_state =
anv_state_pool_alloc(&device->dynamic_state_pool, num_dwords * 4, 64);
- struct GEN8_BLEND_STATE blend_state = {
+ struct GENX(BLEND_STATE) blend_state = {
.AlphaToCoverageEnable = info->alphaToCoverageEnable,
.AlphaToOneEnable = info->alphaToOneEnable,
};
@@ -210,7 +219,7 @@ emit_cb_state(struct anv_pipeline *pipeline,
blend_state.IndependentAlphaBlendEnable = true;
}
- blend_state.Entry[i] = (struct GEN8_BLEND_STATE_ENTRY) {
+ blend_state.Entry[i] = (struct GENX(BLEND_STATE_ENTRY)) {
.LogicOpEnable = info->logicOpEnable,
.LogicOpFunction = vk_to_gen_logic_op[info->logicOp],
.ColorBufferBlendEnable = a->blendEnable,
@@ -248,9 +257,9 @@ emit_cb_state(struct anv_pipeline *pipeline,
}
}
- GEN8_BLEND_STATE_pack(NULL, pipeline->blend_state.map, &blend_state);
+ GENX(BLEND_STATE_pack)(NULL, pipeline->blend_state.map, &blend_state);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_BLEND_STATE_POINTERS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_BLEND_STATE_POINTERS),
.BlendStatePointer = pipeline->blend_state.offset,
.BlendStatePointerValid = true);
}
@@ -285,6 +294,7 @@ emit_ds_state(struct anv_pipeline *pipeline,
/* We're going to OR this together with the dynamic state. We need
* to make sure it's initialized to something useful.
*/
+ /* FIXME: gen9 wm_depth_stencil */
memset(pipeline->gen8.wm_depth_stencil, 0,
sizeof(pipeline->gen8.wm_depth_stencil));
return;
@@ -292,7 +302,7 @@ emit_ds_state(struct anv_pipeline *pipeline,
/* VkBool32 depthBoundsTestEnable; // optional (depth_bounds_test) */
- struct GEN8_3DSTATE_WM_DEPTH_STENCIL wm_depth_stencil = {
+ struct GENX(3DSTATE_WM_DEPTH_STENCIL) wm_depth_stencil = {
.DepthTestEnable = info->depthTestEnable,
.DepthBufferWriteEnable = info->depthWriteEnable,
.DepthTestFunction = vk_to_gen_compare_op[info->depthCompareOp],
@@ -309,11 +319,11 @@ emit_ds_state(struct anv_pipeline *pipeline,
.BackfaceStencilTestFunction = vk_to_gen_compare_op[info->back.stencilCompareOp],
};
- GEN8_3DSTATE_WM_DEPTH_STENCIL_pack(NULL, pipeline->gen8.wm_depth_stencil, &wm_depth_stencil);
+ GENX(3DSTATE_WM_DEPTH_STENCIL_pack)(NULL, pipeline->gen8.wm_depth_stencil, &wm_depth_stencil);
}
VkResult
-gen8_graphics_pipeline_create(
+genX(graphics_pipeline_create)(
VkDevice _device,
const VkGraphicsPipelineCreateInfo* pCreateInfo,
const struct anv_graphics_pipeline_create_info *extra,
@@ -353,34 +363,34 @@ gen8_graphics_pipeline_create(
emit_ds_state(pipeline, pCreateInfo->pDepthStencilState);
emit_cb_state(pipeline, pCreateInfo->pColorBlendState);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VF_STATISTICS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VF_STATISTICS),
.StatisticsEnable = true);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_HS, .Enable = false);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_TE, .TEEnable = false);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_DS, .FunctionEnable = false);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_STREAMOUT, .SOFunctionEnable = false);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_HS), .Enable = false);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_TE), .TEEnable = false);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_DS), .FunctionEnable = false);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_STREAMOUT), .SOFunctionEnable = false);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_VS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PUSH_CONSTANT_ALLOC_VS),
.ConstantBufferOffset = 0,
.ConstantBufferSize = 4);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_GS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PUSH_CONSTANT_ALLOC_GS),
.ConstantBufferOffset = 4,
.ConstantBufferSize = 4);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PUSH_CONSTANT_ALLOC_PS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PUSH_CONSTANT_ALLOC_PS),
.ConstantBufferOffset = 8,
.ConstantBufferSize = 4);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_WM_CHROMAKEY,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_WM_CHROMAKEY),
.ChromaKeyKillEnable = false);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_AA_LINE_PARAMETERS);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_AA_LINE_PARAMETERS));
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_CLIP,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_CLIP),
.ClipEnable = true,
.ViewportXYClipTestEnable = !(extra && extra->disable_viewport),
.MinimumPointWidth = 0.125,
.MaximumPointWidth = 255.875);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_WM,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_WM),
.StatisticsEnable = true,
.LineEndCapAntialiasingRegionWidth = _05pixels,
.LineAntialiasingRegionWidth = _10pixels,
@@ -394,30 +404,30 @@ gen8_graphics_pipeline_create(
uint32_t log2_samples = __builtin_ffs(samples) - 1;
bool enable_sampling = samples > 1 ? true : false;
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_MULTISAMPLE,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_MULTISAMPLE),
.PixelPositionOffsetEnable = enable_sampling,
.PixelLocation = CENTER,
.NumberofMultisamples = log2_samples);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SAMPLE_MASK,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_SAMPLE_MASK),
.SampleMask = 0xffff);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_URB_VS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_VS),
.VSURBStartingAddress = pipeline->urb.vs_start,
.VSURBEntryAllocationSize = pipeline->urb.vs_size - 1,
.VSNumberofURBEntries = pipeline->urb.nr_vs_entries);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_URB_GS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_GS),
.GSURBStartingAddress = pipeline->urb.gs_start,
.GSURBEntryAllocationSize = pipeline->urb.gs_size - 1,
.GSNumberofURBEntries = pipeline->urb.nr_gs_entries);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_URB_HS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_HS),
.HSURBStartingAddress = pipeline->urb.vs_start,
.HSURBEntryAllocationSize = 0,
.HSNumberofURBEntries = 0);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_URB_DS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_URB_DS),
.DSURBStartingAddress = pipeline->urb.vs_start,
.DSURBEntryAllocationSize = 0,
.DSNumberofURBEntries = 0);
@@ -427,9 +437,9 @@ gen8_graphics_pipeline_create(
length = (gs_prog_data->base.vue_map.num_slots + 1) / 2 - offset;
if (pipeline->gs_vec4 == NO_KERNEL)
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_GS, .Enable = false);
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS), .Enable = false);
else
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_GS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_GS),
.SingleProgramFlow = false,
.KernelStartPointer = pipeline->gs_vec4,
.VectorMaskEnable = Dmask,
@@ -475,14 +485,14 @@ gen8_graphics_pipeline_create(
length = (vue_prog_data->vue_map.num_slots + 1) / 2 - offset;
if (pipeline->vs_simd8 == NO_KERNEL || (extra && extra->disable_vs))
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VS),
.FunctionEnable = false,
/* Even if VS is disabled, SBE still gets the amount of
* vertex data to read from this field. */
.VertexURBEntryOutputReadOffset = offset,
.VertexURBEntryOutputLength = length);
else
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_VS,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_VS),
.KernelStartPointer = pipeline->vs_simd8,
.SingleVertexDispatch = Multiple,
.VectorMaskEnable = Dmask,
@@ -525,8 +535,8 @@ gen8_graphics_pipeline_create(
else
fs_input_map = &gs_prog_data->base.vue_map;
- struct GEN8_3DSTATE_SBE_SWIZ swiz = {
- GEN8_3DSTATE_SBE_SWIZ_header,
+ struct GENX(3DSTATE_SBE_SWIZ) swiz = {
+ GENX(3DSTATE_SBE_SWIZ_header),
};
int max_source_attr = 0;
@@ -548,20 +558,59 @@ gen8_graphics_pipeline_create(
swiz.Attribute[input_index].SourceAttribute = source_attr;
}
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_SBE,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_SBE),
.AttributeSwizzleEnable = true,
.ForceVertexURBEntryReadLength = false,
.ForceVertexURBEntryReadOffset = false,
.VertexURBEntryReadLength = DIV_ROUND_UP(max_source_attr + 1, 2),
.PointSpriteTextureCoordinateOrigin = UPPERLEFT,
.NumberofSFOutputAttributes =
- wm_prog_data->num_varying_inputs);
+ wm_prog_data->num_varying_inputs,
+
+#if ANV_GEN >= 9
+ .Attribute0ActiveComponentFormat = ACF_XYZW,
+ .Attribute1ActiveComponentFormat = ACF_XYZW,
+ .Attribute2ActiveComponentFormat = ACF_XYZW,
+ .Attribute3ActiveComponentFormat = ACF_XYZW,
+ .Attribute4ActiveComponentFormat = ACF_XYZW,
+ .Attribute5ActiveComponentFormat = ACF_XYZW,
+ .Attribute6ActiveComponentFormat = ACF_XYZW,
+ .Attribute7ActiveComponentFormat = ACF_XYZW,
+ .Attribute8ActiveComponentFormat = ACF_XYZW,
+ .Attribute9ActiveComponentFormat = ACF_XYZW,
+ .Attribute10ActiveComponentFormat = ACF_XYZW,
+ .Attribute11ActiveComponentFormat = ACF_XYZW,
+ .Attribute12ActiveComponentFormat = ACF_XYZW,
+ .Attribute13ActiveComponentFormat = ACF_XYZW,
+ .Attribute14ActiveComponentFormat = ACF_XYZW,
+ .Attribute15ActiveComponentFormat = ACF_XYZW,
+ /* wow, much field, very attribute */
+ .Attribute16ActiveComponentFormat = ACF_XYZW,
+ .Attribute17ActiveComponentFormat = ACF_XYZW,
+ .Attribute18ActiveComponentFormat = ACF_XYZW,
+ .Attribute19ActiveComponentFormat = ACF_XYZW,
+ .Attribute20ActiveComponentFormat = ACF_XYZW,
+ .Attribute21ActiveComponentFormat = ACF_XYZW,
+ .Attribute22ActiveComponentFormat = ACF_XYZW,
+ .Attribute23ActiveComponentFormat = ACF_XYZW,
+ .Attribute24ActiveComponentFormat = ACF_XYZW,
+ .Attribute25ActiveComponentFormat = ACF_XYZW,
+ .Attribute26ActiveComponentFormat = ACF_XYZW,
+ .Attribute27ActiveComponentFormat = ACF_XYZW,
+ .Attribute28ActiveComponentFormat = ACF_XYZW,
+ .Attribute29ActiveComponentFormat = ACF_XYZW,
+ .Attribute28ActiveComponentFormat = ACF_XYZW,
+ .Attribute29ActiveComponentFormat = ACF_XYZW,
+ .Attribute30ActiveComponentFormat = ACF_XYZW,
+#endif
+ );
uint32_t *dw = anv_batch_emit_dwords(&pipeline->batch,
- GEN8_3DSTATE_SBE_SWIZ_length);
- GEN8_3DSTATE_SBE_SWIZ_pack(&pipeline->batch, dw, &swiz);
+ GENX(3DSTATE_SBE_SWIZ_length));
+ GENX(3DSTATE_SBE_SWIZ_pack)(&pipeline->batch, dw, &swiz);
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PS,
+ const int num_thread_bias = ANV_GEN == 8 ? 2 : 1;
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS),
.KernelStartPointer0 = pipeline->ps_ksp0,
.SingleProgramFlow = false,
@@ -571,7 +620,7 @@ gen8_graphics_pipeline_create(
.ScratchSpaceBasePointer = pipeline->scratch_start[VK_SHADER_STAGE_FRAGMENT],
.PerThreadScratchSpace = ffs(wm_prog_data->base.total_scratch / 2048),
- .MaximumNumberofThreadsPerPSD = 64 - 2,
+ .MaximumNumberofThreadsPerPSD = 64 - num_thread_bias,
.PositionXYOffsetSelect = wm_prog_data->uses_pos_offset ?
POSOFFSET_SAMPLE: POSOFFSET_NONE,
.PushConstantEnable = wm_prog_data->base.nr_params > 0,
@@ -587,20 +636,25 @@ gen8_graphics_pipeline_create(
.KernelStartPointer2 = pipeline->ps_ksp2);
bool per_sample_ps = false;
- anv_batch_emit(&pipeline->batch, GEN8_3DSTATE_PS_EXTRA,
+ anv_batch_emit(&pipeline->batch, GENX(3DSTATE_PS_EXTRA),
.PixelShaderValid = true,
.PixelShaderKillsPixel = wm_prog_data->uses_kill,
.PixelShaderComputedDepthMode = wm_prog_data->computed_depth_mode,
.AttributeEnable = wm_prog_data->num_varying_inputs > 0,
.oMaskPresenttoRenderTarget = wm_prog_data->uses_omask,
- .PixelShaderIsPerSample = per_sample_ps);
+ .PixelShaderIsPerSample = per_sample_ps,
+#if ANV_GEN >= 9
+ .PixelShaderPullsBary = wm_prog_data->pulls_bary,
+ .InputCoverageMaskState = ICMS_NONE
+#endif
+ );
*pPipeline = anv_pipeline_to_handle(pipeline);
return VK_SUCCESS;
}
-VkResult gen8_compute_pipeline_create(
+VkResult genX(compute_pipeline_create)(
VkDevice _device,
const VkComputePipelineCreateInfo* pCreateInfo,
VkPipeline* pPipeline)
@@ -654,7 +708,7 @@ VkResult gen8_compute_pipeline_create(
const struct brw_cs_prog_data *cs_prog_data = &pipeline->cs_prog_data;
- anv_batch_emit(&pipeline->batch, GEN8_MEDIA_VFE_STATE,
+ anv_batch_emit(&pipeline->batch, GENX(MEDIA_VFE_STATE),
.ScratchSpaceBasePointer = pipeline->scratch_start[VK_SHADER_STAGE_COMPUTE],
.PerThreadScratchSpace = ffs(cs_prog_data->base.total_scratch / 2048),
.ScratchSpaceBasePointerHigh = 0,
@@ -663,7 +717,9 @@ VkResult gen8_compute_pipeline_create(
.MaximumNumberofThreads = device->info.max_cs_threads - 1,
.NumberofURBEntries = 2,
.ResetGatewayTimer = true,
+#if ANV_GEN == 8
.BypassGatewayControl = true,
+#endif
.URBEntryAllocationSize = 2,
.CURBEAllocationSize = 0);