From 1c04731b8721850b6abb12a43a3eec616b850e86 Mon Sep 17 00:00:00 2001 From: Zack Rusin Date: Wed, 1 Jul 2009 10:42:58 -0400 Subject: gallium: fix the front face semantics mesa allocates both frontface and pointcoord registers within the fog coordinate register, by using swizzling. to make it cleaner and easier for drivers we want each of them in its own register. so when doing compilation from the mesa IR to tgsi allocate new registers for both and add new semantics to the respective declarations. --- src/mesa/state_tracker/st_atom_shader.c | 19 +++++++++++++++++-- src/mesa/state_tracker/st_mesa_to_tgsi.c | 23 ++++++++++++++++++++++- src/mesa/state_tracker/st_program.c | 7 ++++++- 3 files changed, 45 insertions(+), 4 deletions(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index ee649be885..c02ccc3528 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -137,8 +137,23 @@ find_translated_vp(struct st_context *st, for (inAttr = 0; inAttr < FRAG_ATTRIB_MAX; inAttr++) { if (fragInputsRead & (1 << inAttr)) { - stfp->input_to_slot[inAttr] = numIn; - numIn++; + if ((fragInputsRead & FRAG_BIT_FOGC)) { + if (stfp->Base.UsesPointCoord) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + if (stfp->Base.UsesFrontFacing) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + if (stfp->Base.UsesFogFragCoord) { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } + } else { + stfp->input_to_slot[inAttr] = numIn; + numIn++; + } } else { stfp->input_to_slot[inAttr] = UNUSED; diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c index 43c9afccc3..3140ebe04a 100644 --- a/src/mesa/state_tracker/st_mesa_to_tgsi.c +++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c @@ -101,8 +101,10 @@ map_register_file( */ static GLuint map_register_file_index( + GLuint procType, GLuint file, GLuint index, + GLuint *swizzle, const GLuint inputMapping[], const GLuint outputMapping[], const GLuint immediateMapping[], @@ -110,6 +112,20 @@ map_register_file_index( { switch( file ) { case TGSI_FILE_INPUT: + if (procType == TGSI_PROCESSOR_FRAGMENT && + index == FRAG_ATTRIB_FOGC) { + if (GET_SWZ(*swizzle, 0) == SWIZZLE_X) { + /* do nothing we're, ok */ + } else if (GET_SWZ(*swizzle, 0) == SWIZZLE_Y) { + /* replace the swizzle with xxxx */ + *swizzle = MAKE_SWIZZLE4(SWIZZLE_X, + SWIZZLE_X, + SWIZZLE_X, + SWIZZLE_X); + } else { + /* fixme: point coord */ + } + } /* inputs are mapped according to the user-defined map */ return inputMapping[index]; @@ -236,8 +252,10 @@ compile_instruction( fulldst = &fullinst->FullDstRegisters[0]; fulldst->DstRegister.File = map_register_file( inst->DstReg.File, 0, NULL, GL_FALSE ); fulldst->DstRegister.Index = map_register_file_index( + procType, fulldst->DstRegister.File, inst->DstReg.Index, + NULL, inputMapping, outputMapping, NULL, @@ -246,6 +264,7 @@ compile_instruction( for (i = 0; i < fullinst->Instruction.NumSrcRegs; i++) { GLuint j; + GLuint swizzle = inst->SrcReg[i].Swizzle; fullsrc = &fullinst->FullSrcRegisters[i]; @@ -264,8 +283,10 @@ compile_instruction( immediateMapping, indirectAccess ); fullsrc->SrcRegister.Index = map_register_file_index( + procType, fullsrc->SrcRegister.File, inst->SrcReg[i].Index, + &swizzle, inputMapping, outputMapping, immediateMapping, @@ -278,7 +299,7 @@ compile_instruction( GLboolean extended = (inst->SrcReg[i].Negate != NEGATE_NONE && inst->SrcReg[i].Negate != NEGATE_XYZW); for( j = 0; j < 4; j++ ) { - swz[j] = GET_SWZ( inst->SrcReg[i].Swizzle, j ); + swz[j] = GET_SWZ( swizzle, j ); if (swz[j] > SWIZZLE_W) extended = GL_TRUE; } diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 72ca852458..9a346fbde0 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -437,11 +437,16 @@ st_translate_fragment_program(struct st_context *st, if (stfp->Base.UsesPointCoord) { stfp->input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC; stfp->input_semantic_index[slot] = num_generic++; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; + } else if (stfp->Base.UsesFrontFacing) { + stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FACE; + stfp->input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_CONSTANT; } else { stfp->input_semantic_name[slot] = TGSI_SEMANTIC_FOG; stfp->input_semantic_index[slot] = 0; + interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; } - interpMode[slot] = TGSI_INTERPOLATE_PERSPECTIVE; break; case FRAG_ATTRIB_TEX0: case FRAG_ATTRIB_TEX1: -- cgit v1.2.3 From e2a8ef4430e153589a9d1a284c8f2005a4a98410 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 1 Jul 2009 19:06:54 +0100 Subject: mesa: Unbind depth/stencil surface from pipe_framebuffer when none is attached. --- src/mesa/state_tracker/st_atom_framebuffer.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_atom_framebuffer.c b/src/mesa/state_tracker/st_atom_framebuffer.c index 536293683e..3ef919a45e 100644 --- a/src/mesa/state_tracker/st_atom_framebuffer.c +++ b/src/mesa/state_tracker/st_atom_framebuffer.c @@ -147,6 +147,8 @@ update_framebuffer_state( struct st_context *st ) assert(strb->surface); pipe_surface_reference(&framebuffer->zsbuf, strb->surface); } + else + pipe_surface_reference(&framebuffer->zsbuf, NULL); } cso_set_framebuffer(st->cso_context, framebuffer); -- cgit v1.2.3 From a4fd94a54a75a3418462c30f1240ab50b5f24090 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 30 Jun 2009 07:33:54 +0200 Subject: st/gl: Add support for glCompressedTexSubImage --- src/mesa/state_tracker/st_cb_texture.c | 58 ++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 14b78d1253..5845b7940c 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1169,6 +1169,63 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, + GLsizei width, GLint height, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + struct st_texture_image *stImage = st_texture_image(texImage); + struct pipe_format_block block; + int srcBlockStride; + int dstBlockStride; + int y; + + if (stImage->pt) { + st_teximage_flush_before_map(ctx->st, stImage->pt, 0, level, + PIPE_TRANSFER_WRITE); + texImage->Data = st_texture_image_map(ctx->st, stImage, 0, + PIPE_TRANSFER_WRITE, + xoffset, yoffset, + width, height); + + block = stImage->pt->block; + srcBlockStride = pf_get_stride(&block, width); + dstBlockStride = stImage->transfer->stride; + } else { + assert(stImage->pt); + /* TODO find good values for block and strides */ + /* TODO also adjust texImage->data for yoffset/xoffset */ + return; + } + + if (!texImage->Data) { + _mesa_error(ctx, GL_OUT_OF_MEMORY, "glCompressedTexSubImage"); + return; + } + + assert(xoffset % block.width == 0); + assert(yoffset % block.height == 0); + assert(width % block.width == 0); + assert(height % block.height == 0); + + for (y = 0; y < height; y += block.height) { + /* don't need to adjust for xoffset and yoffset as st_texture_image_map does that */ + const char *src = (const char*)data + srcBlockStride * pf_get_nblocksy(&block, y); + char *dst = (char*)texImage->Data + dstBlockStride * pf_get_nblocksy(&block, y); + memcpy(dst, src, pf_get_stride(&block, width)); + } + + if (stImage->pt) { + st_texture_image_unmap(ctx->st, stImage); + texImage->Data = NULL; + } +} + + /** * Do a CopyTexSubImage operation using a read transfer from the source, @@ -1818,6 +1875,7 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexSubImage1D = st_TexSubImage1D; functions->TexSubImage2D = st_TexSubImage2D; functions->TexSubImage3D = st_TexSubImage3D; + functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; functions->CopyTexImage1D = st_CopyTexImage1D; functions->CopyTexImage2D = st_CopyTexImage2D; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; -- cgit v1.2.3 From 578230dbbffbf5317d6002d1023dcd62b57186f5 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Tue, 30 Jun 2009 13:59:45 +0200 Subject: st/gl: Add stubs for CompressedTexSubImage[1D|3D] --- src/mesa/state_tracker/st_cb_texture.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index 5845b7940c..a2211ce302 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -1169,6 +1169,18 @@ st_TexSubImage1D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage1D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLsizei width, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + static void st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, GLint xoffset, GLint yoffset, @@ -1226,6 +1238,19 @@ st_CompressedTexSubImage2D(GLcontext *ctx, GLenum target, GLint level, } +static void +st_CompressedTexSubImage3D(GLcontext *ctx, GLenum target, GLint level, + GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLint height, GLint depth, + GLenum format, + GLsizei imageSize, const GLvoid *data, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage) +{ + assert(0); +} + + /** * Do a CopyTexSubImage operation using a read transfer from the source, @@ -1875,7 +1900,9 @@ st_init_texture_functions(struct dd_function_table *functions) functions->TexSubImage1D = st_TexSubImage1D; functions->TexSubImage2D = st_TexSubImage2D; functions->TexSubImage3D = st_TexSubImage3D; + functions->CompressedTexSubImage1D = st_CompressedTexSubImage1D; functions->CompressedTexSubImage2D = st_CompressedTexSubImage2D; + functions->CompressedTexSubImage3D = st_CompressedTexSubImage3D; functions->CopyTexImage1D = st_CopyTexImage1D; functions->CopyTexImage2D = st_CopyTexImage2D; functions->CopyTexSubImage1D = st_CopyTexSubImage1D; -- cgit v1.2.3 From 2a2236606fd6ae473a2f4db6ef6d3d5030261316 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 2 Jul 2009 17:24:25 +0100 Subject: mesa: Assume depth textures have a single level unless told otherwise. --- src/mesa/state_tracker/st_cb_texture.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/mesa/state_tracker') diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index a2211ce302..0a72784ce0 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -335,7 +335,9 @@ guess_and_alloc_texture(struct st_context *st, * pagetable arrangements. */ if ((stObj->base.MinFilter == GL_NEAREST || - stObj->base.MinFilter == GL_LINEAR) && + stObj->base.MinFilter == GL_LINEAR || + stImage->base._BaseFormat == GL_DEPTH_COMPONENT || + stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT) && stImage->level == firstLevel) { lastLevel = firstLevel; } -- cgit v1.2.3