Esempio n. 1
0
static void 
trace_winsys_flush_frontbuffer(struct pipe_winsys *_winsys,
                               struct pipe_surface *surface,
                               void *context_private)
{
   struct trace_winsys *tr_ws = trace_winsys(_winsys);
   struct pipe_winsys *winsys = tr_ws->winsys;

   assert(surface);
   if(surface->texture) {
      struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
      struct trace_texture *tr_tex = trace_texture(tr_scr, surface->texture);
      struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
      surface = tr_surf->surface;
   }
   
   trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
   
   trace_dump_arg(ptr, winsys);
   trace_dump_arg(ptr, surface);
   /* XXX: hide, as there is nothing we can do with this
   trace_dump_arg(ptr, context_private);
   */

   winsys->flush_frontbuffer(winsys, surface, context_private);
   
   trace_dump_call_end();
}
void trace_dump_surface_ptr(struct pipe_surface *_surface)
{
   if (!dumping)
      return;

   if (_surface) {
      struct trace_surface *tr_surf = trace_surface(_surface);
      trace_dump_ptr(tr_surf->surface);
   } else {
      trace_dump_null();
   }
}
static int flip_buffer_vsync(struct fb_info *info, unsigned long arg)
{
	void __user *argp = (void __user *)arg;
	struct mmpfb_info *fbi = info->par;
	struct mmp_surface surface;

	if (copy_from_user(&surface, argp, sizeof(struct mmp_surface)))
		return -EFAULT;
	check_pitch(&surface);
	trace_surface(fbi->overlay->id, &surface);
	mmp_overlay_set_surface(fbi->overlay, &surface.win, &surface.addr);
	return 0;
}
Esempio n. 4
0
static void
trace_screen_tex_surface_destroy(struct pipe_surface *_surface)
{
   struct trace_screen *tr_scr = trace_screen(_surface->texture->screen);
   struct trace_surface *tr_surf = trace_surface(_surface);
   struct pipe_screen *screen = tr_scr->screen;
   struct pipe_surface *surface = tr_surf->surface;

   trace_dump_call_begin("pipe_screen", "tex_surface_destroy");

   trace_dump_arg(ptr, screen);
   trace_dump_arg(ptr, surface);

   trace_dump_call_end();

   trace_surface_destroy(tr_surf);
}
Esempio n. 5
0
static INLINE struct pipe_surface *
trace_surface_unwrap(struct trace_context *tr_ctx,
                     struct pipe_surface *surface)
{
   struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen);
   struct trace_surface *tr_surf;

   if(!surface)
      return NULL;

   assert(surface->texture);
   if(!surface->texture)
      return surface;

   tr_surf = trace_surface(surface);

   assert(tr_surf->surface);
   assert(tr_surf->surface->texture->screen == tr_scr->screen);
   (void) tr_scr;
   return tr_surf->surface;
}
Esempio n. 6
0
static void
trace_screen_flush_frontbuffer(struct pipe_screen *_screen,
                               struct pipe_surface *_surface,
                               void *context_private)
{
   struct trace_screen *tr_scr = trace_screen(_screen);
   struct trace_surface *tr_surf = trace_surface(_surface);
   struct pipe_screen *screen = tr_scr->screen;
   struct pipe_surface *surface = tr_surf->surface;

   trace_dump_call_begin("pipe_screen", "flush_frontbuffer");

   trace_dump_arg(ptr, screen);
   trace_dump_arg(ptr, surface);
   /* XXX: hide, as there is nothing we can do with this
   trace_dump_arg(ptr, context_private);
   */

   screen->flush_frontbuffer(screen, surface, context_private);

   trace_dump_call_end();
}
Esempio n. 7
0
/**
 * XXX: Dispatch pipe_screen::flush_front_buffer to our 
 * stw_winsys::flush_front_buffer.
 */
static void 
stw_flush_frontbuffer(struct pipe_screen *screen,
                     struct pipe_surface *surface,
                     void *context_private )
{
   const struct stw_winsys *stw_winsys = stw_dev->stw_winsys;
   HDC hdc = (HDC)context_private;
   struct stw_framebuffer *fb;
   
   fb = stw_framebuffer_from_hdc( hdc );
   /* fb can be NULL if window was destroyed already */
   if (fb) {
#if DEBUG
      {
         struct pipe_surface *surface2;
   
         if(!st_get_framebuffer_surface( fb->stfb, ST_SURFACE_FRONT_LEFT, &surface2 ))
            assert(0);
         else
            assert(surface2 == surface);
      }
#endif

#ifdef DEBUG
      if(stw_dev->trace_running) {
         screen = trace_screen(screen)->screen;
         surface = trace_surface(surface)->surface;
      }
#endif
   }
   
   stw_winsys->flush_frontbuffer(screen, surface, hdc);
   
   if(fb) {
      stw_framebuffer_update(fb);
      stw_framebuffer_release(fb);
   }
}
Esempio n. 8
0
void Tracer::trace_assembly(Assembly* assembly, Ray* rays, Ray* rays_end) {
	BVH4StreamTraverser traverser;

	// Initialize traverser
	traverser.init_accel(assembly->object_accel);
	traverser.init_rays(rays, rays_end);

	// Trace rays one object at a time
	std::tuple<Ray*, Ray*, size_t> hits = traverser.next_object();
	while (std::get<0>(hits) != std::get<1>(hits)) {
		const auto& instance = assembly->instances[std::get<2>(hits)]; // Short-hand for the current instance

		// Push the current instance index onto the element id
		const auto element_id_bits = assembly->element_id_bits();
		element_id.push_back(std::get<2>(hits), element_id_bits);

		// Propagate transforms (if necessary)
		const auto parent_xforms = xform_stack.top_frame<Transform>();
		const size_t parent_xforms_count = std::distance(parent_xforms.first, parent_xforms.second);
		if (instance.transform_count > 0) {
			const auto xbegin = &(*(assembly->xforms.begin() + instance.transform_index));
			const auto xend = xbegin + instance.transform_count;
			const auto larger_xform_count = std::max(instance.transform_count, parent_xforms_count);

			// Push merged transforms onto transform stack
			auto xforms = xform_stack.push_frame<Transform>(larger_xform_count);
			merge(xforms.first, parent_xforms.first, parent_xforms.second, xbegin, xend);

			for (auto ray = std::get<0>(hits); ray != std::get<1>(hits); ++ray) {
				w_rays[ray->id()].update_ray(ray, lerp_seq(ray->time, xforms.first, xforms.second));
			}
		}

		// Check for shader on the instance, and push to shader stack if it
		// has one.
		if (instance.surface_shader != nullptr) {
			surface_shader_stack.emplace_back(instance.surface_shader);
		}

		// Trace against the object or assembly
		if (instance.type == Instance::OBJECT) {
			Object* obj = assembly->objects[instance.data_index].get(); // Short-hand for the current object
			// Branch to different code path based on object type
			switch (obj->get_type()) {
				case Object::SURFACE:
					trace_surface(reinterpret_cast<Surface*>(obj), std::get<0>(hits), std::get<1>(hits));
					break;
				case Object::COMPLEX_SURFACE:
					trace_complex_surface(reinterpret_cast<ComplexSurface*>(obj), std::get<0>(hits), std::get<1>(hits));
					break;
				case Object::PATCH_SURFACE:
					trace_patch_surface(reinterpret_cast<PatchSurface*>(obj), std::get<0>(hits), std::get<1>(hits));
					break;
				case Object::LIGHT:
					trace_lightsource(reinterpret_cast<Light*>(obj), std::get<0>(hits), std::get<1>(hits));
					break;
				default:
					//std::cout << "WARNING: unknown object type, skipping." << std::endl;
					break;
			}

			Global::Stats::object_ray_tests += std::distance(std::get<0>(hits), std::get<1>(hits));
		} else { /* Instance::ASSEMBLY */
			Assembly* asmb = assembly->assemblies[instance.data_index].get(); // Short-hand for the current object
			trace_assembly(asmb, std::get<0>(hits), std::get<1>(hits));
		}

		// Pop shader stack if we pushed onto it earlier
		if (instance.surface_shader != nullptr) {
			surface_shader_stack.pop_back();
		}

		// Un-transform rays if we transformed them earlier
		if (instance.transform_count > 0) {
			if (parent_xforms_count > 0) {
				for (auto ray = std::get<0>(hits); ray != std::get<1>(hits); ++ray) {
					w_rays[ray->id()].update_ray(ray, lerp_seq(ray->time, parent_xforms.first, parent_xforms.second));
				}
			} else {
				for (auto ray = std::get<0>(hits); ray != std::get<1>(hits); ++ray) {
					w_rays[ray->id()].update_ray(ray);
				}
			}

			// Pop top off of xform stack
			xform_stack.pop_frame();
		}

		// Pop the index of this instance off the element id
		element_id.pop_back(element_id_bits);

		// Get next object to test against
		hits = traverser.next_object();
	}
}