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 VKAPI
vkCreateShader(
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 for (uint32_t i
= 0; i
< info
->bindingCount
; i
++) {
67 const VkVertexInputBindingDescription
*desc
=
68 &info
->pVertexBindingDescriptions
[i
];
70 pipeline
->binding_stride
[desc
->binding
] = desc
->strideInBytes
;
72 /* Step rate is programmed per vertex element (attribute), not
73 * binding. Set up a map of which bindings step per instance, for
74 * reference by vertex element setup. */
75 switch (desc
->stepRate
) {
77 case VK_VERTEX_INPUT_STEP_RATE_VERTEX
:
78 instancing_enable
[desc
->binding
] = false;
80 case VK_VERTEX_INPUT_STEP_RATE_INSTANCE
:
81 instancing_enable
[desc
->binding
] = true;
86 p
= anv_batch_emitn(&pipeline
->batch
, num_dwords
,
87 GEN8_3DSTATE_VERTEX_ELEMENTS
);
89 for (uint32_t i
= 0; i
< info
->attributeCount
; i
++) {
90 const VkVertexInputAttributeDescription
*desc
=
91 &info
->pVertexAttributeDescriptions
[i
];
92 const struct anv_format
*format
= anv_format_for_vk_format(desc
->format
);
94 struct GEN8_VERTEX_ELEMENT_STATE element
= {
95 .VertexBufferIndex
= desc
->location
,
97 .SourceElementFormat
= format
->format
,
98 .EdgeFlagEnable
= false,
99 .SourceElementOffset
= desc
->offsetInBytes
,
100 .Component0Control
= VFCOMP_STORE_SRC
,
101 .Component1Control
= format
->channels
>= 2 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_0
,
102 .Component2Control
= format
->channels
>= 3 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_0
,
103 .Component3Control
= format
->channels
>= 4 ? VFCOMP_STORE_SRC
: VFCOMP_STORE_1_FP
105 GEN8_VERTEX_ELEMENT_STATE_pack(NULL
, &p
[1 + i
* 2], &element
);
107 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_INSTANCING
,
108 .InstancingEnable
= instancing_enable
[desc
->binding
],
109 .VertexElementIndex
= i
,
110 /* Vulkan so far doesn't have an instance divisor, so
111 * this is always 1 (ignored if not instancing). */
112 .InstanceDataStepRate
= 1);
115 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_SGVS
,
116 .VertexIDEnable
= pipeline
->vs_prog_data
.uses_vertexid
,
117 .VertexIDComponentNumber
= 2,
118 .VertexIDElementOffset
= info
->bindingCount
,
119 .InstanceIDEnable
= pipeline
->vs_prog_data
.uses_instanceid
,
120 .InstanceIDComponentNumber
= 3,
121 .InstanceIDElementOffset
= info
->bindingCount
);
125 emit_ia_state(struct anv_pipeline
*pipeline
, VkPipelineIaStateCreateInfo
*info
)
127 static const uint32_t vk_to_gen_primitive_type
[] = {
128 [VK_PRIMITIVE_TOPOLOGY_POINT_LIST
] = _3DPRIM_POINTLIST
,
129 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST
] = _3DPRIM_LINELIST
,
130 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP
] = _3DPRIM_LINESTRIP
,
131 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
] = _3DPRIM_TRILIST
,
132 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP
] = _3DPRIM_TRISTRIP
,
133 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_FAN
] = _3DPRIM_TRIFAN
,
134 [VK_PRIMITIVE_TOPOLOGY_LINE_LIST_ADJ
] = _3DPRIM_LINELIST_ADJ
,
135 [VK_PRIMITIVE_TOPOLOGY_LINE_STRIP_ADJ
] = _3DPRIM_LISTSTRIP_ADJ
,
136 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST_ADJ
] = _3DPRIM_TRILIST_ADJ
,
137 [VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP_ADJ
] = _3DPRIM_TRISTRIP_ADJ
,
138 [VK_PRIMITIVE_TOPOLOGY_PATCH
] = _3DPRIM_PATCHLIST_1
141 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF
,
142 .IndexedDrawCutIndexEnable
= info
->primitiveRestartEnable
,
143 .CutIndex
= info
->primitiveRestartIndex
);
144 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VF_TOPOLOGY
,
145 .PrimitiveTopologyType
= vk_to_gen_primitive_type
[info
->topology
]);
149 emit_rs_state(struct anv_pipeline
*pipeline
, VkPipelineRsStateCreateInfo
*info
)
151 static const uint32_t vk_to_gen_cullmode
[] = {
152 [VK_CULL_MODE_NONE
] = CULLMODE_NONE
,
153 [VK_CULL_MODE_FRONT
] = CULLMODE_FRONT
,
154 [VK_CULL_MODE_BACK
] = CULLMODE_BACK
,
155 [VK_CULL_MODE_FRONT_AND_BACK
] = CULLMODE_BOTH
158 static const uint32_t vk_to_gen_fillmode
[] = {
159 [VK_FILL_MODE_POINTS
] = RASTER_POINT
,
160 [VK_FILL_MODE_WIREFRAME
] = RASTER_WIREFRAME
,
161 [VK_FILL_MODE_SOLID
] = RASTER_SOLID
164 static const uint32_t vk_to_gen_front_face
[] = {
165 [VK_FRONT_FACE_CCW
] = CounterClockwise
,
166 [VK_FRONT_FACE_CW
] = Clockwise
169 static const uint32_t vk_to_gen_coordinate_origin
[] = {
170 [VK_COORDINATE_ORIGIN_UPPER_LEFT
] = UPPERLEFT
,
171 [VK_COORDINATE_ORIGIN_LOWER_LEFT
] = LOWERLEFT
174 struct GEN8_3DSTATE_SF sf
= {
175 GEN8_3DSTATE_SF_header
,
176 .ViewportTransformEnable
= true,
177 .TriangleStripListProvokingVertexSelect
=
178 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 2,
179 .LineStripListProvokingVertexSelect
=
180 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 1,
181 .TriangleFanProvokingVertexSelect
=
182 info
->provokingVertex
== VK_PROVOKING_VERTEX_FIRST
? 0 : 2,
183 .PointWidthSource
= info
->programPointSize
? Vertex
: State
,
186 /* bool32_t rasterizerDiscardEnable; */
189 GEN8_3DSTATE_SF_pack(NULL
, pipeline
->state_sf
, &sf
);
191 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_RASTER
,
192 .FrontWinding
= vk_to_gen_front_face
[info
->frontFace
],
193 .CullMode
= vk_to_gen_cullmode
[info
->cullMode
],
194 .FrontFaceFillMode
= vk_to_gen_fillmode
[info
->fillMode
],
195 .BackFaceFillMode
= vk_to_gen_fillmode
[info
->fillMode
],
196 .ScissorRectangleEnable
= true,
197 .ViewportZClipTestEnable
= info
->depthClipEnable
);
199 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_SBE
,
200 .ForceVertexURBEntryReadLength
= false,
201 .ForceVertexURBEntryReadOffset
= false,
202 .PointSpriteTextureCoordinateOrigin
=
203 vk_to_gen_coordinate_origin
[info
->pointOrigin
],
204 .NumberofSFOutputAttributes
=
205 pipeline
->wm_prog_data
.num_varying_inputs
);
209 VkResult VKAPI
vkCreateGraphicsPipeline(
211 const VkGraphicsPipelineCreateInfo
* pCreateInfo
,
212 VkPipeline
* pPipeline
)
214 struct anv_device
*device
= (struct anv_device
*) _device
;
215 struct anv_pipeline
*pipeline
;
216 const struct anv_common
*common
;
217 VkPipelineShaderStageCreateInfo
*shader_create_info
;
218 VkPipelineIaStateCreateInfo
*ia_info
;
219 VkPipelineRsStateCreateInfo
*rs_info
;
220 VkPipelineVertexInputCreateInfo
*vi_info
;
222 uint32_t offset
, length
;
224 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
);
226 pipeline
= anv_device_alloc(device
, sizeof(*pipeline
), 8,
227 VK_SYSTEM_ALLOC_TYPE_API_OBJECT
);
228 if (pipeline
== NULL
)
229 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
231 pipeline
->device
= device
;
232 pipeline
->layout
= (struct anv_pipeline_layout
*) pCreateInfo
->layout
;
233 memset(pipeline
->shaders
, 0, sizeof(pipeline
->shaders
));
234 result
= anv_batch_init(&pipeline
->batch
, device
);
235 if (result
!= VK_SUCCESS
)
238 for (common
= pCreateInfo
->pNext
; common
; common
= common
->pNext
) {
239 switch (common
->sType
) {
240 case VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_CREATE_INFO
:
241 vi_info
= (VkPipelineVertexInputCreateInfo
*) common
;
243 case VK_STRUCTURE_TYPE_PIPELINE_IA_STATE_CREATE_INFO
:
244 ia_info
= (VkPipelineIaStateCreateInfo
*) common
;
246 case VK_STRUCTURE_TYPE_PIPELINE_TESS_STATE_CREATE_INFO
:
247 case VK_STRUCTURE_TYPE_PIPELINE_VP_STATE_CREATE_INFO
:
249 case VK_STRUCTURE_TYPE_PIPELINE_RS_STATE_CREATE_INFO
:
250 rs_info
= (VkPipelineRsStateCreateInfo
*) common
;
252 case VK_STRUCTURE_TYPE_PIPELINE_MS_STATE_CREATE_INFO
:
253 case VK_STRUCTURE_TYPE_PIPELINE_CB_STATE_CREATE_INFO
:
254 case VK_STRUCTURE_TYPE_PIPELINE_DS_STATE_CREATE_INFO
:
255 case VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO
:
256 shader_create_info
= (VkPipelineShaderStageCreateInfo
*) common
;
257 pipeline
->shaders
[shader_create_info
->shader
.stage
] =
258 (struct anv_shader
*) shader_create_info
->shader
.shader
;
265 pipeline
->use_repclear
= false;
267 anv_compiler_run(device
->compiler
, pipeline
);
269 emit_vertex_input(pipeline
, vi_info
);
270 emit_ia_state(pipeline
, ia_info
);
271 emit_rs_state(pipeline
, rs_info
);
273 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_WM
,
274 .StatisticsEnable
= true,
275 .LineEndCapAntialiasingRegionWidth
= _05pixels
,
276 .LineAntialiasingRegionWidth
= _10pixels
,
277 .EarlyDepthStencilControl
= NORMAL
,
278 .ForceThreadDispatchEnable
= NORMAL
,
279 .PointRasterizationRule
= RASTRULE_UPPER_RIGHT
,
280 .BarycentricInterpolationMode
=
281 pipeline
->wm_prog_data
.barycentric_interp_modes
);
283 uint32_t samples
= 1;
284 uint32_t log2_samples
= __builtin_ffs(samples
) - 1;
285 bool enable_sampling
= samples
> 1 ? true : false;
287 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_MULTISAMPLE
,
288 .PixelPositionOffsetEnable
= enable_sampling
,
289 .PixelLocation
= CENTER
,
290 .NumberofMultisamples
= log2_samples
);
292 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_VS
,
293 .VSURBStartingAddress
= pipeline
->urb
.vs_start
,
294 .VSURBEntryAllocationSize
= pipeline
->urb
.vs_size
- 1,
295 .VSNumberofURBEntries
= pipeline
->urb
.nr_vs_entries
);
297 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_GS
,
298 .GSURBStartingAddress
= pipeline
->urb
.gs_start
,
299 .GSURBEntryAllocationSize
= pipeline
->urb
.gs_size
- 1,
300 .GSNumberofURBEntries
= pipeline
->urb
.nr_gs_entries
);
302 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_HS
,
303 .HSURBStartingAddress
= pipeline
->urb
.vs_start
,
304 .HSURBEntryAllocationSize
= 0,
305 .HSNumberofURBEntries
= 0);
307 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_URB_DS
,
308 .DSURBStartingAddress
= pipeline
->urb
.vs_start
,
309 .DSURBEntryAllocationSize
= 0,
310 .DSNumberofURBEntries
= 0);
312 const struct brw_gs_prog_data
*gs_prog_data
= &pipeline
->gs_prog_data
;
314 length
= (gs_prog_data
->base
.vue_map
.num_slots
+ 1) / 2 - offset
;
316 if (pipeline
->gs_vec4
== NO_KERNEL
)
317 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_GS
, .Enable
= false);
319 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_GS
,
320 .SingleProgramFlow
= false,
321 .KernelStartPointer
= pipeline
->gs_vec4
,
322 .VectorMaskEnable
= Vmask
,
324 .BindingTableEntryCount
= 0,
325 .ExpectedVertexCount
= pipeline
->gs_vertex_count
,
327 .PerThreadScratchSpace
= 0,
328 .ScratchSpaceBasePointer
= 0,
330 .OutputVertexSize
= gs_prog_data
->output_vertex_size_hwords
* 2 - 1,
331 .OutputTopology
= gs_prog_data
->output_topology
,
332 .VertexURBEntryReadLength
= gs_prog_data
->base
.urb_read_length
,
333 .DispatchGRFStartRegisterForURBData
=
334 gs_prog_data
->base
.base
.dispatch_grf_start_reg
,
336 .MaximumNumberofThreads
= device
->info
.max_gs_threads
,
337 .ControlDataHeaderSize
= gs_prog_data
->control_data_header_size_hwords
,
338 //pipeline->gs_prog_data.dispatch_mode |
339 .StatisticsEnable
= true,
340 .IncludePrimitiveID
= gs_prog_data
->include_primitive_id
,
341 .ReorderMode
= TRAILING
,
344 .ControlDataFormat
= gs_prog_data
->control_data_format
,
346 /* FIXME: mesa sets this based on ctx->Transform.ClipPlanesEnabled:
347 * UserClipDistanceClipTestEnableBitmask_3DSTATE_GS(v)
348 * UserClipDistanceCullTestEnableBitmask(v)
351 .VertexURBEntryOutputReadOffset
= offset
,
352 .VertexURBEntryOutputLength
= length
);
354 //trp_generate_blend_hw_cmds(batch, pipeline);
356 const struct brw_vue_prog_data
*vue_prog_data
= &pipeline
->vs_prog_data
.base
;
357 /* Skip the VUE header and position slots */
359 length
= (vue_prog_data
->vue_map
.num_slots
+ 1) / 2 - offset
;
361 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_VS
,
362 .KernelStartPointer
= pipeline
->vs_simd8
,
363 .SingleVertexDispatch
= Multiple
,
364 .VectorMaskEnable
= Dmask
,
366 .BindingTableEntryCount
=
367 vue_prog_data
->base
.binding_table
.size_bytes
/ 4,
368 .ThreadDispatchPriority
= Normal
,
369 .FloatingPointMode
= IEEE754
,
370 .IllegalOpcodeExceptionEnable
= false,
371 .AccessesUAV
= false,
372 .SoftwareExceptionEnable
= false,
374 /* FIXME: pointer needs to be assigned outside as it aliases
375 * PerThreadScratchSpace.
377 .ScratchSpaceBasePointer
= 0,
378 .PerThreadScratchSpace
= 0,
380 .DispatchGRFStartRegisterForURBData
=
381 vue_prog_data
->base
.dispatch_grf_start_reg
,
382 .VertexURBEntryReadLength
= vue_prog_data
->urb_read_length
,
383 .VertexURBEntryReadOffset
= 0,
385 .MaximumNumberofThreads
= device
->info
.max_vs_threads
- 1,
386 .StatisticsEnable
= false,
387 .SIMD8DispatchEnable
= true,
388 .VertexCacheDisable
= ia_info
->disableVertexReuse
,
389 .FunctionEnable
= true,
391 .VertexURBEntryOutputReadOffset
= offset
,
392 .VertexURBEntryOutputLength
= length
,
393 .UserClipDistanceClipTestEnableBitmask
= 0,
394 .UserClipDistanceCullTestEnableBitmask
= 0);
396 const struct brw_wm_prog_data
*wm_prog_data
= &pipeline
->wm_prog_data
;
397 uint32_t ksp0
, ksp2
, grf_start0
, grf_start2
;
401 if (pipeline
->ps_simd8
!= NO_KERNEL
) {
402 ksp0
= pipeline
->ps_simd8
;
403 grf_start0
= wm_prog_data
->base
.dispatch_grf_start_reg
;
404 if (pipeline
->ps_simd16
!= NO_KERNEL
) {
405 ksp2
= pipeline
->ps_simd16
;
406 grf_start2
= wm_prog_data
->dispatch_grf_start_reg_16
;
408 } else if (pipeline
->ps_simd16
!= NO_KERNEL
) {
409 ksp0
= pipeline
->ps_simd16
;
410 grf_start0
= wm_prog_data
->dispatch_grf_start_reg_16
;
412 unreachable("no ps shader");
415 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_PS
,
416 .KernelStartPointer0
= ksp0
,
418 .SingleProgramFlow
= false,
419 .VectorMaskEnable
= true,
422 .ScratchSpaceBasePointer
= 0,
423 .PerThreadScratchSpace
= 0,
425 .MaximumNumberofThreadsPerPSD
= 64 - 2,
426 .PositionXYOffsetSelect
= wm_prog_data
->uses_pos_offset
?
427 POSOFFSET_SAMPLE
: POSOFFSET_NONE
,
428 .PushConstantEnable
= wm_prog_data
->base
.nr_params
> 0,
429 ._8PixelDispatchEnable
= pipeline
->ps_simd8
!= NO_KERNEL
,
430 ._16PixelDispatchEnable
= pipeline
->ps_simd16
!= NO_KERNEL
,
431 ._32PixelDispatchEnable
= false,
433 .DispatchGRFStartRegisterForConstantSetupData0
= grf_start0
,
434 .DispatchGRFStartRegisterForConstantSetupData1
= 0,
435 .DispatchGRFStartRegisterForConstantSetupData2
= grf_start2
,
437 .KernelStartPointer1
= 0,
438 .KernelStartPointer2
= ksp2
);
440 bool per_sample_ps
= false;
441 anv_batch_emit(&pipeline
->batch
, GEN8_3DSTATE_PS_EXTRA
,
442 .PixelShaderValid
= true,
443 .PixelShaderKillsPixel
= wm_prog_data
->uses_kill
,
444 .PixelShaderComputedDepthMode
= wm_prog_data
->computed_depth_mode
,
445 .AttributeEnable
= wm_prog_data
->num_varying_inputs
> 0,
446 .oMaskPresenttoRenderTarget
= wm_prog_data
->uses_omask
,
447 .PixelShaderIsPerSample
= per_sample_ps
);
449 *pPipeline
= (VkPipeline
) pipeline
;
454 anv_device_free(device
, pipeline
);
460 anv_pipeline_destroy(struct anv_pipeline
*pipeline
)
462 anv_compiler_free(pipeline
);
463 anv_batch_finish(&pipeline
->batch
, pipeline
->device
);
464 anv_device_free(pipeline
->device
, pipeline
);
469 VkResult VKAPI
vkCreateGraphicsPipelineDerivative(
471 const VkGraphicsPipelineCreateInfo
* pCreateInfo
,
472 VkPipeline basePipeline
,
473 VkPipeline
* pPipeline
)
475 return VK_UNSUPPORTED
;
478 VkResult VKAPI
vkCreateComputePipeline(
480 const VkComputePipelineCreateInfo
* pCreateInfo
,
481 VkPipeline
* pPipeline
)
483 return VK_UNSUPPORTED
;
486 VkResult VKAPI
vkStorePipeline(
492 return VK_UNSUPPORTED
;
495 VkResult VKAPI
vkLoadPipeline(
499 VkPipeline
* pPipeline
)
501 return VK_UNSUPPORTED
;
504 VkResult VKAPI
vkLoadPipelineDerivative(
508 VkPipeline basePipeline
,
509 VkPipeline
* pPipeline
)
511 return VK_UNSUPPORTED
;
514 // Pipeline layout functions
516 VkResult VKAPI
vkCreatePipelineLayout(
518 const VkPipelineLayoutCreateInfo
* pCreateInfo
,
519 VkPipelineLayout
* pPipelineLayout
)
521 struct anv_device
*device
= (struct anv_device
*) _device
;
522 struct anv_pipeline_layout
*layout
;
523 struct anv_pipeline_layout_entry
*entry
;
527 assert(pCreateInfo
->sType
== VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
);
530 for (uint32_t i
= 0; i
< pCreateInfo
->descriptorSetCount
; i
++) {
531 struct anv_descriptor_set_layout
*set_layout
=
532 (struct anv_descriptor_set_layout
*) pCreateInfo
->pSetLayouts
[i
];
533 for (uint32_t j
= 0; j
< set_layout
->count
; j
++)
534 total
+= set_layout
->total
;
537 size
= sizeof(*layout
) + total
* sizeof(layout
->entries
[0]);
538 layout
= anv_device_alloc(device
, size
, 8,
539 VK_SYSTEM_ALLOC_TYPE_API_OBJECT
);
541 return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY
);
543 entry
= layout
->entries
;
544 for (uint32_t s
= 0; s
< VK_NUM_SHADER_STAGE
; s
++) {
545 layout
->stage
[s
].entries
= entry
;
547 for (uint32_t i
= 0; i
< pCreateInfo
->descriptorSetCount
; i
++) {
548 struct anv_descriptor_set_layout
*set_layout
=
549 (struct anv_descriptor_set_layout
*) pCreateInfo
->pSetLayouts
[i
];
550 for (uint32_t j
= 0; j
< set_layout
->count
; j
++)
551 if (set_layout
->bindings
[j
].mask
& (1 << s
)) {
552 entry
->type
= set_layout
->bindings
[j
].type
;
559 layout
->stage
[s
].count
= entry
- layout
->stage
[s
].entries
;
562 *pPipelineLayout
= (VkPipelineLayout
) layout
;