mesa: remove gl_renderbuffer::surface

this is just a convenience alias

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34054>
This commit is contained in:
Mike Blumenkrantz 2025-03-06 11:32:24 -05:00 committed by Marge Bot
parent c374bfd864
commit 506c8f9b76
11 changed files with 130 additions and 88 deletions

View file

@ -531,10 +531,10 @@ do_blit_framebuffer(struct gl_context *ctx,
_mesa_update_renderbuffer_surface(ctx, srcRb);
if (!srcRb->surface)
srcSurf = _mesa_renderbuffer_get_surface(ctx, srcRb);
if (!srcSurf)
return;
srcSurf = srcRb->surface;
src_base_fmt = srcRb->_BaseFormat;
blit.src.resource = srcSurf->texture;
blit.src.level = srcSurf->u.tex.level;
@ -551,7 +551,7 @@ do_blit_framebuffer(struct gl_context *ctx,
dst_base_fmt = dstRb->_BaseFormat;
_mesa_update_renderbuffer_surface(ctx, dstRb);
dstSurf = dstRb->surface;
dstSurf = _mesa_renderbuffer_get_surface(ctx, dstRb);
if (dstSurf) {
blit.dst.resource = dstSurf->texture;
@ -591,14 +591,14 @@ do_blit_framebuffer(struct gl_context *ctx,
struct gl_renderbuffer *dstDepthRb =
drawFB->Attachment[BUFFER_DEPTH].Renderbuffer;
struct pipe_surface *dstDepthSurf =
dstDepthRb ? dstDepthRb->surface : NULL;
dstDepthRb ? _mesa_renderbuffer_get_surface(ctx, dstDepthRb) : NULL;
struct gl_renderbuffer *srcStencilRb =
readFB->Attachment[BUFFER_STENCIL].Renderbuffer;
struct gl_renderbuffer *dstStencilRb =
drawFB->Attachment[BUFFER_STENCIL].Renderbuffer;
struct pipe_surface *dstStencilSurf =
dstStencilRb ? dstStencilRb->surface : NULL;
dstStencilRb ? _mesa_renderbuffer_get_surface(ctx, dstStencilRb) : NULL;
if (_mesa_has_depthstencil_combined(readFB) &&
_mesa_has_depthstencil_combined(drawFB)) {
@ -613,10 +613,11 @@ do_blit_framebuffer(struct gl_context *ctx,
blit.dst.box.z = dstDepthSurf->u.tex.first_layer;
blit.dst.format = dstDepthSurf->format;
struct pipe_surface *srcDepthSurface = _mesa_renderbuffer_get_surface(ctx, srcDepthRb);
blit.src.resource = srcDepthRb->texture;
blit.src.level = srcDepthRb->surface->u.tex.level;
blit.src.box.z = srcDepthRb->surface->u.tex.first_layer;
blit.src.format = srcDepthRb->surface->format;
blit.src.level = srcDepthSurface->u.tex.level;
blit.src.box.z = srcDepthSurface->u.tex.first_layer;
blit.src.format = srcDepthSurface->format;
ctx->pipe->blit(ctx->pipe, &blit);
}
@ -631,10 +632,11 @@ do_blit_framebuffer(struct gl_context *ctx,
blit.dst.box.z = dstDepthSurf->u.tex.first_layer;
blit.dst.format = dstDepthSurf->format;
struct pipe_surface *srcDepthSurface = _mesa_renderbuffer_get_surface(ctx, srcDepthRb);
blit.src.resource = srcDepthRb->texture;
blit.src.level = srcDepthRb->surface->u.tex.level;
blit.src.box.z = srcDepthRb->surface->u.tex.first_layer;
blit.src.format = srcDepthRb->surface->format;
blit.src.level = srcDepthSurface->u.tex.level;
blit.src.box.z = srcDepthSurface->u.tex.first_layer;
blit.src.format = srcDepthSurface->format;
ctx->pipe->blit(ctx->pipe, &blit);
}
@ -647,10 +649,11 @@ do_blit_framebuffer(struct gl_context *ctx,
blit.dst.box.z = dstStencilSurf->u.tex.first_layer;
blit.dst.format = dstStencilSurf->format;
struct pipe_surface *srcStencilSurface = _mesa_renderbuffer_get_surface(ctx, srcStencilRb);
blit.src.resource = srcStencilRb->texture;
blit.src.level = srcStencilRb->surface->u.tex.level;
blit.src.box.z = srcStencilRb->surface->u.tex.first_layer;
blit.src.format = srcStencilRb->surface->format;
blit.src.level = srcStencilSurface->u.tex.level;
blit.src.box.z = srcStencilSurface->u.tex.first_layer;
blit.src.format = srcStencilSurface->format;
ctx->pipe->blit(ctx->pipe, &blit);
}

View file

@ -1265,7 +1265,7 @@ do_validate_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb)
if (!mixed_formats) {
/* Disallow mixed formats. */
if (att->Type != GL_NONE) {
format = att->Renderbuffer->surface->format;
format = _mesa_renderbuffer_get_format(ctx, att->Renderbuffer);
} else {
continue;
}
@ -5566,7 +5566,7 @@ do_discard_framebuffer(struct gl_context *ctx, struct gl_framebuffer *fb,
if (!att->Renderbuffer || !att->Complete)
return;
prsc = att->Renderbuffer->surface->texture;
prsc = att->Renderbuffer->texture;
/* using invalidate_resource will only work for simple 2D resources */
if (prsc->depth0 != 1 || prsc->array_size != 1 || prsc->last_level != 0)

View file

@ -2551,10 +2551,6 @@ struct gl_renderbuffer
GLuint width, GLuint height);
struct pipe_resource *texture;
/* This points to either "surface_linear" or "surface_srgb".
* It doesn't hold the pipe_surface reference. The other two do.
*/
struct pipe_surface *surface;
struct pipe_surface *surface_linear;
struct pipe_surface *surface_srgb;
GLboolean defined; /**< defined contents? */

View file

@ -76,7 +76,6 @@ delete_renderbuffer(struct gl_context *ctx, struct gl_renderbuffer *rb)
pipe_surface_unref_no_context(&rb->surface_srgb);
pipe_surface_unref_no_context(&rb->surface_linear);
}
rb->surface = NULL;
pipe_resource_reference(&rb->texture, NULL);
free(rb->data);
free(rb->Label);
@ -153,7 +152,6 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
*/
pipe_surface_reference(&rb->surface_srgb, NULL);
pipe_surface_reference(&rb->surface_linear, NULL);
rb->surface = NULL;
pipe_resource_reference(&rb->texture, NULL);
/* If an sRGB framebuffer is unsupported, sRGB formats behave like linear
@ -290,7 +288,7 @@ renderbuffer_alloc_storage(struct gl_context * ctx,
return false;
_mesa_update_renderbuffer_surface(ctx, rb);
return rb->surface != NULL;
return _mesa_renderbuffer_get_surface(ctx, rb) != NULL;
}
/**
@ -491,11 +489,13 @@ _mesa_map_renderbuffer(struct gl_context *ctx,
else
y2 = y;
map = pipe_texture_map(pipe,
rb->texture,
rb->surface->u.tex.level,
rb->surface->u.tex.first_layer,
transfer_flags, x, y2, w, h, &rb->transfer);
_mesa_update_renderbuffer_surface(ctx, rb);
const struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
map = pipe_texture_map(pipe,
rb->texture,
surface->u.tex.level,
surface->u.tex.first_layer,
transfer_flags, x, y2, w, h, &rb->transfer);
if (map) {
if (invert) {
*rowStrideOut = -(int) rb->transfer->stride;
@ -549,9 +549,43 @@ _mesa_regen_renderbuffer_surface(struct gl_context *ctx,
/* create -> destroy to avoid blowing up cached surfaces */
surf = pipe->create_surface(pipe, resource, &surf_tmpl);
pipe_surface_unref(pipe, psurf);
*psurf = surf;
}
rb->surface = *psurf;
static void
update_renderbuffer_surface(struct gl_context *ctx, struct gl_renderbuffer *rb, struct pipe_surface *surf, bool enable_srgb)
{
if (enable_srgb)
rb->surface_srgb = surf;
else
rb->surface_linear = surf;
}
struct pipe_surface *
_mesa_renderbuffer_get_surface(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
bool enable_srgb = ctx->Color.sRGBEnabled && _mesa_is_format_srgb(rb->Format);
return enable_srgb ? rb->surface_srgb : rb->surface_linear;
}
enum pipe_format
_mesa_renderbuffer_get_format(struct gl_context *ctx, struct gl_renderbuffer *rb)
{
/*
* For winsys fbo, it is possible that the renderbuffer is sRGB-capable but
* the format of rb->texture is linear (because we have no control over
* the format). Check rb->Format instead of rb->texture->format
* to determine if the rb is sRGB-capable.
*/
bool enable_srgb = ctx->Color.sRGBEnabled && _mesa_is_format_srgb(rb->Format);
enum pipe_format format = rb->texture->format;
if (rb->is_rtt) {
const struct gl_texture_object *stTexObj = rb->TexImage->TexObject;
if (stTexObj->surface_based)
format = stTexObj->surface_format;
}
return enable_srgb ? util_format_srgb(format) : util_format_linear(format);
}
/**
@ -569,24 +603,15 @@ _mesa_update_renderbuffer_surface(struct gl_context *ctx,
unsigned rtt_height = rb->Height;
unsigned rtt_depth = rb->Depth;
/*
* For winsys fbo, it is possible that the renderbuffer is sRGB-capable but
* the format of rb->texture is linear (because we have no control over
* the format). Check rb->Format instead of rb->texture->format
* to determine if the rb is sRGB-capable.
*/
bool enable_srgb = ctx->Color.sRGBEnabled &&
_mesa_is_format_srgb(rb->Format);
enum pipe_format format = resource->format;
enum pipe_format format = _mesa_renderbuffer_get_format(ctx, rb);
if (rb->is_rtt) {
stTexObj = rb->TexImage->TexObject;
if (stTexObj->surface_based)
format = stTexObj->surface_format;
}
format = enable_srgb ? util_format_srgb(format) : util_format_linear(format);
if (resource->target == PIPE_TEXTURE_1D_ARRAY) {
rtt_depth = rtt_height;
rtt_height = 1;
@ -654,9 +679,7 @@ _mesa_update_renderbuffer_surface(struct gl_context *ctx,
}
}
struct pipe_surface **psurf =
enable_srgb ? &rb->surface_srgb : &rb->surface_linear;
struct pipe_surface *surf = *psurf;
struct pipe_surface *surf = _mesa_renderbuffer_get_surface(ctx, rb);
if (!surf ||
surf->texture->nr_samples != rb->NumSamples ||
@ -677,9 +700,8 @@ _mesa_update_renderbuffer_surface(struct gl_context *ctx,
surf_tmpl.u.tex.last_layer = last_layer;
/* create -> destroy to avoid blowing up cached surfaces */
struct pipe_surface *surf = pipe->create_surface(pipe, resource, &surf_tmpl);
pipe_surface_unref(pipe, psurf);
*psurf = surf;
struct pipe_surface *psurf = pipe->create_surface(pipe, resource, &surf_tmpl);
pipe_surface_unref(pipe, &surf);
update_renderbuffer_surface(ctx, rb, psurf, enable_srgb);
}
rb->surface = *psurf;
}

View file

@ -66,6 +66,12 @@ _mesa_reference_renderbuffer(struct gl_renderbuffer **ptr,
_mesa_reference_renderbuffer_(ptr, rb);
}
enum pipe_format
_mesa_renderbuffer_get_format(struct gl_context *ctx, struct gl_renderbuffer *rb);
struct pipe_surface *
_mesa_renderbuffer_get_surface(struct gl_context *ctx, struct gl_renderbuffer *rb);
void
_mesa_map_renderbuffer(struct gl_context *ctx,
struct gl_renderbuffer *rb,

View file

@ -163,12 +163,13 @@ st_update_framebuffer_state( struct st_context *st )
num_multiview_layer = MAX2(num_multiview_layer, rb->rtt_numviews);
}
if (rb->surface) {
if (rb->surface->context != st->pipe) {
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
if (surface) {
if (surface->context != st->pipe) {
_mesa_regen_renderbuffer_surface(ctx, rb);
}
framebuffer.cbufs[i] = rb->surface;
update_framebuffer_size(&framebuffer, rb->surface);
framebuffer.cbufs[i] = surface;
update_framebuffer_size(&framebuffer, surface);
}
rb->defined = GL_TRUE; /* we'll be drawing something */
}
@ -197,12 +198,13 @@ st_update_framebuffer_state( struct st_context *st )
_mesa_update_renderbuffer_surface(ctx, rb);
num_multiview_layer = MAX2(num_multiview_layer, rb->rtt_numviews);
}
if (rb->surface && rb->surface->context != ctx->pipe) {
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
if (surface && surface->context != ctx->pipe) {
_mesa_regen_renderbuffer_surface(ctx, rb);
}
framebuffer.zsbuf = rb->surface;
if (rb->surface)
update_framebuffer_size(&framebuffer, rb->surface);
framebuffer.zsbuf = surface;
if (surface)
update_framebuffer_size(&framebuffer, surface);
}
else
framebuffer.zsbuf = NULL;

View file

@ -40,6 +40,7 @@
#include "main/framebuffer.h"
#include "main/macros.h"
#include "main/glformats.h"
#include "main/renderbuffer.h"
#include "program/prog_instruction.h"
#include "st_context.h"
#include "st_atom.h"
@ -405,9 +406,10 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (b != BUFFER_NONE && mask & (1 << b)) {
struct gl_renderbuffer *rb
= ctx->DrawBuffer->Attachment[b].Renderbuffer;
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
int colormask_index = ctx->Extensions.EXT_draw_buffers2 ? i : 0;
if (!rb || !rb->surface)
if (!rb || !surface)
continue;
unsigned colormask =
@ -417,7 +419,7 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
continue;
unsigned surf_colormask =
util_format_colormask(util_format_description(rb->surface->format));
util_format_colormask(util_format_description(surface->format));
bool scissor = is_scissor_enabled(ctx, rb);
if ((scissor && !st->can_scissor_clear) ||
@ -432,7 +434,8 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
}
if (mask & BUFFER_BIT_DEPTH) {
if (depthRb->surface && ctx->Depth.Mask) {
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, depthRb);
if (surface && ctx->Depth.Mask) {
bool scissor = is_scissor_enabled(ctx, depthRb);
if ((scissor && !st->can_scissor_clear) ||
is_window_rectangle_enabled(ctx))
@ -443,7 +446,8 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
}
}
if (mask & BUFFER_BIT_STENCIL) {
if (stencilRb->surface && !is_stencil_disabled(ctx, stencilRb)) {
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, stencilRb);
if (surface && !is_stencil_disabled(ctx, stencilRb)) {
bool scissor = is_scissor_enabled(ctx, stencilRb);
if ((scissor && !st->can_scissor_clear) ||
is_window_rectangle_enabled(ctx) ||
@ -511,4 +515,3 @@ st_Clear(struct gl_context *ctx, GLbitfield mask)
if (mask & BUFFER_BIT_ACCUM)
_mesa_clear_accum_buffer(ctx);
}

View file

@ -42,6 +42,7 @@
#include "main/pack.h"
#include "main/pbo.h"
#include "main/readpix.h"
#include "main/renderbuffer.h"
#include "main/state.h"
#include "main/teximage.h"
#include "main/texstore.h"
@ -951,8 +952,10 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
struct gl_pixelstore_attrib clippedUnpack = *unpack;
GLubyte *sValues;
GLuint *zValues;
struct pipe_surface *surface;
rb = ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Renderbuffer;
surface = _mesa_renderbuffer_get_surface(ctx, rb);
if (_mesa_fb_orientation(ctx->DrawBuffer) == Y_0_TOP) {
y = ctx->DrawBuffer->Height - y - height;
@ -968,8 +971,8 @@ draw_stencil_pixels(struct gl_context *ctx, GLint x, GLint y,
}
stmap = pipe_texture_map(pipe, rb->texture,
rb->surface->u.tex.level,
rb->surface->u.tex.first_layer,
surface->u.tex.level,
surface->u.tex.first_layer,
usage, x, y,
width, height, &pt);
@ -1445,10 +1448,11 @@ copy_stencil_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
assert(util_format_get_blockheight(rbDraw->texture->format) == 1);
/* map the stencil buffer */
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rbDraw);
drawMap = pipe_texture_map(pipe,
rbDraw->texture,
rbDraw->surface->u.tex.level,
rbDraw->surface->u.tex.first_layer,
surface->texture,
surface->u.tex.level,
surface->u.tex.first_layer,
usage, dstx, dsty,
width, height, &ptDraw);
@ -1592,23 +1596,25 @@ blit_copy_pixels(struct gl_context *ctx, GLint srcx, GLint srcy,
!_mesa_regions_overlap(readX, readY, readX + readW, readY + readH,
drawX, drawY, drawX + drawW, drawY + drawH)) {
struct pipe_blit_info blit;
struct pipe_surface *read_surface = _mesa_renderbuffer_get_surface(ctx, rbRead);
struct pipe_surface *draw_surface = _mesa_renderbuffer_get_surface(ctx, rbDraw);
memset(&blit, 0, sizeof(blit));
blit.src.resource = rbRead->texture;
blit.src.level = rbRead->surface->u.tex.level;
blit.src.level = read_surface->u.tex.level;
blit.src.format = rbRead->texture->format;
blit.src.box.x = readX;
blit.src.box.y = readY;
blit.src.box.z = rbRead->surface->u.tex.first_layer;
blit.src.box.z = read_surface->u.tex.first_layer;
blit.src.box.width = readW;
blit.src.box.height = readH;
blit.src.box.depth = 1;
blit.dst.resource = rbDraw->texture;
blit.dst.level = rbDraw->surface->u.tex.level;
blit.dst.level = draw_surface->u.tex.level;
blit.dst.format = rbDraw->texture->format;
blit.dst.box.x = drawX;
blit.dst.box.y = drawY;
blit.dst.box.z = rbDraw->surface->u.tex.first_layer;
blit.dst.box.z = draw_surface->u.tex.first_layer;
blit.dst.box.width = drawW;
blit.dst.box.height = drawH;
blit.dst.box.depth = 1;
@ -1867,14 +1873,15 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
/* Copy the src region to the temporary texture. */
{
struct pipe_blit_info blit;
struct pipe_surface *read_surface = _mesa_renderbuffer_get_surface(ctx, rbRead);
memset(&blit, 0, sizeof(blit));
blit.src.resource = rbRead->texture;
blit.src.level = rbRead->surface->u.tex.level;
blit.src.level = read_surface->u.tex.level;
blit.src.format = rbRead->texture->format;
blit.src.box.x = readX;
blit.src.box.y = readY;
blit.src.box.z = rbRead->surface->u.tex.first_layer;
blit.src.box.z = read_surface->u.tex.first_layer;
blit.src.box.width = readW;
blit.src.box.height = readH;
blit.src.box.depth = 1;

View file

@ -32,6 +32,7 @@
#include "main/readpix.h"
#include "main/enums.h"
#include "main/framebuffer.h"
#include "main/renderbuffer.h"
#include "util/u_inlines.h"
#include "util/format/u_format.h"
#include "cso_cache/cso_context.h"
@ -103,7 +104,7 @@ try_pbo_readpixels(struct st_context *st, struct gl_renderbuffer *rb,
struct pipe_context *pipe = st->pipe;
struct pipe_screen *screen = st->screen;
struct cso_context *cso = st->cso_context;
struct pipe_surface *surface = rb->surface;
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(st->ctx, rb);
struct pipe_resource *texture = rb->texture;
const struct util_format_description *desc;
struct st_pbo_addresses addr;
@ -307,9 +308,10 @@ blit_to_staging(struct st_context *st, struct gl_renderbuffer *rb,
if (!dst)
return NULL;
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(st->ctx, rb);
memset(&blit, 0, sizeof(blit));
blit.src.resource = rb->texture;
blit.src.level = rb->surface->u.tex.level;
blit.src.level = surface->u.tex.level;
blit.src.format = src_format;
blit.dst.resource = dst;
blit.dst.level = 0;
@ -318,7 +320,7 @@ blit_to_staging(struct st_context *st, struct gl_renderbuffer *rb,
blit.dst.box.x = 0;
blit.src.box.y = y;
blit.dst.box.y = 0;
blit.src.box.z = rb->surface->u.tex.first_layer;
blit.src.box.z = surface->u.tex.first_layer;
blit.dst.box.z = 0;
blit.src.box.width = blit.dst.box.width = width;
blit.src.box.height = blit.dst.box.height = height;
@ -347,6 +349,7 @@ try_cached_readpixels(struct st_context *st, struct gl_renderbuffer *rb,
{
struct pipe_resource *src = rb->texture;
struct pipe_resource *dst = NULL;
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(st->ctx, rb);
if (ST_DEBUG & DEBUG_NOREADPIXCACHE)
return NULL;
@ -354,13 +357,13 @@ try_cached_readpixels(struct st_context *st, struct gl_renderbuffer *rb,
/* Reset cache after invalidation or switch of parameters. */
if (st->readpix_cache.src != src ||
st->readpix_cache.dst_format != dst_format ||
st->readpix_cache.level != rb->surface->u.tex.level ||
st->readpix_cache.layer != rb->surface->u.tex.first_layer) {
st->readpix_cache.level != surface->u.tex.level ||
st->readpix_cache.layer != surface->u.tex.first_layer) {
pipe_resource_reference(&st->readpix_cache.src, src);
pipe_resource_reference(&st->readpix_cache.cache, NULL);
st->readpix_cache.dst_format = dst_format;
st->readpix_cache.level = rb->surface->u.tex.level;
st->readpix_cache.layer = rb->surface->u.tex.first_layer;
st->readpix_cache.level = surface->u.tex.level;
st->readpix_cache.layer = surface->u.tex.first_layer;
st->readpix_cache.hits = 0;
}

View file

@ -43,6 +43,7 @@
#include "main/pack.h"
#include "main/pbo.h"
#include "main/pixeltransfer.h"
#include "main/renderbuffer.h"
#include "main/texcompress.h"
#include "main/texcompress_astc.h"
#include "main/texcompress_bptc.h"
@ -2824,10 +2825,11 @@ fallback_copy_texsubimage(struct gl_context *ctx,
srcY = rb->Height - srcY - height;
}
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
map = pipe_texture_map(pipe,
rb->texture,
rb->surface->u.tex.level,
rb->surface->u.tex.first_layer,
surface->u.tex.level,
surface->u.tex.first_layer,
PIPE_MAP_READ,
srcX, srcY,
width, height, &src_trans);
@ -3010,7 +3012,7 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
!_mesa_is_format_astc_2d(texImage->TexFormat) &&
texImage->TexFormat != MESA_FORMAT_ETC1_RGB8);
if (!rb || !rb->surface || !stImage->pt) {
if (!rb || !_mesa_renderbuffer_get_surface(ctx, rb) || !stImage->pt) {
debug_printf("%s: null rb or stImage\n", __func__);
return;
}
@ -3058,13 +3060,14 @@ st_CopyTexSubImage(struct gl_context *ctx, GLuint dims,
/* Blit the texture.
* This supports flipping, format conversions, and downsampling.
*/
struct pipe_surface *surface = _mesa_renderbuffer_get_surface(ctx, rb);
memset(&blit, 0, sizeof(blit));
blit.src.resource = rb->texture;
blit.src.format = util_format_linear(rb->surface->format);
blit.src.level = rb->surface->u.tex.level;
blit.src.format = util_format_linear(surface->format);
blit.src.level = surface->u.tex.level;
blit.src.box.x = srcX;
blit.src.box.y = srcY0;
blit.src.box.z = rb->surface->u.tex.first_layer;
blit.src.box.z = surface->u.tex.first_layer;
blit.src.box.width = width;
blit.src.box.height = srcY1 - srcY0;
blit.src.box.depth = 1;

View file

@ -201,7 +201,6 @@ st_set_ws_renderbuffer_surface(struct gl_renderbuffer *rb,
else
pipe_surface_reference(&rb->surface_linear, surf);
rb->surface = surf; /* just assign, don't ref */
pipe_resource_reference(&rb->texture, surf->texture);
rb->Width = pipe_surface_width(surf);
rb->Height = pipe_surface_height(surf);
@ -455,8 +454,6 @@ st_new_renderbuffer_fb(enum pipe_format format, unsigned samples, bool sw)
return NULL;
}
rb->surface = NULL;
return rb;
}