Mesa (master): mesa: fix rgtc snorm decoding
Module: Mesa Branch: master Commit: bceb5f36ec9a8fdda515102c3e52f41aa6cad1c5 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=bceb5f36ec9a8fdda515102c3e52f41aa6cad1c5 Author: Roland Scheidegger srol...@vmware.com Date: Mon Jul 22 21:02:56 2013 +0200 mesa: fix rgtc snorm decoding The codeword must be unsigned (otherwise will shift in 1's from above when merging low/high parts so some texels decode wrong). This also affects gallium's util/u_format_rgtc. Reviewed-by: Jose Fonseca jfons...@vmware.com Reviewed-by: Zack Rusin za...@vmware.com --- src/mesa/main/texcompress_rgtc_tmp.h |6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mesa/main/texcompress_rgtc_tmp.h b/src/mesa/main/texcompress_rgtc_tmp.h index 277d69b..5fa9de6 100644 --- a/src/mesa/main/texcompress_rgtc_tmp.h +++ b/src/mesa/main/texcompress_rgtc_tmp.h @@ -37,9 +37,9 @@ static void TAG(fetch_texel_rgtc)(unsigned srcRowStride, const TYPE *pixdata, const TYPE alpha0 = blksrc[0]; const TYPE alpha1 = blksrc[1]; const char bit_pos = ((j3) * 4 + (i3)) * 3; - const TYPE acodelow = blksrc[2 + bit_pos / 8]; - const TYPE acodehigh = (3 + bit_pos / 8) 8 ? blksrc[3 + bit_pos / 8] : 0; - const TYPE code = (acodelow (bit_pos 0x7) | + const unsigned char acodelow = blksrc[2 + bit_pos / 8]; + const unsigned char acodehigh = (3 + bit_pos / 8) 8 ? blksrc[3 + bit_pos / 8] : 0; + const unsigned char code = (acodelow (bit_pos 0x7) | (acodehigh (8 - (bit_pos 0x7 0x7; if (code == 0) ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): draw: always call util_cpu_detect() in draw context creation .
Module: Mesa Branch: master Commit: 1e003b44e83dde3912ec48eb3df0e25802b5101e URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=1e003b44e83dde3912ec48eb3df0e25802b5101e Author: Roland Scheidegger srol...@vmware.com Date: Wed Jul 24 01:38:50 2013 +0200 draw: always call util_cpu_detect() in draw context creation. Since disabling denorms in draw_vbo() we require the util_cpu_caps to be initialized there. Hence add another util_cpu_detect() call in draw_create_context() which should ensure this. (There is another call in draw_get_option_use_llvm() which only gets called with x86 (not x86_64) but calling it always there wouldn't help since it most likely wouldn't get called when compiling without llvm, so leave it alone there.) This fixes https://bugs.freedesktop.org/show_bug.cgi?id=66806. (Because util_cpu_caps wasn't initialized when first calling util_fpstate_get() hence it returning zero, but it would later get initialized by rtasm translate code hence when draw call returned it unmasked all exceptions by calling util_fpstate_set(). This was happening only with DRAW_USE_LLVM=0 or not compiling with llvm, otherwise the llvm init code was calling it on time too.) Reviewed-by: Jose Fonseca jfons...@vmware.com Reviewed-by: Zack Rusin za...@vmware.com Tested-by: Vinson Lee v...@freedesktop.org --- src/gallium/auxiliary/draw/draw_context.c |5 - 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 4a08765..4a6ba1a 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -58,7 +58,7 @@ draw_get_option_use_llvm(void) #ifdef PIPE_ARCH_X86 util_cpu_detect(); - /* require SSE2 due to LLVM PR6960. */ + /* require SSE2 due to LLVM PR6960. XXX Might be fixed by now? */ if (!util_cpu_caps.has_sse2) value = FALSE; #endif @@ -78,6 +78,9 @@ draw_create_context(struct pipe_context *pipe, boolean try_llvm) if (draw == NULL) goto err_out; + /* we need correct cpu caps for disabling denorms in draw_vbo() */ + util_cpu_detect(); + #if HAVE_LLVM if (try_llvm draw_get_option_use_llvm()) { draw-llvm = draw_llvm_create(draw); ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Demos (master): trivial/tri-rotate: draw a triangle with rotation
Module: Demos Branch: master Commit: 613e19b8cd2094bd05cb7480de9e13edd54de18c URL: http://cgit.freedesktop.org/mesa/demos/commit/?id=613e19b8cd2094bd05cb7480de9e13edd54de18c Author: Brian Paul bri...@vmware.com Date: Wed Jul 24 11:28:24 2013 -0600 trivial/tri-rotate: draw a triangle with rotation Specify initial rotation on command line. Press r/R to rotate interactively. --- src/trivial/CMakeLists.txt |1 + src/trivial/Makefile.am|1 + src/trivial/tri-rotate.c | 107 3 files changed, 109 insertions(+), 0 deletions(-) diff --git a/src/trivial/CMakeLists.txt b/src/trivial/CMakeLists.txt index ed6445b..b42d1f9 100644 --- a/src/trivial/CMakeLists.txt +++ b/src/trivial/CMakeLists.txt @@ -147,6 +147,7 @@ set (targets tri-point-line-clipped tri-query tri-repeat + tri-rotate tri-scissor-tri tri-square tri-stencil diff --git a/src/trivial/Makefile.am b/src/trivial/Makefile.am index 2543068..87d4e40 100644 --- a/src/trivial/Makefile.am +++ b/src/trivial/Makefile.am @@ -159,6 +159,7 @@ bin_PROGRAMS = \ tri-point-line-clipped \ tri-query \ tri-repeat \ + tri-rotate \ tri-scissor-tri \ tri-square \ tri-stencil \ diff --git a/src/trivial/tri-rotate.c b/src/trivial/tri-rotate.c new file mode 100644 index 000..357de59 --- /dev/null +++ b/src/trivial/tri-rotate.c @@ -0,0 +1,107 @@ +/* + * Draw a triangle with rotation + */ + +#include stdio.h +#include stdlib.h +#include glut_wrap.h + + +static int win; +static float rot = 0.0f; + + +static void +Reshape(int width, int height) +{ + glViewport(0, 0, width, height); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + + +static void +Key(unsigned char key, int x, int y) +{ + if (key == 27) { + glutDestroyWindow(win); + exit(0); + } + else if (key == 'r') { + rot += 5.0f; + glutPostRedisplay(); + } + else if (key == 'R') { + rot -= 5.0f; + glutPostRedisplay(); + } +} + + +static void +Draw(void) +{ + glClear(GL_COLOR_BUFFER_BIT); + + glPushMatrix(); + glRotatef(rot, 0.0, 0.0, 1.0f); + + glBegin(GL_TRIANGLES); + glColor3f(1.0f, 0.0f, 0.0f); + glVertex3f(-0.8f, -0.8f, 0.0f); + glColor3f(0.0f, 1.0f, 0.0f); + glVertex3f(0.8f, -0.8f, 0.0f); + glColor3f(0.0f, 0.0f, 1.0f); + glVertex3f(0.0f, 0.8f, 0.0f); + glEnd(); + + glPopMatrix(); + + glutSwapBuffers(); +} + + +static void +Init(void) +{ + fprintf(stderr, GL_RENDERER = %s\n, (char *) glGetString(GL_RENDERER)); + fprintf(stderr, GL_VERSION= %s\n, (char *) glGetString(GL_VERSION)); + fprintf(stderr, GL_VENDOR = %s\n, (char *) glGetString(GL_VENDOR)); + fflush(stderr); + + glClearColor(0.3, 0.3, 0.7, 0.0); +} + + +int +main(int argc, char **argv) +{ + glutInit(argc, argv); + + if (argc 1) { + rot = atof(argv[1]); + printf(Using rotation %g\n, rot); + fflush(stdout); + } + + glutInitWindowPosition(0, 0); + glutInitWindowSize(250, 250); + + glutInitDisplayMode(GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE); + + win = glutCreateWindow(*argv); + if (!win) { + exit(1); + } + + Init(); + + glutReshapeFunc(Reshape); + glutKeyboardFunc(Key); + glutDisplayFunc(Draw); + glutMainLoop(); + return 0; +} ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): nv50,nvc0: s/uint16/uint32 for constant buffer offset
Module: Mesa Branch: master Commit: 5c37039797938e43a7dfb6c7d39a1f0bb4f32df3 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5c37039797938e43a7dfb6c7d39a1f0bb4f32df3 Author: Christoph Bumiller e0425...@student.tuwien.ac.at Date: Wed Jul 24 20:41:31 2013 +0200 nv50,nvc0: s/uint16/uint32 for constant buffer offset Looks like a thinko, Hey, constant buffers can be at most 64 KiB in size, offset can't be larger. But it can, of course. I think piglit lacks a test for UBO and BindBufferRange that tests if it actually works. --- src/gallium/drivers/nv50/nv50_stateobj.h |2 +- src/gallium/drivers/nvc0/nvc0_stateobj.h |2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/nv50/nv50_stateobj.h b/src/gallium/drivers/nv50/nv50_stateobj.h index f75608c..37b9967 100644 --- a/src/gallium/drivers/nv50/nv50_stateobj.h +++ b/src/gallium/drivers/nv50/nv50_stateobj.h @@ -40,7 +40,7 @@ struct nv50_constbuf { const uint8_t *data; } u; uint32_t size; /* max 65536 */ - uint16_t offset; + uint32_t offset; boolean user; /* should only be TRUE if u.data is valid and non-NULL */ }; diff --git a/src/gallium/drivers/nvc0/nvc0_stateobj.h b/src/gallium/drivers/nvc0/nvc0_stateobj.h index edab60b..80c3342 100644 --- a/src/gallium/drivers/nvc0/nvc0_stateobj.h +++ b/src/gallium/drivers/nvc0/nvc0_stateobj.h @@ -38,7 +38,7 @@ struct nvc0_constbuf { const void *data; } u; uint32_t size; - uint16_t offset; + uint32_t offset; boolean user; /* should only be TRUE if u.data is valid and non-NULL */ }; ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: handle 2D texture arrays in get_tex_rgba_compressed()
Module: Mesa Branch: master Commit: 2931bcb0d245c356ea9c467e792fd176790f9cfc URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=2931bcb0d245c356ea9c467e792fd176790f9cfc Author: Brian Paul bri...@vmware.com Date: Mon Jul 15 10:23:49 2013 -0600 mesa: handle 2D texture arrays in get_tex_rgba_compressed() If we call glGetTexImage() for a compressed 2D texture array we need to loop over all the slices. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66850 NOTE: This is a candidate for the 9.x branches. Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: José Fonseca jfons...@vmware.com --- src/mesa/main/texgetimage.c | 52 +++--- 1 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 4c672e3..7050f10 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -233,8 +233,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, const GLuint width = texImage-Width; const GLuint height = texImage-Height; const GLuint depth = texImage-Depth; - GLfloat *tempImage, *srcRow; - GLuint row; + GLfloat *tempImage, *tempSlice, *srcRow; + GLuint row, slice; /* Decompress into temp float buffer, then pack into user buffer */ tempImage = malloc(width * height * depth @@ -244,20 +244,22 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, return; } - /* Decompress the texture image - results in 'tempImage' */ - { + /* Decompress the texture image slices - results in 'tempImage' */ + for (slice = 0; slice depth; slice++) { GLubyte *srcMap; GLint srcRowStride; - ctx-Driver.MapTextureImage(ctx, texImage, 0, + tempSlice = tempImage + slice * 4 * width * height; + + ctx-Driver.MapTextureImage(ctx, texImage, slice, 0, 0, width, height, GL_MAP_READ_BIT, srcMap, srcRowStride); if (srcMap) { _mesa_decompress_image(texFormat, width, height, -srcMap, srcRowStride, tempImage); +srcMap, srcRowStride, tempSlice); - ctx-Driver.UnmapTextureImage(ctx, texImage, 0); + ctx-Driver.UnmapTextureImage(ctx, texImage, slice); } else { _mesa_error(ctx, GL_OUT_OF_MEMORY, glGetTexImage); @@ -294,15 +296,19 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, rebaseFormat); } - srcRow = tempImage; - for (row = 0; row height; row++) { - void *dest = _mesa_image_address(dimensions, ctx-Pack, pixels, - width, height, format, type, - 0, row, 0); - - _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow, - format, type, dest, ctx-Pack, transferOps); - srcRow += width * 4; + tempSlice = tempImage; + for (slice = 0; slice depth; slice++) { + srcRow = tempSlice; + for (row = 0; row height; row++) { + void *dest = _mesa_image_address(dimensions, ctx-Pack, pixels, + width, height, format, type, + slice, row, 0); + + _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) srcRow, +format, type, dest, ctx-Pack, transferOps); + srcRow += 4 * width; + } + tempSlice += 4 * width * height; } free(tempImage); @@ -616,18 +622,8 @@ _mesa_get_teximage(struct gl_context *ctx, GLenum format, GLenum type, GLvoid *pixels, struct gl_texture_image *texImage) { - GLuint dimensions; - - switch (texImage-TexObject-Target) { - case GL_TEXTURE_1D: - dimensions = 1; - break; - case GL_TEXTURE_3D: - dimensions = 3; - break; - default: - dimensions = 2; - } + const GLuint dimensions = + _mesa_get_texture_dimensions(texImage-TexObject-Target); /* map dest buffer, if PBO */ if (_mesa_is_bufferobj(ctx-Pack.BufferObj)) { ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit
Mesa (master): mesa: implement mipmap generation for compressed 2D array textures
Module: Mesa Branch: master Commit: 8a9df7a370b66ec50b6255e4d66ac1ed331319fb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=8a9df7a370b66ec50b6255e4d66ac1ed331319fb Author: Brian Paul bri...@vmware.com Date: Tue Jul 16 06:04:32 2013 -0600 mesa: implement mipmap generation for compressed 2D array textures We weren't looping over all the slices in the array. The updated code should also correctly handle 3D compressed textures too, whenever we have that feature. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66850 NOTE: This is a candidate for the 9.x branches Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: José Fonseca jfons...@vmware.com --- src/mesa/main/mipmap.c | 59 +++- 1 files changed, 43 insertions(+), 16 deletions(-) diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c index edf7257..5839632 100644 --- a/src/mesa/main/mipmap.c +++ b/src/mesa/main/mipmap.c @@ -2020,13 +2020,15 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, GLuint level; gl_format temp_format; GLint components; - GLuint temp_src_stride; /* in bytes */ + GLuint temp_src_row_stride, temp_src_img_stride; /* in bytes */ GLubyte *temp_src = NULL, *temp_dst = NULL; GLenum temp_datatype; GLenum temp_base_format; + GLubyte **temp_src_slices, **temp_dst_slices; /* only two types of compressed textures at this time */ assert(texObj-Target == GL_TEXTURE_2D || + texObj-Target == GL_TEXTURE_2D_ARRAY || texObj-Target == GL_TEXTURE_CUBE_MAP_ARB); /* @@ -2051,15 +2053,24 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, /* allocate storage for the temporary, uncompressed image */ - /* 20 extra bytes, just be safe when calling last FetchTexel */ - temp_src_stride = _mesa_format_row_stride(temp_format, srcImage-Width); - temp_src = malloc(temp_src_stride * srcImage-Height + 20); - if (!temp_src) { + temp_src_row_stride = _mesa_format_row_stride(temp_format, srcImage-Width); + temp_src_img_stride = _mesa_format_image_size(temp_format, srcImage-Width, + srcImage-Height, 1); + temp_src = malloc(temp_src_img_stride * srcImage-Depth); + + /* Allocate storage for arrays of slice pointers */ + temp_src_slices = malloc(srcImage-Depth * sizeof(GLubyte *)); + temp_dst_slices = malloc(srcImage-Depth * sizeof(GLubyte *)); + + if (!temp_src || !temp_src_slices || !temp_dst_slices) { + free(temp_src); + free(temp_src_slices); + free(temp_dst_slices); _mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps); return; } - /* decompress base image to the temporary */ + /* decompress base image to the temporary src buffer */ { /* save pixel packing mode */ struct gl_pixelstore_attrib save = ctx-Pack; @@ -2075,7 +2086,6 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, ctx-Pack = save; } - for (level = texObj-BaseLevel; level maxLevel; level++) { /* generate image[level+1] from image[level] */ const struct gl_texture_image *srcImage; @@ -2084,7 +2094,8 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, GLint dstWidth, dstHeight, dstDepth; GLint border; GLboolean nextLevel; - GLuint temp_dst_stride; /* in bytes */ + GLuint temp_dst_row_stride, temp_dst_img_stride; /* in bytes */ + GLuint i; /* get src image parameters */ srcImage = _mesa_select_tex_image(ctx, texObj, target, level); @@ -2100,9 +2111,12 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, if (!nextLevel) break; - temp_dst_stride = _mesa_format_row_stride(temp_format, dstWidth); + /* Compute dst image strides and alloc memory on first iteration */ + temp_dst_row_stride = _mesa_format_row_stride(temp_format, dstWidth); + temp_dst_img_stride = _mesa_format_image_size(temp_format, dstWidth, +dstHeight, 1); if (!temp_dst) { -temp_dst = malloc(temp_dst_stride * dstHeight); +temp_dst = malloc(temp_dst_img_stride * dstDepth); if (!temp_dst) { _mesa_error(ctx, GL_OUT_OF_MEMORY, generate mipmaps); break; @@ -2117,13 +2131,23 @@ generate_mipmap_compressed(struct gl_context *ctx, GLenum target, return; } - /* rescale src image to dest image */ + /* for 2D arrays, setup array[depth] of slice pointers */ + for (i = 0; i srcDepth; i++) { + temp_src_slices[i] = temp_src + temp_src_img_stride * i; + } + for (i = 0; i dstDepth; i++) { + temp_dst_slices[i] = temp_dst + temp_dst_img_stride * i; + } + + /* Rescale src image to dest image. + * This will loop over the slices of a 2D array. + */ _mesa_generate_mipmap_level(target,
Mesa (master): meta: handle 2D texture arrays in decompress_texture_image()
Module: Mesa Branch: master Commit: 484fa879847fdc7c9ef22231315f78a4c342e85d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=484fa879847fdc7c9ef22231315f78a4c342e85d Author: Brian Paul bri...@vmware.com Date: Tue Jul 16 06:27:33 2013 -0600 meta: handle 2D texture arrays in decompress_texture_image() Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=66850 NOTE: This is a candidate for the 9.x branches. Cc: mesa-sta...@lists.freedesktop.org Reviewed-by: José Fonseca jfons...@vmware.com --- src/mesa/drivers/common/meta.c | 23 +-- 1 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index e848429..4a3497c 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -4095,10 +4095,29 @@ _mesa_meta_GetTexImage(struct gl_context *ctx, _mesa_get_format_datatype(texImage-TexFormat) == GL_UNSIGNED_NORMALIZED) { struct gl_texture_object *texObj = texImage-TexObject; - const GLuint slice = 0; /* only 2D compressed textures for now */ + GLuint slice; /* Need to unlock the texture here to prevent deadlock... */ _mesa_unlock_texture(ctx, texObj); - decompress_texture_image(ctx, texImage, slice, format, type, pixels); + for (slice = 0; slice texImage-Depth; slice++) { + void *dst; + if (texImage-TexObject-Target == GL_TEXTURE_2D_ARRAY) { +/* Setup pixel packing. SkipPixels and SkipRows will be applied + * in the decompress_texture_image() function's call to + * glReadPixels but we need to compute the dest slice's address + * here (according to SkipImages and ImageHeight). + */ +struct gl_pixelstore_attrib packing = ctx-Pack; +packing.SkipPixels = 0; +packing.SkipRows = 0; +dst = _mesa_image_address3d(packing, pixels, texImage-Width, +texImage-Height, format, type, +slice, 0, 0); + } + else { +dst = pixels; + } + decompress_texture_image(ctx, texImage, slice, format, type, dst); + } /* ... and relock it */ _mesa_lock_texture(ctx, texObj); } ___ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit