aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/mesa/state_tracker')
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_accum.c347
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_accum.h63
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_clear.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_fbo.c21
-rw-r--r--mesalib/src/mesa/state_tracker/st_cb_texture.c222
-rw-r--r--mesalib/src/mesa/state_tracker/st_context.c5
-rw-r--r--mesalib/src/mesa/state_tracker/st_extensions.c10
-rw-r--r--mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp18
-rw-r--r--mesalib/src/mesa/state_tracker/st_manager.c64
-rw-r--r--mesalib/src/mesa/state_tracker/st_program.c19
10 files changed, 146 insertions, 628 deletions
diff --git a/mesalib/src/mesa/state_tracker/st_cb_accum.c b/mesalib/src/mesa/state_tracker/st_cb_accum.c
deleted file mode 100644
index 3e3659d15..000000000
--- a/mesalib/src/mesa/state_tracker/st_cb_accum.c
+++ /dev/null
@@ -1,347 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
- /*
- * Authors:
- * Brian Paul
- */
-
-#include "main/imports.h"
-#include "main/image.h"
-#include "main/macros.h"
-#include "main/mfeatures.h"
-
-#include "st_debug.h"
-#include "st_context.h"
-#include "st_cb_accum.h"
-#include "st_cb_fbo.h"
-#include "st_texture.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "util/u_format.h"
-#include "util/u_inlines.h"
-#include "util/u_tile.h"
-
-
-#if FEATURE_accum
-
-/**
- * For hardware that supports deep color buffers, we could accelerate
- * most/all the accum operations with blending/texturing.
- * For now, just use the get/put_tile() functions and do things in software.
- */
-
-
-void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
-{
- struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
- const GLint xpos = ctx->DrawBuffer->_Xmin;
- const GLint ypos = ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - xpos;
- const GLint height = ctx->DrawBuffer->_Ymax - ypos;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
-
- if(!data)
- return;
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- GLshort r = FLOAT_TO_SHORT(ctx->Accum.ClearColor[0]);
- GLshort g = FLOAT_TO_SHORT(ctx->Accum.ClearColor[1]);
- GLshort b = FLOAT_TO_SHORT(ctx->Accum.ClearColor[2]);
- GLshort a = FLOAT_TO_SHORT(ctx->Accum.ClearColor[3]);
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *dst = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width; j++) {
- dst[0] = r;
- dst[1] = g;
- dst[2] = b;
- dst[3] = a;
- dst += 4;
- }
- }
- }
- break;
- default:
- _mesa_problem(ctx, "unexpected format in st_clear_accum_buffer()");
- }
-}
-
-
-/** For ADD/MULT */
-static void
-accum_mad(struct gl_context *ctx, GLfloat scale, GLfloat bias,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb)
-{
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = SHORT_TO_FLOAT(*acc) * scale + bias;
- *acc++ = FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-}
-
-
-static void
-accum_accum(struct st_context *st, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st->pipe;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
- GLfloat *buf;
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- color_trans = pipe_get_transfer(st->pipe,
- color_strb->texture,
- 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- util_format_linear(color_strb->texture->format),
- buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const GLfloat *color = buf;
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = *color++ * value;
- *acc++ += FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-accum_load(struct st_context *st, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st->pipe;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- GLubyte *data = acc_strb->data;
- GLfloat *buf;
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- color_trans = pipe_get_transfer(st->pipe, color_strb->texture,
- 0, 0,
- PIPE_TRANSFER_READ, xpos, ypos,
- width, height);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- util_format_linear(color_strb->texture->format),
- buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- const GLfloat *color = buf;
- int i, j;
- for (i = 0; i < height; i++) {
- GLshort *acc = (GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width * 4; j++) {
- float val = *color++ * value;
- *acc++ = FLOAT_TO_SHORT(val);
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-accum_return(struct gl_context *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct st_renderbuffer *acc_strb,
- struct st_renderbuffer *color_strb)
-{
- struct pipe_context *pipe = st_context(ctx)->pipe;
- const GLubyte *colormask = ctx->Color.ColorMask[0];
- enum pipe_transfer_usage usage;
- struct pipe_transfer *color_trans;
- size_t stride = acc_strb->stride;
- const GLubyte *data = acc_strb->data;
- GLfloat *buf;
- enum pipe_format format = util_format_linear(color_strb->texture->format);
-
- if (ST_DEBUG & DEBUG_FALLBACK)
- debug_printf("%s: fallback processing\n", __FUNCTION__);
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3])
- usage = PIPE_TRANSFER_READ_WRITE;
- else
- usage = PIPE_TRANSFER_WRITE;
-
- color_trans = pipe_get_transfer(pipe,
- color_strb->texture, 0, 0,
- usage,
- xpos, ypos,
- width, height);
-
- if (usage & PIPE_TRANSFER_READ)
- pipe_get_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- format, buf);
-
- switch (acc_strb->format) {
- case PIPE_FORMAT_R16G16B16A16_SNORM:
- {
- GLfloat *color = buf;
- int i, j, ch;
- for (i = 0; i < height; i++) {
- const GLshort *acc = (const GLshort *) (data + (ypos + i) * stride + xpos * 8);
- for (j = 0; j < width; j++) {
- for (ch = 0; ch < 4; ch++) {
- if (colormask[ch]) {
- GLfloat val = SHORT_TO_FLOAT(*acc * value);
- *color = CLAMP(val, 0.0f, 1.0f);
- }
- else {
- /* No change */
- }
- ++acc;
- ++color;
- }
- }
- }
- }
- break;
- default:
- _mesa_problem(NULL, "unexpected format in st_clear_accum_buffer()");
- }
-
- pipe_put_tile_rgba_format(pipe, color_trans, 0, 0, width, height,
- format, buf);
-
- free(buf);
- pipe->transfer_destroy(pipe, color_trans);
-}
-
-
-static void
-st_Accum(struct gl_context *ctx, GLenum op, GLfloat value)
-{
- struct st_context *st = st_context(ctx);
- struct st_renderbuffer *acc_strb
- = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
- struct st_renderbuffer *color_strb
- = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
-
- const GLint xpos = ctx->DrawBuffer->_Xmin;
- const GLint ypos = ctx->DrawBuffer->_Ymin;
- const GLint width = ctx->DrawBuffer->_Xmax - xpos;
- const GLint height = ctx->DrawBuffer->_Ymax - ypos;
-
- if(!acc_strb->data)
- return;
-
- switch (op) {
- case GL_ADD:
- if (value != 0.0F) {
- accum_mad(ctx, 1.0, value, xpos, ypos, width, height, acc_strb);
- }
- break;
- case GL_MULT:
- if (value != 1.0F) {
- accum_mad(ctx, value, 0.0, xpos, ypos, width, height, acc_strb);
- }
- break;
- case GL_ACCUM:
- if (value != 0.0F) {
- accum_accum(st, value, xpos, ypos, width, height, acc_strb, color_strb);
- }
- break;
- case GL_LOAD:
- accum_load(st, value, xpos, ypos, width, height, acc_strb, color_strb);
- break;
- case GL_RETURN:
- accum_return(ctx, value, xpos, ypos, width, height, acc_strb, color_strb);
- break;
- default:
- assert(0);
- }
-}
-
-
-
-void st_init_accum_functions(struct dd_function_table *functions)
-{
- functions->Accum = st_Accum;
-}
-
-#endif /* FEATURE_accum */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_accum.h b/mesalib/src/mesa/state_tracker/st_cb_accum.h
deleted file mode 100644
index 90feddd6f..000000000
--- a/mesalib/src/mesa/state_tracker/st_cb_accum.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-
-#ifndef ST_CB_ACCUM_H
-#define ST_CB_ACCUM_H
-
-
-#include "main/mfeatures.h"
-
-struct dd_function_table;
-struct gl_context;
-struct gl_renderbuffer;
-
-#if FEATURE_accum
-
-extern void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
-
-extern void st_init_accum_functions(struct dd_function_table *functions);
-
-#else
-
-#include "main/compiler.h"
-
-static INLINE void
-st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
-{
- ASSERT_NO_FEATURE();
-}
-
-static INLINE void
-st_init_accum_functions(struct dd_function_table *functions)
-{
-}
-
-#endif /* FEATURE_accum */
-
-#endif /* ST_CB_ACCUM_H */
diff --git a/mesalib/src/mesa/state_tracker/st_cb_clear.c b/mesalib/src/mesa/state_tracker/st_cb_clear.c
index 89273e28e..61d98aeb9 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_clear.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_clear.c
@@ -34,12 +34,12 @@
*/
#include "main/glheader.h"
+#include "main/accum.h"
#include "main/formats.h"
#include "main/macros.h"
#include "program/prog_instruction.h"
#include "st_context.h"
#include "st_atom.h"
-#include "st_cb_accum.h"
#include "st_cb_clear.h"
#include "st_cb_fbo.h"
#include "st_format.h"
@@ -599,8 +599,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
ctx->Depth.Clear, ctx->Stencil.Clear);
}
if (mask & BUFFER_BIT_ACCUM)
- st_clear_accum_buffer(ctx,
- ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
+ _mesa_clear_accum_buffer(ctx);
}
diff --git a/mesalib/src/mesa/state_tracker/st_cb_fbo.c b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
index 2a60ed4df..ec40a2b70 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_fbo.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_fbo.c
@@ -667,6 +667,22 @@ st_MapRenderbuffer(struct gl_context *ctx,
unsigned usage;
GLuint y2;
+ if (strb->software) {
+ /* software-allocated renderbuffer (probably an accum buffer) */
+ GLubyte *map = (GLubyte *) strb->data;
+ if (strb->data) {
+ map += strb->stride * y;
+ map += util_format_get_blocksize(strb->format) * x;
+ *mapOut = map;
+ *rowStrideOut = strb->stride;
+ }
+ else {
+ *mapOut = NULL;
+ *rowStrideOut = 0;
+ }
+ return;
+ }
+
usage = 0x0;
if (mode & GL_MAP_READ_BIT)
usage |= PIPE_TRANSFER_READ;
@@ -716,6 +732,11 @@ st_UnmapRenderbuffer(struct gl_context *ctx,
struct st_renderbuffer *strb = st_renderbuffer(rb);
struct pipe_context *pipe = st->pipe;
+ if (strb->software) {
+ /* software-allocated renderbuffer (probably an accum buffer) */
+ return;
+ }
+
pipe_transfer_unmap(pipe, strb->transfer);
pipe->transfer_destroy(pipe, strb->transfer);
strb->transfer = NULL;
diff --git a/mesalib/src/mesa/state_tracker/st_cb_texture.c b/mesalib/src/mesa/state_tracker/st_cb_texture.c
index c58a9df56..52f654d7d 100644
--- a/mesalib/src/mesa/state_tracker/st_cb_texture.c
+++ b/mesalib/src/mesa/state_tracker/st_cb_texture.c
@@ -214,56 +214,6 @@ st_UnmapTextureImage(struct gl_context *ctx,
/**
- * From linux kernel i386 header files, copes with odd sizes better
- * than COPY_DWORDS would:
- * XXX Put this in src/mesa/main/imports.h ???
- */
-#if defined(PIPE_CC_GCC) && defined(PIPE_ARCH_X86)
-static INLINE void *
-__memcpy(void *to, const void *from, size_t n)
-{
- int d0, d1, d2;
- __asm__ __volatile__("rep ; movsl\n\t"
- "testb $2,%b4\n\t"
- "je 1f\n\t"
- "movsw\n"
- "1:\ttestb $1,%b4\n\t"
- "je 2f\n\t"
- "movsb\n" "2:":"=&c"(d0), "=&D"(d1), "=&S"(d2)
- :"0"(n / 4), "q"(n), "1"((long) to), "2"((long) from)
- :"memory");
- return (to);
-}
-#else
-#define __memcpy(a,b,c) memcpy(a,b,c)
-#endif
-
-
-/**
- * The system memcpy (at least on ubuntu 5.10) has problems copying
- * to agp (writecombined) memory from a source which isn't 64-byte
- * aligned - there is a 4x performance falloff.
- *
- * The x86 __memcpy is immune to this but is slightly slower
- * (10%-ish) than the system memcpy.
- *
- * The sse_memcpy seems to have a slight cliff at 64/32 bytes, but
- * isn't much faster than x86_memcpy for agp copies.
- *
- * TODO: switch dynamically.
- */
-static void *
-do_memcpy(void *dest, const void *src, size_t n)
-{
- if ((((unsigned long) src) & 63) || (((unsigned long) dest) & 63)) {
- return __memcpy(dest, src, n);
- }
- else
- return memcpy(dest, src, n);
-}
-
-
-/**
* Return default texture resource binding bitmask for the given format.
*/
static GLuint
@@ -1420,11 +1370,13 @@ st_copy_texsubimage(struct gl_context *ctx,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
enum pipe_format dest_format, src_format;
- GLboolean use_fallback = GL_TRUE;
GLboolean matching_base_formats;
GLuint format_writemask, sample_count;
struct pipe_surface *dest_surface = NULL;
GLboolean do_flip = (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP);
+ struct pipe_surface surf_tmpl;
+ unsigned int dst_usage;
+ GLint srcY0, srcY1;
/* make sure finalize_textures has been called?
*/
@@ -1472,99 +1424,105 @@ st_copy_texsubimage(struct gl_context *ctx,
matching_base_formats =
(_mesa_get_format_base_format(strb->Base.Format) ==
_mesa_get_format_base_format(texImage->TexFormat));
- format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
- if (ctx->_ImageTransferState == 0x0) {
+ if (ctx->_ImageTransferState) {
+ goto fallback;
+ }
+
+ if (matching_base_formats &&
+ src_format == dest_format &&
+ !do_flip) {
+ /* use surface_copy() / blit */
+ struct pipe_box src_box;
+ u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer,
+ width, height, &src_box);
+
+ /* for resource_copy_region(), y=0=top, always */
+ pipe->resource_copy_region(pipe,
+ /* dest */
+ stImage->pt,
+ stImage->base.Level,
+ destX, destY, destZ + stImage->base.Face,
+ /* src */
+ strb->texture,
+ strb->surface->u.tex.level,
+ &src_box);
+ return;
+ }
- if (matching_base_formats &&
- src_format == dest_format &&
- !do_flip)
- {
- /* use surface_copy() / blit */
- struct pipe_box src_box;
- u_box_2d_zslice(srcX, srcY, strb->surface->u.tex.first_layer,
- width, height, &src_box);
-
- /* for resource_copy_region(), y=0=top, always */
- pipe->resource_copy_region(pipe,
- /* dest */
- stImage->pt,
- stImage->base.Level,
- destX, destY, destZ + stImage->base.Face,
- /* src */
- strb->texture,
- strb->surface->u.tex.level,
- &src_box);
- use_fallback = GL_FALSE;
- }
- else if (format_writemask &&
- texBaseFormat != GL_DEPTH_COMPONENT &&
- texBaseFormat != GL_DEPTH_STENCIL &&
- screen->is_format_supported(screen, src_format,
- PIPE_TEXTURE_2D, sample_count,
- PIPE_BIND_SAMPLER_VIEW) &&
- screen->is_format_supported(screen, dest_format,
- PIPE_TEXTURE_2D, 0,
- PIPE_BIND_RENDER_TARGET)) {
- /* draw textured quad to do the copy */
- GLint srcY0, srcY1;
- struct pipe_surface surf_tmpl;
- memset(&surf_tmpl, 0, sizeof(surf_tmpl));
- surf_tmpl.format = util_format_linear(stImage->pt->format);
- surf_tmpl.usage = PIPE_BIND_RENDER_TARGET;
- surf_tmpl.u.tex.level = stImage->base.Level;
- surf_tmpl.u.tex.first_layer = stImage->base.Face + destZ;
- surf_tmpl.u.tex.last_layer = stImage->base.Face + destZ;
-
- dest_surface = pipe->create_surface(pipe, stImage->pt,
- &surf_tmpl);
-
- if (do_flip) {
- srcY1 = strb->Base.Height - srcY - height;
- srcY0 = srcY1 + height;
- }
- else {
- srcY0 = srcY;
- srcY1 = srcY0 + height;
- }
+ if (texBaseFormat == GL_DEPTH_STENCIL) {
+ goto fallback;
+ }
- /* Disable conditional rendering. */
- if (st->render_condition) {
- pipe->render_condition(pipe, NULL, 0);
- }
+ if (texBaseFormat == GL_DEPTH_COMPONENT) {
+ format_writemask = TGSI_WRITEMASK_XYZW;
+ dst_usage = PIPE_BIND_DEPTH_STENCIL;
+ }
+ else {
+ format_writemask = compatible_src_dst_formats(ctx, &strb->Base, texImage);
+ dst_usage = PIPE_BIND_RENDER_TARGET;
+ }
- util_blit_pixels_writemask(st->blit,
- strb->texture,
- strb->surface->u.tex.level,
- srcX, srcY0,
- srcX + width, srcY1,
- strb->surface->u.tex.first_layer,
- dest_surface,
- destX, destY,
- destX + width, destY + height,
- 0.0, PIPE_TEX_MIPFILTER_NEAREST,
- format_writemask);
-
- /* Restore conditional rendering state. */
- if (st->render_condition) {
- pipe->render_condition(pipe, st->render_condition,
- st->condition_mode);
- }
+ if (!format_writemask ||
+ !screen->is_format_supported(screen, src_format,
+ PIPE_TEXTURE_2D, sample_count,
+ PIPE_BIND_SAMPLER_VIEW) ||
+ !screen->is_format_supported(screen, dest_format,
+ PIPE_TEXTURE_2D, 0,
+ dst_usage)) {
+ goto fallback;
+ }
- use_fallback = GL_FALSE;
- }
+ if (do_flip) {
+ srcY1 = strb->Base.Height - srcY - height;
+ srcY0 = srcY1 + height;
+ }
+ else {
+ srcY0 = srcY;
+ srcY1 = srcY0 + height;
+ }
+
+ /* Disable conditional rendering. */
+ if (st->render_condition) {
+ pipe->render_condition(pipe, NULL, 0);
+ }
+
+ memset(&surf_tmpl, 0, sizeof(surf_tmpl));
+ surf_tmpl.format = util_format_linear(stImage->pt->format);
+ surf_tmpl.usage = dst_usage;
+ surf_tmpl.u.tex.level = stImage->base.Level;
+ surf_tmpl.u.tex.first_layer = stImage->base.Face + destZ;
+ surf_tmpl.u.tex.last_layer = stImage->base.Face + destZ;
+
+ dest_surface = pipe->create_surface(pipe, stImage->pt,
+ &surf_tmpl);
+ util_blit_pixels_writemask(st->blit,
+ strb->texture,
+ strb->surface->u.tex.level,
+ srcX, srcY0,
+ srcX + width, srcY1,
+ strb->surface->u.tex.first_layer,
+ dest_surface,
+ destX, destY,
+ destX + width, destY + height,
+ 0.0, PIPE_TEX_MIPFILTER_NEAREST,
+ format_writemask);
+ pipe_surface_reference(&dest_surface, NULL);
- if (dest_surface)
- pipe_surface_reference(&dest_surface, NULL);
+ /* Restore conditional rendering state. */
+ if (st->render_condition) {
+ pipe->render_condition(pipe, st->render_condition,
+ st->condition_mode);
}
- if (use_fallback) {
+ return;
+
+fallback:
/* software fallback */
fallback_copy_texsubimage(ctx, target, level,
strb, stImage, texBaseFormat,
destX, destY, destZ,
srcX, srcY, width, height);
- }
}
@@ -1937,8 +1895,6 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->MapTextureImage = st_MapTextureImage;
functions->UnmapTextureImage = st_UnmapTextureImage;
- functions->TextureMemCpy = do_memcpy;
-
/* XXX Temporary until we can query pipe's texture sizes */
functions->TestProxyTexImage = _mesa_test_proxy_teximage;
diff --git a/mesalib/src/mesa/state_tracker/st_context.c b/mesalib/src/mesa/state_tracker/st_context.c
index a1817720d..dc1d33f1d 100644
--- a/mesalib/src/mesa/state_tracker/st_context.c
+++ b/mesalib/src/mesa/state_tracker/st_context.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "main/imports.h"
+#include "main/accum.h"
#include "main/context.h"
#include "main/samplerobj.h"
#include "main/shaderobj.h"
@@ -34,7 +35,6 @@
#include "glapi/glapi.h"
#include "st_context.h"
#include "st_debug.h"
-#include "st_cb_accum.h"
#include "st_cb_bitmap.h"
#include "st_cb_blit.h"
#include "st_cb_bufferobjects.h"
@@ -276,7 +276,8 @@ void st_init_driver_functions(struct dd_function_table *functions)
_mesa_init_shader_object_functions(functions);
_mesa_init_sampler_object_functions(functions);
- st_init_accum_functions(functions);
+ functions->Accum = _mesa_accum;
+
st_init_blit_functions(functions);
st_init_bufferobject_functions(functions);
st_init_clear_functions(functions);
diff --git a/mesalib/src/mesa/state_tracker/st_extensions.c b/mesalib/src/mesa/state_tracker/st_extensions.c
index 37fb3e7fd..9e39729e9 100644
--- a/mesalib/src/mesa/state_tracker/st_extensions.c
+++ b/mesalib/src/mesa/state_tracker/st_extensions.c
@@ -210,12 +210,10 @@ void st_init_limits(struct st_context *st)
options->MaxUnrollIterations = MIN2(screen->get_shader_param(screen, sh, PIPE_SHADER_CAP_MAX_INSTRUCTIONS), 65536);
}
- /* PIPE_CAP_MAX_FS_INPUTS specifies the number of COLORn + GENERICn inputs
- * and is set in MaxNativeAttribs. It's always 2 colors + N generic
- * attributes. The GLSL compiler never uses COLORn for varyings, so we
- * subtract the 2 colors to get the maximum number of varyings (generic
- * attributes) supported by a driver. */
- c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
+ /* PIPE_SHADER_CAP_MAX_INPUTS for the FS specifies the maximum number
+ * of inputs. It's always 2 colors + N generic inputs. */
+ c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_CAP_MAX_INPUTS);
c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
c->MinProgramTexelOffset = screen->get_param(screen, PIPE_CAP_MIN_TEXEL_OFFSET);
diff --git a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 59b5ffd4c..6cc655d70 100644
--- a/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/mesalib/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -3514,25 +3514,23 @@ glsl_to_tgsi_visitor::eliminate_dead_code_advanced(void)
break;
case TGSI_OPCODE_ENDIF:
- --level;
- break;
-
case TGSI_OPCODE_ELSE:
- /* Clear all channels written inside the preceding if block from the
- * write array, but leave those that were not touched.
- *
- * FIXME: This destroys opportunities to remove dead code inside of
- * IF blocks that are followed by an ELSE block.
+ /* Promote the recorded level all channels written inside the preceding
+ * if or else block to the level above the if/else block.
*/
for (int r = 0; r < this->next_temp; r++) {
for (int c = 0; c < 4; c++) {
if (!writes[4 * r + c])
continue;
- if (write_level[4 * r + c] >= level)
- writes[4 * r + c] = NULL;
+ if (write_level[4 * r + c] == level)
+ write_level[4 * r + c] = level-1;
}
}
+
+ if(inst->op == TGSI_OPCODE_ENDIF)
+ --level;
+
break;
case TGSI_OPCODE_IF:
diff --git a/mesalib/src/mesa/state_tracker/st_manager.c b/mesalib/src/mesa/state_tracker/st_manager.c
index d5228d387..55699e721 100644
--- a/mesalib/src/mesa/state_tracker/st_manager.c
+++ b/mesalib/src/mesa/state_tracker/st_manager.c
@@ -404,54 +404,6 @@ st_visual_to_context_mode(const struct st_visual *visual,
}
/**
- * Determine the default draw or read buffer from a visual.
- */
-static void
-st_visual_to_default_buffer(const struct st_visual *visual,
- GLenum *buffer, GLint *index)
-{
- enum st_attachment_type statt;
- GLenum buf;
- gl_buffer_index idx;
-
- statt = visual->render_buffer;
- /* do nothing if an invalid render buffer is specified */
- if (statt == ST_ATTACHMENT_INVALID ||
- !st_visual_have_buffers(visual, 1 << statt))
- return;
-
- switch (statt) {
- case ST_ATTACHMENT_FRONT_LEFT:
- buf = GL_FRONT_LEFT;
- idx = BUFFER_FRONT_LEFT;
- break;
- case ST_ATTACHMENT_BACK_LEFT:
- buf = GL_BACK_LEFT;
- idx = BUFFER_BACK_LEFT;
- break;
- case ST_ATTACHMENT_FRONT_RIGHT:
- buf = GL_FRONT_RIGHT;
- idx = BUFFER_FRONT_RIGHT;
- break;
- case ST_ATTACHMENT_BACK_RIGHT:
- buf = GL_BACK_RIGHT;
- idx = BUFFER_BACK_RIGHT;
- break;
- default:
- buf = GL_NONE;
- idx = BUFFER_COUNT;
- break;
- }
-
- if (buf != GL_NONE) {
- if (buffer)
- *buffer = buf;
- if (index)
- *index = idx;
- }
-}
-
-/**
* Create a framebuffer from a manager interface.
*/
static struct st_framebuffer *
@@ -471,12 +423,6 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
st_visual_to_context_mode(stfbi->visual, &mode);
_mesa_initialize_window_framebuffer(&stfb->Base, &mode);
- /* modify the draw/read buffers of the fb */
- st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorDrawBuffer[0],
- &stfb->Base._ColorDrawBufferIndexes[0]);
- st_visual_to_default_buffer(stfbi->visual, &stfb->Base.ColorReadBuffer,
- &stfb->Base._ColorReadBufferIndex);
-
stfb->iface = stfbi;
stfb->iface_stamp = p_atomic_read(&stfbi->stamp) - 1;
@@ -776,16 +722,6 @@ st_api_make_current(struct st_api *stapi, struct st_context_iface *stctxi,
if (stread != stdraw)
st_framebuffer_validate(stread, st);
- /* modify the draw/read buffers of the context */
- if (stdraw->iface) {
- st_visual_to_default_buffer(stdraw->iface->visual,
- &st->ctx->Color.DrawBuffer[0], NULL);
- }
- if (stread->iface) {
- st_visual_to_default_buffer(stread->iface->visual,
- &st->ctx->Pixel.ReadBuffer, NULL);
- }
-
ret = _mesa_make_current(st->ctx, &stdraw->Base, &stread->Base);
st->draw_stamp = stdraw->stamp - 1;
diff --git a/mesalib/src/mesa/state_tracker/st_program.c b/mesalib/src/mesa/state_tracker/st_program.c
index 768da5114..04d3ef60f 100644
--- a/mesalib/src/mesa/state_tracker/st_program.c
+++ b/mesalib/src/mesa/state_tracker/st_program.c
@@ -649,6 +649,25 @@ st_translate_fragment_program(struct st_context *st,
if (write_all == GL_TRUE)
ureg_property_fs_color0_writes_all_cbufs(ureg, 1);
+ if (stfp->Base.FragDepthLayout != FRAG_DEPTH_LAYOUT_NONE) {
+ switch (stfp->Base.FragDepthLayout) {
+ case FRAG_DEPTH_LAYOUT_ANY:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_ANY);
+ break;
+ case FRAG_DEPTH_LAYOUT_GREATER:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_GREATER);
+ break;
+ case FRAG_DEPTH_LAYOUT_LESS:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_LESS);
+ break;
+ case FRAG_DEPTH_LAYOUT_UNCHANGED:
+ ureg_property_fs_depth_layout(ureg, TGSI_FS_DEPTH_LAYOUT_UNCHANGED);
+ break;
+ default:
+ assert(0);
+ }
+ }
+
if (stfp->glsl_to_tgsi)
st_translate_program(st->ctx,
TGSI_PROCESSOR_FRAGMENT,