summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/acc2.c319
-rw-r--r--src/mesa/state_tracker/st_atom_framebuffer.c28
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c20
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c20
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c2
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c2
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c2
-rw-r--r--src/mesa/state_tracker/st_cb_strings.c2
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c4
-rw-r--r--src/mesa/state_tracker/st_draw.c18
-rw-r--r--src/mesa/state_tracker/st_extensions.c7
-rw-r--r--src/mesa/state_tracker/st_format.c97
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c25
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c6
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c50
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.h2
-rw-r--r--src/mesa/state_tracker/st_program.c84
-rw-r--r--src/mesa/state_tracker/st_public.h8
-rw-r--r--src/mesa/state_tracker/st_texture.c47
19 files changed, 335 insertions, 408 deletions
diff --git a/src/mesa/state_tracker/acc2.c b/src/mesa/state_tracker/acc2.c
deleted file mode 100644
index fa5de2b764..0000000000
--- a/src/mesa/state_tracker/acc2.c
+++ /dev/null
@@ -1,319 +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 "st_context.h"
-#include "st_cb_accum.h"
-#include "st_cb_fbo.h"
-#include "st_draw.h"
-#include "st_format.h"
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-#include "pipe/p_inlines.h"
-#include "util/p_tile.h"
-
-
-#define UNCLAMPED_FLOAT_TO_SHORT(us, f) \
- us = ( (short) ( CLAMP((f), -1.0, 1.0) * 32767.0F) )
-
-
-/**
- * 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.
- */
-
-
-static void
-acc_get_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
- uint x, uint y, uint w, uint h, float *p)
-{
- const enum pipe_format f = acc_ps->format;
- const int cpp = acc_ps->cpp;
-
- acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM;
- acc_ps->cpp = 8;
-
- pipe_get_tile_rgba(pipe, acc_ps, x, y, w, h, p);
-
- acc_ps->format = f;
- acc_ps->cpp = cpp;
-}
-
-
-static void
-acc_put_tile_rgba(struct pipe_context *pipe, struct pipe_surface *acc_ps,
- uint x, uint y, uint w, uint h, const float *p)
-{
- enum pipe_format f = acc_ps->format;
- const int cpp = acc_ps->cpp;
-
- acc_ps->format = PIPE_FORMAT_R16G16B16A16_SNORM;
- acc_ps->cpp = 8;
-
- pipe_put_tile_rgba(pipe, acc_ps, x, y, w, h, p);
-
- acc_ps->format = f;
- acc_ps->cpp = cpp;
-}
-
-
-
-void
-st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
-{
- struct pipe_context *pipe = ctx->st->pipe;
- struct st_renderbuffer *acc_strb = st_renderbuffer(rb);
- struct pipe_surface *acc_ps = acc_strb->surface;
- 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;
- const GLfloat r = ctx->Accum.ClearColor[0];
- const GLfloat g = ctx->Accum.ClearColor[1];
- const GLfloat b = ctx->Accum.ClearColor[2];
- const GLfloat a = ctx->Accum.ClearColor[3];
- GLfloat *accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- int i;
-
-#if 1
- GLvoid *map;
-
- map = pipe_surface_map(acc_ps);
- 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 *) map
- + ((ypos + i) * acc_ps->pitch + xpos) * 4);
- 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()");
- }
-
- pipe_surface_unmap(acc_ps);
-
-#else
- for (i = 0; i < width * height; i++) {
- accBuf[i*4+0] = r;
- accBuf[i*4+1] = g;
- accBuf[i*4+2] = b;
- accBuf[i*4+3] = a;
- }
-
- acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
-#endif
-}
-
-
-/** For ADD/MULT */
-static void
-accum_mad(struct pipe_context *pipe, GLfloat scale, GLfloat bias,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct pipe_surface *acc_ps)
-{
- GLfloat *accBuf;
- GLint i;
-
- accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
-
- for (i = 0; i < 4 * width * height; i++) {
- accBuf[i] = accBuf[i] * scale + bias;
- }
-
- pipe_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
-
- free(accBuf);
-}
-
-
-static void
-accum_accum(struct pipe_context *pipe, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct pipe_surface *acc_ps,
- struct pipe_surface *color_ps)
-{
- GLfloat *colorBuf, *accBuf;
- GLint i;
-
- colorBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- accBuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, colorBuf);
- acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
-
- for (i = 0; i < 4 * width * height; i++) {
- accBuf[i] = accBuf[i] + colorBuf[i] * value;
- }
-
- acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, accBuf);
-
- free(colorBuf);
- free(accBuf);
-}
-
-
-static void
-accum_load(struct pipe_context *pipe, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct pipe_surface *acc_ps,
- struct pipe_surface *color_ps)
-{
- GLfloat *buf;
- GLint i;
-
- buf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, buf);
-
- for (i = 0; i < 4 * width * height; i++) {
- buf[i] = buf[i] * value;
- }
-
- acc_put_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, buf);
-
- free(buf);
-}
-
-
-static void
-accum_return(GLcontext *ctx, GLfloat value,
- GLint xpos, GLint ypos, GLint width, GLint height,
- struct pipe_surface *acc_ps,
- struct pipe_surface *color_ps)
-{
- struct pipe_context *pipe = ctx->st->pipe;
- const GLubyte *colormask = ctx->Color.ColorMask;
- GLfloat *abuf, *cbuf = NULL;
- GLint i, ch;
-
- abuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
-
- acc_get_tile_rgba(pipe, acc_ps, xpos, ypos, width, height, abuf);
-
- if (!colormask[0] || !colormask[1] || !colormask[2] || !colormask[3]) {
- cbuf = (GLfloat *) malloc(width * height * 4 * sizeof(GLfloat));
- pipe_get_tile_rgba(pipe, color_ps, xpos, ypos, width, height, cbuf);
- }
-
- for (i = 0; i < width * height; i++) {
- for (ch = 0; ch < 4; ch++) {
- if (colormask[ch]) {
- GLfloat val = abuf[i * 4 + ch] * value;
- abuf[i * 4 + ch] = CLAMP(val, 0.0, 1.0);
- }
- else {
- abuf[i * 4 + ch] = cbuf[i * 4 + ch];
- }
- }
- }
-
- pipe_put_tile_rgba(pipe, color_ps, xpos, ypos, width, height, abuf);
-
- free(abuf);
- if (cbuf)
- free(cbuf);
-}
-
-
-static void
-st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
-{
- struct st_context *st = ctx->st;
- struct pipe_context *pipe = st->pipe;
- struct st_renderbuffer *acc_strb
- = st_renderbuffer(ctx->DrawBuffer->Attachment[BUFFER_ACCUM].Renderbuffer);
- struct st_renderbuffer *color_strb
- = st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
- struct pipe_surface *acc_ps = acc_strb->surface;
- struct pipe_surface *color_ps = color_strb->surface;
-
- 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;
-
- /* make sure color bufs aren't cached */
- pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE, NULL);
-
- switch (op) {
- case GL_ADD:
- if (value != 0.0F) {
- accum_mad(pipe, 1.0, value, xpos, ypos, width, height, acc_ps);
- }
- break;
- case GL_MULT:
- if (value != 1.0F) {
- accum_mad(pipe, value, 0.0, xpos, ypos, width, height, acc_ps);
- }
- break;
- case GL_ACCUM:
- if (value != 0.0F) {
- accum_accum(pipe, value, xpos, ypos, width, height, acc_ps, color_ps);
- }
- break;
- case GL_LOAD:
- accum_load(pipe, value, xpos, ypos, width, height, acc_ps, color_ps);
- break;
- case GL_RETURN:
- accum_return(ctx, value, xpos, ypos, width, height, acc_ps, color_ps);
- break;
- default:
- assert(0);
- }
-}
-
-
-
-void st_init_accum_functions(struct dd_function_table *functions)
-{
- functions->Accum = st_Accum;
-}
diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c
index 2916886610..ca1a719a9a 100644
--- a/src/mesa/state_tracker/st_atom_framebuffer.c
+++ b/src/mesa/state_tracker/st_atom_framebuffer.c
@@ -95,7 +95,7 @@ update_framebuffer_state( struct st_context *st )
struct pipe_framebuffer_state *framebuffer = &st->state.framebuffer;
struct gl_framebuffer *fb = st->ctx->DrawBuffer;
struct st_renderbuffer *strb;
- GLuint i, j;
+ GLuint i;
memset(framebuffer, 0, sizeof(*framebuffer));
@@ -108,20 +108,18 @@ update_framebuffer_state( struct st_context *st )
* to determine which surfaces to draw to
*/
framebuffer->num_cbufs = 0;
- for (j = 0; j < MAX_DRAW_BUFFERS; j++) {
- for (i = 0; i < fb->_NumColorDrawBuffers[j]; i++) {
- strb = st_renderbuffer(fb->_ColorDrawBuffers[j][i]);
-
- /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
- if (strb->rtt) {
- /* rendering to a GL texture, may have to update surface */
- update_renderbuffer_surface(st, strb);
- }
+ for (i = 0; i < fb->_NumColorDrawBuffers; i++) {
+ strb = st_renderbuffer(fb->_ColorDrawBuffers[i]);
- if (strb->surface) {
- framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface;
- framebuffer->num_cbufs++;
- }
+ /*printf("--------- framebuffer surface rtt %p\n", strb->rtt);*/
+ if (strb->rtt) {
+ /* rendering to a GL texture, may have to update surface */
+ update_renderbuffer_surface(st, strb);
+ }
+
+ if (strb->surface) {
+ framebuffer->cbufs[framebuffer->num_cbufs] = strb->surface;
+ framebuffer->num_cbufs++;
}
}
@@ -146,7 +144,7 @@ update_framebuffer_state( struct st_context *st )
cso_set_framebuffer(st->cso_context, framebuffer);
- if (fb->_ColorDrawBufferMask[0] & BUFFER_BIT_FRONT_LEFT) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
if (st->frontbuffer_status == FRONT_STATUS_COPY_OF_BACK) {
/* XXX copy back buf to front? */
}
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index cef61fb55c..d7b904354f 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -121,24 +121,30 @@ gl_filter_to_img_filter(GLenum filter)
static void
update_samplers(struct st_context *st)
{
- const struct st_fragment_program *fs = st->fp;
+ struct gl_vertex_program *vprog = st->ctx->VertexProgram._Current;
+ struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+ const GLbitfield samplersUsed = (vprog->Base.SamplersUsed |
+ fprog->Base.SamplersUsed);
GLuint su;
st->state.num_samplers = 0;
- /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fs->Base.Base.SamplersUsed);*/
-
/* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureImageUnits; su++) {
struct pipe_sampler_state *sampler = st->state.samplers + su;
memset(sampler, 0, sizeof(*sampler));
- if (fs->Base.Base.SamplersUsed & (1 << su)) {
- GLuint texUnit = fs->Base.Base.SamplerUnits[su];
- const struct gl_texture_object *texobj
- = st->ctx->Texture.Unit[texUnit]._Current;
+ if (samplersUsed & (1 << su)) {
+ struct gl_texture_object *texobj;
+ GLuint texUnit;
+
+ if (fprog->Base.SamplersUsed & (1 << su))
+ texUnit = fprog->Base.SamplerUnits[su];
+ else
+ texUnit = vprog->Base.SamplerUnits[su];
+ texobj = st->ctx->Texture.Unit[texUnit]._Current;
if (!texobj) {
texobj = st_get_default_texture(st);
}
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index fb03766ff5..18ffc08c6b 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -44,22 +44,30 @@
static void
update_textures(struct st_context *st)
{
+ struct gl_vertex_program *vprog = st->ctx->VertexProgram._Current;
struct gl_fragment_program *fprog = st->ctx->FragmentProgram._Current;
+ const GLbitfield samplersUsed = (vprog->Base.SamplersUsed |
+ fprog->Base.SamplersUsed);
GLuint su;
st->state.num_textures = 0;
- /*printf("%s samplers used = 0x%x\n", __FUNCTION__, fprog->Base.SamplersUsed);*/
-
+ /* loop over sampler units (aka tex image units) */
for (su = 0; su < st->ctx->Const.MaxTextureCoordUnits; su++) {
struct pipe_texture *pt = NULL;
- if (fprog->Base.SamplersUsed & (1 << su)) {
- const GLuint texUnit = fprog->Base.SamplerUnits[su];
- struct gl_texture_object *texObj
- = st->ctx->Texture.Unit[texUnit]._Current;
+ if (samplersUsed & (1 << su)) {
+ struct gl_texture_object *texObj;
struct st_texture_object *stObj;
GLboolean flush, retval;
+ GLuint texUnit;
+
+ if (fprog->Base.SamplersUsed & (1 << su))
+ texUnit = fprog->Base.SamplerUnits[su];
+ else
+ texUnit = vprog->Base.SamplerUnits[su];
+
+ texObj = st->ctx->Texture.Unit[texUnit]._Current;
if (!texObj) {
texObj = st_get_default_texture(st);
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index bc05ca6a2f..f14e562400 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -821,7 +821,7 @@ st_destroy_bitmap(struct st_context *st)
}
if (st->bitmap.vbuf) {
- pipe_buffer_destroy(pipe->screen, st->bitmap.vbuf);
+ pipe_buffer_reference(pipe->screen, &st->bitmap.vbuf, NULL);
st->bitmap.vbuf = NULL;
}
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 327bafeb98..2852623472 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -79,7 +79,7 @@ st_BlitFramebuffer(GLcontext *ctx,
struct st_renderbuffer *srcRb =
st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer);
struct st_renderbuffer *dstRb =
- st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]);
+ st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0]);
struct pipe_surface *srcSurf = srcRb->surface;
struct pipe_surface *dstSurf = dstRb->surface;
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index b6cea16163..fca1107d72 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -116,7 +116,7 @@ st_destroy_clear(struct st_context *st)
st->clear.vs = NULL;
}
if (st->clear.vbuf) {
- pipe_buffer_destroy(pipe->screen, st->clear.vbuf);
+ pipe_buffer_reference(pipe->screen, &st->clear.vbuf, NULL);
st->clear.vbuf = NULL;
}
}
diff --git a/src/mesa/state_tracker/st_cb_strings.c b/src/mesa/state_tracker/st_cb_strings.c
index 066124f8f3..09545aa8fb 100644
--- a/src/mesa/state_tracker/st_cb_strings.c
+++ b/src/mesa/state_tracker/st_cb_strings.c
@@ -40,7 +40,7 @@
#include "st_context.h"
#include "st_cb_strings.h"
-#define ST_VERSION_STRING "0.1"
+#define ST_VERSION_STRING "0.2"
static const GLubyte *
st_get_string(GLcontext * ctx, GLenum name)
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 0b2b639a5b..d08229b57a 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -749,8 +749,8 @@ st_GetTexImage(GLcontext * ctx, GLenum target, GLint level,
static void
st_GetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
GLvoid *pixels,
- const struct gl_texture_object *texObj,
- const struct gl_texture_image *texImage)
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage)
{
st_get_tex_image(ctx, target, level, 0, 0, pixels,
(struct gl_texture_object *) texObj,
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index e78d98f1e9..31383b4887 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -301,18 +301,17 @@ is_interleaved_arrays(const struct st_vertex_program *vp,
}
*userSpace = (num_client_arrays == vp->num_inputs);
- /*printf("user space: %d\n", (int) *userSpace);*/
+ /* printf("user space: %d (%d %d)\n", (int) *userSpace,num_client_arrays,vp->num_inputs); */
return GL_TRUE;
}
/**
- * Once we know all the arrays are in user space, this function
- * computes the memory range occupied by the arrays.
+ * Compute the memory range occupied by the arrays.
*/
static void
-get_user_arrays_bounds(const struct st_vertex_program *vp,
+get_arrays_bounds(const struct st_vertex_program *vp,
const struct gl_client_array **arrays,
GLuint max_index,
const GLubyte **low, const GLubyte **high)
@@ -366,20 +365,21 @@ setup_interleaved_attribs(GLcontext *ctx,
/*printf("stobj %u = %p\n", attr, (void*)stobj);*/
if (attr == 0) {
+ const GLubyte *low, *high;
+
+ get_arrays_bounds(vp, arrays, max_index, &low, &high);
+ /*printf("buffer range: %p %p %d\n", low, high, high-low);*/
+
+ offset0 = low;
if (userSpace) {
- const GLubyte *low, *high;
- get_user_arrays_bounds(vp, arrays, max_index, &low, &high);
- /*printf("user buffer range: %p %p %d\n", low, high, high-low);*/
vbuffer->buffer =
pipe_user_buffer_create(pipe->screen, (void *) low, high - low);
vbuffer->buffer_offset = 0;
- offset0 = low;
}
else {
vbuffer->buffer = NULL;
pipe_buffer_reference(pipe->screen, &vbuffer->buffer, stobj->buffer);
vbuffer->buffer_offset = (unsigned) arrays[mesaAttr]->Ptr;
- offset0 = arrays[mesaAttr]->Ptr;
}
vbuffer->pitch = stride; /* in bytes */
vbuffer->max_index = max_index;
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 60fd440ef7..5ff0c61147 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1,6 +1,7 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright (c) 2008 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -89,6 +90,9 @@ void st_init_limits(struct st_context *st)
= _min(screen->get_param(screen, PIPE_CAP_MAX_TEXTURE_IMAGE_UNITS),
MAX_TEXTURE_IMAGE_UNITS);
+ c->MaxVertexTextureImageUnits
+ = screen->get_param(screen, PIPE_CAP_MAX_VERTEX_TEXTURE_UNITS);
+
c->MaxDrawBuffers
= _clamp(screen->get_param(screen, PIPE_CAP_MAX_RENDER_TARGETS),
1, MAX_DRAW_BUFFERS);
@@ -240,6 +244,9 @@ void st_init_extensions(struct st_context *st)
if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SRGB,
PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_USAGE_SAMPLER, 0) ||
+ screen->is_format_supported(screen, PIPE_FORMAT_A8R8G8B8_SRGB,
+ PIPE_TEXTURE_2D,
PIPE_TEXTURE_USAGE_SAMPLER, 0)) {
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index a8ae30a454..9e2d60c926 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -1,6 +1,7 @@
/**************************************************************************
*
* Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright (c) 2008 VMware, Inc.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -263,6 +264,28 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
return PIPE_FORMAT_DXT3_RGBA;
case MESA_FORMAT_RGBA_DXT5:
return PIPE_FORMAT_DXT5_RGBA;
+#if FEATURE_EXT_texture_sRGB
+ case MESA_FORMAT_SRGB_DXT1:
+ return PIPE_FORMAT_DXT1_SRGB;
+ case MESA_FORMAT_SRGBA_DXT1:
+ return PIPE_FORMAT_DXT1_SRGBA;
+ case MESA_FORMAT_SRGBA_DXT3:
+ return PIPE_FORMAT_DXT3_SRGBA;
+ case MESA_FORMAT_SRGBA_DXT5:
+ return PIPE_FORMAT_DXT5_SRGBA;
+#endif
+#endif
+#if FEATURE_EXT_texture_sRGB
+ case MESA_FORMAT_SLA8:
+ return PIPE_FORMAT_A8L8_SRGB;
+ case MESA_FORMAT_SL8:
+ return PIPE_FORMAT_L8_SRGB;
+ case MESA_FORMAT_SRGB8:
+ return PIPE_FORMAT_R8G8B8_SRGB;
+ case MESA_FORMAT_SRGBA8:
+ return PIPE_FORMAT_R8G8B8A8_SRGB;
+ case MESA_FORMAT_SARGB8:
+ return PIPE_FORMAT_A8R8G8B8_SRGB;
#endif
default:
assert(0);
@@ -294,6 +317,28 @@ default_rgba_format(struct pipe_screen *screen,
return PIPE_FORMAT_NONE;
}
+/**
+ * Find an sRGBA format supported by the context/winsys.
+ */
+static enum pipe_format
+default_srgba_format(struct pipe_screen *screen,
+ enum pipe_texture_target target,
+ unsigned tex_usage,
+ unsigned geom_flags)
+{
+ static const enum pipe_format colorFormats[] = {
+ PIPE_FORMAT_A8R8G8B8_SRGB,
+ PIPE_FORMAT_B8G8R8A8_SRGB,
+ PIPE_FORMAT_R8G8B8A8_SRGB,
+ };
+ uint i;
+ for (i = 0; i < Elements(colorFormats); i++) {
+ if (screen->is_format_supported( screen, colorFormats[i], target, tex_usage, geom_flags )) {
+ return colorFormats[i];
+ }
+ }
+ return PIPE_FORMAT_NONE;
+}
/**
* Search list of formats for first RGBA format with >8 bits/channel.
@@ -512,6 +557,36 @@ st_choose_format(struct pipe_context *pipe, GLint internalFormat,
return PIPE_FORMAT_Z24S8_UNORM;
return PIPE_FORMAT_NONE;
+ case GL_SRGB_EXT:
+ case GL_SRGB8_EXT:
+ case GL_COMPRESSED_SRGB_EXT:
+ case GL_COMPRESSED_SRGB_ALPHA_EXT:
+ case GL_SRGB_ALPHA_EXT:
+ case GL_SRGB8_ALPHA8_EXT:
+ return default_srgba_format( screen, target, tex_usage, geom_flags );
+ case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+ return PIPE_FORMAT_DXT1_SRGB;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+ return PIPE_FORMAT_DXT1_SRGBA;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+ return PIPE_FORMAT_DXT3_SRGBA;
+ case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+ return PIPE_FORMAT_DXT5_SRGBA;
+
+ case GL_SLUMINANCE_ALPHA_EXT:
+ case GL_SLUMINANCE8_ALPHA8_EXT:
+ case GL_COMPRESSED_SLUMINANCE_EXT:
+ case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+ if (screen->is_format_supported( screen, PIPE_FORMAT_A8L8_SRGB, target, tex_usage, geom_flags ))
+ return PIPE_FORMAT_A8L8_SRGB;
+ return default_srgba_format( screen, target, tex_usage, geom_flags );
+
+ case GL_SLUMINANCE_EXT:
+ case GL_SLUMINANCE8_EXT:
+ if (screen->is_format_supported( screen, PIPE_FORMAT_L8_SRGB, target, tex_usage, geom_flags ))
+ return PIPE_FORMAT_L8_SRGB;
+ return default_srgba_format( screen, target, tex_usage, geom_flags );
+
default:
return PIPE_FORMAT_NONE;
}
@@ -591,6 +666,28 @@ translate_gallium_format_to_mesa_format(enum pipe_format format)
return &_mesa_texformat_rgba_dxt3;
case PIPE_FORMAT_DXT5_RGBA:
return &_mesa_texformat_rgba_dxt5;
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_DXT1_SRGB:
+ return &_mesa_texformat_srgb_dxt1;
+ case PIPE_FORMAT_DXT1_SRGBA:
+ return &_mesa_texformat_srgba_dxt1;
+ case PIPE_FORMAT_DXT3_SRGBA:
+ return &_mesa_texformat_srgba_dxt3;
+ case PIPE_FORMAT_DXT5_SRGBA:
+ return &_mesa_texformat_srgba_dxt5;
+#endif
+#endif
+#if FEATURE_EXT_texture_sRGB
+ case PIPE_FORMAT_A8L8_SRGB:
+ return &_mesa_texformat_sla8;
+ case PIPE_FORMAT_L8_SRGB:
+ return &_mesa_texformat_sl8;
+ case PIPE_FORMAT_R8G8B8_SRGB:
+ return &_mesa_texformat_srgb8;
+ case PIPE_FORMAT_R8G8B8A8_SRGB:
+ return &_mesa_texformat_srgba8;
+ case PIPE_FORMAT_A8R8G8B8_SRGB:
+ return &_mesa_texformat_sargb8;
#endif
/* XXX add additional cases */
default:
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 7d270a3272..ea22a94303 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -153,9 +153,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb,
}
-void st_unreference_framebuffer( struct st_framebuffer **stfb )
+void st_unreference_framebuffer( struct st_framebuffer *stfb )
{
- _mesa_unreference_framebuffer((struct gl_framebuffer **) stfb);
+ _mesa_unreference_framebuffer((struct gl_framebuffer **) &stfb);
}
@@ -169,6 +169,7 @@ void
st_set_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex, struct pipe_surface *surf)
{
+ GET_CURRENT_CONTEXT(ctx);
static const GLuint invalid_size = 9999999;
struct st_renderbuffer *strb;
GLuint width, height, i;
@@ -176,12 +177,23 @@ st_set_framebuffer_surface(struct st_framebuffer *stfb,
assert(surfIndex < BUFFER_COUNT);
strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
- assert(strb);
+
+ /* fail */
+ if (!strb) return;
/* replace the renderbuffer's surface/texture pointers */
pipe_surface_reference( &strb->surface, surf );
pipe_texture_reference( &strb->texture, surf->texture );
+ if (ctx) {
+ /* If ctx isn't set, we've likely not made current yet.
+ * But when we do, we need to start setting this dirty bit
+ * to ensure the renderbuffer attachements are up-to-date
+ * via update_framebuffer.
+ */
+ ctx->st->dirty.st |= ST_NEW_FRAMEBUFFER;
+ }
+
/* update renderbuffer's width/height */
strb->Base.Width = surf->width;
strb->Base.Height = surf->height;
@@ -304,3 +316,10 @@ void *st_framebuffer_private( struct st_framebuffer *stfb )
return stfb->Private;
}
+void st_get_framebuffer_dimensions( struct st_framebuffer *stfb,
+ uint *width,
+ uint *height)
+{
+ *width = stfb->Base.Width;
+ *height = stfb->Base.Height;
+}
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index b9d114b1c9..a15faf732c 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -138,11 +138,11 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
_mesa_generate_mipmap_level(target, datatype, comps,
0 /*border*/,
pt->width[srcLevel], pt->height[srcLevel], pt->depth[srcLevel],
- srcSurf->stride, /* stride in bytes */
srcData,
+ srcSurf->stride, /* stride in bytes */
pt->width[dstLevel], pt->height[dstLevel], pt->depth[dstLevel],
- dstSurf->stride, /* stride in bytes */
- dstData);
+ dstData,
+ dstSurf->stride); /* stride in bytes */
pipe_buffer_unmap(pipe->screen, srcSurf->buffer);
pipe_buffer_unmap(pipe->screen, dstSurf->buffer);
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 33574ddf40..ce8b441194 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -346,6 +346,12 @@ compile_instruction(
case OPCODE_DDY:
fullinst->Instruction.Opcode = TGSI_OPCODE_DDY;
break;
+ case OPCODE_DP2:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_DP2;
+ break;
+ case OPCODE_DP2A:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_DP2A;
+ break;
case OPCODE_DP3:
fullinst->Instruction.Opcode = TGSI_OPCODE_DP3;
break;
@@ -389,8 +395,8 @@ compile_instruction(
fullinst->Instruction.Opcode = TGSI_OPCODE_IF;
fullinst->InstructionExtLabel.Label = inst->BranchTarget + preamble_size;
break;
- case OPCODE_INT:
- fullinst->Instruction.Opcode = TGSI_OPCODE_INT;
+ case OPCODE_TRUNC:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_TRUNC;
break;
case OPCODE_KIL:
/* conditional */
@@ -443,6 +449,12 @@ compile_instruction(
case OPCODE_NOP:
fullinst->Instruction.Opcode = TGSI_OPCODE_NOP;
break;
+ case OPCODE_NRM3:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_NRM;
+ break;
+ case OPCODE_NRM4:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_NRM4;
+ break;
case OPCODE_POW:
fullinst->Instruction.Opcode = TGSI_OPCODE_POW;
break;
@@ -498,6 +510,9 @@ compile_instruction(
case OPCODE_SNE:
fullinst->Instruction.Opcode = TGSI_OPCODE_SNE;
break;
+ case OPCODE_SSG:
+ fullinst->Instruction.Opcode = TGSI_OPCODE_SSG;
+ break;
case OPCODE_SUB:
fullinst->Instruction.Opcode = TGSI_OPCODE_SUB;
break;
@@ -569,7 +584,8 @@ make_input_decl(
GLuint usage_mask,
GLboolean semantic_info,
GLuint semantic_name,
- GLbitfield semantic_index )
+ GLbitfield semantic_index,
+ GLbitfield input_flags)
{
struct tgsi_full_declaration decl;
@@ -588,6 +604,10 @@ make_input_decl(
if (interpolate_info) {
decl.Declaration.Interpolate = interpolate;
}
+ if (input_flags & PROG_PARAM_BIT_CENTROID)
+ decl.Declaration.Centroid = 1;
+ if (input_flags & PROG_PARAM_BIT_INVARIANT)
+ decl.Declaration.Invariant = 1;
return decl;
}
@@ -600,7 +620,8 @@ make_output_decl(
GLuint index,
GLuint semantic_name,
GLuint semantic_index,
- GLbitfield usage_mask )
+ GLuint usage_mask,
+ GLbitfield output_flags)
{
struct tgsi_full_declaration decl;
@@ -614,6 +635,10 @@ make_output_decl(
decl.DeclarationRange.Last = index;
decl.Semantic.SemanticName = semantic_name;
decl.Semantic.SemanticIndex = semantic_index;
+ if (output_flags & PROG_PARAM_BIT_CENTROID)
+ decl.Declaration.Centroid = 1;
+ if (output_flags & PROG_PARAM_BIT_INVARIANT)
+ decl.Declaration.Invariant = 1;
return decl;
}
@@ -727,10 +752,12 @@ st_translate_mesa_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
+ const GLbitfield inputFlags[],
GLuint numOutputs,
const GLuint outputMapping[],
const ubyte outputSemanticName[],
const ubyte outputSemanticIndex[],
+ const GLbitfield outputFlags[],
struct tgsi_token *tokens,
GLuint maxTokens )
{
@@ -768,7 +795,8 @@ st_translate_mesa_program(
GL_TRUE, interpMode[i],
TGSI_WRITEMASK_XYZW,
GL_TRUE, inputSemanticName[i],
- inputSemanticIndex[i]);
+ inputSemanticIndex[i],
+ inputFlags[i]);
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
@@ -785,7 +813,8 @@ st_translate_mesa_program(
fulldecl = make_input_decl(i,
GL_FALSE, 0,
TGSI_WRITEMASK_XYZW,
- GL_FALSE, 0, 0);
+ GL_FALSE, 0, 0,
+ inputFlags[i]);
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
@@ -804,13 +833,15 @@ st_translate_mesa_program(
fulldecl = make_output_decl(i,
TGSI_SEMANTIC_POSITION, /* Z / Depth */
outputSemanticIndex[i],
- TGSI_WRITEMASK_Z );
+ TGSI_WRITEMASK_Z,
+ outputFlags[i]);
break;
case TGSI_SEMANTIC_COLOR:
fulldecl = make_output_decl(i,
TGSI_SEMANTIC_COLOR,
outputSemanticIndex[i],
- TGSI_WRITEMASK_XYZW );
+ TGSI_WRITEMASK_XYZW,
+ outputFlags[i]);
break;
default:
assert(0);
@@ -829,7 +860,8 @@ st_translate_mesa_program(
fulldecl = make_output_decl(i,
outputSemanticName[i],
outputSemanticIndex[i],
- TGSI_WRITEMASK_XYZW );
+ TGSI_WRITEMASK_XYZW,
+ outputFlags[i]);
ti += tgsi_build_full_declaration(&fulldecl,
&tokens[ti],
header,
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h
index 77c74644b8..7b2bee1ab7 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.h
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h
@@ -48,10 +48,12 @@ st_translate_mesa_program(
const ubyte inputSemanticName[],
const ubyte inputSemanticIndex[],
const GLuint interpMode[],
+ const GLbitfield inputFlags[],
GLuint numOutputs,
const GLuint outputMapping[],
const ubyte outputSemanticName[],
const ubyte outputSemanticIndex[],
+ const GLbitfield outputFlags[],
struct tgsi_token *tokens,
GLuint maxTokens );
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index af0df22dc5..cf4b39cee4 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -99,7 +99,12 @@ st_translate_vertex_program(struct st_context *st,
ubyte vs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
uint vs_num_outputs = 0;
+ GLbitfield input_flags[MAX_PROGRAM_INPUTS];
+ GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+
memset(&vs, 0, sizeof(vs));
+ memset(input_flags, 0, sizeof(input_flags));
+ memset(output_flags, 0, sizeof(output_flags));
if (stvp->Base.IsPositionInvariant)
_mesa_insert_mvp_code(st->ctx, &stvp->Base);
@@ -171,6 +176,8 @@ st_translate_vertex_program(struct st_context *st,
default:
assert(0);
}
+
+ input_flags[slot] = stvp->Base.Base.InputFlags[attr];
}
}
@@ -192,6 +199,7 @@ st_translate_vertex_program(struct st_context *st,
for (i = 0; i < PIPE_MAX_SHADER_OUTPUTS; i++) {
vs_output_semantic_name[i] = TGSI_SEMANTIC_GENERIC;
vs_output_semantic_index[i] = 0;
+ output_flags[i] = 0x0;
}
num_generic = 0;
@@ -276,6 +284,8 @@ st_translate_vertex_program(struct st_context *st,
vs_output_semantic_index[slot] = num_generic++;
}
}
+
+ output_flags[slot] = stvp->Base.Base.OutputFlags[attr];
}
}
@@ -307,21 +317,23 @@ st_translate_vertex_program(struct st_context *st,
/* XXX: fix static allocation of tokens:
*/
- num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_VERTEX,
- &stvp->Base.Base,
- /* inputs */
- vs_num_inputs,
- stvp->input_to_index,
- vs_input_semantic_name,
- vs_input_semantic_index,
- NULL,
- /* outputs */
- vs_num_outputs,
- outputMapping,
- vs_output_semantic_name,
- vs_output_semantic_index,
- /* tokenized result */
- tokens, ST_MAX_SHADER_TOKENS);
+ num_tokens = st_translate_mesa_program(TGSI_PROCESSOR_VERTEX,
+ &stvp->Base.Base,
+ /* inputs */
+ vs_num_inputs,
+ stvp->input_to_index,
+ vs_input_semantic_name,
+ vs_input_semantic_index,
+ NULL,
+ input_flags,
+ /* outputs */
+ vs_num_outputs,
+ outputMapping,
+ vs_output_semantic_name,
+ vs_output_semantic_index,
+ output_flags,
+ /* tokenized result */
+ tokens, ST_MAX_SHADER_TOKENS);
assert(num_tokens < ST_MAX_SHADER_TOKENS);
@@ -371,7 +383,12 @@ st_translate_fragment_program(struct st_context *st,
ubyte fs_output_semantic_index[PIPE_MAX_SHADER_OUTPUTS];
uint fs_num_outputs = 0;
+ GLbitfield input_flags[MAX_PROGRAM_INPUTS];
+ GLbitfield output_flags[MAX_PROGRAM_OUTPUTS];
+
memset(&fs, 0, sizeof(fs));
+ memset(input_flags, 0, sizeof(input_flags));
+ memset(output_flags, 0, sizeof(output_flags));
/* which vertex output goes to the first fragment input: */
if (inputsRead & FRAG_BIT_WPOS)
@@ -435,6 +452,8 @@ st_translate_fragment_program(struct st_context *st,
stfp->input_semantic_index[slot] = num_generic++;
interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
}
+
+ input_flags[slot] = stfp->Base.Base.InputFlags[attr];
}
}
@@ -471,6 +490,9 @@ st_translate_fragment_program(struct st_context *st,
default:
assert(0);
}
+
+ output_flags[fs_num_outputs] = stfp->Base.Base.OutputFlags[attr];
+
fs_num_outputs++;
}
}
@@ -481,21 +503,23 @@ st_translate_fragment_program(struct st_context *st,
/* XXX: fix static allocation of tokens:
*/
- num_tokens = st_translate_mesa_program( TGSI_PROCESSOR_FRAGMENT,
- &stfp->Base.Base,
- /* inputs */
- fs_num_inputs,
- inputMapping,
- stfp->input_semantic_name,
- stfp->input_semantic_index,
- interpMode,
- /* outputs */
- fs_num_outputs,
- outputMapping,
- fs_output_semantic_name,
- fs_output_semantic_index,
- /* tokenized result */
- tokens, ST_MAX_SHADER_TOKENS);
+ num_tokens = st_translate_mesa_program(TGSI_PROCESSOR_FRAGMENT,
+ &stfp->Base.Base,
+ /* inputs */
+ fs_num_inputs,
+ inputMapping,
+ stfp->input_semantic_name,
+ stfp->input_semantic_index,
+ interpMode,
+ input_flags,
+ /* outputs */
+ fs_num_outputs,
+ outputMapping,
+ fs_output_semantic_name,
+ fs_output_semantic_index,
+ output_flags,
+ /* tokenized result */
+ tokens, ST_MAX_SHADER_TOKENS);
assert(num_tokens < ST_MAX_SHADER_TOKENS);
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index 5cfb2e41f2..88995aa874 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -42,6 +42,8 @@
#define ST_SURFACE_DEPTH 8
#define ST_TEXTURE_2D 0x2
+#define ST_TEXTURE_RECT 0x4
+
#define ST_TEXTURE_RGB 0x1
#define ST_TEXTURE_RGBA 0x2
@@ -75,6 +77,9 @@ void st_resize_framebuffer( struct st_framebuffer *stfb,
void st_set_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex, struct pipe_surface *surf);
+void st_get_framebuffer_dimensions( struct st_framebuffer *stfb,
+ uint *width, uint *height);
+
struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex);
@@ -83,7 +88,7 @@ struct pipe_texture *st_get_framebuffer_texture(struct st_framebuffer *stfb,
void *st_framebuffer_private( struct st_framebuffer *stfb );
-void st_unreference_framebuffer( struct st_framebuffer **stfb );
+void st_unreference_framebuffer( struct st_framebuffer *stfb );
void st_make_current(struct st_context *st,
struct st_framebuffer *draw,
@@ -96,6 +101,7 @@ void st_finish( struct st_context *st );
void st_notify_swapbuffers(struct st_framebuffer *stfb);
void st_notify_swapbuffers_complete(struct st_framebuffer *stfb);
+int st_set_teximage(struct pipe_texture *pt, int target);
/** Redirect rendering into stfb's surface to a texture image */
int st_bind_teximage(struct st_framebuffer *stfb, uint surfIndex,
diff --git a/src/mesa/state_tracker/st_texture.c b/src/mesa/state_tracker/st_texture.c
index 29b1634762..63cfe5fc16 100644
--- a/src/mesa/state_tracker/st_texture.c
+++ b/src/mesa/state_tracker/st_texture.c
@@ -32,6 +32,7 @@
#include "st_cb_fbo.h"
#include "main/enums.h"
#include "main/teximage.h"
+#include "main/texstore.h"
#undef Elements /* fix re-defined macro warning */
@@ -352,6 +353,52 @@ st_texture_image_copy(struct pipe_context *pipe,
}
}
+/** Bind a pipe surface for use as a texture image */
+int
+st_set_teximage(struct pipe_texture *pt, int target)
+{
+ GET_CURRENT_CONTEXT(ctx);
+ const GLuint unit = ctx->Texture.CurrentUnit;
+ struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
+ struct gl_texture_object *texObj;
+ struct gl_texture_image *texImage;
+ struct st_texture_image *stImage;
+ int internalFormat;
+
+ switch (pt->format) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ internalFormat = GL_RGBA8;
+ break;
+ default:
+ return 0;
+ };
+
+ switch (target) {
+ case ST_TEXTURE_2D:
+ target = GL_TEXTURE_2D;
+ break;
+ case ST_TEXTURE_RECT:
+ target = GL_TEXTURE_RECTANGLE_ARB;
+ break;
+ default:
+ return 0;
+ }
+
+ texObj = _mesa_select_tex_object(ctx, texUnit, target);
+ texImage = _mesa_get_tex_image(ctx, texObj, target, 0);
+ stImage = st_texture_image(texImage);
+
+ _mesa_init_teximage_fields(ctx, GL_TEXTURE_2D, texImage, pt->width[0],
+ pt->height[0], 1, 0, internalFormat);
+
+ texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat, GL_RGBA,
+ GL_UNSIGNED_BYTE);
+ _mesa_set_fetch_functions(texImage, 2);
+
+ pipe_texture_reference(&stImage->pt, pt);
+
+ return 1;
+}
/** Redirect rendering into stfb's surface to a texture image */
int