- /* 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_NEAREST;
- 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
- * Note: we should only have to set the min/max LOD clamps to ensure
- * we grab texels from the right mipmap level. But some hardware
- * has trouble with min clamping so we also set the lod_bias to
- * try to work around that.
- */
- sampler.min_lod = sampler.max_lod = srcLevel;
- sampler.lod_bias = 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]);
-
- pipe->set_sampler_textures(pipe, 1, &pt);
-
- draw_quad(st->ctx);
-
- pipe->flush(pipe, PIPE_FLUSH_WAIT);
-
- /*pipe->texture_update(pipe, pt); not really needed */
-
- pipe->delete_sampler_state(pipe, sampler_cso);
- }
-
- /* restore pipe state */
-#if 0
- cso_set_rasterizer(st->cso_context, &st->state.rasterizer);
- cso_set_samplers(st->cso_context, st->state.samplers_list);
- pipe->bind_fs_state(pipe, st->fp->shader_program);
- pipe->bind_vs_state(pipe, st->vp->shader_program);
- pipe->set_sampler_textures(pipe, st->state.num_textures,
- st->state.sampler_texture);
- pipe->set_viewport_state(pipe, &st->state.viewport);
-#else
- /* XXX is this sufficient? */
- st_invalidate_state(st->ctx, _NEW_COLOR | _NEW_TEXTURE);
-#endif