if(templat->last_level >= SVGA_MAX_TEXTURE_LEVELS)
goto error2;
- width = templat->width[0];
- height = templat->height[0];
- depth = templat->depth[0];
+ width = templat->width0;
+ height = templat->height0;
+ depth = templat->depth0;
for(level = 0; level <= templat->last_level; ++level) {
- tex->base.width[level] = width;
- tex->base.height[level] = height;
- tex->base.depth[level] = depth;
tex->base.nblocksx[level] = pf_get_nblocksx(&tex->base.block, width);
tex->base.nblocksy[level] = pf_get_nblocksy(&tex->base.block, height);
- width = minify(width);
- height = minify(height);
- depth = minify(depth);
+ width = u_minify(width, 1);
+ height = u_minify(height, 1);
+ depth = u_minify(depth, 1);
}
- size.width = templat->width0;
- size.height = templat->height0;
- size.depth = templat->depth0;
+ tex->key.flags = 0;
- tex->key.size.width = templat->width[0];
- tex->key.size.height = templat->height[0];
- tex->key.size.depth = templat->depth[0];
++ tex->key.size.width = templat->width0;
++ tex->key.size.height = templat->height0;
++ tex->key.size.depth = templat->depth0;
if(templat->target == PIPE_TEXTURE_CUBE) {
- flags |= SVGA3D_SURFACE_CUBEMAP;
- numFaces = 6;
+ tex->key.flags |= SVGA3D_SURFACE_CUBEMAP;
+ tex->key.numFaces = 6;
}
else {
- numFaces = 1;
+ tex->key.numFaces = 1;
}
if(templat->tex_usage & PIPE_TEXTURE_USAGE_SAMPLER)
"svga: Create surface view: face %d zslice %d mips %d..%d\n",
face_pick, zslice_pick, start_mip, start_mip+num_mip-1);
- size.width = u_minify(tex->base.width0, start_mip);
- size.height = u_minify(tex->base.height0, start_mip);
- size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
- assert(size.depth == 1);
+ key->flags = 0;
+ key->format = format;
+ key->numMipLevels = num_mip;
- key->size.width = tex->base.width[start_mip];
- key->size.height = tex->base.height[start_mip];
- key->size.depth = zslice_pick < 0 ? tex->base.depth[start_mip] : 1;
++ key->size.width = u_minify(tex->base.width0, start_mip);
++ key->size.height = u_minify(tex->base.height0, start_mip);
++ key->size.depth = zslice_pick < 0 ? u_minify(tex->base.depth0, start_mip) : 1;
+ key->cachable = 1;
+ assert(key->size.depth == 1);
if(tex->base.target == PIPE_TEXTURE_CUBE && face_pick < 0) {
- flags |= SVGA3D_SURFACE_CUBEMAP;
- numFaces = 6;
+ key->flags |= SVGA3D_SURFACE_CUBEMAP;
+ key->numFaces = 6;
} else {
- numFaces = 1;
+ key->numFaces = 1;
}
- if(format == SVGA3D_FORMAT_INVALID)
+ if(key->format == SVGA3D_FORMAT_INVALID) {
+ key->cachable = 0;
return NULL;
+ }
- handle = sws->surface_create(sws, flags, format, size, numFaces, numMipLevels);
-
- if (!handle)
+ SVGA_DBG(DEBUG_DMA, "surface_create for texture view\n");
+ handle = svga_screen_surface_create(ss, key);
+ if (!handle) {
+ key->cachable = 0;
return NULL;
+ }
- SVGA_DBG(DEBUG_DMA, "create sid %p (texture view)\n", handle);
+ SVGA_DBG(DEBUG_DMA, " --> got sid %p (texture view)\n", handle);
if (face_pick < 0)
face_pick = 0;
if (zslice_pick >= 0)
z_offset = zslice_pick;
- for (i = 0; i < num_mip; i++) {
- for (j = 0; j < numFaces; j++) {
+ for (i = 0; i < key->numMipLevels; i++) {
+ for (j = 0; j < key->numFaces; j++) {
if(tex->defined[j + face_pick][i + start_mip]) {
- unsigned depth = zslice_pick < 0 ? u_minify(tex->base.depth0, i + start_mip) : 1;
- svga_texture_copy_handle(svga_context(pipe), ss,
- tex->handle, 0, 0, z_offset, i + start_mip, j + face_pick,
- unsigned depth = zslice_pick < 0 ? tex->base.depth[i + start_mip] : 1;
++ unsigned depth = (zslice_pick < 0 ?
++ u_minify(tex->base.depth0, i + start_mip) :
++ 1);
++
+ svga_texture_copy_handle(svga_context(pipe),
+ ss,
+ tex->handle,
+ 0, 0, z_offset,
+ i + start_mip,
+ j + face_pick,
handle, 0, 0, 0, i, j,
- tex->base.width[i + start_mip],
- tex->base.height[i + start_mip],
+ u_minify(tex->base.width0, i + start_mip),
- u_minify(tex->base.height0, i + start_mip), depth);
++ u_minify(tex->base.height0, i + start_mip),
+ depth);
}
}
}
SVGA3dSurfaceFormat format;
s = CALLOC_STRUCT(svga_surface);
- ps = &s->base;
- if (!ps)
+ if (!s)
return NULL;
- pipe_reference_init(&ps->reference, 1);
- pipe_texture_reference(&ps->texture, pt);
- ps->format = pt->format;
- ps->width = u_minify(pt->width0, level);
- ps->height = u_minify(pt->height0, level);
- ps->usage = flags;
- ps->level = level;
- ps->face = face;
- ps->zslice = zslice;
+ pipe_reference_init(&s->base.reference, 1);
+ pipe_texture_reference(&s->base.texture, pt);
+ s->base.format = pt->format;
- s->base.width = pt->width[level];
- s->base.height = pt->height[level];
++ s->base.width = u_minify(pt->width0, level);
++ s->base.height = u_minify(pt->height0, level);
+ s->base.usage = flags;
+ s->base.level = level;
+ s->base.face = face;
+ s->base.zslice = zslice;
if (!render)
format = svga_translate_format(pt->format);
"svga: Sampler view: no %p, mips %u..%u, nr %u, size (%ux%ux%u), last %u\n",
pt, min_lod, max_lod,
max_lod - min_lod + 1,
- pt->width[0],
- pt->height[0],
- pt->depth[0],
+ pt->width0,
+ pt->height0,
+ pt->depth0,
pt->last_level);
+ sv->key.cachable = 0;
sws->surface_reference(sws, &sv->handle, tex->handle);
return sv;
}
exa->bound_textures);
}
- static void
- setup_vs_constant_buffer(struct exa_context *exa,
- int width, int height)
- {
- const int param_bytes = 8 * sizeof(float);
- float vs_consts[8] = {
- 2.f/width, 2.f/height, 1, 1,
- -1, -1, 0, 0
- };
- renderer_set_constants(exa->renderer, PIPE_SHADER_VERTEX,
- vs_consts, param_bytes);
- }
-
-
- static void
- setup_fs_constant_buffer(struct exa_context *exa)
- {
- const int param_bytes = 4 * sizeof(float);
- const float fs_consts[8] = {
- 0, 0, 0, 1,
- };
- renderer_set_constants(exa->renderer, PIPE_SHADER_FRAGMENT,
- fs_consts, param_bytes);
- }
-
- static void
- setup_constant_buffers(struct exa_context *exa, struct exa_pixmap_priv *pDst)
- {
- int width = pDst->tex->width0;
- int height = pDst->tex->height0;
- setup_vs_constant_buffer(exa, width, height);
- setup_fs_constant_buffer(exa);
- }
-
-
static INLINE boolean matrix_from_pict_transform(PictTransform *trans, float *matrix)
{
if (!trans)
PIPE_REFERENCED_FOR_WRITE)
exa->pipe->flush(exa->pipe, 0, NULL);
- assert(pPix->drawable.width <= priv->tex->width[0]);
- assert(pPix->drawable.height <= priv->tex->height[0]);
++ assert(pPix->drawable.width <= priv->tex->width0);
++ assert(pPix->drawable.height <= priv->tex->height0);
+
priv->map_transfer =
exa->scrn->get_tex_transfer(exa->scrn, priv->tex, 0, 0, 0,
#ifdef EXA_MIXED_PIXMAPS
PIPE_TRANSFER_MAP_DIRECTLY |
#endif
PIPE_TRANSFER_READ_WRITE,
++<<<<<<< HEAD:src/gallium/state_trackers/xorg/xorg_exa.c
+ 0, 0, priv->tex->width0, priv->tex->height0);
++=======
+ 0, 0,
+ pPix->drawable.width,
+ pPix->drawable.height );
++>>>>>>> origin/mesa_7_7_branch:src/gallium/state_trackers/xorg/xorg_exa.c
if (!priv->map_transfer)
#ifdef EXA_MIXED_PIXMAPS
return FALSE;
debug_assert(priv == exa->copy.dst);
- renderer_copy_pixmap(exa->renderer, exa->copy.dst, dstX, dstY,
- exa->copy.src, srcX, srcY,
- width, height);
+ if (exa->copy.use_surface_copy) {
+ /* XXX: consider exposing >1 box in surface_copy interface.
+ */
+ exa->pipe->surface_copy( exa->pipe,
+ exa->copy.dst_surface,
+ dstX, dstY,
+ exa->copy.src_surface,
+ srcX, srcY,
+ width, height );
+ }
+ else {
+ renderer_copy_pixmap(exa->renderer,
+ dstX, dstY,
+ srcX, srcY,
+ width, height,
- exa->copy.src_texture->width[0],
- exa->copy.src_texture->height[0]);
++ exa->copy.src_texture->width0,
++ exa->copy.src_texture->height0);
+ }
}
+ static void
+ ExaDoneCopy(PixmapPtr pPixmap)
+ {
+ ScrnInfoPtr pScrn = xf86Screens[pPixmap->drawable.pScreen->myNum];
+ modesettingPtr ms = modesettingPTR(pScrn);
+ struct exa_pixmap_priv *priv = exaGetPixmapDriverPrivate(pPixmap);
+ struct exa_context *exa = ms->exa;
+
+ if (!priv)
+ return;
+
+ renderer_draw_flush(exa->renderer);
+
+ exa->copy.src = NULL;
+ exa->copy.dst = NULL;
+ pipe_surface_reference(&exa->copy.src_surface, NULL);
+ pipe_surface_reference(&exa->copy.dst_surface, NULL);
+ pipe_texture_reference(&exa->copy.src_texture, NULL);
+ }
+
+
+
static Bool
picture_check_formats(struct exa_pixmap_priv *pSrc, PicturePtr pSrcPicture)
{
if (!priv || pPixData)
return FALSE;
- priv->tex->width[0],
- priv->tex->height[0]);
+ if (0) {
+ debug_printf("%s pixmap %p sz %dx%dx%d devKind %d\n",
+ __FUNCTION__, pPixmap, width, height, bitsPerPixel, devKind);
+
+ if (priv->tex)
+ debug_printf(" ==> old texture %dx%d\n",
++ priv->tex->width0,
++ priv->tex->height0);
+ }
+
+
if (depth <= 0)
depth = pPixmap->drawable.depth;
/* Deal with screen resize */
if ((exa->accel || priv->flags) &&
(!priv->tex ||
- (priv->tex->width0 != width ||
- priv->tex->height0 != height ||
- priv->tex_flags != priv->flags))) {
- !size_match(width, priv->tex->width[0]) ||
- !size_match(height, priv->tex->height[0]) ||
++ !size_match(width, priv->tex->width0) ||
++ !size_match(height, priv->tex->height0) ||
+ priv->tex_flags != priv->flags)) {
struct pipe_texture *texture = NULL;
struct pipe_texture template;
template.target = PIPE_TEXTURE_2D;
exa_get_pipe_format(depth, &template.format, &bitsPerPixel, &priv->picture_format);
pf_get_block(template.format, &template.block);
- template.width0 = width;
- template.height0 = height;
+ if (ROUND_UP_TEXTURES && priv->flags == 0) {
- template.width[0] = util_next_power_of_two(width);
- template.height[0] = util_next_power_of_two(height);
++ template.width0 = util_next_power_of_two(width);
++ template.height0 = util_next_power_of_two(height);
+ }
+ else {
- template.width[0] = width;
- template.height[0] = height;
++ template.width0 = width;
++ template.height0 = height;
+ }
+
- template.depth[0] = 1;
+ template.depth0 = 1;
template.last_level = 0;
template.tex_usage = PIPE_TEXTURE_USAGE_RENDER_TARGET | priv->flags;
priv->tex_flags = priv->flags;
dst_surf = exa->scrn->get_tex_surface(
exa->scrn, texture, 0, 0, 0, PIPE_BUFFER_USAGE_GPU_WRITE);
src_surf = xorg_gpu_surface(exa->pipe->screen, priv);
- if (exa->pipe->surface_copy) {
- exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width0),
- min(height, texture->height0));
- } else {
- util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width0),
- min(height, texture->height0));
- }
+ if (exa->pipe->surface_copy) {
+ exa->pipe->surface_copy(exa->pipe, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width[0]),
- min(height, texture->height[0]));
++ 0, 0, min(width, texture->width0),
++ min(height, texture->height0));
+ } else {
+ util_surface_copy(exa->pipe, FALSE, dst_surf, 0, 0, src_surf,
- 0, 0, min(width, texture->width[0]),
- min(height, texture->height[0]));
++ 0, 0, min(width, texture->width0),
++ min(height, texture->height0));
+ }
exa->scrn->tex_surface_destroy(dst_surf);
exa->scrn->tex_surface_destroy(src_surf);
}
void renderer_copy_pixmap(struct xorg_renderer *r,
- struct exa_pixmap_priv *dst_priv, int dx, int dy,
- struct exa_pixmap_priv *src_priv, int sx, int sy,
- int width, int height)
+ int dx, int dy,
+ int sx, int sy,
+ int width, int height,
+ float src_width,
+ float src_height)
{
- float dst_loc[4], src_loc[4];
- float dst_bounds[4], src_bounds[4];
- float src_shift[4], dst_shift[4], shift[4];
- struct pipe_texture *dst = dst_priv->tex;
- struct pipe_texture *src = src_priv->tex;
+ float s0, t0, s1, t1;
+ float x0, y0, x1, y1;
++<<<<<<< HEAD:src/gallium/state_trackers/xorg/xorg_renderer.c
+ if (r->pipe->is_texture_referenced(r->pipe, src, 0, 0) &
+ PIPE_REFERENCED_FOR_WRITE)
+ r->pipe->flush(r->pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
+
+ dst_loc[0] = dx;
+ dst_loc[1] = dy;
+ dst_loc[2] = width;
+ dst_loc[3] = height;
+ dst_bounds[0] = 0.f;
+ dst_bounds[1] = 0.f;
+ dst_bounds[2] = dst->width0;
+ dst_bounds[3] = dst->height0;
+
+ src_loc[0] = sx;
+ src_loc[1] = sy;
+ src_loc[2] = width;
+ src_loc[3] = height;
+ src_bounds[0] = 0.f;
+ src_bounds[1] = 0.f;
+ src_bounds[2] = src->width0;
+ src_bounds[3] = src->height0;
+
+ bound_rect(src_loc, src_bounds, src_shift);
+ bound_rect(dst_loc, dst_bounds, dst_shift);
+ shift[0] = src_shift[0] - dst_shift[0];
+ shift[1] = src_shift[1] - dst_shift[1];
+
+ if (shift[0] < 0)
+ shift_rectx(src_loc, src_bounds, -shift[0]);
+ else
+ shift_rectx(dst_loc, dst_bounds, shift[0]);
+
+ if (shift[1] < 0)
+ shift_recty(src_loc, src_bounds, -shift[1]);
+ else
+ shift_recty(dst_loc, dst_bounds, shift[1]);
+
+ sync_size(src_loc, dst_loc);
+
+ if (src_loc[2] >= 0 && src_loc[3] >= 0 &&
+ dst_loc[2] >= 0 && dst_loc[3] >= 0) {
+ struct pipe_texture *temp_src = src;
+
+ if (src == dst)
+ temp_src = create_sampler_texture(r, src);
+
+ renderer_copy_texture(r,
+ temp_src,
+ src_loc[0],
+ src_loc[1],
+ src_loc[0] + src_loc[2],
+ src_loc[1] + src_loc[3],
+ dst,
+ dst_loc[0],
+ dst_loc[1],
+ dst_loc[0] + dst_loc[2],
+ dst_loc[1] + dst_loc[3]);
+
+ if (src == dst)
+ pipe_texture_reference(&temp_src, NULL);
+ }
++=======
+
+ /* XXX: could put the texcoord scaling calculation into the vertex
+ * shader.
+ */
+ s0 = sx / src_width;
+ s1 = (sx + width) / src_width;
+ t0 = sy / src_height;
+ t1 = (sy + height) / src_height;
+
+ x0 = dx;
+ x1 = dx + width;
+ y0 = dy;
+ y1 = dy + height;
+
+ /* draw quad */
+ renderer_draw_conditional(r, 4*8);
+ add_vertex_1tex(r, x0, y0, s0, t0);
+ add_vertex_1tex(r, x1, y0, s1, t0);
+ add_vertex_1tex(r, x1, y1, s1, t1);
+ add_vertex_1tex(r, x0, y1, s0, t1);
++>>>>>>> origin/mesa_7_7_branch:src/gallium/state_trackers/xorg/xorg_renderer.c
}
+
+
+
void renderer_draw_yuv(struct xorg_renderer *r,
int src_x, int src_y, int src_w, int src_h,
int dst_x, int dst_y, int dst_w, int dst_h,