Exemplo n.º 1
0
		program::program(VkDevice dev, VkPipeline p, const std::vector<program_input> &vertex_input, const std::vector<program_input>& fragment_inputs)
			: m_device(dev), pipeline(p)
		{
			load_uniforms(glsl::program_domain::glsl_vertex_program, vertex_input);
			load_uniforms(glsl::program_domain::glsl_vertex_program, fragment_inputs);
			attribute_location_mask = 0;
		}
Exemplo n.º 2
0
t_shader const	*load_shader(t_sub file_name)
{
	static t_hmap	*cache = NULL;
	t_hmap			*uniforms;
	t_hpair			tmp;
	uint32_t		handle;

	if (cache == NULL)
		cache = ft_hmapnew(SHADER_CACHE_SIZE, &ft_djb2);
	if ((tmp = ft_hmapget(cache, file_name)).value != NULL)
		return (tmp.value);
	tmp = ft_hmapput(cache, file_name, NULL, sizeof(t_shader));
	if (!load_shaders_file(tmp.key, &handle))
	{
		ft_hmaprem(cache, file_name, NULL);
		return (NULL);
	}
	uniforms = ft_hmapnew(SHADER_LOC_SIZE, &ft_djb2);
	load_uniforms(handle, uniforms);
	ft_memcpy(tmp.value, &(t_shader){uniforms, handle}, sizeof(t_shader));
	return (tmp.value);
}