Vulkan: Add test case for render graph draw
Pull Request: https://projects.blender.org/blender/blender/pulls/124507
This commit is contained in:
@@ -132,4 +132,89 @@ TEST(vk_render_graph, begin_clear_attachments_end_read_back)
|
||||
log[5]);
|
||||
}
|
||||
|
||||
TEST(vk_render_graph, begin_draw_end)
|
||||
{
|
||||
VkHandle<VkImage> image(1u);
|
||||
VkHandle<VkImageView> image_view(2u);
|
||||
VkHandle<VkPipelineLayout> pipeline_layout(4u);
|
||||
VkHandle<VkPipeline> pipeline(3u);
|
||||
|
||||
Vector<std::string> log;
|
||||
VKResourceStateTracker resources;
|
||||
VKRenderGraph render_graph(std::make_unique<CommandBufferLog>(log), resources);
|
||||
resources.add_image(image, VK_IMAGE_LAYOUT_UNDEFINED, ResourceOwner::APPLICATION);
|
||||
|
||||
{
|
||||
VKResourceAccessInfo access_info = {};
|
||||
access_info.images.append(
|
||||
{image, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, VK_IMAGE_ASPECT_COLOR_BIT});
|
||||
VKBeginRenderingNode::CreateInfo begin_rendering(access_info);
|
||||
begin_rendering.node_data.color_attachments[0].sType =
|
||||
VK_STRUCTURE_TYPE_RENDERING_ATTACHMENT_INFO_KHR;
|
||||
begin_rendering.node_data.color_attachments[0].imageLayout =
|
||||
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
|
||||
begin_rendering.node_data.color_attachments[0].imageView = image_view;
|
||||
begin_rendering.node_data.color_attachments[0].loadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
|
||||
begin_rendering.node_data.color_attachments[0].storeOp = VK_ATTACHMENT_STORE_OP_STORE;
|
||||
begin_rendering.node_data.vk_rendering_info.sType = VK_STRUCTURE_TYPE_RENDERING_INFO;
|
||||
begin_rendering.node_data.vk_rendering_info.colorAttachmentCount = 1;
|
||||
begin_rendering.node_data.vk_rendering_info.layerCount = 1;
|
||||
begin_rendering.node_data.vk_rendering_info.pColorAttachments =
|
||||
begin_rendering.node_data.color_attachments;
|
||||
|
||||
render_graph.add_node(begin_rendering);
|
||||
}
|
||||
|
||||
{
|
||||
VKResourceAccessInfo access_info = {};
|
||||
VKDrawNode::CreateInfo draw(access_info);
|
||||
draw.node_data.first_instance = 0;
|
||||
draw.node_data.first_vertex = 0;
|
||||
draw.node_data.instance_count = 1;
|
||||
draw.node_data.vertex_count = 4;
|
||||
draw.node_data.pipeline_data.push_constants_data = nullptr;
|
||||
draw.node_data.pipeline_data.push_constants_size = 0;
|
||||
draw.node_data.pipeline_data.vk_descriptor_set = VK_NULL_HANDLE;
|
||||
draw.node_data.pipeline_data.vk_pipeline = pipeline;
|
||||
draw.node_data.pipeline_data.vk_pipeline_layout = pipeline_layout;
|
||||
render_graph.add_node(draw);
|
||||
}
|
||||
|
||||
{
|
||||
VKEndRenderingNode::CreateInfo end_rendering = {};
|
||||
render_graph.add_node(end_rendering);
|
||||
}
|
||||
|
||||
render_graph.submit();
|
||||
EXPECT_EQ(5, log.size());
|
||||
EXPECT_EQ(
|
||||
"pipeline_barrier(src_stage_mask=VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, "
|
||||
"dst_stage_mask=VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT" +
|
||||
endl() +
|
||||
" - image_barrier(src_access_mask=, "
|
||||
"dst_access_mask=VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT, "
|
||||
"old_layout=VK_IMAGE_LAYOUT_UNDEFINED, "
|
||||
"new_layout=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, image=0x1, subresource_range=" +
|
||||
endl() +
|
||||
" aspect_mask=VK_IMAGE_ASPECT_COLOR_BIT, base_mip_level=0, "
|
||||
"level_count=4294967295, base_array_layer=0, layer_count=4294967295 )" +
|
||||
endl() + ")",
|
||||
log[0]);
|
||||
EXPECT_EQ("begin_rendering(p_rendering_info=flags=, render_area=" + endl() +
|
||||
" offset=" + endl() + " x=0, y=0 , extent=" + endl() +
|
||||
" width=0, height=0 , layer_count=1, view_mask=0, "
|
||||
"color_attachment_count=1, p_color_attachments=" +
|
||||
endl() +
|
||||
" image_view=0x2, image_layout=VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, "
|
||||
"resolve_mode=VK_RESOLVE_MODE_NONE, resolve_image_view=0, "
|
||||
"resolve_image_layout=VK_IMAGE_LAYOUT_UNDEFINED, "
|
||||
"load_op=VK_ATTACHMENT_LOAD_OP_DONT_CARE, store_op=VK_ATTACHMENT_STORE_OP_STORE" +
|
||||
endl() + ")",
|
||||
log[1]);
|
||||
EXPECT_EQ("bind_pipeline(pipeline_bind_point=VK_PIPELINE_BIND_POINT_GRAPHICS, pipeline=0x3)",
|
||||
log[2]);
|
||||
EXPECT_EQ("draw(vertex_count=4, instance_count=1, first_vertex=0, first_instance=0)", log[3]);
|
||||
EXPECT_EQ("end_rendering()", log[4]);
|
||||
}
|
||||
|
||||
} // namespace blender::gpu::render_graph
|
||||
|
||||
@@ -116,9 +116,15 @@ class CommandBufferLog : public VKCommandBufferInterface {
|
||||
uint32_t first_vertex,
|
||||
uint32_t first_instance) override
|
||||
{
|
||||
UNUSED_VARS(vertex_count, instance_count, first_vertex, first_instance);
|
||||
EXPECT_TRUE(is_recording_);
|
||||
GTEST_FAIL() << __func__ << " not implemented!";
|
||||
std::stringstream ss;
|
||||
ss << "draw(";
|
||||
ss << "vertex_count=" << vertex_count;
|
||||
ss << ", instance_count=" << instance_count;
|
||||
ss << ", first_vertex=" << first_vertex;
|
||||
ss << ", first_instance=" << first_instance;
|
||||
ss << ")";
|
||||
log_.append(ss.str());
|
||||
}
|
||||
|
||||
void draw_indexed(uint32_t index_count,
|
||||
@@ -127,9 +133,16 @@ class CommandBufferLog : public VKCommandBufferInterface {
|
||||
int32_t vertex_offset,
|
||||
uint32_t first_instance) override
|
||||
{
|
||||
UNUSED_VARS(index_count, instance_count, first_index, vertex_offset, first_instance);
|
||||
EXPECT_TRUE(is_recording_);
|
||||
GTEST_FAIL() << __func__ << " not implemented!";
|
||||
std::stringstream ss;
|
||||
ss << "draw_indexed(";
|
||||
ss << "index_count=" << index_count;
|
||||
ss << ", instance_count=" << instance_count;
|
||||
ss << ", first_index=" << first_index;
|
||||
ss << ", vertex_offset=" << vertex_offset;
|
||||
ss << ", first_instance=" << first_instance;
|
||||
ss << ")";
|
||||
log_.append(ss.str());
|
||||
}
|
||||
|
||||
void draw_indirect(VkBuffer buffer,
|
||||
|
||||
Reference in New Issue
Block a user