コード例 #1
0
ファイル: Flags.cpp プロジェクト: QuentinFiard/httpxx
Flags GetFlagsFromParser(const ::http_parser& parser) {
  Flags res;
  if (parser.flags & F_CHUNKED) res.set(flags::CHUNKED);
  if (parser.flags & F_CONNECTION_KEEP_ALIVE) res.set(flags::KEEPALIVE);
  if (parser.flags & F_CONNECTION_CLOSE) res.set(flags::CLOSE);
  if (parser.flags & F_TRAILING) res.set(flags::TRAILING);
  if (parser.flags & F_UPGRADE) res.set(flags::UPGRADE);
  if (parser.flags & F_SKIPBODY) res.set(flags::SKIPBODY);
  return res;
}
コード例 #2
0
bool Directional_shadow_renderer_EVSM_MS::init(Resource_manager& resource_manager, Constant_buffer_cache& constant_buffer_cache)
{
    auto& device = rendering_tool_.device();

    Texture_description texture_description;

    texture_description.type = Texture_description::Type::Texture_2D;
    texture_description.format = Data_format::R32G32B32A32_Float;
    texture_description.dimensions.xy = shadow_map_dimensions_;
    texture_description.num_samples = 0;
    texture_description.shader_resource = true;

    shadow_map_ = device.create_render_target_shader_resource_view(texture_description);
    if (!shadow_map_)
    {
        return false;
    }

	if (!Shadow_renderer_EVSM_MS::init(shadow_map_dimensions_, rendering_tool_, resource_manager, constant_buffer_cache))
    {
        return false;
    }

    apply_shadow_.framebuffer = rendering_tool_.device().create_framebuffer();
    if (!apply_shadow_.framebuffer)
    {
        return false;
    }

	Flags<Effect_provider::Options, uint32_t> flags;
	flags.set(Effect_provider::Options::Use_custom_constant_buffers, true);

	apply_shadow_.effect = resource_manager.load<Effect>("Effects/Shadowing/Apply_shadow_map_EVSM.effect", flags.data());
    if (!apply_shadow_.effect)
    {
        return false;
    }

    apply_shadow_.technique        = apply_shadow_.effect->technique("Apply_shadow_map");
    apply_shadow_.volume_technique = apply_shadow_.effect->technique("Apply_shadow_map_volume");

    apply_shadow_.input_layout = rendering_tool_.vertex_layout_cache().input_layout(*Vertex_position2x32_tex_coord2x32::vertex_layout_description(), apply_shadow_.technique->program()->signature());
    if (!apply_shadow_.input_layout)
    {
        return false;
    }

    apply_shadow_.volume_input_layout = rendering_tool_.vertex_layout_cache().input_layout(*Vertex_position3x32::vertex_layout_description(), apply_shadow_.volume_technique->program()->signature());
    if (!apply_shadow_.volume_input_layout)
    {
        return false;
    }

    if (!apply_shadow_.filter_kernel.init(apply_shadow_.effect, "Filter_kernel"))
    {
        return false;
    }

    Constant_buffer_adapter* change_per_camera_adapter = apply_shadow_.effect->constant_buffer_adapter("Change_per_camera");
    if (!change_per_camera_adapter)
    {
        return false;
    }

    Handle<Constant_buffer> change_per_camera_buffer = constant_buffer_cache.constant_buffer("Change_per_camera");
    if (!change_per_camera_buffer)
    {
        return false;
    }

    change_per_camera_adapter->set_constant_buffer(change_per_camera_buffer);

    if (!apply_shadow_.change_per_cascade.init(apply_shadow_.effect, "Change_per_cascade"))
    {
        return false;
    }

    apply_shadow_.effect->create_default_constant_buffers(device);

    if (!volume_.init(rendering_tool_))
    {
        return false;
    }

    for (uint32_t i = 0; i < filter_kernel_size_; ++i)
    {
        apply_shadow_.filter_kernel.data().filter_kernel[i] = filter_kernel_[i];
    }

    apply_shadow_.filter_kernel.update(device);

    return create_render_states();
}
コード例 #3
0
bool Particle_renderer::init(Resource_manager& resource_manager, Constant_buffer_cache& constant_buffer_cache)
{
	Flags<Effect_provider::Options, uint32_t> flags;
	flags.set(Effect_provider::Options::Use_custom_constant_buffers, true);

	effect_ = resource_manager.load<Effect>("Effects/Particle_rendering/Particle_renderer.effect", flags.data());
	if (!effect_)
	{
		return false;
	}

	techniques_.color_map      = effect_->technique("Color_map");
	techniques_.color_map_soft = effect_->technique("Color_map_soft");

	techniques_.array_color_map      = effect_->technique("Array_color_map");
	techniques_.array_color_map_soft = effect_->technique("Array_color_map_soft");

	lighting_techniques_.color_map_soft = effect_->technique("Lighting_color_map_soft");

	Vertex_layout_description::Element elements[] =
	{
		Vertex_layout_description::Element("Position",   0, Data_format::R32G32B32A32_Float),
		Vertex_layout_description::Element("Properties", 0, Data_format::R32G32B32A32_Float)
	};

	static const Vertex_layout_description description(2, elements);

	input_layout_ = rendering_tool_.vertex_layout_cache().input_layout(description, techniques_.color_map->program()->signature());
	if (!input_layout_)
	{
		return false;
	}

	color_texture_offset_			  = effect_->sampler_offset("g_color_map");
	color_texture_array_offset_		  = effect_->sampler_offset("g_color_map_array");
	irradiance_volume_texture_offset_ = effect_->sampler_offset("g_irradiance_volume_map0");

	auto& device = rendering_tool_.device();

	Constant_buffer_adapter* change_per_camera_adapter = effect_->constant_buffer_adapter("Change_per_camera");

	if (!constant_buffer_cache.connect(change_per_camera_adapter, "Change_per_camera"))
	{
		return false;
	}

	Constant_buffer_adapter* change_per_light_adapter = effect_->constant_buffer_adapter("Change_per_light");

	if (!constant_buffer_cache.connect(change_per_light_adapter, "Change_per_light"))
	{
		return false;
	}

	if (!change_per_light_.init(change_per_light_adapter))
	{
		return false;
	}

	effect_->create_default_constant_buffers(device);

	if (!create_buffers())
	{
		return false;
	}

	return create_render_states();
}
コード例 #4
0
bool Deferred_lighting_renderer::init(Resource_manager& resource_manager, Constant_buffer_cache& constant_buffer_cache)
{
	Flags<Effect_provider::Options, uint32_t> flags;
	flags.set(Effect_provider::Options::Use_custom_constant_buffers, true);

	effect_ = resource_manager.load<Effect>("Effects/Lighting/Deferred_lighting_renderer.effect", flags.data());
	if (!effect_)
	{
		return false;
	}

	techniques_.emissive_light = effect_->technique("Emissive_light");
	techniques_.irradiance_volume = effect_->technique("Irradiance_volume");
	techniques_.light_probe_specular = effect_->technique("Light_probe_specular");
	techniques_.volume_light_probe_specular = effect_->technique("Volume_light_probe_specular");
	techniques_.directional_light = effect_->technique("Directional_light");
	techniques_.directional_light_with_shadow = effect_->technique("Directional_light_with_shadow");
	techniques_.point_light = effect_->technique("Point_light");
	techniques_.spot_light = effect_->technique("Spot_light");
	techniques_.spot_light_with_shadow = effect_->technique("Spot_light_with_shadow");

	input_layout_ = rendering_tool_.vertex_layout_cache().input_layout(*Vertex_position2x32_tex_coord2x32::vertex_layout_description(), techniques_.directional_light->program()->signature());
	if (!input_layout_)
	{
		return false;
	}

	Constant_buffer_adapter* change_per_camera_adapter = effect_->constant_buffer_adapter("Change_per_camera");

	if (!constant_buffer_cache.connect(change_per_camera_adapter, "Change_per_camera"))
	{
		return false;
	}

	if (!filter_kernel_.init(effect_, "Filter_kernel"))
	{
		return false;
	}

	if (!change_per_light_.init(effect_, "Change_per_light"))
	{
		return false;
	}

	auto& device = rendering_tool_.device();

	Constant_buffer_adapter* change_per_light_adapter = change_per_light_.adapter();
	Handle<Constant_buffer> change_per_light_buffer = device.create_constant_buffer(change_per_light_adapter->num_bytes());
	change_per_light_adapter->set_constant_buffer(change_per_light_buffer);

	constant_buffer_cache.set_constant_buffer("Change_per_light", change_per_light_buffer);

	effect_->create_default_constant_buffers(device);

	volume_input_layout_ = rendering_tool_.vertex_layout_cache().input_layout(*Vertex_position3x32::vertex_layout_description(), techniques_.point_light->program()->signature());
	if (!volume_input_layout_)
	{
		return false;
	}

	light_2D_texture_offset0_         = effect_->sampler_offset("g_light_2D_map0");
	light_2D_texture_offset1_         = effect_->sampler_offset("g_light_2D_map1");
	light_probe_texture_offset_       = effect_->sampler_offset("g_light_probe_map");
	irradiance_volume_texture_offset_ = effect_->sampler_offset("g_irradiance_volume_map0");

	if (!box_volume_.init(rendering_tool_))
	{
		return false;
	}

	if (!sphere_volume_.init(rendering_tool_))
	{
		return false;
	}

	if (!frustum_volume_.init(rendering_tool_))
	{
		return false;
	}

	if (!directional_shadow_renderer_.init(resource_manager, constant_buffer_cache))
	{
		logging::error("Directional shadow renderer could not be initialized.");

		return false;
	}

	if (!spot_shadow_renderer_.init(resource_manager, constant_buffer_cache))
	{
		logging::error("Spot shadow renderer could not be initialized.");

		return false;
	}

	for (uint32_t i = 0, count = spot_shadow_renderer_.filter_kernel_size(); i < count; ++i)
	{
		filter_kernel_.data().filter_kernel[i] = spot_shadow_renderer_.filter_kernel()[i];
	}

	filter_kernel_.update(device);

	return create_render_states();
}