Пример #1
0
struct delicious* skip_function_with_no_spec(void) {
  struct delicious* cake = NULL;
  int i;

  if (bake(&cake) == NULL) {
    return 0;
  }

  i = cake->yum;
  return cake;
}
Пример #2
0
static void bake_startjob(void *bkv, short *UNUSED(stop), short *UNUSED(do_update), float *UNUSED(progress))
{
	BakeAPIRender *bkr = (BakeAPIRender *)bkv;

	bkr->result = bake(
	        bkr->main, bkr->scene, bkr->ob, &bkr->selected_objects, bkr->reports,
	        bkr->pass_type, bkr->margin, bkr->save_mode,
	        bkr->is_clear, bkr->is_split_materials, bkr->is_automatic_name, bkr->use_selected_to_active,
	        bkr->cage_extrusion, bkr->normal_space, bkr->normal_swizzle,
	        bkr->custom_cage, bkr->filepath, bkr->width, bkr->height, bkr->identifier
	        );
}
Пример #3
0
 void ACPI::walk_sdts(const char* addr)
 {
   // find total number of SDTs
   auto* rsdt = (SDTHeader*) addr;
   int  total = (rsdt->Length - sizeof(SDTHeader)) / 4;
   // go past rsdt
   addr += sizeof(SDTHeader);
   
   // parse all tables
   constexpr uint32_t APIC_t = bake('A', 'P', 'I', 'C');
   constexpr uint32_t HPET_t = bake('H', 'P', 'E', 'T');
   constexpr uint32_t FACP_t = bake('F', 'A', 'C', 'P');
   
   while (total) {
     // convert *addr to SDT-address
     auto sdt_ptr = *(intptr_t*) addr;
     // create SDT pointer
     auto* sdt = (SDTHeader*) sdt_ptr;
     // find out which SDT it is
     switch (sdt->sigint()) {
     case APIC_t:
       debug("APIC found: P=%p L=%u\n", sdt, sdt->Length);
       walk_madt((char*) sdt);
       break;
     case HPET_t:
       debug("HPET found: P=%p L=%u\n", sdt, sdt->Length);
       this->hpet_base = sdt_ptr + sizeof(SDTHeader);
       break;
     case FACP_t:
       debug("FACP found: P=%p L=%u\n", sdt, sdt->Length);
       walk_facp((char*) sdt);
       break;
     default:
       debug("Signature: %.*s (u=%u)\n", 4, sdt->Signature, sdt->sigint());
     }
     
     addr += 4; total--;
   }
   debug("Finished walking SDTs\n");
 }
Пример #4
0
static int bake_exec(bContext *C, wmOperator *op)
{
	int result;
	BakeAPIRender bkr = {NULL};

	bake_init_api_data(op, C, &bkr);

	result = bake(
	        bkr.main, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports,
	        bkr.pass_type, bkr.margin, bkr.save_mode,
	        bkr.is_clear, bkr.is_split_materials, bkr.is_automatic_name, bkr.use_selected_to_active,
	        bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
	        bkr.custom_cage, bkr.filepath, bkr.width, bkr.height, bkr.identifier);

	BLI_freelistN(&bkr.selected_objects);
	return result;
}
/* Please see header for specification */
VkPipeline Anvil::BasePipelineManager::get_pipeline(PipelineID in_pipeline_id)
{
    std::unique_lock<std::recursive_mutex> mutex_lock;
    auto                                   mutex_ptr         = get_mutex();
    Pipelines::const_iterator              pipeline_iterator;
    Pipeline*                              pipeline_ptr      = nullptr;
    VkPipeline                             result            = VK_NULL_HANDLE;

    if (mutex_ptr != nullptr)
    {
        mutex_lock = std::move(
            std::unique_lock<std::recursive_mutex>(*mutex_ptr)
        );
    }

    if (m_outstanding_pipelines.size() > 0)
    {
        bake();
    }

    pipeline_iterator = m_baked_pipelines.find(in_pipeline_id);

    if (pipeline_iterator == m_baked_pipelines.end() )
    {
        anvil_assert(!(pipeline_iterator == m_baked_pipelines.end()) );

        goto end;
    }

    pipeline_ptr = pipeline_iterator->second.get();

    if (pipeline_ptr->pipeline_create_info_ptr->is_proxy() )
    {
        anvil_assert(!pipeline_ptr->pipeline_create_info_ptr->is_proxy() );

        goto end;
    }

    result = pipeline_ptr->baked_pipeline;
    anvil_assert(result != VK_NULL_HANDLE);
end:
    return result;
}
Пример #6
0
static void mainLoop(GLFWwindow *window, scene_t *scene)
{
	glfwPollEvents();
	if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
		bake(scene);

	int w, h;
	glfwGetFramebufferSize(window, &w, &h);
	glViewport(0, 0, w, h);

	// camera for glfw window
	float view[16], projection[16];
	fpsCameraViewMatrix(window, view);
	perspectiveMatrix(projection, 45.0f, (float)w / (float)h, 0.01f, 100.0f);

	// draw to screen with a blueish sky
	glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	drawScene(scene, view, projection);

	glfwSwapBuffers(window);
}
/* Please see header for specification */
bool Anvil::BasePipelineManager::get_shader_statistics(PipelineID                  in_pipeline_id,
                                                       Anvil::ShaderStage          in_shader_stage,
                                                       VkShaderStatisticsInfoAMD*  out_shader_statistics_ptr)
{
    Anvil::ExtensionAMDShaderInfoEntrypoints entrypoints            = m_device_ptr->get_extension_amd_shader_info_entrypoints();
    std::unique_lock<std::recursive_mutex>   mutex_lock;
    auto                                     mutex_ptr              = get_mutex();
    Pipelines::const_iterator                pipeline_iterator;
    Pipeline*                                pipeline_ptr           = nullptr;
    bool                                     result                 = false;
    const auto                               shader_stage_vk        = Anvil::Utils::get_shader_stage_flag_bits_from_shader_stage(in_shader_stage);
    size_t                                   shader_statistics_size = sizeof(VkShaderStatisticsInfoAMD);
    VkResult                                 vk_result;

    if (entrypoints.vkGetShaderInfoAMD == nullptr)
    {
        anvil_assert(!(entrypoints.vkGetShaderInfoAMD == nullptr));

        goto end;
    }

    if (mutex_ptr != nullptr)
    {
        mutex_lock = std::move(
            std::unique_lock<std::recursive_mutex>(*mutex_ptr)
        );
    }

    if (m_outstanding_pipelines.size() > 0)
    {
        bake();
    }

    pipeline_iterator = m_baked_pipelines.find(in_pipeline_id);
    if (pipeline_iterator == m_baked_pipelines.end())
    {
        anvil_assert(!(pipeline_iterator == m_baked_pipelines.end()));

        goto end;
    }

    pipeline_ptr = pipeline_iterator->second.get();

    if (pipeline_ptr->baked_pipeline == VK_NULL_HANDLE)
    {
        bake();

        anvil_assert(!pipeline_ptr->baked_pipeline != VK_NULL_HANDLE);
    }

    vk_result = entrypoints.vkGetShaderInfoAMD(m_device_ptr->get_device_vk(),
                                               pipeline_ptr->baked_pipeline,
                                               static_cast<VkShaderStageFlagBits>(shader_stage_vk),
                                               VK_SHADER_INFO_TYPE_STATISTICS_AMD,
                                              &shader_statistics_size,
                                               out_shader_statistics_ptr);

    if (vk_result == VK_ERROR_FEATURE_NOT_PRESENT)
    {
        goto end;
    }

    if (!is_vk_call_successful(vk_result)                                      ||
         shader_statistics_size           != sizeof(VkShaderStatisticsInfoAMD))
    {
        goto end;
    }

    result = true;

end:
    return result;
}
/* Please see header for specification */
bool Anvil::BasePipelineManager::get_shader_info(PipelineID                  in_pipeline_id,
                                                 Anvil::ShaderStage          in_shader_stage,
                                                 Anvil::ShaderInfoType       in_info_type,
                                                 std::vector<unsigned char>* out_data_ptr)
{
    Anvil::ExtensionAMDShaderInfoEntrypoints entrypoints       = m_device_ptr->get_extension_amd_shader_info_entrypoints();
    std::unique_lock<std::recursive_mutex>   mutex_lock;
    auto                                     mutex_ptr         = get_mutex();
    Pipelines::const_iterator                pipeline_iterator;
    Pipeline*                                pipeline_ptr      = nullptr;
    size_t                                   out_data_size     = out_data_ptr->size();
    bool                                     result            = false;
    const auto                               shader_stage_vk   = Anvil::Utils::get_shader_stage_flag_bits_from_shader_stage(in_shader_stage);
    VkShaderInfoTypeAMD                      vk_info_type;
    VkResult                                 vk_result;

    if (entrypoints.vkGetShaderInfoAMD == nullptr)
    {
        anvil_assert(!(entrypoints.vkGetShaderInfoAMD == nullptr));

        goto end;
    }

    if (mutex_ptr != nullptr)
    {
        mutex_lock = std::move(
            std::unique_lock<std::recursive_mutex>(*mutex_ptr)
        );
    }

    if (m_outstanding_pipelines.size() > 0)
    {
        bake();
    }

    pipeline_iterator = m_baked_pipelines.find(in_pipeline_id);
    if (pipeline_iterator == m_baked_pipelines.end())
    {
        anvil_assert(!(pipeline_iterator == m_baked_pipelines.end()));

        goto end;
    }

    pipeline_ptr = pipeline_iterator->second.get();

    if (pipeline_ptr->baked_pipeline == VK_NULL_HANDLE)
    {
        bake();

        anvil_assert(!pipeline_ptr->baked_pipeline != VK_NULL_HANDLE);
    }

    switch (in_info_type)
    {
        case ShaderInfoType::BINARY:
        {
            vk_info_type = VK_SHADER_INFO_TYPE_BINARY_AMD;

            break;
        }

        case ShaderInfoType::DISASSEMBLY:
        {
            vk_info_type = VK_SHADER_INFO_TYPE_DISASSEMBLY_AMD;

            break;
        }

        default:
        {
            anvil_assert(!"Unknown shader info type");

            goto end;
        }
    }

    if (out_data_size == 0)
    {
        vk_result = entrypoints.vkGetShaderInfoAMD(m_device_ptr->get_device_vk(),
                                                   pipeline_ptr->baked_pipeline,
                                                   static_cast<VkShaderStageFlagBits>(shader_stage_vk),
                                                   vk_info_type,
                                                  &out_data_size,
                                                   nullptr);

        if (vk_result == VK_ERROR_FEATURE_NOT_PRESENT)
        {
            goto end;
        }

        if (!is_vk_call_successful(vk_result)       ||
             out_data_size                    == 0)
        {
            goto end;
        }

        out_data_ptr->resize(out_data_size);
    }

    vk_result = entrypoints.vkGetShaderInfoAMD(m_device_ptr->get_device_vk(),
                                               pipeline_ptr->baked_pipeline,
                                               static_cast<VkShaderStageFlagBits>(shader_stage_vk),
                                               vk_info_type,
                                              &out_data_size,
                                              &(*out_data_ptr).at(0));

    if (vk_result == VK_ERROR_FEATURE_NOT_PRESENT)
    {
        goto end;
    }

    if (!is_vk_call_successful(vk_result)      ||
         out_data_size                    == 0)
    {
        goto end;
    }

    result = true;
end:
    return result;
}
Пример #9
0
void BakedLightmap::_debug_bake() {
	bake(get_parent(), true);
}
Пример #10
0
void GIProbe::_debug_bake() {

	bake(NULL,true);
}
Пример #11
0
int main(int argc, char* argv[])
{
	glfwSetErrorCallback(error_callback);
	if (!glfwInit()) return 1;
	glfwWindowHint(GLFW_RED_BITS, 8);
	glfwWindowHint(GLFW_GREEN_BITS, 8);
	glfwWindowHint(GLFW_BLUE_BITS, 8);
	glfwWindowHint(GLFW_ALPHA_BITS, 8);
	glfwWindowHint(GLFW_DEPTH_BITS, 32);
	glfwWindowHint(GLFW_STENCIL_BITS, GLFW_DONT_CARE);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
	glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2);
	glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE);
	glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);
	glfwWindowHint(GLFW_OPENGL_DEBUG_CONTEXT, GL_TRUE);
	glfwWindowHint(GLFW_SAMPLES, 4);
	GLFWwindow *window = glfwCreateWindow(1024, 768, "Lightmapping Example", NULL, NULL);
	if (!window) return 1;
	glfwMakeContextCurrent(window);
	gladLoadGLLoader((GLADloadproc)glfwGetProcAddress);
	glfwSwapInterval(1);

	scene_t scene = {0};
	if (!initScene(&scene))
	{
		fprintf(stderr, "Could not initialize scene.\n");
		return 1;
	}

	printf("Ambient Occlusion Baking Example.\n");
	printf("Use your mouse and the W, A, S, D, E, Q keys to navigate.\n");
	printf("Press SPACE to start baking one light bounce!\n");
	printf("This will take a few seconds and bake a lightmap illuminated by:\n");
	printf("1. The mesh itself (initially black)\n");
	printf("2. A white sky (1.0f, 1.0f, 1.0f)\n");

	while (!glfwWindowShouldClose(window))
	{
		glfwPollEvents();
		if (glfwGetKey(window, GLFW_KEY_SPACE) == GLFW_PRESS)
			bake(&scene);

		int w, h;
		glfwGetFramebufferSize(window, &w, &h);
		glViewport(0, 0, w, h);

		// camera for glfw window
		float view[16], projection[16];
		fpsCameraViewMatrix(window, view);
		perspectiveMatrix(projection, 45.0f, (float)w / (float)h, 0.01f, 100.0f);
		
		// draw to screen with a blueish sky
		glClearColor(0.6f, 0.8f, 1.0f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
		drawScene(&scene, view, projection);

		glfwSwapBuffers(window);
	}

	destroyScene(&scene);
	glfwDestroyWindow(window);
	glfwTerminate();
	return 0;
}
Пример #12
0
static int bake_exec(bContext *C, wmOperator *op)
{
	Render *re;
	int result = OPERATOR_CANCELLED;
	BakeAPIRender bkr = {NULL};
	Scene *scene = CTX_data_scene(C);

	G.is_break = false;
	G.is_rendering = true;

	bake_set_props(op, scene);

	bake_init_api_data(op, C, &bkr);
	re = bkr.render;

	/* setup new render */
	RE_test_break_cb(re, NULL, bake_break);

	if (!bake_pass_filter_check(bkr.pass_type, bkr.pass_filter, bkr.reports)) {
		goto finally;
	}

	if (!bake_objects_check(bkr.main, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports, bkr.is_selected_to_active)) {
		goto finally;
	}

	if (bkr.is_clear) {
		const bool is_tangent = ((bkr.pass_type == SCE_PASS_NORMAL) && (bkr.normal_space == R_BAKE_SPACE_TANGENT));
		bake_images_clear(bkr.main, is_tangent);
	}

	RE_SetReports(re, bkr.reports);

	if (bkr.is_selected_to_active) {
		result = bake(
		        bkr.render, bkr.main, bkr.scene, bkr.ob, &bkr.selected_objects, bkr.reports,
		        bkr.pass_type, bkr.pass_filter, bkr.margin, bkr.save_mode,
		        bkr.is_clear, bkr.is_split_materials, bkr.is_automatic_name, true, bkr.is_cage,
		        bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
		        bkr.custom_cage, bkr.filepath, bkr.width, bkr.height, bkr.identifier, bkr.sa,
		        bkr.uv_layer);
	}
	else {
		CollectionPointerLink *link;
		const bool is_clear = bkr.is_clear && BLI_listbase_is_single(&bkr.selected_objects);
		for (link = bkr.selected_objects.first; link; link = link->next) {
			Object *ob_iter = link->ptr.data;
			result = bake(
			        bkr.render, bkr.main, bkr.scene, ob_iter, NULL, bkr.reports,
			        bkr.pass_type, bkr.pass_filter, bkr.margin, bkr.save_mode,
			        is_clear, bkr.is_split_materials, bkr.is_automatic_name, false, bkr.is_cage,
			        bkr.cage_extrusion, bkr.normal_space, bkr.normal_swizzle,
			        bkr.custom_cage, bkr.filepath, bkr.width, bkr.height, bkr.identifier, bkr.sa,
			        bkr.uv_layer);
		}
	}

	RE_SetReports(re, NULL);


finally:
	G.is_rendering = false;
	BLI_freelistN(&bkr.selected_objects);
	return result;
}
Пример #13
0
void
top_level_eval(void)
{
	save();

	trigmode = 0;

	p1 = symbol(AUTOEXPAND);

	if (iszero(get_binding(p1)))
		expanding = 0;
	else
		expanding = 1;

	p1 = pop();
	push(p1);
	eval();
	p2 = pop();

	// "draw", "for" and "setq" return "nil", there is no result to print

	if (p2 == symbol(NIL)) {
		push(p2);
		restore();
		return;
	}

	// update "last"

	set_binding(symbol(LAST), p2);

	if (!iszero(get_binding(symbol(BAKE)))) {
		push(p2);
		bake();
		p2 = pop();
	}

	// If we evaluated the symbol "i" or "j" and the result was sqrt(-1)

	// then don't do anything.

	// Otherwise if "j" is an imaginary unit then subst.

	// Otherwise if "i" is an imaginary unit then subst.

	if ((p1 == symbol(SYMBOL_I) || p1 == symbol(SYMBOL_J))
	&& isimaginaryunit(p2))
		;
	else if (isimaginaryunit(get_binding(symbol(SYMBOL_J)))) {
		push(p2);
		push(imaginaryunit);
		push_symbol(SYMBOL_J);
		subst();
		p2 = pop();
	} else if (isimaginaryunit(get_binding(symbol(SYMBOL_I)))) {
		push(p2);
		push(imaginaryunit);
		push_symbol(SYMBOL_I);
		subst();
		p2 = pop();
	}

#ifndef LINUX

	// if we evaluated the symbol "a" and got "b" then print "a=b"

	// do not print "a=a"

	if (issymbol(p1) && !iskeyword(p1) && p1 != p2 && test_flag == 0) {
		push_symbol(SETQ);
		push(p1);
		push(p2);
		list(3);
		p2 = pop();
	}
#endif
	push(p2);

	restore();
}