summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers/dri/intel')
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.c92
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h71
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.c181
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffer_objects.c30
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.c94
-rw-r--r--src/mesa/drivers/dri/intel/intel_buffers.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_clear.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c442
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.h150
-rw-r--r--src/mesa/drivers/dri/intel/intel_depthtmp.h10
-rw-r--r--src/mesa/drivers/dri/intel/intel_extensions.c36
-rw-r--r--src/mesa/drivers/dri/intel/intel_extensions.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c273
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.h30
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.c215
-rw-r--r--src/mesa/drivers/dri/intel/intel_mipmap_tree.h32
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel.c8
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_bitmap.c22
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_copy.c33
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_draw.c4
-rw-r--r--src/mesa/drivers/dri/intel/intel_pixel_read.c13
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.c127
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c549
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.h15
-rw-r--r--src/mesa/drivers/dri/intel/intel_span.c190
-rw-r--r--src/mesa/drivers/dri/intel/intel_spantmp.h10
-rw-r--r--src/mesa/drivers/dri/intel/intel_state.c20
-rw-r--r--src/mesa/drivers/dri/intel/intel_swapbuffers.c248
-rw-r--r--src/mesa/drivers/dri/intel/intel_swapbuffers.h52
-rw-r--r--src/mesa/drivers/dri/intel/intel_syncobj.c2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex.c22
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex.h7
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_copy.c57
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_format.c89
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c170
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_layout.h2
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_obj.h1
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_subimage.c30
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_validate.c67
41 files changed, 993 insertions, 2415 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 6aa36d10b1..3a4b21a844 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -80,7 +80,7 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
batch->buf = NULL;
}
- if (!batch->buffer && intel->ttm == GL_TRUE)
+ if (!batch->buffer)
batch->buffer = malloc (intel->maxBatchSize);
batch->buf = dri_bo_alloc(intel->bufmgr, "batchbuffer",
@@ -94,7 +94,6 @@ intel_batchbuffer_reset(struct intel_batchbuffer *batch)
batch->size = intel->maxBatchSize;
batch->ptr = batch->map;
batch->dirty_state = ~0;
- batch->cliprect_mode = IGNORE_CLIPRECTS;
}
struct intel_batchbuffer *
@@ -129,13 +128,10 @@ intel_batchbuffer_free(struct intel_batchbuffer *batch)
/* TODO: Push this whole function into bufmgr.
*/
static void
-do_flush_locked(struct intel_batchbuffer *batch,
- GLuint used, GLboolean allow_unlock)
+do_flush_locked(struct intel_batchbuffer *batch, GLuint used)
{
struct intel_context *intel = batch->intel;
int ret = 0;
- unsigned int num_cliprects = 0;
- struct drm_clip_rect *cliprects = NULL;
int x_off = 0, y_off = 0;
if (batch->buffer)
@@ -146,31 +142,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
batch->map = NULL;
batch->ptr = NULL;
-
- if (batch->cliprect_mode == LOOP_CLIPRECTS) {
- intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
- }
- /* Dispatch the batchbuffer, if it has some effect (nonzero cliprects).
- * Can't short-circuit like this once we have hardware contexts, but we
- * should always be in DRI2 mode by then anyway.
- */
- if ((batch->cliprect_mode != LOOP_CLIPRECTS ||
- num_cliprects != 0) && !intel->no_hw) {
- dri_bo_exec(batch->buf, used, cliprects, num_cliprects,
- (x_off & 0xffff) | (y_off << 16));
- }
-
- if (batch->cliprect_mode == LOOP_CLIPRECTS && num_cliprects == 0) {
- if (allow_unlock) {
- /* If we are not doing any actual user-visible rendering,
- * do a sched_yield to keep the app from pegging the cpu while
- * achieving nothing.
- */
- UNLOCK_HARDWARE(intel);
- sched_yield();
- LOCK_HARDWARE(intel);
- }
- }
+ dri_bo_exec(batch->buf, used, NULL, 0, (x_off & 0xffff) | (y_off << 16));
if (INTEL_DEBUG & DEBUG_BATCH) {
dri_bo_map(batch->buf, GL_FALSE);
@@ -183,7 +155,6 @@ do_flush_locked(struct intel_batchbuffer *batch,
}
if (ret != 0) {
- UNLOCK_HARDWARE(intel);
exit(1);
}
intel->vtbl.new_batch(intel);
@@ -201,24 +172,17 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
}
- if (intel->first_post_swapbuffers_batch == NULL) {
- intel->first_post_swapbuffers_batch = intel->batch->buf;
- drm_intel_bo_reference(intel->first_post_swapbuffers_batch);
- }
-
- if (used == 0) {
- batch->cliprect_mode = IGNORE_CLIPRECTS;
+ if (used == 0)
return;
- }
if (INTEL_DEBUG & DEBUG_BATCH)
fprintf(stderr, "%s:%d: Batchbuffer flush with %db used\n", file, line,
used);
+ batch->reserved_space = 0;
/* Emit a flush if the bufmgr doesn't do it for us. */
- if (intel->always_flush_cache || !intel->ttm) {
- *(GLuint *) (batch->ptr) = intel->vtbl.flush_cmd();
- batch->ptr += 4;
+ if (intel->always_flush_cache) {
+ intel_batchbuffer_emit_mi_flush(batch);
used = batch->ptr - batch->map;
}
@@ -249,12 +213,15 @@ _intel_batchbuffer_flush(struct intel_batchbuffer *batch, const char *file,
if (intel->vtbl.finish_batch)
intel->vtbl.finish_batch(intel);
+ /* Check that we didn't just wrap our batchbuffer at a bad time. */
+ assert(!intel->no_batch_wrap);
+
+ batch->reserved_space = BATCH_RESERVED;
+
/* TODO: Just pass the relocation list and dma buffer up to the
* kernel.
*/
- LOCK_HARDWARE(intel);
- do_flush_locked(batch, used, GL_FALSE);
- UNLOCK_HARDWARE(intel);
+ do_flush_locked(batch, used);
if (INTEL_DEBUG & DEBUG_SYNC) {
fprintf(stderr, "waiting for idle\n");
@@ -296,11 +263,38 @@ intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
void
intel_batchbuffer_data(struct intel_batchbuffer *batch,
- const void *data, GLuint bytes,
- enum cliprect_mode cliprect_mode)
+ const void *data, GLuint bytes)
{
assert((bytes & 3) == 0);
- intel_batchbuffer_require_space(batch, bytes, cliprect_mode);
+ intel_batchbuffer_require_space(batch, bytes);
__memcpy(batch->ptr, data, bytes);
batch->ptr += bytes;
}
+
+/* Emit a pipelined flush to either flush render and texture cache for
+ * reading from a FBO-drawn texture, or flush so that frontbuffer
+ * render appears on the screen in DRI1.
+ *
+ * This is also used for the always_flush_cache driconf debug option.
+ */
+void
+intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
+{
+ struct intel_context *intel = batch->intel;
+
+ if (intel->gen >= 4) {
+ BEGIN_BATCH(4);
+ OUT_BATCH(_3DSTATE_PIPE_CONTROL |
+ PIPE_CONTROL_INSTRUCTION_FLUSH |
+ PIPE_CONTROL_WRITE_FLUSH |
+ PIPE_CONTROL_NO_WRITE);
+ OUT_BATCH(0); /* write address */
+ OUT_BATCH(0); /* write data */
+ OUT_BATCH(0); /* write data */
+ ADVANCE_BATCH();
+ } else {
+ BEGIN_BATCH(1);
+ OUT_BATCH(MI_FLUSH);
+ ADVANCE_BATCH();
+ }
+}
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index 9a619fbd5c..b052b724d8 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -10,35 +10,6 @@
#define BATCH_SZ 16384
#define BATCH_RESERVED 16
-enum cliprect_mode {
- /**
- * Batchbuffer contents may be looped over per cliprect, but do not
- * require it.
- */
- IGNORE_CLIPRECTS,
- /**
- * Batchbuffer contents require looping over per cliprect at batch submit
- * time.
- *
- * This will be upgraded to NO_LOOP_CLIPRECTS when there's a single
- * constant cliprect, as in DRI2 or FBO rendering.
- */
- LOOP_CLIPRECTS,
- /**
- * Batchbuffer contents contain drawing that should not be executed multiple
- * times.
- */
- NO_LOOP_CLIPRECTS,
- /**
- * Batchbuffer contents contain drawing that already handles cliprects, such
- * as 2D drawing to front/back/depth that doesn't respect DRAWING_RECTANGLE.
- *
- * Equivalent behavior to NO_LOOP_CLIPRECTS, but may not persist in batch
- * outside of LOCK/UNLOCK. This is upgraded to just NO_LOOP_CLIPRECTS when
- * there's a constant cliprect, as in DRI2 or FBO rendering.
- */
- REFERENCES_CLIPRECTS
-};
struct intel_batchbuffer
{
@@ -51,8 +22,6 @@ struct intel_batchbuffer
GLubyte *map;
GLubyte *ptr;
- enum cliprect_mode cliprect_mode;
-
GLuint size;
/** Tracking of BEGIN_BATCH()/OUT_BATCH()/ADVANCE_BATCH() debugging */
@@ -62,6 +31,7 @@ struct intel_batchbuffer
} emit;
GLuint dirty_state;
+ GLuint reserved_space;
};
struct intel_batchbuffer *intel_batchbuffer_alloc(struct intel_context
@@ -84,8 +54,7 @@ void intel_batchbuffer_reset(struct intel_batchbuffer *batch);
* intel_buffer_dword() calls.
*/
void intel_batchbuffer_data(struct intel_batchbuffer *batch,
- const void *data, GLuint bytes,
- enum cliprect_mode cliprect_mode);
+ const void *data, GLuint bytes);
void intel_batchbuffer_release_space(struct intel_batchbuffer *batch,
GLuint bytes);
@@ -95,6 +64,7 @@ GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
uint32_t read_domains,
uint32_t write_domain,
uint32_t offset);
+void intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch);
/* Inline functions - might actually be better off with these
* non-inlined. Certainly better off switching all command packets to
@@ -104,7 +74,7 @@ GLboolean intel_batchbuffer_emit_reloc(struct intel_batchbuffer *batch,
static INLINE GLint
intel_batchbuffer_space(struct intel_batchbuffer *batch)
{
- return (batch->size - BATCH_RESERVED) - (batch->ptr - batch->map);
+ return (batch->size - batch->reserved_space) - (batch->ptr - batch->map);
}
@@ -119,36 +89,19 @@ intel_batchbuffer_emit_dword(struct intel_batchbuffer *batch, GLuint dword)
static INLINE void
intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
- GLuint sz,
- enum cliprect_mode cliprect_mode)
+ GLuint sz)
{
assert(sz < batch->size - 8);
if (intel_batchbuffer_space(batch) < sz)
intel_batchbuffer_flush(batch);
-
- if ((cliprect_mode == LOOP_CLIPRECTS ||
- cliprect_mode == REFERENCES_CLIPRECTS) &&
- batch->intel->constant_cliprect)
- cliprect_mode = NO_LOOP_CLIPRECTS;
-
- if (cliprect_mode != IGNORE_CLIPRECTS) {
- if (batch->cliprect_mode == IGNORE_CLIPRECTS) {
- batch->cliprect_mode = cliprect_mode;
- } else {
- if (batch->cliprect_mode != cliprect_mode) {
- intel_batchbuffer_flush(batch);
- batch->cliprect_mode = cliprect_mode;
- }
- }
- }
}
/* Here are the crusty old macros, to be removed:
*/
#define BATCH_LOCALS
-#define BEGIN_BATCH(n, cliprect_mode) do { \
- intel_batchbuffer_require_space(intel->batch, (n)*4, cliprect_mode); \
+#define BEGIN_BATCH(n) do { \
+ intel_batchbuffer_require_space(intel->batch, (n)*4); \
assert(intel->batch->emit.start_ptr == NULL); \
intel->batch->emit.total = (n) * 4; \
intel->batch->emit.start_ptr = intel->batch->ptr; \
@@ -157,7 +110,7 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
#define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
#define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
- assert((unsigned) (delta) <= buf->size); \
+ assert((unsigned) (delta) < buf->size); \
intel_batchbuffer_emit_reloc(intel->batch, buf, \
read_domains, write_domain, delta); \
} while (0)
@@ -173,12 +126,4 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
intel->batch->emit.start_ptr = NULL; \
} while(0)
-
-static INLINE void
-intel_batchbuffer_emit_mi_flush(struct intel_batchbuffer *batch)
-{
- intel_batchbuffer_require_space(batch, 4, IGNORE_CLIPRECTS);
- intel_batchbuffer_emit_dword(batch, MI_FLUSH);
-}
-
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 9e114db6c7..55bee0084c 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -29,7 +29,6 @@
#include "main/mtypes.h"
#include "main/context.h"
#include "main/enums.h"
-#include "main/texformat.h"
#include "main/colormac.h"
#include "intel_blit.h"
@@ -43,137 +42,6 @@
#define FILE_DEBUG_FLAG DEBUG_BLIT
-/**
- * Copy the back color buffer to the front color buffer.
- * Used for SwapBuffers().
- */
-void
-intelCopyBuffer(const __DRIdrawablePrivate * dPriv,
- const drm_clip_rect_t * rect)
-{
-
- struct intel_context *intel;
- const intelScreenPrivate *intelScreen;
-
- DBG("%s\n", __FUNCTION__);
-
- assert(dPriv);
-
- intel = intelScreenContext(dPriv->driScreenPriv->private);
- if (!intel)
- return;
-
- intelScreen = intel->intelScreen;
-
- /* The LOCK_HARDWARE is required for the cliprects. Buffer offsets
- * should work regardless.
- */
- LOCK_HARDWARE(intel);
-
- if (dPriv && dPriv->numClipRects) {
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
- struct intel_region *src, *dst;
- int nbox = dPriv->numClipRects;
- drm_clip_rect_t *pbox = dPriv->pClipRects;
- int cpp;
- int src_pitch, dst_pitch;
- unsigned short src_x, src_y;
- int BR13, CMD;
- int i;
- dri_bo *aper_array[3];
-
- src = intel_get_rb_region(&intel_fb->Base, BUFFER_BACK_LEFT);
- dst = intel_get_rb_region(&intel_fb->Base, BUFFER_FRONT_LEFT);
-
- src_pitch = src->pitch * src->cpp;
- dst_pitch = dst->pitch * dst->cpp;
-
- cpp = src->cpp;
-
- ASSERT(intel_fb);
- ASSERT(intel_fb->Base.Name == 0); /* Not a user-created FBO */
- ASSERT(src);
- ASSERT(dst);
- ASSERT(src->cpp == dst->cpp);
-
- if (cpp == 2) {
- BR13 = (0xCC << 16) | BR13_565;
- CMD = XY_SRC_COPY_BLT_CMD;
- }
- else {
- BR13 = (0xCC << 16) | BR13_8888;
- CMD = XY_SRC_COPY_BLT_CMD | XY_BLT_WRITE_ALPHA | XY_BLT_WRITE_RGB;
- }
-
- assert(src->tiling != I915_TILING_Y);
- assert(dst->tiling != I915_TILING_Y);
-#ifndef I915
- if (src->tiling != I915_TILING_NONE) {
- CMD |= XY_SRC_TILED;
- src_pitch /= 4;
- }
- if (dst->tiling != I915_TILING_NONE) {
- CMD |= XY_DST_TILED;
- dst_pitch /= 4;
- }
-#endif
- /* do space/cliprects check before going any further */
- intel_batchbuffer_require_space(intel->batch, 8 * 4,
- REFERENCES_CLIPRECTS);
- again:
- aper_array[0] = intel->batch->buf;
- aper_array[1] = dst->buffer;
- aper_array[2] = src->buffer;
-
- if (dri_bufmgr_check_aperture_space(aper_array, 3) != 0) {
- intel_batchbuffer_flush(intel->batch);
- goto again;
- }
-
- for (i = 0; i < nbox; i++, pbox++) {
- drm_clip_rect_t box = *pbox;
-
- if (rect) {
- if (!intel_intersect_cliprects(&box, &box, rect))
- continue;
- }
-
- if (box.x1 >= box.x2 ||
- box.y1 >= box.y2)
- continue;
-
- assert(box.x1 < box.x2);
- assert(box.y1 < box.y2);
- src_x = box.x1 - dPriv->x + dPriv->backX;
- src_y = box.y1 - dPriv->y + dPriv->backY;
-
- BEGIN_BATCH(8, REFERENCES_CLIPRECTS);
- OUT_BATCH(CMD);
- OUT_BATCH(BR13 | dst_pitch);
- OUT_BATCH((box.y1 << 16) | box.x1);
- OUT_BATCH((box.y2 << 16) | box.x2);
-
- OUT_RELOC(dst->buffer,
- I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
- 0);
- OUT_BATCH((src_y << 16) | src_x);
- OUT_BATCH(src_pitch);
- OUT_RELOC(src->buffer,
- I915_GEM_DOMAIN_RENDER, 0,
- 0);
- ADVANCE_BATCH();
- }
-
- /* Flush the rendering and the batch so that the results all land on the
- * screen in a timely fashion.
- */
- intel_batchbuffer_emit_mi_flush(intel->batch);
- intel_batchbuffer_flush(intel->batch);
- }
-
- UNLOCK_HARDWARE(intel);
-}
-
static GLuint translate_raster_op(GLenum logicop)
{
switch(logicop) {
@@ -249,7 +117,6 @@ intelEmitCopyBlit(struct intel_context *intel,
} while (pass < 2);
if (pass >= 2) {
- LOCK_HARDWARE(intel);
dri_bo_map(dst_buffer, GL_TRUE);
dri_bo_map(src_buffer, GL_FALSE);
_mesa_copy_rect((GLubyte *)dst_buffer->virtual + dst_offset,
@@ -263,12 +130,11 @@ intelEmitCopyBlit(struct intel_context *intel,
dri_bo_unmap(src_buffer);
dri_bo_unmap(dst_buffer);
- UNLOCK_HARDWARE(intel);
return GL_TRUE;
}
- intel_batchbuffer_require_space(intel->batch, 8 * 4, NO_LOOP_CLIPRECTS);
+ intel_batchbuffer_require_space(intel->batch, 8 * 4);
DBG("%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
__FUNCTION__,
src_buffer, src_pitch, src_offset, src_x, src_y,
@@ -313,7 +179,7 @@ intelEmitCopyBlit(struct intel_context *intel,
assert(dst_x < dst_x2);
assert(dst_y < dst_y2);
- BEGIN_BATCH(8, NO_LOOP_CLIPRECTS);
+ BEGIN_BATCH(8);
OUT_BATCH(CMD);
OUT_BATCH(BR13 | (uint16_t)dst_pitch);
OUT_BATCH((dst_y << 16) | dst_x);
@@ -371,8 +237,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
skipBuffers = BUFFER_BIT_STENCIL;
}
- LOCK_HARDWARE(intel);
-
intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
if (num_cliprects) {
GLint cx, cy, cw, ch;
@@ -436,6 +300,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
intel_region_buffer(intel, irb->region,
all ? INTEL_WRITE_FULL :
INTEL_WRITE_PART);
+ int x1 = b.x1 + irb->region->draw_x;
+ int y1 = b.y1 + irb->region->draw_y;
+ int x2 = b.x2 + irb->region->draw_x;
+ int y2 = b.y2 + irb->region->draw_y;
GLuint clearVal;
GLint pitch, cpp;
@@ -444,11 +312,10 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
pitch = irb->region->pitch;
cpp = irb->region->cpp;
- DBG("%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n",
+ DBG("%s dst:buf(%p)/%d %d,%d sz:%dx%d\n",
__FUNCTION__,
irb->region->buffer, (pitch * cpp),
- irb->region->draw_offset,
- b.x1, b.y1, b.x2 - b.x1, b.y2 - b.y1);
+ x1, y1, x2 - x1, y2 - y1);
BR13 = 0xf0 << 16;
CMD = XY_COLOR_BLT_CMD;
@@ -494,12 +361,14 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
- switch (irb->texformat->MesaFormat) {
+ switch (irb->Base.Format) {
case MESA_FORMAT_ARGB8888:
- clearVal = intel->ClearColor8888;
+ case MESA_FORMAT_XRGB8888:
+ clearVal = PACK_COLOR_8888(clear[3], clear[0],
+ clear[1], clear[2]);
break;
case MESA_FORMAT_RGB565:
- clearVal = intel->ClearColor565;
+ clearVal = PACK_COLOR_565(clear[0], clear[1], clear[2]);
break;
case MESA_FORMAT_ARGB4444:
clearVal = PACK_COLOR_4444(clear[3], clear[0],
@@ -511,7 +380,7 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
break;
default:
_mesa_problem(ctx, "Unexpected renderbuffer format: %d\n",
- irb->texformat->MesaFormat);
+ irb->Base.Format);
clearVal = 0;
}
}
@@ -521,17 +390,17 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
buf, irb->Base.Name);
*/
- assert(b.x1 < b.x2);
- assert(b.y1 < b.y2);
+ assert(x1 < x2);
+ assert(y1 < y2);
- BEGIN_BATCH(6, REFERENCES_CLIPRECTS);
+ BEGIN_BATCH(6);
OUT_BATCH(CMD);
OUT_BATCH(BR13);
- OUT_BATCH((b.y1 << 16) | b.x1);
- OUT_BATCH((b.y2 << 16) | b.x2);
+ OUT_BATCH((y1 << 16) | x1);
+ OUT_BATCH((y2 << 16) | x2);
OUT_RELOC(write_buffer,
I915_GEM_DOMAIN_RENDER, I915_GEM_DOMAIN_RENDER,
- irb->region->draw_offset);
+ 0);
OUT_BATCH(clearVal);
ADVANCE_BATCH();
clearMask &= ~bufBit; /* turn off bit, for faster loop exit */
@@ -539,8 +408,6 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
}
}
}
-
- UNLOCK_HARDWARE(intel);
}
GLboolean
@@ -582,8 +449,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
intel_batchbuffer_require_space( intel->batch,
(8 * 4) +
(3 * 4) +
- dwords * 4,
- REFERENCES_CLIPRECTS );
+ dwords * 4 );
opcode = XY_SETUP_BLT_CMD;
if (cpp == 4)
@@ -605,7 +471,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
if (dst_tiling != I915_TILING_NONE)
blit_cmd |= XY_DST_TILED;
- BEGIN_BATCH(8 + 3, REFERENCES_CLIPRECTS);
+ BEGIN_BATCH(8 + 3);
OUT_BATCH(opcode);
OUT_BATCH(br13);
OUT_BATCH((0 << 16) | 0); /* clip x1, y1 */
@@ -624,8 +490,7 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
intel_batchbuffer_data( intel->batch,
src_bits,
- dwords * 4,
- REFERENCES_CLIPRECTS );
+ dwords * 4 );
intel_batchbuffer_emit_mi_flush(intel->batch);
diff --git a/src/mesa/drivers/dri/intel/intel_blit.h b/src/mesa/drivers/dri/intel/intel_blit.h
index 240cb7cd1b..eb66fe0481 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.h
+++ b/src/mesa/drivers/dri/intel/intel_blit.h
@@ -30,7 +30,7 @@
#include "intel_context.h"
-extern void intelCopyBuffer(const __DRIdrawablePrivate * dpriv,
+extern void intelCopyBuffer(const __DRIdrawable * dpriv,
const drm_clip_rect_t * rect);
extern void intelClearWithBlit(GLcontext * ctx, GLbitfield mask);
diff --git a/src/mesa/drivers/dri/intel/intel_buffer_objects.c b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
index a0225936c8..3b7015b5ad 100644
--- a/src/mesa/drivers/dri/intel/intel_buffer_objects.c
+++ b/src/mesa/drivers/dri/intel/intel_buffer_objects.c
@@ -209,9 +209,23 @@ intel_bufferobj_subdata(GLcontext * ctx,
memcpy((char *)intel_obj->sys_buffer + offset, data, size);
else {
/* Flush any existing batchbuffer that might reference this data. */
- intelFlush(ctx);
+ if (drm_intel_bo_busy(intel_obj->buffer) ||
+ drm_intel_bo_references(intel->batch->buf, intel_obj->buffer)) {
+ drm_intel_bo *temp_bo;
+
+ temp_bo = drm_intel_bo_alloc(intel->bufmgr, "subdata temp", size, 64);
+
+ drm_intel_bo_subdata(temp_bo, 0, size, data);
- dri_bo_subdata(intel_obj->buffer, offset, size, data);
+ intel_emit_linear_blit(intel,
+ intel_obj->buffer, offset,
+ temp_bo, 0,
+ size);
+
+ drm_intel_bo_unreference(temp_bo);
+ } else {
+ dri_bo_subdata(intel_obj->buffer, offset, size, data);
+ }
}
}
@@ -254,13 +268,14 @@ intel_bufferobj_map(GLcontext * ctx,
if (intel_obj->sys_buffer) {
obj->Pointer = intel_obj->sys_buffer;
+ obj->Length = obj->Size;
+ obj->Offset = 0;
return obj->Pointer;
}
- /* Flush any existing batchbuffer that might have written to this
- * buffer.
- */
- intelFlush(ctx);
+ /* Flush any existing batchbuffer that might reference this data. */
+ if (drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
+ intelFlush(ctx);
if (intel_obj->region)
intel_bufferobj_cow(intel, intel_obj);
@@ -330,7 +345,8 @@ intel_bufferobj_map_range(GLcontext * ctx,
* the batchbuffer so that GEM knows about the buffer access for later
* syncing.
*/
- if (!(access & GL_MAP_UNSYNCHRONIZED_BIT))
+ if (!(access & GL_MAP_UNSYNCHRONIZED_BIT) &&
+ drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
intelFlush(ctx);
if (intel_obj->buffer == NULL) {
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.c b/src/mesa/drivers/dri/intel/intel_buffers.c
index e7357e78c5..7c4b79f743 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.c
+++ b/src/mesa/drivers/dri/intel/intel_buffers.c
@@ -102,32 +102,33 @@ intel_get_cliprects(struct intel_context *intel,
unsigned int *num_cliprects,
int *x_off, int *y_off)
{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
-
- if (intel->constant_cliprect) {
- /* FBO or DRI2 rendering, which can just use the fb's size. */
- intel->fboRect.x1 = 0;
- intel->fboRect.y1 = 0;
- intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
- intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
-
- *cliprects = &intel->fboRect;
- *num_cliprects = 1;
- *x_off = 0;
- *y_off = 0;
- } else if (intel->front_cliprects || dPriv->numBackClipRects == 0) {
- /* use the front clip rects */
- *cliprects = dPriv->pClipRects;
- *num_cliprects = dPriv->numClipRects;
- *x_off = dPriv->x;
- *y_off = dPriv->y;
- }
- else {
- /* use the back clip rects */
- *num_cliprects = dPriv->numBackClipRects;
- *cliprects = dPriv->pBackClipRects;
- *x_off = dPriv->backX;
- *y_off = dPriv->backY;
+ intel->fboRect.x1 = 0;
+ intel->fboRect.y1 = 0;
+ intel->fboRect.x2 = intel->ctx.DrawBuffer->Width;
+ intel->fboRect.y2 = intel->ctx.DrawBuffer->Height;
+
+ *cliprects = &intel->fboRect;
+ *num_cliprects = 1;
+ *x_off = 0;
+ *y_off = 0;
+}
+
+
+/**
+ * Check if we're about to draw into the front color buffer.
+ * If so, set the intel->front_buffer_dirty field to true.
+ */
+void
+intel_check_front_buffer_rendering(struct intel_context *intel)
+{
+ const struct gl_framebuffer *fb = intel->ctx.DrawBuffer;
+ if (fb->Name == 0) {
+ /* drawing to window system buffer */
+ if (fb->_NumColorDrawBuffers > 0) {
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
+ intel->front_buffer_dirty = GL_TRUE;
+ }
+ }
}
}
@@ -172,13 +173,17 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
return;
}
- /*
- * How many color buffers are we drawing into?
+ /* How many color buffers are we drawing into?
+ *
+ * If there are zero buffers or the buffer is too big, don't configure any
+ * regions for hardware drawing. We'll fallback to software below. Not
+ * having regions set makes some of the software fallback paths faster.
*/
- if (fb->_NumColorDrawBuffers == 0) {
+ if ((fb->Width > ctx->Const.MaxRenderbufferSize)
+ || (fb->Height > ctx->Const.MaxRenderbufferSize)
+ || (fb->_NumColorDrawBuffers == 0)) {
/* writing to 0 */
colorRegions[0] = NULL;
- intel->constant_cliprect = GL_TRUE;
}
else if (fb->_NumColorDrawBuffers > 1) {
int i;
@@ -188,36 +193,23 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
irb = intel_renderbuffer(fb->_ColorDrawBuffers[i]);
colorRegions[i] = irb ? irb->region : NULL;
}
- intel->constant_cliprect = GL_TRUE;
}
else {
/* Get the intel_renderbuffer for the single colorbuffer we're drawing
- * into, and set up cliprects if it's .
+ * into.
*/
if (fb->Name == 0) {
- intel->constant_cliprect = intel->driScreen->dri2.enabled;
/* drawing to window system buffer */
- if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT) {
- if (!intel->constant_cliprect && !intel->front_cliprects)
- intel_batchbuffer_flush(intel->batch);
- intel->front_cliprects = GL_TRUE;
+ if (fb->_ColorDrawBufferIndexes[0] == BUFFER_FRONT_LEFT)
colorRegions[0] = intel_get_rb_region(fb, BUFFER_FRONT_LEFT);
-
- intel->front_buffer_dirty = GL_TRUE;
- }
- else {
- if (!intel->constant_cliprect && intel->front_cliprects)
- intel_batchbuffer_flush(intel->batch);
- intel->front_cliprects = GL_FALSE;
- colorRegions[0]= intel_get_rb_region(fb, BUFFER_BACK_LEFT);
- }
+ else
+ colorRegions[0] = intel_get_rb_region(fb, BUFFER_BACK_LEFT);
}
else {
/* drawing to user-created FBO */
struct intel_renderbuffer *irb;
irb = intel_renderbuffer(fb->_ColorDrawBuffers[0]);
colorRegions[0] = (irb && irb->region) ? irb->region : NULL;
- intel->constant_cliprect = GL_TRUE;
}
}
@@ -257,7 +249,7 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
if (fb->_StencilBuffer && fb->_StencilBuffer->Wrapped) {
irbStencil = intel_renderbuffer(fb->_StencilBuffer->Wrapped);
if (irbStencil && irbStencil->region) {
- ASSERT(irbStencil->Base._ActualFormat == GL_DEPTH24_STENCIL8_EXT);
+ ASSERT(irbStencil->Base.Format == MESA_FORMAT_S8_Z24);
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
}
else {
@@ -269,6 +261,12 @@ intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb)
FALLBACK(intel, INTEL_FALLBACK_STENCIL_BUFFER, GL_FALSE);
}
+ /* If we have a (packed) stencil buffer attached but no depth buffer,
+ * we still need to set up the shared depth/stencil state so we can use it.
+ */
+ if (depthRegion == NULL && irbStencil && irbStencil->region)
+ depthRegion = irbStencil->region;
+
/*
* Update depth and stencil test state
*/
diff --git a/src/mesa/drivers/dri/intel/intel_buffers.h b/src/mesa/drivers/dri/intel/intel_buffers.h
index 6069d38e9e..d7800f2ca2 100644
--- a/src/mesa/drivers/dri/intel/intel_buffers.h
+++ b/src/mesa/drivers/dri/intel/intel_buffers.h
@@ -45,6 +45,8 @@ extern struct intel_region *intel_readbuf_region(struct intel_context *intel);
extern struct intel_region *intel_drawbuf_region(struct intel_context *intel);
+extern void intel_check_front_buffer_rendering(struct intel_context *intel);
+
extern void intel_draw_buffer(GLcontext * ctx, struct gl_framebuffer *fb);
extern void intelInitBufferFuncs(struct dd_function_table *functions);
diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c
index fb62f0f430..956f2339ff 100644
--- a/src/mesa/drivers/dri/intel/intel_clear.c
+++ b/src/mesa/drivers/dri/intel/intel_clear.c
@@ -68,13 +68,17 @@ static void
intelClear(GLcontext *ctx, GLbitfield mask)
{
struct intel_context *intel = intel_context(ctx);
- const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask);
+ const GLuint colorMask = *((GLuint *) & ctx->Color.ColorMask[0]);
GLbitfield tri_mask = 0;
GLbitfield blit_mask = 0;
GLbitfield swrast_mask = 0;
struct gl_framebuffer *fb = ctx->DrawBuffer;
GLuint i;
+ if (mask & (BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_FRONT_RIGHT)) {
+ intel->front_buffer_dirty = GL_TRUE;
+ }
+
if (0)
fprintf(stderr, "%s\n", __FUNCTION__);
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 934f7aa187..13a28f0419 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -55,10 +55,8 @@
#include "intel_decode.h"
#include "intel_bufmgr.h"
#include "intel_screen.h"
-#include "intel_swapbuffers.h"
#include "drirenderbuffer.h"
-#include "vblank.h"
#include "utils.h"
#include "xmlpool.h" /* for symbolic values of enum-type options */
@@ -68,7 +66,7 @@ int INTEL_DEBUG = (0);
#endif
-#define DRIVER_DATE "20090712 2009Q2 RC3"
+#define DRIVER_DATE "20091221 DEVELOPMENT"
#define DRIVER_DATE_GEM "GEM " DRIVER_DATE
@@ -176,9 +174,7 @@ intelGetString(GLcontext * ctx, GLenum name)
break;
}
- (void) driGetRendererString(buffer, chipset,
- (intel->ttm) ? DRIVER_DATE_GEM : DRIVER_DATE,
- 0);
+ (void) driGetRendererString(buffer, chipset, DRIVER_DATE_GEM, 0);
return (GLubyte *) buffer;
default:
@@ -189,28 +185,17 @@ intelGetString(GLcontext * ctx, GLenum name)
static unsigned
intel_bits_per_pixel(const struct intel_renderbuffer *rb)
{
- switch (rb->Base._ActualFormat) {
- case GL_RGB5:
- case GL_DEPTH_COMPONENT16:
- return 16;
- case GL_RGB8:
- case GL_RGBA8:
- case GL_DEPTH_COMPONENT24:
- case GL_DEPTH24_STENCIL8_EXT:
- case GL_STENCIL_INDEX8_EXT:
- return 32;
- default:
- return 0;
- }
+ return _mesa_get_format_bytes(rb->Base.Format) * 8;
}
void
intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
{
- struct intel_framebuffer *intel_fb = drawable->driverPrivate;
+ struct gl_framebuffer *fb = drawable->driverPrivate;
struct intel_renderbuffer *rb;
struct intel_region *region, *depth_region;
struct intel_context *intel = context->driverPrivate;
+ struct intel_renderbuffer *front_rb, *back_rb, *depth_rb, *stencil_rb;
__DRIbuffer *buffers = NULL;
__DRIscreen *screen;
int i, count;
@@ -226,26 +211,25 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
if (screen->dri2.loader
&& (screen->dri2.loader->base.version > 2)
&& (screen->dri2.loader->getBuffersWithFormat != NULL)) {
- struct intel_renderbuffer *depth_rb;
- struct intel_renderbuffer *stencil_rb;
+
+ front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+ back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+ depth_rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+ stencil_rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
i = 0;
if ((intel->is_front_buffer_rendering ||
intel->is_front_buffer_reading ||
- !intel_fb->color_rb[1])
- && intel_fb->color_rb[0]) {
+ !back_rb) && front_rb) {
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
- attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[0]);
+ attachments[i++] = intel_bits_per_pixel(front_rb);
}
- if (intel_fb->color_rb[1]) {
+ if (back_rb) {
attachments[i++] = __DRI_BUFFER_BACK_LEFT;
- attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[1]);
+ attachments[i++] = intel_bits_per_pixel(back_rb);
}
- depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
if ((depth_rb != NULL) && (stencil_rb != NULL)) {
attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
attachments[i++] = intel_bits_per_pixel(depth_rb);
@@ -266,13 +250,13 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
drawable->loaderPrivate);
} else if (screen->dri2.loader) {
i = 0;
- if (intel_fb->color_rb[0])
+ if (intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT))
attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
- if (intel_fb->color_rb[1])
+ if (intel_get_renderbuffer(fb, BUFFER_BACK_LEFT))
attachments[i++] = __DRI_BUFFER_BACK_LEFT;
- if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH))
+ if (intel_get_renderbuffer(fb, BUFFER_DEPTH))
attachments[i++] = __DRI_BUFFER_DEPTH;
- if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL))
+ if (intel_get_renderbuffer(fb, BUFFER_STENCIL))
attachments[i++] = __DRI_BUFFER_STENCIL;
buffers = (*screen->dri2.loader->getBuffers)(drawable,
@@ -305,32 +289,32 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
for (i = 0; i < count; i++) {
switch (buffers[i].attachment) {
case __DRI_BUFFER_FRONT_LEFT:
- rb = intel_fb->color_rb[0];
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
region_name = "dri2 front buffer";
break;
case __DRI_BUFFER_FAKE_FRONT_LEFT:
- rb = intel_fb->color_rb[0];
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
region_name = "dri2 fake front buffer";
break;
case __DRI_BUFFER_BACK_LEFT:
- rb = intel_fb->color_rb[1];
+ rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
region_name = "dri2 back buffer";
break;
case __DRI_BUFFER_DEPTH:
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+ rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
region_name = "dri2 depth buffer";
break;
case __DRI_BUFFER_DEPTH_STENCIL:
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+ rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
region_name = "dri2 depth / stencil buffer";
break;
case __DRI_BUFFER_STENCIL:
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+ rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
region_name = "dri2 stencil buffer";
break;
@@ -377,7 +361,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
intel_region_release(&region);
if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
- rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+ rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
if (rb != NULL) {
struct intel_region *stencil_region = NULL;
@@ -405,9 +389,6 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
void (*old_viewport)(GLcontext *ctx, GLint x, GLint y,
GLsizei w, GLsizei h);
- if (!driContext->driScreenPriv->dri2.enabled)
- return;
-
if (!intel->meta.internal_viewport_call && ctx->DrawBuffer->Name == 0) {
/* If we're rendering to the fake front buffer, make sure all the pending
* drawing has landed on the real front buffer. Otherwise when we
@@ -426,7 +407,6 @@ intel_viewport(GLcontext *ctx, GLint x, GLint y, GLsizei w, GLsizei h)
old_viewport = ctx->Driver.Viewport;
ctx->Driver.Viewport = NULL;
intel->driDrawable = driContext->driDrawablePriv;
- intelWindowMoved(intel);
intel_draw_buffer(ctx, intel->ctx.DrawBuffer);
ctx->Driver.Viewport = old_viewport;
}
@@ -489,16 +469,9 @@ intel_flush(GLcontext *ctx, GLboolean needs_mi_flush)
if (intel->Fallback)
_swrast_flush(ctx);
- if (!IS_965(intel->intelScreen->deviceID))
+ if (intel->gen < 4)
INTEL_FIREVERTICES(intel);
- /* Emit a flush so that any frontbuffer rendering that might have occurred
- * lands onscreen in a timely manner, even if the X Server doesn't trigger
- * a flush for us.
- */
- if (needs_mi_flush)
- intel_batchbuffer_emit_mi_flush(intel->batch);
-
if (intel->batch->map != intel->batch->ptr)
intel_batchbuffer_flush(intel->batch);
@@ -604,15 +577,15 @@ intelInitDriverFunctions(struct dd_function_table *functions)
GLboolean
intelInitContext(struct intel_context *intel,
const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate,
struct dd_function_table *functions)
{
GLcontext *ctx = &intel->ctx;
GLcontext *shareCtx = (GLcontext *) sharedContextPrivate;
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
- int fthrottle_mode;
+ int bo_reuse_mode;
if (!_mesa_initialize_context(&intel->ctx, mesaVis, shareCtx,
functions, (void *) intel)) {
@@ -623,35 +596,46 @@ intelInitContext(struct intel_context *intel,
driContextPriv->driverPrivate = intel;
intel->intelScreen = intelScreen;
intel->driScreen = sPriv;
- intel->sarea = intelScreen->sarea;
intel->driContext = driContextPriv;
-
- /* Dri stuff */
- intel->hHWContext = driContextPriv->hHWContext;
intel->driFd = sPriv->fd;
- intel->driHwLock = sPriv->lock;
+
+ if (IS_965(intel->intelScreen->deviceID)) {
+ intel->gen = 4;
+ } else if (IS_9XX(intel->intelScreen->deviceID)) {
+ intel->gen = 3;
+ if (IS_945(intel->intelScreen->deviceID)) {
+ intel->is_945 = GL_TRUE;
+ }
+ } else {
+ intel->gen = 2;
+ }
+
+ if (IS_IGDNG(intel->intelScreen->deviceID)) {
+ intel->is_ironlake = GL_TRUE;
+ intel->needs_ff_sync = GL_TRUE;
+ intel->has_luminance_srgb = GL_TRUE;
+ } else if (IS_G4X(intel->intelScreen->deviceID)) {
+ intel->has_luminance_srgb = GL_TRUE;
+ intel->is_g4x = GL_TRUE;
+ }
driParseConfigFiles(&intel->optionCache, &intelScreen->optionCache,
intel->driScreen->myNum,
- IS_965(intelScreen->deviceID) ? "i965" : "i915");
+ (intel->gen >= 4) ? "i965" : "i915");
if (intelScreen->deviceID == PCI_CHIP_I865_G)
intel->maxBatchSize = 4096;
else
intel->maxBatchSize = BATCH_SZ;
intel->bufmgr = intelScreen->bufmgr;
- intel->ttm = intelScreen->ttm;
- if (intel->ttm) {
- int bo_reuse_mode;
- bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
- switch (bo_reuse_mode) {
- case DRI_CONF_BO_REUSE_DISABLED:
- break;
- case DRI_CONF_BO_REUSE_ALL:
- intel_bufmgr_gem_enable_reuse(intel->bufmgr);
- break;
- }
+ bo_reuse_mode = driQueryOptioni(&intel->optionCache, "bo_reuse");
+ switch (bo_reuse_mode) {
+ case DRI_CONF_BO_REUSE_DISABLED:
+ break;
+ case DRI_CONF_BO_REUSE_ALL:
+ intel_bufmgr_gem_enable_reuse(intel->bufmgr);
+ break;
}
/* This doesn't yet catch all non-conformant rendering, but it's a
@@ -695,7 +679,7 @@ intelInitContext(struct intel_context *intel,
meta_init_metaops(ctx, &intel->meta);
ctx->Const.MaxColorAttachments = 4; /* XXX FBO: review this */
- if (IS_965(intelScreen->deviceID)) {
+ if (intel->gen >= 4) {
if (MAX_WIDTH > 8192)
ctx->Const.MaxRenderbufferSize = 8192;
} else {
@@ -732,33 +716,22 @@ intelInitContext(struct intel_context *intel,
break;
}
- if (IS_965(intelScreen->deviceID))
+ if (intel->gen >= 4)
intel->polygon_offset_scale /= 0xffff;
intel->RenderIndex = ~0;
- fthrottle_mode = driQueryOptioni(&intel->optionCache, "fthrottle_mode");
- intel->irqsEmitted = 0;
-
- intel->do_irqs = (intel->intelScreen->irq_active &&
- fthrottle_mode == DRI_CONF_FTHROTTLE_IRQS);
-
- intel->do_usleeps = (fthrottle_mode == DRI_CONF_FTHROTTLE_USLEEPS);
-
- if (IS_965(intelScreen->deviceID) && !intel->intelScreen->irq_active) {
+ if (intel->gen >= 4 && !intel->intelScreen->irq_active) {
_mesa_printf("IRQs not active. Exiting\n");
exit(1);
}
- intelInitExtensions(ctx, GL_FALSE);
+ intelInitExtensions(ctx);
INTEL_DEBUG = driParseDebugString(getenv("INTEL_DEBUG"), debug_control);
if (INTEL_DEBUG & DEBUG_BUFMGR)
dri_bufmgr_set_debug(intel->bufmgr, GL_TRUE);
- if (!sPriv->dri2.enabled)
- intel_recreate_static_regions(intel);
-
intel->batch = intel_batchbuffer_alloc(intel);
intel_fbo_init(intel);
@@ -807,7 +780,7 @@ intelInitContext(struct intel_context *intel,
}
void
-intelDestroyContext(__DRIcontextPrivate * driContextPriv)
+intelDestroyContext(__DRIcontext * driContextPriv)
{
struct intel_context *intel =
(struct intel_context *) driContextPriv->driverPrivate;
@@ -830,7 +803,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
_vbo_DestroyContext(&intel->ctx);
_swrast_DestroyContext(&intel->ctx);
- intel->Fallback = 0; /* don't call _swrast_Flush later */
+ intel->Fallback = 0x0; /* don't call _swrast_Flush later */
intel_batchbuffer_free(intel->batch);
intel->batch = NULL;
@@ -854,57 +827,6 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
*/
}
- /* XXX In intelMakeCurrent() below, the context's static regions are
- * referenced inside the frame buffer; it's listed as a hack,
- * with a comment of "XXX FBO temporary fix-ups!", but
- * as long as it's there, we should release the regions here.
- * The do/while loop around the block is used to allow the
- * "continue" statements inside the block to exit the block,
- * to avoid many layers of "if" constructs.
- */
- do {
- __DRIdrawablePrivate * driDrawPriv = intel->driDrawable;
- struct intel_framebuffer *intel_fb;
- struct intel_renderbuffer *irbDepth, *irbStencil;
- if (!driDrawPriv) {
- /* We're already detached from the drawable; exit this block. */
- continue;
- }
- intel_fb = (struct intel_framebuffer *) driDrawPriv->driverPrivate;
- if (!intel_fb) {
- /* The frame buffer is already gone; exit this block. */
- continue;
- }
- irbDepth = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- irbStencil = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
- /* If the regions of the frame buffer still match the regions
- * of the context, release them. If they've changed somehow,
- * leave them alone.
- */
- if (intel_fb->color_rb[0] && intel_fb->color_rb[0]->region == intel->front_region) {
- intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
- }
- if (intel_fb->color_rb[1] && intel_fb->color_rb[1]->region == intel->back_region) {
- intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
- }
-
- if (irbDepth && irbDepth->region == intel->depth_region) {
- intel_renderbuffer_set_region(irbDepth, NULL);
- }
- /* Usually, the stencil buffer is the same as the depth buffer;
- * but they're handled separately in MakeCurrent, so we'll
- * handle them separately here.
- */
- if (irbStencil && irbStencil->region == intel->depth_region) {
- intel_renderbuffer_set_region(irbStencil, NULL);
- }
- } while (0);
-
- intel_region_release(&intel->front_region);
- intel_region_release(&intel->back_region);
- intel_region_release(&intel->depth_region);
-
driDestroyOptionCache(&intel->optionCache);
/* free the Mesa context */
@@ -916,7 +838,7 @@ intelDestroyContext(__DRIcontextPrivate * driContextPriv)
}
GLboolean
-intelUnbindContext(__DRIcontextPrivate * driContextPriv)
+intelUnbindContext(__DRIcontext * driContextPriv)
{
struct intel_context *intel =
(struct intel_context *) driContextPriv->driverPrivate;
@@ -930,50 +852,33 @@ intelUnbindContext(__DRIcontextPrivate * driContextPriv)
}
GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv)
+intelMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv)
{
- __DRIscreenPrivate *psp = driDrawPriv->driScreenPriv;
+ struct intel_context *intel;
+ GET_CURRENT_CONTEXT(curCtx);
+
+ if (driContextPriv)
+ intel = (struct intel_context *) driContextPriv->driverPrivate;
+ else
+ intel = NULL;
+
+ /* According to the glXMakeCurrent() man page: "Pending commands to
+ * the previous context, if any, are flushed before it is released."
+ * But only flush if we're actually changing contexts.
+ */
+ if (intel_context(curCtx) && intel_context(curCtx) != intel) {
+ _mesa_flush(curCtx);
+ }
if (driContextPriv) {
- struct intel_context *intel =
- (struct intel_context *) driContextPriv->driverPrivate;
- struct intel_framebuffer *intel_fb =
- (struct intel_framebuffer *) driDrawPriv->driverPrivate;
- GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
+ struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+ struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
- if (driContextPriv->driScreenPriv->dri2.enabled) {
- intel_update_renderbuffers(driContextPriv, driDrawPriv);
- if (driDrawPriv != driReadPriv)
- intel_update_renderbuffers(driContextPriv, driReadPriv);
- } else {
- /* XXX FBO temporary fix-ups! These are released in
- * intelDextroyContext(), above. Changes here should be
- * reflected there.
- */
- /* if the renderbuffers don't have regions, init them from the context */
- struct intel_renderbuffer *irbDepth
- = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- struct intel_renderbuffer *irbStencil
- = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
- if (intel_fb->color_rb[0]) {
- intel_renderbuffer_set_region(intel_fb->color_rb[0],
- intel->front_region);
- }
- if (intel_fb->color_rb[1]) {
- intel_renderbuffer_set_region(intel_fb->color_rb[1],
- intel->back_region);
- }
-
- if (irbDepth) {
- intel_renderbuffer_set_region(irbDepth, intel->depth_region);
- }
- if (irbStencil) {
- intel_renderbuffer_set_region(irbStencil, intel->depth_region);
- }
- }
+ intel_update_renderbuffers(driContextPriv, driDrawPriv);
+ if (driDrawPriv != driReadPriv)
+ intel_update_renderbuffers(driContextPriv, driReadPriv);
/* set GLframebuffer size to match window, if needed */
driUpdateFramebufferSize(&intel->ctx, driDrawPriv);
@@ -982,37 +887,10 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
driUpdateFramebufferSize(&intel->ctx, driReadPriv);
}
- _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
-
+ _mesa_make_current(&intel->ctx, fb, readFb);
intel->driReadDrawable = driReadPriv;
-
- if (intel->driDrawable != driDrawPriv) {
- if (driDrawPriv->swap_interval == (unsigned)-1) {
- int i;
-
- driDrawPriv->vblFlags = (intel->intelScreen->irq_active != 0)
- ? driGetDefaultVBlankFlags(&intel->optionCache)
- : VBLANK_FLAG_NO_IRQ;
-
- /* Prevent error printf if one crtc is disabled, this will
- * be properly calculated in intelWindowMoved() next.
- */
- driDrawPriv->vblFlags = intelFixupVblank(intel, driDrawPriv);
-
- (*psp->systemTime->getUST) (&intel_fb->swap_ust);
- driDrawableInitVBlank(driDrawPriv);
- intel_fb->vbl_waited = driDrawPriv->vblSeq;
-
- for (i = 0; i < 2; i++) {
- if (intel_fb->color_rb[i])
- intel_fb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq;
- }
- }
- intel->driDrawable = driDrawPriv;
- intelWindowMoved(intel);
- }
-
- intel_draw_buffer(&intel->ctx, &intel_fb->Base);
+ intel->driDrawable = driDrawPriv;
+ intel_draw_buffer(&intel->ctx, fb);
}
else {
_mesa_make_current(NULL, NULL, NULL);
@@ -1020,143 +898,3 @@ intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
return GL_TRUE;
}
-
-static void
-intelContendedLock(struct intel_context *intel, GLuint flags)
-{
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- __DRIscreenPrivate *sPriv = intel->driScreen;
- volatile drm_i915_sarea_t *sarea = intel->sarea;
- int me = intel->hHWContext;
-
- drmGetLock(intel->driFd, intel->hHWContext, flags);
-
- if (INTEL_DEBUG & DEBUG_LOCK)
- _mesa_printf("%s - got contended lock\n", __progname);
-
- /* If the window moved, may need to set a new cliprect now.
- *
- * NOTE: This releases and regains the hw lock, so all state
- * checking must be done *after* this call:
- */
- if (dPriv)
- DRI_VALIDATE_DRAWABLE_INFO(sPriv, dPriv);
-
- if (sarea && sarea->ctxOwner != me) {
- if (INTEL_DEBUG & DEBUG_BUFMGR) {
- fprintf(stderr, "Lost Context: sarea->ctxOwner %x me %x\n",
- sarea->ctxOwner, me);
- }
- sarea->ctxOwner = me;
- }
-
- /* If the last consumer of the texture memory wasn't us, notify the fake
- * bufmgr and record the new owner. We should have the memory shared
- * between contexts of a single fake bufmgr, but this will at least make
- * things correct for now.
- */
- if (!intel->ttm && sarea->texAge != intel->hHWContext) {
- sarea->texAge = intel->hHWContext;
- intel_bufmgr_fake_contended_lock_take(intel->bufmgr);
- if (INTEL_DEBUG & DEBUG_BATCH)
- intel_decode_context_reset();
- if (INTEL_DEBUG & DEBUG_BUFMGR)
- fprintf(stderr, "Lost Textures: sarea->texAge %x hw context %x\n",
- sarea->ctxOwner, intel->hHWContext);
- }
-
- /* Drawable changed?
- */
- if (dPriv && intel->lastStamp != dPriv->lastStamp) {
- intelWindowMoved(intel);
- intel->lastStamp = dPriv->lastStamp;
- }
-}
-
-
-_glthread_DECLARE_STATIC_MUTEX(lockMutex);
-
-/* Lock the hardware and validate our state.
- */
-void LOCK_HARDWARE( struct intel_context *intel )
-{
- __DRIdrawable *dPriv = intel->driDrawable;
- __DRIscreen *sPriv = intel->driScreen;
- char __ret = 0;
- struct intel_framebuffer *intel_fb = NULL;
- struct intel_renderbuffer *intel_rb = NULL;
-
- intel->locked++;
- if (intel->locked >= 2)
- return;
-
- if (!sPriv->dri2.enabled)
- _glthread_LOCK_MUTEX(lockMutex);
-
- if (intel->driDrawable) {
- intel_fb = intel->driDrawable->driverPrivate;
-
- if (intel_fb)
- intel_rb =
- intel_get_renderbuffer(&intel_fb->Base,
- intel_fb->Base._ColorDrawBufferIndexes[0]);
- }
-
- if (intel_rb && dPriv->vblFlags &&
- !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ) &&
- (intel_fb->vbl_waited - intel_rb->vbl_pending) > (1<<23)) {
- drmVBlank vbl;
-
- vbl.request.type = DRM_VBLANK_ABSOLUTE;
-
- if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
- vbl.request.type |= DRM_VBLANK_SECONDARY;
- }
-
- vbl.request.sequence = intel_rb->vbl_pending;
- drmWaitVBlank(intel->driFd, &vbl);
- intel_fb->vbl_waited = vbl.reply.sequence;
- }
-
- if (!sPriv->dri2.enabled) {
- DRM_CAS(intel->driHwLock, intel->hHWContext,
- (DRM_LOCK_HELD|intel->hHWContext), __ret);
-
- if (__ret)
- intelContendedLock( intel, 0 );
- }
-
-
- if (INTEL_DEBUG & DEBUG_LOCK)
- _mesa_printf("%s - locked\n", __progname);
-}
-
-
-/* Unlock the hardware using the global current context
- */
-void UNLOCK_HARDWARE( struct intel_context *intel )
-{
- __DRIscreen *sPriv = intel->driScreen;
-
- intel->locked--;
- if (intel->locked > 0)
- return;
-
- assert(intel->locked == 0);
-
- if (!sPriv->dri2.enabled) {
- DRM_UNLOCK(intel->driFd, intel->driHwLock, intel->hHWContext);
- _glthread_UNLOCK_MUTEX(lockMutex);
- }
-
- if (INTEL_DEBUG & DEBUG_LOCK)
- _mesa_printf("%s - unlocked\n", __progname);
-
- /**
- * Nothing should be left in batch outside of LOCK/UNLOCK which references
- * cliprects.
- */
- if (intel->batch->cliprect_mode == REFERENCES_CLIPRECTS)
- intel_batchbuffer_flush(intel->batch);
-}
-
diff --git a/src/mesa/drivers/dri/intel/intel_context.h b/src/mesa/drivers/dri/intel/intel_context.h
index b104096912..c7b7235836 100644
--- a/src/mesa/drivers/dri/intel/intel_context.h
+++ b/src/mesa/drivers/dri/intel/intel_context.h
@@ -61,6 +61,10 @@ typedef void (*intel_line_func) (struct intel_context *, intelVertex *,
intelVertex *);
typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
+/**
+ * Bits for intel->Fallback field
+ */
+/*@{*/
#define INTEL_FALLBACK_DRAW_BUFFER 0x1
#define INTEL_FALLBACK_READ_BUFFER 0x2
#define INTEL_FALLBACK_DEPTH_BUFFER 0x4
@@ -68,8 +72,10 @@ typedef void (*intel_point_func) (struct intel_context *, intelVertex *);
#define INTEL_FALLBACK_USER 0x10
#define INTEL_FALLBACK_RENDERMODE 0x20
#define INTEL_FALLBACK_TEXTURE 0x40
+#define INTEL_FALLBACK_DRIVER 0x1000 /**< first for drivers */
+/*@}*/
-extern void intelFallback(struct intel_context *intel, GLuint bit,
+extern void intelFallback(struct intel_context *intel, GLbitfield bit,
GLboolean mode);
#define FALLBACK( intel, bit, mode ) intelFallback( intel, bit, mode )
@@ -111,8 +117,6 @@ struct intel_context
struct intel_region * depth_region,
GLuint num_regions);
- GLuint (*flush_cmd) (void);
-
void (*reduced_primitive_state) (struct intel_context * intel,
GLenum rprim);
@@ -131,14 +135,6 @@ struct intel_context
struct intel_region * draw_region,
struct intel_region * depth_region);
- void (*meta_draw_quad)(struct intel_context *intel,
- GLfloat x0, GLfloat x1,
- GLfloat y0, GLfloat y1,
- GLfloat z,
- GLuint color, /* ARGB32 */
- GLfloat s0, GLfloat s1,
- GLfloat t0, GLfloat t1);
-
void (*meta_color_mask) (struct intel_context * intel, GLboolean);
void (*meta_stencil_replace) (struct intel_context * intel,
@@ -170,27 +166,27 @@ struct intel_context
struct dri_metaops meta;
- GLint refcount;
- GLuint Fallback;
+ GLbitfield Fallback; /**< mask of INTEL_FALLBACK_x bits */
GLuint NewGLState;
dri_bufmgr *bufmgr;
unsigned int maxBatchSize;
- struct intel_region *front_region;
- struct intel_region *back_region;
- struct intel_region *depth_region;
-
/**
- * This value indicates that the kernel memory manager is being used
- * instead of the fake client-side memory manager.
+ * Generation number of the hardware: 2 is 8xx, 3 is 9xx pre-965, 4 is 965.
*/
- GLboolean ttm;
+ int gen;
+ GLboolean needs_ff_sync;
+ GLboolean is_ironlake;
+ GLboolean is_g4x;
+ GLboolean is_945;
+ GLboolean has_luminance_srgb;
+
+ int urb_size;
struct intel_batchbuffer *batch;
drm_intel_bo *first_post_swapbuffers_batch;
GLboolean no_batch_wrap;
- unsigned batch_id;
struct
{
@@ -210,10 +206,6 @@ struct intel_context
char *prevLockFile;
int prevLockLine;
- GLuint ClearColor565;
- GLuint ClearColor8888;
-
-
/* Offsets of fields within the current vertex:
*/
GLuint coloroffset;
@@ -230,6 +222,7 @@ struct intel_context
GLboolean hw_stipple;
GLboolean depth_buffer_is_float;
GLboolean no_rast;
+ GLboolean no_hw;
GLboolean always_flush_batch;
GLboolean always_flush_cache;
@@ -255,19 +248,6 @@ struct intel_context
intel_tri_func draw_tri;
/**
- * Set to true if a single constant cliprect should be used in the
- * batchbuffer. Otherwise, cliprects must be calculated at batchbuffer
- * flush time while the lock is held.
- */
- GLboolean constant_cliprect;
-
- /**
- * In !constant_cliprect mode, set to true if the front cliprects should be
- * used instead of back.
- */
- GLboolean front_cliprects;
-
- /**
* 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
@@ -295,48 +275,23 @@ struct intel_context
GLboolean use_early_z;
drm_clip_rect_t fboRect; /**< cliprect for FBO rendering */
- int perf_boxes;
-
- GLuint do_usleeps;
- int do_irqs;
- GLuint irqsEmitted;
-
- GLboolean scissor;
drm_clip_rect_t draw_rect;
drm_clip_rect_t scissor_rect;
- drm_context_t hHWContext;
- drmLock *driHwLock;
int driFd;
- __DRIcontextPrivate *driContext;
- __DRIdrawablePrivate *driDrawable;
- __DRIdrawablePrivate *driReadDrawable;
- __DRIscreenPrivate *driScreen;
+ __DRIcontext *driContext;
+ __DRIdrawable *driDrawable;
+ __DRIdrawable *driReadDrawable;
+ __DRIscreen *driScreen;
intelScreenPrivate *intelScreen;
- volatile drm_i915_sarea_t *sarea;
-
- GLuint lastStamp;
-
- GLboolean no_hw;
/**
* Configuration cache
*/
driOptionCache optionCache;
-
- int64_t swap_ust;
- int64_t swap_missed_ust;
-
- GLuint swap_count;
- GLuint swap_missed_count;
};
-/* These are functions now:
- */
-void LOCK_HARDWARE( struct intel_context *intel );
-void UNLOCK_HARDWARE( struct intel_context *intel );
-
extern char *__progname;
@@ -347,6 +302,19 @@ extern char *__progname;
#define ALIGN(value, alignment) ((value + alignment - 1) & ~(alignment - 1))
#define IS_POWER_OF_TWO(val) (((val) & (val - 1)) == 0)
+static INLINE uint32_t
+U_FIXED(float value, uint32_t frac_bits)
+{
+ value *= (1 << frac_bits);
+ return value < 0 ? 0 : value;
+}
+
+static INLINE uint32_t
+S_FIXED(float value, uint32_t frac_bits)
+{
+ return value * (1 << frac_bits);
+}
+
#define INTEL_FIREVERTICES(intel) \
do { \
if ((intel)->prim.flush) \
@@ -354,29 +322,6 @@ do { \
} while (0)
/* ================================================================
- * Color packing:
- */
-
-#define INTEL_PACKCOLOR4444(r,g,b,a) \
- ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4))
-
-#define INTEL_PACKCOLOR1555(r,g,b,a) \
- ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
- ((a) ? 0x8000 : 0))
-
-#define INTEL_PACKCOLOR565(r,g,b) \
- ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
-
-#define INTEL_PACKCOLOR8888(r,g,b,a) \
- ((a<<24) | (r<<16) | (g<<8) | b)
-
-#define INTEL_PACKCOLOR(format, r, g, b, a) \
-(format == DV_PF_555 ? INTEL_PACKCOLOR1555(r,g,b,a) : \
- (format == DV_PF_565 ? INTEL_PACKCOLOR565(r,g,b) : \
- (format == DV_PF_8888 ? INTEL_PACKCOLOR8888(r,g,b,a) : \
- 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 ???
@@ -461,12 +406,10 @@ extern int INTEL_DEBUG;
extern GLboolean intelInitContext(struct intel_context *intel,
const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate,
struct dd_function_table *functions);
-extern void intelGetLock(struct intel_context *intel, GLuint flags);
-
extern void intelFinish(GLcontext * ctx);
extern void intelFlush(GLcontext * ctx);
@@ -568,4 +511,25 @@ is_power_of_two(uint32_t value)
return (value & (value - 1)) == 0;
}
+static INLINE void
+intel_bo_map_gtt_preferred(struct intel_context *intel,
+ drm_intel_bo *bo,
+ GLboolean write)
+{
+ if (intel->intelScreen->kernel_exec_fencing)
+ drm_intel_gem_bo_map_gtt(bo);
+ else
+ drm_intel_bo_map(bo, write);
+}
+
+static INLINE void
+intel_bo_unmap_gtt_preferred(struct intel_context *intel,
+ drm_intel_bo *bo)
+{
+ if (intel->intelScreen->kernel_exec_fencing)
+ drm_intel_gem_bo_unmap_gtt(bo);
+ else
+ drm_intel_bo_unmap(bo);
+}
+
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_depthtmp.h b/src/mesa/drivers/dri/intel/intel_depthtmp.h
index 16d7708453..a9c75d44cf 100644
--- a/src/mesa/drivers/dri/intel/intel_depthtmp.h
+++ b/src/mesa/drivers/dri/intel/intel_depthtmp.h
@@ -31,6 +31,16 @@
*/
#define VALUE_TYPE INTEL_VALUE_TYPE
+#define WRITE_DEPTH(_x, _y, d) \
+ (*(INTEL_VALUE_TYPE *)(irb->region->buffer->virtual + \
+ NO_TILE(_x, _y)) = d)
+#define READ_DEPTH(d, _x, _y) \
+ d = *(INTEL_VALUE_TYPE *)(irb->region->buffer->virtual + \
+ NO_TILE(_x, _y))
+#define TAG(x) INTEL_TAG(intel_gttmap_##x)
+#include "depthtmp.h"
+
+#define VALUE_TYPE INTEL_VALUE_TYPE
#define WRITE_DEPTH(_x, _y, d) INTEL_WRITE_DEPTH(NO_TILE(_x, _y), d)
#define READ_DEPTH(d, _x, _y) d = INTEL_READ_DEPTH(NO_TILE(_x, _y))
#define TAG(x) INTEL_TAG(intel##x)
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index 2eb08a8f05..5ac5ce10af 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -28,6 +28,7 @@
#include "intel_chipset.h"
#include "intel_context.h"
#include "intel_extensions.h"
+#include "utils.h"
#define need_GL_ARB_copy_buffer
@@ -63,7 +64,7 @@
#define need_GL_VERSION_2_0
#define need_GL_VERSION_2_1
-#include "extension_helper.h"
+#include "main/remap_helper.h"
/**
@@ -78,6 +79,7 @@ static const struct dri_extension card_extensions[] = {
{ "GL_ARB_half_float_pixel", NULL },
{ "GL_ARB_map_buffer_range", GL_ARB_map_buffer_range_functions },
{ "GL_ARB_multitexture", NULL },
+ { "GL_ARB_pixel_buffer_object", NULL },
{ "GL_ARB_point_parameters", GL_ARB_point_parameters_functions },
{ "GL_ARB_point_sprite", NULL },
{ "GL_ARB_shader_objects", GL_ARB_shader_objects_functions },
@@ -103,6 +105,8 @@ static const struct dri_extension card_extensions[] = {
{ "GL_EXT_blend_logic_op", NULL },
{ "GL_EXT_blend_subtract", NULL },
{ "GL_EXT_cull_vertex", GL_EXT_cull_vertex_functions },
+ { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions },
+ { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
{ "GL_EXT_fog_coord", GL_EXT_fog_coord_functions },
{ "GL_EXT_gpu_program_parameters", GL_EXT_gpu_program_parameters_functions },
{ "GL_EXT_packed_depth_stencil", NULL },
@@ -120,7 +124,6 @@ static const struct dri_extension card_extensions[] = {
{ "GL_MESA_pack_invert", NULL },
{ "GL_MESA_ycbcr_texture", NULL },
{ "GL_NV_blend_square", NULL },
- { "GL_NV_point_sprite", GL_NV_point_sprite_functions },
{ "GL_NV_vertex_program", GL_NV_vertex_program_functions },
{ "GL_NV_vertex_program1_1", NULL },
{ "GL_SGIS_generate_mipmap", NULL },
@@ -175,14 +178,6 @@ static const struct dri_extension arb_oq_extensions[] = {
{ NULL, NULL }
};
-
-static const struct dri_extension ttm_extensions[] = {
- { "GL_ARB_pixel_buffer_object", NULL },
- { "GL_EXT_framebuffer_blit", GL_EXT_framebuffer_blit_functions },
- { "GL_EXT_framebuffer_object", GL_EXT_framebuffer_object_functions },
- { NULL, NULL }
-};
-
static const struct dri_extension fragment_shader_extensions[] = {
{ "GL_ARB_fragment_shader", NULL },
{ NULL, NULL }
@@ -193,31 +188,24 @@ static const struct dri_extension fragment_shader_extensions[] = {
* extensions for a context.
*/
void
-intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging)
+intelInitExtensions(GLcontext *ctx)
{
- struct intel_context *intel = ctx?intel_context(ctx):NULL;
+ struct intel_context *intel = intel_context(ctx);
/* Disable imaging extension until convolution is working in teximage paths.
*/
- enable_imaging = GL_FALSE;
-
- driInitExtensions(ctx, card_extensions, enable_imaging);
-
- if (intel == NULL || intel->ttm)
- driInitExtensions(ctx, ttm_extensions, GL_FALSE);
+ driInitExtensions(ctx, card_extensions, GL_FALSE);
- if (intel == NULL || IS_965(intel->intelScreen->deviceID))
+ if (intel->gen >= 4)
driInitExtensions(ctx, brw_extensions, GL_FALSE);
- if (intel == NULL || IS_915(intel->intelScreen->deviceID)
- || IS_945(intel->intelScreen->deviceID)) {
+ if (intel->gen == 3) {
driInitExtensions(ctx, i915_extensions, GL_FALSE);
- if (intel == NULL || driQueryOptionb(&intel->optionCache, "fragment_shader"))
+ if (driQueryOptionb(&intel->optionCache, "fragment_shader"))
driInitExtensions(ctx, fragment_shader_extensions, GL_FALSE);
- if (intel == NULL || driQueryOptionb(&intel->optionCache,
- "stub_occlusion_query"))
+ if (driQueryOptionb(&intel->optionCache, "stub_occlusion_query"))
driInitExtensions(ctx, arb_oq_extensions, GL_FALSE);
}
}
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.h b/src/mesa/drivers/dri/intel/intel_extensions.h
index 97147ecdb0..1d1c97a4a9 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.h
+++ b/src/mesa/drivers/dri/intel/intel_extensions.h
@@ -30,7 +30,7 @@
extern void
-intelInitExtensions(GLcontext *ctx, GLboolean enable_imaging);
+intelInitExtensions(GLcontext *ctx);
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index 8dfb24290d..d58ffd95fa 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -33,11 +33,11 @@
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/context.h"
-#include "main/texformat.h"
#include "main/texrender.h"
#include "drivers/common/meta.h"
#include "intel_context.h"
+#include "intel_batchbuffer.h"
#include "intel_buffers.h"
#include "intel_fbo.h"
#include "intel_mipmap_tree.h"
@@ -106,8 +106,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
{
struct intel_context *intel = intel_context(ctx);
struct intel_renderbuffer *irb = intel_renderbuffer(rb);
- GLboolean softwareBuffer = GL_FALSE;
int cpp;
+ GLuint pitch;
ASSERT(rb->Name != 0);
@@ -115,27 +115,16 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_R3_G3_B2:
case GL_RGB4:
case GL_RGB5:
- rb->_ActualFormat = GL_RGB5;
+ rb->Format = MESA_FORMAT_RGB565;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 5;
- rb->GreenBits = 6;
- rb->BlueBits = 5;
- irb->texformat = &_mesa_texformat_rgb565;
- cpp = 2;
break;
case GL_RGB:
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- rb->_ActualFormat = GL_RGB8;
+ rb->Format = MESA_FORMAT_XRGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 0;
- irb->texformat = &_mesa_texformat_argb8888; /* XXX: Need xrgb8888 */
- cpp = 4;
break;
case GL_RGBA:
case GL_RGBA2:
@@ -145,14 +134,8 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- rb->_ActualFormat = GL_RGBA8;
+ rb->Format = MESA_FORMAT_ARGB8888;
rb->DataType = GL_UNSIGNED_BYTE;
- rb->RedBits = 8;
- rb->GreenBits = 8;
- rb->BlueBits = 8;
- rb->AlphaBits = 8;
- irb->texformat = &_mesa_texformat_argb8888;
- cpp = 4;
break;
case GL_STENCIL_INDEX:
case GL_STENCIL_INDEX1_EXT:
@@ -160,36 +143,23 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
case GL_STENCIL_INDEX8_EXT:
case GL_STENCIL_INDEX16_EXT:
/* alloc a depth+stencil buffer */
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_S8_Z24;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->StencilBits = 8;
- cpp = 4;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
case GL_DEPTH_COMPONENT16:
- rb->_ActualFormat = GL_DEPTH_COMPONENT16;
+ rb->Format = MESA_FORMAT_Z16;
rb->DataType = GL_UNSIGNED_SHORT;
- rb->DepthBits = 16;
- cpp = 2;
- irb->texformat = &_mesa_texformat_z16;
break;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_S8_Z24;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->DepthBits = 24;
- cpp = 4;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- rb->_ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ rb->Format = MESA_FORMAT_S8_Z24;
rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
- rb->DepthBits = 24;
- rb->StencilBits = 8;
- cpp = 4;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
default:
_mesa_problem(ctx,
@@ -197,6 +167,9 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
return GL_FALSE;
}
+ rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
+ cpp = _mesa_get_format_bytes(rb->Format);
+
intelFlush(ctx);
/* free old region */
@@ -205,32 +178,25 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
/* allocate new memory region/renderbuffer */
- if (softwareBuffer) {
- return _mesa_soft_renderbuffer_storage(ctx, rb, internalFormat,
- width, height);
- }
- else {
- /* Choose a pitch to match hardware requirements:
- */
- GLuint pitch = ((cpp * width + 63) & ~63) / cpp;
- /* alloc hardware renderbuffer */
- DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width,
- height, pitch);
+ /* Choose a pitch to match hardware requirements:
+ */
+ pitch = ((cpp * width + 63) & ~63) / cpp;
+
+ /* alloc hardware renderbuffer */
+ DBG("Allocating %d x %d Intel RBO (pitch %d)\n", width, height, pitch);
- irb->region = intel_region_alloc(intel, I915_TILING_NONE,
- cpp, width, height, pitch,
- GL_TRUE);
- if (!irb->region)
- return GL_FALSE; /* out of memory? */
+ irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp,
+ width, height, pitch, GL_TRUE);
+ if (!irb->region)
+ return GL_FALSE; /* out of memory? */
- ASSERT(irb->region->buffer);
+ ASSERT(irb->region->buffer);
- rb->Width = width;
- rb->Height = height;
+ rb->Width = width;
+ rb->Height = height;
- return GL_TRUE;
- }
+ return GL_TRUE;
}
@@ -246,7 +212,7 @@ intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
ASSERT(rb->Name == 0);
rb->Width = width;
rb->Height = height;
- rb->_ActualFormat = internalFormat;
+ rb->InternalFormat = internalFormat;
return GL_TRUE;
}
@@ -256,7 +222,6 @@ static void
intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
GLuint width, GLuint height)
{
- struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
int i;
_mesa_resize_framebuffer(ctx, fb, width, height);
@@ -267,9 +232,10 @@ intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
return;
}
+
/* Make sure all window system renderbuffers are up to date */
- for (i = 0; i < 2; i++) {
- struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
+ for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
+ struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
/* only resize if size is changing */
if (rb && (rb->Width != width || rb->Height != height)) {
@@ -307,12 +273,11 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *rb,
* not a user-created renderbuffer.
*/
struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat)
+intel_create_renderbuffer(gl_format format)
{
GET_CURRENT_CONTEXT(ctx);
struct intel_renderbuffer *irb;
- const GLuint name = 0;
irb = CALLOC_STRUCT(intel_renderbuffer);
if (!irb) {
@@ -320,75 +285,43 @@ intel_create_renderbuffer(GLenum intFormat)
return NULL;
}
- _mesa_init_renderbuffer(&irb->Base, name);
+ _mesa_init_renderbuffer(&irb->Base, 0);
irb->Base.ClassID = INTEL_RB_CLASS;
- switch (intFormat) {
- case GL_RGB5:
- irb->Base._ActualFormat = GL_RGB5;
- irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 5;
- irb->Base.GreenBits = 6;
- irb->Base.BlueBits = 5;
+ switch (format) {
+ case MESA_FORMAT_RGB565:
+ irb->Base._BaseFormat = GL_RGB;
irb->Base.DataType = GL_UNSIGNED_BYTE;
- irb->texformat = &_mesa_texformat_rgb565;
break;
- case GL_RGB8:
- irb->Base._ActualFormat = GL_RGB8;
+ case MESA_FORMAT_XRGB8888:
irb->Base._BaseFormat = GL_RGB;
- irb->Base.RedBits = 8;
- irb->Base.GreenBits = 8;
- irb->Base.BlueBits = 8;
- irb->Base.AlphaBits = 0;
irb->Base.DataType = GL_UNSIGNED_BYTE;
- irb->texformat = &_mesa_texformat_argb8888; /* XXX: Need xrgb8888 */
break;
- case GL_RGBA8:
- irb->Base._ActualFormat = GL_RGBA8;
+ case MESA_FORMAT_ARGB8888:
irb->Base._BaseFormat = GL_RGBA;
- irb->Base.RedBits = 8;
- irb->Base.GreenBits = 8;
- irb->Base.BlueBits = 8;
- irb->Base.AlphaBits = 8;
- irb->Base.DataType = GL_UNSIGNED_BYTE;
- irb->texformat = &_mesa_texformat_argb8888;
- break;
- case GL_STENCIL_INDEX8_EXT:
- irb->Base._ActualFormat = GL_STENCIL_INDEX8_EXT;
- irb->Base._BaseFormat = GL_STENCIL_INDEX;
- irb->Base.StencilBits = 8;
irb->Base.DataType = GL_UNSIGNED_BYTE;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
- case GL_DEPTH_COMPONENT16:
- irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
+ case MESA_FORMAT_Z16:
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 16;
irb->Base.DataType = GL_UNSIGNED_SHORT;
- irb->texformat = &_mesa_texformat_z16;
break;
- case GL_DEPTH_COMPONENT24:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
+ case MESA_FORMAT_X8_Z24:
irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
- irb->Base.DepthBits = 24;
irb->Base.DataType = GL_UNSIGNED_INT;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
- case GL_DEPTH24_STENCIL8_EXT:
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
- irb->Base.DepthBits = 24;
- irb->Base.StencilBits = 8;
+ case MESA_FORMAT_S8_Z24:
+ irb->Base._BaseFormat = GL_DEPTH_STENCIL;
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
- irb->texformat = &_mesa_texformat_s8_z24;
break;
default:
_mesa_problem(NULL,
"Unexpected intFormat in intel_create_renderbuffer");
+ _mesa_free(irb);
return NULL;
}
- irb->Base.InternalFormat = intFormat;
+ irb->Base.Format = format;
+ irb->Base.InternalFormat = irb->Base._BaseFormat;
/* intel-specific methods */
irb->Base.Delete = intel_delete_renderbuffer;
@@ -465,59 +398,46 @@ static GLboolean
intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
struct gl_texture_image *texImage)
{
- irb->texformat = texImage->TexFormat;
-
- if (texImage->TexFormat == &_mesa_texformat_argb8888) {
- irb->Base._ActualFormat = GL_RGBA8;
- irb->Base._BaseFormat = GL_RGBA;
+ if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGBA8 texture OK\n");
}
- else if (texImage->TexFormat == &_mesa_texformat_rgb565) {
- irb->Base._ActualFormat = GL_RGB5;
- irb->Base._BaseFormat = GL_RGB;
+ else if (texImage->TexFormat == MESA_FORMAT_XRGB8888) {
+ irb->Base.DataType = GL_UNSIGNED_BYTE;
+ DBG("Render to XGBA8 texture OK\n");
+ }
+ else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to RGB5 texture OK\n");
}
- else if (texImage->TexFormat == &_mesa_texformat_argb1555) {
- irb->Base._ActualFormat = GL_RGB5_A1;
- irb->Base._BaseFormat = GL_RGBA;
+ else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB1555 texture OK\n");
}
- else if (texImage->TexFormat == &_mesa_texformat_argb4444) {
- irb->Base._ActualFormat = GL_RGBA4;
- irb->Base._BaseFormat = GL_RGBA;
+ else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
irb->Base.DataType = GL_UNSIGNED_BYTE;
DBG("Render to ARGB4444 texture OK\n");
}
- else if (texImage->TexFormat == &_mesa_texformat_z16) {
- irb->Base._ActualFormat = GL_DEPTH_COMPONENT16;
- irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
+ else if (texImage->TexFormat == MESA_FORMAT_Z16) {
irb->Base.DataType = GL_UNSIGNED_SHORT;
DBG("Render to DEPTH16 texture OK\n");
}
- else if (texImage->TexFormat == &_mesa_texformat_s8_z24) {
- irb->Base._ActualFormat = GL_DEPTH24_STENCIL8_EXT;
- irb->Base._BaseFormat = GL_DEPTH_STENCIL_EXT;
+ else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
DBG("Render to DEPTH_STENCIL texture OK\n");
}
else {
- DBG("Render to texture BAD FORMAT %d\n",
- texImage->TexFormat->MesaFormat);
+ DBG("Render to texture BAD FORMAT %s\n",
+ _mesa_get_format_name(texImage->TexFormat));
return GL_FALSE;
}
- irb->Base.InternalFormat = irb->Base._ActualFormat;
+ irb->Base.Format = texImage->TexFormat;
+
+ irb->Base.InternalFormat = texImage->InternalFormat;
+ irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);
irb->Base.Width = texImage->Width;
irb->Base.Height = texImage->Height;
- irb->Base.RedBits = texImage->TexFormat->RedBits;
- irb->Base.GreenBits = texImage->TexFormat->GreenBits;
- irb->Base.BlueBits = texImage->TexFormat->BlueBits;
- irb->Base.AlphaBits = texImage->TexFormat->AlphaBits;
- irb->Base.DepthBits = texImage->TexFormat->DepthBits;
- irb->Base.StencilBits = texImage->TexFormat->StencilBits;
irb->Base.Delete = intel_delete_renderbuffer;
irb->Base.AllocStorage = intel_nop_alloc_storage;
@@ -571,7 +491,7 @@ intel_render_texture(GLcontext * ctx,
= att->Texture->Image[att->CubeMapFace][att->TextureLevel];
struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
struct intel_texture_image *intel_image;
- GLuint imageOffset;
+ GLuint dst_x, dst_y;
(void) fb;
@@ -618,18 +538,17 @@ intel_render_texture(GLcontext * ctx,
}
/* compute offset of the particular 2D image within the texture region */
- imageOffset = intel_miptree_image_offset(intel_image->mt,
- att->CubeMapFace,
- att->TextureLevel);
-
- if (att->Texture->Target == GL_TEXTURE_3D) {
- const GLuint *offsets = intel_miptree_depth_offsets(intel_image->mt,
- att->TextureLevel);
- imageOffset += offsets[att->Zoffset];
- }
-
- /* store that offset in the region */
- intel_image->mt->region->draw_offset = imageOffset;
+ intel_miptree_get_image_offset(intel_image->mt,
+ att->TextureLevel,
+ att->CubeMapFace,
+ att->Zoffset,
+ &dst_x, &dst_y);
+
+ intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->pitch +
+ dst_x) * intel_image->mt->cpp;
+ intel_image->mt->region->draw_x = dst_x;
+ intel_image->mt->region->draw_y = dst_y;
+ intel_image->used_as_render_target = GL_TRUE;
/* update drawing region, etc */
intel_draw_buffer(ctx, fb);
@@ -643,19 +562,23 @@ static void
intel_finish_render_texture(GLcontext * ctx,
struct gl_renderbuffer_attachment *att)
{
- /* no-op
- * Previously we released the renderbuffer's intel_region but
- * that's not necessary and actually caused problems when trying
- * to do a glRead/CopyPixels from the renderbuffer later.
- * The region will be released later if the texture is replaced
- * or the renderbuffer deleted.
- *
- * The intention of this driver hook is more of a "done rendering
- * to texture, please re-twiddle/etc if necessary".
+ struct intel_context *intel = intel_context(ctx);
+ struct gl_texture_object *tex_obj = att->Texture;
+ struct gl_texture_image *image =
+ tex_obj->Image[att->CubeMapFace][att->TextureLevel];
+ struct intel_texture_image *intel_image = intel_texture_image(image);
+
+ /* Flag that this image may now be validated into the object's miptree. */
+ intel_image->used_as_render_target = GL_FALSE;
+
+ /* Since we've (probably) rendered to the texture and will (likely) use
+ * it in the texture domain later on in this batchbuffer, flush the
+ * batch. Once again, we wish for a domain tracker in libdrm to cover
+ * usage inside of a batchbuffer like GEM does in the kernel.
*/
+ intel_batchbuffer_emit_mi_flush(intel->batch);
}
-
/**
* Do additional "completeness" testing of a framebuffer object.
*/
@@ -668,11 +591,21 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
intel_get_renderbuffer(fb, BUFFER_STENCIL);
int i;
- if (stencilRb && stencilRb != depthRb) {
- /* we only support combined depth/stencil buffers, not separate
- * stencil buffers.
- */
- fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ if (depthRb && stencilRb && stencilRb != depthRb) {
+ if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE &&
+ ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE &&
+ (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Texture->Name ==
+ ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Texture->Name)) {
+ /* OK */
+ } else {
+ /* we only support combined depth/stencil buffers, not separate
+ * stencil buffers.
+ */
+ DBG("Only supports combined depth/stencil (found %s, %s)\n",
+ depthRb ? _mesa_get_format_name(depthRb->Base.Format): "NULL",
+ stencilRb ? _mesa_get_format_name(stencilRb->Base.Format): "NULL");
+ fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
+ }
}
for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
@@ -683,12 +616,14 @@ intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
continue;
if (irb == NULL) {
+ DBG("software rendering renderbuffer\n");
fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
continue;
}
- switch (irb->texformat->MesaFormat) {
+ switch (irb->Base.Format) {
case MESA_FORMAT_ARGB8888:
+ case MESA_FORMAT_XRGB8888:
case MESA_FORMAT_RGB565:
case MESA_FORMAT_ARGB1555:
case MESA_FORMAT_ARGB4444:
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.h b/src/mesa/drivers/dri/intel/intel_fbo.h
index f0665af482..586dbbbb25 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.h
+++ b/src/mesa/drivers/dri/intel/intel_fbo.h
@@ -28,32 +28,12 @@
#ifndef INTEL_FBO_H
#define INTEL_FBO_H
+#include "main/formats.h"
#include "intel_screen.h"
struct intel_context;
/**
- * Intel framebuffer, derived from gl_framebuffer.
- */
-struct intel_framebuffer
-{
- struct gl_framebuffer Base;
-
- struct intel_renderbuffer *color_rb[2];
-
- /* VBI
- */
- GLuint vbl_waited;
-
- int64_t swap_ust;
- int64_t swap_missed_ust;
-
- GLuint swap_count;
- GLuint swap_missed_count;
-};
-
-
-/**
* Intel renderbuffer, derived from gl_renderbuffer.
*/
struct intel_renderbuffer
@@ -61,10 +41,6 @@ struct intel_renderbuffer
struct gl_renderbuffer Base;
struct intel_region *region;
- const struct gl_texture_format *texformat;
-
- GLuint vbl_pending; /**< vblank sequence number of pending flip */
-
uint8_t *span_cache;
unsigned long span_cache_offset;
};
@@ -114,7 +90,7 @@ intel_renderbuffer_set_region(struct intel_renderbuffer *irb,
extern struct intel_renderbuffer *
-intel_create_renderbuffer(GLenum intFormat);
+intel_create_renderbuffer(gl_format format);
extern void
@@ -122,7 +98,7 @@ intel_fbo_init(struct intel_context *intel);
extern void
-intel_flip_renderbuffers(struct intel_framebuffer *intel_fb);
+intel_flip_renderbuffers(struct gl_framebuffer *fb);
static INLINE struct intel_region *
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 4f5101a312..82e4150c6a 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -28,6 +28,7 @@
#include "intel_context.h"
#include "intel_mipmap_tree.h"
#include "intel_regions.h"
+#include "intel_tex_layout.h"
#include "intel_chipset.h"
#ifndef I915
#include "brw_state.h"
@@ -36,6 +37,7 @@
#define FILE_DEBUG_FLAG DEBUG_MIPTREE
+
static GLenum
target_to_target(GLenum target)
{
@@ -52,6 +54,7 @@ target_to_target(GLenum target)
}
}
+
static struct intel_mipmap_tree *
intel_miptree_create_internal(struct intel_context *intel,
GLenum target,
@@ -84,7 +87,7 @@ intel_miptree_create_internal(struct intel_context *intel,
mt->pitch = 0;
#ifdef I915
- if (IS_945(intel->intelScreen->deviceID))
+ if (intel->is_945)
ok = i945_miptree_layout(intel, mt, tiling);
else
ok = i915_miptree_layout(intel, mt, tiling);
@@ -101,6 +104,7 @@ intel_miptree_create_internal(struct intel_context *intel,
return mt;
}
+
struct intel_mipmap_tree *
intel_miptree_create(struct intel_context *intel,
GLenum target,
@@ -118,7 +122,7 @@ intel_miptree_create(struct intel_context *intel,
if (intel->use_texture_tiling && compress_byte == 0 &&
intel->intelScreen->kernel_exec_fencing) {
- if (IS_965(intel->intelScreen->deviceID) &&
+ if (intel->gen >= 4 &&
(base_format == GL_DEPTH_COMPONENT ||
base_format == GL_DEPTH_STENCIL_EXT))
tiling = I915_TILING_Y;
@@ -134,8 +138,10 @@ intel_miptree_create(struct intel_context *intel,
/*
* pitch == 0 || height == 0 indicates the null texture
*/
- if (!mt || !mt->pitch || !mt->total_height)
+ if (!mt || !mt->pitch || !mt->total_height) {
+ free(mt);
return NULL;
+ }
mt->region = intel_region_alloc(intel,
tiling,
@@ -153,6 +159,7 @@ intel_miptree_create(struct intel_context *intel,
return mt;
}
+
struct intel_mipmap_tree *
intel_miptree_create_for_region(struct intel_context *intel,
GLenum target,
@@ -190,7 +197,8 @@ intel_miptree_create_for_region(struct intel_context *intel,
intel_region_reference(&mt->region, region);
return mt;
- }
+}
+
/**
* intel_miptree_pitch_align:
@@ -204,7 +212,6 @@ intel_miptree_create_for_region(struct intel_context *intel,
* Given @pitch, compute a larger value which accounts for
* any necessary alignment required by the device
*/
-
int intel_miptree_pitch_align (struct intel_context *intel,
struct intel_mipmap_tree *mt,
uint32_t tiling,
@@ -217,16 +224,12 @@ int intel_miptree_pitch_align (struct intel_context *intel,
if (!mt->compressed) {
int pitch_align;
- if (intel->ttm) {
- /* XXX: Align pitch to multiple of 64 bytes for now to allow
- * render-to-texture to work in all cases. This should probably be
- * replaced at some point by some scheme to only do this when really
- * necessary.
- */
- pitch_align = 64;
- } else {
- pitch_align = 4;
- }
+ /* XXX: Align pitch to multiple of 64 bytes for now to allow
+ * render-to-texture to work in all cases. This should probably be
+ * replaced at some point by some scheme to only do this when really
+ * necessary.
+ */
+ pitch_align = 64;
if (tiling == I915_TILING_X)
pitch_align = 512;
@@ -250,6 +253,7 @@ int intel_miptree_pitch_align (struct intel_context *intel,
return pitch;
}
+
void
intel_miptree_reference(struct intel_mipmap_tree **dst,
struct intel_mipmap_tree *src)
@@ -259,6 +263,7 @@ intel_miptree_reference(struct intel_mipmap_tree **dst,
DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
}
+
void
intel_miptree_release(struct intel_context *intel,
struct intel_mipmap_tree **mt)
@@ -287,9 +292,10 @@ intel_miptree_release(struct intel_context *intel,
intel_region_release(&((*mt)->region));
- for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
- if ((*mt)->level[i].image_offset)
- free((*mt)->level[i].image_offset);
+ for (i = 0; i < MAX_TEXTURE_LEVELS; i++) {
+ free((*mt)->level[i].x_offset);
+ free((*mt)->level[i].y_offset);
+ }
free(*mt);
}
@@ -297,33 +303,31 @@ intel_miptree_release(struct intel_context *intel,
}
-
-
-/* Can the image be pulled into a unified mipmap tree. This mirrors
+/**
+ * Can the image be pulled into a unified mipmap tree? This mirrors
* the completeness test in a lot of ways.
*
* Not sure whether I want to pass gl_texture_image here.
*/
GLboolean
intel_miptree_match_image(struct intel_mipmap_tree *mt,
- struct gl_texture_image *image,
- GLuint face, GLuint level)
+ struct gl_texture_image *image)
{
- /* Images with borders are never pulled into mipmap trees.
- */
- if (image->Border ||
- ((image->_BaseFormat == GL_DEPTH_COMPONENT) &&
- ((image->TexObject->WrapS == GL_CLAMP_TO_BORDER) ||
- (image->TexObject->WrapT == GL_CLAMP_TO_BORDER))))
+ GLboolean isCompressed = _mesa_is_format_compressed(image->TexFormat);
+ struct intel_texture_image *intelImage = intel_texture_image(image);
+ GLuint level = intelImage->level;
+
+ /* Images with borders are never pulled into mipmap trees. */
+ if (image->Border)
return GL_FALSE;
if (image->InternalFormat != mt->internal_format ||
- image->IsCompressed != mt->compressed)
+ isCompressed != mt->compressed)
return GL_FALSE;
- if (!image->IsCompressed &&
+ if (!isCompressed &&
!mt->compressed &&
- image->TexFormat->TexelBytes != mt->cpp)
+ _mesa_get_format_bytes(image->TexFormat) != mt->cpp)
return GL_FALSE;
/* Test image dimensions against the base level image adjusted for
@@ -350,82 +354,59 @@ intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
mt->level[level].height = h;
mt->level[level].depth = d;
mt->level[level].level_offset = (x + y * mt->pitch) * mt->cpp;
+ mt->level[level].level_x = x;
+ mt->level[level].level_y = y;
mt->level[level].nr_images = nr_images;
DBG("%s level %d size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
level, w, h, d, x, y, mt->level[level].level_offset);
- /* Not sure when this would happen, but anyway:
- */
- if (mt->level[level].image_offset) {
- free(mt->level[level].image_offset);
- mt->level[level].image_offset = NULL;
- }
-
assert(nr_images);
+ assert(!mt->level[level].x_offset);
- mt->level[level].image_offset = malloc(nr_images * sizeof(GLuint));
- mt->level[level].image_offset[0] = 0;
+ mt->level[level].x_offset = malloc(nr_images * sizeof(GLuint));
+ mt->level[level].x_offset[0] = mt->level[level].level_x;
+ mt->level[level].y_offset = malloc(nr_images * sizeof(GLuint));
+ mt->level[level].y_offset[0] = mt->level[level].level_y;
}
void
-intel_miptree_set_image_offset_ex(struct intel_mipmap_tree *mt,
- GLuint level, GLuint img,
- GLuint x, GLuint y,
- GLuint offset)
-{
- if (img == 0 && level == 0)
- assert(x == 0 && y == 0);
-
- assert(img < mt->level[level].nr_images);
-
- mt->level[level].image_offset[img] = (x + y * mt->pitch) * mt->cpp + offset;
-
- DBG("%s level %d img %d pos %d,%d image_offset %x\n",
- __FUNCTION__, level, img, x, y, mt->level[level].image_offset[img]);
-}
-
-void
intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
GLuint level, GLuint img,
GLuint x, GLuint y)
{
- intel_miptree_set_image_offset_ex(mt, level, img, x, y, 0);
-}
+ if (img == 0 && level == 0)
+ assert(x == 0 && y == 0);
+ assert(img < mt->level[level].nr_images);
-/* Although we use the image_offset[] array to store relative offsets
- * to cube faces, Mesa doesn't know anything about this and expects
- * each cube face to be treated as a separate image.
- *
- * These functions present that view to mesa:
- */
-const GLuint *
-intel_miptree_depth_offsets(struct intel_mipmap_tree *mt, GLuint level)
-{
- static const GLuint zero = 0;
+ mt->level[level].x_offset[img] = mt->level[level].level_x + x;
+ mt->level[level].y_offset[img] = mt->level[level].level_y + y;
- if (mt->target != GL_TEXTURE_3D || mt->level[level].nr_images == 1)
- return &zero;
- else
- return mt->level[level].image_offset;
+ DBG("%s level %d img %d pos %d,%d\n",
+ __FUNCTION__, level, img,
+ mt->level[level].x_offset[img], mt->level[level].y_offset[img]);
}
-GLuint
-intel_miptree_image_offset(struct intel_mipmap_tree *mt,
- GLuint face, GLuint level)
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint face, GLuint depth,
+ GLuint *x, GLuint *y)
{
- if (mt->target == GL_TEXTURE_CUBE_MAP_ARB)
- return (mt->level[level].level_offset +
- mt->level[level].image_offset[face]);
- else
- return mt->level[level].level_offset;
+ if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) {
+ *x = mt->level[level].x_offset[face];
+ *y = mt->level[level].y_offset[face];
+ } else if (mt->target == GL_TEXTURE_3D) {
+ *x = mt->level[level].x_offset[depth];
+ *y = mt->level[level].y_offset[depth];
+ } else {
+ *x = mt->level[level].x_offset[0];
+ *y = mt->level[level].y_offset[0];
+ }
}
-
-
/**
* Map a teximage in a mipmap tree.
* \param row_stride returns row stride in bytes
@@ -441,6 +422,7 @@ intel_miptree_image_map(struct intel_context * intel,
GLuint level,
GLuint * row_stride, GLuint * image_offsets)
{
+ GLuint x, y;
DBG("%s \n", __FUNCTION__);
if (row_stride)
@@ -449,19 +431,26 @@ intel_miptree_image_map(struct intel_context * intel,
if (mt->target == GL_TEXTURE_3D) {
int i;
- for (i = 0; i < mt->level[level].depth; i++)
- image_offsets[i] = mt->level[level].image_offset[i] / mt->cpp;
+ for (i = 0; i < mt->level[level].depth; i++) {
+
+ intel_miptree_get_image_offset(mt, level, face, i,
+ &x, &y);
+ image_offsets[i] = x + y * mt->pitch;
+ }
+
+ return intel_region_map(intel, mt->region);
} else {
assert(mt->level[level].depth == 1);
- assert(mt->target == GL_TEXTURE_CUBE_MAP ||
- mt->level[level].image_offset[0] == 0);
+ intel_miptree_get_image_offset(mt, level, face, 0,
+ &x, &y);
image_offsets[0] = 0;
- }
- return (intel_region_map(intel, mt->region) +
- intel_miptree_image_offset(mt, face, level));
+ return intel_region_map(intel, mt->region) +
+ (x + y * mt->pitch) * mt->cpp;
+ }
}
+
void
intel_miptree_image_unmap(struct intel_context *intel,
struct intel_mipmap_tree *mt)
@@ -471,8 +460,8 @@ intel_miptree_image_unmap(struct intel_context *intel,
}
-
-/* Upload data for a particular image.
+/**
+ * Upload data for a particular image.
*/
void
intel_miptree_image_data(struct intel_context *intel,
@@ -483,21 +472,21 @@ intel_miptree_image_data(struct intel_context *intel,
GLuint src_row_pitch,
GLuint src_image_pitch)
{
- GLuint depth = dst->level[level].depth;
- GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
- const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
+ const GLuint depth = dst->level[level].depth;
GLuint i;
- GLuint height = 0;
DBG("%s: %d/%d\n", __FUNCTION__, face, level);
for (i = 0; i < depth; i++) {
+ GLuint dst_x, dst_y, height;
+
+ intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
+
height = dst->level[level].height;
if(dst->compressed)
height = (height + 3) / 4;
+
intel_region_data(intel,
- dst->region,
- dst_offset + dst_depth_offset[i], /* dst_offset */
- 0, 0, /* dstx, dsty */
+ dst->region, 0, dst_x, dst_y,
src,
src_row_pitch,
0, 0, /* source x, y */
@@ -507,8 +496,9 @@ intel_miptree_image_data(struct intel_context *intel,
}
}
-extern void intel_get_texture_alignment_unit(GLenum, GLuint *, GLuint *);
-/* Copy mipmap image between trees
+
+/**
+ * Copy mipmap image between trees
*/
void
intel_miptree_image_copy(struct intel_context *intel,
@@ -519,38 +509,37 @@ intel_miptree_image_copy(struct intel_context *intel,
GLuint width = src->level[level].width;
GLuint height = src->level[level].height;
GLuint depth = src->level[level].depth;
- GLuint dst_offset = intel_miptree_image_offset(dst, face, level);
- GLuint src_offset = intel_miptree_image_offset(src, face, level);
- const GLuint *dst_depth_offset = intel_miptree_depth_offsets(dst, level);
- const GLuint *src_depth_offset = intel_miptree_depth_offsets(src, level);
+ GLuint src_x, src_y, dst_x, dst_y;
GLuint i;
GLboolean success;
if (dst->compressed) {
GLuint align_w, align_h;
- intel_get_texture_alignment_unit(dst->internal_format, &align_w, &align_h);
+ intel_get_texture_alignment_unit(dst->internal_format,
+ &align_w, &align_h);
height = (height + 3) / 4;
width = ALIGN(width, align_w);
}
for (i = 0; i < depth; i++) {
+ intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y);
+ intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y);
success = intel_region_copy(intel,
- dst->region, dst_offset + dst_depth_offset[i],
- 0, 0,
- src->region, src_offset + src_depth_offset[i],
- 0, 0, width, height, GL_COPY);
+ dst->region, 0, dst_x, dst_y,
+ src->region, 0, src_x, src_y, width, height,
+ GL_COPY);
if (!success) {
GLubyte *src_ptr, *dst_ptr;
src_ptr = intel_region_map(intel, src->region);
dst_ptr = intel_region_map(intel, dst->region);
- _mesa_copy_rect(dst_ptr + dst_offset + dst_depth_offset[i],
+ _mesa_copy_rect(dst_ptr + dst->cpp * (dst_x + dst_y * dst->pitch),
dst->cpp,
dst->pitch,
0, 0, width, height,
- src_ptr + src_offset + src_depth_offset[i],
+ src_ptr + src->cpp * (src_x + src_y * src->pitch),
src->pitch,
0, 0);
intel_region_unmap(intel, src->region);
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
index c890b2a0d0..b19c548def 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.h
@@ -70,6 +70,10 @@ struct intel_mipmap_level
* always zero in that case.
*/
GLuint level_offset;
+ /** Offset to this miptree level, used in computing x_offset. */
+ GLuint level_x;
+ /** Offset to this miptree level, used in computing y_offset. */
+ GLuint level_y;
GLuint width;
GLuint height;
/** Depth of the mipmap at this level: 1 for 1D/2D/CUBE, n for 3D. */
@@ -86,7 +90,7 @@ struct intel_mipmap_level
* compute the offsets of depth/cube images within a mipmap level,
* so have to store them as a lookup table.
*/
- GLuint *image_offset;
+ GLuint *x_offset, *y_offset;
};
struct intel_mipmap_tree
@@ -161,8 +165,7 @@ void intel_miptree_release(struct intel_context *intel,
/* Check if an image fits an existing mipmap tree layout
*/
GLboolean intel_miptree_match_image(struct intel_mipmap_tree *mt,
- struct gl_texture_image *image,
- GLuint face, GLuint level);
+ struct gl_texture_image *image);
/* Return a pointer to an image within a tree. Return image stride as
* well.
@@ -176,19 +179,10 @@ GLubyte *intel_miptree_image_map(struct intel_context *intel,
void intel_miptree_image_unmap(struct intel_context *intel,
struct intel_mipmap_tree *mt);
-
-/* Return the linear offset of an image relative to the start of the
- * tree:
- */
-GLuint intel_miptree_image_offset(struct intel_mipmap_tree *mt,
- GLuint face, GLuint level);
-
-/* Return pointers to each 2d slice within an image. Indexed by depth
- * value.
- */
-const GLuint *intel_miptree_depth_offsets(struct intel_mipmap_tree *mt,
- GLuint level);
-
+void
+intel_miptree_get_image_offset(struct intel_mipmap_tree *mt,
+ GLuint level, GLuint face, GLuint depth,
+ GLuint *x, GLuint *y);
void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
GLuint level,
@@ -196,16 +190,10 @@ void intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
GLuint x, GLuint y,
GLuint w, GLuint h, GLuint d);
-void intel_miptree_set_image_offset_ex(struct intel_mipmap_tree *mt,
- GLuint level,
- GLuint img, GLuint x, GLuint y,
- GLuint offset);
-
void intel_miptree_set_image_offset(struct intel_mipmap_tree *mt,
GLuint level,
GLuint img, GLuint x, GLuint y);
-
/* Upload an image into a tree
*/
void intel_miptree_image_data(struct intel_context *intel,
diff --git a/src/mesa/drivers/dri/intel/intel_pixel.c b/src/mesa/drivers/dri/intel/intel_pixel.c
index 993e427a99..5142f3dcd9 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel.c
@@ -88,10 +88,10 @@ intel_check_blit_fragment_ops(GLcontext * ctx, GLboolean src_alpha_is_one)
return GL_FALSE;
}
- if (!(ctx->Color.ColorMask[0] &&
- ctx->Color.ColorMask[1] &&
- ctx->Color.ColorMask[2] &&
- ctx->Color.ColorMask[3])) {
+ if (!(ctx->Color.ColorMask[0][0] &&
+ ctx->Color.ColorMask[0][1] &&
+ ctx->Color.ColorMask[0][2] &&
+ ctx->Color.ColorMask[0][3])) {
DBG("fallback due to color masking\n");
return GL_FALSE;
}
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
index 9a0bcc07a5..85e5ad2cdd 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_bitmap.c
@@ -32,7 +32,9 @@
#include "main/mtypes.h"
#include "main/macros.h"
#include "main/bufferobj.h"
+#include "main/polygon.h"
#include "main/pixelstore.h"
+#include "main/polygon.h"
#include "main/state.h"
#include "main/teximage.h"
#include "main/texenv.h"
@@ -164,7 +166,7 @@ static GLuint get_bitmap_rect(GLsizei width, GLsizei height,
* Returns the low Y value of the vertical range given, flipped according to
* whether the framebuffer is or not.
*/
-static inline int
+static INLINE int
y_flip(struct gl_framebuffer *fb, int y, int height)
{
if (fb->Name != 0)
@@ -227,16 +229,13 @@ do_blit_bitmap( GLcontext *ctx,
UNCLAMPED_FLOAT_TO_UBYTE(ubcolor[3], tmpColor[3]);
if (dst->cpp == 2)
- color = INTEL_PACKCOLOR565(ubcolor[0], ubcolor[1], ubcolor[2]);
+ color = PACK_COLOR_565(ubcolor[0], ubcolor[1], ubcolor[2]);
else
- color = INTEL_PACKCOLOR8888(ubcolor[0], ubcolor[1],
- ubcolor[2], ubcolor[3]);
+ color = PACK_COLOR_8888(ubcolor[3], ubcolor[0], ubcolor[1], ubcolor[2]);
if (!intel_check_blit_fragment_ops(ctx, tmpColor[3] == 1.0F))
return GL_FALSE;
- LOCK_HARDWARE(intel);
-
intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
if (num_cliprects != 0) {
GLuint i;
@@ -324,7 +323,6 @@ do_blit_bitmap( GLcontext *ctx,
}
}
out:
- UNLOCK_HARDWARE(intel);
if (INTEL_DEBUG & DEBUG_SYNC)
intel_batchbuffer_flush(intel->batch);
@@ -335,6 +333,8 @@ out:
unpack->BufferObj);
}
+ intel_check_front_buffer_rendering(intel);
+
return GL_TRUE;
}
@@ -435,13 +435,14 @@ intel_texture_bitmap(GLcontext * ctx,
}
/* Save GL state before we start setting up our drawing */
- _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT |
- GL_VIEWPORT_BIT);
+ _mesa_PushAttrib(GL_ENABLE_BIT | GL_CURRENT_BIT | GL_POLYGON_BIT |
+ GL_TEXTURE_BIT | GL_VIEWPORT_BIT);
_mesa_PushClientAttrib(GL_CLIENT_VERTEX_ARRAY_BIT |
GL_CLIENT_PIXEL_STORE_BIT);
old_active_texture = ctx->Texture.CurrentUnit;
_mesa_Disable(GL_POLYGON_STIPPLE);
+ _mesa_PolygonMode(GL_FRONT_AND_BACK, GL_FILL);
/* Upload our bitmap data to an alpha texture */
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB);
@@ -500,9 +501,8 @@ intel_texture_bitmap(GLcontext * ctx,
meta_restore_fragment_program(&intel->meta);
meta_restore_vertex_program(&intel->meta);
- _mesa_PopClientAttrib();
- _mesa_Disable(GL_TEXTURE_2D); /* asserted that it was disabled at entry */
_mesa_ActiveTextureARB(GL_TEXTURE0_ARB + old_active_texture);
+ _mesa_PopClientAttrib();
_mesa_PopAttrib();
_mesa_DeleteTextures(1, &texname);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
index f058b3c8e4..e002516cdd 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c
@@ -35,28 +35,33 @@
#include "intel_buffers.h"
#include "intel_regions.h"
#include "intel_pixel.h"
+#include "intel_fbo.h"
#define FILE_DEBUG_FLAG DEBUG_PIXEL
static struct intel_region *
copypix_src_region(struct intel_context *intel, GLenum type)
{
+ struct intel_renderbuffer *depth;
+
+ depth = (struct intel_renderbuffer *)
+ &intel->ctx.DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer;
+
switch (type) {
case GL_COLOR:
return intel_readbuf_region(intel);
case GL_DEPTH:
- /* Don't think this is really possible execpt at 16bpp, when we have no stencil.
- */
- if (intel->depth_region && intel->depth_region->cpp == 2)
- return intel->depth_region;
+ /* Don't think this is really possible execpt at 16bpp, when we
+ * have no stencil. */
+ if (depth && depth->region->cpp == 2)
+ return depth->region;
case GL_STENCIL:
- /* Don't think this is really possible.
- */
+ /* Don't think this is really possible. */
break;
case GL_DEPTH_STENCIL_EXT:
/* Does it matter whether it is stencil/depth or depth/stencil?
*/
- return intel->depth_region;
+ return depth->region;
default:
break;
}
@@ -83,10 +88,10 @@ intel_check_copypixel_blit_fragment_ops(GLcontext * ctx)
ctx->Depth.Test ||
ctx->Fog.Enabled ||
ctx->Stencil._Enabled ||
- !ctx->Color.ColorMask[0] ||
- !ctx->Color.ColorMask[1] ||
- !ctx->Color.ColorMask[2] ||
- !ctx->Color.ColorMask[3] ||
+ !ctx->Color.ColorMask[0][0] ||
+ !ctx->Color.ColorMask[0][1] ||
+ !ctx->Color.ColorMask[0][2] ||
+ !ctx->Color.ColorMask[0][3] ||
ctx->Texture._EnabledUnits ||
ctx->FragmentProgram._Enabled ||
ctx->Color.BlendEnabled);
@@ -134,8 +139,6 @@ do_blit_copypixels(GLcontext * ctx,
intelFlush(&intel->ctx);
- LOCK_HARDWARE(intel);
-
intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
if (num_cliprects != 0) {
GLint delta_x;
@@ -214,13 +217,13 @@ do_blit_copypixels(GLcontext * ctx,
ctx->Color.ColorLogicOpEnabled ?
ctx->Color.LogicOp : GL_COPY)) {
DBG("%s: blit failure\n", __FUNCTION__);
- UNLOCK_HARDWARE(intel);
return GL_FALSE;
}
}
}
out:
- UNLOCK_HARDWARE(intel);
+
+ intel_check_front_buffer_rendering(intel);
DBG("%s: success\n", __FUNCTION__);
return GL_TRUE;
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_draw.c b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
index 5ffa847fd4..b870e9315e 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_draw.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_draw.c
@@ -69,7 +69,6 @@ intel_stencil_drawpixels(GLcontext * ctx,
GLfloat vertices[4][2];
struct intel_renderbuffer *irb;
struct intel_renderbuffer *depth_irb;
- struct gl_renderbuffer *rb;
struct gl_pixelstore_attrib old_unpack;
GLstencil *stencil_pixels;
int row, y1, y2;
@@ -169,8 +168,7 @@ intel_stencil_drawpixels(GLcontext * ctx,
* buffer.
*/
depth_irb = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_DEPTH);
- irb = intel_create_renderbuffer(GL_RGBA8);
- rb = &irb->Base;
+ irb = intel_create_renderbuffer(MESA_FORMAT_ARGB8888);
irb->Base.Width = depth_irb->Base.Width;
irb->Base.Height = depth_irb->Base.Height;
intel_renderbuffer_set_region(irb, depth_irb->region);
diff --git a/src/mesa/drivers/dri/intel/intel_pixel_read.c b/src/mesa/drivers/dri/intel/intel_pixel_read.c
index 4707500180..9c0fdc6067 100644
--- a/src/mesa/drivers/dri/intel/intel_pixel_read.c
+++ b/src/mesa/drivers/dri/intel/intel_pixel_read.c
@@ -77,7 +77,7 @@ do_texture_readpixels(GLcontext * ctx,
struct intel_context *intel = intel_context(ctx);
intelScreenPrivate *screen = intel->intelScreen;
GLint pitch = pack->RowLength ? pack->RowLength : width;
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
+ __DRIdrawable *dPriv = intel->driDrawable;
int textureFormat;
GLenum glTextureFormat;
int destFormat, depthFormat, destPitch;
@@ -105,15 +105,12 @@ do_texture_readpixels(GLcontext * ctx,
return GL_FALSE;
}
- LOCK_HARDWARE(intel);
-
if (intel->driDrawable->numClipRects) {
intel->vtbl.install_meta_state(intel);
intel->vtbl.meta_no_depth_write(intel);
intel->vtbl.meta_no_stencil_write(intel);
if (!driClipRectToFramebuffer(ctx->ReadBuffer, &x, &y, &width, &height)) {
- UNLOCK_HARDWARE(intel);
SET_STATE(i830, state);
if (INTEL_DEBUG & DEBUG_PIXEL)
fprintf(stderr, "%s: cliprect failed\n", __FUNCTION__);
@@ -150,7 +147,6 @@ do_texture_readpixels(GLcontext * ctx,
intel->vtbl.leave_meta_state(intel);
}
- UNLOCK_HARDWARE(intel);
intel_region_wait_fence(ctx, dest_region); /* required by GL */
return GL_TRUE;
@@ -224,7 +220,6 @@ do_blit_readpixels(GLcontext * ctx,
* fire with lock held to guarentee cliprects are correct.
*/
intelFlush(&intel->ctx);
- LOCK_HARDWARE(intel);
if (intel->driReadDrawable->numClipRects) {
GLboolean all = (width * height * src->cpp == dst->Base.Size &&
@@ -233,7 +228,7 @@ do_blit_readpixels(GLcontext * ctx,
dri_bo *dst_buffer = intel_bufferobj_buffer(intel, dst,
all ? INTEL_WRITE_FULL :
INTEL_WRITE_PART);
- __DRIdrawablePrivate *dPriv = intel->driReadDrawable;
+ __DRIdrawable *dPriv = intel->driReadDrawable;
int nbox = dPriv->numClipRects;
drm_clip_rect_t *box = dPriv->pClipRects;
drm_clip_rect_t rect;
@@ -261,12 +256,10 @@ do_blit_readpixels(GLcontext * ctx,
rect.y2 - src_rect.y2,
rect.x2 - rect.x1, rect.y2 - rect.y1,
GL_COPY)) {
- UNLOCK_HARDWARE(intel);
return GL_FALSE;
}
}
}
- UNLOCK_HARDWARE(intel);
if (INTEL_DEBUG & DEBUG_PIXEL)
_mesa_printf("%s - DONE\n", __FUNCTION__);
@@ -285,11 +278,11 @@ intelReadPixels(GLcontext * ctx,
intelFlush(ctx);
-#ifdef I915
if (do_blit_readpixels
(ctx, x, y, width, height, format, type, pack, pixels))
return;
+#ifdef I915
if (do_texture_readpixels
(ctx, x, y, width, height, format, type, pack, pixels))
return;
diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c
index a86c66a844..61aefa01b8 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.c
+++ b/src/mesa/drivers/dri/intel/intel_regions.c
@@ -362,14 +362,12 @@ intel_region_data(struct intel_context *intel,
intel_region_cow(intel, dst);
}
- LOCK_HARDWARE(intel);
_mesa_copy_rect(intel_region_map(intel, dst) + dst_offset,
dst->cpp,
dst->pitch,
dstx, dsty, width, height, src, src_pitch, srcx, srcy);
intel_region_unmap(intel, dst);
- UNLOCK_HARDWARE(intel);
}
/* Copy rectangular sub-regions. Need better logic about when to
@@ -485,7 +483,6 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
/* Now blit from the texture buffer to the new buffer:
*/
- LOCK_HARDWARE(intel);
ok = intelEmitCopyBlit(intel,
region->cpp,
region->pitch, pbo->buffer, 0, region->tiling,
@@ -494,7 +491,6 @@ intel_region_cow(struct intel_context *intel, struct intel_region *region)
region->pitch, region->height,
GL_COPY);
assert(ok);
- UNLOCK_HARDWARE(intel);
}
dri_bo *
@@ -510,126 +506,3 @@ intel_region_buffer(struct intel_context *intel,
return region->buffer;
}
-
-static struct intel_region *
-intel_recreate_static(struct intel_context *intel,
- const char *name,
- struct intel_region *region,
- intelRegion *region_desc)
-{
- intelScreenPrivate *intelScreen = intel->intelScreen;
- int ret;
-
- if (region == NULL) {
- region = calloc(sizeof(*region), 1);
- region->refcount = 1;
- _DBG("%s creating new region %p\n", __FUNCTION__, region);
- }
- else {
- _DBG("%s %p\n", __FUNCTION__, region);
- }
-
- if (intel->ctx.Visual.rgbBits == 24)
- region->cpp = 4;
- else
- region->cpp = intel->ctx.Visual.rgbBits / 8;
- region->pitch = intelScreen->pitch;
- region->width = intelScreen->width;
- region->height = intelScreen->height;
-
- if (region->buffer != NULL) {
- dri_bo_unreference(region->buffer);
- region->buffer = NULL;
- }
-
- if (intel->ttm) {
- assert(region_desc->bo_handle != -1);
- region->buffer = intel_bo_gem_create_from_name(intel->bufmgr,
- name,
- region_desc->bo_handle);
-
- ret = dri_bo_get_tiling(region->buffer, &region->tiling,
- &region->bit_6_swizzle);
- if (ret != 0) {
- fprintf(stderr, "Couldn't get tiling of buffer %d (%s): %s\n",
- region_desc->bo_handle, name, strerror(-ret));
- intel_region_release(&region);
- return NULL;
- }
- } else {
- if (region->classic_map != NULL) {
- drmUnmap(region->classic_map,
- region->pitch * region->cpp * region->height);
- region->classic_map = NULL;
- }
- ret = drmMap(intel->driFd, region_desc->handle,
- region->pitch * region->cpp * region->height,
- &region->classic_map);
- if (ret != 0) {
- fprintf(stderr, "Failed to drmMap %s buffer\n", name);
- free(region);
- return NULL;
- }
-
- region->buffer = intel_bo_fake_alloc_static(intel->bufmgr,
- name,
- region_desc->offset,
- region->pitch * region->cpp *
- region->height,
- region->classic_map);
-
- /* The sarea just gives us a boolean for whether it's tiled or not,
- * instead of which tiling mode it is. Guess.
- */
- if (region_desc->tiled) {
- if (IS_965(intel->intelScreen->deviceID) &&
- region_desc == &intelScreen->depth)
- region->tiling = I915_TILING_Y;
- else
- region->tiling = I915_TILING_X;
- } else {
- region->tiling = I915_TILING_NONE;
- }
-
- region->bit_6_swizzle = I915_BIT_6_SWIZZLE_NONE;
- }
-
- assert(region->buffer != NULL);
-
- return region;
-}
-
-/**
- * Create intel_region structs to describe the static front, back, and depth
- * buffers created by the xserver.
- *
- * Although FBO's mean we now no longer use these as render targets in
- * all circumstances, they won't go away until the back and depth
- * buffers become private, and the front buffer will remain even then.
- *
- * Note that these don't allocate video memory, just describe
- * allocations alread made by the X server.
- */
-void
-intel_recreate_static_regions(struct intel_context *intel)
-{
- intelScreenPrivate *intelScreen = intel->intelScreen;
-
- intel->front_region =
- intel_recreate_static(intel, "front",
- intel->front_region,
- &intelScreen->front);
-
- intel->back_region =
- intel_recreate_static(intel, "back",
- intel->back_region,
- &intelScreen->back);
-
- /* Still assumes front.cpp == depth.cpp. We can kill this when we move to
- * private buffers.
- */
- intel->depth_region =
- intel_recreate_static(intel, "depth",
- intel->depth_region,
- &intelScreen->depth);
-}
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index 0d379bdc6e..535fcd7be0 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -62,6 +62,8 @@ struct intel_region
GLuint map_refcount; /**< Reference count for mapping */
GLuint draw_offset; /**< Offset of drawing address within the region */
+ GLuint draw_x, draw_y; /**< Offset of drawing within the region */
+
uint32_t tiling; /**< Which tiling mode the region is in */
uint32_t bit_6_swizzle; /**< GEM flag for address swizzling requirement */
drmAddress classic_map; /**< drmMap of the region when not in GEM mode */
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 24f7fbc992..5165716e09 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -31,7 +31,6 @@
#include "main/renderbuffer.h"
#include "utils.h"
-#include "vblank.h"
#include "xmlpool.h"
#include "intel_batchbuffer.h"
@@ -41,7 +40,6 @@
#include "intel_extensions.h"
#include "intel_fbo.h"
#include "intel_regions.h"
-#include "intel_swapbuffers.h"
#include "intel_screen.h"
#include "intel_span.h"
#include "intel_tex.h"
@@ -57,7 +55,6 @@
PUBLIC const char __driConfigOptions[] =
DRI_CONF_BEGIN
DRI_CONF_SECTION_PERFORMANCE
- DRI_CONF_FTHROTTLE_MODE(DRI_CONF_FTHROTTLE_IRQS)
DRI_CONF_VBLANK_MODE(DRI_CONF_VBLANK_ALWAYS_SYNC)
/* Options correspond to DRI_CONF_BO_REUSE_DISABLED,
* DRI_CONF_BO_REUSE_ALL
@@ -99,133 +96,12 @@ PUBLIC const char __driConfigOptions[] =
DRI_CONF_SECTION_END
DRI_CONF_END;
-const GLuint __driNConfigOptions = 12;
+const GLuint __driNConfigOptions = 11;
#ifdef USE_NEW_INTERFACE
static PFNGLXCREATECONTEXTMODES create_context_modes = NULL;
#endif /*USE_NEW_INTERFACE */
-/**
- * Map all the memory regions described by the screen.
- * \return GL_TRUE if success, GL_FALSE if error.
- */
-GLboolean
-intelMapScreenRegions(__DRIscreenPrivate * sPriv)
-{
- intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
-
- if (0)
- _mesa_printf("TEX 0x%08x ", intelScreen->tex.handle);
- if (intelScreen->tex.size != 0) {
- if (drmMap(sPriv->fd,
- intelScreen->tex.handle,
- intelScreen->tex.size,
- (drmAddress *) & intelScreen->tex.map) != 0) {
- intelUnmapScreenRegions(intelScreen);
- return GL_FALSE;
- }
- }
-
- return GL_TRUE;
-}
-
-void
-intelUnmapScreenRegions(intelScreenPrivate * intelScreen)
-{
- if (intelScreen->tex.map) {
- drmUnmap(intelScreen->tex.map, intelScreen->tex.size);
- intelScreen->tex.map = NULL;
- }
-}
-
-
-static void
-intelPrintDRIInfo(intelScreenPrivate * intelScreen,
- __DRIscreenPrivate * sPriv, I830DRIPtr gDRIPriv)
-{
- fprintf(stderr, "*** Front size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->front.size, intelScreen->front.offset,
- intelScreen->pitch);
- fprintf(stderr, "*** Back size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->back.size, intelScreen->back.offset,
- intelScreen->pitch);
- fprintf(stderr, "*** Depth size: 0x%x offset: 0x%x pitch: %d\n",
- intelScreen->depth.size, intelScreen->depth.offset,
- intelScreen->pitch);
- fprintf(stderr, "*** Texture size: 0x%x offset: 0x%x\n",
- intelScreen->tex.size, intelScreen->tex.offset);
- fprintf(stderr, "*** Memory : 0x%x\n", gDRIPriv->mem);
-}
-
-
-static void
-intelPrintSAREA(const drm_i915_sarea_t * sarea)
-{
- fprintf(stderr, "SAREA: sarea width %d height %d\n", sarea->width,
- sarea->height);
- fprintf(stderr, "SAREA: pitch: %d\n", sarea->pitch);
- fprintf(stderr,
- "SAREA: front offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
- sarea->front_offset, sarea->front_size,
- (unsigned) sarea->front_handle, sarea->front_tiled);
- fprintf(stderr,
- "SAREA: back offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
- sarea->back_offset, sarea->back_size,
- (unsigned) sarea->back_handle, sarea->back_tiled);
- fprintf(stderr, "SAREA: depth offset: 0x%08x size: 0x%x handle: 0x%x tiled: %d\n",
- sarea->depth_offset, sarea->depth_size,
- (unsigned) sarea->depth_handle, sarea->depth_tiled);
- fprintf(stderr, "SAREA: tex offset: 0x%08x size: 0x%x handle: 0x%x\n",
- sarea->tex_offset, sarea->tex_size, (unsigned) sarea->tex_handle);
-}
-
-
-/**
- * A number of the screen parameters are obtained/computed from
- * information in the SAREA. This function updates those parameters.
- */
-static void
-intelUpdateScreenFromSAREA(intelScreenPrivate * intelScreen,
- drm_i915_sarea_t * sarea)
-{
- intelScreen->width = sarea->width;
- intelScreen->height = sarea->height;
- intelScreen->pitch = sarea->pitch;
-
- intelScreen->front.offset = sarea->front_offset;
- intelScreen->front.handle = sarea->front_handle;
- intelScreen->front.size = sarea->front_size;
- intelScreen->front.tiled = sarea->front_tiled;
-
- intelScreen->back.offset = sarea->back_offset;
- intelScreen->back.handle = sarea->back_handle;
- intelScreen->back.size = sarea->back_size;
- intelScreen->back.tiled = sarea->back_tiled;
-
- intelScreen->depth.offset = sarea->depth_offset;
- intelScreen->depth.handle = sarea->depth_handle;
- intelScreen->depth.size = sarea->depth_size;
- intelScreen->depth.tiled = sarea->depth_tiled;
-
- if (intelScreen->driScrnPriv->ddx_version.minor >= 9) {
- intelScreen->front.bo_handle = sarea->front_bo_handle;
- intelScreen->back.bo_handle = sarea->back_bo_handle;
- intelScreen->depth.bo_handle = sarea->depth_bo_handle;
- } else {
- intelScreen->front.bo_handle = -1;
- intelScreen->back.bo_handle = -1;
- intelScreen->depth.bo_handle = -1;
- }
-
- intelScreen->tex.offset = sarea->tex_offset;
- intelScreen->logTextureGranularity = sarea->log_tex_granularity;
- intelScreen->tex.handle = sarea->tex_handle;
- intelScreen->tex.size = sarea->tex_size;
-
- if (0)
- intelPrintSAREA(sarea);
-}
-
static const __DRItexOffsetExtension intelTexOffsetExtension = {
{ __DRI_TEX_OFFSET },
intelSetTexOffset,
@@ -239,17 +115,13 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
static const __DRIextension *intelScreenExtensions[] = {
&driReadDrawableExtension,
- &driCopySubBufferExtension.base,
- &driSwapControlExtension.base,
- &driFrameTrackingExtension.base,
- &driMediaStreamCounterExtension.base,
&intelTexOffsetExtension.base,
&intelTexBufferExtension.base,
NULL
};
static GLboolean
-intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
+intel_get_param(__DRIscreen *psp, int param, int *value)
{
int ret;
struct drm_i915_getparam gp;
@@ -266,68 +138,12 @@ intel_get_param(__DRIscreenPrivate *psp, int param, int *value)
return GL_TRUE;
}
-static GLboolean intelInitDriver(__DRIscreenPrivate *sPriv)
-{
- intelScreenPrivate *intelScreen;
- I830DRIPtr gDRIPriv = (I830DRIPtr) sPriv->pDevPriv;
- drm_i915_sarea_t *sarea;
-
- if (sPriv->devPrivSize != sizeof(I830DRIRec)) {
- fprintf(stderr,
- "\nERROR! sizeof(I830DRIRec) does not match passed size from device driver\n");
- return GL_FALSE;
- }
-
- /* Allocate the private area */
- intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
- if (!intelScreen) {
- fprintf(stderr, "\nERROR! Allocating private area failed\n");
- return GL_FALSE;
- }
- /* parse information in __driConfigOptions */
- driParseOptionInfo(&intelScreen->optionCache,
- __driConfigOptions, __driNConfigOptions);
-
- intelScreen->driScrnPriv = sPriv;
- sPriv->private = (void *) intelScreen;
- sarea = (drm_i915_sarea_t *)
- (((GLubyte *) sPriv->pSAREA) + gDRIPriv->sarea_priv_offset);
- intelScreen->sarea = sarea;
-
- intelScreen->deviceID = gDRIPriv->deviceID;
-
- intelUpdateScreenFromSAREA(intelScreen, sarea);
-
- if (!intelMapScreenRegions(sPriv)) {
- fprintf(stderr, "\nERROR! mapping regions\n");
- _mesa_free(intelScreen);
- sPriv->private = NULL;
- return GL_FALSE;
- }
-
- if (0)
- intelPrintDRIInfo(intelScreen, sPriv, gDRIPriv);
-
- intelScreen->drmMinor = sPriv->drm_version.minor;
-
- /* Determine if IRQs are active? */
- if (!intel_get_param(sPriv, I915_PARAM_IRQ_ACTIVE,
- &intelScreen->irq_active))
- return GL_FALSE;
-
- sPriv->extensions = intelScreenExtensions;
-
- return GL_TRUE;
-}
-
-
static void
-intelDestroyScreen(__DRIscreenPrivate * sPriv)
+intelDestroyScreen(__DRIscreen * sPriv)
{
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
dri_bufmgr_destroy(intelScreen->bufmgr);
- intelUnmapScreenRegions(intelScreen);
driDestroyOptionInfo(&intelScreen->optionCache);
FREE(intelScreen);
@@ -339,160 +155,106 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
* This is called when we need to set up GL rendering to a new X window.
*/
static GLboolean
-intelCreateBuffer(__DRIscreenPrivate * driScrnPriv,
- __DRIdrawablePrivate * driDrawPriv,
+intelCreateBuffer(__DRIscreen * driScrnPriv,
+ __DRIdrawable * driDrawPriv,
const __GLcontextModes * mesaVis, GLboolean isPixmap)
{
+ struct intel_renderbuffer *rb;
+
if (isPixmap) {
return GL_FALSE; /* not implemented */
}
else {
GLboolean swStencil = (mesaVis->stencilBits > 0 &&
mesaVis->depthBits != 24);
- GLenum rgbFormat;
+ gl_format rgbFormat;
- struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
+ struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
- if (!intel_fb)
+ if (!fb)
return GL_FALSE;
- _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
+ _mesa_initialize_framebuffer(fb, mesaVis);
if (mesaVis->redBits == 5)
- rgbFormat = GL_RGB5;
+ rgbFormat = MESA_FORMAT_RGB565;
else if (mesaVis->alphaBits == 0)
- rgbFormat = GL_RGB8;
+ rgbFormat = MESA_FORMAT_XRGB8888;
else
- rgbFormat = GL_RGBA8;
+ rgbFormat = MESA_FORMAT_ARGB8888;
/* setup the hardware-based renderbuffers */
- intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
- &intel_fb->color_rb[0]->Base);
+ rb = intel_create_renderbuffer(rgbFormat);
+ _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base);
if (mesaVis->doubleBufferMode) {
- intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat);
-
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
- &intel_fb->color_rb[1]->Base);
-
+ rb = intel_create_renderbuffer(rgbFormat);
+ _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base);
}
if (mesaVis->depthBits == 24) {
if (mesaVis->stencilBits == 8) {
/* combined depth/stencil buffer */
struct intel_renderbuffer *depthStencilRb
- = intel_create_renderbuffer(GL_DEPTH24_STENCIL8_EXT);
+ = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
/* note: bind RB to two attachment points */
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
- &depthStencilRb->Base);
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
- &depthStencilRb->Base);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
+ _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
} else {
struct intel_renderbuffer *depthRb
- = intel_create_renderbuffer(GL_DEPTH_COMPONENT24);
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
- &depthRb->Base);
+ = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
}
}
else if (mesaVis->depthBits == 16) {
/* just 16-bit depth buffer, no hw stencil */
struct intel_renderbuffer *depthRb
- = intel_create_renderbuffer(GL_DEPTH_COMPONENT16);
- _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
+ = intel_create_renderbuffer(MESA_FORMAT_Z16);
+ _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
}
/* now add any/all software-based renderbuffers we may need */
- _mesa_add_soft_renderbuffers(&intel_fb->Base,
+ _mesa_add_soft_renderbuffers(fb,
GL_FALSE, /* never sw color */
GL_FALSE, /* never sw depth */
swStencil, mesaVis->accumRedBits > 0,
GL_FALSE, /* never sw alpha */
GL_FALSE /* never sw aux */ );
- driDrawPriv->driverPrivate = (void *) intel_fb;
+ driDrawPriv->driverPrivate = fb;
return GL_TRUE;
}
}
static void
-intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv)
-{
- struct intel_framebuffer *intel_fb = driDrawPriv->driverPrivate;
- struct intel_renderbuffer *depth_rb;
- struct intel_renderbuffer *stencil_rb;
-
- if (intel_fb) {
- if (intel_fb->color_rb[0]) {
- intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
- }
-
- if (intel_fb->color_rb[1]) {
- intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
- }
-
- depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
- if (depth_rb) {
- intel_renderbuffer_set_region(depth_rb, NULL);
- }
-
- stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
- if (stencil_rb) {
- intel_renderbuffer_set_region(stencil_rb, NULL);
- }
- }
-
- _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
-}
-
-
-/**
- * Get information about previous buffer swaps.
- */
-static int
-intelGetSwapInfo(__DRIdrawablePrivate * dPriv, __DRIswapInfo * sInfo)
+intelDestroyBuffer(__DRIdrawable * driDrawPriv)
{
- struct intel_framebuffer *intel_fb;
-
- if ((dPriv == NULL) || (dPriv->driverPrivate == NULL)
- || (sInfo == NULL)) {
- return -1;
- }
-
- intel_fb = dPriv->driverPrivate;
- sInfo->swap_count = intel_fb->swap_count;
- sInfo->swap_ust = intel_fb->swap_ust;
- sInfo->swap_missed_count = intel_fb->swap_missed_count;
-
- sInfo->swap_missed_usage = (sInfo->swap_missed_count != 0)
- ? driCalculateSwapUsage(dPriv, 0, intel_fb->swap_missed_ust)
- : 0.0;
-
- return 0;
+ struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+
+ _mesa_reference_framebuffer(&fb, NULL);
}
-
/* There are probably better ways to do this, such as an
* init-designated function to register chipids and createcontext
* functions.
*/
extern GLboolean i830CreateContext(const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate);
extern GLboolean i915CreateContext(const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate);
extern GLboolean brwCreateContext(const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate);
static GLboolean
intelCreateContext(const __GLcontextModes * mesaVis,
- __DRIcontextPrivate * driContextPriv,
+ __DRIcontext * driContextPriv,
void *sharedContextPrivate)
{
- __DRIscreenPrivate *sPriv = driContextPriv->driScreenPriv;
+ __DRIscreen *sPriv = driContextPriv->driScreenPriv;
intelScreenPrivate *intelScreen = (intelScreenPrivate *) sPriv->private;
#ifdef I915
@@ -513,152 +275,20 @@ intelCreateContext(const __GLcontextModes * mesaVis,
return GL_FALSE;
}
-
-static __DRIconfig **
-intelFillInModes(__DRIscreenPrivate *psp,
- unsigned pixel_bits, unsigned depth_bits,
- unsigned stencil_bits, GLboolean have_back_buffer)
-{
- __DRIconfig **configs;
- __GLcontextModes *m;
- unsigned depth_buffer_factor;
- unsigned back_buffer_factor;
- int i;
-
- /* GLX_SWAP_COPY_OML is only supported because the Intel driver doesn't
- * support pageflipping at all.
- */
- static const GLenum back_buffer_modes[] = {
- GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
- };
-
- uint8_t depth_bits_array[3];
- uint8_t stencil_bits_array[3];
- uint8_t msaa_samples_array[1];
-
- depth_bits_array[0] = 0;
- depth_bits_array[1] = depth_bits;
- depth_bits_array[2] = depth_bits;
-
- /* Just like with the accumulation buffer, always provide some modes
- * with a stencil buffer. It will be a sw fallback, but some apps won't
- * care about that.
- */
- stencil_bits_array[0] = 0;
- stencil_bits_array[1] = 0;
- if (depth_bits == 24)
- stencil_bits_array[1] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- stencil_bits_array[2] = (stencil_bits == 0) ? 8 : stencil_bits;
-
- msaa_samples_array[0] = 0;
-
- depth_buffer_factor = ((depth_bits != 0) || (stencil_bits != 0)) ? 3 : 1;
- back_buffer_factor = (have_back_buffer) ? 3 : 1;
-
- if (pixel_bits == 16) {
- configs = driCreateConfigs(GL_RGB, GL_UNSIGNED_SHORT_5_6_5,
- depth_bits_array, stencil_bits_array,
- depth_buffer_factor, back_buffer_modes,
- back_buffer_factor,
- msaa_samples_array, 1);
- }
- else {
- __DRIconfig **configs_a8r8g8b8;
- __DRIconfig **configs_x8r8g8b8;
-
- configs_a8r8g8b8 = driCreateConfigs(GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV,
- depth_bits_array,
- stencil_bits_array,
- depth_buffer_factor,
- back_buffer_modes,
- back_buffer_factor,
- msaa_samples_array, 1);
- configs_x8r8g8b8 = driCreateConfigs(GL_BGR, GL_UNSIGNED_INT_8_8_8_8_REV,
- depth_bits_array,
- stencil_bits_array,
- depth_buffer_factor,
- back_buffer_modes,
- back_buffer_factor,
- msaa_samples_array, 1);
- configs = driConcatConfigs(configs_a8r8g8b8, configs_x8r8g8b8);
- }
-
- if (configs == NULL) {
- fprintf(stderr, "[%s:%u] Error creating FBConfig!\n", __func__,
- __LINE__);
- return NULL;
- }
-
- /* Mark the visual as slow if there are "fake" stencil bits.
- */
- for (i = 0; configs[i]; i++) {
- m = &configs[i]->modes;
- if ((m->stencilBits != 0) && (m->stencilBits != stencil_bits)) {
- m->visualRating = GLX_SLOW_CONFIG;
- }
- }
-
- return configs;
-}
-
static GLboolean
intel_init_bufmgr(intelScreenPrivate *intelScreen)
{
- GLboolean gem_disable = getenv("INTEL_NO_GEM") != NULL;
- int gem_kernel = 0;
- GLboolean gem_supported;
- struct drm_i915_getparam gp;
- __DRIscreenPrivate *spriv = intelScreen->driScrnPriv;
+ __DRIscreen *spriv = intelScreen->driScrnPriv;
int num_fences = 0;
intelScreen->no_hw = getenv("INTEL_NO_HW") != NULL;
- gp.param = I915_PARAM_HAS_GEM;
- gp.value = &gem_kernel;
-
- (void) drmCommandWriteRead(spriv->fd, DRM_I915_GETPARAM, &gp, sizeof(gp));
-
- /* If we've got a new enough DDX that's initializing GEM and giving us
- * object handles for the shared buffers, use that.
- */
- intelScreen->ttm = GL_FALSE;
- if (intelScreen->driScrnPriv->dri2.enabled)
- gem_supported = GL_TRUE;
- else if (intelScreen->driScrnPriv->ddx_version.minor >= 9 &&
- gem_kernel &&
- intelScreen->front.bo_handle != -1)
- gem_supported = GL_TRUE;
- else
- gem_supported = GL_FALSE;
-
- if (!gem_disable && gem_supported) {
- intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
- if (intelScreen->bufmgr != NULL)
- intelScreen->ttm = GL_TRUE;
- }
+ intelScreen->bufmgr = intel_bufmgr_gem_init(spriv->fd, BATCH_SZ);
/* Otherwise, use the classic buffer manager. */
if (intelScreen->bufmgr == NULL) {
- if (gem_disable) {
- _mesa_warning(NULL, "GEM disabled. Using classic.");
- } else {
- _mesa_warning(NULL,
- "Failed to initialize GEM. Falling back to classic.");
- }
-
- if (intelScreen->tex.size == 0) {
- fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
- __func__, __LINE__);
- return GL_FALSE;
- }
-
- intelScreen->bufmgr =
- intel_bufmgr_fake_init(spriv->fd,
- intelScreen->tex.offset,
- intelScreen->tex.map,
- intelScreen->tex.size,
- (unsigned int * volatile)
- &intelScreen->sarea->last_dispatch);
+ fprintf(stderr, "[%s:%u] Error initializing buffer manager.\n",
+ __func__, __LINE__);
+ return GL_FALSE;
}
if (intel_get_param(spriv, I915_PARAM_NUM_FENCES_AVAIL, &num_fences))
@@ -671,81 +301,12 @@ intel_init_bufmgr(intelScreenPrivate *intelScreen)
/**
* This is the driver specific part of the createNewScreen entry point.
- * Called when using legacy DRI.
- *
- * \todo maybe fold this into intelInitDriver
- *
- * \return the __GLcontextModes supported by this driver
- */
-static const __DRIconfig **intelInitScreen(__DRIscreenPrivate *psp)
-{
- intelScreenPrivate *intelScreen;
-#ifdef I915
- static const __DRIversion ddx_expected = { 1, 5, 0 };
-#else
- static const __DRIversion ddx_expected = { 1, 6, 0 };
-#endif
- static const __DRIversion dri_expected = { 4, 0, 0 };
- static const __DRIversion drm_expected = { 1, 5, 0 };
- I830DRIPtr dri_priv = (I830DRIPtr) psp->pDevPriv;
-
- if (!driCheckDriDdxDrmVersions2("i915",
- &psp->dri_version, &dri_expected,
- &psp->ddx_version, &ddx_expected,
- &psp->drm_version, &drm_expected)) {
- return NULL;
- }
-
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- intelInitExtensions(NULL, GL_TRUE);
-
- if (!intelInitDriver(psp))
- return NULL;
-
- psp->extensions = intelScreenExtensions;
-
- intelScreen = psp->private;
- if (!intel_init_bufmgr(intelScreen))
- return GL_FALSE;
-
- return (const __DRIconfig **)
- intelFillInModes(psp, dri_priv->cpp * 8,
- (dri_priv->cpp == 2) ? 16 : 24,
- (dri_priv->cpp == 2) ? 0 : 8, 1);
-}
-
-struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen)
-{
- /*
- * This should probably change to have the screen allocate a dummy
- * context at screen creation. For now just use the current context.
- */
-
- GET_CURRENT_CONTEXT(ctx);
- if (ctx == NULL) {
- _mesa_problem(NULL, "No current context in intelScreenContext\n");
- return NULL;
- }
- return intel_context(ctx);
-}
-
-/**
- * This is the driver specific part of the createNewScreen entry point.
* Called when using DRI2.
*
* \return the __GLcontextModes supported by this driver
*/
static const
-__DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
+__DRIconfig **intelInitScreen2(__DRIscreen *psp)
{
intelScreenPrivate *intelScreen;
GLenum fb_format[3];
@@ -760,18 +321,6 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
int color;
__DRIconfig **configs = NULL;
- /* Calling driInitExtensions here, with a NULL context pointer,
- * does not actually enable the extensions. It just makes sure
- * that all the dispatch offsets for all the extensions that
- * *might* be enables are known. This is needed because the
- * dispatch offsets need to be known when _mesa_context_create is
- * called, but we can't enable the extensions until we have a
- * context pointer.
- *
- * Hello chicken. Hello egg. How are you two today?
- */
- intelInitExtensions(NULL, GL_TRUE);
-
/* Allocate the private area */
intelScreen = (intelScreenPrivate *) CALLOC(sizeof(intelScreenPrivate));
if (!intelScreen) {
@@ -866,19 +415,19 @@ __DRIconfig **intelInitScreen2(__DRIscreenPrivate *psp)
}
const struct __DriverAPIRec driDriverAPI = {
- .InitScreen = intelInitScreen,
.DestroyScreen = intelDestroyScreen,
.CreateContext = intelCreateContext,
.DestroyContext = intelDestroyContext,
.CreateBuffer = intelCreateBuffer,
.DestroyBuffer = intelDestroyBuffer,
- .SwapBuffers = intelSwapBuffers,
.MakeCurrent = intelMakeCurrent,
.UnbindContext = intelUnbindContext,
- .GetSwapInfo = intelGetSwapInfo,
- .GetDrawableMSC = driDrawableGetMSC32,
- .WaitForMSC = driWaitForMSC32,
- .CopySubBuffer = intelCopySubBuffer,
-
.InitScreen2 = intelInitScreen2,
};
+
+/* This is the table of extensions that the loader will dlsym() for. */
+PUBLIC const __DRIextension *__driDriverExtensions[] = {
+ &driCoreExtension.base,
+ &driDRI2Extension.base,
+ NULL
+};
diff --git a/src/mesa/drivers/dri/intel/intel_screen.h b/src/mesa/drivers/dri/intel/intel_screen.h
index a9b9e109a6..e87e306d86 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.h
+++ b/src/mesa/drivers/dri/intel/intel_screen.h
@@ -66,7 +66,7 @@ typedef struct
int logTextureGranularity;
- __DRIscreenPrivate *driScrnPriv;
+ __DRIscreen *driScrnPriv;
volatile drm_i915_sarea_t *sarea;
@@ -77,7 +77,6 @@ typedef struct
GLboolean no_hw;
GLboolean no_vbo;
- int ttm;
dri_bufmgr *bufmgr;
GLboolean kernel_exec_fencing;
@@ -89,18 +88,18 @@ typedef struct
-extern GLboolean intelMapScreenRegions(__DRIscreenPrivate * sPriv);
+extern GLboolean intelMapScreenRegions(__DRIscreen * sPriv);
extern void intelUnmapScreenRegions(intelScreenPrivate * intelScreen);
-extern void intelDestroyContext(__DRIcontextPrivate * driContextPriv);
+extern void intelDestroyContext(__DRIcontext * driContextPriv);
-extern GLboolean intelUnbindContext(__DRIcontextPrivate * driContextPriv);
+extern GLboolean intelUnbindContext(__DRIcontext * driContextPriv);
extern GLboolean
-intelMakeCurrent(__DRIcontextPrivate * driContextPriv,
- __DRIdrawablePrivate * driDrawPriv,
- __DRIdrawablePrivate * driReadPriv);
+intelMakeCurrent(__DRIcontext * driContextPriv,
+ __DRIdrawable * driDrawPriv,
+ __DRIdrawable * driReadPriv);
extern struct intel_context *intelScreenContext(intelScreenPrivate *intelScreen);
diff --git a/src/mesa/drivers/dri/intel/intel_span.c b/src/mesa/drivers/dri/intel/intel_span.c
index dcfcad1d95..605734d8e5 100644
--- a/src/mesa/drivers/dri/intel/intel_span.c
+++ b/src/mesa/drivers/dri/intel/intel_span.c
@@ -29,7 +29,6 @@
#include "main/macros.h"
#include "main/mtypes.h"
#include "main/colormac.h"
-#include "main/texformat.h"
#include "intel_buffers.h"
#include "intel_fbo.h"
@@ -132,18 +131,6 @@ pwrite_8(struct intel_renderbuffer *irb, uint32_t offset, uint8_t val)
dri_bo_subdata(irb->region->buffer, offset, 1, &val);
}
-static uint32_t
-z24s8_to_s8z24(uint32_t val)
-{
- return (val << 24) | (val >> 8);
-}
-
-static uint32_t
-s8z24_to_z24s8(uint32_t val)
-{
- return (val >> 24) | (val << 8);
-}
-
static uint32_t no_tile_swizzle(struct intel_renderbuffer *irb,
int x, int y)
{
@@ -163,6 +150,9 @@ static uint32_t x_tile_swizzle(struct intel_renderbuffer *irb,
int x_tile_number, y_tile_number;
int tile_off, tile_base;
+ x += irb->region->draw_x;
+ y += irb->region->draw_y;
+
tile_stride = (irb->region->pitch * irb->region->cpp) << 3;
xbyte = x * irb->region->cpp;
@@ -218,6 +208,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
int x_tile_number, y_tile_number;
int tile_off, tile_base;
+ x += irb->region->draw_x;
+ y += irb->region->draw_y;
+
tile_stride = (irb->region->pitch * irb->region->cpp) << 5;
xbyte = x * irb->region->cpp;
@@ -273,8 +266,11 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
unsigned int num_cliprects; \
struct drm_clip_rect *cliprects; \
int x_off, y_off; \
+ int pitch = irb->region->pitch * irb->region->cpp; \
+ void *buf = irb->region->buffer->virtual; \
GLuint p; \
(void) p; \
+ (void)buf; (void)pitch; /* unused for non-gttmap. */ \
intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
/* XXX FBO: this is identical to the macro in spantmp2.h except we get
@@ -296,7 +292,6 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
#define Y_FLIP(_y) ((_y) * yScale + yBias)
-/* XXX with GEM, these need to tell the kernel */
#define HW_LOCK()
#define HW_UNLOCK()
@@ -339,7 +334,7 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
#include "intel_spantmp.h"
/* x8r8g8b8 color span and pixel functions */
-#define INTEL_PIXEL_FMT GL_BGRA
+#define INTEL_PIXEL_FMT GL_BGR
#define INTEL_PIXEL_TYPE GL_UNSIGNED_INT_8_8_8_8_REV
#define INTEL_READ_VALUE(offset) pread_xrgb8888(irb, offset)
#define INTEL_WRITE_VALUE(offset, v) pwrite_xrgb8888(irb, offset, v)
@@ -354,6 +349,9 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
unsigned int num_cliprects; \
struct drm_clip_rect *cliprects; \
int x_off, y_off; \
+ int pitch = irb->region->pitch * irb->region->cpp; \
+ void *buf = irb->region->buffer->virtual; \
+ (void)buf; (void)pitch; /* unused for non-gttmap. */ \
intel_get_cliprects(intel, &cliprects, &num_cliprects, &x_off, &y_off);
@@ -366,20 +364,22 @@ static uint32_t y_tile_swizzle(struct intel_renderbuffer *irb,
#define INTEL_TAG(name) name##_z16
#include "intel_depthtmp.h"
-/* z24 depthbuffer functions. */
+/* z24x8 depthbuffer functions. */
#define INTEL_VALUE_TYPE GLuint
#define INTEL_WRITE_DEPTH(offset, d) pwrite_32(irb, offset, d)
#define INTEL_READ_DEPTH(offset) pread_32(irb, offset)
-#define INTEL_TAG(name) name##_z24
+#define INTEL_TAG(name) name##_z24_x8
#include "intel_depthtmp.h"
-/* z24s8 depthbuffer functions. */
-#define INTEL_VALUE_TYPE GLuint
-#define INTEL_WRITE_DEPTH(offset, d) pwrite_32(irb, offset, z24s8_to_s8z24(d))
-#define INTEL_READ_DEPTH(offset) s8z24_to_z24s8(pread_32(irb, offset))
-#define INTEL_TAG(name) name##_z24_s8
-#include "intel_depthtmp.h"
+/**
+ ** 8-bit stencil function (XXX FBO: This is obsolete)
+ **/
+/* XXX */
+#define WRITE_STENCIL(_x, _y, d) pwrite_8(irb, NO_TILE(_x, _y) + 3, d)
+#define READ_STENCIL(d, _x, _y) d = pread_8(irb, NO_TILE(_x, _y) + 3);
+#define TAG(x) intel_gttmap_##x##_z24_s8
+#include "stenciltmp.h"
/**
** 8-bit stencil function (XXX FBO: This is obsolete)
@@ -413,6 +413,9 @@ intel_renderbuffer_map(struct intel_context *intel, struct gl_renderbuffer *rb)
if (irb == NULL || irb->region == NULL)
return;
+ if (intel->intelScreen->kernel_exec_fencing)
+ drm_intel_gem_bo_map_gtt(irb->region->buffer);
+
intel_set_span_functions(intel, rb);
}
@@ -425,7 +428,10 @@ intel_renderbuffer_unmap(struct intel_context *intel,
if (irb == NULL || irb->region == NULL)
return;
- clear_span_cache(irb);
+ if (intel->intelScreen->kernel_exec_fencing)
+ drm_intel_gem_bo_unmap_gtt(irb->region->buffer);
+ else
+ clear_span_cache(irb);
rb->GetRow = NULL;
rb->PutRow = NULL;
@@ -494,6 +500,8 @@ intel_map_unmap_framebuffer(struct intel_context *intel,
else
intel_renderbuffer_unmap(intel, fb->_StencilBuffer->Wrapped);
}
+
+ intel_check_front_buffer_rendering(intel);
}
/**
@@ -509,7 +517,6 @@ intelSpanRenderStart(GLcontext * ctx)
GLuint i;
intelFlush(&intel->ctx);
- LOCK_HARDWARE(intel);
for (i = 0; i < ctx->Const.MaxTextureImageUnits; i++) {
if (ctx->Texture.Unit[i]._ReallyEnabled) {
@@ -545,8 +552,6 @@ intelSpanRenderFinish(GLcontext * ctx)
intel_map_unmap_framebuffer(intel, ctx->DrawBuffer, GL_FALSE);
if (ctx->ReadBuffer != ctx->DrawBuffer)
intel_map_unmap_framebuffer(intel, ctx->ReadBuffer, GL_FALSE);
-
- UNLOCK_HARDWARE(intel);
}
@@ -605,17 +610,56 @@ intel_set_span_functions(struct intel_context *intel,
struct gl_renderbuffer *rb)
{
struct intel_renderbuffer *irb = (struct intel_renderbuffer *) rb;
- uint32_t tiling;
+ uint32_t tiling = irb->region->tiling;
+
+ if (intel->intelScreen->kernel_exec_fencing) {
+ switch (irb->Base.Format) {
+ case MESA_FORMAT_RGB565:
+ intel_gttmap_InitPointers_RGB565(rb);
+ break;
+ case MESA_FORMAT_ARGB4444:
+ intel_gttmap_InitPointers_ARGB4444(rb);
+ break;
+ case MESA_FORMAT_ARGB1555:
+ intel_gttmap_InitPointers_ARGB1555(rb);
+ break;
+ case MESA_FORMAT_XRGB8888:
+ intel_gttmap_InitPointers_xRGB8888(rb);
+ break;
+ case MESA_FORMAT_ARGB8888:
+ intel_gttmap_InitPointers_ARGB8888(rb);
+ break;
+ case MESA_FORMAT_Z16:
+ intel_gttmap_InitDepthPointers_z16(rb);
+ break;
+ case MESA_FORMAT_X8_Z24:
+ intel_gttmap_InitDepthPointers_z24_x8(rb);
+ break;
+ case MESA_FORMAT_S8_Z24:
+ /* There are a few different ways SW asks us to access the S8Z24 data:
+ * Z24 depth-only depth reads
+ * S8Z24 depth reads
+ * S8Z24 stencil reads.
+ */
+ if (rb->Format == MESA_FORMAT_S8_Z24) {
+ intel_gttmap_InitDepthPointers_z24_x8(rb);
+ } else if (rb->Format == MESA_FORMAT_S8) {
+ intel_gttmap_InitStencilPointers_z24_s8(rb);
+ }
+ break;
+ default:
+ _mesa_problem(NULL,
+ "Unexpected MesaFormat %d in intelSetSpanFunctions",
+ irb->Base.Format);
+ break;
+ }
+ return;
+ }
/* If in GEM mode, we need to do the tile address swizzling ourselves,
* instead of the fence registers handling it.
*/
- if (intel->ttm)
- tiling = irb->region->tiling;
- else
- tiling = I915_TILING_NONE;
-
- switch (irb->texformat->MesaFormat) {
+ switch (irb->Base.Format) {
case MESA_FORMAT_RGB565:
switch (tiling) {
case I915_TILING_NONE:
@@ -658,35 +702,33 @@ intel_set_span_functions(struct intel_context *intel,
break;
}
break;
+ case MESA_FORMAT_XRGB8888:
+ switch (tiling) {
+ case I915_TILING_NONE:
+ default:
+ intelInitPointers_xRGB8888(rb);
+ break;
+ case I915_TILING_X:
+ intel_XTile_InitPointers_xRGB8888(rb);
+ break;
+ case I915_TILING_Y:
+ intel_YTile_InitPointers_xRGB8888(rb);
+ break;
+ }
+ break;
case MESA_FORMAT_ARGB8888:
- if (rb->AlphaBits == 0) { /* XXX: Need xRGB8888 Mesa format */
- /* 8888 RGBx */
- switch (tiling) {
- case I915_TILING_NONE:
- default:
- intelInitPointers_xRGB8888(rb);
- break;
- case I915_TILING_X:
- intel_XTile_InitPointers_xRGB8888(rb);
- break;
- case I915_TILING_Y:
- intel_YTile_InitPointers_xRGB8888(rb);
- break;
- }
- } else {
- /* 8888 RGBA */
- switch (tiling) {
- case I915_TILING_NONE:
- default:
- intelInitPointers_ARGB8888(rb);
- break;
- case I915_TILING_X:
- intel_XTile_InitPointers_ARGB8888(rb);
- break;
- case I915_TILING_Y:
- intel_YTile_InitPointers_ARGB8888(rb);
- break;
- }
+ /* 8888 RGBA */
+ switch (tiling) {
+ case I915_TILING_NONE:
+ default:
+ intelInitPointers_ARGB8888(rb);
+ break;
+ case I915_TILING_X:
+ intel_XTile_InitPointers_ARGB8888(rb);
+ break;
+ case I915_TILING_Y:
+ intel_YTile_InitPointers_ARGB8888(rb);
+ break;
}
break;
case MESA_FORMAT_Z16:
@@ -703,39 +745,27 @@ intel_set_span_functions(struct intel_context *intel,
break;
}
break;
+ case MESA_FORMAT_X8_Z24:
case MESA_FORMAT_S8_Z24:
/* There are a few different ways SW asks us to access the S8Z24 data:
* Z24 depth-only depth reads
* S8Z24 depth reads
* S8Z24 stencil reads.
*/
- if (rb->_ActualFormat == GL_DEPTH_COMPONENT24) {
- switch (tiling) {
- case I915_TILING_NONE:
- default:
- intelInitDepthPointers_z24(rb);
- break;
- case I915_TILING_X:
- intel_XTile_InitDepthPointers_z24(rb);
- break;
- case I915_TILING_Y:
- intel_YTile_InitDepthPointers_z24(rb);
- break;
- }
- } else if (rb->_ActualFormat == GL_DEPTH24_STENCIL8_EXT) {
+ if (rb->Format == MESA_FORMAT_S8_Z24) {
switch (tiling) {
case I915_TILING_NONE:
default:
- intelInitDepthPointers_z24_s8(rb);
+ intelInitDepthPointers_z24_x8(rb);
break;
case I915_TILING_X:
- intel_XTile_InitDepthPointers_z24_s8(rb);
+ intel_XTile_InitDepthPointers_z24_x8(rb);
break;
case I915_TILING_Y:
- intel_YTile_InitDepthPointers_z24_s8(rb);
+ intel_YTile_InitDepthPointers_z24_x8(rb);
break;
}
- } else if (rb->_ActualFormat == GL_STENCIL_INDEX8_EXT) {
+ } else if (rb->Format == MESA_FORMAT_S8) {
switch (tiling) {
case I915_TILING_NONE:
default:
diff --git a/src/mesa/drivers/dri/intel/intel_spantmp.h b/src/mesa/drivers/dri/intel/intel_spantmp.h
index ead0b1c168..bad03398f6 100644
--- a/src/mesa/drivers/dri/intel/intel_spantmp.h
+++ b/src/mesa/drivers/dri/intel/intel_spantmp.h
@@ -32,6 +32,12 @@
#define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
#define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
+#define TAG(x) INTEL_TAG(intel_gttmap_##x)
+#define TAG2(x, y) INTEL_TAG(intel_gttmap_##x##y)
+#include "spantmp2.h"
+
+#define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
+#define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
#define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(NO_TILE(_x, _y), v)
#define GET_VALUE(_x, _y) INTEL_READ_VALUE(NO_TILE(_x, _y))
#define TAG(x) INTEL_TAG(intel##x)
@@ -48,8 +54,8 @@
#define SPANTMP_PIXEL_FMT INTEL_PIXEL_FMT
#define SPANTMP_PIXEL_TYPE INTEL_PIXEL_TYPE
-#define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(X_TILE(_x, _y), v)
-#define GET_VALUE(_x, _y) INTEL_READ_VALUE(X_TILE(_x, _y))
+#define PUT_VALUE(_x, _y, v) INTEL_WRITE_VALUE(Y_TILE(_x, _y), v)
+#define GET_VALUE(_x, _y) INTEL_READ_VALUE(Y_TILE(_x, _y))
#define TAG(x) INTEL_TAG(intel_YTile_##x)
#define TAG2(x, y) INTEL_TAG(intel_YTile_##x)##y
#include "spantmp2.h"
diff --git a/src/mesa/drivers/dri/intel/intel_state.c b/src/mesa/drivers/dri/intel/intel_state.c
index 4ee742377d..aefae53eb2 100644
--- a/src/mesa/drivers/dri/intel/intel_state.c
+++ b/src/mesa/drivers/dri/intel/intel_state.c
@@ -196,25 +196,6 @@ intel_translate_logic_op(GLenum opcode)
}
}
-
-static void
-intelClearColor(GLcontext *ctx, const GLfloat color[4])
-{
- struct intel_context *intel = intel_context(ctx);
- GLubyte clear[4];
-
- CLAMPED_FLOAT_TO_UBYTE(clear[0], color[0]);
- CLAMPED_FLOAT_TO_UBYTE(clear[1], color[1]);
- CLAMPED_FLOAT_TO_UBYTE(clear[2], color[2]);
- CLAMPED_FLOAT_TO_UBYTE(clear[3], color[3]);
-
- /* compute both 32 and 16-bit clear values */
- intel->ClearColor8888 = INTEL_PACKCOLOR8888(clear[0], clear[1],
- clear[2], clear[3]);
- intel->ClearColor565 = INTEL_PACKCOLOR565(clear[0], clear[1], clear[2]);
-}
-
-
/* Fallback to swrast for select and feedback.
*/
static void
@@ -229,5 +210,4 @@ void
intelInitStateFuncs(struct dd_function_table *functions)
{
functions->RenderMode = intelRenderMode;
- functions->ClearColor = intelClearColor;
}
diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.c b/src/mesa/drivers/dri/intel/intel_swapbuffers.c
deleted file mode 100644
index 7d035b9f6e..0000000000
--- a/src/mesa/drivers/dri/intel/intel_swapbuffers.c
+++ /dev/null
@@ -1,248 +0,0 @@
-/**************************************************************************
- *
- * 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.
- *
- **************************************************************************/
-
-#include "intel_blit.h"
-#include "intel_buffers.h"
-#include "intel_swapbuffers.h"
-#include "intel_fbo.h"
-#include "intel_batchbuffer.h"
-#include "drirenderbuffer.h"
-#include "vblank.h"
-#include "i915_drm.h"
-
-
-
-/*
- * Correct a drawablePrivate's set of vblank flags WRT the current context.
- * When considering multiple crtcs.
- */
-GLuint
-intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv)
-{
- if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
- intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
- volatile drm_i915_sarea_t *sarea = intel->sarea;
- drm_clip_rect_t drw_rect = { .x1 = dPriv->x, .x2 = dPriv->x + dPriv->w,
- .y1 = dPriv->y, .y2 = dPriv->y + dPriv->h };
- drm_clip_rect_t planeA_rect = { .x1 = sarea->planeA_x, .y1 = sarea->planeA_y,
- .x2 = sarea->planeA_x + sarea->planeA_w,
- .y2 = sarea->planeA_y + sarea->planeA_h };
- drm_clip_rect_t planeB_rect = { .x1 = sarea->planeB_x, .y1 = sarea->planeB_y,
- .x2 = sarea->planeB_x + sarea->planeB_w,
- .y2 = sarea->planeB_y + sarea->planeB_h };
- GLint areaA = driIntersectArea( drw_rect, planeA_rect );
- GLint areaB = driIntersectArea( drw_rect, planeB_rect );
- GLuint flags = dPriv->vblFlags;
-
- /* Update vblank info
- */
- if (areaB > areaA || (areaA == areaB && areaB > 0)) {
- flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
- } else {
- flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
- }
-
- /* Do the stupid test: Is one of them actually disabled?
- */
- if (sarea->planeA_w == 0 || sarea->planeA_h == 0) {
- flags = dPriv->vblFlags | VBLANK_FLAG_SECONDARY;
- } else if (sarea->planeB_w == 0 || sarea->planeB_h == 0) {
- flags = dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
- }
-
- return flags;
- } else {
- return dPriv->vblFlags & ~VBLANK_FLAG_SECONDARY;
- }
-}
-
-
-/**
- * Called from driSwapBuffers()
- */
-void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
- __DRIscreenPrivate *psp = dPriv->driScreenPriv;
-
- if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
- GET_CURRENT_CONTEXT(ctx);
- struct intel_context *intel;
-
- if (ctx == NULL)
- return;
-
- intel = intel_context(ctx);
-
- if (ctx->Visual.doubleBufferMode) {
- GLboolean missed_target;
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
- int64_t ust;
-
- _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
-
- /*
- * The old swapping ioctl was incredibly racy, just wait for vblank
- * and do the swap ourselves.
- */
- driWaitForVBlank(dPriv, &missed_target);
-
- /*
- * Update each buffer's vbl_pending so we don't get too out of
- * sync
- */
- intel_get_renderbuffer(&intel_fb->Base,
- BUFFER_BACK_LEFT)->vbl_pending = dPriv->vblSeq;
- intel_get_renderbuffer(&intel_fb->Base,
- BUFFER_FRONT_LEFT)->vbl_pending = dPriv->vblSeq;
-
- intelCopyBuffer(dPriv, NULL);
-
- intel_fb->swap_count++;
- (*psp->systemTime->getUST) (&ust);
- if (missed_target) {
- intel_fb->swap_missed_count++;
- intel_fb->swap_missed_ust = ust - intel_fb->swap_ust;
- }
-
- intel_fb->swap_ust = ust;
- }
- drmCommandNone(intel->driFd, DRM_I915_GEM_THROTTLE);
- }
- else {
- /* XXX this shouldn't be an error but we can't handle it for now */
- fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
- }
-}
-
-
-/**
- * Called from driCopySubBuffer()
- */
-void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h)
-{
- if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
- struct intel_context *intel =
- (struct intel_context *) dPriv->driContextPriv->driverPrivate;
- GLcontext *ctx = &intel->ctx;
-
- if (ctx->Visual.doubleBufferMode) {
- drm_clip_rect_t rect;
- rect.x1 = x + dPriv->x;
- rect.y1 = (dPriv->h - y - h) + dPriv->y;
- rect.x2 = rect.x1 + w;
- rect.y2 = rect.y1 + h;
- _mesa_notifySwapBuffers(ctx); /* flush pending rendering comands */
- intelCopyBuffer(dPriv, &rect);
- }
- }
- else {
- /* XXX this shouldn't be an error but we can't handle it for now */
- fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
- }
-}
-
-
-/**
- * This will be called whenever the currently bound window is moved/resized.
- * XXX: actually, it seems to NOT be called when the window is only moved (BP).
- */
-void
-intelWindowMoved(struct intel_context *intel)
-{
- GLcontext *ctx = &intel->ctx;
- __DRIdrawablePrivate *dPriv = intel->driDrawable;
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
-
- if (!intel->intelScreen->driScrnPriv->dri2.enabled &&
- intel->intelScreen->driScrnPriv->ddx_version.minor >= 7) {
- GLuint flags = intelFixupVblank(intel, dPriv);
-
- /* Check to see if we changed pipes */
- if (flags != dPriv->vblFlags && dPriv->vblFlags &&
- !(dPriv->vblFlags & VBLANK_FLAG_NO_IRQ)) {
- int64_t count;
- drmVBlank vbl;
- int i;
-
- /*
- * Deal with page flipping
- */
- vbl.request.type = DRM_VBLANK_ABSOLUTE;
-
- if ( dPriv->vblFlags & VBLANK_FLAG_SECONDARY ) {
- vbl.request.type |= DRM_VBLANK_SECONDARY;
- }
-
- for (i = 0; i < 2; i++) {
- if (!intel_fb->color_rb[i] ||
- (intel_fb->vbl_waited - intel_fb->color_rb[i]->vbl_pending) <=
- (1<<23))
- continue;
-
- vbl.request.sequence = intel_fb->color_rb[i]->vbl_pending;
- drmWaitVBlank(intel->driFd, &vbl);
- }
-
- /*
- * Update msc_base from old pipe
- */
- driDrawableGetMSC32(dPriv->driScreenPriv, dPriv, &count);
- dPriv->msc_base = count;
- /*
- * Then get new vblank_base and vblSeq values
- */
- dPriv->vblFlags = flags;
- driGetCurrentVBlank(dPriv);
- dPriv->vblank_base = dPriv->vblSeq;
-
- intel_fb->vbl_waited = dPriv->vblSeq;
-
- for (i = 0; i < 2; i++) {
- if (intel_fb->color_rb[i])
- intel_fb->color_rb[i]->vbl_pending = intel_fb->vbl_waited;
- }
- }
- } else {
- dPriv->vblFlags &= ~VBLANK_FLAG_SECONDARY;
- }
-
- /* Update Mesa's notion of window size */
- driUpdateFramebufferSize(ctx, dPriv);
- intel_fb->Base.Initialized = GL_TRUE; /* XXX remove someday */
-
- /* Update hardware scissor */
- if (ctx->Driver.Scissor != NULL) {
- ctx->Driver.Scissor(ctx, ctx->Scissor.X, ctx->Scissor.Y,
- ctx->Scissor.Width, ctx->Scissor.Height);
- }
-
- /* Re-calculate viewport related state */
- if (ctx->Driver.DepthRange != NULL)
- ctx->Driver.DepthRange( ctx, ctx->Viewport.Near, ctx->Viewport.Far );
-}
diff --git a/src/mesa/drivers/dri/intel/intel_swapbuffers.h b/src/mesa/drivers/dri/intel/intel_swapbuffers.h
deleted file mode 100644
index 75bb6242ff..0000000000
--- a/src/mesa/drivers/dri/intel/intel_swapbuffers.h
+++ /dev/null
@@ -1,52 +0,0 @@
-
-/**************************************************************************
- *
- * Copyright 2006 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 INTEL_SWAPBUFFERS_H
-#define INTEL_SWAPBUFFERS_H
-
-#include "dri_util.h"
-#include "drm.h"
-
-struct intel_context;
-struct intel_framebuffer;
-
-
-extern void
-intelSwapBuffers(__DRIdrawablePrivate * dPriv);
-
-extern void
-intelCopySubBuffer(__DRIdrawablePrivate * dPriv, int x, int y, int w, int h);
-
-extern GLuint
-intelFixupVblank(struct intel_context *intel, __DRIdrawablePrivate *dPriv);
-
-extern void
-intelWindowMoved(struct intel_context *intel);
-
-
-#endif /* INTEL_SWAPBUFFERS_H */
diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c
index 1286fe929b..0d7889d3c2 100644
--- a/src/mesa/drivers/dri/intel/intel_syncobj.c
+++ b/src/mesa/drivers/dri/intel/intel_syncobj.c
@@ -114,7 +114,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s)
{
struct intel_sync_object *sync = (struct intel_sync_object *)s;
- if (sync->bo && drm_intel_bo_busy(sync->bo)) {
+ if (sync->bo && !drm_intel_bo_busy(sync->bo)) {
drm_intel_bo_unreference(sync->bo);
sync->bo = NULL;
s->StatusFlag = 1;
diff --git a/src/mesa/drivers/dri/intel/intel_tex.c b/src/mesa/drivers/dri/intel/intel_tex.c
index 3cbc379dbd..215a534a5c 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.c
+++ b/src/mesa/drivers/dri/intel/intel_tex.c
@@ -177,6 +177,28 @@ intelGenerateMipmap(GLcontext *ctx, GLenum target,
intel_tex_map_level_images(intel, intelObj, texObj->BaseLevel);
_mesa_generate_mipmap(ctx, target, texObj);
intel_tex_unmap_level_images(intel, intelObj, texObj->BaseLevel);
+
+ {
+ GLuint nr_faces = (texObj->Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
+ GLuint face, i;
+ /* Update the level information in our private data in the new images,
+ * since it didn't get set as part of a normal TexImage path.
+ */
+ for (face = 0; face < nr_faces; face++) {
+ for (i = texObj->BaseLevel + 1; i < texObj->MaxLevel; i++) {
+ struct intel_texture_image *intelImage =
+ intel_texture_image(texObj->Image[face][i]);
+ if (!intelImage)
+ break;
+ intelImage->level = i;
+ intelImage->face = face;
+ /* Unreference the miptree to signal that the new Data is a
+ * bare pointer from mesa.
+ */
+ intel_miptree_release(intel, &intelImage->mt);
+ }
+ }
+ }
}
else {
_mesa_meta_GenerateMipmap(ctx, target, texObj);
diff --git a/src/mesa/drivers/dri/intel/intel_tex.h b/src/mesa/drivers/dri/intel/intel_tex.h
index 57ed0b1aab..f3cc0fff5c 100644
--- a/src/mesa/drivers/dri/intel/intel_tex.h
+++ b/src/mesa/drivers/dri/intel/intel_tex.h
@@ -29,6 +29,7 @@
#define INTELTEX_INC
#include "main/mtypes.h"
+#include "main/formats.h"
#include "intel_context.h"
#include "texmem.h"
@@ -41,10 +42,8 @@ void intelInitTextureSubImageFuncs(struct dd_function_table *functions);
void intelInitTextureCopyImageFuncs(struct dd_function_table *functions);
-const struct gl_texture_format *intelChooseTextureFormat(GLcontext * ctx,
- GLint internalFormat,
- GLenum format,
- GLenum type);
+gl_format intelChooseTextureFormat(GLcontext *ctx, GLint internalFormat,
+ GLenum format, GLenum type);
void intelSetTexOffset(__DRIcontext *pDRICtx, GLint texname,
unsigned long long offset, GLint depth, GLuint pitch);
diff --git a/src/mesa/drivers/dri/intel/intel_tex_copy.c b/src/mesa/drivers/dri/intel/intel_tex_copy.c
index f3e312420d..d8e71093c4 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_copy.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_copy.c
@@ -29,6 +29,7 @@
#include "main/enums.h"
#include "main/image.h"
#include "main/teximage.h"
+#include "main/texstate.h"
#include "main/mipmap.h"
#include "drivers/common/meta.h"
@@ -92,8 +93,7 @@ do_copy_texsubimage(struct intel_context *intel,
GLint x, GLint y, GLsizei width, GLsizei height)
{
GLcontext *ctx = &intel->ctx;
- const struct intel_region *src =
- get_teximage_source(intel, internalFormat);
+ const struct intel_region *src = get_teximage_source(intel, internalFormat);
if (!intelImage->mt || !src) {
if (INTEL_DEBUG & DEBUG_FALLBACKS)
@@ -109,33 +109,34 @@ do_copy_texsubimage(struct intel_context *intel,
return GL_FALSE;
}
- intelFlush(ctx);
- LOCK_HARDWARE(intel);
+ /* intelFlush(ctx); */
{
drm_intel_bo *dst_bo = intel_region_buffer(intel,
intelImage->mt->region,
INTEL_WRITE_PART);
- GLuint image_offset = intel_miptree_image_offset(intelImage->mt,
- intelImage->face,
- intelImage->level);
const GLint orig_x = x;
const GLint orig_y = y;
+ GLuint image_x, image_y;
GLshort src_pitch;
+ /* get dest x/y in destination texture */
+ intel_miptree_get_image_offset(intelImage->mt,
+ intelImage->level,
+ intelImage->face,
+ 0,
+ &image_x, &image_y);
/* Update dst for clipped src. Need to also clip the source rect. */
dstx += x - orig_x;
dsty += y - orig_y;
/* Can't blit to tiled buffers with non-tile-aligned offset. */
- if (intelImage->mt->region->tiling != I915_TILING_NONE &&
- (image_offset & 4095) != 0) {
- UNLOCK_HARDWARE(intel);
+ if (intelImage->mt->region->tiling == I915_TILING_Y) {
return GL_FALSE;
}
if (ctx->ReadBuffer->Name == 0) {
/* reading from a window, adjust x, y */
- const __DRIdrawablePrivate *dPriv = intel->driReadDrawable;
+ const __DRIdrawable *dPriv = intel->driReadDrawable;
y = dPriv->y + (dPriv->h - (y + height));
x += dPriv->x;
@@ -152,6 +153,7 @@ do_copy_texsubimage(struct intel_context *intel,
src_pitch = src->pitch;
}
+ /* blit from src buffer to texture */
if (!intelEmitCopyBlit(intel,
intelImage->mt->cpp,
src_pitch,
@@ -160,17 +162,16 @@ do_copy_texsubimage(struct intel_context *intel,
src->tiling,
intelImage->mt->pitch,
dst_bo,
- image_offset,
+ 0,
intelImage->mt->region->tiling,
- x, y, dstx, dsty, width, height,
+ src->draw_x + x, src->draw_y + y,
+ image_x + dstx, image_y + dsty,
+ width, height,
GL_COPY)) {
- UNLOCK_HARDWARE(intel);
return GL_FALSE;
}
}
- UNLOCK_HARDWARE(intel);
-
return GL_TRUE;
}
@@ -180,8 +181,7 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
GLenum internalFormat,
GLint x, GLint y, GLsizei width, GLint border)
{
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
struct gl_texture_object *texObj =
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
@@ -217,6 +217,8 @@ intelCopyTexImage1D(GLcontext * ctx, GLenum target, GLint level,
return;
fail:
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
_mesa_meta_CopyTexImage1D(ctx, target, level, internalFormat, x, y,
width, border);
}
@@ -228,8 +230,7 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
GLint x, GLint y, GLsizei width, GLsizei height,
GLint border)
{
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
struct gl_texture_object *texObj =
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
@@ -244,7 +245,7 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
*/
ctx->Driver.TexImage2D(ctx, target, level, internalFormat,
width, height, border,
- GL_RGBA, CHAN_TYPE, NULL,
+ GL_RGBA, GL_UNSIGNED_BYTE, NULL,
&ctx->DefaultPacking, texObj, texImage);
srcx = x;
@@ -265,6 +266,8 @@ intelCopyTexImage2D(GLcontext * ctx, GLenum target, GLint level,
return;
fail:
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
_mesa_meta_CopyTexImage2D(ctx, target, level, internalFormat, x, y,
width, height, border);
}
@@ -274,8 +277,7 @@ static void
intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
GLint xoffset, GLint x, GLint y, GLsizei width)
{
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
struct gl_texture_object *texObj =
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
@@ -290,6 +292,8 @@ intelCopyTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
if (!do_copy_texsubimage(intel_context(ctx), target,
intel_texture_image(texImage),
internalFormat, xoffset, 0, x, y, width, 1)) {
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
_mesa_meta_CopyTexSubImage1D(ctx, target, level, xoffset, x, y, width);
}
}
@@ -300,8 +304,7 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLint x, GLint y, GLsizei width, GLsizei height)
{
- struct gl_texture_unit *texUnit =
- &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
+ struct gl_texture_unit *texUnit = _mesa_get_current_tex_unit(ctx);
struct gl_texture_object *texObj =
_mesa_select_tex_object(ctx, texUnit, target);
struct gl_texture_image *texImage =
@@ -316,8 +319,8 @@ intelCopyTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
internalFormat,
xoffset, yoffset, x, y, width, height)) {
- DBG("%s - fallback to _mesa_meta_CopyTexSubImage2D\n", __FUNCTION__);
-
+ if (INTEL_DEBUG & DEBUG_FALLBACKS)
+ fprintf(stderr, "%s - fallback to swrast\n", __FUNCTION__);
_mesa_meta_CopyTexSubImage2D(ctx, target, level,
xoffset, yoffset, x, y, width, height);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_format.c b/src/mesa/drivers/dri/intel/intel_tex_format.c
index 3322a71130..a7c6c45ffe 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_format.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_format.c
@@ -1,7 +1,6 @@
#include "intel_context.h"
#include "intel_tex.h"
#include "intel_chipset.h"
-#include "main/texformat.h"
#include "main/enums.h"
@@ -16,7 +15,7 @@
* these if we take the step of simply swizzling the colors
* immediately after sampling...
*/
-const struct gl_texture_format *
+gl_format
intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
GLenum format, GLenum type)
{
@@ -34,48 +33,48 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_COMPRESSED_RGBA:
if (format == GL_BGRA) {
if (type == GL_UNSIGNED_BYTE || type == GL_UNSIGNED_INT_8_8_8_8_REV) {
- return &_mesa_texformat_argb8888;
+ return MESA_FORMAT_ARGB8888;
}
else if (type == GL_UNSIGNED_SHORT_4_4_4_4_REV) {
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
}
else if (type == GL_UNSIGNED_SHORT_1_5_5_5_REV) {
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
}
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case 3:
case GL_RGB:
case GL_COMPRESSED_RGB:
if (format == GL_RGB && type == GL_UNSIGNED_SHORT_5_6_5) {
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
}
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_rgb565;
+ return do32bpt ? MESA_FORMAT_XRGB8888 : MESA_FORMAT_RGB565;
case GL_RGBA8:
case GL_RGB10_A2:
case GL_RGBA12:
case GL_RGBA16:
- return do32bpt ? &_mesa_texformat_argb8888 : &_mesa_texformat_argb4444;
+ return do32bpt ? MESA_FORMAT_ARGB8888 : MESA_FORMAT_ARGB4444;
case GL_RGBA4:
case GL_RGBA2:
- return &_mesa_texformat_argb4444;
+ return MESA_FORMAT_ARGB4444;
case GL_RGB5_A1:
- return &_mesa_texformat_argb1555;
+ return MESA_FORMAT_ARGB1555;
case GL_RGB8:
case GL_RGB10:
case GL_RGB12:
case GL_RGB16:
- return &_mesa_texformat_argb8888;
+ return MESA_FORMAT_XRGB8888;
case GL_RGB5:
case GL_RGB4:
case GL_R3_G3_B2:
- return &_mesa_texformat_rgb565;
+ return MESA_FORMAT_RGB565;
case GL_ALPHA:
case GL_ALPHA4:
@@ -83,7 +82,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_ALPHA12:
case GL_ALPHA16:
case GL_COMPRESSED_ALPHA:
- return &_mesa_texformat_a8;
+ return MESA_FORMAT_A8;
case 1:
case GL_LUMINANCE:
@@ -92,18 +91,24 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_LUMINANCE12:
case GL_LUMINANCE16:
case GL_COMPRESSED_LUMINANCE:
- return &_mesa_texformat_l8;
+ return MESA_FORMAT_L8;
+
+ case GL_LUMINANCE12_ALPHA4:
+ case GL_LUMINANCE12_ALPHA12:
+ case GL_LUMINANCE16_ALPHA16:
+#ifndef I915
+ return MESA_FORMAT_AL1616;
+#else
+ /* FALLTHROUGH */
+#endif
case 2:
case GL_LUMINANCE_ALPHA:
case GL_LUMINANCE4_ALPHA4:
case GL_LUMINANCE6_ALPHA2:
case GL_LUMINANCE8_ALPHA8:
- case GL_LUMINANCE12_ALPHA4:
- case GL_LUMINANCE12_ALPHA12:
- case GL_LUMINANCE16_ALPHA16:
case GL_COMPRESSED_LUMINANCE_ALPHA:
- return &_mesa_texformat_al88;
+ return MESA_FORMAT_AL88;
case GL_INTENSITY:
case GL_INTENSITY4:
@@ -111,41 +116,41 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_INTENSITY12:
case GL_INTENSITY16:
case GL_COMPRESSED_INTENSITY:
- return &_mesa_texformat_i8;
+ return MESA_FORMAT_I8;
case GL_YCBCR_MESA:
if (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE)
- return &_mesa_texformat_ycbcr;
+ return MESA_FORMAT_YCBCR;
else
- return &_mesa_texformat_ycbcr_rev;
+ return MESA_FORMAT_YCBCR_REV;
case GL_COMPRESSED_RGB_FXT1_3DFX:
- return &_mesa_texformat_rgb_fxt1;
+ return MESA_FORMAT_RGB_FXT1;
case GL_COMPRESSED_RGBA_FXT1_3DFX:
- return &_mesa_texformat_rgba_fxt1;
+ return MESA_FORMAT_RGBA_FXT1;
case GL_RGB_S3TC:
case GL_RGB4_S3TC:
case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
- return &_mesa_texformat_rgb_dxt1;
+ return MESA_FORMAT_RGB_DXT1;
case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
- return &_mesa_texformat_rgba_dxt1;
+ return MESA_FORMAT_RGBA_DXT1;
case GL_RGBA_S3TC:
case GL_RGBA4_S3TC:
case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
- return &_mesa_texformat_rgba_dxt3;
+ return MESA_FORMAT_RGBA_DXT3;
case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
- return &_mesa_texformat_rgba_dxt5;
+ return MESA_FORMAT_RGBA_DXT5;
case GL_DEPTH_COMPONENT:
case GL_DEPTH_COMPONENT16:
case GL_DEPTH_COMPONENT24:
case GL_DEPTH_COMPONENT32:
#if 0
- return &_mesa_texformat_z16;
+ return MESA_FORMAT_Z16;
#else
/* fall-through.
* 16bpp depth texture can't be paired with a stencil buffer so
@@ -154,7 +159,7 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
#endif
case GL_DEPTH_STENCIL_EXT:
case GL_DEPTH24_STENCIL8_EXT:
- return &_mesa_texformat_s8_z24;
+ return MESA_FORMAT_S8_Z24;
#ifndef I915
case GL_SRGB_EXT:
@@ -165,41 +170,41 @@ intelChooseTextureFormat(GLcontext * ctx, GLint internalFormat,
case GL_COMPRESSED_SRGB_ALPHA_EXT:
case GL_COMPRESSED_SLUMINANCE_EXT:
case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
- return &_mesa_texformat_sargb8;
+ return MESA_FORMAT_SARGB8;
case GL_SLUMINANCE_EXT:
case GL_SLUMINANCE8_EXT:
- if (IS_G4X(intel->intelScreen->deviceID))
- return &_mesa_texformat_sl8;
+ if (intel->has_luminance_srgb)
+ return MESA_FORMAT_SL8;
else
- return &_mesa_texformat_sargb8;
+ return MESA_FORMAT_SARGB8;
case GL_SLUMINANCE_ALPHA_EXT:
case GL_SLUMINANCE8_ALPHA8_EXT:
- if (IS_G4X(intel->intelScreen->deviceID))
- return &_mesa_texformat_sla8;
+ if (intel->has_luminance_srgb)
+ return MESA_FORMAT_SLA8;
else
- return &_mesa_texformat_sargb8;
+ return MESA_FORMAT_SARGB8;
case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
- return &_mesa_texformat_srgb_dxt1;
+ return MESA_FORMAT_SRGB_DXT1;
/* i915 could also do this */
case GL_DUDV_ATI:
case GL_DU8DV8_ATI:
- return &_mesa_texformat_dudv8;
+ return MESA_FORMAT_DUDV8;
case GL_RGBA_SNORM:
case GL_RGBA8_SNORM:
- return &_mesa_texformat_signed_rgba8888_rev;
+ return MESA_FORMAT_SIGNED_RGBA8888_REV;
#endif
default:
fprintf(stderr, "unexpected texture format %s in %s\n",
_mesa_lookup_enum_by_nr(internalFormat), __FUNCTION__);
- return NULL;
+ return MESA_FORMAT_NONE;
}
- return NULL; /* never get here */
+ return MESA_FORMAT_NONE; /* never get here */
}
int intel_compressed_num_bytes(GLuint mesaFormat)
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 66201b1f46..307669f87e 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -6,8 +6,10 @@
#include "main/bufferobj.h"
#include "main/convolve.h"
#include "main/context.h"
+#include "main/formats.h"
+#include "main/image.h"
#include "main/texcompress.h"
-#include "main/texformat.h"
+#include "main/texstore.h"
#include "main/texgetimage.h"
#include "main/texobj.h"
#include "main/texstore.h"
@@ -69,6 +71,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
GLuint depth = intelImage->base.Depth;
GLuint l2width, l2height, l2depth;
GLuint i, comp_byte = 0;
+ GLuint texelBytes;
DBG("%s\n", __FUNCTION__);
@@ -112,7 +115,8 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
*/
if ((intelObj->base.MinFilter == GL_NEAREST ||
intelObj->base.MinFilter == GL_LINEAR) &&
- intelImage->level == firstLevel) {
+ intelImage->level == firstLevel &&
+ (intel->gen < 4 || firstLevel == 0)) {
lastLevel = firstLevel;
}
else {
@@ -123,8 +127,11 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
}
assert(!intelObj->mt);
- if (intelImage->base.IsCompressed)
- comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+ if (_mesa_is_format_compressed(intelImage->base.TexFormat))
+ comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat);
+
+ texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
+
intelObj->mt = intel_miptree_create(intel,
intelObj->base.Target,
intelImage->base._BaseFormat,
@@ -134,7 +141,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
width,
height,
depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte,
expect_accelerated_upload);
@@ -166,7 +173,7 @@ target_to_face(GLenum target)
static GLboolean
check_pbo_format(GLint internalFormat,
GLenum format, GLenum type,
- const struct gl_texture_format *mesa_format)
+ gl_format mesa_format)
{
switch (internalFormat) {
case 4:
@@ -174,12 +181,12 @@ check_pbo_format(GLint internalFormat,
return (format == GL_BGRA &&
(type == GL_UNSIGNED_BYTE ||
type == GL_UNSIGNED_INT_8_8_8_8_REV) &&
- mesa_format == &_mesa_texformat_argb8888);
+ mesa_format == MESA_FORMAT_ARGB8888);
case 3:
case GL_RGB:
return (format == GL_RGB &&
type == GL_UNSIGNED_SHORT_5_6_5 &&
- mesa_format == &_mesa_texformat_rgb565);
+ mesa_format == MESA_FORMAT_RGB565);
case GL_YCBCR_MESA:
return (type == GL_UNSIGNED_SHORT_8_8_MESA || type == GL_UNSIGNED_BYTE);
default:
@@ -200,7 +207,10 @@ try_pbo_upload(struct intel_context *intel,
{
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
GLuint src_offset, src_stride;
- GLuint dst_offset, dst_stride;
+ GLuint dst_x, dst_y, dst_stride;
+ dri_bo *dst_buffer = intel_region_buffer(intel,
+ intelImage->mt->region,
+ INTEL_WRITE_FULL);
if (!_mesa_is_bufferobj(unpack->BufferObj) ||
intel->ctx._ImageTransferState ||
@@ -217,32 +227,26 @@ try_pbo_upload(struct intel_context *intel,
else
src_stride = width;
- dst_offset = intel_miptree_image_offset(intelImage->mt,
- intelImage->face,
- intelImage->level);
+ intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
+ intelImage->face, 0,
+ &dst_x, &dst_y);
dst_stride = intelImage->mt->pitch;
- intelFlush(&intel->ctx);
- LOCK_HARDWARE(intel);
+ if (drm_intel_bo_references(intel->batch->buf, dst_buffer))
+ intelFlush(&intel->ctx);
{
dri_bo *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ);
- dri_bo *dst_buffer = intel_region_buffer(intel,
- intelImage->mt->region,
- INTEL_WRITE_FULL);
-
if (!intelEmitCopyBlit(intel,
intelImage->mt->cpp,
src_stride, src_buffer, src_offset, GL_FALSE,
- dst_stride, dst_buffer, dst_offset, GL_FALSE,
- 0, 0, 0, 0, width, height,
+ dst_stride, dst_buffer, 0, GL_FALSE,
+ 0, 0, dst_x, dst_y, width, height,
GL_COPY)) {
- UNLOCK_HARDWARE(intel);
return GL_FALSE;
}
}
- UNLOCK_HARDWARE(intel);
return GL_TRUE;
}
@@ -258,7 +262,7 @@ try_pbo_zcopy(struct intel_context *intel,
{
struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
GLuint src_offset, src_stride;
- GLuint dst_offset, dst_stride;
+ GLuint dst_x, dst_y, dst_stride;
if (!_mesa_is_bufferobj(unpack->BufferObj) ||
intel->ctx._ImageTransferState ||
@@ -275,13 +279,14 @@ try_pbo_zcopy(struct intel_context *intel,
else
src_stride = width;
- dst_offset = intel_miptree_image_offset(intelImage->mt,
- intelImage->face,
- intelImage->level);
+ intel_miptree_get_image_offset(intelImage->mt, intelImage->level,
+ intelImage->face, 0,
+ &dst_x, &dst_y);
dst_stride = intelImage->mt->pitch;
- if (src_stride != dst_stride || dst_offset != 0 || src_offset != 0) {
+ if (src_stride != dst_stride || dst_x != 0 || dst_y != 0 ||
+ src_offset != 0) {
DBG("%s: failure 2\n", __FUNCTION__);
return GL_FALSE;
}
@@ -316,8 +321,6 @@ intelTexImage(GLcontext * ctx,
DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
_mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
- intelFlush(ctx);
-
intelImage->face = target_to_face(target);
intelImage->level = level;
@@ -326,22 +329,11 @@ intelTexImage(GLcontext * ctx,
&postConvHeight);
}
- /* choose the texture format */
- texImage->TexFormat = intelChooseTextureFormat(ctx, internalFormat,
- format, type);
-
- _mesa_set_fetch_functions(texImage, dims);
-
- if (texImage->TexFormat->TexelBytes == 0) {
- /* must be a compressed format */
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
texelBytes = 0;
- texImage->IsCompressed = GL_TRUE;
- texImage->CompressedSize =
- ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
- texImage->Height, texImage->Depth,
- texImage->TexFormat->MesaFormat);
- } else {
- texelBytes = texImage->TexFormat->TexelBytes;
+ }
+ else {
+ texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
/* Minimum pitch of 32 bytes */
if (postConvWidth * texelBytes < 32) {
@@ -374,8 +366,7 @@ intelTexImage(GLcontext * ctx,
intelObj->mt->first_level == level &&
intelObj->mt->last_level == level &&
intelObj->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
- !intel_miptree_match_image(intelObj->mt, &intelImage->base,
- intelImage->face, intelImage->level)) {
+ !intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
DBG("release it\n");
intel_miptree_release(intel, &intelObj->mt);
@@ -392,17 +383,17 @@ intelTexImage(GLcontext * ctx,
assert(!intelImage->mt);
if (intelObj->mt &&
- intel_miptree_match_image(intelObj->mt, &intelImage->base,
- intelImage->face, intelImage->level)) {
+ intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
intel_miptree_reference(&intelImage->mt, intelObj->mt);
assert(intelImage->mt);
} else if (intelImage->base.Border == 0) {
int comp_byte = 0;
-
- if (intelImage->base.IsCompressed) {
+ GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
+ GLenum baseFormat = _mesa_get_format_base_format(intelImage->base.TexFormat);
+ if (_mesa_is_format_compressed(intelImage->base.TexFormat)) {
comp_byte =
- intel_compressed_num_bytes(intelImage->base.TexFormat->MesaFormat);
+ intel_compressed_num_bytes(intelImage->base.TexFormat);
}
/* Didn't fit in the object miptree, but it's suitable for inclusion in
@@ -410,11 +401,11 @@ intelTexImage(GLcontext * ctx,
* It'll get moved into the object miptree at validate time.
*/
intelImage->mt = intel_miptree_create(intel, target,
- intelImage->base.TexFormat->BaseFormat,
+ baseFormat,
internalFormat,
level, level,
width, height, depth,
- intelImage->base.TexFormat->TexelBytes,
+ texelBytes,
comp_byte, pixels == NULL);
}
@@ -475,24 +466,32 @@ intelTexImage(GLcontext * ctx,
pixels, unpack, "glTexImage");
}
- LOCK_HARDWARE(intel);
-
if (intelImage->mt) {
- if (pixels != NULL)
+ if (pixels != NULL) {
+ /* Flush any queued rendering with the texture before mapping. */
+ if (drm_intel_bo_references(intel->batch->buf,
+ intelImage->mt->region->buffer)) {
+ intelFlush(ctx);
+ }
texImage->Data = intel_miptree_image_map(intel,
intelImage->mt,
intelImage->face,
intelImage->level,
&dstRowStride,
intelImage->base.ImageOffsets);
+ }
+
texImage->RowStride = dstRowStride / intelImage->mt->cpp;
}
else {
/* Allocate regular memory and store the image there temporarily. */
- if (texImage->IsCompressed) {
- sizeInBytes = texImage->CompressedSize;
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
+ sizeInBytes = _mesa_format_image_size(texImage->TexFormat,
+ texImage->Width,
+ texImage->Height,
+ texImage->Depth);
dstRowStride =
- _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+ _mesa_format_row_stride(texImage->TexFormat, width);
assert(dims != 3);
}
else {
@@ -523,17 +522,20 @@ intelTexImage(GLcontext * ctx,
pixels,
srcRowStride,
0, 0);
- } else
+ }
+ else {
memcpy(texImage->Data, pixels, imageSize);
- } else if (!texImage->TexFormat->StoreImage(ctx, dims,
- texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, unpack)) {
- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
+ }
+ }
+ else if (!_mesa_texstore(ctx, dims,
+ texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data, 0, 0, 0, /* dstX/Y/Zoffset */
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, depth,
+ format, type, pixels, unpack)) {
+ _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
}
}
@@ -544,8 +546,6 @@ intelTexImage(GLcontext * ctx,
intel_miptree_image_unmap(intel, intelImage->mt);
texImage->Data = NULL;
}
-
- UNLOCK_HARDWARE(intel);
}
@@ -661,9 +661,10 @@ intel_get_tex_image(GLcontext * ctx, GLenum target, GLint level,
if (compressed) {
_mesa_get_compressed_teximage(ctx, target, level, pixels,
texObj, texImage);
- } else {
+ }
+ else {
_mesa_get_teximage(ctx, target, level, format, type, pixels,
- texObj, texImage);
+ texObj, texImage);
}
@@ -724,19 +725,18 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
GLint glx_texture_format,
__DRIdrawable *dPriv)
{
- struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+ struct gl_framebuffer *fb = dPriv->driverPrivate;
struct intel_context *intel = pDRICtx->driverPrivate;
+ GLcontext *ctx = &intel->ctx;
struct intel_texture_object *intelObj;
struct intel_texture_image *intelImage;
struct intel_mipmap_tree *mt;
struct intel_renderbuffer *rb;
- struct gl_texture_unit *texUnit;
struct gl_texture_object *texObj;
struct gl_texture_image *texImage;
- int level = 0, type, format, internalFormat;
+ int level = 0, internalFormat;
- texUnit = &intel->ctx.Texture.Unit[intel->ctx.Texture.CurrentUnit];
- texObj = _mesa_select_tex_object(&intel->ctx, texUnit, target);
+ texObj = _mesa_get_current_tex_object(ctx, target);
intelObj = intel_texture_object(texObj);
if (!intelObj)
@@ -744,15 +744,13 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
intel_update_renderbuffers(pDRICtx, dPriv);
- rb = intel_fb->color_rb[0];
+ rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
/* If the region isn't set, then intel_update_renderbuffers was unable
* to get the buffers for the drawable.
*/
if (rb->region == NULL)
return;
- type = GL_BGRA;
- format = GL_UNSIGNED_BYTE;
if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
internalFormat = GL_RGB;
else
@@ -783,14 +781,14 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
intelImage->face = target_to_face(target);
intelImage->level = level;
- texImage->TexFormat = intelChooseTextureFormat(&intel->ctx, internalFormat,
- type, format);
- _mesa_set_fetch_functions(texImage, 2);
+ if (glx_texture_format == GLX_TEXTURE_FORMAT_RGB_EXT)
+ texImage->TexFormat = MESA_FORMAT_XRGB8888;
+ else
+ texImage->TexFormat = MESA_FORMAT_ARGB8888;
texImage->RowStride = rb->region->pitch;
intel_miptree_reference(&intelImage->mt, intelObj->mt);
- if (!intel_miptree_match_image(intelObj->mt, &intelImage->base,
- intelImage->face, intelImage->level)) {
+ if (!intel_miptree_match_image(intelObj->mt, &intelImage->base)) {
fprintf(stderr, "miptree doesn't match image\n");
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.h b/src/mesa/drivers/dri/intel/intel_tex_layout.h
index c9de9b5678..a9ac9e7eb4 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_layout.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_layout.h
@@ -33,7 +33,7 @@
#include "main/macros.h"
-static GLuint minify( GLuint d )
+static INLINE GLuint minify( GLuint d )
{
return MAX2(1, d>>1);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_obj.h b/src/mesa/drivers/dri/intel/intel_tex_obj.h
index 5a93461525..3ad10d3d23 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_obj.h
+++ b/src/mesa/drivers/dri/intel/intel_tex_obj.h
@@ -66,6 +66,7 @@ struct intel_texture_image
* Else there is no image data.
*/
struct intel_mipmap_tree *mt;
+ GLboolean used_as_render_target;
};
static INLINE struct intel_texture_object *
diff --git a/src/mesa/drivers/dri/intel/intel_tex_subimage.c b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
index 751ec2c98c..7f1dc89022 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_subimage.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_subimage.c
@@ -72,8 +72,6 @@ intelTexSubimage(GLcontext * ctx,
if (!pixels)
return;
- LOCK_HARDWARE(intel);
-
/* Map buffer if necessary. Need to lock to prevent other contexts
* from uploading the buffer under us.
*/
@@ -85,13 +83,13 @@ intelTexSubimage(GLcontext * ctx,
&dstRowStride,
texImage->ImageOffsets);
else {
- if (texImage->IsCompressed) {
+ if (_mesa_is_format_compressed(texImage->TexFormat)) {
dstRowStride =
- _mesa_compressed_row_stride(texImage->TexFormat->MesaFormat, width);
+ _mesa_format_row_stride(texImage->TexFormat, width);
assert(dims != 3);
}
else {
- dstRowStride = texImage->RowStride * texImage->TexFormat->TexelBytes;
+ dstRowStride = texImage->RowStride * _mesa_get_format_bytes(texImage->TexFormat);
}
}
@@ -105,18 +103,20 @@ intelTexSubimage(GLcontext * ctx,
xoffset, yoffset / 4,
(width + 3) & ~3, (height + 3) / 4,
pixels, (width + 3) & ~3, 0, 0);
- } else
+ }
+ else {
memcpy(texImage->Data, pixels, imageSize);
+ }
}
else {
- if (!texImage->TexFormat->StoreImage(ctx, dims, texImage->_BaseFormat,
- texImage->TexFormat,
- texImage->Data,
- xoffset, yoffset, zoffset,
- dstRowStride,
- texImage->ImageOffsets,
- width, height, depth,
- format, type, pixels, packing)) {
+ if (!_mesa_texstore(ctx, dims, texImage->_BaseFormat,
+ texImage->TexFormat,
+ texImage->Data,
+ xoffset, yoffset, zoffset,
+ dstRowStride,
+ texImage->ImageOffsets,
+ width, height, depth,
+ format, type, pixels, packing)) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "intelTexSubImage");
}
}
@@ -127,8 +127,6 @@ intelTexSubimage(GLcontext * ctx,
intel_miptree_image_unmap(intel, intelImage->mt);
texImage->Data = NULL;
}
-
- UNLOCK_HARDWARE(intel);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index a284d5475f..c9a24ac398 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -5,6 +5,7 @@
#include "intel_batchbuffer.h"
#include "intel_mipmap_tree.h"
#include "intel_tex.h"
+#include "intel_chipset.h"
#define FILE_DEBUG_FLAG DEBUG_TEXTURE
@@ -14,7 +15,8 @@
* GL_TEXTURE_MAX_LOD, GL_TEXTURE_BASE_LEVEL, and GL_TEXTURE_MAX_LEVEL.
*/
static void
-intel_calculate_first_last_level(struct intel_texture_object *intelObj)
+intel_calculate_first_last_level(struct intel_context *intel,
+ struct intel_texture_object *intelObj)
{
struct gl_texture_object *tObj = &intelObj->base;
const struct gl_texture_image *const baseImage =
@@ -40,27 +42,27 @@ intel_calculate_first_last_level(struct intel_texture_object *intelObj)
firstLevel = lastLevel = tObj->BaseLevel;
}
else {
-#ifdef I915
- firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
- firstLevel = MAX2(firstLevel, tObj->BaseLevel);
- firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
- lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
- lastLevel = MAX2(lastLevel, tObj->BaseLevel);
- lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
- lastLevel = MIN2(lastLevel, tObj->MaxLevel);
- lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
-#else
- /* Currently not taking min/max lod into account here, those
- * values are programmed as sampler state elsewhere and we
- * upload the same mipmap levels regardless. Not sure if
- * this makes sense as it means it isn't possible for the app
- * to use min/max lod to reduce texture memory pressure:
- */
- firstLevel = tObj->BaseLevel;
- lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
- tObj->MaxLevel);
- lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
-#endif
+ if (intel->gen == 2) {
+ firstLevel = tObj->BaseLevel + (GLint) (tObj->MinLod + 0.5);
+ firstLevel = MAX2(firstLevel, tObj->BaseLevel);
+ firstLevel = MIN2(firstLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = tObj->BaseLevel + (GLint) (tObj->MaxLod + 0.5);
+ lastLevel = MAX2(lastLevel, tObj->BaseLevel);
+ lastLevel = MIN2(lastLevel, tObj->BaseLevel + baseImage->MaxLog2);
+ lastLevel = MIN2(lastLevel, tObj->MaxLevel);
+ lastLevel = MAX2(firstLevel, lastLevel); /* need at least one level */
+ } else {
+ /* Min/max LOD are taken into account in sampler state. We don't
+ * want to re-layout textures just because clamping has been applied
+ * since it means a bunch of blitting around and probably no memory
+ * savings (since we have to keep the other levels around anyway).
+ */
+ firstLevel = tObj->BaseLevel;
+ lastLevel = MIN2(tObj->BaseLevel + baseImage->MaxLog2,
+ tObj->MaxLevel);
+ /* need at least one level */
+ lastLevel = MAX2(firstLevel, lastLevel);
+ }
}
break;
case GL_TEXTURE_RECTANGLE_NV:
@@ -135,9 +137,8 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
/* What levels must the tree include at a minimum?
*/
- intel_calculate_first_last_level(intelObj);
- firstImage =
- intel_texture_image(intelObj->base.Image[0][intelObj->firstLevel]);
+ intel_calculate_first_last_level(intel, intelObj);
+ firstImage = intel_texture_image(tObj->Image[0][intelObj->firstLevel]);
/* Fallback case:
*/
@@ -165,11 +166,12 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intel_miptree_reference(&intelObj->mt, firstImage->mt);
}
- if (firstImage->base.IsCompressed) {
- comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat->MesaFormat);
+ if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
+ comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat);
cpp = comp_byte;
}
- else cpp = firstImage->base.TexFormat->TexelBytes;
+ else
+ cpp = _mesa_get_format_bytes(firstImage->base.TexFormat);
/* Check tree can hold all active levels. Check tree matches
* target, imageFormat, etc.
@@ -189,7 +191,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intelObj->mt->height0 != firstImage->base.Height ||
intelObj->mt->depth0 != firstImage->base.Depth ||
intelObj->mt->cpp != cpp ||
- intelObj->mt->compressed != firstImage->base.IsCompressed)) {
+ intelObj->mt->compressed != _mesa_is_format_compressed(firstImage->base.TexFormat))) {
intel_miptree_release(intel, &intelObj->mt);
}
@@ -220,8 +222,13 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
intel_texture_image(intelObj->base.Image[face][i]);
/* Need to import images in main memory or held in other trees.
+ * If it's a render target, then its data isn't needed to be in
+ * the object tree (otherwise we'd be FBO incomplete), and we need
+ * to keep track of the image's MT as needing to be pulled in still,
+ * or we'll lose the rendering that's done to it.
*/
- if (intelObj->mt != intelImage->mt) {
+ if (intelObj->mt != intelImage->mt &&
+ !intelImage->used_as_render_target) {
copy_image_data_to_tree(intel, intelObj, intelImage);
}
}