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.c3
-rw-r--r--src/mesa/drivers/dri/intel/intel_batchbuffer.h13
-rw-r--r--src/mesa/drivers/dri/intel/intel_blit.c14
-rw-r--r--src/mesa/drivers/dri/intel/intel_chipset.h14
-rw-r--r--src/mesa/drivers/dri/intel/intel_clear.c6
-rw-r--r--src/mesa/drivers/dri/intel/intel_context.c7
-rw-r--r--src/mesa/drivers/dri/intel/intel_decode.c10
-rw-r--r--src/mesa/drivers/dri/intel/intel_extensions.c1
-rw-r--r--src/mesa/drivers/dri/intel/intel_fbo.c36
-rw-r--r--src/mesa/drivers/dri/intel/intel_regions.h8
-rw-r--r--src/mesa/drivers/dri/intel/intel_screen.c94
-rw-r--r--src/mesa/drivers/dri/intel/intel_tex_image.c52
12 files changed, 252 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.c b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
index 4c99dcde23..e38f10ebc6 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.c
@@ -104,7 +104,8 @@ do_flush_locked(struct intel_batchbuffer *batch, GLuint used)
batch->map = NULL;
batch->ptr = NULL;
- dri_bo_exec(batch->buf, used, NULL, 0, (x_off & 0xffff) | (y_off << 16));
+ if (!intel->no_hw)
+ 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);
diff --git a/src/mesa/drivers/dri/intel/intel_batchbuffer.h b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
index b052b724d8..4daada205a 100644
--- a/src/mesa/drivers/dri/intel/intel_batchbuffer.h
+++ b/src/mesa/drivers/dri/intel/intel_batchbuffer.h
@@ -96,6 +96,17 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
intel_batchbuffer_flush(batch);
}
+static INLINE uint32_t float_as_int(float f)
+{
+ union {
+ float f;
+ uint32_t d;
+ } fi;
+
+ fi.f = f;
+ return fi.d;
+}
+
/* Here are the crusty old macros, to be removed:
*/
#define BATCH_LOCALS
@@ -108,6 +119,8 @@ intel_batchbuffer_require_space(struct intel_batchbuffer *batch,
} while (0)
#define OUT_BATCH(d) intel_batchbuffer_emit_dword(intel->batch, d)
+#define OUT_BATCH_F(f) intel_batchbuffer_emit_dword(intel->batch, \
+ float_as_int(f))
#define OUT_RELOC(buf, read_domains, write_domain, delta) do { \
assert((unsigned) (delta) < buf->size); \
diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c
index 5a60a17500..196a64a47a 100644
--- a/src/mesa/drivers/dri/intel/intel_blit.c
+++ b/src/mesa/drivers/dri/intel/intel_blit.c
@@ -89,6 +89,10 @@ intelEmitCopyBlit(struct intel_context *intel,
dri_bo *aper_array[3];
BATCH_LOCALS;
+ /* Blits are in a different ringbuffer so we don't use them. */
+ if (intel->gen >= 6)
+ return GL_FALSE;
+
if (dst_tiling != I915_TILING_NONE) {
if (dst_offset & 4095)
return GL_FALSE;
@@ -218,6 +222,9 @@ intelClearWithBlit(GLcontext *ctx, GLbitfield mask)
GLint cx, cy, cw, ch;
BATCH_LOCALS;
+ /* Blits are in a different ringbuffer so we don't use them. */
+ assert(intel->gen < 6);
+
/*
* Compute values for clearing the buffers.
*/
@@ -388,6 +395,10 @@ intelEmitImmediateColorExpandBlit(struct intel_context *intel,
int dwords = ALIGN(src_size, 8) / 4;
uint32_t opcode, br13, blit_cmd;
+ /* Blits are in a different ringbuffer so we don't use them. */
+ if (intel->gen >= 6)
+ return GL_FALSE;
+
if (dst_tiling != I915_TILING_NONE) {
if (dst_offset & 4095)
return GL_FALSE;
@@ -473,6 +484,9 @@ intel_emit_linear_blit(struct intel_context *intel,
{
GLuint pitch, height;
+ /* Blits are in a different ringbuffer so we don't use them. */
+ assert(intel->gen < 6);
+
/* The pitch is a signed value. */
pitch = MIN2(size, (1 << 15) - 1);
height = size / pitch;
diff --git a/src/mesa/drivers/dri/intel/intel_chipset.h b/src/mesa/drivers/dri/intel/intel_chipset.h
index 3dc8653a73..a0b2266925 100644
--- a/src/mesa/drivers/dri/intel/intel_chipset.h
+++ b/src/mesa/drivers/dri/intel/intel_chipset.h
@@ -1,4 +1,4 @@
-/*
+ /*
* Copyright © 2007 Intel Corporation
*
* Permission is hereby granted, free of charge, to any person obtaining a
@@ -71,6 +71,8 @@
#define PCI_CHIP_ILD_G 0x0042
#define PCI_CHIP_ILM_G 0x0046
+#define PCI_CHIP_SANDYBRIDGE 0x0102
+
#define IS_MOBILE(devid) (devid == PCI_CHIP_I855_GM || \
devid == PCI_CHIP_I915_GM || \
devid == PCI_CHIP_I945_GM || \
@@ -104,14 +106,20 @@
devid == PCI_CHIP_Q33_G || \
devid == PCI_CHIP_Q35_G || IS_IGD(devid))
-#define IS_965(devid) (devid == PCI_CHIP_I965_G || \
+#define IS_GEN4(devid) (devid == PCI_CHIP_I965_G || \
devid == PCI_CHIP_I965_Q || \
devid == PCI_CHIP_I965_G_1 || \
devid == PCI_CHIP_I965_GM || \
devid == PCI_CHIP_I965_GME || \
devid == PCI_CHIP_I946_GZ || \
+ IS_G4X(devid))
+
+#define IS_GEN6(devid) (devid == PCI_CHIP_SANDYBRIDGE)
+
+#define IS_965(devid) (IS_GEN4(devid) || \
IS_G4X(devid) || \
- IS_IGDNG(devid))
+ IS_IGDNG(devid) || \
+ IS_GEN6(devid))
#define IS_9XX(devid) (IS_915(devid) || \
IS_945(devid) || \
diff --git a/src/mesa/drivers/dri/intel/intel_clear.c b/src/mesa/drivers/dri/intel/intel_clear.c
index ca78681538..03b24e2b51 100644
--- a/src/mesa/drivers/dri/intel/intel_clear.c
+++ b/src/mesa/drivers/dri/intel/intel_clear.c
@@ -133,6 +133,12 @@ intelClear(GLcontext *ctx, GLbitfield mask)
}
}
+ if (intel->gen >= 6) {
+ /* Blits are in a different ringbuffer so we don't use them. */
+ tri_mask |= blit_mask;
+ blit_mask = 0;
+ }
+
/* SW fallback clearing */
swrast_mask = mask & ~tri_mask & ~blit_mask;
diff --git a/src/mesa/drivers/dri/intel/intel_context.c b/src/mesa/drivers/dri/intel/intel_context.c
index 3c36c3f4c8..767ad8c9d2 100644
--- a/src/mesa/drivers/dri/intel/intel_context.c
+++ b/src/mesa/drivers/dri/intel/intel_context.c
@@ -610,7 +610,11 @@ intelInitContext(struct intel_context *intel,
intel->driContext = driContextPriv;
intel->driFd = sPriv->fd;
- if (IS_965(intel->intelScreen->deviceID)) {
+ if (IS_GEN6(intel->intelScreen->deviceID)) {
+ intel->gen = 6;
+ intel->needs_ff_sync = GL_TRUE;
+ intel->has_luminance_srgb = GL_TRUE;
+ } else if (IS_965(intel->intelScreen->deviceID)) {
intel->gen = 4;
} else if (IS_9XX(intel->intelScreen->deviceID)) {
intel->gen = 3;
@@ -887,6 +891,7 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
intel->driDrawable = driDrawPriv;
driContextPriv->dri2.draw_stamp = driDrawPriv->dri2.stamp - 1;
driContextPriv->dri2.read_stamp = driReadPriv->dri2.stamp - 1;
+ intel_prepare_render(&intel->ctx);
}
else {
_mesa_make_current(NULL, NULL, NULL);
diff --git a/src/mesa/drivers/dri/intel/intel_decode.c b/src/mesa/drivers/dri/intel/intel_decode.c
index a9dfe281cb..5293482b35 100644
--- a/src/mesa/drivers/dri/intel/intel_decode.c
+++ b/src/mesa/drivers/dri/intel/intel_decode.c
@@ -1437,6 +1437,12 @@ decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, int *failures)
{ 0x7909, 2, 2, "3DSTATE_GLOBAL_DEPTH_OFFSET_CLAMP" },
{ 0x790a, 3, 3, "3DSTATE_AA_LINE_PARAMETERS" },
{ 0x7b00, 6, 6, "3DPRIMITIVE" },
+ { 0x780e, 4, 4, "3DSTATE_CC_STATE_POINTERS" },
+ { 0x7810, 6, 6, "3DSTATE_VS_STATE" },
+ { 0x7811, 6, 6, "3DSTATE_GS_STATE" },
+ { 0x7812, 4, 4, "3DSTATE_CLIP_STATE" },
+ { 0x7815, 5, 5, "3DSTATE_CONSTANT_VS_STATE" },
+ { 0x7816, 5, 5, "3DSTATE_CONSTANT_GS_STATE" },
};
len = (data[0] & 0x0000ffff) + 2;
@@ -1592,7 +1598,7 @@ decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, int *failures)
return len;
case 0x7905:
- if (len != 5 && len != 6)
+ if (len < 5 || len > 7)
fprintf(out, "Bad count in 3DSTATE_DEPTH_BUFFER\n");
if (count < len)
BUFFER_FAIL(count, len, "3DSTATE_DEPTH_BUFFER");
@@ -1611,6 +1617,8 @@ decode_3d_965(uint32_t *data, int count, uint32_t hw_offset, int *failures)
instr_out(data, hw_offset, 4, "volume depth\n");
if (len == 6)
instr_out(data, hw_offset, 5, "\n");
+ if (len == 7)
+ instr_out(data, hw_offset, 6, "render target view extent\n");
return len;
diff --git a/src/mesa/drivers/dri/intel/intel_extensions.c b/src/mesa/drivers/dri/intel/intel_extensions.c
index 84c8d013e3..e16c33b33d 100644
--- a/src/mesa/drivers/dri/intel/intel_extensions.c
+++ b/src/mesa/drivers/dri/intel/intel_extensions.c
@@ -151,6 +151,7 @@ static const struct dri_extension i915_extensions[] = {
static const struct dri_extension brw_extensions[] = {
{ "GL_ARB_depth_clamp", NULL },
{ "GL_ARB_depth_texture", NULL },
+ { "GL_ARB_fragment_coord_conventions", NULL },
{ "GL_ARB_fragment_program", NULL },
{ "GL_ARB_fragment_program_shadow", NULL },
{ "GL_ARB_fragment_shader", NULL },
diff --git a/src/mesa/drivers/dri/intel/intel_fbo.c b/src/mesa/drivers/dri/intel/intel_fbo.c
index e154bd4087..82c7b19eef 100644
--- a/src/mesa/drivers/dri/intel/intel_fbo.c
+++ b/src/mesa/drivers/dri/intel/intel_fbo.c
@@ -200,6 +200,37 @@ intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
}
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_renderbuffer_storage(GLcontext *ctx,
+ struct gl_renderbuffer *rb,
+ void *image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_renderbuffer *irb;
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(intel->driContext, image_handle,
+ intel->driContext->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ irb = intel_renderbuffer(rb);
+ if (irb->region)
+ intel_region_release(&irb->region);
+ intel_region_reference(&irb->region, image->region);
+
+ rb->Width = image->region->width;
+ rb->Height = image->region->height;
+ rb->Format = image->format;
+ rb->DataType = image->data_type;
+ rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
+ image->internal_format);
+}
+#endif
+
/**
* Called for each hardware renderbuffer when a _window_ is resized.
* Just update fields.
@@ -651,4 +682,9 @@ intel_fbo_init(struct intel_context *intel)
intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
intel->ctx.Driver.ValidateFramebuffer = intel_validate_framebuffer;
intel->ctx.Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer;
+
+#if FEATURE_OES_EGL_image
+ intel->ctx.Driver.EGLImageTargetRenderbufferStorage =
+ intel_image_target_renderbuffer_storage;
+#endif
}
diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h
index 6d36f3d88a..7ee6a988ea 100644
--- a/src/mesa/drivers/dri/intel/intel_regions.h
+++ b/src/mesa/drivers/dri/intel/intel_regions.h
@@ -148,4 +148,12 @@ void _mesa_copy_rect(GLubyte * dst,
const GLubyte * src,
GLuint src_pitch, GLuint src_x, GLuint src_y);
+struct __DRIimageRec {
+ struct intel_region *region;
+ GLenum internal_format;
+ GLuint format;
+ GLenum data_type;
+ void *data;
+};
+
#endif
diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c
index 5e23aa8a1d..bc394d048e 100644
--- a/src/mesa/drivers/dri/intel/intel_screen.c
+++ b/src/mesa/drivers/dri/intel/intel_screen.c
@@ -30,6 +30,7 @@
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "main/hash.h"
+#include "main/fbobject.h"
#include "utils.h"
#include "xmlpool.h"
@@ -41,6 +42,7 @@
#include "intel_fbo.h"
#include "intel_screen.h"
#include "intel_tex.h"
+#include "intel_regions.h"
#include "i915_drm.h"
@@ -137,11 +139,103 @@ static const struct __DRI2flushExtensionRec intelFlushExtension = {
intelDRI2Invalidate,
};
+static __DRIimage *
+intel_create_image_from_name(__DRIcontext *context,
+ int width, int height, int format,
+ int name, int pitch, void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_context *intel = context->driverPrivate;
+ int cpp;
+
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ switch (format) {
+ case __DRI_IMAGE_FORMAT_RGB565:
+ image->format = MESA_FORMAT_RGB565;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_XRGB8888:
+ image->format = MESA_FORMAT_XRGB8888;
+ image->internal_format = GL_RGB;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ case __DRI_IMAGE_FORMAT_ARGB8888:
+ image->format = MESA_FORMAT_ARGB8888;
+ image->internal_format = GL_RGBA;
+ image->data_type = GL_UNSIGNED_BYTE;
+ break;
+ default:
+ free(image);
+ return NULL;
+ }
+
+ image->data = loaderPrivate;
+ cpp = _mesa_get_format_bytes(image->format);
+
+ image->region = intel_region_alloc_for_handle(intel, cpp, width, height,
+ pitch, name, "image");
+ if (image->region == NULL) {
+ FREE(image);
+ return NULL;
+ }
+
+ return image;
+}
+
+static __DRIimage *
+intel_create_image_from_renderbuffer(__DRIcontext *context,
+ int renderbuffer, void *loaderPrivate)
+{
+ __DRIimage *image;
+ struct intel_context *intel = context->driverPrivate;
+ struct gl_renderbuffer *rb;
+ struct intel_renderbuffer *irb;
+
+ rb = _mesa_lookup_renderbuffer(&intel->ctx, renderbuffer);
+ if (!rb) {
+ _mesa_error(&intel->ctx,
+ GL_INVALID_OPERATION, "glRenderbufferExternalMESA");
+ return NULL;
+ }
+
+ irb = intel_renderbuffer(rb);
+ image = CALLOC(sizeof *image);
+ if (image == NULL)
+ return NULL;
+
+ image->internal_format = rb->InternalFormat;
+ image->format = rb->Format;
+ image->data_type = rb->DataType;
+ image->data = loaderPrivate;
+ intel_region_reference(&image->region, irb->region);
+
+ return image;
+}
+
+static void
+intel_destroy_image(__DRIimage *image)
+{
+ intel_region_release(&image->region);
+ FREE(image);
+}
+
+static struct __DRIimageExtensionRec intelImageExtension = {
+ { __DRI_IMAGE, __DRI_IMAGE_VERSION },
+ intel_create_image_from_name,
+ intel_create_image_from_renderbuffer,
+ intel_destroy_image,
+};
+
static const __DRIextension *intelScreenExtensions[] = {
&driReadDrawableExtension,
&intelTexOffsetExtension.base,
&intelTexBufferExtension.base,
&intelFlushExtension.base,
+ &intelImageExtension.base,
NULL
};
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index aefd0b97d0..f586aee992 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -814,6 +814,54 @@ intelSetTexBuffer(__DRIcontext *pDRICtx, GLint target, __DRIdrawable *dPriv)
intelSetTexBuffer2(pDRICtx, target, __DRI_TEXTURE_FORMAT_RGBA, dPriv);
}
+#if FEATURE_OES_EGL_image
+static void
+intel_image_target_texture_2d(GLcontext *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ struct intel_context *intel = intel_context(ctx);
+ struct intel_texture_object *intelObj = intel_texture_object(texObj);
+ struct intel_texture_image *intelImage = intel_texture_image(texImage);
+ struct intel_mipmap_tree *mt;
+ __DRIscreen *screen;
+ __DRIimage *image;
+
+ screen = intel->intelScreen->driScrnPriv;
+ image = screen->dri2.image->lookupEGLImage(intel->driContext, image_handle,
+ intel->driContext->loaderPrivate);
+ if (image == NULL)
+ return;
+
+ mt = intel_miptree_create_for_region(intel, target,
+ image->internal_format,
+ 0, 0, image->region, 1, 0);
+ if (mt == NULL)
+ return;
+
+ if (intelImage->mt) {
+ intel_miptree_release(intel, &intelImage->mt);
+ assert(!texImage->Data);
+ }
+ if (intelObj->mt)
+ intel_miptree_release(intel, &intelObj->mt);
+
+ intelObj->mt = mt;
+ _mesa_init_teximage_fields(&intel->ctx, target, texImage,
+ image->region->width, image->region->height, 1,
+ 0, image->internal_format);
+
+ intelImage->face = target_to_face(target);
+ intelImage->level = 0;
+ texImage->TexFormat = image->format;
+ texImage->RowStride = image->region->pitch;
+ intel_miptree_reference(&intelImage->mt, intelObj->mt);
+
+ if (!intel_miptree_match_image(intelObj->mt, &intelImage->base))
+ fprintf(stderr, "miptree doesn't match image\n");
+}
+#endif
void
intelInitTextureImageFuncs(struct dd_function_table *functions)
@@ -825,4 +873,8 @@ intelInitTextureImageFuncs(struct dd_function_table *functions)
functions->CompressedTexImage2D = intelCompressedTexImage2D;
functions->GetCompressedTexImage = intelGetCompressedTexImage;
+
+#if FEATURE_OES_EGL_image
+ functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
+#endif
}