#include "util/u_inlines.h"
#include "util/u_pack_color.h"
#include "util/u_format.h"
+#include "util/u_surface.h"
#include "nvc0_context.h"
#include "nvc0_resource.h"
-#include "nv50_defs.xml.h"
+#include "nv50/nv50_defs.xml.h"
#define NVC0_ENG2D_SUPPORTED_FORMATS 0xff9ccfe1cce3ccc9ULL
case 2:
return NV50_SURFACE_FORMAT_R16_UNORM;
case 4:
- return NV50_SURFACE_FORMAT_A8R8G8B8_UNORM;
+ return NV50_SURFACE_FORMAT_BGRA8_UNORM;
case 8:
- return NV50_SURFACE_FORMAT_R16G16B16A16_UNORM;
+ return NV50_SURFACE_FORMAT_RGBA16_UNORM;
case 16:
- return NV50_SURFACE_FORMAT_R32G32B32A32_FLOAT;
+ return NV50_SURFACE_FORMAT_RGBA32_FLOAT;
default:
return 0;
}
static int
nvc0_2d_texture_set(struct nouveau_channel *chan, int dst,
- struct nvc0_miptree *mt, unsigned level, unsigned layer)
+ struct nv50_miptree *mt, unsigned level, unsigned layer)
{
struct nouveau_bo *bo = mt->base.bo;
uint32_t width, height, depth;
return 1;
}
- width = u_minify(mt->base.base.width0, level);
- height = u_minify(mt->base.base.height0, level);
+ width = u_minify(mt->base.base.width0, level) << mt->ms_x;
+ height = u_minify(mt->base.base.height0, level) << mt->ms_y;
+ depth = u_minify(mt->base.base.depth0, level);
+
+ /* layer has to be < depth, and depth > tile depth / 2 */
- offset = mt->level[level].offset;
if (!mt->layout_3d) {
offset += mt->layer_stride * layer;
+ layer = 0;
depth = 1;
+ } else
+ if (!dst) {
+ offset += nvc0_mt_zslice_offset(mt, level, layer);
layer = 0;
- } else {
- depth = u_minify(mt->base.base.depth0, level);
}
if (!(bo->tile_flags & NOUVEAU_BO_TILE_LAYOUT_MASK)) {
static int
nvc0_2d_texture_do_copy(struct nouveau_channel *chan,
- struct nvc0_miptree *dst, unsigned dst_level,
+ struct nv50_miptree *dst, unsigned dst_level,
unsigned dx, unsigned dy, unsigned dz,
- struct nvc0_miptree *src, unsigned src_level,
+ struct nv50_miptree *src, unsigned src_level,
unsigned sx, unsigned sy, unsigned sz,
unsigned w, unsigned h)
{
+ static const uint32_t duvdxy[5] =
+ {
+ 0x40000000, 0x80000000, 0x00000001, 0x00000002, 0x00000004
+ };
+
int ret;
+ uint32_t ctrl = 0x00;
ret = MARK_RING(chan, 2 * 16 + 32, 4);
if (ret)
if (ret)
return ret;
- /* 0/1 = CENTER/CORNER, 10/00 = POINT/BILINEAR */
+ /* NOTE: 2D engine doesn't work for MS8 */
+ if (src->ms_x)
+ ctrl = 0x11;
+
+ /* 0/1 = CENTER/CORNER, 00/10 = POINT/BILINEAR */
BEGIN_RING(chan, RING_2D(BLIT_CONTROL), 1);
- OUT_RING (chan, 0);
+ OUT_RING (chan, ctrl);
BEGIN_RING(chan, RING_2D(BLIT_DST_X), 4);
- OUT_RING (chan, dx);
- OUT_RING (chan, dy);
- OUT_RING (chan, w);
- OUT_RING (chan, h);
+ OUT_RING (chan, dx << dst->ms_x);
+ OUT_RING (chan, dy << dst->ms_y);
+ OUT_RING (chan, w << dst->ms_x);
+ OUT_RING (chan, h << dst->ms_y);
BEGIN_RING(chan, RING_2D(BLIT_DU_DX_FRACT), 4);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
- OUT_RING (chan, 0);
- OUT_RING (chan, 1);
+ OUT_RING (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0xf0000000);
+ OUT_RING (chan, duvdxy[2 + ((int)src->ms_x - (int)dst->ms_x)] & 0x0000000f);
+ OUT_RING (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0xf0000000);
+ OUT_RING (chan, duvdxy[2 + ((int)src->ms_y - (int)dst->ms_y)] & 0x0000000f);
BEGIN_RING(chan, RING_2D(BLIT_SRC_X_FRACT), 4);
OUT_RING (chan, 0);
- OUT_RING (chan, sx);
+ OUT_RING (chan, sx << src->ms_x);
OUT_RING (chan, 0);
- OUT_RING (chan, sy);
+ OUT_RING (chan, sy << src->ms_x);
return 0;
}
{
struct nvc0_screen *screen = nvc0_context(pipe)->screen;
int ret;
+ boolean m2mf;
unsigned dst_layer = dstz, src_layer = src_box->z;
- assert((src->format == dst->format) ||
- (nvc0_2d_format_faithful(src->format) &&
- nvc0_2d_format_faithful(dst->format)));
+ /* Fallback for buffers. */
+ if (dst->target == PIPE_BUFFER && src->target == PIPE_BUFFER) {
+ util_resource_copy_region(pipe, dst, dst_level, dstx, dsty, dstz,
+ src, src_level, src_box);
+ return;
+ }
+
+ assert(src->nr_samples == dst->nr_samples);
+
+ m2mf = (src->format == dst->format) ||
+ (util_format_get_blocksizebits(src->format) ==
+ util_format_get_blocksizebits(dst->format));
+
+ nv04_resource(dst)->status |= NOUVEAU_BUFFER_STATUS_GPU_WRITING;
+
+ if (m2mf) {
+ struct nv50_m2mf_rect drect, srect;
+ unsigned i;
+ unsigned nx = util_format_get_nblocksx(src->format, src_box->width);
+ unsigned ny = util_format_get_nblocksy(src->format, src_box->height);
+
+ nv50_m2mf_rect_setup(&drect, dst, dst_level, dstx, dsty, dstz);
+ nv50_m2mf_rect_setup(&srect, src, src_level,
+ src_box->x, src_box->y, src_box->z);
+
+ for (i = 0; i < src_box->depth; ++i) {
+ nvc0_m2mf_transfer_rect(&screen->base.base, &drect, &srect, nx, ny);
+
+ if (nv50_miptree(dst)->layout_3d)
+ drect.z++;
+ else
+ drect.base += nv50_miptree(dst)->layer_stride;
+
+ if (nv50_miptree(src)->layout_3d)
+ srect.z++;
+ else
+ srect.base += nv50_miptree(src)->layer_stride;
+ }
+ return;
+ }
+
+ assert(nvc0_2d_format_faithful(src->format));
+ assert(nvc0_2d_format_faithful(dst->format));
for (; dst_layer < dstz + src_box->depth; ++dst_layer, ++src_layer) {
ret = nvc0_2d_texture_do_copy(screen->base.channel,
- nvc0_miptree(dst), dst_level,
+ nv50_miptree(dst), dst_level,
dstx, dsty, dst_layer,
- nvc0_miptree(src), src_level,
+ nv50_miptree(src), src_level,
src_box->x, src_box->y, src_layer,
src_box->width, src_box->height);
if (ret)
struct nvc0_context *nv50 = nvc0_context(pipe);
struct nvc0_screen *screen = nv50->screen;
struct nouveau_channel *chan = screen->base.channel;
- struct nvc0_miptree *mt = nvc0_miptree(dst->texture);
- struct nvc0_surface *sf = nvc0_surface(dst);
+ struct nv50_miptree *mt = nv50_miptree(dst->texture);
+ struct nv50_surface *sf = nv50_surface(dst);
struct nouveau_bo *bo = mt->base.bo;
BEGIN_RING(chan, RING_3D(CLEAR_COLOR(0)), 4);
BEGIN_RING(chan, RING_3D(RT_CONTROL), 1);
OUT_RING (chan, 1);
- BEGIN_RING(chan, RING_3D(RT_ADDRESS_HIGH(0)), 8);
+ BEGIN_RING(chan, RING_3D(RT_ADDRESS_HIGH(0)), 9);
OUT_RELOCh(chan, bo, sf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RELOCl(chan, bo, sf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RING (chan, sf->width);
OUT_RING (chan, sf->height);
OUT_RING (chan, nvc0_format_table[dst->format].rt);
- OUT_RING (chan, mt->level[sf->base.u.tex.level].tile_mode);
- OUT_RING (chan, 1);
- OUT_RING (chan, 0);
+ OUT_RING (chan, (mt->layout_3d << 16) |
+ mt->level[sf->base.u.tex.level].tile_mode);
+ OUT_RING (chan, dst->u.tex.first_layer + sf->depth);
+ OUT_RING (chan, mt->layer_stride >> 2);
+ OUT_RING (chan, dst->u.tex.first_layer);
BEGIN_RING(chan, RING_3D(CLIP_RECT_HORIZ(0)), 2);
OUT_RING (chan, ((dstx + width) << 16) | dstx);
struct nvc0_context *nv50 = nvc0_context(pipe);
struct nvc0_screen *screen = nv50->screen;
struct nouveau_channel *chan = screen->base.channel;
- struct nvc0_miptree *mt = nvc0_miptree(dst->texture);
- struct nvc0_surface *sf = nvc0_surface(dst);
+ struct nv50_miptree *mt = nv50_miptree(dst->texture);
+ struct nv50_surface *sf = nv50_surface(dst);
struct nouveau_bo *bo = mt->base.bo;
uint32_t mode = 0;
+ int unk = mt->base.base.target == PIPE_TEXTURE_2D;
if (clear_flags & PIPE_CLEAR_DEPTH) {
BEGIN_RING(chan, RING_3D(CLEAR_DEPTH), 1);
OUT_RELOCl(chan, bo, sf->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RING (chan, nvc0_format_table[dst->format].rt);
OUT_RING (chan, mt->level[sf->base.u.tex.level].tile_mode);
- OUT_RING (chan, 0);
+ OUT_RING (chan, mt->layer_stride >> 2);
BEGIN_RING(chan, RING_3D(ZETA_ENABLE), 1);
OUT_RING (chan, 1);
BEGIN_RING(chan, RING_3D(ZETA_HORIZ), 3);
OUT_RING (chan, sf->width);
OUT_RING (chan, sf->height);
- OUT_RING (chan, (1 << 16) | 1);
+ OUT_RING (chan, (unk << 16) | (dst->u.tex.first_layer + sf->depth));
+ BEGIN_RING(chan, RING_3D(ZETA_BASE_LAYER), 1);
+ OUT_RING (chan, dst->u.tex.first_layer);
BEGIN_RING(chan, RING_3D(CLIP_RECT_HORIZ(0)), 2);
OUT_RING (chan, ((dstx + width) << 16) | dstx);
void
nvc0_init_surface_functions(struct nvc0_context *nvc0)
{
- nvc0->pipe.resource_copy_region = nvc0_resource_copy_region;
- nvc0->pipe.clear_render_target = nvc0_clear_render_target;
- nvc0->pipe.clear_depth_stencil = nvc0_clear_depth_stencil;
+ struct pipe_context *pipe = &nvc0->base.pipe;
+
+ pipe->resource_copy_region = nvc0_resource_copy_region;
+ pipe->clear_render_target = nvc0_clear_render_target;
+ pipe->clear_depth_stencil = nvc0_clear_depth_stencil;
}