2006-11-01 12:03:11 +00:00
|
|
|
/**************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright 2003 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 INTELCONTEXT_INC
|
|
|
|
#define INTELCONTEXT_INC
|
|
|
|
|
|
|
|
|
2010-12-13 11:02:15 -08:00
|
|
|
#include <stdbool.h>
|
2012-01-12 14:32:50 -08:00
|
|
|
#include <string.h>
|
2008-09-18 15:17:05 -06:00
|
|
|
#include "main/mtypes.h"
|
|
|
|
#include "main/mm.h"
|
2010-08-30 10:40:39 -07:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
/* Evil hack for using libdrm in a c++ compiler. */
|
|
|
|
#define virtual virt
|
|
|
|
#endif
|
|
|
|
|
2008-09-18 15:17:05 -06:00
|
|
|
#include "drm.h"
|
2008-08-24 17:59:10 +10:00
|
|
|
#include "intel_bufmgr.h"
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
#include "intel_screen.h"
|
2007-11-16 16:05:11 -08:00
|
|
|
#include "intel_tex_obj.h"
|
2006-11-01 12:03:11 +00:00
|
|
|
#include "i915_drm.h"
|
2010-08-30 10:40:39 -07:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
#undef virtual
|
|
|
|
#endif
|
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
#include "tnl/t_vertex.h"
|
|
|
|
|
|
|
|
#define TAG(x) intel##x
|
|
|
|
#include "tnl_dd/t_dd_vertex.h"
|
|
|
|
#undef TAG
|
|
|
|
|
|
|
|
#define DV_PF_555 (1<<8)
|
|
|
|
#define DV_PF_565 (2<<8)
|
|
|
|
#define DV_PF_8888 (3<<8)
|
2009-04-09 18:30:12 -07:00
|
|
|
#define DV_PF_4444 (8<<8)
|
|
|
|
#define DV_PF_1555 (9<<8)
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
struct intel_region;
|
|
|
|
struct intel_context;
|
|
|
|
|
|
|
|
typedef void (*intel_tri_func) (struct intel_context *, intelVertex *,
|
|
|
|
intelVertex *, intelVertex *);
|
|
|
|
typedef void (*intel_line_func) (struct intel_context *, intelVertex *,
|
|
|
|
intelVertex *);
|
|
|
|
typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
|
|
|
|
|
2009-10-22 16:33:36 -06:00
|
|
|
/**
|
|
|
|
* Bits for intel->Fallback field
|
|
|
|
*/
|
|
|
|
/*@{*/
|
2006-11-01 12:03:11 +00:00
|
|
|
#define INTEL_FALLBACK_DRAW_BUFFER 0x1
|
|
|
|
#define INTEL_FALLBACK_READ_BUFFER 0x2
|
|
|
|
#define INTEL_FALLBACK_DEPTH_BUFFER 0x4
|
|
|
|
#define INTEL_FALLBACK_STENCIL_BUFFER 0x8
|
|
|
|
#define INTEL_FALLBACK_USER 0x10
|
|
|
|
#define INTEL_FALLBACK_RENDERMODE 0x20
|
2008-02-22 00:51:52 -05:00
|
|
|
#define INTEL_FALLBACK_TEXTURE 0x40
|
2009-10-22 16:45:03 -06:00
|
|
|
#define INTEL_FALLBACK_DRIVER 0x1000 /**< first for drivers */
|
2009-10-22 16:33:36 -06:00
|
|
|
/*@}*/
|
2006-11-01 12:03:11 +00:00
|
|
|
|
2009-10-22 16:33:36 -06:00
|
|
|
extern void intelFallback(struct intel_context *intel, GLbitfield bit,
|
2011-10-07 12:26:50 -07:00
|
|
|
bool mode);
|
2006-11-01 12:03:11 +00:00
|
|
|
#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
|
|
|
|
|
|
|
|
|
|
|
|
#define INTEL_WRITE_PART 0x1
|
|
|
|
#define INTEL_WRITE_FULL 0x2
|
|
|
|
#define INTEL_READ 0x4
|
|
|
|
|
|
|
|
#define INTEL_MAX_FIXUP 64
|
|
|
|
|
2010-11-02 19:55:07 -07:00
|
|
|
#ifndef likely
|
|
|
|
#ifdef __GNUC__
|
|
|
|
#define likely(expr) (__builtin_expect(expr, 1))
|
|
|
|
#define unlikely(expr) (__builtin_expect(expr, 0))
|
|
|
|
#else
|
|
|
|
#define likely(expr) (expr)
|
|
|
|
#define unlikely(expr) (expr)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2009-09-01 12:20:10 -07:00
|
|
|
struct intel_sync_object {
|
|
|
|
struct gl_sync_object Base;
|
|
|
|
|
|
|
|
/** Batch associated with this sync object */
|
|
|
|
drm_intel_bo *bo;
|
|
|
|
};
|
2009-08-06 11:40:06 -06:00
|
|
|
|
2011-11-01 14:30:26 -07:00
|
|
|
struct brw_context;
|
|
|
|
|
2012-04-29 21:46:47 -07:00
|
|
|
struct intel_batchbuffer {
|
|
|
|
/** Current batchbuffer being queued up. */
|
|
|
|
drm_intel_bo *bo;
|
|
|
|
/** Last BO submitted to the hardware. Used for glFinish(). */
|
|
|
|
drm_intel_bo *last_bo;
|
|
|
|
/** BO for post-sync nonzero writes for gen6 workaround. */
|
|
|
|
drm_intel_bo *workaround_bo;
|
|
|
|
bool need_workaround_flush;
|
|
|
|
|
|
|
|
struct cached_batch_item *cached_items;
|
|
|
|
|
|
|
|
uint16_t emit, total;
|
|
|
|
uint16_t used, reserved_space;
|
2013-01-18 18:18:57 -08:00
|
|
|
uint32_t *map;
|
|
|
|
uint32_t *cpu_map;
|
2012-04-29 21:46:47 -07:00
|
|
|
#define BATCH_SZ (8192*sizeof(uint32_t))
|
|
|
|
|
|
|
|
uint32_t state_batch_offset;
|
|
|
|
bool is_blit;
|
|
|
|
bool needs_sol_reset;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint16_t used;
|
|
|
|
int reloc_count;
|
|
|
|
} saved;
|
|
|
|
};
|
|
|
|
|
2009-08-06 11:40:06 -06:00
|
|
|
/**
|
2010-10-12 12:26:10 -04:00
|
|
|
* intel_context is derived from Mesa's context class: struct gl_context.
|
2009-08-06 11:40:06 -06:00
|
|
|
*/
|
2006-11-01 12:03:11 +00:00
|
|
|
struct intel_context
|
|
|
|
{
|
2010-10-12 12:26:10 -04:00
|
|
|
struct gl_context ctx; /**< base class, must be first field */
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
void (*destroy) (struct intel_context * intel);
|
|
|
|
void (*emit_state) (struct intel_context * intel);
|
2008-08-24 17:59:10 +10:00
|
|
|
void (*finish_batch) (struct intel_context * intel);
|
2008-01-09 13:40:40 -08:00
|
|
|
void (*new_batch) (struct intel_context * intel);
|
2008-02-22 00:51:52 -05:00
|
|
|
void (*emit_invarient_state) (struct intel_context * intel);
|
2006-11-01 12:03:11 +00:00
|
|
|
void (*update_texture_state) (struct intel_context * intel);
|
|
|
|
|
|
|
|
void (*render_start) (struct intel_context * intel);
|
2007-07-29 18:04:28 +02:00
|
|
|
void (*render_prevalidate) (struct intel_context * intel);
|
2006-11-01 12:03:11 +00:00
|
|
|
void (*set_draw_region) (struct intel_context * intel,
|
2008-03-13 14:46:38 +08:00
|
|
|
struct intel_region * draw_regions[],
|
|
|
|
struct intel_region * depth_region,
|
|
|
|
GLuint num_regions);
|
2011-07-12 09:43:22 -07:00
|
|
|
void (*update_draw_buffer)(struct intel_context *intel);
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
void (*reduced_primitive_state) (struct intel_context * intel,
|
|
|
|
GLenum rprim);
|
|
|
|
|
2011-10-07 12:26:50 -07:00
|
|
|
bool (*check_vertex_size) (struct intel_context * intel,
|
2008-02-22 00:51:52 -05:00
|
|
|
GLuint expected);
|
|
|
|
void (*invalidate_state) (struct intel_context *intel,
|
|
|
|
GLuint new_state);
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
void (*assert_not_dirty) (struct intel_context *intel);
|
|
|
|
|
2007-12-07 16:15:49 -08:00
|
|
|
void (*debug_batch)(struct intel_context *intel);
|
2012-05-07 14:37:00 -07:00
|
|
|
void (*annotate_aub)(struct intel_context *intel);
|
2011-11-15 11:43:40 -08:00
|
|
|
bool (*render_target_supported)(struct intel_context *intel,
|
2012-01-19 17:23:25 -08:00
|
|
|
struct gl_renderbuffer *rb);
|
2011-05-23 13:47:57 -07:00
|
|
|
|
|
|
|
/** Can HiZ be enabled on a depthbuffer of the given format? */
|
|
|
|
bool (*is_hiz_depth_format)(struct intel_context *intel,
|
|
|
|
gl_format format);
|
2011-09-20 13:43:17 -07:00
|
|
|
|
2011-11-01 14:30:26 -07:00
|
|
|
/**
|
|
|
|
* Surface state operations (i965+ only)
|
|
|
|
* \{
|
|
|
|
*/
|
2012-08-14 15:45:52 -07:00
|
|
|
void (*update_texture_surface)(struct gl_context *ctx,
|
|
|
|
unsigned unit,
|
|
|
|
uint32_t *binding_table,
|
|
|
|
unsigned surf_index);
|
2011-11-01 14:30:26 -07:00
|
|
|
void (*update_renderbuffer_surface)(struct brw_context *brw,
|
|
|
|
struct gl_renderbuffer *rb,
|
|
|
|
unsigned unit);
|
|
|
|
void (*update_null_renderbuffer_surface)(struct brw_context *brw,
|
|
|
|
unsigned unit);
|
|
|
|
void (*create_constant_surface)(struct brw_context *brw,
|
|
|
|
drm_intel_bo *bo,
|
2012-06-20 13:03:04 -07:00
|
|
|
uint32_t offset,
|
2011-11-01 14:30:26 -07:00
|
|
|
int width,
|
|
|
|
uint32_t *out_offset);
|
|
|
|
/** \} */
|
2006-11-01 12:03:11 +00:00
|
|
|
} vtbl;
|
|
|
|
|
2009-10-22 16:33:36 -06:00
|
|
|
GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */
|
2006-11-01 12:03:11 +00:00
|
|
|
GLuint NewGLState;
|
|
|
|
|
2007-12-12 10:25:19 -08:00
|
|
|
dri_bufmgr *bufmgr;
|
|
|
|
unsigned int maxBatchSize;
|
|
|
|
|
2009-10-26 09:28:32 -07:00
|
|
|
/**
|
|
|
|
* Generation number of the hardware: 2 is 8xx, 3 is 9xx pre-965, 4 is 965.
|
|
|
|
*/
|
|
|
|
int gen;
|
2011-09-24 01:10:04 -07:00
|
|
|
int gt;
|
2011-10-07 12:26:50 -07:00
|
|
|
bool needs_ff_sync;
|
2011-08-12 18:22:48 -07:00
|
|
|
bool is_haswell;
|
2011-10-07 12:26:50 -07:00
|
|
|
bool is_g4x;
|
|
|
|
bool is_945;
|
|
|
|
bool has_separate_stencil;
|
|
|
|
bool must_use_separate_stencil;
|
|
|
|
bool has_hiz;
|
2012-02-01 18:06:53 -02:00
|
|
|
bool has_llc;
|
2012-03-02 21:38:44 +01:00
|
|
|
bool has_swizzling;
|
2009-12-16 15:22:26 -08:00
|
|
|
|
|
|
|
int urb_size;
|
2009-10-26 09:28:32 -07:00
|
|
|
|
2012-06-12 12:07:09 -07:00
|
|
|
drm_intel_context *hw_ctx;
|
|
|
|
|
2012-04-29 21:46:47 -07:00
|
|
|
struct intel_batchbuffer batch;
|
2011-02-10 20:25:51 +00:00
|
|
|
|
2011-04-25 10:36:29 -07:00
|
|
|
drm_intel_bo *first_post_swapbuffers_batch;
|
2011-10-07 12:26:50 -07:00
|
|
|
bool need_throttle;
|
|
|
|
bool no_batch_wrap;
|
2011-07-11 11:32:04 -07:00
|
|
|
bool tnl_pipeline_running; /**< Set while i915's _tnl_run_pipeline. */
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
GLuint id;
|
2011-02-10 20:25:51 +00:00
|
|
|
uint32_t start_ptr; /**< for i8xx */
|
2008-08-24 17:59:10 +10:00
|
|
|
uint32_t primitive; /**< Current hardware primitive type */
|
2006-11-01 12:03:11 +00:00
|
|
|
void (*flush) (struct intel_context *);
|
2010-06-07 09:52:57 -07:00
|
|
|
drm_intel_bo *vb_bo;
|
2008-08-24 17:59:10 +10:00
|
|
|
uint8_t *vb;
|
|
|
|
unsigned int start_offset; /**< Byte offset of primitive sequence */
|
|
|
|
unsigned int current_offset; /**< Byte offset of next vertex */
|
|
|
|
unsigned int count; /**< Number of vertices in current primitive */
|
2006-11-01 12:03:11 +00:00
|
|
|
} prim;
|
|
|
|
|
2011-02-08 20:01:10 +00:00
|
|
|
struct {
|
|
|
|
drm_intel_bo *bo;
|
|
|
|
GLuint offset;
|
2011-02-21 20:56:06 +00:00
|
|
|
uint32_t buffer_len;
|
|
|
|
uint32_t buffer_offset;
|
2011-02-10 00:25:17 +00:00
|
|
|
char buffer[4096];
|
2011-02-08 20:01:10 +00:00
|
|
|
} upload;
|
|
|
|
|
2008-02-22 00:51:52 -05:00
|
|
|
GLuint stats_wm;
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
/* Offsets of fields within the current vertex:
|
|
|
|
*/
|
|
|
|
GLuint coloroffset;
|
|
|
|
GLuint specoffset;
|
|
|
|
GLuint wpos_offset;
|
|
|
|
|
|
|
|
struct tnl_attr_map vertex_attrs[VERT_ATTRIB_MAX];
|
|
|
|
GLuint vertex_attr_count;
|
|
|
|
|
|
|
|
GLfloat polygon_offset_scale; /* dependent on depth_scale, bpp */
|
|
|
|
|
2011-10-07 12:26:50 -07:00
|
|
|
bool hw_stencil;
|
|
|
|
bool hw_stipple;
|
|
|
|
bool no_rast;
|
|
|
|
bool always_flush_batch;
|
|
|
|
bool always_flush_cache;
|
2009-03-04 16:48:51 -07:00
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
/* State for intelvb.c and inteltris.c.
|
|
|
|
*/
|
|
|
|
GLuint RenderIndex;
|
|
|
|
GLmatrix ViewportMatrix;
|
|
|
|
GLenum render_primitive;
|
2011-09-26 15:48:54 -07:00
|
|
|
GLenum reduced_primitive; /*< Only gen < 6 */
|
2006-11-01 12:03:11 +00:00
|
|
|
GLuint vertex_size;
|
|
|
|
GLubyte *verts; /* points to tnl->clipspace.vertex_buf */
|
|
|
|
|
|
|
|
/* Fallback rasterization functions
|
|
|
|
*/
|
|
|
|
intel_point_func draw_point;
|
|
|
|
intel_line_func draw_line;
|
|
|
|
intel_tri_func draw_tri;
|
|
|
|
|
2009-04-06 13:15:54 -07:00
|
|
|
/**
|
|
|
|
* Set if rendering has occured to the drawable's front buffer.
|
|
|
|
*
|
|
|
|
* This is used in the DRI2 case to detect that glFlush should also copy
|
|
|
|
* the contents of the fake front buffer to the real front buffer.
|
|
|
|
*/
|
2011-10-07 12:26:50 -07:00
|
|
|
bool front_buffer_dirty;
|
2009-04-06 13:15:54 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Track whether front-buffer rendering is currently enabled
|
|
|
|
*
|
|
|
|
* A separate flag is used to track this in order to support MRT more
|
|
|
|
* easily.
|
|
|
|
*/
|
2011-10-07 12:26:50 -07:00
|
|
|
bool is_front_buffer_rendering;
|
2009-06-19 22:12:52 -07:00
|
|
|
/**
|
|
|
|
* Track whether front-buffer is the current read target.
|
|
|
|
*
|
|
|
|
* This is closely associated with is_front_buffer_rendering, but may
|
|
|
|
* be set separately. The DRI2 fake front buffer must be referenced
|
|
|
|
* either way.
|
|
|
|
*/
|
2011-10-07 12:26:50 -07:00
|
|
|
bool is_front_buffer_reading;
|
2009-04-06 13:15:54 -07:00
|
|
|
|
2011-10-06 14:18:35 -07:00
|
|
|
/**
|
|
|
|
* Count of intel_regions that are mapped.
|
|
|
|
*
|
|
|
|
* This allows us to assert that no batch buffer is emitted if a
|
|
|
|
* region is mapped.
|
|
|
|
*/
|
|
|
|
int num_mapped_regions;
|
|
|
|
|
2011-10-07 12:26:50 -07:00
|
|
|
bool use_texture_tiling;
|
|
|
|
bool use_early_z;
|
2008-02-22 00:51:52 -05:00
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
int driFd;
|
|
|
|
|
2010-01-01 17:09:12 -05:00
|
|
|
__DRIcontext *driContext;
|
2010-02-11 16:44:21 -05:00
|
|
|
struct intel_screen *intelScreen;
|
2010-10-12 12:26:10 -04:00
|
|
|
void (*saved_viewport)(struct gl_context * ctx,
|
2010-05-11 10:23:34 -04:00
|
|
|
GLint x, GLint y, GLsizei width, GLsizei height);
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Configuration cache
|
|
|
|
*/
|
|
|
|
driOptionCache optionCache;
|
|
|
|
};
|
|
|
|
|
|
|
|
extern char *__progname;
|
|
|
|
|
|
|
|
|
|
|
|
#define SUBPIXEL_X 0.125
|
|
|
|
#define SUBPIXEL_Y 0.125
|
|
|
|
|
intel: Fix ROUND_DOWN_TO macro
Previously the macro would (ALIGN(value - alignment - 1, alignment)).
At the very least, this was missing parenthesis around "alignment -
1". As a result, if value was already aligned, it would be reduced by
alignment. Condisder:
x = ROUND_DOWN_TO(256, 128);
This becomes:
x = ALIGN(256 - 128 - 1, 128);
Or:
x = ALIGN(127, 128);
Which becomes:
x = 128;
This macro is currently only used in brw_state_batch
(brw_state_batch.c). It looks like the original version of this macro
would just use too much space in the batch buffer. It's possible, but
not at all clear to me from the code, that the original behavior is
actually desired.
In any case, this patch does not cause any piglit regressions on my
Ironlake system.
I also think that ALIGN_FLOOR would be a better name for this macro,
but ROUND_DOWN_TO matches rounddown in the Linux kernel.
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Keith Whitwell <keithw@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2011-04-08 16:31:22 -07:00
|
|
|
/**
|
|
|
|
* Align a value down to an alignment value
|
|
|
|
*
|
|
|
|
* If \c value is not already aligned to the requested alignment value, it
|
|
|
|
* will be rounded down.
|
|
|
|
*
|
|
|
|
* \param value Value to be rounded
|
|
|
|
* \param alignment Alignment value to be used. This must be a power of two.
|
|
|
|
*
|
|
|
|
* \sa ALIGN()
|
|
|
|
*/
|
|
|
|
#define ROUND_DOWN_TO(value, alignment) ((value) & ~(alignment - 1))
|
|
|
|
|
2009-04-09 18:30:12 -07:00
|
|
|
#define IS_POWER_OF_TWO(val) (((val) & (val - 1)) == 0)
|
2007-10-04 12:07:25 -07:00
|
|
|
|
2009-12-28 18:46:15 -08:00
|
|
|
static INLINE uint32_t
|
2009-10-29 11:52:28 -07:00
|
|
|
U_FIXED(float value, uint32_t frac_bits)
|
|
|
|
{
|
|
|
|
value *= (1 << frac_bits);
|
|
|
|
return value < 0 ? 0 : value;
|
|
|
|
}
|
|
|
|
|
2009-12-28 18:46:15 -08:00
|
|
|
static INLINE uint32_t
|
2009-10-29 11:52:28 -07:00
|
|
|
S_FIXED(float value, uint32_t frac_bits)
|
|
|
|
{
|
|
|
|
return value * (1 << frac_bits);
|
|
|
|
}
|
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
#define INTEL_FIREVERTICES(intel) \
|
|
|
|
do { \
|
|
|
|
if ((intel)->prim.flush) \
|
|
|
|
(intel)->prim.flush(intel); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* From linux kernel i386 header files, copes with odd sizes better
|
|
|
|
* than COPY_DWORDS would:
|
|
|
|
* XXX Put this in src/mesa/main/imports.h ???
|
|
|
|
*/
|
|
|
|
#if defined(i386) || defined(__i386__)
|
2008-06-21 10:52:40 -06:00
|
|
|
static INLINE void * __memcpy(void * to, const void * from, size_t n)
|
2006-11-01 12:03:11 +00:00
|
|
|
{
|
|
|
|
int d0, d1, d2;
|
2008-02-22 00:51:52 -05:00
|
|
|
__asm__ __volatile__(
|
|
|
|
"rep ; movsl\n\t"
|
|
|
|
"testb $2,%b4\n\t"
|
|
|
|
"je 1f\n\t"
|
|
|
|
"movsw\n"
|
|
|
|
"1:\ttestb $1,%b4\n\t"
|
|
|
|
"je 2f\n\t"
|
|
|
|
"movsb\n"
|
|
|
|
"2:"
|
|
|
|
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
|
|
|
|
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
|
|
|
|
: "memory");
|
2006-11-01 12:03:11 +00:00
|
|
|
return (to);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define __memcpy(a,b,c) memcpy(a,b,c)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* Debugging:
|
|
|
|
*/
|
|
|
|
extern int INTEL_DEBUG;
|
|
|
|
|
|
|
|
#define DEBUG_TEXTURE 0x1
|
|
|
|
#define DEBUG_STATE 0x2
|
|
|
|
#define DEBUG_IOCTL 0x4
|
|
|
|
#define DEBUG_BLIT 0x8
|
|
|
|
#define DEBUG_MIPTREE 0x10
|
2012-07-12 12:35:19 -07:00
|
|
|
#define DEBUG_PERF 0x20
|
2006-11-01 12:03:11 +00:00
|
|
|
#define DEBUG_VERBOSE 0x40
|
|
|
|
#define DEBUG_BATCH 0x80
|
|
|
|
#define DEBUG_PIXEL 0x100
|
|
|
|
#define DEBUG_BUFMGR 0x200
|
|
|
|
#define DEBUG_REGION 0x400
|
|
|
|
#define DEBUG_FBO 0x800
|
2010-05-14 10:04:41 -07:00
|
|
|
#define DEBUG_GS 0x1000
|
2007-11-16 14:56:26 -08:00
|
|
|
#define DEBUG_SYNC 0x2000
|
2008-02-22 00:51:52 -05:00
|
|
|
#define DEBUG_PRIMS 0x4000
|
|
|
|
#define DEBUG_VERTS 0x8000
|
|
|
|
#define DEBUG_DRI 0x10000
|
2010-05-17 16:48:16 -07:00
|
|
|
#define DEBUG_SF 0x20000
|
2008-02-22 00:51:52 -05:00
|
|
|
#define DEBUG_SANITY 0x40000
|
|
|
|
#define DEBUG_SLEEP 0x80000
|
|
|
|
#define DEBUG_STATS 0x100000
|
|
|
|
#define DEBUG_TILE 0x200000
|
2011-10-23 21:42:27 -07:00
|
|
|
#define DEBUG_WM 0x400000
|
|
|
|
#define DEBUG_URB 0x800000
|
|
|
|
#define DEBUG_VS 0x1000000
|
|
|
|
#define DEBUG_CLIP 0x2000000
|
2012-03-06 15:31:42 -08:00
|
|
|
#define DEBUG_AUB 0x4000000
|
2012-11-27 14:10:52 -08:00
|
|
|
#define DEBUG_SHADER_TIME 0x8000000
|
2013-01-11 14:08:05 -08:00
|
|
|
#define DEBUG_NO16 0x20000000
|
2008-02-22 00:51:52 -05:00
|
|
|
|
2012-09-25 17:47:45 +03:00
|
|
|
#ifdef HAVE_ANDROID_PLATFORM
|
|
|
|
#define LOG_TAG "INTEL-MESA"
|
|
|
|
#include <cutils/log.h>
|
|
|
|
#ifndef ALOGW
|
|
|
|
#define ALOGW LOGW
|
|
|
|
#endif
|
|
|
|
#define dbg_printf(...) ALOGW(__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define dbg_printf(...) printf(__VA_ARGS__)
|
|
|
|
#endif /* HAVE_ANDROID_PLATFORM */
|
|
|
|
|
2008-02-22 00:51:52 -05:00
|
|
|
#define DBG(...) do { \
|
2010-11-02 19:55:07 -07:00
|
|
|
if (unlikely(INTEL_DEBUG & FILE_DEBUG_FLAG)) \
|
2012-09-25 17:47:45 +03:00
|
|
|
dbg_printf(__VA_ARGS__); \
|
2008-02-22 00:51:52 -05:00
|
|
|
} while(0)
|
2006-11-01 12:03:11 +00:00
|
|
|
|
2012-07-12 12:48:58 -07:00
|
|
|
#define perf_debug(...) do { \
|
|
|
|
if (unlikely(INTEL_DEBUG & DEBUG_PERF)) \
|
2012-09-25 17:47:45 +03:00
|
|
|
dbg_printf(__VA_ARGS__); \
|
2012-07-12 12:48:58 -07:00
|
|
|
} while(0)
|
|
|
|
|
2012-10-12 12:41:56 -07:00
|
|
|
#define WARN_ONCE(cond, fmt...) do { \
|
|
|
|
if (unlikely(cond)) { \
|
|
|
|
static bool _warned = false; \
|
2013-02-22 13:03:51 -08:00
|
|
|
static GLuint msg_id = 0; \
|
2012-10-12 12:41:56 -07:00
|
|
|
if (!_warned) { \
|
|
|
|
fprintf(stderr, "WARNING: "); \
|
|
|
|
fprintf(stderr, fmt); \
|
|
|
|
_warned = true; \
|
2013-02-22 13:03:51 -08:00
|
|
|
\
|
|
|
|
_mesa_gl_debug(ctx, &msg_id, \
|
|
|
|
MESA_DEBUG_TYPE_OTHER, \
|
|
|
|
MESA_DEBUG_SEVERITY_HIGH, fmt); \
|
2012-10-12 12:41:56 -07:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
#define PCI_CHIP_845_G 0x2562
|
|
|
|
#define PCI_CHIP_I830_M 0x3577
|
|
|
|
#define PCI_CHIP_I855_GM 0x3582
|
|
|
|
#define PCI_CHIP_I865_G 0x2572
|
|
|
|
#define PCI_CHIP_I915_G 0x2582
|
|
|
|
#define PCI_CHIP_I915_GM 0x2592
|
|
|
|
#define PCI_CHIP_I945_G 0x2772
|
|
|
|
#define PCI_CHIP_I945_GM 0x27A2
|
2007-05-30 16:18:26 +08:00
|
|
|
#define PCI_CHIP_I945_GME 0x27AE
|
2007-06-05 11:42:43 -07:00
|
|
|
#define PCI_CHIP_G33_G 0x29C2
|
|
|
|
#define PCI_CHIP_Q35_G 0x29B2
|
|
|
|
#define PCI_CHIP_Q33_G 0x29D2
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* intel_context.c:
|
|
|
|
*/
|
|
|
|
|
2011-10-07 12:26:50 -07:00
|
|
|
extern bool intelInitContext(struct intel_context *intel,
|
2012-11-21 16:22:19 -08:00
|
|
|
int api,
|
|
|
|
unsigned major_version,
|
|
|
|
unsigned minor_version,
|
|
|
|
const struct gl_config * mesaVis,
|
|
|
|
__DRIcontext * driContextPriv,
|
|
|
|
void *sharedContextPrivate,
|
|
|
|
struct dd_function_table *functions,
|
|
|
|
unsigned *dri_ctx_error);
|
2006-11-01 12:03:11 +00:00
|
|
|
|
2010-10-12 12:26:10 -04:00
|
|
|
extern void intelFinish(struct gl_context * ctx);
|
2011-10-19 10:39:15 -07:00
|
|
|
extern void intel_flush_rendering_to_batch(struct gl_context *ctx);
|
2011-12-16 13:42:39 -08:00
|
|
|
extern void _intel_flush(struct gl_context * ctx, const char *file, int line);
|
|
|
|
|
|
|
|
#define intel_flush(ctx) _intel_flush(ctx, __FILE__, __LINE__)
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
extern void intelInitDriverFunctions(struct dd_function_table *functions);
|
|
|
|
|
2009-09-01 12:20:10 -07:00
|
|
|
void intel_init_syncobj_functions(struct dd_function_table *functions);
|
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
|
|
|
|
/* ================================================================
|
|
|
|
* intel_state.c:
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define COMPAREFUNC_ALWAYS 0
|
|
|
|
#define COMPAREFUNC_NEVER 0x1
|
|
|
|
#define COMPAREFUNC_LESS 0x2
|
|
|
|
#define COMPAREFUNC_EQUAL 0x3
|
|
|
|
#define COMPAREFUNC_LEQUAL 0x4
|
|
|
|
#define COMPAREFUNC_GREATER 0x5
|
|
|
|
#define COMPAREFUNC_NOTEQUAL 0x6
|
|
|
|
#define COMPAREFUNC_GEQUAL 0x7
|
|
|
|
|
|
|
|
#define STENCILOP_KEEP 0
|
|
|
|
#define STENCILOP_ZERO 0x1
|
|
|
|
#define STENCILOP_REPLACE 0x2
|
|
|
|
#define STENCILOP_INCRSAT 0x3
|
|
|
|
#define STENCILOP_DECRSAT 0x4
|
|
|
|
#define STENCILOP_INCR 0x5
|
|
|
|
#define STENCILOP_DECR 0x6
|
|
|
|
#define STENCILOP_INVERT 0x7
|
|
|
|
|
|
|
|
#define LOGICOP_CLEAR 0
|
|
|
|
#define LOGICOP_NOR 0x1
|
|
|
|
#define LOGICOP_AND_INV 0x2
|
|
|
|
#define LOGICOP_COPY_INV 0x3
|
|
|
|
#define LOGICOP_AND_RVRSE 0x4
|
|
|
|
#define LOGICOP_INV 0x5
|
|
|
|
#define LOGICOP_XOR 0x6
|
|
|
|
#define LOGICOP_NAND 0x7
|
|
|
|
#define LOGICOP_AND 0x8
|
|
|
|
#define LOGICOP_EQUIV 0x9
|
|
|
|
#define LOGICOP_NOOP 0xa
|
|
|
|
#define LOGICOP_OR_INV 0xb
|
|
|
|
#define LOGICOP_COPY 0xc
|
|
|
|
#define LOGICOP_OR_RVRSE 0xd
|
|
|
|
#define LOGICOP_OR 0xe
|
|
|
|
#define LOGICOP_SET 0xf
|
|
|
|
|
|
|
|
#define BLENDFACT_ZERO 0x01
|
|
|
|
#define BLENDFACT_ONE 0x02
|
|
|
|
#define BLENDFACT_SRC_COLR 0x03
|
|
|
|
#define BLENDFACT_INV_SRC_COLR 0x04
|
|
|
|
#define BLENDFACT_SRC_ALPHA 0x05
|
|
|
|
#define BLENDFACT_INV_SRC_ALPHA 0x06
|
|
|
|
#define BLENDFACT_DST_ALPHA 0x07
|
|
|
|
#define BLENDFACT_INV_DST_ALPHA 0x08
|
|
|
|
#define BLENDFACT_DST_COLR 0x09
|
|
|
|
#define BLENDFACT_INV_DST_COLR 0x0a
|
|
|
|
#define BLENDFACT_SRC_ALPHA_SATURATE 0x0b
|
|
|
|
#define BLENDFACT_CONST_COLOR 0x0c
|
|
|
|
#define BLENDFACT_INV_CONST_COLOR 0x0d
|
|
|
|
#define BLENDFACT_CONST_ALPHA 0x0e
|
|
|
|
#define BLENDFACT_INV_CONST_ALPHA 0x0f
|
|
|
|
#define BLENDFACT_MASK 0x0f
|
|
|
|
|
2008-03-05 14:14:54 -08:00
|
|
|
enum {
|
|
|
|
DRI_CONF_BO_REUSE_DISABLED,
|
|
|
|
DRI_CONF_BO_REUSE_ALL
|
|
|
|
};
|
|
|
|
|
2007-12-25 17:22:19 +08:00
|
|
|
extern int intel_translate_shadow_compare_func(GLenum func);
|
2006-11-01 12:03:11 +00:00
|
|
|
extern int intel_translate_compare_func(GLenum func);
|
|
|
|
extern int intel_translate_stencil_op(GLenum op);
|
|
|
|
extern int intel_translate_blend_factor(GLenum factor);
|
|
|
|
extern int intel_translate_logic_op(GLenum opcode);
|
|
|
|
|
2008-09-03 16:13:18 +01:00
|
|
|
void intel_update_renderbuffers(__DRIcontext *context,
|
|
|
|
__DRIdrawable *drawable);
|
2010-02-17 21:17:55 -05:00
|
|
|
void intel_prepare_render(struct intel_context *intel);
|
2006-11-01 12:03:11 +00:00
|
|
|
|
2012-08-09 09:15:36 -07:00
|
|
|
void
|
|
|
|
intel_downsample_for_dri2_flush(struct intel_context *intel,
|
|
|
|
__DRIdrawable *drawable);
|
|
|
|
|
2009-06-04 10:21:29 +00:00
|
|
|
void i915_set_buf_info_for_region(uint32_t *state, struct intel_region *region,
|
|
|
|
uint32_t buffer_id);
|
2011-11-15 15:57:39 -08:00
|
|
|
void intel_init_texture_formats(struct gl_context *ctx);
|
2009-06-04 10:21:29 +00:00
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
/*======================================================================
|
|
|
|
* Inline conversion functions.
|
|
|
|
* These are better-typed than the macros used previously:
|
|
|
|
*/
|
|
|
|
static INLINE struct intel_context *
|
2010-10-12 12:26:10 -04:00
|
|
|
intel_context(struct gl_context * ctx)
|
2006-11-01 12:03:11 +00:00
|
|
|
{
|
|
|
|
return (struct intel_context *) ctx;
|
|
|
|
}
|
|
|
|
|
2011-10-07 12:26:50 -07:00
|
|
|
static INLINE bool
|
2009-05-26 20:45:29 -07:00
|
|
|
is_power_of_two(uint32_t value)
|
|
|
|
{
|
|
|
|
return (value & (value - 1)) == 0;
|
|
|
|
}
|
|
|
|
|
2012-04-27 07:40:34 -07:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-11-01 12:03:11 +00:00
|
|
|
#endif
|