st/mesa: fix temp texture bindings in st_CopyPixels()

The temporary texture should have either PIPE_BIND_RENDER_TARGET or
PIPE_BIND_DEPTH_STENCIL set in addition to PIPE_BIND_SAMPLER_VIEW.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
This commit is contained in:
Chia-I Wu
2013-06-13 13:18:15 +08:00
parent 5507c11f85
commit 399548b17f

View File

@@ -460,12 +460,12 @@ internal_format(struct gl_context *ctx, GLenum format, GLenum type)
*/ */
static struct pipe_resource * static struct pipe_resource *
alloc_texture(struct st_context *st, GLsizei width, GLsizei height, alloc_texture(struct st_context *st, GLsizei width, GLsizei height,
enum pipe_format texFormat) enum pipe_format texFormat, unsigned bind)
{ {
struct pipe_resource *pt; struct pipe_resource *pt;
pt = st_texture_create(st, st->internal_target, texFormat, 0, pt = st_texture_create(st, st->internal_target, texFormat, 0,
width, height, 1, 1, 0, PIPE_BIND_SAMPLER_VIEW); width, height, 1, 1, 0, bind);
return pt; return pt;
} }
@@ -515,7 +515,7 @@ make_texture(struct st_context *st,
return NULL; return NULL;
/* alloc temporary texture */ /* alloc temporary texture */
pt = alloc_texture(st, width, height, pipeFormat); pt = alloc_texture(st, width, height, pipeFormat, PIPE_BIND_SAMPLER_VIEW);
if (!pt) { if (!pt) {
_mesa_unmap_pbo_source(ctx, unpack); _mesa_unmap_pbo_source(ctx, unpack);
return NULL; return NULL;
@@ -1475,6 +1475,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
int num_sampler_view = 1; int num_sampler_view = 1;
GLfloat *color; GLfloat *color;
enum pipe_format srcFormat; enum pipe_format srcFormat;
unsigned srcBind;
GLboolean invertTex = GL_FALSE; GLboolean invertTex = GL_FALSE;
GLint readX, readY, readW, readH; GLint readX, readY, readW, readH;
struct gl_pixelstore_attrib pack = ctx->DefaultPacking; struct gl_pixelstore_attrib pack = ctx->DefaultPacking;
@@ -1540,16 +1541,15 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
/* Choose the format for the temporary texture. */ /* Choose the format for the temporary texture. */
srcFormat = rbRead->texture->format; srcFormat = rbRead->texture->format;
srcBind = PIPE_BIND_SAMPLER_VIEW |
(type == GL_COLOR ? PIPE_BIND_RENDER_TARGET : PIPE_BIND_DEPTH_STENCIL);
if (!screen->is_format_supported(screen, srcFormat, st->internal_target, 0, if (!screen->is_format_supported(screen, srcFormat, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind)) {
(type == GL_COLOR ? PIPE_BIND_RENDER_TARGET
: PIPE_BIND_DEPTH_STENCIL))) {
if (type == GL_DEPTH) { if (type == GL_DEPTH) {
srcFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE, srcFormat = st_choose_format(st, GL_DEPTH_COMPONENT, GL_NONE,
GL_NONE, st->internal_target, 0, GL_NONE, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind, FALSE);
PIPE_BIND_DEPTH_STENCIL, FALSE);
} }
else { else {
assert(type == GL_COLOR); assert(type == GL_COLOR);
@@ -1557,26 +1557,22 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
if (util_format_is_float(srcFormat)) { if (util_format_is_float(srcFormat)) {
srcFormat = st_choose_format(st, GL_RGBA32F, GL_NONE, srcFormat = st_choose_format(st, GL_RGBA32F, GL_NONE,
GL_NONE, st->internal_target, 0, GL_NONE, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind, FALSE);
PIPE_BIND_RENDER_TARGET, FALSE);
} }
else if (util_format_is_pure_sint(srcFormat)) { else if (util_format_is_pure_sint(srcFormat)) {
srcFormat = st_choose_format(st, GL_RGBA32I, GL_NONE, srcFormat = st_choose_format(st, GL_RGBA32I, GL_NONE,
GL_NONE, st->internal_target, 0, GL_NONE, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind, FALSE);
PIPE_BIND_RENDER_TARGET, FALSE);
} }
else if (util_format_is_pure_uint(srcFormat)) { else if (util_format_is_pure_uint(srcFormat)) {
srcFormat = st_choose_format(st, GL_RGBA32UI, GL_NONE, srcFormat = st_choose_format(st, GL_RGBA32UI, GL_NONE,
GL_NONE, st->internal_target, 0, GL_NONE, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind, FALSE);
PIPE_BIND_RENDER_TARGET, FALSE);
} }
else { else {
srcFormat = st_choose_format(st, GL_RGBA, GL_NONE, srcFormat = st_choose_format(st, GL_RGBA, GL_NONE,
GL_NONE, st->internal_target, 0, GL_NONE, st->internal_target, 0,
PIPE_BIND_SAMPLER_VIEW | srcBind, FALSE);
PIPE_BIND_RENDER_TARGET, FALSE);
} }
} }
@@ -1615,7 +1611,7 @@ st_CopyPixels(struct gl_context *ctx, GLint srcx, GLint srcy,
readH = MAX2(0, readH); readH = MAX2(0, readH);
/* Allocate the temporary texture. */ /* Allocate the temporary texture. */
pt = alloc_texture(st, width, height, srcFormat); pt = alloc_texture(st, width, height, srcFormat, srcBind);
if (!pt) if (!pt)
return; return;