2 * Copyright © 2015 Intel Corporation
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
34 VkResult
anv_CreateShader(
36 const VkShaderCreateInfo
* pCreateInfo
,
39 struct anv_device
*device
= (struct anv_device
*) _device
;
40 struct anv_shader
*shader
;
42 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_SHADER_CREATE_INFO
);
44 shader
= anv_device_alloc(device
, sizeof(*shader
) + pCreateInfo
->codeSize
, 8,
45 VK_SYSTEM_ALLOC_TYPE_API_OBJECT
);
47 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
49 shader
->size
= pCreateInfo
->codeSize
;
50 memcpy(shader
->data
, pCreateInfo
->pCode
, shader
->size
);
52 *pShader
= (VkShader
) shader
;
60 emit_vertex_input(struct anv_pipeline
*pipeline
, VkPipelineVertexInputCreateInfo
*info
)
62 const uint32_t num_dwords
= 1 + info
->attributeCount
* 2;
64 bool instancing_enable
[32];
66 pipeline
->vb_used
= 0;
67 for (uint32_t i
= 0; i
< info
->bindingCount
; i
++) {
68 const VkVertexInputBindingDescription
*desc
=
69 &info
->pVertexBindingDescriptions
[i
];
71 pipeline
->vb_used
|= 1 << desc
->binding
;
72 pipeline
->binding_stride
[desc
->binding
] = desc
->strideInBytes
;
74 /* Step rate is programmed per vertex element (attribute), not
75 * binding. Set up a map of which bindings step per instance, for
76 * reference by vertex element setup. */
77 switch (desc
->stepRate
) {
79 case VK_VERTEX_INPUT_STEP_RATE_VERTEX
:
80 instancing_enable
[desc
->binding
] = false;
82 case VK_VERTEX_INPUT_STEP_RATE_INSTANCE
:
83 instancing_enable
[desc
->binding
] = true;
88 p
= anv_batch_emitn(&pipeline
->batch
, num_dwords
,
89 GEN8_3DSTATE_VERTEX_ELEMENTS
);
91 for (uint32_t i
= 0; i
< info
->attributeCount
; i
++) {
92 const VkVertexInputAttributeDescription
*desc
=
93 &info
->pVertexAttributeDescriptions
[i
];
94 const struct anv_format
*format
= anv_format_for_vk_format(desc
->format
);
96 struct GEN8_VERTEX_ELEMENT_STATE element
= {
97 .VertexBufferIndex
= desc
->binding
,
99 .SourceElementFormat
= format
->format
,
100 .EdgeFlagEnable
= false,
101 .SourceElementOffset
= desc
->offsetInBytes
,
102 .Component0Control
= VFCOMP_STORE_SRC
,
103 .Component1Control
= format
->channels
>= 2 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_0
,
104 .Component2Control
= format
->channels
>= 3 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_0
,
105 .Component3Control
= format
->channels
>= 4 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_1_FP
107 GEN8_VERTEX_ELEMENT_STATE_pack(NULL
, &p
[1 + i
* 2], &element
);
109 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_INSTANCING
,
110 .InstancingEnable
= instancing_enable
[desc
->binding
],
111 .VertexElementIndex
= i
,
112 /* Vulkan so far doesn't have an instance divisor, so
113 * this is always 1 (ignored if not instancing). */
114 .InstanceDataStepRate
= 1);
117 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_SGVS
,
118 .VertexIDEnable
= pipeline
->vs_prog_data
.uses_vertexid
,
119 .VertexIDComponentNumber
= 2,
120 .VertexIDElementOffset
= info
->bindingCount
,
121 .InstanceIDEnable
= pipeline
->vs_prog_data
.uses_instanceid
,
122 .InstanceIDComponentNumber
= 3,
123 .InstanceIDElementOffset
= info
->bindingCount
);
127 emit_ia_state(struct anv_pipeline
*pipeline
,
128 VkPipelineIaStateCreateInfo
*info
,
129 const struct anv_pipeline_create_info
*extra
)
131 static const uint32_t vk_to_gen_primitive_type
[] = {
132 [VK_PRIMITIVE_TOPOLOGY_POINT_LIST
] = _3DPRIM_POINTLIST
,
133 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST
] = _3DPRIM_LINELIST
,
134 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
] = _3DPRIM_LINESTRIP
,
135 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
] = _3DPRIM_TRILIST
,
136 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
] = _3DPRIM_TRISTRIP
,
137 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
] = _3DPRIM_TRIFAN
,
138 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_ADJ
] = _3DPRIM_LINELIST_ADJ
,
139 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ
] = _3DPRIM_LISTSTRIP_ADJ
,
140 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_ADJ
] = _3DPRIM_TRILIST_ADJ
,
141 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ
] = _3DPRIM_TRISTRIP_ADJ
,
142 [VK_PRIMITIVE_TOPOLOGY_PATCH
] = _3DPRIM_PATCHLIST_1
144 uint32_t topology
= vk_to_gen_primitive_type
[info
->topology
];
146 if (extra
&& extra
->use_rectlist
)
147 topology
= _3DPRIM_RECTLIST
;
149 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF
,
150 .IndexedDrawCutIndexEnable
= info
->primitiveRestartEnable
,
151 .CutIndex
= info
->primitiveRestartIndex
);
152 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_TOPOLOGY
,
153 .PrimitiveTopologyType
= topology
);
157 emit_rs_state(struct anv_pipeline
*pipeline
, VkPipelineRsStateCreateInfo
*info
,
158 const struct anv_pipeline_create_info
*extra
)
161 static const uint32_t vk_to_gen_cullmode
[] = {
162 [VK_CULL_MODE_NONE
] = CULLMODE_NONE
,
163 [VK_CULL_MODE_FRONT
] = CULLMODE_FRONT
,
164 [VK_CULL_MODE_BACK
] = CULLMODE_BACK
,
165 [VK_CULL_MODE_FRONT_AND_BACK
] = CULLMODE_BOTH
168 static const uint32_t vk_to_gen_fillmode
[] = {
169 [VK_FILL_MODE_POINTS
] = RASTER_POINT
,
170 [VK_FILL_MODE_WIREFRAME
] = RASTER_WIREFRAME
,
171 [VK_FILL_MODE_SOLID
] = RASTER_SOLID
174 static const uint32_t vk_to_gen_front_face
[] = {
175 [VK_FRONT_FACE_CCW
] = CounterClockwise
,
176 [VK_FRONT_FACE_CW
] = Clockwise
179 static const uint32_t vk_to_gen_coordinate_origin
[] = {
180 [VK_COORDINATE_ORIGIN_UPPER_LEFT
] = UPPERLEFT
,
181 [VK_COORDINATE_ORIGIN_LOWER_LEFT
] = LOWERLEFT
184 struct GEN8_3DSTATE_SF sf
= {
185 GEN8_3DSTATE_SF_header
,
186 .ViewportTransformEnable
= !(extra
&& extra
->disable_viewport
),
187 .TriangleStripListProvokingVertexSelect
=
188 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 2,
189 .LineStripListProvokingVertexSelect
=
190 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 1,
191 .TriangleFanProvokingVertexSelect
=
192 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 2,
193 .PointWidthSource
= info
->programPointSize
? Vertex
: State
,
196 /* bool32_t rasterizerDiscardEnable; */
199 GEN8_3DSTATE_SF_pack(NULL
, pipeline
->state_sf
, &sf
);
201 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_RASTER
,
202 .FrontWinding
= vk_to_gen_front_face
[info
->frontFace
],
203 .CullMode
= vk_to_gen_cullmode
[info
->cullMode
],
204 .FrontFaceFillMode
= vk_to_gen_fillmode
[info
->fillMode
],
205 .BackFaceFillMode
= vk_to_gen_fillmode
[info
->fillMode
],
206 .ScissorRectangleEnable
= !(extra
&& extra
->disable_scissor
),
207 .ViewportZClipTestEnable
= info
->depthClipEnable
);
209 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_SBE
,
210 .ForceVertexURBEntryReadLength
= false,
211 .ForceVertexURBEntryReadOffset
= false,
212 .PointSpriteTextureCoordinateOrigin
=
213 vk_to_gen_coordinate_origin
[info
->pointOrigin
],
214 .NumberofSFOutputAttributes
=
215 pipeline
->wm_prog_data
.num_varying_inputs
);
219 VkResult
anv_CreateGraphicsPipeline(
221 const VkGraphicsPipelineCreateInfo
* pCreateInfo
,
222 VkPipeline
* pPipeline
)
224 return anv_pipeline_create(device
, pCreateInfo
, NULL
, pPipeline
);
231 const VkGraphicsPipelineCreateInfo
* pCreateInfo
,
232 const struct anv_pipeline_create_info
* extra
,
233 VkPipeline
* pPipeline
)
235 struct anv_device
*device
= (struct anv_device
*) _device
;
236 struct anv_pipeline
*pipeline
;
237 const struct anv_common
*common
;
238 VkPipelineShaderStageCreateInfo
*shader_create_info
;
239 VkPipelineIaStateCreateInfo
*ia_info
;
240 VkPipelineRsStateCreateInfo
*rs_info
;
241 VkPipelineVertexInputCreateInfo
*vi_info
;
243 uint32_t offset
, length
;
245 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
);
247 pipeline
= anv_device_alloc(device
, sizeof(*pipeline
), 8,
248 VK_SYSTEM_ALLOC_TYPE_API_OBJECT
);
249 if (pipeline
== NULL
)
250 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
252 pipeline
->device
= device
;
253 pipeline
->layout
= (struct anv_pipeline_layout
*) pCreateInfo
->layout
;
254 memset(pipeline
->shaders
, 0, sizeof(pipeline
->shaders
));
255 result
= anv_batch_init(&pipeline
->batch
, device
);
256 if (result
!= VK_SUCCESS
)
259 anv_state_stream_init(&pipeline
->program_stream
,
260 &device
->instruction_block_pool
);
262 for (common
= pCreateInfo
->pNext
; common
; common
= common
->pNext
) {
263 switch (common
->sType
) {
264 case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO
:
265 vi_info
= (VkPipelineVertexInputCreateInfo
*) common
;
267 case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO
:
268 ia_info
= (VkPipelineIaStateCreateInfo
*) common
;
270 case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO
:
271 case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO
:
273 case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO
:
274 rs_info
= (VkPipelineRsStateCreateInfo
*) common
;
276 case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO
:
277 case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO
:
278 case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO
:
279 case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
:
280 shader_create_info
= (VkPipelineShaderStageCreateInfo
*) common
;
281 pipeline
->shaders
[shader_create_info
->shader
.stage
] =
282 (struct anv_shader
*) shader_create_info
->shader
.shader
;
289 pipeline
->use_repclear
= extra
&& extra
->use_repclear
;
291 anv_compiler_run(device
->compiler
, pipeline
);
293 /* FIXME: The compiler dead-codes FS inputs when we don't have a VS, so we
294 * hard code this to num_attributes - 2. This is because the attributes
295 * include VUE header and position, which aren't counted as varying
297 if (pipeline
->vs_simd8
== NO_KERNEL
)
298 pipeline
->wm_prog_data
.num_varying_inputs
= vi_info
->attributeCount
- 2;
300 emit_vertex_input(pipeline
, vi_info
);
301 emit_ia_state(pipeline
, ia_info
, extra
);
302 emit_rs_state(pipeline
, rs_info
, extra
);
304 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_CLIP
,
306 .ViewportXYClipTestEnable
= !(extra
&& extra
->disable_viewport
));
308 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_WM
,
309 .StatisticsEnable
= true,
310 .LineEndCapAntialiasingRegionWidth
= _05pixels
,
311 .LineAntialiasingRegionWidth
= _10pixels
,
312 .EarlyDepthStencilControl
= NORMAL
,
313 .ForceThreadDispatchEnable
= NORMAL
,
314 .PointRasterizationRule
= RASTRULE_UPPER_RIGHT
,
315 .BarycentricInterpolationMode
=
316 pipeline
->wm_prog_data
.barycentric_interp_modes
);
318 uint32_t samples
= 1;
319 uint32_t log2_samples
= __builtin_ffs(samples
) - 1;
320 bool enable_sampling
= samples
> 1 ? true : false;
322 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_MULTISAMPLE
,
323 .PixelPositionOffsetEnable
= enable_sampling
,
324 .PixelLocation
= CENTER
,
325 .NumberofMultisamples
= log2_samples
);
327 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_VS
,
328 .VSURBStartingAddress
= pipeline
->urb
.vs_start
,
329 .VSURBEntryAllocationSize
= pipeline
->urb
.vs_size
- 1,
330 .VSNumberofURBEntries
= pipeline
->urb
.nr_vs_entries
);
332 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_GS
,
333 .GSURBStartingAddress
= pipeline
->urb
.gs_start
,
334 .GSURBEntryAllocationSize
= pipeline
->urb
.gs_size
- 1,
335 .GSNumberofURBEntries
= pipeline
->urb
.nr_gs_entries
);
337 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_HS
,
338 .HSURBStartingAddress
= pipeline
->urb
.vs_start
,
339 .HSURBEntryAllocationSize
= 0,
340 .HSNumberofURBEntries
= 0);
342 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_DS
,
343 .DSURBStartingAddress
= pipeline
->urb
.vs_start
,
344 .DSURBEntryAllocationSize
= 0,
345 .DSNumberofURBEntries
= 0);
347 const struct brw_gs_prog_data
*gs_prog_data
= &pipeline
->gs_prog_data
;
349 length
= (gs_prog_data
->base
.vue_map
.num_slots
+ 1) / 2 - offset
;
351 if (pipeline
->gs_vec4
== NO_KERNEL
)
352 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_GS
, .Enable
= false);
354 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_GS
,
355 .SingleProgramFlow
= false,
356 .KernelStartPointer
= pipeline
->gs_vec4
,
357 .VectorMaskEnable
= Vmask
,
359 .BindingTableEntryCount
= 0,
360 .ExpectedVertexCount
= pipeline
->gs_vertex_count
,
362 .PerThreadScratchSpace
= 0,
363 .ScratchSpaceBasePointer
= 0,
365 .OutputVertexSize
= gs_prog_data
->output_vertex_size_hwords
* 2 - 1,
366 .OutputTopology
= gs_prog_data
->output_topology
,
367 .VertexURBEntryReadLength
= gs_prog_data
->base
.urb_read_length
,
368 .DispatchGRFStartRegisterForURBData
=
369 gs_prog_data
->base
.base
.dispatch_grf_start_reg
,
371 .MaximumNumberofThreads
= device
->info
.max_gs_threads
,
372 .ControlDataHeaderSize
= gs_prog_data
->control_data_header_size_hwords
,
373 //pipeline->gs_prog_data.dispatch_mode |
374 .StatisticsEnable
= true,
375 .IncludePrimitiveID
= gs_prog_data
->include_primitive_id
,
376 .ReorderMode
= TRAILING
,
379 .ControlDataFormat
= gs_prog_data
->control_data_format
,
381 /* FIXME: mesa sets this based on ctx->Transform.ClipPlanesEnabled:
382 * UserClipDistanceClipTestEnableBitmask_3DSTATE_GS(v)
383 * UserClipDistanceCullTestEnableBitmask(v)
386 .VertexURBEntryOutputReadOffset
= offset
,
387 .VertexURBEntryOutputLength
= length
);
389 //trp_generate_blend_hw_cmds(batch, pipeline);
391 const struct brw_vue_prog_data
*vue_prog_data
= &pipeline
->vs_prog_data
.base
;
392 /* Skip the VUE header and position slots */
394 length
= (vue_prog_data
->vue_map
.num_slots
+ 1) / 2 - offset
;
396 if (pipeline
->vs_simd8
== NO_KERNEL
|| (extra
&& extra
->disable_vs
))
397 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VS
,
398 .FunctionEnable
= false,
399 .VertexURBEntryOutputReadOffset
= 1,
400 /* Even if VS is disabled, SBE still gets the amount of
401 * vertex data to read from this field. We use attribute
402 * count - 1, as we don't count the VUE header here. */
403 .VertexURBEntryOutputLength
=
404 DIV_ROUND_UP(vi_info
->attributeCount
- 1, 2));
406 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VS
,
407 .KernelStartPointer
= pipeline
->vs_simd8
,
408 .SingleVertexDispatch
= Multiple
,
409 .VectorMaskEnable
= Dmask
,
411 .BindingTableEntryCount
=
412 vue_prog_data
->base
.binding_table
.size_bytes
/ 4,
413 .ThreadDispatchPriority
= Normal
,
414 .FloatingPointMode
= IEEE754
,
415 .IllegalOpcodeExceptionEnable
= false,
416 .AccessesUAV
= false,
417 .SoftwareExceptionEnable
= false,
419 /* FIXME: pointer needs to be assigned outside as it aliases
420 * PerThreadScratchSpace.
422 .ScratchSpaceBasePointer
= 0,
423 .PerThreadScratchSpace
= 0,
425 .DispatchGRFStartRegisterForURBData
=
426 vue_prog_data
->base
.dispatch_grf_start_reg
,
427 .VertexURBEntryReadLength
= vue_prog_data
->urb_read_length
,
428 .VertexURBEntryReadOffset
= 0,
430 .MaximumNumberofThreads
= device
->info
.max_vs_threads
- 1,
431 .StatisticsEnable
= false,
432 .SIMD8DispatchEnable
= true,
433 .VertexCacheDisable
= ia_info
->disableVertexReuse
,
434 .FunctionEnable
= true,
436 .VertexURBEntryOutputReadOffset
= offset
,
437 .VertexURBEntryOutputLength
= length
,
438 .UserClipDistanceClipTestEnableBitmask
= 0,
439 .UserClipDistanceCullTestEnableBitmask
= 0);
441 const struct brw_wm_prog_data
*wm_prog_data
= &pipeline
->wm_prog_data
;
442 uint32_t ksp0
, ksp2
, grf_start0
, grf_start2
;
446 if (pipeline
->ps_simd8
!= NO_KERNEL
) {
447 ksp0
= pipeline
->ps_simd8
;
448 grf_start0
= wm_prog_data
->base
.dispatch_grf_start_reg
;
449 if (pipeline
->ps_simd16
!= NO_KERNEL
) {
450 ksp2
= pipeline
->ps_simd16
;
451 grf_start2
= wm_prog_data
->dispatch_grf_start_reg_16
;
453 } else if (pipeline
->ps_simd16
!= NO_KERNEL
) {
454 ksp0
= pipeline
->ps_simd16
;
455 grf_start0
= wm_prog_data
->dispatch_grf_start_reg_16
;
457 unreachable("no ps shader");
460 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_PS
,
461 .KernelStartPointer0
= ksp0
,
463 .SingleProgramFlow
= false,
464 .VectorMaskEnable
= true,
467 .ScratchSpaceBasePointer
= 0,
468 .PerThreadScratchSpace
= 0,
470 .MaximumNumberofThreadsPerPSD
= 64 - 2,
471 .PositionXYOffsetSelect
= wm_prog_data
->uses_pos_offset
?
472 POSOFFSET_SAMPLE
: POSOFFSET_NONE
,
473 .PushConstantEnable
= wm_prog_data
->base
.nr_params
> 0,
474 ._8PixelDispatchEnable
= pipeline
->ps_simd8
!= NO_KERNEL
,
475 ._16PixelDispatchEnable
= pipeline
->ps_simd16
!= NO_KERNEL
,
476 ._32PixelDispatchEnable
= false,
478 .DispatchGRFStartRegisterForConstantSetupData0
= grf_start0
,
479 .DispatchGRFStartRegisterForConstantSetupData1
= 0,
480 .DispatchGRFStartRegisterForConstantSetupData2
= grf_start2
,
482 .KernelStartPointer1
= 0,
483 .KernelStartPointer2
= ksp2
);
485 bool per_sample_ps
= false;
486 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_PS_EXTRA
,
487 .PixelShaderValid
= true,
488 .PixelShaderKillsPixel
= wm_prog_data
->uses_kill
,
489 .PixelShaderComputedDepthMode
= wm_prog_data
->computed_depth_mode
,
490 .AttributeEnable
= wm_prog_data
->num_varying_inputs
> 0,
491 .oMaskPresenttoRenderTarget
= wm_prog_data
->uses_omask
,
492 .PixelShaderIsPerSample
= per_sample_ps
);
494 *pPipeline
= (VkPipeline
) pipeline
;
499 anv_device_free(device
, pipeline
);
505 anv_pipeline_destroy(struct anv_pipeline
*pipeline
)
507 anv_compiler_free(pipeline
);
508 anv_batch_finish(&pipeline
->batch
, pipeline
->device
);
509 anv_device_free(pipeline
->device
, pipeline
);
514 VkResult
anv_CreateGraphicsPipelineDerivative(
516 const VkGraphicsPipelineCreateInfo
* pCreateInfo
,
517 VkPipeline basePipeline
,
518 VkPipeline
* pPipeline
)
520 stub_return(VK_UNSUPPORTED
);
523 VkResult
anv_CreateComputePipeline(
525 const VkComputePipelineCreateInfo
* pCreateInfo
,
526 VkPipeline
* pPipeline
)
528 stub_return(VK_UNSUPPORTED
);
531 VkResult
anv_StorePipeline(
537 stub_return(VK_UNSUPPORTED
);
540 VkResult
anv_LoadPipeline(
544 VkPipeline
* pPipeline
)
546 stub_return(VK_UNSUPPORTED
);
549 VkResult
anv_LoadPipelineDerivative(
553 VkPipeline basePipeline
,
554 VkPipeline
* pPipeline
)
556 stub_return(VK_UNSUPPORTED
);
559 // Pipeline layout functions
561 VkResult
anv_CreatePipelineLayout(
563 const VkPipelineLayoutCreateInfo
* pCreateInfo
,
564 VkPipelineLayout
* pPipelineLayout
)
566 struct anv_device
*device
= (struct anv_device
*) _device
;
567 struct anv_pipeline_layout
*layout
;
569 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
);
571 layout
= anv_device_alloc(device
, sizeof(*layout
), 8,
572 VK_SYSTEM_ALLOC_TYPE_API_OBJECT
);
574 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
576 layout
->num_sets
= pCreateInfo
->descriptorSetCount
;
578 uint32_t surface_start
[VK_NUM_SHADER_STAGE
] = { 0, };
579 uint32_t sampler_start
[VK_NUM_SHADER_STAGE
] = { 0, };
581 for (uint32_t s
= 0; s
< VK_NUM_SHADER_STAGE
; s
++) {
582 layout
->stage
[s
].surface_count
= 0;
583 layout
->stage
[s
].sampler_count
= 0;
586 for (uint32_t i
= 0; i
< pCreateInfo
->descriptorSetCount
; i
++) {
587 struct anv_descriptor_set_layout
*set_layout
=
588 (struct anv_descriptor_set_layout
*) pCreateInfo
->pSetLayouts
[i
];
590 layout
->set
[i
].layout
= set_layout
;
591 for (uint32_t s
= 0; s
< VK_NUM_SHADER_STAGE
; s
++) {
592 layout
->set
[i
].surface_start
[s
] = surface_start
[s
];
593 surface_start
[s
] += set_layout
->stage
[s
].surface_count
;
594 layout
->set
[i
].sampler_start
[s
] = sampler_start
[s
];
595 sampler_start
[s
] += set_layout
->stage
[s
].sampler_count
;
597 layout
->stage
[s
].surface_count
+= set_layout
->stage
[s
].surface_count
;
598 layout
->stage
[s
].sampler_count
+= set_layout
->stage
[s
].sampler_count
;
602 *pPipelineLayout
= (VkPipelineLayout
) layout
;