These are needed when texturing stencil buffers, otherwise they are simply ignored.
Signed-off-by: Topi Pohjolainen <topi.pohjolai...@intel.com> --- src/mesa/drivers/dri/i965/brw_context.h | 12 ++++++++ src/mesa/drivers/dri/i965/intel_tex.c | 49 +++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index b2e5416..0e128aa 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -299,6 +299,17 @@ static inline uint32_t AUB_TRACE_SUBTYPE(enum state_struct_type ss_type) return ss_type & 0xFFFF; } +/** + * Store for texture base dimensions per sampler. These are values backing + * corresponding builtin uniforms needed by the stencil texturing logic for + * manual clamping and mip-level offseting. + * For textures other than stencil these are simply ignored. + */ +struct brw_tex_base_dimensions { + uint32_t base_width[MAX_SAMPLERS]; + uint32_t base_height[MAX_SAMPLERS]; +}; + /** Subclass of Mesa vertex program */ struct brw_vertex_program { struct gl_vertex_program program; @@ -317,6 +328,7 @@ struct brw_geometry_program { struct brw_fragment_program { struct gl_fragment_program program; GLuint id; /**< serial no. to identify frag progs, never re-used */ + struct brw_tex_base_dimensions tex_base_dimensions; }; diff --git a/src/mesa/drivers/dri/i965/intel_tex.c b/src/mesa/drivers/dri/i965/intel_tex.c index f18ca45..0b0c1d5 100644 --- a/src/mesa/drivers/dri/i965/intel_tex.c +++ b/src/mesa/drivers/dri/i965/intel_tex.c @@ -291,6 +291,54 @@ intel_texture_view(struct gl_context *ctx, return GL_TRUE; } +/** + * Store the current texture base dimensions for the designated program. + * In case of stencil textures the compiler has introduced corresponding + * builtin uniforms for which values are loaded from this store when program + * and its buffers are loaded for the gpu. For other types of textures these + * are simply ignored. + */ +static void +intel_tex_parameter(struct gl_context *ctx, struct gl_texture_object *texObj, + GLenum pname, const GLfloat *params) +{ + if (pname != GL_DEPTH_STENCIL_TEXTURE_MODE || + (int)params[0] != GL_STENCIL_INDEX) + return; + + struct gl_shader_program *sh_prog = ctx->_Shader->_CurrentFragmentProgram; + if (!sh_prog) + return; + + struct gl_shader *sh = sh_prog->_LinkedShaders[MESA_SHADER_FRAGMENT]; + if (!sh) + return; + + struct gl_program *prog = sh->Program; + if (!prog) + return; + + GLuint s; + struct brw_fragment_program *fp = brw_fragment_program( + (struct gl_fragment_program *)prog); + + for (s = 0; s < MAX_SAMPLERS; ++s) { + if (!(prog->SamplersUsed & (1 << s))) + continue; + + const unsigned unit = prog->SamplerUnits[s]; + + if (ctx->Texture.Unit[unit]._Current != texObj) + continue; + + struct intel_texture_object *intelObj = intel_texture_object(texObj); + const struct intel_mipmap_tree *mt = intelObj->mt; + + fp->tex_base_dimensions.base_width[s] = mt->logical_width0; + fp->tex_base_dimensions.base_height[s] = mt->logical_height0; + } +} + void intelInitTextureFuncs(struct dd_function_table *functions) { @@ -304,4 +352,5 @@ intelInitTextureFuncs(struct dd_function_table *functions) functions->MapTextureImage = intel_map_texture_image; functions->UnmapTextureImage = intel_unmap_texture_image; functions->TextureView = intel_texture_view; + functions->TexParameter = intel_tex_parameter; } -- 1.8.3.1 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev