diff options
author | Ben Skeggs <skeggsb@gmail.com> | 2008-03-19 22:51:17 +1100 |
---|---|---|
committer | Ben Skeggs <skeggsb@gmail.com> | 2008-03-19 22:51:17 +1100 |
commit | 62767cf2dd1006621ecd6023b15d65b5cff41dfa (patch) | |
tree | fe287d4a281884467531d6ac53a29539f1fcd18a /src/mesa/state_tracker | |
parent | 176df85568992a5d99aab7f0b1e382d41459aa13 (diff) | |
parent | ec890533c2852fa62366d449e6fbc899fb0498be (diff) |
Merge remote branch 'upstream/gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_cb_blit.c | 125 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_blit.h | 46 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_clear.c | 63 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 5 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 17 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_extensions.c | 1 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.c | 226 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_gen_mipmap.h | 2 |
8 files changed, 199 insertions, 286 deletions
diff --git a/src/mesa/state_tracker/st_cb_blit.c b/src/mesa/state_tracker/st_cb_blit.c new file mode 100644 index 0000000000..dfa79c975c --- /dev/null +++ b/src/mesa/state_tracker/st_cb_blit.c @@ -0,0 +1,125 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + /* + * Authors: + * Brian Paul + */ + +#include "main/imports.h" +#include "main/image.h" +#include "main/macros.h" +#include "main/texformat.h" +#include "shader/program.h" +#include "shader/prog_parameter.h" +#include "shader/prog_print.h" + +#include "st_context.h" +#include "st_program.h" +#include "st_cb_drawpixels.h" +#include "st_cb_blit.h" +#include "st_cb_fbo.h" + +#include "util/u_blit.h" + +#include "cso_cache/cso_context.h" + + +void +st_init_blit(struct st_context *st) +{ + st->blit = util_create_blit(st->pipe); +} + + +void +st_destroy_blit(struct st_context *st) +{ + util_destroy_blit(st->blit); + st->blit = NULL; +} + + +static void +st_BlitFramebuffer(GLcontext *ctx, + GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter) +{ + struct st_context *st = ctx->st; + struct pipe_context *pipe = st->pipe; + + const uint pFilter = ((filter == GL_NEAREST) + ? PIPE_TEX_MIPFILTER_NEAREST + : PIPE_TEX_MIPFILTER_LINEAR); + + if (mask & GL_COLOR_BUFFER_BIT) { + struct st_renderbuffer *srcRb = + st_renderbuffer(ctx->ReadBuffer->_ColorReadBuffer); + struct st_renderbuffer *dstRb = + st_renderbuffer(ctx->DrawBuffer->_ColorDrawBuffers[0][0]); + struct pipe_surface *srcSurf = srcRb->surface; + struct pipe_surface *dstSurf = dstRb->surface; + + srcY0 = srcRb->Base.Height - srcY0; + srcY1 = srcRb->Base.Height - srcY1; + + dstY0 = dstRb->Base.Height - dstY0; + dstY1 = dstRb->Base.Height - dstY1; + + util_blit_pixels(st->blit, + srcSurf, srcX0, srcY0, srcX1, srcY1, + dstSurf, dstX0, dstY0, dstX1, dstY1, + 0.0, pFilter); + + } + +#if 0 + /* XXX is this sufficient? */ + st_invalidate_state(ctx, _NEW_COLOR | _NEW_TEXTURE); +#else + /* need to "unset" cso state because we went behind the back of the cso + * tracker. Without unset, the _set_ calls would be no-ops. + */ + cso_unset_blend(st->cso_context); + cso_unset_depth_stencil_alpha(st->cso_context); + cso_unset_rasterizer(st->cso_context); + cso_set_blend(st->cso_context, &st->state.blend); + cso_set_depth_stencil_alpha(st->cso_context, &st->state.depth_stencil); + cso_set_rasterizer(st->cso_context, &st->state.rasterizer); + pipe->bind_fs_state(pipe, st->fp->driver_shader); + pipe->bind_vs_state(pipe, st->vp->driver_shader); +#endif +} + + + +void +st_init_blit_functions(struct dd_function_table *functions) +{ + functions->BlitFramebuffer = st_BlitFramebuffer; +} diff --git a/src/mesa/state_tracker/st_cb_blit.h b/src/mesa/state_tracker/st_cb_blit.h new file mode 100644 index 0000000000..ed22986b53 --- /dev/null +++ b/src/mesa/state_tracker/st_cb_blit.h @@ -0,0 +1,46 @@ +/************************************************************************** + * + * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + +#ifndef ST_CB_BLIT_H +#define ST_CB_BLIT_H + + +#include "st_context.h" + + + +extern void +st_init_blit(struct st_context *st); + +extern void +st_destroy_blit(struct st_context *st); + +extern void +st_init_blit_functions(struct dd_function_table *functions); + + +#endif /* ST_CB_BLIT_H */ diff --git a/src/mesa/state_tracker/st_cb_clear.c b/src/mesa/state_tracker/st_cb_clear.c index 5865071439..693cddedf7 100644 --- a/src/mesa/state_tracker/st_cb_clear.c +++ b/src/mesa/state_tracker/st_cb_clear.c @@ -48,6 +48,7 @@ #include "pipe/p_state.h" #include "pipe/p_defines.h" #include "pipe/p_winsys.h" +#include "util/u_pack_color.h" #include "cso_cache/cso_context.h" @@ -56,55 +57,6 @@ #define TEST_DRAW_PASSTHROUGH 0 -static GLuint -color_value(enum pipe_format pipeFormat, const GLfloat color[4]) -{ - GLubyte r, g, b, a; - - UNCLAMPED_FLOAT_TO_UBYTE(r, color[0]); - UNCLAMPED_FLOAT_TO_UBYTE(g, color[1]); - UNCLAMPED_FLOAT_TO_UBYTE(b, color[2]); - UNCLAMPED_FLOAT_TO_UBYTE(a, color[3]); - - switch (pipeFormat) { - case PIPE_FORMAT_R8G8B8A8_UNORM: - return (r << 24) | (g << 16) | (b << 8) | a; - case PIPE_FORMAT_A8R8G8B8_UNORM: - return (a << 24) | (r << 16) | (g << 8) | b; - case PIPE_FORMAT_B8G8R8A8_UNORM: - return (b << 24) | (g << 16) | (r << 8) | a; - case PIPE_FORMAT_R5G6B5_UNORM: - return ((r & 0xf8) << 8) | ((g & 0xfc) << 3) | (b >> 3); - default: - assert(0); - return 0; - } -} - - -static uint -depth_value(enum pipe_format pipeFormat, GLfloat value) -{ - switch (pipeFormat) { - case PIPE_FORMAT_Z16_UNORM: - return (uint) (value * 0xffff); - case PIPE_FORMAT_Z32_UNORM: - /* special-case to avoid overflow */ - if (value == 1.0) - return 0xffffffff; - else - return (uint) (value * 0xffffffff); - case PIPE_FORMAT_S8Z24_UNORM: - return (uint) (value * 0xffffff); - case PIPE_FORMAT_Z24S8_UNORM: - return ((uint) (value * 0xffffff)) << 8; - default: - assert(0); - return 0; - } -} - - static GLboolean is_depth_stencil_format(enum pipe_format pipeFormat) { @@ -405,6 +357,8 @@ clear_with_quad(GLcontext *ctx, st_invalidate_state(ctx, _NEW_COLOR | _NEW_DEPTH | _NEW_STENCIL); #else /* Restore pipe state */ + cso_set_blend(st->cso_context, &st->state.blend); + cso_set_depth_stencil_alpha(st->cso_context, &st->state.depth_stencil); cso_set_rasterizer(st->cso_context, &st->state.rasterizer); pipe->bind_fs_state(pipe, st->fp->driver_shader); pipe->bind_vs_state(pipe, st->vp->driver_shader); @@ -518,7 +472,6 @@ check_clear_stencil_with_quad(GLcontext *ctx, struct gl_renderbuffer *rb) - static void clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) { @@ -527,10 +480,10 @@ clear_color_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) clear_with_quad(ctx, GL_TRUE, GL_FALSE, GL_FALSE); } else { - struct st_renderbuffer *strb = st_renderbuffer(rb); - /* clear whole buffer w/out masking */ - uint clearValue = color_value(strb->surface->format, ctx->Color.ClearColor); + struct st_renderbuffer *strb = st_renderbuffer(rb); + uint clearValue; + util_pack_color(ctx->Color.ClearColor, strb->surface->format, &clearValue); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); } } @@ -547,7 +500,7 @@ clear_depth_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) struct st_renderbuffer *strb = st_renderbuffer(rb); /* simple clear of whole buffer */ - uint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear); + uint clearValue = util_pack_z(strb->surface->format, ctx->Depth.Clear); ctx->st->pipe->clear(ctx->st->pipe, strb->surface, clearValue); } } @@ -591,7 +544,7 @@ clear_depth_stencil_buffer(GLcontext *ctx, struct gl_renderbuffer *rb) struct st_renderbuffer *strb = st_renderbuffer(rb); /* clear whole buffer w/out masking */ - GLuint clearValue = depth_value(strb->surface->format, ctx->Depth.Clear); + GLuint clearValue = util_pack_z(strb->surface->format, ctx->Depth.Clear); switch (strb->surface->format) { case PIPE_FORMAT_S8Z24_UNORM: diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 5458ab420e..e1fc885e0e 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -36,6 +36,7 @@ #include "st_context.h" #include "st_cb_accum.h" #include "st_cb_bufferobjects.h" +#include "st_cb_blit.h" #include "st_cb_clear.h" #include "st_cb_drawpixels.h" #include "st_cb_fbo.h" @@ -100,6 +101,7 @@ st_create_context_priv( GLcontext *ctx, struct pipe_context *pipe ) st_init_atoms( st ); st_init_draw( st ); st_init_generate_mipmap(st); + st_init_blit(st); for (i = 0; i < PIPE_MAX_SAMPLERS; i++) st->state.sampler_list[i] = &st->state.samplers[i]; @@ -151,6 +153,8 @@ static void st_destroy_context_priv( struct st_context *st ) draw_destroy(st->draw); st_destroy_atoms( st ); st_destroy_draw( st ); + st_destroy_generate_mipmap(st); + st_destroy_blit(st); _vbo_DestroyContext(st->ctx); @@ -217,6 +221,7 @@ void st_init_driver_functions(struct dd_function_table *functions) st_init_accum_functions(functions); st_init_bufferobject_functions(functions); + st_init_blit_functions(functions); st_init_clear_functions(functions); st_init_drawpixels_functions(functions); st_init_fbo_functions(functions); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index e81aebba3d..63150dbeaf 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -40,6 +40,9 @@ struct draw_context; struct draw_stage; struct cso_cache; struct cso_blend; +struct gen_mipmap_state; +struct blit_state; + #define ST_NEW_MESA 0x1 /* Mesa state has changed */ #define ST_NEW_FRAGMENT_PROGRAM 0x2 @@ -146,18 +149,8 @@ struct st_context struct st_fragment_program *combined_prog; } bitmap; - /** For gen/render mipmap feature */ - struct { - struct pipe_blend_state blend; - struct pipe_depth_stencil_alpha_state depthstencil; - struct pipe_rasterizer_state rasterizer; - - void *blend_cso; - void *depthstencil_cso; - void *rasterizer_cso; - struct st_fragment_program *stfp; - struct st_vertex_program *stvp; - } gen_mipmap; + struct gen_mipmap_state *gen_mipmap; + struct blit_state *blit; struct cso_context *cso_context; }; diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 99d2a5fb9e..0962b5f74c 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -143,6 +143,7 @@ void st_init_extensions(struct st_context *st) ctx->Extensions.EXT_blend_logic_op = GL_TRUE; ctx->Extensions.EXT_blend_minmax = GL_TRUE; ctx->Extensions.EXT_blend_subtract = GL_TRUE; + ctx->Extensions.EXT_framebuffer_blit = GL_TRUE; ctx->Extensions.EXT_framebuffer_object = GL_TRUE; ctx->Extensions.EXT_fog_coord = GL_TRUE; ctx->Extensions.EXT_multi_draw_arrays = GL_TRUE; diff --git a/src/mesa/state_tracker/st_gen_mipmap.c b/src/mesa/state_tracker/st_gen_mipmap.c index 9c4e1032ef..6c3afca1ba 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.c +++ b/src/mesa/state_tracker/st_gen_mipmap.c @@ -37,6 +37,8 @@ #include "pipe/p_defines.h" #include "pipe/p_inlines.h" #include "pipe/p_winsys.h" +#include "util/u_gen_mipmap.h" + #include "cso_cache/cso_cache.h" #include "cso_cache/cso_context.h" @@ -49,55 +51,6 @@ #include "st_cb_texture.h" - -static struct st_fragment_program * -make_tex_fragment_program(GLcontext *ctx) -{ - struct st_fragment_program *stfp; - struct gl_program *p; - GLuint ic = 0; - - p = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB, 0); - if (!p) - return NULL; - - p->NumInstructions = 2; - - p->Instructions = _mesa_alloc_instructions(p->NumInstructions); - if (!p->Instructions) { - ctx->Driver.DeleteProgram(ctx, p); - return NULL; - } - _mesa_init_instructions(p->Instructions, p->NumInstructions); - - /* TEX result.color, 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_COLR; - 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++; - - /* END; */ - p->Instructions[ic++].Opcode = OPCODE_END; - - assert(ic == p->NumInstructions); - - p->InputsRead = FRAG_BIT_TEX0; - p->OutputsWritten = (1 << FRAG_RESULT_COLR); - - stfp = (struct st_fragment_program *) p; - - st_translate_fragment_program(ctx->st, stfp, NULL); - - return stfp; -} - - - - /** * one-time init for generate mipmap * XXX Note: there may be other times we need no-op/simple state like this. @@ -106,117 +59,18 @@ make_tex_fragment_program(GLcontext *ctx) void st_init_generate_mipmap(struct st_context *st) { - struct pipe_context *pipe = st->pipe; - struct pipe_blend_state blend; - struct pipe_rasterizer_state rasterizer; - struct pipe_depth_stencil_alpha_state depthstencil; - - /* we don't use blending, but need to set valid values */ - memset(&blend, 0, sizeof(blend)); - blend.rgb_src_factor = PIPE_BLENDFACTOR_ONE; - blend.alpha_src_factor = PIPE_BLENDFACTOR_ONE; - blend.rgb_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.alpha_dst_factor = PIPE_BLENDFACTOR_ZERO; - blend.colormask = PIPE_MASK_RGBA; - st->gen_mipmap.blend = blend; - st->gen_mipmap.blend_cso = pipe->create_blend_state(pipe, &blend); - - memset(&depthstencil, 0, sizeof(depthstencil)); - st->gen_mipmap.depthstencil_cso = pipe->create_depth_stencil_alpha_state(pipe, &depthstencil); - - /* Note: we're assuming zero is valid for all non-specified fields */ - memset(&rasterizer, 0, sizeof(rasterizer)); - rasterizer.front_winding = PIPE_WINDING_CW; - rasterizer.cull_mode = PIPE_WINDING_NONE; - st->gen_mipmap.rasterizer_cso = pipe->create_rasterizer_state(pipe, &rasterizer); - - st->gen_mipmap.stfp = make_tex_fragment_program(st->ctx); - st->gen_mipmap.stvp = st_make_passthrough_vertex_shader(st, GL_FALSE); + st->gen_mipmap = util_create_gen_mipmap(st->pipe); } void -st_destroy_generate_mipmpap(struct st_context *st) -{ - struct pipe_context *pipe = st->pipe; - - pipe->delete_blend_state(pipe, st->gen_mipmap.blend_cso); - pipe->delete_depth_stencil_alpha_state(pipe, st->gen_mipmap.depthstencil_cso); - pipe->delete_rasterizer_state(pipe, st->gen_mipmap.rasterizer_cso); - - /* XXX free stfp, stvp */ -} - - -static void -simple_viewport(struct pipe_context *pipe, uint width, uint height) +st_destroy_generate_mipmap(struct st_context *st) { - struct pipe_viewport_state vp; - - vp.scale[0] = 0.5 * width; - vp.scale[1] = -0.5 * height; - vp.scale[2] = 1.0; - vp.scale[3] = 1.0; - vp.translate[0] = 0.5 * width; - vp.translate[1] = 0.5 * height; - vp.translate[2] = 0.0; - vp.translate[3] = 0.0; - - pipe->set_viewport_state(pipe, &vp); + util_destroy_gen_mipmap(st->gen_mipmap); + st->gen_mipmap = NULL; } - -/* - * Draw simple [-1,1]x[-1,1] quad - */ -static void -draw_quad(GLcontext *ctx) -{ - GLfloat verts[4][2][4]; /* four verts, two attribs, XYZW */ - GLuint i; - GLfloat sLeft = 0.0, sRight = 1.0; - GLfloat tTop = 1.0, tBot = 0.0; - GLfloat x0 = -1.0, x1 = 1.0; - GLfloat y0 = -1.0, y1 = 1.0; - - /* upper-left */ - verts[0][0][0] = x0; /* attr[0].x */ - verts[0][0][1] = y0; /* attr[0].y */ - verts[0][1][0] = sLeft; /* attr[1].s */ - verts[0][1][1] = tTop; /* attr[1].t */ - - /* upper-right */ - verts[1][0][0] = x1; - verts[1][0][1] = y0; - verts[1][1][0] = sRight; - verts[1][1][1] = tTop; - - /* lower-right */ - verts[2][0][0] = x1; - verts[2][0][1] = y1; - verts[2][1][0] = sRight; - verts[2][1][1] = tBot; - - /* lower-left */ - verts[3][0][0] = x0; - verts[3][0][1] = y1; - verts[3][1][0] = sLeft; - verts[3][1][1] = tBot; - - /* same for all verts: */ - for (i = 0; i < 4; i++) { - verts[i][0][2] = 0.0; /*Z*/ - verts[i][0][3] = 1.0; /*W*/ - verts[i][1][2] = 0.0; /*R*/ - verts[i][1][3] = 1.0; /*Q*/ - } - - st_draw_vertices(ctx, PIPE_PRIM_QUADS, 4, (float *) verts, 2, GL_TRUE); -} - - - /** * Generate mipmap levels using hardware rendering. * \return TRUE if successful, FALSE if not possible @@ -229,12 +83,7 @@ st_render_mipmap(struct st_context *st, { struct pipe_context *pipe = st->pipe; struct pipe_screen *screen = pipe->screen; - struct pipe_framebuffer_state fb; - struct pipe_sampler_state sampler; - void *sampler_cso; - const uint face = _mesa_tex_target_to_face(target), zslice = 0; - /*const uint first_level_save = pt->first_level;*/ - uint dstLevel; + const uint face = _mesa_tex_target_to_face(target); assert(target != GL_TEXTURE_3D); /* not done yet */ @@ -243,66 +92,7 @@ st_render_mipmap(struct st_context *st, return FALSE; } - /* init framebuffer state */ - memset(&fb, 0, sizeof(fb)); - fb.num_cbufs = 1; - - /* sampler state */ - memset(&sampler, 0, sizeof(sampler)); - sampler.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE; - sampler.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE; - sampler.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE; - sampler.min_mip_filter = PIPE_TEX_MIPFILTER_NONE; - sampler.min_img_filter = PIPE_TEX_FILTER_LINEAR; - sampler.mag_img_filter = PIPE_TEX_FILTER_LINEAR; - sampler.normalized_coords = 1; - - - /* bind state */ - cso_set_blend(st->cso_context, &st->gen_mipmap.blend); - cso_set_depth_stencil_alpha(st->cso_context, &st->gen_mipmap.depthstencil); - cso_set_rasterizer(st->cso_context, &st->gen_mipmap.rasterizer); - - /* bind shaders */ - pipe->bind_fs_state(pipe, st->gen_mipmap.stfp->driver_shader); - pipe->bind_vs_state(pipe, st->gen_mipmap.stvp->driver_shader); - - /* - * XXX for small mipmap levels, it may be faster to use the software - * fallback path... - */ - for (dstLevel = baseLevel + 1; dstLevel <= lastLevel; dstLevel++) { - const uint srcLevel = dstLevel - 1; - - /* - * Setup framebuffer / dest surface - */ - fb.cbufs[0] = screen->get_tex_surface(screen, pt, face, dstLevel, zslice); - pipe->set_framebuffer_state(pipe, &fb); - - /* - * Setup sampler state - */ - sampler.min_lod = sampler.max_lod = srcLevel; - sampler_cso = pipe->create_sampler_state(pipe, &sampler); - pipe->bind_sampler_states(pipe, 1, &sampler_cso); - - simple_viewport(pipe, pt->width[dstLevel], pt->height[dstLevel]); - - /* - * Setup src texture, override pt->first_level so we sample from - * the right mipmap level. - */ - /*pt->first_level = srcLevel;*/ - pipe->set_sampler_textures(pipe, 1, &pt); - - draw_quad(st->ctx); - - pipe->delete_sampler_state(pipe, sampler_cso); - } - - /* restore first_level */ - /*pt->first_level = first_level_save;*/ + util_gen_mipmap(st->gen_mipmap, pt, face, baseLevel, lastLevel); /* restore pipe state */ #if 0 diff --git a/src/mesa/state_tracker/st_gen_mipmap.h b/src/mesa/state_tracker/st_gen_mipmap.h index 7668c1e44e..00fbae9302 100644 --- a/src/mesa/state_tracker/st_gen_mipmap.h +++ b/src/mesa/state_tracker/st_gen_mipmap.h @@ -35,7 +35,7 @@ st_init_generate_mipmap(struct st_context *st); extern void -st_destroy_generate_mipmpap(struct st_context *st); +st_destroy_generate_mipmap(struct st_context *st); extern void |