X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fdri%2Fnouveau%2Fnouveau_texture.c;h=dc5699c76809681c0f59c96515bfc034dc50b542;hb=da9e6fdfe27065b8ede8b2fe30c8cccc3b573245;hp=dfa6d12907a2304b30bcfcc804cc7a5e5bc73bdc;hpb=71fe9437169cfdafda8814aa814bb85429fb6cfc;p=mesa.git diff --git a/src/mesa/drivers/dri/nouveau/nouveau_texture.c b/src/mesa/drivers/dri/nouveau/nouveau_texture.c index dfa6d12907a..dc5699c7680 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_texture.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_texture.c @@ -175,9 +175,9 @@ nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_RGBA16: case GL_RGB10_A2: case GL_COMPRESSED_RGBA: - return MESA_FORMAT_ARGB8888; + return MESA_FORMAT_B8G8R8A8_UNORM; case GL_RGB5_A1: - return MESA_FORMAT_ARGB1555; + return MESA_FORMAT_B5G5R5A1_UNORM; case GL_RGB: case GL_RGB8: @@ -185,12 +185,12 @@ nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_RGB12: case GL_RGB16: case GL_COMPRESSED_RGB: - return MESA_FORMAT_XRGB8888; + return MESA_FORMAT_B8G8R8X8_UNORM; case 3: case GL_R3_G3_B2: case GL_RGB4: case GL_RGB5: - return MESA_FORMAT_RGB565; + return MESA_FORMAT_B5G6R5_UNORM; case 2: case GL_LUMINANCE_ALPHA: @@ -201,7 +201,7 @@ nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_LUMINANCE16_ALPHA16: case GL_LUMINANCE8_ALPHA8: case GL_COMPRESSED_LUMINANCE_ALPHA: - return MESA_FORMAT_ARGB8888; + return MESA_FORMAT_B8G8R8A8_UNORM; case 1: case GL_LUMINANCE: @@ -210,7 +210,7 @@ nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_LUMINANCE16: case GL_LUMINANCE8: case GL_COMPRESSED_LUMINANCE: - return MESA_FORMAT_L8; + return MESA_FORMAT_L_UNORM8; case GL_ALPHA: case GL_ALPHA4: @@ -218,14 +218,15 @@ nouveau_choose_tex_format(struct gl_context *ctx, GLenum target, case GL_ALPHA16: case GL_ALPHA8: case GL_COMPRESSED_ALPHA: - return MESA_FORMAT_A8; + return MESA_FORMAT_A_UNORM8; case GL_INTENSITY: case GL_INTENSITY4: case GL_INTENSITY12: case GL_INTENSITY16: case GL_INTENSITY8: - return MESA_FORMAT_I8; + case GL_COMPRESSED_INTENSITY: + return MESA_FORMAT_I_UNORM8; case GL_RGB_S3TC: case GL_RGB4_S3TC: @@ -344,16 +345,19 @@ relayout_texture(struct gl_context *ctx, struct gl_texture_object *t) height = minify(height, 1); } - /* Get new storage. */ - size = align(offset, 64); + if (t->BaseLevel <= last) { + /* Get new storage. */ + size = align(offset, 64); + assert(size); - ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_MAP | - NOUVEAU_BO_GART | NOUVEAU_BO_VRAM, - 0, size, NULL, &ss[last].bo); - assert(!ret); + ret = nouveau_bo_new(context_dev(ctx), NOUVEAU_BO_MAP | + NOUVEAU_BO_GART | NOUVEAU_BO_VRAM, + 0, size, NULL, &ss[last].bo); + assert(!ret); - for (i = t->BaseLevel; i < last; i++) - nouveau_bo_ref(ss[last].bo, &ss[i].bo); + for (i = t->BaseLevel; i < last; i++) + nouveau_bo_ref(ss[last].bo, &ss[i].bo); + } } } @@ -398,9 +402,9 @@ nouveau_texture_reallocate(struct gl_context *ctx, struct gl_texture_object *t) static unsigned get_teximage_placement(struct gl_texture_image *ti) { - if (ti->TexFormat == MESA_FORMAT_A8 || - ti->TexFormat == MESA_FORMAT_L8 || - ti->TexFormat == MESA_FORMAT_I8) + if (ti->TexFormat == MESA_FORMAT_A_UNORM8 || + ti->TexFormat == MESA_FORMAT_L_UNORM8 || + ti->TexFormat == MESA_FORMAT_I_UNORM8) /* 1 cpp formats will have to be swizzled by the CPU, * so leave them in system RAM for now. */ return NOUVEAU_BO_MAP; @@ -408,6 +412,31 @@ get_teximage_placement(struct gl_texture_image *ti) return NOUVEAU_BO_GART | NOUVEAU_BO_MAP; } +static void +nouveau_compressed_copy(struct gl_context *ctx, GLint dims, + struct gl_texture_image *ti, + GLsizei width, GLsizei height, GLsizei depth, + const GLvoid *src, GLvoid *dst, int row_stride) +{ + struct compressed_pixelstore store; + int i; + + _mesa_compute_compressed_pixelstore(dims, ti->TexFormat, + width, height, depth, + &ctx->Unpack, &store); + + src += store.SkipBytes; + + assert(store.CopySlices == 1); + + /* copy rows of blocks */ + for (i = 0; i < store.CopyRowsPerSlice; i++) { + memcpy(dst, src, store.CopyBytesPerRow); + dst += row_stride; + src += store.TotalBytesPerRow; + } +} + static void nouveau_teximage(struct gl_context *ctx, GLint dims, struct gl_texture_image *ti, @@ -447,13 +476,19 @@ nouveau_teximage(struct gl_context *ctx, GLint dims, GL_MAP_WRITE_BIT, &map, &row_stride); - ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, - ti->TexFormat, - row_stride, - &map, - ti->Width, ti->Height, depth, - format, type, pixels, packing); - assert(ret); + if (compressed) { + nouveau_compressed_copy(ctx, dims, ti, + ti->Width, ti->Height, depth, + pixels, map, row_stride); + } else { + ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, + ti->TexFormat, + row_stride, + &map, + ti->Width, ti->Height, depth, + format, type, pixels, packing); + assert(ret); + } nouveau_unmap_texture_image(ctx, ti, 0); _mesa_unmap_teximage_pbo(ctx, packing); @@ -498,7 +533,8 @@ static GLboolean nouveau_teximage_alloc(struct gl_context *ctx, struct gl_texture_image *ti) { nouveau_teximage(ctx, 3, ti, 0, 0, 0, NULL, - &ctx->DefaultPacking, GL_FALSE); + &ctx->DefaultPacking, + _mesa_is_format_compressed(ti->TexFormat)); return GL_TRUE; } @@ -531,11 +567,18 @@ nouveau_texsubimage(struct gl_context *ctx, GLint dims, xoffset, yoffset, width, height, GL_MAP_WRITE_BIT, &map, &row_stride); - ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, ti->TexFormat, - row_stride, &map, - width, height, depth, - format, type, pixels, packing); - assert(ret); + if (compressed) { + nouveau_compressed_copy(ctx, dims, ti, + width, height, depth, + pixels, map, row_stride); + } else { + ret = _mesa_texstore(ctx, dims, ti->_BaseFormat, + ti->TexFormat, + row_stride, &map, + width, height, depth, + format, type, pixels, packing); + assert(ret); + } nouveau_unmap_texture_image(ctx, ti, 0); _mesa_unmap_teximage_pbo(ctx, packing); @@ -574,11 +617,11 @@ nouveau_compressed_texsubimage(struct gl_context *ctx, GLuint dims, } static void -nouveau_bind_texture(struct gl_context *ctx, GLenum target, - struct gl_texture_object *t) +nouveau_bind_texture(struct gl_context *ctx, GLuint texUnit, + GLenum target, struct gl_texture_object *t) { - context_dirty_i(ctx, TEX_OBJ, ctx->Texture.CurrentUnit); - context_dirty_i(ctx, TEX_ENV, ctx->Texture.CurrentUnit); + context_dirty_i(ctx, TEX_OBJ, texUnit); + context_dirty_i(ctx, TEX_ENV, texUnit); } static mesa_format @@ -589,9 +632,9 @@ get_texbuffer_format(struct gl_renderbuffer *rb, GLint format) if (s->cpp < 4) return s->format; else if (format == __DRI_TEXTURE_FORMAT_RGBA) - return MESA_FORMAT_ARGB8888; + return MESA_FORMAT_B8G8R8A8_UNORM; else - return MESA_FORMAT_XRGB8888; + return MESA_FORMAT_B8G8R8X8_UNORM; } void