Пример #1
0
void gpbridge_export_start(PG_FUNCTION_ARGS)
{
	gphadoop_context* context = create_context(fcinfo);

	parse_gphd_uri(context, false, fcinfo);

	/* get rest servers list and choose one */
	Relation rel = EXTPROTOCOL_GET_RELATION(fcinfo);
	PxfServer* rest_server = get_pxf_server(context->gphd_uri, rel);

	if (!rest_server)
		ereport(ERROR,
				(errcode(ERRCODE_CONNECTION_FAILURE),
						errmsg("No REST servers were found (by accessing PXF URI %s)",
							   context->gphd_uri->uri)));

	elog(DEBUG2, "chosen pxf rest_server = %s:%d", rest_server->host, rest_server->port);

	build_file_name_for_write(context);
	build_uri_for_write(context, rest_server);
	free_datanode_rest_server(rest_server);

	context->churl_headers = churl_headers_init();
	add_querydata_to_http_header(context, fcinfo);

	context->churl_handle = churl_init_upload(context->uri.data,
											  context->churl_headers);
}
Пример #2
0
  void BlockEnvironment::call(STATE, Task* task, Message& msg) {
    Object* val;
    if(msg.args() > 0) {
      Tuple* tup = Tuple::create(state, msg.args());
      for(int i = msg.args() - 1; i >= 0; i--) {
        tup->put(state, i, msg.get_argument(i));
      }

      val = tup;
    } else {
      val = Qnil;
    }
    BlockContext* ctx = create_context(state, task->active());
    if(task->profiler) {
      profiler::Method* prof_meth = task->profiler->enter_method(
          as<Symbol>(home_->name()), home_->module()->name(), profiler::kBlock);

      if(!prof_meth->file()) {
        prof_meth->set_position(method_->file(), method_->start_line(state));
      }
    }

    // HACK: manually clear the stack used as args.
    task->active()->clear_stack(msg.stack);

    task->make_active(ctx);
    task->push(val);
  }
Пример #3
0
  void BlockEnvironment::call(STATE, Task* task, size_t args) {
    Object* val;
    if(args > 0) {
      Tuple* tup = Tuple::create(state, args);
      for(int i = args - 1; i >= 0; i--) {
        tup->put(state, i, task->pop());
      }

      val = tup;
    } else {
      val = Qnil;
    }
    task->pop(); // Remove this from the stack.
    BlockContext* ctx = create_context(state, task->active());
    if(task->profiler) {
      profiler::Method* prof_meth = task->profiler->enter_method(
          as<Symbol>(home_->name()), home_->module()->name(), profiler::kBlock);

      if(!prof_meth->file()) {
        prof_meth->set_position(method_->file(), method_->start_line(state));
      }
    }
    task->make_active(ctx);
    task->push(val);
  }
Пример #4
0
uim_agent_context *
create_uim_agent_context(const char *encoding)
{

  uim_agent_context *ret;
  const char *im;

  debug_printf(DEBUG_NOTE, "create_uim_agent_context\n");

  ret = uim_malloc(sizeof(uim_agent_context));

  if (encoding) {
	ret->encoding = uim_strdup(encoding);
  } else {
	if (debug_level > 0)
	  ret->encoding = uim_strdup("EUC-JP");
	else
	  ret->encoding = uim_strdup("UTF-8");
  }

  ret->context = create_context(ret->encoding, ret);

  if ((im = uim_get_default_im_name(setlocale(LC_CTYPE, NULL))))
	ret->im = uim_strdup(im);
  else
	ret->im = NULL;

  ret->pe = create_preedit();
  ret->cand = create_candidate();
  ret->prop = create_prop();

  ret->comstr = (char *)NULL;

  return ret;
}
Пример #5
0
int context_attach(pid_t pid, ContextAttachCallBack * done, void * data, int mode) {
    Context * ctx = NULL;

    assert(done != NULL);
    trace(LOG_CONTEXT, "context: attaching pid %d", pid);
    if ((mode & CONTEXT_ATTACH_SELF) == 0 && ptrace(PT_ATTACH, pid, 0, 0) < 0) {
        int err = errno;
        trace(LOG_ALWAYS, "error: ptrace(PT_ATTACH) failed: pid %d, error %d %s",
            pid, err, errno_to_str(err));
        errno = err;
        return -1;
    }
    add_waitpid_process(pid);
    ctx = create_context(pid2id(pid, 0));
    ctx->mem = ctx;
    ctx->mem_access |= MEM_ACCESS_INSTRUCTION;
    ctx->mem_access |= MEM_ACCESS_DATA;
    ctx->mem_access |= MEM_ACCESS_USER;
    ctx->big_endian = big_endian_host();
    EXT(ctx)->pid = pid;
    EXT(ctx)->attach_callback = done;
    EXT(ctx)->attach_data = data;
    list_add_first(&ctx->ctxl, &pending_list);
    /* TODO: context_attach works only for main task in a process */
    return 0;
}
int S9xOpenGLDisplayDriver::init ()
{
    initialized = false;

    if (!create_context ())
    {
        return -1;
    }

    if (!opengl_defaults ())
    {
        return -1;
    }

    buffer[0] = malloc (image_padded_size);
    buffer[1] = malloc (scaled_padded_size);

    clear_buffers ();

    padded_buffer[0] = (void *) (((uint8 *) buffer[0]) + image_padded_offset);
    padded_buffer[1] = (void *) (((uint8 *) buffer[1]) + scaled_padded_offset);

    GFX.Screen = (uint16 *) padded_buffer[0];
    GFX.Pitch = image_width * image_bpp;

    context->swap_interval (config->sync_to_vblank);

    initialized = true;

    return 0;
}
Пример #7
0
/*  Build a context from the domain_context and category fields of the data_t
 *  structure.
 *  Use the resultant context as the execution context (setexeccon) for the
 *  next call to exec.
 */
static bool
set_exec_context (data_t* data)
{
        char mcs_str [9] = { 0, }, *context = NULL;
        int p_ret = 0;

        p_ret = snprintf (mcs_str, sizeof (mcs_str), "s0:c%d", data->category);
        if (p_ret < 0 || p_ret > 9) {
                syslog (LOG_CRIT, "insufficient buffer size");
                return false;
        }
        context = create_context (data->domain_context, mcs_str);
        if (context == NULL) {
                syslog (LOG_CRIT, "error creating context from %s and %s",
                        data->domain_context, mcs_str);
                return false;
        }
        syslog (LOG_INFO, "Setting execution context to %s", context);
        if (setexeccon(context) == -1) {
                syslog (LOG_CRIT, "setexeccon: %s", strerror (errno));
                return false;
        }
        free (context);
        return true;
}
void CCryptKey::DecryptData(const std::vector<unsigned char>& encrypted, std::vector<unsigned char>& data)
{
    ies_ctx_t *ctx;
    char error[1024] = "Unknown error";
    cryptogram_t *cryptogram;
    size_t length;
    unsigned char *decrypted;

    ctx = create_context(pkey);
    if (!EC_KEY_get0_private_key(ctx->user_key))
        throw key_error("Given EC key is not private key");

    size_t key_length = ctx->stored_key_length;
    size_t mac_length = EVP_MD_size(ctx->md);
    cryptogram = cryptogram_alloc(key_length, mac_length, encrypted.size() - key_length - mac_length);

    memcpy(cryptogram_key_data(cryptogram), &encrypted[0], encrypted.size());

    decrypted = ecies_decrypt(ctx, cryptogram, &length, error);
    cryptogram_free(cryptogram);
    free(ctx);

    if (decrypted == NULL) {
        throw key_error(std::string("Error in decryption: %s") + error);
    }

    data.resize(length);
    memcpy(&data[0], decrypted, length);
    free(decrypted);
}
Пример #9
0
    cairo_surface_ptr operator()(marker_svg const & marker) const
    {
        box2d<double> bbox(marker.bounding_box());
        agg::trans_affine tr(transform(bbox));

        double width = std::max(1.0, std::round(bbox.width()));
        double height = std::max(1.0, std::round(bbox.height()));
        cairo_rectangle_t extent { 0, 0, width, height };
        cairo_surface_ptr surface(
            cairo_recording_surface_create(
                CAIRO_CONTENT_COLOR_ALPHA, &extent),
            cairo_surface_closer());

        cairo_ptr cairo = create_context(surface);
        cairo_context context(cairo);

        svg_storage_type & svg = *marker.get_data();
        svg_attribute_type const& svg_attributes = svg.attributes();
        svg::vertex_stl_adapter<svg::svg_path_storage> stl_storage(
            svg.source());
        svg::svg_path_adapter svg_path(stl_storage);

        render_vector_marker(context, svg_path, svg_attributes,
            bbox, tr, opacity_);

        return surface;
    }
Пример #10
0
int main(int argc , const char ** argv) {
  enkf_main_install_SIGNALS();

  const char * config_file                  = argv[1];
  const char * config_file_iterations       = argv[2];
  const char * job_file_create_case         = argv[3];
  const char * job_file_init_case_job       = argv[4];
  const char * job_file_load_results        = argv[5];
  const char * job_file_load_results_iter   = argv[6];
  const char * job_file_observation_ranking = argv[7];
  const char * job_file_data_ranking        = argv[8];
  const char * job_file_ranking_export      = argv[9];
  const char * job_file_init_misfit_table   = argv[10];
  const char * job_file_export_runpath      = argv[11];


  ert_test_context_type * test_context = create_context( config_file, "enkf_workflow_job_test" );
  {
    test_create_case_job(test_context, "JOB1" , job_file_create_case);
    test_init_case_job(test_context, "JOB2", job_file_init_case_job);
    test_load_results_job(test_context, "JOB3" , job_file_load_results);
    test_load_results_iter_job( test_context, "JOB4" , job_file_load_results_iter );
    test_init_misfit_table(test_context, "JOB5" , job_file_init_misfit_table);
    test_rank_realizations_on_observations_job(test_context, "JOB6" , job_file_observation_ranking);
    test_rank_realizations_on_data_job(test_context , "JOB7" , job_file_data_ranking);
    test_export_ranking(test_context, "JOB8" , job_file_ranking_export);
  }
  ert_test_context_free( test_context );

  test_export_runpath_files(config_file, config_file_iterations, job_file_export_runpath);

  exit(0);
}
Пример #11
0
smbresultlist* runtarget(char *target, int maxdepth) {
	SMBCCTX         *context;
	char            buf[256];
	smbresultlist   *res = NULL;

	//Try to create a context, if it's null that means we failed, so let the user know.
	if((context = create_context()) == NULL) {
		smbresult *tmp = createSMBResultEmpty();
		parse_smburl(target, &tmp->host, &tmp->share, &tmp->object);
		tmp->statuscode = errno;
		smbresultlist_push(&res, tmp);
		return res;
	}

	//Check to see if the target has smb:// in front, if not add it.
	if(strncmp("smb://", target, 6) != 0) {
		snprintf(buf, sizeof(buf), "smb://%s", target);
	} else {
		strncpy(buf, target, strlen(target) + 1);
	}

	//Browse to our file and get the goods
	res = browse(context, buf, maxdepth, 0);

	//Delete our context, so there's less segfaults.
	delete_context(context);
	return res;
}
Пример #12
0
struct module* new_module(char* filename) {
  void* handle = dlopen(filename, RTLD_LAZY);
  if (!handle) {
    fprintf(stderr, "%s\n", dlerror());
    return NULL;
  }
  mod_match_function* matcher = dlsym(handle, "matchData");
  if (!matcher) {
    fprintf(stderr, "%s\n", dlerror());
    dlclose(handle);
    return NULL;
  }
  struct module* module = malloc(sizeof(struct module));
  memset(module, 0, sizeof(struct module));
  module->handle = handle;
  module->matcher = matcher;
  mod_create_context* create_context = dlsym(handle, "createContext");
  if (create_context) {
    module->context = create_context();
    mod_free_context* free_context = dlsym(handle, "freeContext");
    if (!free_context)
      fprintf(stderr, "WARNING, you seem to have a createContext() function but no freeContext() function, you're possibly leaking memory.\n");
  }
  return module;
};
Пример #13
0
// The default implementation of halide_acquire_cl_context uses the global
// pointers above, and serializes access with a spin lock.
// Overriding implementations of acquire/release must implement the following
// behavior:
// - halide_acquire_cl_context should always store a valid context/command
//   queue in ctx/q, or return an error code.
// - A call to halide_acquire_cl_context is followed by a matching call to
//   halide_release_cl_context. halide_acquire_cl_context should block while a
//   previous call (if any) has not yet been released via halide_release_cl_context.
WEAK int halide_acquire_cuda_context(void *user_context, CUcontext *ctx) {
    // TODO: Should we use a more "assertive" assert? these asserts do
    // not block execution on failure.
    halide_assert(user_context, ctx != NULL);

    if (cuda_ctx_ptr == NULL) {
        cuda_ctx_ptr = &weak_cuda_ctx;
        cuda_lock_ptr = &weak_cuda_lock;
    }

    halide_assert(user_context, cuda_lock_ptr != NULL);
    while (__sync_lock_test_and_set(cuda_lock_ptr, 1)) { }

    // If the context has not been initialized, initialize it now.
    halide_assert(user_context, cuda_ctx_ptr != NULL);
    if (*cuda_ctx_ptr == NULL) {
        CUresult error = create_context(user_context, cuda_ctx_ptr);
        if (error != CUDA_SUCCESS) {
            __sync_lock_release(cuda_lock_ptr);
            return error;
        }
    }

    *ctx = *cuda_ctx_ptr;
    return 0;
}
static void test_register(gconstpointer data)
{
	struct context *context = create_context(data);
	const struct test_pdu *pdu;
	ssize_t len;
	bool ret;

	context->hfp = hfp_gw_new(context->fd_client);
	g_assert(context->hfp);

	pdu = &context->data->pdu_list[context->pdu_offset++];

	ret = hfp_gw_set_close_on_unref(context->hfp, true);
	g_assert(ret);

	if (context->data->result_func) {
		ret = hfp_gw_register(context->hfp, context->data->result_func,
					(char *)pdu->data, context, NULL);
		g_assert(ret);
	}

	pdu = &context->data->pdu_list[context->pdu_offset++];

	len = write(context->fd_server, pdu->data, pdu->size);
	g_assert_cmpint(len, ==, pdu->size);

	execute_context(context);
}
Пример #15
0
int main( int argc, char **argv )
{
    // etape 1 : creer la fenetre
    Window window= create_window(1024, 640);
    if(window == NULL) 
        return 1;       // erreur lors de la creation de la fenetre ou de l'init de sdl2
    
    // etape 2 : creer un contexte opengl pour pouvoir dessiner
    Context context= create_context(window);
    if(context == NULL) 
        return 1;       // erreur lors de la creation du contexte opengl
    
    // etape 3 : creation des objets 
    if(init() < 0)
    {
        printf("[error] init failed.\n");
        return 1;
    }
    
    // etape 4 : affichage de l'application, tant que la fenetre n'est pas fermee. ou que draw() ne renvoie pas 0
    run(window, draw);

    // etape 5 : nettoyage
    quit();
    release_context(context);
    release_window(window);
    return 0;
}
Пример #16
0
// The default implementation of halide_acquire_cl_context uses the global
// pointers above, and serializes access with a spin lock.
// Overriding implementations of acquire/release must implement the following
// behavior:
// - halide_acquire_cl_context should always store a valid context/command
//   queue in ctx/q, or return an error code.
// - A call to halide_acquire_cl_context is followed by a matching call to
//   halide_release_cl_context. halide_acquire_cl_context should block while a
//   previous call (if any) has not yet been released via halide_release_cl_context.
WEAK int halide_acquire_cl_context(void *user_context, cl_context *ctx, cl_command_queue *q) {
    // TODO: Should we use a more "assertive" assert? These asserts do
    // not block execution on failure.
    halide_assert(user_context, ctx != NULL);
    halide_assert(user_context, q != NULL);

    // If the context pointers aren't hooked up, use our weak globals.
    if (cl_ctx_ptr == NULL) {
        cl_ctx_ptr = &weak_cl_ctx;
        cl_q_ptr = &weak_cl_q;
        cl_lock_ptr = &weak_cl_lock;
    }

    halide_assert(user_context, cl_lock_ptr != NULL);
    while (__sync_lock_test_and_set(cl_lock_ptr, 1)) { }

    // If the context has not been initialized, initialize it now.
    halide_assert(user_context, cl_ctx_ptr != NULL);
    halide_assert(user_context, cl_q_ptr != NULL);
    if (!(*cl_ctx_ptr)) {
        cl_int error = create_context(user_context, cl_ctx_ptr, cl_q_ptr);
        if (error != CL_SUCCESS) {
            __sync_lock_release(cl_lock_ptr);
            return error;
        }
    }

    *ctx = *cl_ctx_ptr;
    *q = *cl_q_ptr;
    return 0;
}
void perfmon_init(void)
{
	size_t i;
	long nr;

	if (cpu_type == CPU_TIMER_INT)
		return;

	if (!no_xen) {
		xen_ctx = xmalloc(sizeof(struct child));
		xen_ctx->pid = getpid();
		xen_ctx->up_pipe[0] = -1;
		xen_ctx->up_pipe[1] = -1;
		xen_ctx->sigusr1 = 0;
		xen_ctx->sigusr2 = 0;
		xen_ctx->sigterm = 0;

		create_context(xen_ctx);

		write_pmu(xen_ctx);
		
		load_context(xen_ctx);
		return;
	}
	

	nr = sysconf(_SC_NPROCESSORS_ONLN);
	if (nr == -1) {
		fprintf(stderr, "Couldn't determine number of CPUs.\n");
		exit(EXIT_FAILURE);
	}

	nr_cpus = nr;

	children = xmalloc(sizeof(struct child) * nr_cpus);
	bzero(children, sizeof(struct child) * nr_cpus);

	for (i = 0; i < nr_cpus; ++i) {
		int ret;

		if (pipe(children[i].up_pipe)) {
			perror("Couldn't create child pipe");
			exit(EXIT_FAILURE);
		}

		ret = fork();
		if (ret == -1) {
			perror("Couldn't fork perfmon child");
			exit(EXIT_FAILURE);
		} else if (ret == 0) {
			close(children[i].up_pipe[0]);
			run_child(i);
		} else {
			children[i].pid = ret;
			close(children[i].up_pipe[1]);
			printf("Waiting on CPU%d\n", (int)i);
			wait_for_child(&children[i]);
		}
	}
}
Пример #18
0
int main( int argc, char **argv )
{
    if(argc == 1)
    {
        printf("usage: %s shader.glsl [mesh.obj] [texture0.png [texture1.png]]\n", argv[0]);
        return 0;
    }
    
    Window window= create_window(1024, 640);
    if(window == NULL) 
        return 1;
    
    Context context= create_context(window);
    if(context == NULL) 
        return 1;
    
    // creation des objets opengl
    std::vector<const char *> options(argv + 1, argv + argc);
    if(init(options) < 0)
    {
        printf("[error] init failed.\n");
        return 1;
    }
    
    // affichage de l'application
    run(window, draw);

    // nettoyage
    quit();
    release_context(context);
    release_window(window);
    return 0;
}
static void run_child(size_t cpu)
{
	struct child * self = &children[cpu];

	self->pid = getpid();
	self->sigusr1 = 0;
	self->sigusr2 = 0;
	self->sigterm = 0;

	inner_child = self;
	if (atexit(close_pipe)){
		close_pipe();
		exit(EXIT_FAILURE);
	}

	umask(0);
	/* Change directory to allow directory to be removed */
	if (chdir("/") < 0) {
		perror("Unable to chdir to \"/\"");
		exit(EXIT_FAILURE);
	}

	setup_signals();

	set_affinity(cpu);

	create_context(self);

	write_pmu(self);

	load_context(self);

	notify_parent(self, cpu);

	/* Redirect standard files to /dev/null */
	freopen( "/dev/null", "r", stdin);
	freopen( "/dev/null", "w", stdout);
	freopen( "/dev/null", "w", stderr);

	for (;;) {
		sigset_t sigmask;
		sigfillset(&sigmask);
		sigdelset(&sigmask, SIGUSR1);
		sigdelset(&sigmask, SIGUSR2);
		sigdelset(&sigmask, SIGTERM);

		if (self->sigusr1) {
			perfmon_start_child(self->ctx_fd);
			self->sigusr1 = 0;
		}

		if (self->sigusr2) {
			perfmon_stop_child(self->ctx_fd);
			self->sigusr2 = 0;
		}

		sigsuspend(&sigmask);
	}
}
Пример #20
0
extern GLXContext glXCreateContextWithConfigSGIX (Display *dpy, GLXFBConfigSGIX config, int renderType, GLXContext shareList, Bool direct)
{
	GLXContext ctx;

	GH_GET_PTR_GL(glXCreateContextWithConfigSGIX);
	ctx=GH_glXCreateContextWithConfigSGIX(dpy, config, renderType, shareList, direct);
	create_context(ctx);
	return ctx;
}
Пример #21
0
extern GLXContext glXImportContextEXT (Display *dpy, GLXContextID id)
{
	GLXContext ctx;

	GH_GET_PTR_GL(glXImportContextEXT);
	ctx=GH_glXImportContextEXT(dpy, id);
	create_context(ctx);
	return ctx;
}
Пример #22
0
extern GLXContext glXCreateContext(Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct )
{
	GLXContext ctx;

	GH_GET_PTR_GL(glXCreateContext);
	ctx=GH_glXCreateContext(dpy, vis, shareList, direct);
	create_context(ctx);
	return ctx;
}
Пример #23
0
extern GLXContext glXCreateContextAttribsARB (Display * dpy, GLXFBConfig config, GLXContext shareList, Bool direct, const int *attr)
{
	GLXContext ctx;

	GH_GET_PTR_GL(glXCreateContextAttribsARB);
	ctx=GH_glXCreateContextAttribsARB(dpy, config, shareList, direct, attr);
	create_context(ctx);
	return ctx;
}
Пример #24
0
 cairo_surface_ptr operator() (marker_null const&) const
 {
     cairo_surface_ptr surface(
         cairo_recording_surface_create(
             CAIRO_CONTENT_COLOR_ALPHA, nullptr),
         cairo_surface_closer());
     cairo_ptr cairo = create_context(surface);
     cairo_context context(cairo);
     return surface;
 }
Пример #25
0
static void event_attach_done(void * x) {
    AttachDoneArgs * args = (AttachDoneArgs *)x;
    if (context_find_from_pid(args->pid, 0) != NULL) {
        args->done(ERR_ALREADY_ATTACHED, NULL, args->data);
    }
    else {
        Context * ctx = NULL;
        if (parent_ctx == NULL) {
            pid_t pid = taskIdSelf();
            parent_ctx = create_context(pid2id(pid, 0));
            EXT(parent_ctx)->pid = pid;
            parent_ctx->mem = parent_ctx;
            parent_ctx->mem_access |= MEM_ACCESS_INSTRUCTION;
            parent_ctx->mem_access |= MEM_ACCESS_DATA;
            parent_ctx->big_endian = big_endian_host();
            link_context(parent_ctx);
            send_context_created_event(parent_ctx);
        }
        assert(parent_ctx->ref_count > 0);
        ctx = create_context(pid2id(args->pid, EXT(parent_ctx)->pid));
        EXT(ctx)->pid = args->pid;
        EXT(ctx)->regs = (REG_SET *)loc_alloc(sizeof(REG_SET));
        ctx->mem = parent_ctx;
        ctx->big_endian = parent_ctx->big_endian;
        (ctx->parent = parent_ctx)->ref_count++;
        list_add_last(&ctx->cldl, &parent_ctx->children);
        link_context(ctx);
        trace(LOG_CONTEXT, "context: attached: ctx %#lx, id %#x", ctx, EXT(ctx)->pid);
        send_context_created_event(ctx);
        args->done(0, ctx, args->data);
        if (taskIsStopped(args->pid)) {
            struct event_info * info;
            ctx->pending_intercept = 1;
            info = event_info_alloc(EVENT_HOOK_STOP);
            if (info != NULL) {
                info->stopped_ctx.ctxId = args->pid;
                event_info_post(info);
            }
        }
    }
    loc_free(x);
}
Пример #26
0
Context * context_get_group(Context * ctx, int group) {
    static Context * cpu_group = NULL;
    switch (group) {
    case CONTEXT_GROUP_INTERCEPT:
        return ctx;
    case CONTEXT_GROUP_CPU:
        if (cpu_group == NULL) cpu_group = create_context("CPU");
        return cpu_group;
    }
    return ctx->mem;
}
int
main(int argc, char **argv)
{
	GLenum internal_format = 0;

	EGLDisplay dpy;
	EGLContext ctx;
	bool ok;

	/* Strip common piglit args. */
	piglit_strip_arg(&argc, argv, "-fbo");
	piglit_strip_arg(&argc, argv, "-auto");

	if (argc == 2) {
		if (streq(argv[1], "GL_RGBA")) {
			internal_format = GL_RGBA;
		} else if (streq(argv[1], "GL_DEPTH_COMPONENT24")) {
			internal_format = GL_DEPTH_COMPONENT24;
		}
	}

	if (internal_format == 0)
		usage_error();

	dpy = create_display();
	ctx = create_context(dpy);

	ok = eglMakeCurrent(dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx);
	if (!ok) {
		piglit_loge("failed to make context current without surface");
		piglit_report_result(PIGLIT_FAIL);
	}

	piglit_dispatch_default_init(PIGLIT_DISPATCH_ES2);

	if (!piglit_is_extension_supported("GL_OES_EGL_image")) {
		piglit_loge("context does not support GL_OES_EGL_image");
		piglit_report_result(PIGLIT_SKIP);
	}

	switch (internal_format) {
	case GL_RGBA:
		test_rgba(dpy, ctx);
		break;
	case GL_DEPTH_COMPONENT24:
		test_depth24(dpy, ctx);
		break;
	default:
		break;
	}

	/* unreachable */
	abort();
}
Пример #28
0
int main()
{
  printf("starting test\n");
  FILE* input = fopen("screenshot.bin", "rb");
  if(input == NULL)
  {
    printf("Couldn't find file\n");
    exit(1);
  }
  
  encoder_context* context = create_context();
  init_encoder(context, 1366, 768);
  init_codec(context);
  init_image(context);
  
  struct stat stat_info;
  int result = stat("screenshot.bin", &stat_info);
  if(result)
  {
    fatal("Could not fstat");
  }
  
  char* buffer = malloc(stat_info.st_size);
  fread(buffer, stat_info.st_size, 1, input);
  
  /*
  memset(buffer, 0xF, stat_info.st_size);
  
  int a;
  for(a = 0; a < stat_info.st_size; a++)
  {
    if(a % 4 == 0)
    {
      buffer[a] = 0x0;
    }
  }*/
  
  convert_frame(context, buffer);
  FILE* output = fopen("mem.bin", "wb");
  fwrite(context->raw->planes[2], 100000, 1, output);
  fflush(output);
  printf("Size is %d\n", context->raw->stride[3]);

  int i;
  for(i = 0; i < 100; i++)
  {
  convert_frame(context, buffer);
  
  encode_next_frame(context);
  }
  encode_finish(context);
  
  printf("Finished test\n");
}
void CL_OpenGLWindowProvider_GLX::create_glx_1_2(CL_DisplayWindowSite *new_site, const CL_DisplayWindowDescription &desc, Display *disp)
{
	// Setup OpenGL:
	int gl_attribs_single[] =
	{
		GLX_RGBA,
		GLX_DEPTH_SIZE, 16,
		GLX_STENCIL_SIZE, 8,
		GLX_BUFFER_SIZE, 24,
		None
	};

	int i = 0;

	CL_OpenGLWindowDescription gl_desc(desc);

	int gl_attribs[32];	// WARNING - create() assumes this is 32 in size

	// Note: gl_attribs[32] !!!!
	gl_attribs[i++] = GLX_RGBA;
	if( gl_desc.get_doublebuffer() ) gl_attribs[i++] = GLX_DOUBLEBUFFER;
	if( gl_desc.get_stereo() ) gl_attribs[i++] = GLX_STEREO;
	gl_attribs[i++] = GLX_BUFFER_SIZE;
	gl_attribs[i++] = gl_desc.get_buffer_size();
	gl_attribs[i++] = GLX_RED_SIZE; 
	gl_attribs[i++] = gl_desc.get_red_size();
	gl_attribs[i++] = GLX_GREEN_SIZE;
	gl_attribs[i++] = gl_desc.get_green_size();
	gl_attribs[i++] = GLX_BLUE_SIZE;
	gl_attribs[i++] = gl_desc.get_blue_size();
	gl_attribs[i++] = GLX_DEPTH_SIZE;
	gl_attribs[i++] = gl_desc.get_depth_size();
	gl_attribs[i++] = GLX_STENCIL_SIZE;
	gl_attribs[i++] = gl_desc.get_stencil_size();
	gl_attribs[i++] = None;

	// get an appropriate visual
	if (opengl_visual_info) XFree(opengl_visual_info);
	opengl_visual_info = glx.glXChooseVisual(disp, DefaultScreen(disp), gl_attribs);

	if (opengl_visual_info == NULL)
	{
		opengl_visual_info = glx.glXChooseVisual(disp, DefaultScreen(disp), gl_attribs_single);
		printf("Requested visual not supported by your OpenGL implementation. Falling back on singlebuffered Visual!\n");
		if (opengl_visual_info == NULL)
		{
			throw CL_Exception("glxChooseVisual failed");
		}
	}

	// create a GLX context
	opengl_context = create_context(gl_desc);

}
Пример #30
0
int main()
{
  initialize_memory();
  register_callbacks();
  create_context();
  load_program();
  allocate_control_block();
  run_kernel_loop();
  free_memory();  
  return 0;
}