#include <psemek/wgpu/render_pipeline.hpp>
#include <psemek/wgpu/detail/string_view.hpp>
#include <psemek/wgpu/external/wgpu.h>

namespace psemek::wgpu
{

	bind_group_layout render_pipeline::get_bind_group_layout(std::uint32_t index) const
	{
		return bind_group_layout(wgpuRenderPipelineGetBindGroupLayout((WGPURenderPipeline)get(), index));
	}

	void render_pipeline::set_label(std::string const & label)
	{
		wgpuRenderPipelineSetLabel((WGPURenderPipeline)get(), detail::to_string_view(label));
	}

	void render_pipeline::reference(void * ptr)
	{
		wgpuRenderPipelineAddRef((WGPURenderPipeline)ptr);
	}

	void render_pipeline::release(void * ptr)
	{
		wgpuRenderPipelineRelease((WGPURenderPipeline)ptr);
	}

	detail::chained_struct_ptr to_chained_struct(primitive_state::extras const & extras)
	{
		WGPUPrimitiveStateExtras chained = {};
		chained.chain.sType = (WGPUSType)WGPUSType_PrimitiveStateExtras;
		chained.polygonMode = (WGPUPolygonMode)extras.polygon_mode;
		chained.conservative = extras.conservative;
		return detail::make_chained_struct(chained);
	}

}
