diff options
Diffstat (limited to 'src/mesa/drivers/dri/radeon')
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_common_context.c | 104 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_context.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_fbo.c | 46 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.c | 200 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_screen.h | 11 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_swtcl.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_tcl.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_tex.c | 4 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texstate.c | 20 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.c | 64 | ||||
-rw-r--r-- | src/mesa/drivers/dri/radeon/radeon_texture.h | 7 |
12 files changed, 411 insertions, 57 deletions
diff --git a/src/mesa/drivers/dri/radeon/radeon_common.c b/src/mesa/drivers/dri/radeon/radeon_common.c index 43a6355ad8..7361adffcf 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common.c +++ b/src/mesa/drivers/dri/radeon/radeon_common.c @@ -171,6 +171,10 @@ void radeonSetCliprects(radeonContextPtr radeon) { __DRIdrawable *const drawable = radeon_get_drawable(radeon); __DRIdrawable *const readable = radeon_get_readable(radeon); + + if(drawable == NULL && readable == NULL) + return; + struct radeon_framebuffer *const draw_rfb = drawable->driverPrivate; struct radeon_framebuffer *const read_rfb = readable->driverPrivate; int x_off, y_off; diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c index 40544860b3..fecdd11905 100644 --- a/src/mesa/drivers/dri/radeon/radeon_common_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c @@ -39,6 +39,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "drirenderbuffer.h" #include "drivers/common/meta.h" #include "main/context.h" +#include "main/framebuffer.h" #include "main/renderbuffer.h" #include "main/state.h" #include "main/simple_list.h" @@ -245,16 +246,9 @@ GLboolean radeonInitContext(radeonContextPtr radeon, DRI_CONF_TEXTURE_DEPTH_32 : DRI_CONF_TEXTURE_DEPTH_16; if (IS_R600_CLASS(radeon->radeonScreen)) { - int chip_family = radeon->radeonScreen->chip_family; - if (chip_family >= CHIP_FAMILY_CEDAR) { - radeon->texture_row_align = 512; - radeon->texture_rect_row_align = 512; - radeon->texture_compressed_row_align = 512; - } else { - radeon->texture_row_align = 256; - radeon->texture_rect_row_align = 256; - radeon->texture_compressed_row_align = 256; - } + radeon->texture_row_align = radeon->radeonScreen->group_bytes; + radeon->texture_rect_row_align = radeon->radeonScreen->group_bytes; + radeon->texture_compressed_row_align = radeon->radeonScreen->group_bytes; } else if (IS_R200_CLASS(radeon->radeonScreen) || IS_R100_CLASS(radeon->radeonScreen)) { radeon->texture_row_align = 32; @@ -379,12 +373,12 @@ GLboolean radeonUnbindContext(__DRIcontext * driContextPriv) static void radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon, - struct radeon_framebuffer *draw) + struct gl_framebuffer *draw) { /* if radeon->fake */ struct radeon_renderbuffer *rb; - if ((rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->frontOffset, @@ -396,7 +390,7 @@ radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->frontPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_BACK_LEFT].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->backOffset, @@ -408,7 +402,7 @@ radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->backPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_DEPTH].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->depthOffset, @@ -420,7 +414,7 @@ radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_STENCIL].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_STENCIL].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->depthOffset, @@ -436,7 +430,7 @@ radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon, static void radeon_make_renderbuffer_current(radeonContextPtr radeon, - struct radeon_framebuffer *draw) + struct gl_framebuffer *draw) { int size = 4096*4096*4; /* if radeon->fake */ @@ -448,7 +442,7 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon, } - if ((rb = (void *)draw->base.Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_FRONT_LEFT].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->frontOffset + @@ -461,7 +455,7 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->frontPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_BACK_LEFT].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_BACK_LEFT].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->backOffset + @@ -474,7 +468,7 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->backPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_DEPTH].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_DEPTH].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->depthOffset + @@ -487,7 +481,7 @@ radeon_make_renderbuffer_current(radeonContextPtr radeon, rb->cpp = radeon->radeonScreen->cpp; rb->pitch = radeon->radeonScreen->depthPitch * rb->cpp; } - if ((rb = (void *)draw->base.Attachment[BUFFER_STENCIL].Renderbuffer)) { + if ((rb = (void *)draw->Attachment[BUFFER_STENCIL].Renderbuffer)) { if (!rb->bo) { rb->bo = radeon_bo_open(radeon->radeonScreen->bom, radeon->radeonScreen->depthOffset + @@ -740,10 +734,9 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable, buffers[i].flags); if (bo == NULL) { - fprintf(stderr, "failed to attach %s %d\n", regname, buffers[i].name); - + continue; } ret = radeon_bo_get_tiling(bo, &tiling_flags, &pitch); @@ -793,8 +786,8 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv, __DRIdrawable * driReadPriv) { radeonContextPtr radeon; - struct radeon_framebuffer *drfb; - struct gl_framebuffer *readfb; + struct radeon_framebuffer *rdrfb; + struct gl_framebuffer *drfb, *readfb; if (!driContextPriv) { if (RADEON_DEBUG & RADEON_DRI) @@ -804,17 +797,25 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv, } radeon = (radeonContextPtr) driContextPriv->driverPrivate; - drfb = driDrawPriv->driverPrivate; - readfb = driReadPriv->driverPrivate; + + if(driDrawPriv == NULL && driReadPriv == NULL) { + drfb = _mesa_create_framebuffer(&radeon->glCtx->Visual); + readfb = drfb; + } + else { + drfb = driDrawPriv->driverPrivate; + readfb = driReadPriv->driverPrivate; + } if (driContextPriv->driScreenPriv->dri2.enabled) { - radeon_update_renderbuffers(driContextPriv, driDrawPriv, GL_FALSE); + if(driDrawPriv) + radeon_update_renderbuffers(driContextPriv, driDrawPriv, GL_FALSE); if (driDrawPriv != driReadPriv) radeon_update_renderbuffers(driContextPriv, driReadPriv, GL_FALSE); _mesa_reference_renderbuffer(&radeon->state.color.rb, - &(radeon_get_renderbuffer(&drfb->base, BUFFER_BACK_LEFT)->base)); + &(radeon_get_renderbuffer(drfb, BUFFER_BACK_LEFT)->base)); _mesa_reference_renderbuffer(&radeon->state.depth.rb, - &(radeon_get_renderbuffer(&drfb->base, BUFFER_DEPTH)->base)); + &(radeon_get_renderbuffer(drfb, BUFFER_DEPTH)->base)); } else { radeon_make_renderbuffer_current(radeon, drfb); } @@ -822,35 +823,40 @@ GLboolean radeonMakeCurrent(__DRIcontext * driContextPriv, if (RADEON_DEBUG & RADEON_DRI) fprintf(stderr, "%s ctx %p dfb %p rfb %p\n", __FUNCTION__, radeon->glCtx, drfb, readfb); - driUpdateFramebufferSize(radeon->glCtx, driDrawPriv); + if(driDrawPriv) + driUpdateFramebufferSize(radeon->glCtx, driDrawPriv); if (driReadPriv != driDrawPriv) driUpdateFramebufferSize(radeon->glCtx, driReadPriv); - _mesa_make_current(radeon->glCtx, &drfb->base, readfb); + _mesa_make_current(radeon->glCtx, drfb, readfb); + if (driDrawPriv == NULL && driReadPriv == NULL) + _mesa_reference_framebuffer(&drfb, NULL); _mesa_update_state(radeon->glCtx); - if (radeon->glCtx->DrawBuffer == &drfb->base) { - if (driDrawPriv->swap_interval == (unsigned)-1) { - int i; - driDrawPriv->vblFlags = - (radeon->radeonScreen->irq != 0) - ? driGetDefaultVBlankFlags(&radeon-> - optionCache) - : VBLANK_FLAG_NO_IRQ; - - driDrawableInitVBlank(driDrawPriv); - drfb->vbl_waited = driDrawPriv->vblSeq; - - for (i = 0; i < 2; i++) { - if (drfb->color_rb[i]) - drfb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq; + if (radeon->glCtx->DrawBuffer == drfb) { + if(driDrawPriv != NULL) { + rdrfb = (struct radeon_framebuffer *)drfb; + if (driDrawPriv->swap_interval == (unsigned)-1) { + int i; + driDrawPriv->vblFlags = + (radeon->radeonScreen->irq != 0) + ? driGetDefaultVBlankFlags(&radeon-> + optionCache) + : VBLANK_FLAG_NO_IRQ; + + driDrawableInitVBlank(driDrawPriv); + rdrfb->vbl_waited = driDrawPriv->vblSeq; + + for (i = 0; i < 2; i++) { + if (rdrfb->color_rb[i]) + rdrfb->color_rb[i]->vbl_pending = driDrawPriv->vblSeq; + } } - + radeon_window_moved(radeon); } - radeon_window_moved(radeon); - radeon_draw_buffer(radeon->glCtx, &drfb->base); + radeon_draw_buffer(radeon->glCtx, drfb); } diff --git a/src/mesa/drivers/dri/radeon/radeon_context.c b/src/mesa/drivers/dri/radeon/radeon_context.c index cc9590213c..e3de534b5f 100644 --- a/src/mesa/drivers/dri/radeon/radeon_context.c +++ b/src/mesa/drivers/dri/radeon/radeon_context.c @@ -66,6 +66,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define need_GL_EXT_fog_coord #define need_GL_EXT_secondary_color #define need_GL_EXT_framebuffer_object +#define need_GL_OES_EGL_image #include "main/remap_helper.h" #define DRIVER_DATE "20061018" @@ -101,6 +102,9 @@ static const struct dri_extension card_extensions[] = { "GL_ATI_texture_mirror_once", NULL }, { "GL_MESA_ycbcr_texture", NULL }, { "GL_NV_blend_square", NULL }, +#if FEATURE_OES_EGL_image + { "GL_OES_EGL_image", GL_OES_EGL_image_functions }, +#endif { NULL, NULL } }; diff --git a/src/mesa/drivers/dri/radeon/radeon_fbo.c b/src/mesa/drivers/dri/radeon/radeon_fbo.c index 2a6fbaeaf0..a36a1dc94a 100644 --- a/src/mesa/drivers/dri/radeon/radeon_fbo.c +++ b/src/mesa/drivers/dri/radeon/radeon_fbo.c @@ -199,6 +199,48 @@ radeon_alloc_renderbuffer_storage(struct gl_context * ctx, struct gl_renderbuffe } +#if FEATURE_OES_EGL_image +static void +radeon_image_target_renderbuffer_storage(struct gl_context *ctx, + struct gl_renderbuffer *rb, + void *image_handle) +{ + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + struct radeon_renderbuffer *rrb; + __DRIscreen *screen; + __DRIimage *image; + + screen = radeon->radeonScreen->driScreen; + image = screen->dri2.image->lookupEGLImage(screen, image_handle, + screen->loaderPrivate); + if (image == NULL) + return; + + rrb = radeon_renderbuffer(rb); + + if (ctx->Driver.Flush) + ctx->Driver.Flush(ctx); /* +r6/r7 */ + + if (rrb->bo) + radeon_bo_unref(rrb->bo); + rrb->bo = image->bo; + radeon_bo_ref(rrb->bo); + fprintf(stderr, "image->bo: %p, name: %d, rbs: w %d -> p %d\n", image->bo, image->bo->handle, + image->width, image->pitch); + + rrb->cpp = image->cpp; + rrb->pitch = image->pitch * image->cpp; + + rb->Format = image->format; + rb->InternalFormat = image->internal_format; + rb->Width = image->width; + rb->Height = image->height; + rb->Format = image->format; + rb->DataType = image->data_type; + rb->_BaseFormat = _mesa_base_fbo_format(radeon->glCtx, + image->internal_format); +} +#endif /** * Called for each hardware renderbuffer when a _window_ is resized. @@ -622,6 +664,10 @@ void radeon_fbo_init(struct radeon_context *radeon) #if FEATURE_EXT_framebuffer_blit radeon->glCtx->Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer; #endif +#if FEATURE_OES_EGL_image + radeon->glCtx->Driver.EGLImageTargetRenderbufferStorage = + radeon_image_target_renderbuffer_storage; +#endif } diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c index 43ebc81093..b379240579 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -41,12 +41,14 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "main/mtypes.h" #include "main/framebuffer.h" #include "main/renderbuffer.h" +#include "main/fbobject.h" #define STANDALONE_MMIO #include "radeon_chipset.h" #include "radeon_macros.h" #include "radeon_screen.h" #include "radeon_common.h" +#include "radeon_common_context.h" #if defined(RADEON_R100) #include "radeon_context.h" #include "radeon_tex.h" @@ -398,6 +400,188 @@ static const struct __DRI2flushExtensionRec radeonFlushExtension = { dri2InvalidateDrawable, }; +static __DRIimage * +radeon_create_image_from_name(__DRIcontext *context, + int width, int height, int format, + int name, int pitch, void *loaderPrivate) +{ + __DRIimage *image; + radeonContextPtr radeon = context->driverPrivate; + + if (name == 0) + return NULL; + + 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; + image->cpp = _mesa_get_format_bytes(image->format); + image->width = width; + image->pitch = pitch; + image->height = height; + + image->bo = radeon_bo_open(radeon->radeonScreen->bom, + (uint32_t)name, + image->pitch * image->height * image->cpp, + 0, + RADEON_GEM_DOMAIN_VRAM, + 0); + + if (image->bo == NULL) { + FREE(image); + return NULL; + } + + return image; +} + +static __DRIimage * +radeon_create_image_from_renderbuffer(__DRIcontext *context, + int renderbuffer, void *loaderPrivate) +{ + __DRIimage *image; + radeonContextPtr radeon = context->driverPrivate; + struct gl_renderbuffer *rb; + struct radeon_renderbuffer *rrb; + + rb = _mesa_lookup_renderbuffer(radeon->glCtx, renderbuffer); + if (!rb) { + _mesa_error(radeon->glCtx, + GL_INVALID_OPERATION, "glRenderbufferExternalMESA"); + return NULL; + } + + rrb = radeon_renderbuffer(rb); + image = CALLOC(sizeof *image); + if (image == NULL) + return NULL; + + image->internal_format = rb->InternalFormat; + image->format = rb->Format; + image->cpp = rrb->cpp; + image->data_type = rb->DataType; + image->data = loaderPrivate; + radeon_bo_ref(rrb->bo); + image->bo = rrb->bo; + + image->width = rb->Width; + image->height = rb->Height; + image->pitch = rrb->pitch / image->cpp; + + return image; +} + +static void +radeon_destroy_image(__DRIimage *image) +{ + radeon_bo_unref(image->bo); + FREE(image); +} + +static __DRIimage * +radeon_create_image(__DRIscreen *screen, + int width, int height, int format, + unsigned int use, + void *loaderPrivate) +{ + __DRIimage *image; + radeonScreenPtr radeonScreen = screen->private; + + 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; + image->cpp = _mesa_get_format_bytes(image->format); + image->width = width; + image->height = height; + image->pitch = ((image->cpp * image->width + 255) & ~255) / image->cpp; + + image->bo = radeon_bo_open(radeonScreen->bom, + 0, + image->pitch * image->height * image->cpp, + 0, + RADEON_GEM_DOMAIN_VRAM, + 0); + + if (image->bo == NULL) { + FREE(image); + return NULL; + } + + return image; +} + +static GLboolean +radeon_query_image(__DRIimage *image, int attrib, int *value) +{ + switch (attrib) { + case __DRI_IMAGE_ATTRIB_STRIDE: + *value = image->pitch * image->cpp; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_HANDLE: + *value = image->bo->handle; + return GL_TRUE; + case __DRI_IMAGE_ATTRIB_NAME: + radeon_gem_get_kernel_name(image->bo, (uint32_t *) value); + return GL_TRUE; + default: + return GL_FALSE; + } +} + +static struct __DRIimageExtensionRec radeonImageExtension = { + { __DRI_IMAGE, __DRI_IMAGE_VERSION }, + radeon_create_image_from_name, + radeon_create_image_from_renderbuffer, + radeon_destroy_image, + radeon_create_image, + radeon_query_image +}; + static int radeon_set_screen_flags(radeonScreenPtr screen, int device_id) { screen->device_id = device_id; @@ -1138,6 +1322,12 @@ radeonCreateScreen( __DRIscreen *sPriv ) else screen->chip_flags |= RADEON_CLASS_R600; + /* set group bytes for r6xx+ */ + if (screen->chip_family >= CHIP_FAMILY_CEDAR) + screen->group_bytes = 512; + else + screen->group_bytes = 256; + screen->cpp = dri_priv->bpp / 8; screen->AGPMode = dri_priv->AGPMode; @@ -1382,8 +1572,13 @@ radeonCreateScreen2(__DRIscreen *sPriv) else screen->chip_flags |= RADEON_CLASS_R600; - /* r6xx+ tiling */ - if (IS_R600_CLASS(screen) && (sPriv->drm_version.minor >= 6)) { + /* r6xx+ tiling, default group bytes */ + if (screen->chip_family >= CHIP_FAMILY_CEDAR) + screen->group_bytes = 512; + else + screen->group_bytes = 256; + if (IS_R600_CLASS(screen) && (sPriv->drm_version.minor >= 6) && + (screen->chip_family < CHIP_FAMILY_CEDAR)) { ret = radeonGetParam(sPriv, RADEON_INFO_TILE_CONFIG, &temp); if (ret) fprintf(stderr, "failed to get tiling info\n"); @@ -1507,6 +1702,7 @@ radeonCreateScreen2(__DRIscreen *sPriv) #endif screen->extensions[i++] = &radeonFlushExtension.base; + screen->extensions[i++] = &radeonImageExtension.base; screen->extensions[i++] = NULL; sPriv->extensions = screen->extensions; diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.h b/src/mesa/drivers/dri/radeon/radeon_screen.h index 2b33201a53..417ebf3b06 100644 --- a/src/mesa/drivers/dri/radeon/radeon_screen.h +++ b/src/mesa/drivers/dri/radeon/radeon_screen.h @@ -121,6 +121,17 @@ typedef struct radeon_screen { GLint r7xx_bank_op; } radeonScreenRec, *radeonScreenPtr; +struct __DRIimageRec { + struct radeon_bo *bo; + GLenum internal_format; + GLuint format; + GLenum data_type; + int width, height; /* in pixels */ + int pitch; /* in pixels */ + int cpp; + void *data; +}; + #define IS_R100_CLASS(screen) \ ((screen->chip_flags & RADEON_CLASS_MASK) == RADEON_CLASS_R100) #define IS_R200_CLASS(screen) \ diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c index f5b0df6ef5..ff3506b225 100644 --- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c @@ -412,6 +412,8 @@ static GLboolean radeon_run_render( struct gl_context *ctx, return GL_TRUE; radeon_prepare_render(&rmesa->radeon); + if (rmesa->radeon.NewGLState) + radeonValidateState( ctx ); tnl->Driver.Render.Start( ctx ); diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.c b/src/mesa/drivers/dri/radeon/radeon_tcl.c index c59b413012..5d2e8f4870 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tcl.c +++ b/src/mesa/drivers/dri/radeon/radeon_tcl.c @@ -253,6 +253,8 @@ void radeonTclPrimitive( struct gl_context *ctx, GLuint newprim = hw_prim | RADEON_CP_VC_CNTL_TCL_ENABLE; radeon_prepare_render(&rmesa->radeon); + if (rmesa->radeon.NewGLState) + radeonValidateState( ctx ); if (newprim != rmesa->tcl.hw_primitive || !discrete_prim[hw_prim&0xf]) { diff --git a/src/mesa/drivers/dri/radeon/radeon_tex.c b/src/mesa/drivers/dri/radeon/radeon_tex.c index d5285e24cd..83b1d1b1d7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_tex.c +++ b/src/mesa/drivers/dri/radeon/radeon_tex.c @@ -465,5 +465,9 @@ void radeonInitTextureFuncs( radeonContextPtr radeon, struct dd_function_table * functions->MapTexture = radeonMapTexture; functions->UnmapTexture = radeonUnmapTexture; +#if FEATURE_OES_EGL_image + functions->EGLImageTargetTexture2D = radeon_image_target_texture_2d; +#endif + driInitTextureFormats(); } diff --git a/src/mesa/drivers/dri/radeon/radeon_texstate.c b/src/mesa/drivers/dri/radeon/radeon_texstate.c index dd8ecdd500..32c021cb54 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texstate.c +++ b/src/mesa/drivers/dri/radeon/radeon_texstate.c @@ -653,6 +653,7 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form radeonTexObjPtr t; uint32_t pitch_val; uint32_t internalFormat, type, format; + gl_format texFormat; type = GL_BGRA; format = GL_UNSIGNED_BYTE; @@ -692,10 +693,6 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form radeon_miptree_unreference(&t->mt); radeon_miptree_unreference(&rImage->mt); - _mesa_init_teximage_fields(radeon->glCtx, target, texImage, - rb->base.Width, rb->base.Height, 1, 0, rb->cpp); - texImage->RowStride = rb->pitch / rb->cpp; - rImage->bo = rb->bo; radeon_bo_ref(rImage->bo); t->bo = rb->bo; @@ -705,23 +702,34 @@ void radeonSetTexBuffer2(__DRIcontext *pDRICtx, GLint target, GLint texture_form t->override_offset = 0; switch (rb->cpp) { case 4: - if (texture_format == __DRI_TEXTURE_FORMAT_RGB) + if (texture_format == __DRI_TEXTURE_FORMAT_RGB) { t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format; - else + texFormat = MESA_FORMAT_RGB888; + } + else { t->pp_txformat = tx_table[MESA_FORMAT_ARGB8888].format; + texFormat = MESA_FORMAT_ARGB8888; + } t->pp_txfilter |= tx_table[MESA_FORMAT_ARGB8888].filter; break; case 3: default: + texFormat = MESA_FORMAT_RGB888; t->pp_txformat = tx_table[MESA_FORMAT_RGB888].format; t->pp_txfilter |= tx_table[MESA_FORMAT_RGB888].filter; break; case 2: + texFormat = MESA_FORMAT_RGB565; t->pp_txformat = tx_table[MESA_FORMAT_RGB565].format; t->pp_txfilter |= tx_table[MESA_FORMAT_RGB565].filter; break; } + _mesa_init_teximage_fields(radeon->glCtx, target, texImage, + rb->base.Width, rb->base.Height, 1, 0, + rb->cpp, texFormat); + texImage->RowStride = rb->pitch / rb->cpp; + t->pp_txpitch &= (1 << 13) -1; pitch_val = rb->pitch; diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.c b/src/mesa/drivers/dri/radeon/radeon_texture.c index 18ccb512d7..8b1e34fe76 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.c +++ b/src/mesa/drivers/dri/radeon/radeon_texture.c @@ -1007,3 +1007,67 @@ unsigned radeonIsFormatRenderable(gl_format mesa_format) return 0; } } + +#if FEATURE_OES_EGL_image +void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle) +{ + radeonContextPtr radeon = RADEON_CONTEXT(ctx); + radeonTexObj *t = radeon_tex_obj(texObj); + radeon_texture_image *radeonImage = get_radeon_texture_image(texImage); + __DRIscreen *screen; + __DRIimage *image; + + screen = radeon->dri.screen; + image = screen->dri2.image->lookupEGLImage(screen, image_handle, + screen->loaderPrivate); + if (image == NULL) + return; + + radeonFreeTexImageData(ctx, texImage); + + texImage->Width = image->width; + texImage->Height = image->height; + texImage->Depth = 1; + texImage->_BaseFormat = GL_RGBA; + texImage->TexFormat = image->format; + texImage->RowStride = image->pitch; + texImage->InternalFormat = image->internal_format; + + if(t->mt) + { + radeon_miptree_unreference(&t->mt); + t->mt = NULL; + } + + /* NOTE: The following is *very* ugly and will probably break. But + I don't know how to deal with it, without creating a whole new + function like radeon_miptree_from_bo() so I'm going with the + easy but error-prone way. */ + + radeon_try_alloc_miptree(radeon, t); + + radeonImage->mtface = _mesa_tex_target_to_face(target); + radeonImage->mtlevel = 0; + radeon_miptree_reference(t->mt, &radeonImage->mt); + + if (t->mt == NULL) + { + radeon_print(RADEON_TEXTURE, RADEON_VERBOSE, + "%s Failed to allocate miptree.\n", __func__); + return; + } + + /* Particularly ugly: this is guaranteed to break, if image->bo is + not of the required size for a miptree. */ + radeon_bo_unref(t->mt->bo); + radeon_bo_ref(image->bo); + t->mt->bo = image->bo; + + if (!radeon_miptree_matches_image(t->mt, &radeonImage->base, + radeonImage->mtface, 0)) + fprintf(stderr, "miptree doesn't match image\n"); +} +#endif diff --git a/src/mesa/drivers/dri/radeon/radeon_texture.h b/src/mesa/drivers/dri/radeon/radeon_texture.h index 9138a7d554..a1908c6bc7 100644 --- a/src/mesa/drivers/dri/radeon/radeon_texture.h +++ b/src/mesa/drivers/dri/radeon/radeon_texture.h @@ -137,4 +137,11 @@ void radeonCopyTexSubImage2D(struct gl_context *ctx, GLenum target, GLint level, unsigned radeonIsFormatRenderable(gl_format mesa_format); +#if FEATURE_OES_EGL_image +void radeon_image_target_texture_2d(struct gl_context *ctx, GLenum target, + struct gl_texture_object *texObj, + struct gl_texture_image *texImage, + GLeglImageOES image_handle); +#endif + #endif |