2009-07-26 23:44:38 +01:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* 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: Keith Whitwell <keith@tungstengraphics.com>
|
|
|
|
*/
|
|
|
|
|
2009-12-10 14:55:28 -07:00
|
|
|
#include "pipe/p_state.h"
|
2010-02-02 14:42:17 +00:00
|
|
|
#include "util/u_inlines.h"
|
2010-05-03 17:08:17 -06:00
|
|
|
#include "util/u_framebuffer.h"
|
2009-12-10 14:55:28 -07:00
|
|
|
#include "util/u_surface.h"
|
2009-07-26 23:44:38 +01:00
|
|
|
#include "lp_context.h"
|
2010-04-02 09:17:47 -06:00
|
|
|
#include "lp_scene.h"
|
2009-07-26 23:44:38 +01:00
|
|
|
#include "lp_state.h"
|
2009-10-09 12:26:49 +01:00
|
|
|
#include "lp_setup.h"
|
2009-07-26 23:44:38 +01:00
|
|
|
|
|
|
|
#include "draw/draw_context.h"
|
|
|
|
|
2009-12-03 11:58:36 +01:00
|
|
|
#include "util/u_format.h"
|
|
|
|
|
2009-07-26 23:44:38 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the framebuffer surface info: color buffers, zbuffer, stencil buffer.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
llvmpipe_set_framebuffer_state(struct pipe_context *pipe,
|
|
|
|
const struct pipe_framebuffer_state *fb)
|
|
|
|
{
|
|
|
|
struct llvmpipe_context *lp = llvmpipe_context(pipe);
|
|
|
|
|
2009-12-11 11:41:11 -07:00
|
|
|
boolean changed = !util_framebuffer_state_equal(&lp->framebuffer, fb);
|
2009-07-26 23:44:38 +01:00
|
|
|
|
2010-04-23 09:10:18 -06:00
|
|
|
assert(fb->width <= LP_MAX_WIDTH);
|
|
|
|
assert(fb->height <= LP_MAX_HEIGHT);
|
2010-04-02 09:17:47 -06:00
|
|
|
|
2009-12-10 14:55:28 -07:00
|
|
|
if (changed) {
|
2009-08-22 23:01:58 +01:00
|
|
|
|
2009-12-10 14:55:28 -07:00
|
|
|
util_copy_framebuffer_state(&lp->framebuffer, fb);
|
2009-07-26 23:44:38 +01:00
|
|
|
|
2010-09-16 10:45:52 +01:00
|
|
|
if (LP_PERF & PERF_NO_DEPTH) {
|
|
|
|
pipe_surface_reference(&lp->framebuffer.zsbuf, NULL);
|
|
|
|
}
|
|
|
|
|
2009-07-25 10:01:06 +01:00
|
|
|
/* Tell draw module how deep the Z/depth buffer is */
|
2013-06-27 19:01:11 +02:00
|
|
|
/* FIXME: mrd constant isn't right should use a value derived from
|
|
|
|
* current primitive not a constant (for float depth buffers) */
|
2009-07-26 23:44:38 +01:00
|
|
|
if (lp->framebuffer.zsbuf) {
|
2009-07-25 10:01:06 +01:00
|
|
|
int depth_bits;
|
|
|
|
double mrd;
|
2009-12-03 11:58:36 +01:00
|
|
|
depth_bits = util_format_get_component_bits(lp->framebuffer.zsbuf->format,
|
|
|
|
UTIL_FORMAT_COLORSPACE_ZS,
|
|
|
|
0);
|
2009-07-25 10:01:06 +01:00
|
|
|
if (depth_bits > 16) {
|
|
|
|
mrd = 0.0000001;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
mrd = 0.00002;
|
|
|
|
}
|
2010-11-04 11:42:55 +00:00
|
|
|
lp->mrd = mrd;
|
2009-07-25 10:01:06 +01:00
|
|
|
draw_set_mrd(lp->draw, mrd);
|
2009-07-26 23:44:38 +01:00
|
|
|
}
|
|
|
|
|
2009-12-17 11:29:37 +00:00
|
|
|
lp_setup_bind_framebuffer( lp->setup, &lp->framebuffer );
|
2009-07-26 23:44:38 +01:00
|
|
|
|
2009-10-08 16:33:12 +01:00
|
|
|
lp->dirty |= LP_NEW_FRAMEBUFFER;
|
|
|
|
}
|
2009-07-26 23:44:38 +01:00
|
|
|
}
|