⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

Init macros for designated initializers in C++ #579

@Kangz

Description

@Kangz

On bkaradzic/bgfx#3544 there is an example of the following code that doesn't compile in C++ but should be possible to make work if the INIT macros used designated initializers. Maybe we should consider doing this (where designated initializers are availble, so C++17?)

C++ issue, I used named parameters, but WGPU_*_INIT is using struct / unnamed...

		void initBufferBinding(WGPUBindGroupLayoutEntry& _out, uint32_t _binding, WGPUShaderStage _visibility, WGPUBufferBindingType _type, bool _hasDynamicOffset)
		{
			_out =
			{
				.nextInChain      = NULL,
				.binding          = _binding,
				.visibility       = _visibility,
				.bindingArraySize = 0,
				.buffer =
				{
					.nextInChain      = NULL,
					.type             = _type,
					.hasDynamicOffset = _hasDynamicOffset,
					.minBindingSize   = 0,
				},
				.sampler = WGPU_SAMPLER_BINDING_LAYOUT_INIT,
				.texture = WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT,
				.storageTexture = WGPU_STORAGE_TEXTURE_BINDING_LAYOUT_INIT,
			};
		}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions