mesa/st: merge texture object/image structs into mesa
This just merges the subclasses into main class Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14327>
This commit is contained in:
parent
ea3e700e35
commit
cd0961dce2
|
@ -41,7 +41,7 @@
|
|||
#include "state_tracker/st_texture.h"
|
||||
|
||||
struct st_context;
|
||||
struct st_texture_object;
|
||||
|
||||
#include "frontend/drm_driver.h"
|
||||
#ifdef HAVE_LIBDRM
|
||||
#include "drm-uapi/drm_fourcc.h"
|
||||
|
@ -628,7 +628,7 @@ server_wait_semaphore(struct gl_context *ctx,
|
|||
struct st_context *st = ctx->st;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct gl_buffer_object *bufObj;
|
||||
struct st_texture_object *texObj;
|
||||
struct gl_texture_object *texObj;
|
||||
|
||||
/* The driver is allowed to flush during fence_server_sync, be prepared */
|
||||
st_flush_bitmap_cache(st);
|
||||
|
@ -658,7 +658,7 @@ server_wait_semaphore(struct gl_context *ctx,
|
|||
if (!texObjs[i])
|
||||
continue;
|
||||
|
||||
texObj = st_texture_object(texObjs[i]);
|
||||
texObj = texObjs[i];
|
||||
if (texObj->pt)
|
||||
pipe->flush_resource(pipe, texObj->pt);
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ server_signal_semaphore(struct gl_context *ctx,
|
|||
struct st_context *st = ctx->st;
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
struct gl_buffer_object *bufObj;
|
||||
struct st_texture_object *texObj;
|
||||
struct gl_texture_object *texObj;
|
||||
|
||||
for (unsigned i = 0; i < numBufferBarriers; i++) {
|
||||
if (!bufObjs[i])
|
||||
|
@ -691,7 +691,7 @@ server_signal_semaphore(struct gl_context *ctx,
|
|||
if (!texObjs[i])
|
||||
continue;
|
||||
|
||||
texObj = st_texture_object(texObjs[i]);
|
||||
texObj = texObjs[i];
|
||||
if (texObj->pt)
|
||||
pipe->flush_resource(pipe, texObj->pt);
|
||||
}
|
||||
|
|
|
@ -790,6 +790,23 @@ struct gl_texture_image
|
|||
/** GL_ARB_texture_multisample */
|
||||
GLuint NumSamples; /**< Sample count, or 0 for non-multisample */
|
||||
GLboolean FixedSampleLocations; /**< Same sample locations for all pixels? */
|
||||
|
||||
/* If stImage->pt != NULL, image data is stored here.
|
||||
* Else there is no image data.
|
||||
*/
|
||||
struct pipe_resource *pt;
|
||||
|
||||
/* List of transfers, allocated on demand.
|
||||
* transfer[layer] is a mapping for that layer.
|
||||
*/
|
||||
struct st_texture_image_transfer *transfer;
|
||||
unsigned num_transfers;
|
||||
|
||||
/* For compressed images unsupported by the driver. Keep track of
|
||||
* the original data. This is necessary for mapping/unmapping,
|
||||
* as well as image copies.
|
||||
*/
|
||||
struct st_compressed_data* compressed_data;
|
||||
};
|
||||
|
||||
|
||||
|
@ -937,6 +954,82 @@ struct gl_texture_object
|
|||
GLboolean IsSparse;
|
||||
GLint VirtualPageSizeIndex;
|
||||
GLint NumSparseLevels;
|
||||
|
||||
/* The texture must include at levels [0..lastLevel] once validated:
|
||||
*/
|
||||
GLuint lastLevel;
|
||||
|
||||
unsigned int validated_first_level;
|
||||
unsigned int validated_last_level;
|
||||
|
||||
/* On validation any active images held in main memory or in other
|
||||
* textures will be copied to this texture and the old storage freed.
|
||||
*/
|
||||
struct pipe_resource *pt;
|
||||
|
||||
/* Protect modifications of the sampler_views array */
|
||||
simple_mtx_t validate_mutex;
|
||||
|
||||
/* Container of sampler views (one per context) attached to this texture
|
||||
* object. Created lazily on first binding in context.
|
||||
*
|
||||
* Purely read-only accesses to the current context's own sampler view
|
||||
* require no locking. Another thread may simultaneously replace the
|
||||
* container object in order to grow the array, but the old container will
|
||||
* be kept alive.
|
||||
*
|
||||
* Writing to the container (even for modifying the current context's own
|
||||
* sampler view) always requires taking the validate_mutex to protect against
|
||||
* concurrent container switches.
|
||||
*
|
||||
* NULL'ing another context's sampler view is allowed only while
|
||||
* implementing an API call that modifies the texture: an application which
|
||||
* calls those while simultaneously reading the texture in another context
|
||||
* invokes undefined behavior. (TODO: a dubious violation of this rule is
|
||||
* st_finalize_texture, which is a lazy operation that corresponds to a
|
||||
* texture modification.)
|
||||
*/
|
||||
struct st_sampler_views *sampler_views;
|
||||
|
||||
/* Old sampler views container objects that have not been freed yet because
|
||||
* other threads/contexts may still be reading from them.
|
||||
*/
|
||||
struct st_sampler_views *sampler_views_old;
|
||||
|
||||
/* True if this texture comes from the window system. Such a texture
|
||||
* cannot be reallocated and the format can only be changed with a sampler
|
||||
* view or a surface.
|
||||
*/
|
||||
GLboolean surface_based;
|
||||
|
||||
/* If surface_based is true, this format should be used for all sampler
|
||||
* views and surfaces instead of pt->format.
|
||||
*/
|
||||
enum pipe_format surface_format;
|
||||
|
||||
/* When non-negative, samplers should use this level instead of the level
|
||||
* range specified by the GL state.
|
||||
*
|
||||
* This is used for EGL images, which may correspond to a single level out
|
||||
* of an imported pipe_resources with multiple mip levels.
|
||||
*/
|
||||
int level_override;
|
||||
|
||||
/* When non-negative, samplers should use this layer instead of the one
|
||||
* specified by the GL state.
|
||||
*
|
||||
* This is used for EGL images and VDPAU interop, where imported
|
||||
* pipe_resources may be cube, 3D, or array textures (containing layers
|
||||
* with different fields in the case of VDPAU) even though the GL state
|
||||
* describes one non-array texture per field.
|
||||
*/
|
||||
int layer_override;
|
||||
|
||||
/**
|
||||
* Set when the texture images of this texture object might not all be in
|
||||
* the pipe_resource *pt above.
|
||||
*/
|
||||
bool needs_validation;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ void
|
|||
st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
||||
struct pipe_image_view *img, unsigned shader_access)
|
||||
{
|
||||
struct st_texture_object *stObj = st_texture_object(u->TexObj);
|
||||
struct gl_texture_object *stObj = u->TexObj;
|
||||
|
||||
img->format = st_mesa_format_to_pipe_format(st, u->_ActualFormat);
|
||||
|
||||
|
@ -86,8 +86,8 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
|||
unreachable("bad gl_image_unit::Access");
|
||||
}
|
||||
|
||||
if (stObj->base.Target == GL_TEXTURE_BUFFER) {
|
||||
struct gl_buffer_object *stbuf = stObj->base.BufferObject;
|
||||
if (stObj->Target == GL_TEXTURE_BUFFER) {
|
||||
struct gl_buffer_object *stbuf = stObj->BufferObject;
|
||||
unsigned base, size;
|
||||
|
||||
if (!stbuf || !stbuf->buffer) {
|
||||
|
@ -96,9 +96,9 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
|||
}
|
||||
struct pipe_resource *buf = stbuf->buffer;
|
||||
|
||||
base = stObj->base.BufferOffset;
|
||||
base = stObj->BufferOffset;
|
||||
assert(base < buf->width0);
|
||||
size = MIN2(buf->width0 - base, (unsigned)stObj->base.BufferSize);
|
||||
size = MIN2(buf->width0 - base, (unsigned)stObj->BufferSize);
|
||||
|
||||
img->resource = stbuf->buffer;
|
||||
img->u.buf.offset = base;
|
||||
|
@ -111,7 +111,7 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
|||
}
|
||||
|
||||
img->resource = stObj->pt;
|
||||
img->u.tex.level = u->Level + stObj->base.Attrib.MinLevel;
|
||||
img->u.tex.level = u->Level + stObj->Attrib.MinLevel;
|
||||
assert(img->u.tex.level <= img->resource->last_level);
|
||||
if (stObj->pt->target == PIPE_TEXTURE_3D) {
|
||||
if (u->Layered) {
|
||||
|
@ -122,11 +122,11 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
|||
img->u.tex.last_layer = u->_Layer;
|
||||
}
|
||||
} else {
|
||||
img->u.tex.first_layer = u->_Layer + stObj->base.Attrib.MinLayer;
|
||||
img->u.tex.last_layer = u->_Layer + stObj->base.Attrib.MinLayer;
|
||||
img->u.tex.first_layer = u->_Layer + stObj->Attrib.MinLayer;
|
||||
img->u.tex.last_layer = u->_Layer + stObj->Attrib.MinLayer;
|
||||
if (u->Layered && img->resource->array_size > 1) {
|
||||
if (stObj->base.Immutable)
|
||||
img->u.tex.last_layer += stObj->base.Attrib.NumLayers - 1;
|
||||
if (stObj->Immutable)
|
||||
img->u.tex.last_layer += stObj->Attrib.NumLayers - 1;
|
||||
else
|
||||
img->u.tex.last_layer += img->resource->array_size - 1;
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ st_convert_sampler(const struct st_context *st,
|
|||
texBaseFormat = GL_STENCIL_INDEX;
|
||||
|
||||
if (st->apply_texture_swizzle_to_border_color) {
|
||||
const struct st_texture_object *stobj = st_texture_object_const(texobj);
|
||||
const struct gl_texture_object *stobj = st_texture_object_const(texobj);
|
||||
/* XXX: clean that up to not use the sampler view at all */
|
||||
const struct st_sampler_view *sv = st_texture_get_current_sampler_view(st, stobj);
|
||||
|
||||
|
@ -218,7 +218,7 @@ update_shader_samplers(struct st_context *st,
|
|||
while (unlikely(external_samplers_used)) {
|
||||
GLuint unit = u_bit_scan(&external_samplers_used);
|
||||
GLuint extra = 0;
|
||||
struct st_texture_object *stObj =
|
||||
struct gl_texture_object *stObj =
|
||||
st_get_texture_object(st->ctx, prog, unit);
|
||||
struct pipe_sampler_state *sampler = samplers + unit;
|
||||
|
||||
|
|
|
@ -62,25 +62,23 @@ st_update_single_texture(struct st_context *st,
|
|||
{
|
||||
struct gl_context *ctx = st->ctx;
|
||||
struct gl_texture_object *texObj;
|
||||
struct st_texture_object *stObj;
|
||||
|
||||
texObj = ctx->Texture.Unit[texUnit]._Current;
|
||||
assert(texObj);
|
||||
|
||||
stObj = st_texture_object(texObj);
|
||||
GLenum target = texObj->Target;
|
||||
|
||||
if (unlikely(target == GL_TEXTURE_BUFFER))
|
||||
return st_get_buffer_sampler_view_from_stobj(st, stObj, get_reference);
|
||||
return st_get_buffer_sampler_view_from_stobj(st, texObj, get_reference);
|
||||
|
||||
if (!st_finalize_texture(ctx, st->pipe, texObj, 0) || !stObj->pt)
|
||||
if (!st_finalize_texture(ctx, st->pipe, texObj, 0) || !texObj->pt)
|
||||
return NULL; /* out of mem */
|
||||
|
||||
if (target == GL_TEXTURE_EXTERNAL_OES &&
|
||||
stObj->pt->screen->resource_changed)
|
||||
stObj->pt->screen->resource_changed(stObj->pt->screen, stObj->pt);
|
||||
texObj->pt->screen->resource_changed)
|
||||
texObj->pt->screen->resource_changed(texObj->pt->screen, texObj->pt);
|
||||
|
||||
return st_get_texture_sampler_view_from_stobj(st, stObj,
|
||||
return st_get_texture_sampler_view_from_stobj(st, texObj,
|
||||
_mesa_get_samplerobj(ctx, texUnit),
|
||||
glsl130_or_later,
|
||||
ignore_srgb_decode, get_reference);
|
||||
|
@ -154,7 +152,7 @@ st_get_sampler_views(struct st_context *st,
|
|||
/* For any external samplers with multiplaner YUV, stuff the additional
|
||||
* sampler views we need at the end.
|
||||
*
|
||||
* Trying to cache the sampler view in the stObj looks painful, so just
|
||||
* Trying to cache the sampler view in the texObj looks painful, so just
|
||||
* re-create the sampler view for the extra planes each time. Main use
|
||||
* case is video playback (ie. fps games wouldn't be using this) so I
|
||||
* guess no point to try to optimize this feature.
|
||||
|
@ -162,7 +160,7 @@ st_get_sampler_views(struct st_context *st,
|
|||
while (unlikely(external_samplers_used)) {
|
||||
GLuint unit = u_bit_scan(&external_samplers_used);
|
||||
GLuint extra = 0;
|
||||
struct st_texture_object *stObj =
|
||||
struct gl_texture_object *stObj =
|
||||
st_get_texture_object(st->ctx, prog, unit);
|
||||
struct pipe_sampler_view tmpl;
|
||||
|
||||
|
|
|
@ -648,7 +648,7 @@ st_DrawAtlasBitmaps(struct gl_context *ctx,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct st_texture_object *stObj = st_texture_object(atlas->texObj);
|
||||
struct gl_texture_object *stObj = atlas->texObj;
|
||||
struct pipe_sampler_view *sv;
|
||||
/* convert Z from [0,1] to [-1,-1] to match viewport Z scale/bias */
|
||||
const float z = ctx->Current.RasterPos[2] * 2.0f - 1.0f;
|
||||
|
|
|
@ -181,13 +181,13 @@ st_BlitFramebuffer(struct gl_context *ctx,
|
|||
blit.mask = PIPE_MASK_RGBA;
|
||||
|
||||
if (srcAtt->Type == GL_TEXTURE) {
|
||||
/* Make sure that the st_texture_object->pt is the current storage for
|
||||
/* Make sure that the gl_texture_object->pt is the current storage for
|
||||
* our miplevel. The finalize would happen at some point anyway, might
|
||||
* as well be now.
|
||||
*/
|
||||
st_finalize_texture(ctx, st->pipe, srcAtt->Texture, srcAtt->CubeMapFace);
|
||||
|
||||
struct st_texture_object *srcObj = st_texture_object(srcAtt->Texture);
|
||||
struct gl_texture_object *srcObj = srcAtt->Texture;
|
||||
|
||||
if (!srcObj || !srcObj->pt) {
|
||||
return;
|
||||
|
|
|
@ -645,8 +645,8 @@ st_CopyImageSubData(struct gl_context *ctx,
|
|||
st_invalidate_readpix_cache(st);
|
||||
|
||||
if (src_image) {
|
||||
struct st_texture_image *src = st_texture_image(src_image);
|
||||
struct st_texture_object *stObj = st_texture_object(src_image->TexObject);
|
||||
struct gl_texture_image *src = src_image;
|
||||
struct gl_texture_object *stObj = src_image->TexObject;
|
||||
src_res = src->pt;
|
||||
src_level = stObj->pt != src_res ? 0 : src_image->Level;
|
||||
src_z += src_image->Face;
|
||||
|
@ -661,8 +661,8 @@ st_CopyImageSubData(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (dst_image) {
|
||||
struct st_texture_image *dst = st_texture_image(dst_image);
|
||||
struct st_texture_object *stObj = st_texture_object(dst_image->TexObject);
|
||||
struct gl_texture_image *dst = dst_image;
|
||||
struct gl_texture_object *stObj = dst_image->TexObject;
|
||||
dst_res = dst->pt;
|
||||
dst_level = stObj->pt != dst_res ? 0 : dst_image->Level;
|
||||
dst_z += dst_image->Face;
|
||||
|
|
|
@ -270,8 +270,6 @@ st_bind_egl_image(struct gl_context *ctx,
|
|||
bool native_supported)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj;
|
||||
struct st_texture_image *stImage;
|
||||
GLenum internalFormat;
|
||||
mesa_format texFormat;
|
||||
|
||||
|
@ -282,13 +280,10 @@ st_bind_egl_image(struct gl_context *ctx,
|
|||
else
|
||||
internalFormat = GL_RGB;
|
||||
|
||||
stObj = st_texture_object(texObj);
|
||||
stImage = st_texture_image(texImage);
|
||||
|
||||
/* switch to surface based */
|
||||
if (!stObj->surface_based) {
|
||||
if (!texObj->surface_based) {
|
||||
_mesa_clear_texture_object(ctx, texObj, NULL);
|
||||
stObj->surface_based = GL_TRUE;
|
||||
texObj->surface_based = GL_TRUE;
|
||||
}
|
||||
|
||||
/* TODO RequiredTextureImageUnits should probably be reset back
|
||||
|
@ -382,15 +377,15 @@ st_bind_egl_image(struct gl_context *ctx,
|
|||
_mesa_init_teximage_fields(ctx, texImage, width, height,
|
||||
1, 0, internalFormat, texFormat);
|
||||
|
||||
pipe_resource_reference(&stObj->pt, stimg->texture);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
pipe_resource_reference(&stImage->pt, stObj->pt);
|
||||
pipe_resource_reference(&texObj->pt, stimg->texture);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
pipe_resource_reference(&texImage->pt, texObj->pt);
|
||||
if (st->screen->resource_changed)
|
||||
st->screen->resource_changed(st->screen, stImage->pt);
|
||||
st->screen->resource_changed(st->screen, texImage->pt);
|
||||
|
||||
stObj->surface_format = stimg->format;
|
||||
stObj->level_override = stimg->level;
|
||||
stObj->layer_override = stimg->layer;
|
||||
texObj->surface_format = stimg->format;
|
||||
texObj->level_override = stimg->level;
|
||||
texObj->layer_override = stimg->layer;
|
||||
|
||||
_mesa_dirty_texobj(ctx, texObj);
|
||||
}
|
||||
|
|
|
@ -484,7 +484,7 @@ st_update_renderbuffer_surface(struct st_context *st,
|
|||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_resource *resource = strb->texture;
|
||||
const struct st_texture_object *stTexObj = NULL;
|
||||
const struct gl_texture_object *stTexObj = NULL;
|
||||
unsigned rtt_width = strb->Base.Width;
|
||||
unsigned rtt_height = strb->Base.Height;
|
||||
unsigned rtt_depth = strb->Base.Depth;
|
||||
|
@ -500,7 +500,7 @@ st_update_renderbuffer_surface(struct st_context *st,
|
|||
enum pipe_format format = resource->format;
|
||||
|
||||
if (strb->is_rtt) {
|
||||
stTexObj = st_texture_object(strb->Base.TexImage->TexObject);
|
||||
stTexObj = strb->Base.TexImage->TexObject;
|
||||
if (stTexObj->surface_based)
|
||||
format = stTexObj->surface_format;
|
||||
}
|
||||
|
@ -537,8 +537,8 @@ st_update_renderbuffer_surface(struct st_context *st,
|
|||
|
||||
/* Adjust for texture views */
|
||||
if (strb->is_rtt && resource->array_size > 1 &&
|
||||
stTexObj->base.Immutable) {
|
||||
const struct gl_texture_object *tex = &stTexObj->base;
|
||||
stTexObj->Immutable) {
|
||||
const struct gl_texture_object *tex = stTexObj;
|
||||
first_layer += tex->Attrib.MinLayer;
|
||||
if (!strb->rtt_layered)
|
||||
last_layer += tex->Attrib.MinLayer;
|
||||
|
@ -587,8 +587,8 @@ static struct pipe_resource *
|
|||
get_teximage_resource(struct gl_texture_object *texObj,
|
||||
unsigned face, unsigned level)
|
||||
{
|
||||
struct st_texture_image *stImg =
|
||||
st_texture_image(texObj->Image[face][level]);
|
||||
struct gl_texture_image *stImg =
|
||||
texObj->Image[face][level];
|
||||
|
||||
return stImg->pt;
|
||||
}
|
||||
|
@ -675,7 +675,7 @@ st_validate_attachment(struct gl_context *ctx,
|
|||
const struct gl_renderbuffer_attachment *att,
|
||||
unsigned bindings)
|
||||
{
|
||||
const struct st_texture_object *stObj = st_texture_object(att->Texture);
|
||||
const struct gl_texture_object *stObj = att->Texture;
|
||||
enum pipe_format format;
|
||||
mesa_format texFormat;
|
||||
GLboolean valid;
|
||||
|
|
|
@ -187,7 +187,7 @@ copy_to_staging_dest(struct gl_context * ctx, struct pipe_resource *dst,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_resource *src = stObj->pt;
|
||||
enum pipe_format dst_format = dst->format;
|
||||
mesa_format mesa_format;
|
||||
|
@ -391,7 +391,7 @@ st_NewTextureImage(struct gl_context * ctx)
|
|||
{
|
||||
DBG("%s\n", __func__);
|
||||
(void) ctx;
|
||||
return (struct gl_texture_image *) CALLOC_STRUCT(st_texture_image);
|
||||
return (struct gl_texture_image *) CALLOC_STRUCT(gl_texture_image);
|
||||
}
|
||||
|
||||
|
||||
|
@ -406,7 +406,7 @@ st_DeleteTextureImage(struct gl_context * ctx, struct gl_texture_image *img)
|
|||
struct gl_texture_object *
|
||||
st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
|
||||
{
|
||||
struct st_texture_object *obj = CALLOC_STRUCT(st_texture_object);
|
||||
struct gl_texture_object *obj = CALLOC_STRUCT(gl_texture_object);
|
||||
if (!obj)
|
||||
return NULL;
|
||||
|
||||
|
@ -425,12 +425,12 @@ st_NewTextureObject(struct gl_context * ctx, GLuint name, GLenum target)
|
|||
obj->sampler_views->max = 1;
|
||||
|
||||
DBG("%s\n", __func__);
|
||||
_mesa_initialize_texture_object(ctx, &obj->base, name, target);
|
||||
_mesa_initialize_texture_object(ctx, obj, name, target);
|
||||
|
||||
simple_mtx_init(&obj->validate_mutex, mtx_plain);
|
||||
obj->needs_validation = true;
|
||||
|
||||
return &obj->base;
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
@ -439,11 +439,10 @@ st_DeleteTextureObject(struct gl_context *ctx,
|
|||
struct gl_texture_object *texObj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
|
||||
pipe_resource_reference(&stObj->pt, NULL);
|
||||
st_delete_texture_sampler_views(st, stObj);
|
||||
simple_mtx_destroy(&stObj->validate_mutex);
|
||||
pipe_resource_reference(&texObj->pt, NULL);
|
||||
st_delete_texture_sampler_views(st, texObj);
|
||||
simple_mtx_destroy(&texObj->validate_mutex);
|
||||
_mesa_delete_texture_object(ctx, texObj);
|
||||
}
|
||||
|
||||
|
@ -459,9 +458,7 @@ st_TextureReleaseAllSamplerViews(struct gl_context *ctx,
|
|||
struct gl_texture_object *texObj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -469,8 +466,8 @@ st_FreeTextureImageBuffer(struct gl_context *ctx,
|
|||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
|
||||
DBG("%s\n", __func__);
|
||||
|
||||
|
@ -526,17 +523,15 @@ st_compressed_format_fallback(struct st_context *st, mesa_format format)
|
|||
|
||||
static void
|
||||
compressed_tex_fallback_allocate(struct st_context *st,
|
||||
struct st_texture_image *stImage)
|
||||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct gl_texture_image *texImage = &stImage->base;
|
||||
|
||||
if (!st_compressed_format_fallback(st, texImage->TexFormat))
|
||||
return;
|
||||
|
||||
if (stImage->compressed_data &&
|
||||
pipe_reference(&stImage->compressed_data->reference, NULL)) {
|
||||
free(stImage->compressed_data->ptr);
|
||||
FREE(stImage->compressed_data);
|
||||
if (texImage->compressed_data &&
|
||||
pipe_reference(&texImage->compressed_data->reference, NULL)) {
|
||||
free(texImage->compressed_data->ptr);
|
||||
FREE(texImage->compressed_data);
|
||||
}
|
||||
|
||||
unsigned data_size = _mesa_format_image_size(texImage->TexFormat,
|
||||
|
@ -544,10 +539,10 @@ compressed_tex_fallback_allocate(struct st_context *st,
|
|||
texImage->Height2,
|
||||
texImage->Depth2);
|
||||
|
||||
stImage->compressed_data = CALLOC_STRUCT(st_compressed_data);
|
||||
stImage->compressed_data->ptr =
|
||||
texImage->compressed_data = CALLOC_STRUCT(st_compressed_data);
|
||||
texImage->compressed_data->ptr =
|
||||
malloc(data_size * _mesa_num_tex_faces(texImage->TexObject->Target));
|
||||
pipe_reference_init(&stImage->compressed_data->reference, 1);
|
||||
pipe_reference_init(&texImage->compressed_data->reference, 1);
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,7 +554,6 @@ st_MapTextureImage(struct gl_context *ctx,
|
|||
GLubyte **mapOut, GLint *rowStrideOut)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
GLubyte *map;
|
||||
struct pipe_transfer *transfer;
|
||||
|
||||
|
@ -571,7 +565,7 @@ st_MapTextureImage(struct gl_context *ctx,
|
|||
const enum pipe_map_flags transfer_flags =
|
||||
_mesa_access_flags_to_transfer_flags(mode, false);
|
||||
|
||||
map = st_texture_image_map(st, stImage, transfer_flags, x, y, slice, w, h, 1,
|
||||
map = st_texture_image_map(st, texImage, transfer_flags, x, y, slice, w, h, 1,
|
||||
&transfer);
|
||||
if (map) {
|
||||
if (st_compressed_format_fallback(st, texImage->TexFormat)) {
|
||||
|
@ -583,7 +577,7 @@ st_MapTextureImage(struct gl_context *ctx,
|
|||
* Image and image copies in OES_copy_image).
|
||||
*/
|
||||
unsigned z = transfer->box.z;
|
||||
struct st_texture_image_transfer *itransfer = &stImage->transfer[z];
|
||||
struct st_texture_image_transfer *itransfer = &texImage->transfer[z];
|
||||
|
||||
unsigned blk_w, blk_h;
|
||||
_mesa_get_format_block_size(texImage->TexFormat, &blk_w, &blk_h);
|
||||
|
@ -593,9 +587,9 @@ st_MapTextureImage(struct gl_context *ctx,
|
|||
_mesa_format_row_stride(texImage->TexFormat, texImage->Width2);
|
||||
unsigned block_size = _mesa_get_format_bytes(texImage->TexFormat);
|
||||
|
||||
assert(stImage->compressed_data);
|
||||
assert(texImage->compressed_data);
|
||||
*mapOut = itransfer->temp_data =
|
||||
stImage->compressed_data->ptr +
|
||||
texImage->compressed_data->ptr +
|
||||
(z * y_blocks + (y / blk_h)) * stride +
|
||||
(x / blk_w) * block_size;
|
||||
itransfer->map = map;
|
||||
|
@ -619,19 +613,18 @@ st_UnmapTextureImage(struct gl_context *ctx,
|
|||
GLuint slice)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
|
||||
if (st_compressed_format_fallback(st, texImage->TexFormat)) {
|
||||
/* Decompress the compressed image on upload if the driver doesn't
|
||||
* support the compressed format. */
|
||||
unsigned z = slice + stImage->base.Face;
|
||||
struct st_texture_image_transfer *itransfer = &stImage->transfer[z];
|
||||
unsigned z = slice + texImage->Face;
|
||||
struct st_texture_image_transfer *itransfer = &texImage->transfer[z];
|
||||
struct pipe_transfer *transfer = itransfer->transfer;
|
||||
|
||||
assert(z == transfer->box.z);
|
||||
|
||||
if (transfer->usage & PIPE_MAP_WRITE) {
|
||||
if (util_format_is_compressed(stImage->pt->format)) {
|
||||
if (util_format_is_compressed(texImage->pt->format)) {
|
||||
/* Transcode into a different compressed format. */
|
||||
unsigned size =
|
||||
_mesa_format_image_size(PIPE_FORMAT_R8G8B8A8_UNORM,
|
||||
|
@ -647,7 +640,7 @@ st_UnmapTextureImage(struct gl_context *ctx,
|
|||
transfer->box.width,
|
||||
transfer->box.height);
|
||||
} else if (_mesa_is_format_etc2(texImage->TexFormat)) {
|
||||
bool bgra = stImage->pt->format == PIPE_FORMAT_B8G8R8A8_SRGB;
|
||||
bool bgra = texImage->pt->format == PIPE_FORMAT_B8G8R8A8_SRGB;
|
||||
|
||||
_mesa_unpack_etc2_format(tmp, transfer->box.width * 4,
|
||||
itransfer->temp_data,
|
||||
|
@ -671,7 +664,7 @@ st_UnmapTextureImage(struct gl_context *ctx,
|
|||
struct gl_pixelstore_attrib pack = {0};
|
||||
pack.Alignment = 4;
|
||||
|
||||
_mesa_texstore(ctx, 2, GL_RGBA, stImage->pt->format,
|
||||
_mesa_texstore(ctx, 2, GL_RGBA, texImage->pt->format,
|
||||
transfer->stride, &itransfer->map,
|
||||
transfer->box.width,
|
||||
transfer->box.height, 1, GL_RGBA,
|
||||
|
@ -686,7 +679,7 @@ st_UnmapTextureImage(struct gl_context *ctx,
|
|||
transfer->box.width,
|
||||
transfer->box.height);
|
||||
} else if (_mesa_is_format_etc2(texImage->TexFormat)) {
|
||||
bool bgra = stImage->pt->format == PIPE_FORMAT_B8G8R8A8_SRGB;
|
||||
bool bgra = texImage->pt->format == PIPE_FORMAT_B8G8R8A8_SRGB;
|
||||
|
||||
_mesa_unpack_etc2_format(itransfer->map, transfer->stride,
|
||||
itransfer->temp_data,
|
||||
|
@ -711,7 +704,7 @@ st_UnmapTextureImage(struct gl_context *ctx,
|
|||
itransfer->map = NULL;
|
||||
}
|
||||
|
||||
st_texture_image_unmap(st, stImage, slice);
|
||||
st_texture_image_unmap(st, texImage, slice);
|
||||
}
|
||||
|
||||
|
||||
|
@ -832,10 +825,10 @@ guess_base_level_size(GLenum target,
|
|||
* \param stImage describes the incoming image which we need to store.
|
||||
*/
|
||||
static boolean
|
||||
allocate_full_mipmap(const struct st_texture_object *stObj,
|
||||
const struct st_texture_image *stImage)
|
||||
allocate_full_mipmap(const struct gl_texture_object *stObj,
|
||||
const struct gl_texture_image *stImage)
|
||||
{
|
||||
switch (stObj->base.Target) {
|
||||
switch (stObj->Target) {
|
||||
case GL_TEXTURE_RECTANGLE_NV:
|
||||
case GL_TEXTURE_BUFFER:
|
||||
case GL_TEXTURE_EXTERNAL_OES:
|
||||
|
@ -845,7 +838,7 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
if (stImage->base.Level > 0 || stObj->base.Attrib.GenerateMipmap)
|
||||
if (stImage->Level > 0 || stObj->Attrib.GenerateMipmap)
|
||||
return TRUE;
|
||||
|
||||
/* If the application has explicitly called glTextureParameter to set
|
||||
|
@ -855,20 +848,20 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
|
|||
* Core Mesa will initialize MaxLevel to value much larger than
|
||||
* MAX_TEXTURE_LEVELS, so we check that to see if it's been set at all.
|
||||
*/
|
||||
if (stObj->base.Attrib.MaxLevel < MAX_TEXTURE_LEVELS &&
|
||||
stObj->base.Attrib.MaxLevel - stObj->base.Attrib.BaseLevel > 0)
|
||||
if (stObj->Attrib.MaxLevel < MAX_TEXTURE_LEVELS &&
|
||||
stObj->Attrib.MaxLevel - stObj->Attrib.BaseLevel > 0)
|
||||
return TRUE;
|
||||
|
||||
if (stImage->base._BaseFormat == GL_DEPTH_COMPONENT ||
|
||||
stImage->base._BaseFormat == GL_DEPTH_STENCIL_EXT)
|
||||
if (stImage->_BaseFormat == GL_DEPTH_COMPONENT ||
|
||||
stImage->_BaseFormat == GL_DEPTH_STENCIL_EXT)
|
||||
/* depth/stencil textures are seldom mipmapped */
|
||||
return FALSE;
|
||||
|
||||
if (stObj->base.Attrib.BaseLevel == 0 && stObj->base.Attrib.MaxLevel == 0)
|
||||
if (stObj->Attrib.BaseLevel == 0 && stObj->Attrib.MaxLevel == 0)
|
||||
return FALSE;
|
||||
|
||||
if (stObj->base.Sampler.Attrib.MinFilter == GL_NEAREST ||
|
||||
stObj->base.Sampler.Attrib.MinFilter == GL_LINEAR)
|
||||
if (stObj->Sampler.Attrib.MinFilter == GL_NEAREST ||
|
||||
stObj->Sampler.Attrib.MinFilter == GL_LINEAR)
|
||||
/* not a mipmap minification filter */
|
||||
return FALSE;
|
||||
|
||||
|
@ -881,10 +874,10 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
|
|||
* allocate a mipmapped texture by default. This may cause texture
|
||||
* reallocation later, but GL_NEAREST_MIPMAP_LINEAR is pretty rare.
|
||||
*/
|
||||
if (stObj->base.Sampler.Attrib.MinFilter == GL_NEAREST_MIPMAP_LINEAR)
|
||||
if (stObj->Sampler.Attrib.MinFilter == GL_NEAREST_MIPMAP_LINEAR)
|
||||
return FALSE;
|
||||
|
||||
if (stObj->base.Target == GL_TEXTURE_3D)
|
||||
if (stObj->Target == GL_TEXTURE_3D)
|
||||
/* 3D textures are seldom mipmapped */
|
||||
return FALSE;
|
||||
|
||||
|
@ -893,7 +886,7 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
|
|||
|
||||
|
||||
/**
|
||||
* Try to allocate a pipe_resource object for the given st_texture_object.
|
||||
* Try to allocate a pipe_resource object for the given gl_texture_object.
|
||||
*
|
||||
* We use the given st_texture_image as a clue to determine the size of the
|
||||
* mipmap image at level=0.
|
||||
|
@ -902,8 +895,8 @@ allocate_full_mipmap(const struct st_texture_object *stObj,
|
|||
*/
|
||||
static GLboolean
|
||||
guess_and_alloc_texture(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
const struct st_texture_image *stImage)
|
||||
struct gl_texture_object *stObj,
|
||||
const struct gl_texture_image *stImage)
|
||||
{
|
||||
const struct gl_texture_image *firstImage;
|
||||
GLuint lastLevel, width, height, depth;
|
||||
|
@ -919,29 +912,29 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
|
||||
/* If a base level image with compatible size exists, use that as our guess.
|
||||
*/
|
||||
firstImage = _mesa_base_tex_image(&stObj->base);
|
||||
firstImage = _mesa_base_tex_image(stObj);
|
||||
if (firstImage &&
|
||||
firstImage->Width2 > 0 &&
|
||||
firstImage->Height2 > 0 &&
|
||||
firstImage->Depth2 > 0 &&
|
||||
guess_base_level_size(stObj->base.Target,
|
||||
guess_base_level_size(stObj->Target,
|
||||
firstImage->Width2,
|
||||
firstImage->Height2,
|
||||
firstImage->Depth2,
|
||||
firstImage->Level,
|
||||
&width, &height, &depth)) {
|
||||
if (stImage->base.Width2 == u_minify(width, stImage->base.Level) &&
|
||||
stImage->base.Height2 == u_minify(height, stImage->base.Level) &&
|
||||
stImage->base.Depth2 == u_minify(depth, stImage->base.Level))
|
||||
if (stImage->Width2 == u_minify(width, stImage->Level) &&
|
||||
stImage->Height2 == u_minify(height, stImage->Level) &&
|
||||
stImage->Depth2 == u_minify(depth, stImage->Level))
|
||||
guessed_box = true;
|
||||
}
|
||||
|
||||
if (!guessed_box)
|
||||
guessed_box = guess_base_level_size(stObj->base.Target,
|
||||
stImage->base.Width2,
|
||||
stImage->base.Height2,
|
||||
stImage->base.Depth2,
|
||||
stImage->base.Level,
|
||||
guessed_box = guess_base_level_size(stObj->Target,
|
||||
stImage->Width2,
|
||||
stImage->Height2,
|
||||
stImage->Depth2,
|
||||
stImage->Level,
|
||||
&width, &height, &depth);
|
||||
|
||||
if (!guessed_box) {
|
||||
|
@ -962,7 +955,7 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
*/
|
||||
if (allocate_full_mipmap(stObj, stImage)) {
|
||||
/* alloc space for a full mipmap */
|
||||
lastLevel = _mesa_get_tex_max_num_levels(stObj->base.Target,
|
||||
lastLevel = _mesa_get_tex_max_num_levels(stObj->Target,
|
||||
width, height, depth) - 1;
|
||||
}
|
||||
else {
|
||||
|
@ -970,16 +963,16 @@ guess_and_alloc_texture(struct st_context *st,
|
|||
lastLevel = 0;
|
||||
}
|
||||
|
||||
fmt = st_mesa_format_to_pipe_format(st, stImage->base.TexFormat);
|
||||
fmt = st_mesa_format_to_pipe_format(st, stImage->TexFormat);
|
||||
|
||||
bindings = default_bindings(st, fmt);
|
||||
|
||||
st_gl_texture_dims_to_pipe_dims(stObj->base.Target,
|
||||
st_gl_texture_dims_to_pipe_dims(stObj->Target,
|
||||
width, height, depth,
|
||||
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
|
||||
|
||||
stObj->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(stObj->base.Target),
|
||||
gl_target_to_pipe(stObj->Target),
|
||||
fmt,
|
||||
lastLevel,
|
||||
ptWidth,
|
||||
|
@ -1006,8 +999,8 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
|
|||
struct gl_texture_image *texImage)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
GLuint width = texImage->Width;
|
||||
GLuint height = texImage->Height;
|
||||
GLuint depth = texImage->Depth;
|
||||
|
@ -1070,12 +1063,12 @@ st_AllocTextureImageBuffer(struct gl_context *ctx,
|
|||
unsigned ptWidth;
|
||||
uint16_t ptHeight, ptDepth, ptLayers;
|
||||
|
||||
st_gl_texture_dims_to_pipe_dims(stObj->base.Target,
|
||||
st_gl_texture_dims_to_pipe_dims(stObj->Target,
|
||||
width, height, depth,
|
||||
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
|
||||
|
||||
stImage->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(stObj->base.Target),
|
||||
gl_target_to_pipe(stObj->Target),
|
||||
format,
|
||||
0, /* lastLevel */
|
||||
ptWidth,
|
||||
|
@ -1098,19 +1091,18 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
|
|||
GLenum format, GLenum type)
|
||||
{
|
||||
struct gl_texture_object *texObj = texImage->TexObject;
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
|
||||
/* switch to "normal" */
|
||||
if (stObj->surface_based) {
|
||||
if (texObj->surface_based) {
|
||||
const GLenum target = texObj->Target;
|
||||
const GLuint level = texImage->Level;
|
||||
mesa_format texFormat;
|
||||
|
||||
assert(!st_texture_image(texImage)->pt);
|
||||
assert(!texImage->pt);
|
||||
_mesa_clear_texture_object(ctx, texObj, texImage);
|
||||
stObj->layer_override = -1;
|
||||
stObj->level_override = -1;
|
||||
pipe_resource_reference(&stObj->pt, NULL);
|
||||
texObj->layer_override = -1;
|
||||
texObj->level_override = -1;
|
||||
pipe_resource_reference(&texObj->pt, NULL);
|
||||
|
||||
/* oops, need to init this image again */
|
||||
texFormat = _mesa_choose_texture_format(ctx, texObj, target, level,
|
||||
|
@ -1122,7 +1114,7 @@ prep_teximage(struct gl_context *ctx, struct gl_texture_image *texImage,
|
|||
texImage->Depth, texImage->Border,
|
||||
texImage->InternalFormat, texFormat);
|
||||
|
||||
stObj->surface_based = GL_FALSE;
|
||||
texObj->surface_based = GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1676,8 +1668,8 @@ try_pbo_upload(struct gl_context *ctx, GLuint dims,
|
|||
const struct gl_pixelstore_attrib *unpack)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_resource *texture = stImage->pt;
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_screen *screen = st->screen;
|
||||
|
@ -1788,10 +1780,9 @@ try_pbo_download(struct st_context *st,
|
|||
GLint width, GLint height, GLint depth,
|
||||
const struct gl_pixelstore_attrib *pack, void *pixels)
|
||||
{
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_screen *screen = pipe->screen;
|
||||
struct pipe_resource *texture = stImage->pt;
|
||||
struct pipe_resource *texture = texImage->pt;
|
||||
struct cso_context *cso = st->cso_context;
|
||||
const struct util_format_description *desc;
|
||||
struct st_pbo_addresses addr;
|
||||
|
@ -1966,11 +1957,10 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
const struct gl_pixelstore_attrib *unpack)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_screen *screen = st->screen;
|
||||
struct pipe_resource *dst = stImage->pt;
|
||||
struct pipe_resource *dst = texImage->pt;
|
||||
struct pipe_resource *src = NULL;
|
||||
struct pipe_resource src_templ;
|
||||
struct pipe_transfer *transfer;
|
||||
|
@ -1987,7 +1977,7 @@ st_TexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
st_flush_bitmap_cache(st);
|
||||
st_invalidate_readpix_cache(st);
|
||||
|
||||
if (stObj->pt == stImage->pt)
|
||||
if (stObj->pt == texImage->pt)
|
||||
dst_level = texImage->TexObject->Attrib.MinLevel + texImage->Level;
|
||||
|
||||
assert(!_mesa_is_format_etc2(texImage->TexFormat) &&
|
||||
|
@ -2298,8 +2288,8 @@ st_CompressedTexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
GLenum format, GLsizei imageSize, const void *data)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_resource *buf;
|
||||
struct pipe_resource *texture = stImage->pt;
|
||||
struct pipe_screen *screen = st->screen;
|
||||
|
@ -2488,8 +2478,8 @@ st_GetTexSubImage(struct gl_context * ctx,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_screen *screen = st->screen;
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_resource *src = stObj->pt;
|
||||
struct pipe_resource *dst = NULL;
|
||||
enum pipe_format dst_format, src_format;
|
||||
|
@ -2631,7 +2621,7 @@ cpu_transfer:
|
|||
static void
|
||||
fallback_copy_texsubimage(struct gl_context *ctx,
|
||||
struct st_renderbuffer *strb,
|
||||
struct st_texture_image *stImage,
|
||||
struct gl_texture_image *stImage,
|
||||
GLenum baseFormat,
|
||||
GLint destX, GLint destY, GLint slice,
|
||||
GLint srcX, GLint srcY,
|
||||
|
@ -2732,7 +2722,7 @@ fallback_copy_texsubimage(struct gl_context *ctx,
|
|||
if (tempSrc) {
|
||||
const GLint dims = 2;
|
||||
GLint dstRowStride;
|
||||
struct gl_texture_image *texImage = &stImage->base;
|
||||
struct gl_texture_image *texImage = stImage;
|
||||
struct gl_pixelstore_attrib unpack = ctx->DefaultPacking;
|
||||
|
||||
if (st_fb_orientation(ctx->ReadBuffer) == Y_0_TOP) {
|
||||
|
@ -2823,8 +2813,8 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
struct gl_renderbuffer *rb,
|
||||
GLint srcX, GLint srcY, GLsizei width, GLsizei height)
|
||||
{
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct st_renderbuffer *strb = st_renderbuffer(rb);
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
@ -2906,7 +2896,7 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
|
|||
? 0 : texImage->Level + texImage->TexObject->Attrib.MinLevel;
|
||||
blit.dst.box.x = destX;
|
||||
blit.dst.box.y = destY;
|
||||
blit.dst.box.z = stImage->base.Face + slice +
|
||||
blit.dst.box.z = stImage->Face + slice +
|
||||
texImage->TexObject->Attrib.MinLayer;
|
||||
blit.dst.box.width = width;
|
||||
blit.dst.box.height = height;
|
||||
|
@ -2931,18 +2921,18 @@ fallback:
|
|||
*/
|
||||
static void
|
||||
copy_image_data_to_texture(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *stObj,
|
||||
GLuint dstLevel,
|
||||
struct st_texture_image *stImage)
|
||||
struct gl_texture_image *stImage)
|
||||
{
|
||||
/* debug checks */
|
||||
{
|
||||
ASSERTED const struct gl_texture_image *dstImage =
|
||||
stObj->base.Image[stImage->base.Face][dstLevel];
|
||||
stObj->Image[stImage->Face][dstLevel];
|
||||
assert(dstImage);
|
||||
assert(dstImage->Width == stImage->base.Width);
|
||||
assert(dstImage->Height == stImage->base.Height);
|
||||
assert(dstImage->Depth == stImage->base.Depth);
|
||||
assert(dstImage->Width == stImage->Width);
|
||||
assert(dstImage->Height == stImage->Height);
|
||||
assert(dstImage->Depth == stImage->Depth);
|
||||
}
|
||||
|
||||
if (stImage->pt) {
|
||||
|
@ -2952,20 +2942,20 @@ copy_image_data_to_texture(struct st_context *st,
|
|||
if (stImage->pt->last_level == 0)
|
||||
src_level = 0;
|
||||
else
|
||||
src_level = stImage->base.Level;
|
||||
src_level = stImage->Level;
|
||||
|
||||
assert(src_level <= stImage->pt->last_level);
|
||||
assert(u_minify(stImage->pt->width0, src_level) == stImage->base.Width);
|
||||
assert(u_minify(stImage->pt->width0, src_level) == stImage->Width);
|
||||
assert(stImage->pt->target == PIPE_TEXTURE_1D_ARRAY ||
|
||||
u_minify(stImage->pt->height0, src_level) == stImage->base.Height);
|
||||
u_minify(stImage->pt->height0, src_level) == stImage->Height);
|
||||
assert(stImage->pt->target == PIPE_TEXTURE_2D_ARRAY ||
|
||||
stImage->pt->target == PIPE_TEXTURE_CUBE_ARRAY ||
|
||||
u_minify(stImage->pt->depth0, src_level) == stImage->base.Depth);
|
||||
u_minify(stImage->pt->depth0, src_level) == stImage->Depth);
|
||||
|
||||
st_texture_image_copy(st->pipe,
|
||||
stObj->pt, dstLevel, /* dest texture, level */
|
||||
stImage->pt, src_level, /* src texture, level */
|
||||
stImage->base.Face);
|
||||
stImage->Face);
|
||||
|
||||
pipe_resource_reference(&stImage->pt, NULL);
|
||||
}
|
||||
|
@ -2985,10 +2975,9 @@ st_finalize_texture(struct gl_context *ctx,
|
|||
GLuint cubeMapFace)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(tObj);
|
||||
const GLuint nr_faces = _mesa_num_tex_faces(stObj->base.Target);
|
||||
const GLuint nr_faces = _mesa_num_tex_faces(tObj->Target);
|
||||
GLuint face;
|
||||
const struct st_texture_image *firstImage;
|
||||
const struct gl_texture_image *firstImage;
|
||||
enum pipe_format firstImageFormat;
|
||||
unsigned ptWidth;
|
||||
uint16_t ptHeight, ptDepth, ptLayers, ptNumSamples;
|
||||
|
@ -2997,84 +2986,84 @@ st_finalize_texture(struct gl_context *ctx,
|
|||
return GL_TRUE;
|
||||
|
||||
if (tObj->_MipmapComplete)
|
||||
stObj->lastLevel = stObj->base._MaxLevel;
|
||||
tObj->lastLevel = tObj->_MaxLevel;
|
||||
else if (tObj->_BaseComplete)
|
||||
stObj->lastLevel = stObj->base.Attrib.BaseLevel;
|
||||
tObj->lastLevel = tObj->Attrib.BaseLevel;
|
||||
|
||||
/* Skip the loop over images in the common case of no images having
|
||||
* changed. But if the GL_BASE_LEVEL or GL_MAX_LEVEL change to something we
|
||||
* haven't looked at, then we do need to look at those new images.
|
||||
*/
|
||||
if (!stObj->needs_validation &&
|
||||
stObj->base.Attrib.BaseLevel >= stObj->validated_first_level &&
|
||||
stObj->lastLevel <= stObj->validated_last_level) {
|
||||
if (!tObj->needs_validation &&
|
||||
tObj->Attrib.BaseLevel >= tObj->validated_first_level &&
|
||||
tObj->lastLevel <= tObj->validated_last_level) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
/* If this texture comes from a window system, there is nothing else to do. */
|
||||
if (stObj->surface_based) {
|
||||
if (tObj->surface_based) {
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
firstImage = st_texture_image_const(stObj->base.Image[cubeMapFace]
|
||||
[stObj->base.Attrib.BaseLevel]);
|
||||
firstImage = st_texture_image_const(tObj->Image[cubeMapFace]
|
||||
[tObj->Attrib.BaseLevel]);
|
||||
if (!firstImage)
|
||||
return false;
|
||||
|
||||
/* If both firstImage and stObj point to a texture which can contain
|
||||
/* If both firstImage and tObj point to a texture which can contain
|
||||
* all active images, favour firstImage. Note that because of the
|
||||
* completeness requirement, we know that the image dimensions
|
||||
* will match.
|
||||
*/
|
||||
if (firstImage->pt &&
|
||||
firstImage->pt != stObj->pt &&
|
||||
(!stObj->pt || firstImage->pt->last_level >= stObj->pt->last_level)) {
|
||||
pipe_resource_reference(&stObj->pt, firstImage->pt);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
firstImage->pt != tObj->pt &&
|
||||
(!tObj->pt || firstImage->pt->last_level >= tObj->pt->last_level)) {
|
||||
pipe_resource_reference(&tObj->pt, firstImage->pt);
|
||||
st_texture_release_all_sampler_views(st, tObj);
|
||||
}
|
||||
|
||||
/* Find gallium format for the Mesa texture */
|
||||
firstImageFormat =
|
||||
st_mesa_format_to_pipe_format(st, firstImage->base.TexFormat);
|
||||
st_mesa_format_to_pipe_format(st, firstImage->TexFormat);
|
||||
|
||||
/* Find size of level=0 Gallium mipmap image, plus number of texture layers */
|
||||
{
|
||||
unsigned width;
|
||||
uint16_t height, depth;
|
||||
|
||||
st_gl_texture_dims_to_pipe_dims(stObj->base.Target,
|
||||
firstImage->base.Width2,
|
||||
firstImage->base.Height2,
|
||||
firstImage->base.Depth2,
|
||||
st_gl_texture_dims_to_pipe_dims(tObj->Target,
|
||||
firstImage->Width2,
|
||||
firstImage->Height2,
|
||||
firstImage->Depth2,
|
||||
&width, &height, &depth, &ptLayers);
|
||||
|
||||
/* If we previously allocated a pipe texture and its sizes are
|
||||
* compatible, use them.
|
||||
*/
|
||||
if (stObj->pt &&
|
||||
u_minify(stObj->pt->width0, firstImage->base.Level) == width &&
|
||||
u_minify(stObj->pt->height0, firstImage->base.Level) == height &&
|
||||
u_minify(stObj->pt->depth0, firstImage->base.Level) == depth) {
|
||||
ptWidth = stObj->pt->width0;
|
||||
ptHeight = stObj->pt->height0;
|
||||
ptDepth = stObj->pt->depth0;
|
||||
if (tObj->pt &&
|
||||
u_minify(tObj->pt->width0, firstImage->Level) == width &&
|
||||
u_minify(tObj->pt->height0, firstImage->Level) == height &&
|
||||
u_minify(tObj->pt->depth0, firstImage->Level) == depth) {
|
||||
ptWidth = tObj->pt->width0;
|
||||
ptHeight = tObj->pt->height0;
|
||||
ptDepth = tObj->pt->depth0;
|
||||
} else {
|
||||
/* Otherwise, compute a new level=0 size that is compatible with the
|
||||
* base level image.
|
||||
*/
|
||||
ptWidth = width > 1 ? width << firstImage->base.Level : 1;
|
||||
ptHeight = height > 1 ? height << firstImage->base.Level : 1;
|
||||
ptDepth = depth > 1 ? depth << firstImage->base.Level : 1;
|
||||
ptWidth = width > 1 ? width << firstImage->Level : 1;
|
||||
ptHeight = height > 1 ? height << firstImage->Level : 1;
|
||||
ptDepth = depth > 1 ? depth << firstImage->Level : 1;
|
||||
|
||||
/* If the base level image is 1x1x1, we still need to ensure that the
|
||||
* resulting pipe texture ends up with the required number of levels
|
||||
* in total.
|
||||
*/
|
||||
if (ptWidth == 1 && ptHeight == 1 && ptDepth == 1) {
|
||||
ptWidth <<= firstImage->base.Level;
|
||||
ptWidth <<= firstImage->Level;
|
||||
|
||||
if (stObj->base.Target == GL_TEXTURE_CUBE_MAP ||
|
||||
stObj->base.Target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
||||
if (tObj->Target == GL_TEXTURE_CUBE_MAP ||
|
||||
tObj->Target == GL_TEXTURE_CUBE_MAP_ARRAY)
|
||||
ptHeight = ptWidth;
|
||||
}
|
||||
|
||||
|
@ -3083,48 +3072,48 @@ st_finalize_texture(struct gl_context *ctx,
|
|||
* don't return GL_FALSE as that would raise an incorrect
|
||||
* GL_OUT_OF_MEMORY error. See Piglit fbo-incomplete-texture-03 test.
|
||||
*/
|
||||
if (!stObj->base._BaseComplete) {
|
||||
_mesa_test_texobj_completeness(ctx, &stObj->base);
|
||||
if (!stObj->base._BaseComplete) {
|
||||
if (!tObj->_BaseComplete) {
|
||||
_mesa_test_texobj_completeness(ctx, tObj);
|
||||
if (!tObj->_BaseComplete) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ptNumSamples = firstImage->base.NumSamples;
|
||||
ptNumSamples = firstImage->NumSamples;
|
||||
}
|
||||
|
||||
/* If we already have a gallium texture, check that it matches the texture
|
||||
* object's format, target, size, num_levels, etc.
|
||||
*/
|
||||
if (stObj->pt) {
|
||||
if (stObj->pt->target != gl_target_to_pipe(stObj->base.Target) ||
|
||||
stObj->pt->format != firstImageFormat ||
|
||||
stObj->pt->last_level < stObj->lastLevel ||
|
||||
stObj->pt->width0 != ptWidth ||
|
||||
stObj->pt->height0 != ptHeight ||
|
||||
stObj->pt->depth0 != ptDepth ||
|
||||
stObj->pt->nr_samples != ptNumSamples ||
|
||||
stObj->pt->array_size != ptLayers)
|
||||
if (tObj->pt) {
|
||||
if (tObj->pt->target != gl_target_to_pipe(tObj->Target) ||
|
||||
tObj->pt->format != firstImageFormat ||
|
||||
tObj->pt->last_level < tObj->lastLevel ||
|
||||
tObj->pt->width0 != ptWidth ||
|
||||
tObj->pt->height0 != ptHeight ||
|
||||
tObj->pt->depth0 != ptDepth ||
|
||||
tObj->pt->nr_samples != ptNumSamples ||
|
||||
tObj->pt->array_size != ptLayers)
|
||||
{
|
||||
/* The gallium texture does not match the Mesa texture so delete the
|
||||
* gallium texture now. We'll make a new one below.
|
||||
*/
|
||||
pipe_resource_reference(&stObj->pt, NULL);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
pipe_resource_reference(&tObj->pt, NULL);
|
||||
st_texture_release_all_sampler_views(st, tObj);
|
||||
st->dirty |= ST_NEW_FRAMEBUFFER;
|
||||
}
|
||||
}
|
||||
|
||||
/* May need to create a new gallium texture:
|
||||
*/
|
||||
if (!stObj->pt) {
|
||||
if (!tObj->pt) {
|
||||
GLuint bindings = default_bindings(st, firstImageFormat);
|
||||
|
||||
stObj->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(stObj->base.Target),
|
||||
tObj->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(tObj->Target),
|
||||
firstImageFormat,
|
||||
stObj->lastLevel,
|
||||
tObj->lastLevel,
|
||||
ptWidth,
|
||||
ptHeight,
|
||||
ptDepth,
|
||||
|
@ -3132,7 +3121,7 @@ st_finalize_texture(struct gl_context *ctx,
|
|||
bindings,
|
||||
false);
|
||||
|
||||
if (!stObj->pt) {
|
||||
if (!tObj->pt) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
@ -3142,42 +3131,42 @@ st_finalize_texture(struct gl_context *ctx,
|
|||
*/
|
||||
for (face = 0; face < nr_faces; face++) {
|
||||
GLuint level;
|
||||
for (level = stObj->base.Attrib.BaseLevel; level <= stObj->lastLevel; level++) {
|
||||
struct st_texture_image *stImage =
|
||||
st_texture_image(stObj->base.Image[face][level]);
|
||||
for (level = tObj->Attrib.BaseLevel; level <= tObj->lastLevel; level++) {
|
||||
struct gl_texture_image *stImage =
|
||||
tObj->Image[face][level];
|
||||
|
||||
/* Need to import images in main memory or held in other textures.
|
||||
*/
|
||||
if (stImage && stObj->pt != stImage->pt) {
|
||||
if (stImage && tObj->pt != stImage->pt) {
|
||||
GLuint height;
|
||||
GLuint depth;
|
||||
|
||||
if (stObj->base.Target != GL_TEXTURE_1D_ARRAY)
|
||||
if (tObj->Target != GL_TEXTURE_1D_ARRAY)
|
||||
height = u_minify(ptHeight, level);
|
||||
else
|
||||
height = ptLayers;
|
||||
|
||||
if (stObj->base.Target == GL_TEXTURE_3D)
|
||||
if (tObj->Target == GL_TEXTURE_3D)
|
||||
depth = u_minify(ptDepth, level);
|
||||
else if (stObj->base.Target == GL_TEXTURE_CUBE_MAP)
|
||||
else if (tObj->Target == GL_TEXTURE_CUBE_MAP)
|
||||
depth = 1;
|
||||
else
|
||||
depth = ptLayers;
|
||||
|
||||
if (level == 0 ||
|
||||
(stImage->base.Width == u_minify(ptWidth, level) &&
|
||||
stImage->base.Height == height &&
|
||||
stImage->base.Depth == depth)) {
|
||||
(stImage->Width == u_minify(ptWidth, level) &&
|
||||
stImage->Height == height &&
|
||||
stImage->Depth == depth)) {
|
||||
/* src image fits expected dest mipmap level size */
|
||||
copy_image_data_to_texture(st, stObj, level, stImage);
|
||||
copy_image_data_to_texture(st, tObj, level, stImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stObj->validated_first_level = stObj->base.Attrib.BaseLevel;
|
||||
stObj->validated_last_level = stObj->lastLevel;
|
||||
stObj->needs_validation = false;
|
||||
tObj->validated_first_level = tObj->Attrib.BaseLevel;
|
||||
tObj->validated_last_level = tObj->lastLevel;
|
||||
tObj->needs_validation = false;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -3262,7 +3251,6 @@ st_texture_storage(struct gl_context *ctx,
|
|||
const GLuint numFaces = _mesa_num_tex_faces(texObj->Target);
|
||||
struct gl_texture_image *texImage = texObj->Image[0][0];
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct pipe_screen *screen = st->screen;
|
||||
unsigned ptWidth, bindings;
|
||||
uint16_t ptHeight, ptDepth, ptLayers;
|
||||
|
@ -3272,7 +3260,7 @@ st_texture_storage(struct gl_context *ctx,
|
|||
|
||||
assert(levels > 0);
|
||||
|
||||
stObj->lastLevel = levels - 1;
|
||||
texObj->lastLevel = levels - 1;
|
||||
|
||||
fmt = st_mesa_format_to_pipe_format(st, texImage->TexFormat);
|
||||
|
||||
|
@ -3316,10 +3304,10 @@ st_texture_storage(struct gl_context *ctx,
|
|||
width, height, depth,
|
||||
&ptWidth, &ptHeight, &ptDepth, &ptLayers);
|
||||
|
||||
pipe_resource_reference(&stObj->pt, NULL);
|
||||
pipe_resource_reference(&texObj->pt, NULL);
|
||||
|
||||
if (memObj) {
|
||||
stObj->pt = st_texture_create_from_memory(st,
|
||||
texObj->pt = st_texture_create_from_memory(st,
|
||||
memObj,
|
||||
offset,
|
||||
gl_target_to_pipe(texObj->Target),
|
||||
|
@ -3332,7 +3320,7 @@ st_texture_storage(struct gl_context *ctx,
|
|||
bindings);
|
||||
}
|
||||
else {
|
||||
stObj->pt = st_texture_create(st,
|
||||
texObj->pt = st_texture_create(st,
|
||||
gl_target_to_pipe(texObj->Target),
|
||||
fmt,
|
||||
levels - 1,
|
||||
|
@ -3344,28 +3332,28 @@ st_texture_storage(struct gl_context *ctx,
|
|||
texObj->IsSparse);
|
||||
}
|
||||
|
||||
if (!stObj->pt)
|
||||
if (!texObj->pt)
|
||||
return GL_FALSE;
|
||||
|
||||
/* Set image resource pointers */
|
||||
for (level = 0; level < levels; level++) {
|
||||
GLuint face;
|
||||
for (face = 0; face < numFaces; face++) {
|
||||
struct st_texture_image *stImage =
|
||||
st_texture_image(texObj->Image[face][level]);
|
||||
pipe_resource_reference(&stImage->pt, stObj->pt);
|
||||
struct gl_texture_image *stImage =
|
||||
texObj->Image[face][level];
|
||||
pipe_resource_reference(&stImage->pt, texObj->pt);
|
||||
|
||||
compressed_tex_fallback_allocate(st, stImage);
|
||||
}
|
||||
}
|
||||
|
||||
/* Update gl_texture_object for texture parameter query. */
|
||||
texObj->NumSparseLevels = stObj->pt->nr_sparse_levels;
|
||||
texObj->NumSparseLevels = texObj->pt->nr_sparse_levels;
|
||||
|
||||
/* The texture is in a validated state, so no need to check later. */
|
||||
stObj->needs_validation = false;
|
||||
stObj->validated_first_level = 0;
|
||||
stObj->validated_last_level = levels - 1;
|
||||
texObj->needs_validation = false;
|
||||
texObj->validated_first_level = 0;
|
||||
texObj->validated_last_level = levels - 1;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
@ -3448,8 +3436,8 @@ st_TextureView(struct gl_context *ctx,
|
|||
struct gl_texture_object *origTexObj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *orig = st_texture_object(origTexObj);
|
||||
struct st_texture_object *tex = st_texture_object(texObj);
|
||||
struct gl_texture_object *orig = origTexObj;
|
||||
struct gl_texture_object *tex = texObj;
|
||||
struct gl_texture_image *image = texObj->Image[0][0];
|
||||
|
||||
const int numFaces = _mesa_num_tex_faces(texObj->Target);
|
||||
|
@ -3463,10 +3451,10 @@ st_TextureView(struct gl_context *ctx,
|
|||
/* Set image resource pointers */
|
||||
for (level = 0; level < numLevels; level++) {
|
||||
for (face = 0; face < numFaces; face++) {
|
||||
struct st_texture_image *stImage =
|
||||
st_texture_image(texObj->Image[face][level]);
|
||||
struct st_texture_image *origImage =
|
||||
st_texture_image(origTexObj->Image[face][level]);
|
||||
struct gl_texture_image *stImage =
|
||||
texObj->Image[face][level];
|
||||
struct gl_texture_image *origImage =
|
||||
origTexObj->Image[face][level];
|
||||
pipe_resource_reference(&stImage->pt, tex->pt);
|
||||
if (origImage &&
|
||||
origImage->compressed_data) {
|
||||
|
@ -3541,7 +3529,7 @@ st_ClearTexSubImage(struct gl_context *ctx,
|
|||
{
|
||||
static const char zeros[16] = {0};
|
||||
struct gl_texture_object *texObj = texImage->TexObject;
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
struct gl_texture_image *stImage = texImage;
|
||||
struct pipe_resource *pt = stImage->pt;
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
|
@ -3570,7 +3558,7 @@ st_ClearTexSubImage(struct gl_context *ctx,
|
|||
* texture, we have to apply the MinLevel/Layer offsets. If this is
|
||||
* not a texture view, the offsets will be zero.
|
||||
*/
|
||||
assert(stImage->pt == st_texture_object(texObj)->pt);
|
||||
assert(stImage->pt == texObj->pt);
|
||||
level = texImage->Level + texObj->Attrib.MinLevel;
|
||||
box.z += texObj->Attrib.MinLayer;
|
||||
}
|
||||
|
@ -3597,7 +3585,6 @@ st_TexParameter(struct gl_context *ctx,
|
|||
struct gl_texture_object *texObj, GLenum pname)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
|
||||
switch (pname) {
|
||||
case GL_ALL_ATTRIB_BITS: /* meaning is all pnames, internal */
|
||||
|
@ -3616,7 +3603,7 @@ st_TexParameter(struct gl_context *ctx,
|
|||
/* changing any of these texture parameters means we must create
|
||||
* new sampler views.
|
||||
*/
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
break;
|
||||
default:
|
||||
; /* nothing */
|
||||
|
@ -3641,7 +3628,6 @@ st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
|
|||
struct gl_sampler_object *sampObj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct pipe_sampler_view *view;
|
||||
struct pipe_sampler_state sampler = {0};
|
||||
|
@ -3653,10 +3639,10 @@ st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
|
|||
st_convert_sampler(st, texObj, sampObj, 0, &sampler, false);
|
||||
|
||||
/* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
|
||||
view = st_get_texture_sampler_view_from_stobj(st, stObj, sampObj, 0,
|
||||
view = st_get_texture_sampler_view_from_stobj(st, texObj, sampObj, 0,
|
||||
true, false);
|
||||
} else {
|
||||
view = st_get_buffer_sampler_view_from_stobj(st, stObj, false);
|
||||
view = st_get_buffer_sampler_view_from_stobj(st, texObj, false);
|
||||
}
|
||||
|
||||
return pipe->create_texture_handle(pipe, view, &sampler);
|
||||
|
@ -3741,12 +3727,11 @@ st_TexturePageCommitment(struct gl_context *ctx,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct st_texture_object *tex = st_texture_object(tex_obj);
|
||||
struct pipe_box box;
|
||||
|
||||
u_box_3d(xoffset, yoffset, zoffset, width, height, depth, &box);
|
||||
|
||||
if (!pipe->resource_commit(pipe, tex->pt, level, &box, commit)) {
|
||||
if (!pipe->resource_commit(pipe, tex_obj->pt, level, &box, commit)) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexPageCommitmentARB(out of memory)");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
struct dd_function_table;
|
||||
struct gl_context;
|
||||
struct gl_texture_object;
|
||||
struct gl_texture_image;
|
||||
struct pipe_context;
|
||||
struct st_context;
|
||||
struct st_texture_object;
|
||||
struct gl_renderbuffer;
|
||||
struct gl_pixelstore_attrib;
|
||||
struct gl_memory_object;
|
||||
|
|
|
@ -991,7 +991,7 @@ destroy_tex_sampler_cb(void *data, void *userData)
|
|||
struct gl_texture_object *texObj = (struct gl_texture_object *) data;
|
||||
struct st_context *st = (struct st_context *) userData;
|
||||
|
||||
st_texture_release_context_sampler_view(st, st_texture_object(texObj));
|
||||
st_texture_release_context_sampler_view(st, texObj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1003,7 +1003,7 @@ destroy_framebuffer_attachment_sampler_cb(void *data, void *userData)
|
|||
for (unsigned i = 0; i < BUFFER_COUNT; i++) {
|
||||
struct gl_renderbuffer_attachment *att = &glfb->Attachment[i];
|
||||
if (att->Texture) {
|
||||
st_texture_release_context_sampler_view(st, st_texture_object(att->Texture));
|
||||
st_texture_release_context_sampler_view(st, att->Texture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1041,8 +1041,8 @@ st_destroy_context(struct st_context *st)
|
|||
* context.
|
||||
*/
|
||||
for (unsigned i = 0; i < NUM_TEXTURE_TARGETS; i++) {
|
||||
struct st_texture_object *stObj =
|
||||
st_texture_object(ctx->Shared->FallbackTex[i]);
|
||||
struct gl_texture_object *stObj =
|
||||
ctx->Shared->FallbackTex[i];
|
||||
if (stObj) {
|
||||
st_texture_release_context_sampler_view(st, stObj);
|
||||
}
|
||||
|
|
|
@ -50,7 +50,6 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
struct gl_texture_object *texObj)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct pipe_resource *pt = st_get_texobj_resource(texObj);
|
||||
uint baseLevel = texObj->Attrib.BaseLevel;
|
||||
enum pipe_format format;
|
||||
|
@ -81,7 +80,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
/* The texture isn't in a "complete" state yet so set the expected
|
||||
* lastLevel here, since it won't get done in st_finalize_texture().
|
||||
*/
|
||||
stObj->lastLevel = lastLevel;
|
||||
texObj->lastLevel = lastLevel;
|
||||
|
||||
if (!texObj->Immutable) {
|
||||
const GLboolean genSave = texObj->Attrib.GenerateMipmap;
|
||||
|
@ -106,7 +105,7 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
st_finalize_texture(ctx, st->pipe, texObj, 0);
|
||||
}
|
||||
|
||||
pt = stObj->pt;
|
||||
pt = texObj->pt;
|
||||
if (!pt) {
|
||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "mipmap generation");
|
||||
return;
|
||||
|
@ -122,8 +121,8 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
|
|||
last_layer = util_max_layer(pt, baseLevel);
|
||||
}
|
||||
|
||||
if (stObj->surface_based)
|
||||
format = stObj->surface_format;
|
||||
if (texObj->surface_based)
|
||||
format = texObj->surface_format;
|
||||
else
|
||||
format = pt->format;
|
||||
|
||||
|
|
|
@ -705,8 +705,6 @@ st_context_teximage(struct st_context_iface *stctxi,
|
|||
struct gl_context *ctx = st->ctx;
|
||||
struct gl_texture_object *texObj;
|
||||
struct gl_texture_image *texImage;
|
||||
struct st_texture_object *stObj;
|
||||
struct st_texture_image *stImage;
|
||||
GLenum internalFormat;
|
||||
GLuint width, height, depth;
|
||||
GLenum target;
|
||||
|
@ -732,15 +730,13 @@ st_context_teximage(struct st_context_iface *stctxi,
|
|||
|
||||
_mesa_lock_texture(ctx, texObj);
|
||||
|
||||
stObj = st_texture_object(texObj);
|
||||
/* switch to surface based */
|
||||
if (!stObj->surface_based) {
|
||||
if (!texObj->surface_based) {
|
||||
_mesa_clear_texture_object(ctx, texObj, NULL);
|
||||
stObj->surface_based = GL_TRUE;
|
||||
texObj->surface_based = GL_TRUE;
|
||||
}
|
||||
|
||||
texImage = _mesa_get_tex_image(ctx, texObj, target, level);
|
||||
stImage = st_texture_image(texImage);
|
||||
if (tex) {
|
||||
mesa_format texFormat = st_pipe_format_to_mesa_format(pipe_format);
|
||||
|
||||
|
@ -773,12 +769,12 @@ st_context_teximage(struct st_context_iface *stctxi,
|
|||
width = height = depth = 0;
|
||||
}
|
||||
|
||||
pipe_resource_reference(&stObj->pt, tex);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
pipe_resource_reference(&stImage->pt, tex);
|
||||
stObj->surface_format = pipe_format;
|
||||
pipe_resource_reference(&texObj->pt, tex);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
pipe_resource_reference(&texImage->pt, tex);
|
||||
texObj->surface_format = pipe_format;
|
||||
|
||||
stObj->needs_validation = true;
|
||||
texObj->needs_validation = true;
|
||||
|
||||
_mesa_dirty_texobj(ctx, texObj);
|
||||
_mesa_unlock_texture(ctx, texObj);
|
||||
|
|
|
@ -1025,7 +1025,7 @@ st_GetTexSubImage_shader(struct gl_context * ctx,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_screen *screen = st->screen;
|
||||
struct st_texture_object *stObj = st_texture_object(texImage->TexObject);
|
||||
struct gl_texture_object *stObj = texImage->TexObject;
|
||||
struct pipe_resource *src = stObj->pt;
|
||||
struct pipe_resource *dst = NULL;
|
||||
enum pipe_format dst_format, src_format;
|
||||
|
|
|
@ -69,7 +69,7 @@ st_get_external_sampler_key(struct st_context *st, struct gl_program *prog)
|
|||
|
||||
while (unlikely(mask)) {
|
||||
unsigned unit = u_bit_scan(&mask);
|
||||
struct st_texture_object *stObj =
|
||||
struct gl_texture_object *stObj =
|
||||
st_get_texture_object(st->ctx, prog, unit);
|
||||
enum pipe_format format = st_get_view_format(stObj);
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ get_sampler_view_reference(struct st_sampler_view *sv,
|
|||
*/
|
||||
static struct pipe_sampler_view *
|
||||
st_texture_set_sampler_view(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *stObj,
|
||||
struct pipe_sampler_view *view,
|
||||
bool glsl130_or_later, bool srgb_skip_decode,
|
||||
bool get_reference)
|
||||
|
@ -200,7 +200,7 @@ out:
|
|||
*/
|
||||
struct st_sampler_view *
|
||||
st_texture_get_current_sampler_view(const struct st_context *st,
|
||||
const struct st_texture_object *stObj)
|
||||
const struct gl_texture_object *stObj)
|
||||
{
|
||||
struct st_sampler_views *views = p_atomic_read(&stObj->sampler_views);
|
||||
|
||||
|
@ -221,7 +221,7 @@ st_texture_get_current_sampler_view(const struct st_context *st,
|
|||
*/
|
||||
void
|
||||
st_texture_release_context_sampler_view(struct st_context *st,
|
||||
struct st_texture_object *stObj)
|
||||
struct gl_texture_object *stObj)
|
||||
{
|
||||
GLuint i;
|
||||
|
||||
|
@ -247,7 +247,7 @@ st_texture_release_context_sampler_view(struct st_context *st,
|
|||
*/
|
||||
void
|
||||
st_texture_release_all_sampler_views(struct st_context *st,
|
||||
struct st_texture_object *stObj)
|
||||
struct gl_texture_object *stObj)
|
||||
{
|
||||
/* TODO: This happens while a texture is deleted, because the Driver API
|
||||
* is asymmetric: the driver allocates the texture object memory, but
|
||||
|
@ -285,7 +285,7 @@ st_texture_release_all_sampler_views(struct st_context *st,
|
|||
*/
|
||||
void
|
||||
st_delete_texture_sampler_views(struct st_context *st,
|
||||
struct st_texture_object *stObj)
|
||||
struct gl_texture_object *stObj)
|
||||
{
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
|
||||
|
@ -428,12 +428,12 @@ compute_texture_format_swizzle(GLenum baseFormat, GLenum depthMode,
|
|||
|
||||
static unsigned
|
||||
get_texture_format_swizzle(const struct st_context *st,
|
||||
const struct st_texture_object *stObj,
|
||||
const struct gl_texture_object *texObj,
|
||||
bool glsl130_or_later)
|
||||
{
|
||||
GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
|
||||
GLenum baseFormat = _mesa_base_tex_image(texObj)->_BaseFormat;
|
||||
unsigned tex_swizzle;
|
||||
GLenum depth_mode = stObj->base.Attrib.DepthMode;
|
||||
GLenum depth_mode = texObj->Attrib.DepthMode;
|
||||
|
||||
/* In ES 3.0, DEPTH_TEXTURE_MODE is expected to be GL_RED for textures
|
||||
* with depth component data specified with a sized internal format.
|
||||
|
@ -443,7 +443,7 @@ get_texture_format_swizzle(const struct st_context *st,
|
|||
baseFormat == GL_DEPTH_STENCIL ||
|
||||
baseFormat == GL_STENCIL_INDEX)) {
|
||||
const struct gl_texture_image *firstImage =
|
||||
_mesa_base_tex_image(&stObj->base);
|
||||
_mesa_base_tex_image(texObj);
|
||||
if (firstImage->InternalFormat != GL_DEPTH_COMPONENT &&
|
||||
firstImage->InternalFormat != GL_DEPTH_STENCIL &&
|
||||
firstImage->InternalFormat != GL_STENCIL_INDEX)
|
||||
|
@ -454,7 +454,7 @@ get_texture_format_swizzle(const struct st_context *st,
|
|||
glsl130_or_later);
|
||||
|
||||
/* Combine the texture format swizzle with user's swizzle */
|
||||
return swizzle_swizzle(stObj->base.Attrib._Swizzle, tex_swizzle);
|
||||
return swizzle_swizzle(texObj->Attrib._Swizzle, tex_swizzle);
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,15 +462,15 @@ get_texture_format_swizzle(const struct st_context *st,
|
|||
* Return TRUE if the texture's sampler view swizzle is not equal to
|
||||
* the texture's swizzle.
|
||||
*
|
||||
* \param stObj the st texture object,
|
||||
* \param texObj the st texture object,
|
||||
*/
|
||||
ASSERTED static boolean
|
||||
check_sampler_swizzle(const struct st_context *st,
|
||||
const struct st_texture_object *stObj,
|
||||
const struct gl_texture_object *texObj,
|
||||
const struct pipe_sampler_view *sv,
|
||||
bool glsl130_or_later)
|
||||
{
|
||||
unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
|
||||
unsigned swizzle = get_texture_format_swizzle(st, texObj, glsl130_or_later);
|
||||
|
||||
return ((sv->swizzle_r != GET_SWZ(swizzle, 0)) ||
|
||||
(sv->swizzle_g != GET_SWZ(swizzle, 1)) ||
|
||||
|
@ -480,25 +480,25 @@ check_sampler_swizzle(const struct st_context *st,
|
|||
|
||||
|
||||
static unsigned
|
||||
last_level(const struct st_texture_object *stObj)
|
||||
last_level(const struct gl_texture_object *texObj)
|
||||
{
|
||||
unsigned ret = MIN2(stObj->base.Attrib.MinLevel + stObj->base._MaxLevel,
|
||||
stObj->pt->last_level);
|
||||
if (stObj->base.Immutable)
|
||||
ret = MIN2(ret, stObj->base.Attrib.MinLevel +
|
||||
stObj->base.Attrib.NumLevels - 1);
|
||||
unsigned ret = MIN2(texObj->Attrib.MinLevel + texObj->_MaxLevel,
|
||||
texObj->pt->last_level);
|
||||
if (texObj->Immutable)
|
||||
ret = MIN2(ret, texObj->Attrib.MinLevel +
|
||||
texObj->Attrib.NumLevels - 1);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static unsigned
|
||||
last_layer(const struct st_texture_object *stObj)
|
||||
last_layer(const struct gl_texture_object *texObj)
|
||||
{
|
||||
if (stObj->base.Immutable && stObj->pt->array_size > 1)
|
||||
return MIN2(stObj->base.Attrib.MinLayer +
|
||||
stObj->base.Attrib.NumLayers - 1,
|
||||
stObj->pt->array_size - 1);
|
||||
return stObj->pt->array_size - 1;
|
||||
if (texObj->Immutable && texObj->pt->array_size > 1)
|
||||
return MIN2(texObj->Attrib.MinLayer +
|
||||
texObj->Attrib.NumLayers - 1,
|
||||
texObj->pt->array_size - 1);
|
||||
return texObj->pt->array_size - 1;
|
||||
}
|
||||
|
||||
|
||||
|
@ -507,18 +507,18 @@ last_layer(const struct st_texture_object *stObj)
|
|||
*/
|
||||
static enum pipe_format
|
||||
get_sampler_view_format(struct st_context *st,
|
||||
const struct st_texture_object *stObj,
|
||||
const struct gl_texture_object *texObj,
|
||||
bool srgb_skip_decode)
|
||||
{
|
||||
enum pipe_format format;
|
||||
|
||||
GLenum baseFormat = _mesa_base_tex_image(&stObj->base)->_BaseFormat;
|
||||
format = stObj->surface_based ? stObj->surface_format : stObj->pt->format;
|
||||
GLenum baseFormat = _mesa_base_tex_image(texObj)->_BaseFormat;
|
||||
format = texObj->surface_based ? texObj->surface_format : texObj->pt->format;
|
||||
|
||||
if (baseFormat == GL_DEPTH_COMPONENT ||
|
||||
baseFormat == GL_DEPTH_STENCIL ||
|
||||
baseFormat == GL_STENCIL_INDEX) {
|
||||
if (stObj->base.StencilSampling || baseFormat == GL_STENCIL_INDEX)
|
||||
if (texObj->StencilSampling || baseFormat == GL_STENCIL_INDEX)
|
||||
format = util_format_stencil_only(format);
|
||||
|
||||
return format;
|
||||
|
@ -529,13 +529,13 @@ get_sampler_view_format(struct st_context *st,
|
|||
format = util_format_linear(format);
|
||||
|
||||
/* if resource format matches then YUV wasn't lowered */
|
||||
if (format == stObj->pt->format)
|
||||
if (format == texObj->pt->format)
|
||||
return format;
|
||||
|
||||
/* Use R8_UNORM for video formats */
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_NV12:
|
||||
if (stObj->pt->format == PIPE_FORMAT_R8_G8B8_420_UNORM) {
|
||||
if (texObj->pt->format == PIPE_FORMAT_R8_G8B8_420_UNORM) {
|
||||
format = PIPE_FORMAT_R8_G8B8_420_UNORM;
|
||||
break;
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ get_sampler_view_format(struct st_context *st,
|
|||
break;
|
||||
case PIPE_FORMAT_YUYV:
|
||||
case PIPE_FORMAT_UYVY:
|
||||
if (stObj->pt->format == PIPE_FORMAT_R8G8_R8B8_UNORM ||
|
||||
stObj->pt->format == PIPE_FORMAT_G8R8_B8R8_UNORM) {
|
||||
format = stObj->pt->format;
|
||||
if (texObj->pt->format == PIPE_FORMAT_R8G8_R8B8_UNORM ||
|
||||
texObj->pt->format == PIPE_FORMAT_G8R8_B8R8_UNORM) {
|
||||
format = texObj->pt->format;
|
||||
break;
|
||||
}
|
||||
format = PIPE_FORMAT_R8G8_UNORM;
|
||||
|
@ -584,44 +584,44 @@ get_sampler_view_format(struct st_context *st,
|
|||
|
||||
static struct pipe_sampler_view *
|
||||
st_create_texture_sampler_view_from_stobj(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *texObj,
|
||||
enum pipe_format format,
|
||||
bool glsl130_or_later)
|
||||
{
|
||||
/* There is no need to clear this structure (consider CPU overhead). */
|
||||
struct pipe_sampler_view templ;
|
||||
unsigned swizzle = get_texture_format_swizzle(st, stObj, glsl130_or_later);
|
||||
unsigned swizzle = get_texture_format_swizzle(st, texObj, glsl130_or_later);
|
||||
|
||||
templ.format = format;
|
||||
|
||||
if (stObj->level_override >= 0) {
|
||||
templ.u.tex.first_level = templ.u.tex.last_level = stObj->level_override;
|
||||
if (texObj->level_override >= 0) {
|
||||
templ.u.tex.first_level = templ.u.tex.last_level = texObj->level_override;
|
||||
} else {
|
||||
templ.u.tex.first_level = stObj->base.Attrib.MinLevel +
|
||||
stObj->base.Attrib.BaseLevel;
|
||||
templ.u.tex.last_level = last_level(stObj);
|
||||
templ.u.tex.first_level = texObj->Attrib.MinLevel +
|
||||
texObj->Attrib.BaseLevel;
|
||||
templ.u.tex.last_level = last_level(texObj);
|
||||
}
|
||||
if (stObj->layer_override >= 0) {
|
||||
templ.u.tex.first_layer = templ.u.tex.last_layer = stObj->layer_override;
|
||||
if (texObj->layer_override >= 0) {
|
||||
templ.u.tex.first_layer = templ.u.tex.last_layer = texObj->layer_override;
|
||||
} else {
|
||||
templ.u.tex.first_layer = stObj->base.Attrib.MinLayer;
|
||||
templ.u.tex.last_layer = last_layer(stObj);
|
||||
templ.u.tex.first_layer = texObj->Attrib.MinLayer;
|
||||
templ.u.tex.last_layer = last_layer(texObj);
|
||||
}
|
||||
assert(templ.u.tex.first_layer <= templ.u.tex.last_layer);
|
||||
assert(templ.u.tex.first_level <= templ.u.tex.last_level);
|
||||
templ.target = gl_target_to_pipe(stObj->base.Target);
|
||||
templ.target = gl_target_to_pipe(texObj->Target);
|
||||
|
||||
templ.swizzle_r = GET_SWZ(swizzle, 0);
|
||||
templ.swizzle_g = GET_SWZ(swizzle, 1);
|
||||
templ.swizzle_b = GET_SWZ(swizzle, 2);
|
||||
templ.swizzle_a = GET_SWZ(swizzle, 3);
|
||||
|
||||
return st->pipe->create_sampler_view(st->pipe, stObj->pt, &templ);
|
||||
return st->pipe->create_sampler_view(st->pipe, texObj->pt, &templ);
|
||||
}
|
||||
|
||||
struct pipe_sampler_view *
|
||||
st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *texObj,
|
||||
const struct gl_sampler_object *samp,
|
||||
bool glsl130_or_later,
|
||||
bool ignore_srgb_decode,
|
||||
|
@ -633,7 +633,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
if (!ignore_srgb_decode && samp->Attrib.sRGBDecode == GL_SKIP_DECODE_EXT)
|
||||
srgb_skip_decode = true;
|
||||
|
||||
sv = st_texture_get_current_sampler_view(st, stObj);
|
||||
sv = st_texture_get_current_sampler_view(st, texObj);
|
||||
|
||||
if (sv &&
|
||||
sv->glsl130_or_later == glsl130_or_later &&
|
||||
|
@ -642,33 +642,33 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
* what they're supposed to be.
|
||||
*/
|
||||
struct pipe_sampler_view *view = sv->view;
|
||||
assert(stObj->pt == view->texture);
|
||||
assert(!check_sampler_swizzle(st, stObj, view, glsl130_or_later));
|
||||
assert(get_sampler_view_format(st, stObj, srgb_skip_decode) == view->format);
|
||||
assert(gl_target_to_pipe(stObj->base.Target) == view->target);
|
||||
assert(stObj->level_override >= 0 ||
|
||||
stObj->base.Attrib.MinLevel +
|
||||
stObj->base.Attrib.BaseLevel == view->u.tex.first_level);
|
||||
assert(stObj->level_override >= 0 || last_level(stObj) == view->u.tex.last_level);
|
||||
assert(stObj->layer_override >= 0 ||
|
||||
stObj->base.Attrib.MinLayer == view->u.tex.first_layer);
|
||||
assert(stObj->layer_override >= 0 || last_layer(stObj) == view->u.tex.last_layer);
|
||||
assert(stObj->layer_override < 0 ||
|
||||
(stObj->layer_override == view->u.tex.first_layer &&
|
||||
stObj->layer_override == view->u.tex.last_layer));
|
||||
assert(texObj->pt == view->texture);
|
||||
assert(!check_sampler_swizzle(st, texObj, view, glsl130_or_later));
|
||||
assert(get_sampler_view_format(st, texObj, srgb_skip_decode) == view->format);
|
||||
assert(gl_target_to_pipe(texObj->Target) == view->target);
|
||||
assert(texObj->level_override >= 0 ||
|
||||
texObj->Attrib.MinLevel +
|
||||
texObj->Attrib.BaseLevel == view->u.tex.first_level);
|
||||
assert(texObj->level_override >= 0 || last_level(texObj) == view->u.tex.last_level);
|
||||
assert(texObj->layer_override >= 0 ||
|
||||
texObj->Attrib.MinLayer == view->u.tex.first_layer);
|
||||
assert(texObj->layer_override >= 0 || last_layer(texObj) == view->u.tex.last_layer);
|
||||
assert(texObj->layer_override < 0 ||
|
||||
(texObj->layer_override == view->u.tex.first_layer &&
|
||||
texObj->layer_override == view->u.tex.last_layer));
|
||||
if (get_reference)
|
||||
view = get_sampler_view_reference(sv, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
/* create new sampler view */
|
||||
enum pipe_format format = get_sampler_view_format(st, stObj,
|
||||
enum pipe_format format = get_sampler_view_format(st, texObj,
|
||||
srgb_skip_decode);
|
||||
struct pipe_sampler_view *view =
|
||||
st_create_texture_sampler_view_from_stobj(st, stObj, format,
|
||||
st_create_texture_sampler_view_from_stobj(st, texObj, format,
|
||||
glsl130_or_later);
|
||||
|
||||
view = st_texture_set_sampler_view(st, stObj, view,
|
||||
view = st_texture_set_sampler_view(st, texObj, view,
|
||||
glsl130_or_later, srgb_skip_decode,
|
||||
get_reference);
|
||||
return view;
|
||||
|
@ -677,17 +677,17 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
|
||||
struct pipe_sampler_view *
|
||||
st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *texObj,
|
||||
bool get_reference)
|
||||
{
|
||||
struct st_sampler_view *sv;
|
||||
struct gl_buffer_object *stBuf =
|
||||
stObj->base.BufferObject;
|
||||
texObj->BufferObject;
|
||||
|
||||
if (!stBuf || !stBuf->buffer)
|
||||
return NULL;
|
||||
|
||||
sv = st_texture_get_current_sampler_view(st, stObj);
|
||||
sv = st_texture_get_current_sampler_view(st, texObj);
|
||||
|
||||
struct pipe_resource *buf = stBuf->buffer;
|
||||
|
||||
|
@ -699,12 +699,12 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
* what they're supposed to be.
|
||||
*/
|
||||
assert(st_mesa_format_to_pipe_format(st,
|
||||
stObj->base._BufferObjectFormat)
|
||||
texObj->_BufferObjectFormat)
|
||||
== view->format);
|
||||
assert(view->target == PIPE_BUFFER);
|
||||
ASSERTED unsigned base = stObj->base.BufferOffset;
|
||||
ASSERTED unsigned base = texObj->BufferOffset;
|
||||
ASSERTED unsigned size = MIN2(buf->width0 - base,
|
||||
(unsigned) stObj->base.BufferSize);
|
||||
(unsigned) texObj->BufferSize);
|
||||
assert(view->u.buf.offset == base);
|
||||
assert(view->u.buf.size == size);
|
||||
if (get_reference)
|
||||
|
@ -713,13 +713,13 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
}
|
||||
}
|
||||
|
||||
unsigned base = stObj->base.BufferOffset;
|
||||
unsigned base = texObj->BufferOffset;
|
||||
|
||||
if (base >= buf->width0)
|
||||
return NULL;
|
||||
|
||||
unsigned size = buf->width0 - base;
|
||||
size = MIN2(size, (unsigned)stObj->base.BufferSize);
|
||||
size = MIN2(size, (unsigned)texObj->BufferSize);
|
||||
if (!size)
|
||||
return NULL;
|
||||
|
||||
|
@ -729,7 +729,7 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
struct pipe_sampler_view templ;
|
||||
|
||||
templ.format =
|
||||
st_mesa_format_to_pipe_format(st, stObj->base._BufferObjectFormat);
|
||||
st_mesa_format_to_pipe_format(st, texObj->_BufferObjectFormat);
|
||||
templ.target = PIPE_BUFFER;
|
||||
templ.swizzle_r = PIPE_SWIZZLE_X;
|
||||
templ.swizzle_g = PIPE_SWIZZLE_Y;
|
||||
|
@ -741,7 +741,7 @@ st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
|||
struct pipe_sampler_view *view =
|
||||
st->pipe->create_sampler_view(st->pipe, buf, &templ);
|
||||
|
||||
view = st_texture_set_sampler_view(st, stObj, view, false, false,
|
||||
view = st_texture_set_sampler_view(st, texObj, view, false, false,
|
||||
get_reference);
|
||||
|
||||
return view;
|
||||
|
|
|
@ -32,9 +32,6 @@
|
|||
#include "pipe/p_state.h"
|
||||
#include "util/u_sampler.h"
|
||||
|
||||
struct st_texture_object;
|
||||
|
||||
|
||||
static inline struct pipe_sampler_view *
|
||||
st_create_texture_sampler_view_format(struct pipe_context *pipe,
|
||||
struct pipe_resource *texture,
|
||||
|
@ -59,23 +56,23 @@ st_create_texture_sampler_view(struct pipe_context *pipe,
|
|||
|
||||
extern void
|
||||
st_texture_release_context_sampler_view(struct st_context *st,
|
||||
struct st_texture_object *stObj);
|
||||
struct gl_texture_object *stObj);
|
||||
|
||||
extern void
|
||||
st_texture_release_all_sampler_views(struct st_context *st,
|
||||
struct st_texture_object *stObj);
|
||||
struct gl_texture_object *stObj);
|
||||
|
||||
void
|
||||
st_delete_texture_sampler_views(struct st_context *st,
|
||||
struct st_texture_object *stObj);
|
||||
struct gl_texture_object *stObj);
|
||||
|
||||
struct st_sampler_view *
|
||||
st_texture_get_current_sampler_view(const struct st_context *st,
|
||||
const struct st_texture_object *stObj);
|
||||
const struct gl_texture_object *stObj);
|
||||
|
||||
struct pipe_sampler_view *
|
||||
st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *stObj,
|
||||
const struct gl_sampler_object *samp,
|
||||
bool glsl130_or_later,
|
||||
bool ignore_srgb_decode,
|
||||
|
@ -83,7 +80,7 @@ st_get_texture_sampler_view_from_stobj(struct st_context *st,
|
|||
|
||||
struct pipe_sampler_view *
|
||||
st_get_buffer_sampler_view_from_stobj(struct st_context *st,
|
||||
struct st_texture_object *stObj,
|
||||
struct gl_texture_object *stObj,
|
||||
bool get_reference);
|
||||
|
||||
#endif /* ST_SAMPLER_VIEW_H */
|
||||
|
|
|
@ -252,14 +252,13 @@ st_texture_match_image(struct st_context *st,
|
|||
* \return address of mapping or NULL if any error
|
||||
*/
|
||||
GLubyte *
|
||||
st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
||||
st_texture_image_map(struct st_context *st, struct gl_texture_image *stImage,
|
||||
enum pipe_map_flags usage,
|
||||
GLuint x, GLuint y, GLuint z,
|
||||
GLuint w, GLuint h, GLuint d,
|
||||
struct pipe_transfer **transfer)
|
||||
{
|
||||
struct st_texture_object *stObj =
|
||||
st_texture_object(stImage->base.TexObject);
|
||||
struct gl_texture_object *stObj = stImage->TexObject;
|
||||
GLuint level;
|
||||
void *map;
|
||||
|
||||
|
@ -271,16 +270,16 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
|||
if (stObj->pt != stImage->pt)
|
||||
level = 0;
|
||||
else
|
||||
level = stImage->base.Level;
|
||||
level = stImage->Level;
|
||||
|
||||
if (stObj->base.Immutable) {
|
||||
level += stObj->base.Attrib.MinLevel;
|
||||
z += stObj->base.Attrib.MinLayer;
|
||||
if (stObj->Immutable) {
|
||||
level += stObj->Attrib.MinLevel;
|
||||
z += stObj->Attrib.MinLayer;
|
||||
if (stObj->pt->array_size > 1)
|
||||
d = MIN2(d, stObj->base.Attrib.NumLayers);
|
||||
d = MIN2(d, stObj->Attrib.NumLayers);
|
||||
}
|
||||
|
||||
z += stImage->base.Face;
|
||||
z += stImage->Face;
|
||||
|
||||
map = pipe_texture_map_3d(st->pipe, stImage->pt, level, usage,
|
||||
x, y, z, w, h, d, transfer);
|
||||
|
@ -306,16 +305,15 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
|||
|
||||
void
|
||||
st_texture_image_unmap(struct st_context *st,
|
||||
struct st_texture_image *stImage, unsigned slice)
|
||||
struct gl_texture_image *stImage, unsigned slice)
|
||||
{
|
||||
struct pipe_context *pipe = st->pipe;
|
||||
struct st_texture_object *stObj =
|
||||
st_texture_object(stImage->base.TexObject);
|
||||
struct gl_texture_object *stObj = stImage->TexObject;
|
||||
struct pipe_transfer **transfer;
|
||||
|
||||
if (stObj->base.Immutable)
|
||||
slice += stObj->base.Attrib.MinLayer;
|
||||
transfer = &stImage->transfer[slice + stImage->base.Face].transfer;
|
||||
if (stObj->Immutable)
|
||||
slice += stObj->Attrib.MinLayer;
|
||||
transfer = &stImage->transfer[slice + stImage->Face].transfer;
|
||||
|
||||
DBG("%s\n", __func__);
|
||||
|
||||
|
|
|
@ -102,174 +102,44 @@ struct st_compressed_data
|
|||
GLubyte *ptr;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Subclass of gl_texure_image.
|
||||
*/
|
||||
struct st_texture_image
|
||||
{
|
||||
struct gl_texture_image base;
|
||||
|
||||
/* If stImage->pt != NULL, image data is stored here.
|
||||
* Else there is no image data.
|
||||
*/
|
||||
struct pipe_resource *pt;
|
||||
|
||||
/* List of transfers, allocated on demand.
|
||||
* transfer[layer] is a mapping for that layer.
|
||||
*/
|
||||
struct st_texture_image_transfer *transfer;
|
||||
unsigned num_transfers;
|
||||
|
||||
/* For compressed images unsupported by the driver. Keep track of
|
||||
* the original data. This is necessary for mapping/unmapping,
|
||||
* as well as image copies.
|
||||
*/
|
||||
struct st_compressed_data* compressed_data;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Subclass of gl_texure_object.
|
||||
*/
|
||||
struct st_texture_object
|
||||
{
|
||||
struct gl_texture_object base; /* The "parent" object */
|
||||
|
||||
/* The texture must include at levels [0..lastLevel] once validated:
|
||||
*/
|
||||
GLuint lastLevel;
|
||||
|
||||
unsigned int validated_first_level;
|
||||
unsigned int validated_last_level;
|
||||
|
||||
/* On validation any active images held in main memory or in other
|
||||
* textures will be copied to this texture and the old storage freed.
|
||||
*/
|
||||
struct pipe_resource *pt;
|
||||
|
||||
/* Protect modifications of the sampler_views array */
|
||||
simple_mtx_t validate_mutex;
|
||||
|
||||
/* Container of sampler views (one per context) attached to this texture
|
||||
* object. Created lazily on first binding in context.
|
||||
*
|
||||
* Purely read-only accesses to the current context's own sampler view
|
||||
* require no locking. Another thread may simultaneously replace the
|
||||
* container object in order to grow the array, but the old container will
|
||||
* be kept alive.
|
||||
*
|
||||
* Writing to the container (even for modifying the current context's own
|
||||
* sampler view) always requires taking the validate_mutex to protect against
|
||||
* concurrent container switches.
|
||||
*
|
||||
* NULL'ing another context's sampler view is allowed only while
|
||||
* implementing an API call that modifies the texture: an application which
|
||||
* calls those while simultaneously reading the texture in another context
|
||||
* invokes undefined behavior. (TODO: a dubious violation of this rule is
|
||||
* st_finalize_texture, which is a lazy operation that corresponds to a
|
||||
* texture modification.)
|
||||
*/
|
||||
struct st_sampler_views *sampler_views;
|
||||
|
||||
/* Old sampler views container objects that have not been freed yet because
|
||||
* other threads/contexts may still be reading from them.
|
||||
*/
|
||||
struct st_sampler_views *sampler_views_old;
|
||||
|
||||
/* True if this texture comes from the window system. Such a texture
|
||||
* cannot be reallocated and the format can only be changed with a sampler
|
||||
* view or a surface.
|
||||
*/
|
||||
GLboolean surface_based;
|
||||
|
||||
/* If surface_based is true, this format should be used for all sampler
|
||||
* views and surfaces instead of pt->format.
|
||||
*/
|
||||
enum pipe_format surface_format;
|
||||
|
||||
/* When non-negative, samplers should use this level instead of the level
|
||||
* range specified by the GL state.
|
||||
*
|
||||
* This is used for EGL images, which may correspond to a single level out
|
||||
* of an imported pipe_resources with multiple mip levels.
|
||||
*/
|
||||
int level_override;
|
||||
|
||||
/* When non-negative, samplers should use this layer instead of the one
|
||||
* specified by the GL state.
|
||||
*
|
||||
* This is used for EGL images and VDPAU interop, where imported
|
||||
* pipe_resources may be cube, 3D, or array textures (containing layers
|
||||
* with different fields in the case of VDPAU) even though the GL state
|
||||
* describes one non-array texture per field.
|
||||
*/
|
||||
int layer_override;
|
||||
|
||||
/**
|
||||
* Set when the texture images of this texture object might not all be in
|
||||
* the pipe_resource *pt above.
|
||||
*/
|
||||
bool needs_validation;
|
||||
};
|
||||
|
||||
|
||||
static inline struct st_texture_image *
|
||||
st_texture_image(struct gl_texture_image *img)
|
||||
{
|
||||
return (struct st_texture_image *) img;
|
||||
}
|
||||
|
||||
static inline const struct st_texture_image *
|
||||
static inline const struct gl_texture_image *
|
||||
st_texture_image_const(const struct gl_texture_image *img)
|
||||
{
|
||||
return (const struct st_texture_image *) img;
|
||||
return (const struct gl_texture_image *) img;
|
||||
}
|
||||
|
||||
static inline struct st_texture_object *
|
||||
st_texture_object(struct gl_texture_object *obj)
|
||||
{
|
||||
return (struct st_texture_object *) obj;
|
||||
}
|
||||
|
||||
static inline const struct st_texture_object *
|
||||
static inline const struct gl_texture_object *
|
||||
st_texture_object_const(const struct gl_texture_object *obj)
|
||||
{
|
||||
return (const struct st_texture_object *) obj;
|
||||
return (const struct gl_texture_object *) obj;
|
||||
}
|
||||
|
||||
|
||||
static inline struct pipe_resource *
|
||||
st_get_texobj_resource(struct gl_texture_object *texObj)
|
||||
{
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
return stObj ? stObj->pt : NULL;
|
||||
return texObj ? texObj->pt : NULL;
|
||||
}
|
||||
|
||||
|
||||
static inline struct pipe_resource *
|
||||
st_get_stobj_resource(struct st_texture_object *stObj)
|
||||
st_get_stobj_resource(struct gl_texture_object *stObj)
|
||||
{
|
||||
return stObj ? stObj->pt : NULL;
|
||||
}
|
||||
|
||||
|
||||
static inline struct st_texture_object *
|
||||
static inline struct gl_texture_object *
|
||||
st_get_texture_object(struct gl_context *ctx,
|
||||
const struct gl_program *prog,
|
||||
unsigned unit)
|
||||
{
|
||||
const GLuint texUnit = prog->SamplerUnits[unit];
|
||||
struct gl_texture_object *texObj = ctx->Texture.Unit[texUnit]._Current;
|
||||
|
||||
if (!texObj)
|
||||
return NULL;
|
||||
|
||||
return st_texture_object(texObj);
|
||||
return ctx->Texture.Unit[texUnit]._Current;
|
||||
}
|
||||
|
||||
static inline enum pipe_format
|
||||
st_get_view_format(struct st_texture_object *stObj)
|
||||
st_get_view_format(struct gl_texture_object *stObj)
|
||||
{
|
||||
if (!stObj)
|
||||
return PIPE_FORMAT_NONE;
|
||||
|
@ -312,7 +182,7 @@ st_texture_match_image(struct st_context *st,
|
|||
* well.
|
||||
*/
|
||||
extern GLubyte *
|
||||
st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
||||
st_texture_image_map(struct st_context *st, struct gl_texture_image *stImage,
|
||||
enum pipe_map_flags usage,
|
||||
GLuint x, GLuint y, GLuint z,
|
||||
GLuint w, GLuint h, GLuint d,
|
||||
|
@ -320,7 +190,7 @@ st_texture_image_map(struct st_context *st, struct st_texture_image *stImage,
|
|||
|
||||
extern void
|
||||
st_texture_image_unmap(struct st_context *st,
|
||||
struct st_texture_image *stImage, unsigned slice);
|
||||
struct gl_texture_image *stImage, unsigned slice);
|
||||
|
||||
|
||||
/* Return pointers to each 2d slice within an image. Indexed by depth
|
||||
|
|
|
@ -189,8 +189,6 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
|
|||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct pipe_screen *screen = st->screen;
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
|
||||
struct pipe_resource *res;
|
||||
mesa_format texFormat;
|
||||
|
@ -236,9 +234,9 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
|
|||
}
|
||||
|
||||
/* switch to surface based */
|
||||
if (!stObj->surface_based) {
|
||||
if (!texObj->surface_based) {
|
||||
_mesa_clear_texture_object(ctx, texObj, NULL);
|
||||
stObj->surface_based = GL_TRUE;
|
||||
texObj->surface_based = GL_TRUE;
|
||||
}
|
||||
|
||||
texFormat = st_pipe_format_to_mesa_format(res->format);
|
||||
|
@ -247,13 +245,13 @@ st_vdpau_map_surface(struct gl_context *ctx, GLenum target, GLenum access,
|
|||
res->width0, res->height0, 1, 0, GL_RGBA,
|
||||
texFormat);
|
||||
|
||||
pipe_resource_reference(&stObj->pt, res);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
pipe_resource_reference(&stImage->pt, res);
|
||||
pipe_resource_reference(&texObj->pt, res);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
pipe_resource_reference(&texImage->pt, res);
|
||||
|
||||
stObj->surface_format = res->format;
|
||||
stObj->level_override = -1;
|
||||
stObj->layer_override = layer_override;
|
||||
texObj->surface_format = res->format;
|
||||
texObj->level_override = -1;
|
||||
texObj->layer_override = layer_override;
|
||||
|
||||
_mesa_dirty_texobj(ctx, texObj);
|
||||
pipe_resource_reference(&res, NULL);
|
||||
|
@ -266,15 +264,13 @@ st_vdpau_unmap_surface(struct gl_context *ctx, GLenum target, GLenum access,
|
|||
const void *vdpSurface, GLuint index)
|
||||
{
|
||||
struct st_context *st = st_context(ctx);
|
||||
struct st_texture_object *stObj = st_texture_object(texObj);
|
||||
struct st_texture_image *stImage = st_texture_image(texImage);
|
||||
|
||||
pipe_resource_reference(&stObj->pt, NULL);
|
||||
st_texture_release_all_sampler_views(st, stObj);
|
||||
pipe_resource_reference(&stImage->pt, NULL);
|
||||
pipe_resource_reference(&texObj->pt, NULL);
|
||||
st_texture_release_all_sampler_views(st, texObj);
|
||||
pipe_resource_reference(&texImage->pt, NULL);
|
||||
|
||||
stObj->level_override = -1;
|
||||
stObj->layer_override = -1;
|
||||
texObj->level_override = -1;
|
||||
texObj->layer_override = -1;
|
||||
|
||||
_mesa_dirty_texobj(ctx, texObj);
|
||||
|
||||
|
|
Loading…
Reference in New Issue