Example #1
0
static inline void
renderer_draw(struct xa_context *r)
{
    int num_verts = r->buffer_size / (r->attrs_per_vertex * NUM_COMPONENTS);

    if (!r->buffer_size)
	return;

    if (!r->scissor_valid) {
	r->scissor.minx = 0;
	r->scissor.miny = 0;
	r->scissor.maxx = r->dst->tex->width0;
	r->scissor.maxy = r->dst->tex->height0;
    }

    r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor);

    cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
    util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                 num_verts,	/* verts */
                                 r->attrs_per_vertex);	/* attribs/vert */
    r->buffer_size = 0;

    xa_scissor_reset(r);
}
Example #2
0
void
renderer_draw_yuv(struct xa_context *r,
		  float src_x,
		  float src_y,
		  float src_w,
		  float src_h,
		  int dst_x,
		  int dst_y, int dst_w, int dst_h, struct xa_surface *srf[])
{
   const int num_attribs = 2;	/*pos + tex coord */

   setup_vertex_data_yuv(r,
                         src_x, src_y, src_w, src_h,
                         dst_x, dst_y, dst_w, dst_h, srf);

   if (!r->scissor_valid) {
       r->scissor.minx = 0;
       r->scissor.miny = 0;
       r->scissor.maxx = r->dst->tex->width0;
       r->scissor.maxy = r->dst->tex->height0;
   }

   r->pipe->set_scissor_states(r->pipe, 0, 1, &r->scissor);

   cso_set_vertex_elements(r->cso, num_attribs, r->velems);
   util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                4,	/* verts */
                                num_attribs);	/* attribs/vert */
   r->buffer_size = 0;

   xa_scissor_reset(r);
}
Example #3
0
static void
util_draw_fullscreen_quad(struct cso_context *cso)
{
   static float vertices[] = {
     -1, -1, 0, 1,   0, 0, 0, 0,
     -1,  1, 0, 1,   0, 1, 0, 0,
      1,  1, 0, 1,   1, 1, 0, 0,
      1, -1, 0, 1,   1, 0, 0, 0
   };
   util_set_interleaved_vertex_elements(cso, 2);
   util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2);
}
Example #4
0
/**
 * Test TGSI_PROPERTY_VS_WINDOW_SPACE_POSITION.
 *
 * The viewport state is set as usual, but it should have no effect.
 * Clipping should also be disabled.
 *
 * POSITION.xyz should already be multiplied by 1/w and POSITION.w should
 * contain 1/w. By setting w=0, we can test that POSITION.xyz isn't
 * multiplied by 1/w (otherwise nothing would be rendered).
 *
 * TODO: Whether the value of POSITION.w is correctly interpreted as 1/w
 *       during perspective interpolation is not tested.
 */
static void
tgsi_vs_window_space_position(struct pipe_context *ctx)
{
   struct cso_context *cso;
   struct pipe_resource *cb;
   void *fs, *vs;
   bool pass = true;
   static const float red[] = {1, 0, 0, 1};

   if (!ctx->screen->get_param(ctx->screen,
                               PIPE_CAP_TGSI_VS_WINDOW_SPACE_POSITION)) {
      util_report_result(SKIP);
      return;
   }

   cso = cso_create_context(ctx);
   cb = util_create_texture2d(ctx->screen, 256, 256,
                              PIPE_FORMAT_R8G8B8A8_UNORM);
   util_set_common_states_and_clear(cso, ctx, cb);

   /* Fragment shader. */
   fs = util_make_fragment_passthrough_shader(ctx, TGSI_SEMANTIC_GENERIC,
                                       TGSI_INTERPOLATE_LINEAR, TRUE);
   cso_set_fragment_shader_handle(cso, fs);

   /* Vertex shader. */
   vs = util_set_passthrough_vertex_shader(cso, ctx, true);

   /* Draw. */
   {
      static float vertices[] = {
          0,   0, 0, 0,   1,  0, 0, 1,
          0, 256, 0, 0,   1,  0, 0, 1,
        256, 256, 0, 0,   1,  0, 0, 1,
        256,   0, 0, 0,   1,  0, 0, 1,
      };
      util_set_interleaved_vertex_elements(cso, 2);
      util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2);
   }

   /* Probe pixels. */
   pass = pass && util_probe_rect_rgba(ctx, cb, 0, 0,
                                       cb->width0, cb->height0, red);

   /* Cleanup. */
   cso_destroy_context(cso);
   ctx->delete_vs_state(ctx, vs);
   ctx->delete_fs_state(ctx, fs);
   pipe_resource_reference(&cb, NULL);

   util_report_result(pass);
}
Example #5
0
static void
util_draw_fullscreen_quad_fill(struct cso_context *cso,
                               float r, float g, float b, float a)
{
   float vertices[] = {
     -1, -1, 0, 1,   r, g, b, a,
     -1,  1, 0, 1,   r, g, b, a,
      1,  1, 0, 1,   r, g, b, a,
      1, -1, 0, 1,   r, g, b, a,
   };
   util_set_interleaved_vertex_elements(cso, 2);
   util_draw_user_vertex_buffer(cso, vertices, PIPE_PRIM_QUADS, 4, 2);
}
Example #6
0
static INLINE void
renderer_draw(struct xa_context *r)
{
    int num_verts = r->buffer_size / (r->attrs_per_vertex * NUM_COMPONENTS);

    if (!r->buffer_size)
	return;

    cso_set_vertex_elements(r->cso, r->attrs_per_vertex, r->velems);
    util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                 num_verts,	/* verts */
                                 r->attrs_per_vertex);	/* attribs/vert */
    r->buffer_size = 0;
}
Example #7
0
void
renderer_draw_yuv(struct xa_context *r,
		  float src_x,
		  float src_y,
		  float src_w,
		  float src_h,
		  int dst_x,
		  int dst_y, int dst_w, int dst_h, struct xa_surface *srf[])
{
   const int num_attribs = 2;	/*pos + tex coord */

   setup_vertex_data_yuv(r,
                         src_x, src_y, src_w, src_h,
                         dst_x, dst_y, dst_w, dst_h, srf);

   cso_set_vertex_elements(r->cso, num_attribs, r->velems);
   util_draw_user_vertex_buffer(r->cso, r->buffer, PIPE_PRIM_QUADS,
                                4,	/* verts */
                                num_attribs);	/* attribs/vert */
   r->buffer_size = 0;
}
Example #8
0
/**
 * Draw renderer quad.
 */
static void renderer_quad_draw(struct renderer *r)
{
   util_draw_user_vertex_buffer(r->cso, r->vertices, PIPE_PRIM_TRIANGLE_FAN,
                                Elements(r->vertices),     /* verts */
                                Elements(r->vertices[0])); /* attribs/vert */
}