struct nir_shader *fs_nir,
const VkPipelineVertexInputStateCreateInfo *vi_state,
const VkPipelineDepthStencilStateCreateInfo *ds_state,
- const VkPipelineColorBlendStateCreateInfo *cb_state)
+ const VkPipelineColorBlendStateCreateInfo *cb_state,
+ const VkAllocationCallbacks *alloc)
{
VkDevice device_h = anv_device_to_handle(device);
struct anv_shader_module vs_m = { .nir = vs_nir };
struct anv_shader_module fs_m = { .nir = fs_nir };
- VkShader vs_h;
- ANV_CALL(CreateShader)(device_h,
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&vs_m),
- .pName = "main",
- },
- &vs_h);
-
- VkShader fs_h;
- ANV_CALL(CreateShader)(device_h,
- &(VkShaderCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_SHADER_CREATE_INFO,
- .module = anv_shader_module_to_handle(&fs_m),
- .pName = "main",
- },
- &fs_h);
-
VkPipeline pipeline_h;
anv_graphics_pipeline_create(device_h,
&(VkGraphicsPipelineCreateInfo) {
.pStages = (VkPipelineShaderStageCreateInfo[]) {
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_VERTEX,
- .shader = vs_h,
+ .stage = VK_SHADER_STAGE_VERTEX_BIT,
+ .module = anv_shader_module_to_handle(&vs_m),
+ .pName = "main",
},
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
- .stage = VK_SHADER_STAGE_FRAGMENT,
- .shader = fs_h,
+ .stage = VK_SHADER_STAGE_FRAGMENT_BIT,
+ .module = anv_shader_module_to_handle(&fs_m),
+ .pName = "main",
},
},
.pVertexInputState = vi_state,
.scissorCount = 1,
.pScissors = NULL, /* dynamic */
},
- .pRasterState = &(VkPipelineRasterStateCreateInfo) {
- .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTER_STATE_CREATE_INFO,
- .depthClipEnable = false,
+ .pRasterizationState = &(VkPipelineRasterizationStateCreateInfo) {
+ .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO,
.rasterizerDiscardEnable = false,
- .fillMode = VK_FILL_MODE_SOLID,
+ .polygonMode = VK_POLYGON_MODE_FILL,
.cullMode = VK_CULL_MODE_NONE,
- .frontFace = VK_FRONT_FACE_CCW,
+ .frontFace = VK_FRONT_FACE_COUNTER_CLOCKWISE,
.depthBiasEnable = false,
- .depthClipEnable = false,
},
.pMultisampleState = &(VkPipelineMultisampleStateCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO,
- .rasterSamples = 1, /* FINISHME: Multisampling */
+ .rasterizationSamples = 1, /* FINISHME: Multisampling */
.sampleShadingEnable = false,
.pSampleMask = (VkSampleMask[]) { UINT32_MAX },
+ .alphaToCoverageEnable = false,
+ .alphaToOneEnable = false,
},
.pDepthStencilState = ds_state,
.pColorBlendState = cb_state,
.disable_vs = true,
.use_rectlist = true
},
+ alloc,
&pipeline_h);
- ANV_CALL(DestroyShader)(device_h, vs_h);
- ANV_CALL(DestroyShader)(device_h, fs_h);
-
ralloc_free(vs_nir);
ralloc_free(fs_nir);
const VkPipelineVertexInputStateCreateInfo vi_state = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
- .bindingCount = 1,
+ .vertexBindingDescriptionCount = 1,
.pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) {
{
.binding = 0,
- .strideInBytes = sizeof(struct color_clear_vattrs),
- .stepRate = VK_VERTEX_INPUT_STEP_RATE_VERTEX
+ .stride = sizeof(struct color_clear_vattrs),
+ .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
},
},
- .attributeCount = 3,
+ .vertexAttributeDescriptionCount = 3,
.pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) {
{
/* VUE Header */
.location = 0,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_UINT,
- .offsetInBytes = offsetof(struct color_clear_vattrs, vue_header),
+ .offset = offsetof(struct color_clear_vattrs, vue_header),
},
{
/* Position */
.location = 1,
.binding = 0,
.format = VK_FORMAT_R32G32_SFLOAT,
- .offsetInBytes = offsetof(struct color_clear_vattrs, position),
+ .offset = offsetof(struct color_clear_vattrs, position),
},
{
/* Color */
.location = 2,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
- .offsetInBytes = offsetof(struct color_clear_vattrs, color),
+ .offset = offsetof(struct color_clear_vattrs, color),
},
},
};
const VkPipelineColorBlendStateCreateInfo cb_state = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
- .alphaToCoverageEnable = false,
- .alphaToOneEnable = false,
.logicOpEnable = false,
.attachmentCount = 1,
.pAttachments = (VkPipelineColorBlendAttachmentState []) {
{
.blendEnable = false,
- .channelWriteMask = VK_CHANNEL_A_BIT |
- VK_CHANNEL_R_BIT |
- VK_CHANNEL_G_BIT |
- VK_CHANNEL_B_BIT,
+ .colorWriteMask = VK_COLOR_COMPONENT_A_BIT |
+ VK_COLOR_COMPONENT_R_BIT |
+ VK_COLOR_COMPONENT_G_BIT |
+ VK_COLOR_COMPONENT_B_BIT,
},
},
};
device->meta_state.clear.color_pipeline =
create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state,
- &cb_state);
+ &cb_state, NULL);
}
static void
VkClearColorValue clear_value)
{
struct anv_device *device = cmd_buffer->device;
- VkCmdBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer);
+ VkCommandBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer);
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
VkPipeline pipeline_h =
anv_pipeline_to_handle(device->meta_state.clear.color_pipeline);
ANV_CALL(CmdSetViewport)(cmd_buffer_h, 1,
(VkViewport[]) {
{
- .originX = 0,
- .originY = 0,
+ .x = 0,
+ .y = 0,
.width = fb->width,
.height = fb->height,
.minDepth = 0.0,
const VkPipelineVertexInputStateCreateInfo vi_state = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO,
- .bindingCount = 1,
+ .vertexBindingDescriptionCount = 1,
.pVertexBindingDescriptions = (VkVertexInputBindingDescription[]) {
{
.binding = 0,
- .strideInBytes = sizeof(struct depthstencil_clear_vattrs),
- .stepRate = VK_VERTEX_INPUT_STEP_RATE_VERTEX
+ .stride = sizeof(struct depthstencil_clear_vattrs),
+ .inputRate = VK_VERTEX_INPUT_RATE_VERTEX
},
},
- .attributeCount = 2,
+ .vertexAttributeDescriptionCount = 2,
.pVertexAttributeDescriptions = (VkVertexInputAttributeDescription[]) {
{
/* VUE Header */
.location = 0,
.binding = 0,
.format = VK_FORMAT_R32G32B32A32_UINT,
- .offsetInBytes = offsetof(struct depthstencil_clear_vattrs, vue_header),
+ .offset = offsetof(struct depthstencil_clear_vattrs, vue_header),
},
{
/* Position */
.location = 1,
.binding = 0,
.format = VK_FORMAT_R32G32_SFLOAT,
- .offsetInBytes = offsetof(struct depthstencil_clear_vattrs, position),
+ .offset = offsetof(struct depthstencil_clear_vattrs, position),
},
},
};
.depthBoundsTestEnable = false,
.stencilTestEnable = (aspects & VK_IMAGE_ASPECT_STENCIL_BIT),
.front = {
- .stencilPassOp = VK_STENCIL_OP_REPLACE,
- .stencilCompareOp = VK_COMPARE_OP_ALWAYS,
- .stencilWriteMask = UINT32_MAX,
- .stencilReference = 0, /* dynamic */
+ .passOp = VK_STENCIL_OP_REPLACE,
+ .compareOp = VK_COMPARE_OP_ALWAYS,
+ .writeMask = UINT32_MAX,
+ .reference = 0, /* dynamic */
},
.back = { 0 /* dont care */ },
};
const VkPipelineColorBlendStateCreateInfo cb_state = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO,
- .alphaToCoverageEnable = false,
- .alphaToOneEnable = false,
.logicOpEnable = false,
.attachmentCount = 0,
.pAttachments = NULL,
};
return create_pipeline(device, vs_nir, fs_nir, &vi_state, &ds_state,
- &cb_state);
+ &cb_state, NULL);
}
static void
VkClearDepthStencilValue clear_value)
{
struct anv_device *device = cmd_buffer->device;
- VkCmdBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer);
+ VkCommandBuffer cmd_buffer_h = anv_cmd_buffer_to_handle(cmd_buffer);
const struct anv_framebuffer *fb = cmd_buffer->state.framebuffer;
const struct depthstencil_clear_vattrs vertex_data[3] = {
ANV_CALL(CmdSetViewport)(cmd_buffer_h, 1,
(VkViewport[]) {
{
- .originX = 0,
- .originY = 0,
+ .x = 0,
+ .y = 0,
.width = fb->width,
.height = fb->height,
VkDevice device_h = anv_device_to_handle(device);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.color_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.color_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.depth_only_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.stencil_only_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.stencil_only_pipeline),
+ NULL);
ANV_CALL(DestroyPipeline)(device_h,
- anv_pipeline_to_handle(device->meta_state.clear.depthstencil_pipeline));
+ anv_pipeline_to_handle(device->meta_state.clear.depthstencil_pipeline),
+ NULL);
}
void
{
struct anv_meta_saved_state saved_state;
+ /* Figure out whether or not we actually need to clear anything to avoid
+ * trashing state when clearing is a no-op.
+ */
+ bool needs_clear = false;
+ for (uint32_t a = 0; a < pass->attachment_count; ++a) {
+ struct anv_render_pass_attachment *att = &pass->attachments[a];
+
+ if (anv_format_is_color(att->format)) {
+ if (att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
+ needs_clear = true;
+ break;
+ }
+ } else {
+ if ((att->format->depth_format &&
+ att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) ||
+ (att->format->has_stencil &&
+ att->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR)) {
+ needs_clear = true;
+ break;
+ }
+ }
+ }
+
+ if (!needs_clear)
+ return;
+
meta_clear_begin(&saved_state, cmd_buffer);
for (uint32_t a = 0; a < pass->attachment_count; ++a) {
emit_load_color_clear(cmd_buffer, a, clear_values[a].color);
}
} else {
- VkImageAspectFlags aspects = 0;
+ VkImageAspectFlags clear_aspects = 0;
if (att->format->depth_format &&
att->load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
- aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;
+ clear_aspects |= VK_IMAGE_ASPECT_DEPTH_BIT;
}
if (att->format->has_stencil &&
att->stencil_load_op == VK_ATTACHMENT_LOAD_OP_CLEAR) {
- aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;
+ clear_aspects |= VK_IMAGE_ASPECT_STENCIL_BIT;
}
- emit_load_depthstencil_clear(cmd_buffer, a, aspects,
- clear_values[a].depthStencil);
+ if (clear_aspects) {
+ emit_load_depthstencil_clear(cmd_buffer, a, clear_aspects,
+ clear_values[a].depthStencil);
+ }
}
}
}
void anv_CmdClearColorImage(
- VkCmdBuffer cmdBuffer,
+ VkCommandBuffer commandBuffer,
VkImage _image,
VkImageLayout imageLayout,
const VkClearColorValue* pColor,
uint32_t rangeCount,
const VkImageSubresourceRange* pRanges)
{
- ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, cmdBuffer);
+ ANV_FROM_HANDLE(anv_cmd_buffer, cmd_buffer, commandBuffer);
ANV_FROM_HANDLE(anv_image, image, _image);
struct anv_meta_saved_state saved_state;
meta_clear_begin(&saved_state, cmd_buffer);
for (uint32_t r = 0; r < rangeCount; r++) {
- for (uint32_t l = 0; l < pRanges[r].mipLevels; l++) {
- for (uint32_t s = 0; s < pRanges[r].arraySize; s++) {
+ for (uint32_t l = 0; l < pRanges[r].levelCount; l++) {
+ for (uint32_t s = 0; s < pRanges[r].layerCount; s++) {
struct anv_image_view iview;
anv_image_view_init(&iview, cmd_buffer->device,
&(VkImageViewCreateInfo) {
.image = _image,
.viewType = VK_IMAGE_VIEW_TYPE_2D,
.format = image->format->vk_format,
- .channels = {
- VK_CHANNEL_SWIZZLE_R,
- VK_CHANNEL_SWIZZLE_G,
- VK_CHANNEL_SWIZZLE_B,
- VK_CHANNEL_SWIZZLE_A
- },
.subresourceRange = {
.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
.baseMipLevel = pRanges[r].baseMipLevel + l,
- .mipLevels = 1,
+ .levelCount = 1,
.baseArrayLayer = pRanges[r].baseArrayLayer + s,
- .arraySize = 1
+ .layerCount = 1
},
},
cmd_buffer);
.width = iview.extent.width,
.height = iview.extent.height,
.layers = 1
- }, &fb);
+ }, &cmd_buffer->pool->alloc, &fb);
VkRenderPass pass;
anv_CreateRenderPass(anv_device_to_handle(cmd_buffer->device),
.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO,
.attachmentCount = 1,
.pAttachments = &(VkAttachmentDescription) {
- .sType = VK_STRUCTURE_TYPE_ATTACHMENT_DESCRIPTION,
.format = iview.format->vk_format,
.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD,
.storeOp = VK_ATTACHMENT_STORE_OP_STORE,
},
.subpassCount = 1,
.pSubpasses = &(VkSubpassDescription) {
- .sType = VK_STRUCTURE_TYPE_SUBPASS_DESCRIPTION,
.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS,
- .inputCount = 0,
- .colorCount = 1,
+ .inputAttachmentCount = 0,
+ .colorAttachmentCount = 1,
.pColorAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
.pResolveAttachments = NULL,
- .depthStencilAttachment = (VkAttachmentReference) {
+ .pDepthStencilAttachment = &(VkAttachmentReference) {
.attachment = VK_ATTACHMENT_UNUSED,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
- .preserveCount = 1,
+ .preserveAttachmentCount = 1,
.pPreserveAttachments = &(VkAttachmentReference) {
.attachment = 0,
.layout = VK_IMAGE_LAYOUT_GENERAL,
},
},
.dependencyCount = 0,
- }, &pass);
+ }, &cmd_buffer->pool->alloc, &pass);
ANV_CALL(CmdBeginRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer),
&(VkRenderPassBeginInfo) {
.pClearValues = (VkClearValue[]) {
{ .color = *pColor },
},
- }, VK_RENDER_PASS_CONTENTS_INLINE);
+ }, VK_SUBPASS_CONTENTS_INLINE);
ANV_CALL(CmdEndRenderPass)(anv_cmd_buffer_to_handle(cmd_buffer));
+
+ /* XXX: We're leaking the render pass and framebuffer */
}
}
}
}
void anv_CmdClearDepthStencilImage(
- VkCmdBuffer cmdBuffer,
+ VkCommandBuffer commandBuffer,
VkImage image,
VkImageLayout imageLayout,
const VkClearDepthStencilValue* pDepthStencil,
stub();
}
-void anv_CmdClearColorAttachment(
- VkCmdBuffer cmdBuffer,
- uint32_t colorAttachment,
- VkImageLayout imageLayout,
- const VkClearColorValue* pColor,
- uint32_t rectCount,
- const VkRect3D* pRects)
-{
- stub();
-}
-
-void anv_CmdClearDepthStencilAttachment(
- VkCmdBuffer cmdBuffer,
- VkImageAspectFlags aspectMask,
- VkImageLayout imageLayout,
- const VkClearDepthStencilValue* pDepthStencil,
+void anv_CmdClearAttachments(
+ VkCommandBuffer commandBuffer,
+ uint32_t attachmentCount,
+ const VkClearAttachment* pAttachments,
uint32_t rectCount,
- const VkRect3D* pRects)
+ const VkClearRect* pRects)
{
stub();
}