Ejemplo n.º 1
0
	void D3DUnitMap::set_image(D3DGraphicContextProvider *gc, int index, const Texture &texture)
	{
		if (image_units.size() < index + 1)
			image_units.resize(index + 1);
		image_units[index].object = texture;
		bind_image(gc, index);
	}
Ejemplo n.º 2
0
	void D3DUnitMap::bind_program(D3DGraphicContextProvider *gc, D3DProgramObjectProvider *program)
	{
		for (size_t i = 0; i < program->uniforms.size(); i++)
		{
			switch (program->uniforms[i].type)
			{
			case D3DUniform::type_sampler:
				if (sampler_units.size() < program->uniforms[i].value + 1)
					sampler_units.resize(program->uniforms[i].value + 1);
				for (int j = 0; j < shadertype_num_types; j++)
					sampler_units[program->uniforms[i].value].shader_index[j] = program->uniforms[i].shader_index[j];
				bind_sampler(gc, program->uniforms[i].value);
				break;
			case D3DUniform::type_texture:
				if (texture_units.size() < program->uniforms[i].value + 1)
					texture_units.resize(program->uniforms[i].value + 1);
				for (int j = 0; j < shadertype_num_types; j++)
					texture_units[program->uniforms[i].value].shader_index[j] = program->uniforms[i].shader_index[j];
				bind_texture(gc, program->uniforms[i].value);
				break;
			case D3DUniform::type_image:
				if (image_units.size() < program->uniforms[i].value + 1)
					image_units.resize(program->uniforms[i].value + 1);
				for (int j = 0; j < shadertype_num_types; j++)
					image_units[program->uniforms[i].value].shader_index[j] = program->uniforms[i].shader_index[j];
				bind_image(gc, program->uniforms[i].value);
				break;
			}
		}

		for (size_t i = 0; i < program->uniform_blocks.size(); i++)
		{
			if (uniform_units.size() < program->uniform_blocks[i].value + 1)
				uniform_units.resize(program->uniform_blocks[i].value + 1);
			for (int j = 0; j < shadertype_num_types; j++)
				uniform_units[program->uniform_blocks[i].value].shader_index[j] = program->uniform_blocks[i].shader_index[j];
			bind_uniform_buffer(gc, program->uniform_blocks[i].value);
		}

		for (size_t i = 0; i < program->storage_blocks.size(); i++)
		{
			if (storage_units.size() < program->storage_blocks[i].value + 1)
				storage_units.resize(program->storage_blocks[i].value + 1);
			for (int j = 0; j < shadertype_num_types; j++)
			{
				storage_units[program->storage_blocks[i].value].shader_srv_index[j] = program->storage_blocks[i].shader_srv_index[j];
				storage_units[program->storage_blocks[i].value].shader_uav_index[j] = program->storage_blocks[i].shader_uav_index[j];
			}
			bind_storage_buffer(gc, program->storage_blocks[i].value);
		}
	}
Ejemplo n.º 3
0
extern "C" void bind_appleseed_python_classes()
{
    boost::python::scope().attr("APPLESEED_VERSION") = APPLESEED_VERSION;
    boost::python::scope().attr("APPLESEED_VERSION_MAJOR") = APPLESEED_VERSION_MAJOR;
    boost::python::scope().attr("APPLESEED_VERSION_MINOR") = APPLESEED_VERSION_MINOR;
    boost::python::scope().attr("APPLESEED_VERSION_PATCH") = APPLESEED_VERSION_PATCH;
    boost::python::scope().attr("APPLESEED_VERSION_MATURITY") = APPLESEED_VERSION_MATURITY;
    boost::python::scope().attr("APPLESEED_VERSION_STRING") = APPLESEED_VERSION_STRING;

    bind_utility();
    bind_murmurhash();
    bind_logger();

    bind_vector();
    bind_basis();
    bind_quaternion();
    bind_bbox();
    bind_matrix();
    bind_transform();

    bind_entity();

    bind_color();
    bind_texture();
    bind_bsdf();
    bind_bssrdf();
    bind_edf();
    bind_shader_group();

    bind_surface_shader();
    bind_material();
    bind_light();
    bind_object();
    bind_mesh_object();
    bind_assembly();

    bind_camera();
    bind_environment();
    bind_scene();

    bind_image();
    bind_aov();
    bind_frame();
    bind_fresnel();
    bind_display();
    bind_project();

    bind_renderer_controller();
    bind_tile_callback();
    bind_master_renderer();
}
Ejemplo n.º 4
0
int get_image(VASurfaceID surface, Image *dst_img)
{
    VAAPIContext * const vaapi = vaapi_get_context();
    VAImage image;
    VAImageFormat *image_format = NULL;
    VAStatus status;
    Image bound_image;
    int i, is_bound_image = 0, is_derived_image = 0, error = -1;

    image.image_id = VA_INVALID_ID;
    image.buf      = VA_INVALID_ID;

    if (!image_format) {
        status = vaDeriveImage(vaapi->display, surface, &image);
        if (vaapi_check_status(status, "vaDeriveImage()")) {
            if (image.image_id != VA_INVALID_ID && image.buf != VA_INVALID_ID) {
                D(bug("using vaDeriveImage()\n"));
                is_derived_image = 1;
                image_format = &image.format;
            }
            else {
                D(bug("vaDeriveImage() returned success but VA image is invalid. Trying vaGetImage()\n"));
            }
        }
    }

    if (!image_format) {
        for (i = 0; image_formats[i] != 0; i++) {
            if (get_image_format(vaapi, image_formats[i], &image_format))
                break;
        }
    }

    if (!image_format)
        goto end;
    D(bug("selected %s image format for getimage\n",
          string_of_VAImageFormat(image_format)));

    if (!is_derived_image) {
        status = vaCreateImage(vaapi->display, image_format,
                               vaapi->picture_width, vaapi->picture_height,
                               &image);
        if (!vaapi_check_status(status, "vaCreateImage()"))
            goto end;
        D(bug("created image with id 0x%08x and buffer id 0x%08x\n",
              image.image_id, image.buf));

        VARectangle src_rect;

        src_rect.x      = 0;
        src_rect.y      = 0;
        src_rect.width  = vaapi->picture_width;
        src_rect.height = vaapi->picture_height;

        D(bug("src rect (%d,%d):%ux%u\n",
              src_rect.x, src_rect.y, src_rect.width, src_rect.height));

        status = vaGetImage(
            vaapi->display, vaapi->surface_id,
            src_rect.x, src_rect.y, src_rect.width, src_rect.height,
            image.image_id
        );
        if (!vaapi_check_status(status, "vaGetImage()")) {
            vaDestroyImage(vaapi->display, image.image_id);
            goto end;
        }
    }

    if (bind_image(&image, &bound_image) < 0)
        goto end;
    is_bound_image = 1;

    if (image_convert(dst_img, &bound_image) < 0)
        goto end;

    error = 0;
end:
    if (is_bound_image) {
        if (release_image(&image) < 0)
            error = -1;
    }

    if (image.image_id != VA_INVALID_ID) {
        status = vaDestroyImage(vaapi->display, image.image_id);
        if (!vaapi_check_status(status, "vaDestroyImage()"))
            error = -1;
    }
    return error;
}
Ejemplo n.º 5
0
 //! @brief コンストラクタ
 explicit texture(image* img){bind_image(image_ptr(img));}
Ejemplo n.º 6
0
 //! @biref コンストラクタ
 explicit texture(image_ptr img){bind_image(img);}