Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stack overflow when there are too many config parameters when creating a graphics pipeline #98

Open
3 tasks
johannesugb opened this issue Apr 2, 2021 · 0 comments
Labels
bug Something isn't working C++ C++-centric task

Comments

@johannesugb
Copy link
Member

johannesugb commented Apr 2, 2021

Problematic code:

		// Create a graphics pipeline for drawing the bounding spheres for the meshlets:
	mMeshletNormDistConesPipeline = gvk::context().create_graphics_pipeline_for(
			// Shaders to be used with this pipeline:
			avk::vertex_shader("shaders/instanced_boneanimated_oriented.vert"), 
			avk::fragment_shader("shaders/color.frag"),
			// Declare the vertex input to the shaders:
			avk::from_buffer_binding(0) -> stream_per_vertex<glm::vec3>()                                                  -> to_location(0),	// Declare that positions shall be read from the attached vertex buffer at binding 0, and that we are going to access it in shaders via layout (location = 0)
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_01) -> to_location(1),	// Stream instance data from the buffer at binding 1 to location 1 => the center of the sphere
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_02) -> to_location(2),	// Stream instance data from the buffer at binding 1 to location 2 => the radius of the sphere
			// We need to stream a mat4 using four input locations:
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_03) -> to_location(3),	// Stream instance data from the buffer at binding 1 to location 3 => transformation matrix
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_04) -> to_location(4),	// add another vec4 to complete the whole mat4
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_05) -> to_location(5),	// add another vec4 to complete the whole mat4
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_06) -> to_location(6),	// add another vec4 to complete the whole mat4
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_07) -> to_location(7),	// Stream instance data from the buffer at binding 1 to location 7 => bone matrices index
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_08) -> to_location(8),	// Stream instance data from the buffer at binding 1 to location 8 => mesh index
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_09) -> to_location(9),	// Stream instance data from the buffer at binding 1 to location 9 => texel buffer index
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_10) -> to_location(10),	// Stream instance data from the buffer at binding 1 to location 10 => first vertex index
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_11) -> to_location(11),	// Stream instance data from the buffer at binding 1 to location 11 => inConeApex
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_12) -> to_location(12),	// Stream instance data from the buffer at binding 1 to location 12 => inConeAxisMeshopt
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_13) -> to_location(13),	// Stream instance data from the buffer at binding 1 to location 13 => inConeCutoffMeshopt
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_14) -> to_location(14),	// Stream instance data from the buffer at binding 1 to location 14 => inPrincipalBoneIndex
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_15) -> to_location(15),	// Stream instance data from the buffer at binding 1 to location 15 => inConeAxisPBS
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_16) -> to_location(16),	// Stream instance data from the buffer at binding 1 to location 16 => inConeCutoffPBS
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_17) -> to_location(17),	// Stream instance data from the buffer at binding 1 to location 17 => inConeAxisPBSAni
			avk::from_buffer_binding(1) -> stream_per_instance(mMeshletsBuffer, avk::content_description::user_defined_18) -> to_location(18),	// Stream instance data from the buffer at binding 1 to location 18 => inConeCutoffPBSAni
			avk::attachment::declare(std::make_tuple(mFramebuffers[0]->image_view_at(0)->config().format, mFramebuffers[0]->image_at(0)->config().samples), avk::on_load::load, avk::color(0)+avk::resolve_to(2), avk::on_store::store),
			avk::attachment::declare(std::make_tuple(mFramebuffers[0]->image_view_at(1)->config().format, mFramebuffers[0]->image_at(1)->config().samples), avk::on_load::load, avk::depth_stencil(), avk::on_store::store),
			avk::attachment::declare(mFramebuffers[0]->image_view_at(2)->config().format, avk::on_load::load, avk::resolve_receiver(), avk::on_store::store),
			// Further config for the pipeline:
		avk::cfg::viewport_depth_scissors_config::from_framebuffer(mFramebuffers[0]), // Set to the dimensions of the main window
			avk::cfg::depth_write::disabled(),
			avk::cfg::color_blending_config::enable_alpha_blending_for_all_attachments(),
			avk::descriptor_binding(0, 0, mViewProjBuffers[0]),
			avk::descriptor_binding(1, 0, mBoneMatricesBuffersAni[0]),
			avk::descriptor_binding(1, 1, mMeshRootMatrices),
			avk::descriptor_binding(1, 2, mBindPoseMatrices),
			avk::descriptor_binding(2, 0, avk::as_uniform_texel_buffer_views(mBoneIndicesBuffers)),
			avk::descriptor_binding(2, 1, avk::as_uniform_texel_buffer_views(mBoneWeightsBuffers)),
			avk::push_constant_binding_data{ avk::shader_type::vertex, 0, sizeof(push_constants_for_norm_dist_cones) }
		);

Why does this result in a stack overflow?

Definition of done:

  • A lot of config parameters do not lead to stack overflows
  • The code example above does not lead to a stack overflow anymore
  • The code is well documented and the Contribution Guidelines have been followed.
@johannesugb johannesugb added bug Something isn't working C++ C++-centric task labels Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working C++ C++-centric task
Development

No branches or pull requests

1 participant