#include "main/texobj.h"
#include "main/teximage.h"
#include "main/texstore.h"
+#include "main/glthread.h"
#include "drivers/common/meta.h"
#include "intel_tex.h"
#include "intel_fbo.h"
#include "intel_image.h"
-#include "intel_tiled_memcpy.h"
#include "brw_context.h"
#include "brw_blorp.h"
struct brw_bo *bo;
uint32_t cpp;
- mem_copy_fn mem_copy = NULL;
+ isl_memcpy_type copy_type;
/* This fastpath is restricted to specific texture types:
* a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support
!(texImage->TexObject->Target == GL_TEXTURE_2D ||
texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
pixels == NULL ||
- _mesa_is_bufferobj(packing->BufferObj) ||
+ packing->BufferObj ||
packing->Alignment > 4 ||
packing->SkipPixels > 0 ||
packing->SkipRows > 0 ||
if (ctx->_ImageTransferState)
return false;
- if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp))
+ copy_type = intel_miptree_get_memcpy_type(texImage->TexFormat, format, type,
+ &cpp);
+ if (copy_type == ISL_MEMCPY_INVALID)
return false;
/* If this is a nontrivial texture view, let another path handle it instead. */
xoffset += level_x;
yoffset += level_y;
- linear_to_tiled(
+ isl_memcpy_linear_to_tiled(
xoffset * cpp, (xoffset + width) * cpp,
yoffset, yoffset + height,
map,
pixels,
- image->mt->surf.row_pitch, src_pitch,
+ image->mt->surf.row_pitch_B, src_pitch,
brw->has_swizzling,
image->mt->surf.tiling,
- mem_copy
+ copy_type
);
brw_bo_unmap(bo);
bool ok;
/* Check that there is actually data to store. */
- if (pixels == NULL && !_mesa_is_bufferobj(packing->BufferObj))
+ if (pixels == NULL && !packing->BufferObj)
return;
- bool tex_busy = mt && brw_bo_busy(mt->bo);
+ bool tex_busy = mt &&
+ (brw_batch_references(&brw->batch, mt->bo) || brw_bo_busy(mt->bo));
- if (mt && mt->format == MESA_FORMAT_S_UINT8)
- mt->r8stencil_needs_update = true;
-
- if (_mesa_is_bufferobj(packing->BufferObj) || tex_busy ||
+ if (packing->BufferObj || tex_busy ||
mt->aux_usage == ISL_AUX_USAGE_CCS_E) {
ok = intel_texsubimage_blorp(brw, dims, texImage,
xoffset, yoffset, zoffset,
brw->ctx.Driver.FreeTextureImageBuffer(&brw->ctx, image);
intel_texobj->needs_validate = true;
- intel_image->base.RowStride = mt->surf.row_pitch / mt->cpp;
- assert(mt->surf.row_pitch % mt->cpp == 0);
+ intel_image->base.RowStride = mt->surf.row_pitch_B / mt->cpp;
+ assert(mt->surf.row_pitch_B % mt->cpp == 0);
intel_miptree_reference(&intel_image->mt, mt);
mesa_format texFormat = MESA_FORMAT_NONE;
GLenum internal_format = 0;
+ _mesa_glthread_finish(ctx);
+
texObj = _mesa_get_current_tex_object(ctx, target);
if (!texObj)
}
static void
-intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
- struct gl_texture_object *texObj,
- struct gl_texture_image *texImage,
- GLeglImageOES image_handle)
+intel_image_target_texture(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle,
+ bool storage)
{
struct brw_context *brw = brw_context(ctx);
struct intel_mipmap_tree *mt;
if (image == NULL)
return;
- /* We support external textures only for EGLImages created with
- * EGL_EXT_image_dma_buf_import. We may lift that restriction in the future.
- */
- if (target == GL_TEXTURE_EXTERNAL_OES && !image->dma_buf_imported) {
- _mesa_error(ctx, GL_INVALID_OPERATION,
- "glEGLImageTargetTexture2DOES(external target is enabled only "
- "for images created with EGL_EXT_image_dma_buf_import");
- return;
- }
-
/* Disallow depth/stencil textures: we don't have a way to pass the
* separate stencil miptree of a GL_DEPTH_STENCIL texture through.
*/
struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
intel_texobj->planar_format = image->planar_format;
- const GLenum internal_format =
+ GLenum internal_format =
image->internal_format != 0 ?
image->internal_format : _mesa_get_format_base_format(mt->format);
+
+ /* Fix the internal format when _mesa_get_format_base_format(mt->format)
+ * isn't a valid one for that particular format.
+ */
+ if (brw->mesa_format_supports_render[image->format]) {
+ if (image->format == MESA_FORMAT_R10G10B10A2_UNORM ||
+ image->format == MESA_FORMAT_R10G10B10X2_UNORM ||
+ image->format == MESA_FORMAT_B10G10R10A2_UNORM ||
+ image->format == MESA_FORMAT_B10G10R10X2_UNORM)
+ internal_format = GL_RGB10_A2;
+ }
+
+ /* Guess sized internal format for dma-bufs, as specified by
+ * EXT_EGL_image_storage.
+ */
+ if (storage && target == GL_TEXTURE_2D && image->imported_dmabuf) {
+ internal_format = driGLFormatToSizedInternalGLFormat(image->format);
+ if (internal_format == GL_NONE) {
+ _mesa_error(ctx, GL_INVALID_OPERATION, __func__);
+ return;
+ }
+ }
+
intel_set_texture_image_mt(brw, texImage, internal_format, mt->format, mt);
intel_miptree_release(&mt);
}
+static void
+intel_image_target_texture_2d(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ intel_image_target_texture(ctx, target, texObj, texImage, image_handle,
+ false);
+}
+
+static void
+intel_image_target_tex_storage(struct gl_context *ctx, GLenum target,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage,
+ GLeglImageOES image_handle)
+{
+ struct intel_texture_object *intel_texobj = intel_texture_object(texObj);
+ intel_image_target_texture(ctx, target, texObj, texImage, image_handle,
+ true);
+
+ /* The miptree is in a validated state, so no need to check later. */
+ intel_texobj->needs_validate = false;
+ intel_texobj->validated_first_level = 0;
+ intel_texobj->validated_last_level = 0;
+ intel_texobj->_Format = texImage->TexFormat;
+}
+
static bool
intel_gettexsubimage_blorp(struct brw_context *brw,
struct gl_texture_image *tex_image,
struct brw_bo *bo;
uint32_t cpp;
- mem_copy_fn mem_copy = NULL;
+ isl_memcpy_type copy_type;
/* This fastpath is restricted to specific texture types:
* a 2D BGRA, RGBA, L8 or A8 texture. It could be generalized to support
!(texImage->TexObject->Target == GL_TEXTURE_2D ||
texImage->TexObject->Target == GL_TEXTURE_RECTANGLE) ||
pixels == NULL ||
- _mesa_is_bufferobj(packing->BufferObj) ||
+ packing->BufferObj ||
packing->Alignment > 4 ||
packing->SkipPixels > 0 ||
packing->SkipRows > 0 ||
if (texImage->_BaseFormat == GL_RGB)
return false;
- if (!intel_get_memcpy(texImage->TexFormat, format, type, &mem_copy, &cpp))
+ copy_type = intel_miptree_get_memcpy_type(texImage->TexFormat, format, type,
+ &cpp);
+ if (copy_type == ISL_MEMCPY_INVALID)
return false;
/* If this is a nontrivial texture view, let another path handle it instead. */
xoffset += level_x;
yoffset += level_y;
- tiled_to_linear(
+ isl_memcpy_tiled_to_linear(
xoffset * cpp, (xoffset + width) * cpp,
yoffset, yoffset + height,
pixels,
map,
- dst_pitch, image->mt->surf.row_pitch,
+ dst_pitch, image->mt->surf.row_pitch_B,
brw->has_swizzling,
image->mt->surf.tiling,
- mem_copy
+ copy_type
);
brw_bo_unmap(bo);
DBG("%s\n", __func__);
- if (_mesa_is_bufferobj(ctx->Pack.BufferObj)) {
+ if (ctx->Pack.BufferObj) {
if (intel_gettexsubimage_blorp(brw, texImage,
xoffset, yoffset, zoffset,
width, height, depth, format, type,
functions->TexSubImage = intelTexSubImage;
functions->CompressedTexSubImage = intelCompressedTexSubImage;
functions->EGLImageTargetTexture2D = intel_image_target_texture_2d;
+ functions->EGLImageTargetTexStorage = intel_image_target_tex_storage;
functions->BindRenderbufferTexImage = intel_bind_renderbuffer_tex_image;
functions->GetTexSubImage = intel_get_tex_sub_image;
}