diff options
Diffstat (limited to 'src/mesa/state_tracker')
48 files changed, 631 insertions, 283 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 081b6b3e233..6be03376d01 100644 --- a/src/mesa/state_tracker/st_atom_pixeltransfer.c +++ b/src/mesa/state_tracker/st_atom_pixeltransfer.c @@ -69,7 +69,7 @@ struct state_key }; static void -make_state_key(GLcontext *ctx, struct state_key *key) +make_state_key(struct gl_context *ctx, struct state_key *key) { memset(key, 0, sizeof(*key)); @@ -85,7 +85,7 @@ make_state_key(GLcontext *ctx, struct state_key *key) 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; @@ -108,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; @@ -157,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]; @@ -320,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; diff --git a/src/mesa/state_tracker/st_atom_rasterizer.c b/src/mesa/state_tracker/st_atom_rasterizer.c index 0fe333ae8aa..451299cef0c 100644 --- a/src/mesa/state_tracker/st_atom_rasterizer.c +++ b/src/mesa/state_tracker/st_atom_rasterizer.c @@ -57,7 +57,7 @@ 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; 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 fb1fec1aefd..122d8f07654 100644 --- a/src/mesa/state_tracker/st_cb_drawpixels.c +++ b/src/mesa/state_tracker/st_cb_drawpixels.c @@ -34,31 +34,32 @@ #include "main/image.h" #include "main/bufferobj.h" #include "main/macros.h" +#include "main/pack.h" #include "main/texformat.h" #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 +97,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 +163,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; - if (st->drawpix.z_shader) { - return st->drawpix.z_shader->driver_shader; + assert(shaderIndex < Elements(st->drawpix.shaders)); + + if (st->drawpix.shaders[shaderIndex]) { + /* already have the proper shader */ + return st->drawpix.shaders[shaderIndex]->driver_shader; } /* @@ -185,7 +193,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 +203,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 +235,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); - st->drawpix.z_shader = (struct st_fragment_program *) p; - st_translate_fragment_program(st, st->drawpix.z_shader); + /* save the new shader */ + st->drawpix.shaders[shaderIndex] = stp; - return st->drawpix.z_shader->driver_shader; + st_translate_fragment_program(st, stp); + + return stp->driver_shader; } @@ -239,8 +266,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; @@ -273,8 +299,8 @@ make_passthrough_vertex_shader(struct st_context *st, /** - * Return a texture internalFormat for drawing/copying an image - * of the given type. + * Return a texture base format for drawing/copying an image + * of the given format. */ static GLenum base_format(GLenum format) @@ -293,6 +319,47 @@ base_format(GLenum format) /** + * Return a texture internalFormat for drawing/copying an image + * of the given format and type. + */ +static GLenum +internal_format(GLenum format, GLenum type) +{ + switch (format) { + case GL_DEPTH_COMPONENT: + return GL_DEPTH_COMPONENT; + case GL_DEPTH_STENCIL: + return GL_DEPTH_STENCIL; + case GL_STENCIL_INDEX: + return GL_STENCIL_INDEX; + default: + if (_mesa_is_integer_format(format)) { + switch (type) { + case GL_BYTE: + return GL_RGBA8I; + case GL_UNSIGNED_BYTE: + return GL_RGBA8UI; + case GL_SHORT: + return GL_RGBA16I; + case GL_UNSIGNED_SHORT: + return GL_RGBA16UI; + case GL_INT: + return GL_RGBA32I; + case GL_UNSIGNED_INT: + return GL_RGBA32UI; + default: + assert(0 && "Unexpected type in internal_format()"); + return GL_RGBA_INTEGER; + } + } + else { + return GL_RGBA; + } + } +} + + +/** * Create a temporary texture to hold an image of the given size. * If width, height are not POT and the driver only handles POT textures, * allocate the next larger size of texture that is POT. @@ -320,17 +387,19 @@ 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; enum pipe_format pipeFormat; GLuint cpp; - GLenum baseFormat; + GLenum baseFormat, intFormat; baseFormat = base_format(format); + intFormat = internal_format(format, type); - mformat = st_ChooseTextureFormat(ctx, baseFormat, format, type); + mformat = st_ChooseTextureFormat_renderable(ctx, intFormat, + format, type, GL_FALSE); assert(mformat); pipeFormat = st_mesa_format_to_pipe_format(mformat); @@ -405,7 +474,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 +564,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 +609,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 +647,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 +672,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 +692,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 +707,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 +743,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 +862,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 +907,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 +916,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,26 +927,44 @@ 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) { @@ -858,7 +994,8 @@ copy_stencil_pixels(GLcontext *ctx, GLint srcx, GLint srcy, 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; @@ -935,7 +1072,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) { @@ -945,7 +1082,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; @@ -966,12 +1104,16 @@ 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); } @@ -986,7 +1128,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; } @@ -1031,8 +1174,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; } @@ -1102,13 +1245,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); } @@ -1123,7 +1267,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 ac1f6812b85..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) { @@ -297,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) { @@ -307,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) @@ -321,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) { @@ -411,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); @@ -490,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; @@ -544,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; @@ -565,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 e5f7b6f91e2..15a4f602d1d 100644 --- a/src/mesa/state_tracker/st_cb_rasterpos.c +++ b/src/mesa/state_tracker/st_cb_rasterpos.c @@ -57,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]; @@ -110,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) @@ -132,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; @@ -177,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; @@ -219,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 d9e9a527f63..bcd46ac9d54 100644 --- a/src/mesa/state_tracker/st_cb_readpixels.c +++ b/src/mesa/state_tracker/st_cb_readpixels.c @@ -37,6 +37,7 @@ #include "main/bufferobj.h" #include "main/context.h" #include "main/image.h" +#include "main/pack.h" #include "pipe/p_context.h" #include "pipe/p_defines.h" @@ -55,7 +56,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 +175,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 +190,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 +321,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) 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 9d232d417e4..4c2f7d78960 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -34,6 +34,8 @@ #include "main/imports.h" #include "main/macros.h" #include "main/mipmap.h" +#include "main/pack.h" +#include "main/pixeltransfer.h" #include "main/texcompress.h" #include "main/texfetch.h" #include "main/texgetimage.h" @@ -94,7 +96,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 +106,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 +118,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 +142,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); @@ -411,7 +413,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, @@ -522,7 +524,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, @@ -779,7 +781,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 +798,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 +813,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 +828,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 +846,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 +942,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 +1033,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 +1044,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 +1056,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 +1162,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 +1177,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 +1192,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 +1205,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 +1217,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 +1272,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 +1293,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 +1418,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 +1485,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 +1672,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 +1698,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 +1725,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 +1737,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 +1749,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 +1814,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) { 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..5387499eb94 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, @@ -703,6 +703,9 @@ st_draw_vbo(GLcontext *ctx, } } + info.primitive_restart = st->ctx->Array.PrimitiveRestart; + info.restart_index = st->ctx->Array.RestartIndex; + /* do actual drawing */ for (i = 0; i < nr_prims; i++) { info.mode = translate_prim( ctx, prims[i].mode ); @@ -736,7 +739,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 9b09601bbc5..2720f446450 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -204,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: @@ -432,7 +432,15 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.ARB_geometry_shader4 = GL_TRUE; } + if (screen->get_param(screen, PIPE_CAP_PRIMITIVE_RESTART)) { + ctx->Extensions.NV_primitive_restart = GL_TRUE; + } + 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 b7c54cef841..955d821a657 100644 --- a/src/mesa/state_tracker/st_format.c +++ b/src/mesa/state_tracker/st_format.c @@ -210,6 +210,25 @@ st_mesa_format_to_pipe_format(gl_format mesaFormat) return PIPE_FORMAT_R8G8_UNORM; case MESA_FORMAT_RG1616: return PIPE_FORMAT_R16G16_UNORM; + case MESA_FORMAT_RGBA_16: + return PIPE_FORMAT_R16G16B16A16_UNORM; + + /* signed int formats */ + case MESA_FORMAT_RGBA_INT8: + return PIPE_FORMAT_R8G8B8A8_SSCALED; + case MESA_FORMAT_RGBA_INT16: + return PIPE_FORMAT_R16G16B16A16_SSCALED; + case MESA_FORMAT_RGBA_INT32: + return PIPE_FORMAT_R32G32B32A32_SSCALED; + + /* unsigned int formats */ + case MESA_FORMAT_RGBA_UINT8: + return PIPE_FORMAT_R8G8B8A8_USCALED; + case MESA_FORMAT_RGBA_UINT16: + return PIPE_FORMAT_R16G16B16A16_USCALED; + case MESA_FORMAT_RGBA_UINT32: + return PIPE_FORMAT_R32G32B32A32_USCALED; + default: assert(0); return PIPE_FORMAT_NONE; @@ -253,6 +272,8 @@ st_pipe_format_to_mesa_format(enum pipe_format format) case PIPE_FORMAT_S8_USCALED: return MESA_FORMAT_S8; + case PIPE_FORMAT_R16G16B16A16_UNORM: + return MESA_FORMAT_RGBA_16; case PIPE_FORMAT_R16G16B16A16_SNORM: return MESA_FORMAT_SIGNED_RGBA_16; @@ -316,6 +337,23 @@ st_pipe_format_to_mesa_format(enum pipe_format format) return MESA_FORMAT_RG88; case PIPE_FORMAT_R16G16_UNORM: return MESA_FORMAT_RG1616; + + /* signed int formats */ + case PIPE_FORMAT_R8G8B8A8_SSCALED: + return MESA_FORMAT_RGBA_INT8; + case PIPE_FORMAT_R16G16B16A16_SSCALED: + return MESA_FORMAT_RGBA_INT16; + case PIPE_FORMAT_R32G32B32A32_SSCALED: + return MESA_FORMAT_RGBA_INT32; + + /* unsigned int formats */ + case PIPE_FORMAT_R8G8B8A8_USCALED: + return MESA_FORMAT_RGBA_UINT8; + case PIPE_FORMAT_R16G16B16A16_USCALED: + return MESA_FORMAT_RGBA_UINT16; + case PIPE_FORMAT_R32G32B32A32_USCALED: + return MESA_FORMAT_RGBA_UINT32; + default: assert(0); return MESA_FORMAT_NONE; @@ -435,14 +473,19 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, case GL_RGBA: case GL_RGBA8: case GL_RGB10_A2: - case GL_RGBA12: return default_rgba_format( screen, target, sample_count, bindings, geom_flags ); + case 3: case GL_RGB: return default_rgb_format( screen, target, sample_count, bindings, geom_flags ); + case GL_RGBA12: case GL_RGBA16: + if (screen->is_format_supported( screen, PIPE_FORMAT_R16G16B16A16_UNORM, + target, sample_count, bindings, + geom_flags )) + return PIPE_FORMAT_R16G16B16A16_UNORM; return default_rgba_format( screen, target, sample_count, bindings, geom_flags ); @@ -547,6 +590,8 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, } return PIPE_FORMAT_NONE; + case GL_COMPRESSED_RED: + case GL_COMPRESSED_RG: case GL_COMPRESSED_RGB: /* can only sample from compressed formats */ if (bindings & ~PIPE_BIND_SAMPLER_VIEW) @@ -754,6 +799,92 @@ st_choose_format(struct pipe_screen *screen, GLenum internalFormat, return PIPE_FORMAT_RGTC2_SNORM; return PIPE_FORMAT_NONE; + /* signed/unsigned integer formats. + * XXX Mesa only has formats for RGBA signed/unsigned integer formats. + * If/when new formats are added this code should be updated. + */ + case GL_RED_INTEGER_EXT: + case GL_GREEN_INTEGER_EXT: + case GL_BLUE_INTEGER_EXT: + case GL_ALPHA_INTEGER_EXT: + case GL_RGB_INTEGER_EXT: + case GL_RGBA_INTEGER_EXT: + case GL_BGR_INTEGER_EXT: + case GL_BGRA_INTEGER_EXT: + case GL_LUMINANCE_INTEGER_EXT: + case GL_LUMINANCE_ALPHA_INTEGER_EXT: + /* fall-through */ + case GL_RGBA8I_EXT: + case GL_RGB8I_EXT: + case GL_ALPHA8I_EXT: + case GL_INTENSITY8I_EXT: + case GL_LUMINANCE8I_EXT: + case GL_LUMINANCE_ALPHA8I_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8B8A8_SSCALED; + return PIPE_FORMAT_NONE; + case GL_RGBA16I_EXT: + case GL_RGB16I_EXT: + case GL_ALPHA16I_EXT: + case GL_INTENSITY16I_EXT: + case GL_LUMINANCE16I_EXT: + case GL_LUMINANCE_ALPHA16I_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16B16A16_SSCALED; + return PIPE_FORMAT_NONE; + case GL_RGBA32I_EXT: + case GL_RGB32I_EXT: + case GL_ALPHA32I_EXT: + case GL_INTENSITY32I_EXT: + case GL_LUMINANCE32I_EXT: + case GL_LUMINANCE_ALPHA32I_EXT: + /* xxx */ + if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_SSCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R32G32B32A32_SSCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA8UI_EXT: + case GL_RGB8UI_EXT: + case GL_ALPHA8UI_EXT: + case GL_INTENSITY8UI_EXT: + case GL_LUMINANCE8UI_EXT: + case GL_LUMINANCE_ALPHA8UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R8G8B8A8_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R8G8B8A8_USCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA16UI_EXT: + case GL_RGB16UI_EXT: + case GL_ALPHA16UI_EXT: + case GL_INTENSITY16UI_EXT: + case GL_LUMINANCE16UI_EXT: + case GL_LUMINANCE_ALPHA16UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R16G16B16A16_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R16G16B16A16_USCALED; + return PIPE_FORMAT_NONE; + + case GL_RGBA32UI_EXT: + case GL_RGB32UI_EXT: + case GL_ALPHA32UI_EXT: + case GL_INTENSITY32UI_EXT: + case GL_LUMINANCE32UI_EXT: + case GL_LUMINANCE_ALPHA32UI_EXT: + if (screen->is_format_supported(screen, PIPE_FORMAT_R32G32B32A32_USCALED, + target, + sample_count, bindings, geom_flags)) + return PIPE_FORMAT_R32G32B32A32_USCALED; + return PIPE_FORMAT_NONE; + default: return PIPE_FORMAT_NONE; } @@ -781,8 +912,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; @@ -794,11 +925,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); @@ -817,6 +951,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 66e32b4c9e8..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))) @@ -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 18a7bbe0f90..95e6bd7dac2 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -398,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; @@ -707,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) |