summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2010-10-17 19:03:42 -0700
committerKeith Whitwell <[email protected]>2010-10-17 19:09:42 -0700
commit0072acd447dc6be652e63752e50215c3105322c8 (patch)
tree847d1763b54772d336a04e606f8248291c3092b7 /src/mesa/state_tracker
parent543fb77ddece7e1806e8eaa0d65bb2a945ef9a75 (diff)
parentca2b2ac131933b4171b519813df1aaa3a81621cd (diff)
Merge remote branch 'origin/master' into lp-setup-llvm
Conflicts: src/gallium/drivers/llvmpipe/lp_setup_coef.c src/gallium/drivers/llvmpipe/lp_setup_coef.h src/gallium/drivers/llvmpipe/lp_setup_coef_intrin.c src/gallium/drivers/llvmpipe/lp_setup_point.c src/gallium/drivers/llvmpipe/lp_setup_tri.c src/gallium/drivers/llvmpipe/lp_state_derived.c src/gallium/drivers/llvmpipe/lp_state_fs.h
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_atom.c2
-rw-r--r--src/mesa/state_tracker/st_atom.h2
-rw-r--r--src/mesa/state_tracker/st_atom_blend.c4
-rw-r--r--src/mesa/state_tracker/st_atom_depth.c2
-rw-r--r--src/mesa/state_tracker/st_atom_pixeltransfer.c140
-rw-r--r--src/mesa/state_tracker/st_atom_rasterizer.c16
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c10
-rw-r--r--src/mesa/state_tracker/st_atom_viewport.c2
-rw-r--r--src/mesa/state_tracker/st_cb_accum.c8
-rw-r--r--src/mesa/state_tracker/st_cb_accum.h4
-rw-r--r--src/mesa/state_tracker/st_cb_bitmap.c10
-rw-r--r--src/mesa/state_tracker/st_cb_blit.c2
-rw-r--r--src/mesa/state_tracker/st_cb_bufferobjects.c20
-rw-r--r--src/mesa/state_tracker/st_cb_clear.c12
-rw-r--r--src/mesa/state_tracker/st_cb_condrender.c4
-rw-r--r--src/mesa/state_tracker/st_cb_drawpixels.c295
-rw-r--r--src/mesa/state_tracker/st_cb_drawtex.c2
-rw-r--r--src/mesa/state_tracker/st_cb_eglimage.c6
-rw-r--r--src/mesa/state_tracker/st_cb_fbo.c38
-rw-r--r--src/mesa/state_tracker/st_cb_feedback.c10
-rw-r--r--src/mesa/state_tracker/st_cb_flush.c8
-rw-r--r--src/mesa/state_tracker/st_cb_program.c12
-rw-r--r--src/mesa/state_tracker/st_cb_program.h2
-rw-r--r--src/mesa/state_tracker/st_cb_queryobj.c12
-rw-r--r--src/mesa/state_tracker/st_cb_rasterpos.c11
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.c11
-rw-r--r--src/mesa/state_tracker/st_cb_readpixels.h4
-rw-r--r--src/mesa/state_tracker/st_cb_strings.c2
-rw-r--r--src/mesa/state_tracker/st_cb_texture.c73
-rw-r--r--src/mesa/state_tracker/st_cb_texture.h2
-rw-r--r--src/mesa/state_tracker/st_cb_viewport.c8
-rw-r--r--src/mesa/state_tracker/st_cb_xformfb.c14
-rw-r--r--src/mesa/state_tracker/st_context.c12
-rw-r--r--src/mesa/state_tracker/st_context.h14
-rw-r--r--src/mesa/state_tracker/st_draw.c14
-rw-r--r--src/mesa/state_tracker/st_draw.h4
-rw-r--r--src/mesa/state_tracker/st_draw_feedback.c4
-rw-r--r--src/mesa/state_tracker/st_extensions.c19
-rw-r--r--src/mesa/state_tracker/st_format.c92
-rw-r--r--src/mesa/state_tracker/st_format.h6
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.c6
-rw-r--r--src/mesa/state_tracker/st_gen_mipmap.h2
-rw-r--r--src/mesa/state_tracker/st_manager.c39
-rw-r--r--src/mesa/state_tracker/st_manager.h2
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.c9
-rw-r--r--src/mesa/state_tracker/st_mesa_to_tgsi.h2
-rw-r--r--src/mesa/state_tracker/st_program.c28
-rw-r--r--src/mesa/state_tracker/st_program.h2
-rw-r--r--src/mesa/state_tracker/st_texture.h14
49 files changed, 582 insertions, 435 deletions
diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c
index e389e57346b..e29ab46ef99 100644
--- a/src/mesa/state_tracker/st_atom.c
+++ b/src/mesa/state_tracker/st_atom.c
@@ -109,7 +109,7 @@ static void xor_states( struct st_state_flags *result,
*/
static void check_program_state( struct st_context *st )
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
if (ctx->VertexProgram._Current != &st->vp->Base)
st->dirty.st |= ST_NEW_VERTEX_PROGRAM;
diff --git a/src/mesa/state_tracker/st_atom.h b/src/mesa/state_tracker/st_atom.h
index c7a04951bff..6a5ea365ebc 100644
--- a/src/mesa/state_tracker/st_atom.h
+++ b/src/mesa/state_tracker/st_atom.h
@@ -67,6 +67,6 @@ extern const struct st_tracked_state st_update_vs_constants;
extern const struct st_tracked_state st_update_pixel_transfer;
-uint st_compare_func_to_pipe(GLenum func);
+GLuint st_compare_func_to_pipe(GLenum func);
#endif
diff --git a/src/mesa/state_tracker/st_atom_blend.c b/src/mesa/state_tracker/st_atom_blend.c
index 21403605805..a8ec4adce77 100644
--- a/src/mesa/state_tracker/st_atom_blend.c
+++ b/src/mesa/state_tracker/st_atom_blend.c
@@ -156,7 +156,7 @@ translate_logicop(GLenum logicop)
* Figure out if colormasks are different per rt.
*/
static GLboolean
-colormask_per_rt(GLcontext *ctx)
+colormask_per_rt(struct gl_context *ctx)
{
/* a bit suboptimal have to compare lots of values */
unsigned i;
@@ -172,7 +172,7 @@ colormask_per_rt(GLcontext *ctx)
* Figure out if blend enables are different per rt.
*/
static GLboolean
-blend_per_rt(GLcontext *ctx)
+blend_per_rt(struct gl_context *ctx)
{
if (ctx->Color.BlendEnabled &&
(ctx->Color.BlendEnabled != ((1 << ctx->Const.MaxDrawBuffers) - 1))) {
diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c
index 1616e945fea..aaee432a216 100644
--- a/src/mesa/state_tracker/st_atom_depth.c
+++ b/src/mesa/state_tracker/st_atom_depth.c
@@ -97,7 +97,7 @@ update_depth_stencil_alpha(struct st_context *st)
{
struct pipe_depth_stencil_alpha_state *dsa = &st->state.depth_stencil;
struct pipe_stencil_ref sr;
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
memset(dsa, 0, sizeof(*dsa));
memset(&sr, 0, sizeof(sr));
diff --git a/src/mesa/state_tracker/st_atom_pixeltransfer.c b/src/mesa/state_tracker/st_atom_pixeltransfer.c
index 8a8d17599ec..6be03376d01 100644
--- a/src/mesa/state_tracker/st_atom_pixeltransfer.c
+++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c
@@ -27,7 +27,7 @@
/*
* Generate fragment programs to implement pixel transfer ops, such as
- * scale/bias, colormatrix, colortable, convolution...
+ * scale/bias, colortable, convolution...
*
* Authors:
* Brian Paul
@@ -55,8 +55,6 @@
struct state_key
{
GLuint scaleAndBias:1;
- GLuint colorMatrix:1;
- GLuint colorMatrixPostScaleBias:1;
GLuint pixelMaps:1;
#if 0
@@ -70,27 +68,9 @@ struct state_key
#endif
};
-
-static GLboolean
-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 = (GLfloat)(row == col);
- if (m[i] != val)
- return GL_FALSE;
- }
- return GL_TRUE;
-}
-
-
static void
-make_state_key(GLcontext *ctx, struct state_key *key)
+make_state_key(struct gl_context *ctx, struct state_key *key)
{
- static const GLfloat zero[4] = { 0.0f, 0.0f, 0.0f, 0.0f };
- static const GLfloat one[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
-
memset(key, 0, sizeof(*key));
if (ctx->Pixel.RedBias != 0.0 || ctx->Pixel.RedScale != 1.0 ||
@@ -100,21 +80,12 @@ make_state_key(GLcontext *ctx, struct state_key *key)
key->scaleAndBias = 1;
}
- if (!is_identity(ctx->ColorMatrixStack.Top->m)) {
- key->colorMatrix = 1;
- }
-
- if (!TEST_EQ_4V(ctx->Pixel.PostColorMatrixScale, one) ||
- !TEST_EQ_4V(ctx->Pixel.PostColorMatrixBias, zero)) {
- key->colorMatrixPostScaleBias = 1;
- }
-
key->pixelMaps = ctx->Pixel.MapColorFlag;
}
static struct pipe_resource *
-create_color_map_texture(GLcontext *ctx)
+create_color_map_texture(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
@@ -137,7 +108,7 @@ create_color_map_texture(GLcontext *ctx)
* Update the pixelmap texture with the contents of the R/G/B/A pixel maps.
*/
static void
-load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
+load_color_map_texture(struct gl_context *ctx, struct pipe_resource *pt)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
@@ -186,7 +157,7 @@ load_color_map_texture(GLcontext *ctx, struct pipe_resource *pt)
* Returns a fragment program which implements the current pixel transfer ops.
*/
static struct gl_fragment_program *
-get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
+get_pixel_transfer_program(struct gl_context *ctx, const struct state_key *key)
{
struct st_context *st = st_context(ctx);
struct prog_instruction inst[MAX_INST];
@@ -306,103 +277,6 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
fp->Base.SamplersUsed |= (1 << 1); /* sampler 1 is used */
}
- if (key->colorMatrix) {
- static const gl_state_index row0_state[STATE_LENGTH] =
- { STATE_COLOR_MATRIX, 0, 0, 0, 0 };
- static const gl_state_index row1_state[STATE_LENGTH] =
- { STATE_COLOR_MATRIX, 0, 1, 1, 0 };
- static const gl_state_index row2_state[STATE_LENGTH] =
- { STATE_COLOR_MATRIX, 0, 2, 2, 0 };
- static const gl_state_index row3_state[STATE_LENGTH] =
- { STATE_COLOR_MATRIX, 0, 3, 3, 0 };
-
- GLint row0_p = _mesa_add_state_reference(params, row0_state);
- GLint row1_p = _mesa_add_state_reference(params, row1_state);
- GLint row2_p = _mesa_add_state_reference(params, row2_state);
- GLint row3_p = _mesa_add_state_reference(params, row3_state);
- const GLuint temp = 1;
-
- /* DP4 temp.x, colorTemp, matrow0; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_DP4;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = temp;
- inst[ic].DstReg.WriteMask = WRITEMASK_X;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[1].Index = row0_p;
- ic++;
-
- /* DP4 temp.y, colorTemp, matrow1; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_DP4;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = temp;
- inst[ic].DstReg.WriteMask = WRITEMASK_Y;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[1].Index = row1_p;
- ic++;
-
- /* DP4 temp.z, colorTemp, matrow2; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_DP4;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = temp;
- inst[ic].DstReg.WriteMask = WRITEMASK_Z;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[1].Index = row2_p;
- ic++;
-
- /* DP4 temp.w, colorTemp, matrow3; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_DP4;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = temp;
- inst[ic].DstReg.WriteMask = WRITEMASK_W;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[1].Index = row3_p;
- ic++;
-
- /* MOV colorTemp, temp; */
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_MOV;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = colorTemp;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = temp;
- ic++;
- }
-
- if (key->colorMatrixPostScaleBias) {
- static const gl_state_index scale_state[STATE_LENGTH] =
- { STATE_INTERNAL, STATE_PT_SCALE, 0, 0, 0 };
- static const gl_state_index bias_state[STATE_LENGTH] =
- { STATE_INTERNAL, STATE_PT_BIAS, 0, 0, 0 };
- GLint scale_param, bias_param;
-
- scale_param = _mesa_add_state_reference(params, scale_state);
- bias_param = _mesa_add_state_reference(params, bias_state);
-
- _mesa_init_instructions(inst + ic, 1);
- inst[ic].Opcode = OPCODE_MAD;
- inst[ic].DstReg.File = PROGRAM_TEMPORARY;
- inst[ic].DstReg.Index = colorTemp;
- inst[ic].SrcReg[0].File = PROGRAM_TEMPORARY;
- inst[ic].SrcReg[0].Index = colorTemp;
- inst[ic].SrcReg[1].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[1].Index = scale_param;
- inst[ic].SrcReg[2].File = PROGRAM_STATE_VAR;
- inst[ic].SrcReg[2].Index = bias_param;
- ic++;
- }
-
/* Modify last instruction's dst reg to write to result.color */
{
struct prog_instruction *last = &inst[ic - 1];
@@ -446,7 +320,7 @@ get_pixel_transfer_program(GLcontext *ctx, const struct state_key *key)
static void
update_pixel_transfer(struct st_context *st)
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
struct state_key key;
struct gl_fragment_program *fp;
@@ -473,7 +347,7 @@ update_pixel_transfer(struct st_context *st)
const struct st_tracked_state st_update_pixel_transfer = {
"st_update_pixel_transfer", /* name */
{ /* dirty */
- _NEW_PIXEL | _NEW_COLOR_MATRIX, /* mesa */
+ _NEW_PIXEL, /* mesa */
0, /* st */
},
update_pixel_transfer /* update */
diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c
index 2599bd5ca03..451299cef0c 100644
--- a/src/mesa/state_tracker/st_atom_rasterizer.c
+++ b/src/mesa/state_tracker/st_atom_rasterizer.c
@@ -57,9 +57,10 @@ static GLuint translate_fill( GLenum mode )
static void update_raster_state( struct st_context *st )
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
struct pipe_rasterizer_state *raster = &st->state.rasterizer;
const struct gl_vertex_program *vertProg = ctx->VertexProgram._Current;
+ const struct gl_fragment_program *fragProg = ctx->FragmentProgram._Current;
uint i;
memset(raster, 0, sizeof(*raster));
@@ -175,17 +176,30 @@ static void update_raster_state( struct st_context *st )
if (!ctx->Point.PointSprite && ctx->Point.SmoothFlag)
raster->point_smooth = 1;
+ /* _NEW_POINT | _NEW_PROGRAM
+ */
if (ctx->Point.PointSprite) {
+ /* origin */
if ((ctx->Point.SpriteOrigin == GL_UPPER_LEFT) ^
(st_fb_orientation(ctx->DrawBuffer) == Y_0_BOTTOM))
raster->sprite_coord_mode = PIPE_SPRITE_COORD_UPPER_LEFT;
else
raster->sprite_coord_mode = PIPE_SPRITE_COORD_LOWER_LEFT;
+
+ /* Coord replacement flags. If bit 'k' is set that means
+ * that we need to replace GENERIC[k] attrib with an automatically
+ * computed texture coord.
+ */
for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
if (ctx->Point.CoordReplace[i]) {
raster->sprite_coord_enable |= 1 << i;
}
}
+ if (fragProg->Base.InputsRead & FRAG_BIT_PNTC) {
+ raster->sprite_coord_enable |=
+ 1 << (FRAG_ATTRIB_PNTC - FRAG_ATTRIB_TEX0);
+ }
+
raster->point_quad_rasterization = 1;
}
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 981129621c7..029b0403462 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -52,7 +52,7 @@
*
* \param format PIPE_FORMAT_*.
* \param swizzle Texture swizzle, a bitmask computed using MAKE_SWIZZLE4.
- * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA.
+ * \param depthmode One of GL_LUMINANCE, GL_INTENSITY, GL_ALPHA, GL_RED.
*/
static GLuint apply_depthmode(enum pipe_format format,
GLuint swizzle, GLenum depthmode)
@@ -96,6 +96,14 @@ static GLuint apply_depthmode(enum pipe_format format,
else if (swiz[i] < SWIZZLE_W)
swiz[i] = SWIZZLE_ZERO;
break;
+ case GL_RED:
+ /* Rewrite reads W to 1, XYZ to X00 */
+ for (i = 0; i < 4; i++)
+ if (swiz[i] == SWIZZLE_W)
+ swiz[i] = SWIZZLE_ONE;
+ else if (swiz[i] == SWIZZLE_Y || swiz[i] == SWIZZLE_Z)
+ swiz[i] = SWIZZLE_ZERO;
+ break;
}
return MAKE_SWIZZLE4(swiz[0], swiz[1], swiz[2], swiz[3]);
diff --git a/src/mesa/state_tracker/st_atom_viewport.c b/src/mesa/state_tracker/st_atom_viewport.c
index 0b6c34ca2cb..d10f1840df6 100644
--- a/src/mesa/state_tracker/st_atom_viewport.c
+++ b/src/mesa/state_tracker/st_atom_viewport.c
@@ -41,7 +41,7 @@
static void
update_viewport( struct st_context *st )
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
GLfloat yScale, yBias;
/* _NEW_BUFFERS
diff --git a/src/mesa/state_tracker/st_cb_accum.c b/src/mesa/state_tracker/st_cb_accum.c
index 425e7987d33..6c5caf42e35 100644
--- a/src/mesa/state_tracker/st_cb_accum.c
+++ b/src/mesa/state_tracker/st_cb_accum.c
@@ -55,7 +55,7 @@
void
-st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+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;
@@ -96,7 +96,7 @@ st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
/** For ADD/MULT */
static void
-accum_mad(GLcontext *ctx, GLfloat scale, GLfloat bias,
+accum_mad(struct gl_context *ctx, GLfloat scale, GLfloat bias,
GLint xpos, GLint ypos, GLint width, GLint height,
struct st_renderbuffer *acc_strb)
{
@@ -219,7 +219,7 @@ accum_load(struct st_context *st, GLfloat value,
static void
-accum_return(GLcontext *ctx, GLfloat value,
+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)
@@ -286,7 +286,7 @@ accum_return(GLcontext *ctx, GLfloat value,
static void
-st_Accum(GLcontext *ctx, GLenum op, GLfloat value)
+st_Accum(struct gl_context *ctx, GLenum op, GLfloat value)
{
struct st_context *st = st_context(ctx);
struct st_renderbuffer *acc_strb
diff --git a/src/mesa/state_tracker/st_cb_accum.h b/src/mesa/state_tracker/st_cb_accum.h
index 06425dc8a35..b8c9c350031 100644
--- a/src/mesa/state_tracker/st_cb_accum.h
+++ b/src/mesa/state_tracker/st_cb_accum.h
@@ -35,7 +35,7 @@
#if FEATURE_accum
extern void
-st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb);
+st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb);
extern void st_init_accum_functions(struct dd_function_table *functions);
@@ -44,7 +44,7 @@ extern void st_init_accum_functions(struct dd_function_table *functions);
#include "main/compiler.h"
static INLINE void
-st_clear_accum_buffer(GLcontext *ctx, struct gl_renderbuffer *rb)
+st_clear_accum_buffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
ASSERT_NO_FEATURE();
}
diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c
index 8da5cbb5e68..3c0ee6c2883 100644
--- a/src/mesa/state_tracker/st_cb_bitmap.c
+++ b/src/mesa/state_tracker/st_cb_bitmap.c
@@ -113,7 +113,7 @@ struct bitmap_cache
* This program will be combined with the user's fragment program.
*/
static struct st_fragment_program *
-make_bitmap_fragment_program(GLcontext *ctx, GLuint samplerIndex)
+make_bitmap_fragment_program(struct gl_context *ctx, GLuint samplerIndex)
{
struct st_context *st = st_context(ctx);
struct st_fragment_program *stfp;
@@ -187,7 +187,7 @@ find_free_bit(uint bitfield)
* Combine basic bitmap fragment program with the user-defined program.
*/
static struct st_fragment_program *
-combined_bitmap_fragment_program(GLcontext *ctx)
+combined_bitmap_fragment_program(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
struct st_fragment_program *stfp = st->fp;
@@ -256,7 +256,7 @@ unpack_bitmap(struct st_context *st,
* Create a texture which represents a bitmap image.
*/
static struct pipe_resource *
-make_bitmap_texture(GLcontext *ctx, GLsizei width, GLsizei height,
+make_bitmap_texture(struct gl_context *ctx, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack,
const GLubyte *bitmap)
{
@@ -403,7 +403,7 @@ setup_bitmap_vertex_data(struct st_context *st, bool normalized,
* Render a glBitmap by drawing a textured quad
*/
static void
-draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
+draw_bitmap_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
GLsizei width, GLsizei height,
struct pipe_sampler_view *sv,
const GLfloat *color)
@@ -737,7 +737,7 @@ accum_bitmap(struct st_context *st,
* Called via ctx->Driver.Bitmap()
*/
static void
-st_Bitmap(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
+st_Bitmap(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *unpack, const GLubyte *bitmap )
{
struct st_context *st = st_context(ctx);
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c
index 536748402f4..af41835326a 100644
--- a/src/mesa/state_tracker/st_cb_blit.c
+++ b/src/mesa/state_tracker/st_cb_blit.c
@@ -61,7 +61,7 @@ st_destroy_blit(struct st_context *st)
#if FEATURE_EXT_framebuffer_blit
static void
-st_BlitFramebuffer(GLcontext *ctx,
+st_BlitFramebuffer(struct gl_context *ctx,
GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1,
GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1,
GLbitfield mask, GLenum filter)
diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
index 7991a93a1e6..27540c36ce7 100644
--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
@@ -51,7 +51,7 @@
* internal structure where somehow shared.
*/
static struct gl_buffer_object *
-st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
+st_bufferobj_alloc(struct gl_context *ctx, GLuint name, GLenum target)
{
struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object);
@@ -70,7 +70,7 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
* Called via glDeleteBuffersARB().
*/
static void
-st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
+st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
{
struct st_buffer_object *st_obj = st_buffer_object(obj);
@@ -92,7 +92,7 @@ st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
* Called via glBufferSubDataARB().
*/
static void
-st_bufferobj_subdata(GLcontext *ctx,
+st_bufferobj_subdata(struct gl_context *ctx,
GLenum target,
GLintptrARB offset,
GLsizeiptrARB size,
@@ -132,7 +132,7 @@ st_bufferobj_subdata(GLcontext *ctx,
* Called via glGetBufferSubDataARB().
*/
static void
-st_bufferobj_get_subdata(GLcontext *ctx,
+st_bufferobj_get_subdata(struct gl_context *ctx,
GLenum target,
GLintptrARB offset,
GLsizeiptrARB size,
@@ -161,7 +161,7 @@ st_bufferobj_get_subdata(GLcontext *ctx,
* \return GL_TRUE for success, GL_FALSE if out of memory
*/
static GLboolean
-st_bufferobj_data(GLcontext *ctx,
+st_bufferobj_data(struct gl_context *ctx,
GLenum target,
GLsizeiptrARB size,
const GLvoid * data,
@@ -214,7 +214,7 @@ st_bufferobj_data(GLcontext *ctx,
* Called via glMapBufferARB().
*/
static void *
-st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
+st_bufferobj_map(struct gl_context *ctx, GLenum target, GLenum access,
struct gl_buffer_object *obj)
{
struct st_buffer_object *st_obj = st_buffer_object(obj);
@@ -257,7 +257,7 @@ st_bufferobj_zero_length_range = 0;
* Called via glMapBufferRange().
*/
static void *
-st_bufferobj_map_range(GLcontext *ctx, GLenum target,
+st_bufferobj_map_range(struct gl_context *ctx, GLenum target,
GLintptr offset, GLsizeiptr length, GLbitfield access,
struct gl_buffer_object *obj)
{
@@ -317,7 +317,7 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
static void
-st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
+st_bufferobj_flush_mapped_range(struct gl_context *ctx, GLenum target,
GLintptr offset, GLsizeiptr length,
struct gl_buffer_object *obj)
{
@@ -342,7 +342,7 @@ st_bufferobj_flush_mapped_range(GLcontext *ctx, GLenum target,
* Called via glUnmapBufferARB().
*/
static GLboolean
-st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
+st_bufferobj_unmap(struct gl_context *ctx, GLenum target, struct gl_buffer_object *obj)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
@@ -362,7 +362,7 @@ st_bufferobj_unmap(GLcontext *ctx, GLenum target, struct gl_buffer_object *obj)
* Called via glCopyBufferSubData().
*/
static void
-st_copy_buffer_subdata(GLcontext *ctx,
+st_copy_buffer_subdata(struct gl_context *ctx,
struct gl_buffer_object *src,
struct gl_buffer_object *dst,
GLintptr readOffset, GLintptr writeOffset,
diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c
index 246ab2e9579..bd1dd78b23c 100644
--- a/src/mesa/state_tracker/st_cb_clear.c
+++ b/src/mesa/state_tracker/st_cb_clear.c
@@ -191,7 +191,7 @@ draw_quad(struct st_context *st,
* ctx->DrawBuffer->_X/Ymin/max fields.
*/
static void
-clear_with_quad(GLcontext *ctx,
+clear_with_quad(struct gl_context *ctx,
GLboolean color, GLboolean depth, GLboolean stencil)
{
struct st_context *st = st_context(ctx);
@@ -316,7 +316,7 @@ clear_with_quad(GLcontext *ctx,
* Determine if we need to clear the depth buffer by drawing a quad.
*/
static INLINE GLboolean
-check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
+check_clear_color_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
if (ctx->Scissor.Enabled &&
(ctx->Scissor.X != 0 ||
@@ -340,7 +340,7 @@ check_clear_color_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
* drawing a quad.
*/
static INLINE GLboolean
-check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
+check_clear_depth_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
const GLuint stencilMax = 0xff;
GLboolean maskStencil
@@ -368,7 +368,7 @@ check_clear_depth_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb)
* Determine if we need to clear the depth buffer by drawing a quad.
*/
static INLINE GLboolean
-check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb,
+check_clear_depth_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb,
boolean ds_separate)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
@@ -392,7 +392,7 @@ check_clear_depth_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb,
* Determine if we need to clear the stencil buffer by drawing a quad.
*/
static INLINE GLboolean
-check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb,
+check_clear_stencil_with_quad(struct gl_context *ctx, struct gl_renderbuffer *rb,
boolean ds_separate)
{
const struct st_renderbuffer *strb = st_renderbuffer(rb);
@@ -447,7 +447,7 @@ st_flush_clear(struct st_context *st)
* Called via ctx->Driver.Clear()
*/
static void
-st_Clear(GLcontext *ctx, GLbitfield mask)
+st_Clear(struct gl_context *ctx, GLbitfield mask)
{
static const GLbitfield BUFFER_BITS_DS
= (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL);
diff --git a/src/mesa/state_tracker/st_cb_condrender.c b/src/mesa/state_tracker/st_cb_condrender.c
index b509d43b7c6..7766ead48b5 100644
--- a/src/mesa/state_tracker/st_cb_condrender.c
+++ b/src/mesa/state_tracker/st_cb_condrender.c
@@ -47,7 +47,7 @@
* Called via ctx->Driver.BeginConditionalRender()
*/
static void
-st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
+st_BeginConditionalRender(struct gl_context *ctx, struct gl_query_object *q,
GLenum mode)
{
struct st_query_object *stq = st_query_object(q);
@@ -80,7 +80,7 @@ st_BeginConditionalRender(GLcontext *ctx, struct gl_query_object *q,
* Called via ctx->Driver.BeginConditionalRender()
*/
static void
-st_EndConditionalRender(GLcontext *ctx, struct gl_query_object *q)
+st_EndConditionalRender(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
(void) q;
diff --git a/src/mesa/state_tracker/st_cb_drawpixels.c b/src/mesa/state_tracker/st_cb_drawpixels.c
index 1147b1950e2..94b80f69f28 100644
--- a/src/mesa/state_tracker/st_cb_drawpixels.c
+++ b/src/mesa/state_tracker/st_cb_drawpixels.c
@@ -38,27 +38,27 @@
#include "main/texstore.h"
#include "program/program.h"
#include "program/prog_print.h"
+#include "program/prog_instruction.h"
-#include "st_debug.h"
-#include "st_context.h"
#include "st_atom.h"
#include "st_atom_constbuf.h"
-#include "st_program.h"
#include "st_cb_drawpixels.h"
#include "st_cb_readpixels.h"
#include "st_cb_fbo.h"
+#include "st_context.h"
+#include "st_debug.h"
#include "st_format.h"
+#include "st_program.h"
#include "st_texture.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
-#include "util/u_inlines.h"
#include "tgsi/tgsi_ureg.h"
-#include "util/u_tile.h"
#include "util/u_draw_quad.h"
#include "util/u_format.h"
+#include "util/u_inlines.h"
#include "util/u_math.h"
-#include "program/prog_instruction.h"
+#include "util/u_tile.h"
#include "cso_cache/cso_context.h"
@@ -96,7 +96,7 @@ is_passthrough_program(const struct gl_fragment_program *prog)
* \return pointer to Gallium driver fragment shader
*/
static void *
-combined_drawpix_fragment_program(GLcontext *ctx)
+combined_drawpix_fragment_program(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
struct st_fragment_program *stfp;
@@ -162,20 +162,27 @@ combined_drawpix_fragment_program(GLcontext *ctx)
/**
- * Create fragment shader that does a TEX() instruction to get a Z
- * value, then writes to FRAG_RESULT_DEPTH.
+ * Create fragment shader that does a TEX() instruction to get a Z and/or
+ * stencil value value, then writes to FRAG_RESULT_DEPTH/FRAG_RESULT_STENCIL.
+ * Used for glDrawPixels(GL_DEPTH_COMPONENT / GL_STENCIL_INDEX).
* Pass fragment color through as-is.
* \return pointer to the Gallium driver fragment shader
*/
static void *
-make_fragment_shader_z(struct st_context *st)
+make_fragment_shader_z_stencil(struct st_context *st, GLboolean write_depth,
+ GLboolean write_stencil)
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
struct gl_program *p;
+ struct st_fragment_program *stp;
GLuint ic = 0;
+ const GLuint shaderIndex = write_depth * 2 + write_stencil;
+
+ assert(shaderIndex < Elements(st->drawpix.shaders));
- if (st->drawpix.z_shader) {
- return st->drawpix.z_shader->driver_shader;
+ if (st->drawpix.shaders[shaderIndex]) {
+ /* already have the proper shader */
+ return st->drawpix.shaders[shaderIndex]->driver_shader;
}
/*
@@ -185,7 +192,8 @@ make_fragment_shader_z(struct st_context *st)
if (!p)
return NULL;
- p->NumInstructions = 3;
+ p->NumInstructions = write_depth ? 2 : 1;
+ p->NumInstructions += write_stencil ? 1 : 0;
p->Instructions = _mesa_alloc_instructions(p->NumInstructions);
if (!p->Instructions) {
@@ -194,24 +202,31 @@ make_fragment_shader_z(struct st_context *st)
}
_mesa_init_instructions(p->Instructions, p->NumInstructions);
- /* TEX result.depth, fragment.texcoord[0], texture[0], 2D; */
- p->Instructions[ic].Opcode = OPCODE_TEX;
- p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
- p->Instructions[ic].DstReg.Index = FRAG_RESULT_DEPTH;
- p->Instructions[ic].DstReg.WriteMask = WRITEMASK_Z;
- p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
- p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_TEX0;
- p->Instructions[ic].TexSrcUnit = 0;
- p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
- ic++;
-
- /* MOV result.color, fragment.color */
- p->Instructions[ic].Opcode = OPCODE_MOV;
- p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
- p->Instructions[ic].DstReg.Index = FRAG_RESULT_COLOR;
- p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
- p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_COL0;
- ic++;
+ if (write_depth) {
+ /* TEX result.depth, fragment.texcoord[0], texture[0], 2D; */
+ p->Instructions[ic].Opcode = OPCODE_TEX;
+ p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
+ p->Instructions[ic].DstReg.Index = FRAG_RESULT_DEPTH;
+ p->Instructions[ic].DstReg.WriteMask = WRITEMASK_Z;
+ p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
+ p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_TEX0;
+ p->Instructions[ic].TexSrcUnit = 0;
+ p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
+ ic++;
+ }
+
+ if (write_stencil) {
+ /* TEX result.stencil, fragment.texcoord[0], texture[0], 2D; */
+ p->Instructions[ic].Opcode = OPCODE_TEX;
+ p->Instructions[ic].DstReg.File = PROGRAM_OUTPUT;
+ p->Instructions[ic].DstReg.Index = FRAG_RESULT_STENCIL;
+ p->Instructions[ic].DstReg.WriteMask = WRITEMASK_Y;
+ p->Instructions[ic].SrcReg[0].File = PROGRAM_INPUT;
+ p->Instructions[ic].SrcReg[0].Index = FRAG_ATTRIB_TEX0;
+ p->Instructions[ic].TexSrcUnit = 1;
+ p->Instructions[ic].TexSrcTarget = TEXTURE_2D_INDEX;
+ ic++;
+ }
/* END; */
p->Instructions[ic++].Opcode = OPCODE_END;
@@ -219,13 +234,24 @@ make_fragment_shader_z(struct st_context *st)
assert(ic == p->NumInstructions);
p->InputsRead = FRAG_BIT_TEX0 | FRAG_BIT_COL0;
- p->OutputsWritten = (1 << FRAG_RESULT_COLOR) | (1 << FRAG_RESULT_DEPTH);
- p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
+ p->OutputsWritten = 0;
+ if (write_depth)
+ p->OutputsWritten |= (1 << FRAG_RESULT_DEPTH);
+ if (write_stencil)
+ p->OutputsWritten |= (1 << FRAG_RESULT_STENCIL);
+
+ p->SamplersUsed = 0x1; /* sampler 0 (bit 0) is used */
+ if (write_stencil)
+ p->SamplersUsed |= 1 << 1;
+
+ stp = st_fragment_program((struct gl_fragment_program *) p);
+
+ /* save the new shader */
+ st->drawpix.shaders[shaderIndex] = stp;
- st->drawpix.z_shader = (struct st_fragment_program *) p;
- st_translate_fragment_program(st, st->drawpix.z_shader);
+ st_translate_fragment_program(st, stp);
- return st->drawpix.z_shader->driver_shader;
+ return stp->driver_shader;
}
@@ -239,8 +265,7 @@ make_passthrough_vertex_shader(struct st_context *st,
GLboolean passColor)
{
if (!st->drawpix.vert_shaders[passColor]) {
- struct ureg_program *ureg =
- ureg_create( TGSI_PROCESSOR_VERTEX );
+ struct ureg_program *ureg = ureg_create( TGSI_PROCESSOR_VERTEX );
if (ureg == NULL)
return NULL;
@@ -320,7 +345,7 @@ make_texture(struct st_context *st,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels)
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
struct pipe_context *pipe = st->pipe;
gl_format mformat;
struct pipe_resource *pt;
@@ -330,7 +355,8 @@ make_texture(struct st_context *st,
baseFormat = base_format(format);
- mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type);
+ mformat = st_ChooseTextureFormat_renderable(ctx, baseFormat,
+ format, type, GL_FALSE);
assert(mformat);
pipeFormat = st_mesa_format_to_pipe_format(mformat);
@@ -405,7 +431,7 @@ make_texture(struct st_context *st,
* \param invertTex if true, flip texcoords vertically
*/
static void
-draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
+draw_quad(struct gl_context *ctx, GLfloat x0, GLfloat y0, GLfloat z,
GLfloat x1, GLfloat y1, const GLfloat *color,
GLboolean invertTex, GLfloat maxXcoord, GLfloat maxYcoord)
{
@@ -495,30 +521,34 @@ draw_quad(GLcontext *ctx, GLfloat x0, GLfloat y0, GLfloat z,
static void
-draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
+draw_textured_quad(struct gl_context *ctx, GLint x, GLint y, GLfloat z,
GLsizei width, GLsizei height,
GLfloat zoomX, GLfloat zoomY,
- struct pipe_sampler_view *sv,
+ struct pipe_sampler_view **sv,
+ int num_sampler_view,
void *driver_vp,
void *driver_fp,
const GLfloat *color,
- GLboolean invertTex)
+ GLboolean invertTex,
+ GLboolean write_depth, GLboolean write_stencil)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = st->cso_context;
GLfloat x0, y0, x1, y1;
GLsizei maxSize;
- boolean normalized = sv->texture->target != PIPE_TEXTURE_RECT;
+ boolean normalized = sv[0]->texture->target != PIPE_TEXTURE_RECT;
/* limit checks */
/* XXX if DrawPixels image is larger than max texture size, break
* it up into chunks.
*/
- maxSize = 1 << (pipe->screen->get_param(pipe->screen, PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
+ maxSize = 1 << (pipe->screen->get_param(pipe->screen,
+ PIPE_CAP_MAX_TEXTURE_2D_LEVELS) - 1);
assert(width <= maxSize);
assert(height <= maxSize);
+ cso_save_depth_stencil_alpha(cso);
cso_save_rasterizer(cso);
cso_save_viewport(cso);
cso_save_samplers(cso);
@@ -536,6 +566,24 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_set_rasterizer(cso, &rasterizer);
}
+ if (write_depth || write_stencil)
+ {
+ struct pipe_depth_stencil_alpha_state dsa;
+ memset(&dsa, 0, sizeof(dsa));
+ if (write_depth) {
+ dsa.depth.enabled = 1;
+ dsa.depth.func = PIPE_FUNC_ALWAYS;
+ dsa.depth.writemask = 1;
+ }
+ if (write_stencil) {
+ dsa.stencil[0].enabled = 1;
+ dsa.stencil[0].func = PIPE_FUNC_ALWAYS;
+ dsa.stencil[0].writemask = 0xff;
+ dsa.stencil[0].zpass_op = PIPE_STENCIL_OP_REPLACE;
+ }
+ cso_set_depth_stencil_alpha(cso, &dsa);
+ }
+
/* fragment shader state: TEX lookup program */
cso_set_fragment_shader_handle(cso, driver_fp);
@@ -556,7 +604,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
sampler.normalized_coords = normalized;
cso_single_sampler(cso, 0, &sampler);
- if (st->pixel_xfer.pixelmap_enabled) {
+ if (num_sampler_view > 1) {
cso_single_sampler(cso, 1, &sampler);
}
cso_single_sampler_done(cso);
@@ -581,15 +629,7 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
cso_set_vertex_elements(cso, 3, st->velems_util_draw);
/* texture state: */
- if (st->pixel_xfer.pixelmap_enabled) {
- struct pipe_sampler_view *sampler_views[2];
- sampler_views[0] = sv;
- sampler_views[1] = st->pixel_xfer.pixelmap_sampler_view;
- cso_set_fragment_sampler_views(cso, 2, sampler_views);
- }
- else {
- cso_set_fragment_sampler_views(cso, 1, &sv);
- }
+ cso_set_fragment_sampler_views(cso, num_sampler_view, sv);
/* Compute Gallium window coords (y=0=top) with pixel zoom.
* Recall that these coords are transformed by the current
@@ -609,10 +649,11 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
z = z * 2.0 - 1.0;
draw_quad(ctx, x0, y0, z, x1, y1, color, invertTex,
- normalized ? ((GLfloat) width / sv->texture->width0) : (GLfloat)width,
- normalized ? ((GLfloat) height / sv->texture->height0) : (GLfloat)height);
+ normalized ? ((GLfloat) width / sv[0]->texture->width0) : (GLfloat)width,
+ normalized ? ((GLfloat) height / sv[0]->texture->height0) : (GLfloat)height);
/* restore state */
+ cso_restore_depth_stencil_alpha(cso);
cso_restore_rasterizer(cso);
cso_restore_viewport(cso);
cso_restore_samplers(cso);
@@ -623,8 +664,12 @@ draw_textured_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z,
}
+/**
+ * Software fallback to do glDrawPixels(GL_STENCIL_INDEX) when we
+ * can't use a fragment shader to write stencil values.
+ */
static void
-draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
+draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
GLsizei width, GLsizei height, GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack,
const GLvoid *pixels)
@@ -655,7 +700,8 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
}
if(format != GL_DEPTH_STENCIL &&
- util_format_get_component_bits(strb->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ util_format_get_component_bits(strb->format,
+ UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
@@ -773,19 +819,44 @@ draw_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
* Called via ctx->Driver.DrawPixels()
*/
static void
-st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
+st_DrawPixels(struct gl_context *ctx, GLint x, GLint y,
+ GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *unpack, const GLvoid *pixels)
{
void *driver_vp, *driver_fp;
struct st_context *st = st_context(ctx);
const GLfloat *color;
-
- if (format == GL_STENCIL_INDEX ||
- format == GL_DEPTH_STENCIL) {
- draw_stencil_pixels(ctx, x, y, width, height, format, type,
- unpack, pixels);
- return;
+ struct pipe_context *pipe = st->pipe;
+ GLboolean write_stencil = GL_FALSE, write_depth = GL_FALSE;
+ struct pipe_sampler_view *sv[2];
+ int num_sampler_view = 1;
+ enum pipe_format stencil_format = PIPE_FORMAT_NONE;
+
+ if (format == GL_DEPTH_STENCIL)
+ write_stencil = write_depth = GL_TRUE;
+ else if (format == GL_STENCIL_INDEX)
+ write_stencil = GL_TRUE;
+ else if (format == GL_DEPTH_COMPONENT)
+ write_depth = GL_TRUE;
+
+ if (write_stencil) {
+ enum pipe_format tex_format;
+ /* can we write to stencil if not fallback */
+ if (!pipe->screen->get_param(pipe->screen, PIPE_CAP_SHADER_STENCIL_EXPORT))
+ goto stencil_fallback;
+
+ tex_format = st_choose_format(st->pipe->screen, base_format(format),
+ PIPE_TEXTURE_2D,
+ 0, PIPE_BIND_SAMPLER_VIEW);
+ if (tex_format == PIPE_FORMAT_Z24_UNORM_S8_USCALED)
+ stencil_format = PIPE_FORMAT_X24S8_USCALED;
+ else if (tex_format == PIPE_FORMAT_S8_USCALED_Z24_UNORM)
+ stencil_format = PIPE_FORMAT_S8X24_USCALED;
+ else
+ stencil_format = PIPE_FORMAT_S8_USCALED;
+ if (stencil_format == PIPE_FORMAT_NONE)
+ goto stencil_fallback;
}
/* Mesa state should be up to date by now */
@@ -793,8 +864,8 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
st_validate_state(st);
- if (format == GL_DEPTH_COMPONENT) {
- driver_fp = make_fragment_shader_z(st);
+ if (write_depth || write_stencil) {
+ driver_fp = make_fragment_shader_z_stencil(st, write_depth, write_stencil);
driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
color = ctx->Current.RasterColor;
}
@@ -802,6 +873,10 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
driver_fp = combined_drawpix_fragment_program(ctx);
driver_vp = make_passthrough_vertex_shader(st, GL_FALSE);
color = NULL;
+ if (st->pixel_xfer.pixelmap_enabled) {
+ sv[1] = st->pixel_xfer.pixelmap_sampler_view;
+ num_sampler_view++;
+ }
}
/* draw with textured quad */
@@ -809,30 +884,48 @@ st_DrawPixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
struct pipe_resource *pt
= make_texture(st, width, height, format, type, unpack, pixels);
if (pt) {
- struct pipe_sampler_view *sv = st_create_texture_sampler_view(st->pipe, pt);
+ sv[0] = st_create_texture_sampler_view(st->pipe, pt);
+
+ if (sv[0]) {
+ if (write_stencil) {
+ sv[1] = st_create_texture_sampler_view_format(st->pipe, pt,
+ stencil_format);
+ num_sampler_view++;
+ }
- if (sv) {
draw_textured_quad(ctx, x, y, ctx->Current.RasterPos[2],
- width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
+ width, height,
+ ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
sv,
- driver_vp,
+ num_sampler_view,
+ driver_vp,
driver_fp,
- color, GL_FALSE);
- pipe_sampler_view_reference(&sv, NULL);
+ color, GL_FALSE, write_depth, write_stencil);
+ pipe_sampler_view_reference(&sv[0], NULL);
+ if (num_sampler_view > 1)
+ pipe_sampler_view_reference(&sv[1], NULL);
}
pipe_resource_reference(&pt, NULL);
}
}
+ return;
+
+stencil_fallback:
+ draw_stencil_pixels(ctx, x, y, width, height, format, type,
+ unpack, pixels);
}
+/**
+ * Software fallback for glCopyPixels(GL_STENCIL).
+ */
static void
-copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
+copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLint dstx, GLint dsty)
{
- struct st_renderbuffer *rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
+ struct st_renderbuffer *rbDraw;
struct pipe_context *pipe = st_context(ctx)->pipe;
enum pipe_transfer_usage usage;
struct pipe_transfer *ptDraw;
@@ -846,12 +939,20 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
return;
}
+ /* Get the dest renderbuffer. If there's a wrapper, use the
+ * underlying renderbuffer.
+ */
+ rbDraw = st_renderbuffer(ctx->DrawBuffer->_StencilBuffer);
+ if (rbDraw->Base.Wrapped)
+ rbDraw = st_renderbuffer(rbDraw->Base.Wrapped);
+
/* this will do stencil pixel transfer ops */
st_read_stencil_pixels(ctx, srcx, srcy, width, height,
GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,
&ctx->DefaultPacking, buffer);
- if(util_format_get_component_bits(rbDraw->format, UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
+ if (util_format_get_component_bits(rbDraw->format,
+ UTIL_FORMAT_COLORSPACE_ZS, 0) != 0)
usage = PIPE_TRANSFER_READ_WRITE;
else
usage = PIPE_TRANSFER_WRITE;
@@ -928,7 +1029,7 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy,
static void
-st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
+st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
GLsizei width, GLsizei height,
GLint dstx, GLint dsty, GLenum type)
{
@@ -938,7 +1039,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
struct st_renderbuffer *rbRead;
void *driver_vp, *driver_fp;
struct pipe_resource *pt;
- struct pipe_sampler_view *sv;
+ struct pipe_sampler_view *sv[2];
+ int num_sampler_view = 1;
GLfloat *color;
enum pipe_format srcFormat, texFormat;
GLboolean invertTex = GL_FALSE;
@@ -959,15 +1061,22 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
color = NULL;
driver_fp = combined_drawpix_fragment_program(ctx);
driver_vp = make_passthrough_vertex_shader(st, GL_FALSE);
+ if (st->pixel_xfer.pixelmap_enabled) {
+ sv[1] = st->pixel_xfer.pixelmap_sampler_view;
+ num_sampler_view++;
+ }
}
else {
assert(type == GL_DEPTH);
rbRead = st_renderbuffer(ctx->ReadBuffer->_DepthBuffer);
color = ctx->Current.Attrib[VERT_ATTRIB_COLOR0];
- driver_fp = make_fragment_shader_z(st);
+ driver_fp = make_fragment_shader_z_stencil(st, GL_TRUE, GL_FALSE);
driver_vp = make_passthrough_vertex_shader(st, GL_TRUE);
}
+ if (rbRead->Base.Wrapped)
+ rbRead = st_renderbuffer(rbRead->Base.Wrapped);
+
sample_count = rbRead->texture->nr_samples;
/* I believe this would be legal, presumably would need to do a resolve
for color, and for depth/stencil spec says to just use one of the
@@ -976,7 +1085,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
srcFormat = rbRead->texture->format;
- if (screen->is_format_supported(screen, srcFormat, st->internal_target, sample_count,
+ if (screen->is_format_supported(screen, srcFormat, st->internal_target,
+ sample_count,
PIPE_BIND_SAMPLER_VIEW, 0)) {
texFormat = srcFormat;
}
@@ -1021,8 +1131,8 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
if (!pt)
return;
- sv = st_create_texture_sampler_view(st->pipe, pt);
- if (!sv) {
+ sv[0] = st_create_texture_sampler_view(st->pipe, pt);
+ if (!sv[0]) {
pipe_resource_reference(&pt, NULL);
return;
}
@@ -1092,13 +1202,14 @@ st_CopyPixels(GLcontext *ctx, GLint srcx, GLint srcy,
*/
draw_textured_quad(ctx, dstx, dsty, ctx->Current.RasterPos[2],
width, height, ctx->Pixel.ZoomX, ctx->Pixel.ZoomY,
- sv,
+ sv,
+ num_sampler_view,
driver_vp,
driver_fp,
- color, invertTex);
+ color, invertTex, GL_FALSE, GL_FALSE);
pipe_resource_reference(&pt, NULL);
- pipe_sampler_view_reference(&sv, NULL);
+ pipe_sampler_view_reference(&sv[0], NULL);
}
@@ -1113,7 +1224,13 @@ void st_init_drawpixels_functions(struct dd_function_table *functions)
void
st_destroy_drawpix(struct st_context *st)
{
- st_reference_fragprog(st, &st->drawpix.z_shader, NULL);
+ GLuint i;
+
+ for (i = 0; i < Elements(st->drawpix.shaders); i++) {
+ if (st->drawpix.shaders[i])
+ st_reference_fragprog(st, &st->drawpix.shaders[i], NULL);
+ }
+
st_reference_fragprog(st, &st->pixel_xfer.combined_prog, NULL);
if (st->drawpix.vert_shaders[0])
ureg_free_tokens(st->drawpix.vert_shaders[0]);
diff --git a/src/mesa/state_tracker/st_cb_drawtex.c b/src/mesa/state_tracker/st_cb_drawtex.c
index c99a8d792ed..6cad7d3216e 100644
--- a/src/mesa/state_tracker/st_cb_drawtex.c
+++ b/src/mesa/state_tracker/st_cb_drawtex.c
@@ -100,7 +100,7 @@ lookup_shader(struct pipe_context *pipe,
}
static void
-st_DrawTex(GLcontext *ctx, GLfloat x, GLfloat y, GLfloat z,
+st_DrawTex(struct gl_context *ctx, GLfloat x, GLfloat y, GLfloat z,
GLfloat width, GLfloat height)
{
struct st_context *st = ctx->st;
diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
index 3145416383b..298f8a5b12b 100644
--- a/src/mesa/state_tracker/st_cb_eglimage.c
+++ b/src/mesa/state_tracker/st_cb_eglimage.c
@@ -71,7 +71,7 @@ st_pipe_format_to_base_format(enum pipe_format format)
}
static void
-st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
+st_egl_image_target_renderbuffer_storage(struct gl_context *ctx,
struct gl_renderbuffer *rb,
GLeglImageOES image_handle)
{
@@ -98,7 +98,7 @@ st_egl_image_target_renderbuffer_storage(GLcontext *ctx,
}
static void
-st_bind_surface(GLcontext *ctx, GLenum target,
+st_bind_surface(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
struct pipe_surface *ps)
@@ -139,7 +139,7 @@ st_bind_surface(GLcontext *ctx, GLenum target,
}
static void
-st_egl_image_target_texture_2d(GLcontext *ctx, GLenum target,
+st_egl_image_target_texture_2d(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage,
GLeglImageOES image_handle)
diff --git a/src/mesa/state_tracker/st_cb_fbo.c b/src/mesa/state_tracker/st_cb_fbo.c
index 71bd4729e03..9425f07aee6 100644
--- a/src/mesa/state_tracker/st_cb_fbo.c
+++ b/src/mesa/state_tracker/st_cb_fbo.c
@@ -60,7 +60,7 @@
* during window resize.
*/
static GLboolean
-st_renderbuffer_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
+st_renderbuffer_alloc_storage(struct gl_context * ctx, struct gl_renderbuffer *rb,
GLenum internalFormat,
GLuint width, GLuint height)
{
@@ -164,7 +164,7 @@ st_renderbuffer_delete(struct gl_renderbuffer *rb)
* gl_renderbuffer::GetPointer()
*/
static void *
-null_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb,
+null_get_pointer(struct gl_context * ctx, struct gl_renderbuffer *rb,
GLint x, GLint y)
{
/* By returning NULL we force all software rendering to go through
@@ -181,7 +181,7 @@ null_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb,
* Called via ctx->Driver.NewFramebuffer()
*/
static struct gl_framebuffer *
-st_new_framebuffer(GLcontext *ctx, GLuint name)
+st_new_framebuffer(struct gl_context *ctx, GLuint name)
{
/* XXX not sure we need to subclass gl_framebuffer for pipe */
return _mesa_new_framebuffer(ctx, name);
@@ -192,7 +192,7 @@ st_new_framebuffer(GLcontext *ctx, GLuint name)
* Called via ctx->Driver.NewRenderbuffer()
*/
static struct gl_renderbuffer *
-st_new_renderbuffer(GLcontext *ctx, GLuint name)
+st_new_renderbuffer(struct gl_context *ctx, GLuint name)
{
struct st_renderbuffer *strb = ST_CALLOC_STRUCT(st_renderbuffer);
if (strb) {
@@ -260,6 +260,18 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
case PIPE_FORMAT_R16G16B16A16_SNORM:
strb->Base.InternalFormat = GL_RGBA16;
break;
+ case PIPE_FORMAT_R8_UNORM:
+ strb->Base.InternalFormat = GL_R8;
+ break;
+ case PIPE_FORMAT_R8G8_UNORM:
+ strb->Base.InternalFormat = GL_RG8;
+ break;
+ case PIPE_FORMAT_R16_UNORM:
+ strb->Base.InternalFormat = GL_R16;
+ break;
+ case PIPE_FORMAT_R16G16_UNORM:
+ strb->Base.InternalFormat = GL_RG16;
+ break;
default:
_mesa_problem(NULL,
"Unexpected format in st_new_renderbuffer_fb");
@@ -285,7 +297,7 @@ st_new_renderbuffer_fb(enum pipe_format format, int samples, boolean sw)
* Called via ctx->Driver.BindFramebufferEXT().
*/
static void
-st_bind_framebuffer(GLcontext *ctx, GLenum target,
+st_bind_framebuffer(struct gl_context *ctx, GLenum target,
struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
{
@@ -295,7 +307,7 @@ st_bind_framebuffer(GLcontext *ctx, GLenum target,
* Called by ctx->Driver.FramebufferRenderbuffer
*/
static void
-st_framebuffer_renderbuffer(GLcontext *ctx,
+st_framebuffer_renderbuffer(struct gl_context *ctx,
struct gl_framebuffer *fb,
GLenum attachment,
struct gl_renderbuffer *rb)
@@ -309,7 +321,7 @@ st_framebuffer_renderbuffer(GLcontext *ctx,
* Called by ctx->Driver.RenderTexture
*/
static void
-st_render_texture(GLcontext *ctx,
+st_render_texture(struct gl_context *ctx,
struct gl_framebuffer *fb,
struct gl_renderbuffer_attachment *att)
{
@@ -399,7 +411,7 @@ st_render_texture(GLcontext *ctx,
* Called via ctx->Driver.FinishRenderTexture.
*/
static void
-st_finish_render_texture(GLcontext *ctx,
+st_finish_render_texture(struct gl_context *ctx,
struct gl_renderbuffer_attachment *att)
{
struct st_context *st = st_context(ctx);
@@ -478,7 +490,7 @@ st_is_depth_stencil_combined(const struct gl_renderbuffer_attachment *depth,
* For Gallium we only supports combined Z+stencil, not separate buffers.
*/
static void
-st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
+st_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
{
struct st_context *st = st_context(ctx);
struct pipe_screen *screen = st->pipe->screen;
@@ -532,10 +544,10 @@ st_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
* Called via glDrawBuffer.
*/
static void
-st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
+st_DrawBuffers(struct gl_context *ctx, GLsizei count, const GLenum *buffers)
{
struct st_context *st = st_context(ctx);
- GLframebuffer *fb = ctx->DrawBuffer;
+ struct gl_framebuffer *fb = ctx->DrawBuffer;
GLuint i;
(void) count;
@@ -553,10 +565,10 @@ st_DrawBuffers(GLcontext *ctx, GLsizei count, const GLenum *buffers)
* Called via glReadBuffer.
*/
static void
-st_ReadBuffer(GLcontext *ctx, GLenum buffer)
+st_ReadBuffer(struct gl_context *ctx, GLenum buffer)
{
struct st_context *st = st_context(ctx);
- GLframebuffer *fb = ctx->ReadBuffer;
+ struct gl_framebuffer *fb = ctx->ReadBuffer;
(void) buffer;
diff --git a/src/mesa/state_tracker/st_cb_feedback.c b/src/mesa/state_tracker/st_cb_feedback.c
index e57730b5ecd..5c01856f033 100644
--- a/src/mesa/state_tracker/st_cb_feedback.c
+++ b/src/mesa/state_tracker/st_cb_feedback.c
@@ -62,7 +62,7 @@
struct feedback_stage
{
struct draw_stage stage; /**< Base class */
- GLcontext *ctx; /**< Rendering context */
+ struct gl_context *ctx; /**< Rendering context */
GLboolean reset_stipple_counter;
};
@@ -79,7 +79,7 @@ feedback_stage( struct draw_stage *stage )
static void
-feedback_vertex(GLcontext *ctx, const struct draw_context *draw,
+feedback_vertex(struct gl_context *ctx, const struct draw_context *draw,
const struct vertex_header *v)
{
const struct st_context *st = st_context(ctx);
@@ -179,7 +179,7 @@ feedback_destroy( struct draw_stage *stage )
* Create GL feedback drawing stage.
*/
static struct draw_stage *
-draw_glfeedback_stage(GLcontext *ctx, struct draw_context *draw)
+draw_glfeedback_stage(struct gl_context *ctx, struct draw_context *draw)
{
struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage);
@@ -252,7 +252,7 @@ select_destroy( struct draw_stage *stage )
* Create GL selection mode drawing stage.
*/
static struct draw_stage *
-draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
+draw_glselect_stage(struct gl_context *ctx, struct draw_context *draw)
{
struct feedback_stage *fs = ST_CALLOC_STRUCT(feedback_stage);
@@ -271,7 +271,7 @@ draw_glselect_stage(GLcontext *ctx, struct draw_context *draw)
static void
-st_RenderMode(GLcontext *ctx, GLenum newMode )
+st_RenderMode(struct gl_context *ctx, GLenum newMode )
{
struct st_context *st = st_context(ctx);
struct draw_context *draw = st->draw;
diff --git a/src/mesa/state_tracker/st_cb_flush.c b/src/mesa/state_tracker/st_cb_flush.c
index 8c9959f9544..5a2343d3aec 100644
--- a/src/mesa/state_tracker/st_cb_flush.c
+++ b/src/mesa/state_tracker/st_cb_flush.c
@@ -51,7 +51,7 @@
static INLINE GLboolean
is_front_buffer_dirty(struct st_context *st)
{
- GLframebuffer *fb = st->ctx->DrawBuffer;
+ struct gl_framebuffer *fb = st->ctx->DrawBuffer;
struct st_renderbuffer *strb
= st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
return strb && strb->defined;
@@ -64,7 +64,7 @@ is_front_buffer_dirty(struct st_context *st)
static void
display_front_buffer(struct st_context *st)
{
- GLframebuffer *fb = st->ctx->DrawBuffer;
+ struct gl_framebuffer *fb = st->ctx->DrawBuffer;
struct st_renderbuffer *strb
= st_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer);
@@ -113,7 +113,7 @@ void st_finish( struct st_context *st )
/**
* Called via ctx->Driver.Flush()
*/
-static void st_glFlush(GLcontext *ctx)
+static void st_glFlush(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
@@ -133,7 +133,7 @@ static void st_glFlush(GLcontext *ctx)
/**
* Called via ctx->Driver.Finish()
*/
-static void st_glFinish(GLcontext *ctx)
+static void st_glFinish(struct gl_context *ctx)
{
struct st_context *st = st_context(ctx);
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 6aa7e79af95..4d83fcc6ccb 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -53,7 +53,7 @@ static GLuint SerialNo = 1;
* Called via ctx->Driver.BindProgram() to bind an ARB vertex or
* fragment program.
*/
-static void st_bind_program( GLcontext *ctx,
+static void st_bind_program( struct gl_context *ctx,
GLenum target,
struct gl_program *prog )
{
@@ -77,7 +77,7 @@ static void st_bind_program( GLcontext *ctx,
* Called via ctx->Driver.UseProgram() to bind a linked GLSL program
* (vertex shader + fragment shader).
*/
-static void st_use_program( GLcontext *ctx, struct gl_shader_program *shProg)
+static void st_use_program( struct gl_context *ctx, struct gl_shader_program *shProg)
{
struct st_context *st = st_context(ctx);
@@ -92,7 +92,7 @@ static void st_use_program( GLcontext *ctx, struct gl_shader_program *shProg)
* Called via ctx->Driver.NewProgram() to allocate a new vertex or
* fragment program.
*/
-static struct gl_program *st_new_program( GLcontext *ctx,
+static struct gl_program *st_new_program( struct gl_context *ctx,
GLenum target,
GLuint id )
{
@@ -139,7 +139,7 @@ static struct gl_program *st_new_program( GLcontext *ctx,
void
-st_delete_program(GLcontext *ctx, struct gl_program *prog)
+st_delete_program(struct gl_context *ctx, struct gl_program *prog)
{
struct st_context *st = st_context(ctx);
@@ -195,7 +195,7 @@ st_delete_program(GLcontext *ctx, struct gl_program *prog)
}
-static GLboolean st_is_program_native( GLcontext *ctx,
+static GLboolean st_is_program_native( struct gl_context *ctx,
GLenum target,
struct gl_program *prog )
{
@@ -203,7 +203,7 @@ static GLboolean st_is_program_native( GLcontext *ctx,
}
-static GLboolean st_program_string_notify( GLcontext *ctx,
+static GLboolean st_program_string_notify( struct gl_context *ctx,
GLenum target,
struct gl_program *prog )
{
diff --git a/src/mesa/state_tracker/st_cb_program.h b/src/mesa/state_tracker/st_cb_program.h
index 0fd179ef3df..004afb6d812 100644
--- a/src/mesa/state_tracker/st_cb_program.h
+++ b/src/mesa/state_tracker/st_cb_program.h
@@ -37,7 +37,7 @@ extern void
st_init_program_functions(struct dd_function_table *functions);
extern void
-st_delete_program(GLcontext *ctx, struct gl_program *prog);
+st_delete_program(struct gl_context *ctx, struct gl_program *prog);
#endif
diff --git a/src/mesa/state_tracker/st_cb_queryobj.c b/src/mesa/state_tracker/st_cb_queryobj.c
index e423d9d8a51..724464a33ff 100644
--- a/src/mesa/state_tracker/st_cb_queryobj.c
+++ b/src/mesa/state_tracker/st_cb_queryobj.c
@@ -46,7 +46,7 @@
#if FEATURE_queryobj
static struct gl_query_object *
-st_NewQueryObject(GLcontext *ctx, GLuint id)
+st_NewQueryObject(struct gl_context *ctx, GLuint id)
{
struct st_query_object *stq = ST_CALLOC_STRUCT(st_query_object);
if (stq) {
@@ -62,7 +62,7 @@ st_NewQueryObject(GLcontext *ctx, GLuint id)
static void
-st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
+st_DeleteQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
@@ -77,7 +77,7 @@ st_DeleteQuery(GLcontext *ctx, struct gl_query_object *q)
static void
-st_BeginQuery(GLcontext *ctx, struct gl_query_object *q)
+st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
@@ -121,7 +121,7 @@ st_BeginQuery(GLcontext *ctx, struct gl_query_object *q)
static void
-st_EndQuery(GLcontext *ctx, struct gl_query_object *q)
+st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
@@ -131,7 +131,7 @@ st_EndQuery(GLcontext *ctx, struct gl_query_object *q)
static void
-st_WaitQuery(GLcontext *ctx, struct gl_query_object *q)
+st_WaitQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
@@ -153,7 +153,7 @@ st_WaitQuery(GLcontext *ctx, struct gl_query_object *q)
static void
-st_CheckQuery(GLcontext *ctx, struct gl_query_object *q)
+st_CheckQuery(struct gl_context *ctx, struct gl_query_object *q)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_query_object *stq = st_query_object(q);
diff --git a/src/mesa/state_tracker/st_cb_rasterpos.c b/src/mesa/state_tracker/st_cb_rasterpos.c
index 7b2eb8012de..15a4f602d1d 100644
--- a/src/mesa/state_tracker/st_cb_rasterpos.c
+++ b/src/mesa/state_tracker/st_cb_rasterpos.c
@@ -44,7 +44,6 @@
#include "st_atom.h"
#include "st_draw.h"
#include "st_cb_rasterpos.h"
-#include "st_draw.h"
#include "draw/draw_context.h"
#include "draw/draw_pipe.h"
#include "vbo/vbo.h"
@@ -58,7 +57,7 @@
struct rastpos_stage
{
struct draw_stage stage; /**< Base class */
- GLcontext *ctx; /**< Rendering context */
+ struct gl_context *ctx; /**< Rendering context */
/* vertex attrib info we can setup once and re-use */
struct gl_client_array array[VERT_ATTRIB_MAX];
@@ -111,7 +110,7 @@ rastpos_destroy(struct draw_stage *stage)
* else copy the current attrib.
*/
static void
-update_attrib(GLcontext *ctx, const GLuint *outputMapping,
+update_attrib(struct gl_context *ctx, const GLuint *outputMapping,
const struct vertex_header *vert,
GLfloat *dest,
GLuint result, GLuint defaultAttrib)
@@ -133,7 +132,7 @@ static void
rastpos_point(struct draw_stage *stage, struct prim_header *prim)
{
struct rastpos_stage *rs = rastpos_stage(stage);
- GLcontext *ctx = rs->ctx;
+ struct gl_context *ctx = rs->ctx;
struct st_context *st = st_context(ctx);
const GLfloat height = (GLfloat) ctx->DrawBuffer->Height;
const GLuint *outputMapping = st->vertex_result_to_slot;
@@ -178,7 +177,7 @@ rastpos_point(struct draw_stage *stage, struct prim_header *prim)
* Create rasterpos "drawing" stage.
*/
static struct rastpos_stage *
-new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
+new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
{
struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
GLuint i;
@@ -220,7 +219,7 @@ new_draw_rastpos_stage(GLcontext *ctx, struct draw_context *draw)
static void
-st_RasterPos(GLcontext *ctx, const GLfloat v[4])
+st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
{
struct st_context *st = st_context(ctx);
struct draw_context *draw = st->draw;
diff --git a/src/mesa/state_tracker/st_cb_readpixels.c b/src/mesa/state_tracker/st_cb_readpixels.c
index 6ab03ec9391..0aad733e34a 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.c
+++ b/src/mesa/state_tracker/st_cb_readpixels.c
@@ -55,7 +55,7 @@
* For color/depth we use get_tile(). For stencil, map the stencil buffer.
*/
void
-st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
+st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
@@ -174,7 +174,7 @@ st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
* commands.
*/
struct st_renderbuffer *
-st_get_color_read_renderbuffer(GLcontext *ctx)
+st_get_color_read_renderbuffer(struct gl_context *ctx)
{
struct gl_framebuffer *fb = ctx->ReadBuffer;
struct st_renderbuffer *strb =
@@ -189,7 +189,7 @@ st_get_color_read_renderbuffer(GLcontext *ctx)
* \return GL_TRUE for success, GL_FALSE for failure
*/
static GLboolean
-st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
+st_fast_readpixels(struct gl_context *ctx, struct st_renderbuffer *strb,
GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *pack,
@@ -320,7 +320,7 @@ st_fast_readpixels(GLcontext *ctx, struct st_renderbuffer *strb,
* Image transfer ops are done in software too.
*/
static void
-st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
+st_readpixels(struct gl_context *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *pack,
GLvoid *dest)
@@ -338,9 +338,6 @@ st_readpixels(GLcontext *ctx, GLint x, GLint y, GLsizei width, GLsizei height,
assert(ctx->ReadBuffer->Width > 0);
- /* XXX convolution not done yet */
- assert((transferOps & IMAGE_CONVOLUTION_BIT) == 0);
-
st_validate_state(st);
/* Do all needed clipping here, so that we can forget about it later */
diff --git a/src/mesa/state_tracker/st_cb_readpixels.h b/src/mesa/state_tracker/st_cb_readpixels.h
index 9e1f7b4925e..83c9b659e3d 100644
--- a/src/mesa/state_tracker/st_cb_readpixels.h
+++ b/src/mesa/state_tracker/st_cb_readpixels.h
@@ -34,10 +34,10 @@
struct dd_function_table;
extern struct st_renderbuffer *
-st_get_color_read_renderbuffer(GLcontext *ctx);
+st_get_color_read_renderbuffer(struct gl_context *ctx);
extern void
-st_read_stencil_pixels(GLcontext *ctx, GLint x, GLint y,
+st_read_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
GLsizei width, GLsizei height,
GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
diff --git a/src/mesa/state_tracker/st_cb_strings.c b/src/mesa/state_tracker/st_cb_strings.c
index 0fcb427f30a..21323798fd0 100644
--- a/src/mesa/state_tracker/st_cb_strings.c
+++ b/src/mesa/state_tracker/st_cb_strings.c
@@ -42,7 +42,7 @@
#define ST_VERSION_STRING "0.4"
static const GLubyte *
-st_get_string(GLcontext * ctx, GLenum name)
+st_get_string(struct gl_context * ctx, GLenum name)
{
struct st_context *st = st_context(ctx);
struct pipe_screen *screen = st->pipe->screen;
diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c
index 124cd32e13e..062dd348659 100644
--- a/src/mesa/state_tracker/st_cb_texture.c
+++ b/src/mesa/state_tracker/st_cb_texture.c
@@ -94,7 +94,7 @@ gl_target_to_pipe(GLenum target)
/** called via ctx->Driver.NewTextureImage() */
static struct gl_texture_image *
-st_NewTextureImage(GLcontext * ctx)
+st_NewTextureImage(struct gl_context * ctx)
{
DBG("%s\n", __FUNCTION__);
(void) ctx;
@@ -104,7 +104,7 @@ st_NewTextureImage(GLcontext * ctx)
/** called via ctx->Driver.NewTextureObject() */
static struct gl_texture_object *
-st_NewTextureObject(GLcontext * ctx, GLuint name, GLenum target)
+st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
{
struct st_texture_object *obj = ST_CALLOC_STRUCT(st_texture_object);
@@ -116,7 +116,7 @@ st_NewTextureObject(GLcontext * ctx, GLuint name, GLenum target)
/** called via ctx->Driver.DeleteTextureObject() */
static void
-st_DeleteTextureObject(GLcontext *ctx,
+st_DeleteTextureObject(struct gl_context *ctx,
struct gl_texture_object *texObj)
{
struct st_context *st = st_context(ctx);
@@ -140,7 +140,7 @@ st_DeleteTextureObject(GLcontext *ctx,
/** called via ctx->Driver.FreeTexImageData() */
static void
-st_FreeTextureImageData(GLcontext * ctx, struct gl_texture_image *texImage)
+st_FreeTextureImageData(struct gl_context * ctx, struct gl_texture_image *texImage)
{
struct st_texture_image *stImage = st_texture_image(texImage);
@@ -240,6 +240,12 @@ get_texture_dims(GLenum target)
return 1;
case GL_TEXTURE_2D:
case GL_TEXTURE_CUBE_MAP_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB:
+ case GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB:
+ case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB:
case GL_TEXTURE_RECTANGLE_NV:
case GL_TEXTURE_2D_ARRAY_EXT:
return 2;
@@ -405,7 +411,7 @@ strip_texture_border(GLint border,
* \return GL_TRUE for success, GL_FALSE for failure
*/
static GLboolean
-compress_with_blit(GLcontext * ctx,
+compress_with_blit(struct gl_context * ctx,
GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
@@ -516,7 +522,7 @@ compress_with_blit(GLcontext * ctx,
* Do glTexImage1/2/3D().
*/
static void
-st_TexImage(GLcontext * ctx,
+st_TexImage(struct gl_context * ctx,
GLint dims,
GLenum target, GLint level,
GLint internalFormat,
@@ -539,12 +545,6 @@ st_TexImage(GLcontext * ctx,
DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
- /* The Mesa/Gallium state tracker does not implement the imaging extensions
- * such as convolution.
- */
- assert(!ctx->Extensions.ARB_imaging);
- assert(!ctx->Extensions.EXT_convolution);
-
/* switch to "normal" */
if (stObj->surface_based) {
_mesa_clear_texture_object(ctx, texObj);
@@ -779,7 +779,7 @@ done:
static void
-st_TexImage3D(GLcontext * ctx,
+st_TexImage3D(struct gl_context * ctx,
GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint depth,
@@ -796,7 +796,7 @@ st_TexImage3D(GLcontext * ctx,
static void
-st_TexImage2D(GLcontext * ctx,
+st_TexImage2D(struct gl_context * ctx,
GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint border,
@@ -811,7 +811,7 @@ st_TexImage2D(GLcontext * ctx,
static void
-st_TexImage1D(GLcontext * ctx,
+st_TexImage1D(struct gl_context * ctx,
GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint border,
@@ -826,7 +826,7 @@ st_TexImage1D(GLcontext * ctx,
static void
-st_CompressedTexImage2D(GLcontext *ctx, GLenum target, GLint level,
+st_CompressedTexImage2D(struct gl_context *ctx, GLenum target, GLint level,
GLint internalFormat,
GLint width, GLint height, GLint border,
GLsizei imageSize, const GLvoid *data,
@@ -844,7 +844,7 @@ st_CompressedTexImage2D(GLcontext *ctx, GLenum target, GLint level,
* a textured quad. Store the results in the user's buffer.
*/
static void
-decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
+decompress_with_blit(struct gl_context * ctx, GLenum target, GLint level,
GLenum format, GLenum type, GLvoid *pixels,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
@@ -940,7 +940,7 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level,
* then unmap it.
*/
static void
-st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
+st_get_tex_image(struct gl_context * ctx, GLenum target, GLint level,
GLenum format, GLenum type, GLvoid * pixels,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage, GLboolean compressed_dst)
@@ -1031,7 +1031,7 @@ st_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
static void
-st_GetTexImage(GLcontext * ctx, GLenum target, GLint level,
+st_GetTexImage(struct gl_context * ctx, GLenum target, GLint level,
GLenum format, GLenum type, GLvoid * pixels,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
@@ -1042,7 +1042,7 @@ st_GetTexImage(GLcontext * ctx, GLenum target, GLint level,
static void
-st_GetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
+st_GetCompressedTexImage(struct gl_context *ctx, GLenum target, GLint level,
GLvoid *pixels,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage)
@@ -1054,7 +1054,7 @@ st_GetCompressedTexImage(GLcontext *ctx, GLenum target, GLint level,
static void
-st_TexSubimage(GLcontext *ctx, GLint dims, GLenum target, GLint level,
+st_TexSubimage(struct gl_context *ctx, GLint dims, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint width, GLint height, GLint depth,
GLenum format, GLenum type, const void *pixels,
@@ -1160,7 +1160,7 @@ done:
static void
-st_TexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
+st_TexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLsizei height, GLsizei depth,
GLenum format, GLenum type, const GLvoid *pixels,
@@ -1175,7 +1175,7 @@ st_TexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
static void
-st_TexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+st_TexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid * pixels,
@@ -1190,7 +1190,7 @@ st_TexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
static void
-st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
+st_TexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLsizei width, GLenum format, GLenum type,
const GLvoid * pixels,
const struct gl_pixelstore_attrib *packing,
@@ -1203,7 +1203,7 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
static void
-st_CompressedTexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
+st_CompressedTexSubImage1D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLsizei width,
GLenum format,
GLsizei imageSize, const GLvoid *data,
@@ -1215,7 +1215,7 @@ st_CompressedTexSubImage1D(GLcontext *ctx, GLenum target, GLint level,
static void
-st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
+st_CompressedTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLint height,
GLenum format,
@@ -1270,7 +1270,7 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
static void
-st_CompressedTexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
+st_CompressedTexSubImage3D(struct gl_context *ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLsizei width, GLint height, GLint depth,
GLenum format,
@@ -1291,7 +1291,7 @@ st_CompressedTexSubImage3D(GLcontext *ctx, GLenum target, GLint level,
* Note: srcY=0=TOP of renderbuffer
*/
static void
-fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
+fallback_copy_texsubimage(struct gl_context *ctx, GLenum target, GLint level,
struct st_renderbuffer *strb,
struct st_texture_image *stImage,
GLenum baseFormat,
@@ -1416,7 +1416,7 @@ fallback_copy_texsubimage(GLcontext *ctx, GLenum target, GLint level,
* If the src/dest are incompatible, return 0.
*/
static unsigned
-compatible_src_dst_formats(GLcontext *ctx,
+compatible_src_dst_formats(struct gl_context *ctx,
const struct gl_renderbuffer *src,
const struct gl_texture_image *dst)
{
@@ -1483,7 +1483,7 @@ compatible_src_dst_formats(GLcontext *ctx,
* Note: srcY=0=Bottom of renderbuffer (GL convention)
*/
static void
-st_copy_texsubimage(GLcontext *ctx,
+st_copy_texsubimage(struct gl_context *ctx,
GLenum target, GLint level,
GLint destX, GLint destY, GLint destZ,
GLint srcX, GLint srcY,
@@ -1670,7 +1670,7 @@ st_copy_texsubimage(GLcontext *ctx,
static void
-st_CopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+st_CopyTexImage1D(struct gl_context * ctx, GLenum target, GLint level,
GLenum internalFormat,
GLint x, GLint y, GLsizei width, GLint border)
{
@@ -1696,7 +1696,7 @@ st_CopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
static void
-st_CopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
+st_CopyTexImage2D(struct gl_context * ctx, GLenum target, GLint level,
GLenum internalFormat,
GLint x, GLint y, GLsizei width, GLsizei height,
GLint border)
@@ -1723,7 +1723,7 @@ st_CopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
static void
-st_CopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+st_CopyTexSubImage1D(struct gl_context * ctx, GLenum target, GLint level,
GLint xoffset, GLint x, GLint y, GLsizei width)
{
const GLint yoffset = 0, zoffset = 0;
@@ -1735,7 +1735,7 @@ st_CopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
static void
-st_CopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
+st_CopyTexSubImage2D(struct gl_context * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height)
{
@@ -1747,7 +1747,7 @@ st_CopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
static void
-st_CopyTexSubImage3D(GLcontext * ctx, GLenum target, GLint level,
+st_CopyTexSubImage3D(struct gl_context * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLint zoffset,
GLint x, GLint y, GLsizei width, GLsizei height)
{
@@ -1812,7 +1812,7 @@ copy_image_data_to_texture(struct st_context *st,
* \return GL_TRUE for success, GL_FALSE for failure (out of mem)
*/
GLboolean
-st_finalize_texture(GLcontext *ctx,
+st_finalize_texture(struct gl_context *ctx,
struct pipe_context *pipe,
struct gl_texture_object *tObj)
{
@@ -1998,7 +1998,6 @@ st_init_texture_functions(struct dd_function_table *functions)
functions->NewTextureImage = st_NewTextureImage;
functions->DeleteTexture = st_DeleteTextureObject;
functions->FreeTexImageData = st_FreeTextureImageData;
- functions->UpdateTexturePalette = 0;
functions->TextureMemCpy = do_memcpy;
diff --git a/src/mesa/state_tracker/st_cb_texture.h b/src/mesa/state_tracker/st_cb_texture.h
index 6942478e815..60987055eb1 100644
--- a/src/mesa/state_tracker/st_cb_texture.h
+++ b/src/mesa/state_tracker/st_cb_texture.h
@@ -38,7 +38,7 @@ struct pipe_context;
struct st_context;
extern GLboolean
-st_finalize_texture(GLcontext *ctx,
+st_finalize_texture(struct gl_context *ctx,
struct pipe_context *pipe,
struct gl_texture_object *tObj);
diff --git a/src/mesa/state_tracker/st_cb_viewport.c b/src/mesa/state_tracker/st_cb_viewport.c
index a1fe45cac46..049755e45c0 100644
--- a/src/mesa/state_tracker/st_cb_viewport.c
+++ b/src/mesa/state_tracker/st_cb_viewport.c
@@ -34,19 +34,19 @@
#include "util/u_atomic.h"
/**
- * Cast wrapper to convert a GLframebuffer to an st_framebuffer.
- * Return NULL if the GLframebuffer is a user-created framebuffer.
+ * Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
+ * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
* We'll only return non-null for window system framebuffers.
* Note that this function may fail.
*/
static INLINE struct st_framebuffer *
-st_ws_framebuffer(GLframebuffer *fb)
+st_ws_framebuffer(struct gl_framebuffer *fb)
{
/* FBO cannot be casted. See st_new_framebuffer */
return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
}
-static void st_viewport(GLcontext * ctx, GLint x, GLint y,
+static void st_viewport(struct gl_context * ctx, GLint x, GLint y,
GLsizei width, GLsizei height)
{
struct st_context *st = ctx->st;
diff --git a/src/mesa/state_tracker/st_cb_xformfb.c b/src/mesa/state_tracker/st_cb_xformfb.c
index 749e88e8dbc..838a0a4a934 100644
--- a/src/mesa/state_tracker/st_cb_xformfb.c
+++ b/src/mesa/state_tracker/st_cb_xformfb.c
@@ -44,7 +44,7 @@
#if 0
static struct gl_transform_feedback_object *
-st_new_transform_feedback(GLcontext *ctx, GLuint name)
+st_new_transform_feedback(struct gl_context *ctx, GLuint name)
{
struct gl_transform_feedback_object *obj;
obj = CALLOC_STRUCT(gl_transform_feedback_object);
@@ -58,7 +58,7 @@ st_new_transform_feedback(GLcontext *ctx, GLuint name)
#if 0
static void
-st_delete_transform_feedback(GLcontext *ctx,
+st_delete_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj)
{
GLuint i;
@@ -73,7 +73,7 @@ st_delete_transform_feedback(GLcontext *ctx,
static void
-st_begin_transform_feedback(GLcontext *ctx, GLenum mode,
+st_begin_transform_feedback(struct gl_context *ctx, GLenum mode,
struct gl_transform_feedback_object *obj)
{
/* to-do */
@@ -81,7 +81,7 @@ st_begin_transform_feedback(GLcontext *ctx, GLenum mode,
static void
-st_end_transform_feedback(GLcontext *ctx,
+st_end_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj)
{
/* to-do */
@@ -89,7 +89,7 @@ st_end_transform_feedback(GLcontext *ctx,
static void
-st_pause_transform_feedback(GLcontext *ctx,
+st_pause_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj)
{
/* to-do */
@@ -97,7 +97,7 @@ st_pause_transform_feedback(GLcontext *ctx,
static void
-st_resume_transform_feedback(GLcontext *ctx,
+st_resume_transform_feedback(struct gl_context *ctx,
struct gl_transform_feedback_object *obj)
{
/* to-do */
@@ -105,7 +105,7 @@ st_resume_transform_feedback(GLcontext *ctx,
static void
-st_draw_transform_feedback(GLcontext *ctx, GLenum mode,
+st_draw_transform_feedback(struct gl_context *ctx, GLenum mode,
struct gl_transform_feedback_object *obj)
{
/* XXX to do */
diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c
index 3b046962efe..75fd69540f3 100644
--- a/src/mesa/state_tracker/st_context.c
+++ b/src/mesa/state_tracker/st_context.c
@@ -69,7 +69,7 @@ DEBUG_GET_ONCE_BOOL_OPTION(mesa_mvp_dp4, "MESA_MVP_DP4", FALSE)
/**
* Called via ctx->Driver.UpdateState()
*/
-void st_invalidate_state(GLcontext * ctx, GLuint new_state)
+void st_invalidate_state(struct gl_context * ctx, GLuint new_state)
{
struct st_context *st = st_context(ctx);
@@ -97,7 +97,7 @@ st_get_msaa(void)
static struct st_context *
-st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
+st_create_context_priv( struct gl_context *ctx, struct pipe_context *pipe )
{
uint i;
struct st_context *st = ST_CALLOC_STRUCT( st_context );
@@ -163,11 +163,11 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe )
struct st_context *st_create_context(gl_api api, struct pipe_context *pipe,
- const __GLcontextModes *visual,
+ const struct gl_config *visual,
struct st_context *share)
{
- GLcontext *ctx;
- GLcontext *shareCtx = share ? share->ctx : NULL;
+ struct gl_context *ctx;
+ struct gl_context *shareCtx = share ? share->ctx : NULL;
struct dd_function_table funcs;
memset(&funcs, 0, sizeof(funcs));
@@ -221,7 +221,7 @@ void st_destroy_context( struct st_context *st )
{
struct pipe_context *pipe = st->pipe;
struct cso_context *cso = st->cso_context;
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
GLuint i;
/* need to unbind and destroy CSO objects before anything else */
diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h
index 991feee3001..d342c0cff1e 100644
--- a/src/mesa/state_tracker/st_context.h
+++ b/src/mesa/state_tracker/st_context.h
@@ -68,7 +68,7 @@ struct st_context
{
struct st_context_iface iface;
- GLcontext *ctx;
+ struct gl_context *ctx;
struct pipe_context *pipe;
@@ -160,7 +160,7 @@ struct st_context
/** for glDraw/CopyPixels */
struct {
- struct st_fragment_program *z_shader;
+ struct st_fragment_program *shaders[4];
void *vert_shaders[2]; /**< ureg shaders */
} drawpix;
@@ -195,19 +195,19 @@ struct st_context
/* Need this so that we can implement Mesa callbacks in this module.
*/
-static INLINE struct st_context *st_context(GLcontext *ctx)
+static INLINE struct st_context *st_context(struct gl_context *ctx)
{
return ctx->st;
}
/**
- * Wrapper for GLframebuffer.
+ * Wrapper for struct gl_framebuffer.
* This is an opaque type to the outside world.
*/
struct st_framebuffer
{
- GLframebuffer Base;
+ struct gl_framebuffer Base;
void *Private;
struct st_framebuffer_iface *iface;
@@ -219,7 +219,7 @@ struct st_framebuffer
extern void st_init_driver_functions(struct dd_function_table *functions);
-void st_invalidate_state(GLcontext * ctx, GLuint new_state);
+void st_invalidate_state(struct gl_context * ctx, GLuint new_state);
@@ -260,7 +260,7 @@ st_get_msaa(void);
extern struct st_context *
st_create_context(gl_api api, struct pipe_context *pipe,
- const __GLcontextModes *visual,
+ const struct gl_config *visual,
struct st_context *share);
extern void
diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c
index 318e08886c7..f6f5bb17938 100644
--- a/src/mesa/state_tracker/st_draw.c
+++ b/src/mesa/state_tracker/st_draw.c
@@ -341,7 +341,7 @@ get_arrays_bounds(const struct st_vertex_program *vp,
* \param velements returns vertex element info
*/
static void
-setup_interleaved_attribs(GLcontext *ctx,
+setup_interleaved_attribs(struct gl_context *ctx,
const struct st_vertex_program *vp,
const struct st_vp_varient *vpv,
const struct gl_client_array **arrays,
@@ -407,7 +407,7 @@ setup_interleaved_attribs(GLcontext *ctx,
* \param velements returns vertex element info
*/
static void
-setup_non_interleaved_attribs(GLcontext *ctx,
+setup_non_interleaved_attribs(struct gl_context *ctx,
const struct st_vertex_program *vp,
const struct st_vp_varient *vpv,
const struct gl_client_array **arrays,
@@ -496,7 +496,7 @@ setup_non_interleaved_attribs(GLcontext *ctx,
static void
-setup_index_buffer(GLcontext *ctx,
+setup_index_buffer(struct gl_context *ctx,
const struct _mesa_index_buffer *ib,
struct pipe_index_buffer *ibuffer)
{
@@ -545,7 +545,7 @@ setup_index_buffer(GLcontext *ctx,
* issue a warning.
*/
static void
-check_uniforms(GLcontext *ctx)
+check_uniforms(struct gl_context *ctx)
{
const struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
if (shProg && shProg->LinkStatus) {
@@ -567,7 +567,7 @@ check_uniforms(GLcontext *ctx)
* the corresponding Gallium type.
*/
static unsigned
-translate_prim(const GLcontext *ctx, unsigned prim)
+translate_prim(const struct gl_context *ctx, unsigned prim)
{
/* GL prims should match Gallium prims, spot-check a few */
assert(GL_POINTS == PIPE_PRIM_POINTS);
@@ -595,7 +595,7 @@ translate_prim(const GLcontext *ctx, unsigned prim)
* Basically, translate the information into the format expected by gallium.
*/
void
-st_draw_vbo(GLcontext *ctx,
+st_draw_vbo(struct gl_context *ctx,
const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
@@ -736,7 +736,7 @@ st_draw_vbo(GLcontext *ctx,
void st_init_draw( struct st_context *st )
{
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
vbo_set_draw_func(ctx, st_draw_vbo);
diff --git a/src/mesa/state_tracker/st_draw.h b/src/mesa/state_tracker/st_draw.h
index f36184487a6..2e4c468cff5 100644
--- a/src/mesa/state_tracker/st_draw.h
+++ b/src/mesa/state_tracker/st_draw.h
@@ -47,7 +47,7 @@ void st_init_draw( struct st_context *st );
void st_destroy_draw( struct st_context *st );
extern void
-st_draw_vbo(GLcontext *ctx,
+st_draw_vbo(struct gl_context *ctx,
const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
@@ -57,7 +57,7 @@ st_draw_vbo(GLcontext *ctx,
GLuint max_index);
extern void
-st_feedback_draw_vbo(GLcontext *ctx,
+st_feedback_draw_vbo(struct gl_context *ctx,
const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
diff --git a/src/mesa/state_tracker/st_draw_feedback.c b/src/mesa/state_tracker/st_draw_feedback.c
index df05c7f70df..7f392fc4916 100644
--- a/src/mesa/state_tracker/st_draw_feedback.c
+++ b/src/mesa/state_tracker/st_draw_feedback.c
@@ -52,7 +52,7 @@
* GL_SELECT or GL_FEEDBACK mode or for glRasterPos.
*/
static void
-set_feedback_vertex_format(GLcontext *ctx)
+set_feedback_vertex_format(struct gl_context *ctx)
{
#if 0
struct st_context *st = st_context(ctx);
@@ -90,7 +90,7 @@ set_feedback_vertex_format(GLcontext *ctx)
* Might move this into the failover module some day.
*/
void
-st_feedback_draw_vbo(GLcontext *ctx,
+st_feedback_draw_vbo(struct gl_context *ctx,
const struct gl_client_array **arrays,
const struct _mesa_prim *prims,
GLuint nr_prims,
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 4c18c66cc4d..96e4efcafad 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -186,6 +186,11 @@ void st_init_limits(struct st_context *st)
* attributes) supported by a driver. */
c->MaxVarying = screen->get_shader_param(screen, PIPE_SHADER_FRAGMENT, PIPE_SHADER_CAP_MAX_INPUTS) - 2;
c->MaxVarying = MIN2(c->MaxVarying, MAX_VARYING);
+
+ /* XXX we'll need a better query here someday */
+ if (screen->get_param(screen, PIPE_CAP_GLSL)) {
+ c->GLSLVersion = 120;
+ }
}
@@ -199,7 +204,7 @@ void st_init_limits(struct st_context *st)
void st_init_extensions(struct st_context *st)
{
struct pipe_screen *screen = st->pipe->screen;
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
/*
* Extensions that are supported by all Gallium drivers:
@@ -266,7 +271,6 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.OES_draw_texture = GL_TRUE;
#endif
- ctx->Extensions.SGI_color_matrix = GL_TRUE;
ctx->Extensions.SGIS_generate_mipmap = GL_TRUE;
/*
@@ -285,7 +289,6 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.ARB_vertex_shader = GL_TRUE;
ctx->Extensions.ARB_shader_objects = GL_TRUE;
ctx->Extensions.ARB_shading_language_100 = GL_TRUE;
- ctx->Extensions.ARB_shading_language_120 = GL_TRUE;
}
if (screen->get_param(screen, PIPE_CAP_TEXTURE_MIRROR_REPEAT) > 0) {
@@ -370,6 +373,12 @@ void st_init_extensions(struct st_context *st)
ctx->Extensions.EXT_texture_sRGB = GL_TRUE;
}
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM,
+ PIPE_TEXTURE_2D, 0,
+ PIPE_BIND_SAMPLER_VIEW, 0)) {
+ ctx->Extensions.ARB_texture_rg = GL_TRUE;
+ }
+
/* s3tc support */
if (screen->is_format_supported(screen, PIPE_FORMAT_DXT5_RGBA,
PIPE_TEXTURE_2D, 0,
@@ -426,4 +435,8 @@ void st_init_extensions(struct st_context *st)
if (screen->get_param(screen, PIPE_CAP_DEPTH_CLAMP)) {
ctx->Extensions.ARB_depth_clamp = GL_TRUE;
}
+
+ if (screen->get_param(screen, PIPE_CAP_SHADER_STENCIL_EXPORT)) {
+ ctx->Extensions.ARB_shader_stencil_export = GL_TRUE;
+ }
}
diff --git a/src/mesa/state_tracker/st_format.c b/src/mesa/state_tracker/st_format.c
index 1ed79524b2c..4e90bd01a30 100644
--- a/src/mesa/state_tracker/st_format.c
+++ b/src/mesa/state_tracker/st_format.c
@@ -166,6 +166,8 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
return PIPE_FORMAT_X8Z24_UNORM;
case MESA_FORMAT_X8_Z24:
return PIPE_FORMAT_Z24X8_UNORM;
+ case MESA_FORMAT_S8:
+ return PIPE_FORMAT_S8_USCALED;
case MESA_FORMAT_YCBCR:
return PIPE_FORMAT_UYVY;
#if FEATURE_texture_s3tc
@@ -200,6 +202,14 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat)
case MESA_FORMAT_SARGB8:
return PIPE_FORMAT_B8G8R8A8_SRGB;
#endif
+ case MESA_FORMAT_R8:
+ return PIPE_FORMAT_R8_UNORM;
+ case MESA_FORMAT_R16:
+ return PIPE_FORMAT_R16_UNORM;
+ case MESA_FORMAT_RG88:
+ return PIPE_FORMAT_R8G8_UNORM;
+ case MESA_FORMAT_RG1616:
+ return PIPE_FORMAT_R16G16_UNORM;
default:
assert(0);
return PIPE_FORMAT_NONE;
@@ -297,6 +307,15 @@ st_pipe_format_to_mesa_format(enum pipe_format format)
case PIPE_FORMAT_B8G8R8A8_SRGB:
return MESA_FORMAT_SARGB8;
#endif
+
+ case PIPE_FORMAT_R8_UNORM:
+ return MESA_FORMAT_R8;
+ case PIPE_FORMAT_R16_UNORM:
+ return MESA_FORMAT_R16;
+ case PIPE_FORMAT_R8G8_UNORM:
+ return MESA_FORMAT_RG88;
+ case PIPE_FORMAT_R16G16_UNORM:
+ return MESA_FORMAT_RG1616;
default:
assert(0);
return MESA_FORMAT_NONE;
@@ -686,6 +705,55 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat,
return default_srgba_format( screen, target, sample_count, bindings,
geom_flags );
+ case GL_RED:
+ case GL_R8:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R8_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_R8_UNORM;
+ return PIPE_FORMAT_NONE;
+ case GL_RG:
+ case GL_RG8:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_R8G8_UNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_R16:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R16_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_R16_UNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_RG16:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_R16G16_UNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_COMPRESSED_RED_RGTC1:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_RGTC1_UNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_COMPRESSED_SIGNED_RED_RGTC1:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC1_SNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_RGTC1_SNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_COMPRESSED_RG_RGTC2:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_UNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_RGTC2_UNORM;
+ return PIPE_FORMAT_NONE;
+
+ case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ if (screen->is_format_supported(screen, PIPE_FORMAT_RGTC2_SNORM, target,
+ sample_count, bindings, geom_flags))
+ return PIPE_FORMAT_RGTC2_SNORM;
+ return PIPE_FORMAT_NONE;
+
default:
return PIPE_FORMAT_NONE;
}
@@ -713,8 +781,8 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
* Called via ctx->Driver.chooseTextureFormat().
*/
gl_format
-st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
- GLenum format, GLenum type)
+st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
+ GLenum format, GLenum type, GLboolean renderable)
{
struct pipe_screen *screen = st_context(ctx)->pipe->screen;
enum pipe_format pFormat;
@@ -726,11 +794,14 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
/* GL textures may wind up being render targets, but we don't know
* that in advance. Specify potential render target flags now.
*/
- if (_mesa_is_depth_format(internalFormat) ||
- _mesa_is_depthstencil_format(internalFormat))
- bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_DEPTH_STENCIL;
- else
- bindings = PIPE_BIND_SAMPLER_VIEW | PIPE_BIND_RENDER_TARGET;
+ bindings = PIPE_BIND_SAMPLER_VIEW;
+ if (renderable == GL_TRUE) {
+ if (_mesa_is_depth_format(internalFormat) ||
+ _mesa_is_depth_or_stencil_format(internalFormat))
+ bindings |= PIPE_BIND_DEPTH_STENCIL;
+ else
+ bindings |= PIPE_BIND_RENDER_TARGET;
+ }
pFormat = st_choose_format(screen, internalFormat,
PIPE_TEXTURE_2D, 0, bindings);
@@ -749,6 +820,13 @@ st_ChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
return st_pipe_format_to_mesa_format(pFormat);
}
+gl_format
+st_ChooseTextureFormat(struct gl_context *ctx, GLint internalFormat,
+ GLenum format, GLenum type)
+{
+ return st_ChooseTextureFormat_renderable(ctx, internalFormat,
+ format, type, GL_TRUE);
+}
/**
* Test if a gallium format is equivalent to a GL format/type.
diff --git a/src/mesa/state_tracker/st_format.h b/src/mesa/state_tracker/st_format.h
index 841c58cadc8..43fa59b1006 100644
--- a/src/mesa/state_tracker/st_format.h
+++ b/src/mesa/state_tracker/st_format.h
@@ -59,8 +59,12 @@ st_choose_renderbuffer_format(struct pipe_screen *screen,
GLenum internalFormat, unsigned sample_count);
+gl_format
+st_ChooseTextureFormat_renderable(struct gl_context *ctx, GLint internalFormat,
+ GLenum format, GLenum type, GLboolean renderable);
+
extern gl_format
-st_ChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
+st_ChooseTextureFormat(struct gl_context * ctx, GLint internalFormat,
GLenum format, GLenum type);
diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c
index 2d587df6055..fe31418ddd1 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.c
+++ b/src/mesa/state_tracker/st_gen_mipmap.c
@@ -155,7 +155,7 @@ compress_image(enum pipe_format format,
* Software fallback for generate mipmap levels.
*/
static void
-fallback_generate_mipmap(GLcontext *ctx, GLenum target,
+fallback_generate_mipmap(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
@@ -276,7 +276,7 @@ fallback_generate_mipmap(GLcontext *ctx, GLenum target,
* levels should be generated.
*/
static GLuint
-compute_num_levels(GLcontext *ctx,
+compute_num_levels(struct gl_context *ctx,
struct gl_texture_object *texObj,
GLenum target)
{
@@ -311,7 +311,7 @@ compute_num_levels(GLcontext *ctx,
* Called via ctx->Driver.GenerateMipmap().
*/
void
-st_generate_mipmap(GLcontext *ctx, GLenum target,
+st_generate_mipmap(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj)
{
struct st_context *st = st_context(ctx);
diff --git a/src/mesa/state_tracker/st_gen_mipmap.h b/src/mesa/state_tracker/st_gen_mipmap.h
index 016bf3f4bba..3ba091da151 100644
--- a/src/mesa/state_tracker/st_gen_mipmap.h
+++ b/src/mesa/state_tracker/st_gen_mipmap.h
@@ -43,7 +43,7 @@ st_destroy_generate_mipmap(struct st_context *st);
extern void
-st_generate_mipmap(GLcontext *ctx, GLenum target,
+st_generate_mipmap(struct gl_context *ctx, GLenum target,
struct gl_texture_object *texObj);
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
index 450b0453cf4..183477a3f31 100644
--- a/src/mesa/state_tracker/st_manager.c
+++ b/src/mesa/state_tracker/st_manager.c
@@ -54,13 +54,13 @@
#include "st_manager.h"
/**
- * Cast wrapper to convert a GLframebuffer to an st_framebuffer.
- * Return NULL if the GLframebuffer is a user-created framebuffer.
+ * Cast wrapper to convert a struct gl_framebuffer to an st_framebuffer.
+ * Return NULL if the struct gl_framebuffer is a user-created framebuffer.
* We'll only return non-null for window system framebuffers.
* Note that this function may fail.
*/
static INLINE struct st_framebuffer *
-st_ws_framebuffer(GLframebuffer *fb)
+st_ws_framebuffer(struct gl_framebuffer *fb)
{
/* FBO cannot be casted. See st_new_framebuffer */
return (struct st_framebuffer *) ((fb && !fb->Name) ? fb : NULL);
@@ -296,11 +296,11 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb,
}
/**
- * Intialize a __GLcontextModes from a visual.
+ * Intialize a struct gl_config from a visual.
*/
static void
st_visual_to_context_mode(const struct st_visual *visual,
- __GLcontextModes *mode)
+ struct gl_config *mode)
{
memset(mode, 0, sizeof(*mode));
@@ -420,7 +420,7 @@ static struct st_framebuffer *
st_framebuffer_create(struct st_framebuffer_iface *stfbi)
{
struct st_framebuffer *stfb;
- __GLcontextModes mode;
+ struct gl_config mode;
gl_buffer_index idx;
stfb = CALLOC_STRUCT(st_framebuffer);
@@ -429,7 +429,7 @@ st_framebuffer_create(struct st_framebuffer_iface *stfbi)
/* for FBO-only context */
if (!stfbi) {
- GLframebuffer *base = _mesa_get_incomplete_framebuffer();
+ struct gl_framebuffer *base = _mesa_get_incomplete_framebuffer();
stfb->Base = *base;
@@ -471,8 +471,8 @@ static void
st_framebuffer_reference(struct st_framebuffer **ptr,
struct st_framebuffer *stfb)
{
- GLframebuffer *fb = &stfb->Base;
- _mesa_reference_framebuffer((GLframebuffer **) ptr, fb);
+ struct gl_framebuffer *fb = &stfb->Base;
+ _mesa_reference_framebuffer((struct gl_framebuffer **) ptr, fb);
}
static void
@@ -486,9 +486,18 @@ st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer);
if (!stfb || stfb->iface != stfbi)
stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer);
- assert(stfb && stfb->iface == stfbi);
- p_atomic_set(&stfb->revalidate, TRUE);
+ if (stfb && stfb->iface == stfbi) {
+ p_atomic_set(&stfb->revalidate, TRUE);
+ }
+ else {
+ /* This function is probably getting called when we've detected a
+ * change in a window's size but the currently bound context is
+ * not bound to that window.
+ * If the st_framebuffer_iface structure had a pointer to the
+ * corresponding st_framebuffer we'd be able to handle this.
+ */
+ }
}
static void
@@ -507,7 +516,7 @@ st_context_teximage(struct st_context_iface *stctxi, enum st_texture_type target
struct pipe_resource *tex, boolean mipmap)
{
struct st_context *st = (struct st_context *) stctxi;
- GLcontext *ctx = st->ctx;
+ struct gl_context *ctx = st->ctx;
struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
@@ -616,7 +625,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
struct st_context *shared_ctx = (struct st_context *) shared_stctxi;
struct st_context *st;
struct pipe_context *pipe;
- __GLcontextModes mode;
+ struct gl_config mode;
gl_api api;
if (!(stapi->profile_mask & (1 << attribs->profile)))
@@ -794,7 +803,7 @@ st_manager_get_egl_image_surface(struct st_context *st,
return NULL;
memset(&stimg, 0, sizeof(stimg));
- if (!smapi->get_egl_image(smapi, &st->iface, eglimg, &stimg))
+ if (!smapi->get_egl_image(smapi, eglimg, &stimg))
return NULL;
ps = smapi->screen->get_tex_surface(smapi->screen,
@@ -823,7 +832,7 @@ st_manager_validate_framebuffers(struct st_context *st)
* Add a color renderbuffer on demand.
*/
boolean
-st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
+st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb,
gl_buffer_index idx)
{
struct st_framebuffer *stfb = st_ws_framebuffer(fb);
diff --git a/src/mesa/state_tracker/st_manager.h b/src/mesa/state_tracker/st_manager.h
index 48a9d4d99a6..6a94978390a 100644
--- a/src/mesa/state_tracker/st_manager.h
+++ b/src/mesa/state_tracker/st_manager.h
@@ -46,7 +46,7 @@ void
st_manager_validate_framebuffers(struct st_context *st);
boolean
-st_manager_add_color_renderbuffer(struct st_context *st, GLframebuffer *fb,
+st_manager_add_color_renderbuffer(struct st_context *st, struct gl_framebuffer *fb,
gl_buffer_index idx);
#endif /* ST_MANAGER_H */
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
index 0ed822b8c27..c5c239b2c95 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
@@ -924,7 +924,7 @@ emit_edgeflags( struct st_translate *t,
*/
enum pipe_error
st_translate_mesa_program(
- GLcontext *ctx,
+ struct gl_context *ctx,
uint procType,
struct ureg_program *ureg,
const struct gl_program *program,
@@ -1002,6 +1002,13 @@ st_translate_mesa_program(
t->outputs[i] = ureg_writemask( t->outputs[i],
TGSI_WRITEMASK_Z );
break;
+ case TGSI_SEMANTIC_STENCIL:
+ t->outputs[i] = ureg_DECL_output( ureg,
+ TGSI_SEMANTIC_STENCIL, /* Stencil */
+ outputSemanticIndex[i] );
+ t->outputs[i] = ureg_writemask( t->outputs[i],
+ TGSI_WRITEMASK_Y );
+ break;
case TGSI_SEMANTIC_COLOR:
t->outputs[i] = ureg_DECL_output( ureg,
TGSI_SEMANTIC_COLOR,
diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.h b/src/mesa/state_tracker/st_mesa_to_tgsi.h
index ca076ce3622..9bfd4960b60 100644
--- a/src/mesa/state_tracker/st_mesa_to_tgsi.h
+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.h
@@ -44,7 +44,7 @@ struct gl_program;
enum pipe_error
st_translate_mesa_program(
- GLcontext *ctx,
+ struct gl_context *ctx,
uint procType,
struct ureg_program *ureg,
const struct gl_program *program,
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 8c2d8b6154b..95e6bd7dac2 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -338,17 +338,6 @@ st_translate_fragment_program(struct st_context *st,
input_semantic_index[slot] = 0;
interpMode[slot] = TGSI_INTERPOLATE_CONSTANT;
break;
- case FRAG_ATTRIB_PNTC:
- /* This is a hack. We really need a new semantic label for
- * point coord. The draw module needs to know which fragment
- * shader input is the point coord attribute so that it can set
- * up the right vertex attribute values.
- */
- input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- input_semantic_index[slot] = 0;
- interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
- break;
-
/* In most cases, there is nothing special about these
* inputs, so adopt a convention to use the generic
* semantic name and the mesa FRAG_ATTRIB_ number as the
@@ -364,6 +353,7 @@ st_translate_fragment_program(struct st_context *st,
* zero or be restricted to a particular range -- nobody
* should be building tables based on semantic index.
*/
+ case FRAG_ATTRIB_PNTC:
case FRAG_ATTRIB_TEX0:
case FRAG_ATTRIB_TEX1:
case FRAG_ATTRIB_TEX2:
@@ -380,7 +370,10 @@ st_translate_fragment_program(struct st_context *st,
assert(attr >= FRAG_ATTRIB_TEX0);
input_semantic_index[slot] = (attr - FRAG_ATTRIB_TEX0);
input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
- interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
+ if (attr == FRAG_ATTRIB_PNTC)
+ interpMode[slot] = TGSI_INTERPOLATE_LINEAR;
+ else
+ interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE;
break;
}
}
@@ -405,11 +398,20 @@ st_translate_fragment_program(struct st_context *st,
outputsWritten &= ~(1 << FRAG_RESULT_DEPTH);
}
+ if (outputsWritten & BITFIELD64_BIT(FRAG_RESULT_STENCIL)) {
+ fs_output_semantic_name[fs_num_outputs] = TGSI_SEMANTIC_STENCIL;
+ fs_output_semantic_index[fs_num_outputs] = 0;
+ outputMapping[FRAG_RESULT_STENCIL] = fs_num_outputs;
+ fs_num_outputs++;
+ outputsWritten &= ~(1 << FRAG_RESULT_STENCIL);
+ }
+
/* handle remaning outputs (color) */
for (attr = 0; attr < FRAG_RESULT_MAX; attr++) {
if (outputsWritten & BITFIELD64_BIT(attr)) {
switch (attr) {
case FRAG_RESULT_DEPTH:
+ case FRAG_RESULT_STENCIL:
/* handled above */
assert(0);
break;
@@ -714,7 +716,7 @@ st_translate_geometry_program(struct st_context *st,
* Debug- print current shader text
*/
void
-st_print_shaders(GLcontext *ctx)
+st_print_shaders(struct gl_context *ctx)
{
struct gl_shader_program *shProg = ctx->Shader.CurrentProgram;
if (shProg) {
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index 3805b9a725e..72dbc715fe1 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -223,7 +223,7 @@ st_vp_release_varients( struct st_context *st,
struct st_vertex_program *stvp );
extern void
-st_print_shaders(GLcontext *ctx);
+st_print_shaders(struct gl_context *ctx);
#endif
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index ed5d271597c..c78901c0360 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -134,6 +134,20 @@ st_create_texture_sampler_view(struct pipe_context *pipe,
static INLINE struct pipe_sampler_view *
+st_create_texture_sampler_view_format(struct pipe_context *pipe,
+ struct pipe_resource *texture,
+ enum pipe_format format)
+{
+ struct pipe_sampler_view templ;
+
+ u_sampler_view_default_template(&templ,
+ texture,
+ format);
+
+ return pipe->create_sampler_view(pipe, texture, &templ);
+}
+
+static INLINE struct pipe_sampler_view *
st_get_texture_sampler_view(struct st_texture_object *stObj,
struct pipe_context *pipe)