summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorBen Skeggs <skeggsb@gmail.com>2008-06-23 00:01:17 +1000
committerBen Skeggs <skeggsb@gmail.com>2008-06-23 00:01:17 +1000
commitaa3ab377e6e2e5811cdd704d87c3e24acb5eff72 (patch)
treeab8a443a58a58a6b88f35d4b5730ed1292e44d26 /src/mesa/state_tracker
parent8c26a521ee80f5d8a1d0aabd0910233aad400322 (diff)
parente2c3f06e9649b5b87fc9adbca7d1f07841bba895 (diff)
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Conflicts: configs/default
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_api.c (renamed from src/mesa/state_tracker/st_atom_fixedfunction.c)41
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c2
-rw-r--r--src/mesa/state_tracker/st_atom_sampler.c9
-rw-r--r--src/mesa/state_tracker/st_atom_scissor.c8
-rw-r--r--src/mesa/state_tracker/st_atom_viewport.c12
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c68
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c3
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c8
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c8
-rw-r--r--src/mesa/state_tracker/st_context.c36
-rw-r--r--src/mesa/state_tracker/st_draw.c34
-rw-r--r--src/mesa/state_tracker/st_format.c29
-rw-r--r--src/mesa/state_tracker/st_framebuffer.c57
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c1
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c32
-rw-r--r--src/mesa/state_tracker/st_public.h10
16 files changed, 224 insertions, 134 deletions
diff --git a/src/mesa/state_tracker/st_atom_fixedfunction.c b/src/mesa/state_tracker/st_api.c
index 165567af70..fc0e9a2316 100644
--- a/src/mesa/state_tracker/st_atom_fixedfunction.c
+++ b/src/mesa/state_tracker/st_api.c
@@ -1,6 +1,6 @@
/**************************************************************************
*
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -24,43 +24,10 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**************************************************************************/
- /*
- * Authors:
- * Keith Whitwell <keith@tungstengraphics.com>
- * Brian Paul
- */
-
-#include "tnl/t_vp_build.h"
-
-#include "pipe/p_context.h"
-#include "pipe/p_defines.h"
-
-#include "st_context.h"
-#include "st_atom.h"
-
-
-#define TGSI_DEBUG 0
/**
- * When TnL state has changed, need to generate new vertex program.
- * This should be done before updating the vertes shader (vs) state.
+ * Just a global symbol for EGL to look for to identify the supported
+ * graphics API.
*/
-static void update_tnl( struct st_context *st )
-{
- /* Would be good to avoid this when shaders are active:
- */
- _tnl_UpdateFixedFunctionProgram( st->ctx );
-}
-
-
-const struct st_tracked_state st_update_tnl = {
- "st_update_tnl", /* name */
- { /* dirty */
- TNL_FIXED_FUNCTION_STATE_FLAGS, /* mesa */
- 0 /* st */
- },
- update_tnl /* update */
-};
-
-
+int st_api_OpenGL = 1;
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index e500ac8684..e4de875e8c 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -77,7 +77,7 @@ is_identity(const GLfloat m[16])
GLuint i;
for (i = 0; i < 16; i++) {
const int row = i % 4, col = i / 4;
- const float val = (row == col);
+ const float val = (GLfloat)(row == col);
if (m[i] != val)
return GL_FALSE;
}
diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c
index 10283d31a1..9abd0b3531 100644
--- a/src/mesa/state_tracker/st_atom_sampler.c
+++ b/src/mesa/state_tracker/st_atom_sampler.c
@@ -153,6 +153,15 @@ update_samplers(struct st_context *st)
sampler->min_lod = MAX2(0.0f, texobj->MinLod);
sampler->max_lod = MIN2(texobj->MaxLevel - texobj->BaseLevel,
texobj->MaxLod);
+ if (sampler->max_lod < sampler->min_lod) {
+ /* The GL spec doesn't seem to specify what to do in this case.
+ * Swap the values.
+ */
+ float tmp = sampler->max_lod;
+ sampler->max_lod = sampler->min_lod;
+ sampler->min_lod = tmp;
+ assert(sampler->min_lod <= sampler->max_lod);
+ }
sampler->border_color[0] = texobj->BorderColor[RCOMP];
sampler->border_color[1] = texobj->BorderColor[GCOMP];
diff --git a/src/mesa/state_tracker/st_atom_scissor.c b/src/mesa/state_tracker/st_atom_scissor.c
index f5db492403..3fd59e1945 100644
--- a/src/mesa/state_tracker/st_atom_scissor.c
+++ b/src/mesa/state_tracker/st_atom_scissor.c
@@ -52,14 +52,14 @@ update_scissor( struct st_context *st )
scissor.maxy = fb->Height;
if (st->ctx->Scissor.Enabled) {
- if (st->ctx->Scissor.X > scissor.minx)
+ if ((GLuint)st->ctx->Scissor.X > scissor.minx)
scissor.minx = st->ctx->Scissor.X;
- if (st->ctx->Scissor.Y > scissor.miny)
+ if ((GLuint)st->ctx->Scissor.Y > scissor.miny)
scissor.miny = st->ctx->Scissor.Y;
- if (st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx)
+ if ((GLuint)st->ctx->Scissor.X + st->ctx->Scissor.Width < scissor.maxx)
scissor.maxx = st->ctx->Scissor.X + st->ctx->Scissor.Width;
- if (st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy)
+ if ((GLuint)st->ctx->Scissor.Y + st->ctx->Scissor.Height < scissor.maxy)
scissor.maxy = st->ctx->Scissor.Y + st->ctx->Scissor.Height;
/* check for null space */
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 4b51521470..b105909e96 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -49,7 +49,7 @@ update_viewport( struct st_context *st )
*/
if (st_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
yScale = -1;
- yBias = ctx->DrawBuffer->Height ;
+ yBias = (GLfloat)ctx->DrawBuffer->Height;
}
else {
yScale = 1.0;
@@ -59,12 +59,12 @@ update_viewport( struct st_context *st )
/* _NEW_VIEWPORT
*/
{
- GLfloat x = ctx->Viewport.X;
- GLfloat y = ctx->Viewport.Y;
+ GLfloat x = (GLfloat)ctx->Viewport.X;
+ GLfloat y = (GLfloat)ctx->Viewport.Y;
GLfloat z = ctx->Viewport.Near;
- GLfloat half_width = ctx->Viewport.Width / 2.0;
- GLfloat half_height = ctx->Viewport.Height / 2.0;
- GLfloat half_depth = (ctx->Viewport.Far - ctx->Viewport.Near) / 2.0;
+ GLfloat half_width = (GLfloat)ctx->Viewport.Width / 2.0;
+ GLfloat half_height = (GLfloat)ctx->Viewport.Height / 2.0;
+ GLfloat half_depth = (GLfloat)(ctx->Viewport.Far - ctx->Viewport.Near) / 2.0;
st->state.viewport.scale[0] = half_width;
st->state.viewport.scale[1] = half_height * yScale;
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 3a102df67f..9e32ee2eb4 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -90,6 +90,8 @@ struct bitmap_cache
/** Bounds of region used in window coords */
GLint xmin, ymin, xmax, ymax;
+ GLfloat color[4];
+
struct pipe_texture *texture;
struct pipe_surface *surf;
@@ -360,18 +362,18 @@ setup_bitmap_vertex_data(struct st_context *st,
{
struct pipe_context *pipe = st->pipe;
const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
- const GLfloat fb_width = fb->Width;
- const GLfloat fb_height = fb->Height;
- const GLfloat x0 = x;
- const GLfloat x1 = x + width;
- const GLfloat y0 = y;
- const GLfloat y1 = y + height;
- const GLfloat sLeft = 0.0F, sRight = 1.0F;
- const GLfloat tTop = 0.0, tBot = 1.0 - tTop;
- const GLfloat clip_x0 = x0 / fb_width * 2.0 - 1.0;
- const GLfloat clip_y0 = y0 / fb_height * 2.0 - 1.0;
- const GLfloat clip_x1 = x1 / fb_width * 2.0 - 1.0;
- const GLfloat clip_y1 = y1 / fb_height * 2.0 - 1.0;
+ const GLfloat fb_width = (GLfloat)fb->Width;
+ const GLfloat fb_height = (GLfloat)fb->Height;
+ const GLfloat x0 = (GLfloat)x;
+ const GLfloat x1 = (GLfloat)(x + width);
+ const GLfloat y0 = (GLfloat)y;
+ const GLfloat y1 = (GLfloat)(y + height);
+ const GLfloat sLeft = (GLfloat)0.0, sRight = (GLfloat)1.0;
+ const GLfloat tTop = (GLfloat)0.0, tBot = (GLfloat)1.0 - tTop;
+ const GLfloat clip_x0 = (GLfloat)(x0 / fb_width * 2.0 - 1.0);
+ const GLfloat clip_y0 = (GLfloat)(y0 / fb_height * 2.0 - 1.0);
+ const GLfloat clip_x1 = (GLfloat)(x1 / fb_width * 2.0 - 1.0);
+ const GLfloat clip_y1 = (GLfloat)(y1 / fb_height * 2.0 - 1.0);
GLuint i;
void *buf;
@@ -429,7 +431,8 @@ setup_bitmap_vertex_data(struct st_context *st,
static void
draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
GLsizei width, GLsizei height,
- struct pipe_texture *pt)
+ struct pipe_texture *pt,
+ const GLfloat *color)
{
struct st_context *st = ctx->st;
struct pipe_context *pipe = ctx->st->pipe;
@@ -444,8 +447,8 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
* it up into chunks.
*/
maxSize = 1 << (pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
- assert(width <= maxSize);
- assert(height <= maxSize);
+ assert(width <= (GLsizei)maxSize);
+ assert(height <= (GLsizei)maxSize);
cso_save_rasterizer(cso);
cso_save_samplers(cso);
@@ -488,15 +491,15 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
{
const struct gl_framebuffer *fb = st->ctx->DrawBuffer;
const GLboolean invert = (st_fb_orientation(fb) == Y_0_TOP);
- const float width = fb->Width;
- const float height = fb->Height;
+ const GLfloat width = (GLfloat)fb->Width;
+ const GLfloat height = (GLfloat)fb->Height;
struct pipe_viewport_state vp;
vp.scale[0] = 0.5 * width;
- vp.scale[1] = height * (invert ? -0.5 : 0.5);
+ vp.scale[1] = (GLfloat)(height * (invert ? -0.5 : 0.5));
vp.scale[2] = 1.0;
vp.scale[3] = 1.0;
- vp.translate[0] = 0.5 * width;
- vp.translate[1] = 0.5 * height;
+ vp.translate[0] = (GLfloat)(0.5 * width);
+ vp.translate[1] = (GLfloat)(0.5 * height);
vp.translate[2] = 0.0;
vp.translate[3] = 0.0;
cso_set_viewport(cso, &vp);
@@ -505,7 +508,7 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
/* draw textured quad */
setup_bitmap_vertex_data(st, x, y, width, height,
ctx->Current.RasterPos[2],
- ctx->Current.RasterColor);
+ color);
util_draw_vertex_buffer(pipe, st->bitmap.vbuf,
PIPE_PRIM_TRIANGLE_FAN,
@@ -567,8 +570,9 @@ void
st_flush_bitmap_cache(struct st_context *st)
{
if (!st->bitmap.cache->empty) {
+ struct bitmap_cache *cache = st->bitmap.cache;
+
if (st->ctx->DrawBuffer) {
- struct bitmap_cache *cache = st->bitmap.cache;
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = pipe->screen;
@@ -591,11 +595,13 @@ st_flush_bitmap_cache(struct st_context *st)
cache->ypos,
st->ctx->Current.RasterPos[2],
BITMAP_CACHE_WIDTH, BITMAP_CACHE_HEIGHT,
- cache->texture);
-
- /* release/free the texture */
- pipe_texture_reference(&cache->texture, NULL);
+ cache->texture,
+ cache->color);
}
+
+ /* release/free the texture */
+ pipe_texture_reference(&cache->texture, NULL);
+
reset_cache(st);
}
}
@@ -622,8 +628,10 @@ accum_bitmap(struct st_context *st,
px = x - cache->xpos; /* pos in buffer */
py = y - cache->ypos;
if (px < 0 || px + width > BITMAP_CACHE_WIDTH ||
- py < 0 || py + height > BITMAP_CACHE_HEIGHT) {
- /* This bitmap would extend beyond cache bounds,
+ py < 0 || py + height > BITMAP_CACHE_HEIGHT ||
+ !TEST_EQ_4V(st->ctx->Current.RasterColor, cache->color)) {
+ /* This bitmap would extend beyond cache bounds, or the bitmap
+ * color is changing
* so flush and continue.
*/
st_flush_bitmap_cache(st);
@@ -637,6 +645,7 @@ accum_bitmap(struct st_context *st,
cache->xpos = x;
cache->ypos = y - py;
cache->empty = GL_FALSE;
+ COPY_4FV(cache->color, st->ctx->Current.RasterColor);
}
assert(px != -999);
@@ -692,7 +701,8 @@ st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
if (pt) {
assert(pt->target == PIPE_TEXTURE_2D);
draw_bitmap_quad(ctx, x, y, ctx->Current.RasterPos[2],
- width, height, pt);
+ width, height, pt,
+ st->ctx->Current.RasterColor);
/* release/free the texture */
pipe_texture_reference(&pt, NULL);
}
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 0533d9460f..327bafeb98 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -40,7 +40,6 @@
#include "st_context.h"
#include "st_program.h"
-#include "st_cb_drawpixels.h"
#include "st_cb_blit.h"
#include "st_cb_fbo.h"
@@ -106,5 +105,7 @@ st_BlitFramebuffer(GLcontext *ctx,
void
st_init_blit_functions(struct dd_function_table *functions)
{
+#if FEATURE_EXT_framebuffer_blit
functions->BlitFramebuffer = st_BlitFramebuffer;
+#endif
}
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 3560a040c8..db25ddd615 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -92,10 +92,11 @@ st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
struct pipe_texture template;
unsigned surface_usage;
- /* Free the old surface (and texture if we hold the last
- * reference):
+ /* Free the old surface and texture
*/
pipe_surface_reference( &strb->surface, NULL );
+ pipe_texture_reference( &strb->texture, NULL );
+
memset(&template, 0, sizeof(template));
@@ -346,11 +347,8 @@ st_render_texture(GLcontext *ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
- struct st_context *st = ctx->st;
struct st_renderbuffer *strb;
struct gl_renderbuffer *rb;
- struct pipe_context *pipe = st->pipe;
- struct pipe_screen *screen = pipe->screen;
struct pipe_texture *pt;
struct st_texture_object *stObj;
const struct gl_texture_image *texImage =
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index e15ccec89b..ed65f3b0aa 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -26,7 +26,9 @@
**************************************************************************/
#include "main/imports.h"
+#if FEATURE_convolution
#include "main/convolve.h"
+#endif
#include "main/enums.h"
#include "main/image.h"
#include "main/macros.h"
@@ -95,14 +97,18 @@ static int
compressed_num_bytes(GLuint mesaFormat)
{
switch(mesaFormat) {
+#if FEATURE_texture_fxt1
case MESA_FORMAT_RGB_FXT1:
case MESA_FORMAT_RGBA_FXT1:
+#endif
+#if FEATURE_texture_s3tc
case MESA_FORMAT_RGB_DXT1:
case MESA_FORMAT_RGBA_DXT1:
return 2;
case MESA_FORMAT_RGBA_DXT3:
case MESA_FORMAT_RGBA_DXT5:
return 4;
+#endif
default:
return 0;
}
@@ -517,10 +523,12 @@ st_TexImage(GLcontext * ctx,
stImage->face = _mesa_tex_target_to_face(target);
stImage->level = level;
+#if FEATURE_convolution
if (ctx->_ImageTransferState & IMAGE_CONVOLUTION_BIT) {
_mesa_adjust_image_for_convolution(ctx, dims, &postConvWidth,
&postConvHeight);
}
+#endif
/* choose the texture format */
texImage->TexFormat = st_ChooseTextureFormat(ctx, internalFormat,
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 4081722bc7..bf78cacb8e 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -30,8 +30,10 @@
#include "main/extensions.h"
#include "main/matrix.h"
#include "main/buffers.h"
+#include "main/scissor.h"
#include "vbo/vbo.h"
#include "shader/shader_api.h"
+#include "glapi/glapi.h"
#include "st_public.h"
#include "st_context.h"
#include "st_cb_accum.h"
@@ -39,12 +41,16 @@
#include "st_cb_blit.h"
#include "st_cb_bufferobjects.h"
#include "st_cb_clear.h"
+#if FEATURE_drawpix
#include "st_cb_drawpixels.h"
+#include "st_cb_rasterpos.h"
+#endif
#include "st_cb_fbo.h"
+#if FEATURE_feedback
#include "st_cb_feedback.h"
+#endif
#include "st_cb_program.h"
#include "st_cb_queryobj.h"
-#include "st_cb_rasterpos.h"
#include "st_cb_readpixels.h"
#include "st_cb_texture.h"
#include "st_cb_flush.h"
@@ -162,10 +168,14 @@ static void st_destroy_context_priv( struct st_context *st )
st_destroy_atoms( st );
st_destroy_draw( st );
st_destroy_generate_mipmap(st);
- st_destroy_bitmap(st);
+#if FEATURE_EXT_framebuffer_blit
st_destroy_blit(st);
+#endif
st_destroy_clear(st);
+#if FEATURE_drawpix
+ st_destroy_bitmap(st);
st_destroy_drawpix(st);
+#endif
_vbo_DestroyContext(st->ctx);
@@ -242,21 +252,39 @@ void st_copy_context_state(struct st_context *dst,
}
+
+st_proc st_get_proc_address(const char *procname)
+{
+ return (st_proc) _glapi_get_proc_address(procname);
+}
+
+
+
void st_init_driver_functions(struct dd_function_table *functions)
{
_mesa_init_glsl_driver_functions(functions);
+#if FEATURE_accum
st_init_accum_functions(functions);
- st_init_bitmap_functions(functions);
+#endif
+#if FEATURE_EXT_framebuffer_blit
st_init_blit_functions(functions);
+#endif
st_init_bufferobject_functions(functions);
st_init_clear_functions(functions);
+#if FEATURE_drawpix
+ st_init_bitmap_functions(functions);
st_init_drawpixels_functions(functions);
+ st_init_rasterpos_functions(functions);
+#endif
st_init_fbo_functions(functions);
+#if FEATURE_feedback
st_init_feedback_functions(functions);
+#endif
st_init_program_functions(functions);
+#if FEATURE_ARB_occlusion_query
st_init_query_functions(functions);
- st_init_rasterpos_functions(functions);
+#endif
st_init_readpixels_functions(functions);
st_init_texture_functions(functions);
st_init_flush_functions(functions);
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index a3bffbfc95..5300848ef6 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -365,14 +365,33 @@ st_draw_vbo(GLcontext *ctx,
}
/* draw */
- for (i = 0; i < nr_prims; i++) {
+ if (nr_prims == 1 && pipe->draw_range_elements != NULL) {
+ i = 0;
+
+ /* XXX: exercise temporary path to pass min/max directly
+ * through to driver & draw module. These interfaces still
+ * need a bit of work...
+ */
setup_edgeflags(ctx, prims[i].mode,
prims[i].start + indexOffset, prims[i].count,
arrays[VERT_ATTRIB_EDGEFLAG]);
- pipe->draw_elements(pipe, indexBuf, indexSize,
- prims[i].mode,
- prims[i].start + indexOffset, prims[i].count);
+ pipe->draw_range_elements(pipe, indexBuf, indexSize,
+ min_index,
+ max_index,
+ prims[i].mode,
+ prims[i].start + indexOffset, prims[i].count);
+ }
+ else {
+ for (i = 0; i < nr_prims; i++) {
+ setup_edgeflags(ctx, prims[i].mode,
+ prims[i].start + indexOffset, prims[i].count,
+ arrays[VERT_ATTRIB_EDGEFLAG]);
+
+ pipe->draw_elements(pipe, indexBuf, indexSize,
+ prims[i].mode,
+ prims[i].start + indexOffset, prims[i].count);
+ }
}
pipe_reference_buffer(pipe, &indexBuf, NULL);
@@ -577,9 +596,10 @@ st_feedback_draw_vbo(GLcontext *ctx,
/* map constant buffers */
mapped_constants = pipe_buffer_map(pipe,
- st->state.constants[PIPE_SHADER_VERTEX].buffer,
- PIPE_BUFFER_USAGE_CPU_READ);
- draw_set_mapped_constant_buffer(st->draw, mapped_constants);
+ st->state.constants[PIPE_SHADER_VERTEX].buffer,
+ PIPE_BUFFER_USAGE_CPU_READ);
+ draw_set_mapped_constant_buffer(st->draw, mapped_constants,
+ st->state.constants[PIPE_SHADER_VERTEX].buffer->size);
/* draw here */
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 17a3cfd5a4..03ec558a36 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -49,24 +49,7 @@ format_bits(
pipe_format_rgbazs_t info,
GLuint comp )
{
- GLuint size;
-
- if (pf_swizzle_x(info) == comp) {
- size = pf_size_x(info);
- }
- else if (pf_swizzle_y(info) == comp) {
- size = pf_size_y(info);
- }
- else if (pf_swizzle_z(info) == comp) {
- size = pf_size_z(info);
- }
- else if (pf_swizzle_w(info) == comp) {
- size = pf_size_w(info);
- }
- else {
- size = 0;
- }
- return size << (pf_exp8(info) * 3);
+ return pf_get_component_bits( (enum pipe_format) info, comp );
}
static GLuint
@@ -274,8 +257,11 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
return PIPE_FORMAT_Z32_UNORM;
case MESA_FORMAT_Z24_S8:
return PIPE_FORMAT_Z24S8_UNORM;
+ case MESA_FORMAT_S8_Z24:
+ return PIPE_FORMAT_S8Z24_UNORM;
case MESA_FORMAT_YCBCR:
return PIPE_FORMAT_YCBCR;
+#if FEATURE_texture_s3tc
case MESA_FORMAT_RGB_DXT1:
return PIPE_FORMAT_DXT1_RGB;
case MESA_FORMAT_RGBA_DXT1:
@@ -284,6 +270,7 @@ st_mesa_format_to_pipe_format(GLuint mesaFormat)
return PIPE_FORMAT_DXT3_RGBA;
case MESA_FORMAT_RGBA_DXT5:
return PIPE_FORMAT_DXT5_RGBA;
+#endif
default:
assert(0);
return 0;
@@ -559,14 +546,15 @@ translate_gallium_format_to_mesa_format(enum pipe_format format)
return &_mesa_texformat_z16;
case PIPE_FORMAT_Z32_UNORM:
return &_mesa_texformat_z32;
- case PIPE_FORMAT_S8Z24_UNORM:
- /* XXX fallthrough OK? */
case PIPE_FORMAT_Z24S8_UNORM:
return &_mesa_texformat_z24_s8;
+ case PIPE_FORMAT_S8Z24_UNORM:
+ return &_mesa_texformat_s8_z24;
case PIPE_FORMAT_YCBCR:
return &_mesa_texformat_ycbcr;
case PIPE_FORMAT_YCBCR_REV:
return &_mesa_texformat_ycbcr_rev;
+#if FEATURE_texture_s3tc
case PIPE_FORMAT_DXT1_RGB:
return &_mesa_texformat_rgb_dxt1;
case PIPE_FORMAT_DXT1_RGBA:
@@ -575,6 +563,7 @@ 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;
+#endif
/* XXX add additional cases */
default:
assert(0);
diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c
index 47466c97d8..7e6db46757 100644
--- a/src/mesa/state_tracker/st_framebuffer.c
+++ b/src/mesa/state_tracker/st_framebuffer.c
@@ -32,11 +32,13 @@
#include "main/framebuffer.h"
#include "main/matrix.h"
#include "main/renderbuffer.h"
+#include "main/scissor.h"
#include "st_public.h"
#include "st_context.h"
#include "st_cb_fbo.h"
#include "pipe/p_defines.h"
#include "pipe/p_context.h"
+#include "pipe/p_inlines.h"
struct st_framebuffer *
@@ -154,6 +156,61 @@ void st_unreference_framebuffer( struct st_framebuffer **stfb )
/**
+ * Set/replace a framebuffer surface.
+ * The user of the state tracker can use this instead of
+ * st_resize_framebuffer() to provide new surfaces when a window is resized.
+ */
+void
+st_set_framebuffer_surface(struct st_framebuffer *stfb,
+ uint surfIndex, struct pipe_surface *surf)
+{
+ static const GLuint invalid_size = 9999999;
+ struct st_renderbuffer *strb;
+ GLuint width, height, i;
+
+ assert(surfIndex < BUFFER_COUNT);
+
+ strb = st_renderbuffer(stfb->Base.Attachment[surfIndex].Renderbuffer);
+ assert(strb);
+
+ /* replace the renderbuffer's surface/texture pointers */
+ pipe_surface_reference( &strb->surface, surf );
+ pipe_texture_reference( &strb->texture, surf->texture );
+
+ /* update renderbuffer's width/height */
+ strb->Base.Width = surf->width;
+ strb->Base.Height = surf->height;
+
+ /* Try to update the framebuffer's width/height from the renderbuffer
+ * sizes. Before we start drawing, all the rbs _should_ be the same size.
+ */
+ width = height = invalid_size;
+ for (i = 0; i < BUFFER_COUNT; i++) {
+ if (stfb->Base.Attachment[i].Renderbuffer) {
+ if (width == invalid_size) {
+ width = stfb->Base.Attachment[i].Renderbuffer->Width;
+ height = stfb->Base.Attachment[i].Renderbuffer->Height;
+ }
+ else if (width != stfb->Base.Attachment[i].Renderbuffer->Width ||
+ height != stfb->Base.Attachment[i].Renderbuffer->Height) {
+ /* inconsistant renderbuffer sizes, bail out */
+ return;
+ }
+ }
+ }
+
+ if (width != invalid_size) {
+ /* OK, the renderbuffers are of a consistant size, so update the
+ * parent framebuffer's size.
+ */
+ stfb->Base.Width = width;
+ stfb->Base.Height = height;
+ }
+}
+
+
+
+/**
* Return the pipe_surface for the given renderbuffer.
*/
struct pipe_surface *
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index f51eff05dc..851f17c3b4 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -46,7 +46,6 @@
#include "st_gen_mipmap.h"
#include "st_program.h"
#include "st_texture.h"
-#include "st_cb_drawpixels.h"
#include "st_cb_texture.h"
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index d2be450bdb..a8b6faad1c 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -68,8 +68,8 @@ map_register_file(
case PROGRAM_STATE_VAR:
case PROGRAM_NAMED_PARAM:
case PROGRAM_UNIFORM:
- if (immediateMapping[index] != ~0)
- return TGSI_FILE_IMMEDIATE;
+ if (immediateMapping && immediateMapping[index] != ~0)
+ return TGSI_FILE_IMMEDIATE;
else
return TGSI_FILE_CONSTANT;
case PROGRAM_CONSTANT:
@@ -550,18 +550,16 @@ make_input_decl(
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_INPUT;
- decl.Declaration.Declare = TGSI_DECLARE_RANGE;
decl.Declaration.UsageMask = usage_mask;
decl.Declaration.Semantic = semantic_info;
- decl.u.DeclarationRange.First = index;
- decl.u.DeclarationRange.Last = index;
+ decl.DeclarationRange.First = index;
+ decl.DeclarationRange.Last = index;
if (semantic_info) {
decl.Semantic.SemanticName = semantic_name;
decl.Semantic.SemanticIndex = semantic_index;
}
if (interpolate_info) {
- decl.Declaration.Interpolate = 1;
- decl.Interpolation.Interpolate = interpolate;
+ decl.Declaration.Interpolate = interpolate;
}
return decl;
@@ -583,11 +581,10 @@ make_output_decl(
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_OUTPUT;
- decl.Declaration.Declare = TGSI_DECLARE_RANGE;
decl.Declaration.UsageMask = usage_mask;
decl.Declaration.Semantic = 1;
- decl.u.DeclarationRange.First = index;
- decl.u.DeclarationRange.Last = index;
+ decl.DeclarationRange.First = index;
+ decl.DeclarationRange.Last = index;
decl.Semantic.SemanticName = semantic_name;
decl.Semantic.SemanticIndex = semantic_index;
@@ -603,9 +600,8 @@ make_temp_decl(
struct tgsi_full_declaration decl;
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_TEMPORARY;
- decl.Declaration.Declare = TGSI_DECLARE_RANGE;
- decl.u.DeclarationRange.First = start_index;
- decl.u.DeclarationRange.Last = end_index;
+ decl.DeclarationRange.First = start_index;
+ decl.DeclarationRange.Last = end_index;
return decl;
}
@@ -616,9 +612,8 @@ make_sampler_decl(GLuint index)
struct tgsi_full_declaration decl;
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_SAMPLER;
- decl.Declaration.Declare = TGSI_DECLARE_RANGE;
- decl.u.DeclarationRange.First = index;
- decl.u.DeclarationRange.Last = index;
+ decl.DeclarationRange.First = index;
+ decl.DeclarationRange.Last = index;
return decl;
}
@@ -629,9 +624,8 @@ make_constant_decl(GLuint first, GLuint last)
struct tgsi_full_declaration decl;
decl = tgsi_default_full_declaration();
decl.Declaration.File = TGSI_FILE_CONSTANT;
- decl.Declaration.Declare = TGSI_DECLARE_RANGE;
- decl.u.DeclarationRange.First = first;
- decl.u.DeclarationRange.Last = last;
+ decl.DeclarationRange.First = first;
+ decl.DeclarationRange.Last = last;
return decl;
}
diff --git a/src/mesa/state_tracker/st_public.h b/src/mesa/state_tracker/st_public.h
index 9d88ce9764..b99984215f 100644
--- a/src/mesa/state_tracker/st_public.h
+++ b/src/mesa/state_tracker/st_public.h
@@ -68,6 +68,9 @@ struct st_framebuffer *st_create_framebuffer( const __GLcontextModes *visual,
void st_resize_framebuffer( struct st_framebuffer *stfb,
uint width, uint height );
+void st_set_framebuffer_surface(struct st_framebuffer *stfb,
+ uint surfIndex, struct pipe_surface *surf);
+
struct pipe_surface *st_get_framebuffer_surface(struct st_framebuffer *stfb,
uint surfIndex);
@@ -86,4 +89,11 @@ void st_finish( struct st_context *st );
void st_notify_swapbuffers(struct st_framebuffer *stfb);
void st_notify_swapbuffers_complete(struct st_framebuffer *stfb);
+
+/** Generic function type */
+typedef void (*st_proc)();
+
+st_proc st_get_proc_address(const char *procname);
+
+
#endif